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

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 18
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353



n, k = LI()
if k == 1:
    print(0)
else:
    print(n - k)

Buggy submission (verdict: Runtime Error):
def dfs():
    n = int(input())
    weight = list(map(int, input().split()))
    value = list(map(int, input().split()))
    
    
    def knapsack(n, weight, value):
        dp = [i for i in range(n+1)]
        for i in range(3):
            for j in range(weight[i], n+1):
                dp[j] = max(dp[j], dp[j-weight[i]] + value[i])
        return(dp[-1])
    
    
    new_n=knapsack(n=n, weight=weight, value=value)
    print(knapsack(n=new_n, weight=value, value=weight))
 
    
dfs()

Buggy submission (verdict: Runtime Error):
def dfs():
    n = int(input())
    weight = list(map(int, input().split()))
    value = list(map(int, input().split()))

    dp = [i for i in range(n+1)]

    for i in range(3):
        for j in range(weight[i], n+1):
            max(dp[j], dp[j-weight[i]] + value[i])
    return (dp[-1])
  
  
  dfs()
Problem p03032 (python)

Fixed submission:
import math


n, k = list(map(int, input().split()))
que = list(map(int, input().split()))

ans = 0
max_pop_cnt = min(n, k)
for pop_cnt in range(max_pop_cnt+1):
#  pop_cnt+1にしないと、pop_cntが0の場合は消えてしまう。
    for right in range(pop_cnt+1):
        for push_cnt in range((k - pop_cnt)+1):
            ans = max(ans, sum(sorted(que[:pop_cnt-right] + list(reversed(que))[:right])[push_cnt:]))
# reverseにした方がいい。-1で後ろからスライスをとると、0の場合に全部になってしまう。
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
que = list(map(int, input().split()))
ans = 0
pop_push = [(i, k-i) for i in range(k, math.ceil(k/2)-1, -1)]
for pop, push in pop_push:
    left_right = [(j, pop-j) for j in range(pop+1)]
    for left, right in left_right:
        ans = max(ans, sum(sorted(que[:left] + list(reversed(que))[:right])[push:]))
print(ans)
Problem p03035 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b = LI()
if a>=13:
    print(b)
