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

Fixed submission:
[a0,b0,k]=input().split()
a0=int(a0)
b0=int(b0)
k =int(k)
if a0>k:
    ak=a0-k
    bk=b0
else:
    ak=0
    bk=b0-(k-a0)

if bk<0:
    bk=0
    
print(ak,bk)

Buggy submission (verdict: Runtime Error):
[a0,b0,k]=input().split()
if a0>k:
	ak=a0-k
    bk=b0
else: 
	ak=0
  	bk=b0-(k-a0)

if bk<0:
  bk=0

print(ak,bk)
Problem p03109 (python)

Fixed submission:
#coding:utf-8

if __name__ == "__main__":

    i = str(input())

    j = i.split('/')

    if int(j[0]) < 2019:
        print("Heisei")
    elif int(j[1]) < 5:
        print("Heisei")
    else:
        print("TBD")

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

if __name__ == "__main__":

    i = str(input())

    j = i.split('/')

    if int(j[0]) < 2019:
        print("Heisei")
    elif int(j[1].split('0')[1]) < 5:
        print("Heisei")
    else:
        print("TBD")

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

if __name__ == "__main__":

    i = str(input())

    j = i.split('/')

    print(j[1].split('0')[1])

    if int(j[0]) < 2019:
        print("Heisei")
    elif int(j[1].split('0')[1]) < 5:
        print("Heisei")
    else:
        print("TBD")
Problem p02801 (python)

Fixed submission:
def main():
    s = input()
    print(chr(ord(s) + 1))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    def f(m, n, k):
        return int(math.factorial(n-1-m)/(math.factorial(k-1)*math.factorial(n-k-m)))
    n, k = list(map(int, input().split()))
    a = list(map(int, input().split()))
    a = sorted(a)
    # print(a)
    ans = 0
    law = int(pow(10, 9) + 7)
    for i in range(n - k + 1):
        # print(i, n, k)
        # print(f(i, n, k))
        ans += (a[n-1-i] - a[i]) * f(i, n, k)
        ans = ans % law
    print(int(ans))
if __name__ == "__main__":
    main()
Problem p03836 (python)

Fixed submission:
sx, sy, tx, ty = [int(x) for x in input().split()]
x = tx - sx
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))

Buggy submission (verdict: Runtime Error):
sx, sy, tx, ty = [int(x) for x in input().split()]
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))

Buggy submission (verdict: Runtime Error):
from sys import stdin
sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
x = tx - sx
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))

Buggy submission (verdict: Runtime Error):
from sys import stdin
def main():
    sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
    x = tx - sx
    y = ty - sy
    l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
    print("".join(l))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
sx, sy, tx, ty = [int(x) for x in stdin().readline().rstrip().split()]
x = tx - sx
y = ty - sy
l = ["R"]*x + ["U"]*y + ["L"]*x + ["D"]*y + ["D"] + ["R"] * (x+1) + ["U"]*(y+1) + ["L"] + ["U"] + ["L"]*(x+1) + ["D"]*(y+1) +["R"]
print("".join(l))
Problem p04029 (python)

Fixed submission:
def main():
    n = int(input())
    print(int((n * (n + 1)) / 2))
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = input()
    print((n * (n + 1)) / 2)
if __name__ == '__main__':
    main()
Problem p04043 (python)

Fixed submission:
x = list(map(int, input().split()))
x.sort()
if x[0] == 5 and x[1] == 5 and x[2]== 7:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = map(int, input().split())
x.sort()
if x[0] == 5 and x[1] == 5 and x[2]== 5:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = map(int(), input().split())
x.sort()
if x[0] == 5 and x[1] == 5 and x[2]== 5:
  print("YES")
else:
  print("NO")
Problem p04047 (python)

Fixed submission:
N = int(raw_input())
L = map(int,raw_input().split())
L.sort(reverse = True)
ans = 0
for i in xrange(N):
    ans += min(L[2*i],L[2*i+1])
print ans

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
list_input = sorted(map(int, raw_input().split()))
print(sum(list_input[::2]))

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
list_input = map(int, raw_input().split())

list_input = sorted(list_input)
sums = 0
for i in range(0,2*N,2):
    print(i)
    sums += min(list_input[i],list_input[i+1])
