Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,len(S)-i+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print(sorted(now_subset)[K-1])
    exit()
    

Fixed submission:
S = input().strip()
K = int(input().strip())

unigram = sorted(set(S))

for u in unigram:
  now_subset = set()
  for i,c in enumerate(S):
    if c != u: continue
    for j in range(1,min(K,len(S)-i)+1):
      now_subset.add(S[i:i+j])
  if len(now_subset) < K:
    K -= len(now_subset)
  else:
    print(sorted(now_subset)[K-1])
    exit()
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int, input().strip().split(' '))
K = int(input().strip())

print(sum(A,B,C)+max(A,B,C)*((2**K)-1))


Fixed submission:
A,B,C = map(int, input().strip().split(' '))
K = int(input().strip())

print(A+B+C+max(A,B,C)*((2**K)-1))
Buggy python submission (verdict: Runtime Error):
A,B,K = input().strip().split(' ')

if B-A+1 > K:
  ans = list(range(A, A+K))+list(range(B-K+1, B+1))
  print(*ans, sep="\n")
  
else:
  print(*list(range(A,B+1)), sep="\n")



Fixed submission:
A,B,K = map(int, input().strip().split(' '))

if B-A+1 > K*2:
  ans = list(range(A, A+K))+list(range(B-K+1, B+1))
  print(*ans, sep="\n")
else:
  print(*list(range(A,B+1)), sep="\n")
Buggy python submission (verdict: Time Limit Exceeded):
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [None]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i] = dist(a2pos[i+D], a2pos[i])
  

q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  print(sum(a2dist[l:r:D]))

Fixed submission:
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [0]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i+D] = a2dist[i]+dist(a2pos[i],a2pos[i+D])
  
q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  print(a2dist[r]-a2dist[l])

Buggy python submission (verdict: Time Limit Exceeded):
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [None]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i] = dist(a2pos[i+D], a2pos[i])
  

q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  ans = 0
  now = l
  while now != r:
    ans += a2dist[now]
    now += D
  print(ans)


Fixed submission:
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [0]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i+D] = a2dist[i]+dist(a2pos[i],a2pos[i+D])
  
q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  print(a2dist[r]-a2dist[l])

Buggy python submission (verdict: Time Limit Exceeded):
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  ans = 0
  now = l
  while now != r:
    ans += dist(a2pos[now+D], a2pos[now])
    now += D
  print(ans)


Fixed submission:
H,W,D = map(int, input().strip().split(' '))
A = [list(map(int, input().strip().split(' '))) for _ in range(H)]

a2pos = [None]*(H*W+1)
for h in range(H):
  for w in range(W):
    a2pos[A[h][w]] = [h,w]

def dist(a,b):
  return abs(a[0]-b[0])+abs(a[1]-b[1])

a2dist = [0]*(H*W+1)
for i in range(1,(H*W)-D+1):
  a2dist[i+D] = a2dist[i]+dist(a2pos[i],a2pos[i+D])
  
q = int(input().strip())
for _ in range(q):
  l,r = map(int, input().strip().split(' '))
  print(a2dist[r]-a2dist[l])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
Q = [list(map(int, input().strip().split(' '))) for _ in range(N)]

def make_primeset(N):
  prime_set = {2,3}
  for i in range(5,N+1):
    prime_flag = True
    for j in prime_set:
      if i % j == 0:
        prime_flag = False
        break
    if prime_flag:
      prime_set.add(i)
  return prime_set

max_i = max(q[1] for q in Q)
prime_set = make_primeset(max_i)

# 累積和
cusum = [0]*(max_i+1)

now = 0
for i in range(1,max_i+1,2):
  if i in prime_set and (i+1)//2 in prime_set:
    now += 1
  cusum[i] = now

for l,r in Q:
  if l == 1:
    print(cusum[r])
  else:
    print(cusum[r]-cusum[l-2])

Fixed submission:
N = int(input().strip())
Q = [list(map(int, input().strip().split(' '))) for _ in range(N)]

def make_primeset(N):
  prime_set = {2,3}
  for i in range(5,N+1):
    prime_flag = True
    for j in prime_set:
      if i % j == 0:
        prime_flag = False
        break
    if prime_flag:
      prime_set.add(i)
  return prime_set

