Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
    L = int(input())
    S, T = (input() for _ in [0] * 2)

    s = S * len(T)
    t = T * len(S)
    if s < t:
        a = S
        b = T
    else:
        a = T
        b = S

    i = 0
    while 1:
        x = L - (len(b) * i)
        div_, mod_ = divmod(x, len(a))
        if not mod_:
            ans = a * div_ + b * i
            break
        i += 1
    print(ans)

main()


Fixed submission:
def main():
    L = int(input())
    S, T = (input() for _ in [0] * 2)

    ans = []
    apnd = ans.append
    a = S
    b = T
    i = 0
    for _ in [0] * 2:
        while 1:
            x = L - (len(b) * i)
            div_, mod_ = divmod(x, len(a))
            if not mod_:
                apnd(a * div_ + b * i)
                break
            i += 1
        i = 0
        a, b = b, a
    print(min(ans))

main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
def solve(k, a, b):
    if a - b <= 0 and a < k:
        return -1
    return 1 + (k - a + (a - b) - 1) // (a - b) * 2
k, a, b = map(int, input().split())
print(solve(k, a, b))


Fixed submission:
#!/usr/bin/env python3
def solve(k, a, b):
    if a - b <= 0:
        if k <= a:
            return 1
        else:
            return -1
    return 1 + (k - a + (a - b) - 1) // (a - b) * 2
k, a, b = map(int, input().split())
print(solve(k, a, b))
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b, c, d = map(int, input().split())
h = abs(a - c)
w = abs(b - d)
h1 = h // math.gcd(h, w)
w1 = w // math.gcd(h, w)
print((h1 + w1 - 1) * math.gcd(h, w))


Fixed submission:
#!/usr/bin/env python3
import fractions
a, b, c, d = map(int, input().split())
h = abs(a - c)
w = abs(b - d)
if h == 0 or w == 0:
    ans = 0
else:
    h1 = h // fractions.gcd(h, w)
    w1 = w // fractions.gcd(h, w)
    ans = (h1 + w1 - 1) * fractions.gcd(h, w)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# Atcoder problem Solving

# Code Festival Team Relay
import math

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


def count(X):
    cnt = 0
    for i in range(N):
        w, d = que[i]
        if X >= w:
            cnt+=(X-w)//d+1
    return cnt


# case_impossible
l = -1

# case_possible

r = 10**25

while r-l > 1:
    m = (l+r)//2
    if count(m) < K:
        l = m
    else:
        r = m

print(r)

Fixed submission:
# Atcoder problem Solving

# Code Festival Team Relay
import math

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


def count(X):
    cnt = 0
    for i in range(N):
        w, d = que[i]
        if X >= w:
            cnt+=(X-w)//d+1
    return cnt


# case_impossible
l = -1

# case_possible

r = 10**19

while r-l > 1:
    m = (l+r)//2
    if count(m) < K:
        l = m
    else:
        r = m

print(r)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
print((a**-1+b**-1)**-1)

Fixed submission:
a,b=map(int,input().split())
print((a**-1+b**-1)**-1)
Buggy python submission (verdict: Runtime Error):
inp = raw_input()
list = inp.split()
x = int(list[0])
a = int(list[1])
b = int(list[2])
if abs(a-x)<abs(b-x):
  print('A')
else:
  print('B')


Fixed submission:
inp = raw_input()#raw_input accept number and literary,input accept number only
list = inp.split()
x = int(list[0])
a = int(list[1])
b = int(list[2])
if abs(a-x)<abs(b-x):
  print('A')
else:
  print('B')

Buggy python submission (verdict: Runtime Error):
inp = raw_input()
list = inp.split()
x = int(list[0])
a = int(list[1])
b = int(list[2])
if abs(a-x)<abs(b-x):
  print('A')
else:
  print('B')

Fixed submission:
inp = raw_input()#raw_input accept number and literary,input accept number only
list = inp.split()
x = int(list[0])
a = int(list[1])
b = int(list[2])
if abs(a-x)<abs(b-x):
  print('A')
else:
  print('B')
Buggy python submission (verdict: Runtime Error):
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2]) or (str[1] == str[2] and str[2] == str[3]))else "No


Fixed submission:
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2]) or (str[1] == str[2] and str[2] == str[3]))else "No"

