Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
ans = 2019
for i in range(l, r):
   for i in range(l+1, r+1):
      tmp = i*j % 2019
      if ans > tmp:
         ans = tmp         
      if ans == 0:
         print(ans)
         exit(0)
print(ans)

Fixed submission:
l, r = map(int,input().split())

ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)

Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
num = list(range(l, r+1))
num_map = list(map(lambda j: j % 2019, num)) 
num_map.sort()
print(num_map[0]*num_map[1])

Fixed submission:
l, r = map(int,input().split())

ans = 2019
for i in range(l, r):
    for j in range(i+1, r+1):
        tmp = i*j % 2019
        if ans > tmp:
            ans = tmp
        if ans == 0:
            print(ans)
            exit(0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
cnt = 0
for i in range(a,b+1):
   if i%c != 0 and i%d != 0:
      cnt += 1
print(cnt)

Fixed submission:
a, b, c, d = map(int, input().split())
def gcd(a,b):
   while b != 0:
      a, b = b, a%b
   return a
def lcm(a,b):
   return int(a*b / gcd(a,b))
cnt = 0
quo_c = b//c - (a-1)//c
quo_d = b//d - (a-1)//d
quo_cd = b//lcm(c,d) - (a-1)//lcm(c,d)
print(b - (a-1) - quo_c - quo_d + quo_cd)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l, r = [0]*m, [0]*m
for i in range(m):
    l[i], r[i] = map(int, input().split())

ans = [0]*n
for i in range(m):
    memo = [0]*n
    for j in range(l[i]-1, r[i]):
        memo[j] = 1        
    for k in range(n):
        ans[k] += memo[k]

print(ans.count(m))

Fixed submission:
n, m = map(int, input().split())
l, r = [0]*m, [0]*m
for i in range(m):
    l[i], r[i] = map(int, input().split())

ll = max(l)
rr = min(r)
if rr-ll >= 0:
    print(rr-ll+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
list = [a, b, c, d, e]
if max(lis) - min(lis) <= k:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a <= k:
    print('Yay!')
else:
    print(':(')

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
lis = list(a, b, c, d, e)
if max(lis) - min(lis) <= k:
    print('Yay!')
else:
    print(':(')

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a <= k:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
ae = [int(input()) for _ in range(5)]

nxt_time = [0]*n
for i in range(n):
    if ae[i] % 10 == 0:
        nxt_time[i] = ae[i]
    else:
        nxt_time[i] = ae[i] - ae[i] % 10 + 10
    # nxt_time[i] = (ae[i]+9) // 10 * 10
best_time = 99999999
for i in range(n):
    sumtime = 0
    for j in range(n):
        if i == j:
            sumtime += ae[i]
        else:
            sumtime += nxt_time[i]
    
    best_time = min(best_time, sumtime)

print(best_time)

Fixed submission:
ae = [int(input()) for _ in range(5)]

sum_ae = 0
g = 9
cnt = 0  
for i in ae:
    if i % 10 != 0:
        g = min(g, i % 10)
        sum_ae += (i//10 + 1) * 10
        cnt += 1
    else:
        sum_ae += i
if cnt != 0:
    print(sum_ae - (10-g))
else:
    print(sum_ae)
Buggy python submission (verdict: Runtime Error):
b = input()
for i in range(len(b)):
  if b[i] == 'A':
    b[i] = 'T'
  elif b[i] == 'T':
    b[i] = 'A'
  elif b[i] == 'G':
    b[i] = 'C'
  else:
    b[i] = 'G'
print(b)

Fixed submission:
b = input()
if b == 'A':
    print('T')
elif b == 'T':
    print('A')
elif b == 'G':
    print('C')
else:
    print('G')
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a, b = [0]*n, [0]*n
for i in range(n):
    a[i], b[i] = map(int, input().split())

flag = 1
while flag:
    flag = 0
    for j in range(n-1):
        if a[j] > a[j+1]:
            tmp = a[j]
            a[j] = a[j+1]
            a[j+1] = tmp
            res = b[j]
            b[j] = b[j+1]
            b[j+1] = res
            flag = 1

ans = 0
for i in range(n):
    if m > b[i]:
        ans += a[i]*b[i]
        m -= b[i]
    else:
        ans += m*a[i]
        break

print(ans)

Fixed submission:
n, m = map(int, input().split())
a = [0]*n
for i in range(n):
    a[i] = list(map(int, input().split()))

a.sort(key=lambda x: x[0])

ans = 0
for i in range(n):
    if m > a[i][1]:
        ans += a[i][0]*a[i][1]
        m -= a[i][1]
    else:
        ans += m*a[i][0]
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
for i in range(3):
    if n[i] == '1':
        n[i] = '9'
    elif n[i] == '9':
        n[i] = '1'
print(n)

Fixed submission:
n = input()
print(n.replace('1', 'a').replace('9','1').replace('a', '9'))
Buggy python submission (verdict: Runtime Error):
n, i = map(int, input().split())
if n%k == 0:
    print(0)
else:
    print(1)

Fixed submission:
n, i = map(int, input().split())
if n%i == 0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().spilit())

if n > 8 or m > 8:
  print(':(')
else:
  print('Yay!')

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

if n > 8 or m > 8:
  print(':(')
else:
  print('Yay!')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().solit())

print(max(a+b, a-b, a*b))

Fixed submission:
a, b = map(int, input().split())

print(max(a+b, a-b, a*b))
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = ['.'*(h+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(h+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      xi = i + dx[k]
      yi = j + dy[k]
      if s[i][j] == '#' and s[xi][yi] == '.':
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')


Fixed submission:
h, w = map(int, input().split())
s = ['.'*(w+2)]
for i in range(h):
  ss = '.' + input() + '.'
  s.append(ss)
s.append('.'*(w+2))
dx = [1,0,-1,0]
dy = [0,1,0,-1]
for i in range(h):
  for j in range(w):
    cnt = 0
    for k in range(4):
      yi = i + dy[k]
      xi = j + dx[k]
      if s[i][j] == '#' and s[yi][xi] == '.':
        cnt += 1
    if cnt == 4:
      print('No')
      exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
n = int(input())
prime5 = []
for i in range(1,5600):
  a = i * 10 + 1
  # flag = True
  for j in range(3,int(a**0.5) + 1):
    if a % j == 0:
      # flag = False
  else: prime5.append(a)
print(*prime5[:n])

Fixed submission:
n = int(input())
prime5 = []
for i in range(1,5600):
  a = i * 10 + 1
  flag = True
  for j in range(3,int(a**0.5) + 1):
    if a % j == 0:
      flag = False
  if flag: prime5.append(a)
print(*prime5[:n])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split())) # 横入力

cs = [0]
aa = 0
for i in range(n):
    aa += a[i]
    cs.append(aa)

ans = 0
for i in range(n):
    for j in range(i+1,n+1):
        if cs[j] - cs[i] == 0:
            ans += 1

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split())) # 横入力

