<?php
class IO {
    public static $aAlphabet = ['A','B','C','D', 'E', 'F', 'G', 'H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
    //Input/Output
    public static function arr($sDelimeter = ' ') { return explode($sDelimeter, trim(fgets(STDIN))); }
    public static function str() { return trim(fgets(STDIN)); }
    public static function yes() { echo 'YES' . PHP_EOL; }
    public static function no() { echo 'NO' . PHP_EOL; }
    public static function line($sLine) { echo $sLine . PHP_EOL; }
    public static function asLine($mArr, $sep = ' ') { echo implode($sep, $mArr) . PHP_EOL; }

    //Z-function
    public static function z($sString) {
        $s = str_split($sString);
        $n = count($s);
        $z = array_fill(0, $n, 0);
        $r = $l = 0;
        for ($i = 1; $i < $n; $i++) {
            if ($r >= $i) {
                $z[$i] = min($z[$i - $l], $r - $i + 1);
            }
            while ($z[$i] + $i < $n && $s[$z[$i]] == $s[$z[$i] + $i]) {
                $z[$i]++;
            }
            if ($i + $z[$i] - 1 > $r) {
                $l = $i;
                $r = $i + $z[$i] - 1;
            }
        }
        return $z;
    }
    public static function getCountOfDiffSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $n = count($s);
        $count = 0;
        $t = '';
        for ($i = $n - 1; $i >= 0; $i--) {
            $t = $s[$i] . $t;
            $count += $i + 1 - max(self::z($t));
        }
        return $count;
    }
    public static function getMinPeriodOfSubstrWithZ($sString)
    {
        $s = str_split($sString);
        $res = count($s);
        $z = self::z($sString);
        foreach ($z as $iI => $sV) {
            if ((int) $iI + $z[$iI] == $res && $res % (int) $iI == 0) {
                $res = $iI;
                break;
            }
        }
        return $res;
    }

    //Other functions
    public static function gcd($a, $b) {
        return ($a % $b) ? self::gcd($b,$a % $b) : $b;
    }
    public static function lcm($x, $y) {
        $p = $x;
        $q = $y;
        while ($x != $y)
        {
            if ($x > $y)
                $x = $x - $y;
            else
                $y = $y - $x;
        }
        return ($p*$q)/$x;
    }

}

//$iQueryCount = 1;
$iQueryCount = IO::str();
$aAllResults = [];
while($iQueryCount > 0) {
    $iQueryCount--;
    solve();
}
function solve() {
    $n = IO::str();
    $s = IO::str();
    $a = str_split($s);
    $res = [-1, -1];
    foreach ($a as $k => $v) {
        if (isset($a[$k+1])) {
            if ($v != $a[$k+1]) {
                $res = [$k+1, $k+2];
                break;
            }
        }
    }
    IO::line(implode(' ', $res));

}

?>


<?php
$a = trim(fgets(STDIN));
$j = array();
$k = array();
for($x = 1; $x <= $a; $x++)
{
    list($b, $c, $d, $e, $f, $g, $h, $i) = explode(" ", trim(fgets(STDIN)));
    array_push($j, $b);
    $l = $c * 100 - $d * 50 + $e + $f + $g + $h + $i;
    array_push($k, $l);
}
arsort($k);
$m = array_keys($k);
print $j[$m[0]];
?>

<?
$n=trim(fgets(STDIN));
for($i=0;$i<$n;$i++)
    $arr[]=explode(' ',trim(fgets(STDIN)));

//print_r($arr);
foreach($arr as $val){
    $sum[]=array($val[0],$val[1]*100-$val[2]*50+$val[3]+$val[4]+$val[5]+$val[6]+$val[7]);
}
function cmp($a,$b){
    return $a[1]<$b[1];
}
//print_r($sum);
usort($sum,'cmp');
//print_r($sum);
echo $sum[0][0];
?>


<?php
$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] <= 8) {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 9;
        }
    } else {
        for ($m = 1; $m <= $h + 1; $m++) {
            $str .= 1;
        }
    }

    array_push($array, bcsub($str, $num));
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php

$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] == 9) {
        for ($m = 1; $m <= $h + 1; $m++) {
            $str .= 1;
        }

    } else {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 9;
        }
    }

    array_push($array, bcsub($str, $num));
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::get();
    $s = IO::get();
   $sPolindrom = '';
   if($s[0] == '9') {
        $ss = 1;
        $n +=1;
   } else {
      $ss = '9';
   }
     for($i=0; $i<$n; $i++) {
          $sPolindrom .= $ss;
     }
     $ans = bcsub($sPolindrom, $s);
       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%s", $a);
    $b = ($value = $a[0]+2) . substr($a, 1);
    $k = intval((strlen($value) + $n - 1)/2);
    printf("%s\n", bcsub(($b = substr($b, 0, $k*-1)).strrev(substr($b, 0, $k)), $a));
}

<?php
$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] <= 8) {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 7;
        }
    } else {
        for ($m = 1; $m <= $h + 1; $m++) {
            $str .= 1;
        }
    }

    array_push($array, bcsub($str, $num));
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php
$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] <= 8) {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 7;
        }
    } else {
        for ($m = 1; $m <= $h+1; $m++) {
            $str .= 1;
        }
    }

    $sum = $str - $num;
    array_push($array, $sum);
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php
$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] <= 8) {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 9;
        }
    } else {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 1;
        }
    }

    $sum = $str - $num;
    array_push($array, $sum);
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();
?>

<?php

$array = [];
$t = (int)fgets(STDIN);
while ($t--) {
    $h = trim(fgets(STDIN));
    $num = trim(fgets(STDIN));
    $str = "";
    if ($num[0] <= 8) {
        for ($m = 1; $m <= $h; $m++) {
            $str .= 9;
        }
    } else {
        for ($m = 1; $m <= $h + 1; $m++) {
            $str .= 1;
        }
    }

    $sum = $str - $num;
    array_push($array, $sum);
}
foreach ($array as $key => $value)
    print($value . "\r\n");
$end = readline();

?>

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::get();
    $s = IO::get();
   $sPolindrom = '';
   $ss = (int)$s[0] + 1;
   if($ss == 10) {
        $ss = 1;
        $n +=1;
   }
     for($i=0; $i<$n; $i++) {
          $sPolindrom .= $ss;
     }
     $ans = bcsub($sPolindrom, $s);
       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
    $n = IO::get();
    $s = IO::get();
   $sPolindrom = '';
     for($i=0; $i<$n+1; $i++) {
          $sPolindrom .= '9';
     }
     $ans = bcsub($sPolindrom, $s);
       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
     $n = IO::get();
     $s = IO::get();
     $ss = [];
     for($i=0; $i<$n; $i++) {
          if(isset($ss[$s[$i]])) {
              $ss[$s[$i]] += 1;
          } else {
               $ss[$s[$i]] = 1;
          }
     }
     $sa = array_keys($ss);
     $pN = 0;

     for($i=1; $i < 10; $i++) {
         if(!isset($ss[$i])) {
             $pN = $i;
             break;
         }
     }
     if($pN == 0) {
        $sRev = strrev($s);
        $tt = bcadd($s, $sRev);
        for($i=1; $i<10; $i++) {
             $sPolindrom = '';
            for($w=0; $w<strlen($tt) + 1; $w++) {
                   $sPolindrom .= $i;
            }
          $ans = bcsub($sPolindrom, $s);
          $bs = true;
          for($j=1; $j<strlen($ans) ; $j++) {
               if($ans[$i] == 0 && $ans[$i] == $ans[$i-1]) {
                   $bs = false;
                   break;
               }
          }
          if($bc) {
               break;
          }

        }

     } else {
         if($pN > max($sa)) {
                $nCount = $n;
          } else {
              $nCount = $n +1;
          }
          $sPolindrom = '';
          for($i=0; $i<$nCount; $i++) {
              $sPolindrom .= $pN;
          }
          $ans = bcsub($sPolindrom, $s);
     }

       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
     $n = IO::get();
     $s = IO::get();
     $ss = [];
     for($i=0; $i<$n; $i++) {
         $ss[$s[$i]] = 1;
     }
     $sa = array_keys($ss);
     $pN = 0;

     for($i=1; $i < 10; $i++) {
         if(!isset($ss[$i])) {
             $pN = $i;
             break;
         }
     }
     if($pN > max($sa)) {
         $nCount = $n;
     } else {
         $nCount = $n +1;
     }
     $sPolindrom = '';
     for($i=0; $i<$nCount; $i++) {
         $sPolindrom .= $pN;
     }
     $ans = bcsub($sPolindrom, $s);

       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}