elif 12>=a>=6:
    print(b//2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
def main():
    mod = 10**9+7
    n, m, k = list(map(int, input().split()))
    # 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
    combination = mod_combination(n*m-2, k-2)
    x=y=0
    for i in range(1, n):
        x += i * (n-i)
    for j in range(1, m):
        y += j * (m-j)
    return (((m ** 2) % mod * x % mod) + ((n ** 2) % mod * y % mod)) * combination % mod


def mod_combination(n, r, mod=10**9+7):
    fact = 1
    for i in range(n-r+1, n+1):
        fact = fact * i % mod
    divisor = 1
    for j in range(1, r+1):
        divisor = divisor * j % mod
    return int(fact/divisor)


print(main())

Buggy submission (verdict: Runtime Error):
def main():
    mod = 10**9+7
    n, m, k = list(map(int, input().split()))
    # 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
    combination = mod_combination(n*m-2, k-2)
    x=y=0
    for i in range(1, n):
        x += i * (n-i)
    for j in range(1, m):
        y += j * (m-j)
       
    return (((m ** 2) % mod * x % mod) + ((n ** 2) % mod * y % mod)) * combination % mod


def mod_combination(n, r, mod=10**9+7):
    fact = 1
    for i in range(n-r+1, n+1):
        fact = fact * i % mod
    divisor = 1
    for j in range(1, r+1):
        divisor = divisor * j % mod
    return int(fact/divisor)


main()
Problem p03037 (python)

Fixed submission:
n, k = list(map(int, input().split()))
min_list = []
max_list = []
for i in range(k):
    j, l = list(map(int, input().split()))
    min_list.append(j)
    max_list.append(l)


print(max(0, min(max_list) - max(min_list) + 1))

Buggy submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
min_list = []
max_list = []
for i in range(k):
    j, l = list(map(int, input().split())):
    min_list.append(j)
    max_list.append(l)


print(max(0, min(max_list) - max(min_list) + 1))
Problem p03039 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def mod_combination(n, r, mod=10 ** 9 + 7):
    fact = 1
    for i in range(n - r + 1, n + 1):
        fact = fact * i % mod

    divisor = 1
    for j in range(1, r + 1):
        divisor = divisor * j % mod

    return fact * pow(divisor, mod - 2, mod) % mod


def main():
    mod = 10**9+7
    n, m, k = LI()
    # 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
    combination = mod_combination(n*m-2, k-2)
    x=y=0
    for i in range(1, n):
        x += i * (n-i)
    for j in range(1, m):
        y += j * (m-j)
    return (((m ** 2) % mod * x % mod) + ((n ** 2) % mod * y % mod)) * combination % mod


print(main())

Buggy submission (verdict: Runtime Error):
from math import factorial


mod = 10**9+7
n, m, k = list(map(int, input().split()))
# 　ある配置を固定した時、その2つの配置でmanhattan距離が計算される回数は、他の組み合わせ数。
combination = mod_combination(n*m-2, k-2)

def dfs(arg_one, arg_two, mod):
    arg_squrared = ((arg_one%mod)**2)%mod
    return sum([((i%mod)*(arg_two-i)%mod)%mod*arg_squrared for i in range(1, arg_two)])



def mod_combination(n, r, mod=10**9+7):
    fact = 1
    for i in range(n-r+1, n+1):
        fact = fact * i % mod
    divisor = 1
    for j in range(1, r+1):
        divisor = divisor * j % mod
    return int(fact/divisor)


print(((dfs(m, n, mod) + dfs(n, m, mod))*combination)%mod)
Problem p03074 (python)

Fixed submission:
def main():
    n, k = map(int, input().split())
    s = input()


    cnt = 0
    right = 0
    flag = 1
    j = k + 1 if s[0] == '1' else k
    for i in range(n - 1):
        if s[i]  == '1' and s[i + 1] == '0':
            cnt += 1
        if cnt == j:
            right = i + 1
            flag = 0
            break


    if flag:
        return n


    left = 0
    ret = right - left
    flag = 0

    while True:
        while True:
            if right + 1 >= n:
                flag = 1
                break
            if s[right] == '1' and s[right + 1] == '0':
                right += 1
                break
            right += 1
        while True:
            if s[left] == '0' and s[left + 1] == '1':
                left += 1
                break
            left += 1
        if flag:
            right += 1
        ret = max(ret, right - left)
        if flag:
            break
    return ret


print(main())

Buggy submission (verdict: Runtime Error):
def main():
    n, k = map(int, input().split())
    s = input()


    cnt = 0
    right = 0
    flag = 0
    j = k + 1 if s[0] == '1' else k
    if len(s) == 1:
        if k == 0 and s[0] == '0':
            return 0
        flag = 1
    for i in range(n - 1):
        if i + 1 >= n:
            flag = 1
            break
        if s[i]  == '1' and s[i + 1] == '0':
            cnt += 1
        if cnt == j:
            right = i + 1
            break


    if flag:
        return n


    left = 0
    ret = right - left
    flag = 0

    while True:
        while True:
            if right + 1 >= n:
                flag = 1
                break
            if s[right] == '1' and s[right + 1] == '0':
                right += 1
                break
            right += 1
        while True:
            if s[left] == '0' and s[left + 1] == '1':
                left += 1
                break
            left += 1
        if flag:
            right += 1
        ret = max(ret, right - left)
        if flag:
            break
    return ret


print(main())
Problem p03078 (python)

Fixed submission:
import heapq


x, y, z, k = map(int, input().split())
x_cake = [-float('inf')] + sorted(map(int, input().split()))
y_cake = [-float('inf')] + sorted(map(int, input().split()))
z_cake = [-float('inf')] + sorted(map(int, input().split()))


index_set = set()
x_index = y_index = z_index = -1
que = []
heapq.heappush(que, (-(x_cake[-1] + y_cake[-1] + z_cake[-1]), (-1, -1, -1)))
index_set.add((-1, -1, -1))
for _ in range(k):
    popped_tuple = heapq.heappop(que)
    print(-popped_tuple[0])
    x_index, y_index, z_index = popped_tuple[1]
    if (x_index-1, y_index, z_index) not in index_set:
        heapq.heappush(que, (-(x_cake[x_index-1] + y_cake[y_index] + z_cake[z_index]), (x_index-1, y_index, z_index)))
        index_set.add((x_index-1, y_index, z_index))
    if (x_index, y_index-1, z_index) not in index_set:
        heapq.heappush(que, (-(x_cake[x_index] + y_cake[y_index-1] + z_cake[z_index]), (x_index, y_index-1, z_index)))
        index_set.add((x_index, y_index-1, z_index))
    if (x_index, y_index, z_index-1) not in index_set:
        heapq.heappush(que, (-(x_cake[x_index] + y_cake[y_index] + z_cake[z_index-1]), (x_index, y_index, z_index-1)))
        index_set.add((x_index, y_index, z_index-1))

Buggy submission (verdict: Runtime Error):
import heapq


x, y, z, k = map(int, input().split())
x_cake = [-float('inf')] + sorted(map(int, input().split()))
y_cake = [-float('inf')] + sorted(map(int, input().split()))
z_cake = [-float('inf')] + sorted(map(int, input().split()))


index_set = set()
x_index = y_index = z_index = -1
que = []
cnt = 0
print(x_cake[-1] + y_cake[-1] + z_cake[-1])
while True:
    heapq.heappush(que, (-(x_cake[x_index-1] + y_cake[y_index] + z_cake[z_index]), (x_index-1, y_index, z_index)))
    heapq.heappush(que, (-(x_cake[x_index] + y_cake[y_index-1] + z_cake[z_index]), (x_index, y_index-1, z_index)))
    heapq.heappush(que, (-(x_cake[x_index] + y_cake[y_index] + z_cake[z_index-1]), (x_index, y_index, z_index-1)))
    popped_tuple = heapq.heappop(que)
    x_index, y_index, z_index = popped_tuple[1]
    if (x_index, y_index, z_index) not in index_set:
        index_set.add((x_index, y_index, z_index))
        cnt += 1
        print(-popped_tuple[0])
        if cnt == k-1:
            break
Problem p03165 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


s = S()
t = S()
S,T = len(s),len(t)
dp = [[0]*(T+1) for _ in range(S+1)]
for i in range(S):
    for j in range(T):
        if s[i]==t[j]:
            dp[i+1][j+1] = 1 + dp[i][j]
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])



