Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# かつっぱさん見て
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
babies=[(q,i) for i,q in enumerate(a)]
babies.sort(reverse=True)

dp=defaultdict(int)
ans=0
for l in range(n):
  for r in range(n):
    if l+r==n:
      ans=max(ans,dp[(l,r)])
      break
    act,ind=babies[l+r]
    dp[(l+1,r)]=max(dp[(l+1,r)],dp[(l,r)]+act*abs(ind-l))
    dp[(l,r+1)]=max(dp[(l,r+1)],dp[(l,r)]+act*abs(ind-(n-1-r)))

print(ans)
                    

Fixed submission:
# かつっぱさん見て
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
babies=[(q,i) for i,q in enumerate(a)]
babies.sort(reverse=True)

dp=defaultdict(int)
ans=0
for l in range(n):
  for r in range(n):
    if l+r==n:
      ans=max(ans,dp[(l,r)])
      break
    act,ind=babies[l+r]
    dp[(l+1,r)]=max(dp[(l+1,r)],dp[(l,r)]+act*abs(ind-l))
    dp[(l,r+1)]=max(dp[(l,r+1)],dp[(l,r)]+act*abs(ind-(n-1-r)))

print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
k=map(int,input())
r=range(1,k+1)
ans=0
for i in r:
  for j in r:
    for k in r:
      ans+=gcd(k,gcd(i,j))
print(ans)
# 間に合うはずなくない？？


Fixed submission:
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())

import math
from collections import Counter

# def gcd(*numbers):
    # return reduce(math.gcd, numbers)

ans=0
t=[]
for i in range(1,n+1):
    for j in range(1,n+1):
        t.append(math.gcd(i,j))
        
c=Counter(t).items()

for (i,j) in c:
    for k in range(1,n+1):
        ans+=math.gcd(i,k)*j
        # p\rint(c)
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
k=map(int,input())
r=range(1,k+1)
ans=0
for i in r:
  for j in r:
    for k in r:
      ans+=gcd(k,gcd(i,j))
print(ans)
# 間に合うはずなくない？？

Fixed submission:
# coding: utf-8
# Your code here!

def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())

import math
from collections import Counter

# def gcd(*numbers):
    # return reduce(math.gcd, numbers)

ans=0
t=[]
for i in range(1,n+1):
    for j in range(1,n+1):
        t.append(math.gcd(i,j))
        
c=Counter(t).items()

