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

Fixed submission:
S = input()
T = input()
for i in range(len(S)):
    if S == T:
        print("Yes")
        exit()
    else:
        S = S[-1]+S[:-1]
print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
if S == T or S.reverse == T:
    print("Yes")
else:
    print("No")
Problem p03331 (python)

Fixed submission:
N = list(input())
if int(''.join(N))%10 != 0:
    res = 0
    for i in range(len(N)):
        res += int(N[i])
else:
    res = 10
print(res)

Buggy submission (verdict: Runtime Error):
N = list(input())
if N%10 != 0:
    res = 0
    for i in range(len(N)):
        res += int(N[i])
else:
    res = 10
print(res)
Problem p03393 (python)

Fixed submission:
s = input()
if len(s) < 26:
    for i in range(26):
        c = chr(ord("a")+i)
        if c not in s:
            print(s+c)
            exit()
else:
    for i in reversed(range(1,26)):
        if s[i-1] < s[i]:
            s1 = s[0:i-1]
            for j in range(26):
                c = chr(ord("a")+j)
                if c > s[i-1] and c not in s1:
                    print(s1+c)
                    exit()
    print(-1)

Buggy submission (verdict: Runtime Error):
s =i nput()
if len(s) < 26:
    for i in range(26):
        c = chr(ord("a")+i)
        if c not in s:
            print(s+c)
            exit()
else:
    for i in reversed(range(1,26)):
        if s[i-1] < s[i]:
            s1 = s[0:i-1]
            for j in range(26):
                c = chr(ord("a")+j)
                if c > s[i-1] and c not in s1:
                    print(s1+c)
                    exit()
    print(-1)

Buggy submission (verdict: Runtime Error):
S = list(input())
c = set(S)
all_ar = list("abcdefghijklmnopqrstuvwxyz")
if len(c) == 26:
    print(-1)
    exit()
for i in range(26):
    if not all_ar[i] in c:
        print(''join(S)+all_ar[i])
        exit()
Problem p03416 (python)

Fixed submission:
A,B = map(int, input().split())
cnt = 0
for i in range(A,B+1):
    if str(i) == (str(i))[::-1]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
cnt = 0
for i in range(A,B+1):
    if str(i) == str(i).reverse():
        cnt += 1
print(cnt)
Problem p03470 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
print(len(set(A)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in len(N):
    A.append(int(input()))
print(len(set(A)))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for i in len(N):
    A.append(int(input))
print(len(set(A)))
Problem p03474 (python)

Fixed submission:
A,B = map(int,input().split())
S = list(input())
if S[A] == '-' and S.count('-') == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
S = list(input())
for i in range(A):
    if not 0 <= int(S[i]) <= 9:
        print("No")
        exit()
if S[A] != "-":
    print("No")
    exit()
for i in range(A+1,B):
    if not 0 <= int(S[i]) <= 9:
        print("No")
        exit()
print("Yes")
Problem p03547 (python)

Fixed submission:
S = list(map(str, input().split()))
if S[0] == S[1]:
    print("=")
    exit()
if S == sorted(S):
    print("<")
else:
    print(">")

Buggy submission (verdict: Runtime Error):
S = list(map(str, input().split()))
if S == S.soreted():
    print("<")
else:
    print(">")
Problem p03563 (python)

Fixed submission:
R = int(input())
G = int(input())
print(2*G-R)

Buggy submission (verdict: Runtime Error):
R,G = map(int, input().split())
print(2*G-R)
Problem p03623 (python)

Fixed submission:
x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
    print("A")
else:
    print("B")

Buggy submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int, input().split())), reverse = True)
l = 0
ln = []
for a in A:
    if l == a:
        ln.append(a)
        l = 0
    else:
        l = a
    if len(ln) == 2:
        break
if len(ln) == 2:
    print(ln[0]*ln[1])
else:
    print(0)
Problem p03624 (python)

Fixed submission:
S = list(input())
All = list("abcdefghijklmnopqrstuvwxyz")
res = list(set(S) ^ set(All))
if len(res) > 0:
    print(res[0])
else:
    print("None")

Buggy submission (verdict: Runtime Error):
S = list(input())
All = list("abcdefghijklmnopqrstuvwxyz")
res = list(set(S) ^ set(All))
print(res[0])
Problem p03687 (python)

