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

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u == s:
  a -=1
else:
  b -=1
print(a,b)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
a,b=map(int,input().split())
u=input()
if u = s:
  a -=1
else:
  b -=1
print(a,b)
Problem p02777 (python)

Fixed submission:
s,b = input().split()
d = {}
d[s],d[b] = [int(x) for x in input().split()]
d[input()] -= 1
print(d[s],d[b])

Buggy submission (verdict: Runtime Error):
s,b = input().split()
d = {}
d[s],d[b] = [int(x) for x in input().split()]
d[input] -= 1
print(d[s],d[b])
Problem p02785 (python)

Fixed submission:
n,k = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
m.sort()
if n<k:
  k = n
print(sum(m[0:n-k]))

Buggy submission (verdict: Runtime Error):
n,k = input().split()
m = [int(x) for x in input().split()]
m.sort()
for i in range(k):
  if len(m) == 0:
    break
  m.pop(len(m))
print(sum(m))
Problem p02781 (python)

Fixed submission:
from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0

n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

t = len(number)
t1 = len(number) - 1

if t>=k:
    ans = 0
    def calc(a,k):
        t = len(a)
        t1 = len(a) - 1
        if k<1 or t == 0:
            return 0
        else:
            if a[t1]>0:
                ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
                ans+=calc(a[:(t-1)],k-1)
            else:
                ans = 0
                ans+=calc(a[:(t-1)],k)
            if a[-k]>=1 and k == 1:
               ans+=1
            return ans
    ans += calc(number,k)
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0


t = len(number)
t1 = len(number) - 1
#if t>k:
   # ans = (9**k)*comb(t1,k) + (9**(k-1))*(number[t1]-1)*comb(t1,k-1)
#else:
 #   ans = (9**(k-1))*(number[t1]-1)*comb(t1,k-1)



ans = 0
def calc(a,k):
    t = len(a)
    t1 = len(a) - 1
    if k<1:
        return 0
    else:
        if a[t1]>0: #and t>1:
            ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
        #elif a[t1]>0 and t==1:
           # ans = a[t1]
        else:
            ans = 0
        ans+=calc(a[:(t-1)],k-1)
        return ans
ans += calc(number,k)
if ans>=0:
    if number[-k]>=1:
        print(ans+1)
    else:
        print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
number = []
while n:
    number.append(n%10)
    n//=10

from math import factorial
def comb(n,k):
    if n>=k:
        return int(factorial(n)/(factorial(k)*factorial(n-k)))
    else:
        return 0


t = len(number)
t1 = len(number) - 1
#if t>k:
   # ans = (9**k)*comb(t1,k) + (9**(k-1))*(number[t1]-1)*comb(t1,k-1)
#else:
 #   ans = (9**(k-1))*(number[t1]-1)*comb(t1,k-1)



ans = 0
def calc(a,k):
    t = len(a)
    t1 = len(a) - 1
    if k<1:
        return 0
    else:
        if a[t1]>0: #and t>1:
            ans = (9**k)*comb(t1,k) + (9**(k-1))*(a[t1]-1)*comb(t1,k-1)
        #elif a[t1]>0 and t==1:
           # ans = a[t1]
        else:
            ans = 0
        ans+=calc(a[:(t-1)],k-1)
        return ans
ans += calc(number,k)
if ans>0:
    if number[-k]>=1:
        print(ans+1)
    else:
        print(ans)
else:
    print(0)
Problem p02897 (python)

