Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            dis = [[-1] * w for _ in range(h)]
            dis[i][j] = 0
            q = [(i,j)]
            while q:
                l0,l1 = q.pop(0)
                if l0 > 0:
                    if s[l0-1][l1] == '.':
                        if dis[l0-1][l1] > dis[l0][l1] + 1 or dis[l0-1][l1] == -1:
                            dis[l0-1][l1] = dis[l0][l1] + 1
                            q.append((l0-1,l1))
                if l0 < h - 1:
                    if s[l0+1][l1] == '.':
                        if dis[l0+1][l1] > dis[l0][l1] + 1 or dis[l0+1][l1] == -1:
                            dis[l0+1][l1] = dis[l0][l1] + 1
                            q.append((l0+1,l1))
                if l1 > 0:
                    if s[l0][l1-1] == '.':
                        if dis[l0][l1-1] > dis[l0][l1] + 1 or dis[l0][l1-1] == -1:
                            dis[l0][l1-1] = dis[l0][l1] + 1
                            q.append((l0,l1-1))
                if l1 < w - 1:
                    if s[l0][l1+1] == '.':
                        if dis[l0][l1+1] > dis[l0][l1] + 1 or dis[l0][l1+1] == -1:
                            dis[l0][l1+1] = dis[l0][l1] + 1
                            q.append((l0,l1+1))
        dis_max = 0
        for k in dis:
            dis_max = max(max(k), dis_max)
        ans = max(dis_max,ans)

print(ans)


Fixed submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

ans = 0

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            dis = [[-1] * w for _ in range(h)]
            dis[i][j] = 0
            q = [(i,j)]
            while q:
                l0,l1 = q.pop(0)
                if l0 > 0:
                    if s[l0-1][l1] == '.':
                        if dis[l0-1][l1] > dis[l0][l1] + 1 or dis[l0-1][l1] == -1:
                            dis[l0-1][l1] = dis[l0][l1] + 1
                            q.append((l0-1,l1))
                if l0 < h - 1:
                    if s[l0+1][l1] == '.':
                        if dis[l0+1][l1] > dis[l0][l1] + 1 or dis[l0+1][l1] == -1:
                            dis[l0+1][l1] = dis[l0][l1] + 1
                            q.append((l0+1,l1))
                if l1 > 0:
                    if s[l0][l1-1] == '.':
                        if dis[l0][l1-1] > dis[l0][l1] + 1 or dis[l0][l1-1] == -1:
                            dis[l0][l1-1] = dis[l0][l1] + 1
                            q.append((l0,l1-1))
                if l1 < w - 1:
                    if s[l0][l1+1] == '.':
                        if dis[l0][l1+1] > dis[l0][l1] + 1 or dis[l0][l1+1] == -1:
                            dis[l0][l1+1] = dis[l0][l1] + 1
                            q.append((l0,l1+1))
            dis_max = 0
            for k in dis:
                dis_max = max(max(k), dis_max)
            ans = max(dis_max,ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n = int(input())

x = list(map(int,input().split()))

mod = 10**9 + 7

li = []
for i in range(n-1):
    li.append(x[i+1] - x[i])

dp = [0] * (n-1)
dp2 = [0] * (n-1)
dp3 = [0] * n
dp3[0] = 1

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

dp[0] = x[1] - x[0]
dp2[0] = 1

for i in range(n-2):
    dp2[i+1] = dp2[i] * (i+2) + dp3[i]

ans = 0

for i in range(n-2):
    dp[i+1] = dp[i] * (i+2) + (x[i+2] - x[i+1]) * dp2[i+1]
    dp[i+1] %= mod

print(dp[-1] % mod)


Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
x = list(map(int,input().split()))

#n = 10**5
#x = list(range(10**5))
mod = 10**9 + 7

li = []
for i in range(n-1):
    li.append(x[i+1] - x[i])

dp = [0] * (n-1)
dp2 = [0] * (n-1)
dp3 = [0] * n
dp3[0] = 1

for i in range(n-1):
    dp3[i+1] = dp3[i] * (i+2)
    dp3[i+1] %= mod

dp[0] = x[1] - x[0]
dp2[0] = 1

for i in range(n-2):
    dp2[i+1] = dp2[i] * (i+2) + dp3[i]
    dp2[i+1] %= mod
ans = 0
for i in range(n-2):
    dp[i+1] = dp[i] * (i+2) + (x[i+2] - x[i+1]) * dp2[i+1]
    dp[i+1] %= mod

print(dp[-1] % mod)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
import sys
import bisect

input = sys.stdin.readline

n,m = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse = True)

