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

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if n != 1 and n !=0:
    a = cmb(n,2)
else:
    a = 0

if m != 1 and m !=0:
    b = cmb(m,2)
else:
    b = 0
print(a + b)

Buggy submission (verdict: Runtime Error):
#n = int(input())
n,m = map(int,input().split())
#a_L = list(map(int,input().split()))

nCr = {}


def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if n != 1:
    a = cmb(n,2)
else:
    a = 0

if m != 1:
    b = cmb(m,2)
else:
    b = 0
print(a + b)
Problem p02547 (python)

Fixed submission:
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  count = 0
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()

Buggy submission (verdict: Runtime Error):
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()
Problem p02571 (python)

Fixed submission:
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + len(T) + 1])) for i in range(d + 1)))

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + d + 1])) for i in range(d)))
Problem p02622 (python)

Fixed submission:
count = 0
a = input()
b = input()

for i in range(len(a)):
    if a[i]!=b[i]:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
count = 0
a = input()
b = input()

for i in len(a):
    if a[i]!=b[i]:
        count += 1

print(count)
Problem p03804 (python)

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

d = n - m + 1
flg = False
for i in range(d):
    for j in range(d):
        if a[i][j : j + m] == b[0]:
            for k in range(1, m):
                if a[i + k][j : j + m] != b[k]:
                    break
            else:
                print("Yes")
                flg = True
                break
    if flg:
        break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flg = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if a[i][j : j + m] == b[0]:
            for k in range(i + 1, i + m):
                if a[k][j : j + m] != b[k]:
                    break
            else:
                print("Yes")
                flg = True
                break
    if flg:
        break
else:
    print("No")
Problem p02578 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))

ans = 0
high = 0
for i in range(1,N):
    af = A[i]
    bf = A[i-1]
    if bf > high:
        high = bf
    if high > af:
        ans += high - af

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input()))

ans = 0
high = 0
for i in range(1,N):
    if high < A[i-1]:
        high = A[i-1]
    if high > A[i]:
        ans += high - A[i]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

ans = 0
high = 0
for i in range(1,N):
  if A[i-1] > high:
    high = A[i-1]
  if A[i] < hihg:
    ans += high - A[i]
    
print(ans)
Problem p02701 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]

print(len(set(S)))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for i in range(N)]

print(len(set(S)))
Problem p03135 (python)

Fixed submission:
T,X= map(float,input().split( ))

ans = T/X
print(ans)

Buggy submission (verdict: Runtime Error):
 #include <bits/stdc++.h>
 using namespace std;

 int main() {
 	double ans;
 	double T,X;
 	cin >> T>>X;
 	ans = T/(double(X));
 	cout << ans << endl;
 }
Problem p03137 (python)

Fixed submission:
N,M =map(int,input().split( ))
X = list(map(int,input().split( )))


if N >= M or M == 1:
	ans = 0
elif N == 1:
	X.sort()
	ans = X[-1] -X[0]
else:
	X.sort()
	D = []
	for i in range(M-1):
		d = X[i+1] - X[i]
		D.append([i,d])
	#print(X)

	D.sort(key = lambda x:(x[1]),reverse =True)
	#print(D)
	sikiri = []
	for i in range(N-1):
		sikiri.append(D[i][0])
	sikiri.sort()
	ans = X[sikiri[0]] - X[0]
	for i in range(N-1):
		l = sikiri[i]+1
		if i == N-2:
			r = M-1
		else:
			r = sikiri[i+1]
		ans+= X[r]-X[l]
print(ans)

Buggy submission (verdict: Runtime Error):
N,M =map(int,input().split( ))
X = list(map(int,input().split( )))


if N >= M:
	ans = 0
else:
	X.sort()
	D = []
	for i in range(M-1):
		d = X[i+1] - X[i]
		D.append([i,d])
	#print(X)

	D.sort(key = lambda x:(x[1]),reverse =True)
	#print(D)
	sikiri = []
	for i in range(N-1):
		sikiri.append(D[i][0])
	sikiri.sort()
	ans = X[sikiri[0]] - X[0]
	for i in range(N-1):
		l = sikiri[i]+1
		if i == N-2:
			r = M-1
		else:
			r = sikiri[i+1]
		ans+= X[r]-X[l]
print(ans)
Problem p03221 (python)

Fixed submission:
N ,M = map(int,input().split( ))
l = []
for i in range(M):
	p, y = map(int,input().split( ))
	l.append((y, p, i))
l.sort()


p_count  = [0 for i in range(N)]

