Problem:
Is-Convex For a given polygon g , print "1" if g is a convex polygon, "0" otherwise. Here, in a convex polygon, all interior angles are less than or equal to 180 degrees.  g is represented by a sequence of points p 1 , p 2 ,..., p n where line segments connecting p i and p i+1 (1 ≤ i ≤ n-1 ) are sides of the polygon. The line segment connecting p n and p 1 is also a side of the polygon. Input  g is given by coordinates of the points p 1 ,..., p n in the following format:  n  x 1  y 1  x 2  y 2 : x n  y n  The first integer n is the number of points. The coordinate of a point p i is given by two integers x i and y i . The coordinates of points are given in the order of counter-clockwise visit of them. Output Print "1" or "0" in a line. Constraints  3 ≤ n ≤ 100  -10000 ≤ x i , y i ≤ 10000  No point of the polygon will occur more than once.  Two sides of the polygon can intersect only at a common endpoint.  Sample Input 1 4
0 0
3 1
2 3
0 3 Sample Output 1 1 Sample Input 2 5
0 0
2 0 
1 1
2 2
0 2 Sample Output 2 0

Solution (Python):
from sys import stdin
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def is_convex(p):
    for i in range(len(p)):
        j, k = i - 1, i - 2
        if 0 > cross(p[j] - p[k], p[i] - p[k]):
            return False
    return True

n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]
print(1 if is_convex(p) else 0)

Solution (Python):
n = int(input())
points = [complex(*map(int, input().split())) for _ in range(n)]
edges = [p1 - p0 for p0, p1 in zip(points, points[1:] + [points[0]])]
prev = edges[0]
while edges:
    edge = edges.pop()
    if edge.real * prev.imag - prev.real * edge.imag < -1e-6:
        print(0)
        break
    prev = edge
else:
    print(1)

Solution (Python):
n = input()
p = [map(int, raw_input().split()) for i in xrange(n)]
for i in xrange(n):
    x1 = p[i-1][0] - p[i-2][0]
    y1 = p[i-1][1] - p[i-2][1]
    x2 = p[i][0] - p[i-2][0]
    y2 = p[i][1] - p[i-2][1]
    if x1*y2 - y1*x2 < 0:
        print 0
        break
else:
    print 1

Solution (Python):
n = int(raw_input())
S = float(0)
x = []
y = []
for _ in range(n):
  xi,yi = map(float, raw_input().split())
  x.append(xi)
  y.append(yi)
result = True
for i in range(n):
  ax = x[(i+1) % n] - x[i % n]
  ay = y[(i+1) % n] - y[i % n]
  bx = x[(i+2) % n] - x[(i+1) % n]
  by = y[(i+2) % n] - y[(i+1) % n]
  outer = (ax * by - bx * ay)
  if outer < 0:
    result = False
    break
if result:
  print "1"
else:
  print "0"

Solution (Python):
n=int(input())
p=[complex(*map(int,input().split())) for _ in range(n)]
e=[b-a for a,b in zip(p,p[1:]+[p[0]])]
p=e[0]
for i in range(1,n,):
    now=e[-i]
    if now.real*p.imag-p.real*now.imag<-1e-6:print(0);break
    p=now
else: print(1)

Solution (Python):
def cross(a,b):return a[0]*b[1] - a[1]*b[0]
def dif(a,b):return [x-y for x,y in zip(a,b)]

x = range(int(input()))
t = 1
P,Q = [],[]
for _ in x:P+=[[int(i) for i in input().split()]]
for i in x:Q+=[dif(P[i],P[i-1])]
for i in x:
    if cross(Q[i-1],Q[i]) < 0: t *= False
print(t)

Solution (Python):


import sys, math, os


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


def is_convex(P):
    
    
    N = len(P)
    prods = []
    for k in range(N):
        x0, y0 = P[k]
        x1, y1 = P[(k + 1) % N]
        x2, y2 = P[(k + 2) % N]
        dx1 = x1 - x0
        dy1 = y1 - y0
        dx2 = x2 - x1
        dy2 = y2 - y1
        cross = dx1 * dy2 - dy1 * dx2
        prods.append(cross)
    prods = sorted(prods)
    return prods[0] * prods[-1] >= 0


