Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = input()
N = N[2]
if N = "3":
  print("bon")
elif N = "0" or N = "1" or N = "6" or N = "8":
  print("pon")
else:
  print("hon")

Fixed submission:
N = input()
N = N[len(N)-1]
if N == "3":
  print("bon")
elif N == "0" or N == "1" or N == "6" or N == "8":
  print("pon")
else:
  print("hon")
Buggy python submission (verdict: Runtime Error):
S = input()
if S[1] == S[2] == S[3]:
  print("No")
else:
  print("Yes")

Fixed submission:
S = input()
if S[1] == S[2] == S[0]:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int, input().split())
ans = ""
while len(ans) <= N:
    ans += "b"*A + "r"*B
print(ans)
print(ans[:N].count("b"))

Fixed submission:
N,A,B = map(int, input().split())
temp = N//(A+B)
N-=(A+B)*temp
ans = temp * A
ans += min(N,A)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
print(math.ceil(int(input)/2))

Fixed submission:
import math
print(math.ceil(int(input())/2))
Buggy python submission (verdict: Runtime Error):
N,R = map(int, input().split())
if N >9:
    print(R)
else:
    print(R+100*(10-K))

Fixed submission:
N,R = map(int, input().split())
if N > 9:
    print(R)
else:
    print(R+100*(10-N))
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
i = 1
while K**i =< N:
    i+=1
else:
    print(i)

Fixed submission:
N,K = map(int, input().split())
i = 1
while K**i <= N:
    i+=1
else:
    print(i)
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
print(max(ans))

Fixed submission:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
if len(ans) != 0:
    print(max(ans))
else:
    print(p_sum)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
p = list(map(int, input().split()))
temp = []
for i in range(N-K+1):
    temp.append(sum(p[i:i+K]))
iti = temp.index(max(temp))
ans = 0
for j in p[iti:iti+K]:
    ans += (j+1)/2
print(ans)

Fixed submission:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p = list(map(lambda x:(x+1)/2, p))
temp = []
p_sum=0
for i in range(N):
    p_sum+=p[i]
    temp.append(p_sum)
ans = []
for j in range(K,N):
    ans.append(temp[j]-temp[j-K])
if len(ans) != 0:
    print(max(ans))
else:
    print(p_sum)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
if N<=K:
    print(0)
else:
    H.sort()
    print(sum(H)-sum(H[N-1-k:]))

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
if N<=K:
    print(0)
else:
    H.sort()
    print(sum(H[:N-K]))
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int, input().split())
for _ in range(K):
    if A>0:
        A -= 1
    elif B>0:
        B -= 1
print(A,B)


Fixed submission:
A,B,K = map(int, input().split())
if A>K:
    print(A-K,B)
elif A+B>K:
    print(0,A+B-K)
