Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a = [(1,1,1)]

def h(w):
    x,y,z = w
    x+=1
    y+=1
    z+=1
    return x**2+y**2+z**2+x*y+x*z+z*y

def g(x,y,z,w):
    return x**2+y**2+z**2+x*y+x*z+z*y == w

for w in range(1,n+1):
    a = list(filter(lambda b:h(b)>= w,a))
    b = []
    for x,y,z in a:
        if g(x,y,z,w):
            b.append((x,y,z))
        if g(x,y,z+1,w):
            b.append((x,y,z+1))
        if g(x,y+1,z,w):
            b.append((x,y+1,z))
        if g(x+1,y,z,w):
            b.append((x+1,y,z))
    b = list(set(b))
    a += b
    
    print(len(b))

Fixed submission:
n=int(input())

arr = [[[0 for _ in range(101)] for _ in range(101)] for _ in range(101)]

def g(x,y,z):
    return x**2+y**2+z**2+x*y+x*z+y*z

table = [0]*10001

for i in range(1,101):
    for j in range(1,101):
        for k in range(1,101):
            re = g(i,j,k)
            if re <= 10000:
                table[re]+= 1



for i in range(1,n+1):
    print(table[i])
Buggy python submission (verdict: Time Limit Exceeded):
mod = 998244353
a,b,c,d = map(int,input().split())
dp = [[0 for _ in range(d+1)] for _ in range(c+1)]

dp[a][b] = 1
if d > b:
    dp[a][b+1] = a
if c > a:
    dp[a+1][b] = b
for i in range(b+2,d+1):
    dp[a][i] = dp[a][i-1]*a%mod

for i in range(a+2,c+1):
    dp[i][b] = dp[i-1][b]*b%mod

for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j] = dp[i][j-1] * i % mod + dp[i-1][j] * j % mod - dp[i-1][j-1]*(i-1)*(j-1)%mod

#print(dp)
print(dp[c][d] % mod)

Fixed submission:
mod = 998244353
a,b,c,d = map(int,input().split())
dp = [[0 for _ in range(d+1)] for _ in range(c+1)]

dp[a][b] = 1
if d > b:
    dp[a][b+1] = a
if c > a:
    dp[a+1][b] = b
for i in range(b+2,d+1):
    dp[a][i] = dp[a][i-1]*a%mod

for i in range(a+2,c+1):
    dp[i][b] = dp[i-1][b]*b%mod

for i in range(a+1,c+1):
    for j in range(b+1,d+1):
        dp[i][j] = (dp[i][j-1] * i % mod + dp[i-1][j] * j % mod - dp[i-1][j-1]*(i-1)*(j-1)%mod + mod) % mod

#print(dp)
print(dp[c][d] % mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int,input().split()))

al.sort()
table = [False]*100001
table2 = [False]*100001

for a in al:
    if table2[a]:
        table[a]=True
    if not table[a]:
        table2[a] = True
        for i in range(a+a,100000,a):
            table[i]=True
    

cnt=0
for a in al:
    if not table[a]:
        cnt+=1
print(cnt)

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

al.sort()
table = [False]*1000001
table2 = [False]*1000001

for a in al:
    if table2[a]:
        table[a]=True
    if not table[a]:
        table2[a] = True
        for i in range(a+a,1000001,a):
            table[i]=True
    

cnt=0
for a in al:
    if not table[a]:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)



Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if a.index(0) >= 0:
    print(0)
    exit()
ret = 1
for a_ in a:
  ret *= a_
  if ret > 10**18:
    print(-1)
    exit()
print(ret)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ret = 1
for a_ in a:
  ret *= a_
  if ret_ > 10**18:
    print(-1)
    exit()
print(ret)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    exit()
ret = 1
for a_ in a:
    ret *= a_
    if ret > 10**18:
        print(-1)
        exit()
