Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02834 (python)

Fixed submission:
from collections import deque

INF = -1

n, t, a = map(int, input().split())
t -= 1
a -= 1
g = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v = map(lambda x: int(x) - 1, input().split())
    g[u].append(v)
    g[v].append(u)

def bfs(start):
    dist = [INF] * n
    dist[start] = 0
    q = deque([start])
    while q:
        cur = q.pop()
        for to in g[cur]:
            if dist[to] == INF:
                dist[to] = 1 + dist[cur]
                q.appendleft(to)
    return dist

distT = bfs(t)
distA = bfs(a)
ret = 0
for v in range(n):
    if distT[v] < distA[v]:
        ret = max(ret, distA[v] - 1)
print(ret)

Buggy submission (verdict: Runtime Error):
from collections import deque

n,u,v = map(int,input().split())
edge = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
q = deque()
step = [0 for _ in range(n+1)]
q.appendleft([v,0])
visied = set()
visied.add(v)
while len(q)>0:
    a,v = q.pop()
    for node in edge[a]:
        if node not in visied:
            step[node] = v+1
            q.appendleft([node,v+1])
            visied.add(node)           
q =[]
q.appendleft((u,0))
mx= 0
queue = set()
queue.add((u,0))
while len(q)>0:
    a, v = q.pop()
    p=0
    value =0
    for node in edge[a]:
        cur = v+1
        if cur<step[node]:
            add = (node,cur)
            if add not in queue:
                q.appendleft(add)
                queue.add(add)
                p=1
        else:
            value = max(value,step[node])
    if p ==0:
        mx = max(mx,value)
# print(step)
print(mx)

Buggy submission (verdict: Runtime Error):
from collections import deque

n,u,v = map(int,input().split())
edge = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
q = deque()
step = [0 for _ in range(n+1)]
q.appendLeft([v,0])
visied = set()
visied.add(v)
while len(q)>0:
    a,v = q.pop()
    for node in edge[a]:
        if node not in visied:
            step[node] = v+1
            q.appendLeft([node,v+1])
            visied.add(node)           
q =[]
q.appendLeft((u,0))
mx= 0
queue = set()
queue.add((u,0))
while len(q)>0:
    a, v = q.pop()
    p=0
    value =0
    for node in edge[a]:
        cur = v+1
        if cur<step[node]:
            add = (node,cur)
            if add not in queue:
                q.appendLeft(add)
                queue.add(add)
                p=1
        else:
            value = max(value,step[node])
    if p ==0:
        mx = max(mx,value)
# print(step)
print(mx)
Problem p03045 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(100000)
from collections import deque

nVertices, nEdges = map(int, input().split())
g = [[] for _ in range(nVertices + 1)]
for _ in range(nEdges):
    u, v, _ = map(int, input().split())
    g[u].append(v)
    g[v].append(u)

def dfs(v):
    visited[v] = True
    for to in g[v]:
        if not visited[to]:
            dfs(to)

def bfs(v):
    visited[v] = True
    q = deque([v])
    while q:
        cur = q.pop()
        for to in g[cur]:
            if not visited[to]:
                visited[to] = True
                q.appendleft(to)

cnt = 0
visited = [False] * (nVertices + 1)
for v in range(1, nVertices + 1):
    if not visited[v]:
        bfs(v)
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(100000)

nVertices, nEdges = map(int, input().split())
g = [[] for _ in range(nVertices + 1)]
for _ in range(nEdges):
    u, v, _ = map(int, input().split())
    g[u].append(v)
    g[v].append(u)

def dfs(v):
    visited[v] = True
    for to in g[v]:
        if not visited[to]:
            dfs(to)

cnt = 0
visited = [False] * (nVertices + 1)
for v in range(1, nVertices + 1):
    if not visited[v]:
        dfs(v)
        cnt += 1
print(cnt)
Problem p03127 (python)

Fixed submission:
from functools import reduce

def gcd(a, b):
    while (b):
        a, b = b, a % b
    return a

input()
print(reduce(gcd, map(int, input().split())))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

input()
print(reduce(gcd, map(int, input().split())))
Problem p03209 (python)

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

pattiesCount = lambda level: (1 << (level + 1)) - 1
bunsCount = lambda level: (1 << (level + 1)) - 2
bothCount = lambda level: (1 << (level + 2)) - 3

# for i in range(51):
#     if pattiesCount(i) != p[i]:
#         raise Exception()
#     print(i, '->', pattiesCount(i), bunsCount(i), bothCount(i))

def doit(level, eat):
    if level == 0:
        return int(eat >= 1)
    both = bothCount(level - 1)
    patties = pattiesCount(level - 1)
    if eat == both + 2:
        return 1 + patties
    if eat > both + 1:
        return 1 + patties + doit(level - 1, eat - 2 - both)
    return doit(level - 1, eat - 1)