Fixed submission:
S = input()
res = len(S)
kind_all = set(S)
for i in kind_all:
    temp = S.split(i)
    cnt = 0
    for j in temp:
        cnt = max(cnt,len(j))
    res = min(res,cnt)
print(res)

Buggy submission (verdict: Runtime Error):
S = list(input())
res = len(S)
kind_all = set(S)
for i in kind_all:
    temp = S.split(i)
    cnt = 0
    for j in temp:
        cnt = max(cnt,len(j))
    res = min(res,cnt)
print(res)
Problem p03721 (python)

Fixed submission:
N,K = map(int, input().split())
A = []
for i in range(N):
    a,b = map(int, input().split())
    A.append((a,b))
A.sort()
for i in range(N):
    K -= A[i][1]
    if K <= 0:
        print(A[i][0])
        exit()

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
A = []
ruiseki = [0]
for i in range(N):
    a,b = map(int, input().split())
    A.append(a)
    ruiseki.append(ruiseki[i]+b)
K = ruiseki[-1]-K+1
for i in range(1,N+1):
    if K >= ruiseki[i]:
        n = i
        break
print(A[n+1])
Problem p03738 (python)

Fixed submission:
A = int(input())
B = int(input())
if A > B:
    print("GREATER")
elif A == B:
    print("EQUAL")
else:
    print("LESS")

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
if A > B:
    print("GREATER")
elif A == B:
    print("EQUAL")
else:
    print("LESS")
Problem p03807 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
if sum(A)%2:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())
if sum(A)%2:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(input())
if sum(A)%2:
    print("NO")
else:
    print("YES")
Problem p02660 (python)

Fixed submission:
import math
from sys import exit

n=int(input())
primes = {}
i = 2
ans = 0
square = math.floor(math.sqrt(n))

if n == 1:
    print(0)
    exit()

# while True:
#     if n == 1 or i > square:
#         break
#     if n % i == 0:
#         if i not in primes.keys():
#             primes[i] = 1
#         else:
#             primes[i] += 1
#         n = n // i
#     else:
#         if i == 2:
#             i += 1
#         else:
#             i += 2
#         continue

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

primes = factorization(n)
if len(primes) == 0:
    print(1)
    exit()

for k,v in primes:
    base = v * 2
    root = math.floor(math.sqrt(base))
    if root * (root + 1) > base:
        root -= 1
    ans += root

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from sys import exit

n=int(input())
primes = {}
i = 2
ans = 0
square = math.floor(math.sqrt(n))

if n == 1:
    print(0)
    exit()

while True:
    if i > square:
        break
    if n % i == 0:
        if i not in primes.keys():
            primes[i] = 1
        else:
            primes[i] += 1
        n = n // i
    else:
        if i == 2:
            i += 1
        else:
            i += 2
        continue

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])

#     if temp!=1:
#         arr.append([temp, 1])

#     if arr==[]:
#         arr.append([n, 1])

#     return arr

# primes = factorization(n)
if len(primes) == 0:
    print(1)
    exit()

for k,v in primes:
    base = v * 2
    root = math.floor(math.sqrt(base))
    if root * (root + 1) > base:
        root -= 1
    ans += root

print(ans)
Problem p02690 (python)

Fixed submission:
x = int(input())
a = []

for i in range(500):
    num = i ** 5
    a.append(num)

for i in range(500):
    for j in range(i, 500):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
            break
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
            break
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)
            break

print(ans)

Buggy submission (verdict: Runtime Error):
x = int(input())
a = []

for i in range(100):
    num = i ** 5
    a.append(num)

for i in range(100):
    for j in range(i, 100):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)

print(ans)
Problem p02811 (python)

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

if k * 500 >= x:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math

def count_index(list, k):
    count = 0
    for i in range(k):
        if (list[i] < list[k]):
            count = count + 1
    return list[k]-count-1

n = int(input())-1
p = list(map(int,input().split()))
q = list(map(int,input().split()))

a = (p[0]-1) * math.factorial(n)+1
b = (q[0]-1) * math.factorial(n)+1

for i in range(1,n):
    a = a + count_index(p, i) * math.factorial(n-i)
    b = b + count_index(q, i) * math.factorial(n-i)

ans = a-b
print(abs(ans))
Problem p02995 (python)