function solve()
{
     $n = IO::get();
     $s = IO::get();
     $ss = [];
     for($i=0; $i<$n; $i++) {
         $ss[$s[$i]] = 1;
     }
     $pN = 0;
     $nCount = $n;
     for($i=9; $i > 0; $i--) {
         if(!isset($ss[$i])) {
             $pN = $i;
             if($i < 9) {
                 $nCount += 1;
             }
             break;
         }
     }
     $sPolindrom = '';
     for($i=0; $i<$nCount; $i++) {
         $sPolindrom .= $pN;
     }
     $ans = bcsub($sPolindrom, $s);

       IO::pr($ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}

<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d", $n);
    fscanf(STDIN, "%s", $a);
    $k = intval($n/2);
    $b = substr($a, 0, $k*-1);
    $value = $b[0]+2;
    $b = $value . substr($b, strlen($value));
    printf("%s\n", bcsub($b.strrev(substr($b, 0, $k)), $a));
}


<?php

list($t) = explode(' ', trim(fgets(STDIN)));

for ($i = 0; $i < $t; $i++) {
    list($p) = explode(' ', trim(fgets(STDIN)));
    echo "2 ". strval($p - 1) . "\n";
}

?>

<?php
$fileName = 'php://stdin';
$file = fopen($fileName, "r");

$t = trim(fgets($file));

for ($i = 0; $i < $t; $i++) {
  $n = trim(fgets($file));
  $n -= 1;
  echo '2'.' '.$n.PHP_EOL;
}

?>


<?php
fscanf(STDIN, "%d", $t);
while ($t--) {
    fscanf(STDIN, "%d %d", $c, $d);
    if (0 == $c && 0 == $d) {
        echo 0;
    } elseif ($c == $d) {
        echo 1;
    } elseif ((abs($c) + abs($d)) & 1) {
        echo -1;
    } else {
        echo 2;
    }
    echo "\n";
}


<?php
error_reporting("off");
//143B: Help Kingdom of Far Far Away 2
$n = str_split(trim(fgets(STDIN))); //$n = str_split("-12345678.9");
$negative = FALSE;
if ($n[0] == "-") { //if negative, set negative to true and pop the - sign off the front and reset keys
    $negative = TRUE;
    unset($n[0]);
    $n = array_values($n);
}
$nodot = FALSE;
$explodeint = array(); //the integer part, in pieces in an array
$dot = array_search(".", $n);
if ($dot == FALSE) { //if there's no dot we need to know
    $nodot = TRUE;
    $explodeint = $n;
} else {
    for ($i = 0; $i < $dot; $i++) {
        $explodeint[] = $n[$i];
    }
}

//ahh string manipuation. love it. except for the fact that this has to involve arrays.
$reverse = array_reverse($explodeint); //the only reason explodeint is in an array in the first place
$implode = implode($reverse);
$threechunk = str_split($implode, 3);
$commas = implode(",", $threechunk);
$splitagain = str_split($commas);
$reverseagain = array_reverse($splitagain);
$int = implode($reverseagain);

if ($nodot == TRUE) { //if there's no dot, the decimal is just 00.
    $decimal = "00";
} elseif (!isset($n[$dot + 2])) { //if only one decimal place is set, you need to add a zero.
    $decimal = $n[$dot + 1]."0";
} else { //otherwise, just choose the first two decimal places.
    $decimal = $n[$dot + 1].$n[$dot + 2];
}

$value = $int.".".$decimal;
$snake = "$".$value; //dat "snake" sign

if ($negative == TRUE) { //if it's negative, wrap in parentheses
    echo "(".$snake.")";
} else {
    echo $snake;
}
?>


<?php
$a = trim(fgets(STDIN));
for($x = 1; $x <= $a; $x++)
{
     list($b, $c) = explode(" ", trim(fgets(STDIN)));
     if($b == 0)
     {
          print "1\n";
     }
     else
     {
          print $c * 2 + $b + 1 . "\n";
     }
}
?>

<?php
// $stdin = fopen('input.txt', 'r');

$solve = function ($a, $b) {

	if($a == 0){
		return 1;
	} else {
		return $b * 2 + $a + 1;
	}

};

$t = intval(fgets(STDIN));

for (; $t > 0; $t--) {

	$a = explode(' ', fgets(STDIN));

	echo $solve(intval($a[0]), intval($a[1]));
	echo "\n";

}


<?php
$fp = fopen('php://stdin', 'r');
$n = (int)fgets($fp);
$numbers = array_map('intval', explode(' ', fgets($fp)));
sort($numbers);
$mex = 1;
foreach($numbers as $number) {
	if ($mex <= $number) {
		++$mex;
	}
}
echo $mex;


<?php
	$cin = fopen("php://stdin", "r");
	$s = fgets($cin);
	$a = explode(" ", $s);
	$n = intval($a[0]);
	$k = intval($a[1]);
	$s = fgets($cin);
	$a = explode(" ", $s);
	sort($a,SORT_NUMERIC);
	$ans = 0;
	$mid = intval($n / 2);
	for($i = $mid+1; $i < $n; $i++){
		if($k >= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){
			$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));
			$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));
		}
		else{
			break;
		}
	}
	if($k > 0){
		$ans = $ans + intval($k / ($i - $mid));
	}
	print_r(intval($ans + intval($a[$mid]))."\n");
	fclose($cin);
?>

<?php
	$cin = fopen("php://stdin", "r");
	$s = fgets($cin);
	$a = explode(" ", $s);
	$n = intval($a[0]);
	$k = intval($a[1]);
	$s = fgets($cin);
	$a = explode(" ", $s);
	for($i = 0; $i < sizeof($a); $i++){
		$a[$i] = intval($a[$i]);
	}
	sort($a);
	$ans = 0;
	$mid = intval($n / 2);
	for($i = $mid+1; $i < $n; $i++){
		if($k >= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){
			$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));
			$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));
		}
		else{
			break;
		}
	}
	if($k > 0){
		$ans = $ans + intval($k / ($i - $mid));
	}
	print_r(intval($ans + intval($a[$mid]))."\n");
	fclose($cin);
?>

<?php
	$cin = fopen("php://stdin", "r");
	$s = fgets($cin);
	$a = explode(" ", $s);
	$n = intval($a[0]);
	$k = intval($a[1]);
	$s = fgets($cin);
	$a = explode(" ", $s);
	sort($a);
	$ans = 0;
	$mid = intval($n / 2);
	for($i = $mid+1; $i < $n; $i++){
		if($k >= ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]))){
			$k = $k - ($i - $mid) * (intval($a[$i]) - intval($a[$i-1]));
			$ans = $ans + (intval($a[$i]) - intval($a[$i-1]));
		}
		else{
			break;
		}
	}
	if($k > 0){
		$ans = $ans + intval($k / ($i - $mid));
	}

	print_r(intval($ans + intval($a[$mid]))."\n");
	fclose($cin);