print(sums)

Buggy submission (verdict: Runtime Error):
N = int(raw_input())
list_input = map(int, raw_input().split())

list_input = sorted(list_input)
sums = 0
for i in range(0,2*N,2):
    sums += min(list_input[i],list_input[i+1])

print(sums)

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

list_input = sorted(list_input)
sums = 0
for i in range(0,2*N,2):
    sums += min(list_input[i],list_input[i+1])

print(sums)

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

list_input = sorted(list_input)
sums = 0
for i in range(0,2*N,2):
    sums += min(list_input[i],list_input[i+1])

print(sums)

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

list_input = sorted(list_input)
sums = 0
for i in range(N,2*N):
    sums += list_input[i]

print(sums)
Problem p02706 (python)

Fixed submission:
data = list(map(int, input().split()))
# data = list(map(int, "41 2".split()))

N = data[0] # days of summer vacation
M = data[1] # summer assignments

A = 0 # days to do the i-th assignment.

assignments = list(map(int, input().split()))
# assignments = list(map(int, "5 6".split()))

if sum(assignments) <= N :
    print(N-sum(assignments))
else :
    print(-1)

Buggy submission (verdict: Runtime Error):
data = list(map(int, input().split()))
# data = list(map(int, "41 2 5 6".split()))

N = data[0] # days of summer vacation
M = data[1] # summer assignments

A = 0 # days to do the i-th assignment.

for i in range(2, M+2) :
    # print(data[i])
    A += data[i]

if A <= N :
    print(N-A)
else :
    print(-1)

Buggy submission (verdict: Runtime Error):
inputdata = list(map(input().split()))
# data = list(map(int, "41 2 5 6".split()))

N = data[0] # days of summer vacation
M = data[1] # summer assignments

A = 0 # days to do the i-th assignment.

for i in range(2, M+2) :
    # print(data[i])
    A += data[i]

if A <= N :
    print(N-A)
else :
    print(-1)
Problem p03071 (python)

Fixed submission:
A,B = map(int,input().split())
 
if A > B:
  max = A + A - 1
  print(max)
elif B > A:
  max = B + B - 1
  print(max)
elif A == B:
  max = A + B
  print(max)

Buggy submission (verdict: Runtime Error):
A,B = input().split()
 
if A > B:
  max = A + A - 1
  print(max)
elif B > A:
  max = B + B - 1
  print(max)
elif A == B:
  max = A + B
  print(max)

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
 
if A > B:
  max = A + A - 1
  print(max)
elif B > A:
  max = B + B - 1
  print(max)
elif A == B:
  max = A + B
  print(max)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
 
if A > B:
  max = A + A - 1
  print(max)
elif B > A:
  max = B + B -1
  print(max)
elif A == B:
  max = A + B
  print(max)

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

if A > B:
  max = A + A
  print(max)
elif B > A:
  max = B + B
  print(max)
elif A = B:
  max = A + B
  print(max)
Problem p02981 (python)

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

N = input_arr[0]
A = input_arr[1]
B = input_arr[2]

train = N*A
taxi = B

if train > taxi:
    print(taxi)
else:
    print(train)

Buggy submission (verdict: Runtime Error):
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

if R-L>=2019:
  min_ans=0
else:
  for i in range(L,R):
      for j in range(i+1,R+1):
          ans = (i*j)%2019

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)
Problem p02983 (python)

Fixed submission:
L,R = [int(x) for x in input().split()]
 
min_ans = 10**18

if R-L>=2019:
  min_ans=0
else:
  for i in range(L,R):
      for j in range(i+1,R+1):
          ans = (i*j)%2019

          if ans < min_ans:
              min_ans = ans
          if min_ans == 0:
              break
print(min_ans)

Buggy submission (verdict: Runtime Error):
L,R = [int(x) for x in input().split()]
 
#L = input_arr[0]
#R = input_arr[1]
 
min_ans = 10**18
for i in range(L+1,R+1):
  if ans < min_ans:
    min_ans = ans
  if min_ans == 0:
    break

print(min_ans)

