Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().strip().split(" ")))
ANS=[]
for i in range(200000):
    ANS.append(A.count(i))
ANS.sort(reverse=True)
B=[e for e in ANS if e>0]

P=[]
if len(B)<=k:
    print(0)
else:
    for i in B[k:]:
        P.append(i)
    print(sum(P))

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().strip().split(" ")))
dict={}

for i in A:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1

X=[]
sorted_A = sorted(dict.items(), key=lambda x: x[1], reverse=True)
for i,v in sorted_A:
    X.append(v)

ans=0
if len(X)>k:
    for i in X[k:]:
        ans+=i
print(ans)
Buggy python submission (verdict: Runtime Error):
A=str(input())
a=A.index("A")
Z=[]
for i in enumerate(A):
    if i[1]=="Z":
        Z.append(i[0])
if len(Z)>=2:
    b=max(Z)
else:
    b=A.index("B")
print(len(A[a:b+1]))

Fixed submission:
A=str(input())
a=A.index("A")
Z=[]
for i in enumerate(A):
    if i[1]=="Z":
        Z.append(i[0])
if len(Z)>=2:
    b=max(Z)
else:
    b=A.index("Z")

print(len(A[a:b+1]))
Buggy python submission (verdict: Runtime Error):
s = input()
return s[:-8]

Fixed submission:
s = input()
print(s[:-8])

Buggy python submission (verdict: Runtime Error):
s = input()
return s[:-4]

Fixed submission:
s = input()
print(s[:-8])
Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(x**(1/2))
max_ = 0

while a > 1:
    i = 2
    while a**i <= x:
        if max_ < a**i:
            max_ = a**i
        i += 1
    a -=1
print(max_)

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

if abs(c - a) <= d:
    print("Yes")
elif abs(b - a) <= d and abs(c - b) <= d:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
a = int(x**(1/2))
max_ = 1
    
while a >= 1:
    i = 2
    while a**i < x:
        if max_ <= a**i:
            max_ = a**i
        i += 1
    a -=1
print(max_)

Fixed submission:
x = int(input())
a = int(x**(1/2))
max_ = -1

i = 2

while i <= a:
    j = 2
    while i**j <= x:
        if max_ <= i**j:
            max_ = i**j
        j += 1
    i += 1

if max_ < 0:
    print(1)
else:
    print(max_)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split(" ")))
#print(n, a)

if n == 2:
    print(abs(a[1]) * 2)
    print(abs(a[0]) * 2)
else:
    for i in range(len(a)):
        cost = 0
        if i == 0:
            cost += abs(a[1]) + abs(a[-1])
            for j in range(1, len(a)-1):
                cost += abs(a[j] - a[j+1])
            print(cost)
        elif i == len(a)-1:
            cost += abs(a[0]) + abs(a[-2])
            for j in range(0, len(a)-2):
                cost += abs(a[j] - a[j+1])
            print(cost)
        else:
            cost += abs(a[0]) + abs(a[-1]) + abs(a[i+1] - a[i-1])
            for j in range(i-1):
                cost += abs(a[j] - a[j+1])
            for j in range(i+1, len(a)-1):
                cost += abs(a[j] - a[j+1])
            print(cost)

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

a.insert(0,0)
a.append(0)

total = 0
for i in range(len(a)-1):
    total += abs(a[i] - a[i+1])

for j in range(1, len(a)-1):
    print(total - abs(a[j-1] - a[j]) - abs(a[j] - a[j+1]) + abs(a[j+1]- a[j-1]))

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

if n == 2:
    print(abs(a[1]) * 2)
    print(abs(a[0]) * 2)
else:
    for i in range(len(a)):
        b = a[:]
        b.remove(b[i])
        #print(b)
        
        cost = abs(b[0]) + abs(b[-1])
        for i in range(len(b)-1):
            cost += abs(b[i] - b[i+1])
        print(cost)

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

a.insert(0,0)
a.append(0)

total = 0
for i in range(len(a)-1):
    total += abs(a[i] - a[i+1])

