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

Fixed submission:
N = list(map(int, input()))
N = N[::-1] + [0]

count = 0

for i, n in enumerate(N):
  if n < 5:
    count += n
  elif n > 5:
    count += 10 - n
    N[i+1] += 1
  elif n == 5:
    if N[i+1] >= 5:
      N[i+1] += 1
    count += 5
    
print(count)

Buggy submission (verdict: Runtime Error):
N = list(map(int, input()))
N = N[::-1] + [0]

count = 0

def moveUp(i):
  if N[i] == 9:
    N[i] = 0
    moveUp(i+1)
  else:
    N[i] += 1

for i, n in enumerate(N):
  if n < 5:
    count += n
  elif n > 5:
    count += 10 - n
    moveUp(i+1)
  elif n == 5:
    for j in range(i+1, len(N)):
      if N[j] < 5:
        break
      if N[j] >= 5:
        moveUp(i+1)
        break
      
    count += 5
print(count)

Buggy submission (verdict: Runtime Error):
N = list(map(int, input()))
N = N[::-1] + [0]

count = 0

def moveUp(i):
  if N[i] == 9:
    N[i] = 0
    moveUp(i+1)
  else:
    N[i] += 1

for i, n in enumerate(N):
  if n < 5:
    count += n
  elif n > 5:
    count += 10 - n
    moveUp(i+1)
  elif n == 5:
    for j in range(i+1, len(N)):
      if N[j] < 5:
        break
      if N[j] > 5:
        moveUp(i+1)
        break
      if N[j] == 5:
        continue
      
    count += 5
print(count)

Buggy submission (verdict: Runtime Error):
N = list(map(int, input()))
N = N[::-1] + [0]
out = 0

def moveUp(i, N):
  if N[i] != 9:
      N[i] += 1
  else:
    N[i] = 0
    moveUp(i+1, N)

for i, n in enumerate(N):
  n = int(n)
  if n < 6:
    out += n
  else:
    out += 10-n
    moveUp(i+1, N)
print(out)
Problem p03161 (python)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
H = np.array(list(map(int, input().split())) + [0]*K)

dp = np.full(N+K, 10**9, dtype=np.int64)
dp[0] = 0
for i in range(1, N):
  dp[i:i+K] = np.minimum(dp[i:i+K], dp[i-1] + np.abs(H[i:i+K] - H[i-1]))
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
DP = [0] + [10**9] * N 
for i in range(1, N):
  DP[i] = min(DP[i-j]+abs(H[i]-H[i-j]) for j in range(1, K+1))
print(DP[N-1])
Problem p03164 (python)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

dp = np.full(10**5+1, 10**18, dtype=np.int64)
dp[0] = 0

for i, (w, v) in enumerate(items):
  tmp = dp[:-v] + w
  dp[v:] = np.minimum(dp[v:], tmp)
print(np.max(np.where(dp <= W)))

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

N, W = map(int, input().split())

items = [tuple(map(int, input().split())) for _ in range(N)]
dp = np.zeros(W+1, dtype=np.int64)

for i, (w, v) in enumerate(items):
  tmp = np.zeros(W+1, dtype=np.int64)
  tmp[w:] = dp[:-w] + v
  dp = np.maximum(dp, tmp)
print(dp[W])

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

N, W = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

dp = np.zeros(W+1, dtype=np.int64)

for i, (w, v) in enumerate(items):
  tmp = dp[:-w] + v
  dp[w:] = np.maximum(dp[w:], tmp)
print(dp[W])
Problem p02692 (python)

Fixed submission:
N,A,B,C = list(map(int, input().split()))
s = [input() for i in range(N)]