?>


<?php
$mod = 1000000007;
$intMaxValue = 2147483646; //2147483647

$loop = true;
$t = $loop ? IO::get() : 1;
while($t--) {
    solve();
}
function solve()
{
     list($n, $h, $m) = IO::getArray();
     $sl = $h * 60 + $m;
     $min = 2147483646;
    for($i=0; $i<$n; $i++) {
         list($p, $k) = IO::getArray();
         $w = $p * 60 + $k;

         $temp = $sl > $w ? $w - $sl + 24*60 : $w - $sl;
     //    IO::pr($min . " " . $temp);
         $min = min($min, $temp);
    }
    $h1 = floor($min / 60);
    $m1 = $min % 60;

    $ans = $h1 . " " . $m1;
    IO::pr( $ans);

}

class IO {
    public static function get()
    {
        return trim(fgets(STDIN));
    }

    public static function getArray()
    {
        return explode(' ', trim(fgets(STDIN)));
    }
    public static function pr($s)
    {
        echo $s, PHP_EOL;
    }
    public static function prArray($s)
    {
        echo implode( ' ', $s), PHP_EOL;
    }
    public static function getMinValue($x, $y) {
        return $x > $y ? $y : $x;
    }
    public static function getMaxValue($x, $y) {
        return $x > $y ? $x : $y;
    }
}


<?php

$t = trim(readline());

for ($i = 0; $i < $t; $i++) {
    list($n, $m, $rb, $cb, $rd, $cd) = explode(" ", readline());

    $turn_r = 0;
    $turn_c = 0;

    if ($rb > $rd) {
        $turn_r = ($n - $rb) * 2;
    }

    if ($cb > $cd) {
        $turn_c = ($m - $cb) * 2;
    }

    $to_r = abs($rb - $rd) + $turn_r;
    $to_c = abs($cb - $cd) + $turn_c;

    print min($to_r, $to_c) . "\n";
}

<?php

$file = fopen('php://stdin', 'd');

function solve()
{
    global $file;

    list($n, $m, $robotX, $robotY, $dirtX, $dirtY) = array_map('intval', explode(' ', trim(fgets($file))));

    $time = 0;

    $dx = 1;
    $dy = 1;

    while($robotX !== $dirtX && $robotY !== $dirtY)
    {
        if($robotX + $dx > $n || $robotX + $dx < 1)
        {
            $dx = -$dx;
        }

        if($robotY + $dy > $m || $robotY + $dy < 1)
        {
            $dy = -$dy;
        }

        $robotX += $dx;
        $robotY += $dy;

        $time++;
    }

    echo $time;
    echo PHP_EOL;
}

$t = + fgets($file);

while($t--) solve();


<?php
ini_set('error_reporting', E_ALL & ~E_NOTICE);

$answer = 0;

fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
sort($a);
// var_dump($a);
$sort = $a;
$cur1 = 0;
$cur2 = 0;
while ($cur2 < $N) {
	if ($a[$cur1] < $a[$cur2]) {
		$answer++;
		$cur1++;
		$cur2++;
	} else {
		$cur2++;
	}
}
echo $answer;

<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

$jump = 100;

$offset = 1;
for($i = 0; $i < $count; $i++){
    $value = $values[$i];
	//$offset = 1;

    while($offset < $count){
        $nextValue = $values[$offset];
        $nextKey = $keys[$offset];
		if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}

echo count($finds);

<?

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

if(count($copy) >= 100000){
    echo 'stop';
}

for($i = 0; $i < $count; $i++){
    $value = $values[$i];
    $find = false;
    $offset = 1;

    while($offset+$i < $count){
        $next100Offset = 1000;
        $next100Value = $values[$i+$offset+$next100Offset];
        if(isset($next100Value) && $next100Value <= $value){
            while($offset+$i+$next100Offset < $count){
                if($next100Value <= $value){
                     $next100Offset+=1000;
                     $next100Value = $values[$i+$offset+$next100Offset];
                }else{
                    break;
                }
            }
            $offset+=$next100Offset;
        }

        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
        if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}
echo count($finds);

<?php

//$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
//$b = "10 1 1 1 5 5 3";

$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);                                                                       $values = array_values($copy);
$finds = array();

for($i = 0; $i < count($values); $i++){
    $value = $values[$i];
    $find = false;
    $offset = 1;
    while($offset+$i < count($values)){
        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
        if(isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }else{
            $offset++;
        }
    }
}

echo count($finds);

<?

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

if(count($input)>=10000){
    echo "date 1 is " . microtime();
}

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

if(count($input)>=10000){
    echo "date 2 is " . microtime();
}

for($i = 0; $i < $count; $i++){
    $value = $values[$i];
    $find = false;
    $offset = 1;

    while($offset+$i < $count){
        $next100Offset = 1000;
        $next100Value = $values[$i+$offset+$next100Offset];
        if(isset($next100Value) && $next100Value <= $value){
            while($offset+$i+$next100Offset < $count){
                if($next100Value <= $value){
                     $next100Offset+=1000;
                     $next100Value = $values[$i+$offset+$next100Offset];
                }else{
                    break;
                }
            }
            $offset+=$next100Offset;
        }

        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
        if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}

echo count($finds);
if(count($input)>=10000){
    echo "date 3 is " . microtime();
}

<?php

//$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
//$b = "10 1 1 1 5 5 3";

$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);                                                                       $values = array_values($copy);
$finds = array();

for($i = 0; $i < count($values); $i++){
    $value = $values[$i];
    $find = false;
    $offset = 1;
    while($offset+$i < count($values)){
        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
        if(isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }else{
            $offset++;
        }
    }
}

echo "result = ". count($finds);

<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

$jump = 100;
if(count($input)>=10000){
	echo "jump = ".$jump;
		$value = $values[500];
		echo "lai = $value
";
		$value = $values[700];
		echo "lai2 = $value
";
}

$offset = 1;
for($i = 0; $i < $count; $i++){
    $value = $values[$i];
    $find = false;
	//$offset = 1;

    while($offset+$i < $count){
        $next100Offset = $jump;
        $next100Value = $values[$i+$offset+$next100Offset];
		if(count($input)>=10000){
			echo "num:".$i.",next 100: ".$next100Value . ", current value = ".$value."
";
		}
        if(isset($next100Value) && $next100Value <= $value){
			 if(count($input)>=10000){
                echo "next 100 value = " . $next100Value . ", value  = " + $value;
            }
            while($offset+$i+$next100Offset < $count){
                if($next100Value <= $value){
                     $next100Offset+= $jump;
                     $next100Value = $values[$i+$offset+$next100Offset];
                }else{
                    break;
                }
            }
            if(count($input)>=10000){
                echo "add more offset : ".$next100Offset;
            }
            $offset+=$next100Offset;
        }

        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];

		if(count($input)>=10000){
			echo "nextValue = ".$nextValue;
		}
		if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}

echo count($finds);

<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

$jump = 100;

$offset = 1;
for($i = 0; $i < $count; $i++){
    $value = $values[$i];
    $find = false;
	//$offset = 1;

    while($offset+$i < $count){
        $next100Offset = $jump;
        $next100Value = $values[$i+$offset+$next100Offset];
        if(isset($next100Value) && $next100Value <= $value){
            while($offset+$i+$next100Offset < $count){
                if($next100Value <= $value){
                     $next100Offset+= $jump;
                     $next100Value = $values[$i+$offset+$next100Offset];
                }else{
                    break;
                }
            }
            $offset+=$next100Offset;
        }

        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
		if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}

echo count($finds);

<?php

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));
//$b = "10 1 1 1 5 5 3";