N = int(input())
P = [[int(_) for _ in input().split()] for __ in range(N)]
print(1 if is_convex(P) else 0)

Solution (Python):
import math

class Point():
    def __init__(self, x=None, y=None):
        self.x = x
        self.y = y

class Vector():
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def inner_product(self, vec):
        return self.x*vec.x + self.y*vec.y

    def outer_product(self, vec):
        return self.x*vec.y - self.y*vec.x

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

n = int(input())
points = []
for i in range(n):
    x, y = list(map(int, input().split(' ')))
    points.append(Point(x, y))
points.extend(points[0:2])

is_convex = True
for i in range(1, n+1):
    a, b, c = points[i-1:i+2]
    vec1, vec2 = Vector(a.x - b.x, a.y - b.y), Vector(c.x - b.x, c.y - b.y)
    theta = math.degrees(math.atan2(vec2.outer_product(vec1), vec2.inner_product(vec1)))
    if theta < 0:
        is_convex = False
        break

if is_convex:
    print(1)
else:
    print(0)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def det(a,b):
        return a[0]*b[1]-a[1]*b[0]

    def minus(a,b):
        return (a[0]-b[0],a[1]-b[1])

    def convex_hull(ps):
        n = len(ps)
        ps.sort()
        k = 0
        qs = [0]*(n+2)
        for i in range(n):
            while k > 1 and det(minus(qs[k-1], qs[k-2]), minus(ps[i], qs[k-1])) < 0:
                k -= 1
            qs[k] = ps[i]
            k += 1
        t = k
        for i in range(n-1)[::-1]:
            while k > t and det(minus(qs[k-1], qs[k-2]), minus(ps[i], qs[k-1])) < 0:
                k -= 1
            qs[k] = ps[i]
            k += 1
        qs = qs[:min(n,k-1)]
        return qs
    n = I()
    ps = LIR(n)
    qs = convex_hull(ps)
    if len(qs) == n:
        print(1)
    else:
        print(0)
    return


if __name__ == "__main__":
    solve()

Solution (Python):
from math import pi, cos, sin, atan2
from operator import itemgetter
EPS = 10**(-9)

def eq(value1, value2):
    return abs(value1-value2) <= EPS

class Point():
    def __init__(self, x, y):
        self.x = x
        self.y = y
    
    def __str__(self):
        
        return "{0} {1}".format(self.x, self.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, scal):
        return Point(self.x*scal, self.y*scal)
    
    def __truediv__(self, scal):
        return Point(self.x/scal, self.y/scal)
    
    def __eq__(self, other):
        return eq(self.x, other.x) and eq(self.y, other.y)

    
    def __abs__(self):
        return (self.x**2+self.y**2)**0.5

    def arg(self):
        return atan2(self.y, self.x)
    

def Rotation(vec: Point, rad):
    return Point(vec.x*cos(rad)-vec.y*sin(rad), vec.x*sin(rad)+vec.y*cos(rad))


class Circle():
    def __init__(self, p, r):
        self.p = p
        self.r = r


class Line():
    
    def __init__(self, a, b):
        self.a = a
        self.b = b
    
    def __str__(self):
        return "[({0}, {1}) - ({2}, {3})]".format(self.a.x, self.a.y, self.b.x, self.b.y)
    
    def arg(self):
        return (a-b).arg() % pi

    
    def par(self, point):
        return Line(point, point+(self.a-self.b))

    
    def tan(self, point):
        return Line(point, point + Rotation(self.a-self.b, pi/2))


class Segment(Line):
    def __init__(self, a, b):
        super().__init__(a, b)



def cross(vec1: Point, vec2: Point):
    return vec1.x*vec2.y - vec1.y*vec2.x


def dot(vec1: Point, vec2: Point):
    return vec1.x*vec2.x + vec1.y*vec2.y