li = [0] * (10**5+1)

for i in a:
    li[i] += 1

acm = list(accumulate(li))
acm_a = list(accumulate(a))

l = 0
r = 2 * 10 ** 5

while l <= r:
    mid = (l + r) // 2
    count = 0
    for i in a:
        if mid - i >= 0:
            count += n - acm[mid-i]
        else:
            count += n
    if count >= m:
        l = mid + 1
    else:
        r = mid - 1

sum_idx = 0
ans = 0
b = a[::-1]
for left in a:
    right_min = l - left
    idx = bisect.bisect_left(b,right_min)
    if n - idx > 0:
        sum_idx += n - idx
        ans += left * (n - idx) + acm_a[n - idx - 1]

ans -= l * (sum_idx - m)

print(ans)


Fixed submission:
from itertools import accumulate
import sys
import bisect

input = sys.stdin.readline

n,m = map(int,input().split())
a = list(map(int,input().split()))

a.sort(reverse = True)

li = [0] * (2*10**5+1)

for i in a:
    li[i] += 1

acm = list(accumulate(li))
acm_a = list(accumulate(a))

l = 0
r = 2 * 10 ** 5

while l <= r:
    mid = (l + r) // 2
    count = 0
    for i in a:
        if mid - i >= 0:
            count += n - acm[mid-i]
        else:
            count += n
    if count >= m:
        l = mid + 1
    else:
        r = mid - 1

sum_idx = 0
ans = 0
b = a[::-1]
for left in a:
    right_min = l - left
    idx = bisect.bisect_left(b,right_min)
    if n - idx > 0:
        sum_idx += n - idx
        ans += left * (n - idx) + acm_a[n - idx - 1]

ans -= l * (sum_idx - m)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s) + 1

a = [-1] * n

if s[0] == '<':
    a[0] = 0
if s[-1] == '>':
    a[-1] = 0

for i in range(1,n-2):
    if s[i] == '>' and s[i+1] == '<':
        a[i+1] = 0

for i in range(n-1):
    if a[i] == 0:
        tmp = 1
    else:
        tmp += 1
    if s[i] == '<':
        a[i+1] = tmp
    else:
        tmp = 0

for i in range(n-1):
    i = i * (-1) - 1
    if a[i] == 0:
        tmp = 1
    else:
        tmp += 1
    if s[i] == '>':
        a[i-1] = max(tmp, a[i-1])
    else:
        tmp = 0

print(sum(a))


Fixed submission:
s = input()
n = len(s) + 1

a = [-1] * n
tmp = 0

if s[0] == '<':
    a[0] = 0
if s[-1] == '>':
    a[-1] = 0

for i in range(1,n-2):
    if s[i] == '>' and s[i+1] == '<':
        a[i+1] = 0

for i in range(n-1):
    if a[i] == 0:
        tmp = 1
    else:
        tmp += 1
    if s[i] == '<':
        a[i+1] = tmp
    else:
        tmp = 0

for i in range(n-1):
    i = i * (-1) - 1
    if a[i] == 0:
        tmp = 1
    else:
        tmp += 1
    if s[i] == '>':
        a[i-1] = max(tmp, a[i-1])
    else:
        tmp = 0

print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

hq = []

a.sort()
f.sort(reverse = True)

for i in range(n):
    heapq.heappush(hq, (-a[i]*f[i], a[i], f[i]))

for i in range(k):
    s,a1,f1 = heapq.heappop(hq)
    if s == 0:
        print(0)
        exit()
    a1 -= 1
    heapq.heappush(hq, (-a1*f1, a1, f1))

