qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
import math


def solve(num):
        count = 0
        for i in range(1, int(math.sqrt(num)) + 1):
                if num % i == 0:
                        if (num // i) != i:
                                count += 2
                        else:
                                count += 1
        if count == 8:
                return 1
        else:
                return 0

count = 0
for i in range(1, N+1):
        if i % 2 == 1:
                if solve(i):
                        print(i)
                        count += 1
print(count)


Fixed code:


N = int(input())
import math


def solve(num):
        count = 0
        for i in range(1, int(math.sqrt(num)) + 1):
                if num % i == 0:
                        if (num // i) != i:
                                count += 2
                        else:
                                count += 1
        if count == 8:
                return 1
        else:
                return 0

count = 0
for i in range(1, N+1):
        if i % 2 == 1:
                if solve(i):
                        count += 1
print(count)
Buggy code:
N = int(input())
ans = 0
for i in range(1, N+1):
    count = 0
    for j in range(1, i+1):
        if i % j == 0 and i % 2 != 0:
            count += 1
    if count == 8 and i % 2 != 0:
        ans += 1
        print(i)
print(ans)

Fixed code:
N = int(input())
ans = 0
for i in range(1, N+1):
    count = 0
    for j in range(1, i+1):
        if i % j == 0 and i % 2 != 0:
            count += 1
    if count == 8 and i % 2 != 0:
        ans += 1
print(ans)
Buggy code:
N = int(input())

count = 0

for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, i):
    if i % j == 0:
      tmp += 1
  if tmp == 8:
    count += 1
    
print(count)
  

Fixed code:
N = int(input())

count = 0

for i in range(1, N+1, 2):
  tmp = 0
  for j in range(1, i+1):
    if i % j == 0:
      tmp += 1
  # print(tmp)
  if tmp == 8:
    count += 1
    
print(count)
Buggy code:
n=int(input())

def yakusu_num(x):
    cnt=0
    for i in range(x):
        if x%(i+1)==0:
            cnt+=1
    return(cnt)

cnt=0
for i in range(-(-105//2)):
  if yakusu_num(2*i+1)==8:
    cnt+=1
  
print(cnt)

Fixed code:
n=int(input())

def yakusu_num(x):
    cnt=0
    for i in range(x):
        if x%(i+1)==0:
            cnt+=1
    return(cnt)

ans=0
for i in range(-(-n//2)):
  if yakusu_num(2*i+1)==8:
    ans+=1
  
print(ans)
Buggy code:
n=input()
s=0
a=[105,135,165,195,189]
for i in a:
  if n>=i:
    s+=1
print(s)

Fixed code:
n=int(input())
s=0
a=[105,135,165,195,189]
for i in a:
 if n>=i:
  s+=1
print(s)
Buggy code:
N=int(input())
def yakusuu(n):
  num=0
  for i in range(1,n):
    if n%i==0:
      num=num+1
  return num==8
ans=0
for i in range(n):
  if def(i):
    ans=ans+1
print(ans)
  
      

Fixed code:
n=int(input())
def yakusuu(n):
  num=0
  if n%2==1:
    for i in range(1,n+1):
      if n%i==0:
        num=num+1
  return num 

ans=0
for i in range(n+1):
  if yakusuu(i)==8:
    ans=ans+1
print(ans)
Buggy code:
n = int(input())
b = 0
for i in range(1, n+1):
  if i % 2 == 1:
    a = 0
    for j in range(1, i+1):
      if i % j == 0:
        a += 1
    if a == 8:
      b += 1

Fixed code:
n = int(input())
b = 0
for i in range(1, n+1):
  if i % 2 == 1:
    a = 0
    for j in range(1, i+1):
      if i % j == 0:
        a += 1
    if a == 8:
      b += 1
print(b)
Buggy code:
N = int(input())

count = 0
for i in range(1, N+1, 2):
    c = 0
    for j in range(1, i+1):
        if i % j == 0:
            c += 1
    
    if c == 8:
        print(i)
        count += 1
else:
    print(count)

Fixed code:
N = int(input())

count = 0
for i in range(1, N+1, 2):
    c = 0
    for j in range(1, i+1):
        if i % j == 0:
            c += 1
    
    if c == 8:
        count += 1
else:
    print(count)
Buggy code:
n = int(input())

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)

    # print(divisors)
    return divisors

ans = 0

for i in range(1, n+1):
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)


Fixed code:
n = int(input())

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)

    # print(divisors)
    return divisors

ans = 0

for i in range(1, n+1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1

print(ans)
Buggy code:
n=int(input())
ans=0
for i in range(105,n+1,2):
  cnt=0
  for j in range(3,i):
    if i%j==0:
      cnt+=1
  if cnt==8:
    ans+=1
print(ans)

Fixed code:
n = int(input())
ans = 0
for i in range(1, n+1):
    if i % 2 == 1:
        cnt = 0
        for j in range(1, i+1):
            if i % j == 0:
                cnt += 1

        if cnt == 8:
            ans += 1
print(ans)
Buggy code:
n=int(input())
print(len([i for i in range (1,int(input())+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))

Fixed code:
n=int(input())
print(len([i for i in range (1,n+1) if i%2 == 1 and len([1 for x in range(1,i+1) if i%x==0]) == 8]))
Buggy code:
N=int(input())
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)
    # divisors.sort()
    return divisors

cnt=0
for i in range(N):
    divsors = make_divisors(i)
    if len(divsors) == 8:
        cnt += 1

print(cnt)

Fixed code:
N=int(input())
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)
    divisors.sort()
    return divisors

cnt=0
for i in range(1, N+1):
    divsors = make_divisors(i)
    if i % 2 != 0 and len(divsors) == 8:
        cnt += 1

print(cnt)
Buggy code:
n = int(input())

count = 0
c = 0

for i in range(1,n + 1):
  if n % 2 != 0:
    for j in range(1,i + 1):
      if i % j == 0:
        count += 1
    if count == 8:
      c += 1
    count = 0

print(c)

Fixed code:
n = int(input())

count = 0
c = 0

for i in range(1,n + 1):
  if i % 2 != 0:
    for j in range(1,i + 1):
      if i % j == 0:
        count += 1
    if count == 8:
      c += 1
    count = 0

print(c)
Buggy code:
n = int(input())
ans = 0
for i in range(1,n+1,2) :
  cnt = 0
    for j in range(1,i+1) :
      if i % j == 0 :
        cnt += 1
    if cnt == 8 :
      ans += 1
print(ans)     

Fixed code:
n = int(input())
ans = 0
for i in range(1,n+1,2) :
        cnt = 0
        for j in range(1,i+1) :
                if i % j == 0 :
                        cnt += 1
        if cnt == 8 :
                ans += 1
print(ans)
Buggy code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:15:46 2020

@author: black
"""
def check(x):
    div = [1]
    for j in range(1, x):
        if (x)%(j+1) == 0:
            div.extend([j+1])
            if (i+1)%(j+1) == 0:
                div.extend([j+1])
    return len(div)




N = int(input())
ans = []

for x in range(1, N+1):
    if x%2 == 1:
        if check(x) == 8:
            ans.extend([x])


print(len(ans))

Fixed code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 09:15:46 2020

@author: black
"""
def check(x):
    div = [1]
    for j in range(1, x):
        if (x)%(j+1) == 0:
            div.extend([j+1])
    return len(div)




N = int(input())
ans = []

for x in range(1, N+1):
    if x%2 == 1:
        if check(x) == 8:
            ans.extend([x])


print(len(ans))
Buggy code:
n = int(input())

for i in range(1, n+1, 2):
    count = 0
    for j in range(1, n+1):
        if (i % j) == 0:
            count += 1
    if count == 8:
        print(i)


Fixed code:
n = int(input())
ans = 0
for i in range(1,n+1):
    count = 0
    if i % 2 == 1:
        for j in range(1,i+1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
print(ans)
Buggy code:
n = int(input())


def count_divisors():
  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)
  length = len(divisors)
  return length


l = []
for i in range(1, n + 1):
  if i % 2 == 0:
    continue
  else:
    if count_divisors(i) == 8:
      l.append(i)

      
print(len(l))


Fixed code:
n = int(input())


def count_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)
  length = len(divisors)
  return length


l = []
for i in range(1, n + 1):
  if i % 2 == 0:
    continue
  else:
    if count_divisors(i) == 8:
      l.append(i)

      
print(len(l))
Buggy code:
n = int(input())
count = 0

for i in range(1, n):
  if i % 2 == 1:
    divisors_count = 0
    for a in range(1, i):
      if i % a == 0:
        divisors_count += 1
    if divisors_count == 8:
      count += 1

print(count)

Fixed code:
n = int(input())
count = 0

for i in range(1, n + 1):
  if i % 2 == 1:
    divisors_count = 0
    for a in range(1, i + 1):
      if i % a == 0:
        divisors_count += 1
    if divisors_count == 8:
      count += 1

print(count)
Buggy code:
n = int(input())
ans = []
for i in range(n):
  temp = []
  for j in range(1, i + 1, 2):
    if i % j == 0:
      temp.append(j)
  if len(temp) == 8:
    ans.append(i)
    
print(len(ans))

Fixed code:
n = int(input())
ans = []
for i in range(1, n + 1):
  temp = []
  for j in range(1, i + 1, 2):
    if i % j == 0:
      temp.append(j)
  if len(temp) == 8:
    ans.append(i)
    
print(len(ans))
Buggy code:
N = int(input())
a = 0

for i in range(1,1+N,2):
  b = 0
  for j in range(1,1+i,2):
    if i%j==0:
      b+=1
    if n==8:
      a+=1

print(a)

Fixed code:
N = int(input())
a = 0

for i in range(1,1+N,2):
  n = 0
  for j in range(1,1+i,2):
    if i%j==0:
      n+=1
    if n==8:
      a+=1

print(a)
Buggy code:
N = int(input())
ans = 0
for a in range(1,N+1):
  c = 0
  for b in range(1,a+1):
    if a % b == 0:
      c += 1
  if c == 8:
    ans += 1
print(ans)

Fixed code:
N = int(input())
ans = 0
for a in range(1,N+1):
  if a%2==0:
    continue
  c = 0
  for b in range(1,a+1):
    if a % b == 0:
      c += 1
  if c == 8:
    ans += 1
print(ans)
Buggy code:
N = int(input())
x = 1
count = 0
while x < N:
  a = 0
  k = 1
  while k < N:
    if N%k == 0:
      a += 1
    k += 2
  if a == 8:
    count += 1
  x += 2

print(count)

Fixed code:
N = int(input())
x = 1
count = 0

while x <= N:
  a = 0
  k = 1
  while k <= x:
    if x%k == 0:
      a += 1
    k += 2
  if a == 8:
    count += 1
  x += 2

print(count)
Buggy code:
n = int(input())
res = 0
for i in range(1,n+1, 2):
	if i % 1:
		cnt = 0
		for j in range(i+1):
			if i % j == 0:
				cnt += 1
		if cnt == 8:
			res += 1

print(res)

Fixed code:
n=int(input())
ans = 0
for i in range(1,n+1,2):
  cnt = 0
  for j in range(1,i+1):
    if i%j == 0:
      cnt += 1
  if cnt == 8:
    ans += 1
print(ans)
Buggy code:
n =int(input()) 
t = 0
for k in range(1,n,2):
  K = k
  ans = 1
  for i in range(1,int(K/2)+1,2):
    if k % i == 0:
      ans  += 1
  if ans == 8:
    t += 1
print(t)

Fixed code:
n =int(input()) 
t = 0
for k in range(1,n+1,2):
  K = k
  ans = 1
  for i in range(1,int(K/2)+1,2):
    if k % i == 0:
      ans  += 1
  if ans == 8:
    t += 1
print(t)
Buggy code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()

ans=0
for k in range(5,n+1):
    c=0
    for i in range(1,int(k**0.5)+1,2):
        if k%i==0:
            c+=2
    if i**2==k:
        c-=1
    if c==8:
        ans+=1
print(ans)

Fixed code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()

ans=0
for k in range(105,n+1,2):
    c=0
    for i in range(1,int(k**0.5)+1):
        if k%i==0:
            c+=2
    if i**2==k:
        c-=1
    if c==8:
        ans+=1
print(ans)
Buggy code:
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<195)
    print(3)
else:
    print(4)

Fixed code:
#106
n = int(input())
if(n<105):
    print(0)
elif(n<135):
    print(1)
elif(n<165):
    print(2)
elif(n<189):
    print(3)
elif(n<195):
    print(4)
else:
    print(5)
Buggy code:
import math

N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


list(map(search_divisor_num,list(range(1,N + 1))[:: 2])).count(8)

Fixed code:
import math

N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


print(int(list(map(search_divisor_num,list(range(1,N + 1))[:: 2])).count(8)))
Buggy code:
n = int(input())
count = 0
for i in range(105, n + 1):
    insu = 0
    if i % 2 != 0:
        continue
    for j in range(1, i + 1):
        if i % j == 0:
            insu += 1
    if insu == 8:
        count += 1
print(count)


Fixed code:
n = int(input())
count = 0
for i in range(105, n + 1):
    insu = 0
    if i % 2 == 0:
        continue
    for j in range(1, i + 1):
        if i % j == 0:
            insu += 1
    if insu == 8:
        count += 1
print(count)
Buggy code:
N = int(input())
cnt = 0

for i in range(1,N+1)
    if i % 2 == 0:continue
    c = 0
    for j in range(1,N+1):
        if cnt > 8:
            cnt -= 1:continue
        if i % j == 0:
            c += 1
    if c ==8:
        cnt += 1
print(cnt)

Fixed code:
N = int(input())
cnt = 0
for i in range(1,N+1):
    if i % 2 == 0:continue
    c = 0
    for j in range(1,N+1):
        if c > 8:
            cnt -= 1
            continue
        if i % j == 0:
            c += 1
    if c ==8:
        cnt += 1
print(cnt)
Buggy code:
n = int(input())
cnt = 0
ans = 0

for i in range(105, n + 1, 2):
    for j in range(1, n + 1):
        if i%j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
    cnt = 0
print(ans

Fixed code:
n = int(input())

ans = 0
for i in range(1, n + 1, 2):
    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1

print(ans)
Buggy code:
N = int(inut())
if N<105:
  print(0)
elif N<135:
  print(1)
elif N<165:
  print(2)
elif N<189:
  print(3)
elif N<195:
  print(4)
else:
  print(5)

Fixed code:
N = int(input())
if N<105:
  print(0)
elif N<135:
  print(1)
elif N<165:
  print(2)
elif N<189:
  print(3)
elif N<195:
  print(4)
else:
  print(5)
Buggy code:
N = int(input())
ans = 0
for i in range(1, N+1):
  a = 0
  for j in range(1, i+1):
    if i % j == 0:
      a += 1
  if a == 8:
    ans += 1
print(ans)

Fixed code:
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 2 == 0:
    continue
  a = 0
  for j in range(1, i+1):
    if i % j == 0:
      a += 1
  if a == 8:
    ans += 1
print(ans)
Buggy code:
n = input()
ans = 0
for i in range(1, n + 1):
    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1
    if cnt == 8 and cnt % 2 == 1:
        ans += 1
print ans

Fixed code:
n = int(input())
ans = 0
for i in range(1, n + 1):
    cnt = 0
    for j in range(1, i + 1):
        if i % j == 0:
            cnt += 1
    if cnt == 8 and i % 2 == 1:
        ans += 1
print(ans)
Buggy code:
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())
ans = 0
if n < 105:
    print(0)
else:
    for i in range(105,n+1,2):
        m = make_divisors(i)
        if len(m) == 8:
            ans += 1

print(ans)

Fixed code:
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())
ans = 0
if n < 105:
    print(0)