for j in range(1, len(a)-1):
    print(total - abs(a[j-1] - a[j]) - abs(a[j] - a[j+1]) + abs(a[j+1]- a[j-1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

from operator import mul
from functools import reduce

even_list = list(filter(lambda x:x%2==0, a))

if len(even_list) == 0:
    print(0)
else:
    m = reduce(mul, even_list)
    count = 0
    while True:
        m = m / 2
        count += 1
    
        if m % 2 == 1:
            break

    print(count)



Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]

from operator import mul
from functools import reduce

even_list = list(filter(lambda x:x%2==0, a))

if len(even_list) == 0:
    print(0)
else:

    count = 0

    for m in even_list:
    
        while True:
            m = m / 2
            count += 1
    
            if m % 2 == 1:
                break

    print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = map(int, input().split())
c = 0

for i in range(1, N):
	if s[i] == s[i - 1]:
		c += 1
	else:
print(c)


Fixed submission:
N = int(input())
a = [s for s in map(int, input().split())]
a.append(-1)
c = 0
result = 0
for i in range(1, N + 1):
	if a[i] == a[i - 1]:
		c += 1
	else:
		if c == 0:
			continue
		else:
			c += 1
			if c % 2 == 1:
				result += (c - 1) / 2
				c = 0
			else:
				result += c / 2
				c = 0
print(int(result))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s = map(int, input().split())
c = 0

for i in range(1, N):
	if s[i] == s[i - 1]:
		c += 1
	else:
		pass
print(c)


Fixed submission:
N = int(input())
a = [s for s in map(int, input().split())]
a.append(-1)
c = 0
result = 0
for i in range(1, N + 1):
	if a[i] == a[i - 1]:
		c += 1
	else:
		if c == 0:
			continue
		else:
			c += 1
			if c % 2 == 1:
				result += (c - 1) / 2
				c = 0
			else:
				result += c / 2
				c = 0
print(int(result))
Buggy python submission (verdict: Runtime Error):
D, N = map(int, input().split())
output = 1
for i in range(D):
	output *= 100
if N = 100:
	N = 101
output *= N
print(output)


Fixed submission:
D, N = map(int, input().split())
output = 1
for i in range(D):
	output *= 100
if N == 100:
	N = 101
output *= N
print(output)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

c, d = (int(i) for i in input().split())  
a = [int(i) for i in input().split()]
b = a.copy()

k = 0
for i in a:
    b[k] = abs(i - d)
    k += 1

m = min(b) 

lo = []

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


                
print(gcd_list(b))

Fixed submission:
a, b = (int(i) for i in input().split())

if a%2 ==0 or b%2 ==0: 
    print("No") 
else: 
    print("Yes")
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
m=0
for i in range(n-1):
    x=s[:i]
    y=s[i:]
    x=set(x)
    y=set(y)
    z=x.intersection(y)
    m=max(len(z),m)
print(m)

Fixed submission:
x=input().split()
(a,b)=(int(x[0]),int(x[1]))
print(max(a*b,a-b,a+b))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
m=n+5
for i in range(n):
    c=0
    w=s[:i]
    e=s[i+1:]
    for j in w:
        if j=='W':
            c+=1
    for j in e:
        if j=='E':
            c+=1
    m=min(m,c)
print(m)

Fixed submission:
n=int(input())
s=input()
m=n+5
w=0
e=0
for i in range(1,n):
    if s[i]=='E':
        e+=1
m=min(m,w+e)
for i in range(1,n):
    if s[i-1]=='W':
        w+=1
    if s[i]=='E':
        e-=1
    m=min(m,w+e)
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
s=list(input())
t=list(input())
sl = [s.count(e) for e in s]
tl = [t.count(e) for e in t]
if sl==tl:
    print('Yes')
else:
    print('No')

Fixed submission:
s=list(input())
t=list(input())
s_res = sorted(set(s), key=s.index)
t_res = sorted(set(t), key=t.index)
sl = [s.count(e) for e in s_res]
tl = [t.count(e) for e in t_res]
if sl==tl:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
xy=input().split()
x1=int(hw[0])
y1=int(hw[1])
x2=int(hw[2])
y2=int(hw[3])
a=x2-x1
b=y2-y1
print(x2-b,y2+a,x1-b,y1+a)

Fixed submission:
xy=input().split()
x1=int(xy[0])
y1=int(xy[1])
x2=int(xy[2])
y2=int(xy[3])
a=x2-x1
b=y2-y1
print(x2-b,y2+a,x1-b,y1+a)
Buggy python submission (verdict: Runtime Error):
l=input.split()
a=int(l[0])
b=int(l[1])
if a<9 and b<9:
    print('Yay!')
else:
    print(':(')

Fixed submission:
l=input().split()
a=int(l[0])
b=int(l[1])
if a<9 and b<9:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()
Fujitakes-MacBook-Pro:tmp mas

Fixed submission:
def main():
    nums = sorted([int(i) for i in input().split()], reverse=True)
    max_num = 10 * nums[0] + nums[1] + nums[2]
    print(max_num)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
K = int(input())
max_index = numbers.index(max(numbers))
result = [numbers[i] * 2 ** K if i == max_index else numbers[i] for i in range(len(numbers))]
print(sum(result))

Fixed submission:
a, b = list(map(int, input().split()))
if a <= b:
    print(a)
else:
    print(a-1)
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())

a = 2 * N / math.gcd(2, N)

print(a)

Fixed submission:
N = int(input())
if N%2==0:
    print(N)
elif N%2!=0:
    print(2*N)
Buggy python submission (verdict: Time Limit Exceeded):
import statistics
N = int(input())
A = list(map(int,input().rstrip().split()))

i = 0
kari =[]
for j in A:
    i +=1
    B = j-i
    kari.append(B)

sum = 0
for i in kari:
    sum+=abs(i-statistics.median(kari))
print(int(sum))

Fixed submission:
import math
import statistics
N = int(input())

A = input().rstrip().split()
#print(A)
i = 0
kari =[]
for j in A:
    i +=1
    B = int(j)-i
    kari.append(B)
#print(kari)
b = statistics.median(kari)

sum = 0
for i in kari:
    sum+=abs(i-b)
print(int(sum))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    del A[0:K]
print(sum)

Fixed submission:
N = list(input())
sum=0
for i in N:
    if i == '+':
        sum+=1
    elif i == '-':
        sum-=1
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    del A[0:K]
print(sum)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(K,min(A[:K]))
    print(A)
    del A[0:K]
print(sum)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().rstrip().split()))
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(0,min(A[:K]))
    del A[0:K]