print(-heapq.heappop(hq)[0])


Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))

def hantei(c):
    tmp = 0
    for i in range(n):
        if af[i] > c:
            a1 = c // f[i]
            tmp += a[i]- a1
    if tmp <= k:
        return True
    else:
        return False

hq = []

a.sort()
f.sort(reverse = True)

af = []
for i in range(n):
    af.append(a[i] * f[i])

l = 0
r = 10**12+10

while r - l > 1:
    c = (l + r) // 2
    if hantei(c):
        r = c
    else:
        l = c

if hantei(l):
    print(l)
else:
    print(r)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())

li = []

count = 1
tmp = s[0]

for i in range(1,len(s)):
    if s[i] == tmp:
        count += 1
    else:
        li.append((s[i-1],count))
        count = 1
    tmp = s[i]
if count != 1:
    li.append((s[-1],count))
    
if len(li) == 1:
    print(li[0][1] * k // 2)
elif li[0][0] == li[-1][0] and k >= 2:
    li2 = [(li[0][0],li[0][1]+li[-1][1])]
    for i in range(1,len(li)-1):
        li2.append(li[i])
    ans = 0
    for i in li2:
        ans += i[1] // 2
    ans *= k - 1
    for i in li:
        ans += i[1] // 2
    print(ans)
else:
    ans = 0
    for i in li:
        ans += i[1] // 2
    ans *= k
    print(ans)


Fixed submission:
s = input()
k = int(input())

li = []

count = 1
tmp = s[0]

if len(s) == 1:
    print(k//2)
    exit()

for i in range(1,len(s)):
    if s[i] == tmp:
        count += 1
    else:
        li.append((s[i-1],count))
        count = 1
    tmp = s[i]
if count != 1:
    li.append((s[-1],count))

if len(li) == 1:
    print(li[0][1] * k // 2)
elif li[0][0] == li[-1][0] and k >= 2:
    li2 = [(li[0][0],li[0][1]+li[-1][1])]
    for i in range(1,len(li)-1):
        li2.append(li[i])
    ans = 0
    for i in li2:
        ans += i[1] // 2
    ans *= k - 1
    for i in li:
        ans += i[1] // 2
    print(ans)
else:
    ans = 0
    for i in li:
        ans += i[1] // 2
    ans *= k
    print(ans)

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

li = []

count = 1
tmp = s[0]

for i in range(1,len(s)):
    if s[i] == tmp:
        count += 1
    else:
        li.append((s[i-1],count))
        count = 1
    tmp = s[i]
if count != 1:
    li.append((s[-1],count))
    
if len(li) == 1:
    print(li[0][1] * k // 2)
elif li[0][0] == li[-1][0] and k >= 2:
    li2 = [(li[0][0],li[0][1]+li[-1][1])]
    for i in range(1,len(li)-1):
        li2.append(li[i])
    ans = 0
    for i in li2:
        ans += i[1] // 2
    ans *= k - 1
    for i in li:
        ans += i[1] // 2
    print(ans)
else:
    ans = 0
    for i in li:
        ans += i[1] // 2
    ans *= k
    print(ans)


Fixed submission:
s = input()
k = int(input())

li = []

count = 1
tmp = s[0]

if len(s) == 1:
    print(k//2)
    exit()

for i in range(1,len(s)):
    if s[i] == tmp:
        count += 1
    else:
        li.append((s[i-1],count))
        count = 1
    tmp = s[i]
if count != 1:
    li.append((s[-1],count))

if len(li) == 1:
    print(li[0][1] * k // 2)
elif li[0][0] == li[-1][0] and k >= 2:
    li2 = [(li[0][0],li[0][1]+li[-1][1])]
    for i in range(1,len(li)-1):
        li2.append(li[i])
    ans = 0
    for i in li2:
        ans += i[1] // 2
    ans *= k - 1
    for i in li:
        ans += i[1] // 2
    print(ans)
else:
    ans = 0
    for i in li:
        ans += i[1] // 2
    ans *= k
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    money = [[] for _ in range(10**5)]
    dp = [0] * m

    for _ in range(n):
        a,b = map(int,input().split())
        money[a-1].append(b)

    max1 = []
    for i in range(m):
        max1 += money[i]
        if max1:
            dp[i] = max1.pop(max1.index(max(max1)))
        if i >= 1:
            dp[i] += dp[i-1]

    print(dp[-1])

if __name__ == '__main__':
    main()


Fixed submission:
import sys
import heapq
imput = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    money = [[] for _ in range(10**5)]
    dp = [0] * m
    hq = []
    heapq.heapify(hq)

    for _ in range(n):
        a,b = map(int,input().split())
        money[a-1] += [b]

    for i in range(m):
        for j in money[i]:
            heapq.heappush(hq,-j)
        if hq:
            dp[i] += -heapq.heappop(hq)
        if i >= 1:
            dp[i] += dp[i-1]
    print(dp[-1])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
money = [[] for _ in range(10**5)]
dp = [0] * m

for _ in range(n):
    a,b = map(int,input().split())
    money[a-1].append(b)

max1 = []
for i in range(m):
    max1 += money[i]
    max1.sort(reverse = True)
    if max1:
        dp[i] = max1.pop(0)
    if i >= 1:
        dp[i] += dp[i-1]

print(dp[-1])


Fixed submission:
import sys
import heapq
imput = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    money = [[] for _ in range(10**5)]
    dp = [0] * m
    hq = []
    heapq.heapify(hq)

    for _ in range(n):
        a,b = map(int,input().split())
        money[a-1] += [b]

    for i in range(m):
        for j in money[i]:
            heapq.heappush(hq,-j)
        if hq:
            dp[i] += -heapq.heappop(hq)
        if i >= 1:
            dp[i] += dp[i-1]
    print(dp[-1])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    while True:
        cnt = 0
        if all((a[i] == 0 for i in range(n))):
            print('Yes')
            exit()
        for i in range(n):
            if a[i] % 2 == 0:
                cnt += 1
                flag = True
            a[i] //= 2
        if flag:
            if cnt * 3 != n:
                print('No')
                exit()


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

a.sort()

if n % 3 != 0:
    if all((a[i] == 0 for i in range(n))):
        print('Yes')
    else:
        print('No')
else:
    a1 = a[:n//3]
    a2 = a[n//3:n*2//3]
    a3 = a[n*2//3:]
    if all((a1[i] == 0 for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))):
        print('Yes')
    elif all((a1[i] == a1[0] for i in range(n//3))) and all((a2[i] == a2[0] for i in range(n//3))) and all((a3[i] == a3[0] for i in range(n//3))) and a1[0] ^ a2[0] ^ a3[0] == 0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = ''

for i in range(n):
    a2 = a[i:] + a[:i]
    b = a2[1:n:2]
    c = a2[2:n-1:2]
    ans += str(a2[0]+a2[n-1]+sum(c)-sum(b))
    if i != n-1:
        ans += ' '

print(ans)


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

ans = [sum(a[0:2*n:2])-sum(a[1:2*n:2])]
ans2 = ''

for i in range(n-1):
    ans.append(2*a[i]-ans[i])

for i in range(n):
    ans2 += str(ans[i])
    if i != n-1:
        ans2 += ' '

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

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

mod = 10**9+7
nCr = {}

def cmb(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

b = k
r = n - k


for i in range(1,k+1):
    r2 = r - i + 1
    print(int(cmb(b-1,i-1)*cmb(r2+i,i))%mod)


Fixed submission:
from math import factorial

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

mod = 10**9+7
nCr = {}

def cmb(n,r):
    return factorial(n)//(factorial(r)*factorial(n-r))

b = k
r = n - k


for i in range(1,k+1):
    r2 = r - i + 1
    if r2 < 0:
        print(0)
    else:
        print(int(cmb(b-1,i-1)*cmb(r2+i,i))%mod)
Buggy python submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())

def count(x):
    return x - int(x/c) - int(x/d) + int(x/(c*d/(math.gcd(c,d))))


print(count(b) - count(a-1))


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

def lcm(a,b):
    return a*b//gcd(a,b)

a,b,c,d = map(int,input().split())

def count(x):
    return x - x//c - x//d + x//lcm(c,d)

print(count(b) - count(a-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]

li2 = [(x[0]-y[0],x[1]-y[1]) for x in li for y in li]
data = list(set(li2)) #かぶりを消すような作業や、カウントする前はsetがよい
data.remove((0,0))
data2 = tuple(data) #forなどでlistの中身をたくさん参照する場合はtupleがよい
qty = list(map(lambda x: li2.count(x),data2))

print(n-max(qty))


Fixed submission:
n = int(input())
li = []
for i in range(n):
    a = list(map(int,input().split()))
    li.append(a)

li.sort(key = lambda x:x[0])
li2 = []

for i in range(n):
    for j in range(i):
        a = [li[i][0]-li[j][0],li[i][1]-li[j][1]]
        li2.append(a)

for i in li2:
    if i[0] < 0:
        i[0] = -i[0]
        i[1] = -i[1]
    if i[0] == 0 and i[1] < 0:
        i[1] = -i[1]

ans = 0

for i in li2:
    ans = max(ans,li2.count(i))

print(n-ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))

li.sort()

if li[0] > 0:
    print(sum(li)-2*li[0])
    for i in range(n-2):
        print(li[0],li[i+1])
        li[0] -= li[i+1]
    print(li[n-1],li[0])
elif li[n-1] < 0:
    print(abs(sum(li))+2*li[n-1])
    for i in range(n-1):
        print(li[n-1],li[i])
        li[n-1] -= li[i]
else:
    for i in range(n):
        if li[i] > 0:
            a = i-1
            break
    print(abs(sum(li[:a+1])) + sum(li[a+1:]))
    for i in range(n-a-2):
        print(li[0],li[a+1+i])
        li[0] -= li[a+1+i]
    for i in range(a+1):
        print(li[n-1],li[i])
        li[n-1] -= li[i]


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

li.sort()

if li[0] >= 0:
    print(sum(li)-2*li[0])
    for i in range(n-2):
        print(li[0],li[i+1])
        li[0] -= li[i+1]
    print(li[n-1],li[0])
elif li[n-1] <= 0:
    print(abs(sum(li))+2*li[n-1])
    for i in range(n-1):
        print(li[n-1],li[i])
        li[n-1] -= li[i]
else:
    for i in range(n):
        if li[i] > 0:
            a = i-1
            break
    print(abs(sum(li[:a+1])) + sum(li[a+1:]))
    for i in range(n-a-2):
        print(li[0],li[a+1+i])
        li[0] -= li[a+1+i]
    for i in range(a+1):
        print(li[n-1],li[i])
        li[n-1] -= li[i]
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
lia = [int(input()) for _ in range(m)]
cnt = 0
li = [0] * (n+1)
mod = 1000000007

for i in range(n+1):
    if i == 0 or i == 1:
        if lia[cnt] == i:
            li[i] = 0
            if cnt < m-1:
                cnt += 1
        else:
            li[i] = 1
    else:
        if lia[cnt] == i:
            li[i] = 0
            if cnt < m-1:
                cnt += 1
        else:
            li[i] = li[i-1] + li[i-2]
    li[i] %= mod

print(li[n])


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

li = []
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n+10):
    if i == 0 or i == 1:
        li.append(1)
    else:
        li.append((li[i-1] + li[i-2]) % mod)

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        ans = 0
    ans %= mod

print(ans%mod)

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

li = []
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n):
    if i == 0 or i == 1:
        li.append(1)
    else:
        li.append((li[i-1] + li[i-2]) % mod)

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        ans = 0
    ans %= mod

print(ans%mod)


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

li = []
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n+10):
    if i == 0 or i == 1:
        li.append(1)
    else:
        li.append((li[i-1] + li[i-2]) % mod)

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        ans = 0
    ans %= mod

print(ans%mod)

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

li = [0]*10**5
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n):
    if i == 0:
        li[i] = 1
    elif i == 1:
        li[i] = 1
    else:
        li[i] = li[i-1] + li[i-2]

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        if lia[i] == 0 or lia[i+1] == n:
            pass
        else:
            ans = 0
    ans %= mod

print(ans%mod)


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

li = []
lia = [-1]
ans = 1
mod = 1000000007

for i in range(n+10):
    if i == 0 or i == 1:
        li.append(1)
    else:
        li.append((li[i-1] + li[i-2]) % mod)

for i in range(m):
    a = int(input())
    lia.append(a)

lia.append(n+1)

for i in range(len(lia)-1):
    if lia[i+1]-lia[i] != 1:
        ans *= li[lia[i+1]-lia[i]-2]
    else:
        ans = 0
    ans %= mod

print(ans%mod)
Buggy python submission (verdict: Runtime Error):
s = int(input())

b = s % 100
a = int((s-b)/100)

if a ==0 or b == 0:
    print(‘NA’)
elif a> 12 and b>12:
    print(‘NA’)
elif a>12:
    print(‘YYMM’)
elif b>12:
    print(‘MMYY’)
else:
    print(‘AMBIGUOUS’)



Fixed submission:
s = int(input())

b = s % 100
a = int((s-b)/100)

flaga = False
flagb = False

if a > 0 and a < 13:
    flaga = True
if b > 0 and b < 13:
    flagb = True

if flaga == True and flagb == True:
    print('AMBIGUOUS')
if flaga == False and flagb == True:
    print('YYMM')
if flaga == True and flagb == False:
    print('MMYY')
if flaga == False and flagb == False:
    print('NA')

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

b = s % 100
a = int((s-b)/100)

if a ==0 or b == 0
    print(‘NA’)
elif a> 12 and b>12
    print(‘NA’)
elif a>12
    print(‘YYMM’)
elif b>12
    print(‘MMYY’)
else
    print(‘AMBIGUOUS’)



Fixed submission:
s = int(input())

b = s % 100
a = int((s-b)/100)

flaga = False
flagb = False

if a > 0 and a < 13:
    flaga = True
if b > 0 and b < 13:
    flagb = True

if flaga == True and flagb == True:
    print('AMBIGUOUS')
if flaga == False and flagb == True:
    print('YYMM')
if flaga == True and flagb == False:
    print('MMYY')
if flaga == False and flagb == False:
    print('NA')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    li = [list(map(int,input().split())) for _ in range(m)]

    roots = [[] for _ in range(n)]
    for x,y,z in li:
        roots[x-1].append(y-1)
        roots[y-1].append(x-1)

    ans = 0
    count = 0
    stack = []
    group = [-1] * n

    while count < n:
        a = group.index(-1)
        stack.append(a)
        group[a] = ans
        count += 1
        while stack:
            label = stack.pop(-1)
            for i in roots[label]:
                if group[i] == -1:
                    group[i] = ans
                    stack.append(i)
                    count += 1
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n,m = map(int,input().split())
    li = [list(map(int,input().split())) for _ in range(m)]

    roots = [[] for _ in range(n)]
    for x,y,z in li:
        roots[x-1].append(y-1)
        roots[y-1].append(x-1)

    ans = 0
    count = 0
    group = [-1] * n

    for i in range(n):
        if group[i] == -1:
            stack = [i]
            while stack:
                label = stack.pop(-1)
                for j in roots[label]:
                    if group[j] == -1:
                        group[j] = ans
                        stack.append(j)
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n =map(int,input().split())
count =0
for i in range(4000):
    if r * i <= n:
        for j in range(4000):
            if (r * i + g * j) <= n:
                for k in range(4000):
                    if r*i+g*j+b*k == n:
                        count += 1
                    elif r*i+g*j+b*k > n:
                        break
            else:
                break
    else: 
        break

print(count)


Fixed submission:
r,g,b,n = map(int,input().split())

count = 0

for i in range(int(n/r)+1):
    for j in range(int((n-i*r)/g)+1):
        k =  n - i * r - j * g
        if k % b == 0:
            count += 1

print(count)