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

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

from functools import reduce
import fractions 


A.sort(reverse = True)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(A))

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

from functools import reduce
import fraction 


A.sort(reverse = True)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))

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

from functools import reduce
import math 


A.sort(reverse = True)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(A))
Problem p03252 (python)

Fixed submission:
import sys

s = input()
t = input()

#print(s)
#print(t)

n = len(s)

dic = {}
dic2 = {}


for i in range(n):
    if s[i] in dic:
        if dic[s[i]] != t[i]:
            print("No")
            sys.exit()
            
    else:
        dic[s[i]] = t[i]
            
            
    if t[i] in dic2:
        if dic2[t[i]] != s[i]:
            print("No")
            sys.exit()
            
    else:
        dic2[t[i]] = s[i]
        
print("Yes")

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

#print(s)
#print(t)

n = len(s)

dic = {}
dic2 = {}


for i in range(n):
    if s[i] in dic:
        if dic[s[i]] != t[i]:
            print("No")
            sys.exit()
            
    else:
        dic[s[i]] = t[i]
            
            
    if t[i] in dic2:
        if dic2[t[i]] != s[i]:
            print("No")
            sys.exit()
            
    else:
        dic2[t[i]] = s[i]
        
print("Yes")

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

#print(s)
#print(t)

n = len(s)

dic = {}
dic2 = {}

if s == t:
    print("Yes")

else:
    for i in range(n):
        if s[i] in dic:
            if dic[s[i]] != t[i]:
                print("No")
                sys.exit()

        else:
            dic[s[i]] = t[i]

        
        if t[i] in dic2:
            if dic2[t[i]] != s[i]:
                print("No")
                sys.exit()

        else:
            dic2[t[i]] = s[i]

print("Yes")
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K: break
	while b[j] > K - a[i]: j -= 1
	ans = max(ans, i + j)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, N): A[i] += A[i - 1]
for i in range(1, M): B[i] += B[i - 1]
ans, j = 0, M - 1
for i in range(N):
    if A[i] > K: break
    while B[j] > K - A[i]: j -= 1
    ans = max(ans, i + j + 2)
    j = M - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, N): A[i] += A[i - 1]
for i in range(1, M): B[i] += B[i - 1]
print(A)
print(B)
ans, j = 0, M - 1
for i in range(N):
    if A[i] > K: break
    while B[j] > K - A[i]: j -= 1
    ans = max(ans, i + j + 2)
    j = M - 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(1, N): A[i] += A[i - 1]
for i in range(1, M): B[i] += B[i - 1]
ans, j = 0, M - 1
for i in range(N):
    if A[i] > K: break
    while B[j] > K - A[i]: j -= 1
    ans = max(ans, i + j + 2)
print(ans)
Problem p03108 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.size = [1 for _ in range(n+1)]

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    
def main():
    N, M = [int(_) for _ in input().split()]
    bridge = [tuple(map(int, input().split())) for _ in range(M)]

    last = []
    last.append(int(N * (N-1) * 0.5))

    ins = UnionFind(N)
    last_temp = 0

    for i in range(M-1):
        #print(ins.par)
        if ins.same_check(bridge[M-1-i][0],bridge[M-1-i][1]):
            last.append(last[-1])
            #ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
        else:
            last_temp = last[-1] - (ins.size[ins.find(bridge[M-1-i][0])]) * (ins.size[ins.find(bridge[M-1-i][1])])
            #print(ins.size,i)
            last.append(last_temp)
            ins.union(bridge[M-1-i][0],bridge[M-1-i][1])
    
    [print(last[M-i-1]) for i in range(M)]
    exit()
    
main()

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

n,m = [int(i) for i in input().split()]
a = np.array([0]*m)
b = np.array([0]*m)
ans = np.array([0]*m)
ans[m - 1] = n * (n - 1) / 2

for i in range(m):
	a[i],b[i] = [int(i) for i in input().split()]

