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

Fixed submission:
import collections

N = int(input())
A = sorted(map(int, input().split()))

cnt = collections.defaultdict(int)
for a in A:
    cnt[a] += 1
ans = sum(A)

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * cnt[B]
    cnt[C] += cnt[B]
    cnt[B] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
ans = sum(A)
nums = [A.count(num) for num in range(10 ** 5)]

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * nums[B]
    nums[C] += nums[B]
    nums[B] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

nums = [A.count(num) for num in range(10 ** 5)]
ans = sum(i * num for i, num in enumerate(nums))

for i in range(Q):
    ans += (C[i] - B[i]) * nums[B[i]]
    nums[C[i]] += nums[B[i]]
    nums[B[i]] = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted(map(int, input().split()))
Q = int(input())
B = []
C = []
for _ in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

ans = sum(A)
nums = [A.count(num) for num in range(10 ** 5)]

for i in range(Q):
    ans += (C[i] - B[i]) * nums[B[i]]
    nums[C[i]] += nums[B[i]]
    nums[B[i]] = 0
    print(ans)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n >= (p ** e) and n % (p ** e) == 0:
    n = n // (p ** e)
    score += 1
    e += 1
  else:
    p = p + 1 if p == 2 else p + 2
else:
  if sum([n % (i + 1) == 0 for i in range(p+1, n)]) == 1:
    score += 1
print(score)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input())
print(a * b)
Problem p02660 (python)

Fixed submission:
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  # print(n, p, e)
  while n >= (p ** e) and n % (p ** e) == 0:
    n = n // (p ** e)
    score += 1
    e += 1
  else:
    while n >= p and n % p == 0:
      n = n // p
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)

Buggy submission (verdict: Runtime Error):
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  print(n, p, e)
  while n >= (p ** e) 
and n % (p ** e) == 0:
    n = n // (p ** e)
    score += 1
    e += 1
  else:
    p = p + 1 if p == 2 else p + 2
else:
  if n != 1:
    score += 1
print(score)
Problem p02664 (python)

Fixed submission:
print(input().replace('?', 'D'))

Buggy submission (verdict: Runtime Error):
print(input().replase('?', 'D'))