Buggy submission (verdict: Runtime Error):
input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
      	ans = (i*j)%2019
        if ans < min_ans:
            min_ans = ans
        if min_ans == 0:
          break
print(min_ans)

Buggy submission (verdict: Runtime Error):
input_arr = [int(x) for x in input().split()]
 
L = input_arr[0]
R = input_arr[1]
 
min_ans = 10**18
for i in range(L,R):
    for j in range(i+1,R+1):
        if (i*j)%2019 < min_ans:
            min_ans = ans
print(min_ans)
Problem p03079 (python)

Fixed submission:
input_number = input().rstrip().split(' ')
if (input_number[0] == input_number[1])and (input_number[1] == input_number[2]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
input_num = int(input())
input_color = input()
r_num = 0
b_num = 0
for color in input_color:
    if color == "R":
        r_num += 1
    if color == "B":
        b_num += 1
if r_num > b_num:
    print("Yes")
else:
    print("No")
Problem p02718 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
pop = 1/(4*M)*sum(A)
lis = []
for i in A:
    if i>=pop:
        lis.append(i)
if len(lis)>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
pop = int(1/(4*M)*sum(A))
lis = []
for i in A:
    if i>=pop:
        lis.append(i)
if len(lis)>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
pop = 1/(4*M)*sum(A)
lis = []
for i in A:
    if i>pop:
        lis.append(i)
if len(lis)>=M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
pop = 1/(4*M)*sum(A)
lis = []

for i in A:
    if i>pop:
        lis.append(i)
if len(lis)>=M:
    print("Yes")
else:
    print("No")
Problem p02717 (python)

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

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n >= k:
  print(n%k)
 
else:
  print(min(n, abs(k-n)))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
num = int(sum(a)/(4*m))
if a[m-1] < num:
  print('No')
else:
  print('Yes')
Problem p03160 (python)

Fixed submission:
N = int(input())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2, N):
    dp[i] = dp[i-1]+abs(h[i]-h[i-1])
    dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
for i in range(N):
    dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, K)+1))
 
print(dp[N-1])
Problem p03161 (python)

Fixed submission:
import numpy as np
N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = np.min(dp[j:i]+np.abs(h[i]-h[j:i]))
                 
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
[*h] = map(int, input().split())
dp = [float('inf') for _ in range(N)]
dp[0] = 0
for i in range(N):
    dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i, K)+1))
 
print(dp[N-1])
Problem p02730 (python)

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


def check_kaibun(kaibun):
    n = len(kaibun)
    middle = n // 2
    count = 0
    for i in range(middle):
        if kaibun[i] == kaibun[n - i - 1]:
            count += 1
        else:
            count = 0
            break
    if count == middle:
        return True
    else: 
        return False


left_center = (l-2) // 2
right_center = (l+2) // 2

check0 = check_kaibun(s)
check1 = check_kaibun(s[:left_center + 1])
check2 = check_kaibun(s[right_center:])

if (check0 == True) and (check1 == True) and (check2 == True): 
    print("Yes")
else:
    print("No")

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

"""
def check_kaibun(kaibun):
    n = len(kaibun)
    middle = n // 2
    count = 0
    print("s[i]:{}".format(kaibun))
    for i in range(middle):
        if kaibun[i] == kaibun[n - i]:
            count += 1
        else:
            count = 0
            break
    if count == middle:
        return True
    else: 
        return False
"""

left_center = (l-2) // 2
right_center = (l+2) // 2