l_2 = []
for i in range(M):
	p_count[l[i][1]-1] += 1
	l_2.append((l[i][2], l[i][1], p_count[l[i][1]-1]))
l_2.sort()
for i in range(M):
	print(str(l_2[i][1]).zfill(6)+str(l_2[i][2]).zfill(6))

Buggy submission (verdict: Runtime Error):
N ,M = map(int,input().split( ))
P = []
Y = []

l = []
for i in range(N):
	l.append([])

for i in range(M):
	p, y = map(int,input().split( ))
	P.append(p)
	Y.append(y)
	l[P[i]-1].append(Y[i])

for i in range(N):
	l[i].sort()


for i in range(M):
	Y[i] = l[P[i]-1].index(Y[i]) + 1
	while len(str(P[i])) < 6 :
		P[i] = '0' + str(P[i])
	while len(str(Y[i])) < 6 :
		Y[i] = '0' + str(Y[i])
	print(P[i] + Y[i])

Buggy submission (verdict: Runtime Error):
N ,M = map(int,input().split( ))
P = []
Y = []
for i in range(M):
	p, y = map(int,input().split( ))
	P.append(p)
	Y.append(y)

l = []

for i in range(N):
	l.append([])

for i in range(M):
	l[P[i]-1].append(Y[i])

for i in range(N):
	l[i].sort()

for i in range(M):
	Y[i] = l[P[i]-1].index(Y[i]) + 1

for i in range(M):
	while len(str(P[i])) < 6 :
		P[i] = '0' + str(P[i])

for i in range(M):
	while len(str(Y[i])) < 6 :
		Y[i] = '0' + str(Y[i])

for i in range(M):
	print(P[i] + Y[i])
Problem p03286 (python)

Fixed submission:
N = int(input())
S = ''
ans_l = []
if N != 0:
	while N != 0:
		if N % 2 == 0:
			N = N // (-2)
			S = '0' + S
		else:
			N = (N-1) // (-2)
			S = '1' + S
else:
	S = '0'
print(S)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = ''
ans_l = []
if N != 0:
	while N != 0:
		if N % 2 == 0:
			N = N // (-2)
  			S = '0' + S
		else:
  			N = (N-1) // (-2)
  			S = '1' + S
else:
	S = '0'
print(S)
Problem p03307 (python)

Fixed submission:
n=int(input())
ans=n
if n%2==1:
    ans=2*n
print(ans)

Buggy submission (verdict: Runtime Error):
import statistics
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
	A[i] = A[i] - (i+1)
A.sort()

