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

Fixed submission:
N, M = map(int, input().split())
ac = 0
is_AC = [False] * (N + 1)
WA_cnt = [0] * (N + 1)
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

wa = 0
for i in range(N + 1):
    if is_AC[i]:
        wa += WA_cnt[i]
print(ac, wa)
'''
うまくいかなかったパターン
1 4
1 WA
1 WA
1 WA
1 WA
'''

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ac = [False] * N
wa_cnt = [0] * N
ac_cnt = 0
for i in range(M):
    p, s = input().split()
    p_i = int(p) - 1
    if s == 'WA':
        if not ac[p_i]:
            wa_cnt[p_i] += 1
    else:
        if not ac[p_i]:
            ac[p_i] = True
            ac_cnt += 1

wa_cnt_sum = 0
for i in range(N):
    if ac_cnt[i]:
        wa_cnt_sum += wa_cnt[i]

print(ac_cnt,wa_cnt_sum)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ac = 0
is_AC = [False] * (10 ** 5) + 1
WA_cnt = [0] * (10 ** 5) + 1
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

print(ac, sum(WA_cnt))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
ac = 0
is_AC = [False] * M
WA_cnt = [0] * M
for i in range(M):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC[p]:
            continue
        else:
            WA_cnt[p] += 1
    else:
        if is_AC[p]:
            continue
        else:
            is_AC[p] = True
            ac += 1

print(ac, sum(WA_cnt))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
wa_dict = {}
is_AC = []
ac_cnt = 0
for i in range(N):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if is_AC.count(p) == 0:
            if wa_dict.get(p) is None:
                wa_dict[p] = 1
            else:
                wa_dict[p] += 1
        else:
            continue
    else:
        if is_AC.count(p) == 0:
            ac_cnt += 1
            is_AC.append(p)

print(ac_cnt, sum(wa_dict.values()))
Problem p03006 (python)

Fixed submission:
N = int(input())
AB_list = [list(map(int, input().split())) for i in range(N)]

if len(AB_list) ==1:
    print(1)
    exit(0)

AB_list = sorted(AB_list,key=lambda a:a[0])
kouho_list = []
for i, AB in enumerate(AB_list):
    for j,ab in enumerate(AB_list):
        if i == j:
            continue
        kouho_list.append((ab[0]-AB[0] ,ab[1]-AB[1]))

from collections import Counter
kouho_counter = Counter(kouho_list).most_common()
pq = list(kouho_counter[0][0])

onaji_list = []
#print(kouho_counter)

result = []
for i,ab in enumerate(AB_list):
    for j,ab2 in enumerate(AB_list):
        if i == j:
            continue
        if ab[0] + pq[0] == ab2[0] and ab[1] + pq[1] == ab2[1]:
            result.append(tuple(ab2))
            continue
        #if ab[0] - pq[0] == ab2[0] and ab[1] - pq[1] == ab2[1]:
            #result.append(tuple(ab2))


#print(result)
result = list(set(result))
#print(onaji_list)
#print(result)
print(len(AB_list)-len(result))





'''
候補は49 + 48 + 47 + ...
この候補の中で、一番えらばれているものをp,qとして設定する
その後、ループを回して、実際にコストを計算する

'''


#print(AB_list)

Buggy submission (verdict: Runtime Error):
N = int(input())
AB_list = [list(map(int, input().split())) for i in range(N)]

kouho_list = []

for i, AB in enumerate(AB_list):
    for j,ab in enumerate(AB_list[i+1:]):
        kouho_list.append((AB[0]-ab[0] ,AB[1]-ab[1]))

from collections import Counter
kouho_counter = Counter(kouho_list).most_common()
#print(kouho_counter)
result = len(AB_list) - kouho_counter[0][1]

'''
候補は49 + 48 + 47 + ...
この候補の中で、一番えらばれているものをp,qとして設定する
その後、ループを回して、実際にコストを計算する

'''



#print(AB_list)
print(result)
Problem p03061 (python)

Fixed submission:
import fractions


'''

最大公約数を求める
最大公約数を最大にするには何を変えれば良いか

最大値との最大公約数を求めて、最大になれば良い?

'''

n = list(map(int, input().split()))
A = list(map(int, input().split()))
right = []
left = []
for i,a in enumerate(A):
    if i ==0 :
        right.append(a)
    else:
        right.append(fractions.gcd(right[i-1],a))

for i,b in enumerate(reversed(A)):
    if i ==0 :
        left.append(b)
    else:
        left.append(fractions.gcd(left[i-1],b))

