TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
a, b, h, m = map(int, input().split())

angle_m = 6 * m
angle_h = 30 * h + 0.5 * m
angle = abs(angle_m - angle_h)
if angle >= 180:
  angle -= 180

ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))
print(ans)

import math
a, b, h, m = map(int, input().split())

angle_m = 6 * m
angle_h = 30 * h + 0.5 * m
angle = abs(angle_m - angle_h)
if angle > 180:
  angle -= 180

ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))
print(ans)

import math
a, b, h, m = map(int, input().split())

angle_m = 6 * m
angle_h = 30 * h + 0.5 * m
angle = abs(angle_m - angle_h)
if angle > 180:
  angle = 360 - angle

ans = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(angle)))
print('{:.20f}'.format(ans))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math

def main() :
    A, B, H, M = list(map(int, input().split()))

    theta = abs((H+ M/ 60)* 30- M* 6)
    print(theta)
    
    result = B**2 + A**2 - 2* B* A* math.cos(math.radians(theta))
    result = math.sqrt(result)

    print('{:.020f}'.format(result))

if __name__ == "__main__":
    main()

import math

def main() :
    A, B, H, M = list(map(int, input().split()))

    theta = abs((H+ M/ 60)* 30- M* 6)
    
    
    result = B**2 + A**2 - 2* B* A* math.cos(math.radians(theta))
    result = math.sqrt(result)

    print('{:.020f}'.format(result))

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math

nums = list(map(lambda x:int(x), input().split()))
a, b, h, m = nums[0], nums[1], nums[2], nums[3]

wa = 0.5
wb = 6

tm = 60 * h + m

da = tm * wa
db = (tm % 60) * wb
diff = abs(da - db)
print(tm, da, db, diff)
csq = a*a + b*b - (2 * a * b * math.cos(diff * math.pi / 180))
print("{:.20f}".format(math.sqrt(csq)))

import math

nums = list(map(lambda x:int(x), input().split()))
a, b, h, m = nums[0], nums[1], nums[2], nums[3]

wa = 0.5
wb = 6

tm = 60 * h + m

da = tm * wa * math.pi / 180
db = (tm % 60) * wb * math.pi / 180
diff = abs(da - db)
csq = a*a + b*b - (2 * a * b * math.cos(diff))
print("{:.20f}".format(math.sqrt(csq)))

Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math

A, B, H, M = [int(a) for a in input().split()]
h_d = -2*math.pi/12
m_d = -2*math.pi/60

h_s = h_d*(H+M/60) + math.pi/2
m_s = m_d*M + math.pi/2

h_y = A*math.sin(h_s)
h_x = A*math.cos(h_s)
m_y = B*math.sin(m_s)
m_x = B*math.cos(m_s)

x = h_x - m_x
y = h_y - m_y

print(A, h_x, h_y, math.sqrt(h_x**2+h_y**2))
print(B, m_x, m_y, math.sqrt(m_x**2+m_y**2))

ans = math.sqrt(pow(x,2)+pow(y,2))
print("{:.20f}".format(ans))


import math

A, B, H, M = [int(a) for a in input().split()]
h_d = -2*math.pi/12
m_d = -2*math.pi/60

h_s = h_d*(H+M/60) + math.pi/2
m_s = m_d*M + math.pi/2

h_y = A*math.sin(h_s)
h_x = A*math.cos(h_s)
m_y = B*math.sin(m_s)
m_x = B*math.cos(m_s)

x = h_x - m_x
y = h_y - m_y

ans = math.sqrt(pow(x,2)+pow(y,2))
print("{:.20f}".format(ans))


Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
from math import cos


def time():
    A, B, H, M = map(int, input().split())
    minuteAngel = (float(M) * 360) / 60
    hourAngel = (float(H) % 12) * 30 + (float(M) * 30) / 60
    angel = abs(hourAngel - minuteAngel)
    a = cos((angel % 180)/180 * math.pi)
    diatance = math.sqrt(A * A + B * B - 2 * A * B * a)
    print("%.20f" % diatance)



import math
import cmath
if __name__ == '__main__':
    ABHM = list(map(int, input().split(" ")))
    A, B, H, M = ABHM[0], ABHM[1], ABHM[2], ABHM[3]
    mintime = (float)(60 * H + M)
    M=(float)(mintime%60/360)
    H=(float)(mintime%720/60)
    angle=abs(H-M)
    re=cmath.sqrt(A*A+B*B-2*A*B*math.cos(angle*math.pi))
    print("%.20f",re)

import math
from math import cos


