Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
ptiny(ans)

Fixed submission:
s = input()
t = input()
ans = 0
for i in range(3):
  if s[i] == t[i]:
    ans +=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    hlis = list(map(int, input().split()))


    
    for i in range(0, n-1):
        saishou = min(hlis[i:])
        if hlis[i] - 1 > saishou:
            print('No')
            exit()
        elif hlis[i] - 1 == saishou:
            hlis[i] = saishou

    print("Yes")

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    hlis = list(map(int, input().split()))

    for i in range(0, n-1):
        if hlis[i]-1 > hlis[i+1]:
            print("No")
            exit()
        elif hlis[i]-1 == hlis[i+1]:
            hlis[i] = hlis[i] - 1
            if i > 1 and hlis[i-1] > hlis[i]:
                print('No')
                exit()
        elif i > 1 and hlis[i-1] <= hlis[i] - 1:
            hlis[i] = hlis[i]-1
    print("Yes")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import numpy as np
    n, l = map(int,input().split())
    inlis = []
    taishou = 10 *10000
    flag = 0

    for i in range(l, l+n):
        if taishou > np.abs(i):
            taishou = np.abs(i)
            if i < 0:
                flag = 1
        inlis.append(i)
    if flag == 0:
        print(sum(inlis) - taishou)
    else:
        print(sum(inlis) + taishou)

    
        

    
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    import numpy as np
    n, l = map(int,input().split())
    inlis = []
    taishou = 10 *10000
    flag = 0

    for i in range(l, l+n):
        if taishou > np.abs(i):
            taishou = np.abs(i)
            if i < 0:
                flag = 1
        inlis.append(i)
    if flag == 0:
        print(sum(inlis) - taishou)
    else:
        print(sum(inlis) + taishou)

    
        

    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c= map(int, input().split())
print( sum(a, b, c) - max(a, b, c))

Fixed submission:
p, q, r = map(int, input().split())
print(p + q+ r - max(p, q, r))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()

s[k-1] = s[k-1].lower()
print(s)

Fixed submission:
def main():
    n, k = map(int, input().split())
    s = input()
    
    print(s[:k-1] + s[k-1].lower() + s[k:])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c= map(int, input().split())
