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

Fixed submission:
from heapq import *

x,y,z,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

q=[]
li=[]
heappush(q,((a[0]+b[0]+c[0]) * (-1),0,0,0))

for i in range(k):
  node=heappop(q)
  
  print(node[0]*-1)
  if node[1]+1 != x:
    node_a = ((a[node[1]+1]+b[node[2]]+c[node[3]])*(-1), node[1]+1, node[2], node[3])
    if node_a not in q:
      heappush(q,node_a)
  
  if node[2]+1 != y:
    node_b = ((a[node[1]]+b[node[2]+1]+c[node[3]])*(-1), node[1], node[2]+1, node[3])
    if node_b not in q:
      heappush(q,node_b)
  
  if node[3]+1 != z:
    node_c = ((a[node[1]]+b[node[2]]+c[node[3]+1])*(-1), node[1], node[2], node[3]+1)
    if node_c not in q:
      heappush(q,node_c)

Buggy submission (verdict: Runtime Error):
    x,y,z,k=list(map(int,input().split()))
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
      
    li=[]
    for i in a:
      for j in b:
        li.append(i+j)
    li.sort(reverse=True)
     
    ansli=[]
    for i in c:
      for j in range(min(k,len(li))):
        ansli.append(i+li[j])
    ansli.sort(reverse=True)
     
    for i in range(k):
      print(ansli[i])
Problem p03087 (python)

Fixed submission:
n,q=list(map(int,input().split()))
s=input()
li=[0]
c=0
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    c+=1
  li.append(c)

for i in range(q):
  l,r=list(map(int,input().split()))
  l-=1
  r-=1
  print(li[r]-li[l])

Buggy submission (verdict: Runtime Error):
n,q=list(map(int,input().split()))
s=input()
li=[0]
c=0
for i in range(1,n-1):
  if s[i-1]=="A" and s[i]=="C":
    c+=1
  li.append(c)

for i in range(q):
  l,r=list(map(int,input().split()))
  l-=1
  r-=1
  print(li[r]-li[l])
Problem p03238 (python)

Fixed submission:
ina = input()
if ina == "1":
  print("Hello World")
else:
  inb = int(input())
  inc = int(input())
  print(inb + inc)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

ina = input()
if ina == "1":
  print("Hello World")
else:
  inb = int(input())
  inc = int(input())
  print(inb + inc)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

ina = input()
if ina == "1":
  print("Hello World")
else:
  inb = int(input())
  inc = int(input())
  print(inb + inc)
Problem p03633 (python)

Fixed submission:
import fractions

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))
if n>=2:
    ans=t[0]*t[1]//(fractions.gcd(t[0],t[1]))
    for i in range(2,n):
        ans=ans*t[i]//(fractions.gcd(ans,t[i]))
    print(ans)
else:
    print(t[0])

Buggy submission (verdict: Runtime Error):
import fractions

n=int(input())
t=[]
for i in range(n):
    t.append(int(input()))

ans=t[0]*t[1]//(fractions.gcd(t[0],t[1]))
for i in range(2,n):
    ans=ans*t[i]//(fractions.gcd(ans,t[i]))
print(ans)
Problem p04001 (python)

Fixed submission:
s=input()
ans=0

if len(s)==1:
  print(s)
  exit()

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
#input=sys.stdin.readline

s=input()
ans=0

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

Buggy submission (verdict: Runtime Error):
#import sys
#input=sys.stdin.readline

s=input()
ans=0

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  #0がなし、1が+
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline

s=input()
ans=0

for i in range(2 ** (len(s)-1)):
  bin_i = bin(i)[2:].rjust(len(s)-1,"0")
  li=[]
  n=s[0]
  #0がなし、1が+
  for ix,sign in enumerate(bin_i):
    if sign=="0":
      n+=s[ix+1]
    else:
      li.append(int(n))
      n=s[ix+1]
  li.append(int(n))
  ans+=sum(li)

print(ans)
Problem p04012 (python)

Fixed submission:
in1 = list(input())
in1.sort()
i = 1
flg = True
if len(in1) %2 != 0:
  flg=False
else:
  while i < len(in1):
    if in1[i] != in1[i-1]:
      flg = False
      break
    i+=2
if flg:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
in1 = list(input())
in1.sort()
i = 1
flg = True
while i <= len(in1):
  if in1[i] != in1[i-1]:
    flg = False
    break
  i+=2