def ccw(a, b, c):
    if cross(b-a, c-a) > EPS: return +1 
    if cross(b-a, c-a) < -EPS: return -1 
    if dot(c-a, b-a) < -EPS: return +2 
    if abs(b-a) < abs(c-a): return -2 
    return 0 



def projection(l, p):
    t = dot(l.b-l.a, p-l.a) / abs(l.a-l.b)**2
    return l.a + (l.b-l.a)*t


def reflection(l, p):
    return p + (projection(l, p) - p)*2

def isPararell(l1, l2):
    return eq(cross(l1.a-l1.b, l2.a-l2.b), 0)

def isVertical(l1, l2):
    return eq(dot(l1.a-l1.b, l2.a-l2.b), 0)


def Intersect_lp(l, p):
    return abs(ccw(l.a, l.b, p)) != 1

def Intersect_ll(l1, l2):
    return not isPararell(l1, l2) or Intersect_lp(l1, l2.a)

def Intersect_sp(s, p):
    return ccw(s.a, s.b, p) == 0

def Intersect_ss(s1, s2):
    return ccw(s1.a, s1.b, s2.a)*ccw(s1.a, s1.b, s2.b) <= 0 and ccw(s2.a, s2.b, s1.a)*ccw(s2.a, s2.b, s1.b) <= 0

def Intersect_ls(l, s):
    return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS

def Intersect_cp(c, p):
    return abs(abs(c.p - p) - c.r) < EPS

def Intersect_cl(c, l):
    return distance_lp(l, c.p) <= c.r + EPS

def Intersect_cs(c, s):
    h = projection(s, c.p)
    if abs(h - c.p)**2 - c.r**2 > EPS: return 0 
    d1 = abs(c.p - s.a); d2 = abs(c.p - s.b)
    if d1 < c.r - EPS and d2 < c.r - EPS: return 0 
    if (d1 < c.r - EPS and d2 > c.r + EPS) or (d1 > c.r + EPS and d2 < c.r - EPS): return 1 
    if dot(s.a-h, s.b-h) < 0: return 2 
    return 0


def Intersect_cc(c1, c2):
    if c1.r < c2.r:
        c1, c2 = c2, c1
    d = abs(c1.p - c2.p)
    if eq(c1.r + c2.r, d): return 3 
    if eq(c1.r - c2.r, d): return 1 
    if c1.r + c2.r < d: return 4 
    if c1.r - c2.r < d: return 2 
    return 0 


def distance_pp(p1, p2):
    return abs(p1-p2)

def distance_lp(l, p):
    return abs(projection(l,p)-p)

def distance_ll(l1, l2):
    return 0 if Intersect_ll(l1, l2) else distance_lp(l1, l2.a)

def distance_sp(s, p):
    r = projection(s, p)
    if Intersect_sp(s, r): return abs(r-p)
    return min(abs(s.a-p), abs(s.b-p))

def distance_ss(s1, s2):
    if Intersect_ss(s1, s2): return 0
    return min([distance_sp(s1, s2.a), distance_sp(s1, s2.b), distance_sp(s2, s1.a), distance_sp(s2, s1.b)])

def distance_ls(l, s):
    if Intersect_ls(l, s): return 0
    return min(distance_lp(l, s.a), distance_lp(l, s.b))


def crosspoint_ll(l1, l2):
    A = cross(l1.b - l1.a, l2.b - l2.a)
    B = cross(l1.b - l1.a, l1.b - l2.a)
    if eq(abs(A), 0) and eq(abs(B), 0): return l2.a
    return l2.a + (l2.b - l2.a) * B / A

def crosspoint_ss(s1, s2):
    return crosspoint_ll(s1, s2)

def crosspoint_lc(l, c):
    p = projection(l, c.p)
    if eq(distance_lp(l, c.p), c.r): return [p]
    e = (l.b - l.a) / abs(l.b-l.a)
    dis = (c.r**2-abs(p-c.p)**2)**0.5
    return [p + e*dis, p - e*dis]

