Problem:


凸 n 角形の面積

凸 n 角形（すべての頂点の内角が 180 度未満である多角形、要するにへこんでいない多角形のこと）の頂点の座標を読んで、その面積を出力するプログラムを作成してください。頂点には辺のつながりの順序に従って頂点 1、頂点 2、頂点 3、‥‥頂点 n という名前がついています。

ただし、 n は 3 以上 20 以下とします。また、次の、三角形の 3 辺の長さ a, b, c から面積 S を求める公式を使ってもかまいません。

入力

入力は以下の形式で与えられます。

x1,y1
x2,y2
:
xn,yn

xi, yi はそれぞれ頂点 i の x 座標, y 座標を表す実数です。

出力

面積 S （実数）を１行に出力します。
出力は 0.000001 以下の誤差を含んでもかまいません。

Sample Input

0.0,0.0
0.0,1.0 
1.0,1.0 
2.0,0.0 
1.0,-1.0 

Output for the Sample Input

2.500000



Sample input:
0.0,0.0
0.0,1.0
1.0,1.0
2.0,0.0
1.0,-1.0


Sample output:
2.500000

Submission status: Wrong Answer

Solution code:
x,y,r,l,s=[],[],[],[],[]
while 1:
    try:
        a,b=map(float,raw_input().split(','))
        x.append(a)
        y.append(b)
    except:
        break
for i in range(len(x)-1):
    r.append(((x[i+1]-x[0])**2+(y[i+1]-y[0])**2)**0.5)
for i in range(1,len(x)-1):
    l.append(((x[i+1]-x[i])**2+(y[i+1]-y[i])**2)**0.5)
for i in range(len(x)-2):
    s.append((r[i]+r[i+1]+l[i])/2)
sum=0.0
for i in range(len(x)-2):
    sum+=(s[i]*(s[i]-r[i])*(s[i]-r[i+1])*(s[i]-l[i]))
print sum

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

t=[]
while 1:
    try:
        x,y=map(float,raw_input().split(','))
        t.append((x,y))
    except:
        break

t.sort()
ans=0
for i in range(len(t)-2):
    a=t[i+1][0]-t[i][0]
    b=t[i+1][1]-t[i][1]
    c=t[i+2][0]-t[i][0]
    d=t[i+2][1]-t[i][1]
    ans+=abs(a*d-b*c)/2.0
print ans

Submission status: Wrong Answer

Solution code:
import math
f = []
while True:
    try:
        st = input().strip().split(',')
        print("st=",st)
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

px = [p.real for p in f]
ox = (max(px) + min(px)) / 2.0

py = [p.imag for p in f]
oy = (max(py) + min(py)) / 2.0

fo = ox + oy * 1j

ss = 0.0
for i in range(len(f)):
    if i == len(f)-1:
        j = 0
    else:
        j = i + 1
    a = abs(f[i]-fo)
    b = abs(f[j]-fo)
    c = abs(f[j]-f[i])
    z = (a + b + c) / 2.0
    s = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ss += s
print(ss)

Submission status: Wrong Answer

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
for i in range(len(p)-2):
 a,b=p[i+1];c,d=p[i+2]
 s-=((a-x)*(d-y)-(b-y)*(c-x))/2
print(s)

Submission status: Wrong Answer

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin];n=len(p)
for i in range(n):a,b=p[i];c,d=p[-~i%n];s+=a*d-b*c
print(-s/2)

Submission status: Wrong Answer

Solution code:
import sys,math

l=[list(map(float,i.split(","))) for i in sys.stdin]
S=0
for (i,j) in enumerate(l[:-1]):
    xn,yn=j
    xn_1,yn_1=l[i+1]
    a=math.sqrt(xn**2+yn**2)
    b=math.sqrt(xn_1**2+yn_1**2)
    c=math.sqrt((xn_1-xn)**2+(yn_1-yn)**2)
    z=(a+b+c)/2
    S+=math.sqrt(z*(z-a)*(z-b)*(z-c))
print(S)

Submission status: Wrong Answer

Solution code:
import sys
x0,y0=map(float,raw_input()[:-1].split(","))
x1,y1=map(float,raw_input()[:-1].split(","))
s=0
for e in sys.stdin:
    ex,ey=map(float,e[:-1].split(","))
    x2,y2=ex-x0,ey-y0
    s+=abs(x1*y2-x2*y1)
    x1,y1=x2,y2
print s/2

Submission status: Wrong Answer

Solution code:
import sys
x=[map(float,s[:-1].split(",")) for s in sys.stdin]
s=[x[i][0]*x[i+1][1]-x[i][1]*x[i+1][0] for i in range(len(x)-1)]
print abs(sum(s))/2

