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

Fixed submission:

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k = map(int, input().split())

    if num == 2:
        max_num = 10
    else:
        max_num = combinations_count(num - 1, 2)
    # max_num = combinations_count(num - 1, 2)

    if k > max_num or num == 2:
        if num == 2 and k == 0:
            print(1)
            print(1, 2)
        else:
            print('-1')
    else:
        edge = num - 1
        now_count = max_num
        data = [[num, i] for i in range(1, num)]
        for i in range(1, num):
            for j in range(i + 1, num):
                if now_count > k:
                    edge += 1
                    now_count -= 1
                    data.append([i, j])
                else:
                    pass

        print(edge)
        for i, j in data:
            print(i, j)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k = map(int, input().split())

    max_num = combinations_count(num - 1, 2)

    if k > max_num:
        print('-1')
    else:
        edge = num - 1
        now_count = max_num
        data = [[num, i] for i in range(1, num)]
        for i in range(1, num):
            for j in range(i + 1, num):
                if now_count > k:
                    edge += 1
                    now_count -= 1
                    data.append([i, j])
                else:
                    pass

        print(edge)
        for i, j in data:
            print(i, j)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k = map(int, input().split())

    if k >= num - 1:
        print('-1')
    else:
        edge = (num - 1) * 2 - k - 1
        edge += combinations_count(num - 2, 2)
        print(edge)
        for i in range(2 + k, num + 1):
            print(1, i)
        for i in range(2, num):
            print(num, i)
        for i in range(2, num):
            for j in range(i + 1, num):
                print(i, j)

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

Fixed submission:

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            if t == 0 or t + n - 1 >= mod:
                ans = 0
            else:
                ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
                ans %= mod
                ans *= pow(d, n, mod)
                ans %= mod
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools




def main():
    num = int(input())
    data = [list(map(int, input().split())) for i in range(num)]
    mod = 10 ** 6 + 3

    origin = [0 for i in range(mod + 1)]
    origin[1] = 1
    for i in range(2, mod + 1):
        origin[i] = origin[i - 1] * i
        origin[i] %= mod

    for i in range(num):
        x, d, n = data[i]
        if d == 0:
            ans = pow(x, n, mod)
        else:
            t = x * pow(d, mod - 2, mod)
            t %= mod
            ans = origin[t + n - 1] * pow(origin[t - 1], mod - 2, mod)
            ans %= mod
            ans *= pow(d, n, mod)
            ans %= mod
        print(ans)

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

Fixed submission:
import sys


def visit(current, v, dist, color):
    for ele in v[current]:
        if color[ele] != -1:
            continue
        if dist[(ele, current)] % 2 == 0:
            color[ele] = color[current]
        else:
            if color[current] == 0:
                color[ele] = 1
            else:
                color[ele] = 0
        visit(ele, v, dist, color)

def main():
    sys.setrecursionlimit(100100)
    num = int(input())

    v = [[] for i in range(num + 1)]

    dist = {}

    for i in range(1, num):
        a, b, d = map(int, input().split())
        v[a].append(b)
        v[b].append(a)
        dist[(a, b)] = d
        dist[(b, a)] = d

    color = [-1 for i in range(num + 1)]
    color[1] = 0
    visit(1, v, dist, color)

    for i in range(1, num + 1):
        print(color[i])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def visit(current, v, dist, color):
    for ele in v[current]:
        if color[ele] != -1:
            continue
        if dist[(ele, current)] % 2 == 0:
            color[ele] = color[current]
        else:
            if color[current] == 0:
                color[ele] = 1
            else:
                color[ele] = 0
        visit(ele, v, dist, color)

def main():

    num = int(input())

    v = [[] for i in range(num + 1)]

    dist = {}

    for i in range(1, num):
        a, b, d = map(int, input().split())
        v[a].append(b)
        v[b].append(a)
        dist[(a, b)] = d
        dist[(b, a)] = d

    color = [-1 for i in range(num + 1)]
    color[1] = 0
    visit(1, v, dist, color)

    for i in range(1, num + 1):
        print(color[i])

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

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def kari():
    a = list(map(int, input().split()))
    b = map(int, input().split())