for (i,j) in c:
    for k in range(1,n+1):
        ans+=math.gcd(i,k)*j
        # p\rint(c)
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  for i in range(j):
    if (k:=2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        ans-=1   
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
from collections import Counter
def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")


for j in range(n):
    jj=s[j]
    for i in range(j):
        k=2*j-i
        if not j<=k<=n-1:
            continue
        ii=s[i]
        kk=s[k]
        if jj!=ii and jj!=kk and ii!=kk:
            ans-=1

print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  for i in range(j):
    if (k:=2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        ans-=1   
print(ans)

Fixed submission:
# coding: utf-8
# Your code here!
from collections import Counter
def MI():return map(int,input().split())
def LI():return list(MI())

n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")


for j in range(n):
    jj=s[j]
    for i in range(j):
        k=2*j-i
        if not j<=k<=n-1:
            continue
        ii=s[i]
        kk=s[k]
        if jj!=ii and jj!=kk and ii!=kk:
            ans-=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def MI():return map(int,input().split())
def LI():return list(MI())

from collections import deque
INF=float("inf")
n,x,y=MI()
x-=1
y-=1
ans=[0]*n

for sv in range(n):
  dist=[INF]*n
  q=deque()
  def push(v,d):
    if dist[v]!=INF:
      return
    dist[v]=d
    q.append(v)
  push(sv,0)
  while q:
    v=q.popleft()
    d=dist[v]
    if v-1>=0:
      push(v-1,d+1)
    if v+1<n:
      push(v+1,d+1)  
    if v==x:
      push(y,d+1)
    if v==y:
      push(x,d+1)
        
  for i in range(n):
    ans[dist[i]]+=1
for i in range(n):
  ans[i]//=2
for i in range(1,n):
  print(ans[i])

Fixed submission:
def II():return int(input())
def MI():return map(int,input().split())
def LI():return list(MI())
def ok():print("Yes")
def ng():print("No");exit()

n,x,y=MI()

ans=[0]*n

for i in range(1,n+1):
    for j in range(i+1,n+1):
        num=min(abs(i-j),abs(x-i)+abs(y-j)+1)
        ans[num]+=1

for an in ans[1:]:
    print(an)
Buggy python submission (verdict: Runtime Error):
def mi():return map(int,input().split())
n,m=mi()
n=pow(2,n)-1
m=pow(2,m)-1

for i in range(n):
    if i==0 or i==n-1:
        print("1"*m)
    else:
        if i%2==1:
            print("1"*m)
        else:
            print("1"+"0"*(m-2)+"1")


Fixed submission:
def mi():return map(int,input().split())

# n=int(input())
# a,b=mi()
s=input()
# l=list(mi())

ans=["hi","hihi","hihihi","hihihihi","hihihihihi"]
if s in ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
ql=[]

for _ in range(q):
    ql.append(list(map(str,input().split())))
flg=True #正順
for qi in ql:
    # qi=list(map(str,input().split()))
    if qi[0]=="1":
        flg=not flg
    else:
        f,c=qi[1],qi[2]
        if f=="1":
            if flg:
                s=c+s
            else:
                s=s+c
        else:
            if not flg:
                s=c+s
            else:
                s=s+c
                

if flg:
    s=s
else:
    s=s[::-1]
    
print(s)




Fixed submission:
s=input()
q=int(input())
l=""
r=""
flg=True

for i in range(q):
    p=list(map(str,input().split()))
    if p[0]=="1":
        flg=not flg
    else:
        z,f,c=p
        if f=="1":
            if flg:
                l=c+l
            else:
                r=r+c
        else:
            if not flg:
                l=c+l
            else:
                r=r+c
s=l+s+r

if flg:
    ans=s
else:
    ans=s[::-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())

flg=True #正順
for i in range(q):
    qi=list(map(str,input().split()))
    if qi[0]=="1":
        flg=not flg
    else:
        f,c=qi[1],qi[2]
        if f=="1":
            if flg:
                s=c+s
            else:
                s=s+c
        else:
            if not flg:
                s=c+s
            else:
                s=s+c
                

if flg:
    s=s
else:
    s=s[::-1]
    
print(s)




Fixed submission:
s=input()
q=int(input())
l=""
r=""
flg=True

for i in range(q):
    p=list(map(str,input().split()))
    if p[0]=="1":
        flg=not flg
    else:
        z,f,c=p
        if f=="1":
            if flg:
                l=c+l
            else:
                r=r+c
        else:
            if not flg:
                l=c+l
            else:
                r=r+c
s=l+s+r

if flg:
    ans=s
else:
    ans=s[::-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def mi():return map(int,input().split())
def li():return list(mi())

s=input()
q=int(input())

for i in range(q):
    qi=list(map(str,input().split()))
    if qi[0]=="1":
        s=s[::-1]
    else:
        if qi[1]=="1":
            s=qi[2]+s
        else:
            s=s+qi[2]
            
print(s)

Fixed submission:
s=input()
q=int(input())
l=""
r=""
flg=True

for i in range(q):
    p=list(map(str,input().split()))
    if p[0]=="1":
        flg=not flg
    else:
        z,f,c=p
        if f=="1":
            if flg:
                l=c+l
            else:
                r=r+c
        else:
            if not flg:
                l=c+l
            else:
                r=r+c
s=l+s+r

if flg:
    ans=s
else:
    ans=s[::-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

h,n=map(int,input().split())
a=[]
b=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)

INF=float("inf")
    
dp=np.array([[INF]*(1+h) for i in range(1+n)])


dp[0][0]=0

for i in range(n):
    # print(dp)
    for j in range(h+1):
        # print("i+1=",i+1,"j=",j)
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        dp[i+1][min(h,j+a[i])]=min(dp[i+1][min(h,j+a[i])],dp[i+1][j]+b[i])
        # print(i+1,j,min(h,j+a[i]),"\n",dp)
    # print("==================")

# print(dp)
print(dp[n][h])


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

a=[]
b=[]
for _ in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    
# print(a)
# print(b)

INF=float("inf")

dp=[INF]*(h+1)
dp[h]=0

for aa,bb in zip(a,b):
    for hh in range(h,0,-1):
        if hh-aa>=0:
            dp[hh-aa]=min(dp[hh-aa],dp[hh]+bb)
        else:
            dp[0]=min(dp[0],dp[hh]+bb)
            
print(dp[0])
# print(dp)

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

skills=[tuple(map(int,input().split())) for _ in range(n)]

dp=[10**30]*(10**4+1)

dp[hp]=0

for a,b in skills:
    for h in range(hp,0,-1):
        if h-a>=0:
            dp[h-a]=min(dp[h-a],dp[h]+b)
        else:
            dp[0]=min(dp[0],dp[h]+b)
            
print(dp[0])

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

a=[]
b=[]
for _ in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
    
# print(a)
# print(b)

INF=float("inf")

dp=[INF]*(h+1)
dp[h]=0

for aa,bb in zip(a,b):
    for hh in range(h,0,-1):
        if hh-aa>=0:
            dp[hh-aa]=min(dp[hh-aa],dp[hh]+bb)
        else:
            dp[0]=min(dp[0],dp[hh]+bb)
            
print(dp[0])
# print(dp)
Buggy python submission (verdict: Runtime Error):
n=int(input())
cnt=[[0 for i in range(10)] for j in range(n)]

for i in range(1,n+1):
  s=str(i)
  head=int(s[0])
  tail=int(s[-1])
  cnt[head][tail]+=1

ans=0
for h in range(0,10):
  for t in range(0,10):
    ans+=cnt[h][t]*cnt[t][h]
print(ans)

Fixed submission:
c={}
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    c[l+r]=0


n=int(input())
for i in range(1,n+1):
  l=str(i)[0]
  r=str(i)[-1]
  try:
    c[l+r]+=1
  except:
    pass
  
      
ans=0
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    ans+=c[l+r]*c[r+l]
    
    
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())

c=[[0]*10 for i in range(n)]

for i in range(1,n+1):
    t=str(i)
    c[int(t[0])][int(t[-1])]+=1
    
ans=0
for i in range(10):
    for j in range(10):
        ans+=c[i][j]*c[j][i]
        
print(ans)

Fixed submission:
c={}
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    c[l+r]=0


n=int(input())
for i in range(1,n+1):
  l=str(i)[0]
  r=str(i)[-1]
  try:
    c[l+r]+=1
  except:
    pass
  
      
ans=0
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    ans+=c[l+r]*c[r+l]
    
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main(n):
    l=[i for i in range(1,n+1)]
    ans=0
    for i in l:
        for j in l:    
            if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]:
                # print(i,j)
                ans+=1
                
    print(ans)
n=int(input())
main(n)

Fixed submission:
c={}
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    c[l+r]=0


n=int(input())
for i in range(1,n+1):
  l=str(i)[0]
  r=str(i)[-1]
  try:
    c[l+r]+=1
  except:
    pass
  
      
ans=0
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    ans+=c[l+r]*c[r+l]
    
    
print(ans)

Buggy python submission (verdict: Runtime Error):
def main(n):
    l=[i for i in range(1,n+1)]
    ans=0
    for i in l:
        for j in l:    
            if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]:
                # print(i,j)
                ans+=1
                
    print(ans)