print(ret)
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(ap(int,input().split()))
print(len([0 for x in h if x >= k]))


Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
print(len([0 for x in h if x >= k]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())

from collections import Counter
cnt = Counter()
    
for i in range(n):
    for j in range(i+1,n):
        cnt[str((x[j]-x[i],y[j]-y[i]))]+=1

print(n-cnt.most_common()[0][1])


Fixed submission:
n=int(input())
if n==1:
    print(1)
    exit()
x=[0]*n
y=[0]*n
for i in range(n):
    x[i],y[i]=map(int,input().split())

from collections import Counter
cnt = Counter()
    
for i in range(n):
    for j in range(n):
        if i!=j:
            cnt[str((x[j]-x[i],y[j]-y[i]))]+=1

print(n-cnt.most_common()[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
a,b,q=map(int,input().split())
s=[0]*a
t=[0]*b
x=[0]*q
for i in range(a):
  s[i]=int(input())
for i in range(b):
  t[i]=int(input())
import bisect
for i in range(q):
  x=int(input())
  ids=bisect.bisect_left(s,x)
  idt=bisect.bisect_left(t,x)
  mi=14857363987569617
  if ids < a:
    if idt < b:
      mi=min(mi,min([abs(s[ids]-x)+abs(s[ids]-t[idt]),
                    abs(t[idt]-x)+abs(t[idt]-s[ids])]))
    if idt > 0:
      mi=min(mi,min([abs(s[ids]-x)+abs(s[ids]-t[idt-1]),
                    abs(t[idt-1]-x)+abs(t[idt-1]-s[ids])]))
  if ids > 0:
    if idt < b:
      mi=min(mi,min([abs(s[ids-1]-x)+abs(s[ids-1]-t[idt]),
                    abs(t[idt]-x)+abs(t[idt]-s[ids-1])]))
    if idt > 0:
      mi=min(mi,min([abs(s[ids-1]-x)+abs(s[ids-1]-t[idt-1]),
                    abs(t[idt-1]-x)+abs(t[idt-1]-s[ids-1])]))
  print(mi)


Fixed submission:
a,b,q=map(int,input().split())
s=[0]*a
t=[0]*b
x=[0]*q
for i in range(a):
  s[i]=int(input())
for i in range(b):
  t[i]=int(input())
import bisect
for i in range(q):
  x=int(input())
  ids=bisect.bisect_left(s,x)
  idt=bisect.bisect_left(t,x)
  mi=14857363987569617
  if ids < a:
    if idt < b:
      mi=min(mi,min([abs(s[ids]-x)+abs(s[ids]-t[idt]),
                    abs(t[idt]-x)+abs(t[idt]-s[ids])]))
    if idt > 0:
      mi=min(mi,min([abs(s[ids]-x)+abs(s[ids]-t[idt-1]),
                    abs(t[idt-1]-x)+abs(t[idt-1]-s[ids])]))
  if ids > 0:
    if idt < b:
      mi=min(mi,min([abs(s[ids-1]-x)+abs(s[ids-1]-t[idt]),
                    abs(t[idt]-x)+abs(t[idt]-s[ids-1])]))
    if idt > 0:
      mi=min(mi,min([abs(s[ids-1]-x)+abs(s[ids-1]-t[idt-1]),
                    abs(t[idt-1]-x)+abs(t[idt-1]-s[ids-1])]))
  print(mi)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=n//1000
n=n%1000
b=n//100
n=n%100
c=n//10
d=n%10
if b==c and (a==b or c==d):
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
a=n//1000
n=n%1000
b=n//100
n=n%100
c=n//10
d=n%10
if b==c and (a==b or c==d):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
k = int(input())
g = [[] for _ in range(k)]
for i in range(1,k):
    g[i].append([i*10%k,0])
    if i%10 != 9:
        g[i].append([(i+1)%k,1])
v = [100000]*k
v[1] = 1

def bfs(w,d):
    w_nexts = g[w]
    for w_next in w_nexts:
        if v[w_next[0]] <= d + w_next[1] or d + w_next[1] > 45:
            continue
        v[w_next[0]] = d + w_next[1]
        bfs(w_next[0],d + w_next[1])

bfs(1,1)
print(v[0])


Fixed submission:
k = int(input())
g = [[] for _ in range(k)]
for i in range(1,k):
    g[i].append([i*10%k,0])
    if i%10 != 9:
        g[i].append([(i+1)%k,1])
v = [100000]*k
v[1] = 1

def draw(d):
    for i in range(k):
        if v[i] > d:
            continue
        for v_next in g[i]:
            if v[i] == d and v_next[1] == 0 and v[v_next[0]] > d:
                v_n = v_next[0]
                while v[v_n] > d:
                    v[v_n] = d
                    v_n = v_n*10%k
            elif v[i] == d-1 and v_next[1] == 1 and v[v_next[0]] > d:
                v_n = v_next[0]
                while v[v_n] > d:
                    v[v_n] = d
                    v_n = v_n*10%k
            
for i in range(1,46):
    draw(i)
    if v[0] == i:
        print(v[0])
        exit()
Buggy python submission (verdict: Runtime Error):
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	h1 = h1_cand
    	h1_cand = 0
  	else:
    	h1_cand = bars[m]

print h1*h2

Fixed submission:
n = input()
bars = map(int,raw_input().split(' '))
bars.sort()
h1_cand=0
h2_cand=0
h1=0
h2=0
for i in range(n):
  m = n-1-i
  if h1 > 0:
    if h2_cand == bars[m]:
      h2 = h2_cand
      break
    else:
      h2_cand = bars[m]
  else:
	if h1_cand == bars[m]:
    	  h1 = h1_cand
    	  h1_cand = 0
  	else:
    	  h1_cand = bars[m]
 
print h1*h2
Buggy python submission (verdict: Runtime Error):
n = input()
st1 = raw_input()
st2 = raw_input()
m = 1
mod = 1000000007
pat = 0 # or 1,2
bl = False
for i in range(n):
  if pat == 2 and bl:
    bl = False
    continue
  if st1[i] == st2[i] and pat = 0:
    m = m*3/mod
	pat = 1
  elif st1[i] == st2[i] and pat = 1:
    m = m*2/mod
    pat = 1
  elif st1[i] == st2[i] and pat = 2:
    m = m*2/mod
    pat = 1
  elif st1[i] != st2[i] and pat = 0:
    m = m*6/mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat = 1:
    m = m*2/mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat = 2:
    m = m*3/mod
    pat = 2
    bl = True
print m

Fixed submission:
n = input()
st1 = raw_input()
st2 = raw_input()
m = 1
mod = 1000000007
pat = 0 # or 1,2
bl = False
for i in range(n):
  #print m
  if pat == 2 and bl:
    bl = False
    continue
  if st1[i] == st2[i] and pat == 0:
    m = m*3%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 1:
    m = m*2%mod
    pat = 1
  elif st1[i] == st2[i] and pat == 2:
    pat = 1
  elif st1[i] != st2[i] and pat == 0:
    m = m*6%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 1:
    m = m*2%mod
    pat = 2
    bl = True
  elif st1[i] != st2[i] and pat == 2:
    m = m*3%mod
    pat = 2
    bl = True
print m
Buggy python submission (verdict: Runtime Error):
a,b,c,d = input().split(" ")
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)

Fixed submission:
a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)

Buggy python submission (verdict: Runtime Error):
a,b,c,d = input()
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)

