Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a_list = list(map(int,input().split()))
a_n_list = []
for i in range(N):
    a_n_list.append([a_list[i],i+1])
a_n_list.sort()
ans = ""
for i in range(N):
    ans = ans + str(a_n_list[i][1]) + " "
print(ans[0:-1])

Fixed submission:
N = int(input())

a_list = list(map(int,input().split()))
a_n_list = []
for i in range(N):
    a_n_list.append([a_list[i],i+1])
a_n_list.sort()
ans = ""
for i in range(N):
    print(a_n_list[i][1], end=" ")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))
ans = sum(B_list)

for i in range(1,N):
    
    if A_list[i] == A_list[i-1]+1 :
        ans += C_list[i]
print(ans)
    

Fixed submission:
N = int(input())
A_list = list(map(int,input().split()))
B_list = list(map(int,input().split()))
C_list = list(map(int,input().split()))
ans = sum(B_list)

for i in range(1,N):
    
    if A_list[i] == A_list[i-1]+1 :
        ans += C_list[A_list[i]-2]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
RtoL = []
LtoR = []
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RtoL.append(i+1)
    elif S[i] == 'L' and S[i+1] == 'R':
        LtoR.append(i+1)
LtoR.append(len(S))
LR_RL = [0]*(len(LtoR))
ans = [0]*len(S)
for i in range(len(LtoR)-1,-1,-1):
    LR_RL[i] = LtoR[i]-RtoL[i]
    if i-1 > -1:
        LtoR[i] = LtoR[i]-LtoR[i-1]
    k = LtoR[i]
    p = LtoR[i]//2
    z = RtoL[i]
    if k%2 ==0:
        ans[z] = p
        ans[z-1] = p
    else:
        if LR_RL[i]%2 == 0:
            ans[z] = p
            ans[z-1] = k-p
        else:
            ans[z] = k-p
            ans[z-1] = p


ans_str = ""
for i in range(len(ans)):
    ans_str += str(ans[i])
    ans_str += " "
    
print(ans_str[0:-1])

Fixed submission:
S = input()
RtoL = []
LtoR = []
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RtoL.append(i+1)
    elif S[i] == 'L' and S[i+1] == 'R':
        LtoR.append(i+1)
LtoR.append(len(S))
LR_RL = [0]*(len(LtoR))
ans = [0]*len(S)
for i in range(len(LtoR)-1,-1,-1):
    LR_RL[i] = LtoR[i]-RtoL[i]
    if i-1 > -1:
        LtoR[i] = LtoR[i]-LtoR[i-1]
    k = LtoR[i]
    p = LtoR[i]//2
    z = RtoL[i]
    if k%2 ==0:
        ans[z] = p
        ans[z-1] = p
    else:
        if LR_RL[i]%2 == 0:
            ans[z] = p
            ans[z-1] = k-p
        else:
            ans[z] = k-p
            ans[z-1] = p


ans_str = ""
for i in range(len(ans)):
    ans_str += str(ans[i])
    ans_str += " "
    
print(ans_str[0:-1])

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
RtoL = []
LtoR = []
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RtoL.append(i+1)
    elif S[i] == 'L' and S[i+1] == 'R':
        LtoR.append(i+1)
LtoR.append(len(S))
LR_RL = []
for i in range(len(LtoR)):
    LR_RL.append(LtoR[i]-RtoL[i])
for i in range(len(LtoR)-1,0,-1):
    LtoR[i] = LtoR[i]-LtoR[i-1]
ans = [0]*len(S)
for i in range(len(RtoL)):
    k = LtoR[i]
    p = LtoR[i]//2
    z = RtoL[i]
    if k%2 ==0:
        ans[z] = p
        ans[z-1] = p
    else:
        if LR_RL[i]%2 == 0:
            ans[z] = p
            ans[z-1] = k-p
        else:
            ans[z] = k-p
            ans[z-1] = p
ans_str = ""
for i in range(len(ans)):
    ans_str += str(ans[i])
    ans_str += " "
    
print(ans_str[0:-1])

Fixed submission:
S = input()
RtoL = []
LtoR = []
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        RtoL.append(i+1)
    elif S[i] == 'L' and S[i+1] == 'R':
        LtoR.append(i+1)
