ZhenlongDai/ACPR huggingface dataset:
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate


N = int(input())
A = [0] + list(accumulate(map(int, input().split())))
print(A)
min_diff = float("inf")
for i in range(N - 1):
    if abs(A[N] - 2 * A[i + 1]) < min_diff:
        min_diff = abs(A[N] - 2 * A[i + 1])
print(abs(min_diff))


Failing test case input:
12
010 18 33 5 1 477 011 0 179 100 -1 001

Expected output:
254


Actual output:
[0, 10, 28, 61, 66, 67, 544, 555, 555, 734, 834, 833, 834]
254


Fixed submission (verdict: Accepted):
from itertools import accumulate


N = int(input())
A = [0] + list(accumulate(map(int, input().split())))
min_diff = float("inf")
for i in range(N - 1):
    if abs(A[N] - 2 * A[i + 1]) < min_diff:
        min_diff = abs(A[N] - 2 * A[i + 1])
print(min_diff)

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
b = sum(a)
l = 0
r = 0
x = 0
ans = 0
for i in a:
  l += i
  r = b - l
  if l==r:
    break;
  elif l>r:
    ans = min(l-r,y-x)
    print(l-r,y-x)
    break;
  x = l
  y = r
print(ans)

Failing test case input:
12
011 10 33 24 79 344 111 2 139 000 1 011

Expected output:
237


Actual output:
237 451
237


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
b = sum(a)
l = 0
r = 0
x = 0
ans = 0
for i in a:
  l += i
  r = b - l
  if l==r:
    break;
  elif l>r:
    ans = min(l-r,y-x)
    break;
  x = l
  y = r
print(ans)

Problem: p02854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

s = sum(a)

left = 0
right = 0
for i in range(n):
    left += a[i]
    if left >= s/2:
        right = s - left
        break
    
if left == s/2:
    print(0)
else:
    print(abs(left-right))

Failing test case input:
12
101 104 102 105 103 103 100 117 104 102 104 111

Expected output:
20


Actual output:
180


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
 
s = sum(a)
 
left = 0
right = s
res = s
for i in range(n-1):
    left += a[i]
    right -= a[i]
    res = min(res,abs(left-right))
    if res == 0:
        break
    
print(res)

Problem: p02854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):



N = int(input())
a_list = list(map(int, input().split()))


min_cost = 10*18
left_sum = 0
right_sum = sum(a_list)


for i in range(N-1):
    left_sum += a_list[i]
    right_sum -= a_list[i]
    distance = abs(left_sum - right_sum)
    min_cost = min(min_cost, distance)


print(min_cost)


Failing test case input:
12
010 5 66 4 1 477 001 1 179 100 -1 000

Expected output:
283


Actual output:
180


Fixed submission (verdict: Accepted):



N = int(input())
a_list = list(map(int, input().split()))


min_cost = 10**18
left_sum = 0
right_sum = sum(a_list)


for i in range(N-1):
    left_sum += a_list[i]
    right_sum -= a_list[i]
    distance = abs(left_sum - right_sum)
    min_cost = min(min_cost, distance)


print(min_cost)
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



from itertools import accumulate 

N = ii()
A = li()

acc = list(accumulate(A))
sa = acc[-1] -acc[0]

for i in range(N):
    if acc[i] - (acc[-1] - acc[i]) >= 0:
        break

if i == N-1:
    print(abs(A[i] - acc[i-1]))
else:
    print(abs(acc[i] - (acc[-1] - acc[i])))

Failing test case input:
12
011 5 33 24 167 344 010 349 91 195 4 111

Expected output:
156


Actual output:
542


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]



from itertools import accumulate 

N = ii()
A = li()

acc = list(accumulate(A))


for i in range(N):
    if acc[i] - (acc[-1] - acc[i]) >= 0:
        break

if i == N-1:
    print(abs(A[i] - acc[i-1]))
elif i == 0:
    print(abs(acc[i] - (acc[-1] - acc[i])))
else:
    ans = min(abs(acc[i] - (acc[-1] - acc[i])), abs(acc[i-1] - (acc[-1] - acc[i-1])))
    print(ans)

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*a=map(int,open(0).read().split())
b=sum(a)
c=b
d=200000
for i in a:
    c-=i
    if c<0:
        break
    d=min(d,c)
print(d)

Failing test case input:
12
010 3 66 4 1 477 001 1 179 100 -1 100

Expected output:
181


Actual output:
0


Fixed submission (verdict: Accepted):
n,*a=map(int,open(0).read().split())
b=sum(a)
c=0
d=2020202020
for i in a:
    c+=i
    d=min(d,abs(c-b/2))
print(int(d*2))

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))


sum = 0
for i in range(n):
    sum += a[i]

sum2 = 0
for i in range(n):
    sum2 += a[i]
    x = sum2*2 - sum
    if x >= 0:
        y = sum - sum2*2 - a[i]
        if x >= y:
            print(x)
            break
        else:
            print(y)
            break


Failing test case input:
12
011 11 54 192 125 344 010 349 196 161 48 111

Expected output:
118


Actual output:
580


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))


sum = 0
for i in range(n):
    sum += a[i]

sum2 = 0
for i in range(n):
    sum2 += a[i]
    x = sum2*2 - sum
    if x >= 0:
        y = sum - (sum2-a[i])*2
        if x <= y:
            print(x)
            break
        else:
            print(y)
            break
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

now_length = sum(A)
half = now_length / 2
low_price = now_length - sum(A[:int(N/2)])

