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

ans = 0
left = 0
right = 0
while left <= N-1:
    right = left
    xor = A[left]
    asum = A[left]
    for i in range(left+1, right):
        xor = xor ^ A[i]
        asum += A[i]
    while right <= N-1:
        if left == right or xor == asum:
            right += 1
            if right <= N-1:
                xor = xor ^ A[right]
                asum += A[right]
        else:
            break
    ans += right - left
    left += 1
print(ans)


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

ans = 0
left = 0
right = 0
ex = 0
while left <= N-1:
    right = max(left, right)
    while right <= N-1:
        if ex + A[right] == ex ^ A[right]:
            ex += A[right]
            right += 1
        else:
            ex -= A[left]
            break
    ans += right - left
    left += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N = int(input())
S = [input() for _ in range(N)]

ans = 0
for s in combinations(S, 3):
    _flag = True
    pre = list(map(lambda x: x[0], s))
    for p in pre:
        if p not in ['M', 'A', 'R', 'C', 'H']:
            _flag = False
    if len(pre) != len(list(set(pre))):
        _flag = False
    if _flag:
        ans += 1
print(ans)


Fixed submission:
from itertools import combinations
from collections import Counter

N = int(input())
S = Counter()
for _ in range(N):
    S[input()[0]] += 1
print(sum([S[a]*S[b]*S[c] for a, b, c in combinations('MARCH', 3)]))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
S = ['#'*(W+2)]
white_num = 0
for _ in range(H):
    s = input()
    white_num += s.count('.')
    S.append('#'+s+'#')
S.append('#'*(W+2))

C = [[-1]*(W+2) for _ in range(H+2)]
q = deque()
q.append((1, 1, 0))
xlist = [0, 0, 1, -1]
ylist = [1, -1, 0, 0]
while len(q) > 0:
    x, y, c = q.popleft()
    C[x][y] = c + 1
    for i in range(4):
        mx = x + xlist[i]
        my = y + ylist[i]
        if S[mx][my] == '#' or C[mx][my] >= 0:
            continue
        q.append((mx, my, c+1))
if C[H][W] == -1:
    print(-1)
else:
    print(white_num - C[H][W])


Fixed submission:
from collections import deque

H, W = map(int, input().split())
S = ['#'*(W+2)]
white_num = 0
for _ in range(H):
    s = input()
    white_num += s.count('.')
    S.append('#'+s+'#')
S.append('#'*(W+2))

C = [[-1]*(W+2) for _ in range(H+2)]
C[1][1] = 1
q = deque()
q.append((1, 1))
xlist = [0, 0, 1, -1]
ylist = [1, -1, 0, 0]
while len(q) > 0:
    x, y = q.popleft()
    for i in range(4):
        mx = x + xlist[i]
        my = y + ylist[i]
        if S[mx][my] == '#' or C[mx][my] >= 0:
            continue
        C[mx][my] = C[x][y] + 1
        q.append((mx, my))
if C[H][W] == -1:
    print(-1)
else:
    print(white_num - C[H][W])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
S = []
white_num = 0
for _ in range(H):
    s = input()
    white_num += s.count('.')
    S.append(s)

C = [[-1]*W for _ in range(H)]
C[0][0] = 0
q = deque()
q.append((0, 0, 0))
xlist = [0, 0, 1, -1]
ylist = [1, -1, 0, 0]
while len(q) > 0:
    x, y, c = q.popleft()
    C[x][y] = c + 1
    for i in range(4):
        mx = x + xlist[i]
        my = y + ylist[i]
        if mx < 0 or my < 0 or mx >= H or my >= W or S[mx][my] == '#' or C[mx][my] >= 0:
            continue
        q.append((mx, my, c+1))
if C[H-1][W-1] == -1:
    print(-1)
else:
    print(white_num - C[H-1][W-1])


Fixed submission:
from collections import deque

H, W = map(int, input().split())
S = ['#'*(W+2)]
white_num = 0
for _ in range(H):
    s = input()
    white_num += s.count('.')
    S.append('#'+s+'#')
S.append('#'*(W+2))

C = [[-1]*(W+2) for _ in range(H+2)]
C[1][1] = 1
q = deque()
q.append((1, 1))
xlist = [0, 0, 1, -1]
ylist = [1, -1, 0, 0]
while len(q) > 0:
    x, y = q.popleft()
    for i in range(4):
        mx = x + xlist[i]
        my = y + ylist[i]
        if S[mx][my] == '#' or C[mx][my] >= 0:
            continue
        C[mx][my] = C[x][y] + 1
        q.append((mx, my))
if C[H][W] == -1:
    print(-1)
else:
    print(white_num - C[H][W])
Buggy python submission (verdict: Time Limit Exceeded):
def is_prime(n):
    '''
    素数判定する
    '''
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True


Q = int(input())
prime_list = [None] * 100001
for _ in range(Q):
    ans = 0
    l, r = map(int, input().split())
    for i in range(l, r+1, 2):
        i2 = (i + 1) // 2
        if prime_list[i] == None:
            prime_list[i] = is_prime(i)
        if prime_list[i2] == None:
            prime_list[i2] = is_prime(i2)
        ans += 1 if prime_list[i] and prime_list[i2] else 0
    print(ans)