$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$usedIndex = [];
$keys = array_keys($copy);
$values = array_values($copy);
$success = 0;

for($i = 0; $i < sizeof($input); $i++){
    $current = $input[$i];
    $currentIndex = array_search($i, $keys);

    $offset = 1;
    $next = $values[$currentIndex +$offset];

    while(isset($next)){
        if($next == $current|| in_array($keys[$currentIndex+$offset], $usedIndex)){
            $offset++;
            $next = $values[$currentIndex+$offset];
        }else{
            //找到比自己大的
            $nextKey = $keys[$currentIndex+$offset];
            array_push($usedIndex, $nextKey);
			$success++;
			echo "got $next";
            break;
        }
    }

    if(!isset($next)){
        //沒有比這個元素大的
        foreach($copy as $key => $value){
            if(in_array($key, $usedIndex)){
                continue;
            }
            array_push($usedIndex, $key);
			break;
        }
    }
}
echo "$success";

<?php
$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);

echo '4';

<?

$a = trim(fgets(STDIN));
$b = trim(fgets(STDIN));

//$b = "10 1 1 1 5 5 3";
$input = $b;
$input = explode(" ", $input);

$copy = new ArrayObject($input);
$copy = $copy->getArrayCopy();

//按照value由小到大sorting,但保留key的位置
asort($copy);
$keys = array_keys($copy);
$values = array_values($copy);
$finds = array();
$count = count($values);

if(count($input)>=10000){
    echo "date is " . date("Y-m-d h:i:sa");
}

for($i = 0; $i < $count; $i++){
    $value = $values[$i];
    $find = false;
    $offset = 1;

    while($offset+$i < $count){
        $next100Offset = 1000;
        $next100Value = $values[$i+$offset+$next100Offset];
        if(isset($next100Value) && $next100Value <= $value){
            while($offset+$i+$next100Offset < $count){
                if($next100Value <= $value){
                     $next100Offset+=1000;
                     $next100Value = $values[$i+$offset+$next100Offset];
                }else{
                    break;
                }
            }
            $offset+=$next100Offset;
        }

        $nextValue = $values[$i+$offset];
        $nextKey = $keys[$i+$offset];
        if($nextValue <= $value || isset($finds[$nextKey])){
            $offset++;
            continue;
        }
        if($nextValue > $value){
            $finds[$nextKey] = 1;
            break;
        }
     }
}

echo count($finds);
if(count($input)>=10000){
    echo "date 2 is " . date("Y-m-d h:i:sa");
}


<?php

main();

function main() {
  $num_cases = trim(fgets(STDIN));

  for ($i = 1; $i <= $num_cases; $i++) {

    list($hp, $n, $m) = explode(" ", trim(fgets(STDIN)));
    $res = run_case($hp, $n, $m);

    print $res . "\n";
  }
}

function run_case($hp, $n, $m) {
	for ($i = 0; $i < $n; $i++) {
			$new_hp = intdiv($hp, 2)+10;
			if ($new_hp < $hp) {
				$hp = $new_hp;
			} else {
				break;
			}
	}
	for ($i = 0; $i < $m; $i++) {
		$hp = $hp - 10;
	}

	if ($hp <= 0) {
		return "YES";
	} else {
		return "NO";
	}

}

?>

<?php
    define("MAXN", 1024) ;
    define("GAP_VAL", 1e-7) ;

    function gap($n)
    {
        return $n < GAP_VAL ;
    }

    $t = intval(trim(fgets(STDIN))) ;
    while($t --)
    {
        $in_str = explode(" ", trim(fgets(STDIN))) ;

        $x = intval($in_str[0]) ;
        $n = intval($in_str[1]) ;
        $m = intval($in_str[2]) ;

        for($i = 0; $i < $n; $i ++)
        {
            if($x <= 20) break ;
            $x = intval($x / 2) + 10 ;
        }
        for($i = 0; $i < $m ; $i ++) $x -= 10 ;

        echo $x <= 0 ? "YES\n" : "NO\n" ;
    }
?>

<?php
// $stdin = fopen('input.txt', 'r');

$calc = function ($x, $n, $m) {
	if ($m == 0) {
		return false;
	} else if($x <= $m * 10){
		return true;
	}

	for (; $n > 0; $n--) {
		$x = floor($x / 2) + 10;
		if($x <= $m * 10){
			return true;
		}
	}

	return false;
};

for ($t = intval(fgets(STDIN)); $t > 0; $t--) {

	list($x, $n, $m) = explode(' ', fgets(STDIN));

	echo ($calc($x, $n, $m) ? 'YES' : 'NO') . "\n";

}

<?php

main();

function main() {
  $num_cases = trim(fgets(STDIN));

  for ($n = 1; $n <= $num_cases; $n++) {
    list($hp, $n, $m) = explode(" ", trim(fgets(STDIN)));
    $res = run_case($hp, $n, $m);

    print $res . "\n";
  }
}

function run_case($hp, $n, $m) {
	for ($i = 0; $i < $n; $i++) {
			$new_hp = intdiv($hp, 2)+10;
			if ($new_hp < $hp) {
				$hp = $new_hp;
			} else {
				break;
			}
	}
	for ($i = 0; $i < $m; $i++) {
		$hp = $hp - 10;
	}

	if ($hp <= 0) {
		return "YES";
	} else {
		return "NO";
	}

}

?>


#!/usr/bin/env php
<?php

if (PHP_OS == 'WINNT') {
    $count = stream_get_line(STDIN, 1024, PHP_EOL);
    $queries = [];
    $arr = [];
    for ($i = 0; $i < $count; $i++) {
        $range = stream_get_line(STDIN, 1024, PHP_EOL);
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];

    }

} else {
    $count = readline();
    $arr = [];
    $queries = [];
    for ($i = 0; $i < $count; $i++) {
        $range = readline();;
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];
    }
}

$result = [];

foreach ($queries as $query) {
    $len = $query['r'] - ($query['l']-1);

    if ($len%2 == 0){ //чётное
        $sum = ($len/2);
        if ($query['l']%2 == 0){
            $sum *=-1;
        }
    }else{
        if ($query['r']%2 == 0){
            $sum = floor($len/2)*(-1)+$query['r'];
        }else{
            $sum = floor($len/2)-$query['r'];
        }
    }

    array_push($result, $sum);
}

foreach ($result as $res){
    echo $res.PHP_EOL;
}

<?php
/*****************************************/
class InputReader {protected $_fh;public function __construct($fileHandler = STDIN){$this->_fh = $fileHandler;}
	public function readInt() {$d = trim(fgets($this->_fh));return (int)$d;}
	public function readArrayOfInt($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (int)$item;}return $a;}
	public function readArrayOfFloat($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = (float)$item;}return $a;}
	public function readArrayOfString($size, $indexFrom = 0) {$a = [];$ind = $indexFrom;foreach (explode(' ', fgets($this->_fh)) as $item) {$a[$ind++] = $item;}return $a;}
}

/* Perform action N times. Can return values in array */
function ntimes($n, $func, $returnResults = false) {$a = [];for ($i=1; $i<=$n; $i++) {$result = $func();if ($returnResults) {$a[$i] = $result;}}return $a;}

/* Integral. Keys preserved. By reference. */
function cumsum(&$a){$sum = 0;foreach($a as $k=>$v) {$a[$k] += $sum;$sum = $a[$k];}}