u = ["A","B","C"]
ss = ["BC","AC","AB"]
t = [A,B,C]
trace = []
ans = "Yes"
for i in range(N):
  idx = ss.index(s[i])
  if t[(idx+1)%3] == 0 and t[(idx+2)%3] == 0:
    ans = "No"
    break
  elif t[(idx+2)%3] == 0:
    t[(idx+1)%3] -= 1
    t[(idx+2)%3] += 1
    trace.append(u[(idx+2)%3])
  elif t[(idx+1)%3] == 0:
    t[(idx+1)%3] += 1
    t[(idx+2)%3] -= 1
    trace.append(u[(idx+1)%3])
  elif i+1<N and s[i+1] == ss[(idx+1)%3]:
    t[(idx+1)%3] -= 1
    t[(idx+2)%3] += 1
    trace.append(u[(idx+2)%3])
  else:
    t[(idx+1)%3] += 1
    t[(idx+2)%3] -= 1
    trace.append(u[(idx+1)%3])
print(ans)
if ans == "Yes":
  for v in trace:
    print(v)

Buggy submission (verdict: Runtime Error):
N,A,B,C = list(map(int, input().split()))
s = [input() for i in range(N)]

ns = [s[0]]
for v in s[1:]:
  if v!=ns[-1]:
    ns.append([v,1])
  else:
    ns[-1][1] += 1

ans = "No"
q = [[] for i in range(N+1)]
q[0] = [(A,B,C)]
q2 = [[] for i in range(N+1)]
q2[0] = [[]]
for i in range(N):
  while q[i]:
    a,b,c = q[i].pop(0)
    trace = q2[i].pop(0)
    if s[i] == "AB":
      if a-1>0 and (a-1,b+1,c) not in q[i+1]:
        q[i+1].append((a-1,b+1,c))
        q2[i+1].append(trace+["B"])
      if b-1>0 and (a+1,b-1,c) not in q[i+1]:
        q[i+1].append((a+1,b-1,c))
        q2[i+1].append(trace+["A"])
    if s[i] == "BC":
      if b-1>0 and (a,b-1,c+1) not in q[i+1]:
        q[i+1].append((a,b-1,c+1))
        q2[i+1].append(trace+["C"])
      if c-1>0 and (a,b+1,c-1) not in q[i+1]:
        q[i+1].append((a,b+1,c-1))
        q2[i+1].append(trace+["B"])
    if s[i] == "AC":
      if a-1>0 and (a-1,b,c+1) not in q[i+1]:
        q[i+1].append((a-1,b,c+1))
        q2[i+1].append(trace+["C"])
      if c-1>0 and (a+1,b,c-1) not in q[i+1]:
        q[i+1].append((a+1,b,c-1))
        q2[i+1].append(trace+["A"])
if q[N]:
  trace = q2[N].pop(0)
  ans = "Yes"


print(ans)
if ans =="Yes":
  for v in trace:
    print(v)

Buggy submission (verdict: Runtime Error):

N,A,B,C = list(map(int, input().split()))
s = [input() for i in range(N)]

ns = [s[0]]
for v in s[1:]:
  if v!=ns[-1]:
    ns.append([v,1])
  else:
    ns[-1][1] += 1

ans = "No"
q = [[] for i in range(N+1)]
q[0] = [(A,B,C,[])]
for i in range(N):
  while q[i]:
    a,b,c,trace = q[i].pop(0)
    if s[i] == "AB":
      if a-1>0:
        q[i+1].append((a-1,b+1,c,trace+["B"]))
      if b-1>0:
        q[i+1].append((a+1,b-1,c,trace+["A"]))
    if s[i] == "BC":
      if b-1>0:
        q[i+1].append((a,b-1,c+1,trace+["C"]))
      if c-1>0:
        q[i+1].append((a,b+1,c-1,trace+["B"]))
    if s[i] == "AC":
      if a-1>0:
        q[i+1].append((a-1,b,c+1,trace+["C"]))
      if c-1>0:
        q[i+1].append((a+1,b,c-1,trace+["A"]))
if q[N]:
  a,b,c,trace = q[N].pop(0)
  ans = "Yes"


print(ans)
if ans =="Yes":
  for v in trace:
    print(v)
Problem p02700 (python)

Fixed submission:
A,B,C,D = map(int,input().split())

while True:
  C -= B
  if C<=0:
    print('Yes')
    break
  A -= D
  if A<=0:
    print('No')
    break

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