Submission status: Wrong Answer

Solution code:
from math import hypot

polygon = []
while 1:
    try:
        x, y = map(float, raw_input().split(','))
        polygon.append((x, y))
    except EOFError:
        break

A = polygon[0]
B = polygon[0]
ret = 0.0
for i in xrange(2, len(polygon)):
    C = polygon[i]
    a = hypot(A[0] - B[0], A[1] - B[1])
    b = hypot(A[0] - C[0], A[1] - C[1])
    c = hypot(C[0] - B[0], C[1] - B[1])
    z = (a + b + c) / 2
    S = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    ret += S
print S

Submission status: Wrong Answer

Solution code:
from math import hypot

polygon = []
for i in xrange(5):
    try:
        x, y = map(float, raw_input().split(','))
        polygon.append((x, y))
    except EOFError:
        break
polygon.sort()
A = polygon[0]
ret = 0.0
for i in xrange(1, len(polygon) - 1):
    B = polygon[i]
    C = polygon[i + 1]
    a = hypot(A[0] - B[0], A[1] - B[1])
    b = hypot(A[0] - C[0], A[1] - C[1])
    c = hypot(C[0] - B[0], C[1] - B[1])
    z = (a + b + c) / 2
    S = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    ret += S
print ret

Submission status: Wrong Answer

Solution code:
from math import hypot

polygon = []
while 1:
    try:
        x, y = map(float, raw_input().split(','))
        polygon.append((x, y))
    except EOFError:
        break
polygon.sort()
A = polygon[0]
ret = 0.0
for i in xrange(1, len(polygon) - 1):
    B = polygon[i]
    C = polygon[i + 1]
    a = hypot(A[0] - B[0], A[1] - B[1])
    b = hypot(A[0] - C[0], A[1] - C[1])
    c = hypot(C[0] - B[0], C[1] - B[1])
    z = (a + b + c) / 2
    S = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    ret += S
print ret

Submission status: Wrong Answer

Solution code:
from math import hypot

polygon = []
while 1:
    try:
        x, y = map(float, raw_input().split(','))
        polygon.append((x, y))
    except EOFError:
        break
polygon.sort()
ret = 0.0
for i in xrange(len(polygon) - 2):
    A = polygon[i]
    B = polygon[i + 1]
    C = polygon[i + 2]
    a = hypot(A[0] - B[0], A[1] - B[1])
    b = hypot(A[0] - C[0], A[1] - C[1])
    c = hypot(C[0] - B[0], C[1] - B[1])
    z = (a + b + c) / 2
    S = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    ret += S
print ret

Submission status: Wrong Answer

Solution code:
from math import hypot

polygon = []
while 1:
    try:
        x, y = map(float, raw_input().split(','))
        polygon.append((x, y))
    except EOFError:
        break
polygon.sort()
A = polygon[0]
polygon = sorted(polygon[1:], key=lambda a: a[1])
ret = 0.0
for i in xrange(len(polygon) - 1):
    B = polygon[i]
    C = polygon[i + 1]
    a = hypot(A[0] - B[0], A[1] - B[1])
    b = hypot(A[0] - C[0], A[1] - C[1])
    c = hypot(C[0] - B[0], C[1] - B[1])
    z = (a + b + c) / 2
    S = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    ret += S
print ret

Submission status: Accepted

Solution code:
xlst = []
ylst = []
while True:
  try:
    x, y = map(float, input().split(","))
    xlst.append(x)
    ylst.append(y)
  except EOFError:
    break

num = len(xlst)
cx, cy = sum(xlst) / num, sum(ylst) / num

xlst.append(xlst[0])
ylst.append(ylst[0])
ans = 0
for i in range(num):
  x1, y1, x2, y2 = xlst[i], ylst[i], xlst[i + 1], ylst[i + 1]
  a = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** (1 / 2)
  b = ((x1 - cx) ** 2 + (y1 - cy) ** 2) ** (1 / 2)
  c = ((x2 - cx) ** 2 + (y2 - cy) ** 2) ** (1 / 2)
  z = (a + b + c) / 2
  s = (z * (z - a) * (z - b) * (z - c)) ** (1 / 2)
  ans += s 
print(ans)

Submission status: Accepted

Solution code:
import sys
from math import sqrt, hypot

def _hypot(p1, p2):
    return hypot(p2[0]-p1[0], p2[1]-p1[1])

def heron(p1, p2, p3):
    e1, e2, e3 = _hypot(p1, p2), _hypot(p2, p3), _hypot(p1, p3)
    z = (e1+e2+e3)/2
    return sqrt(z*(z-e1)*(z-e2)*(z-e3))