n=init(input())
main(n)

Fixed submission:
c={}
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    c[l+r]=0


n=int(input())
for i in range(1,n+1):
  l=str(i)[0]
  r=str(i)[-1]
  try:
    c[l+r]+=1
  except:
    pass
  
      
ans=0
for i in range(1,10):
  for j in range(1,10):
    l=str(i)
    r=str(j)
    ans+=c[l+r]*c[r+l]
    
    
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
#import numpy as np

h,w=map(int,input().split())
#sy,sx=map(int,input().split())
#sy=sy-1
#sx=sx-1
#gy,gx=map(int,input().split())
#gy=gy-1
#gx=gx-1
maze=[list("#"*(w+2))]+[list("#"+input()+"#") for i in range(h)]+[list("#"*(w+2))]
INF=10800 #>50*50
visited=[[-INF]*(w+2) for i in range(h+2)]

ss=[]

for i in range(1,h+1):
  for j in range(1,w+1):
    if maze[i][j]==".":
      ss.append((i,j))



def bfs(maze,visited,sy,sx):#,gy,gx):
  queue=deque([[sy,sx]])
  visited[sy][sx]=0
  while queue:
    [y,x]=queue.popleft()
    #if (y,x)==(gy,gx):
    #  return visited[gy][gx]
    for i,j in ((-1,0),(1,0),(0,1),(0,-1)):
      #もともと壁があって、はみ出す心配はない。
      y_new,x_new=y+i,x+j
      if maze[y_new][x_new]=="." and visited[y_new][x_new]==-INF:
        visited[y_new][x_new]=visited[y][x]+1
        queue.append([y_new,x_new])

        
        