def start_process(num, data):
    kouyakusuu1, kouyakusuu2, kouyakusuu3 = gcd(data[0], data[1]), max(data[0], data[1]), min(data[0], data[1])
    # print(kouyakusuu2, kouyakusuu3)

    for i in range(2, num):
        if i == 2:
            a = gcd(data[i], kouyakusuu2)
            b = gcd(data[i], kouyakusuu3)
            kari1 = max(a, b)
            kari2 = kouyakusuu1

            kari3 = gcd(data[i], kouyakusuu1)
        else:
            kari1 = gcd(data[i], kouyakusuu2)
            kari2 = kouyakusuu1

            kari3 = gcd(data[i], kouyakusuu1)



        kouyakusuu1 = kari3
        kouyakusuu2 = max(kari1, kari2)



    print(max(kouyakusuu1, kouyakusuu2))

# def start_process(num, data):
#     for i in range(num)

def main():
    num = int(input())
    data = list(map(int, input().split()))
    start_process(num, data)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

import math


def kari():
    a = list(map(int, input().split()))
    b = map(int, input().split())


def start_process(num, data):
    kouyakusuu1, kouyakusuu2, kouyakusuu3 = math.gcd(data[0], data[1]), max(data[0], data[1]), min(data[0], data[1])
    # print(kouyakusuu2, kouyakusuu3)

    for i in range(2, num):
        if i == 2:
            a = math.gcd(data[i], kouyakusuu2)
            b = math.gcd(data[i], kouyakusuu3)
            kari1 = max(a, b)
            kari2 = kouyakusuu1

            kari3 = math.gcd(data[i], kouyakusuu1)
        else:
            kari1 = math.gcd(data[i], kouyakusuu2)
            kari2 = kouyakusuu1

            kari3 = math.gcd(data[i], kouyakusuu1)



        kouyakusuu1 = kari3
        kouyakusuu2 = max(kari1, kari2)



    print(max(kouyakusuu1, kouyakusuu2))

# def start_process(num, data):
#     for i in range(num)

def main():
    num = int(input())
    data = list(map(int, input().split()))
    start_process(num, data)



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

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
MOD = 998244353

N = int(input())
A = [int(input()) for _ in range(N)]
S = sum(A)

# 赤の和がS/2以上となるものを求めて3倍
# 和に対して何通りあるのか

dp = np.zeros(S+1, dtype=np.int64)
dp[0] = 1
for a in A:
    prev = dp
    dp = prev * 2 # 赤以外を採用
    dp[a:] += prev[:-a] # 赤
    dp %= MOD

