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

Fixed submission:
#import math
from functools import reduce

def gcd_list(numbers):
    def gcd(a, b):
        if (b == 0):
            return a;
        return gcd(b, a % b)

    return reduce(gcd, numbers)


input_list1 = list(map(int, input().split()))
input_list2 = list(map(int, input().split()))
#input_list1 = [3, 81]
#input_list2 = [33, 105, 57]
N = input_list1[0]
X = input_list1[1]

#print('N:', N)
#print('X:', X)

# 都市のリストにXを追加し、小さい順にソートする
input_list2.append(X)
input_list2.sort()
#print(input_list2)

# それぞれの差を取る
ans_list = []
for i, target in enumerate(input_list2):
    if i == N:
        break
    aa = input_list2[i + 1] - input_list2[i]
    #print(input_list2[i + 1], '-' , input_list2[i])
    ans_list.append(aa)

# 重複排除
ans_list = set(ans_list)

# 最大公約数を求める
if len(ans_list) > 1:
    print(gcd_list(ans_list))
else:
    print(min(ans_list))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


input_list1 = list(map(int, input().split()))
input_list2 = list(map(int, input().split()))
#input_list1 = [3, 81]
#input_list2 = [33, 105, 57]
N = input_list1[0]
X = input_list1[1]

#print('N:', N)
#print('X:', X)

# 都市のリストにXを追加し、小さい順にソートする
input_list2.append(X)
input_list2.sort()
#print(input_list2)

# それぞれの差を取る
ans_list = []
for i, target in enumerate(input_list2):
    if i == N:
        break
    aa = input_list2[i + 1] - input_list2[i]
    #print(input_list2[i + 1], '-' , input_list2[i])
    ans_list.append(aa)

# 重複排除
ans_list = set(ans_list)

# 最大公約数を求める
if len(ans_list) > 1:
    print(gcd_list(ans_list))
else:
    print(min(ans_list))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


input_list1 = list(map(int, input().split()))
input_list2 = list(map(int, input().split()))
#input_list1 = [3, 81]
#input_list2 = [33, 105, 57]
N = input_list1[0]
X = input_list1[1]

#print('N:', N)
#print('X:', X)

# 都市のリストにXを追加し、小さい順にソートする
input_list2.append(X)
input_list2.sort()
#print(input_list2)

# それぞれの差を取る
ans_list = []
for i, target in enumerate(input_list2):
    if i == N:
        break
    aa = input_list2[i + 1] - input_list2[i]
    #print(input_list2[i + 1], '-' , input_list2[i])
    ans_list.append(aa)

# 重複排除
ans_list = set(ans_list)

ans_list = [27, 18, 9, 3]

# 最大公約数を求める
if len(ans_list) > 1:
    print(gcd_list(ans_list))
else:
    print(min(ans_list))
Problem p03280 (python)

Fixed submission:
inp = input()
l = list(map(int, inp.split()))
a = l[0]
b = l[1]

ans = a * b - a - b + 1
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
ans = a * b - a - b + 1
print(ans)
Problem p02939 (python)

Fixed submission:
s = input()
t = ""
ans = 0
prev = 2
i = 0
while i < len(s):
    if prev == 2:
        ans += 1
        prev = 1
        i += 1
    elif s[i-1] != s[i]:
        ans += 1
        prev = 1
        i += 1
    elif (i+1) == len(s):
        break
    else:
        ans += 1
        prev = 2
        i += 2
            

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = ""
ans = 0
for i in range(len(s)):
    t += s[i]
    #print(t)
    if i+1 = len(s) or i+1+len(t) > len(s):
        ans += 1
        t = ""
    elif s[i+1:i+1+len(t)] != t:
        ans += 1
        t = ""

print(ans)
Problem p03035 (python)

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

if a >= 13:
    print(b)
elif a >= 6:
    print(int(b/2))
else:
    print(0)

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

lmin = 1
rmax = n
for i in range(m):
    l, r = map(int, input().split())

    if l > lmin:
        lmin = l

    if r < rmax:
        rmax = r

if rmax	< lmin:
    print(0)
else:
    print(rmax - lmin + 1)
Problem p03044 (python)