print(sum)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))

Buggy python submission (verdict: Time Limit Exceeded):
line = list(map(int,input().rstrip().split()))
N = line[0]
K = line[1]
A = list(map(int,input().rstrip().split()))
sum =0
while len(A)>=2:
    sum+=1
    A.insert(0,min(A[:K]))
    del A[0:K]
print(sum)

Fixed submission:
import math
N,K = map(int,input().rstrip().split())
print(math.ceil((N-1)/(K-1)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S= input()
a= []
for i in range(N):
    a.append(S[0:i].count('W')+S[i:N].count('E'))
print(min(a))

Fixed submission:
N = int(input())
S = input()
Ecount = S.count('E')
Wcount = 0
min = Ecount
for i in S:
    if i == 'E':
        Ecount -= 1
    else:
        Wcount += 1
    if min > Ecount + Wcount:
        min = Ecount + Wcount
print(min)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
a = []
for i in range(A,B+1):
    a.append(i)
b =set(a[0:K]+a[-K:])
print(' '.join(map(str, sorted(b))))

Fixed submission:
A,B,K = map(int,input().split())
a = []

if B-A<=K:
    for i in range(A,B+1):
        print(i)
else:
    for i in range(A,A+K):
        a.append(i)
    for i in range(B-K+1,B+1):
        a.append(i)
    b =set(a)
    print(' '.join(map(str, sorted(b))))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N=int(input())
    a=[0]+list(map(int,input().split()))+[0]
    cost=[]
    for i in range(N+1):
        cost.append(abs(a[i+1]-a[i]))
    for i in range(N):
        print(sum(cost)-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))
main()

Fixed submission:
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
    cost.append(abs(a[i+1]-a[i]))
S = sum(cost)
for i in range(N):
    print(S-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
        cost.append(abs(a[i+1]-a[i]))
for i in range(N):
    print(sum(cost)-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))

Fixed submission:
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
    cost.append(abs(a[i+1]-a[i]))
S = sum(cost)
for i in range(N):
    print(S-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
    if i==0:
        cost.append(abs(a[i]))
    else:
        cost.append(abs(a[i]-a[i-1]))
cost.append(abs(a[N]))
for i in range(N):
    print(sum(cost)-cost[i+1]-cost[i+2]+abs(a[i+2]-a[i]))

Fixed submission:
N=int(input())
a=[0]+list(map(int,input().split()))+[0]
cost=[]
for i in range(N+1):
    cost.append(abs(a[i+1]-a[i]))
S = sum(cost)
for i in range(N):
    print(S-cost[i]-cost[i+1]+abs(a[i+2]-a[i]))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

print(abs(N-2)*abs(M-2))

Fixed submission:
a = list(input())
b = list(input())
c = list(input())
print(a[0]+b[1]+c[2])
Buggy python submission (verdict: Runtime Error):
A,B,C,D =map(int,input().split())

if A+B >C+D:
    print('Left')
elif A+B ==C+D:
    print('Balanced')
else A+B <=C+D:
    print('Right')

Fixed submission:
A,B,C,D =map(int,input().split())

if A+B >C+D:
    print('Left')
elif A+B ==C+D:
    print('Balanced')
elif A+B <=C+D:
    print('Right')
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
a = 0
for i in range(1,N+1):
    s = sum(map(int,str(i)))
    if A <= s <= B:
        a += n
print(a)

Fixed submission:
N,A,B = map(int,input().split())
a = 0
for i in range(1,N+1):
    s = sum(map(int,str(i)))
    if A <= s <= B:
        a += i
print(a)
Buggy python submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print(int(math.ceil((a+b)/2,0)))

Fixed submission:
import math
a,b = map(int,input().split())
print(int(math.ceil((a+b)/2)))
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
s = list(map(int,input().split()))
c = Counter(src)
ans = 0
for i,j in c.items():
    ans += j if j<i else j-i
print(ans)

Fixed submission:
from collections import Counter
N = int(input())
s = list(map(int,input().split()))
c = Counter(s)
ans = 0
for i,j in c.items():
    ans += j if j<i else j-i
print(ans)

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

count=0
for i in b:
    if a.count(i)==i:
        pass
    elif a.count(i)>i:
        for j in range(a.count(i)-i):
        	a.remove(i)
        	count+=1
    else:
        for j in range(a.count(i)):
        	a.remove(i)
        	count+=1
print(count)

Fixed submission:
from collections import Counter
N = int(input())
s = list(map(int,input().split()))
c = Counter(s)
ans = 0
for i,j in c.items():
    ans += j if j<i else j-i
print(ans)

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

count=0
for i in b:
    if a.count(i)==i:
        pass
    elif a.count(i)>i:
            count+=1*(a.count(i)-i)
    else:
            count+=1*a.count(i)
print(count)

Fixed submission:
from collections import Counter
N = int(input())
s = list(map(int,input().split()))
c = Counter(s)
ans = 0
for i,j in c.items():
    ans += j if j<i else j-i
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(N)
if N[0]==N[1]==N[2]==N[3] or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()
a = list(N)
if N[0]==N[1]==N[2]==N[3] or N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
 
i = 1
for i in range(N):
    if i >= K:
	i += K
    else:
	i *= 2
print(i)

Fixed submission:
N = int(input())
K = int(input())
 
i = 1
for j in range(N):
    i=min(i*2, i+K)
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(M)]
b = []
c = []
for i in a:
    if i[0]==1:
        b.append(i)
    elif i[1]==N:
        c.append(i)
for i in b:
  for j in c:
    if i[1]==j[0]:
    	print('POSSIBLE')
    	exit()
print('IMPOSSIBLE')

Fixed submission:
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(M)]
b = set()
for i in a:
    if i[0]==1 or i[1]==N:
        b.add((i[0],i[1]))