LtoR.append(len(S))
LR_RL = [0]*(len(LtoR))
ans = [0]*len(S)
for i in range(len(LtoR)-1,-1,-1):
    LR_RL[i] = LtoR[i]-RtoL[i]
    if i-1 > -1:
        LtoR[i] = LtoR[i]-LtoR[i-1]
    k = LtoR[i]
    p = LtoR[i]//2
    z = RtoL[i]
    if k%2 ==0:
        ans[z] = p
        ans[z-1] = p
    else:
        if LR_RL[i]%2 == 0:
            ans[z] = p
            ans[z-1] = k-p
        else:
            ans[z] = k-p
            ans[z-1] = p


ans_str = ""
for i in range(len(ans)):
    ans_str += str(ans[i])
    ans_str += " "
    
print(ans_str[0:-1])
Buggy python submission (verdict: Runtime Error):

A,B,C,D = map(int,input().split())

#N = int(input())

#list(map(int,input().split()))

cnt = B-A+1

import math
E = C*D / math.gcd(C, D)


A_C = A//C
A_dC = A%C

B_C = B//C
#B_dC = B%C

A_D = A//D
A_dD = A%D

B_D = B//D
#B_dD = B%D

A_E = A//E
A_dE = A%E

B_E = B//E
#B_dE = B%E

C_cnt = B_C - A_C
if A_dC == 0:
    C_cnt += 1
D_cnt = B_D - A_D
if A_dD == 0:
    D_cnt += 1
E_cnt = B_E - A_E
if A_dE == 0:
    E_cnt += 1  

ans = cnt - C_cnt - D_cnt + E_cnt
print(int(ans))


Fixed submission:

A,B,C,D = map(int,input().split())

#N = int(input())

#list(map(int,input().split()))

cnt = B-A+1

import fractions
E = C*D // fractions.gcd(C, D)


A_C = A//C
A_dC = A%C

B_C = B//C
#B_dC = B%C

A_D = A//D
A_dD = A%D

B_D = B//D
#B_dD = B%D

A_E = A//E
A_dE = A%E

B_E = B//E
#B_dE = B%E

C_cnt = B_C - A_C
if A_dC == 0:
    C_cnt += 1
D_cnt = B_D - A_D
if A_dD == 0:
    D_cnt += 1
E_cnt = B_E - A_E
if A_dE == 0:
    E_cnt += 1  

ans = cnt - C_cnt - D_cnt + E_cnt
print(int(ans))
Buggy python submission (verdict: Runtime Error):
N = int(input())
# -*- coding: utf-8 -*-
#hq = []
#hq_inv = []#大きいもの
#import heapq
l = list(map(int,input().split()))
l.sort()
import bisect
index = bisect.bisect_right(l, 0)
if index == 0:
    print(sum(l)-l[0])
else:
    print(sum(l[index:]-sum(l[:index-1])))


Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l.sort()
sousa = []
next_m = l[0]
next_p = l[N-1]
for i in range(1,N-1):
    if l[i] > 0:
        sousa.append([next_m,l[i]])
        next_m -= l[i]
    else:
        sousa.append([next_p,l[i]])
        next_p -= l[i]