if half > low_price :
  for i in range(int(N/2),0,-1) :
    var = now_length - sum(A[:i])
    if half == low_price :
      break
    elif low_price > var :
      low_price = var
    else :
      break
else :
  for i in range(int(N/2)+1,N) :
    var = now_length - sum(A[:i])
    if half == low_price :
      break
    elif low_price > var :
      low_price = var
    else :
      break

if low_price == half :
  print(0)
else :
  print(low_price)


Failing test case input:
12
011 5 54 192 167 344 010 349 91 195 3 111

Expected output:
14


Actual output:
759


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

left_length = sum(A[:int(N/2)])
right_length = sum(A[int(N/2):])
if left_length > right_length :
  price = left_length - right_length
  for i in range(int(N/2)-1,0,-1) :
    var = abs(sum(A[:i]) - sum(A[i:]))
    if price > var :
      price = var
    else :
      break
else :
  price = right_length - left_length
  for i in range(int(N/2)+1,N) :
    var = abs(sum(A[i:]) - sum(A[:i]))
    if price > var :
      price = var
    else :
      break

print(price)

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(i) for i in input().split()]
l = sum(a)
l2 = l / 2
tmp = 0
err = [l,l]
errindex = [0,0]
for i in range(n):
    tmp += a[i]
    if err[0] > l2 - tmp and l2 - tmp >= 0:
        err[0] = l2 - tmp
    if err[1] < tmp - l2 and l2 - tmp <= 0:
        err[1] = tmp - l2
ans = min(err)
if ans != int(ans):
    ans += 1
print(int(ans))


Failing test case input:
12
011 19 54 192 125 344 010 349 196 104 48 111

Expected output:
53


Actual output:
27


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(i) for i in input().split()]
l = sum(a)
l2 = l / 2
tmp = 0
err = [l,l]
errindex = [0,0]
ans = 0
for i in range(n):
    tmp += a[i]
    if err[0] > l2 - tmp and l2 - tmp >= 0:
        err[0] = l2 - tmp
    if err[1] > tmp - l2 and l2 - tmp <= 0:
        err[1] = tmp - l2

tmp2 = min(err)
tmp3 = int(tmp2)
ans = tmp3 * 2 
if tmp2 - tmp3 > 0:
    ans += 1
print(ans)
Problem: p02854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    sm = sum(A)
    agg = 0
    idx = 0
    mid = sm / 2
    shrink_cnt = 0
    while agg < mid and idx < N-1:
        shrink_cnt += A[idx] - 1
        
        agg += A[idx]
        idx += 1
    
    shrink = (agg-mid) / 0.5
    expand = (mid - (agg-A[idx]))/0.5

    if shrink <= shrink_cnt:
        ans = min(shrink, expand)
    else:
        ans = expand
    
    print(int(ans))

if __name__ == '__main__':
    solve()

Failing test case input:
12
010 0 107 5 0 127 101 1 179 110 0 100

Expected output:
38


Actual output:
-100


Fixed submission (verdict: Accepted):
def solve():
    N = int(input())
    A = list(map(int,input().split()))

    sm = sum(A)
    agg = 0
    idx = 0
    mid = sm / 2
    shrink_cnt = sm - N
    while agg < mid and idx < N-1:
        
        agg += A[idx]
        idx += 1
    
    oneleft = agg
    oneright = sm - oneleft 
    twoleft = agg-A[idx-1]
    tworight = sm - twoleft
    ans = min(abs(oneleft-oneright), abs(twoleft-tworight))

    print(int(ans))

if __name__ == '__main__':
    solve()

Problem: p02854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
 
s = sum(a)
 
left = 0
right = s
for i in range(n-1):
    left += a[i]
    right -= a[i]
    if left >= s/2:
        right = s - left
        break

if left == s/2:
    print(0)
else:
    print(abs(left-right))

Failing test case input:
12
011 11 43 187 125 344 010 349 104 191 48 111

Expected output:
72


Actual output:
626


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
 
s = sum(a)
 
left = 0
right = s
res = s
for i in range(n-1):
    left += a[i]
    right -= a[i]
    res = min(res,abs(left-right))
    if res == 0:
        break
    
print(res)

Problem: p02854
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import collections
import bisect


def main():
    n = int(input())
    AList = list(map(int, input().split()))
    sumAList = AList
    sumA = sum(AList)
    for i in range(n):
        if i != 0:
            AList[i] = AList[i] + AList[i - 1]
        if sumA - AList[i] <= AList[i]:
            print(abs(sumA - 2 * AList[i]))
            return

    print(sumAList)


if __name__ == '__main__':
    main()


Failing test case input:
12
010 0 107 5 1 182 101 1 27 111 0 110

Expected output:
45


Actual output:
157


Fixed submission (verdict: Accepted):
import sys
import collections
import bisect


def main():
    n = int(input())
    AList = list(map(int, input().split()))
    ASum = sum(AList)
    c = 0
    for i in range(n):
        c += AList[i]
        if c >= ASum / 2:
            k = i
            break
    ans = min(2 * c - ASum, ASum - 2 * c + 2 * AList[k])
    print(ans)


if __name__ == '__main__':
    main()
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math
N = int(input())
A = list(map(int, input().split()))

sum = 0
for i in range(len(A)):
    sum += A[i]

check_sum = 0
for i in range(len(A)):
    check_sum += A[i]
    if check_sum == sum/2:
        print(0)
        exit()
    if check_sum > sum / 2:
        if i+ 1 == len(A):
            print(A[i] - (check_sum - A[i]))
            exit()
        else:
            print(abs(2* check_sum - sum))
            exit()