Fixed submission:
from collections import deque

n = int(input())
neibors = [[] for i in range(n)]
for i in range(n-1):
    u,v,w = map( int, input().split() )
    neibors[u-1].append( (v-1,w%2) )
    neibors[v-1].append( (u-1,w%2) )

dist = [-1 for i in range(n)]
stack = deque([0])
while( len(stack) != 0 ):
    current = stack.popleft()
    current_dist = dist[current]

    for neibor_n, neibor_w in neibors[current]:
        if dist[neibor_n] == -1:
            stack.append( neibor_n )
            dist[neibor_n] = (neibor_w + current_dist) % 2  

for item in dist:
    print(item)

Buggy submission (verdict: Runtime Error):
class dfs():
    
    def __init__(self, n, el):
        self.n = n
        self.el = el

        self.evenl = [1 for i in range(n)]
        self.neibors = dict([(i,[[],[]]) for i in range(n)])


    def calc(self, nf, used):
        used.append( nf )
        for node in set( self.neibors[nf][0] ) - set(used) :
            if self.evenl[nf] == 1:
                self.evenl[node] = 1
            else:
                self.evenl[node] = 0

            self.calc(node, used)

        for node in set( self.neibors[nf][1] ) - set(used) :
            if self.evenl[nf] == 1:
                self.evenl[node] = 0
            else:
                self.evenl[node] = 1

            self.calc(node, used)


    def set_neibors(self):
        for e in self.el:
            u,v,w = e
            if w % 2 == 0:
                self.neibors[u-1][0].append(v-1)
                self.neibors[v-1][0].append(u-1)
            else:
                self.neibors[u-1][1].append(v-1)
                self.neibors[v-1][1].append(u-1)

n = int(input())
el = []
for i in range(n-1):
    u,v,w = map( int, input().split() )
    el.append( (u,v,w) )    

m = dfs(n,el)
m.set_neibors()
m.calc(0, [])

for item in m.evenl:
    print(item)
Problem p02971 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
ans = 0
Max1 = max(A)
indexes = [i for i, x in enumerate(A) if x == Max1]
if len(A) == len(indexes):
    for i in A:
        print(i)
else:
    Max2 = sorted(set(A))[-2]
    if len(indexes) >= 2:
        for i in range(N):
            print(Max1)
    else:
        for i in range(N):
            ans = Max2 if A[i] == Max1 else Max1
            print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [input() for i in range(N)]
ans = 0
Max1 = max(A)
Max2 = sorted(set(A))[-2]
indexes = [i for i, x in enumerate(A) if x == Max1]
for i in range(N):
    ans = Max2 if len(indexes) < 2 and A[i] == Max1 else Max1
    print(ans)
Problem p02936 (python)

Fixed submission:
N, Q = map(int, raw_input().split())
ans = [0 for i in range(N)]
tree_s = ['' for i in range(N-1)]

for i in range(0, N-1):
    a, b = map(int, raw_input().split())
    tree_s[i] = str(a).zfill(8) + '-' + str(b)

tree_s.sort()

for i in range(0, Q):
    v, p = map(int, raw_input().split())
    ans[v-1] += p

for i in range(0, N-1):
    ab = tree_s[i].split("-")
    ans[int(ab[1])-1] += ans[int(ab[0])-1]


print ' '.join(map(str, ans))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, raw_input().split())
tree = [set() for i in range(N)]
ans = [0 for i in range(N)]


def func(_x, _p):
    ans[_x-1] += _p
    for x in tree[_x-1]:
        func(x, _p)


for i in range(0, N-1):
    a, b = map(int, raw_input().split())
    tree[a-1].add(b)

for i in range(0, Q):
    v, p = map(int, raw_input().split())
    func(v, p)

print ' '.join(map(str, ans))
Problem p02975 (python)

Fixed submission:
N = int(input())
A = map(str, raw_input().split())

nums = {}

for i in range(N):
    if A[i] in nums:
        nums[A[i]] += 1
    else:
        nums[A[i]] = 1

if len(nums) == 1:
    if '0' in nums:
        print('Yes')
    else:
        print('No')
elif len(nums) == 2:
    if '0' in nums and nums['0'] * 3 == len(A):
        print('Yes')
    else:
        print('No')