if flg:
  print("Yes")
else:
  print("No")
Problem p04029 (python)

Fixed submission:
inn = int(input())
r = 0
for i in range(1,inn+1):
  r+= i
print(r)

Buggy submission (verdict: Runtime Error):
    inn = int(input())
    r = 0
    for i in range(1,inn+1):
      r += i
    print(r)
Problem p02850 (python)

Fixed submission:
import sys
from collections import deque
read = sys.stdin.read

N, *ab = map(int, read().split())

graph = [[] for _ in range(N + 1)]
 
for a, b in zip(*[iter(ab)] * 2):
    graph[a].append(b)
 
color = [0] * (N + 1)
queue = deque([1])
 
while queue:
    V = queue.popleft()
    number = 1
    for v in graph[V]:
        if number == color[V]:
            number += 1
        color[v] = number
        queue.append(v)
        number += 1
 
print(max(color))
for a, b in zip(*[iter(ab)] * 2):
    print(color[b])

Buggy submission (verdict: Runtime Error):
iro = []
iro_i = []
res = []
r = 0
cm = []
for i in range(N+1):
  cm.append([])
N = int(input())
for i in range(N-1):
  a,b = input().split(" ")
  a = int(a)
  b = int(b)
  for cr in set(iro_i) - set(cm[a] + cm[b]):
    res.append(cr+1)
    cm[a].append(cr)
    cm[b].append(cr)
    break
  else:
    iro_i.append(r)
    cm[a].append(r)
    cm[b].append(r)
    res.append(r+1)
    r+=1
print(r+1)
for i in res:
  print(i)

Buggy submission (verdict: Runtime Error):
iro = []
res = []
r = 0
cm = []
for i in range(N):
  cm.append([])
N = int(input())
for i in range(N-1):
  a,b = input().split(" ")
  a = int(a)
  b = int(b)
  cr = 0
  while cr < r
    if a not in iro[cr] and b not in iro[cr]:
      iro[cr].append(a)
      iro[cr].append(b)
      res.append(cr+1)
      break
    cr += 1
  else:
    r = cr
    iro.append([a,b])
    res.append(cr+1)
print(r+1)
for i in res:
  print(i)

Buggy submission (verdict: Runtime Error):
iro = []
res = []
r = 0
cc = {}
N = int(input())
for i in range(N-1):
  a,b = input().split(" ")
  a = int(a)
  b = int(b)
  cr = 0
  for p in iro:
    if a in iro:
      cr += 1
      continue
    elif b in iro:
      cr += 1
      continue
    elif a not in p and b not in p:
      iro[cr].append(a)
      iro[cr].append(b)
      res.append(cr+1)
      else:
        if cc[a] > 

      break
    cr += 1
  else:
    r = cr
    iro.append([a,b])
    res.append(cr+1)
print(r+1)
for i in res:
  print(i)

Buggy submission (verdict: Runtime Error):
iro = []
res = []
r = 0
cc = {}
N = int(input())
for i in range(N-1):
  a,b = input().split(" ")
  a = int(a)
  b = int(b)
  cr = 0
  for p in iro:
    if a in iro:
      continue
    elif b in iro:
      continue
    elif a not in p and b not in p:
      iro[cr].append(a)
      iro[cr].append(b)
      res.append(cr+1)
      else:
        if cc[a] > 

      break
    cr += 1
  else:
    r = cr
    iro.append([a,b])
    res.append(cr+1)
print(r+1)
for i in res:
  print(i)
Problem p03323 (python)

Fixed submission:
# データ読み込み

import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, B  = map(int,input_data().split())
A
out = ":("
if A <= 8 and B <= 8:
  out = "Yay!"

print(out)

Buggy submission (verdict: Runtime Error):
# データ読み込み

import sys
from collections import deque

def input_data(d):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, B  = map(int,input_data().split())
A
out = ":("
if A <= 6 and B <= 6:
  out = "Yay!"

print(out)
Problem p02909 (python)

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

Buggy submission (verdict: Runtime Error):
if S == 'Sunny':
	print('Cloudy')
elif S == 'Cloudy':
	print('Rainy')
elif S == 'Rainy':
	print('Sunny')

Buggy submission (verdict: Runtime Error):
if S == 'Sunny':
	print('Cloudy')