Failing test case input:
12
011 10 33 24 167 344 110 310 91 110 4 011

Expected output:
47


Actual output:
173


Fixed submission (verdict: Accepted):

import math
N = int(input())
A = list(map(int, input().split()))

sum = 0
for i in range(len(A)):
    sum += A[i]

check_sum = 0
for i in range(len(A)):
    check_sum += A[i]
    if check_sum == sum/2:
        print(0)
        exit()
    if check_sum > sum / 2:
        if i+ 1 == len(A):
            print(A[i] - (check_sum - A[i]))
            exit()
        else:
            if (abs(2 * (check_sum - A[i]) - sum) < abs(2 * check_sum - sum)):
                print(abs(2 * (check_sum - A[i]) - sum))
                exit()
            
            else:
                print(abs(2 * check_sum - sum))
                exit()

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
L = sum(a)
l = 0
i = 0
while l < L / 2:
    l += a[i]
    i += 1
if i + 1 <= len(a):
    ans = min(abs(sum(a[:i]) - sum(a[i:])), abs(sum(a[:i + 1]) - sum(a[i + 1:])))
else:
    ans = abs(sum(a[:i]) - sum(a[i:]))
print(ans)


Failing test case input:
12
001 104 102 187 191 176 110 117 104 102 104 011

Expected output:
139


Actual output:
213


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
L = sum(a)
l = 0
i = 0
while l < L / 2:
    l += a[i]
    i += 1
print(min(abs(sum(a[:i - 1]) - sum(a[i - 1:])), abs(sum(a[:i]) - sum(a[i:]))))

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys

n = int(input())

a = list(map(int, input().split()))

cnt = 0
sum_ = sum(a)/2

for i in range(n):
    cnt += a[i]
    if cnt == sum_:
        print(0)
        sys.exit()
    elif cnt > sum_:
        x1 = sum_ -cnt +a[i-1]
        if x1 <= cnt -sum_:
            x1 = cnt -sum_
        break

print(int(x1*2))

Failing test case input:
12
100 104 102 105 103 103 100 105 104 102 104 101

Expected output:
1


Actual output:
205


Fixed submission (verdict: Accepted):
import sys

n = int(input())

a = list(map(int, input().split()))

cnt = 0
ave = sum(a)/2

for i in range(n):
    cnt += a[i]
    if cnt == ave:
        print(0)
        sys.exit()
    
    elif cnt > ave:
        x = ave -cnt +a[i]
        if x >= cnt -ave:
            x = cnt -ave
        break

print(int(x*2))
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

print(int(N/2))

left_length = sum(A[:int(N/2)])
right_length = sum(A[int(N/2):])
if left_length > right_length :
  price = left_length - right_length
  for i in range(int(N/2)-1,0,-1) :
    var = sum(A[i:]) - sum(A[:i])
    if price > var :
      price = var
    else :
      break
else :
  price = right_length - left_length
  for i in range(int(N/2)+1,N) :
    var = sum(A[:i]) - sum(A[i:])
    if price > var :
      price = var
    else :
      break

print(price)

Failing test case input:
12
010 18 33 5 1 477 011 1 179 100 -1 001

Expected output:
253


Actual output:
6
253


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

left_length = sum(A[:int(N/2)])
right_length = sum(A[int(N/2):])
if left_length > right_length :
  price = left_length - right_length
  for i in range(int(N/2)-1,0,-1) :
    var = abs(sum(A[:i]) - sum(A[i:]))
    if price > var :
      price = var
    else :
      break
else :
  price = right_length - left_length
  for i in range(int(N/2)+1,N) :
    var = abs(sum(A[i:]) - sum(A[:i]))
    if price > var :
      price = var
    else :
      break

print(price)

Problem: p02854
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
sum_li = []
for i,l in enumerate(li):
    if i == 0:
        sum_li.append(l)
        continue
    sum_li.append(sum_li[-1]+l)
all_li = []
for ss in sum_li:
    
    all_li.append(abs(s-ss))
print(min(all_li))


Failing test case input:
12
011 11 54 192 125 344 010 349 104 161 48 111

Expected output:
26


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
li = list(map(int,input().split()))
s = sum(li)
sum_li = []
for i,l in enumerate(li):
    if i == 0:
        sum_li.append(l)
        continue
    sum_li.append(sum_li[-1]+l)
all_li = []
for ii,ss in enumerate(sum_li):
    if ii == len(sum_li)-1:
        break
    all_li.append(abs(s-2*ss))

print(min(all_li))

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
S=list(map(int, input().split()))
Sum=sum(S)

wa=0
count=0
for i in range(n):
    if wa<Sum/2:
        wa=wa+S[i]
        count=count+1
if count==n:
    wa=wa-S[n-1]
        
print(int(abs(Sum-2*wa)))

Failing test case input:
12
011 11 54 192 125 344 010 349 196 104 48 111

Expected output:
61


Actual output:
637


Fixed submission (verdict: Accepted):
n=int(input())
S=list(map(int, input().split()))
Sum=sum(S)

wa=0
count=0
for i in range(n):
    if wa<Sum/2:
        wa=wa+S[i]
        count=count+1
x=int(abs(Sum-2*wa))
wa=wa-S[count-1]
        