def time():
    A, B, H, M = map(int, input().split())
    minuteAngel = (float(M) * 360) / 60
    hourAngel = (float(H) % 12) * 30 + (float(M) * 30) / 60
    angel = abs(hourAngel - minuteAngel)
    a = cos(angel / 180 * math.pi)
    a = float('%.30f' % a)
    diatance = math.sqrt(A * A + B * B - 2 * A * B * a)
    print("%.20f" % diatance)



import math
from math import cos


def time():
    A, B, H, M = map(int, input().split())
    minuteAngel = M * 360.0 / 60.0
    hourAngel = H * 30.0 + M * 30.0 / 60.0
    angel = abs(hourAngel - minuteAngel)
    a = cos(angel / 180 * math.pi)
    a = float('%.20f' % a)
    distance = math.sqrt(A * A + B * B - 2 * A * B * a)
    print("%.20f" % distance)


if __name__=="__main__":
    time()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
#!/usr/bin/env python


__author__ = 'bugttle <bugttle@gmail.com>'

import math

def normalize_angle(angle):
    angle = 360 - angle
    angle = angle + 90
    if (360 <= angle):
        angle -= 360
    return angle


def main():
    A, B, H, M = list(map(int, input().split()))

    # X * 12 = 360
    # X * 60 = 30
    angle = normalize_angle((H * 30 + M * 0.5))
    print(angle)
    x1 = A * math.cos(math.radians(angle))
    y1 = A * math.sin(math.radians(angle))

    # X * 60 = 360
    angle = normalize_angle((M * 6))
    print(angle)
    x2 = B * math.cos(math.radians(angle))
    y2 = B * math.sin(math.radians(angle))

    print("{},{}".format(x1, y1))
    print("{},{}".format(x2, y2))

    print(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2))

if __name__ == '__main__':
    main()


#!/usr/bin/env python


__author__ = 'bugttle <bugttle@gmail.com>'

import math

def normalize_angle(angle):
    angle = 360 - angle
    angle = angle + 90
    if (360 <= angle):
        angle -= 360
    return angle


def main():
    A, B, H, M = list(map(int, input().split()))

    # X * 12 = 360
    # X * 60 = 30
    angle = normalize_angle((H * 30 + M * 0.5))
    print(angle)
    x1 = A * math.cos(math.radians(angle))
    y1 = A * math.sin(math.radians(angle))

    # X * 60 = 360
    angle = normalize_angle((M * 6))
    print(angle)
    x2 = B * math.cos(math.radians(angle))
    y2 = B * math.sin(math.radians(angle))

    print("{},{}".format(x1, y1))
    print("{},{}".format(x2, y2))

    print("{:.20f}".format(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2)))

if __name__ == '__main__':
    main()


#!/usr/bin/env python


__author__ = 'bugttle <bugttle@gmail.com>'

import math

def normalize_angle(angle):
    angle = 360 - angle
    angle = angle + 90
    if (360 <= angle):
        angle -= 360
    return angle


def main():
    A, B, H, M = list(map(int, input().split()))

    # X * 12 = 360
    # X * 60 = 30
    angle = normalize_angle((H * 30 + M * 0.5))
    x1 = A * math.cos(math.radians(angle))
    y1 = A * math.sin(math.radians(angle))

    # X * 60 = 360
    angle = normalize_angle((M * 6))
    x2 = B * math.cos(math.radians(angle))
    y2 = B * math.sin(math.radians(angle))

    print("{:.20f}".format(math.sqrt((x2 - x1)**2 + (y2 - y1) ** 2)))

if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math


a,b,h,m=map(int, input().split())


d = 30*(h+m/60)-6*m
e = 360-d
f = int(min(d,e))
y = math.cos(math.radians(f))


x = a**2+b**2-2*a*b*y
print(math.sqrt(x))


import math
 
 
a,b,h,m=map(int, input().split())
 
 
d = 30*(h+m/60)-6*m
e = 360-d
f = min(d,e)
y = math.cos(math.radians(f))
 
 
x = a**2+b**2-2*a*b*y
z = float(math.sqrt(x))
print("{0:.20f}".format(z))

Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
import sys
sys.stdin.readline

def yogen(x):
    ans = 0
    ans = (A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(x)))**(1/2)
    print(ans)

A, B, H, M = map(int, input().split())

ji = int(H)*30 + int(M)/2
hun = int(M)*6

if ji == hun:
    print(0)
elif ji - hun < 180:
    yogen(ji - hun)
else:
    yogen(hun-ji)


import math
import sys
sys.stdin.readline

def yogen(x):
    ans = (A ** 2 + B ** 2 - 2*A*B*math.cos(math.radians(x)))**(1/2)
    print("{:.20f}".format(ans))

A, B, H, M = map(int, input().split())

ji = int(H)*30 + int(M)/2
hun = int(M)*6

if ji == hun:
    aaa = abs(A-B)
    print("{:.20f}".format(aaa))