else:
    for i in [i for i in range(105,n+1) if i %2 == 1]:
        m = make_divisors(i)
        if len(m) == 8:
            ans += 1   
    print(ans)
Buggy code:
import sys
input = sys.stdin.readline
n=int(input())
import fractions

ans=0
if n<=104:
    print(0)
else:
    ans=0
    for i in range(105,n+1,2):
        c=0
        for j in range(1,i+1):
            if i%j==0:
                c+=1
        if c==8:
            ans+=1
            print(i)
    print(ans)

Fixed code:
import sys
input = sys.stdin.readline
n=int(input())

ans=0
if n<=104:
    print(0)
else:
    ans=0
    for i in range(105,n+1,2):
        c=0
        for j in range(1,i+1):
            if i%j==0:
                c+=1
        if c==8:
            ans+=1
    print(ans)
Buggy code:
n = int(input())

def cnt(x):
	return sum(1 for i in range(1, x+1) if x%i == 0)

sum(1 for i in range(1, n+1, 2) if cnt(i) == 8)

Fixed code:
n = int(input())
def cnt(x):
	return sum(1 for i in range(1, x+1) if x%i == 0)
print(sum(1 for i in range(1, n+1, 2) if cnt(i) == 8))
Buggy code:
N = int(input())
cnt=  0
ans =0
for i in range(1, N+1, 2):
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
    if cnt == 0:
        ans += 1