if N % 2 == 0:
	med1 = A[N // 2 - 1]
	med2 = A[N //2]
	ans = min(sum([abs(a - med1) for a in A]), sum([abs(a - med2) for a in A]))

else:
	med = A[N // 2]
	ans = sum([abs(a - med) for a in A])
	
print(ans)
Problem p03631 (python)

Fixed submission:
N  = list(input())
if N[0] == N[2]:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
N  = list(input())
if N[0] == N[2]:
	print('Yes')
else:
	pritn('No')
Problem p02989 (python)

Fixed submission:
N = int(input())
l = list(map(int,input().split()))

new_l = sorted(l)
half1 = new_l[N//2-1]
half2 = new_l[N//2]

if half1 == half2:
    print(0)
else:
    print(half2-half1)

Buggy submission (verdict: Runtime Error):
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1
Problem p03036 (python)

Fixed submission:
r,D,x =map(int,input().split())
 
for i in range(10):
	x = r*x-D
	print(x)

Buggy submission (verdict: Runtime Error):
#! python3
#  solve127A.py

age,cost = map(int,input().split())

if age <= 5:
    cost = 0
elif 6 <= age <= 12:
    cost = cost//2
elif 7 <= age:
    cost = cost

print(cost)

Buggy submission (verdict: Runtime Error):
r,D,x =map(int,input().split())

for i in range(10)
	x = r*x-D
  	print(x)
Problem p03075 (python)

Fixed submission:
l = [int(input()) for i in range(6)]

if l[4]-l[0]>l[5]:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
l = [int(input()) for i in range(4)]

for i in range(4):
  for j in range(4):
    if l[i]*l[j]>l[4]:
      print(":(")
      break
    else:
      print("Yay!")

Buggy submission (verdict: Runtime Error):
l = list(map(int,input().split()))

for i in range(4):
  for j in range(4):
    if l[i]*l[j]>k:
      print(":(")
      break
    else:
      print("Yay!")
Problem p03135 (python)

Fixed submission:
T,X = map(int,input().split())
print(T/X)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
print(a/b)
Problem p03315 (python)

Fixed submission:
s = input()

print(s.count("+")-s.count("-"))

Buggy submission (verdict: Runtime Error):
a = list(map(str,input().split()))
 
num = 0
 
for i in range [0,1,2,3]:
  if a[i] == "+":
    num +=1
  else:
    num -=1
 
print(num)

Buggy submission (verdict: Runtime Error):
a = list(map(str,input().split()))

num = 0

for i in range len a:
  if a[i] = "+":
    num +=1
  else:
    num -=1

print(num)
Problem p02970 (python)

Fixed submission:
n,d = (int(x) for x in input().split())
if n % (2*d + 1) == 0:
  print(n//(2*d + 1))
else:
  print(n//(2*d + 1) + 1)

Buggy submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
if n//(2*d) = 0:
  print(n/(2*d))
else:
  print(n/(2*d)+1)

Buggy submission (verdict: Runtime Error):
n,d = (int(x) for x in input().split())
print(n/2d)

Buggy submission (verdict: Runtime Error):
N,D = array(input(),input())
print(roundup(N/2D ,0)
Problem p02693 (python)

Fixed submission:
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%K==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a=1
if a==1:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
a=0
for i in range(A,B+1):
  if i%k==0:
    a=1
if a=1:
  print("OK")
else:
  print("NG")
Problem p02550 (python)

Fixed submission:
from collections import defaultdict
n, x, m = map(int, input().split())
now = x
ans = x
d = defaultdict(int)
repeat = []

for i in range(n):
    now = (now**2)%m
    d[now] += 1
    repeat.append(now)
    if d[now] > 1:
        break

for g in range(len(repeat)):
    if repeat[g] == now:
        break
    else:
        ans += repeat[g]
        n -= 1

repeat = repeat[g:-1] 
n -= 1
if len(repeat) != 0:
    ans += sum(repeat)*(n//len(repeat)) + sum(repeat[:n%len(repeat)])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n, x, m = map(int, input().split())
if x == 0:
    print(0)
    exit()
now = x
ans = x
d = defaultdict(int)
repeat = []

for i in range(n):
    now = (now**2)%m
    d[now] += 1
    repeat.append(now)
    if d[now] > 1:
        break

for g in range(len(repeat)):
    if repeat[g] == now:
        break
    else:
        ans += repeat[g]
        n -= 1
repeat = repeat[g:-1] 
n -= 1

ans += sum(repeat)*(n//len(repeat)) + sum(repeat[:n%len(repeat)])
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
n, x, m = map(int, input().split())
now = x
ans = x
d = defaultdict(int)
repeat = []

for i in range(n):
    now = (now**2)%m
    d[now] += 1
    repeat.append(now)
    if d[now] > 1:
        break

for g in range(len(repeat)):
    if repeat[g] == now:
        break
    else:
        ans += repeat[g]
        n -= 1
repeat = repeat[g:-1] 
n -= 1

ans += sum(repeat)*(n//len(repeat)) + sum(repeat[:n%len(repeat)])
print(ans)
Problem p02881 (python)

Fixed submission:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n=int(input())
a = make_divisors(n)
ans = 11451481019191919191919
for i in a:
	ans = min(ans, i+n/i)
	
print(int(ans-2))

Buggy submission (verdict: Runtime Error):
import sympy
n=int(input())
a = sympy.divisors(n)
ans = 11451481019191919191919
for i in a:
	ans = min(ans, i+n/i)
	
print(int(ans-2))
Problem p02984 (python)

Fixed submission:
N = int(input())  
A = [int(i) for i in input().split()]

ans = []

sumA = sum(A)
sum_even = 2*sum(A[1 : N : 2])
ans_i = sumA - sum_even
ans.append(ans_i)

for i in range(N-2):
	ans_i = 2*A[i] - ans_i
	ans.append(ans_i)

ans.append(2*A[-1] - ans[0])

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())  
A = [int(i) for i in input().split()]

a = np.eye(N, k=0)+np.eye(N, k=1) 
a[N-1,0]=1

inv = np.linalg.inv(a)
A = np.array(A)

ans = 2*np.dot(inv, A)
ans = list(np.array(ans, dtype="int"))

ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)
Problem p02990 (python)

Fixed submission:
import math

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    if n-k+1-i<0:
        print(0)
    else:
        print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)

Buggy submission (verdict: Runtime Error):
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,k=map(int,input().split())
mod=10**9+7


for i in range(1,k+1):
    print(comb(n-k+1,i)*comb(k-1,i-1)%mod)
Problem p03013 (python)

Fixed submission:
N,M = (int(i) for i in input().split()) 
a = set(int(input()) for i in range(M))

mod=10**9+7

dp=[0]*(N+1)

dp[0]=1
if 1 in a:
	dp[1]=0
else:
	dp[1]=1

for i in range(0, N-1):
	if i+2 in a:
		dp[i+2]=0
	else:
		dp[i+2]+=dp[i+1]+dp[i]
	
print(dp[N]%mod)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
j = 0
dp = [0] * 100100
dp[0] = 1
for i in range(1,N+1):
    if i == A[j]:
        j += 1
        dp[i] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= 10**9+7
print(dp[N])
Problem p03209 (python)

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

patty = [2**(i+1)-1 for i in range(n+1)][::-1]
length = [2**(i+2)-3 for i in range(n+1)][::-1]

ans=0
end=[0,1,2,3,3]

for i in range(n):
    hambergar=[1,1+length[i+1],2+length[i+1],2+2*length[i+1],3+2*length[i+1]]
    if i==n-1:
        ans+=end[x-1]
    else:
        if hambergar[0]<x and x<hambergar[2]:
            x-=1
        
        elif hambergar[2]<x and x<hambergar[4]:
            ans+=patty[i+1]+1
            x-=hambergar[2]
        
        elif hambergar[2]==x:
            ans+=patty[i+1]+1
            break

        elif hambergar[4]==x:
            ans+=patty[i]
            break
        
        elif hambergar[4]<x or x<=1:
            break

print(ans)

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())

patty = [2**(i+1)-1 for i in range(n+1)][::-1]
length = [2**(i+2)-3 for i in range(n+1)][::-1]

ans=0
end=[0,1,2,3,3]

for i in range(n):
    hambergar=[1,1+length[i+1],2+length[i+1],2+2*length[i+1],3+2*length[i+1]]
    if i==n-1:
        ans+=end[x-1]
    else:
        if hambergar[0]<x and x<hambergar[2]:
            x-=1
        
        elif hambergar[2]<x and x<=hambergar[4]:
            ans+=patty[i+1]+1
            x-=hambergar[2]
        
        elif hambergar[2]==x:
            ans+=patty[i+1]+1
            break
        
        elif hambergar[4]<x or x<=1:
            break

print(ans)
Problem p03242 (python)

Fixed submission:
n=list(input())
for i in range(3):
  if n[i]=='1':
    n[i]='9'
  elif n[i]=='9':
    n[i]='1'
ans=''
for i in range(3):
  ans+=n[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
for i in range(3):
  if n[i]=='1':
    n[i]='9'
  if n[i]=='9':
    n[i]='1'
print(n)
Problem p03804 (python)

Fixed submission:
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    for g in range(n-m+1):
        d=[]
        for l in range(m):
            d.append(a[l+i][g:g+m])
        if d==b:
            print("Yes")
            exit()
print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(m):
    for g in range(m):
        d=[]
        for l in range(m):
            d.append(a[l+i][g:g+m])
        if d==b:
            print("Yes")
            exit()
            
print("No")
Problem p02580 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
input = sys.stdin.buffer.readline
H, W, M = map(int, input().split())

HH = [0]*H
WW = [0]*W
d = set()
for line in readlines():
    h, w = map(int, line.split())
    h -= 1
    w -= 1
    d.add((h, w))
    HH[h] += 1
    WW[w] += 1

m = -1
argm = []
for i, c in enumerate(HH):
    if c > m:
        m = c
        argm = [i]
    elif c == m:
        argm.append(i)

mH = m
aH = argm

m = -1
argm = []
for i, c in enumerate(WW):
    if c > m:
        m = c
        argm = [i]
    elif c == m:
        argm.append(i)

mW = m
aW = argm

ans = mH + mW
for h in aH:
    for w in aW:
        if (h, w) not in d:
            break
    else:
        continue
    break
else:
    ans -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
from heapq import heapify, heappop, heappush
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
input = sys.stdin.readline

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
S = [input().rstrip() for _ in [0]*H]
print(S[0])

INF = 10**10
D = [[INF]*W for _ in [0]*H]
used = set()

q = []
heappush(q, (0, Ch*W+Cw))

dirs = [(-1, 0), (1, 0), (0, 1), (0, -1)]
wps = [
    [(-2, -2), (-2, -1), (-2, 0), (-2, 1), (-2, 2), (-1, -1), (-1, 1)],
    [(2, 2), (2, -1), (2, 0), (2, 1), (2, 2), (1, -1), (1, 1)],
    [(-2, 2), (-1, 2), (0, 2), (1, 2), (2, 2), (-1, 1), (1, 1)],
    [(-2, -2), (-1, -2), (0, -2), (1, -2), (2, -2), (-1, -1), (1, -1)]
]

while q:
    d, ij = heappop(q)
    i, j = divmod(ij, W)
    if D[i][j] > d:
        D[i][j] = d
    else:
        continue
    if i == Dh and j == Dw:
        break

    for k, (di, dj) in enumerate(dirs):
        _i = i + di
        _j = j + dj
        if 0 <= _i < H and 0 <= _j < W:
            if S[_i][_j] == '.':
                if D[_i][_j] <= d:
                    continue
                heappush(q, (d, _i*W+ _j))
            else:
                for di, dj in wps[k]:
                    _i = i + di
                    _j = j + dj
                    if 0 <= _i < H and 0 <= _j < W and S[_i][_j] == '.':
                        if D[_i][_j] <= d+1:
                            continue
                        heappush(q, (d+1, _i*W+_j))

ans = D[Dh][Dw]
print(ans if ans < INF else -1)
Problem p02594 (python)

Fixed submission:
N = int(input())

if N >= 30:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, Q = map(int, input().split())
    *C, = map(int, input().split())

    last = [-1]*(N+1)
    P = []
    for i, c in enumerate(C):
        if last[c] != -1:
            P.append((last[c], i+1))
        last[c] = i+1

    queries = []
    for i in range(Q):
        l, r = map(int, input().split())
        queries.append((l, r, i))

    P.sort()
    queries.sort(reverse=True)

    class BIT():
        def __init__(self, n, x=1):
            self.n = n
            self.T = [0]*(n+1)

        def add(self, i, x):
            while i <= self.n:
                self.T[i] += x
                i += i & -i

        def sum(self, i):
            ret = 0
            while i:
                ret += self.T[i]
                i -= i & -i
            return ret

    bit = BIT(N)
    ans = [0]*Q
    for l, r, i in queries:
        while P and P[-1][0] >= l:
            cl, cr = P.pop()
            bit.add(cr, 1)
        ans[i] = r-l+1-bit.sum(r)

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()
Problem p02679 (python)

Fixed submission:
from math import gcd
from collections import Counter
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)

mod = 10**9 + 7


def modpow(a, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = ret * a % mod
        a = a * a % mod
        n >>= 1
    return ret

col = []
row = []
zero = 0
for a, b in A:
    if a == b == 0:
        zero += 1
        continue
    if a == 0:
        col.append((1,0))
        continue
    elif b == 0:
        row.append((1,0))
        continue
    else:
        g = gcd(abs(a), abs(b))
        a //= g
        b //= g

    if a < 0:
        a *= -1
        b *= -1

    if b > 0:
        col.append((a, b))
    elif b < 0:
        row.append((-b, a))

C = Counter(col)
D = Counter(row)
S = set(col) | set(row)

ans = 1
for s in S:
    if s in C:
        if s in D:
            mul = modpow(2, C[s], mod) + modpow(2, D[s], mod) - 1
            mul %= mod
        else:
            mul = modpow(2, C[s], mod)
    elif s in D:
        mul = modpow(2, D[s], mod)

    ans *= mul
    ans %= mod

ans -= 1
ans += zero
ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
from collections import Counter
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)

mod = 10**9 + 7


def modpow(a, n, mod):
    ret = 1
    while n:
        if n & 1:
            ret = ret * a % mod
        a = a * a % mod
        n >>= 1
    return ret


col = []
row = []
for a, b in A:
    g = gcd(abs(a), abs(b))
    a //= g
    b //= g

    if a < 0:
        a *= -1
        b *= -1

    if a >= 0 and b > 0:
        col.append((a, b))
    elif a > 0 and b <= 0:
        row.append((-b, a))


C = Counter(col)
D = Counter(row)
S = set(col) | set(row)

ans = 1
for s in S:
    if s in C:
        if s in D:
            mul = modpow(2, C[s], mod) + modpow(2, D[s], mod) - 1
        else:
            mul = modpow(2, C[s], mod)
    elif s in D:
        mul = modpow(2, D[s], mod)

    ans *= mul
    ans %= mod

ans -= 1
ans %= mod

print(ans)