Buggy python submission (verdict: Runtime Error):
str = raw_input()[0:-1]
print "Yes" if((str[0] == str[1] and str[1] == str[2] and str[2] == str[3]) or (str[1] == str[2] and str[2] == str[3] and str[3] == str[4])) else "NO"


Fixed submission:
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2]) or (str[1] == str[2] and str[2] == str[3]))else "No"

Buggy python submission (verdict: Runtime Error):
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2] and str[2] == str[3]) or (str[1] == str[2] and str[2] == str[3] and str[3] == str[4])) else "NO"

Fixed submission:
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2]) or (str[1] == str[2] and str[2] == str[3]))else "No"
Buggy python submission (verdict: Time Limit Exceeded):
def a(n):
    return 2 if(n == 0)else 1 if(n == 1)else a(n - 1) + a(n - 2)

N = input()
print a(N)

Fixed submission:
l = [2, 1]
def a(N): 
    global l
    if(N == 0):
        return 2
    if(N == 1):
        return 1
    if(len(l) > N):
        return l[N]
    ans = a(N - 1) + a(N - 2)
    l.append(ans)
    return ans
    
N = input()
print a(N)
Buggy python submission (verdict: Runtime Error):


N = int(raw_input())
As = [(int(i), 2) for i in raw_input().split(" ")]
Bs = [(int(i), 1) for i in raw_input().split(" ")]
Cs = [(int(i), 0) for i in raw_input().split(" ")]

l = sorted(As + Bs + Cs)


count = (0, 0, 0, 1)
for i in l:
    count[i[1]] += count[i[1] + 1]
print count[0]

Fixed submission:


N = int(raw_input())
As = raw_input().split(" ")
Bs = raw_input().split(" ")
Cs = raw_input().split(" ")

As = [(int(i), 2) for i in As]
Bs = [(int(i), 1) for i in Bs]
Cs = [(int(i), 0) for i in Cs]

l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)

ac = 0
bc = 0
cc = 0

for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print cc

Buggy python submission (verdict: Runtime Error):

N = int(raw_input())
As = [(int(i), 2) for i in raw_input().split(" ")]
Bs = [(int(i), 1) for i in raw_input().split(" ")]
Cs = [(int(i), 0) for i in raw_input().split(" ")]

l = sorted(As + Bs + Cs)


count = (0, 0, 0, 1)
for i in l:
    count[i] += count[i + 1]
print count[0]

Fixed submission:


N = int(raw_input())
As = raw_input().split(" ")
Bs = raw_input().split(" ")
Cs = raw_input().split(" ")

As = [(int(i), 2) for i in As]
Bs = [(int(i), 1) for i in Bs]
Cs = [(int(i), 0) for i in Cs]

l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)

ac = 0
bc = 0
cc = 0

for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print cc

Buggy python submission (verdict: Runtime Error):


N = int(raw_input())
As = [(int(i), 2) for i in raw_input().split(" ")]
Bs = [(int(i), 1) for i in raw_input().split(" ")]
Cs = [(int(i), 0) for i in raw_input().split(" ")]

l = sorted(As + Bs + Cs)


count = (0, 0, 0, 1)
for i in l:
    count[i] += count[i + 1]
print count[0]

Fixed submission:


N = int(raw_input())
As = raw_input().split(" ")
Bs = raw_input().split(" ")
Cs = raw_input().split(" ")

As = [(int(i), 2) for i in As]
Bs = [(int(i), 1) for i in Bs]
Cs = [(int(i), 0) for i in Cs]

l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)

ac = 0
bc = 0
cc = 0

for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print cc

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
As = [(int(i), 2) for i in raw_input().split(" ")]
Bs = [(int(i), 1) for i in raw_input().split(" ")]
Cs = [(int(i), 0) for i in raw_input().split(" ")]
l = sorted(As + Bs + Cs, key=lambda x: (x[0],x[1]))
count = (0, 0, 0)
for i in l:
    count[i[1]] += 1 if(i[1] == 2)else count[2] if(i[1] == 1) else count[1]
print count[0]


Fixed submission:


N = int(raw_input())
As = raw_input().split(" ")
Bs = raw_input().split(" ")
Cs = raw_input().split(" ")