for i in range(2,N):
    if (1,i) in b and (i,N) in b:
    	print('POSSIBLE')
    	exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
atai =abs(sum(a[0:1])-sum(a[1:]))
suma = sum(a)
atai = abs(suma - 2*sum(a[:1]))
for i in range(N-1):
    h = abs(suma - 2*sum(a[:i+1]))
    atai = min(h,atai)
print(atai)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = sum(a) - 2*a[0]
abst = abs(ans)
for i in range(1,N-1):
    ans -=2*a[i]
    if abs(ans)<abst:
        abst = abs(ans)
print(abst)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
atai =abs(sum(a[0:1])-sum(a[1:]))
for i in range(N-1):
    h = abs(sum(a[:i+1])-sum(a[i+1:]))
    atai = min(h,atai)
print(atai)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = sum(a) - 2*a[0]
abst = abs(ans)
for i in range(1,N-1):
    ans -=2*a[i]
    if abs(ans)<abst:
        abst = abs(ans)
print(abst)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
temp=a[0]
for i in range(n - 1):
    if temp > 0:
        temp+=a[i+1]
        if temp < 0:
            pass
        else:
            while temp >= 0:
                temp -= 1
                ans += 1
    else:
        temp+=a[i+1]
        if temp > 0:
            pass
        else:
            while temp <= 0:
                temp += 1
                ans += 1
print(ans)


Fixed submission:
import functools
n = int(input())
a = list(map(int, input().split()))

@functools.lru_cache()
def memo(n):
    ans1 = 0
    ans2 = 0
    now = 0

    for i in range(n):
        now += a[i]
        if i % 2 == 0:
            if now <= 0:
                ans1 += 1 - now
                now = 1
        else:
            if now >= 0:
                ans1 += now + 1
                now = -1

    now = 0

    for i in range(n):
        now += a[i]
        if i % 2 == 1:
            if now <= 0:
                ans2 += 1 - now
                now = 1
        else:
            if now >= 0:
                ans2 += now + 1
                now = -1
    
    return min([ans1,ans2])