else:
    print(0,0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
if N%2 == 1:
    print("No")
    exit()
t = S[:N/2]
if S[N/2:] == t:
    print("Yes")
else:
    print("No")


Fixed submission:
N = int(input())
S = input()
if N%2 == 1:
    print("No")
    exit()
if S[N//2:] == S[:N//2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import re
N = int(input())
S = input()
for _ in range(N):
    S = re.sub("(.)\\1", "\\1", S)
print(len(S))  

Fixed submission:
import re
N = int(input())
S = input()
while re.search("(.)\\1",S):
    S = re.sub("(.)\\1", "\\1", S)
print(len(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = "1" if N == 1 else "0.5" if N%2 != 1 else (N-1)/2N
print(ans)

Fixed submission:
N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = "1" if N = 1 else "0.6" if N%2 = 1 else "0.5"
print(ans)

Fixed submission:
N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
print(ans: "1" if N = 1 else "0.6" if N%2 = 1 else "0.5")

Fixed submission:
N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
print("1" if N = 1 else "0.6" if N%2 = 1 else "0.5")

Fixed submission:
N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N%2 != 1:
    ans= 0.5
else:
    ans=(N+1)/(2*N)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input(),split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    if i>K:
        ans +=1
print(ans)

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
    if i >= K:
        ans +=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N =int(input())
dic = {}
j=1
for i in map(int, input().split()):
    dic[i]=j
    j+=1
for n in range(N):
    print(dic[n])

Fixed submission:
N =int(input())
dic = {}
j=1
for i in map(int, input().split()):
    dic[i]=j
    j+=1
for n in range(1, N+1):
    print(dic.get(n))
Buggy python submission (verdict: Runtime Error):
S=input()
if S == Sunny:
  print(Cloudy)
  elif S == Cloudy:
    print(Rainy)
    else
    	print(Sunny)
    	

Fixed submission:
S=input()
if S == "Sunny":
	print("Cloudy")
elif S == "Cloudy":
	print("Rainy")
else:
	print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
slen = len(S)
i = int(0)
j = int(0)
while slen >= i:
	if (i%2 == 1 and S[i] == "R","U","D"):
		j = 0
	elif (i%2 == 0 and S[i] == "L","U","D"):
		j = 0
	else:
		j += 1
	i+1
if j == 0:
	print("No")
else:
	print("Yes")

Fixed submission:
S = list(input())
if False not in [i not in "L" for i in S[::2]] and False not in [i not in "R"for i in S[1::2]]:
	print("Yes")
else:
	print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
slen = len(S)
i = int(0)
j = int(0)
while slen >= i:
	if i%2 == 1 and S[i] == "R","U","D":
		j = 0
	elif i%2 == 0 and S[i] == "L","U","D":
		j = 0
	else:
		j += 1
  i+1
if j == 0:
	print("No")
else:
	print("Yes")

Fixed submission:
S = list(input())
if False not in [i not in "L" for i in S[::2]] and False not in [i not in "R"for i in S[1::2]]:
	print("Yes")
else:
	print("No")
Buggy python submission (verdict: Runtime Error):
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
 A.append(int(input()))
P = []
P = [0] * (N-1)
i = 0
while Q>i:
    P[A[i]-1] += 1
    i += 1
for j in P:
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")


Fixed submission:
N, K, Q = map(int, input().split())
A = []
for _ in range(Q):
 A.append(int(input()))
P = []
P = [0] * N
i = 0
while Q>i:
    P[A[i]-1] += 1
    i += 1
for j in P:
    if (K - Q + j) > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
n=int(0)
manzoku=int(0)
hantei = int(1)
if A[0] == hantei:
        manzoku += sum(C) + sum(B)
else:
        manzoku += sum(C) - C[A[0]-3] +sum(B)

print(manzoku)


Fixed submission:
N=int(input())
print(N*N*N)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
ans = 0
for i in S and j in T:
    if i == j:
        ans += 1
print(ans)

Fixed submission:
S = input()
T = input()
ans = 0
for i, j in zip(S, T):
    if i == j:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans,i = 0
for n in range(N):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
i = 0
for n in range(N-1):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
i = 0
j = 0
n = 0
ans = []
ans = [0] * N
for n in range(N):
    for i, j in zip(H[n::],H[n+1::]):
        if i >= j:
            ans[n] += 1
        else:
            break
print(max(ans))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
i = 0
for n in range(N-1):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H = list(map(int, input().split()))
ans = []
ans = [0] * N
for n in range(N):
    for i, j in zip(H[n::],H[n+1::]):
        if i >= j:
            ans[n] += 1
        else:
            break
print(max(ans))


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
i = 0
for n in range(N-1):
    if H[n] >= H[n+1]:
        i += 1
    else:
        if ans < i:
            ans = i
        i=0
print(max(ans,i))
Buggy python submission (verdict: Runtime Error):
N = float(input())
A = list(map(float, input().split()))
j = float(0)
ans = float(0)
for i in A:
    J += 1/i
ans = 1/j
print(ans)

Fixed submission:
N = float(input())
A = list(map(float, input().split()))
j = float(0)
ans = float(0)
for i in A:
    j += 1/i
ans = 1/j
print(ans)
Buggy python submission (verdict: Runtime Error):
K, X = map(int, input().split())
print(range(x-k,x+k))


Fixed submission:
K, X = map(int, input().split())
a=X-K+1
b=X+K
for i in range(a,b):
    print(i)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1,0,-1):
    if H[i]>H[i-1]:
        if H[i]>(H[i-1]-1):
            print("No")
            exit()
print("Yes")


Fixed submission:
A, B, C = map(int, input().split())
print(C-A+B if C-A+B>0 else 0)

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N-1,0,-1):
    if H[i]>H[i-1]:
        if H[i]>(H[i]-1):
            print("No")
            exit()
print("Yes")


Fixed submission:
A, B, C = map(int, input().split())
print(C-A+B if C-A+B>0 else 0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N<10:
    print(N)
elif N<100:
    prnt(9)
elif N<1000:
    print(N-90)
else:
    print(90909)


Fixed submission:
N = int(input())
if N < 10:
    print(N)
elif N < 100:
    print(9)
elif N < 1000:
    print(N-90)
elif N < 10000:
    print(909)
elif N < 100000:
    print(N - 9090)
else:
    print(90909)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break
print("Yes")


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
for i in range(N,-1,-1):
    if H[i]>H[i-1]:
        H[i] -= 1
        if H[i]>H[i-1]:
            print("No")
            break()
print("Yes")



Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
        else:
            break
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i,j,k in zip(H,H[1::],H[2::]):
    if i == j:
        if j > k:
            ans *= 0
    else i > j+1:
        ans *= 0
print("Yes" if ans == 1 else "No")


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
ans = 1
for i in range(N):
    if H[i] == H[i+1] or (H[i+1]-1):
        ans *= 1
    else:
        ans *= 0
print("Yes" if ans == 1 else "No")

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
for i in reversed(range(N-1)):
    if H[i]>H[i+1]:
        H[i] -= 1
        if H[i]>H[i+1]:
            print("No")
            exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
fans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N):
    for j in range(D):
        tmp.append((X[i-1][j]-X[i][j])**2)
    ans.append((tmp[0] + tmp[1])**0.5)
    tmp = []
for A in ans:
    if A.is_integer():
        fans += 1
print(fans)

Fixed submission:
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
fans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N-1):
    for j in range(i+1, N):
        if D == 1:
            tmp.append((X[i][0]-X[j][0])**2)
        else:
            for k in range(D):
                tmp.append((X[i][k]-X[j][k])**2)
        ans.append(sum(tmp)**0.5)
        tmp = []
for A in ans:
    if A.is_integer():
        fans += 1
print(fans)

Buggy python submission (verdict: Runtime Error):
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N):
    for j in range(D):
        tmp.append((X[i-1][j]-X[i][j])**2)
    ans.append(tmp[0] + tmp[1])