Fixed submission:
n = int(input())
print((n-n//2)/n)

Buggy submission (verdict: Runtime Error):
n = int(input())
print((n-n//2)/n))
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm(x, y):
    return (x * y) // gcd(x, y)

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=int(listA[0])
b=int(listA[1])

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

try:
    listA = list(input().split())
    #listA<-[1,2,2,3,1]
    #print(listA)
    #ここに逐次処理を書けばいいと思う。
except:
    quit();
    #または、quit(),os.exit()をして止める。

a=int(listA[0])
b=int(listA[1])

print(lcm(a, b))
Problem p03017 (python)

Fixed submission:
N,A,B,C,D = map(int,input().split())
S = input()
M = max(C,D)
A -= 1
B -= 1
C -= 1
D -= 1


for i in range(A,max(C,D)):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
if  C < D:
    print("Yes")
elif D <= C:
    for i in range(B-1,D):
        if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
            print("Yes")
            quit()
    print("No")

Buggy submission (verdict: Runtime Error):
N,A,B,C,D = map(int,input().split())
S = input()
M = max(C,D)
C = S
S = S[A-1:M]

for i in range(len(S) - 1):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
S = C[B:M]
for i in range(len(S) - 2):
    if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
        print("Yes")
        quit()
if C <= B:
    print("Yes")
elif  C < D:
    print("Yes")
elif D <= C:
    print("No")
Problem p03291 (python)

Fixed submission:
S = input()
dp = [[0 for i in range(4)] for i in range(len(S)+1)]
MOD = 10**9+7
dp[0][3] = 1
for i in range(len(S)):
    if S[i] == '?': k = 3
    else: k = 1
    for _ in range(k):
        dp[i+1][0] += dp[i][0] 
        dp[i+1][1] += dp[i][1] 
        dp[i+1][2] += dp[i][2] 
        dp[i+1][3] += dp[i][3] 
    if S[i] == 'A':
        dp[i+1][0] +=  dp[i][3]
    elif S[i] == 'B':
        dp[i+1][1] +=  dp[i][0]
    elif S[i] == 'C':
        dp[i+1][2] += dp[i][1]
    else:
        dp[i+1][0] += dp[i][3]
        dp[i+1][1] += dp[i][0]
        dp[i+1][2] += dp[i][1]
    for j in range(4):
        if dp[1+i][j] > MOD: dp[i+1][j] %= MOD
print(dp[len(S)][2]%MOD)

Buggy submission (verdict: Runtime Error):
S = input()
dp = [[0 for i in range(4)] for i in range(len(S)+1)]
MOD = 10**9+7
dp[0][3] = 1
for i in range(len(S)):
    if S[i] == '?': k = 3
    else: k = 1
    for _ in range(k):
      for l in range(4)
        dp[i+1][l] += dp[i][l] 
    if S[i] == 'A':
        dp[i+1][0] +=  dp[i][3]
    elif S[i] == 'B':
        dp[i+1][1] +=  dp[i][0]
    elif S[i] == 'C':
        dp[i+1][2] += dp[i][1]
    else:
        dp[i+1][0] += dp[i][3]
        dp[i+1][1] += dp[i][0]
        dp[i+1][2] += dp[i][1]
    for j in range(4):
        if dp[i][j] > MOD: dp[i][j] %= MOD
print(dp[len(S)][2]%MOD)
Problem p03745 (python)

Fixed submission:
N = int(input())
cnt = 0
tmp = ''
M = list(map(int,input().split()))
L = []
for x in M:
    if x == tmp:
        pass
    else:
        L.append(x)
    tmp = x
    

    
while True:
    try: 
        if L[0] <L[1]>L[2] or L[0] > L[1] <L[2]:
            a0=L.pop(0)
            a1=L.pop(0)
            cnt += 1
        else:
            L.pop(0)
    except:
        break
#    print(L)
print(1+cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
cnt = 0
L = list(map(int,input()..split()))
for i in range(N-2):
  if (L[i] > L[i+1] < L[i+2]) or (L[i] < L[i+1] > L[i+2]):
    cnt += 1
print(cnt)
Problem p03072 (python)

Fixed submission:
# B - Great Ocean View
# https://atcoder.jp/contests/abc124/tasks/abc124_b


n = int(input())
points = list(map(int, input().split()))
ans = 1
need_height = points[0]


for i in range(1, n):
    current = points[i]
    if need_height <= current:
        ans += 1
        need_height = current


print(ans)

Buggy submission (verdict: Runtime Error):
# B - Great Ocean View
# https://atcoder.jp/contests/abc124/tasks/abc124_b


n = int(input())
points = list(map(int, input().split()))
# points = [1,2,3,4,5]

# if len(points) < 3:
#     first, second = points[0], points[1]
need_height = max(points[0], points[1])
ans = 1
for i in range(1, len(points)):
    pre_spot = points[i-1]
    if need_height <= points[i] and pre_spot <= points[i]:
        ans += 1

        
print(ans)
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
h = input()
if s == h and a >= 1:
    a -= 1
if t == h and b >= 1:
    b -= 1
print(a, b)

Buggy submission (verdict: Runtime Error):
s, t = input().split()
a, b = map(int, input().split())
h = input()
if s == h and a >= 1:
  a -= 1
if t == h and b >= 1:
  b -= 1
print a, b
Problem p02790 (python)

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

if a < b:	print(str(a) * b )
else:	print(str(b) * a )

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

if a < b:	print(str(a+'0') * b )
else:	print(str(b+'0') * a )
Problem p02777 (python)

Fixed submission:
s, t = map(str,input().split())
a, b = map(int,input().split())
u = input()
 
if s == u:
	print(a-1, b)
else:
	print(a, b-1)

Buggy submission (verdict: Runtime Error):
print(S)
Problem p02779 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

# N=6
# A = [4,1,3,1,6,2]


if N == len(set(A)):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(int,input().split())

if N != len(set(A)):
    print('YES')
else:
    print('NO')
Problem p02777 (python)

Fixed submission:

S, T = input().split()
A, B = map(int, input().split())
U = input()
if S==U:
  print("{} {}".format(A-1,B))
else:
  print("{} {}".format(A,B-1))

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
A, B = map(int, input().split())
U = input()
if S=U:
  print("{} {}".format(S-1,T))
else:
  print("{} {}".format(S,T-1)

Buggy submission (verdict: Runtime Error):
aa
Problem p03986 (python)

Fixed submission:
a = input()
s,t = 0,0
for i in a:
    if i == "S":
        s += 1
    else:
        if s==0:
            t += 1
        else:
            s -=1
print(s+t)

Buggy submission (verdict: Runtime Error):
a = input()
b = a.replace("ST","")
if a[0] =="S" and b[-1] =="T":
    print(0)
while "ST" in b:
    b = b.replace("ST","")
print(len(b))
Problem p02785 (python)

Fixed submission:
import numpy as np
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
a = list(np.zeros(K))
if N - K>=0:
    b = list(np.ones(N-K))
    a.extend(b)
else:
    a = list(np.zeros(N))

print(int(np.dot(a, li)))

Buggy submission (verdict: Runtime Error):
#入力
N, K = map(int, input().split())
li = list(map(int,input().split()))
list.sort(li, reverse = True)

#出力
for i in range(K):
    li[i] = 0

print(sum(li))
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]-1]
  if i < N - 1 and A[i] == A[i+1]-1:
    ans += C[A[i]-1]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
for i in range(N):
  ans += B[A[i]]
  if A[i]+1 == A[i+1]:
    ans += C[A[i]]

print(ans)
Problem p03013 (python)

Fixed submission:
from functools import lru_cache
import sys
sys.setrecursionlimit(10**6)


@lru_cache(maxsize=1000000)
def get_ways(n):
    if n == 1 or n == 2:
        return n
    elif n == 0:
        return 1
    elif n == -1:
        return 0
    else:
        return get_ways(n - 2) + get_ways(n - 1)


N, M = map(int, input().split())
ans = 1
tmp = 0
for i in range(M):
    a = int(input())
    ans *= get_ways(a - tmp - 1)
    tmp = a + 1
ans *= get_ways(N - tmp)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache


@lru_cache(maxsize=10000000)
def get_ways(n):
    if n == 1 or n == 2:
        return n
    elif n == 0:
        return 1
    elif n == -1:
        return 0
    else:
        return get_ways(n - 2) + get_ways(n - 1)


N, M = map(int, input().split())
ans = 1
tmp = 0
for i in range(M):
    a = int(input())
    ans *= get_ways(a - tmp - 1)
    tmp = a + 1
ans *= get_ways(N - tmp)
print(ans % 1000000007)

Buggy submission (verdict: Runtime Error):
from functools import lru_cache


@lru_cache(maxsize=100000)
def get_ways(n):
    if n == 1 or n == 2:
        return n
    elif n == 0:
        return 1
    elif n == -1:
        return 0
    else:
        return get_ways(n - 2) + get_ways(n - 1)


N, M = map(int, input().split())
ans = 1
tmp = 0
for i in range(M):
    a = int(input())
    ans *= get_ways(a - tmp - 1)
    tmp = a + 1
ans *= get_ways(N - tmp)
print(ans % 1000000007)
Problem p03075 (python)

Fixed submission:
L = [int(input()) for i in range(len("abcde"))]
k = int(input())

for i in range(4):
    for j in range(i+1, 5):
        if abs(L[i] - L[j]) > k:
            print(":(")
            break
    else:
        continue
    break
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
L = [int(input()) for i in range(len("abcde"))]
k = int(input())

for i in range(5):
  for j in range(i, 5):
    if abs(L[i] - L[i+j+1]) > k:
      print(":(")
      break
  else:
    continue
  break
else:
  print("Yay!")
Problem p03209 (python)

Fixed submission:
import math


# def burger_generator(n):
#     if n == 0:
#         return int("101", 2)
#     else:
#         lt = burger_generator(n-1)
#         x1 = 1 + (lt << 1)
#         length = int(math.log2(x1)) + 1
#         x1 = x1 + (lt << length + 1)
#         length = int(math.log2(x1)) + 1
#         return x1 + (1 << length)


def f(N, X):
    if X == 1:
        # print(1)
        return 0 if not N == 0 else 1
    elif X <= 1 + size[N - 1]:
        # print(2)
        return f(N - 1, X - 1)
    elif X == 2 + size[N - 1]:
        # print(3)
        return patty[N - 1] + 1
    elif X <= 2 + 2 * size[N - 1]:
        # print(4)
        return patty[N - 1] + 1 + f(N - 1, X - 2 - size[N - 1])
    elif X == 3 + 2 * size[N - 1]:
        # print(5)
        return 2 * patty[N - 1] + 1


N, X = map(int, input().split())
# burger = format(burger_generator(N), "b")
# print(burger[-K:].count("0"))
size, patty = [1], [1]
for i in range(N):
    size.append(size[i] * 2 + 3)
    patty.append(patty[i] * 2 + 1)
# for i in range(N):
#     print(size)
# for i in range(N):
#     print(patty)
print(f(N, X))

Buggy submission (verdict: Runtime Error):
import math


# def burger_generator(n):
#     if n == 0:
#         return int("101", 2)
#     else:
#         lt = burger_generator(n-1)
#         x1 = 1 + (lt << 1)
#         length = int(math.log2(x1)) + 1
#         x1 = x1 + (lt << length + 1)
#         length = int(math.log2(x1)) + 1
#         return x1 + (1 << length)


def f(N, X):
    if X == 1:
        return 0
    if 1 < X <= 1 + size[N - 1]:
        return f(N - 1, X - 1)
    if X == 2 + size[N]:
        return patty[N - 1] + 1
    if 2 + size[N - 1] < X <= 2 + 2 * size[N - 1]:
        return patty[N - 1] + 1 + f(N - 1, X - 2 - size[N - 1])
    if X == 3 + 2 * size[N - 1]:
        return 2 * patty[N - 1] + 1


N, X = map(int, input().split())
print(N, X)
# burger = format(burger_generator(N), "b")
# print(burger[-K:].count("0"))
size, patty = [1], [1]
for i in range(N):
    size.append(size[i] * 2 + 3)
    patty.append(patty[i] * 2 + 1)

print(f(N, X))
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = str(input())

if a >= 3200:
    print(s)
else:
    print(red)
Problem p02989 (python)

Fixed submission:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *d = map(int, read().split())
d.sort()

ans = d[N // 2] - d[N // 2 - 1]
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = readline().decode().strip()
K = int(readline())
cnt = 0
ans = 0
for i in N:
    if len(N) == 1:
        ans = N[0]
        break
    if i == '1':
        cnt += 1
        continue
    else:
        if int(i) * 5000 * 10 ** 12 + cnt >= K:
            ans = i
            break
        else:
            ans = N[N.find(i) + 1]
            break

print(ans)
Problem p03272 (python)

Fixed submission:
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, i = map(int, readline().split())
print(N - i + 1)

Buggy submission (verdict: Runtime Error):
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, i = map(int, readline())
print(N - i + 1)
Problem p02777 (python)

Fixed submission:
import sys

S, T = sys.stdin.readline().split()
A, B = [int(x) for x in sys.stdin.readline().split()]
U = sys.stdin.readline().strip()

if U == S:
    A -= 1
elif U == T:
    B -= 1
print(' '.join([str(x) for x in [A, B]]))

Buggy submission (verdict: Runtime Error):
from typing import *
import math
import collections, itertools, functools, heapq, bisect

def main():
    S, T = input().split()
    A, B = [int(x) for x in input().split()]
    U = input().strip()
    
    if U == S:
        A -= 1
    elif U == T:
        B -= 1
    print(' '.join([str(x) for x in [A, B]]))


if __name__ == '__main__':
    main()
Problem p02777 (python)

Fixed submission:
a,b=input().split()
A,B=map(int,input().split())
c=input()
if a==c:
  A=A-1
else:
  B=B-1
print(A,B)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
i=0
c="YES"   ##ここ文字列だからくおーてーしょんいるの注意
for i in range(a-1):
 j=i+1
 for j in range (a-1):
    if b[i]==b[j]:
    c="NO" ##ここも
print(c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=list(map(int,input().split()))
i=0
j=0
c="YES"  ##ここ文字列だからくおーてーしょんいるの注意
for i in range(a-1):
  for j in range (a-1):
    if b[i]==b[j]
    c="NO" 
print(c)
Problem p02819 (python)

Fixed submission:
a=int(input())
if a==2:
  print(a)
else:
  sosuu=1
  a=a-1
  while sosuu==1:
    a+=1
    b=2
    while a!=b:
      if a%b==0:
        sosuu=1
        break
      else:
        b+=1
        sosuu=0
  print(a)

Buggy submission (verdict: Runtime Error):
a=int(input())
if a==2:
  print(a)
else:
  sosuu=1
  a=a-1
  while sosuu==1:
    a+=1
    b=2
    while a!=b:
      sosuu=0
      if a%b==0:
        sosuu=1//割り切れた
        break
      else:
        b+=1
  print(a)
Problem p02777 (python)

Fixed submission:
S, T = input().split()
A,B = map(int,input().split())
U = input()
if U == S:
  A -= 1
  print(A,B)
else:
  B -= 1
  print(A,B)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,K = map(int,input().split())
P = list(map(int,input().split()))
total = 0
for i in range(N-K+1):
  A = P[i:i+K]
  total = sum(A)
  if total>0:
    B = A
np.array(B)
C = (B+np.array([1]))/np.array([2])
print(sum(C))
Problem p02777 (python)

Fixed submission:
s, t = map(str, input().split())
a, b = map(int, input().split())
u = str(input())

if u == s:
    print(a-1, b)
elif u == t:
    print(a, b-1)
else:
    print(a, b)

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

total_expects = []
# 1回のサイコロについて
for i in range(0, n):    
    # 1個のサイコロの期待値リスト
    expect = [q * (1 / p[i]) for q in range(1, p[i]+1)]
    total_expects.append(sum(expect))

print(max([sum(total_expects[i:i+k]) for i in range(0, k)]))
Problem p02951 (python)

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

c1 = b
c2 = c
cap = a - b

c1 = c1 + cap
c2 = c2 - cap

if c2 < 0:
    c2 = 0
print(c2)

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
h = list(map(int, input().split()))

h = np.array(h)

for i in range(len(h)-1):
   if h[i] < h[i+1]:
       h[i+1] -= 1
np.diff(h-1, n=1)

minus = [i for i in np.diff(h-1, n=1) if i < 0]

if len(minus) > 0:
    print('No')
else:
    print('Yes')
Problem p03015 (python)

Fixed submission:
L=input()
length=len(L)
inf=10**9+7
a=2
b=1
for i in range(1,len(L)):
	if L[i]=="0":
		b=b*3%inf
		continue
	else:
		b=(b*3+a)%inf
		a=a*2%inf
print((a+b)%inf)

Buggy submission (verdict: Runtime Error):
import itertools

L = int(input(), 2)

count = 1
# (a, b)の組み合わせ
#products = itertools.product(range(L+1), range(L+1))
products = list(itertools.combinations(range(L+1), 2))
for p in products:
    s = p[0] + p[1]
    if s <= L:
        # XOR
        if s == (p[0] ^ p[1]):
            count += 1
            if p[0] != p[1]:
                count += 1

print(count % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import itertools

L = int(input(), 2)

count = 0
# (a, b)の組み合わせ
products = itertools.product(range(L+1), range(L+1))
for p in products:
    s = p[0] + p[1]
    if s <= L:
        # XOR
        if s == (p[0] ^ p[1]):
            count += 1
            # a, bが異なる値ならば、組み合わせ数+1
            #if a != b:
            #    count += 1

#print(count)
print(count % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
L = int(input(), 2)
count = 0
# (a, b)の組み合わせ
products = itertools.product(range(L+1), range(L+1))
for p in products:
    s = p[0] + p[1]
    if s <= L:
        # XOR
        if s == (p[0] ^ p[1]):
            count += 1

print(count % (10**9 + 7))
Problem p03018 (python)

Fixed submission:
import re

s = input()
s = s.replace('BC', 'D')

count = 0
count_a = 0
for string in s:
    if string == 'A':
        count_a += 1
    elif string == 'D':
        count += count_a
    else:
        count_a = 0

print(count)

Buggy submission (verdict: Runtime Error):
import import re

s = str(input())
find_s = 'ABC'
count = 0
while True:
    s_n = re.sub(r"ABC", "BCA", s)
    l_find = len(re.findall(r"ABC", s))
    count += l_find

    if l_find == 0:
        print(count)
        break
    else:
        s = s_n
Problem p03042 (python)

Fixed submission:
S = str(input())

if 12 >= int(S[0:2]) >= 1:

    if 12 >= int(S[2:4]) >= 1:
        print("AMBIGUOUS")

    else:
        print("MMYY")

else:
    if 12 >= int(S[2:4]) >= 1:
        print("YYMM")

    else:
        print("NA")

Buggy submission (verdict: Runtime Error):
S = input()

if int(S[0:2]) <= 12 and int (S[0:2]) > 0:
    if int(S[2:4]) > 0 and int(S[2:4]) <= 12:
        print("AMBIGUOUS")
    elif int(S[2:4]) > 0:
        print("MMYY")
        
elif int(S[2:4]) <= 12 and int(S[2:4]) > 0:
    if int(S[0:2]) > 0 and int(S[0:2]) <= 12:
        print("AMBIGUOUS")    
    elif int(S[0:2]) > 0:
        print("YYMM")

elif int(S[0:2]) >= 13 and int(S[0:2]) == 0:
    if int(S[2:4]) == 0:
        print("NA")

elif int(S[2:4]) >= 13 and int(S[2:4]) == 0
    if int(S[0:2]) == 0:
        print("NA")

Buggy submission (verdict: Runtime Error):
S = input()

if int(S[0:2]) <= 12 and int (S[0:2]) > 0:
    if int(S[2:4]) > 0 and int(S[2:4]) <= 12:
        print("AMBIGUOUS")
    elif int(S[2:4]) > 0:
        print("MMYY")
        
elif int(S[2:4]) <= 12 and int(S[2:4]) > 0:
    if int(S[0:2]) > 0 and int(S[0:2]) <= 12:
        print("AMBIGUOUS")    
    elif int(S[0:2]) > 0:
        print("YYMM")

elif int(S[0:2]) >= 13 and int(S[0:2]) == 0:
    if int(S[2:4]) == 0:
        print("NA")

elif int(S[2:4]) >= 13: and int(S[2:4]) == 0
    if int(S[0:2]) == 0:
        print("NA")
Problem p02777 (python)

Fixed submission:
st = input().split()
ab = input().split()
u = input()
if u == st[0]:
 print(int(ab[0])-1,int(ab[1]))
else:
 print(int(ab[0]),int(ab[1])-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
tmp = input().split()
length = len(tmp)
length2 = len(list(set(tmp)))
if length == length2 :
  print("YES")
else:
  print("NO")
Problem p02777 (python)

Fixed submission:
s,t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
  a -= 1
else:
  b -= 1
print(a,b)

Buggy submission (verdict: Runtime Error):
s,t = input().split()
a, b = map(int, input().split())
u = input()
if s == u:
  a -= 1
 else:
  b -= 1
 print(a,b)