ans = next_p - next_m
print(ans)
sousa.append([next_p,next_m])
for i in range(N-1):
    print(str(sousa[i][0])+" "+str(sousa[i][1]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
# -*- coding: utf-8 -*-
#hq = []
#hq_inv = []#大きいもの
#import heapq
l = list(map(int,input().split()))
l.sort()
import bisect
index = bisect.bisect_right(l, 0)
if index == 0:
    print(sum(l)-l[0])
else:
    print(sum(l[index:]-sum(l[:index-1])))


Fixed submission:
N = int(input())
l = list(map(int,input().split()))
l.sort()
sousa = []
next_m = l[0]
next_p = l[N-1]
for i in range(1,N-1):
    if l[i] > 0:
        sousa.append([next_m,l[i]])
        next_m -= l[i]
    else:
        sousa.append([next_p,l[i]])
        next_p -= l[i]
ans = next_p - next_m
print(ans)
sousa.append([next_p,next_m])
for i in range(N-1):
    print(str(sousa[i][0])+" "+str(sousa[i][1]))
Buggy python submission (verdict: Time Limit Exceeded):
#N = int(input())
INF = 1000000007
N,M = map(int,input().split())
a_list = [-1]
for i in range(M):
    a_list.append(int(input()))
a_list.append(N+1)
a_list.sort()
sa_list = []
for i in range(1,M+2):
    sa_list.append(a_list[i]-a_list[i-1])

def fibonacci(n):
    if (n<=1):
        return (n)
    else:
        return(fibonacci(n-1) + fibonacci(n-2))
n=max(sa_list)+2
fib_list=[]
for i in range(n-1):
    fib_list.append(fibonacci(i))
ans = 1
for sa_i in range(len(sa_list)):
    sa = sa_list[sa_i]
#    print(sa)
    ans = ans*fib_list[sa-1]
    ans = ans % INF
print(ans)

Fixed submission:
#N = int(input())
INF = 1000000007
N,M = map(int,input().split())
a_list = [-1]
for i in range(M):
    a_list.append(int(input()))
a_list.append(N+1)
a_list.sort()
sa_list = []
for i in range(1,M+2):
    sa_list.append(a_list[i]-a_list[i-1])

#def fibonacci(n):
#    if (n<=1):
#        return (n)
#    else:
#        return(fibonacci(n-1) + fibonacci(n-2))
n=max(sa_list)+2
fib_list = []

a, b = 0, 1
for i in range(n):
    fib_list.append(a)
    a, b = b, a + b

#fib_list = [i for i in fib(n)]
#for i in range(n-1):
#    fib_list.append(fibonacci(i))
ans = 1
for sa_i in range(len(sa_list)):
    sa = sa_list[sa_i]
#    print(sa)
    ans = ans*fib_list[sa-1]
    ans = ans % INF
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

L1,R1 = map(int,input().split())
through = set(range(L1,R1+1))
for i in range(M-1):
    L,R = map(int,input().split())
    through = through & set(range(L,R+1))
print(len(through))

Fixed submission:
N,M = map(int,input().split())

through_list = []
for i in range(M):
    L,R = map(int,input().split())
    through_list.append([L,R])
through_list.sort()
ans_range = through_list[0]
for i in range(M-1):
    ans_range = [max(ans_range[0],through_list[i+1][0]),min(ans_range[1],through_list[i+1][1])]
ans = ans_range[1]-ans_range[0]+1 
ans = max(0,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
import math
sq_N = int(math.sqrt(N))
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0 or N//k == N%k:
        ans += k

print(ans)



Fixed submission:
N = int(input())
import math
sq_N = int(math.sqrt(N))
ans = 0
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
N_divs = make_divisors(N)


for i in range(len(N_divs)): 
    k = N//N_divs[i] - 1
    if k != 0:
        if N//k == N%k:
            ans += k

print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = 0
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
if  a >= b:
  ans += a
  a -= 1
else:
  ans += b
  b -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)]) + min([abcde[i]%10 for i in range(5) if abcde[i]%10 != 0])-10
print(ans)

Fixed submission:
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
amari = [abcde[i]%10 for i in range(5) if abcde[i]%10 != 0]
if len(amari) == 0:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
else:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])-10+min(amari)
    
print(ans)

Buggy python submission (verdict: Runtime Error):
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([(abcde[i]//10+1)*10 for i in range(5)]) + min([abcde[i]%10 for i in range(5) if abcde[i]%10 != 0])-10
print(ans)

Fixed submission:
abcde = []
for i in range(5):
    abcde.append(int(input()))
ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
amari = [abcde[i]%10 for i in range(5) if abcde[i]%10 != 0]
if len(amari) == 0:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])
else:
    ans = sum([-(-abcde[i] // 10)*10 for i in range(5)])-10+min(amari)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int,input().split())
s = input()
lr_list = []
#for i in range(q):
#    lr_list.append(list(map(int,input().split())))
ans_list = []
for i in range(q):
#    l,r = lr_list[i]
    l,r = map(int,input().split())
    ans_list.append(s[l-1:r].count('AC'))
for i in range(q):
    print(ans_list[i])

Fixed submission:
n, q = map(int,input().split())
s = input()
ruiseki = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        ac = 1
    else:
        ac = 0
    ruiseki[i+1] = ruiseki[i] + ac
ans_list = []
for i in range(q):
    l,r = map(int,input().split())
    ans_list.append(ruiseki[r-1]-ruiseki[l-1])
for i in range(q):
    print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int,input().split())
s = input()
lr_list = []
#for i in range(q):
#    lr_list.append(list(map(int,input().split())))
ans_list = []
for i in range(q):
#    l,r = lr_list[i]
    l,r = map(int,input().split())
    ans_list.append(s[l-1:r].replace('AC','1').count('1'))
for i in range(q):
    print(ans_list[i])

Fixed submission:
n, q = map(int,input().split())
s = input()
ruiseki = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        ac = 1
    else:
        ac = 0
    ruiseki[i+1] = ruiseki[i] + ac
ans_list = []
for i in range(q):
    l,r = map(int,input().split())
    ans_list.append(ruiseki[r-1]-ruiseki[l-1])
for i in range(q):
    print(ans_list[i])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int,input().split())
s = input()
lr_list = []
for i in range(q):
    lr_list.append(list(map(int,input().split())))
    
for i in range(q):
    l,r = lr_list[i]
    print(s[l-1:r].replace('AC','1').count('1'))
    

Fixed submission:
n, q = map(int,input().split())
s = input()
ruiseki = [0]*(n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        ac = 1
    else:
        ac = 0
    ruiseki[i+1] = ruiseki[i] + ac
ans_list = []
for i in range(q):
    l,r = map(int,input().split())
    ans_list.append(ruiseki[r-1]-ruiseki[l-1])
for i in range(q):
    print(ans_list[i])
Buggy python submission (verdict: Runtime Error):
ap(int,input().split())

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())

print((H-h)*(W-w))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
origin_length = len(S)
while True:
    length = len(S)
    S = S.replace('01','')
    S = S.replace('10','')
    if len(S) == length:
        break
print(origin_length-len(S))

Fixed submission:
S = input()
origin_length = len(S)
zero_cnt = S.count('0')
ones_cnt = S.count('1')
print(min(zero_cnt,ones_cnt)*2)
Buggy python submission (verdict: Runtime Error):
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
inf = 10**9
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l(cur),b,c)
    ret2 = dfs(cur+1,a,b+l(cur),c)
    ret3 = dfs(cur+1,a,b,c+l(cur))
    
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))