ans=0
for i,j in ss:
  bfs(maze,visited,3,1)
  for i in range(1,h+1):
    for j in range(1,w+1):
      ans=max(ans,visited[i][j])

    
    
print(ans)



Fixed submission:
from collections import deque

h,w=map(int,input().split())

maze=[list("#"*(w+2))]+[list("#"+input()+"#") for i in range(h)]+[list("#"*(w+2))]
INF=10800 #>50*50
visited=[[-INF]*(w+2) for i in range(h+2)]

ss=[]

for i in range(1,h+1):
  for j in range(1,w+1):
    if maze[i][j]==".":
      ss.append((i,j))



def bfs(maze,visited,sy,sx):#,gy,gx):
  queue=deque([[sy,sx]])
  visited[sy][sx]=0
  while queue:
    [y,x]=queue.popleft()
    for i,j in ((-1,0),(1,0),(0,1),(0,-1)):
      y_new,x_new=y+i,x+j
      if maze[y_new][x_new]=="." and visited[y_new][x_new]==-INF:
        visited[y_new][x_new]=visited[y][x]+1
        queue.append([y_new,x_new])

        
        
ans=0
for i,j in ss:
  visited=[[-INF]*(w+2) for i in range(h+2)]
  bfs(maze,visited,i,j)
  for i in range(1,h+1):
    for j in range(1,w+1):
      ans=max(ans,visited[i][j])

    
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=s.cpount("ABC")
print(ans)

Fixed submission:
n=input()
s=input()

print(s.count("ABC"))
Buggy python submission (verdict: Runtime Error):
s,t=map(int,input().split())
print(t+s)

Fixed submission:
左,右=map(str,input().split())
print(右+左)

Buggy python submission (verdict: Runtime Error):
s,t=map(int,input().split())
print(s+t)

Fixed submission:
左,右=map(str,input().split())
print(右+左)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

n=int(input())
S=input()
l=list("0123456789")

ret=[False]*1000
for i in (l):
    for j in (l):
        for k in (l):
            flg1=flg2=False
            for s in S:
                if s==i and not flg1:
                    flg1=True
                    continue
                if flg1 and s==j and not flg2:
                    flg2=True
                    continue
                if flg2 and s==k:
                    tmp=int(i+j+k)
                    # print(tmp)
                    ret[tmp]=True
                    break
          
print(sum(ret))

Fixed submission:
# coding: utf-8
# Your code here!

n=int(input())
S=input()
l=list("0123456789")

ret=[False]*1000
for i in (l):
    for j in (l):
        for k in (l):
            flg1=flg2=False
            for s in S:
                if s==i and not flg1:
                    flg1=True
                    continue
                if flg1 and s==j and not flg2:
                    flg2=True
                    continue
                if flg2 and s==k:
                    tmp=int(i+j+k)
                    # print(tmp)
                    ret[tmp]=True
                    break
          