print(doit(n, eat))

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

pattiesCount = lambda level: (1 << (level + 1)) - 1
bunsCount = lambda level: (1 << (level + 1)) - 2
bothCount = lambda level: (1 << (level + 2)) - 3

# for i in range(51):
#     if pattiesCount(i) != p[i]:
#         raise Exception()
#     print(i, '->', pattiesCount(i), bunsCount(i), bothCount(i))

def doit(level, eat):
    if level == 0:
        if eat > 1:
            raise Exception()
        return int(eat == 1)
    both = bothCount(level - 1)
    patties = pattiesCount(level - 1)
    if eat == both + 2:
        return 1 + patties
    if eat < both + 2:
        return doit(level - 1, eat - 1)
    return 1 + patties + doit(level - 1, eat - 2 - both)


print(doit(n, eat))
Problem p02990 (python)

Fixed submission:
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    if N - K + 1 < i:
        print(0)
    else:
        print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    if N == K:
        print(0)
    else:
        print((cmb(N - K + 1, i) % (10**9 + 7)) * (cmb(K - 1, i - 1) % (10**9 + 7)))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    if N == K:
        print(0)
    else:
        print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n - 1, r) + cmb(n - 1, r - 1)
    return nCr[(n, r)]


N, K = map(int, input().split())

for i in range(1, K + 1):
    print((cmb(N - K + 1, i) %
           (10**9 + 7)) * (cmb(K - 1, i - 1) %
                           (10**9 + 7)))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    print((cmb(N - K + 1, i) %
           (10**9 + 7)) * (cmb(K - 1, i - 1) %
                           (10**9 + 7)))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N, K = map(int, input().split())

for i in range(1, K + 1):
    print((cmb(N - K + 1, i) * cmb(K - 1, i - 1)) % (10**9 + 7))
Problem p02897 (python)

Fixed submission:
N = int(input())
print(0.5 if N % 2 == 0 else -(-N // 2)/ N)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
count = 0
for h in H:
    if h >= K:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
for h_i in lst:
    if h_i < K:
        continue
    else:
        i += 1
print(i)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = list(map(int, input().split()))
i = 0
for h_i in lst:
    if h_i < K:
        continue
    i += 1
print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(0.5 if N % 2 == 0 else ((N //2) + !)/ 2)
Problem p03834 (python)

Fixed submission:
a, b, c = input().split(',')
print(a, b, c)

Buggy submission (verdict: Runtime Error):
a, b, c = input().split(,)
print(a, b, c)
Problem p02753 (python)

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

if s[0] == s[1] == s[2]:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
    #n,m = list(map(int,input().split()))
    s = input()
     
    if s[0] == s[1] == s[2]:
      print('No')
    else:
      print('Yes')
Problem p02773 (python)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]

c = collections.Counter(s)
common = c.most_common()

count = common[0][1]
ans = []
for i in common:
  if i[1] == count:
    ans.append(i[0])
  else:
    break
ans.sort()
print(*ans,sep='\n')

Buggy submission (verdict: Runtime Error):
 = int(input())
s = [input() for i in range(n)]

m = 0
for i in s:
    mae = len(s)
    s = [j for j in s if j != i]
    ato = len(s)
    num = mae - ato

    if num > m:
        ans = [i]
        m = num
    elif num == m:
        ans.append(i)


ans.sort()

#print(*ans,sep='\n')
print('\n'.join(map(str, ans)))
#for i in range(len(ans)):
#    print(ans[i])
Problem p02723 (python)

Fixed submission:
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s = input()
ans = 'No'
if s[2] == s[3] and s[4] == s[5]:
    ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

s, = input()
ans = 'No'
if s[2] == s[3] and s[5] == s[6]:
    ans = 'Yes'
print(ans)
Problem p02829 (python)

Fixed submission:
import sys
def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(var):
	print(var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

a = []
a.append(I()[0])
a.append(I()[0])
for i in range(1, 4):
	if i not in a:
		print(i)
		break

Buggy submission (verdict: Runtime Error):
import sys
def fastio():
    from io import StringIO
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var):
    print(*var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

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

Buggy submission (verdict: Runtime Error):
import sys
def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(var):
	print(var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from math import gcd
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

a = []
a.append(I()[0])
a.append(I()[0])
for i in range(1, 4):
	if i not in a:
		print(i)
		break
Problem p02835 (python)

Fixed submission:
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd

a, b, c = I()
if a + b + c >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

a, b, c = I()
if a + b + c >= 22:
    print('bust')
else:
    print('win')

Buggy submission (verdict: Runtime Error):
fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

a, b, c = I()
if a + b + c >= 22:
    print('bust')
else:
    print('win')
Problem p02836 (python)

Fixed submission:

MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i-1])
print(ans)

Buggy submission (verdict: Runtime Error):

MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i-1])
print(ans)

Buggy submission (verdict: Runtime Error):

MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i])
print(ans)