while True:
  C -= B
  if C<=0:
    print('Yes')
    break
  A -= D
  if <=0:
    print('No')
    break
Problem p02713 (python)

Fixed submission:
from math import gcd

k = int(input())
ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    x = gcd(a,b)
    for c in range(1,k+1):
        ans += gcd(x,c)
print(ans)

Buggy submission (verdict: Runtime Error):
k = int(input())
ans = 0
for a in range(k):
  for b in range(k):
    for c in range(k):
      ans += gcd(gcd(a,b),c)
print(ans)

def gcd(p,q):
  if p % q == 0:
    return q
  return gcd(q, p%q)
Problem p02947 (python)

Fixed submission:
n = int(input())
ls = []
dic = {}
ans = 0
for i in range(n):
    ls.append(input())
for i in range(n):
    tmp = "".join(sorted(ls[i]))
    if tmp in dic:
        ans += dic[tmp]
        dic[tmp] += 1
    else:
        dic[tmp] = 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = []
l = [0 for i in range(n)]
for i in range(n):
  ls.append(input())
for i in range(n):
  for j in range(10):
    alpha = ord(ls[i][j]) - ord("a")
    l[i]+=10**alfa
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if l[i] == l[j]:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ls = []
for i in range(n):
    ls.append(input())
l=[[0 for j in range(26)] for i in range(n)]
for i in range(n):
    for s in ls[i]:
        alpha = ord(s) - ord("a") + 1
        l[i][alpha] +=1
ans = 0
for i in range(n):
    for j in range(i+1,n):
        if l[i] == l[j]:
            ans+=1
print(ans)
Problem p02639 (python)

Fixed submission:
#ABC170-A
X = list(input().split())
for i in range(5):
  if X[i] == "0":
    print(i + 1)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
if x not in p:
    print(x)
else:
    a, b = 1, 1
    while True:
        if (x + a) not in p:
            break
        else:
            a += 1

    while True:
        if (x - b) not in p:
            break
        else:
            b += 1

    if a >= b:
        print(x - b)
    else:
        print(x + a)
Problem p02717 (python)

Fixed submission:
#ABC161-A
x,y,z=map(int,input().split())
print(z,x,y)

Buggy submission (verdict: Runtime Error):
count = 0
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    if a[i] >= sum(a)/4/m:
        count += 1
if count >= m:
    print("Yes")
else:
    print("No")
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

if T[:-1]==S and len(T)==len(S)+1:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
S, T = list(input().split())
if T[:-1]==S:
    print("YES")
else:
    print("NO")
Problem p02694 (python)

Fixed submission:
X = int(input())
import math
temp = 100
year = 0
while temp < X:
    temp = int(math.floor(temp*1.01))
    year += 1
print(year)

Buggy submission (verdict: Runtime Error):
import math
temp = 100
year = 0
while temp < X:
    temp = int(math.floor(temp*1.01))
    year += 1
print(year)
Problem p02784 (python)

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

if sum(A)>=H:
    print("Yes")
else:
    print("No")

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

if sum(A)>=H:
    print("Yes")
else:
    print("No")
Problem p02603 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().strip().split()))
day=0
money=1000
stock=0
is_up=True
while day<N :
    if is_up :
        past_day=day
        while A[day]<=A[day+1]:
            day+=1
            if day==N-1:
                break
        stock=int(money/A[past_day])
        money+=stock*(A[day]-A[past_day])
        day+=1
        if day==N-1:
            break
        is_up=False
    else :
        while A[day]>=A[day+1] :
            day+=1
            if day==N-1:
                day+=1
                break
        is_up=True


print("{}".format(money))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().strip().split()))
day=0
money=1000
stock=0
is_up=True
while day<N :
    if is_up :
        past_day=day
        while A[day]<=A[day+1]:
            day+=1
            if day==N-1:
                break
        stock=int(money/A[past_day])
        money+=stock*(A[day]-A[past_day])
        day+=1
        is_up=False
    else :
        while A[day]>=A[day+1] :
            day+=1
            if day==N-1:
                day+=1
                break
        is_up=True