def crosspoint_sc(s, c):
    l = Line(s.a, s.b)
    if Intersect_cs(c, s) == 2: return crosspoint_lc(l, c)
    Points = crosspoint_lc(l, c)
    if len(Points) == 1:
        return Points
    if dot(s.a-Points[0], s.b-Points[0]) < 0: return [Points[0]]
    return [Points[1]]


def crosspoint_cc(c1, c2):
    d = abs(c1.p-c2.p)
    if not abs(c1.r-c2.r) <= d <= c1.r+c2.r:
        return []
    mid_p = (c2.p * (c1.r**2-c2.r**2+d**2) + c1.p * (c2.r**2-c1.r**2+d**2)) / (2*d**2)
    tanvec = Rotation(c1.p-c2.p, pi/2)
    return crosspoint_lc(Line(mid_p, mid_p+tanvec), c1)



def tangent_cp(c, p):
    return crosspoint_cc(c, Circle(p, (abs(p-c.p)**2 - c.r**2)**0.5))


def tangent_cc(c1, c2):
    pass


def isConvex(Points):
    n = len(Points)
    for i in range(n):
        if ccw(Points[i-1], Points[i], Points[(i+1)%n]) == -1: return False
    return True


def ConvexHull(Points):
    Points.sort(key=lambda p: p.y)
    Points.sort(key=lambda p: p.x)

    Qs = []
    for p in Points:
        while len(Qs) > 1 and ccw(Qs[-2], Qs[-1], p) == -1:
            Qs.pop()
        Qs.append(p)
        
    t = len(Qs)
    Qs.pop()
    for p in reversed(Points):
        while len(Qs) > t and ccw(Qs[-2], Qs[-1], p) == -1:
            Qs.pop()
        Qs.append(p)
    Qs.pop()

    return Qs


import sys
input = sys.stdin.readline

def verify_1A():
    p1x, p1y, p2x, p2y = map(int, input().split())
    l = Line(Point(p1x, p1y), Point(p2x, p2y))
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        print(projection(l, p))

def verify_1B():
    p1x, p1y, p2x, p2y = map(int, input().split())
    l = Line(Point(p1x, p1y), Point(p2x, p2y))
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        print(reflection(l, p))

def verify_1C():
    p1x, p1y, p2x, p2y = map(int, input().split())
    p1 = Point(p1x, p1y); p2 = Point(p2x, p2y)
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for px, py in Query:
        p = Point(px, py)
        result = ccw(p1, p2, p)
        if result == 1:
            print("COUNTER_CLOCKWISE")
        elif result == -1:
            print("CLOCKWISE")
        elif result == 2:
            print("ONLINE_BACK")
        elif result == -2:
            print("ONLINE_FRONT")
        else:
            print("ON_SEGMENT")

def verify_2A():
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y in Query:
        l1 = Line(Point(p0x, p0y), Point(p1x, p1y))
        l2 = Line(Point(p2x, p2y), Point(p3x, p3y))
        if isPararell(l1, l2):
            print(2)
        elif isVertical(l1, l2):
            print(1)
        else:
            print(0)

def verify_2B():
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y in Query:
        s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
        s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
        if Intersect_ss(s1, s2):
            print(1)
        else:
            print(0)


def verify_2C():
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y in Query:
        s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
        s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
        print(crosspoint_ss(s1, s2))  

def verify_2D():
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y in Query:
        s1 = Segment(Point(p0x, p0y), Point(p1x, p1y))
        s2 = Segment(Point(p2x, p2y), Point(p3x, p3y))
        print("{:.8f}".format(distance_ss(s1, s2)))

def verify_3B():
    Q = int(input())
    Points = [Point(*map(int, input().split())) for _ in range(Q)]
    print(1 if isConvex(Points) else 0)

verify_3B()