elif ji - hun < 180:
    yogen(ji-hun)
else:
    yogen(hun-ji)


Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*40
a=abs(sita1-sita2)
x1 = B*math.cos(math.radians(sita1))
y1 = B*math.sin(math.radians(sita1))
x2 = A*math.cos(math.radians(sita2))
y2 = A*math.sin(math.radians(sita2))

d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print('{:.20f}'.format(d))


import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*40
a=abs(sita1-sita2)
x1 = B*math.cos(math.radians(sita1))
y1 = B*math.sin(math.radians(sita1))
x2 = A*math.cos(math.radians(sita2))
y2 = A*math.sin(math.radians(sita2))

print(A,B,a)
d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print(d)

import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*M

a=abs(sita1-sita2)
if a > 180:
    a = 360 - a
print(A,B,a)
d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print('{:.20f}'.format(d))


import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*40

a=abs(sita1-sita2)

d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print('{:.20f}'.format(d))


import math

A,B,H,M = map(int,input().split())

sita1=(360-M*360/60+90)%360
sita2=(360-H*360/12+90)%360
x1 = B*math.cos(math.radians(sita1))
y1 = B*math.sin(math.radians(sita1))
x2 = A*math.cos(math.radians(sita2))
y2 = A*math.sin(math.radians(sita2))

d = math.sqrt((x2-x1)**2 +(y2-y1)**2)

print(d)


import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*40
a=abs(sita1-sita2)
x1 = B*math.cos(math.radians(sita1))
y1 = B*math.sin(math.radians(sita1))
x2 = A*math.cos(math.radians(sita2))
y2 = A*math.sin(math.radians(sita2))

d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print(d)

import math

A,B,H,M = map(int,input().split())

sita1=M*360/60
sita2=H*360/12+0.5*M

a=abs(sita1-sita2)
if a > 180:
    a = 360 - a
d = math.sqrt(A*A+B*B-2*A*B*math.cos(math.radians(a)))

print('{:.20f}'.format(d))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
from decimal import *
import sympy
a, b, h, m = map(int, input().split())

big = max(30*h, 6*m)
small = min(30*h, 6*m)
gap = min(big - small, 360 - (big - small)) + (m*0.5)


print(format(Decimal(a**2 + b**2 - 2*a*b*sympy.cos(sympy.radians(gap)))**Decimal("0.5"), ".20f"))


import math
a, b, h, m = map(int, input().split())

big = max(30*h, 6*m)
small = min(30*h, 6*m)
gap = min(big - small, 360 - (big - small))

print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))))

import math
a, b, h, m = map(int, input().split())

big = max(30*h, 6*m)
small = min(30*h, 6*m)
gap = min(big - small, 360 - (big - small)) + (m*0.5)


print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))))

import math
a, b, h, m = map(int, input().split())

big = max(30*h + (m*0.5), 6*m)
small = min(30*h + (m*0.5), 6*m)
gap = min(big - small, 360 - (big - small))

print(format(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(gap))), ".20f"))

Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import sys
import numpy as np

##i = list(map(int, input().split()))
##a = i[0]
##b = i[1]
##h = i[2]
##m = i[3]
a,b,h,m = 3,4,10,40
time = h*60+m
ths = np.pi/2-(np.pi * time/(60*12))
thl = np.pi/2-(np.pi * m/30.0)
#ths = np.deg2rad(90-h*30.0)
#thl = np.deg2rad(90-m*6.0)
x1 = a*np.cos(ths)
y1 = a*np.sin(ths)
x2 = b*np.cos(thl)
y2 = b*np.sin(thl)
print(np.sqrt((x1-x2)**2+(y1-y2)**2))

import sys
import numpy as np

i = list(map(int, input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]
ths = np.pi/2-(np.pi * h/6)
thl = np.pi/2-(np.pi * m/30)
x1 = a*np.cos(ths)
y1 = a*np.sin(ths)
x2 = b*np.cos(thl)
y2 = b*np.sin(thl)
print(np.linalg.norm(np.array([x1,y1])-np.array([x2,y2])))

import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h*60.0+m
#angle = np.abs(((time-24*m)/60*12))%180
angle = np.abs(time/2-60*m)%360
angle = min(angle, 360-angle)
print(angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))


import sys
import numpy as np



i = list(map(float, input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]

time = float(h*60.0+m)
th = np.abs(np.pi*(time-24.0*m)/(60.0*12)).astype('float64')
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*np.cos(th)*a*b)))

import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h*60.0+m
#angle = np.abs(((time-24*m)/60*12))%180
angle = np.abs(time/2-60*m)
print(angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))


import sys
import numpy as np