Fixed submission:
from fractions import gcd
a,b,c,d = map(int,input().split())

lcm = c*d//gcd(c,d)
print(b - a + 1 - b//c + (a-1)//c - b//d + (a-1)//d + b//lcm - (a-1)//lcm)

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b,c,d = map(int,input().split())

lcm = c*d/gcd(c,d)
print(b - a + 1 - int(b/c) + int((a-1)/c) - int(b/d) + int((a-1)/d) + int(b/lcm) - int((a-1)/lcm))
Problem p03164 (python)

Fixed submission:
def main():
    N,W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]

    INF = float('inf')
    dp = [list([INF] * (10 ** 5 + 101)) for _ in range(N)]
    dp[0][wv[0][1]] = wv[0][0]
    dp[0][0] = 0

    for i in range(1,N):
        w = wv[i][0]
        v = wv[i][1]
        for j in range(10 ** 5 + 1):
            sum_v = j + v
            if dp[i-1][j] + w <= W:
                dp[i][sum_v] = min(dp[i-1][sum_v], dp[i-1][j] + w)
            dp[i][j] = min(dp[i][j], dp[i-1][j])
    
    max_v = 0
    for i in range(10 ** 5 + 1):
        if dp[N-1][i] <= W:
            max_v = i
    print(max_v)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N,W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]

    dp = [list([0] * (W+1)) for _ in range(N)]
    dp[0][wv[0][0]] = wv[0][1]

    for i in range(1,N):
        w = wv[i][0]
        if W < w:
            continue
        v = wv[i][1]
        for j in range(W+1):
            sum_w = j + w
            if sum_w <= W:
                dp[i][sum_w] = max(dp[i-1][sum_w], dp[i-1][j] + v)
            dp[i][j] = max(dp[i][j],dp[i-1][j])

    print(max(dp[-1]))

if __name__ == "__main__":
    main()
Problem p02658 (python)

Fixed submission:
a=1
n=input()
s=list(map(int,input().split()))

count=0
if 0 in s:
  print(0)
  count=1
else:
  a=1
  for i in s:
    a*=i
    if a>10**18:
      print(-1)
      break
if a<=10**18 and count!=1:
  print(a)

Buggy submission (verdict: Runtime Error):
a=1
n=input()

s=input()
for i in range(len(s)):
  if i%2==1:
    continue
  a*=int(s[i])
if a>10**18:
  print(-1)
else:
  print(a)
Problem p02660 (python)

Fixed submission:
import numpy as np
import sys
A=a=int(input())
count=2
samenumcount=0
y=[]
 
if A==1:
    print(0)
    sys.exit()
 
while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
if A!=1:
    y.append(A)
y.sort()
count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1
 
if count2==0:
    count2+=1

print(count2)

Buggy submission (verdict: Runtime Error):
import numpy as np
A=a=int(input())
count=2
samenumcount=0
y=[]

if A==1:
    print(0)
    sys.exit()

while A!=1 and count<np.sqrt(a):
    if A%count==0:
        samenumcount+=1
        y.append(count**samenumcount)
        A=A/count
    else:
        count+=1
        samenumcount=0
y.sort()

count2=0
for i in y:
    if a==1:
      break
    if a%i==0:
        a=a/i
        count2+=1

if count2==0:
    print(1)
else:
    print(count2)
Problem p02684 (python)

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

count=0
k=1
countlist={}
#countlist[1]=A[0]
count=1
while True:    
    k=A[k-1]
    
    if k in countlist:
        cycle=count-countlist[k]
        rest=K-count
        move=rest%cycle
        for i in range(min(rest,move)):
            k=A[k-1]
        print(k)
        break
    
    countlist[k]=count
    
    if count==K:
        print(k)
        break
    
    count+=1

Buggy submission (verdict: Runtime Error):
import sys

N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K+1):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
      count+=1
      if count==K+1:
        print(b)
        sys.exit()
    print(b)
    break
  a[b]=count
  if count==K+1:
    print(b)
    break

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K+1):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
      count+=1
      if count==K+1:
        break
    print(b)
    break
  a[b]=count
  if count==K+1:
    print(b)
    break

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=1
while(True):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
    print(b)
    break
  a[b]=count