a = [tuple(map(float, l.split(","))) for l in sys.stdin]
result = 0
for p1, p2 in zip(a[1:], a[2:]):
    result += heron(a[0], p1, p2)
print(result)

Submission status: Accepted

Solution code:
import sys


def delta_s(p1,p2,p3):
    a = ( (p2[0]-p1[0])**2 + (p2[1]-p1[1])**2 )**0.5
    b = ( (p3[0]-p2[0])**2 + (p3[1]-p2[1])**2 )**0.5
    c = ( (p1[0]-p3[0])**2 + (p1[1]-p3[1])**2 )**0.5
    z = ( a+b+c )/2
    return (z*(z-a)*(z-b)*(z-c))**0.5
d = []

for s in sys.stdin:
    ds = map(float,s.split(","))
    d.append(ds)

d0 = d[0]
s = 0
for i in xrange(2,len(d)):
    s += delta_s(d[i],d[i-1],d0)
print s

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

def triangle_area(a, b, c):
    z = (a + b + c) / 2
    s = (z * (z - a) * (z - b) * (z - c)) ** 0.5
    return s

apexes = []
for line in f:
    x, y = map(float, line.split(','))
    apexes.append(x + y * 1j)

s = 0
for i in range(2,len(apexes)):
    s += triangle_area(abs(apexes[0] - apexes[i - 1]),abs(apexes[0] - apexes[i]),abs(apexes[i] - apexes[i - 1]))
print(s)

Submission status: Accepted

Solution code:
x,y,r,l,s=[],[],[],[],[]
while 1:
    try:
        a,b=map(float,raw_input().split(','))
        x.append(a)
        y.append(b)
    except:
        break
for i in range(len(x)-1):
    r.append(((x[i+1]-x[0])**2+(y[i+1]-y[0])**2)**0.5)
for i in range(1,len(x)-1):
    l.append(((x[i+1]-x[i])**2+(y[i+1]-y[i])**2)**0.5)
for i in range(len(x)-2):
    s.append((r[i]+r[i+1]+l[i])/2)
sum=0.0
for i in range(len(x)-2):
    sum+=(s[i]*(s[i]-r[i])*(s[i]-r[i+1])*(s[i]-l[i]))**0.5
print sum

Submission status: Accepted

Solution code:
def cross(x, y):
    return (x.conjugate() * y).imag

def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
    
    
import sys

p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))

print(area_polygon(p))

Submission status: Accepted

Solution code:
import math

def euclid_dis(c,d,a=0.0,b=0.0):
    return math.sqrt((c-a)**2.0+(d-b)**2.0)

def heron(a,b,c):
    z=(a+b+c)/2.0
    return math.sqrt(z*(z-a)*(z-b)*(z-c))

ans=0
xy=[]
while 1:
    try:
        xy.append(map(float,raw_input().split(",")))
    except:
        break

n=len(xy)

for i in xrange(2,n):
    a=euclid_dis(xy[(i-1)%n][0],xy[(i-1)%n][1],xy[0][0],xy[0][1])
    b=euclid_dis(xy[i%n][0],xy[i%n][1],xy[0][0],xy[0][1])
    c=euclid_dis(xy[i%n][0],xy[i%n][1],xy[(i-1)%n][0],xy[(i-1)%n][1])   
    ans+=heron(a,b,c)
print ans

Submission status: Accepted

Solution code:
x,y=map(float,input().split(','))
bx,by=map(float,input().split(','))
s=0
while 1:
    try:xx,yy=map(float,input().split(','))
    except:break
    a=(pow(bx - xx, 2) + pow(by - yy, 2))**0.5;
    b=(pow(x - bx, 2) + pow(y - by, 2))**0.5;
    c=(pow(x - xx, 2) + pow(y - yy, 2))**0.5;
    z=(a+b+c)/2
    s+=(z*(z - a)*(z - b)*(z - c))**0.5
    bx,by=xx,yy
print(s)

Submission status: Accepted

Solution code:
x,y=map(float,input().split(','))
bx,by=map(float,input().split(','))
s=0
while 1:
    try:xx,yy=map(float,input().split(','))
    except:break
    a=((bx-xx)**2+(by-yy)**2)**0.5;
    b=((x-bx)**2+(y-by)**2)**0.5;
    c=((x-xx)**2+(y-yy)**2)**0.5;
    z=(a+b+c)/2
    s+=(z*(z-a)*(z-b)*(z-c))**0.5
    bx,by=xx,yy
print(s)

Submission status: Accepted

Solution code:
import math
f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

px = [p.real for p in f]
ox = (max(px) + min(px)) / 2.0

py = [p.imag for p in f]
oy = (max(py) + min(py)) / 2.0