cs = [0]
aa = 0
for i in range(n):
    aa += a[i]
    cs.append(aa)

cs.sort()
cnt = 1
ans = 0
for i in range(n):
    if cs[i] == cs[i+1]:
        cnt += 1
    else:
        if cnt != 1:
            ans += cnt*(cnt-1)//2
            cnt = 1
if cnt != 1:
    ans += cnt*(cnt-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, x =map(int, inpit().split())

if 0 <= (x-a) <= b:
  print('Yes')
else:
  print('No')

Fixed submission:
a, b, x =map(int, input().split())

if 0 <= x-a <= b:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a, b, x =map(int, inpit().split())

if a > x:
  print('No')
else:
  if a + b < x:
    print('No')
  else:
    if x-a > b:
      print('No')
    else:
      print('Yes')


Fixed submission:
a, b, x =map(int, input().split())

if 0 <= x-a <= b:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a, b, x =map(int, inpit().split())

if a + b < x:
  print('No')
else:
  if a > x:
    print('No')
  else:
    print('Yes')


Fixed submission:
a, b, x =map(int, input().split())

if 0 <= x-a <= b:
  print('YES')
else:
  print('NO')

Buggy python submission (verdict: Runtime Error):
a, b, x =map(int, inpit().split())

if a > x:
  print('No')
else:
  if a + b < x:
    print('No')
  else:
    print('Yes')

Fixed submission:
a, b, x =map(int, input().split())

if 0 <= x-a <= b:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Runtime Error):
def main():
  s = input()
  if s.count(a) == 1 and s.count(b) == 1 and s.count(c) == 1:
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  s = input()
  if s.count('a') == 1 and s.count('b') == 1 and s.count('c') == 1:
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  s = input()
  if s = 'abc' or s = 'bca' or s = 'cab':
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  s = input()
  if s.count('a') == 1 and s.count('b') == 1 and s.count('c') == 1:
    print('Yes')
  else:
    print('No')

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int ,input().split())
num = []
for i in range(a,b+1):
    num.append(i)
ans = []
for i in range(k):
    ans.append(num[i])