Fixed submission:
def is_prime(n):
    '''
    素数判定する
    '''
    if n == 1:
        return False
    for k in range(2, int(n**0.5) + 1):
        if n % k == 0:
            return False
    return True


Q = int(input())
prime_list = [False] * 100001
L = []
R = []
for _ in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)
a = [0] * 100001
prime_list[2] = True
for i in range(1, 100001):
    prime_list[i] = is_prime(i)
    if prime_list[i] and prime_list[(i+1)//2]:
        a[i] = a[i-1] + 1
    else:
        a[i] = a[i-1]
for i in range(Q):
    ans = a[R[i]] - a[L[i]-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect


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

BDP = [-1] * N
ans = 0
for a in A:
    b_idx = bisect.bisect_right(B, a)
    for i in range(b_idx,N):
        if BDP[i] == -1:
            c_idx = bisect.bisect_right(C, B[i])
            BDP[i] = N - c_idx
        ans += BDP[i]
print(ans)


Fixed submission:
import bisect


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

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (N - bisect.bisect_right(C, b))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
a = [int(input()) for _ in range(int(input()))]
print(sum([1 for i in set(a) if a.count(i) % 2 == 1]))

Fixed submission:
A = {}
for _ in range(int(input())):
    a = input()
    A[a] = A.get(a, 0) + 1

print(len(list(filter(lambda x: x % 2 != 0, A.values()))))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


N, M = map(int, input().split())
AB = [tuple(sorted(map(int, input().split(' ')))) for _ in range(M)]

ans = 0
for i in range(2, N):
    if tuple([1, i]) in AB and tuple([i, N]) in AB:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


Fixed submission:
n, m = map(int, input().split())
sa = set()
sb = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
import itertools


N, M = map(int, input().split())
AB = [tuple(sorted(map(int, input().split(' ')))) for _ in range(M)]

ans = 0
for i in range(2, N):
    l = [1, i, N]
    ans += sum([1 for edge in zip(l, l[1:]) if tuple(sorted(edge)) in AB]) == 2
if ans > 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
n, m = map(int, input().split())
sa = set()
sb = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(1, n):
    ans.append(abs(sum(a[0:i]) - sum(a[i:n])))
print(min(ans))

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
m = sum(a[:1])
n = sum(a[1:])
ans = [abs(m-n)]
for i in range(1, N-1):
    m += a[i]
    n -= a[i]
    ans.append(abs(m-n))
print(min(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
print(*A[::-2], *A[n%2::2])

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str, A[::-2])), ' '.join(map(str, A[n%2::2])))

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

# TLE
# l = []
# for i, a in enumerate(A):
#     if i%2 == 0:
#         l.append(a)
#     else:
#         l.insert(0, a)
# print(' '.join(map(str, l)))

print(*A[::-2], *A[n%2::2])

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str, A[::-2])), ' '.join(map(str, A[n%2::2])))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = map(int, input().split())
l = []
for a in A:
    l.append(a)
    l.reverse()
print(' '.join(map(str, l)))

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print(' '.join(map(str, A[::-2])), ' '.join(map(str, A[n%2::2])))
Buggy python submission (verdict: Runtime Error):
def bellman_ford(edges, n, src):
    # n:ノード数, src:スタートノード
    # edges:edge(src, tgt, cost)のリスト
    inf = float('inf')
    dist = [inf for _ in range(n)]
    dist[src] = 0
    # 移動経路
    pre = {}

    # 最短経路算出
    for i in range(n-1):
        for edge in edges:
            # srcにコストがあり、tgtのコストよりも低いコストで更新できそうなら
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                pre[edge[1]] = edge[0]

    # 負の閉路検出
    def checkpath(pre, n, src):
        if src in pre and pre[n] == src and pre[src] == n:
            return True
        count = 0
        p = pre[n-1]
        while p != src:
            p = pre[p]
            if p == src and src in pre:
                return True
            count += 1
            if count >= n-1:
                return True
        return False

    is_cycle = checkpath(pre, n, src)
    return (dist, is_cycle)


N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

d, is_cycle = bellman_ford(edges, N, 0)
if is_cycle:
    print('inf')
else:
    print(-d[N-1])

Fixed submission:
def bellman_ford(edges, n, src):
    # n:ノード数, src:スタートノード
    # edges:edge(src, tgt, cost)のリスト
    inf = float('inf')
    dist = [inf for _ in range(n)]
    dist[src] = 0
    # 移動経路
    pre = {}

    # 最短経路算出
    for i in range(n-1):
        for edge in edges:
            # srcにコストがあり、tgtのコストよりも低いコストで更新できそうなら
            if dist[edge[0]] != inf and dist[edge[1]] > dist[edge[0]] + edge[2]:
                dist[edge[1]] = dist[edge[0]] + edge[2]
                pre[edge[1]] = edge[0]

    # 負の閉路検出
    def checkpath(pre, n, src):
        if src in pre and pre[n-1] == src and pre[src] == n-1:
            return True
        count = 0
        p = pre[n-1]
        while p != src:
            p = pre[p]
            if p == src and src in pre:
                return True
            count += 1
            if count >= n-1:
                return True
        return False

    is_cycle = checkpath(pre, n, src)
    return (dist, is_cycle)