elif len(nums) == 3:
    keys = [x for x in nums]
    a = keys[0]
    b = keys[1]
    c = keys[2]
    if nums[a] == nums[b] and nums[a] == nums[c] and int(a) ^ int(b) == int(c) and int(b) ^ int(c) == int(a) and int(a) ^ int(c) == int(b):
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

k = 0
g = 0

for i in range(N):
    if A[i] % 2 == 0:
        g += 1
    else:
        k += 1

if k == 0 or (k % g == 0 and k / g == 2):
    print('Yes')
else:
    print('No')
Problem p02972 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = [0]*(n+1)
cnt = 0
for i in range(n,0,-1):
    #print(i)
    for j in range(1,n+1):
        #print(j)
        if(i*j>n):
            break
        else:
            cnt += b[i*j]
    if((cnt%2==0 and a[i]==0) or (cnt%2==1 and a[i]==1)):
        b[i] = 0
    elif((cnt%2==0 and a[i]==1) or (cnt%2==1 and a[i]==0)):
        b[i] = 1
    else:
        b[i]=a[i]
    cnt = 0

m = sum(b)
print(m)
for k in range(1,n+1):
    if(b[k]==1):
        print(k,end=' ')
#print('')
# print(a)
#print(b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
m = 0
cnt = 0
b = [0]*n

for i in range(n-1,-1,-1):
    if(i>=n/2):
        b[i]=a[i]
    else:
        for j in range(1,n):
            if(j*i>n):
                break
            else:
                cnt += b[i*j]%2
        if(cnt==a[i]):
            b[i]=0
        elif(cnt!=a[i]):
            b[i]=1

for i in range(n):
    m += b[i]
print(m)
for k in range(n):
    if(b[k]==1):
        print(k+1,end=" ")
Problem p03030 (python)

Fixed submission:
import numpy as np

N = input()
N = int(N)
a = []
for i in range(0,N):
    S, P = map(str,input().split())
    P = int(P)
    a.append([i,S,P])

b = sorted(a, key=lambda x:(x[1],-x[2]))
for j in range(0,N):
    print(b[j][0]+1)

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

N = input()
N = int(N)
a_np = np.ones((N,1))
a_pd = pd.DataFrame(a_np,columns=['A'])
a_pd['B']=None
a_pd['C']=None
for i in range(0,N):
    S, P = map(str, input().split())
    P = int(P)
    a_pd.loc[i,:] = [i,S,P]
    #print(i,S,P)
b_pd = a_pd.sort_values(['B','C'],ascending=[True, False])
b_pd = b_pd.reset_index()
print(b_pd)
c = b_pd.loc[:,'A']
for j in range(0,N):
    print(int(c[j]+1))
Problem p03106 (python)

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

ans = []

for i in range(1, max(a, b) + 1):
	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

ans = []

for i in range(1, max(a, b)):
 	if a % i == 0 and b % i == 0:
		ans.append(i)