max_i = max(q[1] for q in Q)
prime_set = make_primeset(max_i)

# 累積和
cusum = [0]*(max_i+1)

now = 0
for i in range(1,max_i+1,2):
  if i in prime_set and (i+1)//2 in prime_set:
    now += 1
  cusum[i] = now

for l,r in Q:
  if l == 1:
    print(cusum[r])
  else:
    print(cusum[r]-cusum[l-2])
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int, input.strip().split(' '))
print(math.ceil((a+b)/2))

Fixed submission:
import math
a,b = map(int, input().strip().split(' '))
print(math.ceil((a+b)/2))
Buggy python submission (verdict: Runtime Error):
S = ''.join(sorted(input.strip()))
T = ''.join(sorted(input.strip(),reverse=True))
print('Yes' if S < T else 'No')


Fixed submission:
S = ''.join(sorted(input().strip()))
T = ''.join(sorted(input().strip(),reverse=True))
print('Yes' if S < T else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

c_even = len(1 for a in A if a % 2 == 0)
ans = 3**len(A) - 2**c_even
print(ans)


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

c_even = len([1 for a in A if a % 2 == 0])
ans = 3**len(A) - 2**c_even
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
  counter += Counter([i-1,i,i+1])

print(counter.most_common(1)[0][1])

Fixed submission:
from collections import Counter
N = int(input().strip())
counter = Counter()
for i in list(map(int, input().strip().split(' '))):
  counter[i-1] += 1
  counter[i] += 1
  counter[i+1] += 1

print(counter.most_common(1)[0][1])
Buggy python submission (verdict: Runtime Error):
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1

print('Yes' if a_4 >= a_1+a_2 else 'No')


Fixed submission:
_ = input()
A = list(map(int, input().strip().split(' ')))

a_4,a_2,a_1 = 0,0,0
for a in A:
  if a%4 == 0:
    a_4 += 1
  elif a%2 == 0:
    a_2 = 1
  else:
    a_1 += 1
#print(a_4,a_2,a_1)
print('Yes' if (a_4+1) >= (a_1+a_2) else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input().strip())
A = input().strip().split(' ')
ans = ''
for i,a in enumerate(A):
  if i == 0:
    ans = a
  elif i%2 == 0:
    ans += ','+a
  else:
    ans = a+','+ans
if n%2 == 0:
  print(*ans.split(','))
else:
  print(*ans.split(',')[::-1])



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

odd = A[::2]
even = A[1::2]

if N % 2 == 0:
  ans = even[::-1]+odd
else:
  ans = odd[::-1]+even

print(*ans)
Buggy python submission (verdict: Runtime Error):
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)

N,M = map(int, input().strip().split(' '))

@lru_cache(maxsize=512)
def factorial(n):
  if n in {0,1}:
    return 1
  return n*factorial(n-1) % 1000000007

if abs(N-M) >= 2:
  print(0)
elif N == M:
  print(factorial(N)*factorial(M)*2 % 1000000007)
else:
  print(factorial(N)*factorial(M) % 1000000007)


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

def factorial(n):
  ans = 1
  for i in range(2,n+1):
    ans = ans*i % 1000000007
  return ans

if abs(N-M) >= 2:
  print(0)
elif N == M:
  print(factorial(N)*factorial(M)*2 % 1000000007)
else:
  print(factorial(N)*factorial(M) % 1000000007)
Buggy python submission (verdict: Runtime Error):
_ = input()
a = list(map(int, input().strip().strip(' ')))
print(max(a)-min(a))


Fixed submission:
_ = input()
a = list(map(int, input().strip().split(' ')))
print(max(a)-min(a))
Buggy python submission (verdict: Runtime Error):
_ = input().strip()
kind_set = {}
colors = list(map(int, input().strip().split(' ')))

def whatcolor(rate):
  if rate < 400:
    return 0
  elif rate < 800:
    return 1
  elif rate < 1200:
    return 2
  elif rate < 1600:
    return 3
  elif rate < 2000:
    return 4
  elif rate < 2400:
    return 5
  elif rate < 2800:
    return 6
  elif rate < 3200:
    return 7
  else:
    return 'red'
  