for i in range(-k,0):
    ans.append(num[i])

anss = list(set(ans))

for i in range(len(anss)):
    print(anss[i])

Fixed submission:
a, b, k = map(int ,input().split())
if b-a+1 <= k:
    k = b-a+1
ans = []
for i in range(k):
    print(a+i)
    ans.append(a+i)
for i in range(-k+1,1):
    if b+i not in ans:
        print(b+i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
sa = []
for i in range(n+1):
    sa.append(abs(a[i]-a[i+1]))

for i in range(1, n+1):
    print(sum(sa) - sa[i-1] - sa[i] + abs(a[i-1]-a[i+1]))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
sa = 0
for i in range(n+1):
    sa += abs(a[i]-a[i+1])

for i in range(1, n+1):
    print(sa - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])) + abs(a[i-1]-a[i+1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

for h in range(1, n+1):
    ans = 0
    memo = a.pop(h)    # 削除
    for i in range(n):
        ans += abs(a[i]-a[i+1])
    a.insert(h, memo)
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
sa = 0
for i in range(n+1):
    sa += abs(a[i]-a[i+1])

for i in range(1, n+1):
    print(sa - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])) + abs(a[i-1]-a[i+1]))
Buggy python submission (verdict: Runtime Error):
n = input()
a = input()
n %= 500
if n <= a:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())
a = int(input())
n %= 500
if n <= a:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = a * b
d = c % 2
if d = 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
a, b = map(int, input().split())
c = a * b
d = c % 2
if d == 0:
    print('Even')
else:
    print('Odd')

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
int c,d
c = a * b
d = c % 2
if d = 0:
    print('Even')
else:
    print('Odd')

Fixed submission:
a, b = map(int, input().split())
c = a * b
d = c % 2
if d == 0:
    print('Even')
else:
    print('Odd')
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
past_t = past_x = past_y = 0
i = 0
while(i <= n-1):
    t, x, y = map(int,input().split())
    i += 1 
for j in range(n):
    if t - past_t < x + y or ((t-past_t)-(x+y)) % 2 != 0:
        sys.exit('No')
print('Yes')


Fixed submission:
n = int(input())
judge = 'Yes'
past_t = past_x = past_y = 0
for i in range(n):
    t, x, y = map(int,input().split())
    if t - past_t < x + y or ((t-past_t)-(x+y)) % 2 != 0:
        judge = 'No'
print(judge)
Buggy python submission (verdict: Runtime Error):
n, d = map(int, input().split())
ans = [-1]*3
for x in range(n+1):
    for y in range(n-x+1):
        if d = 10000*x + 5000*y + 1000*(n-x-y):
            ans = [x, y, n-x-y]
        # if zd//1000 == n-x-y:
        #     ans[0] = x
        #     ans[1] = y
        #     ans[2] = zd//1000
        #     break
print(*ans)

Fixed submission:
n, y = map(int,input().split())
ans = [-1,-1,-1]
for i in range(n+1):
    for j in range(n+1-i):
        if 10000*i + 5000*j + 1000*(n-i-j) == y:
            ans = [i,j,n-i-j]
print(*ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
n = len(s)
m = len(t)

ss = [s[i] for i in range(n)]
tt = [t[i] for i in range(m)]
ss.sort()
tt.sort(reverse=True)

for i in range(n):
    if ss[i] < tt[i]:
        print('Yes')
        exit()
    elif ss[i] > tt[i]:
        print('No')
        exit()

if n < m:
    print('Yes')
else:
    print('No')


Fixed submission:
s = input()
t = input()

ss = sorted(s)
tt = sorted(t, reverse=True)

if ss < tt:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)


Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)


Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)


Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i%2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i % 2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

count = 0
while all(i % 2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))

count = 0
while all(i % 2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))

Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input().split()))
while all(i % 2 == 0 for i in a):
    a = [i / 2 for i in a]
    count += 1
print(count)

Fixed submission:
i = input()
print(i.count("1"))
Buggy python submission (verdict: Runtime Error):
n = input()

ans(0, int(n[0]), n[0])

def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

Fixed submission:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

print(ans(0, int(n[0]), n[0]))

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

print(ans(0, int(n[0]), n[0]))


def ans(i, j, k):
    if i == 3:
        if j == 7:
            return k + '=7'
    return ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]), ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])


Fixed submission:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