print(min(c, b//a)

Fixed submission:
a, b, c= map(int, input().split())
print(min(c, b//a))
Buggy python submission (verdict: Runtime Error):
s = input()

year = s[:4]
mo = s[5:7]
da = s[8:]

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)

Fixed submission:
s = input()

year = int(s[:4])
mo = int(s[5:7])

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis.sort()

    while len(inlis) > 1:
        tmp = 0
        i = 1
        while tmp < len(inlis):
            #print(i, tmp)
            if inlis[i] % inlis[0] != 0:
                inlis[i] %= inlis[0]
                i += 1
                if i >= len(inlis):
                    break
            else:
                inlis.remove(inlis[i])
            tmp += 1
        inlis.sort()
        #print(inlis, len(inlis))
    print(inlis[0])


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    inlis = set(inlis)
    inlis = list(inlis)
    inlis.sort()

    while len(inlis) > 1:
        tmp = 0
        i = 1
        while tmp < len(inlis):
            #print(i, tmp)
            if inlis[i] % inlis[0] != 0:
                inlis[i] %= inlis[0]
                i += 1
                if i >= len(inlis):
                    break
            else:
                inlis.remove(inlis[i])
            tmp += 1
        inlis = set(inlis)
        inlis = list(inlis)
        inlis.sort()
        #print(inlis, len(inlis))
    print(inlis[0])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().splis())
dai = max(a,b,c)
shou = min(a,b,c)
mid = a + b + c - dai - shou

print(shou * mid / 2)

Fixed submission:
a, b, c = map(int, input().split())
dai = max(a,b,c)
shou = min(a,b,c)
mid = a + b + c - dai - shou

print(shou * mid // 2)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k= map(int, input().split())
    lis = list(map(int, input().split()))
    dp = []
    tmp = []
    for _ in range(n+1):
        dp.append(0)

    for i in range(2, k+1):
        if i <= n:
            dp[i] = abs(lis[i-1] - lis[0])
        # print(i, dp[i])
    #print("start")
    for i in range(k+1, n+1):
        for t in range(1, k+1):
            cost_t = abs(lis[i-1] - lis[i-1 - t]) + dp[i-t]
            tmp.append(cost_t)
        dp[i] = min(tmp)
        tmp = []
        #print(i, dp[i])
    print(dp[n])

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k= map(int, input().split())
    lis = list(map(int, input().split()))
    dp = []
    tmp = []
    for _ in range(n+1):
        dp.append(0)

    for i in range(2, k+1):
        if i <= n:
            dp[i] = abs(lis[i-1] - lis[0])
        # print(i, dp[i])
    #print("start")
    for i in range(k+1, n+1):
        for t in range(1, k+1):
            cost_t = abs(lis[i-1] - lis[i-1 - t]) + dp[i-t]
            tmp.append(cost_t)
        dp[i] = min(tmp)
        tmp = []
        #print(i, dp[i])
    print(dp[n])

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
n, k= map(int, input().split())
lis = list(map(int, input().split()))
dp = []
tmp = []
for _ in range(n+1):
    dp.append(0)

for i in range(2, k+1):
    if i <= n:
        dp[i] = abs(lis[i-1] - lis[0])
       # print(i, dp[i])
#print("start")
for i in range(k+1, n+1):
    for t in range(1, k+1):
        cost_t = abs(lis[i-1] - lis[i-1 - t]) + dp[i-t]
        tmp.append(cost_t)
    dp[i] = min(tmp)
    tmp = []
    #print(i, dp[i])
print(dp[n])

Fixed submission:
def main():
    n, k= map(int, input().split())
    lis = list(map(int, input().split()))
    dp = []
    tmp = []
    for _ in range(n+1):
        dp.append(0)

    for i in range(2, k+1):
        if i <= n:
            dp[i] = abs(lis[i-1] - lis[0])
        # print(i, dp[i])
    #print("start")
    for i in range(k+1, n+1):
        for t in range(1, k+1):
            cost_t = abs(lis[i-1] - lis[i-1 - t]) + dp[i-t]
            tmp.append(cost_t)
        dp[i] = min(tmp)
        tmp = []
        #print(i, dp[i])
    print(dp[n])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n==7 or n==5 or n=3:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
if n==7 or n==5 or n==3:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n=int(input())
if n ==1:
  print('Hello World')
else:
  a, b= map(int, input().split())
  print(a+b)

Fixed submission:
n=int(input())
if n ==1:
  print('Hello World')
else:
  a=int(input())
  b=int(input())
  print(a+b)
Buggy python submission (verdict: Runtime Error):
def main():
    s = input()
    k = int(input())

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k <= m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i
            ans = s[i]
            break
    
    if k < m:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i
            ans = s[i]
            break
    
    if k < i:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()

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

    m = 0
    ans = ""

    for i in range(len(s)):
        if s[i] != "1":
            m = i+1
            ans = s[i]
            break
    
    if k < m:
        print(1)
    elif m == 0:
        print(1)
    else:
        print(int(ans))



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
k, m = map(int, input().split())
x = math.ceil((k-1)/(n-1))

print(x)

Fixed submission:
import math
k, m = map(int, input().split())
x = math.ceil((k-1)/(m-1))
 
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    num_m = 0
    num_a = 0
    num_r = 0
    num_c = 0
    num_h = 0
    inlis = []
    for i in range(n):
        s = input()
        if s in inlis:
            pass
        else:
            inlis.append(s)
            if s[0] == "M":
                num_m += 1        
            if s[0] == "A":
                num_a += 1
            if s[0] == "R":
                num_r += 1
            if s[0] == "C":
                num_c += 1
            if s[0] == "H":
                num_h += 1
    numlis = [num_m, num_a, num_r, num_c, num_h]
    ans = 0
    if sum(numlis) < 3:
        print(0)
    else:
        for i in range(5):
            for j in range(5):
                for k in range(5):
                    if i == j or i == k or j == k:
                        pass
                    else:
                        ans += numlis[i] * numlis[j] * numlis[k]
        print(int(ans/6))
                    


if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    num_m = 0
    num_a = 0
    num_r = 0
    num_c = 0
    num_h = 0
    inlis = set()
    for i in range(n):
        s = input()
        if s in inlis:
            pass
        else:
            inlis.add(s)
            if s[0] == "M":
                num_m += 1        
            if s[0] == "A":
                num_a += 1
            if s[0] == "R":
                num_r += 1
            if s[0] == "C":
                num_c += 1
            if s[0] == "H":
                num_h += 1
    numlis = [num_m, num_a, num_r, num_c, num_h]
    ans = 0
    if sum(numlis) < 3:
        print(0)
    else:
        for i in range(5):
            for j in range(5):
                for k in range(5):
                    if i == j or i == k or j == k:
                        pass
                    else:
                        ans += numlis[i] * numlis[j] * numlis[k]
        print(int(ans/6))
                    


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    dlis = []
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    dlis.sort()
    for t in tlis:
        if t in dlis:
            #print(t,tlis, dlis)
            dlis.remove(t)
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ddic = {}
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    for d in dlis:
        if d in ddic:
            ddic[d] += 1
        else:
            ddic[d] = 0
    for t in tlis:
        if t in ddic and ddic[t] >= 0:
            #print(t,tlis, dlis)
            ddic[t] -= 1
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    dlis = []
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    dlis.sort()
    for t in tlis:
        if t in dlis:
            #print(t,tlis, dlis)
            dlis.remove(t)
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ddic = {}
    tlis = []
    dlis = list(map(int, input().split()))
    m = int(input())
    tlis = list(map(int, input().split()))
    for d in dlis:
        if d in ddic:
            ddic[d] += 1
        else:
            ddic[d] = 0
    for t in tlis:
        if t in ddic and ddic[t] >= 0:
            #print(t,tlis, dlis)
            ddic[t] -= 1
        else:
            #print(t,tlis, dlis)
            print("NO")
            exit()
    print("YES")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1,-1):
        if inlis[i] != i+1:
            break
        else:
            #print(inlis)
            #print("mae", inlis[i])
            a = inlis[i-1]
            inlis[i] = a
            inlis[i-1] = i+1
            ans += 1
    if ans < n-1:
        #print(inlis)
        for i in range(n):
            if inlis[i] == i+1:
                #print("ato", inlis[i])
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    n = int(input())
    inlis= list(map(int, input().split()))
    ans = 0

    for i in range(n-1, -1, -1):
        #print(i)
        if inlis[i] != i+1:
            #print(i, inlis[i], i+1)
            break
        else:
            #print(inlis)
            #print("mae", inlis[i])
            if i-1 >= 0:
                a = inlis[i-1]
                inlis[i] = a
                inlis[i-1] = i+1
                ans += 1
                #print(inlis)
                
    if ans < n-1:
        #print(inlis)
        for i in range(n):
            if inlis[i] == i+1 and i+1 <= n-1:
                #print("ato", inlis[i])
                b = inlis[i+1]
                inlis[i] = b
                inlis[i+1] = i
                ans += 1
        
    print(ans)


    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    import math
    n = int(input())
    inlis = []
    for _ in range(n):
        a = int(input())
        inlis.append(a)

    ans = inlis[0]
    for i in range(1, n):
        ans = ans * inlis[i] // math.gcd(ans, inlis[i])

    print(ans)

    



    
    
if __name__ == "__main__":
    main()


Fixed submission:
def main():
    import fractions
    n = int(input())
    inlis = []
    for _ in range(n):
        a = int(input())
        inlis.append(a)
    
    ans = inlis[0]
    for i in range(1, n):
        ans = ans * inlis[i] // fractions.gcd(ans, inlis[i])

    print(ans)

    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    total = sum(inlis)
    ans = 10 ** 20

    for i in range(n-1):
        x = sum(inlis[:i+1])
        y = total - x
        tmp = abs(x-y)
        if tmp < ans:
            ans = tmp

    print(ans)





if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    inlis = list(map(int, input().split()))

    total = sum(inlis)
    ans = 10 ** 20

    for i in range(n-1):
        if i == 0:
            x = inlis[i]
        else:
            x += inlis[i]
        y = total - x
        tmp = abs(x-y)
        if tmp < ans:
            ans = tmp

    print(ans)





if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c=map(int, input().split())
print(total(a,b,c)-max(a, b, c))

Fixed submission:
a, b, c=map(int, input().split())
print((a + b+ c)-max(a, b, c))
Buggy python submission (verdict: Runtime Error):
a, b, c= map(int, input().split())
if b <= c:
  print("delicious")
elif c-b<= x:
  print("safe")
else:
  print("dengerous")

Fixed submission:
a, b, c= map(int, input().split())
if b >= c:
  print("delicious")
elif c-b<=a:
  print("safe")
else:
  print("dangerous")
Buggy python submission (verdict: Runtime Error):
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n < m:
            n, m = m, n
        else:
            if n != m:
                ans = math.factorial(n) % (10*9 + 7) * math.factorial(m) % (10**9 + 7)
            else:
                ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    import math
    n, m = map(int, input().split())
    if n - m <= -2 or n - m >= 2:
        print(0)
        exit()

    else:
        if n != m:
            ans = math.factorial(n) % (10**9 + 7) * math.factorial(m) % (10**9 + 7)
        else:
            ans = math.factorial(n) * 2 % (10**9 + 7) * math.factorial(m) % (10**9 + 7)

    print(ans)


    

 
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
if a == b:
  print('Draw')
elif a > b and b!=1:
  print('Alice')
else:
  print('Bob')

Fixed submission:
a, b = map(int, input().split())
if a == b:
  print('Draw')
elif a > b and b!=1:
  print('Alice')
elif a==1:
  print('Alice')
else:
  print('Bob')
Buggy python submission (verdict: Runtime Error):
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W" and s[-2] == "B":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B" and s[-2] == "W":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    s = input()
    slen = len(s)
    cnt = 0
    last = 0
    if s[0] == "W":
        for i in range(slen-1):
            if s[i] == "W" and s[i+1] =="B":
                cnt += 1
        if s[-1] == "W":
            last = 1
    if s[0] == "B":
        for i in range(slen-1):
            if s[i] == "B" and s[i+1] =="W":
                cnt += 1
        if s[-1] == "B":
            last = 1        
    if cnt == 0:
        print(cnt)
    else:
        print(cnt*2 - 1 + last)
    

 
    
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))