def verify_4A():
    Q = int(input())
    Points = [Point(*map(int, input().split())) for _ in range(Q)]
    Qs = ConvexHull(Points)
    min_y = 10**10
    min_x = 10**10
    for i, p in enumerate(Qs):
        if p.y < min_y:
            min_y = p.y
            min_x = p.x
            min_ind = i
        elif p.y == min_y and p.x < min_x:
            min_x = p.x
            min_ind = i
    Qs = Qs[min_ind:] + Qs[:min_ind]
    print(len(Qs))
    print("\n".join([str(p.x) + " " + str(p.y) for p in Qs]))

def verify_7A():
    c1x, c1y, c1r = map(int, input().split())
    c2x, c2y, c2r = map(int, input().split())
    print(Intersect_cc(Circle(Point(c1x, c1y), c1r), Circle(Point(c2x, c2y), c2r)))

def verify_7D():
    cx, cy, cr = map(int, input().split())
    c = Circle(Point(cx, cy), cr)
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    for x1, y1, x2, y2 in Query:
        Points = crosspoint_lc(Line(Point(x1, y1), Point(x2,y2)), c)
        if len(Points) == 1:
            Points.append(Points[-1])
        Points.sort(key=lambda p: p.y)
        Points.sort(key=lambda p: p.x)
        print(*Points)

def verify_7E():
    c1x, c1y, c1r = map(int, input().split())
    c1 = Circle(Point(c1x, c1y), c1r)
    c2x, c2y, c2r = map(int, input().split())
    c2 = Circle(Point(c2x, c2y), c2r)

    Points = crosspoint_cc(c1, c2)
    if len(Points) == 1:
        Points.append(Points[-1])
    Points.sort(key=lambda p: p.y)
    Points.sort(key=lambda p: p.x)
    print(*Points)  

def verify_7F():
    px, py = map(int, input().split())
    cx, cy, cr = map(int, input().split())
    Points = tangent_cp(Circle(Point(cx, cy), cr), Point(px, py))
    if len(Points) == 1:
        Points.append(Points[-1])
    Points.sort(key=lambda p: p.y)
    Points.sort(key=lambda p: p.x)
    print(*Points, sep="\n")

Solution (Python):
def cross(a,b):
  return a.real*b.imag-a.imag*b.real

n=int(input())

A=[]
for _ in range(n):
  x,y=map(int,input().split())
  A.append(x+y*1j)

flag=0
for i in range(n-1):
  for j in range(i+1,n):
    if cross(A[i]-A[i-1],A[j]-A[i-1])<0 or cross(A[i+1]-A[i],A[j]-A[i])<0:
      print("0")
      flag=1
      break
  if(flag==1):
    break

if(flag==0):
  print("1")

Solution (Python):
import cmath
import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


PI = cmath.pi
TAU = cmath.pi * 2
EPS = 1e-8