Fixed submission:
a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)

Buggy python submission (verdict: Runtime Error):
a,b,c,d = input()
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)

Fixed submission:
a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)
Buggy python submission (verdict: Runtime Error):
mod=10**9+7
s=int(input())
dp=[1]*(s+1)
dp[0]=0
dp[2]=0
dp[1]=0
for i in range(3,s+1):
    for j in range(3,i-2):
        dp[i]+=dp[j]
print(dp[s]%mod)



Fixed submission:
mod=10**9+7
s=int(input())
dp=[1]*(s+1)
if s==1 or s==2:
    print(0)
    quit()
for i in range(3,s+1):
    for j in range(3,i-2):
        dp[i]+=dp[j]
print(dp[s]%mod)
Buggy python submission (verdict: Runtime Error):
from math import inf
n,k=map(int,input().split())
arr=[0]+list(map(int,input().split()))
cost=[0]+list(map(int,input().split()))
ma=-inf
for i in range(1,n+1):
    se=set()
    cur=i
    pref=[0]
    f=0
    while(True):
        if cur not in se:
            se.add(cur)
            co=cost[cur]
            cur=arr[cur]
            pref.append(pref[-1]+co)
            ma=max(ma,pref[-1])
            f+=1
        else:
            break
        if k<=f:
            break
    print(pref)
    if k>=f:
        ans=pref[-1]*(k//f)
        for j in range(k%f+1):
            ma=max(ma,ans+pref[j])
print(ma)











Fixed submission:
from math import inf
n,k=map(int,input().split())
arr=[0]+list(map(int,input().split()))
cost=[0]+list(map(int,input().split()))
ma=-inf
for i in range(1,n+1):
    se=set()
    cur=i
    pref=[0]
    f=0
    while(cur not in se and f<k):
        se.add(cur)
        cur=arr[cur]
        co = cost[cur]
        pref.append(pref[-1]+co)
        ma=max(ma,pref[-1])
        f+=1

    if pref[-1]>0 and k>=f:
        ans=pref[-1]*(k//f)
        for j in range(k%f+1):
            ma=max(ma,ans+pref[j])
        ma=max(ma,pref[-1]*(k//f-1)+max(pref))
print(ma)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
def isvalid(mid,k):
    ans=k
    for i in arr:
        if i>mid:
            ans-=i//mid
    return ans>=0


l=0
r=10**9
while(l<r):
    mid=(l+r)//2
    if isvalid(mid,k):
        r=mid
    else:
        l=mid+1
print(l)













Fixed submission:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
def isvalid(mid,k):
    if mid==0:
        return False
    ans=k
    for i in arr:
        if i>mid:
            ans-=i//mid
    return ans>=0


l=0
r=10**9
while(l<r):
    mid=(l+r)//2
    if isvalid(mid,k):
        r=mid
    else:
        l=mid+1
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr=list(map(int,input().split()))
ans=1
for i in range(n):
    if i<k:
        ans*=arr[i]
    else:
        c=ans
        ans=(ans*arr[i])//arr[i-k]
        if ans>c:
            print("Yes")
        else:
            print("No")




Fixed submission:
n,k=map(int,input().split())
arr=list(map(int,input().split()))
for i in range(n):
    if i>=k:
        if arr[i-k]<arr[i]:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left,bisect_right
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
for i in range(1,n):
    arr1[i]=arr1[i]+arr1[i-1]
for i in range(1,m):
    arr2[i]=arr2[i]+arr2[i-1]
ma=0
for i in range(n):
    c=k-arr1[i]
    ind=bisect_right(arr2,c)
    if arr2[ind]<=c:
        ma=max(ma,ind+i+1)
print(ma)

Fixed submission:
from bisect import bisect_left,bisect_right
n,m,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
for i in range(1,n):
    arr1[i]=arr1[i]+arr1[i-1]
for i in range(1,m):
    arr2[i]=arr2[i]+arr2[i-1]
ma=0
for i in range(n):
    if arr1[i]<=k:
        ma=max(ma,bisect_right(arr2,k-arr1[i])+i+1)
for i in range(m):
    if arr2[i]<=k:
        ma=max(ma,bisect_right(arr1,k-arr2[i])+i+1)
print(ma)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dp=[2]*(n+1)
dp[0]=0
dp[1]=1
c=1
for i in range(2,n+1):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            dp[i]+=2
    if int(i**0.5)*int(i**0.5)==i:
        dp[i]-=1
    c+=dp[i]*i
print(c)


Fixed submission:
n=int(input())
c=0
ans=0
for i in range(1,n+1):
    c=n//i
    ans+=(c)*(c+1)*(i)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dp=[2]*(n+1)
dp[0]=0
dp[1]=1
c=1
for i in range(2,n+1):
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            dp[i]+=2
    if int(i**0.5)*int(i**0.5)==i:
        dp[i]-=1
    c+=dp[i]*i
print(c)


Fixed submission:
n=int(input())
c=0
ans=0
for i in range(1,n+1):
    c=n//i
    ans+=(c)*(c+1)*(i)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
dp=[1]*(n+1)
dp[0]=0
dp[1]=1
c=0
for i in range(2,n+1):
    for j in range(i,n+1,i):
        dp[j]+=1
for i in range(n+1):
    c+=dp[i]*i
print(c)


Fixed submission:
n=int(input())
c=0
ans=0
for i in range(1,n+1):
    c=n//i
    ans+=(c)*(c+1)*(i)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
s=0
d={}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    s+=i
for i in range(int(input())):
    a,b=map(int,input().split())
    if a in d:
        s=s-a*d[a]+b*d[a]
    if b in d:
        d[b]+=d[a]
    else:
        if a in d:
            d[b]=d[a]
    d[a] = 0
    print(s)


Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
s=0
d={}
for i in arr:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    s+=i
for i in range(int(input())):
    a,b=map(int,input().split())
    if a in d:
        s=s-a*d[a]+b*d[a]
    if b in d and a in d:
        d[b]+=d[a]
    else:
        if a in d:
            d[b]=d[a]
    d[a] = 0
    print(s)
Buggy python submission (verdict: Runtime Error):
from math import log
n=int(input())
arr=list(map(int,input().split()))
ma=max(arr)
c=int(log(ma,2))
for i in arr:
    d=i^(2**c-1)
    if (i&1)!=(d&1):
        d=d^1
    print(d,end=" ")




Fixed submission:
from math import log
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in arr:
    c=c^i
for i in arr:
    print(c^i,end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
c=1
arr.sort()
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        d=1
        print(-1)
if(d==0):
    print(c)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
c=1
arr.sort()
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        d=1
        print(-1)
        break
if(d==0):
    print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(map(int,input().split()))
c=1
for i in arr:
    c=c*i
if(c>10**18):
    print(-1)
else:
    print(c)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
c=1
arr.sort()
d=0
for i in arr:
    c=c*i
    if(c>10**18):
        d=1
        print(-1)
        break
if(d==0):
    print(c)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int((a*b*100)/100))

Fixed submission:
from fractions import Fraction
a,b=map(Fraction,input().split())
print(int(a*b))

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
    a,b=map(int,input().split())
    if(n%2==0 and i==n//2-1):
        ans=b-a+2
    if(n%2!=0 and i==n//2):
        ans=b-a+1
print(ans)
        

Fixed submission:
from fractions import Fraction
a,b=map(Fraction,input().split())
print(int(a*b))
Buggy python submission (verdict: Runtime Error):
n=int(input())
aa=[]
bb=[]
for i in range(n):
    a,b=map(int,input().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if(n%2==0):
    print(b[n//2-1]+b[n//2]-a[n//2]-a[n//2-1]+1)
else:
    print(b[n//2]-a[n//2]+1)

Fixed submission:
n=int(input())
aa=[]
bb=[]
for i in range(n):
    a,b=map(int,input().split())
    aa.append(a)
    bb.append(b)
aa.sort()
bb.sort()
if(n%2==0):
    print(bb[n//2-1]+bb[n//2]-aa[n//2]-aa[n//2-1]+1)
else:
    print(bb[n//2]-aa[n//2]+1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
li=[]

for i in range(n):
    cnt=0
    for j in range(n):
        if j>i and s[j]=="E":
            cnt+=1
        if j<i and s[j]=="W":
            cnt+=1
    li.append(cnt)
print(min(li))

Fixed submission:
n=int(input())
s=input()
li=[]
w,e=0,0
wli,eli=[],[]
ans=[]

for i in range(n):
    if s[i]=="W":
        w+=1
    wli.append(w)
for i in reversed(range(n)):
    if s[i]=="E":
        e+=1
    eli.append(e)
for i in range(n):
    if i!=0 and i!=n-1:
        ans.append(wli[i-1]+eli[n-i-2])
    elif i==0:
        ans.append(eli[n-2])
    elif i==n-1:
        ans.append(wli[n-2])

print(min(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
alice,bob=0,0
cnt=0
for x in range(n):
    global alice
    global bob
    while cnt<n:
        alice+=a[cnt]
        cnt+=1
        bob+=a[cnt]
        cnt+=1
print(abs(alice-bob))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
alice,bob=0,0
cnt=0
for x in range(n):
    global alice
    global bob
    if cnt<n:
        alice+=a[cnt]
        cnt+=1
    if cnt<n:
        bob+=a[cnt]
        cnt+=1
print(abs(alice-bob))
Buggy python submission (verdict: Runtime Error):
a,b,c,x=map(int,input().split())
ans=0

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

Fixed submission:
a,b,c,x=[int(input()) for i in range(4)]
ans=0

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

Buggy python submission (verdict: Runtime Error):
a,b,c,x=map(int,input().split())
val=0
ans=0

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

Fixed submission:
a,b,c,x=[int(input()) for i in range(4)]
ans=0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = [[i] for i in int(input())]
N = int(input())
d = [int(input()) for i in range(N)]
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))

Fixed submission:
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))
Buggy python submission (verdict: Runtime Error):
s = list(map(int,input().split()))
cnt=0
for i in range(3):
    if s[i]==1:
        cnt+=1
print(cnt)

Fixed submission:
S = input()
cnt = 0
for i in range(3):
    if S[i] == "1":
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(raw_input())
a = map(int, raw_input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)

Fixed submission:
def how_many_times_divisible(n):
	ans = 0
	while n % 2 == 0:
		n /= 2
		ans += 1
	return ans
 
n = int(input())
a = map(int, input().split())
ans = min(map(how_many_times_divisible, a))
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())
print (min(N*A,B))

Fixed submission:
list1 = [int(i) for i in input().split()]
print (min(list1[0]*list1[1],list1[2]))
Buggy python submission (verdict: Time Limit Exceeded):
#整数Nを入力
x = input()
N = int(x)

#N番目のリュカ数を返す関数を定義
def lucas(N):
  if N == 0:
    return 2
  elif N == 1:
    return 1
  return lucas(N-1) + lucas(N-2)

#N番目のリュカ数を出力
if 1<=N<=86:
    LN = lucas(N)
    print(LN)

Fixed submission:
x = input()
N = int(x)

a = 2
luca = 1

for i in range(1,N):
  c = luca
  luca = a+luca
  a = c
  
print(luca)