elif S == 'Cloudy':
	print('Rainy')
else:
	print('Sunny')

Buggy submission (verdict: Runtime Error):
if S == 'Sunny':
print('Cloudy')
elif S == 'Cloudy':
print('Rainy')
else:
print('Sunny')

Buggy submission (verdict: Runtime Error):
if S == 'Sunny'
print('Cloudy')
elif S == 'Cloudy'
print('Rainy')
else
print('Sunny')
Problem p02982 (python)

Fixed submission:
import math
import itertools

N, D = [int(n) for n in input().split()]
X = []
for i in range(N):
    X.append([int(m) for m in input().split()])

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N, D = [int(n) for n in input().split()]
X = []
for i in range(N):
    X.append([int(m) for m in input().split()])

def get_distance(p1, p2):
    d2 = 0
    for i in range(D):
        d2 += (p1[i] - p2[i])**2
    return math.sqrt(d2)

count = 0
for i, j in itertools.combinations(range(N), 2):
    if get_distance(X[i], X[j]).is_integer():
        count += 1

print(count)
Problem p03067 (python)

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

if a < c < b or b < c < a:
    print('Yes')
else:
    print('No')

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

# the number of '#'
p0 = s.count('#')

# the number of '.'
p1 = n - p0

p_min = min(p0, p1)

wb_ = 0
bw_ = 0
for i in range(n):

    if s[i] == '.':
        bw = bw_ 
        wb = p1
    else:
        bw = bw_ + 1
        wb = p1 - 1
    
    p_min = min(p_min, (bw + wb))

print(p_min)
Problem p03146 (python)

Fixed submission:
s = int(input())

def func(n):
    if n%2 == 0:
        return int(n / 2)
    else:
        return 3 * n + 1

a = [s]
i = 0
flg = 1
while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                flg = 0
                break
        if flg == 0:
            break
        
    i += 1

Buggy submission (verdict: Runtime Error):
while(flg):
    a.append(func(a[i]))
    #print(a)
    for k in range(len(a)):
        for l in range(1, len(a)-k): 
            if a[k] == a[k+l]:
                print(k+l+1)
                break
        else:
            continue
        break   
        
    i += 1
Problem p03238 (python)

Fixed submission:
N = int(input())

if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)

Buggy submission (verdict: Runtime Error):
import itertools

N = int(input())
params = []
for i in range(N):
    xyh = [int(n) for n in input().split()]
    params.append(xyh)

for cxi, cyi in itertools.product(range(101), range(101)):
    for k in range(N):
        if params[k][2] > 0:
            hight = params[k][2] + abs(params[k][0] - cxi) + abs(params[k][1] - cyi)

    for k in range(N):
        if params[k][2] != max(hight - abs(params[k][0] - cxi) - abs(params[k][1] - cyi), 0)
            break
    
    else:
        print(cxi, cyi, hight)
Problem p03244 (python)

Fixed submission:
from collections import Counter

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

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

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vn[0][1]
            else:
                gp = vp[0][1]
                gn = vn[1][1]
 
    ans = n - gp - gn
print(ans)

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

n = int(input())
V = [int(n) for n in input().split()]

if len(set(V)) == 1:
    ans = len(V) // 2
else:
    vp_ = [v for i, v in enumerate(V) if i%2 == 0] 
    vn_ = [v for i, v in enumerate(V) if i%2 != 0] 

    vp = Counter(vp_).most_common()
    vn = Counter(vn_).most_common()

    if vp[0][0] != vn[0][0]:
        gp = vp[0][1]
        gn = vn[0][1]
    else:
        if vp[0][1] > vn[0][1]:
            gp = vp[0][1]
            gn = vn[1][1]
        elif vp[0][1] < vn[0][1]:
            gp = vp[1][1]
            gn = vn[0][1]
        else vp[0][1] == vn[0][1]:
            if vp[1][1] >= vn[1][1]:
                gp = vp[1][1]
                gn = vp[0][1]
            else:
                gp = vp[0][1]
                gn = vp[1][1]
 
    ans = n - gp - gn
print(ans)
Problem p03260 (python)

Fixed submission:
a, b = map(int, input().split())
if (a*b) % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
if (a*b) % 2 == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
if a*b % 2 == 0:
    print('No')
else:
    print('Yes')
Problem p03288 (python)

Fixed submission:
R = int(input())