class Point:
    """
    2次元空間上の点
    """

    
    CCW_COUNTER_CLOCKWISE = 1
    
    CCW_CLOCKWISE = -1
    
    CCW_ONLINE_BACK = 2
    
    CCW_ONLINE_FRONT = -2
    
    CCW_ON_SEGMENT = 0

    def __init__(self, c: complex):
        self.c = c

    @property
    def x(self):
        return self.c.real

    @property
    def y(self):
        return self.c.imag

    @staticmethod
    def from_rect(x: float, y: float):
        return Point(complex(x, y))

    @staticmethod
    def from_polar(r: float, phi: float):
        return Point(cmath.rect(r, phi))

    def __add__(self, p):
        """
        :param Point p:
        """
        return Point(self.c + p.c)

    def __iadd__(self, p):
        """
        :param Point p:
        """
        self.c += p.c
        return self

    def __sub__(self, p):
        """
        :param Point p:
        """
        return Point(self.c - p.c)

    def __isub__(self, p):
        """
        :param Point p:
        """
        self.c -= p.c
        return self

    def __mul__(self, f: float):
        return Point(self.c * f)

    def __imul__(self, f: float):
        self.c *= f
        return self

    def __truediv__(self, f: float):
        return Point(self.c / f)

    def __itruediv__(self, f: float):
        self.c /= f
        return self

    def __repr__(self):
        return "({}, {})".format(round(self.x, 10), round(self.y, 10))

    def __neg__(self):
        return Point(-self.c)

    def __eq__(self, p):
        return abs(self.c - p.c) < EPS

    def __abs__(self):
        return abs(self.c)

    @staticmethod
    def ccw(a, b, c):
        """
        線分 ab に対する c の位置
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
        :param Point a:
        :param Point b:
        :param Point c:
        """
        b = b - a
        c = c - a
        det = b.det(c)
        if det > EPS:
            return Point.CCW_COUNTER_CLOCKWISE
        if det < -EPS:
            return Point.CCW_CLOCKWISE
        if b.dot(c) < -EPS:
            return Point.CCW_ONLINE_BACK
        if c.norm() - b.norm() > EPS:
            return Point.CCW_ONLINE_FRONT
        return Point.CCW_ON_SEGMENT

    def dot(self, p):
        """
        内積
        :param Point p:
        :rtype: float
        """
        return self.x * p.x + self.y * p.y

    def det(self, p):
        """
        外積
        :param Point p:
        :rtype: float
        """
        return self.x * p.y - self.y * p.x

    def dist(self, p):
        """
        距離
        :param Point p:
        :rtype: float
        """
        return abs(self.c - p.c)

    def norm(self):
        """
        原点からの距離
        :rtype: float
        """
        return abs(self.c)

    def phase(self):
        """
        原点からの角度
        :rtype: float
        """
        return cmath.phase(self.c)

    def angle(self, p, q):
        """
        p に向かってる状態から q まで反時計回りに回転するときの角度
        :param Point p:
        :param Point q:
        :rtype: float
        """
        return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c)) % TAU

    def area(self, p, q):
        """
        p, q となす三角形の面積
        :param Point p:
        :param Point q:
        :rtype: float
        """
        return abs((p - self).det(q - self) / 2)

    def projection_point(self, p, q, allow_outer=False):
        """
        線分 pq を通る直線上に垂線をおろしたときの足の座標
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=ja
        :param Point p:
        :param Point q:
        :param allow_outer: 答えが線分の間になくても OK
        :rtype: Point|None
        """
        diff_q = q - p
        
        r = (self - p).dot(diff_q) / abs(diff_q)
        
        phase = diff_q.phase()

        ret = Point.from_polar(r, phase) + p
        if allow_outer or (p - ret).dot(q - ret) < EPS:
            return ret
        return None

    def reflection_point(self, p, q):
        """
        直線 pq を挟んで反対にある点
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B&lang=ja
        :param Point p:
        :param Point q:
        :rtype: Point
        """
        
        r = abs(self - p)
        
        angle = p.angle(q, self)
        
        angle = (q - p).phase() - angle
        return Point.from_polar(r, angle) + p

    def on_segment(self, p, q, allow_side=True):
        """
        点が線分 pq の上に乗っているか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
        :param Point p:
        :param Point q:
        :param allow_side: 端っこでギリギリ触れているのを許容するか
        :rtype: bool
        """
        if not allow_side and (self == p or self == q):
            return False
        
        
        return abs((p - self).det(q - self)) < EPS and (p - self).dot(q - self) < EPS