answer = pow(3,N,MOD) - dp[(1+S)//2:].sum() * 3
# 2色が反例となる場合を引きすぎている
if S % 2 == 0:
    dp = np.zeros(S+1, dtype=np.int64)
    dp[0] = 1
    for a in A:
        dp[a:] += dp.copy()[:-a]
        dp %= MOD
    answer += dp[S//2] * 3
answer %= MOD
print(answer)

Buggy submission (verdict: Runtime Error):

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import numpy as np




def main():
    num = int(input())
    data = [int(input()) for i in range(num)]
    sum_num = sum(data)
    mod = 998244353

    dp = np.zeros(sum_num + 1, dtype=np.int64)
    dp[0] = 1
    for i in range(num):
        now_num = data[i]
        prev = dp
        dp = 2 * prev
        dp[now_num:] += prev[:-now_num]
        dp %= mod

    dp2 = np.zeros(sum_num + 1, dtype=np.int64)
    dp2[0] = 1
    for i in range(num):
        now_num = data[i]
        prev = dp2
        dp2[now_num:] += prev[:-now_num]
        dp2 %= mod

    ans = pow(3, num, mod)
    hikukazu = 0
    for i in range(math.ceil(sum_num / 2), sum_num + 1):
        hikukazu += dp[i]
    if sum_num % 2 == 0:
        hikukazu -= dp2[sum_num // 2]
    ans -= hikukazu * 3
    ans %= mod
    print(ans)
    # print(dp)


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

Fixed submission:

def get_match_list(num_list, num_num):
    match_num_list = set()
    match_dic = [2,5,5,4,5,6,3,7,6]
    for num in num_list:
        match_num_list.add(match_dic[num-1])
    match_num_list = list(match_num_list)
    match_num_list.sort()
    return match_num_list

def get_dp(use_match_list, match_nun):
    dp = [-1 for i in range(match_nun + 1)]
    dp[0] = 0
    for i in range(2, match_nun + 1):
        for macth_bar in use_match_list:
            if dp[i-macth_bar] >= 0:
                dp[i] = dp[i-macth_bar] + 1
                break
    return dp

def print_ans(dp, match_nun, num_list):
    match_dic = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    max_ketasuu = dp[match_nun]
    ans = ''
    while match_nun > 0:
        for num in num_list:
            use_match_num = match_dic[num - 1]
            if match_nun - use_match_num < 0:
                continue
            if dp[match_nun - use_match_num] == max_ketasuu - 1:
                ans += str(num)
                match_nun -= use_match_num
                max_ketasuu -= 1
                break
    print(ans)



def main():
    match_nun, num_num = map(int, input().split())
    num_list = list(map(int, input().split()))
    num_list.sort(reverse=True)
    use_match_list = get_match_list(num_list, num_num)
    dp = get_dp(use_match_list, match_nun)
    print_ans(dp, match_nun, num_list)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def get_match_list(num_list, num_num):
    match_num_list = set()
    match_dic = [2,5,5,4,5,6,3,7,6]
    for num in num_list:
        match_num_list.add(match_dic[num-1])
    match_num_list = list(match_num_list)
    match_num_list.sort()
    return match_num_list

def get_dp(use_match_list, match_nun):
    dp = [-1 for i in range(match_nun + 1)]
    dp[0] = 0
    for i in range(2, match_nun + 1):
        for macth_bar in use_match_list:
            if dp[i-macth_bar] >= 0:
                dp[i] = dp[i-macth_bar] + 1
                break
    return dp

def print_ans(dp, match_nun, num_list):
    match_dic = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    max_ketasuu = dp[match_nun]
    ans = ''
    while match_nun > 0:
        for num in num_list:
            use_match_num = match_dic[num - 1]
            if dp[match_nun - use_match_num] == max_ketasuu - 1:
                ans += str(num)
                match_nun -= use_match_num
                max_ketasuu -= 1
                break
    print(ans)



def main():
    match_nun, num_num = map(int, input().split())
    num_list = list(map(int, input().split()))
    num_list.sort(reverse=True)
    use_match_list = get_match_list(num_list, num_num)
    dp = get_dp(use_match_list, match_nun)
    print_ans(dp, match_nun, num_list)


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

Fixed submission:

import heapq


def main():
    num_sushi, chose_num = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num_sushi)]

    data.sort(key=lambda x: -x[1])
    delicious_heap = []
    count_d, count_n = 0, 0
    neta_data = [0 for i in range(num_sushi + 1)]

    for i in range(chose_num):
        neta, oishisa = data[i]

        if neta_data[neta]:
            heapq.heappush(delicious_heap, oishisa)
        else:
            neta_data[neta] = 1
            count_n += 1

        count_d += oishisa

    ans = count_d + count_n ** 2

    for i in range(chose_num, num_sushi):
        if len(delicious_heap) == 0:
            break
        neta, oishisa = data[i]

        if neta_data[neta]:
            continue
        neta_data[neta] = 1
        count_n += 1
        pop_oishisa = heapq.heappop(delicious_heap)
        count_d += oishisa - pop_oishisa

        ans = max(ans, count_d + count_n ** 2)

    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
ans = 0

def calc_final_data(suhsi_data, eat_data, sushi_num):
    global ans
    ans_kari = 0
    neta_hist = set()
    for i in range(sushi_num):
        if eat_data[i]:
            neta_hist.add(str(suhsi_data[i][0]))
            ans_kari += suhsi_data[i][1]
    ans_kari += len(neta_hist) * len(neta_hist)
    if ans_kari > ans:
        ans = ans_kari

def eat_sushi(suhsi_data, max_eat, eat_data_kari, index, eat_flg, sushi_num):
    eat_data = eat_data_kari.copy()
    if index == sushi_num or eat_data.count(1) == max_eat:
        calc_final_data(suhsi_data, eat_data, sushi_num)
        return
    if eat_flg:
        eat_data[index] = 1
    eat_sushi(suhsi_data, max_eat, eat_data, index+1, 0, sushi_num)
    eat_sushi(suhsi_data, max_eat, eat_data, index+1, 1, sushi_num)


def calc_eat(suhsi_data, max_eat, eat_data, sushi_num):
    eat_sushi(suhsi_data, max_eat, eat_data, 0, 0, sushi_num)
    eat_sushi(suhsi_data, max_eat, eat_data, 0, 1, sushi_num)

def print_ans():
    global ans
    print(ans)

def main():
    sushi_num, max_eat = list(map(int, input().split()))
    suhsi_data = [list(map(int, input().split())) for i in range(sushi_num)]
    eat_data = [0 for i in range(sushi_num)]
    calc_eat(suhsi_data, max_eat, eat_data, sushi_num)
    print_ans()

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

Fixed submission:
from collections import defaultdict

def main():
    num, weigh = map(int, input().split())
    dp = [defaultdict(int) for i in range(num + 1)]
    dp[0][0] = 0

    for i in range(1, num + 1):
        data = list(map(int, input().split()))
        for pre_value in dp[i - 1].keys():
            dp[i][pre_value] = max(dp[i - 1][pre_value], dp[i][pre_value])
            if pre_value + data[0] <= weigh:
                dp[i][pre_value + data[0]] = max(dp[i - 1][pre_value] + data[1], dp[i][pre_value + data[0]])

    print(max(list(dp[-1].values())))


if __name__ == '__main__':
    main()

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

def main():
    num, weigh = map(int, input().split())
    dp = np.zeros((num + 1, weigh + 1), dtype=int)

    for i in range(1, num + 1):
        now_weigh, now_value = map(int, input().split())
        dp[i, :now_weigh] = dp[i - 1, :now_weigh]
        dp[i, now_weigh:] = np.maximum(dp[i - 1, :weigh - now_weigh + 1] + now_value, dp[i - 1, now_weigh:])

    print(dp[-1][-1])


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

Fixed submission:
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import numpy as np




def main():
    num, lim_weight = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(num)]

    dp = np.full(10 ** 5 + 1, np.inf)

    for i in range(num):
        weight, value = data[i]
        prev = dp.copy()
        dp[:value] = np.minimum(prev[:value], weight)
        dp[value:] = np.minimum(prev[value:], prev[:-value] + weight)

        # print(dp[:100])
    ans = np.max(np.where(dp <= lim_weight)) + 1
    print(ans)