if R < 1200:
    print('ABC')
elif R < 2800:
    print('ARC')
else:
    print('AGC')

Buggy submission (verdict: Runtime Error):
D, G = [int(n) for n in input().split()]

score_table = []
for i in range(1, D+1):
    p, c = [int(n) for n in input().split()]
    score_table.append([i*100, p, c])

min_count = sum([l[1] for l in score_table])
#print(min_count)

for bit in range(1<<D):
    score = 0
    count = 0

    for i in range(D):
        if bit & (1<<i):
            score += score_table[i][0] * score_table[i][1] + score_table[i][2]
            count += score_table[i][1]
    
    if score >= G:
        min_count = min(min_count, count)
    else:
        additional = []
        for j in range(D):
            if not bit & (1<<j):
                additional.append(score_table[j])
        
        additional_ = sorted(additional, key=lambda x:x[0], reverse=True)
        #print(additional_)
        
        # for i in additional_:
        #     if i[1] > 1:
        #         add_score = i
        #         break

        add_score = additional_[0]

        for k in range(add_score[1]-1):
            score += add_score[0]
            count += 1
            if score >= G:
                min_count = min(min_count, count)

print(min_count)
Problem p03292 (python)

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

A = sorted(A)
ans = A[2] - A[0]
print(ans)

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

A = sorted(A)
ans = a[2] - a[0]
print(ans)
Problem p03309 (python)

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
a_ = sorted([n - (i+1) for i, n in enumerate(a) ])