N, M = map(int, input().split())
edges = []
for _ in range(M):
    a, b, c = map(int, input().split())
    edges.append((a-1, b-1, -c))

d, is_cycle = bellman_ford(edges, N, 0)
if is_cycle:
    print('inf')
else:
    print(-d[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split(' '))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        for k in range(k+1):
            if i+j+k == s:
                ans += 1
print(ans)

Fixed submission:
k, s = map(int, input().split(' '))
ans = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s-i-j <= k:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

ans = 0
for i in range(2**(len(S)-1)):
    tmp = S[0]
    for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
        if b == '1':
            tmp += '+'
        tmp += S[j+1]
    ans += eval(tmp)
print(ans)


Fixed submission:
S = input()

ans = 0
if len(S) == 1:
    ans = int(S)
else:
    for i in range(2**(len(S)-1)):
        tmp = S[0]
        for j, b in enumerate(format(i, 'b').zfill(len(S)-1)):
            if b == '1':
                tmp += '+'
            tmp += S[j+1]
        ans += eval(tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
ct=1
maxn=p.index(1)
while True:
    if maxn==0:
        break
    p=p[0:maxn]
    i+=1
    maxn=p.index(min(p))
    ct+=1
print(ct)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ct=1
i=1
maxn=p.index(i)
while True:
    if maxn==0:
        break
    p=p[0:maxn]
    i+=1
    maxn=p.index(min(p))
    ct+=1
print(ct)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)

Buggy python submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
ct=1
i=1
maxn=p.index(i)
while True:
    p=p[0:maxn]
    i+=1
    maxn=p.index(min(p))
    ct+=1
    if maxn==0:
        break
print(ct)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ct=1
maxn=p.index(1)
for i in range(1,len(p)):
    if p.index(i+1)<maxn:
        maxn=p.index(i+1)
        ct+=1
print(ct)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
ct=1
maxn=p.index(1)
for i in range(1,len(p)):
    if p.index(i+1)>maxn:
        pass
    else:
        maxn=p.index(i+1)
        ct+=1
print(ct)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
ct=1
minn=p[0]
for i in range(1,n):
    if minn==1:
        #ct+=1
        break
    elif minn>p[i]:
        minn=p[i]
        ct+=1
print(ct)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Fixed submission:
a,b=map(int,input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

print(lcm(a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ct=0
for i in range(n):
    ct+=i
print(ct)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(input())

ans = int(n*(n-1)//2)

print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
        break
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')
Buggy python submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
out=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
        
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')

Fixed submission:
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
out=0
ct=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-2,d-1):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[14]:


S=input()
t=list()
ct=0
for i in range(len(S)-1):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
print(max(t))


# In[ ]:






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

# In[21]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
t.append(ct)
print(max(t))


# In[ ]:

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python
# coding: utf-8

# In[11]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
print(max(t))


# In[ ]:






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

# In[21]:


S=input()
t=list()
ct=0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='T' or S[i]=='G':
        i+=1
        ct+=1
    else:
        t.append(ct)
        ct=0
        i+=1
t.append(ct)
print(max(t))


# In[ ]:
Buggy python submission (verdict: Runtime Error):
N,A,B,C=map(int,input().split())
l=[]

for i in range(N):
l.append(int(input()))
INF=100000

def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))

Fixed submission:
N,A,B,C=map(int,input().split())
l=[]
 
for i in range(N):
    l.append(int(input()))
INF=100000
 
def mp(j,a,b,c):
    if j==N:
      return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else INF
    ret0=mp(j+1,a,b,c)
    ret1=mp(j+1,a+l[j],b,c)+10
    ret2=mp(j+1,a,b+l[j],c)+10
    ret3=mp(j+1,a,b,c+l[j])+10
    return min(ret0,ret1,ret2,ret3)
print(mp(0,0,0,0))
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("YES")
else:
    print("NO")

Fixed submission:
import math
input = input().split(' ')
a = input[0]
b = input[1]
num = int(a + b)
n = math.sqrt(num)
if float.is_integer(n):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())
count = 0
for i in range(N):
	count += 1
	for j in range(M):
		if i+1 < L[j] or i+1 > R[j]:
			count -= 1
			break
print(count)

Fixed submission:
N, M = map(int, input().split())
L = [0] * M
R = [0] * M
for i in range(M):
    L[i], R[i] = map(int, input().split())
s = 1
e = N
for i in range(M):
	if s < L[i]:
		s = L[i]
	if e > R[i]:
		e = R[i]
if s > e:
	print(0)
else:
	print(e-s+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k]:
		ss += s[i]
	else:
		ss += '*'
print(ss)

Fixed submission:
n = int(input())
s = input()
k = int(input())
ss = ''
for i in range(n):
	if s[i] == s[k-1]:
		ss += s[i]
	else:
		ss += '*'
print(ss)