print("{}".format(money))
Problem p02743 (python)

Fixed submission:
from decimal import *
a,b,c = map(int,input().split())
print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy submission (verdict: Runtime Error):
from decimal import *
a,b,c = map(int,input().split())
print("Yes" if Decimal(a.sqrt()) + Decimal(b.sqrt()) < Decimal(c.sqrt()) else "No")

Buggy submission (verdict: Runtime Error):
import math
from decimal import *
a,b,c = map(int,input().split())
if decimal(math.sqrt(a)) + decimal(math.sqrt(b)) < decimal(math.sqrt(c)): print("Yes")
else: print("No")
Problem p02975 (python)

Fixed submission:
# -*- coding: utf-8 -*-

import numpy
import sys
import os

def solve():
    num = int(input())
    camels = [int(i) for i in input().split()]

    if len(camels) % 3 != 0:
        for c in camels:
            if c !=0:
                print("No")
                return(0)

        print("Yes")
        return

    camels.sort()
    length = len(camels)

    for i in range(3):
        for j in range(int(i*length/3), int((i+1)*length/3)):
            if camels[int(i*length/3)] != camels[j]:
                print("No")
                return(0)

    if camels[0] ^ camels[int(num/3)] != camels[int(num/3)*2]:
        print("No")
        return(0)

    print("Yes")

solve()

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

import numpy as np
import sys
import os

def solve():

    N, M = list(map(int, input().split()))
    graph = [[] for i in range(N)]

    for i in range(M):
        A, B = list(map(int, input().split()))
        graph[A-1].append(B-1)
        graph[B-1].append(A-1)

    result = []
    finish = [0 for i in range(N)]
    out_num = [0 for i in range(N)]

    loop = True
    while loop:
        loop = False
        for i in range(N):
            if len(graph[i]) == 0:
                continue
            if len(graph[i])==2:
                for g in graph[i]:
                    result.append([i,g])
                    graph[g].remove(i)
                    out_num[i] += 1
                else:
                    graph[i] = []
                    loop = True


    for g in graph:
        if len(g) != 0:
            print("-1")
            return

    for r in result:
        print(str(r[0]+1) + " " +str(r[1]+1))


solve()
Problem p02641 (python)

Fixed submission:
import bisect
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()
P=sorted(list(map(int, input().split())))
key=bisect.bisect_right(P,X)
small=101
large=0

for i in range(N):
    if P[key-1]-i not in P:
        small=P[key-1]-i
        break
for i in range(N):
    if P[key-1]+i not in P:
        large=P[key-1]+i
        break
print(small if abs(X-small)<=abs(X-large) else large)

Buggy submission (verdict: Runtime Error):
import bisect
X,N=map(int,input().split())
if N==0:
    print(X)
    exit()
P=sorted(list(map(int, input().split())))
key=bisect.bisect_left(P,X)
small=P[-1]
key2=bisect.bisect_right(P,X)
for i in range(N):
    if P[key]-i not in P:
        small=P[key]-i
        break
for i in range(N):
    if P[key2-1]+i not in P:
        large=P[key2-1]+i
        break
print(small if abs(X-small)<=abs(X-large) else large)
Problem p02772 (python)

Fixed submission:
N=int(input())
A = list(map(int, input().split()))
outflag = 0
for i in range(N):
    if A[i]%2==0:
        if A[i]%3==0 or A[i]%5==0:
            pass
        else:
            outflag=1
            break
    else:
        pass
print("DENIED" if outflag else "APPROVED")

Buggy submission (verdict: Runtime Error):
from fractions import gcd
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)
Problem p02995 (python)

Fixed submission:
from fractions import gcd
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//math.gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)