print(ans)


Fixed code:
N = int(input())
#cnt = 0
ans = 0
for i in range(1, N+1, 2):
    cnt = 0 
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)
Buggy code:

def countDiv(x):
  count = 0
  for i in range(1,n+1):
    if x % i == 0:
      count += 1
  return count

n = int(input())
ans = 0
for i in range(1,n+1):
  if countDiv(i) == 8:
    ans += 1

print(ans)

Fixed code:
def countDiv(x):
  count = 0
  for i in range(1,x+1):
    if x % i == 0:
      count += 1
  return count
 
n = int(input())
ans = 0
for i in range(1,n+1,2):
  #print(i, countDiv(i))
  if countDiv(i) == 8:
    ans += 1
 
print(ans)
Buggy code:
N = int(input())
cnt =  0
ans = 0
for i in range(1, N+1, 2):
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
    if cnt == 8:
        ans += 1
print(ans)


Fixed code:
n = int(input())
ans = 0

for i in range(1, n+1, 2):
    cnt = 0
    for j in range(1, i+1):
        if i % j == 0:
            cnt += 1
            if cnt == 8:
                ans += 1

print(ans)
Buggy code:
n=int(input())
if n<105:print(0)
elif n<3*5*7:print(1)
elif n<3*5*9:print(2)
elif n<3*5*11:print(3)
else:print(4)