print(ans[-k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

ans = []

for i in range(1, max(a, b) + 1):
  if a % i == 0 and b % i == 0:
    ans.append(i)

    print(ans[-k])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

ans = []

for i in range(1, max(a, b) + 1):
  if a % i == 0 and b % i == 0:
    ans.append(i)

    print(ans[k-1])
Problem p03219 (python)

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

print(X + Y // 2)

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + int(Y / 2))

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + int(Y // 2))

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())
X, Y = a[0], a[1]
print(X + Y // 2)

Buggy submission (verdict: Runtime Error):
X, Y = input().split()

print(X + Y // 2)

Buggy submission (verdict: Runtime Error):
print(int(input()) + int(input()) // 2)

Buggy submission (verdict: Runtime Error):
print(int(input()) + int(input() / 2))
Problem p03239 (python)

Fixed submission:
def abc112_b():
    n, limit_time = map(int, input().split())
    ans = 10000

    for _ in range(n):
        cost, time = map(int, input().split())

        if time <= limit_time and ans > cost:
            ans = cost

    return ans if ans != 10000 else "TLE"


if __name__ == '__main__':
    print(abc112_b())

Buggy submission (verdict: Runtime Error):
import collections

n, T = map(int, input().split())

input_dict = collections.OrderedDict()

for _ in range(n):
    a, b = list(map(int, input().split()))
    input_dict[a] = b

t = min([value for key, value in input_dict.items() if key <= T])

ans = [i for i, x in enumerate(input_dict.values()) if x == t]

if ans is []:
    print('TLE')

else:
    print(list(input_dict.keys()).index(ans))
Problem p03243 (python)

Fixed submission:
x = str(input())

while True:
    if x[0] == x[1] == x[2]:
        print(x)
        break

    x = str(int(x) + 1)

Buggy submission (verdict: Runtime Error):
x = str(input())

while True:
  if x[0] == x[1] == x[2]:
    print(x)
    break
  
  x += 1
Problem p03261 (python)

Fixed submission:
def abc112_b():
    n, limit_time = map(int, input().split())
    ans = 1001

    for _ in range(n):
        cost, time = map(int, input().split())

        if time <= limit_time and ans > cost:
            ans = cost

    return ans if ans != 1001 else "TLE"


def abc109_b():
    length = int(input())
    word_list = []

    for _ in range(length):
        word_list.append(input())

    for i in range(len(word_list) - 1):

        if word_list.count(word_list[i]) >= 2 or word_list[i][-1] != word_list[i+1][0]:
            return "No"

    return "Yes"


if __name__ == '__main__':
    print(abc109_b())

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


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

for i in range(len(W)):
    if W[i][-1] != W[i+1][0]:
        print('No')
        break

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

else:
    print('Yes')

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


N = int(input())

i = 0
W = []
while i < N:
    W.append(str(input()))
    i += 1

for i in range(len(W)):
    if W[i][0] != W[i+1][-1]:
        print('No')
        break

c = collections.Counter(W)

if c.values() in range(2, N+1):
    print('No')

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

Fixed submission:
s = str(input())

ans = 'AC'

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s)):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'

if s.count('C') != 1:
    ans = 'WA'

print(ans)

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

ans = 'AC'
cnt = 0

if s[0] != 'A':
    ans = 'WA'

for i in range(1, len(s) + 1):
    if s[i].isupper():
        if i == 1 or i == len(s) - 1 or s[i] != 'C':
            ans = 'WA'
else:
    cnt += 1

if cnt != 1:
    ans = 'WA'

print(ans)

Buggy submission (verdict: Runtime Error):
 = str(input())
s1 = ''

if len(s) == 4:
    df = len(s)
else:
    df = len(s) - 1
    s1 += s[df:]

flag = False

if s.count('C') == 1:
    for i in range(1, df):
        if s[i] == 'C' and i <= 2:
            flag = True
        else:
            s1 += s[i]
else:
    flag = False

if s1.islower() and len(s) >= 1:
    flag = True
else:
    flag = False

print(s1)

if flag and s[0] == 'A':
    print('AC')
else:
    print('WA')
Problem p03294 (python)

Fixed submission:
import fractions
from functools import reduce
 
 
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
 
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
 
 
n = int(input())
a = [int(i) for i in input().split()]
 
ans1 = 0
 
lcm = lcm_list(a)
 
for num in a:
    ans1 += (lcm - 1) % num
 
print(ans1)

Buggy submission (verdict: Runtime Error):
import math
import fraction
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Buggy submission (verdict: Runtime Error):
import math
import fraction
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


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

ans1 = 0

lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num

print(ans1)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

ans1 = ans2 = 0
li_ans = []


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm = lcm_list(a)

for num in a:
    ans1 += (lcm - 1) % num
    ans2 += (lcm + 1) % num

print(max(ans1, ans2))
Problem p03308 (python)

Fixed submission:
N = int(input())

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

print(max(A) - min(A))

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

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

print(max(A) - min(A))
Problem p03309 (python)

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

B = [A[i] - (i + 1) for i in range(N)]

B.sort()

b = B[len(B) // 2]

ans = 0

for j in range(N):
    ans += abs(A[j] - (b + j + 1))

print(ans)

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

sum = 0
ans = []

for b in range(-int(N / 2), int(N / 2)):
    for i in range(N):
        sum += abs(A[i] - (b + i))
    else:
        ans.append(sum)
        sum = 0

print(min(ans))

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

sum = 0
ans = []

for b in range(int(-N / 2), int(N / 2)):
    for i in range(N):
        sum += abs(A[i] - (b + i))
    else:
        ans.append(sum)
        sum = 0

print(min(ans))
Problem p03316 (python)

Fixed submission:
N = int(input())
sum = 0
a = N
while a > 0:
    sum += a % 10
    a = a // 10

if N % sum == 0:
    print('Yes')
else:
    print('No')

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

while N > 0:
    sum += N % 10
    N = N // 10

if sum % N == 0:
    print('Yes')
else:
    print('No')
Problem p03424 (python)

Fixed submission:
def abc089_b():
    n = int(input())
    s = [str(i) for i in input().split()]

    return "Three" if len(set(s)) == 3 else "Four"


if __name__ == '__main__':
    print(abc089_b())

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [str(i) for i in input().split()]
 
print("Three" if len(list(set(s))) == 3 else "Four" if len(list(set(s))) == 4)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [str(i) for i in input().split()]

print("Three" if len(set(s)) ==3 else "Four" if len(set(s)) == 4)
Problem p03434 (python)

Fixed submission:
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = sorted(a_li, reverse=True)

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())

Buggy submission (verdict: Runtime Error):
def card_game():
    n = int(input())
    a_li = [int(i) for i in input().split()]
    ans = 0
    turn_switch = True

    li = a_li.sorted()

    for i in li:
        if turn_switch:
            ans += i
            turn_switch = False
        else:
            ans -= i
            turn_switch = True

    return ans


if __name__ == '__main__':
    print(card_game())
Problem p03456 (python)

Fixed submission:
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(1, 100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Buggy submission (verdict: Runtime Error):
def abc086_b():
    a, b = map(str, input().split())

    inpt = a + b

    for i in range(100101):
        if int(inpt) / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Buggy submission (verdict: Runtime Error):
def abc086_b():
    a, b = map(str, input().split())
    
    inpt = a + b
    
    for i in range(100101):
        if inpt / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())

Buggy submission (verdict: Runtime Error):
def abc086_b():
    inpt = sum(map(str, input().split()))

    for i in range(100101):
        if inpt / i == i:
            return "Yes"

    return "No"


if __name__ == '__main__':
    print(abc086_b())
Problem p03545 (python)

Fixed submission:
inp = str(input())

A = int(inp[0])
B = int(inp[1])
C = int(inp[2])
D = int(inp[3])

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d-%d-%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)

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

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d+%d+%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)
Problem p03632 (python)

Fixed submission:
def abc070_b():
    a, b, c, d = map(int, input().split())

    if c <= a < b <= d:
        return b - a

    if a <= c < d <= b:
        return d - c

    if a <= c < b <= d:
        return b - c

    if c <= a < d <= b:
        return d - a

    if b <= c or d <= a:
        return 0


if __name__ == '__main__':
    print(abc070_b())

Buggy submission (verdict: Runtime Error):
def abc070_b():
    a, b, c, d = map(int, input().split())
    
    if c > b:
        return 0
    
    if c < a < b < d:
        return b - a
    
    if a < c < b < d:
        return b - c
    
    if a < c < d < b:
        return d - c
    
    
if __name__ == '__main__':
    print(abc048_b())
Problem p03814 (python)

Fixed submission:
def abc053_b():
    s = str(input())

    start = s.index('A')
    end = 0
    for i in range(len(s) - 1, 0, -1):
        if s[i] == "Z":
            return i - start + 1


if __name__ == '__main__':
    print(abc053_b())

Buggy submission (verdict: Runtime Error):
def abc053_b():
    s = str(input())

    start = int(s.index('a'))
    
    for i in range(len(s), 0, -1):
        if s[i] == "z":
            return i - start


if __name__ == '__main__':
    print(abc053_b())
Problem p03963 (python)

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


def abc046_b():
    n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())

Buggy submission (verdict: Runtime Error):

def abc046_b():
	n, k = map(int, input().split())
    return k * ((k - 1) ** (n - 1))


if __name__ == '__main__':
    print(abc046_b())