As = [(int(i), 2) for i in As]
Bs = [(int(i), 1) for i in Bs]
Cs = [(int(i), 0) for i in Cs]

l = sorted(As + Bs + Cs, key=lambda x: x[0] + x[1] * 0.1)

ac = 0
bc = 0
cc = 0

for i in l:
    if i[1] == 2:
        ac += 1
    elif i[1] == 1:
        bc += ac
    elif i[1] == 0:
        cc += bc
print cc
Buggy python submission (verdict: Runtime Error):
str = raw_input()
print str[0] + str(len(str)-2) + str[-1]

Fixed submission:
inp = raw_input()
print inp[0] + str(len(inp) - 2) + inp[-1]
Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    b = 4/0
    print "No"


Fixed submission:
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes" if(c1 <= c2)
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    b = 4/0
    print "No"


Fixed submission:
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes" if(c1 <= c2)
elif c1 - 1 == c2 and N == c1 + c2
    print "Yes"
else:
    b = 4/0
    print "No"


Fixed submission:
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"

Buggy python submission (verdict: Runtime Error):
N = int(raw_input())
a = map(int, raw_input().split(" ")[-2:])

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    if ai % 4 == 0:
        c2 += 1

print "Yes" if(c1 <= c2 || (c1 - 1 == c2 and N == c1 + c2))else "No"


Fixed submission:
N = int(raw_input())
a = [int(i[-2:])for i in raw_input().split(" ")]

c1 = 0
c2 = 0

for ai in a:
    if ai % 2 != 0:
        c1 += 1
    elif ai % 4 == 0:
        c2 += 1
if c1 <= c2:
    print "Yes"
elif c1 - 1 == c2 and N == c1 + c2:
    print "Yes"
else:
    print "No"
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=1
for i in range (N):
	P*=i+1
P=P%(10**9+7)
print(P)

Fixed submission:
N=int(input())
P=1
for i in range (N):
	P*=i+1
	P=P%(10**9+7)
print(P)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=1
for i in range (N):
	P*=i+1
print(P%(10**9+7 ))

Fixed submission:
N=int(input())
P=1
for i in range (N):
	P*=i+1
	P=P%(10**9+7)
print(P)
Buggy python submission (verdict: Runtime Error):
K,S =map(int, input().split())
c=0
for i in range(K+1)
	for j in range(K+1)
		if 0<=S-i-j<=K
			c+=1

print(c)

Fixed submission:
K,S =map(int, input().split())
c=0
for i in range(K+1):
	for j in range(K+1):
		if 0<=S-i-j<=K:
			c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
sr = input()

a, b, c, d = int(sr[0]), int(sr[1]), int(sr[2]), int(sr[3])

def calc(one, two, three):
  if a + b*one + c*two + d*three == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        q, w, e = change(q), change(w), change(e)
        print(str(a)+q+str(b)+w+str(c)+e+str(d)+"=7")
        break


Fixed submission:
sr = input()

a, b, c, d = int(sr[0]), int(sr[1]), int(sr[2]), int(sr[3])

def calc(one, two, three):
  if a + one*b + two*c + three*d == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
flag = False
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        flag = True
        break
    if flag:
      break
  if flag:
    break
Buggy python submission (verdict: Runtime Error):
import sys
import math

n = int(raw_input())

root = math.floor(math.sqrt(n))
print(int(root * root))

Fixed submission:
import sys
import math

n = int(input())

root = math.floor(math.sqrt(n))
print(int(root * root))
Buggy python submission (verdict: Time Limit Exceeded):


def ryuka(n):
    if n > 2:
        return ryuka(n - 1) + ryuka(n - 2)
    elif n == 2:
        return 1
    elif n == 1:
        return 2

n = int(input()) +1
print(ryuka(n))

Fixed submission:

n = int(input())

ans = 4
pre = 1
prepre = 2

if n == 1:
    ans = 1
elif n == 2:
    ans = 3
elif n == 3:
    ans = 4
else:
    for n in range(n - 3):
        ans += pre + prepre
        a = prepre
        prepre = pre
        pre = pre + a

print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y = input().split()
X = int(X, 16)
Y = int(Y, 16)

if A < B:
    print('<')
elif A > B:
    print('>')
else:
    print('=')

Fixed submission:
X, Y = input().split()
X = int(X, 16)
Y = int(Y, 16)

