Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,x,m = (int(x) for x in input().split())
lst = []
ans = 0
cnt = 0
i = 0
visited = [-1 for _ in xrange(m)]
stop_c = False
while i < n:
    ret = pow(x,2**i,m)

    if visited[ret] == -1:
        visited[ret] = i
    else:
        stop_c = True
        # i += 1
        break
    ans += ret
    lst.append(ret)
    i += 1

if stop_c:
    cycle_len = len(lst[visited[ret]:])
    cycle_sum = sum(lst[visited[ret]:])
    remsum  = sum(lst[visited[ret]:][:(n-visited[ret]) % cycle_len])
    print((ans -cycle_sum) + (cycle_sum * ((n-visited[ret]) // cycle_len)) + remsum)
else:
    print(ans)

Fixed submission:
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,x,m = (int(x) for x in input().split())
lst = []
ans = 0
cnt = 0
i = 0
visited = [-1 for _ in xrange(m)]
stop_c = False
while i < n:
    if i == 0:
        ret = pow(x,1,m)
    else:
        ret = pow(x,2,m)
    x = ret
    if visited[ret] == -1:
        visited[ret] = i
    else:
        stop_c = True
        # i += 1
        break
    ans += ret
    lst.append(ret)
    i += 1

if stop_c:
    cycle_len = len(lst[visited[ret]:])
    cycle_sum = sum(lst[visited[ret]:])
    remsum  = sum(lst[visited[ret]:][:(n-visited[ret]) % cycle_len])
    print((ans -cycle_sum) + (cycle_sum * ((n-visited[ret]) // cycle_len)) + remsum)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def ncr(n,r,p):
    num = den = 1
    for i in range(r):
        num = (num * (n-i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0
for i in range(k+1):
    ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    if ans > p:
        ans = ans % p 
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

f = [(1,1), ]

def ncr(n,r,p):
    num = (f[-1][0] * (n-(r-1))) % p
    den = (f[-1][1] * ((r-1) + 1)) % p
    f.append([num, den])
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0

for i in range(k+1):
    if i == 0:
        ans += m*pow(m-1, n-i-1,p)
    else:
        ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    ans = ans % p 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def ncr(n,r,p):
    num = den = 1
    for i in xrange(r):
        num = (num * (n-i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0
for i in xrange(k+1):
    ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    ans = ans % p 
print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

f = [(1,1), ]

def ncr(n,r,p):
    num = (f[-1][0] * (n-(r-1))) % p
    den = (f[-1][1] * ((r-1) + 1)) % p
    f.append([num, den])
    return (num * pow(den, p-2, p)) % p

n,m,k = (int(x) for x in input().split())
p = 998244353
ans = 0

for i in range(k+1):
    if i == 0:
        ans += m*pow(m-1, n-i-1,p)
    else:
        ans += m*pow(m-1, n-i-1,p) * ncr(n-1,i,p)
    ans = ans % p 
print(ans)
Buggy python submission (verdict: Runtime Error):
x = int(input())
eps = 1e-9
a = 1
while a**5 <= x:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(round(diff**0.2))
        if sign:
            b = -b
        break
    a += 1
print(a,int(b))


Fixed submission:
import sys
input = sys.stdin.readline

print("ABC" if input().strip() == "ARC" else "ARC")
Buggy python submission (verdict: Runtime Error):
x = int(input())
eps = 1e-9
a = 1
while a**5 <= x:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(round(diff**0.2))
        if sign:
            b = -b
        break
    a += 1
print(a,int(b))


Fixed submission:
import sys
input = sys.stdin.readline

x = int(input())
eps = 1e-9
a = 1
while True:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(diff**0.2)
        if sign:
            b = -b
        break
    a += 1
print a,int(b)

Buggy python submission (verdict: Runtime Error):
x = int(input())
eps = 1e-9
a = 1
while a**5 <= x:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(round(diff**0.2))
        if sign:
            b = -b
        break
    a += 1
print a,int(b)


Fixed submission:
import sys
input = sys.stdin.readline

x = int(input())
eps = 1e-9
a = 1
while True:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(diff**0.2)
        if sign:
            b = -b
        break
    a += 1
print a,int(b)

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from  math import log

x = int(input())
eps = 1e-9
a = 1
while a**5 <= x:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(round(diff**0.2))
        if sign:
            b = -b
        break
    a += 1
print a,int(b)


Fixed submission:
import sys
input = sys.stdin.readline

x = int(input())
eps = 1e-9
a = 1
while True:
    diff = a**5-x
    if diff < 0:
        diff = abs(diff)
        sign = True
    else:
        sign = False
    if abs(diff**0.2 - round(diff**0.2)) < eps:
        b = round(diff**0.2)
        if sign:
            b = -b
        break
    a += 1
print a,int(b)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n = int(input())
seq = [int(x) for x in input().split()]
visited = [False for _ in xrange(n)]
ans = 0
p = set()
for i, val in enumerate(seq):
    if val > n:
        continue

    for j in xrange(min(n,i+val-2), n):
        if abs(j-i) == val + seq[j]:
            if not visited[i]:
                visited[i] = True
            if not visited[j]:
                visited[j] = True
            if (i,j) not in p:
                ans += 1
                p.add((i,j))
    for j in xrange(0, max(i-val, 0)):
        if abs(i - j) == val + seq[j]:
            if not visited[i]:
                visited[i] = True
            if not visited[j]:
                visited[j] = True
            if (j,i) not in p:
                ans += 1
                p.add((j,i))
print(ans)



Fixed submission:
import sys
input = sys.stdin.readline

n = int(input())
seq = [(int(x),i) for i, x in enumerate(input().split())]
seq1 =(i-x for x,i in seq)
seq2 =(i+x for x,i in seq)

d1 = dict()
d2 = dict()
s1 = set()
s2 = set()
for val in seq1:
    try:
        d1[val] += 1
    except:
        d1[val] = 1
for val in seq2:
    try:
        d2[val] += 1
    except:
        d2[val] = 1

ans = 0
for key in d1:
    try:
        ans += d1[key] * d2[key]
    except:
        pass

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
que = []
for i in range(k+9):
    if i < 9:
        que.append(i+1)
    else:
        x = que.pop(0)
        if x % 10 != 0:
            que.append(10*x+(x%10) -1)
        que.append(10*x+(x%10))
        if x % 10 != 9:
             que.append(10*x+(x%10) +1)
            
print(x)


Fixed submission:
from collections import deque
k = int(input())
que = deque()
for i in range(k+9):
    if i < 9:
        que.append(i+1)
    else:
        x = que.popleft()
        if x % 10 != 0:
            que.append(10*x+(x%10) -1)
        que.append(10*x+(x%10))
        if x % 10 != 9:
             que.append(10*x+(x%10) +1)
            
print(x)
Buggy python submission (verdict: Runtime Error):
from mpmath import *

mp.dps=50
mp.pretty = True

a,b,c = (int(x) for x in input().split())
if a+b+2*(mp.sqrt(a*b)) < c:
    print('Yes')
else:
    print('No')

Fixed submission:
from decimal import *
a,b,c = (int(x) for x in input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c) 
if a+b+2*(a.sqrt()*b.sqrt()) < c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
r = False
for _ in range(q):
  cmd = input()
  if cmd[0] == '1':
    r = not r
  else:
    t,f,c = cmd.split()
    if (f == '1' and not r) or (f == '2' and r):
      s = c + s
    else:
      s = s + c
if r:
	print(s[::-1])
else:
	print(s)


Fixed submission:
from collections import deque
s = input()

q = int(input())
s = deque(s)
r = False
for _ in range(q):
    cmd = input()
    if cmd[0] == '1':
        r = not r
    else:
        cmd, f, c = cmd.split()
        if (f == '2' and not r) or (f=='1' and r):
            s.append(c)
        else:
            s.appendleft(c)
if r:
    s.reverse()
print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for _ in range(q):
  cmd = input()
  if cmd[0] == '1':
    s = s[::-1]
  else:
    t,f,c = cmd.split()
    if f == '1':
      s = c + s
    else:
      s = s + c
print(s)
    

Fixed submission:
from collections import deque
s = input()

q = int(input())
s = deque(s)
r = False
for _ in range(q):
    cmd = input()
    if cmd[0] == '1':
        r = not r
    else:
        cmd, f, c = cmd.split()
        if (f == '2' and not r) or (f=='1' and r):
            s.append(c)
        else:
            s.appendleft(c)
if r:
    s.reverse()
print(''.join(s))
Buggy python submission (verdict: Runtime Error):
n = int(n)
seq = [int(x) for x in input().split()]
d = round(sum(seq) / len(seq))
print(sum([(x-d)**2 for x in seq]))


Fixed submission:
n = int(input())
seq = [int(x) for x in input().split()]
d = round(sum(seq) / len(seq))
print(sum([(x-d)**2 for x in seq]))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]
ans = 0
for i in range(n-k+1):
  score = 0 
  for j in range(k):
    n = seq[i+j]
    score += 1/2*(2+(n-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))

Fixed submission:
n, k = (int(x) for x in input().split())
seq = [int(x) for x in input().split()]

ans = 0
for i in range(k):
    ans += 1/2*(2+(seq[i]-1)) 
score = ans
for i in range(n-k):
  score -= 1/2*(2+(seq[i]-1)) 
  score += 1/2*(2+(seq[i+k]-1)) 
  ans = max(ans, score)
  
print(round(ans, 9))
Buggy python submission (verdict: Runtime Error):
n, m = [int(x) for x in input().split()]
lst = [None]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  if s == 'AC' and lst[p] is None:
    a += 1
    lst[p] = True
  elif s == 'WA' and lst[p] is None:
    b += 1
print(a,b)

Fixed submission:
n, m = [int(x) for x in input().split()]
lst = [0]*(n+1)
a = 0
b = 0
for i in range(m):
  p, s = input().split()
  p = int(p)
  if s == 'AC' and lst[p] is not None:
    a += 1
    b += lst[p]
    lst[p] = None
  elif s == 'WA' and lst[p] is not None:
    lst[p] += 1
print(a,b)
Buggy python submission (verdict: Runtime Error):
n, a, b = (int(x) for x in input().split())
if (b-a) % 2 == 0:
  ans = (b-a) // 2
else:
  ans = min(a-1,n-b)+1+(b−a−1)//2
print(ans)

Fixed submission:
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b−a−1)//2
print(ans)


Fixed submission:
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
  ans = (b-a) // 2
else:
  ans = min(a-1, n-b) + 1 + (b−a−1)//2
print(ans)


Fixed submission:
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
  ans = (b-a) // 2
else:
  ans = min(a-1, n-b) + 1 + (B−A−1)//2
print(ans)

Fixed submission:
n, a, b = (int(x) for x in input().split())
if (b - a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans = min(a-1, n-b) + 1 + (b-a-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
 
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Fixed submission:
from fractions import gcd
 
def lcm(a, b):
    return abs(a*b) // gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Buggy python submission (verdict: Runtime Error):
import math
 
def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Fixed submission:
from fractions import gcd
 
def lcm(a, b):
    return abs(a*b) // gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))

Buggy python submission (verdict: Runtime Error):
import math

def lcm(a, b):
    return abs(a*b) // math.gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))


Fixed submission:
from fractions import gcd
 
def lcm(a, b):
    return abs(a*b) // gcd(a, b)
  
a, b = [int(x) for x in input().split()]
print(lcm(a,b))
Buggy python submission (verdict: Runtime Error):
n = int(x)
if n % 2 == 1:
  ans = 0
else:
  ans = int(n // 10) + int(n // 50) + int(n // 250)
print(ans)

Fixed submission:
n = int(input())
if n == 0:
  ans = 0
elif n % 2 == 1:
  ans = 0
else:
  pwr = 10
  ans = 0
  while pwr <= n:
    ans += n // pwr
    pwr *= 5
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
m = 10**9 + 7
n = int(input())
seq = [bin(int(x))[2:].zfill(61) for x in input().split()]
cnt = [[0,0] for i in range(61)]
for s in seq:
    for i in range(61):
        if s[i] == '0':
            cnt[i][0] += 1
        else:
            cnt[i][1] += 1
ans = 0
for i in range(61):
  ans += cnt[-i-1][0]*cnt[-i-1][1]*(2**i)
  ans = ans % m
print(ans)

Fixed submission:
m = 10**9 + 7
n = int(input())
seq = [bin(int(x))[2:].zfill(61) for x in input().split()]
cnt = [[0,0] for i in range(61)]
for s in seq:
    for i in range(len(s)):
        if s[i] == '0':
            cnt[i][0] += 1
        else:
            cnt[i][1] += 1
ans = 0
for i in range(61):
  ans += cnt[-i-1][0]*cnt[-i-1][1]*(2**i)
  ans = ans % m
print(ans)
Buggy python submission (verdict: Runtime Error):
def solve(X):
    for a in range(1 + X // 100):
        for b in range(1 + X // 101):
            for c in range(1+ X // 102):
                for d in range(1 + X // 103):
                    for e in range(1 + X // 104):
                        for f in range( 1 + X // 105):
                            if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 == X:
                                return 1
                            elif a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
                                break
                #        if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
                 #           break
              #      if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
               #         break
            #    if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
             #       break
          #  if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
           #     break
        #if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
         #   break
    return 0

X = int(input())
print(solve(X))
~

Fixed submission:
def solve(X):
    for a in range(1 + X // 100):
        for b in range(1 + X // 101):
            for c in range(1+ X // 102):
                for d in range(1 + X // 103):
                    for e in range(1 + X // 104):
                        for f in range( 1 + X // 105):
                            if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 == X:
                                return 1
                            elif a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
                                break
                #        if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
                 #           break
              #      if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
               #         break
            #    if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
             #       break
          #  if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
           #     break
        #if a*100 + b*101+ c*102 + d * 103 + e * 104 + f * 105 > X:
         #   break
    return 0

X = int(input())
print(solve(X))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(1000):
    seq = f"{i:03d}"
    cnt = 0
    for j in s:
        if seq[cnt] == j:
            cnt += 1
            if cnt == 3:
                break
    if cnt == 3:
        ans +=1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    seq = "{:03d}".format(i)
    cnt = 0
    for j in s:
        if seq[cnt] == j:
            cnt += 1
            if cnt == 3:
                break
    if cnt == 3:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 0
for i in range(1000):
    seq = f"{i:03d}"
    cnt = 0
    for j in s:
        if seq[cnt] == j:
            cnt += 1
            if cnt == 3:
                break
    if cnt == 3:
        ans +=1
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    seq = "{:03d}".format(i)
    cnt = 0
    for j in s:
        if seq[cnt] == j:
            cnt += 1
            if cnt == 3:
                break
    if cnt == 3:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 0:
	print(0.5)
else:
	print((N//2+1) / N)

Fixed submission:
n = int(input())
if n % 2 == 0:
	print(0.5)
else:
	print((n//2+1) / n)
Buggy python submission (verdict: Runtime Error):
s = raw_input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")

Fixed submission:
s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]

total = sum(b)
last_dish = a[0]
for d in a[1:]:
	if d-last_dish == 1:
    	total += c[last_dish-1]
	last_dish = d
print(total)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
total = sum(b)
last_dish = a[0]
for d in a[1:]:
  if d-last_dish == 1:
    total += c[last_dish-1]
  last_dish = d
print(total)
Buggy python submission (verdict: Runtime Error):
a, b = (int(x) for x in input().split())
print(int((b-1) / (a-1))
  
  

Fixed submission:
a, b = (int(x) for x in input().split())
print(int((b-1) / (a-1)) + (1 if (b-1) % (a-1) != 0 else 0))
Buggy python submission (verdict: Time Limit Exceeded):
print(sum(range(int(input()))))

Fixed submission:
n = int(input())-1
print(((2+n-1)*n ) >> 1)

Buggy python submission (verdict: Runtime Error):
print(sum(range(int(input())))

Fixed submission:
n = int(input())-1
print(((2+n-1)*n ) >> 1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
n = int(input())
b = 2*np.array([int(x) for x in input().split()])
A = np.eye(n)
for i in range(n-1):
    A[i, i+1] = 1
A[-1,0] = 1
print(' '.join(str(int(val)) for val in np.linalg.solve(A,b)))

Fixed submission:
n = int(input())
bs = [int(x) for x in input().split()]
sign = 1
a_2 = bs[0]
for b in bs[1:]:
    a_2 += sign*b
    sign *= -1

ans = str(a_2) + ' '
for i in range(n-2):
    a_2 = 2*bs[i+1] - a_2
    ans += str(a_2) + ' '
ans = str(2*bs[i+2] - a_2) + ' ' + ans
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = (int(x) for x in input().split())
ss = set(range(n))
for _ in range(m):
  l, r = (int(x) for x in input().split())
  ss = ss.intersection(range(l-1, r))
print(len(ss))

Fixed submission:
n, m = (int(x) for x in input().split())
max_l = float('-inf')
min_r = float('inf')
for _ in range(m):
  l, r = (int(x) for x in input().split())
  max_l = max(max_l, l)
  min_r = min(min_r, r)
print(max(0, min_r - max_l+1))
Buggy python submission (verdict: Runtime Error):
s = input()
option1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 = 0
print(min(ans_1, ans_2))

Fixed submission:
s = input()
option_1 = ['1' if i % 2 == 0 else '0' for i in range(len(s))]
option_2 = ['0' if i % 2 == 0 else '1' for i in range(len(s))]
ans_1 = 0
ans_2 = 0
for i, c in enumerate(s):
  if option_1[i] != c:
    ans_1 += 1
  if option_2[i] != c:
    ans_2 += 1
print(min(ans_1, ans_2))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
og_l = len(s)
diff = 1
while diff > 0:
  cur_l = len(s)
  s = s.replace("01", '').replace("10", '')
  diff = cur_l - len(s)
print(og_l - len(s))

Fixed submission:
s = input()
z = 0
o = 0
for c in s:
  if c == '0':
    z += 1
  else:
    o += 1
print(2*min(z,o))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = [int(x) for x in input().split()]
seq = [int(x) for x in input().split()]
dp = [0]*n
k = min(k, n)
for i in range(1, k):
    dp[i] = abs(seq[i] - seq[0])
# print(dp)
for i in range(k, n):
    a = dp[i-1] + abs(seq[i] - seq[i-1])
    for j in range(k-1):
        a = min(a, dp[i-2-j] + abs(seq[i] - seq[i-2-j]))
    dp[i] = a
# print(dp)
print(dp[-1])

Fixed submission:
n, k = [int(x) for x in input().split()]
seq = [int(x) for x in input().split()]
dp = [0]*n
k = min(k, n)
for i in range(1, k):
    dp[i] = abs(seq[i] - seq[0])
# print(dp)
for i in range(k, n):
    a = dp[i-1] + abs(seq[i] - seq[i-1])
    for j in range(k-1):
        a = min(a, dp[i-2-j] + abs(seq[i] - seq[i-2-j]))
    dp[i] = a
# print(dp)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
c = [[],[],[]]
c[0] = [int(x) for x in input().split()]
c[1] = [int(x) for x in input().split()]
c[2] = [int(x) for x in input().split()]

ans = "Yes"
for i in range(3):
  for j in range(3):
  	if c[(i+1)%3][(j+1)%3] + c[(i+2)%3][(j+2)%3] != c[(i+2)%3][(j+1)%3] + c[(i+1)%3][(j+2)%3]
      ans = "No"	
      break
  if ans == "No":
    break
print(ans)

Fixed submission:
c = [[],[],[]]
c[0] = [int(x) for x in input().split()]
c[1] = [int(x) for x in input().split()]
c[2] = [int(x) for x in input().split()]

ans = "Yes"
for i in range(3):
    for j in range(3):
        if c[(i+1)%3][(j+1)%3] + c[(i+2)%3][(j+2)%3] != c[(i+2)%3][(j+1)%3] + c[(i+1)%3][(j+2)%3]:
            ans = "No"
            break
    if ans == "No":
        break
print(ans)