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

Fixed submission:
import collections

N = int(input())
A = list(map(int, input().split()))
A = collections.Counter(A)
B = []
C = []
for i in A:
    if A[i] == 1:
        B.append(i)
    else:
        C.append(i)
B = sorted(B)
if len(B) == 0:
    print(0)
    exit()
mb = 1000000
ok = [True] * (mb+1)

if len(C) > 0:
    C = sorted(C)
    for c in C:
        if not ok[c]:
            continue
        k = 2
        while k*c <= mb:
            ok[k*c] = False
            k += 1

for b in B:
    if not ok[b]:
        continue
    k = 2
    while k*b <= mb:
        ok[k*b] = False
        k += 1

ans = 0
for b in B:
    if ok[b]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int, input().split()))
A = collections.Counter(A)
B = []
C = []
for i in A:
    if A[i] == 1:
        B.append(i)
    else:
        C.append(i)
B = sorted(B)
if len(B) == 0:
    print(0)
    exit()
mb = B[-1]
ok = [True] * (mb+1)

if len(C) > 0:
    C = sorted(C)
    for c in C:
        if not ok[c]:
            continue
        k = 2
        while k*c <= mb:
            ok[k*c] = False
            k += 1

for b in B:
    if not ok[b]:
        continue
    k = 2
    while k*b <= mb:
        ok[k*b] = False
        k += 1

ans = 0
for b in B:
    if ok[b]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N = int(input())
A = list(map(int, input().split()))
A = collections.Counter(A)
B = []
C = []
for i in A:
    if A[i] == 1:
        B.append(i)
    else:
        C.append(i)
B = sorted(B)
if len(B) == 0:
    print(0)
    exit()
mb = B[-1]
ok = [True] * (mb+1)

C = sorted(C)
for c in C:
    if not ok[c]:
        continue
    k = 2
    while k*c <= mb:
        ok[k*c] = False
        k += 1

for b in B:
    if not ok[b]:
        continue
    k = 2
    while k*b <= mb:
        ok[k*b] = False
        k += 1

ans = 0
for b in B:
    if ok[b]:
        ans += 1

print(ans)
Problem p02678 (python)

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

paths = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    paths[a].add(b)
    paths[b].add(a)

rooms = [-1] * N
rooms[0] = 0
marks = [-1] * (N-1)
key_rooms = [[0]]
for step in range(1, N):
    next_key_rooms = set()
    for key_room in key_rooms[-1]:
        for else_room in paths[key_room]:
            if rooms[else_room] == -1:
                rooms[else_room] = step
                next_key_rooms.add(else_room)
                marks[else_room-1] = key_room
    key_rooms.append(next_key_rooms)

print('Yes')
for i in marks:
    print(i+1)

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

paths = [set() for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    paths[a].add(b)
    paths[b].add(a)

rooms = [-1] * N
rooms[0] = 0
marks = [-1] * (N-1)
key_rooms = [[0]]
for step in range(1, N):
    next_key_rooms = set()
    for key_room in key_rooms[-1]:
        for else_room in paths[key_room]:
            if rooms[else_room] == -1:
                rooms[else_room] = step
                next_key_rooms.add(else_room)
                marks[else_room-1] = key_room
    key_rooms.append(next_key_rooms)

print('Yes')
for i in marks:
    print(i+1)
Problem p02690 (python)

Fixed submission:
X = int(input())

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)
    divisors.sort()
    save = -1
    for i in range(len(divisors)):
        if divisors[i] >= 200:
            save = i
            break
    if save > 0:
        divisors = divisors[:save]
    return divisors

def f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-120
  b = -120
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -120
  b = -div-120
  while f(a, b) > X and b < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])

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

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 f(a, b):
  return a**5 - b**5

divs = make_divisors(X)
ans = 0
for div in divs:
  a = -div-100
  b = -100
  while f(a, b) < X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
  a = -100
  b = -div-100
  while f(a, b) > X and a < 2:
    a += 1
    b += 1
  if f(a, b) == X:
    ans = (a, b)
    