if count==K+1:
  print(b)
  break

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K+1):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    #print(a)
    #print(b)
    #print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
    print(b)
    break
  a[b]=count
  if count==K+1:
    print(b)
    break

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
N=list(map(int,input().split()))
a={}
 
b=1
a[1]=1
count=0
while(count<=K):
  count+=1
  b=N[b-1]
  #print(b)
  if b in a:
    print(a)
    print(b)
    print(count)
    cycle=count-a[b]
    rest=K-count+1
    ans=rest%cycle
    for i in range(ans-1):
      b=N[b-1]
    print(b)
    break
  a[b]=count

print(b)
Problem p02690 (python)

Fixed submission:
X=int(input())
k=breaknum=1
while(True):
    for n in range(-118,120):
        x=n**5-(n-k)**5
        if X==x:
            print("{0} {1}".format(n,n-k))
            breaknum=-1
            break
    k+=1
    if breaknum==-1:
        break

Buggy submission (verdict: Runtime Error):
X=int(input())
while(True):
    k=breaknum=0
    for n in range(-118,120):
        x=n**5-(n-k)**5
        if X==x:
            print(n**5)
            breaknum=-1
            break
    k+=1
    if breaknum=-1:
        break
Problem p02696 (python)

Fixed submission:
A,B,N=map(int,input().split())
def f(x):
  return int(A*x/B)-A*int(x/B)

print(f(min(N,B-1)))

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,B/A)]))

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))]))

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
import numpy as np
print(max([int(A*x/B)-A*int(x/B) for x in np.arange(0,N+1,max((B/A),1))])
Problem p02705 (python)

Fixed submission:
import numpy as np
print(float(input())*2*np.pi)

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  INF = float('inf')
  A = [(i+1, a) for i, a in enumerate(map(int, input().split()))]
  A = sorted(A, key=lambda x: x[1], reverse = True)
 
  dp = [[-INF] * (N+1) for _ in range(N+1)]
  dp[0][0] = 0
 
  for s in range(1, N+1):
    for l in range(s+1):
      r = s - l
      dp[l][r] = max(dp[l-1][r] + A[s-1][1] * abs(A[s-1][0]-l), dp[l][r-1] + A[s-1][1] * abs(N-r+1-A[s-1][0]))
    
  ans = 0
  for m in range(N):
    if(dp[m][N-m] > ans):
      ans = dp[m][N-m]
    
  print(ans)
 
main()

Buggy submission (verdict: Runtime Error):
N=int(input())
actlist=list(map(int,input().split()))
As = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]

left=1
right=N
sumnum=0

for i in As:
    move=0
    moveleft=abs(i[1]+1-left)
    moveright=abs(i[1]+1-right)
    if moveleft>moveright:
        move=moveleft
        left+=1
    else:
        move=moveright
        right=right-1
    sumnum+=move*i[0]
    