class Line:
    """
    2次元空間上の直線
    """

    def __init__(self, a: float, b: float, c: float):
        """
        直線 ax + by + c = 0
        """
        self.a = a
        self.b = b
        self.c = c

    @staticmethod
    def from_gradient(grad: float, intercept: float):
        """
        直線 y = ax + b
        :param grad: 傾き
        :param intercept: 切片
        :return:
        """
        return Line(grad, -1, intercept)

    @staticmethod
    def from_segment(p1, p2):
        """
        :param Point p1:
        :param Point p2:
        """
        a = p2.y - p1.y
        b = p1.x - p2.x
        c = p2.y * (p2.x - p1.x) - p2.x * (p2.y - p1.y)
        return Line(a, b, c)

    @property
    def gradient(self):
        """
        傾き
        """
        return INF if self.b == 0 else -self.a / self.b

    @property
    def intercept(self):
        """
        切片
        """
        return INF if self.b == 0 else -self.c / self.b

    def is_parallel_to(self, l):
        """
        平行かどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Line l:
        """
        
        return abs(Point.from_rect(self.a, self.b).det(Point.from_rect(l.a, l.b))) < EPS

    def is_orthogonal_to(self, l):
        """
        直行しているかどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Line l:
        """
        
        return abs(Point.from_rect(self.a, self.b).dot(Point.from_rect(l.a, l.b))) < EPS

    def intersection_point(self, l):
        """
        交差する点
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B&lang=ja
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C&lang=ja
        FIXME: 誤差が気になる。EPS <= 1e-9 だと CGL_2_B ダメだった。
        :param l:
        :rtype: Point|None
        """
        a1, b1, c1 = self.a, self.b, self.c
        a2, b2, c2 = l.a, l.b, l.c
        det = a1 * b2 - a2 * b1
        if abs(det) < EPS:
            
            return None
        x = (b1 * c2 - b2 * c1) / det
        y = (a2 * c1 - a1 * c2) / det
        return Point.from_rect(x, y)


class Segment:
    """
    2次元空間上の線分
    """

    def __init__(self, p1, p2):
        """
        :param Point p1:
        :param Point p2:
        """
        self.p1 = p1
        self.p2 = p2

    def norm(self):
        """
        線分の長さ
        """
        return abs(self.p1 - self.p2)

    def intersects_with(self, s, allow_side=True):
        """
        交差するかどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B&lang=ja
        :param Segment s:
        :param allow_side: 端っこでギリギリ触れているのを許容するか
        """
        l1 = Line.from_segment(self.p1, self.p2)
        l2 = Line.from_segment(s.p1, s.p2)
        if l1.is_parallel_to(l2):
            
            return (s.p1.on_segment(self.p1, self.p2, allow_side) or
                    s.p2.on_segment(self.p1, self.p2, allow_side) or
                    self.p1.on_segment(s.p1, s.p2, allow_side) or
                    self.p2.on_segment(s.p1, s.p2, allow_side))
        else:
            
            p = l1.intersection_point(l2)
            return p.on_segment(self.p1, self.p2, allow_side) and p.on_segment(s.p1, s.p2, allow_side)

    def closest_point(self, p):
        """
        線分上の、p に最も近い点
        :param Point p:
        """
        
        d = (p - self.p1).dot(self.p2 - self.p1) / self.norm()
        
        if d < EPS:
            return self.p1
        
        if -EPS < d - self.norm():
            return self.p2
        
        return Point.from_polar(d, (self.p2 - self.p1).phase()) + self.p1

    def dist(self, p):
        """
        他の点との最短距離
        :param Point p:
        """
        return abs(p - self.closest_point(p))

    def dist_segment(self, s):
        """
        他の線分との最短距離
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D&lang=ja
        :param Segment s:
        """
        if self.intersects_with(s):
            return 0.0
        return min(
            self.dist(s.p1),
            self.dist(s.p2),
            s.dist(self.p1),
            s.dist(self.p2),
        )