for r in rates:
  color = whatcolor(r)
  if color == 'red':
    continue
  else:
    kind_set.add(color)

print(max(1, len(kind_set)))


Fixed submission:
_ = input().strip()
kind_set = set()
rates = list(map(int, input().strip().split(' ')))

def whatcolor(rate):
  if rate < 400:
    return 0
  elif rate < 800:
    return 1
  elif rate < 1200:
    return 2
  elif rate < 1600:
    return 3
  elif rate < 2000:
    return 4
  elif rate < 2400:
    return 5
  elif rate < 2800:
    return 6
  elif rate < 3200:
    return 7
  else:
    return 'free'
  
free_n = 0
for r in rates:
  color = whatcolor(r)
  if color == 'free':
    free_n += 1
  else:
    kind_set.add(color)

ans_min = max(1, len(kind_set))
ans_max = len(kind_set) + free_n
print(ans_min, ans_max)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().strip())
G = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().strip().split(' '))
  a,b = a-1, b-1
  G[a].append(b)
  G[b].append(a)

for i in range(N):
  print(len(G[i]))




Fixed submission:
N,M = map(int, input().strip().split(' '))
G = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().strip().split(' '))
  a,b = a-1, b-1
  G[a].append(b)
  G[b].append(a)

for i in range(N):
  print(len(G[i]))

Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().strip())
G = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().strip().split(' '))
  G[a].append(b)
  G[b].append(a)

for i in range(N):
  print(len(G[i]))




Fixed submission:
N,M = map(int, input().strip().split(' '))
G = [[] for _ in range(N)]
for _ in range(M):
  a,b = map(int, input().strip().split(' '))
  a,b = a-1, b-1
  G[a].append(b)
  G[b].append(a)

for i in range(N):
  print(len(G[i]))
Buggy python submission (verdict: Runtime Error):
N,T = map(int, input().strip().split(' '))
t = list(map(int, input().strip().split(' ')))

imos = [0]*(t[-1]+T+1)
for i in t:
  imos[i] += 1
  imos[i+T] -= 1

for i in range(len(imos)-1):
  imos[i+1] += imos[i]
  
print(len([1 for i in imos if i > 0]))

Fixed submission:
N,T = map(int, input().strip().split(' '))
t = list(map(int, input().strip().split(' ')))

ans = 0
for i in range(N-1):
  ans += min(t[i+1]-t[i], T)
print(ans+T)
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().strip().split(' '))
if A > B:
  print('GREATER')
elif A < B:
  print('LESS')
else:
  print('EQUAL')

Fixed submission:
A = int(input().strip())
B = int(input().strip())
if A > B:
  print('GREATER')
elif A < B:
  print('LESS')
else:
  print('EQUAL')
Buggy python submission (verdict: Runtime Error):
A,B = map(int, input().strip())
print((A+B)%24)

Fixed submission:
A,B = map(int, input().strip().split(' '))
print((A+B)%24)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input().strip())
states = {0}
for i in range(1,X+1):
  next_set = {s+i for s in states}
  if X in next_set:
    print(i)
    break
  states |= next_set

Fixed submission:
X = int(input().strip())
now_max = 0
for i in range(1,X+1):
  now_max += i
  if X <= now_max:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
print(eval(''join(input().strip().split(' '))))