print(memo(n))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans =0
    
for i in range(n-1):
    if a[i]>0:
        if sum(a[:i+2])<0:
            pass
        else:
            while sum(a[:i+2])>=0:
                 a[i+1]-=1
                 ans+=1
    else:
        if sum(a[:i+2])>0:
            pass
        else:
            while sum(a[:i+2])<=0:
                a[i+1]+=1
                ans+=1
print(ans)

Fixed submission:
import functools
n = int(input())
a = list(map(int, input().split()))

@functools.lru_cache()
def memo(n):
    ans1 = 0
    ans2 = 0
    now = 0

    for i in range(n):
        now += a[i]
        if i % 2 == 0:
            if now <= 0:
                ans1 += 1 - now
                now = 1
        else:
            if now >= 0:
                ans1 += now + 1
                now = -1

    now = 0

    for i in range(n):
        now += a[i]
        if i % 2 == 1:
            if now <= 0:
                ans2 += 1 - now
                now = 1
        else:
            if now >= 0:
                ans2 += now + 1
                now = -1
    
    return min([ans1,ans2])

print(memo(n))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

i =1
j =0
while j <N:
    i=i*(j+1)
    j+=1
print(i%(10**9+7))

Fixed submission:
import math
print(math.factorial(int(input()))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
s,c = map(int,input().split())

if s<c/2:
    c_s = (c-2*s)//4
    sc = s
    print(c_s+sc)
else:
    sc = (min(s,c//2)
    print(sc)

Fixed submission:
s,c = map(int,input().split())
if s<c/2:
    print((c-2*s)//4+s)
else:
    print(min(s,c//2))
Buggy python submission (verdict: Runtime Error):
print((int(input())//11)*2+(x%11-1)//6+1)

Fixed submission:
import math
x = int(input())

if x<=6:
    print(1)
elif 7<=x<=11:
    print(2)
else:
    if x%11 ==1 or x%11 ==2 or x%11 ==3 or x%11 ==4 or x%11 ==5 or x%11 ==6:
        print((x//11)*2+1)
    elif x%11 ==7 or x%11 ==8 or x%11 ==9 or x%11 ==10:
        print((x // 11) * 2 + 2)
    else:
        print((x//11)*2)
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
if abs(y) > abs(x):
  if x < 0:ans += 1
  if y < 0:ans += 1
  ans += (abs(y)-abs(x))
else:
  if x > 0:ans += 1
  if y > 0:ans += 1
  ans += (abs(x)-abs(y))
print(ans)

Fixed submission:
x,y = map(int,input().split())
ans = 0
if abs(y) > abs(x):
  if x < 0:ans += 1
  if y < 0:ans += 1
  ans += (abs(y)-abs(x))
else:
  if x > 0:ans += 1
  if y > 0:ans += 1
  ans += (abs(x)-abs(y))
print(ans)
Buggy python submission (verdict: Runtime Error):
N=input().split()
A=N[0]
B=N[1]
Ans=A+B
if(Ans<A-B):
  Ans=A-B
  
if(Ans<A*B):
  Ans=A*B
  
print(Ans)

Fixed submission:
N=input().split()
A=int(N[0])
B=int(N[1])
Ans=A+B
if(Ans<A-B):
  Ans=A-B
  
if(Ans<A*B):
  Ans=A*B
  
print(Ans)
Buggy python submission (verdict: Runtime Error):
N=Int(input())
S=input()
for i in range(N):
  SR=S[(i+1):]
  SL=S[:(i+1)]
  count=0
  for j in SL:
    for k in SR:
  	  if(SL[j]===SR[k]):
    	count++
        break

  if(count_M<count):
  		count_M=count

print(count)
   

Fixed submission:
N=int(input())
S=input()
count_M=0
for i in range(N):
	SR=S[(i+1):]
	SL=S[:(i+1)]
	count = 0
	for j in range(len(SL)):
		for k in range(len(SR)):
			if(SL[j] == SR[k]):
				count+=1
				SR=SR.replace(SR[k],' ')
	
	if(count_M < count):
		count_M=count

print(count_M)
Buggy python submission (verdict: Runtime Error):
s=input().split()
A=s[0]
op=s[1]
B=s[2]
if(op=="+"):
  print(A+B)
else:
  print(A-B)

Fixed submission:
s=input().split()
A=int(s[0])
op=s[1]
B=int(s[2])
if(op=="+"):
  print(A+B)
else:
  print(A-B)