class Polygon:
    """
    2次元空間上の多角形
    """

    def __init__(self, points):
        """
        :param list of Point points:
        """
        self.points = points

    def iter2(self):
        """
        隣り合う2点を順に返すイテレータ
        :rtype: typing.Iterator[(Point, Point)]
        """
        return zip(self.points, self.points[1:] + self.points[:1])

    def iter3(self):
        """
        隣り合う3点を順に返すイテレータ
        :rtype: typing.Iterator[(Point, Point, Point)]
        """
        return zip(self.points,
                   self.points[1:] + self.points[:1],
                   self.points[2:] + self.points[:2])

    def area(self):
        """
        面積
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_A&lang=ja
        """
        
        dets = []
        for p, q in self.iter2():
            dets.append(p.det(q))
        return abs(math.fsum(dets)) / 2

    def is_convex(self, allow_straight=False, allow_collapsed=False):
        """
        凸包かどうか
        :param allow_straight: 3点がまっすぐ並んでるのを許容するかどうか
        :param allow_collapsed: 面積がゼロの場合を許容するか
        """
        ccw = []
        for a, b, c in self.iter3():
            ccw.append(Point.ccw(a, b, c))
        ccw = set(ccw)
        if len(ccw) == 1:
            if ccw == {Point.CCW_CLOCKWISE}:
                return True
            if ccw == {Point.CCW_COUNTER_CLOCKWISE}:
                return True
        if allow_straight and len(ccw) == 2:
            if ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_CLOCKWISE}:
                return True
            if ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_COUNTER_CLOCKWISE}:
                return True
        if allow_collapsed and len(ccw) == 3:
            return ccw == {Point.CCW_ONLINE_FRONT, Point.CCW_ONLINE_BACK, Point.CCW_ON_SEGMENT}
        return False


Q = int(sys.stdin.buffer.readline())
XY = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(Q)]

points = []
for x, y in XY:
    points.append(Point(complex(x, y)))
polygon = Polygon(points)
print(int(polygon.is_convex(allow_straight=True, allow_collapsed=True)))

Solution (Python):


import array
from fractions import Fraction
import math
import os
import sys


def main():
    N = read_int()
    P = [Vec(x, y) for x, y in [read_ints() for _ in range(N)]]
    print(solve(N, P))


def solve(N, P):
    for i in range(N):
        a = P[i]
        b = P[(i + 1) % N]
        c = P[(i + 2) % N]
        if (b - a).cross(c - b) < 0:
            return 0
    return 1




class Vec(object):
    def __init__(self, x, y):
        self.x = x
        self.y = y
        super().__init__()

    def __add__(self, other):
        return Vec(self.x + other.x, self.y + other.y)

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

    def __mul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __rmul__(self, scalar):
        return Vec(self.x * scalar, self.y * scalar)

    def __truediv__(self, scalar):
        return Vec(self.x / scalar, self.y / scalar)

    def __iadd__(self, other):
        self.x += other.x
        self.y += other.y
        return self

    def __isub__(self, other):
        self.x -= other.x
        self.y -= other.y
        return self

    def __imul__(self, scalar):
        self.x *= scalar
        self.y *= scalar
        return self

    def __idiv__(self, scalar):
        self.x /= scalar
        self.y /= scalar
        return self

    def __neg__(self):
        return Vec(-self.x, -self.y)

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

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

    def __abs__(self):
        return math.sqrt(float(self.abs2()))

    def __str__(self):
        return '({}, {})'.format(self.x, self.y)


DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == "__main__":
    n = int(input())
    coordinates = [complex(*map(int, input().split())) for _ in range(n)]
    vecs = [b - a for a, b in zip(coordinates, coordinates[1:] + [coordinates[0]])]
    prev = vecs[0]

    for i in range(1, n):
        cur = vecs[-i]
        if cur.real * prev.imag - prev.real * cur.imag < -1e-6:
            print(0)
            exit(0)
        prev = cur

    print(1)

Solution (Python):
def vc(p,q):
    return[p[0]-q[0],p[1]-q[1]]

def cross(u,v):
    return(u[0]*v[1]-u[1]*v[0])

n = int(input())
v = []
for _ in range(n):
    x0,y0 = map(int,input().split())
    v.append([x0,y0])
flag = True
for i in range(n-2):
    e_i = vc(v[i+1],v[i])
    e_nxt = vc(v[i+2],v[i+1])
    if cross(e_i,e_nxt)<0:
        flag = False
e_i = vc(v[-1],v[-2])
e_nxt = vc(v[0],v[-1])
if cross(e_i,e_nxt)<0:
    flag = False
e_i = vc(v[0],v[-1])
e_nxt = vc(v[1],v[0])
if cross(e_i,e_nxt)<0:
    flag = False
if flag:
    print(1)
else:
    print(0)