Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03254 (python)

Fixed submission:
n, x = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])
ans = 0
for i in range(n):
    x -= a[i]
    if x < 0:
        break
    else:
        ans += 1
print(ans - 1 if x > 0 else ans)

Buggy submission (verdict: Runtime Error):
n, x = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
ans = 0
for i in range(n):
  	x -= a[i]
    if x < 0:
      	break
    else:
      	ans += 1
print(ans - 1 if x > 0 else ans)
Problem p03323 (python)

Fixed submission:
print(["Yay!", ":(", ":("][sum([int(x) > 8 for x in input().split()])])

Buggy submission (verdict: Runtime Error):
print(["Yay!", ":(", ":("][sum([x > 8 for x in input().split()])])
Problem p03997 (python)

Fixed submission:
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))

Buggy submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print((a+b)*h/2)

Buggy submission (verdict: Runtime Error):
a,b,h=map(int,input().split())
print(int((a+b)*h/2))
Problem p03151 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Cm = []
Cp = []
for i in range(N):
	if(A[i]-B[i]<0):
		Cm.append(A[i]-B[i])
	elif(A[i]-B[i]>0):
		Cp.append(A[i]-B[i])
Cm.sort()
Cp.sort()


if(len(Cm) == 0):
	print(0)
	exit(0)
if(sum(Cp)<abs(sum(Cm))):
	print(-1)
	exit(0)

j=0
i = 0
nowCp = int(Cp[len(Cp)-i-1])


while(j<len(Cm)):
	if(nowCp>=abs(Cm[j])):
		nowCp -= abs(Cm[j])
		j += 1
	elif(nowCp<abs(Cm[j]) and i<len(Cp)):
		i += 1
		nowCp += int(Cp[len(Cp)-i-1])

	else:
		break
	

if(j == len(Cm)):
	print(j+i+1)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Cm = []
Cp = []
for i in range(N):
	if(A[i]-B[i]<0):
		Cm.append(A[i]-B[i])
	elif(A[i]-B[i]>0):
		Cp.append(A[i]-B[i])
Cm.sort()
Cp.sort()


if(len(Cm) == 0):
	print(0)
	exit(1)
if(sum(Cp)<abs(sum(Cm))):
	print(-1)
	exit(1)

j=0
i = 0
nowCp = int(Cp[len(Cp)-i-1])


while(j<len(Cm)):
	if(nowCp>=abs(Cm[j])):
		nowCp -= abs(Cm[j])
		j += 1
	elif(nowCp<abs(Cm[j]) and i<len(Cp)):
		i += 1
		nowCp += int(Cp[len(Cp)-i-1])

	else:
		break
	

if(j == len(Cm)):
	print(j+i+1)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
Cm = []
Cp = []
for i in range(N):
	if(A[i]-B[i]<0):
		Cm.append(A[i]-B[i])
	elif(A[i]-B[i]>0):
		Cp.append(A[i]-B[i])
Cm.sort()
Cp.sort()


if(len(Cm) == 0):
	print(0)
	exit(1)
if(sum(Cp)<abs(sum(Cm))):
	print(-1)
	exit(1)

j=0
i = 0
nowCp = int(Cp[len(Cp)-i-1])


while(j<len(Cm)):
	if(nowCp>=abs(Cm[j])):
		nowCp -= abs(Cm[j])
		j += 1
	elif(nowCp<abs(Cm[j])):
		i += 1
		nowCp += int(Cp[len(Cp)-i-1])

	else:
		break
	

if(j == len(Cm)):
	print(j+i+1)
else:
	print(-1)
Problem p03280 (python)

Fixed submission:
A,B = input().split()
A = int(A)
B = int(B)

print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print((A-1)*(B-1))
Problem p03720 (python)

Fixed submission:
nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break

for p in range(1,NM_list[0]+1):
	print(n_list[p-1])

Buggy submission (verdict: Runtime Error):
import msvcrt

nm=input().split()
NM_list = list(map(int,nm))

A_list=[]
B_list=[]
for m in range(NM_list[1]):
	ab=input().split()
	AB_list = list(map(int,ab))
	A_list.append(AB_list[0])
	B_list.append(AB_list[1])

n_list=[]
for n in range(1,NM_list[0]+1):
	n_list.append(0)