print(sumnum+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
actlist=list(map(int,input().split()))
As = sorted([(A, i) for i, A in enumerate(actlist)])[::-1]
 
left=1
right=N
sumnum=0
 
for i in As:
    move=0
    moveleft=abs(i[1]+1-left)
    moveright=abs(i[1]+1-right)
    if moveleft>moveright:
        move=moveleft
        left+=1
    else:
        move=moveright
        right=right-1
    sumnum+=move*i[0]
    
print(sumnum+1)

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

num=[0]*N
for i in A:
    num[i-1]+=1

for j in range(len(num)):
    print(num[j])
Problem p02709 (python)

Fixed submission:
def main():
  N = int(input())
  INF = float('inf')
  A = [(i+1, a) for i, a in enumerate(map(int, input().split()))]
  A = sorted(A, key=lambda x: x[1], reverse = True)
 
  dp = [[-INF] * (N+1) for _ in range(N+1)]
  dp[0][0] = 0
 
  for s in range(1, N+1):
    for l in range(s+1):
      r = s - l
      dp[l][r] = max(dp[l-1][r] + A[s-1][1] * abs(A[s-1][0]-l), dp[l][r-1] + A[s-1][1] * abs(N-r+1-A[s-1][0]))
    
  ans = 0
  for m in range(N):
    if(dp[m][N-m] > ans):
      ans = dp[m][N-m]
    
  print(ans)
 
main()

Buggy submission (verdict: Runtime Error):
import itertools

N=int(input())
actlist=list(map(int,input().split()))
alllist=list(itertools.permutations(range(1,N+1)))

count=1

hapsum=0
for i in range(N-1):
    for j in (i+1,N):
        maxnum=0
        for m,n in zip(alllist[i],alllist[j]):
            hapsum+=actlist[i]*abs(m-n)
        if maxnum<hapsum:
            maxnum=hapsum
        

print(maxnum)
Problem p03061 (python)

Fixed submission:
# coding:utf-8
import fractions


def main():
    N = int(input())
    # N = 10 ** 5
    num = list(map(int, input().split()))
    # num = list(range(1, 10**5 + 1))
    # num.sort()
    gcd = 0
    gcd_list_front = []
    gcd_list_back = []
    gcd_list_front.append(num[0])
    gcd_list_back.append(num[-1])

    for i in range(1, N-1):
        gcd_list_front.append(fractions.gcd(gcd_list_front[i-1], num[i]))
        gcd_list_back.append(fractions.gcd(gcd_list_back[i-1], num[-i-1]))

    gcd_list_back.reverse()
    # print(gcd_list_front)
    # print(gcd_list_back)

    gcd = max(gcd_list_back[0], gcd_list_front[-1])

    for i in range(0, N-2):
        # print(gcd_list_front[i], gcd_list_back[i+1])
        temp_gcd = fractions.gcd(gcd_list_front[i], gcd_list_back[i+1])
        if temp_gcd > gcd:
            gcd = temp_gcd

    print(gcd)
    # ans = 0
    # print()


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding:utf-8
import math


def main():
    N = int(input())
    num = list(map(int, input().split()))
    # num.sort()
    # print(num)
    # print(num[0:0])
    gcd = 0
    for i in range(len(num)):
        temp_list = num[0:i]+num[i+1:]
        temp_gcd = temp_list[0]
        for i in temp_list:
            temp_gcd = math.gcd(temp_gcd, i)
        # temp_gcd = functools.reduce(math.gcd, temp_list)
        if temp_gcd > gcd:
            gcd = temp_gcd
    print(gcd)
    # ans = 0
    # print()


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding:utf-8
import functools
import math


def main():
    N = int(input())
    num = list(map(int, input().split()))
    # num.sort()
    # print(num)
    # print(num[0:0])
    gcd = 0
    for i in range(len(num)):
        temp_list = num[0:i]+num[i+1:]
        temp_gcd = functools.reduce(math.gcd, temp_list)
        if temp_gcd > gcd:
            gcd = temp_gcd
    print(gcd)
    # ans = 0
    # print()


if __name__ == "__main__":
    main()
Problem p03079 (python)

Fixed submission:
# coding: utf-8
def main():
    a,b,c = map(int, input().split())
    if a==b and b == c:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
def main():
    N,Q = map(int, input().split())
    s = input()
    ans = N
    command = []

    # print(char_list)

    for i in range(Q):
        t,d = input().split()
        command.append([t,d])

    r = binary_serch_R(command,s,N)
    #print(r)
    l = binary_serch_L(command,s,N)
    #print(l)
    ans = ans - (N-r) - (l+1)
    if ans < 0:
        ans = 0
    print(ans)

def simulation_R(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return False
        elif now >= N:
            return True
    return False

def simulation_L(command,s,now,N):
    for pair in command:
        if pair[0] == s[now]:
            if pair[1] == 'L':
                now -= 1
            elif pair[1] == 'R':
                now += 1
        if now < 0:
            return True
        elif now >= N:
            return False
    return False


def binary_serch_R(command,s,N):
    left = 0
    right = N-1
    if simulation_R(command,s,left,N) :
        return -1
    if simulation_R(command,s,right,N) == False:
        return N

    while abs(right - left) > 1:
        mid = int((left+right)/2)
        # print(mid)
        if simulation_R(command,s,mid,N) :
            right = mid
        else :
            left = mid 
    return right

def binary_serch_L(command,s,N):
    left = 0
    right = N-1
    if simulation_L(command,s,left,N) == False :
        return -1
    if simulation_L(command,s,right,N):
        return N
        
    while abs(right-left) > 1:
        mid = int((left+right)/2)
        if simulation_L(command,s,mid,N) :
            left = mid
        else :
            right = mid 
    return left

if __name__ == "__main__":
    main()