i = list(map(int, input().split()))
a = i[0]
b = i[1]
h = i[2]
m = i[3]
time = h*60+m
ths = np.pi/2-(np.pi * time/(60*12))
thl = np.pi/2-(np.pi * m/30.0)
#ths = np.deg2rad(90-h*30.0)
#thl = np.deg2rad(90-m*6.0)
x1 = a*np.cos(ths)
y1 = a*np.sin(ths)
x2 = b*np.cos(thl)
y2 = b*np.sin(thl)
print(np.sqrt((x1-x2)**2+(y1-y2)**2))


import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h*60.0+m
#angle = np.abs(((time-24*m)/60*12))%180
angle = np.abs(time/2-60*m)%360
angle = min(angle, 360-angle)
print(angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))


import sys
import numpy as np
import math

a,b,h,m = map(int,input().split())
time = h+m/60.0
#angle = np.abs(((time-24*m)/60*12))%180
#angle = np.abs(time/12-m/60)*360
angle = np.abs(30*time-m*6)%360
angle = min(angle, 360-angle)
print('{:.20f}'.format(np.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(angle)))))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
def:
	A B H M=map(int,input().split(" "))
	if H>M/5:
		angle=(H/12-M/60)*360
	else:
		angle=(M/60-H/12)*360
    t=cos(angle)
    d=(A^2+B^2-2AB*t)^0.5
    print(d)
    

import math
def:
	A B H M=map(int,input().split(" "))
	if H>M/5:
		angle=(H/12-M/60)
	else:
		angle=(M/60-H/12)
    t=math.cos(math.pi*angle)
    d=(A^2+B^2-2AB*t)^0.5
    print(d)
    

import math


def cal():
    string = input()
    a, b, h, m = string.split(" ")
    a = int(a)
    b = int(b)
    h = int(h)
    m = int(m)
    minuteAngel = (float(m) * 360) / 60
    hourAngel = (float(h) % 12) * 30 + (float(m) * 30) / 60
    angel = abs(hourAngel - minuteAngel)
    angel=angel/180
    cosine = math.cos(math.pi*angel)
    ans = math.sqrt(a*a + b*b - 2*a*b*cosine)
    print(format(ans, '.20f'))
    # print(angle1)
    # print(angle2)
    # print(angle)
    # print(cosine)

cal()

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
import math
def readInt():
    return list(map(int, input().split()))
a,b,h,m = readInt()
# print(a)
arg_h = 30*h + 30*(m/60)
arg_m = 6*m
if abs(arg_h-arg_m) <= 180:
    arg = math.radians(abs(arg_h-arg_m))
else:
    arg = math.radians(abs(arg_h-arg_m)-180) 
# print(arg_h, arg_m, arg)
# print(math.cos(arg))
ans = math.sqrt(a**2+b**2-2*a*b*math.cos(arg))
print(ans)

import math
def readInt():
    return list(map(int, input().split()))
a,b,h,m = readInt()
# print(a)
arg_h = 30*h + 30*(m/60)
arg_m = 6*m
if abs(arg_h-arg_m) < 180:
    arg = math.radians(abs(arg_h-arg_m))
    ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)
elif abs(arg_h-arg_m) == 180:
    ans = a+b
else:
    arg = math.radians(360-abs(arg_h-arg_m)) 
    ans = (a**2+b**2-2*a*b*math.cos(arg))**(1/2)
# print(arg_h, arg_m, arg)
# print(math.cos(arg))

print('{:.20f}'.format(ans))

Verdicts: Wrong Answer

Accepted
Problem: Consider an analog clock whose hour and minute hands are A and B centimeters long, respectively.  An endpoint of the hour hand and an endpoint of the minute hand are fixed at the same point, around which each hand rotates clockwise at constant angular velocity. It takes the hour and minute hands 12 hours and 1 hour to make one full rotation, respectively.  At 0 o'clock, the two hands overlap each other. H hours and M minutes later, what is the distance in centimeters between the unfixed endpoints of the hands?

Submission attempts (in order):
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