for i in range(1,len(A_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == A_list[i-1]):
			n_list[n_len-1] += 1
			break

for i in range(1,len(B_list)+1):
	for n_len in range(1,len(n_list)+1):
		if(n_len == B_list[i-1]):
			n_list[n_len-1] += 1
			break
			
for p in range(1,NM_list[0]+1):
	print(n_list[p-1])
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())

if (a*b) % 2:
    print('Odd')
else:
    print('Even')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

if (a*b) % 2:
    print('Odd')
else:
    print('Even')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

if (a*b) % 2:
    print(‘Odd’)
else:
    print(‘Even’)
Problem p02802 (python)

Fixed submission:
n,m = map(int, input().split())
sub_list = [list(input().split()) for _ in range(m)]

penalty_list = [0]*n #問題ごとのACが出るまでのペナルティ数
result_list = [0]*n #問題ごとの最終的にACが出たかどうかのリスト

for i in range(m):
  if sub_list[i][1] =='AC':
    result_list[int(sub_list[i][0]) -1] = 1
  else:
    if result_list[int(sub_list[i][0]) -1] == 0:
      penalty_list[int(sub_list[i][0]) -1] += 1

ac_count = 0
wa_count = 0
for i in range(n):
  if result_list[i] == 1:
    ac_count += 1
    wa_count += penalty_list[i]

print(f'{ac_count} {wa_count}')

Buggy submission (verdict: Runtime Error):
n,m =map(int, input().split())
ac_dic = {}
wa_dic = {}
for _ in range(m):
  p,s = input().split()
  if s == 'AC':
    if p in ac_dic:
      continue
    else:
      ac_dic[p] = 1
  else:
    if p in ac_dic:
      continue
    else:
      if p in wa_dic:
        wa_dic[p] += 1
      else:
        wa_dic[p] = 1

wa_count = 0
for i,c in wa_dic.items():
  if ac_dic[i]:
    wa_count += c

print(f'{sum(ac_dic.values())} {wa_count}')
Problem p02687 (python)

Fixed submission:
N=input()
def contest(N):
  if N=="ABC":
    return "ARC"
  else:
    return "ABC"
print(contest(N))

Buggy submission (verdict: Runtime Error):
N=int(input())
def contest(N):
  if N=="ABC":
    return ARC
  else:
    return ABC
contest(N)
Problem p02612 (python)

Fixed submission:
n=input()
t=len(n)
if t<4:
  print(1000-int(n))
else:
  k=int(n[0])
  if int(n)>k*10**(t-1):
    print((k+1)*1000-int(n))
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=input()
t=len(n)
if t<4:
  print(1000-int(n))
else:
  k,p=int(n[0]),int(n[1])
  if p!=0:
    print((k+1)*1000-int(n))
  else:
    print(0

Buggy submission (verdict: Runtime Error):
n=input()
t=len(n)
if t<4:
  print(1000-n)
else:
  k,p=n[0],n[1]
  if p!=0:
    print((k+1)*1000-n)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
u=str(n)
t=len(u)
if t<4:
  print(1000-n)
else:
  k,p=u[0],u[1]
  if p!=0:
    print((k+1)*1000-n)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
u,t=str(n),len(n)
if t<4:
  print(1000-n)
else:
  k,p=u[0],u[1]
  if p!=0:
    print((k+1)*1000-n)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=int(input())
t=len(n)
if t<4:
  print(1000-n)
else:
  k,p=n[0],k[1]
  if p!=0:
    print((k+1)*1000-n)
  else:
    print(0)
Problem p02639 (python)

Fixed submission:
l=list(map(int,input().split()))
for i in range(len(l)):
	if l[i]==0:
		print(i+1)
		break

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split())
for i in range(len(l)):
	if l[i]==0:
        print(i+1)
        break
Problem p03407 (python)

Fixed submission:
A, B, C = map(int, input().split())