# にぶたん: 答えをx以下にできるか？
ok, ng = 10 ** 9 + 1, -1
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    cnt = 0

    for a in A:
        if a <= x:
            continue

        cnt += a // x
        if cnt > K:
            ng = x
            break
    else:
        ok = x

print(ok)


Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))

# にぶたん: 答えをx以下にできるか？
ok, ng = 10 ** 9 + 1, 0
while abs(ok - ng) > 1:
    x = (ok + ng) // 2
    cnt = 0

    for a in A:
        if a <= x:
            continue

        cnt += a // x
        if cnt > K:
            ng = x
            break
    else:
        ok = x

print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
A = list(map(int, input().split()))
MAX_A = 5 * 10 ** 5
query = []
for q in range(Q):
    l, r = map(int, input().split())
    query.append((l, r, q))


# 一番後ろの1を削りながら0までやるイメージ
# 1-indexed
# 閉区間
# 区間[s, t]の和 => BIT.add(t) - BIT.add(s - 1)

class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N)
X = [-1] * (MAX_A + 1)
for i, a in enumerate(A, start=1):
    X[a] = i
for x in X:
    if x == -1:
        continue
    BIT.add(x, 1)

ans = [-1] * Q
query.sort(key=lambda x: x[1])

for l, r, i in query:
    BIT.add(X[A[r - 1]], -1)
    X[A[r - 1]] = r
    BIT.add(r, 1)
    ans[i] = BIT.sum(r) - BIT.sum(l - 1)