from math import pi, cos,  sqrt
A, B, H, M = map(int, input().split())
w_a = 2*pi/(12*60.0)
w_b = 2*pi/(60.0)
theta_a = w_a*(H*60+M)
theta_b = w_b*M
ans = sqrt(A**2+B**2-2*A*B*cos(theta_a-theta_b))
print("{:.20f}".format(ans))

Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
import fractions
from collections import Counter
N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if A < 0:
        A = -A
        B = -B
    C = fractions.gcd(abs(A), abs(B))
    A_B.append((A//C, B//C))
A_B_C = Counter(A_B)


hate_couple = 0
ans = 1
Done = set([])
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keyb < 0:
        keya = -keya
        keyb = -keyb
    if (keyb, -keya) not in A_B_C:
        a = pow(2, value, mod)
    else:
        a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
        Done.add((keyb, -keya))
    ans *= a
    Done.add(key)

print(ans - 1)

import math
from collections import Counter

N = int(input())
A_B = []
mod = 1000000007
for _ in range(N):
    A, B = map(int, input().split())
    if (A == 0) and (B == 0):
        A_B.append((A, B))
    elif A == 0:
        A_B.append((0, -1))
    elif B == 0:
        A_B.append((1, 0))
    else:
        if A < 0:
            A = -A
            B = -B
        C = math.gcd(abs(A), abs(B))
        A_B.append((A // C, B // C))

A_B_C = Counter(A_B)


ans = 1
Done = set([])
Done.add((0, 0))
for key, value in A_B_C.items():
    if key in Done:
        continue
    keya, keyb = key
    a = 0
    if keya == 0 and keyb == 0:
        a = value + 1
        Done.add((0, 0))
    else:
        if keyb < 0:
            keya = -keya
            keyb = -keyb
        if (keyb, -keya) not in A_B_C:
            a = pow(2, value, mod)
        else:
            a = (pow(2, value, mod) - 1) + (pow(2, A_B_C[(keyb, -keya)], mod) - 1) + 1
            Done.add((keyb, -keya))
    ans *= a
    ans %= mod
    Done.add(key)
ans -= 1
ans += A_B_C[(0, 0)]

print(ans % mod)


Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
N = int(input())
D = {}

def gcd(x,y):
    if x>y: x,y=y,x
    while x:
        x,y=y%x,x
    return y

print(gcd(12,5))
print(gcd(12,16))

for _ in range(N):
    A, B = map(int, input().split())
    if   A==0 and B==0: key=(0,0)
    elif A==0: key=(0,1)
    elif B==0: key=(1,0)
    else:
        if A<0:
            A=-A
            B=-B
        g = gcd(A,abs(B))
        key = (A//g, B//g)

    if key not in D: D[key]=0
    D[key]+=1

mod = 10**9+7

ans = 1
n00 = 0
for k1, v1 in D.items():
    if k1==(0,0):
        n00+=v1
        continue
    if v1==0: continue
        
    k2 = (k1[1], -k1[0]) if k1[1]>0 else (-k1[1], k1[0])
    if k2 not in D:
        ans = ans * pow(2, v1, mod) % mod
    else:
        v2 = D[k2]
        m = (pow(2, v1, mod) + pow(2, v2, mod) - 1) % mod
        ans = ans * m % mod
        D[k2]=0
        
print((ans+n00-1)%mod)


N = int(input())
D = {}

def gcd(x,y):
    if x>y: x,y=y,x
    while x:
        x,y=y%x,x
    return y

for _ in range(N):
    A, B = map(int, input().split())
    if   A==0 and B==0: key=(0,0)
    elif A==0: key=(0,1)
    elif B==0: key=(1,0)
    else:
        if A<0:
            A=-A
            B=-B
        g = gcd(A,abs(B))
        key = (A//g, B//g)

    if key not in D: D[key]=0
    D[key]+=1

mod = 10**9+7

ans = 1
n00 = 0
for k1, v1 in D.items():
    if k1==(0,0):
        n00+=v1
        continue
    if v1==0: continue
        
    k2 = (k1[1], -k1[0]) if k1[1]>0 else (-k1[1], k1[0])
    if k2 not in D:
        ans = ans * pow(2, v1, mod) % mod
    else:
        v2 = D[k2]
        m = (pow(2, v1, mod) + pow(2, v2, mod) - 1) % mod
        ans = ans * m % mod
        D[k2]=0
        
print((ans+n00-1)%mod)


Verdicts: Wrong Answer

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
		try:
        	iwashi[(0, -1)] += 1
		except KeyError:
            iwashi[(0, -1)] = 1
        continue
    elif(y == 0):
        try:
        	iwashi[(-1, 0)] += 1
		except KeyError:
            iwashi[(-1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = y, -x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)


from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        try:
        	iwashi[(0, 1)] += 1
        except KeyError:
            iwashi[(0, 1)] = 1
            continue
    elif(y == 0):
        try:
        	iwashi[(1, 0)] += 1
        except KeyError:
            iwashi[(1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = -y, x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)


Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
from math import gcd

mod = 10**9 +7
N = int(input())
dic = {}

zero = 0
for _ in range(N):
    a,b = map(int, input().split())
    if  a ==0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        key = (0,1)
    elif b == 0:
        key = (1,0)
    else:
        if a<0:
            a=-a 
            b=-b
        g = gcd(a,abs(b))
        key = (a//g,b//g)
    
    if key not in dic:
        dic[key]=0

    dic[key] +=1

ans = 1
for k1, v1 in dic.items():
    if v1 ==0:
        continue

    if k1[1] >0:
        k2 = (k1[1],-k1[0])
    else:
        k2 = (-k1[1],k1[0])

    if k2 not in dic:
        ans *= 2**v1
        ans %= mod
    else:
        ans *= ((2**v1-1)) %mod) + ((2**dic[k2]-1)) %mod) +1
        ans %= mod
        dic[k2]=0

ans = (ans + zero -1 )%mod
print(ans)

from math import gcd

mod = 10**9 +7
N = int(input())
dic = {}

zero = 0
for _ in range(N):
    a,b = map(int, input().split())
    if  a ==0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        key = (0,1)
    elif b == 0:
        key = (1,0)
    else:
        if a<0:
            a=-a 
            b=-b
        g = gcd(a,abs(b))
        key = (a//g,b//g)
    
    if key not in dic:
        dic[key]=0

    dic[key] +=1

ans = 1
for k1, v1 in dic.items():
    if v1 ==0:
        continue

    if k1[1] >0:
        k2 = (k1[1],-k1[0])
    else:
        k2 = (-k1[1],k1[0])

    if k2 not in dic:
        ans *= 2**v1
        ans %= mod
    else:
        ans *= ((2**v1-1) %mod) + ((2**dic[k2]-1) %mod) +1
        ans %= mod
        dic[k2]=0

ans = (ans + zero -1 )%mod
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
from collections import defaultdict
import sys
from fractions import Fraction

count = defaultdict(int)
if 1:
    N = int(sys.stdin.readline())

    edges = defaultdict(list)
    for i in range(N):
        A, B = [int(x) for x in sys.stdin.readline().split()]
        if B == 0:
            angle = "I"
        else:
            angle = Fraction(A, B)
        count[angle] += 1

pairs = {}
solos = []
for k1 in count:
    if k1 in pairs:
        continue
    for k2 in count:
        if k1 * k2 == -1:
            pairs[k2] = k1
            break
    else:
        solos.append(k1)
print(pairs, solos)


def power(n):
    1000000007


result = 1
for p in pairs:
    print("pair", p, count[p], pairs[p], count[pairs[p]])
    n = count[p]
    m = count[pairs[p]]
    result *= (2 ** n - 1) + (2 ** m - 1) + 1
for k in solos:
    print("solo", k, count[k])
    result *= 2 ** count[k]

print(result - 1)


from collections import defaultdict
import sys
from math import gcd
count = defaultdict(int)
N = int(sys.stdin.readline())

zeros = 0
for i in range(N):
    A, B = [int(x) for x in input().split()]
    if A == B == 0:
        zeros += 1
        continue
    if A == 0:
        angle = (0, 1)
    elif B == 0:
        angle = (1, 0)
    else:
        sgn = A // abs(A)
        g = gcd(A, B)
        angle = (A // sgn // g, B // sgn // g)

    count[angle] += 1
# print(count)

pairs = {}
solos = []
for k1 in count:
    if k1 in pairs:
        continue
    if k1 == (0, 1):
        if (1, 0) in count:
            pairs[(1, 0)] = k1
        else:
            solos.append(k1)
        continue

    A, B = k1
    if B:
        sgn = -B // abs(B)
        k2 = (-B // sgn, A // sgn)
    else:
        k2 = (0, 1)
    if k2 in count:
        pairs[k2] = k1
    else:
        solos.append(k1)


P = 1000000007


def pow2(n):
    # if n < 30:
    #     return 2 ** n

    
    
    # if n % 2 == 1:
    #     return (2 * pp) % P
    # else:
    #     return pp
    return pow(2, n, P)


result = 1
for p in pairs:
    
    n = count[p]
    m = count[pairs[p]]
    result = result * ((pow2(n) - 1) + (pow2(m) - 1) + 1) % P
for k in solos:
    # print("solo", k, count[k])
    result = result * pow2(count[k]) % P

print((result + zeros - 1) % P)


Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
from math import gcd
mod=1000000007

n=int(input())
zeros = 0
vec = {}
for _ in range(n):
  a,b=map(int,input().split())
  if a==0 and b==0:
    zeros+=1
    continue
  elif a==0:
    vec[(0,1)]=vec.get((0,1),0)+1
  elif b==0:
    vec[(1,0)]=vec.get((1,0),0)+1
  else:
    g = gcd(a,b)
    a,b= a//g,b//g
    vec[(a,b)]=vec.get((a,b),0)+1
done = set()
total=1
for (a,b),v in vec.items():
  if (-b,a) in done or (b,-a) in done: continue
  done.add((a,b))
  w=vec[(-b,a)]+vec[(b,-a)]
  total *= (pow(2,v,mod)+pow(2,w,mod)-1)
  total %= mod
print((total+zeros-1+mod)%mod)


from math import gcd
n=int(input())
mod = 1000000007
z=0
d={}
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    z+=1
    continue
  if a==0:
    d[(0,1)]=d.get((0,1),0)+1
    continue
  if b==0:
    d[(1,0)]=d.get((1,0),0)+1
    continue
  g = gcd(a,b)
  s = a//abs(a)
  a,b = (a//g)*s, (b//g)*s
  d[(a,b)]=d.get((a,b),0)+1

done = set()
ans = 1
for (a,b), v in d.items():
  if (a,b) in done:continue
  done.add((a,b))
  done.add((-b,a))
  done.add((b,-a))
  w = d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
ans = (ans + z - 1 + mod)%mod
print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
# -*- coding: utf-8 -*-
from fractions import Fraction

N = int(input())

dict_F = {}
count_0 = 0

def insert(A,B,s): # A>=0, B>0, s=0or1
  if Fraction(A,B) not in dict_F.keys():
    dict_F[Fraction(A,B)] = [0,0]
  dict_F[Fraction(A,B)][s] += 1

def power2(A):
  result = 1
  for _ in range(A):
    result = (2*result)%mod
  return result

for _ in range(N):
  A,B = map(int, input().split())
  if A==0 and B==0:
    count_0 += 1
  elif A>=0 and B>0:
    insert(A,B,0)
  elif A>0 and B<=0:
    insert(-B,A,1)
  elif A<=0 and B<0:
    insert(-A,-B,0)
  elif A<0 and B>=0:
    insert(B,-A,1)

mod = 1000000007
answer = 1


answer = (answer+count_0-1)%mod
print(answer)

# -*- coding: utf-8 -*-
import sys
from math import gcd

N, *AB = map(int, sys.stdin.buffer.read().split())

dict_F = {}
count_0 = 0

def insert(A,B,s): # A>=0, B>0, s=0or1
  if (A,B) not in dict_F.keys():
    dict_F[(A,B)] = [0,0]
  dict_F[(A,B)][s] += 1

def make_power2(N):
  result = 1
  list_result = [1]
  for _ in range(N):
    result = (2*result)%mod
    list_result.append(result)
  return list_result

for i in range(N):
  A,B = AB[2*i:2*i+2]
  if A==0 and B==0:
    count_0 += 1
    continue
  g = gcd(A,B)
  A //= g
  B //= g
  if A>=0 and B>0:
    insert(A,B,0)
  elif A>0 and B<=0:
    insert(-B,A,1)
  elif A<=0 and B<0:
    insert(-A,-B,0)
  elif A<0 and B>=0:
    insert(B,-A,1)

mod = 1000000007
power2 = make_power2(N)
answer = 1

for A,B in dict_F.values():
  answer = (answer*(power2[A]+power2[B]-1))%mod
answer = (answer+count_0-1)%mod

print(answer)

Verdicts: Wrong Answer

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
import math
def main():
    N = int(input())
    d = {}
    zb = 0
    za = 0
    zab = 0
    r = 0
    mod = 10**9 + 7
    for i in range(N):
        a, b = map(int, input().split())
        if a== 0 and b == 0:
            zab += 1
        elif b == 0:
            zb += 1
        elif a == 0:
            za += 1
        else:
            if a < 0:
                a = -a
                b = -b
            x = math.gcd(abs(a), abs(b))
            if (a//x, b//x) in d:
                d[(a//x, b//x)] += 1
            else:
                d[(a//x, b//x)] = 1
    used = set()
    l = []
    for x in d:
        if x in used:
            continue
        a, b = x[0], x[1]
        used.add(x)
        if a * b > 0:
            t = (abs(b), -abs(a))
            if t in d:
                used.add(t)
                l.append((d[x], d[t]))
            else:
                l.append((1, 0))
        else:
            t = (abs(b), abs(a))
            if t in d:
                used.add(t)
                l.append((d[x], d[t]))
            else:
                l.append((1, 0))
    r = zab + pow(2, za) + pow(2, zb) - 2
    for i in l:
        r *= (pow(2, i[0]) + pow(2, i[1]) - 1)
        r %= mod
    return r % mod - 1
print(main())


import math
def main():
    N = int(input())
    d = {}
    za = zb = zab = r = 0
    mod = 10**9 + 7
    for i in range(N):
        a, b = map(int, input().split())
        if a== 0 and b == 0:
            zab += 1
        elif b == 0:
            zb += 1
        elif a == 0:
            za += 1
        else:
            if a < 0:
                a, b = -a, -b
            x = math.gcd(abs(a), abs(b))
            d[(a//x, b//x)] = d.get((a//x, b//x), 0) + 1
    used = set()
    l = []
    for x in d:
        if x in used:
            continue
        a, b = x[0], x[1]
        used.add(x)
        if a * b > 0:
            t = (abs(b), -abs(a))
        else:
            t = (abs(b), abs(a))
        used.add(t)
        l.append((d[x], d.get(t, 0)))
    r = pow(2, za) + pow(2, zb) - 1
    for i in l:
        r *= (pow(2, i[0]) + pow(2, i[1]) - 1)
        r %= mod
    return (r - 1 + zab) % mod
print(main())


Verdicts: Wrong Answer

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
di = {}
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a
for a, b in ab:
    if a*b!=0:
        g = gcd(abs(a), abs(b))
        a, b = a//g, b//g
    if a*b>0:
        ind = (abs(a), abs(b))
    elif a*b<0:
        ind = (abs(b), abs(a))
    else:
        ind = 0
    if ind in di:
        x, y = di[ind]
    else:
        x = y = 0
    if a*b==0:
        if b!=0:
            di[ind] = (x+1, y)
        elif a!=0:
            di[ind] = (x, y+1)
    else:
        if a*b>0:
            di[ind] = (x+1, y)
        else:
            di[ind] = (x, y+1)
print(di)
mod = 10**9+7
ans = 1
for i, j in di.values():
    ans *= (pow(2, i, mod)+pow(2, j, mod)-1)
    ans %= mod
print((ans-1)%mod)

n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
di = {}
z = 0
def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a
for a, b in ab:
    if a*b!=0:
        g = gcd(abs(a), abs(b))
        a, b = a//g, b//g
    if a*b>0:
        ind = (abs(a), abs(b))
    elif a*b<0:
        ind = (abs(b), abs(a))
    else:
        ind = 0
    if ind in di:
        x, y = di[ind]
    else:
        x = y = 0
    if a*b==0:
        if b!=0:
            di[ind] = (x+1, y)
        elif a!=0:
            di[ind] = (x, y+1)
        else:
            z += 1
    else:
        if a*b>0:
            di[ind] = (x+1, y)
        else:
            di[ind] = (x, y+1)
mod = 10**9+7
ans = 1
for i, j in di.values():
    ans *= (pow(2, i, mod)+pow(2, j, mod)-1)
    ans %= mod
print((ans+z-1)%mod)

Verdicts: Wrong Answer

Accepted
Problem: We have caught N sardines. The _deliciousness_ and _fragrantness_ of the i-th sardine is A_i and B_i, respectively.  We will choose one or more of these sardines and put them into a cooler. However, two sardines on bad terms cannot be chosen at the same time.  The i-th and j-th sardines (i \neq j) are on bad terms if and only if A_i \cdot A_j + B_i \cdot B_j = 0.  In how many ways can we choose the set of sardines to put into the cooler? Since the count can be enormous, print it modulo 1000000007.

Submission attempts (in order):
from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x / g, y / g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 


def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (i, j) in tuple(d.values()):
    now = 1
    now = (now + mod_pow(2, i, mod) - 1) % mod
    now = (mow + mod_pow(2, j, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
ans += zeros % mod
ans = ans % mod
print(ans)

from math import gcd
from sys import setrecursionlimit
setrecursionlimit(4100000)
mod = 10 ** 9 + 7
n = int(input())

zeros = 0
d = {}
for i in range(n):
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        zeros += 1
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if (y < 0) or (y == 0 and x < 0): 
            x, y = -x, -y
        else: 
            pass
        if x <= 0:
            sq = True   #second quadrant
            x, y = y, -x
        else:
            sq = False
        if sq == True:
            if (x, y) in d:
                d[(x, y)][1] += 1
            else:
                d[(x, y)] = [0, 1]
        else:
            if (x, y) in d:
                d[(x, y)][0] += 1
            else:
                d[(x, y)] =[1, 0] 


def  mod_pow(a:int, b:int, mod:int)->int:
    if b == 0:
        return 1 % mod
    elif b % 2 == 0:
        return (mod_pow(a, b//2, mod) ** 2) % mod
    elif b == 1:
        return a % mod
    else:
        return ((mod_pow(a, b//2, mod) ** 2) * a) % mod
#print(d)

ans = 1
for (a, b), (k, l) in d.items():
    now = 1
    now = (now + mod_pow(2, k, mod) - 1) % mod
    now = (now + mod_pow(2, l, mod) - 1) % mod
    ans = (ans * now) % mod
    
ans -= 1
zeros = zeros % mod
ans = (ans + zeros) % mod
print(ans)

Verdicts: Runtime Error

Accepted