if A+B>=C:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=input().sprit(" ")
if int(a[0]) + int(a[1]) >= int(a[2]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a=input()
if int(a[0]) + int(a[1]) >= int(a[2]):
  print("Yes")
else:
  print("No")
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
dic = {}
ac = 0
wa = 0
for x in range(M):
    p, s = input().split()
    try:
        dic[p]
    except:
        dic[p] = [False, 0]
    
    if s == 'WA':
        if not dic[p][0]:
            dic[p][1] += 1
        
        
    else:
        if not dic[p][0]:
            dic[p][0] = True
            ac += 1
            wa += dic[p][1]

print(ac, wa)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ac_list = []
wa_dic = {}
for i in range(M):
    p, s = input().split()
    p = int(p)
    if p in ac_list: continue

    if s == 'WA':
        try:
            wa_dic[p] += 1
        except:
            wa_dic[p] = 1
        
    else:
        ac_list.append(p)
        

#print(ac_list, wa_dic)
print(len(ac_list), sum([wa_dic[x] for x in ac_list]))
Problem p03289 (python)

Fixed submission:
B = input()
S = B
a = 0
if S[0] == "A":
    if S[2:-1].count("C") == 1:
        if "C" in S[2:-1]:
            t = 2 + S[2:-1].index("C")
            S = str(S.lstrip("A"))
            S = str(S[0] + S[1:t-1] + S[t:])
            if S.islower():
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")

Buggy submission (verdict: Runtime Error):
B = input()
S = B
a = 0
if S[0] == "A":
    if S[2:-2].count("C") == 1:
        if "C" in S[2:-2]:
            t = 2 + S[2:-2].index("C")
            S = str(S.lstrip("A"))
            S = str(S[0] + S[1:t-1] + S[t:])
            if S.islower():
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")
    print("A" > 1)

Buggy submission (verdict: Runtime Error):
B = input()
A = B
a = 0
if S[0] == "A":
    if S[2:-2].count("C") == 1:
        if "C" in S[2:-2]:
            t = 2 + S[2:-2].index("C")
            S = str(S.lstrip("A"))
            S = str(S[0] + S[1:t-1] + S[t:])
            if S.islower():
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")
    S = S.replace("A", "")
    if S.islower():
        pass

Buggy submission (verdict: Runtime Error):
S = input()
a = 0
if S[0] == "A":
    if S.count("C") == 1:
        if S[2] == "C" or S[-2] == "C":
            S = str(S.replace("A", "", 1))
            S = str(S.replace("C", ""), 1)
            A = S.islower()
            if A == True:
                a = 1
if a == 1:
    print("AC")
else:
    print("WA")
Problem p02658 (python)

Fixed submission:
n = int(input())
lt = [int(x) for x in input().split()]
ans =0
if 0 in lt:
    ans=0
else:
    ans = 1 
    for x in lt:
        ans*=x 
        if ans > 10**18:
            ans="-1"
            break 
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
lt = [int(x) for x in input().split()]
if 0 in lt:
    print(0)
else:
    ans = 1 
    for x in lt:
      ans*=x 
      if ans > 10**18:
        ans='-1'
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
lt = [int(x) for x in input().split()]
if 0 in lt:
    print(0)
else:
    ans = 1 
    for x in lt:
       ans*=x 
       if ans > 10**18:
           ans=-1
print(ans)
Problem p02677 (python)

Fixed submission:
from math import cos
a,b,h,m = map(int, input().split())
p = 3.14159265358979323846264338327950

rad = h/12.0 + m/(60*12) - m/60.0
rad = 2*p * rad

ans = a**2 + b**2 -2*a*b*cos(rad)
 

print(ans**(0.5))

Buggy submission (verdict: Runtime Error):
from math import cos
a,b,h,m = map(int, input().split())
p = 3.14159265358979323846264338327950
tot_min = h*60 + m 
tot_sec = tot_min * 60 
 
h_angle = float("{:.25f}".format((tot_sec*pi)/(6*3600)))
m_angle = float("{:.25f}".format((tot_sec*pi)/(1800)))
 
while h_angle > 2*p:
    h_angle-=2*p 
while m_angle > 2*p:
    m_angle-=2*p 
r = abs(h_angle - m_angle)
if r > p:
    r-=p 
c = float("{:.25f}".format(cos(r)))
ans = float("{:.25f}".format(a**2 + b**2 -2*a*b*c))
ans = float("{:.25f}".format(ans**(0.5)))
print(ans)
Problem p02741 (python)

Fixed submission:
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
t=int(input())
print(arr[t-1])

Buggy submission (verdict: Runtime Error):
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

t = int(input())

print(arr[t+1])
Problem p02576 (python)

Fixed submission:
import math
N,X,T=map(int,input().split())
print(math.ceil(N/X)*T)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
a_1=sum(A)
count=0
for i in range(0,len(A)-1):
    if A[i]>A[i+1]:
        A[i+1]=A[i]
a_2=sum(A)
print(a_2-a_1)
Problem p02657 (python)

Fixed submission:
a,b=map(int,input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=1
for i in A:
  B=i*B
  if(B>10**18):
    B=-1
    break
print(B)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))
import numpy
Q=numpy.array(P)
 