if __name__ == '__main__':
    main()

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

def main():
    num, weigh = map(int, input().split())
    dp = np.zeros((num + 1, weigh + 1), dtype=int)

    for i in range(1, num + 1):
        now_weigh, now_value = map(int, input().split())
        dp[i, :now_weigh] = dp[i - 1, :now_weigh]
        dp[i, now_weigh:] = np.maximum(dp[i - 1, :weigh - now_weigh + 1] + now_value, dp[i - 1, now_weigh:])

    print(dp[-1][-1])


if __name__ == '__main__':
    main()

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

def main():
    num, weigh = map(int, input().split())
    dp = np.zeros((num + 1, weigh + 1), dtype=int)

    for i in range(1, num + 1):
        now_weigh, now_value = map(int, input().split())
        dp[i, :now_weigh] = dp[i - 1, :now_weigh]
        dp[i, now_weigh:] = np.maximum(dp[i - 1, :weigh - now_weigh + 1] + now_value, dp[i - 1, now_weigh:])

    print(dp[-1][-1])


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

Fixed submission:
print(input().count('2'))

Buggy submission (verdict: Runtime Error):


if __name__ == '__main__':
    num = int(input())
    # data = [int(input()) for i in range(num)]
    
    ans = 0
    for i in range(num):
        data = input()
        if int(data[-1]) % 2 == 1:
            ans += 1

    if ans+1 % 2 == 0:
        print('second')
    else:
        print('first')

Buggy submission (verdict: Runtime Error):

import collections

# def get_lim(n):
#     # for i in range(n):
#     #     if i * i > n:
#     #         return i + 1
#     return pow(10, int((len(str(n)) / 2)))

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    # lim = get_lim(n)
    for i in range(2, n):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i > n or n == 1:
            break
        print(n, i)
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

        soinnsuu = prime_factor(num, length)
        ans = 1
        # print(soinnsuu)
        for data in soinnsuu.keys():
            if soinnsuu[data] >= length:
               ans *= data
        print(ans)

