Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
N = int(input())
s = ["".join(sorted(list(input()))) for i in range(N)]
tmp = list(set(s))
for i in range(len(tmp)):
    s.remove(tmp[i])
tmp = list(set(s))
countlist = []
for i in range(len(tmp)):
    counter = 1
    for j in range(len(s)):
        if tmp[i] == s[j]:
            counter += 1
    countlist.append(counter)
ans = 0
if countlist == []:
    print(0)
else:
    for i in range(len(countlist)):
        if countlist[i] == 2:
            ans += 1
        else:
            ans += factorial(countlist[i])//(factorial(countlist[i]-2)*2)
    print(ans)

Fixed submission:
N = int(input())
s = {}
ans = 0
for i in range(N):
    a = "".join(sorted(input()))
    if a not in s:
        s.setdefault(a,0)
    else:
        s[a] += 1
        ans += s[a]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [sorted(list(input())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(N):
        if s[i] == s[j]:
            count += 1
print(int((count-N)/2))

Fixed submission:
N = int(input())
s = {}
ans = 0
for i in range(N):
    a = "".join(sorted(input()))
    if a not in s:
        s.setdefault(a,0)
    else:
        s[a] += 1
        ans += s[a]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
c = 0
d = ""
runlength = []
for i in range(len(S)):
    if d == "":
        d = S[i]
        c += 1
    if d == S[i]:
        c += 1
    else:
        runlength.append([d,c])
        d = ""
        c = 0
ans = [0]*len(S)
ind = -1
for rl in runlength:
    if rl[0] == "R":
        ind += rl[1]
        ans[ind] += rl[1] - rl[1]//2
        ans[ind+1] += rl[1]//2
    else:
        ans[ind] += rl[1]//2
        ans[ind+1] += rl[1] - rl[1]//2
        ind += rl[1]
print(*ans)

Fixed submission:
S = input()
def runlength(str):
    res = []
    data,count = str[0],1
    for i in range(1,len(str)):
        if str[i] == data:
            count += 1
        else:
            res.append((data,count))
            data,count = str[i],1
    res.append((data,count))
    return res
ans = [0]*len(S)
ind = -1
for rl in runlength(S):
    if rl[0] == "R":
        ind += rl[1]
        ans[ind] += rl[1] - rl[1]//2
        ans[ind+1] += rl[1]//2
    else:
        ans[ind] += rl[1]//2
        ans[ind+1] += rl[1] - rl[1]//2
        ind += rl[1]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = [1]*len(S)
for i in range(len(S)):
    if S[i] == "L":
        if S[i-1] == "R":
            continue
        else:
            ans[i] = 0
            j = 1
            count = 1
            while True:
                if S[i-j] == "R":
                    break
                j += 1
                count += 1
            if count%2 == 0:
                ans[i-j] += 1
            else:
                ans[i-j+1] += 1
    else:
        if S[i+1] == "L":
            continue
        else:
            ans[i] = 0
            j = 1
            count = 1
            while True:
                if S[i+j] == "L":
                    break
                j += 1
                count += 1
            if count%2 == 0:
                ans[i+j] += 1
            else:
                ans[i+j-1] += 1
print(*ans,sep=" ")

Fixed submission:
S = input()
def runlength(str):
    res = []
    data,count = str[0],1
    for i in range(1,len(str)):
        if str[i] == data:
            count += 1
        else:
            res.append((data,count))
            data,count = str[i],1
    res.append((data,count))
    return res
ans = [0]*len(S)
ind = -1
for rl in runlength(S):
    if rl[0] == "R":
        ind += rl[1]
        ans[ind] += rl[1] - rl[1]//2
        ans[ind+1] += rl[1]//2
    else:
        ans[ind] += rl[1]//2
        ans[ind+1] += rl[1] - rl[1]//2
        ind += rl[1]
print(*ans)
Buggy python submission (verdict: Runtime Error):
L,R = map(int,input().split())
tmp = list(range(L,R+1))
mod = []
rem = []
for i in tmp:
    if i%2019 not in mod:
        mod.append(i%2019)
        rem.append(i)
    if len(mod) == 2019:
        break
ans = 2019
for i in rem:
    for j in rem:
        if i*j%2019 < ans and i < j:
            ans = i*j%2019
        if ans == 0:
            break
print(ans)

Fixed submission:
L,R = map(int,input().split())
if R - L > 2019:
        print(0)
else:
    ans = 10**9
    for i in range(L,R):
        for j in range(i+1,R+1):
            if ans > i*j%2019:
                ans = i*j%2019
                if ans == 0:
                    break
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = map(int,input().split())
countC = math.floor(B/C) - math.floor((A-1)/C)
countD = math.floor(B/D) - math.floor((A-1)/D)
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
lcmCD = lcm(C,D)
countlcm = math.floor(B/lcmCD) - math.floor((A-1)/lcm(C,D))
print(B - A + 1 - (countC + countD - countlcm))

Fixed submission:
import math
import fractions
A,B,C,D = map(int,input().split())
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)
def cal(n,x,y):
    return n-(n//x + n//y - n//lcm(x,y))
print(cal(B,C,D)-cal(A-1,C,D))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
booli = [False]*(N)
for i in a:
    booli[i-1] = True
mod = 1000000007
INF = -1
dp = [INF]*(N+1)
dp[0] = 1
if booli[1]:
    dp[1] = 0
else:
    dp[1] = 1
def solve():
    for i in range(2,N+1):
        if booli[i-1]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())

Fixed submission:
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
booli = [False]*(N+1)
for i in a:
    booli[i] = True
mod = 1000000007
INF = -1
dp = [INF]*(N+1)
dp[0] = 1
if booli[1]:
    dp[1] = 0
else:
    dp[1] = 1
def solve():
    for i in range(2,N+1):
        if booli[i]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
mod = 1000000007
INF = 0
dp = [INF]*(N+1)
dp[0] = 1
if 1 not in a:
    dp[1] = 1
else:
    dp[1] = 0
def solve():
    for i in range(2,N+1):
        if i in a:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())

