Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections

h,w=map(int,input().split())
board=[list(input()) for _ in range(h)]
q=collections.deque()
if board[0][0]=='#':
  q.append((0,0,1,1))
else:
  q.append((0,0,0,0))
ans=10**18
while len(q)!=0:
  x,y,cnt,flag=q.popleft()
  if x==w-1 and y==h-1:
    ans=min(ans,cnt)
  else:
    if x!=w-1:
      if flag==0:
        if board[y][x+1]=='#':
          q.append((x+1,y,cnt+1,1))
        else:
          q.append((x+1,y,cnt,0))
      else:
        if board[y][x+1]=='#':
          q.append((x+1,y,cnt,1))
        else:
          q.append((x+1,y,cnt,0))
    if y!=h-1:
      if flag==0:
        if board[y+1][x]=='#':
          q.append((x,y+1,cnt+1,1))
        else:
          q.append((x,y+1,cnt,0))
      else:
        if board[y+1][x]=='#':
          q.append((x,y+1,cnt,1))
        else:
          q.append((x,y+1,cnt,0))
print(ans)

Fixed submission:
import collections

h,w=map(int,input().split())
board=[list(input()) for _ in range(h)]
q=collections.deque()
if board[0][0]=='#':
  q.append((0,0,1,1))
else:
  q.append((0,0,0,0))
dp=[[10**18]*w for _ in range(h)]
ans=10**18
while len(q)!=0:
  x,y,cnt,flag=q.popleft()
  if x==w-1 and y==h-1:
    ans=min(ans,cnt)
  else:
    if x!=w-1:
      if flag==0:
        if board[y][x+1]=='#':
          if dp[y][x+1]>cnt+1:
            q.append((x+1,y,cnt+1,1))
            dp[y][x+1]=cnt+1
        else:
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,0))
            dp[y][x+1]=cnt
      else:
        if board[y][x+1]=='#':
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,1))
            dp[y][x+1]=cnt
        else:
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,0))
            dp[y][x+1]=cnt
    if y!=h-1:
      if flag==0:
        if board[y+1][x]=='#':
          if dp[y+1][x]>cnt+1:
            q.append((x,y+1,cnt+1,1))
            dp[y+1][x]=cnt+1
        else:
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,0))
            dp[y+1][x]=cnt
      else:
        if board[y+1][x]=='#':
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,1))
            dp[y+1][x]=cnt
        else:
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,0))
            dp[y+1][x]=cnt