fo = ox + oy * 1j

ss = 0.0
for i in range(len(f)):
    if i == len(f)-1:
        j = 0
    else:
        j = i + 1
    a = abs(f[i]-fo)
    b = abs(f[j]-fo)
    c = abs(f[j]-f[i])
    z = (a + b + c) / 2.0
    s = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ss += s
print("%.6f" % ss)

Submission status: Accepted

Solution code:
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))
 
print(area_polygon(p))

Submission status: Accepted

Solution code:
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(complex(x, y))
 
print(abs(area_polygon(p)))

Submission status: Accepted

Solution code:
def cross(x, y):
    return (x.conjugate() * y).imag
 
def area_polygon(points):
    area = 0
    n = len(points)
    for i in range(n):
        area += cross(points[i], points[(i+1)%n])
    return area / 2
     
     
import sys
 
p = []
for line in sys.stdin:
    x, y = map(float, line.split(','))
    p.append(x+y*1j)
 
print(abs(area_polygon(p)))

Submission status: Accepted

Solution code:
import math
f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

ss = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    a = abs(f[i]-fo)
    b = abs(f[j]-fo)
    c = abs(f[j]-f[i])
    z = (a + b + c) / 2.0
    s = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ss += s
print("%.6f" % ss)

Submission status: Accepted

Solution code:
def op(u,v):
    return (complex.conjugate(u)*v).imag

f = []
while True:
    try:
        st = input().strip().split(',')
        x,y = list(map(float,st ))
        f.append(x + y*1j)
    except EOFError:
        break

s = 0.0
fo = f[0]
for j in range(2,len(f)):
    i = j - 1
    s += op(f[i]-fo,f[j]-fo)/2.0
print("%.6f" % abs(s))

Submission status: Accepted

Solution code:
import math
X = []
Y = []

def area(a,b,c):
    p = math.sqrt((X [a] - X [b]) ** 2 + (Y [a] - Y [b]) ** 2)
    q = math.sqrt((X [b] - X [c]) ** 2 + (Y [b] - Y [c]) ** 2)
    r = math.sqrt((X [c] - X [a]) ** 2 + (Y [c] - Y [a]) ** 2)
    z = (p + q + r) / 2
    return math.sqrt(z * (z - p) * (z - q) * (z - r))

while True:
    try:
        a,b = map(float,input().split(','))
        X.append(a)
        Y.append(b)
    except EOFError:
        break

ans = 0.0
for i in range(1,len(X) - 1):
    ans += area(0,i,i + 1)
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import os
import math

def length(v, w):
    x_diff = v[0] - w[0]
    y_diff = v[1] - w[1]
    return math.sqrt(x_diff ** 2 + y_diff ** 2)

X = []
Y = []
for s in sys.stdin:
    x, y = map(float, s.split(','))
    X.append(x)
    Y.append(y)

n = len(X)
answer = 0
for i in range(1, n-1):
    p0 = (X[0], Y[0])
    p1 = (X[i], Y[i])
    p2 = (X[i+1], Y[i+1])

    a = length(p0, p1)
    b = length(p1, p2)
    c = length(p2, p0)

    z = (a + b + c) / 2
    S = math.sqrt(z * (z - a) * (z - b) * (z - c))
    answer += S
print(answer)

Submission status: Accepted

Solution code:
# Aizu Problem 0079: Area of Polygon
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def poly_area(polygon, M):
    A = 0
    for i in range(M):
        x1, y1 = polygon[i][0], polygon[i][1]
        x2, y2 = polygon[(i+1)%M][0], polygon[(i+1)%M][1]
        A += (x1 * y2 - x2 * y1)
    return abs(A / 2)