result = []

for i,r in enumerate(A):
    if i ==0:
        result.append(right[len(right)- 2])
    if i == len(A) -1:
        result.append(left[len(left) - 2])

    result.append(fractions.gcd(left[i -1], right[len(right) - i -2]))

print(max(result))

Buggy submission (verdict: Runtime Error):
import math

n = list(map(int, input().split()))
A = list(map(int, input().split()))
a_max = max(A)
result = []
for a in A:
    result.append(math.gcd(a_max,a))

result.sort(reverse=True)

print(result[1])
Problem p03067 (python)

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

result = 'Yes'
t = min(a,b)
u = max(a,b)
if c > t and c < u:
    print(result)
else :
    result = 'No'
    print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()

shiro_num = s.count(".")
kuro_num = n - shiro_num

right_kuro_num = kuro_num
right_siro_num = shiro_num

result = shiro_num

for e in s:
    if e == '.':
        right_siro_num -= 1
    else:
        right_kuro_num -= 1
    num = right_siro_num + kuro_num - right_kuro_num
    result = min(num,result)

print(result)
Problem p03071 (python)

Fixed submission:
n = list(map(int, input().split()))
if n[0] == n[1]:
    print(n[0] * 2)
else:
    print(max(n) + max(n) - 1)

Buggy submission (verdict: Runtime Error):
q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])

# print(ruiseki)
answer = 0
for i in range(0, len(ruiseki), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)
Problem p03074 (python)

Fixed submission:
q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

# print(sum01)
Add = 2 * k + 1
ruiseki = [0]
for i, e in enumerate(sum01):
    ruiseki.append(ruiseki[i] + sum01[i])

# print(ruiseki)
answer = 0
for i in range(0, len(sum01), 2):
    left = i
    right = min(i + Add, len(sum01))
    temp = ruiseki[right] - ruiseki[left]
    answer = max(temp, answer)

print(answer)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S_list = ['0'] + list(input()) + ['-1']

s_count_list =[]

cnt = 1
for i in range(1,N+2) :
    if S_list[i] == S_list[i-1] :
        cnt +=1
    else:
        s_count_list.append(cnt)
        cnt = 1
if S_list[1] == '0':
    s_count_list[0] = s_count_list[0] -1
else:
    s_count_list.pop(0)

ruisekiwa = [0]
for i,s in enumerate(s_count_list):
    ruisekiwa.append(s_count_list[i] + s)

for i in range(0,len(ruisekiwa),2):
    left = i
    right = min((i + (2 * K) + 1),len(ruisekiwa))
    tmp = ruisekiwa[right] - ruisekiwa[left]
    answer = max(tmp,answer)

print(answer)

Buggy submission (verdict: Runtime Error):
q, k = list(map(int, input().split()))
list = [int(i) for i in input()]

# 0 ,1 のまとまりを作る
sum01 = []
pre = 1
cnt = 0
# 111010
# 001010
for i, e in enumerate(list):
    if e != pre:
        sum01.append(cnt)
        cnt = 1
        pre = e
    else:
        cnt += 1
if cnt != 0:
    sum01.append(cnt)

if len(sum01) % 2 == 1:
    sum01.append(0)

print(sum01)
Add = 2 * k + 1
answer = 0
for i in range(0, len(sum01), 2):
    temp = 0
    left = i
    right = min(i + Add, len(sum01))
    for j in range(left, right, 1):
        temp += sum01[j]
    answer = max(temp, answer)

print(answer)