result =numpy.prod(Q)
 
if result>pow(10, 18):
    print('-1')
else:
    print(str(result))

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[list(map(int,input().split()))]
from functools import reduce
from operator import add, mul
result =reduce(mul, P[0])

if result>10**18:
    print(-1)
else:
    print(result)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[list(map(int,input().split()))]
import numpy
Q=numpy.array(P)
result =numpy.prod(Q[0])

if result>10**18:
    print(-1)
else:
    print(result)

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[list(map(int,input().split()))]
import numpy
P=numpy.array(P)
result =numpy.prod(P[0])

if result>10**18:
    print(-1)
else:
    print(int(result))
Problem p02658 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
B=1
for i in A:
  B*=i
  if(B>10**18):
    B=-1
    break
print(B)

Buggy submission (verdict: Runtime Error):
N=int(input())
from decimal import Decimal
P=input().split()
for i in range(0,len(P)):
    P[i]=Decimal(P[i])
import numpy
Q=numpy.array(P)

result =numpy.prod(Q)

if result>pow(10, 18):
    print(-1)
else:
    print(result)

Buggy submission (verdict: Runtime Error):
N=int(input())
from decimal import Decimal
P=input().split()
for i in range(0,len(P)):
    P[i]=Decimal(P[i])
import numpy
P=numpy.array(P)

result =numpy.prod(P)
 
if result>pow(10, 18):
    print(-1)
else:
    print(result)
Problem p02789 (python)

Fixed submission:
n,m = map(int,input().split())


if n==m:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):

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

if(a== b)
    print("Yes")
else:
    print("No")
Problem p02937 (python)

Fixed submission:
import bisect
s = input()
t = input()

s_len = len(s)
t_len = len(t)

n = [[] for i in range(28)]

def get_ord(c):
    return ord(c)-97

for i in range(s_len):
    ord_c = get_ord(s[i])
    n[ord_c].append(i)

#print(n)

#print("s_len",s_len)
#print("t_len",t_len)

def get_ans():
    res = 0
    for i in range(t_len):
        
        rr = res % s_len
        t_ord = get_ord(t[i])
        words = n[t_ord]
        
        if(len(words)==0):
            return -1
        if(i==0 and words[0] == 0):
            res = 0
            continue
    
        if(words[len(words)-1]<=rr):
            res += s_len - rr 
            #print("add",s_len-rr)
            rr = -1
        
        bis = bisect.bisect_right(words,rr)
        #print(bis,len(words),rr,words)
        w = words[bis]


        if(rr!=-1):
            res += w - rr
        else:
            res += w
        #print(t[i],words,rr,res)
    
    return res+1

print(get_ans())

Buggy submission (verdict: Runtime Error):
import bisect
s = input()
t = input()

s_len = len(s)
t_len = len(t)

n = [[] for i in range(28)]

def get_ord(c):
    return ord(c)-97

for i in range(s_len):
    ord_c = get_ord(s[i])
    n[ord_c].append(i)

#print(n)

#print("s_len",s_len)
#print("t_len",t_len)

def get_ans():
    res = 0
    for i in range(t_len):
        rr = res % s_len
        t_ord = get_ord(t[i])
        words = n[t_ord]
        if(len(words)==0):
            return -1
        if(words[len(words)-1]<=rr):
            res += s_len - rr 
            #print("add",s_len-rr)
            rr = res % s_len
        
        bis = bisect.bisect_right(words,rr)
        w = words[bis]
        res += w - rr
        #print(t[i],words,rr,res)
    
    return res+1

print(get_ans())
Problem p03071 (python)