/* Difference. Keys preserved. By reference. */
function diff(&$a){$prev = 0;foreach($a as $k=>$v) {$buf=$a[$k];$a[$k]-=$prev;$prev = $buf;}}

function bitCount($n){$cnt = 0;for ($j=$n; $j; $j>>=1){$cnt += $j&1;}return $cnt;}
/*****************************************/

$ir = new InputReader();

/* TASK */

$n = $ir->readInt();

function sn($n)
{
	return ($n>>1) - $n*($n&1);
}

ntimes($n, function() use ($ir) {
	list($l, $r) = $ir->readArrayOfInt(2);
	echo sn($r) - sn($l-1);
	echo "\n";
});

#!/usr/bin/env php
<?php

if (PHP_OS == 'WINNT') {
    $count = stream_get_line(STDIN, 1024, PHP_EOL);
    $queries = [];
    $arr = [];
    for ($i = 0; $i < $count; $i++) {
        $range = stream_get_line(STDIN, 1024, PHP_EOL);
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];

    }

} else {
    $count = readline();
    $arr = [];
    $queries = [];
    for ($i = 0; $i < $count; $i++) {
        $range = readline();;
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];
    }
}

$result = [];

foreach ($queries as $query) {
    $len = $query['r'] - ($query['l']-1);

    if ($len%2 == 0){ //чётное
        $sum = ($len/2);
        if ($query['l']%2 == 0){
            $sum *=-1;
        }
    }else{
        if ($query['r']%2 == 0){
            $sum = floor($len/2)+$query['r'];
        }else{
            $sum = floor($len/2)-$query['r'];
        }
    }

    array_push($result, $sum);
}

foreach ($result as $res){
    echo $res.PHP_EOL;
}

#!/usr/bin/env php
<?php

if (PHP_OS == 'WINNT') {
    $count = stream_get_line(STDIN, 1024, PHP_EOL);
    $queries = [];
    $arr = [];
    for ($i = 0; $i < $count; $i++) {
        $range = stream_get_line(STDIN, 1024, PHP_EOL);
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];
        $arr[$i] = ($i + 1) * pow(-1, $i + 1);
    }

} else {
    $count = readline();
    $arr = [];
    $queries = [];
    for ($i = 0; $i < $count; $i++) {
        $range = readline();;
        $queries[$i] = [
            'l' => explode(' ', $range)[0],
            'r' => explode(' ', $range)[1],
        ];
    }
    $arr[$i] = ($i + 1) * pow(-1, $i + 1);
}

$result = [];

foreach ($queries as $query) {
    $len = $query['r'] - ($query['l']-1);
    $arr2 = array_slice($arr, $query['l']-1, $len);
    $sum = 0;
    foreach ($arr2 as $a){
        $sum+=$a;
    }
    array_push($result, $sum);
}

foreach ($result as $res){
    echo $res.PHP_EOL;
}


<?php

function read_input_data() {
  $handle = fopen ("php://stdin","r");
  $n = intval(fgets($handle));

  $data = array();
  for ($i = 0; $i<$n; $i++) {
    $data[] = explode(' ', trim(fgets($handle)));
  }
  fclose($handle);

  return array($n, $data);
}

function read_input_data_test() {
  $n = 4;
  $data = array(
    array(5, 7, 8, 4),
    array(9, 5, 3, 2),
    array(1, 6, 6, 4),
    array(9, 5, 7, 3),
  );

  return array($n, $data);
}

function extract_v_line($arr, $j) {
  $result = array();
  foreach ($arr as $i => $line) {

    # code...
  }
}

list($n, $data) = read_input_data();
$v_sum = $h_sum = array_fill(0, $n, 0);

for ($i = 0; $i<$n; $i++) {
  $line = $data[$i];
  $h_sum[$i] = array_sum($line);
  for ($j = 0; $j<$n; $j++) {
    $v_sum[$j] += $line[$j];
  }
}

// print_r($v_sum);
// print_r($h_sum);

$result = 0;

for ($i = 0; $i<$n; $i++) {
  for ($j = 0; $j<$n; $j++) {
    if ($v_sum[$j] > $h_sum[$i]) {
      $result++;
    }
  }
}

print $result ."\n";

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$countMatr = (int)(str_replace( "\r\n", '', fgets($fp)));

$sumRows = array();
$sumCols = array();
$i = 0;
while( $countMatr-- ){
	$points = explode(" ", trim( str_replace( "\r\n", '', fgets($fp)) ) );
	foreach( $points as $key => $value )
	{
		$sumRows[$i] += $value;
		$sumCols[$key] += $value;
	}
	$i++;
}

$res = 0;
foreach( $sumRows as $key1 => $rowsVal ){
	foreach( $sumCols as $key2 => $colsVal ){
		if( $colsVal > $rowsVal ){
			$res++;
		}
	}
}
echo $res;
fclose($fp);
?>

<?
$stdin = fopen('php://stdin', 'r');
$lines = stream_get_contents($stdin);

$lines=explode("\n", $lines);

$n=$lines[0];

for ($l=1; $l<=$n; $l++)
{
    $line=trim($lines[$l]);
    $numbers_in_line=explode(" ", $line);
    //Сумма в линии $l
    $sum_line[$l-1]=array_sum($numbers_in_line);
    for ($c=0; $c<$n; $c++)
        $sum_col[$c]+=$numbers_in_line[$c];
}
$good=0;
for ($l=1; $l<=$n; $l++)
{
    for ($c=0; $c<$n; $c++)
        if ($sum_col[$c]>$sum_line[$l-1])
            $good++;
}

echo $good;
?>

<?php

$str = file_get_contents('php://stdin');
//$str = file_get_contents('STDIN');

$s = explode("\n", $str);

$lines = array();

foreach ($s as $k=>$v) {
	if ($k == 0) {
		$size = $v;
	} else {
		$l = explode(" ", $v);
		$lines[] = $l;
		//$sum_x[] = array_sum($l);
	}
}

$wins = 0;
$x = $y = array();
for ($i = 0; $i < $size; $i++) {
	$sum_x = array_sum($lines[$i]);
	$sum_y = 0;
	for ($n = 0; $n < $size; $n++) {
		$sum_y += $lines[$n][$i];
	}

	$x[] = $sum_x;
	$y[] = $sum_y;

}

foreach ($x as $k=>$v) {
	for ($i = 0; $i < $size; $i++) {
		if ($v < $y[$i]) {
			$wins++;
		}
	}
}

printf('%s', $wins);

<?php
$count = 0;
$n = fgets(STDIN);
$arr = array();

function check($i0, $j0)
{
    global $arr, $n;

    $sumH = $sumV = 0;

    for($j = 0; $j < $n; $j++)
        $sumH += $arr[$i0][$j];

    for($i = 0; $i < $n; $i++)
        $sumV += $arr[$i][$j0];

    if($sumV > $sumH)
        return true;
}

for($i = 0; $i < $n; $i++)
{
    $arr[$i] = array();

    $line = fgets(STDIN);
    $exp = @explode(' ', $line);

    for($j = 0; $j < $n; $j++)
        $arr[$i][$j] = $exp[$j];
}

for($i = 0; $i < $n; $i++)
    for($j = 0; $j < $n; $j++)
        if(check($i, $j))
            $count++;

echo $count;
?>

<?
$input='';
while($s=fgets(STDIN)){
$input.=$s;
}
$mas=preg_split('|\n|', $input);
$n=$mas[0];
array_splice($mas,0,1);
$mx=array();
$rsr=array();
$rss=array();
$mxr=0;
$mxs=0;
foreach ($mas as $id=>$st){
    $str=preg_split('| |', $st);
    foreach ($str as $idd=>$rec){
        $mx[$mxr][$mxs]=$rec;
        $mxs++;
    }
    $mxs=0;
    $mxr++;
}

