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

Fixed submission:
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    for j in range(N):
        count = 0 
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) & 1:
                count += 1
        a += rieki[j][count]
    
    if ans < a : ans = a 
print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = -10**9
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h) == 1:
                count[j] += 1
        a += rieki[j][count[j]]
    
    if ans < a : ans = a 
print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = []
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h)&1:
                count[j] += 1
        a += rieki[j][count[j]]
    ans.append(a)
    
print("{}".format(max(ans)))

Buggy submission (verdict: Runtime Error):
N = int(input())
st_con = [[i for i in map(int,input().split())] for j in range(N)]
rieki = [[i for i in map(int,input().split())] for j in range(N)]

ans = []
for i in range(1,2**10):
    a = 0
    count = [0]*10
    for j in range(N):
        for h in range(10):
            if (i>>h) & st_con[j][h] and (i>>h)&1:
                count[j] += 1
        a += rieki[j][count[j]]
    ans.append(a)
    
print("{}".format(max(ans)))
Problem p03633 (python)

Fixed submission:
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)


def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,-1,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Buggy submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)

"""
全ての最小公倍数を求めたら良い
lcm(a,b,c...) = lcm(a,lcm(b,c.......))
gcd(a,b,c...) = gcd(a,gcd(b,c,d....))
"""

"""
最大公倍数の実装
ユークリッドの互除法
a = b*c + d
c = d*e + f
"""
def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        a = max(para[i],p)
        b = min(para[i],p)
        p = lcm(a,b)
print(p)

Buggy submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)
import sys
sys.setrecursionlimit(100000)

def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        p = lcm(para[i],p)
print(p)

Buggy submission (verdict: Runtime Error):
N=int(input())
para = [int(input()) for i in range(N)]
para.sort(reverse=True)

"""
全ての最小公倍数を求めたら良い
lcm(a,b,c...) = lcm(a,lcm(b,c.......))
gcd(a,b,c...) = gcd(a,gcd(b,c,d....))
"""

"""
最大公倍数の実装
ユークリッドの互除法
a = b*c + d
c = d*e + f
"""
def gcd(a,b):
    if b == 0 : 
        return a  
    return gcd(b,a%b)

def lcm(a,b) :
    return a*b//gcd(a,b)

for i in range(N-1,0,-1):
    if i == N-1:
        p = lcm(para[i-1],para[i])
    else :
        p = lcm(para[i],p)
print(p)
Problem p03963 (python)

Fixed submission:
n,k = map(int,input().split())
ans = k*(k-1)**(n-1)
print(ans)

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

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)

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

def ans(cnt,a,b,c=0):
    if cnt == a :
        return c
    else :
        if cnt == 0: 
            c += b
            cnt += 1
            return ans(cnt,a,b,c) 
        else: 
            cnt += 1
            c = c*(b-1)
            return ans(cnt,a,b,c)

a = ans(cnt = 0,a = n,b = k,c=0)
print(a)
Problem p04030 (python)

Fixed submission:
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if len(ans) >= 1 :
        if s[i] ==  "B" :
            ans.pop(-1)
        else : ans.append(s[i])

    elif s[i] != "B" : ans.append(s[i])

b = "".join(ans)
print(b)

Buggy submission (verdict: Runtime Error):
s = list(input())
size = len(s)
ans = []
for i in range(size) :
    if s[i] ==  "B":
        ans.pop(-1)
    else: ans.append(s[i])

b = "".join(ans)
print(b)

Buggy submission (verdict: Runtime Error):
s = list(input())
size = len(s)
print(s)
ans = []
for i in range(size) :
    if s[i] ==  "B":
        ans.pop(-1)
    else: ans.append(s[i])

b = "".join(ans)
print(b)
Problem p03001 (python)

Fixed submission:
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
else:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))