print(ans)

Fixed submission:
N ,D = map(int, input().split())
X = []
tmp = []
ans = []
fans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))
for i in range(N-1):
    for j in range(i+1, N):
        if D == 1:
            tmp.append((X[i][0]-X[j][0])**2)
        else:
            for k in range(D):
                tmp.append((X[i][k]-X[j][k])**2)
        ans.append(sum(tmp)**0.5)
        tmp = []
for A in ans:
    if A.is_integer():
        fans += 1
print(fans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[N/2] - d[N/2-1])
    

Fixed submission:
import math
N = int(input())
d = list(map(int, input().split()))
d.sort()
tmp = math.floor(N/2)
print(d[tmp] - d[tmp-1])
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
tmp = 0
for _ in range(N):
    tmp += L
    L += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L=< 0:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N > L:
        print(tmp)
    else:
        print(tmp-(N+L-1))
        

Fixed submission:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N+L == 0:
        print(tmp+1)
    elif N + L > 0:
        print(tmp)
    else:
        print(tmp - N - L + 1)

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
for _ in range(N):
    tmp += L
    L += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L=< 0:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N > L:
        print(tmp)
    else:
        print(tmp-(N+L-1))
        

Fixed submission:
N, L = map(int, input().split())
tmp = 0
i = L
for _ in range(N):
    tmp += i
    i += 1
if tmp == 0:
    print(0)
elif tmp > 0:
    if L < 1:
        print(tmp)
    else:
        print(tmp-L)
else:
    if N+L == 0:
        print(tmp+1)
    elif N + L > 0:
        print(tmp)
    else:
        print(tmp - N - L + 1)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, D = map(int, input().split())
ans = 0
for i in range(A,B+1):
    if i%C == 0:
        continue
    else:
        if i%D == 0:
            continue
        else:
            ans += 1