Fixed submission:
print(eval(''.join(input().strip().split(' '))))
Buggy python submission (verdict: Runtime Error):
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
if N % 2 == 1:
  checklist = {0: 1}
  for i in range((N-2)//2):
    checklist[(i+1)*2] = 2
else:
  checklist = {(i*2+1):2 in i in range(N//2)}
  
for a in A:
  if a in checklist and checklist[a] in {1,2}:
    checklist[a] -= 1
  else:
    print(0)
    exit()
print(int(2**(N//2)))

Fixed submission:
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))
if N % 2 == 1:
  checklist = {0:1}
  for i in range((N-1)//2):
    checklist[(i+1)*2] = 2
else:
  checklist = {(i*2+1):2 for i in range(N//2)}

for a in A:
  if a in checklist and checklist[a] in {1,2}:
    checklist[a] -= 1
  else:
    print(0)
    exit()
print(int(2**(N//2))%1000000007)
Buggy python submission (verdict: Runtime Error):
N,L = map(int, input().strip().splip(' '))
print(''.join(sorted([input().strip() for _ in range(N)])))

Fixed submission:
N,L = map(int, input().strip().split(' '))
print(''.join(sorted([input().strip() for _ in range(N)])))
Buggy python submission (verdict: Runtime Error):
S, W = int(input())
if S <= W:
     print("unsafe")
else:
    print("safe")

Fixed submission:
S, W = map(int, input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(2 * r * pi)


Fixed submission:
from math import pi

r = int(input())
print(2 * r * pi)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
data = list(map(int, input().split()))
exist_tuple = tuple(data)
for i in range(1, N + 1):
    if i in exist_tuple:
        print(data.count(i))
    else:
        print("0")

Fixed submission:
from collections import Counter

N = int(input())
data = Counter(list(map(int, input().split())))
for i in range(1, N + 1):
    print(data[i])
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    a = sys.stdin.readline().rstrip().split()
    num = int("".join(a))
    if math.sqrt(num).is_integer():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import math

def main():
    a = sys.stdin.readline().rstrip().split()
    num = int("".join(a))
    if math.sqrt(num).is_integer():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
    def iterate_position():
        yield list(map(int, sys.stdin.readline().rstrip().split()))

    N = int(sys.stdin.readline().rstrip())
    now_position = [0, 0, 0]
    for x in range(N):
        try:
            next_position = next(iterate_position())
            dt = next_position[0] - now_position[0]
            dx = next_position[1] - now_position[1]
            dy = next_position[2] - now_position[2]
            if dt < abs(dx) + abs(dy):
                print("No")
                sys.exit()
            check = dt - (dx + dy)
            if check % 2 == 1:
                print("No")
                sys.exit()
            now_position = next_position
        except StopIteration:
            print("No")
    else:
        print("Yes")

Fixed submission:
import sys
import math

def main():
    def iterate_position():
        yield list(map(int, sys.stdin.readline().rstrip().split()))

    N = int(sys.stdin.readline().rstrip())
    now_position = [0, 0, 0]
    for x in range(N):
        try:
            next_position = next(iterate_position())
            dt = next_position[0] - now_position[0]
            dx = next_position[1] - now_position[1]
            dy = next_position[2] - now_position[2]
            if dt < abs(dx) + abs(dy):
                print("No")
                sys.exit()
            check = dt - (dx + dy)
            if check % 2 == 1:
                print("No")
                sys.exit()
            now_position = next_position
        except StopIteration:
            print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
items=[]
for i in range(n):
    s=input()
    if s not in items:
        items.append(s)
print(len(items))


Fixed submission:
n= int(input())
items={}
for i in range(n):
    s=input()
    items[s]=0
print(len(items))
Buggy python submission (verdict: Runtime Error):
  S=input()  
  a, b, c = (int(i) for i in S.split())  
    d=(a+b+c)/17
    e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
    if(d==1 and e==1): print("YES")
    else: print("NO")

Fixed submission:
a, b, c = (int(i) for i in input().split())
d=(a+b+c)/17
e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
if(d==1 and e==1): print("YES")
else: print("NO")

Buggy python submission (verdict: Runtime Error):
    a, b, c = (int(i) for i in input().split())  
    d=(a+b+c)/17
    e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
    if(d==1 and e==1): print("YES")
    else: print("NO")

Fixed submission:
a, b, c = (int(i) for i in input().split())
d=(a+b+c)/17
e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
if(d==1 and e==1): print("YES")
else: print("NO")

Buggy python submission (verdict: Runtime Error):
    a, b, c = (int(i) for i in input().split())  
    d=(a+b+c)/17
    e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
    if(d==1 and e==1): print("YES")
    else: print("NO")
    

Fixed submission:
a, b, c = (int(i) for i in input().split())
d=(a+b+c)/17
e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
if(d==1 and e==1): print("YES")
else: print("NO")

Buggy python submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split())  
d=(a+b+c)/17
e=(max(a,b)-2+max(a,c)+max(b,c))/21

if(d==1 and e==1)
print(min(a,b,c), max(a,b,c), min(a,b,c))

Fixed submission:
a, b, c = (int(i) for i in input().split())
d=(a+b+c)/17
e=(max(a,b)-2+max(a,c)+max(b,c))/17
     
if(d==1 and e==1): print("YES")
else: print("NO")
Buggy python submission (verdict: Runtime Error):
S=int(input("S"))
W=int(input("W"))
if W>=S:
    print("unsafe")
else:
    print("safe")

Fixed submission:
S,W=map(int,input().split())
if W>=S:
    print("unsafe")
else:
    print("safe")

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
if(N<=K):
    print('unsafe')
else:
    print('safe'

Fixed submission:
N,K = map(int,input().split())
if(N<=K):
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
a = list(map(int,input().split()))
for i in range(1,N+1):
    print(a.count(i))

Fixed submission:
import math
N = int(input())
a = list(map(int,input().split()))
c = [0]*(N+1)
for i in range(N-1):
    b = a[i]
    c[b] += 1
for j in range(1,N+1):
    print(c[j])
Buggy python submission (verdict: Runtime Error):
from collections import Counter

i = int(input())

dic = {}
for j in range(i):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1


dic2 = sorted(dic.items(), key=lambda x:x[1])

k = len(dic2)-1
s = 0
while True:
    t = dic2[k][1]
    print(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break

Fixed submission:
i = int(input())

dic = {}
for j in range(i):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1


dic2 = sorted(dic.items(), key=lambda x:x[1])
k = len(dic2)-1
s = 0
ans = []
for p in range(len(dic2)):
    t = dic2[k][1]
    ans.append(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break
ans.sort()
for ak in ans:
    print(ak)
Buggy python submission (verdict: Runtime Error):
a = input()
if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 900
elif len(a)==4:
    b = int(a)
    c = 9 + 900
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
print(c)

Fixed submission:
a = input()
if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 900
elif len(a)==4:
    b = int(a)
    c = 9 + 900
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
elif len(a)==6:
    c = 90000 + 900 +9
print(c)

Buggy python submission (verdict: Runtime Error):
a = input()

if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 1000
elif len(a)==4:
    b = int(a)
    c = 9 + 1000
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
print(c)

Fixed submission:
a = input()
if len(a)==5:
    b = int(a)
    c = b - 9999 + 9 + 900
elif len(a)==4:
    b = int(a)
    c = 9 + 900
elif len(a)==3:
    b = int(a)
    c = b - 99 + 9
elif len(a)==2:
    b = int(a)
    c = 9
elif len(a)==1:
    b = int(a)
    c = b
elif len(a)==6:
    c = 90000 + 900 +9
print(c)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
c = [0]*(b-a+1)
j = 0
for i in range(a,b+1):
    c[j] = i%2019
    j += 1
x = min(c)
c.remove(x)
y = min(c)
print((x*y)%2019)

Fixed submission:
a,b = map(int,input().split())
c = [2019]*2
p = 0
flag = 0
if (b-a) >= 2019:
    for j in range(a,a+2020):
        if j%2019 == 0:
            flag = 1
            break
        for l in range(j+1,a+2020):
            if l%2019==0:
                flag = 1
                break
            c[1] = (j*l)%2019
            c[0] = (j*l)%2019 if c[0] > c[1] else c[0]
else:
    for m in range(a,b+1):
        if m%2019 == 0:
            flag = 1
            break
        for n in range(m+1,b+1):
            if n%2019==0:
                flag = 1
                break
            c[1] = (n*m)%2019
            c[0] = (n*m)%2019 if c[0] > c[1] else c[0]
if flag == 1:
    print(0)
else:
    print(c[0])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
c = [i+b for i in range(a)]
d = [abs(j+b) for j in range(a)]
c.remove(min(d))
print(sum(c))

Fixed submission:
a,b = map(int,input().split())
c = [i+b for i in range(a)]
d = [abs(j+b) for j in range(a)]
print(sum(c)-c[d.index(min(d))])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = map(int,input().split())
f = [i for i in range(a,b+1) if not ((i%c==0)or(i%d==0))]
print(len(f))

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e,f,g = (a-1)//c,(a-1)//d,(a-1)//(c * d // fractions.gcd(c, d))
h,i,j = b//c,b//d,b//(c * d // fractions.gcd(c, d))
ans = (b-a+1)-((h+i-j)-(e+f-g))
print(ans)