poly = [[float(_) for _ in line.split(',')] for line in sys.stdin]
print("%.6f" % poly_area(poly, len(poly)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0079

"""
import sys
from math import sqrt, atan2, acos, sin, cos, hypot
from sys import stdin
input = stdin.readline


class Point(object):
    epsilon = 1e-10

    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Point(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Point(self.x / other, self.y / other)

    def __lt__(self, other):
        if self.x == other.x:
            return self.y < other.y
        else:
            return self.x < other.x

    def __eq__(self, other):
        from math import fabs
        if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
            return True
        else:
            return False

    def norm(self):
        return self.x * self.x + self.y * self.y

    def __abs__(self):
        return sqrt(self.norm())

    def ccw(self, p0, p1):
        # ??????2???(p0, p1)?????????????????????????????????????????¢????????????
        a = Vector(p1 - p0)
        b = Vector(self - p0)
        if Vector.cross(a, b) > Point.epsilon:
            return 1 # 'COUNTER_CLOCKWISE'
        elif Vector.cross(a, b) < -Point.epsilon:
            return -1 # 'CLOCKWISE'
        elif Vector.dot(a, b) < -Point.epsilon:
            return 2 # 'ONLINE_BACK'
        elif a.norm() < b.norm():
            return -2 # 'ONLINE_FRONT'
        else:
            return 0 # 'ON_SEGMENT'

    def project(self, s):
        # ??????(Point)????????????s??????????????????????????????????????§?¨?(?°???±)????±???????
        base = Vector(s.p2 - s.p1)
        a = Vector(self - s.p1)
        r = Vector.dot(a, base)
        r /= base.norm()
        return s.p1 + base * r

    def reflect(self, s):
        # ??????s???????§°?????¨?????????????????¨???????§°??????????????§?¨?(????°?)????±???????
        proj = self.project(s)
        return self + (proj - self)*2

    def distance(self, s):
        # ????????¨??????s????????¢????¨??????????
        if Vector.dot(s.p2-s.p1, self-s.p1) < 0.0:
            return abs(self - s.p1)
        if Vector.dot(s.p1-s.p2, self-s.p2) < 0.0:
            return abs(self - s.p2)
        return abs(Vector.cross(s.p2-s.p1, self-s.p1) / abs(s.p2-s.p1))


class Vector(Point):
    def __init__(self, x=0.0, y=0.0):
        if isinstance(x, tuple):
            self.x = x[0]
            self.y = x[1]
        elif isinstance(x, Point):
            self.x = x.x
            self.y = x.y
        else:
            self.x = x
            self.y = y

    # ????????????
    def __add__(self, other):
        return Vector(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector(self.x - other.x, self.y - other.y)

    def __mul__(self, other):
        return Vector(other * self.x, other * self.y)

    def __truediv__(self, other):
        return Vector(self.x / other, self.y / other)

    @classmethod
    def dot(cls, a, b):
        return a.x * b.x + a.y * b.y

    @classmethod
    def cross(cls, a, b):
        return a.x * b.y - a.y * b.x

    @classmethod
    def is_orthogonal(cls, a, b):
        return abs(Vector.dot(a, b)) < Vector.epsilon

    @classmethod
    def is_parallel(cls, a, b):
        return abs(Vector.cross(a, b)) < Vector.epsilon


class Segment(object):
    def __init__(self, p1=Point(), p2=Point()):
        if isinstance(p1, Point):
            self.p1 = p1
            self.p2 = p2
        elif isinstance(p1, tuple):
            self.p1 = Point(p1[0], p1[1])
            self.p2 = Point(p2[0], p2[1])

    def intersect(self, s):
        # ????????¨??????????????????????????????????????????????????????
        ans1 = s.p1.ccw(self.p1, self.p2) * s.p2.ccw(self.p1, self.p2)
        ans2 = self.p1.ccw(s.p1, s.p2) * self.p2.ccw(s.p1, s.p2)
        return ans1 <= 0 and ans2 <= 0

    def cross_point(self, s):
        # ????????¨??????????????????????????????????????§?¨?????±???????
        base = s.p2 - s.p1
        d1 = abs(Vector.cross(base, self.p1-s.p1))
        d2 = abs(Vector.cross(base, self.p2-s.p1))
        t = d1 / (d1 + d2)
        return self.p1 + (self.p2 - self.p1) * t

    def distance(self, s):
        # ????????¨?????????????????????????????¢????±???????
        if self.intersect(s):
            return 0.0
        d1 = s.p1.distance(self)
        d2 = s.p2.distance(self)
        d3 = self.p1.distance(s)
        d4 = self.p2.distance(s)
        return min(d1, d2, d3, d4)


    @classmethod
    def is_orthogonal(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_orthogonal(a, b)

    @classmethod
    def is_parallel(cls, s1, s2):
        a = Vector(s1.p2 - s1.p1)
        b = Vector(s2.p2 - s2.p1)
        return Vector.is_parallel(a, b)


class Line(Segment):
    pass


class Cirle(object):
    def __init__(self, x, y=Point(), r=1.0):
        if isinstance(x, Point):
            self.c = x
            self.r = y
        elif isinstance(x, tuple):
            self.c = Point(x[0], x[1])
            self.r = r

    def cross_points(self, s):
        if isinstance(s, Segment):
            pr = self.c.project(s)
            e = (s.p2 - s.p1) / abs(s.p2 - s.p1)
            base = sqrt(self.r * self.r - (pr - self.c).norm())
            return pr + e * base, pr - e * base
        elif isinstance(s, Cirle):
            c2 = s
            d = abs(self.c - c2.c)
            a = acos((self.r * self.r + d * d - c2.r * c2.r) / (2 * self.r * d))
            t = atan2(c2.c.y - self.c.y, c2.c.x - self.c.x)
            temp1 = Point(cos(t+a)*self.r, sin(t+a)*self.r)
            temp2 = Point(cos(t-a)*self.r, sin(t-a)*self.r)
            return self.c + temp1, self.c + temp2

class Triangle(object):
    def __init__(self, p1, p2, p3):
        self.p1 = p1
        self.p2 = p2
        self.p3 = p3

    def length(self):
        l1 = hypot(self.p1.x-self.p2.x, self.p1.y-self.p2.y)
        l2 = hypot(self.p2.x-self.p3.x, self.p2.y-self.p3.y)
        l3 = hypot(self.p3.x-self.p1.x, self.p3.y-self.p1.y)
        return l1, l2, l3

    def area(self):
        a, b, c = self.length()
        z = (a+b+c) / 2.0
        return sqrt(z * (z-a)*(z-b)*(z-c))



def main(args):
    points = []
    for line in sys.stdin:
        x, y = map(float, line.split(','))
        points.append(Point(x, y))

    area = 0.0
    p1 = points[0]
    points = points[1:]
    while len(points) > 1:
        p2 = points[0]
        p3 = points[1]
        t = Triangle(p1, p2, p3)
        area += t.area()
        points = points[1:]
    print('{:.8f}'.format(area))


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
import math

def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
x0,y0 = [float(i) for i in N[0].split(",")]
ans = 0.0
for l in range(2,len(N)):
    x1, y1 = [float(i) for i in N[l-1].split(",")]
    x2, y2 = [float(i) for i in N[l].split(",")]
    a = math.sqrt((x1-x0)**2 + (y1-y0)**2)
    b = math.sqrt((x2-x1)**2 + (y2-y1)**2)
    c = math.sqrt((x2-x0)**2 + (y2-y0)**2)
    z = (a+b+c)/2.0
    S = math.sqrt(z*(z-a)*(z-b)*(z-c))
    ans += S
print(ans)

Submission status: Accepted

Solution code:
import math

def calc_d(a, b):
    return math.sqrt((a[0] - b[0])**2 + (a[1] - b[1])**2)

p = []
while True:
    try:
        p.append(list(map(float, input().split(","))))
    except:
        break

n = len(p)
s = 0
for i in range(1, n - 1):
    a = calc_d(p[0], p[i])
    b = calc_d(p[0], p[i+1])
    c = calc_d(p[i], p[i+1])
    z = (a + b + c)/2
    s += math.sqrt(z*(z - a)*(z - b)*(z - c))
print(s)

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
for i in range(len(p)-2):
 a,b=p[i+1];c,d=p[i+2]
 s+=((a-x)*(d-y)-(b-y)*(c-x))/2
print(abs(s))

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
for i in range(len(p)-2):
 a,b=p[i+1];c,d=p[i+2]
 s+=(a*d-b*c+(b-d)*x+(c-a)*y)/2
print(abs(s))

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
print(abs(sum((p[i][0]-x)*(p[i+1][1]-y)-(p[i][1]-y)*(p[i+1][0]-x)for i in range(1,len(p)-1)))/2)

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
x,y=p[0]
for i in range(len(p)-2):a,b=p[i+1];c,d=p[i+2];s+=(a-x)*(d-y)-(b-y)*(c-x)
print(abs(s)/2)

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
n=len(p)
for i in range(n):a,b=p[i];c,d=p[-~i%n];s+=a*d-b*c
print(s/2)

##      abs abs

Submission status: Accepted

Solution code:
import sys
s=0
p=[list(map(float,e.split(',')))for e in sys.stdin]
n=len(p)
for i in range(n):a,b=p[i];c,d=p[-~i%n];s+=a*d-b*c
print(abs(s)/2)

Submission status: Accepted

Solution code:
import sys,math

l=[list(map(float,i.split(","))) for i in sys.stdin]
S=0
for (i,j) in enumerate(l):
    xn,yn=j
    if i!=len(l)-1:
        xn_1,yn_1=l[i+1]
    else:
        xn_1,yn_1=l[0]
    a=math.sqrt(xn**2+yn**2)
    b=math.sqrt(xn_1**2+yn_1**2)
    c=math.sqrt((xn_1-xn)**2+(yn_1-yn)**2)
    z=(a+b+c)/2
    S+=math.sqrt(z*(z-a)*(z-b)*(z-c))
print(S)

Submission status: Accepted

Solution code:
# AOJ 0079 Area of Polygon
# Python3 2018.6.17 bal4u

def calc_area(p):
	n, s = len(p), 0
	p.append(p[0])
	for i in range(n):
		s += (p[i].real-p[i+1].real)*(p[i].imag+p[i+1].imag)
	return abs(s)/2

p = []
while True:
	try: x, y = list(map(float, input().split(',')))
	except EOFError: break
	p.append(complex(x, y))
print(calc_area(p))

Submission status: Accepted

Solution code:
vertices = []
for _ in range(20):
    try:
        vertices.append([float(x) for x in input().split(',')])
    except:
        break
n = len(vertices)

def dist(p,q):
    return ((p[0]-q[0])**2 + (p[1]-q[1])**2)**0.5

def area(p,q,r):
    a = dist(p,q)
    b = dist(q,r)
    c = dist(r,p)
    z = (a+b+c)/2
    return (z*(z-a)*(z-b)*(z-c))**0.5

S = 0
for i in range(1,n-1):
    S += area(vertices[0],vertices[i],vertices[i+1])

print(S)

Submission status: Accepted

Solution code:
import sys
p=[map(float,line.strip().split(","))  for line in sys.stdin.readlines()]
print abs(sum([p[i-1][0]*p[i][1]-p[i][0]*p[i-1][1] for i in xrange(len(p))]))/2.0

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from math import hypot, sqrt

vertexs = []
for line in stdin:
    vertexs.append(tuple(float(s) for s in line.split(',')))

s = 0.0
x0, y0 = vertexs[0]
for i in range(1, len(vertexs)-1):
    x1, y1 = vertexs[i]
    x2, y2 = vertexs[i+1]

    a = hypot(x0 - x1, y0 - y1)
    b = hypot(x1 - x2, y1 - y2)
    c = hypot(x2 - x0, y2 - y0)
    z = (a + b + c) / 2.0
    s += sqrt(z * (z-a) * (z-b) * (z-c))
print('{:.6f}'.format(s))

Submission status: Accepted

Solution code:
import math
x, y, r, l, s = [], [], [], [], []
while True:
    try:
        a, b = map(float, raw_input().split(","))
        x.append(a); y.append(b)
    except:
        break
    
for i in range(len(x)-1):
    r.append(math.sqrt((x[i+1] - x[0])**2 + (y[i+1] - y[0])**2))
for i in range(1,len(x)-1):
    l.append(math.sqrt((x[i+1] - x[i])**2 + (y[i+1] - y[i])**2))
for i in range(len(x)-2):
    s.append((r[i]+r[i+1]+l[i])/2)

sum = 0.0
for i in range(len(x)-2):
    sum += math.sqrt(s[i]*(s[i]-r[i])*(s[i]-r[i+1])*(s[i]-l[i]))
    
print sum

Submission status: Accepted

Solution code:
import sys,cmath,math
c=[]
for s in sys.stdin:
    x,y=map(float,s[:-1].split(","))
    c+=[complex(x,y)]
c0=c[0]
c1=c[1]
r1,a1=cmath.polar(c1-c0)
s=0
for e in c[2:]:
    r2,a2=cmath.polar(e-c0)
    s+=r1*r2*math.sin(abs(a1-a2))/2
    r1,a1=r2,a2
print s

Submission status: Accepted

Solution code:
import sys
c=[map(float,s[:-1].split(",")) for s in sys.stdin]
x0,y0=c[0]
x1,y1=c[1][0]-x0,c[1][1]-y0
s=0
for ex,ey in c[2:]:
    x2,y2=ex-x0,ey-y0
    s+=abs(x1*y2-x2*y1)
    x1,y1=x2,y2
print s/2

Submission status: Accepted

Solution code:
import sys
x0,y0=map(float,raw_input()[:-1].split(","))
x1,y1=map(float,raw_input()[:-1].split(","))
x1,y1=x1-x0,y1-y0
s=0
for e in sys.stdin:
    ex,ey=map(float,e[:-1].split(","))
    x2,y2=ex-x0,ey-y0
    s+=abs(x1*y2-x2*y1)
    x1,y1=x2,y2
print s/2

Submission status: Accepted

Solution code:
import sys
s=0
i=0
for e in sys.stdin:
    ex,ey=map(float,e[:-1].split(","))
    if i==0:x0,y0=ex,ey
    elif i==1:x1,y1=ex-x0,ey-y0
    else: 
        x2,y2=ex-x0,ey-y0
        s+=abs(x1*y2-x2*y1)
        x1,y1=x2,y2
    i+=1
print s/2

Submission status: Accepted

Solution code:
import sys
x=[map(float,s[:-1].split(",")) for s in sys.stdin]
x=[x[-1]]+x
s=[x[i][0]*x[i+1][1]-x[i][1]*x[i+1][0] for i in range(len(x)-1)]
print abs(sum(s))/2

Submission status: Accepted

Solution code:
import sys
x=[map(float,s[:-1].split(",")) for s in sys.stdin]
s=[x[i][0]*x[i-1][1]-x[i][1]*x[i-1][0] for i in range(len(x))]
print abs(sum(s))/2

Submission status: Accepted

Solution code:
i = 0
x = []
y = []
while 1:
    try:
        a,b = map(float,input().split(","))
        x.append(a)
        y.append(b)
    except EOFError:
        break

S = 0
for i in range(len(x)-2):
    a = ((x[0]-x[i+1]) ** 2 + (y[0]-y[i+1]) ** 2) ** 0.5
    b = ((x[0]-x[i+2]) ** 2 + (y[0]-y[i+2]) ** 2) ** 0.5
    c = ((x[i+1]-x[i+2]) ** 2 + (y[i+1]-y[i+2]) ** 2) ** 0.5
    z = (a + b + c)/2
    S += (z * (z - a) * (z - b) * (z - c)) ** 0.5
print(S)

Submission status: Accepted

Solution code:
n = 0
S = 0
xylst = []
while True:
    try:
        x, y = map(float, input().split(','))
        xylst.append([x,y])
        n += 1


    except EOFError:
        break


for i in range(-1, n-1):
    S = S + abs(xylst[i][0]*xylst[i+1][1] - xylst[i][1]*xylst[i+1][0])/2

print(S)

Submission status: Accepted

Solution code:
import cmath
import math

P = []
try:
    while True:
        # print("Hello!")
        x, y = map(float,input().split(","))
        P.append(complex(x,y))  
except  EOFError:
    pass

# def dot_product(a,b):
#     return (a.conjugate()*b).real
def cross_product(a,b):
    return (a.conjugate()*b).imag

N = len(P)
total = 0.0
for i in range(1,N-1):
    a, b, c = P[0], P[i], P[i+1]
    total += 0.5 * (cross_product(P[i]-P[0], P[i+1]-P[0]))

print("%.6f" % (abs(total)))

Submission status: Accepted

Solution code:

p= []
try:
    while True:
        x,y = map(float,input().split(",")) 
        p.append(complex(x,y))
except EOFError: 
    pass


n=len(p)
sum=0.0
for i in range(1,n-1):
    a,b= p[i]-p[0], p[i+1]-p[0]
    s= (a.conjugate()* b).imag
    sum+= s
print("%.6f" % (abs(sum)/2.0))

Submission status: Accepted

Solution code:
a = []
try:
    while True:
        x, y = map(float, input().split(","))
        a.append(complex(x, y))
except EOFError:
    pass
n = len(a)
ans = 0.0
p = a[0]
for i in range(n - 2):
    q, r = a[i + 1], a[i + 2]
    ans += (((q - p).conjugate() * (r - p)).imag) / 2
print(abs(ans))

Submission status: Accepted

Solution code:
def cross_product(a,b):
  return (a.conjugate()*b).imag
P = [] #頂点列
try:
    while True:
        x,y = map(float,input().split(','))
        P.append(complex(x,y))
except EOFError:
    pass
N=len(P)#頂点の個数
total = 0.0
for i in range(1,N-1):
    a,b,c = P[0],P[i],P[i+1]
    total += cross_product(b-a,c-a)
print("%.6f" % (abs(total)/2.0))

Submission status: Accepted

Solution code:
import math
import cmath
def dot(a:complex,b:complex):
  return (a.conjugate()*b).real
def cross(a:complex,b:complex):
  return (a.conjugate()*b).imag
p=[]
try:
  while True:
    x,y=map(float,input().split(','))
    p.append(complex(x,y))
except EOFError:
  pass
S=0
for i in range(1,len(p)-1):
  S+=cross(p[i]-p[0],p[i+1]-p[0])
print(abs(S)/2)

Submission status: Accepted

Solution code:
import math
def angle(i1, j1, i2, j2, i3, j3) :
    a = math.sqrt((i1-i2)**2 + (j1-j2)**2)
    b = math.sqrt((i2-i3)**2 + (j2-j3)**2)
    c = math.sqrt((i3-i1)**2 + (j3-j1)**2)
    z = (a+b+c) / 2
    S = math.sqrt(z * (z-a) * (z-b) * (z-c))
    return S

ans = 0
x1, y1 = map(float, input().split(","))
x2, y2 = map(float, input().split(","))
while True :
    try :
        x3, y3 = map(float, input().split(","))
    except EOFError :
        break
    
    ans += angle(x1, y1, x2, y2, x3, y3)
    x2 = x3
    y2 = y3
    
print('{:.6f}'.format(ans))