class UnionFind:
    def __init__(self, n):
        #親の番号を格納する。親だった場合は-(その集合のサイズ)
        #作るときはself.parの値をすべて-1にする
        self.par = [-1 for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def size(self, x):
        return -self.par[self.find(x)]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return 
        if self.size(x) < self.size(y):
            x , y = y , x
        self.par[x] += self.par[y]
        self.par[y] = x

uni = UnionFind(n)

for i in range(m-1,0,-1):
    ans[i-1] = ans[i]
    if uni.find(a[i]-1) != uni.find(b[i]-1):
        ans[i-1] -= uni.size(a[i]-1)*uni.size(b[i]-1)
    
        uni.union(a[i]-1,b[i]-1)

for i in ans:
    print(i)
Problem p03265 (python)

Fixed submission:
x1, y1, x2, y2 = list(map(int, input().split()))

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x

x4 = x1 - y
y4 = y1 + x

print(str(x3) + ' ' + str(y3) + ' ' + str(x4) + ' ' + str(y4))

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

x1,y1,x2,y2 = [int(i) for i in input().split()]

vx = x2-x1
vy = y2-y1

vx2,vy2 = np.array([[0,-1],[1,0]])@np.array([vx,vy])

x3 = x2+vx2
y3 = y2+vy2

vx3,vy3 = np.array([[0,-1],[1,0]])@np.array([vx2,vy2])

x4 = x3+vx3
y4 = y3+vy3

print(x3,y3,x4,y4)

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

x1,y1,x2,y2 = [int(i) for i in input().split()]

vx = x2-x1
vy = y2-y1

vx2,vy2 = np.array([[0,-1],[1,0]])@np.array([vx,vy])

x3 = x2+vx2
y3 = y2+vy2

vx3,vy3 = np.array([[0,-1],[1,0]])@np.array([vx2,vy2])

x4 = x3+vx3
y4 = y3+vy3

print(x3,y3,x4,y4)
Problem p03775 (python)

Fixed submission:
import math
n = int(input())

def order(a,b):
    return max(len(str(int(a))),len(str(int(b))))
    
ans = [] 


for i in range(1,int(math.ceil(math.sqrt(n)))+1):
    if n % i == 0:
        ans.append(order(n/i,i))

if len(ans) == 0:
    print(1)
else:
    print(min(ans))

Buggy submission (verdict: Runtime Error):
import math
n = int(input())

def order(a,b):
    return max(len(str(int(a))),len(str(int(b))))
    
ans = [] 


for i in range(1,int(math.ceil(math.sqrt(n)))):
    if n % i == 0:
        ans.append(order(n/i,i))

print(min(ans))

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

def order(a,b):
    return max(len(str(int(a))),len(str(int(b))))
    
ans = [] 
numbers = []

for i in range(1,n):
    if len(numbers) != 0:
        if i > min(numbers):
            break
    if n % i == 0:
        ans.append(order(n/i,i))
        numbers.append(n/i)
        

print(min(ans))
Problem p02790 (python)

Fixed submission:
a, b = input().split()
print(a*int(b) if a < b else b*int(a))

Buggy submission (verdict: Runtime Error):
a, b = input().split()
if a >= b:
  print(a*int(b))
  break
else:
  print(b*int(a))
Problem p02880 (python)

Fixed submission:
N=int(input())
f=0
for i in range(1,10):
    for j in range(1,10):
        if N==i*j:
            f=1
            break
    if f==1:
        break
if f==0:
    print("No")
else:
    print("Yes")

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

for i in range(1, 10):
  for j in range(1, 10):
    if i*j == n:
      print('Yes')
      return

print('No')

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

for i in range(1, 10):
	for j in range(1, 10):
		if i*j == n:
        	print('Yes')

print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n // 2):
	for j in range(n // 2):
    	if i*j == n:
        	print('Yes')
            
print('No')

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python
N = input()
for i in range(1, 10):
    m = N / i
    if m.is_integer() and 1 <= m <= 9:
        print('Yes')
        break
    else:
        print('No')
Problem p03329 (python)

Fixed submission:
N = int(input())

units = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1]

dp = [100000]*(N+1)
dp[0] = 0
dp[1] = 1

for i in range(2, N+1):
    for u in units:
        p = i-u
        if p >= 0:
            dp[i] = min(dp[p]+1, dp[i])

print(dp[N])

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

units = [59049, 46656, 7776, 6561, 1296, 729, 216, 81, 36, 9, 6, 1]

dp = [100000]*100000
dp[0] = 0
dp[1] = 1

for i in range(2, N+1):
    for unit in units:
        if i - unit >= 0:
            dp[i] = min(dp[i-unit]+1, dp[i])

print(dp[N])
Problem p02699 (python)

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

if S <= W:
    print('unsafe') 
else :
    print('safe')

Buggy submission (verdict: Runtime Error):
from itertools import combinations

S = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

a = 1
d = 0

for s in S:
    d = d + int(s)*a
    num = d%2019
    counts[num] += 1
    a *= 10

ans = 0

for i in counts:
    if i >=2:
        x = len(list(combinations(list(range(i)),2)))
        ans += x

print(ans)
Problem p02693 (python)

Fixed submission:
K = int(input())
arr = list(map(int, input().split()))
a = arr[1] % K
b = arr[1] - arr[0]
if a <= b:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
K = int(input())
arr = list(map(int, input()))
a = arr[1] % K
b = arr[1] - arr[0]
if a > b:
    print("OK")
else:
    print("NG")
Problem p02623 (python)

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


def cusum(array):
    for i in range(len(array) - 1):
        array[i + 1] += array[i]


cusum(A)
cusum(B)
A = [0] + A
B = [0] + B
tsundoku = 0
ia = 0
ib = M

for ia in range(N + 1):
    if A[ia] > K:
        break
    while A[ia] + B[ib] > K and ib >= 0:
        ib -= 1
    tsundoku = max(ia + ib, tsundoku)

print(tsundoku)

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

N, M, K = map(int, input().split())
A = deque([int(x) for x in input().split()])
B = deque([int(x) for x in input().split()])
tsundoku = 0

while K > 0:
    if not A:
        K -= B.popleft()
    elif not B:
        K -= A.popleft()
    elif A[0] < B[0]:
        K -= A.popleft()
    elif A[0] > B[0]:
        K -= B.popleft()
    elif A[0] == A[0]:
        if A[1] < B[1]:
            K -= A.popleft()
        elif A[1] > B[1]:
            K -= B.popleft()

    if K >= 0:
        tsundoku += 1

print(tsundoku)
Problem p02831 (python)

Fixed submission:
import fractions
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
print(A * B / math.gcd(A, B))
Problem p02879 (python)

Fixed submission:
A, B = list(map(int, input().split()))
if A <= 9 and B <= 9 :
	print(A * B)
else :
	print(-1)

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input().split()))
if A <= 9 and B =< 9 :
	print(A * B)