Fixed submission:
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
booli = [False]*(N+1)
for i in a:
    booli[i] = True
mod = 1000000007
INF = -1
dp = [INF]*(N+1)
dp[0] = 1
if booli[1]:
    dp[1] = 0
else:
    dp[1] = 1
def solve():
    for i in range(2,N+1):
        if booli[i]:
            dp[i] = 0
        else:
            dp[i] = dp[i-1]+dp[i-2]
    return dp[N]%mod
print(solve())
Buggy python submission (verdict: Runtime Error):
from math import ceil
tmp1 = list(map(int,input().split()))
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(sum(tmp1)-max(tmp2))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
from math import ceil
tmp1 = [A,B,C,D,E]
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(sum(tmp1)-max(tmp2))

Buggy python submission (verdict: Runtime Error):
from math import ceil
tmp1 = list(map(int,input().split()))
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(tmp1)
print(tmp2)
print(sum(tmp1)-max(tmp2))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
from math import ceil
tmp1 = [A,B,C,D,E]
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(sum(tmp1)-max(tmp2))

Buggy python submission (verdict: Runtime Error):
from math import ceil
tmp1 = list(map(int,input().split()))
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(float("inf"))
    else:
        tmp2.append(tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(tmp1)
print(tmp2)
print(sum(tmp1)-min(tmp2))

Fixed submission:
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
from math import ceil
tmp1 = [A,B,C,D,E]
tmp2 = list()
for j in range(5):
    if tmp1[j]%10 == 0:
        tmp2.append(0)
    else:
        tmp2.append(10 - tmp1[j]%10)
for i in range(5):
    tmp1[i] = ceil(tmp1[i]/10)*10
print(sum(tmp1)-max(tmp2))
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = input()
for i in range(Q):
    a,b = map(int,input().split())
    print(S[a-1:b].count("AC"))

Fixed submission:
N,Q = map(int,input().split())
S = input()
ac = [0]*(N+1)
for i in range(N):
    ac[i+1] = ac[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = list(input())
ls = [list(map(int,input().split())) for i in range(Q)]
ac = [0]*N
for i in range(1,N):
    if S[i-1] == "A":
        if S[i] == "C":
            ac[i] += 1
ans = 0
for i in range(Q):
    print(sum(ac[ls[i][0]:ls[i][1]]))

Fixed submission:
N,Q = map(int,input().split())
S = input()
ac = [0]*(N+1)
for i in range(N):
    ac[i+1] = ac[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = list(input())
num = list(range(N))
dic1 = dict(zip(num,S))
q = [list(map(lambda x: int(x)-1,input().split())) for _ in range(Q)]
dic2 = {}
for i in range(N-1):
    if dic1[i]+dic1[i+1] == "AC":
        dic2[i] = i
vl = list(dic2.values())
num = list(range(len(vl)))
dic3 = dict(zip(num,vl))
for i in range(Q):
    ans = 0
    for j in range(len(vl)):
        if q[i][0] <= dic3[j] < q[i][1]:
            ans += 1
    print(ans)

Fixed submission:
N,Q = map(int,input().split())
S = input()
ac = [0]*(N+1)
for i in range(N):
    ac[i+1] = ac[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = map(int,input().split())
S = list(input())
num = list(range(N))
dic1 = dict(zip(num,S))
q = [list(map(lambda x: int(x)-1,input().split())) for _ in range(Q)]
dic2 = {}
for i in range(N-1):
    if dic1[i]+dic1[i+1] == "AC":
        dic2[i] = i
vl = list(dic2.values())
for i in range(Q):
    ans = 0
    for j in range(len(dic2)):
        if q[i][0] <= vl[j] < q[i][1]:
            ans += 1
    print(ans)

Fixed submission:
N,Q = map(int,input().split())
S = input()
ac = [0]*(N+1)
for i in range(N):
    ac[i+1] = ac[i] + (1 if S[i:i+2] == "AC" else 0)
for i in range(Q):
    l,r = map(int,input().split())
    print(ac[r-1]-ac[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
ans = 0
tmp = 0
while tmp < M:
    num = min([M-tmp,B[A.index(min(A))]])
    tmp += num
    ans += num * min(A)
    ind = A.index(min(A))
    del A[ind]
    del B[ind]
print(ans)

Fixed submission:
from operator import itemgetter
N,M = map(int,input().split())
ls = [list(map(int,input().split())) for _ in range(N)]
ls = sorted(ls,key=itemgetter(0))
ans = 0
pon = 0
for i in range(N):
    if pon < M:
        pon += ls[i][1]
        ans += ls[i][1]*ls[i][0]
    else:
        i = i-1
        break
if pon == M:
    print(ans)
else:
    ans -= ls[i][0]*(pon - M)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
while "01" in S:
    ind = S.find("01")
    S = S[:ind]+S[ind+2:]
    ans += 2
while "10" in S:
    ind = S.find("10")
    S = S[:ind]+S[ind+2:]
    ans += 2
print(ans)

Fixed submission:
import collections
S = input()
c = collections.Counter(S)
if len(c.values()) == 2:
    print(min(c.values())*2)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
def main():
    INF = 10**9
    N = int(input())
    h = list(map(int,input().split()))
    dp = [INF]*N
    dp[0] = 0
    dp[1] = h[0]
    for i in range(2,N):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[N])

if __name__ == '__main__':
    main()

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp1 = abs(h[i]-h[i-1])+dp[i-1]
    dp2 = abs(h[i]-h[i-2])+dp[i-2]
    dp[i] = min([dp1,dp2])
print(dp[N-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp1 = abs(h[i]-h[i-1])+dp[i-1]
    dp2 = abs(h[i]-h[i-2])+dp[i-2]
    dp[i] = min([dp1,dp2])
    print(dp)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp1 = abs(h[i]-h[i-1])+dp[i-1]
    dp2 = abs(h[i]-h[i-2])+dp[i-2]
    dp[i] = min([dp1,dp2])
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
# メモ化再帰ｓ
# def rec(i,j):
#     if dp[i][j] >= 0:
#         return dp[i][j]
#     res = 0
#     if i == n:
#         res = 0
#     elif j < w[i]:
#         res = rec(i+1,j)
#     else:
#         res = max(rec(i+1,j),rec(i+1,j-w[i])+v[i])
#     dp[i][j] = res
#     return res

# def main():
#     global n,w,v,dp
#     n = int(input())
#     w,v = [0]*n,[0]*n
#     for i in range(n):
#         w[i],v[i] = map(int,input().split())
#     W = int(input())
#     dp = [[-1]*(W+1) for _ in range(n+1)]
#     print(rec(0,W))

# DP
def main():
    global n,w,v,dp
    n,W = map(int,input().split())
    w,v = [0]*(n),[0]*(n)
    for i in range(n):
        w[i],v[i] = map(int,input().split())
    dp = [[0]*(W+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,W+1):
            if j < w[i-1]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1])
    print(dp[n][W])


if __name__ == '__main__':
    main()

"""
in
4 5
2 3
1 2
3 4
2 2

out
7
"""

Fixed submission:
def main():
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(N)]
    dp = [[0]*(W+1) for _ in range(N+1)]
    for i in range(N):
        for j in range(W+1):
            if j-wv[i][0] >= 0:
                dp[i+1][j] = max(dp[i][j],dp[i][j-wv[i][0]]+wv[i][1])
            else:
                dp[i+1][j] = dp[i][j]
    print(dp[N][W])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    INF = float('inf')
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(N)]
    sumv = sum([v for w,v in wv])
    dp = [[INF]*(sumv+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(sumv+1):
            if j-wv[i][1] >= 0:
                dp[i+1][j] = min(dp[i][j],dp[i][j-wv[i][1]]+wv[i][0])
            else:
                dp[i+1][j] = dp[i][j]
    ans = 0
    for i in range(sumv+1):
        if dp[N][i] <= W:
            ans = max(ans,i)
    print(ans)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    INF = float('inf')
    N,W = map(int,input().split())
    wv = [list(map(int,input().split())) for _ in range(N)]
    sumv = sum([v for w,v in wv])
    dp = [[INF]*(sumv+1) for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(sumv+1):
            if j-wv[i][1] >= 0:
                dp[i+1][j] = min(dp[i][j],dp[i][j-wv[i][1]]+wv[i][0])
            else:
                dp[i+1][j] = dp[i][j]
    ans = 0
    for i in range(sumv+1):
        if dp[N][i] <= W:
            ans = max(ans,i)
    print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    p = list(map(float,input().split()))
    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(i+1):
            dp[i+1][j] += dp[i][j] * (1-p[i])
            dp[i+1][j+1] += dp[i][j] * p[i]
    print(sum(dp[N][N//2+1:]))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    N = int(input())
    p = list(map(float,input().split()))
    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(i+1):
            dp[i+1][j] += dp[i][j] * (1-p[i])
            dp[i+1][j+1] += dp[i][j] * p[i]
    print(sum(dp[N][N//2+1:]))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = list(input())
    ans = 0
    while True:
        for i in range(len(S)-1):
            if S[i] < S[i+1]:
                tmp = S[i+1]
                S[i+1] = S[i]
                S[i] = tmp
                ans += 1
                break
        else:
            break
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    S = list(input())
    accum = [0]
    for i in range(1,len(S)):
        tmp = accum[i-1] + 1 if S[i-1] == "B" else accum[i-1]
        accum.append(tmp)
    ans = 0
    for i in range(len(S)):
        tmp = 0 if S[i] == "B" else accum[i]
        ans += tmp
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
p=[]
N=int(input())
for i in range:
  p.append(int(input()))
ans=sum(p)-(max(p)2)
print(int(ans))

Fixed submission:
p=[]
N=int(input())
for i in range(N):
  p.append(int(input()))
ans=sum(p)-(max(p)/2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
N=int(input())
p=list(map(int,input().split("\n")))
ans=sum(p)-(max(p)2)
print(int(ans))

Fixed submission:
p=[]
N=int(input())
for i in range(N):
  p.append(int(input()))
ans=sum(p)-(max(p)/2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
N=int(input())
p=[int(input()) for i in range(N)]
ans=sum(p)-(max(p)2)
print(int(ans))

Fixed submission:
p=[]
N=int(input())
for i in range(N):
  p.append(int(input()))
ans=sum(p)-(max(p)/2)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
S=input()
tmp=[]
for i in range(len(S)-2):
  tmp.append(S[i:i+2])
for j in range(len(S)-2):
  tmp[i]=abs(753-int(tmp[i]))
print(int(min(tmp)))

Fixed submission:
S = input()
tmp = []
for i in range(len(S)-2):
    tmp.append(S[i:i+3])
for j in range(len(S)-2):
    tmp[j] = abs(753-int(tmp[j]))
print(min(tmp))

Buggy python submission (verdict: Runtime Error):
S=input()
tmp=[]
for i in range(len(S)-2):
  tmp.append(S[i:i+2])
for j in range(len(tmp)):
  tmp[i]=abs(753-int(tmp[i]))
print(int(min(tmp)))

Fixed submission:
S = input()
tmp = []
for i in range(len(S)-2):
    tmp.append(S[i:i+3])
for j in range(len(S)-2):
    tmp[j] = abs(753-int(tmp[j]))
print(min(tmp))

Buggy python submission (verdict: Runtime Error):
S=input()
tmp=[]
for i in range(len(S)-2):
  tmp.append(S[i:i+2])
for j in range(len(tmp)):
  tmp[i]=abs(753-int(tmp[i]))
print(min(tmp))

Fixed submission:
S = input()
tmp = []
for i in range(len(S)-2):
    tmp.append(S[i:i+3])
for j in range(len(S)-2):
    tmp[j] = abs(753-int(tmp[j]))
print(min(tmp))
Buggy python submission (verdict: Runtime Error):
N = int(input())
words = [input() for i in range(N)]
ans = "Yes"
tmp = list(dict.fromkeys(words))
if words == tmp:
    for j in range(1,N):
        if words[j][0] != word[j-1][-1]:
            ans = "No"
            break
    print(ans)
else:
    print("No")

Fixed submission:
N = int(input())
W = [input() for i in range(N)]
ans = "Yes"
if sorted(set(W)) != sorted(W):
    ans = "No"
else:
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            ans = "No"
            break
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
if N >= 999:
    print("ABC")
else:
    print("ABD")

Fixed submission:
N = int(input())
if N <= 999:
    print("ABC")
else:
    print("ABD")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = [int(input()) for _ in range(N)]
maxlen = 1
tmplen = 1
indexls = [P.index(i+1) for i in range(N)]
for i in range(1,N):
    if indexls[i] > indexls[i-1]:
        tmplen += 1
        maxlen = max(maxlen,tmplen)
    else:
        tmplen = 1
print(N-maxlen)

Fixed submission:
N = int(input())
P = []
indexls = [0]*N
for i in range(N):
    tmp = int(input())
    P.append(tmp)
    indexls[tmp-1] = i
maxlen = 1
tmplen = 1
for i in range(1,N):
    if indexls[i] > indexls[i-1]:
        tmplen += 1
        maxlen = max(maxlen,tmplen)
    else:
        tmplen = 1
print(N-maxlen)
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
tmp = list(range(A,B+1))
if K > len(tmp):
    K = len(tmp)
small = tmp[:K]
big = tmp[-K:]
tmp = sorted(list(set(small + big)))
for i in tmp:
    print(i)

Fixed submission:
A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
tmp = list(range(A,B+1))
small = tmp[:K]
big = tmp[-K:]
tmp = sorted(list(set(small + big)))
for i in tmp:
    print(i)

Fixed submission:
A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
tmp1 = list(range(A,A+min([len(list(range(A,B+1))),K])))
tmp2 = list(range(B-min([len(list(range(A,B+1))),K])+1,B+1))
ans = sorted(list(set(tmp1+tmp2)))
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
tmp = list(range(A,B+1))
ans = []
flag = 1
for i in range(min([len(tmp),K])):
    ans.append(tmp[i])
for j in range(min([len(tmp),K])):
    ans.append(tmp[-j-1])
ans = sorted(list(set(ans)))
for k in range(len(ans)):
    print(ans[k])

Fixed submission:
A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())
tmp = list(range(A,B+1))
ans = []
flag = 1
for i in range(K):
    ans.append(tmp[i])
for j in range(K):
    ans.append(tmp[-j-1])
ans = list(set(ans))
for k in range(len(ans)):
    print(ans[k])

Fixed submission:
A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)
Buggy python submission (verdict: Runtime Error):
for i in range(N):
    if flag:
        break
    for j in range(N-i):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y and (N-i-j) >= 0:
            A,B,C = i,j,(N-i-j)
            flag = True
            break
print(A,B,C)

Fixed submission:
N,Y = map(int,input().split())
A,B,C = -1,-1,-1
flag = False
for i in range(N+1):
    if flag:
        break
    for j in range(N+1-i):
        if i*10000 + j*5000 + (N-i-j)*1000 == Y and (N-i-j) >= 0:
            A,B,C = i,j,(N-i-j)
            flag = True
            break
print(A,B,C)