for i in range(left_center // 2):
    if s[i] != s[left_center - i]:
        print("No")
        break
else:
    for i in range(len(s[right_center:]) // 2):
        if s[right_center + i] != s[l - i - 1]:
            print("No")
            break
    else:
        right = True
"""
check1 = check_kaibun(s[:left_center])
check2 = check_kaibun(s[right_center:])
"""
if right == True: 
    print("Yes")
Problem p02706 (python)

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

a = sum(int(i) for i in a)

asobi = n -a
if asobi >= 0:
  print(asobi)
else:
  print(-1)

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

a = sum(int(i) for i in a)

asobi = n -a
if asobi => 0:
  print(asobi)
else:
  print(-1)
Problem p02945 (python)

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

print(max([a+b, a-b, a*b]))

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

print(max(a+b, a-b, a*b)
Problem p02957 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
 
k = a+b
if k%2==0:
  print(k//2)
else:
  print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

k = a+b
if k%2==0:
  return k/2
else:
  return 'IMPOSSIBLE'

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

k = a+b
if k%2==0:
  return k/2
else:
  print('IMPOSSIBLE')
Problem p02958 (python)

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

sorted_b = [i+1 for i in range(a)]

diff = [x-y for (x,y) in zip(sorted_b, b)]

if len([i for i in diff if i != 0]) <= 2:
  print('YES')
else:
  print('NO')

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

sorted_b = [i+1 for i in range(a)]

diff = [x-y for (x,y) in zip(sorted_b, b)]

if len([i for i in diff if i == 0]) == 2:
  print('YES')
else:
  print('NO')
Problem p02787 (python)

Fixed submission:
import numpy as np
h, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = np.array(sorted(VW, key=lambda x:(x[0]/x[1],x[0])))
a = VW[:, 0]
b = VW[:, 1]

dp = np.zeros(10**4+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])

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

M, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = sorted(VW, key=lambda x:(x[0]/x[1],x[0]))

@lru_cache(maxsize=None)
def dp(h):
    if h<=0:
        return 0
    else:
        best = float("inf")
        for a,b in VW:
            val = b+dp(h-a)
            if val < best:
                best = val
            else:
                break
        return best
print(dp(M))

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

M, N = map(int,input().split())
VW = [[int(x) for x in input().split()] for _ in range(N)]
VW = sorted(VW, key=lambda x:(x[0]/x[1],x[0]))
@lru_cache(maxsize=None)
def dp(h):
    if h<=0:
        return 0
    else:
        best = float("inf")
        for a,b in VW:
            val = b+dp(h-a)
            if val < best:
                best = val
            else:
                break
        return best
print(dp(M))
Problem p02796 (python)

Fixed submission:
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[0]+x[1])
m = -float("inf")
ans = 0
for n in range(N):
    if XL[n][0]-XL[n][1] >= m:
        ans += 1
        m = XL[n][0]+XL[n][1]
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
    a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
    if max(a) != 0:
        ans += 1
    else:
        s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
	XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
	a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
	if a.max() != 0:
		ans += 1
	else:
		s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
XL = []
for n in range(N):
    XL.append([int(x) for x in input().split()])
XL = sorted(XL, key=lambda x:x[1])
s = np.zeros(2*(10**9))
ans = 0
for n in range(N):
    a = s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]]
    if a.max() != 0:
        ans += 1
    else:
        s[max(XL[n][0]-XL[n][1],-1)+1:XL[n][0]+XL[n][1]] += 1
print(N-ans)
Problem p02866 (python)

Fixed submission:
N = int(input())
D = [int(x) for x in input().split()]
new_l = [0 for n in range(max(D)+1)]
for n in range(N):
    new_l[D[n]] += 1
if new_l[0] == 1 and D[0] == 0:
    res = 1
    for n in range(max(D)):
        res *= pow(new_l[n],new_l[n+1],998244353)
    print(res%998244353)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = [int(x) for x in input().split()]
D = sorted(D)
new_l = [0 for n in range(max(D))]
ini = D[0]
for n in range(N):
    new_l[D[n]] += 1
res = new_l[0]**new_l[1]
for n in range(1,len(new_l)-1):
    res *= new_l[n]**new_l[n+1]
    res %= 998244353
print(res%998244353)
Problem p02867 (python)

Fixed submission:
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
I = B.argsort()
A = A[I]
B = B[I]
calc = max(A) <= max(B)
if not calc:
    print("No")
    exit(0)
if any(np.sort(A)[1:] <= B[:-1]):
    print('Yes')
    exit()
p = A.argsort().tolist()
x = 0
c = 0
while True:
    c += 1
    x = p[x]
    if x == 0:
        break
print("Yes" if c != N else "No")

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array([int(x) for x in input().split()])
B = np.array([int(x) for x in input().split()])
I = B.argsort()
A = A[I]
B = B[I]
calc = max(A) <= max(B)
if not calc:
    print("No")
    exit(0)