'''
Problem p03106 (python)

Fixed submission:
import fractions

A, B, K = list(map(int, input().split()))

a_re = []
b_re = []

for i in range(max(A,B) + 1):
    if i == 0:
        continue
    #print(i)
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)
#print(a_re)

result = list (set(a_re) & set( b_re))

result.sort(reverse=True)
print(result[K-1])

Buggy submission (verdict: Runtime Error):
import fractions

A, B, K = list(map(int, input().split()))

a_re = []
b_re = []

for i in range(max(A,B)//2 +1):
    if i == 0:
        continue
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)

result = list (set(a_re) & set( b_re))
if len(result) == 0:
    print(1)
    exit(0)

result.sort(reverse=True)
print(result[K-1])

Buggy submission (verdict: Runtime Error):
import fractions

A, B, K = list(map(int, input().split()))

a_re = []
b_re = []

for i in range(max(A,B)//2 +1):
    if i == 0:
        continue
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)

result = list (set(a_re) & set( b_re))
result.sort(reverse=True)

#print(result)
print(result[K-1])

Buggy submission (verdict: Runtime Error):
import fractions

A, B, K = list(map(int, input().split()))

a_re = []
b_re = []

for i in range(max(A,B)//2 +1):
    if i == 0:
        continue
    if A % i ==0:
        a_re.append(i)
    if B % i ==0:
        b_re.append(i)

result = list (set(a_re) & set( b_re))
result.sort(reverse=True)

print(result)
print(result[K-1])
Problem p03112 (python)

Fixed submission:
import bisect

INF = 10 ** 18
A, B, Q = map(int, input().split())
shrine_list = [-INF] + [int(input()) for i in range(A)] + [INF]
temple_list = [-INF] + [int(input()) for i in range(B)] + [INF]
question_list = [int(input()) for i in range(Q)]
for q in question_list:
    b, d = bisect.bisect_right(shrine_list, q), bisect.bisect_right(temple_list, q)
    ans = INF
    for s in [shrine_list[b - 1], shrine_list[b]]:
        for t in [temple_list[d - 1], temple_list[d]]:
            ans = min(abs(q - s) + abs(t - s), abs(q - t) + abs(s - t), ans)
    print(ans)

'''
二分検索
深さ優先検索
幅優先検索
累積和
尺取法
動的計画法
mod
XOR
データ構造
'''

Buggy submission (verdict: Runtime Error):
import bisect

INF = 10 ** 9
A, B, Q = map(int, input().split())
shrine_list = [-INF] + [int(input()) for i in range(A)] + [INF]
temple_list = [-INF] + [int(input()) for i in range(B)] + [INF]
question_list = [int(input()) for i in range(Q)]

for q in question_list:
    b, d = bisect.bisect_right(shrine_list, q), bisect.bisect_right(temple_list, q)
    ans = INF
    for s in [shrine_list[b - 1], shrine_list[b]]:
        for t in [temple_list[d - 1], temple_list[d]]:
            ans = min(abs(q - s) + abs(t - s), abs(q - t) + abs(s - t), ans)
    print(ans)
Problem p03212 (python)

Fixed submission:
S = input()

'''
357 375 537 573 735 753 
3357 3375 3537 3573 3735 3753 
5357 5375 5537 5573 5735 5753 
3357,3375,3537,

3けた　、4けた 5 ,6, 7, 8
6,18,54,162,486, 8
sum = [2 * 3,2 * 3 * 3,]
'''

N = len(S)
list375 =['3','5','7']
if N <  3:
    print(0)
    exit(0)

for i in range(N + 1):
    if i ==0:
        continue
    else:
        targetList = list375[:]
        for l in targetList:
            #print(l)
            list375.append(l + '3')
            list375.append(l + '5')
            list375.append(l + '7')

result = [i for i in list(set(list375)) if int(i) <= int(S) and (i.count('3') >0 and i.count('5') >0 and i.count('7') >0)]
#print(result)
print(len(result))


'''
def judge753():
    if keta[0] < 3:
        return 0
    if keta[0] < 5:
        if keta[1] < 3:
            return 0
        if keta[1] < 5:
            if keta[2] < 5:
                return 0
            if keta[2] < 7:
                return 1
            return 2
        if keta[1] < 7:
            
        return sum[len(S)-1]
    if keta[0] < 7:
        if keta[1] < 3:
            return sum[len(S)-1] + sum[len(S)-2]
        if keta[1] < 5:
            if keta[2] < 5:
        
        return sum[len(S)-1]
        