Buggy submission (verdict: Runtime Error):
w, h, x, y = list(map(int, input().split()))
area_ans = w * h / 2
cog_x = w/2 
cog_y = h/2
if cog_x == x and cog_y == y: 
    cog_ans = 1
    print(str(area_ans) +" "+ str(cog_ans))
elif:
    cog_ans = 0
    print(str(area_ans) +" "+ str(cog_ans))
Problem p03043 (python)

Fixed submission:
input_num = input().split()
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    while score < border_socre:
        score = score * 2
        coin_counter += 1
    ans_p += (1 / dice_num ) * ((1/2 ) ** coin_counter)
    
print(round(ans_p, 12))

Buggy submission (verdict: Runtime Error):
dice_num = int(input_num[0])
border_socre = int(input_num[1])
ans_p = 0

for score in range(1,dice_num + 1):
    coin_counter = 0
    
    while score <= border_socre:
        score = score * 2
        coin_counter += 1
    ans_p += (1 / dice_num ) * (1/2 ) ** coin_counter
print(ans_p)
Problem p03048 (python)

Fixed submission:
r, g, b, n = map(int, input().split())
ans = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g == n:
            ans += 1
        elif (n - (i * r + j * g)) >= 0 and (n - (i * r + j * g)) % b == 0:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
r, g, b, n = map(int, input().split())
ans = 0
nr = n // r
ng = n // g
for i in range(nr + 1):
    for j in range(ng + 1):
      	tmp = n - i * r - j * g 
        if tmp >= 0 and tmp % b == 0:
            ans += 1
print(ans)
Problem p03078 (python)

Fixed submission:
import sys
X, Y, Z, K = map(int, input().split())
A = list(map(int, sys.stdin.readline().split()))
B = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))
A.sort(reverse = True)
B.sort(reverse = True)
C.sort(reverse = True)
AB = []
ans = []
for a in A:
    for b in B:
        AB.append(a + b)
AB.sort(reverse=True)
AB = AB[:min(3001, X*Y*Z+1)]
for c in C:
    for ab in AB:
        ans.append(c + ab)
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
X, Y, Z, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
AB = []
ans = []
for a in A:
    for b in B:
        AB.append(a + b)
AB.sort(reverse=True)
AB = AB[:min(3001,X*Y*Z+1)]
for c in C:
    for ab in AB:
        ans.append(c + ab)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
Problem p03086 (python)

Fixed submission:
s = input()
cnt = 0
r = []
r.append(0)
for ss in s:
    if ss in ["A", "C", "T", "G"]:
        cnt += 1
    else:
        r.append(cnt)
        cnt = 0
    r.append(cnt)
print(max(r))

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
res = []
for a in s:
    if a in ["A", "G", "C", "T"]:
        cnt += 1
    else:
        res.append(cnt)
        cnt = 0
print(max(res))
Problem p03090 (python)

Fixed submission:
N = int(input())
ans = []
lis = []
for i in range(N):
    lis.append(i + 1)
if N % 2 == 0:
    M = (N - 2) * N // 2
    for i in range(1, N):
        for j in range(1, N):
            if j != i and i != lis[-j]:
                if sorted([i, lis[-j]]) not in ans:
                    ans.append(sorted([i, lis[-j]]))
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))
else:
    M = (N - 1) ** 2 // 2
    for i in range(1, N):
        for j in range(2, N):
            if j != i + 1 and i != lis[-j]:
                if sorted([i, lis[-j]]) not in ans:
                    ans.append([i, lis[-j]])
    for i in range(1, N):
        ans.append([N, i])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = []
M = n + 1 * (N % 2 == 0)
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        if i + j == M:
            continue
        ans.append('{} {}'.format(i, j))
print(len(ans))
print('\n'.join(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = []
lis = []
for i in range(N):
    lis.append(i + 1)
if N % 2 == 0:
    M = (N - 2) * N // 2
    for i in range(1, N):
        for j in range(1, N):
            if j != i and i != lis[-j]:
              	tmp = sorted([i, lis[-j]]) 
                if tmp not in ans:
                    ans.append(tmp)
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))
else:
    M = (N - 1) ** 2 // 2
    for i in range(1, N):
        for j in range(2, N):
            if j != i + 1 and i != lis[-j]:
              	tmp = sorted([i, lis[-j]])
                if tmp not in ans:
                    ans.append(tmp)
    for i in range(1, N):
        ans.append([N, i])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = []
lis = []
for i in range(N):
    lis.append(i + 1)
if N % 2 == 0:
    M = (N - 2) * N // 2
    for i in range(1, N // 2 + 1):
        for j in range(1, N):
            if j != i and i != lis[-j]:
                ans.append([i, lis[-j]])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))
else:
    M = (N - 1) ** 2 // 2
    for i in range(1, (N - 1) // 2 + 1):
        for j in range(2, N):
            if j != i + 1 and i != lis[-j]:
                ans.append([i, lis[-j]])
    for i in range(1, N):
        ans.append([N, i])
    print(M)
    for i in range(M):
        print(' '.join(map(str, ans[i])))
Problem p03096 (python)

Fixed submission:
import sys

N = int(input())
C = [int(sys.stdin.readline()) for _ in range(N)]
MOD = 10**9 + 7
A = []
for c in C:
    if A and A[-1] == c:
        continue
    A.append(c)
NA = len(A)
last = [-1] * 200001
B = [-1] * 200001
for i, a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * NA
dp[0] = 1
for i in range(1, NA):
    prev = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i - 1] + prev) % MOD
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys

N = int(input())
C = [int(sys.stdin.readline()) for _ in range(N)]
MOD = 10**9 + 7
A = []
for c in C:
    if A and A[-1] == c:
        continue
    A.append(c)
NA = len(A)
last = [-1] * NA
B = [-1] * NA
for i, a in enumerate(A):
    B[i] = last[a]
    last[a] = i

dp = [0] * NA
dp[0] = 1
for i in range(1, NA):
    prev = 0 if B[i] < 0 else dp[B[i]]
    dp[i] = (dp[i - 1] + prev) % MOD
print(dp[-1])
Problem p03112 (python)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect
import sys
A, B, Q = map(int, input().split())
INF = 10 ** 13
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
xs = [int(sys.stdin.readline()) for i in range(Q)]
for x in range(xs):
    b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)
Problem p03126 (python)

Fixed submission:
def read():
    return int(input())

def reads():
    return list(map(int, input().split()))

n,m = reads()
a = []
r = []
for i in range(n):
    a.append(reads())
for i in range(n):
    for j in range(1,a[i][0]+1):
        r.append(a[i][j])
ans = 0
for i in set(r):
    if r.count(i) == n:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = set(input().split()[1:])
for i in range(n - 1):
    a &= set(reads()[1:])
print(len(a))
Problem p03141 (python)

Fixed submission:
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(reverse = True,key = lambda x:x[0]+x[1])
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB[i][0]
    else:
        ans -= AB[i][1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(reverse = True, key = lambda x:x[0]+x[1])
ans = sum(AB[0::2][0]) - sum(AB[1::2][1])
print(ans)
Problem p03163 (python)

Fixed submission:
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
dp = [0]*(W+1)
for i in range(n):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j], dp[j-w] + v)
print(max(dp))
Problem p03194 (python)

Fixed submission:
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p+1)**(1/n))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Buggy submission (verdict: Runtime Error):
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p+1)**(1/2))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Buggy submission (verdict: Runtime Error):
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int((p)**(1/2))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)

Buggy submission (verdict: Runtime Error):
import math
n, p=map(int,input().split())
ans = 0
if n != 1:
    for i in range(1,int(math.sqrt(p+1))+1):
        ni = i**n
        if p/ni >= 1 and p/ni == int(p/ni):
            ans = i
        elif p/ni < 1:
            break
    print(ans)
else:
    print(p)
Problem p03285 (python)