Buggy submission (verdict: Runtime Error):

import collections

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    for i in range(2,int(n**0.5)+1):
        # print(pow(i, length),  n)
        if pow(i, length) > n:
            break
        if i > n or n == 1:
            break
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    soinnsuu = prime_factor(num, length)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)
Problem p03200 (python)

Fixed submission:
data = list(input())

count = 0
# i = 0
# while 1:
count_b = 0
for i in range(len(data)):
    # print(i)
    if data[i] == 'W':
        count += count_b
        # count += 1
        # data[i], data[i+1] = 'B', 'W'
        # break
    else:
        count_b += 1
    # else:
    #     break
print(count)

Buggy submission (verdict: Runtime Error):


ball_num = int(input())
num_data = list(map(int, input().split()))

ans = 0

def check_beki(num1, num2):
    data = num1 + num2
    while 1:
        data1 = data % 2
        data = int(data / 2)
        if data1 == 1:
            return 0
        elif num1 + num2 >= 1 and data == 1:
            return 1

def check_ans(ans_list, tasu_flg):
    global ans
    ans_kari = 0
    for i in range(len(ans_list)):
        if check_beki(ans_list[i], 0) and tasu_flg[i] == 1:
            ans_kari += 1
    if ans_kari > ans:
        ans = ans_kari

def check(index, ans_list_ori, tasu_flg_ori):
    global ball_num, num_data
    ans_list = ans_list_ori.copy()
    tasu_flg = tasu_flg_ori.copy()

    # if len(ans_list) >= tree_num:
    #     return

    # print(check_beki(3, 5))

    if index < ball_num:
        for j in range(len(ans_list)):
            # print(ans_list[j], num_data[index])
            if check_beki(ans_list[j], num_data[index]) and tasu_flg[j] == 0:
                # print('yyy')
                ans_list[j] += num_data[index]
                tasu_flg[j] = 1
                check(index+1, ans_list, tasu_flg)
                tasu_flg[j] = 0
                ans_list[j] -= num_data[index]
            # 新しく木を使う場合
            ans_list.append(num_data[index])
            tasu_flg.append(0)
            check(index+1, ans_list, tasu_flg)
            tasu_flg.pop(-1)
            ans_list.pop(-1)
    else:
        # 以前よりも最少の気で作れたら最小値の更新
        check_ans(ans_list, tasu_flg)


def main():
    global num_data
    check(1, [num_data[0]], [0])

    print(ans)



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

Fixed submission:
a, b = list(map(int, input().split()))
print(a+int(b/2))

Buggy submission (verdict: Runtime Error):


if __name__ == '__main__':
    ken_num, city_num = list(map(int, input().split()))
    data = []
    for i in range(city_num):
        element = list(map(int, input().split())).append(i)
        data.append(element)
    # data = [list(map(int, input().split())).append(i) for i in range(city_num)]

    # ken_num, city_num = 2, 3
    # data = [[1,32,0], [2,63,1],[1,12,2]]

    data = sorted(data, key=lambda x: (x[0], x[1]))

    count = 1
    ken_num = 1
    ans_data = {}

    for i in range(city_num):
        number = data[i][2]
        if data[i][0] != ken_num:
            count = 1
            ken_num = data[i][0]
        chr = "{0:06d}".format(ken_num) + "{0:06d}".format(count)
        ans_data.update({number:chr})
        count += 1

    for i in range(city_num):
        print(ans_data[i])
Problem p03239 (python)

Fixed submission:
num, time_lim = list(map(int, input().split()))
ans = 'TLE'
for i in range(num):
  cost, time_data = list(map(int, input().split()))
  if time_data > time_lim:
    continue
  if ans == 'TLE':
    ans = cost
  if ans > cost:
    ans = cost
print(ans)

Buggy submission (verdict: Runtime Error):
num, time_lim = list(map(int, input().spli()))
ans = 'TLE'
for i in range(num):
  cost, time_data = list(map(int, input().spli()))
  if time_data > time_lim:
    continue
  if ans == 'TLE':
    ans = cost
  if ans > cost:
    ans = cost
print(ans)