print(min(absList))
'''

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 9)
N = input()
N_len = len(N)
'''
75333
'''


# t = []


def dfs(a, depth):
    if depth == N_len:
        if int(a) <= int(N) and a.count('3') > 0 \
                and a.count('5') > 0 and a.count('7') > 0 and str(int(a)).count('0') == 0:
            t.append(a)
            return 1
        else:
            return 0

    ret1 = dfs(a + '0', depth + 1)
    ret2 = dfs(a + '3', depth + 1)
    ret3 = dfs(a + '5', depth + 1)
    ret4 = dfs(a + '7', depth + 1)
    return ret1 + ret2 + ret3 + ret4


ans = dfs('', 0)
print(ans)
# print(t)

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10 ** 6)
N = input()
N_len = len(N)
'''
75333
'''


# t = []


def dfs(a, depth):
    if depth == N_len:
        if int(a) <= int(N) and a.count('3') > 0 \
                and a.count('5') > 0 and a.count('7') > 0 and str(int(a)).count('0') == 0:
            t.append(a)
            return 1
        else:
            return 0

    ret1 = dfs(a + '0', depth + 1)
    ret2 = dfs(a + '3', depth + 1)
    ret3 = dfs(a + '5', depth + 1)
    ret4 = dfs(a + '7', depth + 1)
    return ret1 + ret2 + ret3 + ret4


ans = dfs('', 0)
print(ans)
# print(t)
Problem p03219 (python)

Fixed submission:
X, Y = map(int,input().split())
print(X + Y//2)

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

pre = A
'''
3
21 -11
81234 52141 94124
'''
for i, h in enumerate(H_list):
    if i == 0:
        ans = i
        pre = T - h * 0.006
        continue
    kion = T - h * 0.006
    if abs(A - kion) < abs(A - pre):
        #print(kion)
        #print(pre)
        #print(abs(A - kion),'kion')
        #print(abs(A - pre),'pre')
        ans = i
print(ans + 1)
Problem p03240 (python)

Fixed submission:
N = int(input())
XYH_list = [list(map(int, input().split())) for i in range(N)]
XYH_list = sorted(XYH_list, key=lambda x: x[2], reverse=True)

for xi in range(0, 101):
    for yi in range(0, 101):
        tmpH = 0
        for k in range(N):
            x,y,h = XYH_list[k]
            if k == 0:
                tmpH =h + abs(x - xi) + abs(y - yi)
            if h == max((tmpH - abs(x - xi) - abs(y - yi)), 0):
                if k == N - 1:
                    ans = [str(xi), str(yi), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
XYH_list = [list(map(int, input().split())) for i in range(N)]

for i in range(0, 101):
    for j in range(0, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                tmpH = xyh[2] + abs(xyh[0] - i) + abs(xyh[1] - j)
                continue
            if xyh[2] == max((tmpH - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
XYH_list = [list(map(int, input().split())) for i in range(N)]

for i in range(1, 101):
    for j in range(1, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                for l in range(1, 201):
                    if xyh[2] == max((l - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                        tmpH = l
                        break
            if xyh[2] == max((tmpH - abs(xyh[0] - i) - abs(xyh[1] - j)), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
XYH_list = [list(map(int, input().split())) for i in range(N)]

for i in range(1, 101):
    for j in range(1, 101):
        tmpH = 0
        tmpI = i
        tmpJ = j
        for k, xyh in enumerate(XYH_list):
            if k == 0:
                for l in range(1, 100000):
                    if xyh[2] == max(l - abs(xyh[0] - i) - abs(xyh[1] - j), 0):
                        tmpH = l
                        break
            if xyh[2] == max(tmpH - abs(xyh[0] - i) - abs(xyh[1] - j), 0):
                if k == N - 1:
                    ans = [str(tmpI), str(tmpJ), str(tmpH)]
                continue
            else:
                break
print(' '.join(ans))
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.append(X)
X_list.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import fractions
from functools import reduce


def gcd_list(*numbers):
    return reduce(fractions.gcd, numbers)


print(gcd_list(*kyori_list))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.append(X)
X_list.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import math
from functools import reduce

def gcd_list(*numbers):
    return reduce(math.gcd, numbers)


print(gcd_list(*kyori_list))
# print(X_list)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
X_list = list(map(int, input().split()))
X_list.append(X)
X_list.sort()
kyori_list = []
for i, x in enumerate(X_list):
    if i == len(X_list) - 1:
        break
    kyori_list.append(X_list[i + 1] - x)

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)


print(gcd(*kyori_list))
# print(X_list)
Problem p03353 (python)

Fixed submission:
S = input()
K = int(input())
S_len = len(S)
ans = set()
for i in range(0, K+1):
    for j in range(0, S_len):
        if j + i <= S_len:
            t = S[j:j + i]
            if t != '':
                ans.add(t)
ans = list(ans)
ans.sort()
print(ans[K-1])

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
target = []
def func(split_range):
    for i in range(0,len(S)-split_range+1):
        #print(S[0:0])
        #print(S[0:1])
        #print(S[i:i+split_range])
        #print(S[i:i+split_range])
        target.append(S[i:i+split_range])

for i in range(1,len(S)+1):
    #print(i)
    func(i)
#print(target)
print(sorted(set(target))[K-1]
Problem p03543 (python)

Fixed submission:
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N)-1):
    if s1[i] != s1[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
    exit(0)

isOk = True
for i in range(1, len(N)-1):
    if s2[i] != s2[i - 1]:
        isOk = False
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N-1)):
    if s1[i] != s1[i - 1]:
        break
        isOk = False
    else:
        continue

if isOk:
    print('Yes')

isOk = True
for i in range(1, len(N-1)):
    if s2[i] != s2[i - 1]:
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = input()
s1 = N[1:len(N)]
s2 = N[0:len(N) - 1]
isOk = True
for i in range(1, len(N)):
    if s1[i] != s1[i - 1]:
        break
        isOk = False
    else:
        continue

if isOk:
    print('Yes')

isOk = True
for i in range(1, len(N)):
    if s2[i] != s2[i - 1]:
        break
    else:
        continue

if isOk:
    print('Yes')
else:
    print('No')
Problem p03544 (python)

Fixed submission:
N = int(input())
l_list = [2,1]
for i in range(2,N+1):
    a = l_list[i-1] + l_list[i-2]
    l_list.append(a)
print(l_list[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
l_list = [2,1]
for i in range(2,N+1):
    a = l_list[i-1] + l_list[i-2]
    l_list.append(a)
print(l_list[i])
Problem p03612 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == N-1:
        if P[i] == i+1:
            ans +=1
        break
    a, b = P[i], P[i + 1]
    if a == i + 1:
        ans += 1
        P[i] = b
        P[i + 1] = a
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
    if i == N-1:
        if P[i] == i+1:
            ans +=1
    a, b = P[i], P[i + 1]
    if a == i + 1:
        ans += 1
        P[i] = b
        P[i + 1] = a
print(ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
if p == []:
    print(x)
    exit()
t = [0]*(max(p)+2)
for i in p:
    t[i] = 1

mi = t[:x+1]
ma = t[x:]
mi.reverse()
mii = mi.index(0)
maa = ma.index(0)

if mii < maa:
    print(x-mii)
elif mii > maa:
    print(x+maa)
elif mii == maa:
    print(x-mii)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
t = [0]*101

for i in p:
    t[i] = 1

for j in range(50):
    if t[x-j] == 0:
        print(x-t[n-j])
        break
    elif t[x+j] == 0:
        print(x+t[n+j]+1)
        break
Problem p03239 (python)

Fixed submission:
n, t = map(int, input().split())
c = 10000
for i in range(n):
    tmp = input().split()
    if t >= int(tmp[1]):
        if int(tmp[0]) < c:
            c = int(tmp[0])
if c == 10000:
    print('TLE')
    exit()
else:
    print(c)

Buggy submission (verdict: Runtime Error):
n, t = map(int, input().split())
c = 999
for i in range(n):
    tmp = input().split()
    if t <= tmp[1]:
        if tmp[0] < c:
            c = tmp[0]
if c == 999:
    print('TLE')
    exit()
else:
    print(c)
Problem p03611 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
al = [0]*(10**5+2)

for i in a:
    al[i] += 1
    al[i+1] += 1
    al[i+2] += 1

print(max(al))

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

if n == 1:
    print(1)
    exit()
elif n == 2:
    if abs(a[0] - a[1]) <= 2:
        print(2)
        exit()
    else:
        print(1)
        exit()

al = [0]*(max(a)+1)
for i in a:
    al[i] += 1
index = al.index(max(al))

if index == min(a):
    index += 1
elif index == max(a):
    index -= 1

print(al[index-1] + al[index] + al[index+1])

Buggy submission (verdict: Runtime Error):
x = int(input())
a = list(map(int, input().split()))
al = [0]*(max(a)+1)
for i in a:
    al[i] += 1
index = al.index(max(al))

if index == 1:
    index += 1
elif index == max(a)-1:
    index -= 1

if x == 1:
    print(x)
elif x == 2:
    if abs(a[0] - a[1]) <= 1:
        print(2)
    else:
        print(1) 
else:
    print(al[index-1] + al[index] + al[index+1])
Problem p03633 (python)

Fixed submission:
from fractions import gcd

n = int(input())
t = [int(input()) for _ in range(n)]
result = 1


for i in range(n):
    num = t[i]
    result = result * num // gcd(result, num)

print(result)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

n = int(input())
t = [int(input()) for _ in range(n)]
cm = []
t.sort()

def lcm(x, y):
    return (x * y) // gcd(x, y)

for i in range(n-1):
    cm.append(lcm(t[i], t[i+1]))

print(max(cm))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
t = [int(input()) for _ in range(n)]
cm = []
t.sort()

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

for i in range(n-1):
    cm.append(lcm(t[i], t[i+1]))

print(max(cm))