print(sum(ret))
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())

if (x+y)%3!=0:
    print(0)
    exit()
    
a=(2*y-x)//3
b=(2*x-y)//3

mod=10**9+7

F=[1]
for i in range(1,a+b+1):
    tmp=F[-1]*i
    F.append(tmp%mod)

Ia=pow(F[a],mod-2,mod)
Ib=pow(F[b],mod-2,mod)

ans=F[a+b]*Ia*Ib%mod
print(ans)


Fixed submission:
x,y=map(int,input().split())

if (x+y)%3!=0:
    print(0)
    exit()
    
a=(2*y-x)//3
b=(2*x-y)//3

if a<0 or b<0:
    print(0)
    exit()

mod=10**9+7

F=[1]
for i in range(1,a+b+1):
    tmp=F[-1]*i
    F.append(tmp%mod)

Ia=pow(F[a],mod-2,mod)
Ib=pow(F[b],mod-2,mod)

ans=F[a+b]*Ia*Ib%mod
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import *
def abc144c():
  n,k=map(int,input().split())
  a=sorted(list(map(int,input().split())))
  f=sorted(list(map(int,input().split())))[::-1]
  q=[] 
  for i,j in zip(a,f):
    heappush(q,(-i*j,j))
  kk=min(k,10**12)
  for i in range(k):
    tmp,key=heappop(q)
    heappush(q,(tmp+key,key))
  ans,key=heappop(q)
  print(max(-ans,0))
abc144c()


Fixed submission:
a,b=map(int,input().split())
if 1<=a<=9 and 1<=b<=9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
# s=input()
# a,b=map(int,input().split())
# h=list(map(int,input().split()))
l=sorted(list(map(int,input().split())))

# mod=10**9+7
# n=20
# fact=[1]
# for i in range(n):
#     fact+=fact[-1]*(i+1)%mod,
# print(fact)
# print(l)
# ほんと？
from bisect import bisect_left,bisect_right
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        ll=l[j+1:]
        # print(ll)
        # abs(a-b)<c<a+bをみたすcは何個？
        ans+=bisect_left(ll,a+b) # -bisect_right(ll,b-a)
print(ans)

Fixed submission:
import bisect
 
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
 