Buggy submission (verdict: Runtime Error):
def fastio():
    import sys
    from io import StringIO 
    from atexit import register
    global input
    sys.stdin = StringIO(sys.stdin.read())
    input = lambda : sys.stdin.readline().rstrip('\r\n')
    sys.stdout = StringIO()
    register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

MOD = 10**9 + 7
INF = 10**20
I = lambda:list(map(int,input().split()))
from collections import defaultdict as dd
from math import gcd

s = input()
n = len(s)
ans = 0
for i in range(n//2):
    ans += (s[i] != s[n-i])
print(ans)
Problem p02726 (python)

Fixed submission:
N, X, Y = map(int, input().split())

mind = [[N] * N for i in range(N)]
    
for i in range(N):
    for j in range(i+1, N):
        mind[i][j] = min(abs(j-i), abs((X-1)-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

mindcnt = [0] * N
for i in range(N):
    for j in range(i+1, N):
        d = mind[i][j]
        mindcnt[d] += 1

for k in range(1, N):
    print(mindcnt[k])

Buggy submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())

mind = [[N] * N for i in range(N)]
    
for i in range(N):
    for j in range(i+1, N):
        mind[i][j] = min(abs(j-i), abs((X-1)-i)+1+abs(j-(Y-1)), abs((Y-1)-i)+1+abs(j-(X-1)))

mindcnt = [0] * N
for i in range(N):
    for j in range(i+1, N):
        mind = mind[i][j]
        mindcnt[mind] += 1

for k in range(1, N):
    print(mindcnt[k])
Problem p02757 (python)

Fixed submission:
N, P = map(int, input().split())
S = input()

r_circ = []
v = 1
while True:
    r = v % P
    if r in r_circ:
        break
    r_circ.append(r)
    v *= 10

ans = 0
if P in (2, 5):
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i+1
else:
    pr = 0
    rcntmap = [0] * P
    rcntmap[0] = 1  # r - 0 patten
    for i in reversed(range(len(S))):
        d = int(S[i])
        r = (d * r_circ[(len(S)-1-i) % len(r_circ)] + pr) % P
        #r = int(S[i:]) % P
        ans += rcntmap[r]
    
        rcntmap[r] += 1
        pr = r

print(ans)

Buggy submission (verdict: Runtime Error):
 or P == 5:N, P = map(int, input().split())
S = input()

r_circ = []
v = 1
while True:
    r = v % P
    if r in r_circ:
        break
    r_circ.append(r)
    v *= 10

ans = 0
if P in (2, 5):
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i+1
else:
    pr = 0
    rcntmap = [0] * P
    rcntmap[0] = 1  # r - 0 patten
    for i in reversed(range(len(S))):
        d = int(S[i])
        r = (d * r_circ[(len(S)-1-i) % len(r_circ)] + pr) % P
        #r = int(S[i:]) % P
        ans += rcntmap[r]
    
        rcntmap[r] += 1
        pr = r

print(ans)
Problem p02990 (python)

Fixed submission:
# WARN: Require mod number m is prime number
class ModComb:
    # For nCr mod m
    def __init__(self, n_max, m):
        self._n_max = n_max
        self._m = m
        self._mod_facts = [1] * (n_max+1)       # list of n! mod m
        self._mod_inv_facts = [1] * (n_max+1)   # list of inverse r! mod m

        if not m >= 3:
            raise ValueError('Require mod number m >= 3')

        # Calc n_max! mod m
        for i in range(2, n_max+1):
            self._mod_facts[i] = self._mod_facts[i-1] * i % m

        # Calc inverse r! mod m
        self._mod_inv_facts[n_max] = pow(self._mod_facts[n_max], m-2, m)
        for i in range(n_max-1, 1, -1):
            self._mod_inv_facts[i] = self._mod_inv_facts[i+1] * (i+1) % m

    def calc(self, n, r):
        # Return nCr mod m
        if n > self._n_max:
            raise Exception('n is larger than n_max')

        if r == 0:
            return 1

        m = self._m
        return self._mod_facts[n] * self._mod_inv_facts[r] * self._mod_inv_facts[n-r] % m

N, K = map(int, input().split())

MOD = 10**9 + 7

mcomb = ModComb(N, MOD)
for i in range(1, K+1):
    if N-K < (i-1) :
        print(0)
        continue
    b = mcomb.calc(K-1, i-1)
    # N-K-(i-1) を i+1に組分け
    p = mcomb.calc(N-K-(i-1) + i, i)
    #print(N-K-(i-1) + i, i)
    #print(b, p)
    print(b*p % MOD)

Buggy submission (verdict: Runtime Error):
# WARN: Require mod number m is prime number
class ModComb:
    # For nCr mod m
    def __init__(self, n_max, m):
        self._n_max = n_max
        self._m = m
        self._mod_facts = [1] * (n_max+1)       # list of n! mod m
        self._mod_inv_facts = [1] * (n_max+1)   # list of inverse r! mod m

        if not m >= 3:
            raise ValueError('Require mod number m >= 3')

        # Calc n_max! mod m
        for i in range(2, n_max+1):
            self._mod_facts[i] = self._mod_facts[i-1] * i % m

        # Calc inverse r! mod m
        self._mod_inv_facts[n_max] = pow(self._mod_facts[n_max], m-2, m)
        for i in range(n_max-1, 1, -1):
            self._mod_inv_facts[i] = self._mod_inv_facts[i+1] * (i+1) % m

    def calc(self, n, r):
        # Return nCr mod m
        if n > self._n_max:
            raise Exception('n is larger than n_max')
        if r > n:
            raise Exception('r is larger than n')

        if r == 0:
            return 1

        m = self._m
        return self._mod_facts[n] * self._mod_inv_facts[r] * self._mod_inv_facts[n-r] % m

N, K = map(int, input().split())

MOD = 10**9 + 7

mcomb = ModComb(N, MOD)
for i in range(1, K+1):
    #if N-K < (i-1) :
    #    print(0)
    #    continue
    b = mcomb.calc(K-1, i-1)
    # N-K-(i-1) を i+1に組分け
    p = mcomb.calc(N-K-(i-1) + i, i)
    #print(N-K-(i-1) + i, i)
    #print(b, p)
    print(b*p % MOD)
Problem p03015 (python)

Fixed submission:
L = input()

MOD = 10**9 + 7

d = [0] * len(L)
in_d = [0] * len(L)

for i in range(len(L)):
    if i == 0:
        d[i] = 1
        in_d[i] = 2
        continue

    # (0, 0), (0, 1), (1, 0)
    if L[i] == '1':
        d[i] = (d[i-1]*3 + in_d[i-1]*1) % MOD
        in_d[i] = in_d[i-1]*2 % MOD
    else:
        d[i] = d[i-1]*3 % MOD
        in_d[i] = in_d[i-1]*1 % MOD

d[-1] = (d[-1] + in_d[-1]) % MOD
print(d[-1])

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7

L = input()

p = [0] * (len(L)+1)
p[0] = 1
for i in range(1, len(L)+1):
    p[i] = p[i-1] * 2 % MOD

ans = 1
tmp = 0
for i in range(len(L)+1):
    tmp += p[i] * 2 % MOD
ans += p[tmp]

#ans = p[len(L)-1]
#isAllBit = True
#for i in range(len(L)-1, 0, -1):
#    if isAllBit and L[i] == '1':
#        ans += p[len(L)-1-i]
#        ans %= MOD

ans += (p[len(L)-1] - 1) * 2
ans %= MOD
if L.count('1') == len(L):
    ans += (p[len(L)] - 1) * 2
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
MOD = 10**9 + 7

L = input()

p = [0] * (len(L)+1)
p[0] = 1
for i in range(1, len(L)+1):
    p[i] = p[i-1] * 2 % MOD

ans = 1
tmp  = 0
for i in range(len(L)+1):
    tmp += p[i] * 2 % MOD
ans += p[tmp]

#ans = p[len(L)-1]
#isAllBit = True
#for i in range(len(L)-1, 0, -1):
#    if isAllBit and L[i] == '1':
#        ans += p[len(L)-1-i]
#        ans %= MOD

ans =+ (p[len(L)-1] - 1) * 2
ans %= MOD
if L.count('1') == len(L):
    ans += (p[len(L)] - 1) * 2
    ans %= MOD

print(ans)
Problem p03207 (python)

Fixed submission:
N = int(input())
p = []
for i in range(N):
    p.append(int(input()))

ans = sum(p) - max(p)//2

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())                                                                                                            [0/0]
p = []
for i in range(N):
    p.append(int(input()))

ans = sum(p) - max(p)//2

print(ans)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
print(6 - a - b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(6 - a - b)
Problem p02933 (python)

Fixed submission:
n = int(input())
s = input()
print(s if not n < 3200 else "red")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
print(s if not a < 3200 else "red")