Problem p02846 (python)

Fixed submission:
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]

if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0 and abs(y)%(x+y)==0:
    print((abs(y)//(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]

if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0 and abs(y)%(x+y)==0
    print((abs(y)//(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2+[0,3][abs(y)%(x+y)>0])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
#    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2+[0,2][abs(y)%(x+y)>0])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
#elif (x<0 and y<0) or (x>0 and y>0):
#    print(0)
#elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
#    print(1)

#elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
#elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
#elif x>0 and x+y<0:
#    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y>0:
    print((abs(y)//(x+y))*2[0,2][abs(y)%(x+y)>0])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>0])
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
elif x>0 and x+y<0:
    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
#elif x>0 and x+y>0:
#    print((abs(y)//(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
elif x>0 and x+y<0:
    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
elif x>0 and x+y<0:
    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
elif x>0 and x+y<0:
    print((x//abs(x+y))*2+[0,1][x%abs(x+y)>0])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
elif x<0 and x+y<0:
    print((y//abs(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
#elif x<0 and x+y>0: OKOK
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    #print((y//abs(x+y))*2+[0,1][y%abs(x+y)>1])
    print((y//abs(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
#elif x<0 and x+y>0: OKOK
#    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x<0 and x+y<0:
    print((y//abs(x+y))*2+[0,1][y%abs(x+y)>1])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
#elif x>0 and x+y<0:
#    print((abs(y)//abs(x+y))*2+[0,1][abs(y)%abs(x+y)>1])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x>0 and x+y<0:
    print((abs(y)//abs(x+y))*2+[0,1][abs(y)%abs(x+y)>1])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
elif x>0 and x+y<0:
    print((abs(y)//(x+y))*2+[0,1][abs(y)%(x+y)>1])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
#print(x,y,abs(x)<abs(y))
#exit()
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print((abs(x)//(x+y))*2+[0,1][abs(x)%(x+y)>1])
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
#elif x<0 and x+y>0:
#    print(abs(x//(x+y))*2-1)
elif x>0 and x+y<0:
    print(abs(y//(x+y))*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print(abs(x//(x+y))*2-1)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print(y//(x+y)*2-1)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
#elif (x<0 and x+y>0) or (x>0 and x+y<0):
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+y>0) or (x>0 and x+y<0):
    print(1)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
print(x,y)
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif x<0 and x+y>0:
    print(1)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if sum(w)==0:
    print(w[9])
    #print("infinity")
else:
    print("infinity")
    #print(w[9])

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if sum(w)==0:
    print("infinity")
else:
    print(w[9])

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if w[-1]==0:
        print("infinity")
        exit()
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):
            print(0)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]>0 and w[3]>0) or (w[0]<0 and w[1]>0 and w[2]<0 and w[3]<0):
            print(2)
            exit()
#print(w)
#print(max(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))*2-1)
#x,y=(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))
x,y=(w[0]//abs(w[2]-w[0]),w[1]//abs(w[3]-w[1]))
#if w[0]<w[2] and w[1]<w[3] and w[0]<0:
if w[0]<w[2] and w[1]<w[3] and x<0:
    print(-x*2-1)
#elif w[0]<w[2] and w[1]<w[3] and w[0]>0:
elif w[0]<w[2] and w[1]<w[3] and y<0:
    print(-y*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if w[-1]==0:
        print("infinity")
        exit()
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):
            print(0)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]>0 and w[3]>0) or (w[0]<0 and w[1]>0 and w[2]<0 and w[3]<0):
            print(2)
            exit()
#print(w)
#print(max(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))*2-1)
#x,y=(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))
x,y=(w[0]//(w[2]-w[0]),w[1]//(w[3]-w[1]))
#if w[0]<w[2] and w[1]<w[3] and w[0]<0:
if w[0]<w[2] and w[1]<w[3] and x<0:
    print(-x*2-1)
#elif w[0]<w[2] and w[1]<w[3] and w[0]>0:
elif w[0]<w[2] and w[1]<w[3] and y<0:
    print(-y*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if w[-1]==0:
        print("infinity")
        exit()
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):
            print(0)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]>0 and w[3]>0) or (w[0]<0 and w[1]>0 and w[2]<0 and w[3]<0):
            print(2)
            exit()
#print(w)
#print(max(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))*2-1)
x,y=(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))
if w[0]<w[2] and w[1]<w[3] and w[0]<0:
    print(x*2-1)
elif w[0]<w[2] and w[1]<w[3] and w[0]>0:
    print(x*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if w[-1]==0:
        print("infinity")
        exit()
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):
            print(0)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]>0 and w[3]>0) or (w[0]<0 and w[1]>0 and w[2]<0 and w[3]<0):
            print(2)
            exit()
print(w)
#print(max(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))*2-1)
x,y=(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))
if w[0]<w[2] and w[1]<w[3] and w[0]<0:
    print(x*2-1)
elif w[0]<w[2] and w[1]<w[3] and w[0]>0:
    print(x*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if w[-1]==0:
        print("infinity")
        exit()
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):
            print(0)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)
            exit()
        elif (w[0]>0 and w[1]<0 and w[2]>0 and w[3]>0) or (w[0]<0 and w[1]>0 and w[2]<0 and w[3]<0):
            print(2)
            exit()
#print(w)
#print(max(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))*2-1)
x,y=(abs(w[0]//(w[2]-w[0])),abs(w[1]//(w[3]-w[1])))
if w[0]<0 and x>y:
    print(x*2-1)
elif w[0]<0 and x<y:
    print(x*2)
else:
    print(hhh)

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if i==3:
        if len(set(w))!=4:
            #print("infinity")
            print(ans)
            exit()
        chk=0
        #print(ans)
        print("infinity")

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
w=[]
for i in range(4):
    p.append(p[-1]+a[i%2]*t[i%2])
    q.append(q[-1]+b[i%2]*t[i%2])
    w.append(p[i+1]-q[i+1])
    if i==3:
        if len(set(w))!=4:
            print("infinity")
            exit()
        chk=0
        if (w[0]>0 and w[1]>0) or (w[0]<0 and w[1]<0):]
            print(0)
        elif (w[0]>0 and w[1]<0 and w[2]<0) or (w[0]<0 and w[1]>0 and w[2]>0):
            print(1)