Fixed submission:
a, b = map(int, input().split())

res = 0
for i in range(2):
    if a > b:
        res += a
        a -= 1
    else:
        res += b
        b -= 1

print(res)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

res = 0 3
for i in range(2):
    if a > b:
        res += a
        a -= 1
    else:
        res += b
        b -= 1

print(res)
Problem p02612 (python)

Fixed submission:
n = int(input())
import math
print(math.ceil(n/1000)*1000 - n)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7

ps = []
ns = []
zs = []
for i in range(n):
  if a[i] > 0:
    ps.append(a[i])
  elif a[i] < 0:
    ns.append(a[i])
  else:
    zs.append(a[i])
  
if k == 1:
  print(max(a))
elif len(ps) + len(ns) < k:
  print(0)
elif len(ps) == 0:
  ans = 1
  if k % 2 == 0:
    ns = sorted(ns)
    for i in range(k):
      ans = ans * ns[i] % mod
  elif len(zs) > 0:
    print(0)
  else:
    ns = sorted(ns, reverse=True)
    for i in range(k):
      ans = ans * ns[i] % mod
  print(ans)
else:
  ans = 1
  ps = sorted(ps, reverse=True)
  ns = sorted(ns)
  if k % 2 == 0:
    pp = []
    for i in range(0,min(k, len(ps)), 2):
      try:
        pp.append(ps[i] * ps[i+1])
      except:
        pass
  else:
    pp = []
    ans = ps[0]
    for i in range(1,len(ps), 2):
      try:
        pp.append(ps[i] * ps[i+1])
      except:
        pass
  np = []
  for i in range(0, len(ns), 2):
    try:
      np.append(ns[i] * ns[i+1])
    except:
      pass
  pnp = sorted(pp + np, reverse=True)
  if len(pnp) >= k//2:
    for i in range(k//2):
      ans = ans * pnp[i] % mod
    print(ans)
  else:
    print(0)
Problem p02619 (python)

Fixed submission:
D = int(input())
c = list(map(int, input().split()))
s = [[]]
for _ in range(D):
  s.append(list(map(int, input().split())))

lasts = [0 for i in range(len(c))]
ans = 0
for d in range(1, D+1):
  t = int(input()) - 1
  lasts[t] = d
  ans += s[d][t]
  for i in range(len(c)):
    ans -= c[i] * (d - lasts[i])
  print(ans)

Buggy submission (verdict: Runtime Error):
D = map(int, input().split())
c = list(map(int, input().split()))
s = []
for _ in range(D):
  s.append(list(map(int, input().split())))

lasts = [0 for i in range(len(c))]
ans = 0
for d in range(1, D+1):
  t = int(input()) - 1
  lasts[t] = d
  ans += s[d][t]
  for i in range(len(c)):
    ans -= c[i] * (d - lasts[i])
print(ans)
Problem p02675 (python)

Fixed submission:
x = int(input()[-1])
if x in [2,4,5,7,9]:
  print('hon')
elif x == 3:
  print('bon')
else:
  print('pon')

Buggy submission (verdict: Runtime Error):
from math import gcd
mod = 10**9+7
n = int(input())
dicn = {}
dicp = {}
dicz = {'a': 0, 'b': 0, 'z': 0}
for i in range(n):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    dicz['z'] += 1
  else:
    g = gcd(a,b)
    a //= g
    b //= g
    if a < 0:
      a *= -1
      b *= -1
    elif a == 0 and b < 0:
      b *= -1
    if a * b > 0:
      if a in dicp:
        if b in dicp[a]:
          dicp[a][b] += 1
        else:
          dicp[a][b] = 1
      else:
        dicp[a] = {b: 1}
    elif a * b < 0:
      if b in dicn:
        if a in dicn[b]:
          dicn[b][a] += 1
        else:
          dicn[b][a] = 1
      else:
        dicn[b] = {a: 1}
    else:
      if a == 0:
        dicz['a'] += 1
      else:
        dicz['b'] += 1

ans = 1

for a in dicp:
  for b in dicp[a]:
    if -a in dicn:
      if b in dicn[-a]:
        ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)
        dicn[-a][b] = 0
      else:
        ans *= pow(2, dicp[a][b], mod)
    else:
      ans *= pow(2, dicp[a][b], mod)
    ans %= mod