for i in range(n):
  for j in range(i+1,n):
    temp=l[i]+l[j]
    ans+=(bisect.bisect_left(l,temp)-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
# s=input()
# a,b=map(int,input().split())
# h=list(map(int,input().split()))
l=sorted(list(map(int,input().split())))

# mod=10**9+7
# n=20
# fact=[1]
# for i in range(n):
#     fact+=fact[-1]*(i+1)%mod,
# print(fact)
# print(l)
# ほんと？
from bisect import bisect_left,bisect_right
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        ll=l[j+1:]
        # print(ll)
        # abs(a-b)<c<a+bをみたすcは何個？
        ans+=bisect_left(ll,a+b)-bisect_right(ll,b-a)
print(ans)

Fixed submission:
import bisect
 
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
 
for i in range(n):
  for j in range(i+1,n):
    temp=l[i]+l[j]
    ans+=(bisect.bisect_left(l,temp)-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#defnishitaradoudarou
def abc143c():
  n=int(input())
  l=list(map(int,input().split()))
  cnt=0
  for i in range(n):
    for j in range(i+1,n):
      for k in range(j+1,n):
        #print(i,j,k)
        a=l[i];b=l[j];c=l[k]
        if a<b+c and b<a+c and c<b+a:
          cnt+=1
  print(cnt)
abc143c()


Fixed submission:
import bisect
 
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
 
for i in range(n):
  for j in range(i+1,n):
    temp=l[i]+l[j]
    ans+=(bisect.bisect_left(l,temp)-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
cnt=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      #print(i,j,k)
      a=l[i];b=l[j];c=l[k]
      if a<b+c and b<a+c and c<b+a:
        cnt+=1
print(cnt)

Fixed submission:
import bisect
 
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
 
for i in range(n):
  for j in range(i+1,n):
    temp=l[i]+l[j]
    ans+=(bisect.bisect_left(l,temp)-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l=list(map(int,input().split()))
cnt=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      #print(i,j,k)
      a=l[i];b=l[j];c=l[k]
      if a<b+c and b<a+c and c<b+a:
        cnt+=1
print(cnt)

Fixed submission:
import bisect
 
n=int(input())
l=sorted(list(map(int,input().split())))
ans=0
 
for i in range(n):
  for j in range(i+1,n):
    temp=l[i]+l[j]
    ans+=(bisect.bisect_left(l,temp)-j-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(1,n+1):
  b.append(a.index(i)+1)
print(*b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i,q in enumerate(a):
  #print(i+1,q)
  b[q-1]=i+1
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(a.index(i)+1,end=" ")
print()

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i,q in enumerate(a):
  #print(i+1,q)
  b[q-1]=i+1
print(*b)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in range(1,n+1):
  b.append(a.index(i)+1)
print(*b)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i,q in enumerate(a):
  #print(i+1,q)
  b[q-1]=i+1
print(*b)
Buggy python submission (verdict: Runtime Error):
def main():

  n,m=map(int,input().split())
  a=list(map(int,input().split()))
  for i in range(m):
    a.sort(reverse=True)
    a[0]=a[0]//2
  print(sum(a))
  
main()


Fixed submission:
s=input()
if s =="Sunny":
  ans="Cloudy"
elif s == "Cloudy":
  ans="Rainy"
else:
  ans="Sunny"

print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()

n=len(s)
for i in range(0,n,2):

  if s[i] == "R" or s[i] =="U" or s[i] =="D":
    flag1=True
  else:
    flag1=False
for i in range(1,n,2):
  if s[i] == "L" or s[i] =="U" or s[i] =="D":
    flag2=True
  else:
    flag2=False

if flag1 == True and flag2 == True:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
even=["L","U","D"] #mondaide
odd=["R","U","D"]
l=len(s)
fumiyasui=False
for i in range(l):
  if i%2==0:
    if s[i] in odd:
      fumiyasui=True      
    else:
      print("No")
      exit()
  else:
    if s[i] in even:
      fumiyasui=True      
    else:
      print("No")
      exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
msg=input()



left=(msg[0]!="R")
right=(msg[-1]!="L")
msg2=msg[1:-1]
cntrl=msg.count("RL")


first=n-cntrl*2-left-right
print("f",first)
ans=first+2*min(k,msg2(count("RL")))
if ans==n:
  ans=n-1
print(ans)
               

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

happiness=0
for c,d in zip(s,s[1:]):
  if c == d:
    happiness +=1
    
ans=min(n-1,happiness+2*k)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
ss=set(s)
ans=0
for _ in ss:
  l=s.count(_)
  ans+=l*(l-1)//2
print(ans)


Fixed submission:
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
#sss=set(s)
ans=0
import collections
c=collections.Counter(s)

for l in c.values():
  ans+=l*(l-1)*(1/2)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
s.sort()
sss=set(s)
ans=0
for _ in sss:
  l=s.count(_)
  ans+=l*(l-1)//2
print(ans)


Fixed submission:
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
#sss=set(s)
ans=0
import collections
c=collections.Counter(s)

for l in c.values():
  ans+=l*(l-1)*(1/2)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
s.sort()
sss=set(s)
ans=0
for _ in sss:
  l=s.count(_)
  ans+=l*(l-1)//2
print(ans)

Fixed submission:
n=int(input())
s=[]
for i in range(n):
  s.append("".join(sorted(input())))
#sss=set(s)
ans=0
import collections
c=collections.Counter(s)

for l in c.values():
  ans+=l*(l-1)*(1/2)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(1,n+1):
  if len(i)%2==1:
    ans+=1
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n + 1):
  if len(str(i)) % 2 == 1:
    ans += 1
print(ans)