Fixed submission:
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
inf = 10**9
def dfs(cur,a,b,c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else inf
    ret0 = dfs(cur+1,a,b,c)
    ret1 = dfs(cur+1,a+l[cur],b,c) + 10
    ret2 = dfs(cur+1,a,b+l[cur],c) + 10
    ret3 = dfs(cur+1,a,b,c+l[cur]) + 10
    
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_left(s, x), bisect.bisect_left(t, x)
    res = INF
    for S in [s[b + 1], s[b]]:
        for T in [t[d + 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,Q = map(int,input().split())
Ss = []
for i in range(A):
    Ss.append(int(input()))
Ts = []
for i in range(B):
    Ts.append(int(input()))

def binary_search(search_list,target):
    left = 0
    right = len(search_list)
    while left < right:
        center = (left + right)//2
        if search_list[center] < target:
            left = center + 1
        elif search_list[center] > target:
            right = center
    index = left
    return index-1

S_to_T = []
for i in range(A):
    index = binary_search(Ts,Ss[i])
    if index+1 == B:
        right = float('inf')
    else:
        right = abs(Ss[i]-Ts[index+1])
    length = min(abs(Ss[i]-Ts[index]),right)
    S_to_T.append(length)
T_to_S = []
for i in range(B):
    index = binary_search(Ss,Ts[i])
    if index+1 == A:
        right = float('inf')
    else:
        right = abs(Ts[i]-Ss[index+1])
    length = min(abs(Ts[i]-Ss[index]),right)
    T_to_S.append(length)

for i in range(Q):
    q = int(input())
    Sindex = binary_search(Ss,q)
    S_left = abs(Ss[Sindex]-q)+S_to_T[Sindex]
    if Sindex+1 == A:
        S_right = float('inf')
    else:
        S_right = abs(Ss[Sindex+1]-q)+S_to_T[Sindex+1]
    Tindex = binary_search(Ts,q)
    T_left = abs(Ts[Tindex]-q)+T_to_S[Tindex]
    if Tindex+1 == B:
        T_right = float('inf')
    else:
        T_right = abs(Ts[Tindex+1]-q)+T_to_S[Tindex+1]
    ans = min(S_left,S_right,T_left,T_right)
    print(ans)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
Buggy python submission (verdict: Time Limit Exceeded):
# 配るDP
N,K= map(int,input().split())
h_list = list(map(int,input().split()))
INF = 10**9 + 7
DP = [INF]*N
DP[0] = 0
for i in range(N):
    for k in range(1,K+1):
        if i+k >= N:
            continue
        DP[i+k] = min(DP[i+k],DP[i]+abs(h_list[i]-h_list[i+k]))  
print(DP[-1])



Fixed submission:
# 配るDP
N,K= map(int,input().split())
h_list = list(map(int,input().split()))
INF = 10**9 + 7
DP = [INF]*N
DP[0] = 0
for i in range(N):
    for k in range(1,K+1):
        if i+k >= N:
            continue
        DP[i+k] = min(DP[i+k],DP[i]+abs(h_list[i]-h_list[i+k]))  
print(DP[-1])
Buggy python submission (verdict: Runtime Error):
x = int(input())
if x == 7:
  ans = 'YES'
elif x == 5:
  ans = 'YES
elif x == 3:
  ans = 'YES'
else:
  ans = 'NO'
print(ans)
    

Fixed submission:
x = int(input())
if x == 7:
  ans = 'YES'
elif x == 5:
  ans = 'YES'
elif x == 3:
  ans = 'YES'
else:
  ans = 'NO'
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #

Fixed submission:
N = int(input())

def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0')) #
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
divide_list = []
for i in range(M):
    newleft,newright = map(int,input().split())
    if i == 0:
        divide_list.append([newleft,newright])
    else:
        for divide in divide_list:
            left = divide[0]
            right = divide[1]
            if newleft >= right or newright <= left:
                divide_list.append([left,right])
            elif left <= newleft and newright <= right:
                divide_list.remove(divide)
                divide_list.append([newleft,newright])
            elif newleft <= left and right <= newright:
                pass
            elif left < newleft < right and right < newright:
                divide_list.remove(divide)
                divide_list.append([newleft,right])
            elif newleft < left < newright and newright < right:
                divide_list.remove(divide)
                divide_list.append([left,newright])
            else:
                print(divide,newleft,newright)
print(len(divide_list))

Fixed submission:
N,M = map(int,input().split())
war_list = []
divide_list = []
for i in range(M):
    war_list.append(list(map(int,input().split())))
war_list.sort(key = lambda x : x[1])

divide_list = [war_list[0][1]]
for i in range(1,M):
    if  war_list[i][0] < divide_list[-1]:
        pass
    else:
        divide_list.append(war_list[i][1])
    
print(len(divide_list))
Buggy python submission (verdict: Time Limit Exceeded):
K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(x,K+1):
        if x+y > S:
            break
        for z in range(y,K+1):
            if x+y+z == S:
#                print(x,y,z)
                if len({x,y,z}) == 1:
                    count += 1
                elif len({x,y,z}) == 2:
                    count += 3
                elif len({x,y,z}) == 3:
                    count += 6
            elif x+y+z > S:
                break
print(count)
        

Fixed submission:
K,S = map(int,input().split())
count = 0
for x in range(K+1):
    for y in range(K+1):
        z = S-x-y
        if 0 <= z <= K:
#            print(x,y,z)
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
str =list(input())
counter =0
max=0
for s in str:
    if s ='S':
        counter =0
    else 
       counter +=1
       if max <counter
          max =counter
print(max)

Fixed submission:
str =list(input())
counter =0
max=0
for s in str:
    if s =='S':
        counter =0
    else :
       counter +=1
       if max <counter:
          max =counter
print(max)
Buggy python submission (verdict: Runtime Error):
height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[a-1]=1
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[b-1]=1
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0
print(lst.count(1))

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

height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0

print(lst.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5-j**5==x:
            print("{} {}".format(i,j))
            break

Fixed submission:
x=int(input())
for i in range(0,1000):
    for j in range(-1000,1000):
        if i**5-j**5==x:
            print("{} {}".format(i,j))
            exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
num=int(input())
lst=[]
counter =0
for i in range(num):
    s=input()
    if s not in lst:
        lst.append(s)
        counter+=1
print(counter)

Fixed submission:
num=int(input())
lst=[]
if 1<=num<=2*10**5:
    lst=[input() for i in range(num)]
    print(len(set(lst)))

Buggy python submission (verdict: Time Limit Exceeded):
num=int(input())
lst=[]
counter =0
for i in range(num):
    s=input()
    if s not in lst:
        lst.append(s)
        counter+=1
print(counter)

Fixed submission:
num=int(input())
lst=[]
if 1<=num<=2*10**5:
    lst=[input() for i in range(num)]
    print(len(set(lst)))
Buggy python submission (verdict: Runtime Error):
str = input()
splited = str.split('')
print(splited)

Fixed submission:
str = input()
splited = list(str)

cccount = 0
count = 0
for s in splited:
  if s == 'R':
    count = count + 1
    if count > cccount:
      cccount = count
  else:
      count = 0
    
print(cccount)