for b in dicn:
  for a in dicn[b]:
    ans *= pow(2, dicn[b][a], mod)
    ans %= mod
    
if dicz['a'] > 0 and dicz['b'] > 0:
  ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1
elif dicz['a'] > 0:
  ans *= pow(2,dicz['a'],mod)
elif dicz['b'] > 0:
  ans *= pow(2,dicz['b'],mod)
  
ans += dicz['z']
print((ans-1)%mod)

Buggy submission (verdict: Runtime Error):
from math import gcd
mod = 10**9+7
n = int(input())
dicn = {}
dicp = {}
dicz = {'a': 0, 'b': 0, 'z': 0}
for i in range(n):
  a, b = map(int, input().split())
  if a == 0 and b == 0:
    dicz['z'] += 1
  else:
    g = gcd(a,b)
    a //= g
    b //= g
    if a < 0:
      a *= -1
      b *= -1
    elif a == 0 and b < 0:
      b *= -1
    if a * b > 0:
      if a in dicp:
        if b in dicp[a]:
          dicp[a][b] += 1
        else:
          dicp[a][b] = 1
      else:
        dicp[a] = {b: 1}
    elif a * b < 0:
      if b in dicn:
        if a in dicn[b]:
          dicn[b][a] += 1
        else:
          dicn[b][a] = 1
      else:
        dicn[b] = {a: 1}
    else:
      if a == 0:
        dicz['a'] += 1
      else:
        dicz['b'] += 1

ans = 1

for a in dicp:
  for b in dicp[a]:
    if -a in dicn:
      if b in dicn[-a]:
        ans *= (pow(2, dicp[a][b], mod) + pow(2, dicn[-a][b], mod) - 1)
        dicn[-a][b] = 0
      else:
        ans *= pow(2, dicp[a][b], mod)
    else:
      ans *= pow(2, dicp[a][b], mod)
    ans %= mod

for b in dicn:
  for a in dicn[b]:
    ans *= pow(2, dicn[b][a], mod)
    ans %= mod
    
if dicz['a'] > 0 and dicz['b'] > 0:
  ans *= pow(2,dicz['a'],mod) + pow(2,dicz['b'],mod) - 1
elif dicz['a'] > 0:
  ans *= pow(2,dicz['a'],mod)
elif dicz['b'] > 0:
  ans *= pow(2,dicz['b'],mod)
  
ans += pow(2,dicz['z'],mod)
print((ans-1)%mod)
Problem p02730 (python)

Fixed submission:
def kai(s):
  n = len(s)
  for i in range(n):
    if s[i]!=s[n-i-1]:
      return False
  else:
    return True
  
s = input()
n = len(s)
if kai(s) and kai(s[:(n-1)//2]) and kai(s[(n+1)//2]):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def kai(s):
  n = len(s)
  for i in range(n):
    if s[i]!=s[n-i-1]:
      return False
  else:
    return True
  
s = input()
n = len(s)
if kai(s) and kai(s[:(n-1)//2]) and kai(s[(n+3)//2]):
  print('Yes')
else:
  print('No')
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
  _s, _c = map(int, input().split())
  s.append(_s)
  c.append(_c)

st = [0, 0, 10, 100]
go = [10, 10, 100, 1000]
for i in range(st[n], go[n]):
  i_str = str(i)
  for j in range(m):
    if i_str[s[j]-1] != str(c[j]):
      break
  else:
    print(i)
    break
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = []
c = []
for i in range(m):
  _s, _c = map(int, input().split())
  s.append(_s)
  c.append(_c)

s = [0, 0, 10, 100]
g = [10, 10, 100, 1000]
for i in range(s[n], g[n]):
  i_str = str(i)
  for j in range(m):
    if i_str[s[j]-1] != str(c[j]):
      break
  else:
    print(i)
    break
else:
  print(-1)
Problem p02772 (python)

Fixed submission:
n = int(input())
for a in list(map(int, input().split())):
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      print('DENIED')
      break
else:
  print('APPROVED')

Buggy submission (verdict: Runtime Error):
n = int(input().split())
for a in list(map(int, input().split())):
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      print('DENIED')
      break
else:
  print('APPROVED')