$output2=0;
$asr=0;
$ass=0;
for ($r = 0; $r <=$n-1; $r++) {
    for ($s = 0; $s<=$n-1; $s++) {
        $ass=0;
        $asr=0;
        for ($ss = 0; $ss<=$n-1; $ss++) {
            $asr=$asr+$mx[$r][$ss];
            $ass=$ass+$mx[$ss][$s];
        }
        if($ass>$asr){$output2++;}
    }
}
echo $output2;
?>

<?
$stdin = fopen('php://stdin', 'r');
$lines = stream_get_contents($stdin);
$mas= explode("\n", $lines);

$n=$mas[0];
array_splice($mas,0,1);
$mx=array();
$rsr=array();
$rss=array();
$mxr=0;
$mxs=0;
foreach ($mas as $id=>$st){
    $str=preg_split('| |', $st);
    foreach ($str as $idd=>$rec){
        $mx[$mxr][$mxs]=$rec;
        $mxs++;
    }
    $mxs=0;
    $mxr++;
}

$output2=0;
$asr=0;
$ass=0;
for ($r = 0; $r <=$n-1; $r++) {
    for ($s = 0; $s<=$n-1; $s++) {
        $ass=0;
        $asr=0;
        for ($ss = 0; $ss<=$n-1; $ss++) {
            $asr=$asr+$mx[$r][$ss];
            $ass=$ass+$mx[$ss][$s];
        }
        if($ass>$asr){$output2++;}
    }
}
echo $output2;
?>

<?php
$input='';
while($s=fgets(STDIN)){
$input.=$s;
}
$mas=preg_split('|\n|', $input);
$n=$mas[0];
array_splice($mas,0,1);
$mx=array();
$rsr=array();
$rss=array();
$mxr=0;
$mxs=0;
foreach ($mas as $id=>$st){
    $str=preg_split('| |', $st);
    foreach ($str as $idd=>$rec){
        $mx[$mxr][$mxs]=$rec;
        $mxs++;
    }
    $mxs=0;
    $mxr++;
}

$output2=0;
$asr=0;
$ass=0;
for ($r = 0; $r <=$n-1; $r++) {
    for ($s = 0; $s<=$n-1; $s++) {
        $ass=0;
        $asr=0;
        for ($ss = 0; $ss<=$n-1; $ss++) {
            $asr=$asr+$mx[$r][$ss];
            $ass=$ass+$mx[$ss][$s];
        }
        if($ass>$asr){$output2++;}
    }
}
echo $output2;
?>

<?php
$input='';
while($s=fgets(STDIN)){
$input.=$s;
}
$mas=preg_split('|\n|', $input);
$n=$mas[0];
array_splice($mas,0,1);
$mx=array();
$rsr=array();
$rss=array();
$mxr=0;
$mxs=0;
foreach ($mas as $id=>$st){
    $str=preg_split('| |', $st);
    foreach ($str as $idd=>$rec){
        $mx[$mxr][$mxs]=$rec;
        $mxs++;
    }
    $mxs=0;
    $mxr++;
}