y=int(abs(Sum-2*wa))
print(min(x,y))
Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    r = [0] * (N+1)
    rr = [0] * (N+1)

    for i in range(1,N+1):
        r[i] = r[i-1] + A[i-1]
        rr[i] = rr[i-1] + A[i-1]-1

    from bisect import bisect_left
    c = sum(A)/2
    p = bisect_left(r, c)
    t = (r[p] - c)/0.5
    print(int(t))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()


Failing test case input:
12
010 0 107 5 1 127 101 1 179 110 0 100

Expected output:
37


Actual output:
321


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, A: "List[int]"):
    r = [0] * (N+1)
    rr = [0] * (N+1)

    for i in range(1,N+1):
        r[i] = r[i-1] + A[i-1]
    
    for i in range(N-1, -1, -1):
        rr[i] = rr[i+1] + A[i]

    ans = INF
    for i in range(1,N):
        ans = min(ans, abs(r[i]-rr[i]))

    print(ans)

    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Problem: p02854
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
aaa = map(int, input().split())

length = 0
lengths = []
for a in aaa:
  length += a
  lengths.append(length)
  
diff = 999999
for l in lengths:
  if abs(l - (length - l)) < diff:
    diff = abs(l - (length - l))
  else:
    break
    
print(diff)

Failing test case input:
12
001 0 107 5 0 196 001 1 2 101 0 110

Expected output:
94


Actual output:
522


Fixed submission (verdict: Accepted):
n = int(input())
aaa = map(int, input().split())

length = 0
lengths = []
for a in aaa:
  length += a
  lengths.append(length)
  
diffs = []
for l in lengths:
  diff = abs(l - (length - l))
  diffs.append(diff)
    
print(min(diffs))
Problem: p02767
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
x = list(map(int, input().split()))

max_x = max(x)
min_x = min(x)

ans = []
for i in range(1, 101):
  a = 0
  for xi in x:
    a += (xi - (i+1))*(xi - (i+1))
  ans.append(a)
  
print(min(ans))

Failing test case input:
7
1 2 2 2 9 -3 -4

Expected output:
108


Actual output:
111


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int, input().split()))

max_x = max(x)
min_x = min(x)

ans = []
for i in range(1, 101):
  a = 0
  for xi in x:
    a += (xi - i)*(xi - i)
  ans.append(a)
  
print(min(ans))

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
l = map(int, input().split())

mean = int(sum(l)/N)

stamina = 0

for p in l:
	stamina += (p - mean)**2
    
print(stamina)

Failing test case input:
7
11 14 3 33 56 1 0

Expected output:
2563


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
l = list(map(int, input().split()))

mean = round(sum(l)/N)
stamina = 0

for p in l:
    stamina += (p - mean)**2

print(stamina)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def resolve():
    import math
    n = int(input())
    x = list(map(int,input().split()))
    b =  math.ceil(sum(x)/n)
    m = 0
    for i in x:
        m += (i-b) * (i-b)
    print(m)
resolve()

Failing test case input:
7
0 1 0 0 198 2 -2

Expected output:
33557


Actual output:
33558


Fixed submission (verdict: Accepted):
def resolve():
    n = int(input())
    x = list(map(int,input().split()))
    b =  round(sum(x)/n)
    m = 0
    for i in x:
        m += (i-b) * (i-b)
    print(m)
resolve()

Problem: p02767
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
x = list(map(int, input().split()))

p0 = sum(x)

cost = 10**9
for i in range(1,101):
    now = 0
    for j in x:
        now += abs(i-j)**2
    if cost > now:
        cost = now

print(now)


Failing test case input:
7
4 14 0 12 21 0 0

Expected output:
426


Actual output:
60597


Fixed submission (verdict: Accepted):

n = int(input())
x = list(map(int, input().split()))
cost = 10**9
for i in range(1,100):
    now = 0
    for j in x:
        now += (i-j)**2
    if cost > now:
        cost = now
print(cost)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = list(map(int,input().split()))
m = 0
j = max(x)

for p in range(j):
    c = 0
    for i in range(n):
        p = (i+1) * (i+1) - n
        c = c + (p * p)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(c)

Failing test case input:
7
-2 2 4 6 -1 -1 -3

Expected output:
68


Actual output:
3059


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for i in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)
Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = list(map(int, input().split()))
ans = 10 ** 9
for p in range(0, n+1):
    cnt = 0
    for i in x:
        cnt += (i-p)**2
    ans = min(ans, cnt)
print(ans)

Failing test case input:
7
0 1 0 0 198 2 -2

Expected output:
33557


Actual output:
36770


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int, input().split()))
ans = 10 ** 9
for p in range(0, 101):
    cnt = 0
    for i in x:
        cnt += (i-p)**2
    ans = min(ans, cnt)
print(ans)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
N = int(input())
X = list(map(int,input().split()))
a = sum(X)
mean = a/N
b = 0
for i in range(N):
    b +=(X[i]-mean)**2
print(math.ceil(b))

Failing test case input:
7
4 14 0 12 21 2 0

Expected output:
401


Actual output:
400


Fixed submission (verdict: Accepted):
import math
from statistics import mean, median,variance,stdev
N = int(input())
X = list(map(int,input().split()))
a = sum(X)
ave = round(a/N)
b = 0
for i in range(N):
    b +=(X[i]-ave)**2
print(b)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
X=list(map(int,input().split()))
p=sum(X)
ans=0
for i in range(len(X)):
    ans+=(X[i]-p)**2
print(ans)


Failing test case input:
7
0 1 0 19 82 0 -1

Expected output:
5631


Actual output:
58092


Fixed submission (verdict: Accepted):
N=int(input())
X=list(map(int,input().split()))
p=round(sum(X)/len(X))
ans=0
for i in range(len(X)):
    ans+=(X[i]-p)**2