Buggy submission (verdict: Runtime Error):
print(input().replase('?', 'D')
Problem p02687 (python)

Fixed submission:
S = input()
print('ARC' if S == 'ABC' else 'ABC')

Buggy submission (verdict: Runtime Error):
print('ARC' if input() != 'ABC else 'ABC')

Buggy submission (verdict: Runtime Error):
S = input()
print('ARC' if S != 'ABC else 'ABC')
Problem p02642 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 10 ** 6 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if target > A[-1]:
                break
            if table[target] == 0:
                table[target] = 1
            i += 1
    print(len(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 10 ** 6 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if table[target] == 0:
                table[target] = 1
            i += 1
            if target >= A[-1]:
                break
    print(len(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(10 ** 6 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if table[target] == 0:
                table[target] = 1
            i += 1
            if target >= A[-1]:
                break
    print(len(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 2 * 10 ** 5 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if table[target] == 0:
                table[target] = 1
            i += 1
            if target >= A[-1]:
                break
    print(len(ans))
if __name__ == "__main__":
    main()
Problem p02664 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    T = list(input().rstrip())
    ans = ["D" if c == "?" else c for c in T]
    print("".join(ans))
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    T = input().rstrip()
    T_list = []
    for i, c in enumerate(T):
        if i == 0:
            T_list.append(c)
            continue
        if c == "?":
            if T_list[i-1] == "P":
                T_list.append("D")
            elif T_list[i-1] == "D":
                T_list.append("P")
            continue
        T_list.append(c)
    print("".join(T_list))
if __name__ == "__main__":
    main()
Problem p02714 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def main():
    N = int(input())
    S = input().rstrip("\r\n")
    R = []
    G = []
    B = []
    for i, s in enumerate(S):
        if s == "R":
            R.append(i)
        elif s == "G":
            G.append(i)
        else:
            B.append(i)
    ans = len(R) * len(G) * len(B)
    for i in range(N):
        for j in range(i+1, N):
            k = 2 * j - i
            if k >= N:continue
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
    print(ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
def main():
    N = int(input())
    S = input().rstrip("\r\n")
    R = []
    G = []
    B = []
    for i, s in enumerate(S):
        if s == "R":
            R.append(i)
        elif s == "G":
            G.append(i)
        else:
            B.append(i)
    ans = len(R) * len(G) * len(B)
    for i in range(len(R)):
        for j in range(len(G)):
            diff = G[j] - R[i]
            left = 0
            right = len(B)
            exists_same = False
            while left < right:
                m = (left + right) // 2
                if B[m] - G[j] == diff:
                    exists_same = True
                    break
                elif B[m] - G[j] > diff:
                    right = m
                elif B[m] - G[j] < diff:
                    left = m + 1
            if exists_same:
                ans -= 1
    for i in range(len(R)):
        for j in range(len(B)):
            diff = B[j] - R[i]
            left = 0
            right = len(G)
            exists_same = False
            while left < right:
                m = (left + right) // 2
                if G[m] - B[j] == diff:
                    exists_same = True
                    break
                elif G[m] - B[j] > diff:
                    right = m
                elif G[m] - B[j] < diff:
                    left = m + 1
            if exists_same:
                ans -= 1
    for i in range(len(B)):
        for j in range(len(G)):
            diff = B[j] - R[i]
            left = 0
            right = len(R)
            exists_same = False
            while left < right:
                m = (left + right) // 2
                if R[m] - B[j] == diff:
                    exists_same = True
                    break
                elif R[m] - B[j] > diff:
                    right = m
                elif R[m] - B[j] < diff:
                    left = m + 1
            if exists_same:
                ans -= 1
    print(ans)
if __name__ == "__main__":
    main()
Problem p02727 (python)

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

X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
p = p[A-X:]
q.sort()
q = q[B-Y:]
r.sort()
a = p+q+r
a.sort(reverse=True)
print(sum(a[:X+Y]))

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

X,Y,A,B,C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
m = [X,Y]
ans = 0
while m[0] > 0 or m[1] > 0:
    if m[0] > 0:
        if p[-1] < r[-1]:
            ans += r[-1]
            r.pop()
        else:
            ans += p[-1]
            p.pop()
        m[0] -= 1
    if m[1] > 0:
        if q[-1] < r[-1]:
            ans += r[-1]
            r.pop()
        else:
            ans += q[-1]
            q.pop()
        m[1] -= 1
print(ans)
Problem p02767 (python)

Fixed submission:
import math
N = int(input())
X = list(map(int, input().split(' ')))

s = 0
for xi in X:
    s += xi
si = round(s / N)
ps = 0
for xi in X:
    ps += int(math.pow(xi-si, 2))
print(ps)

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

s = 0
for xi in X:
    s += xi
si = round(s / N)
ps = 0
for xi in X:
    ps += int(math.pow(xi-si, 2))
print(ps)
Problem p02850 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
class Edge:
    def __init__(self, to, id):
        self.to = to
        self.id = id
N = int(input())
graph = {}
ans = [0] * (N-1)
def dfs(v, c=-1, p=-1):
    global graph, ans
    k = 1
    for edge in graph[v]:
        nv = edge.to
        if nv == p:continue
        if k == c:k += 1
        ans[edge.id] = k
        dfs(nv, k, v)
        k += 1
def main():
    global N, graph, ans
    for i in range(N):
        graph[i] = set()
    for i in range(N-1):
        a, b = map(int, input().split())
        graph[a-1].add(Edge(b-1, i))
        graph[b-1].add(Edge(a-1, i))
    color_count = 0
    for i in range(N):
        color_count = max(color_count, len(graph[i]))
    dfs(0, 0, -1)
    print(color_count)
    for x in ans:
        print(x)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque
import heapq
def main():
    N = int(input())
    graph = {}
    for i in range(1, N+1):
        graph[i] = set()
    ans_order = []
    for _ in range(N-1):
        a, b = map(int, input().split())
        graph[a].add(b)
        graph[b].add(a)
        ans_order.append((a, b))
    K = 0
    for i in range(1, N+1):
        K = max(K, len(graph[i]))
    available_colors = deque([i for i in range(1, K+1)])
    not_available_colors = deque([])
    seen = [0 for _ in range(N)]
    seen[0] = 1
    ans = {i: {} for i in range(1, N+1)}
    que = deque([])
    que.append(1)
    pre_edges = deque([])
    while len(que) != 0:
        v = que.popleft()
        pre_edges.append(len(graph[v]))
        for node in graph[v]:
            if seen[node-1] == 1:continue
            seen[node-1] = 1
            col = available_colors.popleft()
            ans[v][node] = col
            not_available_colors.append(col)
            que.append(node)
        if len(pre_edges) > 1:
            restore_count = pre_edges.popleft()
            for _ in range(restore_count):
                if len(not_available_colors) > 0:
                    available_colors.append(not_available_colors.popleft())
    print(K)
    for pair in ans_order:
        a, b = pair
        print(ans[a][b])
if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from fractions import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from math import gcd
def prime_factorize(n):
    res = []
    for i in range(2, int(n**0.5)+1):
        if n % i != 0:continue
        ex = 0
        while n % i == 0:
            ex += 1
            n = n//i
        res.append((i, ex))
    if n != 1:res.append((n, 1))
    return res
def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    res = prime_factorize(g)
    ans = len(res) + 1
    print(ans)
if __name__ == "__main__":
    main()
Problem p02947 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0
def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)

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

N = int(input())
d = defaultdict(int)
for _ in range(N):
    s = list(input().rstrip("\r\n"))
    s.sort()
    d["".join(s)] += 1
ans = 0

def count(v):
    if v == 0:
        return 0
    return v + count(v-1)
for k in d:
    ans += count(d[k]-1)
print(ans)
Problem p03112 (python)

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

a,b,q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for _ in range(a)] + [INF]
t = [-INF] + [int(input()) for _ in range(b)] + [INF]
for _ in range(q):
    x = int(input())
    i = bisect.bisect_right(s,x)
    j = bisect.bisect_right(t,x)
    d = INF
    for si in [s[i-1],s[i]]:
        for ti in [t[j-1],t[j]]:
            d1 = abs(x-si)+abs(ti-si)
            d2 = abs(x-ti)+abs(ti-si)
            d = min(d,d1,d2)
    print(d)

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

a,b,q = map(int, input().split())
m = {}
st = []
for _ in range(a):
    num = int(input())
    st.append(num)
    m[num] = "A"
for _ in range(b):
    num = int(input())
    st.append(num)
    m[num] = "B"
st.sort()

def search_left(idx):
    t = {"A": False, "B": False}
    for i in st[:idx][::-1]:
        if m[i] == "A":t["A"]=True
        if m[i] == "B":t["B"]=True
        if t["A"] and t["B"]:return i
    return 0
def search_right(idx):
    t = {"A": False, "B": False}
    for i in st[idx:]:
        if m[i] == "A":t["A"]=True
        if m[i] == "B":t["B"]=True
        if t["A"] and t["B"]:return i
    return 0
def search_left_one(idx, c):
    for i in st[:idx][::-1]:
        if m[i] == c:return i
def search_right_one(idx, c):
    for i in st[idx:]:
        if m[i] == c:return i
for _ in range(q):
    x = int(input())
    idx = bisect.bisect_left(st,x)
    if idx == 0:
        most_right = search_right(0)
        print(abs(x-most_right))
        continue
    elif idx == a+b:
        most_left = search_left(a+b)
        print(abs(x-most_left))
        continue        
    left = st[idx-1]
    right = st[idx]
    c = "A" if m[left]=="B" else "B"
    most_right = search_right_one(idx, c)
    ans = abs(abs(x-left)+most_right-left)
    c = "A" if m[right]=="B" else "B"
    most_left = search_left_one(idx, c)
    ans = min(ans,abs(abs(x-right)+right-most_left))
    most_left = search_left(idx)
    if most_left != 0:ans = min(ans,abs(x-most_left))
    most_right = search_right(idx)
    if most_right != 0:ans = min(ans,abs(x-most_right))
    print(ans)
Problem p03160 (python)

Fixed submission:
def chmin(dp, idx, a, b):
    if a > b:
        dp[idx] = b
        return True
    else:
        return False
def dp(N, h):
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    for i in range(1, N):
        chmin(dp, i, dp[i], dp[i-1] + abs(h[i]-h[i-1]))
        if i < 2:
            continue
        chmin(dp, i, dp[i], dp[i-2] + abs(h[i]-h[i-2]))
    return dp
N = int(input())
h = list(map(int, input().split(' ')))
dp = dp(N, h)
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
def chmin(dp, idx, a, b):
    if a > b:
        dp[idx] = b
        return True
    else:
        return False
def rec(dp, i):
    INF = 10**9
    if dp[i] < INF:
        return dp[i]
    if i == 0:
        return 0
    chmin(dp, i, dp[i], rec(dp, i-1) + abs(h[i]-h[i-1]))
    if i > 1:
        chmin(dp, i, dp[i], rec(dp, i-2) + abs(h[i]-h[i-2]))
    return dp[i]
def dp(N, h):
    INF = 10 ** 9
    dp = [INF] * N
    dp[0] = 0
    rec(dp, N-1)
    return dp
N = int(input())
h = list(map(int, input().split(' ')))
dp = dp(N, h)
print(dp[N-1])
Problem p03274 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    neg_dists = []
    pos_dists = []
    exists_zero = False
    for xi in x:
        if xi < 0:
            neg_dists.append(abs(xi))
        elif xi > 0:
            pos_dists.append(abs(xi))
        else:
            exists_zero = True
    neg_dists.sort()
    pos_dists.sort()
    ans = 10 ** 9
    count = K - int(exists_zero)
    for i in range(count):
        d = 0
        if i >= len(neg_dists):continue
        d += neg_dists[i]
        if len(pos_dists) == 0 or count-2-i >= len(pos_dists):continue
        d += pos_dists[count-2-i] + neg_dists[i]
        ans = min(ans, d)
    for i in range(count):
        d = 0
        if i >= len(pos_dists):continue
        d += pos_dists[i]
        if len(neg_dists) == 0 or count-2-i >= len(neg_dists):continue
        d += neg_dists[count-2-i] + pos_dists[i]
        ans = min(ans, d)
    if len(neg_dists) > 0 and count <= len(neg_dists):ans = min(ans, neg_dists[count-1])
    if len(pos_dists) > 0 and count <= len(pos_dists):ans = min(ans, pos_dists[count-1])
    if exists_zero and len(neg_dists) == 0 and len(pos_dists) == 0:ans = 0
    print(ans)
            
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    neg_dists = []
    pos_dists = []
    exists_zero = False
    for xi in x:
        if xi < 0:
            neg_dists.append(abs(xi))
        elif xi > 0:
            pos_dists.append(abs(xi))
        else:
            exists_zero = True
    neg_dists.sort()
    pos_dists.sort()
    ans = 10 ** 9
    count = K - int(exists_zero)
    for i in range(count):
        d = 0
        if i >= len(neg_dists):continue
        d += neg_dists[i]
        if count-2-i >= len(pos_dists):continue
        d += pos_dists[count-2-i] + neg_dists[i]
        ans = min(ans, d)
    if count < len(neg_dists):ans = min(ans, neg_dists[count-1])
    if count < len(pos_dists):ans = min(ans, pos_dists[count-1])
    if exists_zero and len(neg_dists) == 0 and len(pos_dists) == 0:ans = 0
    print(ans)
            
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    x = list(map(int, input().split()))
    neg_dists = []
    pos_dists = []
    for xi in x:
        if xi < 0:
            neg_dists.append(abs(xi))
        else:
            pos_dists.append(abs(xi))
    neg_dists.sort()
    pos_dists.sort()
    ans = 10 ** 9
    d = 0
    for i in range(K):
        if i >= len(neg_dists):continue
        d += neg_dists[i]
        if K-2-i >= len(pos_dists):continue
        d += pos_dists[K-2-i] + neg_dists[i]
        ans = min(ans, d)
    if K <= len(neg_dists):ans = min(ans, neg_dists[K-1])
    if K <= len(pos_dists):ans = min(ans, pos_dists[K-1])
    print(ans)
            
if __name__ == "__main__":
    main()
Problem p03485 (python)

Fixed submission:
import math
a, b = map(int, input().split(' '))
print(math.ceil((a+b)/2))

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

if N % 500 <= A:
    print('Yes')
else:
    print('No')
Problem p03502 (python)

Fixed submission:
N = input().rstrip('\r')
fx = 0
for n in N:
    num = int(n)
    fx += num
if int(N) % fx == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
fn = 0
for i in range(1, 9):
    fn += N // (10*i)
if N % fn == 0:
    print('Yes')
else:
    print('No')
Problem p03545 (python)

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

nums = list(map(int, list(input().rstrip('\r\n'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)

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

nums = list(map(int, list(input().rstrip('\r'))))
ans_op = [''] * 3
for bit in range(2**3):
    total = 0
    tmp = [''] * 3
    for i in range(3):
        if i == 0:
            total += nums[i]
        if (bit >> i) & 1:
            total += nums[i+1]
            tmp[i] = '+'
        else:
            total -= nums[i+1]
            tmp[i] = '-'
    if total == 7:
       ans_op = tmp
       break
ans = ''
for i in range(3):
    if i == 0:
        ans += (str(nums[i]))
    ans += (ans_op[i] + str(nums[i+1]))
ans += '=7'
print(ans)