if N//2 == 0:
    b = a_[N//2]
else:
    b = a_[(N-1)//2]

s = [abs(n - b) for i, n in enumerate(a_)]

print(sum(s))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
a_ = [n - (i+1) for i, n in enumerate(a) ]

b = sum(a_) // N
b_ = b + 1
s = [abs(n - b) for i, n in enumerate(a_)]
s_ = [abs(n - b_) for i, n in enumerate(a_)]

print(min(sum(s), sum(s_))
Problem p03361 (python)

Fixed submission:
H, W = map(int, input().split())
S = [['.']*(W+2)]
for i in range(H):
    S.append(['.'] + list(input()) + ['.'])
S.append(['.']*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i+1][j] == '.' and S[i-1][j] == '.' and S[i][j+1] == '.' and S[i][j-1] == '.':
                print('No')
                break
    else:
        continue
    break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [['.']*W]
for i in range(H):
    S.append(['.'] + list(input()) + ['.'])
S.append(['.']*W)

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i+1][j] == '.' and S[i-1][j] == '.' and S[i][j+1] == '.' and S[i][j-1] == '.':
                print('No')
                break
    else:
        continue
    break

else:
    print('Yes')
Problem p03555 (python)

Fixed submission:
c = list(input())

if c[::-1] == list(input()):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
import math

n = math.sqrt(int(input()))
print(math.floor(n)**2)
Problem p03556 (python)

Fixed submission:
import math
n = math.sqrt(int(input()))
print(math.floor(n)**2)

Buggy submission (verdict: Runtime Error):
n = math.sqrt(int(input()))
print(math.floor(n)**2)
Problem p03047 (python)

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

print(N - K + 1)

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

print(N - K + 1)
Problem p03061 (python)

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

def GCD(m, n):
  if m == 0:
    return n
  elif n == 0:
    return m
  a = max(m, n)
  b = min(m, n)
  while b > 0:
    r = a % b
    if r == 0:
      return b
    a = b
    b = r  

L = [0] * (N + 1)
R = [0] * (N + 1)
for i in range(N):
  L[i + 1] = GCD(L[i], A[i])
  R[N - i - 1] = GCD(R[N - i], A[N - i - 1])
M = [GCD(L[i], R[i+1]) for i in range(N)]
print(max(M))

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

def GCD(m, n):
  a = max(m, n)
  b = min(m, n)
  while b > 0:
    r = a % b
    if r == 0:
      return b
    a = b
    b = r  

import numpy as np

B = np.ones((N, N)) * 10 ** 10

for m in range(N):
  for n in range(m, N):
    if m == n:
      B[m, m] = 0
    else:
      B[m, n] = B[n, m] = GCD(A[m], A[n])

C = B.sum(axis=1)
idx = C.argmin()

B = np.where(B == 0, 10 ** 10, B)
B = np.delete(B, idx, axis=0)
B = np.delete(B, idx, axis=1)
print(int(B.min()))
Problem p03086 (python)

Fixed submission:
S = input()

base_list = ["A", "T", "G", "C"]
seq_list = []
seq = ""
for s in S:
  if s in base_list:
    seq += s
  else:
    seq_list.append(seq)
    seq = ""
seq_list.append(seq)
seq_len_list = [len(seq) for seq in seq_list]
print(max(seq_len_list))

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

base_list = ["A", "T", "G", "C"]
seq_list = []
seq = ""
for s in S:
  if s in base_list:
    seq += s
  else:
    seq_list.append(seq)
    seq = ""
seq_len_list = [len(seq) for seq in seq_list]
print(max(seq_len_list))
Problem p03103 (python)

Fixed submission:
N, M = [int(x) for x in input().split()]
V = [tuple(map(int, input().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - count) * a
    break
print(money)

Buggy submission (verdict: Runtime Error):
N, M = [int(x) for x in input().split()]
V = [tuple(map(int, innput().split())) for i in range(N)]
V.sort()

money = 0
count = 0

for a, b in V:
  if count + b < M:
    count += b
    money += a * b
  else:
    money += (M - b) * a
    break
print(money)
Problem p03109 (python)

Fixed submission:
y, m, d = list(input().split('/'))

#y = y.zfill(4)
n = int(y + m + d)

if n <= 20190430:
  print("Heisei")
else:
  print("TBD")

Buggy submission (verdict: Runtime Error):
N, A, B, C = [int(x) for x in input().split()]
l = []
for i in range(N):
  l.append(int(input()))
 
def dfs(cur, a, b, c):
  if cur == N:
    return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else 1000000
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
 
print(dfs(0, 0, 0, 0))
Problem p03206 (python)

Fixed submission:
D = int(input())
 
if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve')
elif D == 22:
  print('Christmas Eve Eve Eve')

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

if D == 25:
  print('Christmas')
elif D == 24:
  print('Christmas Eve')
elif D == 23:
  print('Christmas Eve Eve')
elif = D == 22:
  print('Christmas Eve Eve Eve')
Problem p02934 (python)

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

#print(ai)

ans = 0
for i in ai:
    ans=ans+1/i

print(1/ans)

Buggy submission (verdict: Runtime Error):
ans = 0
for i in ai:
    ans=ans+1/i

print(1/ans)
Problem p02958 (python)

Fixed submission:
N = int(input())
pi = list(map(int, input().split()))
#print(pi)

pis = sorted(pi)
#print(pis)

count = 0
for i in range(N):
    if pi[i] != pis[i]:
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):

N = int(input())
pi = list(map(int, input().split()))
#print(pi)

pis = sorted(pi)
#print(pis)

count = 0

for i in range(5):
    if pi[i] != pis [i]:
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")
Problem p03026 (python)

Fixed submission:

from collections import deque

n = int(input())
tree = [[] for i in range(n+1)]

for i in range(1,n):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

c = list(map(int,input().split()))
#print(c)
#cs = sorted(c, reverse=True)
#print(cs)
cs = sorted(c)
#print(cs)

ansd=[0]*(n)
score=0

stack = deque()
stack.append(1)
ansd[0]=cs.pop()
visitted=[]

while stack:
    cur = stack.popleft()
    visitted.append(cur)
    for v in tree[cur]:
        if v in visitted:
            continue
        stack.append(v)
        ansd[v-1]=cs.pop()
        score += min(ansd[cur-1], ansd[v-1])

print(score)
print(*ansd, sep=' ')
#print(visitted)

Buggy submission (verdict: Runtime Error):
n = int(input())
tree = [[] for i in range(n+1)]

for i in range(1,n):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

c = list(map(int,input().split()))
#print(c)
#cs = sorted(c, reverse=True)
#print(cs)
cs = sorted(c)
#print(cs)

ansd=[0]*(n)
score=0

stack = deque()
stack.append(1)
ansd[0]=cs.pop()
visitted=[]

while stack:
    cur = stack.popleft()
    visitted.append(cur)
    for v in tree[cur]:
        if v in visitted:
            continue
        stack.append(v)
        ansd[v-1]=cs.pop()
        score += min(ansd[cur-1], ansd[v-1])

print(score)
print(*ansd, sep=' ')
#print(visitted)