print(ans)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = list(map(int,input().split()))
m = 10**10
for p in range(x[0],x[n-1]+1):
    power = 0
    for i in range(n):
        power += (x[i]-p)**2
    m = min(m,power)
print(m)

Failing test case input:
7
0 2 2 2 9 -2 -4

Expected output:
102


Actual output:
10000000000


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int,input().split()))
x = sorted(x)
m = 10**20
for p in range(x[0],x[n-1]+1):
    power = 0
    for i in range(n):
        power += (x[i]-p)**2
    m = min(m,power)
print(m)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    m_energy += (x[k]-1)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)

Failing test case input:
7
1 2 3 2 9 -3 -4

Expected output:
111


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int,input().split()))
m_energy = 250000
for i in range(1,101):
  energy = 0
  for k in range(n):
    energy += (x[k]-i)**2
  if energy < m_energy:
    m_energy = energy
print(m_energy)
Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x = list(map(int, input().split()))

x.sort()
ave = sum(x) / len(x)
squared = sum([i*i for i in x])

print(Decimal(str(squared - n*(ave)*ave)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))



Failing test case input:
7
1 1 0 1 141 1 -1

Expected output:
16925


Actual output:
16924


Fixed submission (verdict: Accepted):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

n = int(input())
x = list(map(int, input().split()))