$output=0;
$asr=0;
$ass=0;
for ($r = 0; $r <=$n-1; $r++) {
    for ($s = 0; $s<=$n-1; $s++) {
        $ass=0;
        $asr=0;
        for ($ss = 0; $ss<=$n-1; $ss++) {
            $asr=$asr+$mx[$r][$ss];
            $ass=$ass+$mx[$ss][$s];
        }
        if($ass>$asr){$output++;}
    }
}
echo $output;
?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$row_sum[$i] += $inp_num;
			$col_sum[$j] += $inp_num;
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			//if($row_sum[$i] > $col_sum[$j]) $count++;
			if($row_sum[$i] < $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
			$col_sum[$j] += $inp_num;
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			//if($row_sum[$i] > $col_sum[$j]) $count++;
			if($row_sum[$i] < $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
		}
	}
	$col_sum = array();
	for ($k = 0; $k < $inp_n; $k++) {
		for ($l = 0; $l < $inp_n; $l++) {
			$col_sum[$k] += $inp_row[$l][$k];
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			//if($row_sum[$i] > $col_sum[$j]) $count++;
			if($row_sum[$i] < $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
			$col_sum[$j] += $inp_num;
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			//if($row_sum[$i] > $col_sum[$j]) $count++;
			if($row_sum[$i] < $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	$Scanner = new Scanner("php://stdin");
	//$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
		}
	}
	$col_sum = array();
	for ($k = 0; $k < $inp_n; $k++) {
		for ($l = 0; $l < $inp_n; $l++) {
			$col_sum[$k] += $inp_row[$l][$k];
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			if($row_sum[$i] > $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
		}
	}
	$col_sum = array();
	for ($k = 0; $k < $inp_n; $k++) {
		for ($l = 0; $l < $inp_n; $l++) {
			$col_sum[$k] += $inp_row[$l][$k];
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			//if($row_sum[$i] > $col_sum[$j]) $count++;
			if($row_sum[$i] < $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?php
error_reporting(0);

function solve(){
	//$Scanner = new Scanner("php://stdin");
	$Scanner = new Scanner("input.txt");

	$inp_n = $Scanner->Scan();
	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			$inp_num = $Scanner->Scan();
			$inp_row[$i][] = $inp_num;
			$row_sum[$i] += $inp_num;
		}
	}
	$col_sum = array();
	for ($k = 0; $k < $inp_n; $k++) {
		for ($l = 0; $l < $inp_n; $l++) {
			$col_sum[$k] += $inp_row[$l][$k];
		}
	}

	for ($i = 0; $i < $inp_n; $i++) {
		for ($j = 0; $j < $inp_n; $j++) {
			if($row_sum[$i] > $col_sum[$j]) $count++;
		}
	}
	printf("%d", $count);

	$Scanner->close();

}

function run(){
	solve();
}

ob_end_clean();
run();

//input -  $inp_
//block    $temp_
//two block$ttemp_
//as 	   $as_
//instance $(Upper)
//ref      $ref
//class menba $(Upper)

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
class Scanner{
	private $Stream;
	private $Scanners = array();
	private $Id = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link or ''php://stdin' err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		//err $c_row = array("\n", "\r", "\r\n");
		$c_row = array("\r\n", "\r", "\n");
		$contents = str_replace($c_row, " ", $contents);
		$this->Scanners = explode(" ", $contents);
	}

	function Scan(){
		$x = $this->Id;
		$sc = $this->Scanners[$x];
		$this->Id = ++$x;
		return $sc;
	}

	function close(){
		fclose($this->Stream);
	}
}

//error_reporting(0);
//$Scanner = new Scanner("php://stdin");
//ref "#109_div2_B_1230942 laurenceHR"
/*
class LineScanner{
	private $Stream;
	private $Scanners = array();
	private $LineIds_Of_ScanIds= array();
	private $LinesScanners = array();
	private $LastScanIds_Of_LineIds = array();
	private $Scan_number = 0;
	private $Scanline_number = 0;

	public function __construct($opend){
		if((!is_file($opend) && !is_link($opend)) && $opend !== "php://stdin"){
  			print("file or link err");
  			exit;
		}

		$this->Stream = fopen($opend, 'r');
		$contents = stream_get_contents($this->Stream);

		$temp_lines = explode("\n", $contents);
		$temp_linescanners = array();
		$temp_x = 0;
		$temp_y = 0;
		//--attention for initting of array--(these is not needed but for easily reading)//
		$ttemp_scanners = array();
		//$del = Array("\n","\r","\n\r");
		foreach ($temp_lines as $as_line) {
			if (strlen($as_line) === 0) {
				print("input err");
			}

			//$as_line = str_replace($del,'',$as_line);
			$temp_linescanners[] = $as_line;
			$ttemp_line_scanners = explode(" ", $as_line);
			//$ttemp_scanners = array();
			foreach ($ttemp_line_scanners as $as_sc) {
				$ttemp_scanners[] = $as_sc;
				$this->LineIds_Of_ScanIds[$temp_x] = $temp_y;
				$temp_x++;
			}
			$this->LastScanIds_Of_LineIds[$temp_y] = $temp_x - 1;
			$temp_y++;
		}
		$this->Scanners = $ttemp_scanners;
		$this->LinesScanners = $temp_linescanners;
	}

	function Scan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("scan err");
		}

		$sc = $this->Scanners[$x];
		//--attention for ++$x//
		//$this->Scan_number = $x++;
		$this->Scan_number = ++$x;
		$this->Scanline_number = $this->LineIds_Of_ScanIds[$x];
		return $sc;
	}

	function LineScan(){
		$x = $this->Scan_number;
		$y = $this->Scanline_number;
		if ($this->LineIds_Of_ScanIds[$x] === false || $this->LastScanIds_Of_LineIds[$y] === false) {
			print("linescan err");
		}

		$lsc = $this->LinesScanners[$y];
		$this->Scan_number = $this->LastScanIds_Of_LineIds[$y] + 1;
		$this->Scanline_number = $y + 1;
		return $lsc;
	}

	function close(){
		fclose($this->Stream);
	}
}
*/
/*
class Token{
	private $token;
	private $tok;

	public function __construct($str_line, $tok) {
		$this->tok = $tok;
		$this->token = strtok($str_line, $this->tok);
	}

	public function nextToken() {
		$thisToken = $this->token;
		$this->token = strtok($this->tok);
		return $thisToken;
	}

	public function nextFloat() {
		return (float)$this->nextToken();
	}

  	public function nextInt() {
		return (int)$this->nextToken();
	}

	public function nextIntArray() {
		$temp_arr = array();
		$flag = -1;
		while ($flag !== 1) {
			$thisToken = $this->nextToken();
			if ($thisToken !== false) {
				$temp_arr[] = $thisToken;
			} else {
				$flag = 1;
			}
		}
		return $temp_arr;
	}

	public function nnextIntArray($num) {
		$temp_arr = array();
		for ($i = 0; $i < $num; $i++) {
			$temp_arr[] = (int)$this->token;
		}
		return $temp_arr;
	}
}
*/
/*
function get_line() {
        $stdin = fopen("php://stdin", "r");
        $line = rtrim($stdin, "\n");
        fclose($stdin);
        return $line;
}
*/

function num_printf($i){
	if (is_float($i)) {
		printf("%.10f", $i);
	}
	if (is_int($i)) {
		printf("%10d", $i);
	}
}

function array_printf(array $array) {
		$message = "";
		foreach ($array as $value) {
			$message .= "$value" . " ";
		}
		$message = rtrim($message);
		printf('%s', $message);
}
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$countMatr = (int)(str_replace( "\r\n", '', fgets($fp)));

$sumRows = array();
$sumCols = array();
$i = 0;
while( $countMatr-- ){
	$points = explode(" ", trim( str_replace( "\r\n", '', fgets($fp)) ) );
	foreach( $points as $key => $value )
	{
		$sumRows[$i] += $value;
		$sumCols[$key] += $value;
	}
	$i++;
}

$res = 0;
foreach( $sumRows as $rowsVal ){
	foreach( $sumCols as $colsVal ){
		if( $rowsVal > $colsVal ){
			$res++;
		}
	}
}
echo $res;
fclose($fp);
?>

<?
error_reporting(0);

$fp = fopen("php://stdin",'r');
$countMatr = (int)(str_replace( "\r\n", '', fgets($fp)));

$sumRows = array();
$sumCols = array();
$i = 0;
while( $countMatr-- ){
	$points = explode(" ", trim( str_replace( "\r\n", '', fgets($fp)) ) );
	foreach( $points as $key => $value )
	{
		$sumRows[$i] += $value;
		$sumCols[$key] += $value;
	}
	$i++;
}

$res = 0;
foreach( $sumRows as $key1 => $rowsVal ){
	foreach( $sumCols as $key2 => $colsVal ){
		if( $colsVal > $rowsVal ){
			echo $key1 . ' ' . $key2 . "\n";
			$res++;
		}
	}
}
echo $res;
fclose($fp);
?>

<?php

$str = file_get_contents('php://stdin');
//$str = file_get_contents('STDIN');

$s = explode("\n", $str);

$lines = array();

foreach ($s as $k=>$v) {
	if ($k == 0) {
		$size = $v;
	} else {
		$l = explode(" ", $v);
		$lines[] = $l;
		//$sum_x[] = array_sum($l);
	}
}

echo '<pre>';

$wins = 0;
$x = $y = array();
for ($i = 0; $i < $size; $i++) {
	$sum_x = array_sum($lines[$i]);
	$sum_y = 0;
	for ($n = 0; $n < $size; $n++) {
		$sum_y += $lines[$n][$i];
	}

	$x[] = $sum_x;
	$y[] = $sum_y;

}

foreach ($x as $k=>$v) {
	for ($i = 0; $i < $size; $i++) {
		if ($v < $y[$i]) {
			$wins++;
		}
	}
}

printf('%s', $wins);

<?php
$input='';
$mas=preg_split('|\n|', $input);
$n=$mas[1];
array_splice($mas,0,2);
array_splice($mas,count($mas)-1,1);
$mx=array();
$rsr=array();
$rss=array();
$mxr=0;
$mxs=0;
foreach ($mas as $id=>$st){
    $str=preg_split('| |', $st);
    foreach ($str as $idd=>$rec){
        $mx[$mxr][$mxs]=$rec;
        $mxs++;
    }
    $mxs=0;
    $mxr++;
}

$output=0;
$asr=0;
$ass=0;
for ($r = 0; $r <=$n-1; $r++) {
    for ($s = 0; $s<=$n-1; $s++) {
        $ass=0;
        $asr=0;
        for ($ss = 0; $ss<=$n-1; $ss++) {
            $asr=$asr+$mx[$r][$ss];
            $ass=$ass+$mx[$ss][$s];
        }
        if($ass>$asr){$output++;}
    }
}
echo $output;
?>

<?
$stdin = fopen('php://stdin', 'r');
$lines = stream_get_contents($stdin);

$lines=explode("\n", $lines);

$n=$lines[0];

for ($l=1; $l<=$n; $l++)
{
    $line=trim($lines[$l]);
    $numbers_in_line=explode(" ", $line);
    //Сумма в линии $l
    $sum_line[$l-1]=array_sum($numbers_in_line);
    for ($c=0; $c<$n; $c++)
        $sum_col[$c]+=$numbers_in_line[$c];
}

for ($l=1; $l<=$n; $l++)
{
    for ($c=0; $c<$n; $c++)
        if ($sum_col[$c]>$sum_line[$l-1])
            $good++;
}

echo $good;
?>


<?php
    define("MAXN", 1024) ;

    function solve($n, $k)
    {
    }

    $T = intval(fgets(STDIN));
    while($T --)
    {
        $n = intval(fgets(STDIN)) ;

        $candy = explode(" ", fgets(STDIN)) ;

        for($i = 0; $i < $n; $i ++) $candy[$i] = intval($candy[$i]) ;

        $step = 0 ;
        $a_eat = 0 ;
        $b_eat = 0 ;

        $l = 0;
        $r = $n - 1 ;
        $now_eat = 0 ;
        $now_u = 0 ;

        while($l <= $r)
        {
            $step ++ ;

            if($now_u == 0)
            {
                // Alice
                $eat = 0 ;
                for($i = $l; $i <= $r; $i ++)
                {
                    $eat += $candy[$i] ;

                    if($eat > $now_eat)
                    {

                        $l = $i + 1 ;
                        $now_eat = $eat ;
                        $a_eat += $eat ;
                        $now_u = 1 ;
                        break ;
                    }
                }

                if($i > $r)
                {
                    $l = $r + 1 ;
                    $now_eat = $eat ;
                    $a_eat += $eat ;
                    $now_u = 1 ;
                }
            }
            else
            {
                // Bob
                $eat = 0 ;
                for($i = $r; $i >= $l; $i --)
                {
                    $eat += $candy[$i] ;

                    if($eat > $now_eat)
                    {

                        $r = $i - 1 ;
                        $now_eat = $eat ;
                        $b_eat += $eat ;
                        $now_u = 0 ;
                        break ;
                    }
                }

                if($i < $l)
                {
                    $r = $l - 1 ;
                    $now_eat = $eat ;
                    $b_eat += $eat ;
                    $now_u = 0 ;
                }
            }
        }

        echo $step . " " . $a_eat . " " . $b_eat . "\n" ;
    }
?>


<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
97591.0354 49021.4126
2000

INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 10000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$pa = $a; $pd = $d;
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE + 0.5); $d = (int) ($d * BASE + 0.5);
$a4 = $a * 4;
$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur = bcadd($cur, $d); $cur = bcmod($cur, $a4);
    $o = bcdiv($cur, $a, 0); $m = bcmod($cur, $a);
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= bcdiv($m, BASE, 5) . " 0.0\n";
            break;
        case 1:
            $ret .= $pa . ' ' . bcdiv($m, BASE, 5) . "\n";
            break;
        case 2:
            $ret .= bcdiv(bcsub($a, $m), BASE, 5) . ' ' . $pa . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . bcdiv(bcsub($a,$m), BASE, 5) . "\n";
            break;
    }
}
echo $ret;