else :
	print(-1)
Problem p02951 (python)

Fixed submission:
A, B, C = list(map(int, input().split()))
ans = C - (A - B)
if ans >= 0 :
	print(ans)
else :
	print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N < 10 :
	print(N)
elif N < 100 :
	print(9)
elif N < 1000 :
	print(9 + (N - 100 + 1))
elif N < 10000 :
	print(9 + 900)
elif N < 100000 :
	print(9 + 900 + (N - 10000 + 1))
else :
	print(9 + 900 + 90000)
Problem p02707 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
L = [0] * (N+1)
for i in range(N-1):
  L[A[i]]+=1
for i in range(1,N+1):
  print(L[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
L = [0] * (N+1)
for i in range(N):
  L[A[i]]+=1
for i in range(1,N+1):
  print(L[i])
Problem p02785 (python)

Fixed submission:
import numpy as np
N, K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

sorted_H = sorted(H)
num = np.maximum(0, N-K)
answer = sum(sorted_H[:num])
print(answer)

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

sorted_H = sorted(H)
num = np.maximum(0, N-K)
answer = sum(sorted_H[:num])
print(answer)
Problem p02831 (python)

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

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

def lcm(a, b):
    return (a * b) // gcd(a, b)
	
answer = lcm(A, B)
print(answer)

Buggy submission (verdict: Runtime Error):
import math

A, B = [int(i) for i in input().split()]

answer = (A * B) // math.gcd(A, B)
print(answer)
Problem p02831 (python)

Fixed submission:
A,B=map(int,input().split())
C=A*B
if A<B :
    A,B=B,A
while A%B!=0:
    A,B=B,A%B 
D=C/B
print(int(D))

Buggy submission (verdict: Runtime Error):
A,B=map(int,input().split())
C=A*B
if A<B :
    A,B=B,A
while a%b=0:
    A,B=B,A%B 
D=C/B
print(D)
Problem p02835 (python)

Fixed submission:
A,B,C=map(int,input().split())
if A+B+C>=22:
    print("bust")
elif A+B+C<=21:
    print("win")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input.split)
if A+B+C>=22:
    print("bust")
elif A+B+C<=21:
    print("win")
Problem p02627 (python)

Fixed submission:
alpha = input()

if alpha.islower():
  print('a')
else:
  print('A')

Buggy submission (verdict: Runtime Error):
# a(1)〜z(26)を使った26進数に変換する

import string

N = int(input())
alpha = list(string.ascii_lowercase)
alpha.append('')

# valueに答えとなるalphabetの羅列を入れる
value = []
value.append(alpha[N // (26**10) - 1])

for i in range(10,1,-1):
  value.append(alpha[(N % (26**i)) // (26**(i-1)) - 1])

value.append(alpha[N % (26**1) - 1])

value = ''.join(value)
print(value)
Problem p02623 (python)

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

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break    
    while b[j]>K-a[i]:
        j -= 1    
    ans = max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A_time = list(map(int,input().split()))
B_time = list(map(int,input().split()))
all_time = 0
a_t = A_time.pop(0)
b_t = B_time.pop(0)
count = 1
while all_time < K:
    if a_t <= b_t:
        all_time = all_time + a_t
        if count == 1 and all_time > K:
            count = -1
            break
        a_t = A_time.pop(0)
        count +=1
    else:
        all_time = all_time + b_t
        if count == 1 and all_time > K:
            count = -1
            break
        b_t = B_time.pop()
        count +=1
    if len(A_time)==0 or len(B_time)==0:
        break
        
if all_time > K:
    print(count-1)
elif count == -1:
    print(0)
else:
    if len(A_time)==0:
        while all_time > K:
            all_time = all_time + b_t
            count += 1
            b_t = B_time.pop(0)
        print(count - 1)
    else:
        while all_time > K:
            all_time = all_time + a_t
            count += 1
            b_t = A_time.pop(0)
        print(count - 1)
Problem p02659 (python)

Fixed submission:
A,B = input().split()
B = int(B.replace(".",""))
A = int(A)
print(int(A*B//100))

Buggy submission (verdict: Runtime Error):
A,B = input().split()
B = int(B*100)
A = int(A)
print(int(A*B//100))
Problem p02699 (python)

Fixed submission:
S,W = map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    si = input()
    if si not in S:
        S = S + [si]
print(len(S))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = []
for i in range(N):
    si = input()
    S = S + [si]
print(len(set(S)))
Problem p02659 (python)

Fixed submission:
a,b = input().split()
a = int(a)
b = round(float(b)*100)
p = (a*b)//100
print(p)

Buggy submission (verdict: Runtime Error):
a,b = input().split()
a = int(a)
b = int(b*100)
p = (a*b)//100
print(p)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
p = a*b
print(int(p))
Problem p02781 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

n, k = map(int, read().split())


@lru_cache()
def check(n, k):
    if n < 10:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, k)
    return cnt


print(check(n, k))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from functools import lru_cache

n, k = map(int, read().split())


@lru_cache(None)
def check(n, k):
    a, b = divmod(n, 10)
    cnt = 0
    if k >= 1:
        cnt += check(a, k - 1) * b
        cnt += check(a - 1, k - 1) * (9 - b)
    cnt += check(a, b)
    return cnt


if n < 10:
    if k == 1:
        print(n)
    else:
        print(0)
else:
    print(check(n, k))
Problem p02793 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
A = list(map(int, readline().split()))
mod = 10 ** 9 + 7


def lcm(X, Y):
    x = X
    y = Y
    if y > x:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return X * Y // y


cnt = 0
ans = 0
LCM = 1
for i in range(n):
    Q = lcm(LCM, A[i])
    cnt *= Q // LCM
    LCM = Q
    cnt += Q // A[i]
print(cnt % mod)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from math import gcd

n = int(readline())
a = list(map(int, readline().split()))
ans = 0
gcd_ans = a[0]
lcm_ans = a[0]
mod = 10 ** 9 + 7
for i in range(1, n):
    gcd_ans = gcd(lcm_ans, a[i])
    lcm_ans = lcm_ans * a[i] // gcd_ans
for i in range(n):
    ans += lcm_ans // a[i]
    ans %= mod
print(ans % mod)
Problem p03018 (python)

Fixed submission:
import sys
input = sys.stdin.readline

s = input()
s = s[::-1]
ans = 0
a = -1
s = (s.replace('CB', 'D').replace('C', '\t').replace('B', '\t')).split()
for i in range(len(s)):
    for j in range(s[i].count('A')):
        a = s[i].find('A',a+1)
        ans += a-j
    a = -1
print(ans)

Buggy submission (verdict: Runtime Error):
import re

s = input()
s = s[::-1]
ans = 0
for i in range(s.count('A')):
    a = re.search('(CB)+A', s)
    ans += (a.end()-a.start()-1)//2
    s = s.replace('A', '', 1)
    print((a.end()-a.start()),s,ans)
print(ans)
Problem p03054 (python)

Fixed submission:
h, w, n = map(int, input().split())
ar, ac = map(int, input().split())
s = input()
t = input()
r = ac
l = ac
u = ar
d = ar
ans = False

for i in range(n):
    if s[i] == "R":
        r += 1
    if s[i] == "L":
        l -= 1
    if s[i] == "U":
        u -= 1
    if s[i] == "D":
        d += 1
    if l==0 or r==w+1 or u==0 or d==h+1:
        print("NO")
        ans = True
        break
        
    if t[i] == "R" and l != w:
        l += 1
    if t[i] == "L" and r != 1:
        r -= 1
    if t[i] == "U" and d != 1:
        d -= 1
    if t[i] == "D" and u != h:
        u += 1
 
if ans != True:
    print("YES")

Buggy submission (verdict: Runtime Error):
h, w, n = map(int, input().split())
ar, ac = map(int, input().split())
s = input()
t = input()
r = ac
l = ac
u = ar
d = ar

for i in range(n):
    if s[i] == "R":
        r += 1
    if s[i] == "L":
        l -= 1
    if s[i] == "U":
        u -= 1
    if s[i] == "D":
        d += 1
    if l==0 or r==w+1 or u==0 or d==h+1:
        print("NO")
        ans = True
        break
        
    if t[i] == "R" and l != w:
        l += 1
    if t[i] == "L" and r != 1:
        r -= 1
    if t[i] == "U" and d != 1:
        d -= 1
    if t[i] == "D" and u != h:
        u += 1
 
if ans != True:
    print("YES")
Problem p03104 (python)

Fixed submission:
def xy(a):
    if a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    elif a % 4 == 3 or a == 0:
        return 0
    else:
        return a

a, b = map(int, input().split())
ans = xy(b) ^ xy(a - 1)
print(ans)

Buggy submission (verdict: Runtime Error):
def xy(a)
    if a % 4 == 1:
        return 1
    elif a % 4 == 2:
        return a + 1
    elif a % 4 == 3 or a == 0:
        return 0
    else:
        return a

a, b = map(int, input().split())
ans = xy(b) ^ xy(a - 1)
print(ans)

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

a=bin(0)
for i in range(A,B+1):
    i=bin(i)
    a=bin(a^i)
print(a)
Problem p03107 (python)

Fixed submission:
S = input()

red = S.count('0')
blue = S.count('1')
N = 2 * min(red,blue)

print(N)

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

red = S.count('0')
blue = S.count('1')
N = red + blue

if red > blue:
    ans = N - (red - blue)
elif blue < red:
    ans = N - (blue - red)
print(ans)

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

red = S.count('0')
blue = S.count('1')
N = red + blue

if red > blue:
    ans = N - (red - blue)
elif blue < red:
    ans = N - (blue - red)
print(ans)
Problem p03137 (python)

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

if n >= m:
    ans = 0
else:
    x.sort()
    cheak = [0]*(m-1)
    
    for i in range(m-1):
        cheak[i] = abs(x[i+1]-x[i])
    cheak.sort(reverse=True)
    
    for j in range(n-1):
        cheak.pop(0)
    
    ans = sum(cheak)
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
cheak = [0]*m
for i in range(m):
    cheak[m] = abs[x[m+1]-x[m]]
cheak.sort()
for j in range(n-1):
    cheak.pop(m-j)
ans = sum(cheak)
print(ans)
Problem p03250 (python)

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

A = 10*a+b+c
B = 10*b+a+c
C = 10*c+a+b
print(max(A, B, C))

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

if (a>b) and (a>c):
    ans = 10*a+b+c
elif = (b>a) and (b>c):
    ans = 10*b+a+c
else:
    ans = 10*c+a+b
print(ans)