ave = sum(x) / len(x)
p = Decimal(str(ave)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
squared = sum([i*i for i in x])

print(n*p*p - 2*p*sum(x) + squared)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def physical_strength(x,p):
  return pow((x - p), 2)



if __name__ == '__main__':
  num_resident = input()
  x_list = [int(a) for a in input().split()]
  min_x = min(x_list)
  max_x = max(x_list)
  
  fin_ps = pow(max_x, 2)
  for i in range(min_x, max_x + 1):
    sum_ps = 0
    for x in x_list:
      sum_ps += physical_strength(x, i)
    if(sum_ps < fin_ps):
      fin_ps = sum_ps
  
  print(fin_ps)


Failing test case input:
7
-2 2 4 6 7 -1 -3

Expected output:
95


Actual output:
49


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
  num_resident = int(input())
  
  x_list = [int(a) for a in input().split()]
  min_x = min(x_list)
  max_x = max(x_list)
  
  fin_ps = 0
  for i in range(min_x, max_x + 1):
    sum_ps = 0
    for x_i in range(num_resident):
      sum_ps += pow((x_list[x_i] - i), 2)
    
    if(i == min_x):
      fin_ps = sum_ps 
      
    if(sum_ps < fin_ps):
      fin_ps = sum_ps
  
  print(fin_ps)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
list = list(map(int, input().split()))

l=len(list)
m=0
i=0
j=1
r=0

while(i<l):
  if(m < abs(list[i]-j)):
    m = j
  i+=1
  j+=1

k=0

while(k<l):
  r+=abs(list[k]-m)*abs(list[k]-m)
  k+=1

print(r)

Failing test case input:
7
4 1 0 12 23 0 -1

Expected output:
475


Actual output:
488


Fixed submission (verdict: Accepted):
N=int(input())
list = list(map(int, input().split()))
c=100
l=len(list)
m=0
k=0
i=0
while(k<l):
  m+=(list[k]-1)**2
  k+=1
j=1
while(j<c):
  r=0
  i=0
  while(i<l):
    r+=(list[i]-j) ** 2
    i+=1
  if(r<m):
    m=r
  j+=1
print(m)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
cnt=0
cntm=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
print(min(cnt,cntm))
  

Failing test case input:
7
0 2 3 2 9 -2 -1

Expected output:
79


Actual output:
84


Fixed submission (verdict: Accepted):
import statistics
n=int(input())
x=[int(_) for _ in input().split()]
mid=int(statistics.mean(x))
mmid=mid-1
pmid=mid+1
cnt=0
cntm=0
cntp=0
for i in range(len(x)):
  cnt+= (x[i]-mid)**2
  cntm+=(x[i]-mmid)**2
  cntp+=(x[i]-pmid)**2
print(min(cnt,cntm,cntp))
Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
X = [int(n) for n in range(N)]

min_ans = +float('inf')

for i in range(N):
    ans = 0
    for x in X:
        ans += (x - i)**2
    min_ans = min([min_ans, ans])

print(min_ans)

Failing test case input:
7
-1 2 3 5 9 -1 -1

Expected output:
86


Actual output:
28


Fixed submission (verdict: Accepted):
N = int(input())
X = list(map(int, input().split()))
min_ans = +float('inf')

for i in range(1, 100):
    ans = 0
    for x in X:
        ans += (x - i)**2
    min_ans = min([min_ans, ans])

print(min_ans)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
X = list(map(int, input().split()))
sum = []
for n in range(1,N+1):
    s = 0
    for x in X:
        s = s + ((x-n)*(x-n))
    sum.append(s)

print(min(sum))

Failing test case input:
7
0 0 0 0 198 2 -1

Expected output:
33553


Actual output:
36766


Fixed submission (verdict: Accepted):
N = int(input())
X = list(map(int, input().split()))
sum = []

for n in range(1,101):
    s = 0
    for x in X:
            s = s + ((x-n)*(x-n))
    sum.append(s)

print(min(sum))

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
X = list(map(int, input().split()))
min = 1000000

for i in range(1, X[N-1]+1):
    T = 0
    for j in range(N):
      T += (X[j]-i) ** 2
    if T < min:
        min = T

print(min)

Failing test case input:
7
4 14 0 12 14 0 0

Expected output:
276


Actual output:
1000000


Fixed submission (verdict: Accepted):
N = int(input())
X = list(map(int, input().split()))
min = 1000000

for i in range(1, 100):
    T = 0
    for j in range(N):
        T += (X[j]-i) ** 2
    if T < min:
        min = T

print(min)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = [int(i) for i in input().split()]
l, r = 0, 0
for i in x:
    l = min(l, i)
    r = max(l, i)
ans = 10e9
for i in range(l, r):
    cost = 0
    for j in range(n):
        cost += (x[j] - i) * (x[j] - i)
    ans = min(ans, cost)
print(ans)


Failing test case input:
7
0 1 0 20 141 1 -1

Expected output:
16535


Actual output:
10000000000.0


Fixed submission (verdict: Accepted):
n = int(input())
x = [int(i) for i in input().split()]
l, r = x[0], x[0]
for i in x:
    l = min(l, i)
    r = max(r, i)
ans = 10e9
for i in range(l, r + 1):
    cost = 0
    for j in range(n):
        cost += (x[j] - i) ** 2
    ans = min(ans, cost)
print(ans)
Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x = list(map(int, input().split()))

mini, maxi = min(x), max(x)
min2, max2 = mini**2, maxi**2
ans = max2 if max2 > min2 else min2

for p in range(mini, maxi):
  suma = 0
  for z in x:
    suma += (z-p)**2
  if ans > suma:
    ans = suma
    
print(ans)

Failing test case input:
7
4 14 0 12 14 0 0

Expected output:
276


Actual output:
196


Fixed submission (verdict: Accepted):
n = int(input())
x = list(map(int, input().split()))

mini, maxi = min(x), max(x)
min2, max2 = mini**2*n, maxi**2*n
ans = max2 if max2 > min2 else min2

for p in range(mini, maxi+1):
  suma = 0
  for z in x:
    suma += (z-p)**2
  if ans > suma:
    ans = suma
    
print(ans)

Problem: p02767
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
x=list(map(int,input().split()))
ans=sum(x)
print(ans)
v=0
for i in x:
    v+=(i-ans)**2
print(v)


Failing test case input:
7
0 1 0 19 23 0 -1

Expected output:
640


Actual output:
42
9712


Fixed submission (verdict: Accepted):
n=int(input())
x=list(map(int,input().split()))
my_round_int = lambda y: int((y * 2 + 1) 
ans=sum(x)/n
ans=my_round_int(ans)
v=0
for i in x:
    v+=(i-ans)**2
print(v)
Problem: p02327
Buggy submission (Python3, verdict: Wrong Answer):


from itertools import chain

if __name__ == '__main__':

    H, W = map(int, input().split())
    C = []
    hist = []
    for i in range(H):
        l = input().split()
        C.append([int(x) for x in l])
        hist.append([(int(x) + 1) % 2 for x in l])

    for i in range(1, H):
        for j in range(W):
            if C[i][j] == 0:
                hist[i][j] = hist[i - 1][j] + 1
                
    S = []
    max_area = 0
    for i in range(H):
        for j in range(W):
            rect = [j, hist[i][j]]
            if not S:
                S.append(rect)
            elif S[-1][1] < rect[1]:
                S.append(rect)
            elif S[-1][1] > rect[1]:
                while S and S[-1][1] > rect[1]:
                    post_rect = S.pop()
                    area = post_rect[1] * (j - post_rect[0])
                    max_area = max(max_area, area)
                S.append([post_rect[0], rect[1]])

    print(max_area)





Failing test case input:
1 5
1 1 1 0 0
2 0 -1 0 1
1 -1 0 0 0
0 0 1 2 0

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):


from itertools import chain

if __name__ == '__main__':

    H, W = map(int, input().split())
    C = []
    hist = []
    for i in range(H):
        l = input().split()
        C.append([int(x) for x in l])
        hist.append([(int(x) + 1) % 2 for x in l])

    for i in range(1, H):
        for j in range(W):
            if C[i][j] == 0:
                hist[i][j] = hist[i - 1][j] + 1
    
    S = []
    max_area = 0
    for i in range(H):
        for j in range(W):
            rect = [j, hist[i][j]]
            if not S:
                S.append(rect)
            elif S[-1][1] < rect[1]:
                S.append(rect)
            elif S[-1][1] > rect[1]:
                while S and S[-1][1] > rect[1]:
                    post_rect = S.pop()
                    area = post_rect[1] * (j - post_rect[0])
                    max_area = max(max_area, area)
                S.append([post_rect[0], rect[1]])
        while S:
            post_rect = S.pop()
            area = post_rect[1] * (W - post_rect[0])
            max_area = max(max_area, area)

    print(max_area)
Problem: p02327
Buggy submission (Python3, verdict: Wrong Answer):
h, w = map(int, input().split())

mp = []
for _ in range(h):
  lst = list(map(int, input().split()))
  cum = []
  acc = 0
  for i in lst:
    if not i:
      acc += 1
    else:
      acc = 0
    cum.append(acc)
  mp.append(cum)
mp.append([-1] * w)
ans = 0

for i in range(w - 1, -1, -1):
  stack = []

  for j in range(h + 1):

    score = mp[j][i]
    if not stack:
      stack.append((score, j))
    else:
      last_score, last_ind = stack[-1][0], stack[-1][1]
      if score > last_score:
        stack.append((score, j))
      elif score == last_score:
        continue
      else:
        while stack and last_score > score:
          last_score, last_ind = stack.pop()
          ans = max(ans, last_score * (j - last_ind))
        stack.append((score, last_ind))

print(ans)


Failing test case input:
4 5
1 0 1 1 0
1 0 0 0 0
0 0 1 0 0
0 0 0 1 0

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
h, w = map(int, input().split())

mp = []
for _ in range(h):
  lst = list(map(int, input().split()))
  cum = []
  acc = 0
  for i in lst:
    if not i:
      acc += 1
    else:
      acc = 0
    cum.append(acc)
  mp.append(cum)
mp.append([-1] * w)
ans = 0


for i in range(w - 1, -1, -1):
  stack = []

  for j in range(h + 1):

    score = mp[j][i]
    if not stack:
      stack.append((score, j))
    else:
      last_score, last_ind = stack[-1][0], stack[-1][1]
      if score > last_score:
        stack.append((score, j))
      elif score == last_score:
        continue
      else:
        while stack and stack[-1][0] > score:
          last_score, last_ind = stack.pop()
          ans = max(ans, last_score * (j - last_ind))
        if not stack:
          stack.append((score, last_ind))
        elif stack[-1][0] == score:
          pass
        else:
          stack.append((score, last_ind))

print(ans)
Problem: p02327
Buggy submission (Python3, verdict: Wrong Answer):
h, w = map(int, input().split())
max_rect, prev = 0, [0] * (w + 1)
for i in range(h):
    current = [p + 1 if f else 0 for f, p in zip(map(lambda x: int(x) ^ 1, input().split()), prev)] + [0]
    stack = [(0, 0)]
    for j in range(w + 1):
        c_j = current[j]
        if stack[-1][0] < c_j:
            stack.append((c_j, j))
            continue
        if stack[-1][0] > c_j:
            while stack[-1][0] > c_j:
                height, since = stack.pop()
                max_rect = max(max_rect, height * (j - since))
            if c_j:
                stack.append((c_j, j))
    prev = current

print(max_rect)

Failing test case input:
4 5
1 0 1 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 1 0

Expected output:
8


Actual output:
6


Fixed submission (verdict: Accepted):
h, w = map(int, input().split())
max_rect, prev = 0, [0] * (w + 1)
for i in range(h):
    current = [p + 1 if f else 0 for f, p in zip(map(lambda x: int(x) ^ 1, input().split()), prev)] + [0]
    stack = [(0, 0)]
    for j in range(w + 1):
        c_j = current[j]
        if stack[-1][0] < c_j:
            stack.append((c_j, j))
            continue
        if stack[-1][0] > c_j:
            since = 0
            while stack[-1][0] > c_j:
                height, since = stack.pop()
                max_rect = max(max_rect, height * (j - since))
            if c_j:
                stack.append((c_j, since))
    prev = current
print(max_rect)
Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    d=0
    for j in range(m):
       d+=a[j]*b[j]
    d+=c
    if(d<=0):
        continue
    else:
     ans=i
print(ans)

Failing test case input:
4 1 -4
-2 5
100 41
110 40
-4 -2
-6 -1
18 -13

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    d=0
    for j in range(m):
       d+=a[j]*b[j]
    d+=c
    if(d<=0):
        continue
    else:
     ans+=1
print(ans)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n ,m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int,input().split())) for i in range(n)] 
    