ans = ""
while dp[S][T]:
    if dp[S - 1][T] == dp[S][T]:
        S -= 1
    elif dp[S][T - 1] == dp[S][T]:
        T -= 1
    else:
        S -= 1
        T -= 1
        ans = s[S] + ans


if len(ans) == 0:
    print("")
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce
from copy import deepcopy

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): pass
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


s = S()
t = S()
si = len(s)
ti = len(t)
S,T = len(s),len(t)
dp = [[0]*(T+1) for _ in range(S+1)]
for i in range(S):
    for j in range(T):
        if s[i]==t[j]:
            dp[i+1][j+1] = 1 + dp[i][j]
        else:
            dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])



ans = ""
while si >= 0 or ti >= 0:
    if dp[si][ti] == dp[si - 1][ti - 1] + 1:
        si -= 1
        ti -= 1
        ans = s[si] + ans
    elif dp[si][ti] == dp[si - 1][ti]:
        si -= 1
    else:
        ti -= 1


if len(ans) == 0:
    print("")
else:
    print(ans)
Problem p03290 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


d, g = LI()
g //= 100
p, c = list(zip(*LIR(d)))
c = [c[i] // 100 for i in range(d)]



ans = INF
for i in range(2 ** d):
    cnt = 0
    score = 0
    for j in range(d):
        if 1 << j & i:
            cnt += p[j]
            score += (j + 1) * p[j]
            score += c[j]


    max_score = -INF
    for k in range(d):
        if not (1 << k) & i:
            max_score = max(max_score, k + 1)
    if score < g:
        remain_num = (g - score) // max_score + bool((g - score) % max_score)
        if remain_num >= p[max_score - 1]:
            continue
        cnt += remain_num
    ans = min(ans, cnt)


print(ans)

Buggy submission (verdict: Runtime Error):
n, l, t = list(map(int, input().split()))
ants = []
for i in range(n):
    ants.append(list(map(int, input().split())))
normal_ant = [i for i, direction in ants if direction==1]
counter_ant = [i for i, direction in ants if direction==2]
cnt = (t // l) * len(normal_ant) + sum([1 for i in normal_ant if i + t%l >= l])
counter_cnt = (t // l) * len(counter_ant) + sum([1 for i in counter_ant if i - t%l < 0])
final_pos = sorted([(i-t)%l for i in counter_ant] + [(i+t)%l for i in normal_ant])
print(*final_pos[(cnt-counter_cnt)%n:] + final_pos[:(cnt-counter_cnt)%n], sep='\n')

Buggy submission (verdict: Runtime Error):
score_max, total = list(map(int, input().split()))
total //= 100
per_score_num = []
bonus = []
for i in range(score_max):
    inp = list(map(int, input().split()))
    per_score_num.append(inp[0])
    bonus.append(int(inp[1] / 100))
    

require = 0
min_cnt = np.inf


for bits in range(1 << score_max):
    solve_cnt = 0
    score = 0
    for i in range(score_max):
        if (1<<i)&bits:
            score += per_score_num[i] * (i+1)
            score += bonus[i]
            solve_cnt += per_score_num[i]
    if total > score:
        for j in range(score_max-1, -1, -1):
            if not (1<<j) & bits:
                require = math.ceil((total - score) // (j+1))
                if require < per_score_num[j]:
                    solve_cnt += require
                else:
                    solve_cnt = np.inf
                break
    min_cnt = min(min_cnt, solve_cnt)
print(min_cnt)
Problem p03422 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



def solve(n, k):
    if n % k == 0:
        return n // k
    diff = (n // k) + 1
    target = n - n % k
    if (n - target) % diff == 0:
        return solve(target, k)
    n -= -((-(n - target)) // diff) * diff
    return solve(n, k)


n = I()
ret = 0
for i in range(n):
    a, k = LI()
    ret ^= solve(a, k)

print("Takahashi" if ret else "Aoki")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



def solve(n, k):
    if n % k == 0:
        return n // k
    diff = (n // k) + 1
    target = n - n % k
    r = n % k
    if r % diff == 0:
        return solve(n - r, k)
    n -= r // diff * diff
    return solve(n, k)


n = I()
ret = 0
for i in range(n):
    a, k = LI()
    ret ^= solve(a, k)

print("Takahashi" if ret else "Aoki")
Problem p03504 (python)

Fixed submission:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, c = LI()
L = [0] * (10 ** 5 + 2)
each_channel = [[] for _ in range(c)]
for s, t, k in LIR(n):
    each_channel[k - 1] += [(s, t)]



for i in each_channel:
    i.sort()


for i in range(c):
    pre_t = -1
    for j in range(len(each_channel[i])):
        s, t = each_channel[i][j]
        if j >= 1 and pre_t == s:
            L[pre_t + 1] += 1
            L[t + 1] -= 1
        else:
            L[s] += 1
            L[t + 1] -= 1
        pre_t = t


print(max(accumulate(L)))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, c = LI()
L = [0] * (10 ** 5 + 1)
for s, t, c in LIR(n):
    L[s] += 1
    L[t + 1] -= 1



print(max(accumulate(L)))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left
import random
from itertools import permutations, accumulate, combinations
import sys
import string


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 10 ** 9 + 7


n, c = LI()
L = [0] * 10 ** 5
for s, t, c in LIR(n):
    L[s] += 1
    L[t + 1] -= 1



print(max(accumulate(L)))