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

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

def common_divisors(a, b):
    cd = []
    n = min(a, b)
    m = max(a, b)
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            if m % i == 0:
                cd.append(i)
            if i != n // i and m % (n//i) == 0:
                cd.append(n//i)
    return cd

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

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


cd = common_divisors(A, B)
#prime = sieve(max(cd))

def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if i*i > n:
            break
        if n % i == 0:
            return False
    return True

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if is_prime(a):
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
A, B = [int(x) for x in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

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

def sieve(n):
    prime = []
    is_prime = [True]*(n+1)
    is_prime[0] = False
    is_prime[1] = False

    for i in range(2, n+1):
        if is_prime[i]:
            prime.append(i)
            for j in range(2*i, n+1, i):
                is_prime[j] = False
    return prime


A_div = make_divisors(A)
B_div = make_divisors(B)

cd = sorted([a for a in A_div if a in B_div])
prime = sieve(max(cd))

#print(cd)
#print(max(cd))
#print(prime)

ans = 1 # 1は絶対入る
for a in cd:
    if a in prime:
        ans += 1

print(ans)
Problem p03043 (python)

Fixed submission:
N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    inverse_p = N
    while j < K:
        j *= 2
        inverse_p *= 2
    prob += 1/ inverse_p

print(prob)

Buggy submission (verdict: Runtime Error):
N, K = [int(a) for a in input().split()]

prob = 0

for i in range(1, N+1):
    j = i
    inverse_p = j
    while j < K:
        j *= 2
        inverse_p *= 2
    prob += 1/ p

print(prob)
Problem p03049 (python)

Fixed submission:
import re

N = int(input())
s = [input() for _ in range(N)]

num_end_with_A = 0
num_start_with_B = 0
num_both = 0
num_inner_AB = 0

for ss in s:
    res = re.findall('AB', ss)
    if res:
        num_inner_AB += len(res)
    if ss[0] == 'B' and ss[-1] == 'A':
        num_both += 1
    elif ss[0] == 'B':
        num_start_with_B += 1
    elif ss[-1] == 'A':
        num_end_with_A += 1

if num_end_with_A == 0 and num_start_with_B == 0:
    print(num_inner_AB + max(num_both - 1, 0))
else:
    print(num_inner_AB + min(num_end_with_A, num_start_with_B) + num_both)

Buggy submission (verdict: Runtime Error):
import re

N = int(input())
s = [input() for _ in range(N)]

num_end_with_A = 0
num_start_with_B = 0
num_both = 0
num_inner_AB = 0

for ss in s:
    res = re.findall('AB', ss)
    if res:
        num_inner_AB += len(res)
    if ss[0] == 'B' and ss[-1] == 'A':
        num_both += 1
    elif ss[0] == 'B':
        num_start_with_B += 1
    elif ss[-1] == 'A':
        num_end_with_A += 1


if num_end_with_A == num_start_with_B:
    print(num_inner_AB + num_end_with_a + max(num_both - 1, 0))
else:
    print(num_inner_AB + min(num_end_with_A, num_start_with_B) + num_both)
Problem p03087 (python)

Fixed submission:
import numpy as np
def find_AC(S):
  ret = [0]*len(S)
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret[i+1] = 1
  return ret

N, Q = [int(x) for x in input().split()]
S = input()

cum = np.cumsum(find_AC(S))

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = cum[r-1] - cum[l-1]
  print(ans)

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

def find_AC(S):
  ret = []
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret.append(i)
  return re

N, Q = [int(x) for x in input().split()]
S = input()
result = find_AC(S)
#pos = np.array([res.start()+1 for res in result])
pos = [res.start()+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)
Problem p03103 (python)

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

AB = []

for _ in range(N):

    AB.append([int(x) for x in input().split()])

AB = sorted(AB, key=lambda x: x[0])

current_drinks = 0

current_buget = 0

for a, b in AB:

    num_buy = min(b, (M-current_drinks))

    current_drinks += num_buy

    current_buget += num_buy*a

    # print(current_drinks, current_buget)

    if current_drinks == M:

        break

print(current_buget)

Buggy submission (verdict: Runtime Error):
def find_AC(S):
  ret = []
  for i in range(len(S)-1):
    if S[i] == 'A' and S[i+1] == 'C':
      ret.append(i)
  return ret

N, Q = [int(x) for x in input().split()]
S = input()
result = find_AC(S)
print(result)
pos = [res+1 for res in result]

for _ in range(Q):
  l, r = [int(x) for x in input().split()]
  ans = 0
  for p in pos:
    if p>=l and p<=r-1:
      ans += 1
  print(ans)
Problem p03244 (python)

Fixed submission:
n = int(input())
a = [int(aa) for aa in input().split()]

def add_entry(hist, aa):
    if aa in hist:
        hist[aa] += 1
    else:
        hist[aa] = 1


def make_hist(a):
    even_hist = {}
    odd_hist = {}

    for i in range(len(a)//2):
        add_entry(even_hist, a[2*i])
        add_entry(odd_hist, a[2*i+1])

    return even_hist, odd_hist


def get_sorted_hist(hist):
    return sorted(hist.items(), key=lambda x: -x[1])

eh, oh = make_hist(a)
seh = get_sorted_hist(eh)
soh = get_sorted_hist(oh)


if seh[0][0] != soh[0][0]:
    print(len(a) - seh[0][1] - soh[0][1])
else:
    if len(seh) == 1 and len(soh) == 1:
        print(len(a)//2)
    elif len(seh) == 1:
        print(len(a) - seh[0][1] - soh[1][1])
    elif len(soh) == 1:
        print(len(a) - soh[0][1] - seh[1][1])
    else:
        print(min(len(a) - seh[0][1] - soh[1][1], len(a) - soh[0][1] - seh[1][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(aa) for aa in input().split()]

def add_entry(hist, aa):
    if aa in hist:
        hist[aa] += 1
    else:
        hist[aa] = 1


def make_hist(a):
    even_hist = {}
    odd_hist = {}

    for i in range(len(a)//2):
        add_entry(even_hist, a[2*i])
        add_entry(odd_hist, a[2*i+1])

    return even_hist, odd_hist


def get_sorted_hist(hist):
    return sorted(hist.items(), key=lambda x: -x[0])


eh, oh = make_hist(a)
seh = get_sorted_hist(eh)
soh = get_sorted_hist(oh)

if seh[0][0] != soh[0][0]
    print(len(a) - seh[0][1] - soh[0][1])
else:
    if seh[0][1] >= soh[0][1]:
        print(len(a) - seh[0][1] - soh[1][1])
    else:
        print(len(a) - seh[1][1] - soh[0][1])
Problem p03262 (python)

Fixed submission:
import numpy as np

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
line = input().split()
N = int(line[0])
X = int(line[1])

line = input().split()

diff = [abs(int(x)-X) for x in line]

min_ = gcd(diff[0], diff[0])

for df in diff:
    min_ = min(min_, gcd(diff[0], df))

print(min_)

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

line = input().split()
N = int(line[0])
X = int(line[1])

line = input().split()


diff = [abs(int(x)-X) for x in line]

min_ = math.gcd(diff[0], diff[0])

for df in diff:
    min_ = min(min_, math.gcd(diff[0], df))

print(min_)
Problem p03713 (python)

Fixed submission:
H, W = [int(x) for x in input().split()]

def solve(H, W):
  if H % 3 == 0 or W % 3 == 0:
    return 0  
  else:
    ans = 1e20
    for i in range(max(W//3-1, 1), min(W//3+2, W)):
      a = i
      b = W - a
      for i in range(max(H//2-1, 1), min(H//2+2, H)):
        c = i
        d = H - c
        S = [a*H, b*c, b*d]
        ans = min(ans, max(S)-min(S))
      for i in range(max(b//2-1, 1), min(b//2+2, b)):
        c = i
        d = b - c
        S = [a*H, c*H, d*H]
        ans = min(ans, max(S)-min(S))
  return ans

print(min(solve(H, W), solve(W, H)))

Buggy submission (verdict: Runtime Error):
H, W = [int(x) for x in input().split()]

def solve(H, W):
  if H % 3 == 0 or W % 3 == 0:
    return 0  
  else:
    min_ = 1e10
    a = 0
    ans = 1e20
    for i in range(W+1):
      if abs(i-target) < min_:
        a = i
        min_ = abs(i-target)
      b = W - a
      target = H/2
      for i in range(min(int(target)-1, 2), min(int(target)+2, H+1)):
        if abs(i-target) < min_:
          c = i
          min_ = abs(i-target)
      d = H - c
      S = [a*H, b*c, b*d]
    ans = min(ans, max(S)-min(S))
  return ans

print(min(solve(H, W), solve(W, H)))

Buggy submission (verdict: Runtime Error):
H, W = [int(x) for x in input().split()]

def solve(H, W):
  if H % 3 == 0 or W % 3 == 0:
    return 0  
  else:
    target = W/3
    min_ = 1e10
    a = 0
    for i in range(min(int(target)-1, 2), min(int(target)+2, W+1)):
      if abs(i-target) < min_:
        a = i
        min_ = abs(i-target)
    b = W - a
    target = H/2
    min_ = 1e20
    for i in range(min(int(target)-1, 2), min(int(target)+2, H+1)):
      if abs(i-target) < min_:
        c = i
        min_ = abs(i-target)
    d = H - c
    S = [a*H, b*c, b*d]
    return max(S)-min(S)

print(min(solve(H, W), solve(W, H))
Problem p03760 (python)

Fixed submission:
O = input()
E = input()

ans = ""

for i in range(len(E)):
  ans += O[i] + E[i]

if len(O) > len(E):
  ans += O[-1]
  
print(ans)

Buggy submission (verdict: Runtime Error):
O = input()
E = input()

ans = ""

for i in range(len(O)):
  ans += O[i] + E[i]

if len(O) > len(E):
  ans += O[-1]

print(ans)
Problem p02993 (python)

Fixed submission:
S = input()

flag = True
for i in range(1, len(S)):
    if S[i-1] == S[i]:
        flag = False
if flag == True:
    print('Good')
else:
    print('Bad')

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

for i in range(1, len(S)):
    if S[i-1] == S[i]:
        print('Bad')
        exit(1)

print('Good')
Problem p03079 (python)

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

if A == B and B == C:
    print('Yes')
else:
    print('No')

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

if A == B and B == C:
    print('Yes')
else:
    print('No')

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

if A**2 + B**2 == C**2:
    print('Yes')
else:
    print('No')
Problem p03085 (python)

Fixed submission:
def main():
    to = ['T', 'G']
    fr = ['A', 'C']

    inc = input()

    try:
        print(to[fr.index(inc)])
    except Exception:
        print(fr[to.index(inc)])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    to = ['T', 'G']
    fr = ['A', 'C']

    print(to[fr.index(input())])


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

Fixed submission:
ACGT = ['A', 'C', 'G', 'T']


def not_acgt(s):
    for c in s:
        if c not in ACGT:
            return False

    return True


def main():
    S = input()

    results = []
    # all_results = []
    for i in range(len(S)):
        for j in range(len(S)):
            if not_acgt(S[i:j+1]):
                results.append(S[i:j+1])
            # all_results.append(S[i:j+1])
    try:
        print(max([len(s) for s in results]))
    except Exception:
        print(0)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
ACGT = ['A', 'C', 'G', 'T']


def not_acgt(s):
    for c in s:
        if c not in ACGT:
            return False

    return True


def main():
    S = input()

    results = []
    # all_results = []
    for i in range(len(S)):
        for j in range(len(S)):
            if not_acgt(S[i:j+1]):
                results.append(S[i:j+1])
            # all_results.append(S[i:j+1])

    print(max([len(s) for s in results]))


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

Fixed submission:
def main():
    H, W = map(int, input().split())
    h, w = map(int, input().split())

    print(H*W - (h*W + (H-h)*w))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    H, W = map(int, input())
    h, w = map(int, input())

    print(H*W - h*w)


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

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

if len(list(range(1, N+1, 2))) >= K:
    print('YES')
else:
    print('NO')

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

elif len(list(range(1, N+1, 2))) >= K:
    print('YES')
else:
    print('NO')
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
    print('Hello World')
else:
    A, B = map(int, [input() for i in range(2)])
    print(A+B)

Buggy submission (verdict: Runtime Error):
N = int(input())

if N == 1:
    print('Hello, World')
else:
    A, B = map(int, open(0).read().split())
    print(A+B)
Problem p02917 (python)

Fixed submission:
n = int(input())
a = [int(a) for a in input().split()]
aaa=[]
if n==2:
  print(a[0]*2)
else:
  aaa.append(a[0])
  for i in range (1,n-1):
    aa = min(a[i-1],a[i])
    aaa.append(aa)
  aaa.append(a[n-2])
  print(sum(aaa))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(a) for a in input().split()]
for i in range (n-1):
  aa = min(a[i],a[i+1])
  aaa.append(aa)
print(aaa)
Problem p02969 (python)

Fixed submission:
r = int(input())
print(3* (r**2))

Buggy submission (verdict: Runtime Error):
N = int(input())
mylist = []
for i in range (N):
  A = int(input())
  mylist.append(int(A))
my = sorted(mylist,reverse=True)
del my[2:]
for j in range (N):
  if mylist[j] == my[0]:
    print(my[1])
  else:
    print(my[0])
Problem p03000 (python)

Fixed submission:
a,b=map(int,input().split())
M = input()
l = M.split()
ll = list(map(int, l))
q=0
ans=1
for i in range(a):
  q += ll[i]
  if q <= b :
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
M = input()
l = M.split()
ll = list(map(int, l))
q=0
ans=1
for i in range(a):
  ai +=1
  q += ll[i]
  if q <= b :
    ans += 1
print(ans)
Problem p03035 (python)

Fixed submission:
a,b=input().split()
if int(a) >= 13 :
    print(int(b))
if int(a) >= 6 and int(a) <=12 :
    print(round(int(b) / 2))
if int(a) <= 5 :
    print(0)

Buggy submission (verdict: Runtime Error):
a,b,c=input(int()).split()
s = b
aa = int(a)
cc = int(c)
bb = int(b)
for i in  range(10):
    d= aa * cc - bb
    cc = d
    print (int(d))
Problem p03067 (python)

Fixed submission:
A,B,C = map(int,input().split())
if A > C > B :
    print("Yes")
elif B > C > A :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
if A > C > B :
    print("Yes")
elif B > C > A :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
if A < B:
    D = B
    E = A
else :
    E = B
    D = A

if D > C > E :
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
if A < B:
    D = B
    E = A
else :
    E = B
    D = A
if D > C > E :
    print("yes")
else :
    print("no")

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
if A < B:
    D = B
    E = A
else :
    E = B
    D = A

if D > C > E :
    print("yes")
else :
    print("no")
Problem p02922 (python)

Fixed submission:
S = input().split()
cnt = 1
num = int(S[0])

if int(S[1]) == 1:
  print(0)
else:
  while(num < int(S[1])):
    num += (int(S[0]) - 1)
    cnt += 1
  print(cnt)

Buggy submission (verdict: Runtime Error):
S = input().split()
cnt = 1
num = int(S[0])

if int(S[1]) == 1:
  print("0")
else:
	while(num < int(S[1])):
    	num += int(S[0]) - 1
    	cnt += 1
    
	print(cnt)
Problem p03047 (python)

Fixed submission:
n = input().split()

max_num = int(n[0])
kernel = int(n[1])

print(max_num - kernel + 1)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

max_num = args[1]
kernel = args[2]

print(max_num - kernel + 1)

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

max_num = args[1]
kernel = args[2]

print(max_num - kernel + 1)
Problem p03457 (python)

Fixed submission:
N = int(input())
count = 0
T, X, Y = 0, 0, 0
for i in range(N):
    t, x, y = map(int, input().split())
    if abs(x-X)+abs(y-Y) <= t-T and t % 2 == (x+y) % 2:
        count += 1
    T, X, Y = t, x, y
if count==N:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0


for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        exit()
    T,X,Y=t,x,y
print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0


for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        sys.exit()
    T,X,Y=t,x,y
print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print('{}'.format(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

a='Yes'
for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        a='No'
        break
    T,X,Y=t,x,y
print(a)

Buggy submission (verdict: Runtime Error):
n=int(input())
T,X,Y=0,0,0

for i in range(n):
    t,x,y=map(int,input().split())
    if abs(s-X)+abs(y-Y)>t-T or t%2!=(x+y)%2:
        print('No')
        break
    T,X,Y=t,x,y
print('Yes')
Problem p03493 (python)

Fixed submission:
s=input()
counter=0

for n in range(3):
  if int(s[n])==1:
    counter+=1

print(counter)

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

def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_divisibles,a))
print(ans)

Buggy submission (verdict: Runtime Error):
s=int(input())
counter=0
for n in range(3):
  if s[n]==1:
    counter+=1

print(counter)
Problem p03494 (python)

Fixed submission:
import numpy as np

def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_divisibles,a))
print(ans)

Buggy submission (verdict: Runtime Error):


def how_many_times_divisibles(j):
	counter=0
	while j%2==0:
		j/=2
		counter+=1
	return counter

n=int(input())
a=map(int,input().split())
ans=min(map(how_many_times_dibishibles,a))

print(ans)
Problem p02865 (python)

Fixed submission:
n = int(input())

ans = (n-1)//2

print(ans)

Buggy submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))
Problem p02866 (python)

Fixed submission:
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  for j in range(d_count[i+1]):
    ans = ans * d_count[i]
    ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

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

print(len(d))
print(d[n-1])

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])
  ans = ans % 998244353

ans = ans % 998244353

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

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

ans = -1

d_count = [0] * (max(d)+1)
for i in range(n):
  d_count[d[i]] += 1

if d[0] != 0 or d_count[0] != 1:
  print(0)
  exit()

ans = 1
for i in range(1,len(d_count)-1):
  ans = ans *  math.pow(d_count[i], d_count[i+1])

ans = ans % 998244353

print(int(ans))
Problem p02910 (python)

Fixed submission:
s = input()
n = len(s)

k = s[0::2]
g = s[1::2]

d = 0

for i in range(len(k)):
  if k[i] == "L":
    print("No")
    d = 1
    break

if d == 0:
  for i in range(len(g)):
    if g[i] == "R":
      print("No")
      d = 1
      break
if d == 0:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)

if n == 1:
  p = 1
else:
  p = n//2
d = 0
for i in range(p):
  if s[2*i] == "L" or s[2*i+1] == "R":
    print("No")
    d = 1
    break

if d == 0:
  print("Yes")
Problem p02953 (python)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
d = 0

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1

for i in range(N-2):
  if l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] <= -1:
        break
      if l[j] - l[j+1] == 0:
        continue
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")

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

for i in range(N-1):
  if l[i] - l[i+1] >= 2:
    d = 1
  else l[i] - l[i+1] == 1:
    for j in range(i+1, N-1):
      if l[j] - l[j+1] == 1:
        d = 1
        break

if d == 0:
  print("Yes")
else:
  print("No")
Problem p02958 (python)

Fixed submission:
N = int(input())
l = list(map(int, input().split()))
score = 0
for i in range(N):
  if not l[i] == i+1:
    score += 1
if score  ==0 or score ==2:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score += 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
list = [int(i) for i in input().split()]
score == 0
for i in range(N):
    if list[i] != i+1:
        score =+ 1
if score == 0 or 2:
    print("YES")
else:
    print("NO")
Problem p02887 (python)

Fixed submission:
N = int(input())
S = input()

cnt = 0
for i in range(N-1):
	if S[i] == S[i+1]:
		cnt += 1

print(N - cnt)

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

mark = 0
dekiru_f = True

while dekiru_f:
	if len(S) == 1:
		break
	elif S[mark] == S[mark+1]:
		S = S.replace("{}{}".format(S[mark], S[mark+1]), "{}".format(S[mark]))
	elif S[mark] != S[mark+1]:
		mark += 1
		l = len(S)
		if mark == l-1:
			dekiru_f = False
		else:
			continue

print(len(S))
Problem p02921 (python)

Fixed submission:
S = list(input())
T = list(input())

count = 0

for i in range(3):
    if(S[i] == T[i]):count = count + 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys

A,B = map(int,input().split())

for _ in range(1,10000):
    if( (A-1)*(_-1)+A >= B):
        print(_)
        break