Buggy submission (verdict: Runtime Error):
# ABC131C - Anti-Division
import math
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = round(C*D//math.gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)

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

Buggy submission (verdict: Runtime Error):
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
Z = B//lcm - (A-1)//int(C/math.gcd(C,D) *D)
print(B-A+1-X-Y+Z)

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

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

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D = map(int, input().split())
X = B//C - (A-1)//C
Y = B//D - (A-1)//D
lcm = int(C*D/math.gcd(C,D))
Z = B//lcm - (A-1)//lcm
print(B-A+1-X-Y+Z)
Problem p03495 (python)

Fixed submission:
from collections import Counter
N,K=map(int,input().split())
A=Counter(input().split())
print(sum(sorted(A.values(), reverse=True)[K:]))

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=Counter(list(map(int,input().split())) )
print(sum(sorted(A.keys(), reverse=True)[K:]))
Problem p04043 (python)

Fixed submission:
l,m,n = map(int, input().split())
newlist = sorted([l,m,n])
if newlist[0]==5 and newlist[1]==5 and newlist[2]==7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
l,m,n = map(int, input().split())
newlist = sorted([l,m,n])
if newlist(1)==5 & newlist(2)==5 & newlist(3)==7:
    print(str(YES))
else print(str(NO))
Problem p02582 (python)

Fixed submission:
s = str(input())
count = []
x = 0 
for i in range(len(s)):
    if s[i] == "R":
        x += 1
        if i == len(s)-1:
            count.append(x)
    if s[i] == "S":
        count.append(x)
        x = 0

print(max(count))

Buggy submission (verdict: Runtime Error):
s = str(input())
count = []
x = 0 
for i in range(len(s)):
    if s[i] == "R":
        x += 1
        if s[i] == len(s)-1:
            count.append(x)
    if s[i] == "S":
        count.append(x)
        x = 0

print(max(count))
Problem p02630 (python)

Fixed submission:
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)

ans=0
for v in c:
  ans += v*c[v]

#print(c)
#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    ans=ans-B*c[B]+C*c[B]
    c[C] += c[B]
    del c[B]
  else:
    ans=ans-B*c[B]+C*c[B]
    c[C] = c[B]
    del c[B]
  
  print(ans)

Buggy submission (verdict: Runtime Error):
import collections

N=int(input())
A=[int(_) for _ in input().split(" ")]
Q=int(input())

c = collections.Counter(A)


#d['k10'] = d.pop('k1')    
    
for i in range(Q):
  B,C=map(int,input().split(" "))
  
  if C in c:
    c[C] += c[B]
    del c[B]
  else:
    c[C] = c.pop(B)
  
  #print(c)
  
  s=list(c.keys())
  j=0
  ans=0
  for v in c.values():
    ans += s[j]*v
    j=j+1
  
  print(ans)
Problem p03067 (python)

Fixed submission:
arr=input().split(' ')
a=int(arr[0])
b=int(arr[1])
c=int(arr[2])
if ( a < c and c < b ) or ( b < c and c < a ):
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
k=int(input())
c=s[k-1]
sl=list(s)
for i in range(n):
	if sl[i] != c:
		sl[i] = '*'

print("".join(sl))
Problem p03136 (python)

Fixed submission:
n = int(input())
sides = []
sides2 = input()
sides2 = sides2.split()
for i in sides2:
  sides.append(int(i))
maxim = max(sides)
if maxim>=sum(sides)-maxim:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n = int(input())
sides = []
for i in range(n):
  sides.append(int(input()))
maxim = max(sides)
if maxim>sum(sides)-maxim:
  print("No")
else:
  print("Yes")
Problem p03545 (python)

Fixed submission:
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a+b+c-d==7:
  print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a+b-c+d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif a+b-c-d==7:
  print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif a-b+c+d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif a-b+c-d==7:
  print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif a-b-c+d==7:
  print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
else:
  print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