if any(A.sort()[1:] <= B[:-1]):
    print('Yes')
    exit()
p = A.argsort().tolist()
x = 0
c = 0
while True:
    c += 1
    x = p[x]
    if x == 0:
        break
print("Yes" if p != N else "No")
Problem p02899 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = []
for x in tmp:
  res.append(x[0])
print(*res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = ""
for x in tmp:
  res.append(x[0])
print(*res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
tmp = list()
for n in range(len(A)):
  tmp.append([n+1, A[n]])
tmp = sorted(tmp, key=lambda x: x[1])
res = ""
for x in tmp:
  res.append(x[0])
print(' '.join(res))
Problem p02910 (python)

Fixed submission:
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if 2*x < len(S):
    if S[2*x] not in ["R","U","D"]:
      res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)

Buggy submission (verdict: Runtime Error):
S = input()
res = "Yes"
for x in range(int(len(S)/2)+1):
  if S[2*x] not in ["R","U","D"]:
    res = "No"
  if 2*x + 1 < len(S):
    if S[2*x+1] not in ["L","U","D"]:
      res = "No"
print(res)

Buggy submission (verdict: Runtime Error):
S = input()
res = "Yes"
for n in range(int(len(S/2))):
  if S[2*n+1] not in ["R","U","D"]:
    res = "No"
  if S[2*n] not in ["L","U","D"]:
    res = "No"
print(res)
Problem p02995 (python)

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())
def F(x):
    l = x//C
    l += x//D
    lcm = C*D//fractions.gcd(C,D)
    l -= x//lcm
    return x-l
print(F(B)-F(A-1))

Buggy submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())
l = int((B-A)/C)
m = int((B-A)/D)
lcm = C*D/math.gcd(C,D)
c = B-A-l-m+int((B-A)/lcm)
print(c)

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

l = int((B-A)/C)
m = int((B-A)/D)
lcm = C*D/math.gcd(C,D)
c = B-A-l-m+int((B-A)/lcm)
print(c)
Problem p03565 (python)

Fixed submission:
S = input()
T = input()
ss = list()
for n in range(len(S)-len(T)+1):
    for m in range(len(T)):
        if S[n+m] not in ["?", T[m]]:
            break
    else:
        ss.append((S[:n]+T+S[n+len(T):]).replace("?","a"))
if len(ss) == 0:
    print("UNRESTORABLE")
else:
    print(min(ss))

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
for n in range(len(S)):
    if S[n] == T[0]:
        noOfnext = 0
        for m in range(n+1, len(S)):
            if S[m] == "?":
                noOfnext += 1
            else:
                break
        if noOfnext < len(T)-1:
            continue
        else:
            for m in range(noOfnext):
                S[n+1+m] = T[m+1]
            for k in range(len(S)):
                if S[k] == "?":
                    S[k] = "a"
if "?" in S:
    print("UNRESTORABLE")
else:
    print("".join(S))
Problem p02732 (python)

Fixed submission:
from collections import defaultdict


def num_combinations(_n):
    return _n * (_n - 1) // 2


if __name__ == '__main__':
    n = int(input())
    xs = [int(s) for s in input().split()]
    freq = defaultdict(int)

    for n in xs:
        freq[n] += 1

    total = sum([num_combinations(n) for n in freq.values()])
    for x in xs:
        print(total - (freq[x] - 1))

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

mem = {}


def binomialCoeff(n, k):
    if n < k:
        return 0
    if k == 0 or k == n:
        return 1
    if n in mem.keys():
        return mem[n]

    # Recursive Call
    mem[n] = binomialCoeff(n - 1, k - 1) + binomialCoeff(n - 1, k)
    return mem[n]


if __name__ == '__main__':
    n = int(input())
    xs = [int(s) for s in input().split()]
    freq = defaultdict(int)
    xs_res = defaultdict(int)

    for n in xs:
        freq[n] += 1
        if freq[n] > 2:
            xs_res[n] *= 2
        if freq[n] > 1:
            xs_res[n] += 1

    res = 0

    for k in range(len(xs)):
        res = 0
        for num in freq.keys():
            res += binomialCoeff(freq[num] if num != xs[k] else freq[num] - 1, 2)
        print(res)