if X < Y:
    print('<')
elif X > Y:
    print('>')
else:
    print('=')
Buggy python submission (verdict: Runtime Error):
def s(n):
    ret = 0
    sn = str(n)
    for c in sn:
        ret += int(c)
    return ret
 
N = int(input())
t = N
 
ans = float('inf')
for i in range(600000):
    t += N
    ans = min(s(t), ans)
 
print(ans)

Fixed submission:
c = input()
c2 = input()

if c[0] == c2[2] and c[1] == c2[1] and c[2] == c2[0]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
s_x = [i for i in s if 'x' not in i]

cnt = 1
a, b = ' ', ''
for c in s:
    if c == 'x':
        pass
    elif c != s_x[len(s_x)-cnt]:
        print(-1)
        break
    else:
        cnt += 1
    d = len(s_x)/2
    if cnt <= d+1:
        a += c
        if c == 'x' and cnt > d:
            b += c
    elif cnt > d:
        b += c
else:
    b = ' ' + b[::-1]
    ans = 0
    i, j = 0, 0
    while i < len(a)-1 or j < len(b)-1:
        if i >= len(a):
            i -= 1
        if j >= len(b):
            j -= 1
        if a[i] == b[j]:
            i += 1
            j += 1
        elif a[i] == 'x':
            i += 1
            ans += 1
        elif b[j] == 'x':
            j += 1
            ans += 1
    print(ans)

Fixed submission:
s = input()

i, j = 0, len(s)-1
ans = 0
while i < j:
    if s[i] == s[j]:
        i, j = i+1, j-1
    elif s[i] == 'x':
        i += 1
        ans += 1
    elif s[j] == 'x':
        j -= 1
        ans += 1
    else:
        ans = -1
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

ans = float('inf')
for i in range(1, N):
    ans = min(abs(sum(a[:i])-sum(a[i:])), ans)

print(ans)

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

arai = sum(a)-a[0]
sunuke = a[0]
ans = abs(sunuke-arai)
for i in a[1:-1]:
    sunuke += i
    arai -= i
    ans = min(abs(sunuke-arai), ans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def lucas(n):
     if n == 0:
         return 2
     elif n == 1:
         return 1
     else:
         return lucas(n-1)+lucas(n-2)
n = int(input().strip())
print(lucas(n))

Fixed submission:
memo = [0]*100
memo[0] = 2
memo[1] = 1
def lucas(n):
     if memo[n] != 0:
         return memo[n]
     else:
         memo[n] = lucas(n-1)+lucas(n-2)
         return memo[n] 
n = int(input().strip())
print(lucas(n))
Buggy python submission (verdict: Runtime Error):
S_ = input()
T = input()
a = S_
b = T
def fit(pat, word):
    return all([pi==wi for pi, wi in zip(pat, word) if pi != '?'])

for i in reversed(range(len(a)-len(b)+1)):
    if fit(a[i:i+len(b)], b):
        ret = a[:i]+b+a[i+len(b):]
        break    
print(ret.replace('?', 'a'))



Fixed submission:
S_ = input()
T = input()
a = S_
b = T
def fit(pat, word):
    return all([pi==wi for pi, wi in zip(pat, word) if pi != '?'])

ret = False
for i in reversed(range(len(a)-len(b)+1)):
    if fit(a[i:i+len(b)], b):
        ret = a[:i]+b+a[i+len(b):]
        break    
    
if not ret:
    print('UNRESTORABLE')
elif not '?' in a:
    print(a)
else:
    print(ret.replace('?', 'a'))

Buggy python submission (verdict: Runtime Error):
S_ = input()
T = input()
a = S_
b = T
def fit(pat, word):
    and([pi==wi for pi, wi in zip(pat, w) if s != '?'])
for i in reversed(range(len(a)-len(b)+1)):
    if fit(a[i:i+len(b)], b):
        ret = a[:i]+b+a[i+len(b):]
    
print(ret.replace('?', 'a')


Fixed submission:
S_ = input()
T = input()
a = S_
b = T
def fit(pat, word):
    return all([pi==wi for pi, wi in zip(pat, word) if pi != '?'])

ret = False
for i in reversed(range(len(a)-len(b)+1)):
    if fit(a[i:i+len(b)], b):
        ret = a[:i]+b+a[i+len(b):]
        break    
    
if not ret:
    print('UNRESTORABLE')
elif not '?' in a:
    print(a)
else:
    print(ret.replace('?', 'a'))
Buggy python submission (verdict: Runtime Error):
H, W = map(int,input().strip().split())
for i in range(H):
  line = input()
  for j in range(2):
  print(line)

Fixed submission:
H, W = map(int,input().strip().split())
for i in range(H):
  line = input()
  for j in range(2):
  	print(line)
Buggy python submission (verdict: Runtime Error):
ls = input().strip().split()
return (ls.count('7') == 1) and (ls.count('5')==2)

Fixed submission:
ls = input().strip().split()
print('YES' if (ls.count('7') == 1) and (ls.count('5')==2) else 'NO')
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
k=k+1
count=0
for i in range(k):
    for j in range(k):
        if i+j > s:
            break
        for m in range(k):
            if i+j+m > s:
                break
            if i+j+m == s:
                count = count+1
            #print(i," ",j," ",m)

print(count)

Fixed submission:
k,s = map(int,input().split())
k=k+1
count=0
for i in range(k):
    for j in range(k):
        if i+j > s:
            break
        m = s - (i+j)
        if m >= 0 and m < k:
            count = count+1
        #print(i," ",j," ",m)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if X + Y > S:
            break
        elif Z > K:
            continue
        else:
            if X + Y + Z == S:
                cnt +=1
print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if 0<=Z and Z<=K:
            cnt +=1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y

        if X + Y > S:
            break
        elif Z <= K:
            if X + Y + Z == S:
                cnt +=1
        else:
            continue

print(cnt)

Fixed submission:
K, S = map(int, input().split())
cnt = 0

for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if 0<=Z and Z<=K:
            cnt +=1

print(cnt)
Buggy python submission (verdict: Runtime Error):
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1])