Fixed submission:
n = int(input())
ans = 'No'
for i in range(n):
    for j in range(n):
        if 7*i + 4*j == n:
            ans = 'Yes'
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
f = False
for i in range(int(n/4)):
    for j in range((n/7)):
      if 4*i + 7*j == n:
        f = True
if f:
  print('Yes')
else:
  print('No')
Problem p03331 (python)

Fixed submission:
N = int(input())
if N % 10 == 0:
    print(10)
else:
    s = 0
    for i in str(N):
        s += int(i)
    print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N % 10 == 0:
    print(10)
else:
    s = 0
    for i in str(N):
        s += int(i)
	print(s)
Problem p03339 (python)

Fixed submission:
import numpy
n = int(input())
s = input()
a = [0]*n
ans = 10**6
for i in range(n):
    if s[i] == 'W':
        a[i] = 1
res = numpy.cumsum(a)
for i in range(n):
    x = res[i]-str(a[i]).count('1')
    y = n-i-1-(res[n-1]-res[i])
    ans = min(ans,x+y)
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy
n = int(input())
s = input()
a = [0]*n
ans = 10**6
for i in range(n):
    if s[i] == 'W':
        a[i] = 1
res = numpy.cumsum(a)
for i in range(n):
    x = res[i]-str(a[i]).count('1')
    y = n-i-1-(res[n-1]-res[i])
    ans = min(ans,x+y)
print(ans)
Problem p03415 (python)

Fixed submission:
s1=input()
s2=input()
s3=input()
print(s1[0]+s2[1]+s3[2])

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans=0
if n==1 and m==1:
    ans=1
else:
    ans=abs(n-2)*abs(m-2)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
ans=0
if n==1 and m==1:
    ans=1
else:
    ans=(n-2)*(m-2)
print(ans)

Buggy submission (verdict: Runtime Error):
s1 = list(map(str, input().split()))
s2 = list(map(str, input().split()))
s3 = list(map(str, input().split()))
print(s1[0]+s2[1]+s3[2])
Problem p03437 (python)

Fixed submission:
x,y=map(int,input().split())
if x%y==0:
    print('-1')
else:
    print(x)

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

c = 0
for i in range(n):
    ai = a[i]
    bi = b[i]
    if ai < bi:
        c += (bi-ai)//2
    else:
        c -= (ai-bi)
print('Yes' if c >= 0 else 'No')
Problem p03479 (python)

Fixed submission:
x, y = map(int, input().split())
cnt = 0
while x <= y:
    x *= 2
    cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
x, y = map(int,input().split())
print(int(math.log2(y/x,2))+1)
Problem p03544 (python)

Fixed submission:
N = int(input())
L = [0]*100
L[0] = 2
L[1] = 1
if N == 0 or N == 1:
    print(L[N])
    exit()
for i in range(2,N+1):
    L[i] = L[i-1] + L[i-2]