Fixed code:
n=int(input())
if n<105:print(0)
elif n<3*5*9:print(1)
elif n<3*5*11:print(2)
elif n<3*7*9:print(3)
elif n<3*5*13:print(4)
else:print(5)
Buggy code:
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

c = 0
for i in range(2,N+1):
    s = factorization(i)
    ans = 1
    for j in range(len(s)):
        ans *= (s[j][1] +1)
    if ans == 8:
        c += 1

print(c)
    

Fixed code:
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i ==0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr

c = 0
for i in range(2,N+1):
    if i%2 == 1:
        s = factorization(i)
        ans = 1
        for j in range(len(s)):
            ans *= (s[j][1] +1)
        if ans == 8:
            c += 1

print(c)
Buggy code:
N, M, Q = map(int, input().split())
trains = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    trains[L][R] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        trains[i][j] += trains[i - 1][j]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        trains[i][j] += trains[i][j - 1]
print(trains)
ans = [0] * Q
for k in range(Q):
    p, q = map(int, input().split())
    ans[k] = trains[q][q] - trains[p-1][q] - trains[q][p-1] + trains[p-1][p-1]
for A in ans:
    print(A)

Fixed code:
N, M, Q = map(int, input().split())
trains = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    trains[L][R] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        trains[i][j] += trains[i - 1][j]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        trains[i][j] += trains[i][j - 1]
ans = [0] * Q
for k in range(Q):
    p, q = map(int, input().split())
    ans[k] = trains[q][q] - trains[p-1][q] - trains[q][p-1] + trains[p-1][p-1]
for A in ans:
    print(A)
Buggy code:
from copy import deepcopy

n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

cnt = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    cnt[l][r] += 1

acc = cnt.deepcopy()
for i in range(n):
    for j in range(n):
        tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]
        acc[i + 1][j + 1] += tmp

for p, q in pq:
    p -= 1
    ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]
    print(ans)


Fixed code:
n, m, q = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(m)]
pq = [list(map(int, input().split())) for _ in range(q)]

cnt = [[0] * (n + 1) for _ in range(n + 1)]
for l, r in lr:
    cnt[l][r] += 1

acc = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(n):
        tmp = acc[i][j + 1] + acc[i + 1][j] - acc[i][j]
        acc[i + 1][j + 1] = tmp + cnt[i + 1][j + 1]

for p, q in pq:
    p -= 1
    ans = acc[q][q] - acc[p][q] - acc[q][p] + acc[p][p]
    print(ans)