count = 0
for i in A:
  numberSum = c
  for a, b in zip(i, B):
    numberSum += (a * b)  
    if numberSum > 0:
      count += 1
print(count)
  

Failing test case input:
3 3 0
101 -100 0
0 100 111
100 100 100
-100 100 101

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
n ,m, c = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int,input().split())) for i in range(n)] 
    

count = 0
for i in A:
    numberSum = c
    for a, b in zip(i, B):
      numberSum += (a * b)  
    if numberSum > 0:
        count += 1
print(count)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M,C = map(int,input().split())
B = input().split()
Anm = []
for i in range(N):
    Anm.append(input().split())
cont = 0
for A in Anm:
    c = 0
    for i in range(M):
        c += int(A[i]) * int(B[i])
    if c > 0:
        cont += 1
print(cont)

Failing test case input:
2 3 -10
1 2 4
6 2 1
-1 1 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N,M,C = map(int,input().split())
B = input().split()
Anm = []
for i in range(N):
    Anm.append(input().split())
cont = 0
for A in Anm:
    c = C
    for i in range(M):
        c += int(A[i]) * int(B[i])
    if c > 0:
        cont += 1
print(cont)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m,c=map(int,input().split())
b= [int(x) for x in input().split()]
ans=0

for i in range(n):
    a=[int(x)*y for x,y in zip(input().split(),b)]
    s=0
    for j in range(m):
        s=sum(a)
        if(s+c>0):
            ans=+1
print(ans)

Failing test case input:
5 2 -4
-2 5
100 41
100 40
-3 0
-6 -2
18 -13

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n,m,c=map(int,input().split())
b= [int(x) for x in input().split()]
ans=0

for i in range(n):
    a=[int(x)*y for x, y in zip(input().split(), b)]
    if(sum(a)+c>0):
        ans+=1
print(ans)
Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    N, M, C = map(int, input().split())
    
    B = list(map(int, input().split())) 
    A = [[] for i in range(N)]
    for i in range(N):
        A[i] = list(map(int, input().split()))
    print('B=',B)
    print('A=',A)
    
    num = 0
    for i in range(N):
        sum = 0
        for j in range(M):
            sum = sum + A[i][j]*B[j]
        result = sum + C
        if (result > 0 ):
            num = num + 1
    print(num)
    return num