print(ans(0, int(n[0]), n[0]))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))
  ans = 0
  for x in range(min(a)-1, max(a)+2):
    cnt = 0
    for i in range(n):
      if abs(x-a[i]) <= 1:
        cnt += 1
    ans = max(ans, cnt)

  print(ans)
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))
  ans = 0
  for x in range(min(a)-1, max(a)+2):
    cnt = 0
    for i in range(n):
      if abs(x-a[i]) <= 1:
        cnt += 1
    ans = max(ans, cnt)

  print(ans)
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  a = list(map(int ,input().split()))
  ans = 0
  for x in range(min(a)-1, max(a)+2):
    cnt = 0
    for i in range(n):
      if abs(x-a[i]) <= 1:
        cnt += 1
    ans = max(ans, cnt)

  print(ans)
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
  x, t = map(int, input().split())
  if t > x:
    print(0)
  else:
    print(x-t)

if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  a = list(map(int ,input().split()))
  ans = 0
  for x in range(min(a)-1, max(a)+2):
    cnt = 0
    for i in range(n):
      if abs(x-a[i]) <= 1:
        cnt += 1
    ans = max(ans, cnt)

  print(ans)
if __name__ == '__main__':
  main()

Fixed submission:
def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

now = a[0]
cnt = 0

while now != 2:
    cnt += 1
    now = a[now-1]
    if cnt >= n:
        print(-1)
        exit()
    fp.append(now)

if now == 2:
    cnt += 1

print(cnt)

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

now = a[0]
cnt = 0

while cnt <= n:
    cnt += 1
    if now == 2:
        print(cnt)
        exit()
    now = a[now-1]

print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

fp = [a[0]]
now = a[0]
cnt = 0

while now != 2:
    cnt += 1
    now = a[now-1]
    if now in fp:
        print(-1)
        exit()
    fp.append(now)

if now == 2:
    cnt += 1

print(cnt)

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())

now = a[0]
cnt = 0

while cnt <= n:
    cnt += 1
    if now == 2:
        print(cnt)
        exit()
    now = a[now-1]

print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
cookie = list(map(int, input().split()))
sc = sum(cookie)
cnt = -1
if cookie[0] == cookie[1] and cookie[1] == cookie[2]:
    if cookie[0] % 2 == 0:
        print(cnt)
        exit()
    else:
        print(0)
memo = [0]*3
while sum(cookie) == sc:
    memo[0] = (cookie[1] + cookie[2]) // 2
    memo[1] = (cookie[0] + cookie[2]) // 2
    memo[2] = (cookie[1] + cookie[0]) // 2
    for i in range(3):
        cookie[i] = memo[i]
    cnt += 1

print(cnt)

Fixed submission:
cookie = list(map(int, input().split()))
sc = sum(cookie)
cnt = 0
if cookie[0] == cookie[1] and cookie[1] == cookie[2] and cookie[0]%2 == 0:
    print(-1)
    exit()
memo = [0]*3
while cookie[0]%2 == 0 and cookie[1]%2 == 0 and cookie[2]%2 == 0:
    memo[0] = (cookie[1] + cookie[2]) // 2
    memo[1] = (cookie[0] + cookie[2]) // 2
    memo[2] = (cookie[1] + cookie[0]) // 2
    for i in range(3):
        cookie[i] = memo[i]
    cnt += 1

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
    for i in range(n//2):
        if a.count(2*i + 1) != 2:
            print(0)
            exit()
else:
    if a.count(0) != 1:
        print(0)
        exit()
    for i in range(1,n//2+1):
        if a.count(2*i) != 2:
            print(0)
            exit()
    
print(2**(n//2) % (10**9+7))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
d = 0

if n % 2 == 0:
    for i in range(n//2):
        d += (2*i + 1) * 2
    if d != sum(a):
        print(0)
        exit()
else:    
    for i in range(1, n//2+1):
        d += 4 * i
    if d != sum(a):
        print(0)
        exit()

print(2**(n//2) % (10**9+7))
Buggy python submission (verdict: Runtime Error):
daydream = ['reamd','reamerd','rasee','rasere']
S = input()
S = strip(S[0])
if 'reamd' in S:
    S = S.strip('reamed')
if 'reamrd' in S:
    S = S.strip('reamerd')
if 'rasee' in S:
    S = S.strip('rasee')
if 'rasere' in S:
    S = S.strip('rasere')
if not str:
    print('NO')
else:
    print('YES')

Fixed submission:
s = input()
if 'eraser' in s:
    s = s.replace('eraser','')
if 'erase' in s:
    s = s.replace('erase','')
if 'dreamer' in s:
    s = s.replace('dreamer','') 
if 'dream' in s:
    s = s.replace('dream','') 
emp = len(s)
if emp == 0:
    print('YES')
else:
    print('NO')