print(L[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [0]*100
L[0] = 2
L[1] = 1
for i in range(2,N+1):
    L[i] = L[i-1] + L[i-2]
print(L[i])
Problem p03838 (python)

Fixed submission:
x, y = map(int, input().split())
print(min(a for a in [y - x, y + x + 1, -y - x + 1, -y + x + 2] if a >= 0))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
X = abs(x)
Y = abs(y)
if x * y < 0:
    print(max(Y - X, X - Y) + 1)
else:
    print(max(x - y, y - x) + 2 * (y < x))x, y = map(int, input().split())
X = abs(x)
Y = abs(y)
if x * y < 0:
    print(max(Y - X, X - Y) + 1)
elif x * y > 0:
    print(max(x - y, y - x) + (y < x) + (X > 0))
Problem p03035 (python)

Fixed submission:
import sys 
 
A, B = map(int, input().split())
cond_older = (12 < A)
cond_young = (6 <= A) & (12 >= A)
 
ans = (
  B if cond_older else
  B//2 if cond_young else
  0
)
 
print(ans)

Buggy submission (verdict: Runtime Error):
import sys 

A, B = int(input()).split()
cond_older = (13 > A)
cond_young = (6 <= A) & (13 >= A)

ans = (
  B if cond_older else
  B//2 if cond_young else
  0
)

print(ans)
Problem p04011 (python)

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(n, k)* x + max(0, n - k) * y);

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())
print(min(n, k)* x + max(0, n - k) * y);
Problem p02615 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = 0
for i in range(1,n):
  ans += a[i//2]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(inpput())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
ans = 0
ans += a[0]
for i in range(2,n):
  ans += min(a[i-1],a[i-2])
print(ans)
Problem p02910 (python)

Fixed submission:
S = input()
N = len(S)
ans = 'Yes'

for i in range(N):   
    if S[i] == 'R' and (i+1)%2 == 0:
        ans = 'No'
        break
    elif S[i] == 'L' and (i+1)%2 == 1:
        ans ='No'
        break

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
ans = 'Yes'

for i in range(N):
    if S[2*i] == 'R':
        ans = 'No'
        break
    elif S[2*i+1] == 'L':
        ans ='No'
        break

print(ans)

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

for i in range(N):
    if S[2*i] == 'R':
        print('No')
        break
    else S[2*i+1] == 'L':
        print('No')
        break

print('Yes')
Problem p02995 (python)

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

A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D
ck = gcd(C,D)
asb = C*D//ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(int(newb-newa))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
        while b!=0:
                a,b=b,a%b
        return a

A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D
ck = 0

asb = C*D//ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(int(newb-newa))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split(" "))
ans = 0
Bc = B // C
Bd = B // D

ck = math.gcd(C, D)
asb = C*D/ck
Bs = B//asb

newb = B - Bc - Bd + Bs

Ac = (A-1) // C
Ad = (A-1) // D
As = (A-1)//asb

newa = (A-1)-Ac-Ad+As

print(newb-newa)
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split(" "))
botlist = []
ans = 0
for n in range(M):
    bot = list(map(int, input().split(" ")))
    
    botlist.append(bot)
#botlist
plist = list(map(int, input().split(" ")))

pushlist = [[]for i in range(2**N)]

for p in range(N):
    for q in range(2**N):
        if q % (2**(p+1)) <2**p:
            pushlist[q].append(0)
        else:
            pushlist[q].append(1) 

for A in pushlist:
    #print(A)
    g = 0
    faa = 0
    for B in botlist:
        g += 1
        cou = 0
        for c in range(B[0]):
            cou += A[B[c+1]-1]

        if cou % 2 == plist[g-1]:
            faa += 1
    if faa == M:
        ans += 1
    

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split(" "))
botlist = []
ans = 0
for n in range(M):
    bot = list(map(int, input().split(" ")))
    
    botlist.append(bot)
#botlist
plist = list(map(int, input().split(" ")))

pushlist = [[]for i in range(2**N)]

for p in range(N):
    M = (2**N)/(p+1)
    for q in range(M):
        for r in range(p+1):
            if q%2 == 0:
                pushlist[r*q] = 0
            else:
                pushlist[r*q] = 1

for A in pushlist:
    g = 0
    for B in botlist:
        cou = 0
        for c in range(B[0]):
            cou += A[B[c]]
        if cou % 2 == plist[g]:
            ans += 1
    g +=1

print(ans)
Problem p03999 (python)

Fixed submission:
s = input()

sum = 0
for bit in range(1 << (len(s) - 1)):
    expr = s[0]
    for i in range(len(s) - 1):
        if bit & 1 << i:
            expr += '+'
        expr += s[i + 1]
    sum += eval(expr)

print(sum)

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

sum = 0
for bit in range(1 << (len(s) - 1)):
    expr = s
    ins = 0
    for i in range(len(s) - 1):
        ins += i
        if bit & 1 << i:
            expr = expr[:ins+1] + '+' + expr[ins+1:]
            ins += 1
    sum += eval(expr)

print(sum)