print(dp[-1][-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(input())
arr=[int(arr[i]) for i in range(n)]
if n==1:
  print(arr[0])
if n==2:
  print(abs(arr[0]-arr[1]))
else:
  tmp=[]
  for i in range(n-2):
    tmp.append(abs(abs(arr[i]-arr[i+1])-abs(arr[i+1]-arr[i+2])))
  arr=tmp
  while len(arr)>3:
    tmp=[]
    if len(arr)%2==9:
      for i in range(len(arr)//2):
        tmp.append(abs(arr[2*i]-arr[2*i+1]))
    else:
      for i in range(len(arr)-1):
        tmp.append(abs(arr[i]-arr[i+1]))
    arr=tmp
  if len(arr)==1:
    print(arr[0])
  elif len(arr)==2:
    print(abs(arr[0]-arr[1]))
  elif len(arr)==3:
    print(abs(abs(arr[0]-arr[1])-abs(arr[1]-arr[2])))

Fixed submission:
n=int(input())
arr=list(input())
arr=[int(arr[i]) for i in range(n)]
if n==1:
  print(arr[0])
if n==2:
  print(abs(arr[0]-arr[1]))
else:
  tmp=[]
  for i in range(n-2):
    tmp.append(abs(abs(arr[i]-arr[i+1])-abs(arr[i+1]-arr[i+2])))
  arr=tmp
  while len(arr)>3:
    tmp=[]
    if len(arr)%2==0:
      for i in range(len(arr)//2):
        tmp.append(abs(arr[2*i]-arr[2*i+1]))
    else:
      for i in range(len(arr)-1):
        tmp.append(abs(arr[i]-arr[i+1]))
    arr=tmp
  if len(arr)==1:
    print(arr[0])
  elif len(arr)==2:
    print(abs(arr[0]-arr[1]))
  elif len(arr)==3:
    print(abs(abs(arr[0]-arr[1])-abs(arr[1]-arr[2])))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
arr=list(input())
arr=[int(arr[i]) for i in range(n)]
if n==1:
  print(arr[0])
if n==2:
  print(abs(arr[0]-arr[1]))
else:
  tmp=[]
  for i in range(n-2):
    tmp.append(abs(abs(arr[i]-arr[i+1])-abs(arr[i+1]-arr[i+2])))
  arr=tmp
  while len(arr)>3:
    tmp=[]
    if len(arr)%2==9:
      for i in range(len(arr)//2):
        tmp.append(abs(arr[2*i]-arr[2*i+1]))
    else:
      for i in range(len(arr)-1):
        tmp.append(abs(arr[i]-arr[i+1]))
    arr=tmp
  if len(arr)==1:
    print(arr[0])
  elif len(arr)==2:
    print(abs(arr[0]-arr[1]))
  elif len(arr)==3:
    print(abs(abs(arr[0]-arr[1])-abs(arr[1]-arr[2])))

Fixed submission:
n=int(input())
arr=list(input())
arr=[int(arr[i]) for i in range(n)]
if n==1:
  print(arr[0])
if n==2:
  print(abs(arr[0]-arr[1]))
else:
  tmp=[]
  for i in range(n-2):
    tmp.append(abs(abs(arr[i]-arr[i+1])-abs(arr[i+1]-arr[i+2])))
  arr=tmp
  while len(arr)>3:
    tmp=[]
    if len(arr)%2==0:
      for i in range(len(arr)//2):
        tmp.append(abs(arr[2*i]-arr[2*i+1]))
    else:
      for i in range(len(arr)-1):
        tmp.append(abs(arr[i]-arr[i+1]))
    arr=tmp
  if len(arr)==1:
    print(arr[0])
  elif len(arr)==2:
    print(abs(arr[0]-arr[1]))
  elif len(arr)==3:
    print(abs(abs(arr[0]-arr[1])-abs(arr[1]-arr[2])))
Buggy python submission (verdict: Runtime Error):
from decimal import *

a,b,c=map(int,input().split())
a,b,c=Decimal(a),Decimal(b),Decimal(c)
if c**0.5>a**0.5+b**0.5:
  print('Yes')
else:
  print('No')

Fixed submission:
from decimal import *

a,b,c=map(int,input().split())
a,b,c=Decimal(a),Decimal(b),Decimal(c)
if (max(0,c-(a+b)))**2>4*a*b:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
arr=[int(s[i]) for i in range(len(s))]
dic={}
match=[]
pows=[1]
for _ in range(n):
  pows.append((pows[-1]*10)%p)
tmp=0
for i in range(n-1,-1,-1):
  tmp+=arr[i]*pows[n-1-i]
  tmp%=p
  match.append(tmp)
  if tmp not in dic:
    dic[tmp]=1
  else:
    dic[tmp]+=1
match=match[::-1]
ans=0
rem=0
rev=pow(10,p-2,p)
for i in range(n-1,-1,-1):
  ans+=dic[rem]
  rem*=rev
  rem+=arr[i]
  rem%=p
  dic[match[i]]-=1
print(ans)

Fixed submission:
import collections

n,p=map(int,input().split())
s=input()
arr=[int(s[i]) for i in range(len(s))]
if p==2 or p==5:
  ans=0
  for i in range(n):
    if arr[i]%p==0:
      ans+=i+1
  print(ans)
else:
  dic=collections.defaultdict(int)
  match=[]
  pows=[1]
  for _ in range(n):
    pows.append((pows[-1]*10)%p)
  tmp=0
  for i in range(n-1,-1,-1):
    tmp+=arr[i]*pows[n-1-i]
    tmp%=p
    match.append(tmp)
    dic[tmp]+=1
  match=match[::-1]
  ans=0
  rem=0
  rev=pow(10,p-2,p)
  for i in range(n-1,-1,-1):
    ans+=dic[rem]
    rem+=arr[i]*pows[n-1-i]
    rem%=p
    dic[match[i]]-=1
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))

Fixed submission:
s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))
Buggy python submission (verdict: Runtime Error):
n=input()
arr=list(map(int,input().split()))
arr=sorted(arr)
for i in range(n-1):
  if arr[i]==arr[i+1]:
    print('NO')
    break
else:
  print('YES')

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
for i in range(n-1):
  if arr[i]==arr[i+1]:
    print('NO')
    break
else:
  print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
def paths(r,c):
  return (facts[r+c]*ifacts[r]*ifacts[c])%mod

mod=10**9+7
r1,c1,r2,c2=map(int,input().split())
facts=[1]
ifacts=[1]
for i in range(1,r2+c2+10):
  facts.append((facts[-1]*i)%mod)
  ifacts.append((ifacts[-1]*pow(i,mod-2,mod))%mod)
ans=0
for i in range(r1+1,r2+2):
  ans+=paths(i,c2)-paths(i,c1-1)
  ans%=mod
print(ans)

Fixed submission:
def paths(r,c):
  return facts[r+c]*ifacts[r]*ifacts[c]

mod=10**9+7
r1,c1,r2,c2=map(int,input().split())
facts=[1]*(r2+c2+10)
ifacts=[1]*(r2+c2+10)
for i in range(1,r2+c2+10):
  facts[i]=(facts[i-1]*i)%mod
  ifacts[i]=pow(facts[i],mod-2,mod)
ans=0
for i in range(r1+1,r2+2):
  ans+=paths(i,c2)-paths(i,c1-1)
  ans%=mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def calc():
  h,n=map(int,input().split())
  arr=[]
  for _ in range(n):
    arr.append(list(map(int,input().split())))
  dp=[10**10]*20001
  dp[0]=0
  for i in range(20001):
    for j in range(n):
      if i+arr[j][0]>20000:
        continue
      dp[i+arr[j][0]]=min(dp[i+arr[j][0]],dp[i]+arr[j][1])
  ans=10**18
  for i in range(h,20001):
    ans=min(ans,dp[i])
  print(ans)
calc()

Fixed submission:
h,n=map(int,input().split())
arr=[]
for _ in range(n):
  arr.append(list(map(int,input().split())))
dp=[10**10]*20001
dp[0]=0
for i in range(20001):
  for j in range(n):
    if i+arr[j][0]>20000:
      continue
    dp[i+arr[j][0]]=min(dp[i+arr[j][0]],dp[i]+arr[j][1])
ans=10**18
for i in range(h,20001):
  ans=min(ans,dp[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input().split())
arr=list(map(int,input().split()))
ans=1
least=arr[0]
for i in range(1,n):
  if arr[i]<=least:
    ans+=1
  least=min(least,arr[i])
print(ans)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
ans=1
least=arr[0]
for i in range(1,n):
  if arr[i]<=least:
    ans+=1
  least=min(least,arr[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input().split())
arr=list(map(int,input().split()))
ans=1
least=arr[0]
for i in range(1,n):
  if arr[i]<=least:
    ans+=1
  least=min(least,arr[i])
print(ans)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
ans=1
least=arr[0]
for i in range(1,n):
  if arr[i]<=least:
    ans+=1
  least=min(least,arr[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k,s=map(int,input().split())
if s!=10**9:
  ans=[s]*k+[10**9]*(n-k)
else:
  ans=[s]*k+(10**9-1)*(n-k)
print(*ans)

Fixed submission:
n,k,s=map(int,input().split())
if s!=10**9:
  ans=[s]*k+[10**9]*(n-k)
else:
  ans=[s]*k+[10**9-1]*(n-k)
print(*ans)
Buggy python submission (verdict: Runtime Error):
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
acum=[1]
for i in range(2,n+1):
  tmp=acum+pow(i,mod-2,mod)
  tmp%=mod
  acum.append(tmp)
ans=0
for i in range(n-1):
  ans+=(arr[i+1]-arr[i])*acum[i]
  ans%=mod
for i in range(1,n):
  ans*=i
  ans%=mod
print(ans)

Fixed submission:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
acum=[0]
for i in range(1,n+1):
  tmp=acum[-1]+pow(i,mod-2,mod)*pow(i+1,mod-2,mod)
  tmp%=mod
  acum.append(tmp)
ans=0
for i in range(n-1):
  ans+=arr[i]*acum[i]
  ans%=mod
  ans-=arr[i]*acum[n-2-i]
  ans%=mod
  ans-=arr[i]*pow(n-1-i,mod-2,mod)
  ans%=mod
for i in range(1,n):
  ans+=arr[-1]*pow(i,mod-2,mod)
  ans%=mod
for i in range(1,n):
  ans*=i
  ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
def fact(n):
  ret=1
  for i in range(2.n+1):
    ret=ret*i
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
checked1=[0]*(n+1)
checked2=[0]*(n+1)
for i in range(n):
  checked1[arr1[i]]=1
  checked2[arr2[i]]=1
  cnt1+=(arr1[i]-1-sum(checked1[:arr1[i]]))*fact(n-i-1)
  cnt2+=(arr2[i]-1-sum(checked2[:arr2[i]]))*fact(n-i-1)
print(abs(cnt1-cnt2))

Fixed submission:
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
arrs=list(itertools.permutations(range(1,n+1)))
cnt1=0
cnt2=0
for i in range(len(arrs)):
  if arrs[i]==p:
    cnt1=i
  if arrs[i]==q:
    cnt2=i
print(abs(cnt2-cnt1))

Buggy python submission (verdict: Runtime Error):
def fact(n):
  ret=1
  for i in range(2.n+1):
    ret=ret*i
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
checked1=[0]*(n+1)
checked2=[0]*(n+1)
for i in range(n):
  checked1[arr1[i]]=1
  checked2[arr2[i]]=1
  cnt1+=(arr1[i]-1-sum(checked1[:arr1[i]]))*fact(n-i-1)
  cnt2+=(arr2[i]-1-sum(checked2[:arr2[i]]))*fact(n-i-1)
print(abs(cnt1-cnt2))

Fixed submission:
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
arrs=list(itertools.permutations(range(1,n+1)))
cnt1=0
cnt2=0
for i in range(len(arrs)):
  if arrs[i]==p:
    cnt1=i
  if arrs[i]==q:
    cnt2=i
print(abs(cnt2-cnt1))

Buggy python submission (verdict: Runtime Error):
def fact(n):
  ret=1
  for i in range(2.n+1):
    ret=ret*i
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
checked1=[0]*(n+1)
checked2=[0]*(n+1)
for i in range(n):
  checked1[arr1[i]]=1
  checked2[arr2[i]]=1
  cnt1+=(arr1[i]-1-sum(checked1[:arr1[i]]))*fact(n-i-1)
  cnt2+=(arr2[i]-1-sum(checked1[:arr2[i]]))*fact(n-i-1)
print(abs(cnt1-cnt2))

Fixed submission:
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
arrs=list(itertools.permutations(range(1,n+1)))
cnt1=0
cnt2=0
for i in range(len(arrs)):
  if arrs[i]==p:
    cnt1=i
  if arrs[i]==q:
    cnt2=i
print(abs(cnt2-cnt1))

Buggy python submission (verdict: Runtime Error):
def fact(n):
  ret=1
  for i in range(2.n+1):
    ret=ret*i
  return ret

n=int(input())
arr1=list(map(int,input().split()))
arr2=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(n):
  cnt1+=(arr1[i]-1)*fact(n-i-1)
  cnt2+=(arr2[i]-1)*fact(n-i-1)
print(abs(cnt1-cnt2))

Fixed submission:
import itertools
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
arrs=list(itertools.permutations(range(1,n+1)))
cnt1=0
cnt2=0
for i in range(len(arrs)):
  if arrs[i]==p:
    cnt1=i
  if arrs[i]==q:
    cnt2=i
print(abs(cnt2-cnt1))
Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)

Fixed submission:
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  l=arr[0]
else:
  l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)

Fixed submission:
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  return (a*b)//gcd(a,b)

n,m=map(int,input().split())
arr=list(map(int,input().split()))
if n==1:
  l=arr[0]
else:
  l=lcm(arr[0],arr[1])
for i in range(2,n):
  l=lcm(l,arr[i])
  if l//2>m:
    print(0)
    exit()
for i in range(n):
  if (l//arr[i])%2==0:
    print(0)
    exit()
ans=(m-l//2)//l+1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
scores=list(map(int,input().split()))
t=input()
winner={'r':2,'s':0,'p':1}
ans=0
for i in range(k):
  ts=''
  for j in range(n):
    if k*j+i>=n:
      continue
    ts+=t[k*j+i]
  ts+='?'
  l=len(ts)
  hand=ts[0]
  cnt=1
  for j in range(1,l):
    if hand==ts[j]:
      cnt+=1
    else:
      ans+=scores[winner[hand]]*((cnt+1)//2)
      hand=ts[j]
      cnt=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
scores=list(map(int,input().split()))
t=input()
winner={'r':2,'s':0,'p':1}
ans=0
for i in range(k):
  ts=''
  for j in range(n):
    if k*j+i>=n:
      break
    ts+=t[k*j+i]
  ts+='?'
  l=len(ts)
  hand=ts[0]
  cnt=1
  for j in range(1,l):
    if hand==ts[j]:
      cnt+=1
    else:
      ans+=scores[winner[hand]]*((cnt+1)//2)
      hand=ts[j]
      cnt=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
scores=list(map(int,input().split()))
t=input()
winner={'r':2,'s':0,'p':1}
ans=0
for i in range(k):
  ts=''
  for j in range(n):
    if k*j+i>=n:
      continue
    ts+=t[k*j+i]
  ts+='?'
  l=len(ts)
  hand=ts[0]
  cnt=1
  for j in range(1,l):
    if hand==ts[j]:
      cnt+=1
    else:
      ans+=scores[winner[hand]]*((cnt+1)//2)
      hand=ts[j]
      cnt=1
print(ans)

Fixed submission:
n,k=map(int,input().split())
scores=list(map(int,input().split()))
t=input()
winner={'r':2,'s':0,'p':1}
ans=0
for i in range(k):
  ts=''
  for j in range(n):
    if k*j+i>=n:
      break
    ts+=t[k*j+i]
  ts+='?'
  l=len(ts)
  hand=ts[0]
  cnt=1
  for j in range(1,l):
    if hand==ts[j]:
      cnt+=1
    else:
      ans+=scores[winner[hand]]*((cnt+1)//2)
      hand=ts[j]
      cnt=1
print(ans)
Buggy python submission (verdict: Runtime Error):
ans=[1,2,3]
a=int(input())
b=int(input())
ans.del(a)
ans.del(b)
print(ans[0])

Fixed submission:
ans=[1,2,3]
a=int(input())
b=int(input())
ans.remove(a)
ans.remove(b)
print(ans[0])
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input())
t=a+b+c
if t<=21:
  print('win')
else:
  print('bust')

Fixed submission:
a,b,c=map(int,input().split())
t=a+b+c
if t<=21:
  print('win')
else:
  print('bust')
Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[(2**i)%mod for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(61):
  ans+=(plist[i]*blist[i])*(n-blist[i])+(plist[i]*(n-blist[i]))*blist[i]
  ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)

Fixed submission:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[2**i for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(61):
  ans+=(plist[i]*blist[i])*(n-blist[i])+(plist[i]*(n-blist[i]))*blist[i]
  ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[2**i for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(n):
  flag=format(arr[i],'b')
  if len(flag)!=61:
    flag='0'*(61-len(flag))+flag
  flag=flag[::-1]
  for j in range(61):
    c=int(flag[j])
    if c==1:
      ans+=plist[j]*(n-blist[j])
      ans%=mod
    else:
      ans+=plist[j]*blist[j]
      ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)

Fixed submission:
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
blist=[0]*61
plist=[2**i for i in range(61)]
for i in range(n):
  tmp=arr[i]
  pos=0
  while tmp!=0:
    if tmp%2==1:
      blist[pos]+=1
      tmp-=1
    tmp=tmp//2
    pos+=1
ans=0
for i in range(61):
  ans+=(plist[i]*blist[i])*(n-blist[i])+(plist[i]*(n-blist[i]))*blist[i]
  ans%=mod
ans*=pow(2,mod-2,mod)
ans%=mod
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
dp=[0]*(n+1)
dp[0]=1
for i in range(n+1):
  for j in range(100,106):
    dp[i]=max(dp[i],dp[i-j])
if dp[n]==1:
  print(1)
else:
  print(0)

Fixed submission:
n=int(input())
cnt=n//100
if n%100<=cnt*5:
  print(1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=input()
dp=[[[0]*1000 for _ in range(4)] for _ in range(n+1)]
dp[0][0][0]=1
for i in range(n):
  n=int(s[i])
  for j in range(3):
    for k in range(100):
      dp[i+1][j+1][k*10+n]=max(dp[i+1][j+1][k*10+n],dp[i][j][k])
  for j in range(4):
    for k in range(1000):
      dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k])
ans=0
for i in range(1000):
  if dp[-1][3][i]==1:
    ans+=1
print(ans)

Fixed submission:
import bisect

n=int(input())
s=input()
fpos=[-1]*10
npos=[[-1] for _ in range(10)]
for i in range(n):
  if fpos[int(s[i])]==-1:
    fpos[int(s[i])]=i
  npos[int(s[i])].append(i)
lpos=[len(npos[i]) for i in range(10)]
ans=0
for i in range(10):
  if fpos[i]==-1:
    continue
  for j in range(10):
    spos=bisect.bisect_right(npos[j],fpos[i])
    if spos>=lpos[j]:
      continue
    spos=npos[j][spos]
    for k in range(10):
      tpos=bisect.bisect_right(npos[k],spos)
      if tpos>=lpos[k]:
        continue
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
ans=0
dic={1:300000,2:200000,3:100000}
ans+=dic[x]+dic[y]
if x==1 and y==1:
  ans+=400000
print(ans)

Fixed submission:
x,y=map(int,input().split())
ans=0
if x==1:
  ans+=300000
if x==2:
  ans+=200000
if x==3:
  ans+=100000
if y==1:
  ans+=300000
if y==2:
  ans+=200000
if y==3:
  ans+=100000
if x==1 and y==1:
  ans+=400000
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
total=sum(arr)
acum=[arr[0]]
for i in range(1,n):
  acum.append(arr[i]+acum[-1])
ans=10**18
for i in range(n):
  tmp=abs(acum[i]-(total-acu[i]))
  ans=min(ans,tmp)
print(ans)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
total=sum(arr)
acum=[arr[0]]
for i in range(1,n):
  acum.append(arr[i]+acum[-1])
ans=10**18
for i in range(n):
  tmp=abs(acum[i]-(total-acum[i]))
  ans=min(ans,tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
r＝int(input())
print(r**2)

Fixed submission:
r=int(input())
print(r**2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=10**18
for i in range(10**6+1):
  if n%i==0:
    j=n//i
  ans=min(ans,i+j-2)
print(ans)

Fixed submission:
n=int(input())
ans=10**18
for i in range(1,10**6+1):
  if n%i==0:
    j=n//i
  ans=min(ans,i+j-2)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

pi=math.pi
a,b,x=map(int,input().split())
if 2*x<a*a*b:
  c=(2*x)/(a*b)
  print(math.degrees(math.atan(b/c)))
else:
  x=a*a*b-x
  c=(2*x)/(a*a)
  print(90-math.degrees(math.atan(a/c)))

Fixed submission:
import math

pi=math.pi
a,b,x=map(int,input().split())
if x==a*a*b:
  print(0)
elif 2*x<a*a*b:
  c=(2*x)/(a*b)
  print(math.degrees(math.atan(b/c)))
else:
  x=a*a*b-x
  c=(2*x)/(a*a)
  print(90-math.degrees(math.atan(a/c)))

Buggy python submission (verdict: Runtime Error):
import math

pi=math.pi
a,b,x=map(int,input().split())
if 2*x<=a*a*b:
  c=(2*x)/(a*b)
  print(math.degrees(math.atan(b/c)))
else:
  x=a*a*b-x
  c=(2*x)/(a*a)
  print(90-math.degrees(math.atan(a/c)))

Fixed submission:
import math

pi=math.pi
a,b,x=map(int,input().split())
if x==a*a*b:
  print(0)
elif 2*x<a*a*b:
  c=(2*x)/(a*b)
  print(math.degrees(math.atan(b/c)))
else:
  x=a*a*b-x
  c=(2*x)/(a*a)
  print(90-math.degrees(math.atan(a/c)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr1=sorted(arr1)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
l=-1
r=10**12+1
while r-l!=1:
  m=(r+l)//2
  tmp=0
  for i in range(n):
    if arr1[i]>m//arr2[i]:
      tmp+=(arr1[i]-m//arr2[i])
  if tmp<=k:
    r=m
  else:
    l=m
print(r)

Fixed submission:
n,k=map(int,input().split())
arr1=list(map(int,input().split()))
arr1=sorted(arr1)
arr2=list(map(int,input().split()))
arr2=sorted(arr2,reverse=True)
l=-1
r=10**12+1
while r-l!=1:
  m=(r+l)//2
  tmp=0
  for i in range(n):
    if arr1[i]>m//arr2[i]:
      tmp+=(arr1[i]-m//arr2[i])
  if tmp<=k:
    r=m
  else:
    l=m
print(r)
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
for i in range(n):
  a=arr[i]
  for j in range(i+1,n):
    b=arr[j]
    tmp=a+b
    pos=bisect.bisect_left(arr,tmp)-1
    if pos<=j:
      continue
    else:
      ans+=(pos-j)
print(ans)

Fixed submission:
import bisect

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
ans=0
for i in range(n):
  a=arr[i]
  for j in range(i+1,n):
    b=arr[j]
    tmp=a+b
    pos=bisect.bisect_left(arr,tmp)-1
    if pos<=j:
      continue
    else:
      ans+=(pos-j)
print(ans)