print(*ans, sep='\n')


Fixed submission:
def main():
    import sys
    my_input = sys.stdin.readline
    N, Q = map(int, my_input().split())
    A = list(map(int, my_input().split()))

    MAX_A = 5 * 10 ** 5
    query = []
    for q in range(Q):
        l, r = map(int, my_input().split())
        query.append((l, r, q))

    class BinaryIndexedTree:
        def __init__(self, n):
            self.size = n
            self.bit = [0] * (n + 1)

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.bit[i]
                i -= (i & -i)
            return s

        def add(self, i, x):
            while i <= self.size:
                self.bit[i] += x
                i += (i & -i)

        def reset(self):
            self.bit = [0] * (self.size + 1)


    BIT = BinaryIndexedTree(N)
    X = [-1] * (MAX_A + 1)
    for i, a in enumerate(A, start=1):
        X[a] = i
    for x in X:
        if x == -1:
            continue
        BIT.add(x, 1)

    ans = [-1] * Q
    query.sort(key=lambda x: x[1])

    mr = 0
    for l, r, i in query:
        while mr < r:
            mr += 1
            BIT.add(X[A[mr - 1]], -1)
            X[A[mr - 1]] = mr
            BIT.add(mr, 1)
        ans[i] = BIT.sum(r) - BIT.sum(l - 1)

    for a in ans:
        print(a)


if __name__ == '__main__':
    main()