print(ans)

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
print((B-A+1)-(B//C-(A-1)//C)-(B//D-(A-1)//D)+(B//lcm(C,D)-(A-1)//lcm(C,D)))
Buggy python submission (verdict: Runtime Error):
import math
W, H, x, y = map(int, input().split())
half_s = W*H/2
tmp = (x-y)**2**0.5
print(half_s,math.floor(tmp-1))

Fixed submission:
W, H, x, y = map(float, input().split())
half_s = W*H/2
tmp = 0
if x == W/2 and y == H/2:
    tmp = 1
print(half_s,tmp)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
W = list(int(input()))
w_sort = sorted(W)
if N%2 == 0:
    tmp = N/2 + 1
    s1 = sum(w_sort[:tmp])
    s2 = sum(w_sort[tmp:])
    print(math.floor(abs(s1-s2)))
else:
    tmp = N//2
    s1 = sum(w_sort[:tmp])
    s2 = sum(w_sort[tmp:])
    print(math.floor(abs(s1-s2)))


Fixed submission:
import math
N = int(input())
W = list(map(int, input().split()))
allw = sum(W)
tmp = []
for j in range(N):
    tmp.append(abs(sum(W[:j])-sum(W[j:])))
print(min(tmp))
Buggy python submission (verdict: Runtime Error):
import math
def fib(number):
    a, b = 0, 1
    if number == 1:
        return a
    elif number == 0:
        return b
    else:
        for _ in range(number-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = []
ans = 1
tmp = 0
for _ in range(M):
    a.append(int(input()))
for i in a:
    number = i-1-tmp
    if number<1:
        print(0)
        exit()
    else:
        ans *= fib(number)
        tmp = i
print(number)

Fixed submission:
import math
def fib(number):
    a, b = 0, 1
    for _ in range(number):
        a, b = b, a + b
    return b
N, M = map(int, input().split())
a = []
ans = 1
tmp = 0
for _ in range(M):
    a.append(int(input()))
for i in a:
    number = i-tmp
    if i == 1:
        tmp = 2
        continue
    else:
        if number<1:
            print(0)
            exit()
        else:
            ans *= fib(number-1)
            tmp = i+1
print((ans*fib(N-tmp))%1000000007)
Buggy python submission (verdict: Runtime Error):
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)

Fixed submission:
#1107
import math
A, P = map(int, input().split())
print(math.floor((A*3+P)/2))
Buggy python submission (verdict: Runtime Error):
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    for s in range(n):
        tmp = array([t >> s & 1])
    for i in l:
        if p == sum(tmp[array(i)-1])%2:
            ans += 1
print(ans)

Fixed submission:
from numpy import*
n, m = map(int, input().split())
l = []
for i in range(m):
    *a,=map(int,input().split())
    l.append(a[1:])
*p,=map(int,input().split())
ans = 0
for t in range(2**n):
    tmp=array([t>>s&1 for s in range(n)])
    if p==[sum(tmp[array(i)-1])%2for i in l]:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = 0
R = 0
for _ in range(M):
    inp = input().split()
    l = int(inp[0])
    r = int(inp[1])
    L = max(L,l)
    R = min(R,r)
print(max(0,min(R,N) + 1 - L))

Fixed submission:
#1226
import math
A, B = map(int, input().split())
print(math.floor(B if A > 12 else B/2 if A > 5 else 0))

Buggy python submission (verdict: Runtime Error):
#1226
A, B = map(int, input().split())
print(B if A > 12 else B/2 if A > 5 0)

Fixed submission:
#1226
import math
A, B = map(int, input().split())
print(math.floor(B if A > 12 else B/2 if A > 5 else 0))
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
for k in range(1,N + 1):
    for i,j in zip(L,R):
        if i <= k and k <= j:
            continue
        else:
            break
    else:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = []
R = []
ans = 0
tmp = 1
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
for k in range(1,N + 1):
    for i,j in zip(L,R):
        if tmp == 1:
            if i <= k and k <= j:
                tmp *= 1
            else:
                tmp *= 0
        else:
            break
    if tmp == 1:
        ans += 1
    else:
        tmp = 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = []
R = []
ans = 0
tmp = 1
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
for j in range(1,N + 1):
    for i in range(M):
        if tmp == 1:
            if L[i]-1 < j < R[i]+1:
                tmp *= 1
            else:
                tmp *= 0
        else:
            break
    if tmp == 1:
        ans += 1
    else:
        tmp = 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = int(input().split())
    L.append(inp[0])
    R.append(inp[1])
for i in range(N):
    if L[i] < i + 1 <R[i]:
        ans += 1
print(ans)

Fixed submission:
N, M = map(int, input().split())
L = []
R = []
ans = 0
for _ in range(M):
    inp = input().split()
    L.append(int(inp[0]))
    R.append(int(inp[1]))
L_max = max(L)
R_min = min(R)
for i in range(L_max,min(R_min,N) + 1):
    ans  += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = int(input())
if S[:2] > 12:
    if 13 > S[2:] > 0
        print("YYMM")
    else:
        print("NA")
elif 0 < S[:2] < 13:#12xx~01xx
    if S[2:] > 12:
        print("MMYY")
    elif 0 < S[2:] < 13:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:#00xx
    if 0 < S[2:] <13:
        print("YYMM")
    else:
        print("NA")


Fixed submission:
S = input()
if int(S[:2]) > 12:
    if 13 > int(S[2:]) > 0:
        print("YYMM")
    else:
        print("NA")
elif 0 < int(S[:2]) < 13:#12xx~01xx
    if int(S[2:]) > 12:
        print("MMYY")
    elif 0 < int(S[2:]) < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:#00xx
    if 0 < int(S[2:]) <13:
        print("YYMM")
    else:
        print("NA")