Buggy submission (verdict: Runtime Error):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(a+"+"+b+"+"+c+"+"+d+"=7")
elif a+b+c-d==7:
  print(a+"+"+b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"+b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"+b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"+b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"+b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"+b+"-"+c+"+"+d+"=7")
else:
  print(a+"-"+b+"-"+c+"-"+d+"=7")

Buggy submission (verdict: Runtime Error):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a+b+c+d==7:
  print(a+"+"b+"+"+c+"+"+d+"=7")
elif a+b+c-d==7:
  print(a+"+"b+"+"+c+"-"+d+"=7")
elif a+b-c+d==7:
  print(a+"+"b+"-"+c+"+"+d+"=7")
elif a+b-c-d==7:
  print(a+"+"b+"-"+c+"-"+d+"=7")
elif a-b+c+d==7:
  print(a+"-"b+"+"+c+"+"+d+"=7")
elif a-b+c-d==7:
  print(a+"-"b+"+"+c+"-"+d+"=7")
elif a-b-c+d==7:
  print(a+"-"b+"-"+c+"+"+d+"=7")
else:
  print(a+"-"b+"-"+c+"-"+d+"=7")
Problem p02713 (python)

Fixed submission:
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,math.gcd(j,k))
      
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans = 0

K = int(input())

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += math.gcd(i,j,k)
      
print(ans)
Problem p02719 (python)

Fixed submission:
n,k = map(int,input().split())
x = n % k
a = min(abs(k-x),n,x)


print(a)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
print(min(abs(n%k),k-abs(n%k))
Problem p02721 (python)

Fixed submission:
import copy
 
n,k,c = map(int,input().split())
s = list(input())
 
front = []
back = []
 
# 前から貪欲
j = copy.copy(k)
i = 0
while j > 0:
  if s[i] == "o":
    front.append(i)
    i += c+1
    j -= 1
  else:
    i += 1
 
# 後ろから貪欲
 
j = copy.copy(k)
i = n-1
while j > 0:
  if s[i] == "o":
    back.append(i)
    i -= c+1
    j -= 1
  else:
    i -= 1

back.sort()
for i in range(k):
  if front[i] == back[i]:
    print(front[i]+1)

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

front = [0]*n
back = [0]*n

# 前から貪欲
c = k
i = 0
while c > 0:
  if s[i] == "o":
    front[i] = 1
    i += c+1
  else:
    i += 1
  c -= 1

# 後ろから貪欲

c = k
i = n-1
while c > 0:
  if s[i] == "o":
    back[i] = 1
    i -= c+1
  else:
    i -= 1
  c -= 1
  
for i in range(n):
  if front[i] == 1 and back[i] == 1:
    print(i+1)
Problem p02608 (python)

Fixed submission:
import itertools
import math
import collections
def main():
    n = int(input())
    s = int(math.sqrt(n))
    a = list(itertools.product(range(1,s),repeat=3))
    ans = []
    for i in range(len(a)):
        t = a[i][0] ** 2 + a[i][1] ** 2 + a[i][2] ** 2 + a[i][0] * a[i][1] + a[i][1] * a[i][2] + a[i][2] * a[i][0]
        ans.append(t)
        # print(ans)
    c = collections.Counter(ans)
    for i in range(1,n+1):
        print(c[i])
        
        
main()

Buggy submission (verdict: Runtime Error):
import itertools
import math
import collections
​
def main():
    n = int(input())
​
    s = int(math.sqrt(n))
    a = list(itertools.product(range(1,s),repeat=3))
​
    ans = []
    for i in range(len(a)):
        t = a[i][0] ** 2 + a[i][1] ** 2 + a[i][2] ** 2 + a[i][0] * a[i][1] + a[i][1] * a[i][2] + a[i][2] * a[i][0]
        ans.append(t)
        # print(ans)
​
    c = collections.Counter(ans)
    for i in range(1,n+1):
        print(c[i])
        
        
main()
Problem p02664 (python)

Fixed submission:
t = input()
t = list(t)

for i in range(len(t)):
    if t[i] == "?":
        t[i] = 'D'
ans = "".join(t)
print(ans)

Buggy submission (verdict: Runtime Error):
t = input()
t = list(t)
count = 1
while(True):
    count = 0
    for i in range(len(t)):
        if t[i] == "?":
            count = count + 1
            if t[i+1] == "P":
                t[i] = 'D'
            elif t[i+1] == "D":
                t[i] = 'P'
    if count == 0:
        break
ans = "".join(t)
print(ans)