print(ans[0], ans[1])
Problem p02691 (python)

Fixed submission:
import collections
N = int(input())

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

plus = [0] * (N-1)
for i in range(N-1):
  plus[i] = i + A[i]

minus = [0] * (N-1)
for j in range(1, N):
  minus[j-1] = j - A[j]

sum = 0
c = dict(collections.Counter(minus))
for i in range(N-1):
  sum += c.get(plus[i], 0)
  c[minus[i]] -= 1

print(sum)

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

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

count = 0
for i in range(N-1):
    for j in range(i+1, N):
        if abs(i-j) == a[i] + a[j]:
            count += 1
            
print(count)
Problem p02714 (python)

Fixed submission:
n = int(input())
s = input()
r = []
g = []
b = []

ans = s.count("R")*s.count("G")*s.count("B")

for i in range(n):
    for j in range(i+1,n):
        k = 2*j-i
        if k>=n:
          break
        ans -= s[k] != s[i] != s[j] != s[k]

print(ans)

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

r = []
g = []
b = []
for i in range(n):
  if s[i] == 'R':
    r.append(i)
  elif s[i] == 'G':
    g.append(i)
  else:
    b.append(i)
mcount = 0
for i in range((n-1)/2-1):
  for j in range(i+1, n-1-1-i):
    if s[j] != s[j-i-1] and s[j] != s[j+i+1] and s[j-i-1] != s[j+i+1]:
      mcount += 1
  

for i in range(n):
  if i in r:
    for j in g:
      for k in b:
        if k < j:
          continue
        count += 1
    for j in b:
      for k in g:
        if k < j:
          continue
        count += 1      
  if i in g:
    for j in r:
      for k in b:
        if k < j:
          continue
        count += 1
    for j in b:
      for k in r:
        if k < j:
          continue
        count += 1
  if i in b:
    for j in g:
      for k in r:
        if k < j:
          continue
        count += 1
    for j in r:
      for k in g:
        if k < j:
          continue
        count += 1
  if i in r:
    r = r[1:]
  elif i in g:
    g = g[1:]
  else:
    b = b[1:]

print(count-mcount)
Problem p02803 (python)

Fixed submission:
from collections import deque
import copy
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = set()
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '.':
      start.add((x, y))

score = -1
ssize = [(-1,0),(0,-1),(1,0),(0,1)]
for xy in start:
  d = deque()
  d.append((xy+(0,)))
  step = 0
  can = copy.deepcopy(start)
  can.remove(xy)
  while len(d) > 0:
    now = d.popleft()
    step = now[2]
    for xs, ys in ssize:
      nxt = (now[0]+xs, now[1]+ys)
      if nxt in can:
        d.append(nxt+(step+1,))
        can.remove(nxt)
  score = max(step, score)
  
print(score)

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = []
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '#':
      wall.add((x, y))
    else:
      start.append((x, y))

score = -1
ssize = [(-1,0),(0,-1),(1,0),(0,1)]
for xy in start:
  d = deque()
  d.append((xy[0],xy[1],0))
  step = 0
  already = set() | wall
  while len(d) > 0:
    now = d.popleft()
    already.add(now[:-1])
    step = now[2]+1
    for xs, ys in ssize:
      x,y = now[0]+xs, now[1]+ys
      if (x, y) not in already and 0 =< x < W and 0 =< y < H:
        d.append((x, y, step))
  score = max(step-1, score)
  
print(score)

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
 
route = []
for _ in range(H):
  route.append(input())
  
wall = set()
start = []
for y, r in enumerate(route):
  for x, w in enumerate(r):
    if w == '#':
      wall.add((x, H-y-1))
    else:
      if y > 0 and y < H and x > 0 and x < W:
        a = route[H-y-1+1][x] == '#'
        b = route[H-y-1][x+1] == '#'
        c = route[H-y-1-1][x] == '#'
        d = route[H-y-1][x-1] == '#'
        if (a and c) or (b and d):
          continue
      start.append((x, H-y-1))