s = input()

dfs(0, s[0], int(s[0]))

Fixed submission:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + '=7')
        break

Buggy python submission (verdict: Runtime Error):
s = input()

def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + s[i + 1], sum + int(s[i + 1]))
        dfs(i + 1, f + "-" + s[i + 1], sum - int(s[i + 1])


dfs(0, s[0], int(s[0]))

Fixed submission:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + '=7')
        break

Buggy python submission (verdict: Runtime Error):
s = input()


def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        dfs(i + 1, f + "+" + s[i + 1], sum + s[i + 1])
        dfs(i + 1, f + "-" + s[i + 1], sum - s[i + 1])


dfs(0, s[0], int(s[0]))

Fixed submission:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += "+"
        else:
            ans -= int(s[i + 1])
            f += "-"
        f += s[i + 1]

    if ans == 7:
        print(f + '=7')
        break
Buggy python submission (verdict: Time Limit Exceeded):
k, s = (int(i) for i in input().split())
count = 0

for i in range(k + 1):
    for j in range(k + 1):
        for k in range(k + 1):
            if i + j + k == s:
                count += 1

print(count)

Fixed submission:
k, s = (int(i) for i in input().split())
count = 0

for h in range(k + 1):
    for i in range(k + 1):
        j = s - i - h
        if 0 <= j <= k:
            count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = tuple(map(int, input().split()))
b =tuple(map(int, input().split()))
c = tuple(map(int, input().split()))

ans = 0

for i in range(n):
    for j in range(n):
            for k in range(n):
                if a[i] < b[j] < c[k]:
                    ans = ans + 1

print(ans)

Fixed submission:
a = input()
b = input()
if a[::-1] == b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
for i in range(n):
    a = input()
    if a in li:
        li.remove(a)
    else:
        li.append(a)

print(len(li))
        

Fixed submission:
n = int(input())
ans = set()
for i in range(n):
    a = input()
    if a in ans:
        ans.remove(a)
    else:
        ans.add(a)
 
print(len(ans))
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split()
a1=int(a)
b1=int(b)
c1=int(c)
d=b1-a1
e=c1-b1
if d==e:
	print('YES')
else :
	print('NO')a,b,c=input().split()

Fixed submission:
a,b,c=input().split()
a1=int(a)
b1=int(b)
c1=int(c)
d=b1-a1
e=c1-b1
if d==e:
	print('YES')
else :
	print('NO')