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

ans=0
for i in range(n-k+1):
 sp=0
 for j in range(i,i+k):
  sp+=((p[j]*(p[j]+1))*0.5)*(1/p[j])
# sp/=100
 ans=max(ans,sp)

print(ans)

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

b=[0]
for i in range(1,n+1):
 b.append(p[i-1]+b[i-1])

mm=0
inx=-1
for i in range(len(b)-k):
 if b[i+k]-b[i]>=mm:
  inx=i
  mm=b[i+k]-b[i]


ans=0
for j in range(inx,inx+k):
  ans+=((p[j]*(p[j]+1))*0.5)*(1/p[j])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

'''
lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)
'''

from functools import reduce

lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)

Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

'''
lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)
'''

from functools import reduce

lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
'''
ans=sum(lcm//i for i in a)
ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)

Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

'''
lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)
'''

from functools import reduce

lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
'''
ans=sum(lcm//i for i in a)
ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))

lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)

Fixed submission:
from fractions import gcd

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

'''
lcm=1
for i in a:
 lcm=(lcm*i)//gcd(lcm,i)

ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
print(ans)
'''

from functools import reduce

lcm=reduce(lambda x,y :(x*y)//gcd(x,y),a)

'''
ans=0
mod=10**9+7
for i in a:
 ans+=lcm//i
 ans%=mod
'''
ans=sum(lcm//i for i in a)
ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from copy import deepcopy
from collections import deque

h,w=nii()
s=[list(input()) for i in range(h)]

def dfs(cs,i,j):
  que=deque()
  que.append([i,j])

  cs[i][j]='#'

  dist=[[-1 for a in range(w)] for b in range(h)]
  dist[i][j]=0

  while que:
    y,x=que.popleft()
    for dy,dx in [[1,0],[-1,0],[0,1],[0,-1]]:
      ny=y+dy
      nx=x+dx
      if 0<=ny<h and 0<=nx<w and cs[ny][nx]=='.':
        que.append([ny,nx])
        cs[ny][nx]='#'
        dist[ny][nx]=dist[y][x]+1

  t_ans=0
  for a in dist:
    t_ans=max(t_ans,max(a))

  return t_ans

ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      cs=deepcopy(s)
      dist=dfs(cs,i,j)
      ans=max(ans,dist)

print(ans

Fixed submission:
from collections import deque
import copy

h,w=map(int,input().split())
ss=[list(input()) for i in range(h)]

ans=0

for hh in range(h):
 for ww in range(w):
  dist=[[-1]*(w+1) for i in range(h+1)]
  c=copy.deepcopy(ss)
  xx=c[hh][ww]
  if xx=='#':
   continue
  dist[hh][ww]=0
  dq=deque()
  dq.append((hh,ww))
  c[hh][ww]='#'
  while dq:
   y,x=dq.popleft()
   for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
    nx=x+dx
    ny=y+dy
    if 0<=nx<w and 0<=ny<h and c[ny][nx]!='#':
     dq.append((ny,nx))
     c[ny][nx]='#'
     dist[ny][nx]=dist[y][x]+1
  for i in dist:
   ans=max(ans,max(i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n,u,v=map(int,input().split())

row,col,w=[],[],[]
for i in range(n-1):
 a,b=map(int,input().split())
 row.append(a-1)
 col.append(b-1)
 w.append(1)

g=csr_matrix((w,(row,col)),shape=(n,n))

d_u=dijkstra(g,directed=False,indices=u-1)
d_v=dijkstra(g,directed=False,indices=v-1)

l=0
for t_u,t_v in zip(d_u,d_v):
 if t_u<t_v:
  l=max(l,t_v)
print(int(l)-1)

Fixed submission:
from collections import deque

def BFS(t):
    tree=[[] for i in range(n)]
    for i in list:
      tree[i[0]-1].append(i[1]-1)
      tree[i[1]-1].append(i[0]-1)

    dist=[-1 for i in range(n)]
    dist[t-1]=0

    que=deque()
    que.append(t-1)
    while que:
        x=que.popleft()
        for p in tree[x]:
            if dist[p]==-1:
                que.append(p)
                dist[p]=dist[x]+1
    return dist

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

u_dist=BFS(u)
v_dist=BFS(v)

l=0
for u_d,v_d in zip(u_dist,v_dist):
 if u_d<v_d:
  l=max(l,v_d)

print(l-1)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

n,u,v=map(int,input().split())

ro,co,w=[],[],[]
for i in range(n-1):
 a,b=map(int,input().split())
 ro.append(a-1)
 co.append(b-1)
 w.append(1)

g=csr_matrix((w,(ro,co)),shape=(n,n))
d_u=dijkstra(g,directed=False,indices=u-1)
d_v=dijkstra(g,directed=False,indices=v-1)

l=0
for t_u,t_v in zip(d_u,d_v):
 if t_u<t_v:
  l=max(l,t_v)
print(int(l)-1)

Fixed submission:
from collections import deque

def BFS(t):
    tree=[[] for i in range(n)]
    for i in list:
      tree[i[0]-1].append(i[1]-1)
      tree[i[1]-1].append(i[0]-1)

    dist=[-1 for i in range(n)]
    dist[t-1]=0

    que=deque()
    que.append(t-1)
    while que:
        x=que.popleft()
        for p in tree[x]:
            if dist[p]==-1:
                que.append(p)
                dist[p]=dist[x]+1
    return dist

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

u_dist=BFS(u)
v_dist=BFS(v)

l=0
for u_d,v_d in zip(u_dist,v_dist):
 if u_d<v_d:
  l=max(l,v_d)

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

mod=10**9+7

ans=0
for i in range(60):
  on=0
  off=0
  for j in a:
    if (j>>i)&1:
      on+=1
    else:
      off+=1
  ans+=(on*off)*(2**i)
  ans%=mod

print(ans)

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

mod=10**9+7

ans=0
for i in range(60):
  on=0
  off=0
  for j in a:
    if (j>>i)&1:
      on+=1
    else:
      off+=1
  ans+=(on*off)*(2**i)
  ans%=mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
mod=10**9+7
a=list(map(int,input().split()))

ans=0
for i in range(n-1):
 for j in range(i+1,n):
  ans+=a[i]^a[j]
  ans%=mod
print(ans)

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

mod=10**9+7

ans=0
for i in range(60):
  on=0
  off=0
  for j in a:
    if (j>>i)&1:
      on+=1
    else:
      off+=1
  ans+=(on*off)*(2**i)
  ans%=mod

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

mod=1000000007
ans=1
r,b,g=0,0,0
for i in a:
    if r2==r and b2==b and g2==g:
        print(0)
        exit()
    if i==r and i==b and i==g:
        ans*=3
        ans%=mod
        r+=1
    elif (i==r and i==b) or (i==g and i==r):
        ans*=2
        ans%=mod
        r+=1
    elif i==b and i==g:
        ans*=2
        ans%=mod
        g+=1
    elif i==r:
        r+=1
    elif i==b:
        b+=1
    elif i==g:
        g+=1

    else:
        print(0)
        exit()
print(ans)

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

mod=1000000007
ans=1
r,b,g=0,0,0
r2,b2,g2=-1,-1,-1
for i in a:
    if r2==r and b2==b and g2==g:
        print(0)
        exit()
    r2=r
    b2=b
    g2=g
    if i==r and i==b and i==g:
        ans*=3
        ans%=mod
        r+=1
    elif (i==r and i==b) or (i==g and i==r):
        ans*=2
        ans%=mod
        r+=1
    elif i==b and i==g:
        ans*=2
        ans%=mod
        g+=1
    elif i==r:
        r+=1
    elif i==b:
        b+=1
    elif i==g:
        g+=1

    else:
        print(0)
        exit()

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from sys import stdin
nii=lambda:map(int,stdin.readline().split())

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

tree=[[] for i in range(n)]
for a,b in l:
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

ans_num=0
for i in tree:
  ans_num=max(ans_num,len(i))

col=[[0] for i in range(n)]

que=deque()
que.append(0)

ans_dict={}
while que:
  x=que.popleft()

  c=1
  for i in tree[x]:
    if col[i]==[0]:
      que.append(i)

      while True:
        if c in col[x]:
          c+=1
        else:
          break

      col[x].append(c)
      col[i].append(c)
      ans_dict[(x+1,i+1)]=c
      ans_dict[(i+1,x+1)]=c

print(ans_num)
for i in l:
  print(ans_dict[tuple(i)])

Fixed submission:
from collections import deque

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

tree=[[]for _ in range(n)]
for a,b in l:
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(b)

ans_num=0
for i in tree:
  ans_num=max(ans_num,len(i))

dq=deque()
dq.append((0,0))

seen=set()
seen.add(0)

ans_dict={}
while dq:
  x,color=dq.pop()

  i=0
  for nx in tree[x]:
    if nx in seen:
      continue

    i+=1
    if i==color:
      i+=1

    seen.add(nx)
    dq.append((nx,i)),
    ans_dict[x+1,nx+1]=i
    ans_dict[nx+1,x+1]=i

print(ans_num)
for i in l:
  print(ans_dict[tuple(i)])
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
ans=0
if x==1 and y==1:
    ans+=400000
if x==3:
    ans+=100000
if x==2:
    ans+=200000
if x==1:
    ans+=300000
if y==3:
    ans+=100000
if y==2:
    ans+=200000
if y==1:
    ans+=300000
print(ans)
~


Fixed submission:
x,y=map(int,input().split())
ans=0
if x==1 and y==1:
    ans+=400000
if x==3:
    ans+=100000
if x==2:
    ans+=200000
if x==1:
    ans+=300000
if y==3:
    ans+=100000
if y==2:
    ans+=200000
if y==1:
    ans+=300000
print(ans)
Buggy python submission (verdict: Runtime Error):
def make_tables(m):
    fac=[1,1]
    finv=[1,1]
    inv=[0,1]
    for i in range(2,m+1):
        fac.append((fac[-1]*i)%mod)
        inv.append((-inv[mod%i]*(mod//i))%mod)
        finv.append(finv[i-1]*inv[i]%mod)
    return fac,finv
 calc_nCk(n,k,fac,finv):
    if n<k or (n<0 or k<0):
        return 0
    k=min(k,n-k)
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

x,y=map(int,input().split())
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print(0)
else:
    m=(y+x)//3
    l=int(n)
    fac,finv=make_tables(m)
    ans = calc_nCk(m,l,fac,finv)
    print(ans)


Fixed submission:
def make_tables(m):
    fac=[1,1]
    finv=[1,1]
    inv=[0,1]
    for i in range(2,m+1):
        fac.append((fac[-1]*i)%mod)
        inv.append((-inv[mod%i]*(mod//i))%mod)
        finv.append(finv[i-1]*inv[i]%mod)
    return fac,finv

def calc_nCk(n,k,fac,finv):
    if n<k or (n<0 or k<0):
        return 0
#    k=min(k,n-k)
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

x,y=map(int,input().split())
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print(0)
else:
    m=(y+x)//3
    l=int(n)
    fac,finv=make_tables(m)
    ans = calc_nCk(m,l,fac,finv)
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a,b,x=map(int,input().split())

if (b*a*a)/2>=x:
    t=((2*x)/(a*b))
    s=b
    print(math.degrees(math.atan(s/t)))
else:
    s=(2*((a*a*b)-x))/(a**2)
    t=a
    print(90-math.degrees(math.atan(t/s)))

Fixed submission:
import math

a,b,x=map(int,input().split())

if a*a*b==x:
    print(0)
elif (b*a*a)/2>=x:
    t=((2*x)/(a*b))
    s=b
    print(math.degrees(math.atan(s/t)))
else:
    s=(2*((a*a*b)-x))/(a**2)
    t=a
    print(90-math.degrees(math.atan(t/s)))
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in h;
  if i>=k:
    ans+=1
print(ans)


Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
cnt=0
for i in h:
    if i>=k:
        cnt+=1
print(cnt)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans=0
for i in h;
  if i>=k:
    ans+=1
pront(ans)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
cnt=0
for i in h:
    if i>=k:
        cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))

for i in range(m):
    x=a[-(i+1)]//2
    bisect.insort(a,x)
print(sum(a[:n]))

Fixed submission:
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
aa=list(map(lambda x:x*(-1),a))
heapq.heapify(aa)
for i in range(m):
    max=heapq.heappop(aa)
    heapq.heappush(aa,max//2+max%2)
print(-1*sum(aa))

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

for i in range(m):
    s=a.index(max(a))
    a[s]=a[s]//2
print(sum(a))

Fixed submission:
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
aa=list(map(lambda x:x*(-1),a))
heapq.heapify(aa)
for i in range(m):
    max=heapq.heappop(aa)
    heapq.heappush(aa,max//2+max%2)
print(-1*sum(aa))
Buggy python submission (verdict: Runtime Error):
,k=map(int,input().split())
s=input()

if n==1:
  print(0)
  exit()

happy=0
for i in range(n-1):
  if s[i]==s[i+1]:
    happy+=1

l_cnt=[]
for i in range(n):
  if s[i]=='R':
    if i==0:
      if s[i+1]=='L':
        l_cnt.append(1)
    if i==n-1:
      if s[i-1]=='L':
        l_cnt.append(1)
    else:
      t_l_cnt=s[i-1:i+2].count('L')
      l_cnt.append(t_l_cnt)

r_cnt=[]
for i in range(n):
  if s[i]=='L':
    if i==0:
      if s[i+1]=='R':
        r_cnt.append(1)
    if i==n-1:
      if s[i-1]=='R':
        r_cnt.append(1)
    else:
      t_r_cnt=s[i-1:i+2].count('R')
      r_cnt.append(t_r_cnt)

ans=l_cnt+r_cnt
ans.sort(reverse=True)
ans=sum(ans[:k])

print(happy+ans)

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

if n==1:
  print(0)
  exit()

happy=0
cnt=0
for i in range(n-1):
  if s[i]==s[i+1]:
    happy+=1
  else:
    cnt+=1

print(min(n-1,happy+min(cnt,k)*2))

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

happy=0
for i in range(n-1):
  if s[i]==s[i+1]:
    happy+=1

l_cnt=[]
for i in range(n):
  if s[i]=='R':
    if i==0:
      if s[i+1]=='L':
        l_cnt.append(1)
    if i==n-1:
      if s[i-1]=='L':
        l_cnt.append(1)
    else:
      t_l_cnt=s[i-1:i+2].count('L')
      l_cnt.append(t_l_cnt)
l_cnt.sort(reverse=True)
ans_l=sum(l_cnt[:k])

r_cnt=[]
for i in range(n):
  if s[i]=='L':
    if i==0:
      if s[i+1]=='R':
        r_cnt.append(1)
    if i==n-1:
      if s[i-1]=='R':
        r_cnt.append(1)
    else:
      t_r_cnt=s[i-1:i+2].count('R')
      r_cnt.append(t_r_cnt)
r_cnt.sort(reverse=True)
ans_r=sum(r_cnt[:k])

print(happy+max(ans_l,ans_r))

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

if n==1:
  print(0)
  exit()

happy=0
cnt=0
for i in range(n-1):
  if s[i]==s[i+1]:
    happy+=1
  else:
    cnt+=1

print(min(n-1,happy+min(cnt,k)*2))
Buggy python submission (verdict: Time Limit Exceeded):
ans=0
for i in range(int(input())):
 ans+=i
print(ans)

Fixed submission:
n=int(input())
print((n-1)*n//2)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
v=lnii()
v.sort()

ans=v[0]
for i in range(1,n):
  ans=(ans+v[i])/2

print(ans

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
vv=sorted(v)
for i in range(n-2):
    vv[i+1] = (vv[i]+vv[i+1]) / 2
print((vv[n-2]+vv[n-1])/2)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = [input() for i in range(n)]
cnt = 0
for i in range(1,n):
    for l in range(i-1):
        if Counter(s[i]) == Counter(s[l]):
            cnt += 1
print(cnt)

Fixed submission:
n = int(input())
d = {}
for i in range(n):
    s = ''.join(sorted(input()))
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
cnt = [i*(i-1)//2 for i in d.values()]
print(sum(cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
hhh = list(map(int, input().split()))
h = np.array(hhh)
ans = 0

h_s_i = list(reversed(list(np.argsort(h))))
for i in range(len(h_s_i) - 1):
    if hhh[i] - 2 >= min(hhh[i+1:]):
        ans = 1

if ans == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())
h = [0] + list(map(int, input().split()))

for i in range(n):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

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

if len(h) != 1:
    for i in range(len(h) - 1):
        if h[i] - 2 >= min(h[i+1:]):
            ans = 1
            break

if ans == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())
h = [0] + list(map(int, input().split()))

for i in range(n):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')

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

if len(h) != 1:
    for i in range(len(h) - 1):
        if h[i] - 2 >= min(h[i+1:]):
            ans = 1
            break

if ans == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())
h = [0] + list(map(int, input().split()))

for i in range(n):
    if h[i] < h[i+1]:
        h[i+1] -= 1
    elif h[i] > h[i+1]:
        print('No')
        exit()

print('Yes')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[-1]+list(map(int,input().split()))

t=((n+1)+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

for i in range(t-1,0,-1):
 t_sum=sum(ans[i+i::i])
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    else:
        print(a_max)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    else:
        print(a_max)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max_ind = index(max(a))
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n)
    if i == a_max_ind:
        print(a_sec)
    else:
        print(a_max)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    else:
        print(a_max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    aaa = a.copy()
    aaa[i] = 0
    print(max(aaa))

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_s = sorted(a, reverse=True)
a_max = a_s[0]
a_sec = a_s[1]
for i in range(n):
    if a[i] == a_max:
        print(a_sec)
    else:
        print(a_max)
Buggy python submission (verdict: Time Limit Exceeded):
l,r=map(int,input().split())

ans=10000
for i in range(l,r):
  for j in range(i+1,r+1):
    ans=min(ans,(i*j)%2019)
    if ans==0:
      break
print(ans)

Fixed submission:
l, r = map(int, input().split())
ans = 2018
if r - l >= 2019:
    for i in range(l, l + 2019 + 1):
        for n in range(l, i):
            ans = min(ans, (i * n) % 2019)
else:
    for i in range(l, r + 1):
        for n in range(l, i):
            ans = min(ans, (i * n) % 2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
print('Yes' if len(set(s))==2 and s.count(s[0]==2) else 'No')

Fixed submission:
s = input()
s_l = list(s)
s_ll = sorted(s_l)
if s_ll[0] == s_ll[1] and s_ll[2] == s_ll[3] and s_ll[1] != s_ll[2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
lcm = (c*d)//math.gcd(c,d)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))

Fixed submission:
import fractions
a,b,c,d = map(int, input().split())
lcm = (c*d)//fractions.gcd(c,d)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
lcm = (c*d)//math.gcd(c,d)
print(lcm)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))

Fixed submission:
import fractions
a,b,c,d = map(int, input().split())
lcm = (c*d)//fractions.gcd(c,d)
sum = b-a+1
x = (b//c) - ((a-1)//c)
y = (b//d) - ((a-1)//d)
z = (b//lcm) - ((a-1)//lcm)
n_i = x+y-z
print(int(sum-n_i))
Buggy python submission (verdict: Runtime Error):
n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n-1):
  for j in range(i+1,n):
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
#  for x,y in xy:
#    if [x+p,y+q] in xy:
#      cnt+=1
  for i in range(n):
    for j in range(n):
      if i==j:
        continue
      x1,y1=xy[i]
      x2,y2=xy[j]
      if (x2-x1)==p and (y2-y1)==q:
        cnt+=1
  ans=min(ans,n-cnt)
print(ans)

Fixed submission:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
xy=[lnii() for i in range(n)]
xy.sort(key=lambda x:x[0])

ans=n

pq=[]
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    t_p=xy[j][0]-xy[i][0]
    t_q=xy[j][1]-xy[i][1]
    pq.append([t_p,t_q])

for p,q in pq:
  cnt=0
  for x,y in xy:
    if [x+p,y+q] in xy:
        cnt+=1
  ans=min(ans,n-cnt)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

L=[[0]*w for i in range(h)]
R=[[0]*w for i in range(h)]
U=[[0]*w for i in range(h)]
D=[[0]*w for i in range(h)]

for i in range(h):
 for j in range(w):
  if s[i][j]=='#':
   L[i][j]=U[i][j]=0
   continue
  if i==0 and j==0:
   L[i][j]=1
   U[i][j]=1
  elif i==0:
   L[i][j]=L[i][j-1]+1
   U[i][j]=1
  elif j==0:
   L[i][j]=1
   U[i][j]=U[i-1][j]+1
  else:
   L[i][j]=L[i][j-1]+1
   U[i][j]=U[i-1][j]+1

for i in range(h-1,-1,-1):
 for j in range(w-1,-1,-1):
  if s[i][j]=='#':
   R[i][j]=D[i][j]=0
   continue
  if i==h-1 and j==w-1:
   R[i][j]=1
   D[i][j]=1
  elif i==h-1:
   R[i][j]=R[i][j+1]+1
   D[i][j]=1
  elif j==w-1:
   R[i][j]=1
   D[i][j]=D[i+1][j]+1
  else:
   R[i][j]=R[i][j+1]+1
   D[i][j]=D[i+1][j]+1

ans=0
for i in range(h):
 for j in range(w):
  ans=max(ans,R[i][j]+L[i][j]+U[i][j]+D[i][j]-3)
print(ans)

Fixed submission:
import numpy as np

h,w=map(int,input().split())
s=[list(input()) for i in range(h)]

s=np.array(s)
s=np.where(s=='.',1,0)

L=np.zeros((h,w),dtype=np.int)
R=np.zeros((h,w),dtype=np.int)
U=np.zeros((h,w),dtype=np.int)
D=np.zeros((h,w),dtype=np.int)

for i in range(w):
 L[:,i]=(L[:,i-1]+1)*s[:,i]
 R[:,-i-1]=(R[:,-i]+1)*s[:,-i-1]
for i in range(h):
 U[i]=(U[i-1]+1)*s[i]
 D[-i-1]=(D[-i]+1)*s[-i-1]

ans=np.max(L+R+U+D)-3
print(ans)