Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
b = []

for i in range(1, int(n**0.5)+10):
    if n % i == 0:
        a.append(i)
        if i != n//i:
            b.append(n//i)

def Check(x):
    cont= 0
    while x > 0:
        x = x//10
        cont += 1
    return cont

A = []
for i in a:
    A.append(Check(i))

B = []
for i in b:
    B.append(Check(i))

print(max(max(A), min(B)))

Fixed submission:
n = int(input())

def Check(x):
    cont= 0
    while x > 0:
        x = x//10
        cont += 1
    return cont

a = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        a.append(i)

a = max(a)
b = n//a

print(max(Check(a), Check(b)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
b = []

for i in range(1, int(n**0.5)+1):
    if n % i ==0:
        a.append(i)
        if i != n//i:
            b.append(n//i)

def Check(x):
    cont= 0
    while x > 0:
        cont += 1
        x = x//10
    return cont

A = []
for i in a:
    A.append(Check(i))

B = []
for i in b:
    B.append(Check(i)) 

print(max(max(A), min(B)))


Fixed submission:
n = int(input())

def Check(x):
    cont= 0
    while x > 0:
        x = x//10
        cont += 1
    return cont

a = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        a.append(i)

a = max(a)
b = n//a

print(max(Check(a), Check(b)))
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):
        for z in range(k+1):
            if s == x + y + z:
                cnt +=1
print(cnt)

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

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if s - (x+y) <= k:
                cont += 1
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            for z in range(k+1):
                if s == (x + y + z):
                    cont += 1
                    break
print(cont)

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

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if s - (x+y) <= k:
                cont += 1
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            for z in range(k+1):
                if s == (x + y + z):
                    cont += 1
print(cont)

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

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if s - (x+y) <= k:
                cont += 1
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

cont = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == (x + y + z):
                cont += 1
print(cont)

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

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if s - (x+y) <= k:
                cont += 1
print(cont)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

cont = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == (x + y + z):
                cont += 1
print(cont)

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

cont = 0
for x in range(k+1):
    for y in range(k+1):
        if x + y <= s:
            if s - (x+y) <= k:
                cont += 1
print(cont)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a <= 0 and b >= 0:
    print("Zero")
    
elif a < 0 and b < 0:
    if len(list(range(a, b+1))) % 2:
        print("Negative")
    else:
        print("Positive")

else:
    print("Positive")

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

if a <= 0 and b >= 0:
    print("Zero")

elif a < 0 and b < 0:
    if (abs(a)-abs(b+1))%2:
        print("Negative")
    else:
        print("Positive")

else:
    print("Positive")

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif a < 0 and b < 0:
    if len(list(range(a, b+1))) % 2:
        print("Negative")
else:
    print("Positive")

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

if a <= 0 and b >= 0:
    print("Zero")

elif a < 0 and b < 0:
    if (abs(a)-abs(b+1))%2:
        print("Negative")
    else:
        print("Positive")

else:
    print("Positive")
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる

"""


def solve(k, s):
    pattern = 0
    for x in range(k+1):
        if x > s:
            break
        for y in range(k+1):
            if x + y > s:
                break
            for z in range(k+1):
                if x + y + z > s:
                    break
                if x+y+z == s:
                    pattern += 1

    return pattern


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる
まだTLEになるので、もう少し考える
実はzはループする必要はなく z = s - (x + y) <= k であれば +1, > k であれば continueでよい
これでO(N^2)に計算量を抑えられる

"""


def solve(k, s):
    pattern = 0
    for x in range(k+1):
        if x > s:
            break
        for y in range(k+1):
            if x + y > s:
                break
            z = s - x - y
            if z <= k:
                pattern += 1

    return pattern


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

"""


def solve(k, s):
    pattern = 0
    for x in range(k+1):
        for y in range(k+1):
            for z in range(k+1):
                if (x+y+z == s):
                    pattern += 1
    return pattern


if __name__ == "__main__":
    main()


Fixed submission:
#!/usr/bin/env python3
# coding:utf-8

def main():
    stdIn1, stdIn2 = map(int, input().split())
    stdOut = solve(stdIn1, stdIn2)
    print(stdOut)


"""
方針
x,y,zそれぞれを3重ループで0からkまで回す
(O(N^3)だが、k<=2500なので気にならない)
x+y+zが等しければパターンを1追加

TLEになったので、もう少し節約するパターンを考える必要あり
ひとまずx,x+y,x+y+zがsより大きなった場合はbreakさせてループを抜ける処理にしてみる
まだTLEになるので、もう少し考える
実はzはループする必要はなく z = s - (x + y) <= k であれば +1, > k であれば continueでよい
これでO(N^2)に計算量を抑えられる

"""


def solve(k, s):
    pattern = 0
    for x in range(k+1):
        if x > s:
            break
        for y in range(k+1):
            if x + y > s:
                break
            z = s - x - y
            if z <= k:
                pattern += 1

    return pattern


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
print(g.index(0)+1)

Fixed submission:
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e:
    g.append(i)
print(g.index(0)+1)

Buggy python submission (verdict: Runtime Error):
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
h=g.index(0)
print(h+1)

Fixed submission:
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e:
    g.append(i)
print(g.index(0)+1)

Buggy python submission (verdict: Runtime Error):
g=[]
a, b, c, d, e, f = map(int,input().split())
for i in a, b, c, d, e, f:
    g.append(i)
h=g.index(0)
print(h+1)

Fixed submission:
g=[]
a, b, c, d, e = map(int,input().split())
for i in a, b, c, d, e:
    g.append(i)
print(g.index(0)+1)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
a += b
can = 0
for i in range(1,100):
  if(i*i == int(a)):
    can = 1
if(can == 1):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b = input().split()
a += b
can = 0
for i in range(1,1000):
  if(i*i == int(a)):
    can = 1
if(can == 1):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > b :
  print('GREATER')
elif a < b :
  print('LESS')
else :
  print('EQUAL')

Fixed submission:
a = int(input())
b = int(input())
if a > b :
  print('GREATER')
elif a < b :
  print('LESS')
else :
  print('EQUAL')
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split(' '))
d_list = []
for i in range(1, n):
    for j in range(i + 1, n + 1):
        if j <= x or y <= i:  # ok
            d_list.append(j - i)
        elif i <= x and x < j <= y:
            d_list.append(min(j - i, x - i + y - j + 1))
        elif i <= x and j > y: # ここまでok
            d_list.append(x - i + j - y + 1)
        elif x < i < y and j < y:
            d_list.append(min(j - i, i - x + y - j + 1))
        elif x < i < y and j >= y:
            d_list.append(min(j - i, i - x + j - y + 1))
for i in range(1, n):
    print(d_list.count(i))

Fixed submission:
n, x, y = map(int, input().split(' '))
d_dict = {i:0 for i in range(1, n)}
for i in range(1, n):
    for j in range(i + 1, n + 1):
        if j <= x or y <= i:
            d_dict[j - i] += 1
        elif i <= x and x < j <= y:
            d_dict[min(j - i, x - i + y - j + 1)] += 1
        elif i <= x and j > y:
            d_dict[x - i + j - y + 1] += 1
        elif x < i < y and j < y:
            d_dict[min(j - i, i - x + y - j + 1)] += 1
        elif x < i < y and j >= y:
            d_dict[min(j - i, i - x + j - y + 1)] += 1
for i in range(1, n):
    print(d_dict[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for c in [chr(ord('a') + i) for i in range(ord(mx) - ord('a') + 1)]:
            dfs(s + c, chr(ord(mx) + 1) if c == mx else mx)

dfx('', 'a')

Fixed submission:
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for c in [chr(ord('a') + i) for i in range(ord(mx) - ord('a') + 1)]:
            dfs(s + c, chr(ord(mx) + 1) if c == mx else mx)

dfs('', 'a')
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split(' '))
s = input()

if 10 % p == 0:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
else:
    ans = 0
    d = [0 for _ in range(n + 1)]
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        d[i] = (d[i + 1] + a) % p
        ten *= 10
        # ten %= p
    cnt = [0 for _ in range(p)]
    for i in range(n, -1, -1):
        ans += cnt[d[i]]
        cnt[d[i]] += 1
    print(ans)

Fixed submission:
n, p = map(int, input().split(' '))
s = input()

if 10 % p == 0:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
else:
    ans = 0
    d = [0 for _ in range(n + 1)]
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        d[i] = (d[i + 1] + a) % p
        ten *= 10
        ten %= p
    cnt = [0 for _ in range(p)]
    for i in range(n, -1, -1):
        ans += cnt[d[i]]
        cnt[d[i]] += 1
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split(' '))
s = input()
ans = 0

for i in range(len(s)):
    for j in range(i + 1, len(s) + 1):
        n_ss = int(s[i:j])
        if n_ss % p == 0:
            ans += 1

print(ans)

Fixed submission:
n, p = map(int, input().split(' '))
s = input()

if 10 % p == 0:
    ans = 0
    for i in range(n):
        if int(s[i]) % p == 0:
            ans += i + 1
    print(ans)
else:
    ans = 0
    d = [0 for _ in range(n + 1)]
    ten = 1
    for i in range(n - 1, -1, -1):
        a = int(s[i]) * ten % p
        d[i] = (d[i + 1] + a) % p
        ten *= 10
        ten %= p
    cnt = [0 for _ in range(p)]
    for i in range(n, -1, -1):
        ans += cnt[d[i]]
        cnt[d[i]] += 1
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, '0{}b'.format(n))
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))


Fixed submission:
a, b, c = map(int, input().split(' '))
print('win') if a + b + c <= 21 else print('bust')

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

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, '0{}b'.format(n)
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))


Fixed submission:
a, b, c = map(int, input().split(' '))
print('win') if a + b + c <= 21 else print('bust')
Buggy python submission (verdict: Runtime Error):
n = int(input())

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, f'0{n}b')
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))


Fixed submission:
n = int(input())

testimony_dict = {}
for i in range(n):
    a = int(input())
    testimony_dict[i + 1] = []
    for j in range(a):
        xy = input().split(' ')
        testimony_dict[i + 1].append(xy)

max_valid_bin = ''
for i in range(2 ** n - 1, 0, -1):
    is_valid = True
    bin_i = format(i, '0{}b'.format(n))
    for j in range(1, len(bin_i) + 1):
        if bin_i[j - 1] == '1':
            for xy_list in testimony_dict[j]:
                if bin_i[int(xy_list[0]) - 1] != xy_list[1]:
                    is_valid = False
    if is_valid:
        max_valid_bin = bin_i
        break

print(len([i for i in max_valid_bin if i == '1']))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [''.join(sorted(input())) for _ in range(n)]
s_set = set(s_list)
cnt = 0
for s in s_set:
    cnt += sum(range(s_list.count(s)))
    s_list.remove(s)
print(cnt)

Fixed submission:
n = int(input())
cnt = 0
s_dic = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in s_dic.keys():
        s_dic[s] += 1
        cnt += s_dic[s]
    else:
        s_dic[s] = 0

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [''.join(sorted(input())) for _ in range(n)]
s_set = set(s_list)
cnt = 0
for s in s_set:
    cnt += sum(range(s_list.count(s)))
print(cnt)

Fixed submission:
n = int(input())
cnt = 0
s_dic = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in s_dic.keys():
        s_dic[s] += 1
        cnt += s_dic[s]
    else:
        s_dic[s] = 0

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [''.join(sorted(input())) for _ in range(n)]
cnt = 0
for i in range(len(s_list) - 1):
    for j in range(i + 1, len(s_list)):
        if s_list[i] == s_list[j]:
            cnt += 1
print(cnt)

Fixed submission:
n = int(input())
cnt = 0
s_dic = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in s_dic.keys():
        s_dic[s] += 1
        cnt += s_dic[s]
    else:
        s_dic[s] = 0

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s_list = [sorted(list(input())) for _ in range(n)]
cnt = 0
for i in range(len(s_list) - 1):
    for j in range(i + 1, len(s_list)):
        if s_list[i] == s_list[j]:
            cnt += 1
print(cnt)


Fixed submission:
n = int(input())
cnt = 0
s_dic = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in s_dic.keys():
        s_dic[s] += 1
        cnt += s_dic[s]
    else:
        s_dic[s] = 0

print(cnt)
Buggy python submission (verdict: Runtime Error):
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 x in range(Q):
  b = bisect.bisect_right(s, x)
  d = disect.bisect_right(t, x)
  dist = 0
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)

Fixed submission:
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 i in range(Q):
  x = int(input())
  b = bisect.bisect_right(s, x)
  d = bisect.bisect_right(t, x)
  dist = INF
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

a, b, q = list(map(int, input().split(' ')))

s_list = np.array([int(input()) for _ in range(a)])
t_list = np.array([int(input()) for _ in range(b)])

for i in range(q):
    x = int(input())

    _s_list_abs = np.abs(s_list - x)
    _t_list_abs = np.abs(t_list - x)

    s_min = np.min(_s_list_abs)
    t_min = np.min(_t_list_abs)

    s_min_dist = s_min
    tmp_x = s_list[np.argmin(_s_list_abs)]
    s_min_dist += np.min(np.abs(t_list - tmp_x))

    t_min_dist = t_min
    tmp_x = t_list[np.argmin(_t_list_abs)]
    t_min_dist += np.min(np.abs(s_list - tmp_x))

    print(np.min([s_min_dist, t_min_dist]))

Fixed submission:
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 i in range(Q):
  x = int(input())
  b = bisect.bisect_right(s, x)
  d = bisect.bisect_right(t, x)
  dist = INF
  for sb in [s[b - 1], s[b]]:
    for td in [t[d - 1], t[d]]:
      d1, d2 = abs(x - sb) + abs(sb - td), abs(x - td) + abs(td - sb)
      dist = min(dist, d1, d2)
  print(dist)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

cnt = 0
while 'BW' in s:
    cnt += s.count('BW')
    s = s.replace('BW', 'WB')

print(cnt)


Fixed submission:
s = input()

w_cnt = 0
_b_cnt = 0
b_flag = False
cnt = 0
for si in list(s)[::-1]:
    if si == 'B':
        _b_cnt += 1
    if si == 'W':
        cnt += w_cnt * _b_cnt
        w_cnt += 1
        _b_cnt = 0
cnt += w_cnt * _b_cnt

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

cnt = 0
while 'BW' in s:
    s = s.replace('BW', 'WB', 1)
    cnt += 1

print(cnt)


Fixed submission:
s = input()

w_cnt = 0
_b_cnt = 0
b_flag = False
cnt = 0
for si in list(s)[::-1]:
    if si == 'B':
        _b_cnt += 1
    if si == 'W':
        cnt += w_cnt * _b_cnt
        w_cnt += 1
        _b_cnt = 0
cnt += w_cnt * _b_cnt

print(cnt)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j:
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())

ans = (x - a) % b
print(ans)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				cnt += 1

print(cnt)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

cnt = 0
for i in range(a + 1):
	if 500 * i <= x:
		p = x - 500 * i
		for j in range(b + 1):
			if 100 * j <= p:
				q = p - 100 * j:
				for k in range(c + 1):
					if q - 50 * k == 0:
						cnt += 1

print(cnt)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a + 1):
	for j in range(b + 1):
		for k in range(c + 1):
			if 500 * i + 100 * j + 50 * k == x:
				cnt += 1

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

X=[]
Y=[]
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
A="NO"
for n in range(N-2):
    if X[n]==Y[n] and X[n+1]==Y[n+1] and X[n+2]==Y[n+2]:
        A="YES"
        break
print(A)

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

lstx=[a,b]
lsty=[c,d]
result=[]
for i in lstx:
    for n in lsty:
        result.append(i*n)
print(max(result))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split(' ')))

res = 1

for i in l:
    res *= i

if res > 10**18:
    print('-1')
else:
    print(res)


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

res = 1

l.sort()

for i in l:
    res *= i
    if res > 10**18:
        res = -1
        break

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

result = 0
for i in range(N):
    result += A[i] * sum(A[i+1:]) % (10**9 + 7)
print(result % (10**9 + 7))


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

A_sum = sum(A)
result = 0
for i in range(N):
    A_sum -= A[i]
    result += A[i] * A_sum % (10**9 + 7)
print(result % (10**9 + 7))

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

result = 0
for i in range(N):
    for j in range(i+1, N):
        result += (A[i] * A[j]) % (10**9 + 7)
print(result % (10**9 + 7))


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

A_sum = sum(A)
result = 0
for i in range(N):
    A_sum -= A[i]
    result += A[i] * A_sum % (10**9 + 7)
print(result % (10**9 + 7))

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

result = 0
for i in range(N):
    for j in range(i+1, N):
        result += (A[i] * A[j])
print(result % (10**9 + 7))


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

A_sum = sum(A)
result = 0
for i in range(N):
    A_sum -= A[i]
    result += A[i] * A_sum % (10**9 + 7)
print(result % (10**9 + 7))