main()


Failing test case input:
3 3 0
100 -100 0
-1 100 101
000 000 100
-100 100 001

Expected output:
0


Actual output:
B= [100, -100, 0]
A= [[-1, 100, 101], [0, 0, 100], [-100, 100, 1]]
0


Fixed submission (verdict: Accepted):
def main():
    N, M, C = map(int, input().split())
    B = list(map(int, input().split())) 
    A = [[] for i in range(N)]
    for i in range(N):
        A[i] = list(map(int, input().split()))

    num = 0
    for i in range(N):
        sum = 0
        for j in range(M):
            sum = sum + A[i][j]*B[j]
        result = sum + C
        if (result > 0 ):
            num = num + 1
    print(num)
    return num

main()

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m,c=map(int,input().split())
b=list(map(int, input().split()))
u=0
for i in range(n):
    inp=list(map(int,input().split()))
    s=0
    for j in range(m):
        s+=inp[j]*(j+1)
    s+=c
    if s>0:
        u+=1
print(u)

Failing test case input:
2 3 -1
111 -173 0
-1 000 101
100 100 100
-100 100 100

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n,m,c=map(int,input().split())
b=list(map(int, input().split()))
u=0
for i in range(n):
    inp=list(map(int,input().split()))
    s=0
    for j in range(m):
        s+=inp[j]*(b[j])
    s+=c
    if s>0:
        u+=1
print(u)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
NMC = list(map(lambda x: int(x), input().split()))
N = NMC[0]
M = NMC[1]
C = NMC[2]

B = list(map(lambda x: int(x), input().split()))
A = [list(map(lambda x: int(x), input().split())) for i in range(N)]

print("B", B)
print("A", A)
print("N", N)
print("M", M)
print("C", C)

answer = 0

for i in range(len(A)):
  judge = 0
  for m in range(len(A[i])):
    judge += A[i][m] * B[m]

  print("judge", judge)
  if (judge + C > 0):
    answer += 1

print(answer)

Failing test case input:
3 3 0
100 -100 0
0 100 101
000 000 100
-100 100 101

Expected output:
0


Actual output:
B [100, -100, 0]
A [[0, 100, 101], [0, 0, 100], [-100, 100, 101]]
N 3
M 3
C 0
judge -10000
judge 0
judge -20000
0


Fixed submission (verdict: Accepted):
NMC = list(map(lambda x: int(x), input().split()))
N = NMC[0]
M = NMC[1]
C = NMC[2]

B = list(map(lambda x: int(x), input().split()))
A = [list(map(lambda x: int(x), input().split())) for i in range(N)]

answer = 0

for i in range(len(A)):
  judge = 0
  for m in range(len(A[i])):
    judge += A[i][m] * B[m]
  if (judge + C > 0):
    answer += 1

print(answer)
Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]*M]*N
ans = 0
sum = 0
for i in range(N):
  A[i] = list(map(int, input().split()))
for i in range(N):
  for j in range(M):
    sum += A[i][j] * B[j]
  sum += C
  if sum > 0:
    ans += 1
      
print(ans)

Failing test case input:
3 3 0
100 -100 1
0 100 100
110 100 100
-100 100 100

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]*M]*N
ans = 0
sum = 0
for i in range(N):
  A[i] = list(map(int, input().split()))
for i in range(N):
  sum = 0
  for j in range(M):
    sum += A[i][j] * B[j]
  sum += C
  if sum > 0:
    ans += 1
      
print(ans)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  if sum([a*b for a in A for b in B])+C>0:
    ans+=1
print(ans)

Failing test case input:
3 3 0
100 -100 1
0 100 010
110 100 100
-100 100 100

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
  A=list(map(int,input().split()))
  if sum([a*b for a,b in zip(A,B)])+C>0:
    ans+=1
print(ans)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=tuple(map(int,input().split()))
b=[]
for i in range(a[0]+1):
    b.append(list(map(int,input().split())))
ans=0
s=0
for j in range(a[0]):
    for k in range(a[1]):
        s+=b[j][k]*b[0][k]
    s+=a[2]
    if s>0:
        ans+=1
    s=0
print(ans)

Failing test case input:
3 3 1
101 -100 -2
-1 100 101
100 110 100
-57 100 100

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
a=tuple(map(int,input().split()))
b=[]
for i in range(a[0]+1):
    b.append(list(map(int,input().split())))
ans=0
s=0
for j in range(a[0]+1)[1:a[0]+1]:
    for k in range(a[1]):
        s+=b[j][k]*b[0][k]
    s+=a[2]
    if s>0:
        ans+=1
    s=0
print(ans)

Problem: p03102
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
l=[]
ans=[]
cnt=0
for i in range(n):
	a=list(map(int,input().split()))
	l.append(a)
for i in range(n):
	sum=0
	for j in range(m):
		sum+=b[j]*l[i][j]
		if j==(m-1):
			sum-=c
			ans.append(sum)
for i in ans:
	if i>0:
		cnt+=1
print(cnt)

Failing test case input:
2 3 -11
1 2 3
3 2 1
1 1 1

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
l=[]
ans=[]
cnt=0
for i in range(n):
	a=list(map(int,input().split()))
	l.append(a)
for i in range(n):
	sum=0
	for j in range(m):
		sum+=b[j]*l[i][j]
		if j==(m-1):
			sum+=c
			ans.append(sum)
for i in ans:
	if i>0:
		cnt+=1
print(cnt)