score = -1
for xy in start:
  d = deque()
  d.append((xy[0],xy[1],0))
  step = 0
  already = set() | wall
  while len(d) > 0:
    now = d.popleft()
    already.add(now[:-1])
    step = now[2]+1
    x,y = now[0]-1, now[1]
    if (x, y) not in already and x >= 0:
      d.append((x, y, step))
    x, y = x+1, y-1
    if (x, y) not in already and y >= 0:
      d.append((x, y, step))
    x, y = x+1, y+1
    if (x, y) not in already and x < W:
      d.append((x, y, step))
    x, y = x-1, y+1
    if (x, y) not in already and y < H:
      d.append((x, y, step))
  score = max(step-1, score)
  
print(score)
Problem p02830 (python)

Fixed submission:
n = int(input())
s, t = input().split()

for i, j in zip(s, t):
  print(i+j, end='')
  
print()

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

for i, j in zip(s, t):
  print(s+t, end='')
  
print()
Problem p02850 (python)

Fixed submission:
N = int(input())
edges = []
node = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  edges += (a-1, b-1),
  node[a-1] += b-1,
  node[b-1] += a-1,

stuck = [(0,0)]
f = [1]+[0]*N
color_dic = dict()
while stuck:
  v, color = stuck.pop()
  i = 0
  for w in node[v]:
    if f[w]:
      continue
    f[w] = 1
    i += 1
    if i == color:
      i += 1
    stuck += (w,i),
    color_dic[v,w] = i

ans = []
for a,b in edges:
  if (a,b) in color_dic:
    ans += color_dic[a,b],
  else:
    ans += color_dic[b,a],

print(max(ans))
for i in ans:
  print(i)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
edges = []
count = np.zeros(N)
for _ in range(N-1):
  a, b = map(int, input().split())
  edges.append([a, b])
  count[a-1] += 1
  count[b-1] += 1
  
MAX = int(np.max(count))

color = [0 for _ in range(N-1)]
used = [set() for _ in range(N)]
for _ in range(N-1):
  id = np.argmax(count)
  count[id] = 0
  id += 1
  for k, [i,j] in enumerate(edges):
    if (i != id and j != id) or color[k] != 0:
      continue
    for l in range(MAX):
      c = l+1
      if c in used[i-1] or c in used[j-1]:
        continue
      used[i-1].add(c)
      used[j-1].add(c)
      color[k] = c
      break

print(MAX)
for i in color:
  print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
edges = []
count = [0 for _ in range(N)]
for _ in range(N-1):
  a, b = map(int, input().split())
  edges.append([a, b])
  count[a-1] += 1
  count[b-1] += 1
  
MAX = max(count)

color = [0 for _ in range(N-1)]
used = [set() for _ in range(N)]

for k, [i,j] in enumerate(edges):
  for l in range(MAX):
    c = l+1
    if c in used[i-1] or c in used[j-1]:
      continue
    used[i-1].add(c)
    used[j-1].add(c)
    color[k] = c
    break

print(MAX)
for i in color:
  if i == 0:
    print(input())
  print(i)
Problem p03160 (python)

Fixed submission:
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  if p < n-2:
    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
    d[p] = m
    return m
  if p == n-2:
    return dp(p+1)+abs(h[p]-h[p+1])