<?php
function move($val, $d){

}
$f = fopen( 'php://stdin', 'r' );
$ar = explode(' ',fgets($f));
$a = $ar[0];
$d = $ar[1];
$n = fgets($f);
$i = 1;
$x = 0;
$y = 0;
$direct = 1;
while($i <= $n){
    $length=$i*$d;
    $mod = floor($length / $a) - floor(floor($length / $a) / 4) * 4;
    $add = $length - floor($length / $a) * $a;
    switch ($mod) {
        case 0:
            echo "\n".number_format($add,'4','.','').' '.number_format(0,'4','.','');
            break;
        case 1:
            echo "\n".number_format($a,'4','.','').' '.number_format($add,'4','.','');
            break;
        case 2:
            echo "\n".number_format($a-$add,'4','.','').' '.number_format($a,'4','.','');
            break;
        case 3:
            echo "\n".number_format(0,'4','.','').' '.number_format($a-$add,'4','.','');
            break;
    }
   $i++;
}

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
4.147 2.8819
6
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 10000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= sprintf("%0.5f", ($m / BASE)) . " 0.0\n";
            break;
        case 1:
            $ret .= sprintf("%0.5f", ($a / BASE)) . ' ' . sprintf("%0.5f", ($m / BASE)) . "\n";
            break;
        case 2:
            $ret .= sprintf("%0.5f", ($a - $m) / BASE) . ' ' . sprintf("%0.5f", ($a / BASE)) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . sprintf("%0.5f", ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
3 3
20
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 100000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= ($m / BASE) . " 0.0\n";
            break;
        case 1:
            $ret .= ($a / BASE) . ' ' . ($m / BASE) . "\n";
            break;
        case 2:
            $ret .= ( ($a - $m) / BASE) . ' ' . ($a / BASE) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . ( ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
40356.3702 72886.7142
100
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 10000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$pa = $a; $pd = $d;
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;
$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur = bcadd($cur, $d); $cur = bcmod($cur, $a4);
    $o = bcdiv($cur, $a, 0); $m = bcmod($cur, $a);
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= bcdiv($m, BASE, 5) . " 0.0\n";
            break;
        case 1:
            $ret .= $pa . ' ' . bcdiv($m, BASE, 5) . "\n";
            break;
        case 2:
            $ret .= bcdiv(bcsub($a, $m), BASE, 5) . ' ' . $pa . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . bcdiv(bcsub($a,$m), BASE, 5) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
4.147 2.8819
6
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 20000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= sprintf("%0.4f", ($m / BASE)) . " 0.0\n";
            break;
        case 1:
            $ret .= sprintf("%0.4f", ($a / BASE)) . ' ' . sprintf("%0.4f", ($m / BASE)) . "\n";
            break;
        case 2:
            $ret .= sprintf("%0.4f", ($a - $m) / BASE) . ' ' . sprintf("%0.4f", ($a / BASE)) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . sprintf("%0.4f", ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
3 5
100
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 10000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a + 0.01); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= sprintf("%0.5f", ($m / BASE)) . " 0.0\n";
            break;
        case 1:
            $ret .= sprintf("%0.5f", ($a / BASE)) . ' ' . sprintf("%0.5f", ($m / BASE)) . "\n";
            break;
        case 2:
            $ret .= sprintf("%0.5f", ($a - $m) / BASE) . ' ' . sprintf("%0.5f", ($a / BASE)) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . sprintf("%0.5f", ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
3 5
100
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 10000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE + 0.5); $d = (int) ($d * BASE + 0.5);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a + 0.05); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= sprintf("%0.5f", ($m / BASE)) . " 0.0\n";
            break;
        case 1:
            $ret .= sprintf("%0.5f", ($a / BASE)) . ' ' . sprintf("%0.5f", ($m / BASE)) . "\n";
            break;
        case 2:
            $ret .= sprintf("%0.5f", ($a - $m) / BASE) . ' ' . sprintf("%0.5f", ($a / BASE)) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . sprintf("%0.5f", ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;

<?php
define('LOCAL_ENV', false);
if (LOCAL_ENV) {
    error_reporting(E_ALL & !E_NOTICE);
//    $test = <<<INPUT
//4.147 2.8819
//6
//INPUT;
    $test = <<<INPUT
4.147 2.8819
6
INPUT;
    $stdin = fopen('php://temp/in', 'rw');
    fwrite($stdin, $test);
    rewind($stdin);
} else {
    error_reporting(0);
    $stdin = STDIN;
}
define('MY_STDIN', $stdin);
define('BASE', 20000);

list($a,$d) = explode(' ', trim(fgets(MY_STDIN)));
$n = (int) trim(fgets(MY_STDIN));
$a = (int) ($a * BASE); $d = (int) ($d * BASE);
$a4 = $a * 4;

$cur = 0;
for ($i = 0; $i < $n; $i++) {
    $cur += $d; $cur %= $a4;
    $o = floor($cur / $a); $m = $cur % $a;
    if ( ($m == 0) && ($o > 0)) {
        $o--;
        $m = $a;
    }
    switch ($o) {
        case 0:
            $ret .= ($m / BASE) . " 0.0\n";
            break;
        case 1:
            $ret .= ($a / BASE) . ' ' . ($m / BASE) . "\n";
            break;
        case 2:
            $ret .= ( ($a - $m) / BASE) . ' ' . ($a / BASE) . "\n";
            break;
        case 3:
            $ret .= '0.0 ' . ( ($a - $m) / BASE) . "\n";
            break;
    }
}
echo $ret;