print(dp(0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  if p < n-2:
    m = min(dp(p+1)+abs(h[p]-h[p+1]), dp(p+2)+abs(h[p]-h[p+2]))
    d[p] = m
    return m
  if p == n-2:
    return dp(p+1)+abs(h[p]-h[p+1])

print(dp(0, 0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1e+5)
 
n = int(input())
 
h = [int(i) for i in input().split()]
 
def dp(cost, p):
  if p == n-1:
    return cost
  if p < n-2:
    return min(dp(cost+abs(h[p]-h[p+1]), p+1), dp(cost+abs(h[p]-h[p+2]), p+2))
  if p == n-2:
    return dp(cost+abs(h[p]-h[p+1]), p+1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)

n = int(input())

h = [int(i) for i in input().split()]

def dp(cost, p):
  if p == n-1:
    return cost
  if p < n-2:
    return min(dp(cost+abs(h[p]-h[p+1]), p+1), dp(cost+abs(h[p]-h[p+2]), p+2))
  if p == n-2:
    return dp(cost+abs(h[p]-h[p+1]), p+1)

print(dp(0, 0))

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

h = [int(i) for i in input().split()]

def dp(cost, p):
  if p == n-1:
    return cost
  if p < n-2:
    return min(dp(cost+abs(h[p]-h[p+1]), p+1), dp(cost+abs(h[p]-h[p+2]), p+2))
  if p == n-2:
    return dp(cost+abs(h[p]-h[p+1]), p+1)

print(dp(0, 0))
Problem p03161 (python)

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

dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  a = [0] * min(i,k)
  for j in range(1, min(i,k)+1): 
    a[j-1] = dp[i-j]+abs(h[i]-h[i-j])
  dp[i] = min(a)

print(dp[-1])

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

dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  a = [0] * min(i,k)
  for j in range(1, min(i,k)): 
    a[i-1] = dp[i-j]+abs(h[i]-h[i-j])
  dp[i] = min(a)

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n, k = map(int, input().split())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  m = min([dp(p+i)+abs(h[p]-h[p+i]) for i in reversed(range(1, min(n-p, k+1)))])
  d[p] = m
  return m

print(dp(0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n, k = map(int, input().split())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  m = min([dp(p+i)+abs(h[p]-h[p+i]) for i in range(1, min(n-p, k+1))])
  d[p] = m
  return m

print(dp(0))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(200000)
 
n, k = map(int, input().split())
 
h = [int(i) for i in input().split()]
 
d = {}
 
def dp(p):
  if p in d:
    return d[p]
  if p == n-1:
    return 0
  m = min([dp(p+i)+abs(h[p]-h[p+i]) for i in range(1, min(n-p, k+1))])
  d[p] = m
  return m

print(dp(0))
Problem p03163 (python)

Fixed submission:
import numpy as np
N, W = map(int, input().split())
dp = np.zeros((N+1, W+1), dtype=int)

w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

for row in range(N):
    dp[row+1,:w[row]] = dp[row,:w[row]]
    dp[row+1,w[row]:] = np.maximum(dp[row,w[row]:],v[row]+dp[row,:-w[row]])

print(dp[N,-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
N, W = map(int, input().split())
dp = np.zeros((N+1, W+1), dtype=int)

w,v = [],[]
for _ in range(N):
    w_,v_ = map(int,input().split())
    w.append(w_)
    v.append(v_)

for row in range(N):
    dp[row+1,:w[row]] = dp[row,:w[row]]
    dp[row+1,w[row]:] = np.maximum(dp[row,w[row]:],v[row]+dp[row,:-w[row]])

print(dp[N,-1])
Problem p02536 (python)

Fixed submission:
class UnionFind:
  par = None
  
  def __init__(self, n):
    self.par = [0] * n
    
  def root(self, x):
    if(self.par[x] == 0):
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.root(self.par[x])
  
  def unite(self, x, y):
    if(self.root(x) != self.root(y)):
      self.par[self.root(x)] = self.root(y)
      
  def same(self, x, y):
    return self.root(x) == self.root(y)
  
N, M = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(M):
  A, B = list(map(int, input().split()))
  UF.unite(A - 1, B - 1) 
ans = 0
for i in range(N):
  if(UF.par[i] == 0):
    ans += 1
print(ans - 1)

Buggy submission (verdict: Runtime Error):
class UnionFind:
  par = None
  
  def __init__(self, n):
    self.par = [0] * n
    
  def root(self, x):
    if(self.par[x] == 0):
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.root(self.par[x])
  
  def unite(self, x, y):
    if(self.root(x) != self.root(y)):
      self.par[self.root(x)] = self.root(y)
      
  def same(self, x, y):
    return self.root(x) == self.root(y)
  
N, M = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(M):
  print(UF.par)
  A, B = list(map(int, input().split()))
  UF.unite(A - 1, B - 1) 
ans = 0
for i in range(N):
  if(UF.par[i] == 0):
    ans += 1
print(UF.par)
print(ans - 1)

Buggy submission (verdict: Runtime Error):
class UnionFind:
  par = None
  
  def __init__(self, N):
    self.par = list(range(N))
    
  def root(self, x):
    if(self.par[x] == x):
      return x
    else:
      self.par[x] = self.root(self.par[x])
      return self.par[x]
  
  def unite(self, x, y):
    if(self.root(x) != self.root(y)):
      self.par[x] = self.root(y)
  
N, M = list(map(int, input().split()))
UF = UnionFind(N)
for i in range(M):
  print(UF.par)
  A, B = list(map(int, input().split()))
  UF.unite(A - 1, B - 1) 
ans = 0
for i in range(N):
  ans += (UF.par[i] == i)
print(UF.par)
print(ans - 1)
Problem p02584 (python)

Fixed submission:
X, K, D = list(map(int, input().split()))
X = abs(X)
if(X >= K * D):
  print(X - K * D)
else:
  q = X // D
  r = X % D
  if((K - q) % 2 == 0):
    print(r)
  else:
    print(abs(r - D))

Buggy submission (verdict: Runtime Error):
X, K, D = list(map(int, input().split()))
X = abs(X)
if(X >= K * D):
  print(X - K * D)
  return
else:
  q = X // D
  r = X // D
  if((K - q) % 2 == 0):
    print(r)
    return
  else:
    print(abs(r - D))
    return

Buggy submission (verdict: Runtime Error):
from math import abs
X, K, D = list(map(int, input().split()))
X = abs(X)
if(X >= K * D):
  print(X - K * D)
  return
else:
  q = X // D
  r = X // D
  if((K - q) % 2 == 0):
    print(r)
    return
  else:
    print(abs(r - D))
    return
Problem p02614 (python)

Fixed submission:
import copy
H, W, K, = list(map(int, input().split()))
C = [0] * H
for i in range(H):
  C[i] = input()
  C[i] = [1 if(C[i][j] == "#") else 0 for j in range(W)]
h = 2 ** H
w = 2 ** W
ans = 0
for i in range(2 ** H):
  w = 2 ** W
  for j in range(2 ** W):
    D = copy.deepcopy(C)
    for k in range(H):
      for l in range(W):
        if(bin(h)[k + 3] == "1" or bin(w)[l + 3] == "1"):
          D[k][l] = 0
    ans += (sum(map(sum, D)) == K)
    w += 1
  h += 1
print(ans)

Buggy submission (verdict: Runtime Error):
H, W, K, = list(map(int, input().split()))
C = [0] * H
for i in range(H):
  C[i] = input()
  C[i] = [1 if(C[i][j] == "#") else 0 for j in range(W)]
h = 2 ** H
w = 2 ** W
ans = 0
cnt = 0
for i in range(2 ** H):
  w = 2 ** W
  for j in range(2 ** W):
    cnt = 0
    for k in range(H):
      for l in range(W):
        if(bin(h)[k + 3] == "0" and bin(w)[l + 3] == "0"):
          cnt += D[k][l]
    ans += (cnt == K)
    w += 1
  h += 1
print(ans)
Problem p02631 (python)

Fixed submission:
from math import log2
N = int(input())
a = list(map(int, input().split()))
Maxa = max(a)
if(Maxa == 0):
  for i in range(N):
    print(0, end = " ")
else:
  J = int(log2(Maxa)) + 1
  A = [format(x, 'b').zfill(J) for x in a]
  S = [0] * J
  for j in range(J):
    for i in range(N):
      S[j] += int(A[i][j])
    S[j] %= 2

  X = [""] * N
  for i in range(N):
    for j in range(J):
      X[i] += str(int((int(A[i][j]) != S[j])))
    print(int(X[i], 2), end = " ")

Buggy submission (verdict: Runtime Error):
from math import log2
N = int(input())
a = list(map(int, input().split()))
Maxa = max(a)
J = int(log2(Maxa)) + 1
A = [format(x, 'b').zfill(J) for x in a]
S = [0] * J
for j in range(J):
  for i in range(N):
    S[j] += int(A[i][j])
  S[j] %= 2
  
X = [""] * N
for i in range(N):
  for j in range(J):
    X[i] += str(int((int(A[i][j]) != S[j])))
  print(int(X[i], 2), end = " ")
Problem p02727 (python)

Fixed submission:
X, Y, A ,B, C = list(map(int, input().split()))
P = sorted(list(map(int, input().split())), reverse = True)[:X]
Q = sorted(list(map(int, input().split())), reverse = True)[:Y]
R = sorted(list(map(int, input().split())), reverse = True)
ans = 0
for i in range(C):
  if(len(P) == 0):
    if(len(Q) == 0):
      break
    elif(Q[-1] < R[i]):
      Q.pop()
      ans += R[i]
    else:
      break
  elif(len(Q) == 0):
    if(P[-1] < R[i]):
      P.pop()
      ans += R[i]
    else:
      break
  else:
    if(P[-1] < Q[-1] and P[-1] < R[i]):
      P.pop()
      ans += R[i]
    elif(Q[-1] <= P[-1] and Q[-1] < R[i]):
      Q.pop()
      ans += R[i]
    else:
      break
ans += sum(P) + sum(Q)
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y, A ,B, C = list(map(int, input().split()))
P = list(map(int, input().split()))
P.sort(reverse = True)
P = P[:X]
Q = list(map(int, input().split()))
Q.sort(reverse = True)
Q = Q[:Y]
R = list(map(int, input().split()))
R.sort(reverse = True)
ans = 0
for i in range(C):
  if(P[-1] < Q[-1]):
    if(P[-1] < R[i]):
      ans += R[i]
      P.pop()
  else:
    if(Q[-1] < R[i]):
      ans += R[i]
      Q.pop()
    else:
      break
ans += sum(P) + sum(Q)
print(ans)
Problem p02802 (python)

Fixed submission:
N, M = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
  p, S = input().split()
  p = int(p)
  if(S == "AC"):
    AC[p-1] = 1
  elif(AC[p-1] == 0):
    WA[p-1] += 1
for i in range(N):
  if(AC[i] == 0):
    WA[i] = 0
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
  p, S = input().split()
  p = int(p)
  if(S == "AC"):
    AC[p-1] = 1
  elif(AC[p-1] == 0):
    WA[p-1] += 1
for i in range(M):
  if(AC[i] == 0):
    WA[i] = 0
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
  p, S = input().split()
  p = int(p)
  if(S == "AC"):
    AC[p-1] = 1
  elif(AC[p] == 0):
    WA[p-1] += 1
print(sum(AC), sum(WA))

Buggy submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))
AC = [0] * N
WA = [0] * N
for i in range(M):
  p, S = input().split()
  p = int(p)
  if(S == "AC"):
    AC[p] = 1
  elif(AC[p] == 0):
    WA[p] += 1
print(sum(AC), sum(WA))
Problem p02841 (python)

Fixed submission:
M1, D1 = input().split()
M2, D2 = input().split()
if(M1 != M2):print(1)
else: print(0)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
ans = 0
for i in range(10):
  l = 0
  while(True):
    if(i == int(S[l])):
      for j in range(10):
        m = l + 1
        while(True):
          if(j == int(S[m])):
            for k in range(10):
              for n in range(m+1, N):
                if(k == int(S[n])):
                  ans += 1
                  break
          m += 1
          if(m >= N - 1 or j == int(S[m - 1])):
             break
    l += 1
    if(l >= N - 2 or i == int(S[l - 1])):
      break
print(ans)
Problem p02909 (python)

Fixed submission:
S = input()
if(S == "Sunny"):
  print("Cloudy")
if(S == "Cloudy"):
  print("Rainy")
if(S == "Rainy"):
  print("Sunny")

Buggy submission (verdict: Runtime Error):
S = input()
if(S == "Sunny"):
  print("Cloudy")
if(S = "Cloudy"):
  print("Rainy")
if(S == "Rainy"):
  print("Sunny")