Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
q=int(input())
r=1
for i in range(q):
  q2=input().split()
  if int(q2[0])==1:
    r*=-1
  else:
    if (r==1 and int(q2[1])==1) or (r==-1 and int(q2[1])==2):
        s=q2[2]+s
    else:
        s=s+q2[2]
print(s if r==1 else s[::-1])

 
        

Fixed submission:
from collections import deque
d=deque()
d.append(input())
q=int(input())
r=1
for i in range(q):
  q2=input().split()
  if int(q2[0])==1:
    r*=-1
  else:
    if (r==1 and int(q2[1])==1) or (r==-1 and int(q2[1])==2):
        d.appendleft(q2[2])
    else:
        d.append(q2[2])

print("".join(d) if r==1 else "".join(d)[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[input() for _ in range(n)]
a.sort()
b=[]
c=[]
w=""
for m in a:
  if m == w:
    c[-1]+=1
  else:
    b.append(m)
    c.append(1)
    w=m
for m in range(len(b)):
  if c[m]==max(c):
    print (b[m])

Fixed submission:
n=int(input())
a={}
for _ in range(n):
  m=input()
  if m in a:
    a[m]+=1
  else:
    a[m]=1
b=[]
v=max(a.values())
for k in a.items() :
     if k[1] == v:
      b.append(k[0])
b.sort()
for l in b:
  print(l)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=0
for i in range(n-k+1):
  b=0
  for j in range(i,i+k):
    b+=p[j]
  if b >c:
    c =b
print((c+k)/2)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
q=[0]
for i in range(0,n-k):
  q.append(q[-1]+p[i+k]-p[i])
b=q.index(max(q))
s=0
for i in range(b,b+k):
  s+=p[i]
print((s+k)/2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=list(map(int,input().split()))
c=0
for m in range(n):
  d=0
  for i in range(m):
    if p[m]>p[i]:
      d+=1
  if d==0:
    c+=1
print(c)
  

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
c=0
d=p[0]
for i in range(n):
  if p[i]<= d:
    d=p[i]
    c+=1
print(c)
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
print(int(a*b/math.gcd(a,b)))


Fixed submission:
import fractions
a,b=map(int,input().split())
print(int(a*b/fractions.gcd(a,b)))
Buggy python submission (verdict: Time Limit Exceeded):
h,w,k=map(int,input().split())
a=["0" for _ in range(h)]
c=1
for i in range(h):
  s=input()
  sh=[]
  nc=0
  if s=="."*w:continue
  
  for j in range(w):
    if s[j]=="#" and nc>0:c+=1
    elif s[j]=="#": nc+=1
    sh.append(str(c))
  a[i]=sh[:]
  c+=1

while "0" in a:
  for i in range(h):
    if a[i]=="0" and i==0:
      a[0]=a[1]
    elif a[i]=="0":
      a[i]=a[i-1]
      
for m in a:
  print(*m)

Fixed submission:
h,w,k=map(int,input().split())
a=["x" for _ in range(h)]
c=1
if k==0:
  a=[1 for _ in range(w)]
  for i in range(h):
    print(*a)
  import sys
  sys.exit()

for i in range(h):
  s=input()
  sh=[]
  nc=0
  if s=="."*w:continue
  
  for j in range(w):
    if s[j]=="#" and nc>0:c+=1
    elif s[j]=="#": nc+=1
    sh.append(str(c))
  a[i]=sh[:]
  c+=1
  
if a[0]=="x":
  l=1
  while a[l]=="x":
    l+=1
  a[0]=a[l]
  
while "x" in a:
  for i in range(h):
    if a[i]=="x":
      l=i-1
      while a[l]=="x":
        l-=1
      a[i]=a[l]
      
for m in a:
  print(*m)
Buggy python submission (verdict: Runtime Error):
s=input()
#print(s)
l=[-1 for _ in range(len(s)+1)]
def aa(ix,v): #ixはlベース
 # print(ix,v,l)
  if (ix>= len(s) and v==1) or (ix==0 and v==0-1):
    return
  if v==1 and s[ix]=="<" and l[ix+1]<=l[ix]:
    l[ix+1]=l[ix]+1
    aa(ix+1,1)
  elif v==-1 and s[ix-1]==">" and l[ix-1]<=l[ix]:
    l[ix-1]=l[ix]+1
    aa(ix-1,-1)
  return

for i in range(0,len(s)):
  if i ==0 and s[0]=="<":    
    l[0]=0
    aa(i,1)
  elif i==len(s)-1 and s[-1]==">":
    l[-1]=0
    aa(i+1,-1)
  elif s[i]==">" and s[i+1]=="<":
    l[i+1]=0
    aa(i+1,1)
    aa(i+1,-1)

print(sum(l))



Fixed submission:
import sys
sys.setrecursionlimit(1000000)
s=input()
#print(s)
l=[-1 for _ in range(len(s)+1)]
def aa(ix,v): #ixはlベース
# print(ix,v,l)
  if (ix>= len(s) and v==1) or (ix==0 and v==0-1):
    return
  if v==1 and s[ix]=="<" and l[ix+1]<=l[ix]:
    l[ix+1]=l[ix]+1
    aa(ix+1,1)
  elif v==-1 and s[ix-1]==">" and l[ix-1]<=l[ix]:
    l[ix-1]=l[ix]+1
    aa(ix-1,-1)
  return

for i in range(0,len(s)):
  if i ==0 and s[0]=="<":    
    l[0]=0
    aa(i,1)
  elif i==len(s)-1 and s[-1]==">":
    l[-1]=0
    aa(i+1,-1)
  elif s[i]==">" and s[i+1]=="<":
    l[i+1]=0
    aa(i+1,1)
    aa(i+1,-1)

print(sum(l))
Buggy python submission (verdict: Runtime Error):
a,b,x=map(float,input().split())
import math
if x<=a*a*b/2:
  print(90-math.degrees(math.asin(2*x/a/b/((2*x/a/b)*2+b**2)**0.5)))
elif (-x/a+a*b)==0:
  print(0)
else:
  print(90-math.degrees(math.atan(a*a/2/(-x/a+a*b))))

Fixed submission:
a,b,x=map(float,input().split())
import math
if x<=a*a*b/2:
  print(math.degrees(math.atan(a*b*b/2/x)))
elif (-x/a+a*b)==0:
  print(0)
else:
  print(math.degrees(math.atan(2/a/a*(a*b-x/a))))

Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
if x<=a*a*b/2:
  print(90-math.degrees(math.asin(2*x/a/b/((2*x/a/b)*2+b**2)**0.5)))
else:
  print(90-math.degrees(math.atan(a*a/2/(-x/a+a*b))))

Fixed submission:
a,b,x=map(float,input().split())
import math
if x<=a*a*b/2:
  print(math.degrees(math.atan(a*b*b/2/x)))
elif (-x/a+a*b)==0:
  print(0)
else:
  print(math.degrees(math.atan(2/a/a*(a*b-x/a))))
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(max(a-2b,0))

Fixed submission:
a,b=map(int,input().split())
print(max(a-2*b,0))
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
import math
c= math.gcd(a,b)
l=[]
i=2
while i<=c:
  if c % i==0:
    c=c//i
    l.append(i)
  else:
    i+=1
print(len(set(l))+1)


Fixed submission:
a,b=map(int,input().split())
import math
c= math.gcd(a,b)
c2=c
l=[]
i=2
while i<=c:
  if c % i==0:
    c=c//i
   
    l.append(i)
  else:
    i+=1
  if i*i-1>c:
    l.append(c)
    break
  
print(len(set(l))+1)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())

d=[[0] for _ in range(n+1)]
d1=[0 for _ in range(n+1)]

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

for i in range(q):
  p,x=map(int,input().split())
  d1[p]+=x

for i in range(1,n+1):
  d[i].remove(0)
  
vi=[0 for _ in range(n+1)]

def dfs(x,i):
  vi[x]=i+d1[x]
  for m in d[x]:
    if vi[m]==0:
      dfs(m,vi[x])    

dfs(1,0)


print(*vi[1:])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())

d=[[0] for _ in range(n+1)]
d1=[0 for _ in range(n+1)]

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

for i in range(q):
  p,x=map(int,input().split())
  d1[p]+=x

#d 関係性 d1価
vi=[-1 for _ in range(n+1)]

def dfs(x,i):
  vi[x]=i+d1[x]
  for m in d[x]:
    if vi[m]==-1 and m!=0:
      dfs(m,vi[x])    

dfs(1,0)


print(*vi[1:])

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

d=[[0] for _ in range(n+1)]
d1=[0 for _ in range(n+1)]

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

for i in range(q):
  p,x=map(int,input().split())
  d1[p]+=x

for i in range(1,n+1):
  d[i].remove(0)
  
vi=[0 for _ in range(n+1)]

def dfs(x,i):
  vi[x]+=i+d1[x]
  for m in d[x]:
    if vi[m]==0:
      dfs(m,vi[x])    

dfs(1,0)


print(*vi[1:])

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
n,q=map(int,input().split())

d=[[0] for _ in range(n+1)]
d1=[0 for _ in range(n+1)]

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

for i in range(q):
  p,x=map(int,input().split())
  d1[p]+=x

#d 関係性 d1価
vi=[-1 for _ in range(n+1)]

def dfs(x,i):
  vi[x]=i+d1[x]
  for m in d[x]:
    if vi[m]==-1 and m!=0:
      dfs(m,vi[x])    

dfs(1,0)


print(*vi[1:])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=["".join(sorted(input())) for _ in range(n)]
c=0
for i in range(n):
  for j in range(i+1,n):
    if s[i]==s[j]:
      c+=1
print(c)

Fixed submission:
from collections import defaultdict
n=int(input())
s=["".join(sorted(input())) for _ in range(n)]

d = defaultdict(int)
for a in s:
  d[a]+=1
c=0
for a in d.values():
  if a>1:
    c+=a*(a-1)//2
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=["".join(sorted(input())) for _ in range(n)]
c=0
for i in range(n):
  for j in range(i+1,n):
    if s[i]==s[j]:
      c+=1
print(c)

Fixed submission:
from collections import defaultdict
n=int(input())
s=["".join(sorted(input())) for _ in range(n)]

d = defaultdict(int)
for a in s:
  d[a]+=1
c=0
for a in d.values():
  if a>1:
    c+=a*(a-1)//2
print(c)
Buggy python submission (verdict: Runtime Error):


    a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))

Fixed submission:
def resolve():


    a,b,c=map(int,input().split())
    print(max(0,c-max(0,a-b)))
resolve()
Buggy python submission (verdict: Runtime Error):
l,r=map(int,input().split())
a=2018
for i in range (l,min(r,l+2019)):
  for j in range(i+1,min(r+1,i+2019)):
    c= ((i%2019)*(j%2019))%2019
    if c<a:
      a=c
print(a)

Fixed submission:
n=int(input())
a=[int(input()) for _ in range(n)]
b=sorted(a)
for m in a:
  if m !=b[-1]:
    print(b[-1])
  else:
    print(b[-2])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 6)
n, m =map(int,input().split())
a=[int(input()) for _ in range(m)]
lis={0:1}
def saiki(x):
  if x not in lis:
      if x in a:
        lis[x]=0
        return 0
      elif x==1:
        lis[1]=1
        return 1
      else:
        d=saiki(x-1)+saiki(x-2)
        if d >10**9+7:
          lis[x]= d % (10**9+7)
          return lis[x]
        else:
          lis[x]=d
          return d
  else:
    return lis[x]
      
print(saiki(n))



Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
n, m =map(int,input().split())
lis={0:1,1:1}
for _ in range(m):
  lis[int(input())]=0 
def saiki(x):
  if x not in lis:
        d=saiki(x-1)+saiki(x-2)
        if d >10**9+7:
          lis[x]= d % (10**9+7)
          return lis[x]
        else:
          lis[x]=d
          return d
  else:
    return lis[x]
      
print(saiki(n))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
  b,c=map(int,input().split())
  a+=[c]*b
print(sum(sorted(a,reverse=True)[:n]))

Fixed submission:
n,m=map(int,input().split())
from collections import defaultdict
d=defaultdict(int)
for k in map(int,input().split()):
  d[k]+=1
for i in range(m):
  b,c=map(int,input().split())
  d[c]+=b
sm=0
c=0

for k,v in sorted(d.items(),reverse=True):
  if c+v<n:
    sm+=k*v
    c+=v
  elif c+v==n:
    sm+=k*v
    break
  else:
    sm+=k*(n-c)
    break
print(sm)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
d=[0]*n
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    d[i]=1
for j in range(q):
  sm=0
  d2=d[l[j][0]-1:l[j][1]-1]
  print(sum(d2))


Fixed submission:
n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]

for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
d=[0]*n
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    d[i]=1
for j in range(q):
  sm=0
  d2=d[l[j][0]-1:l[j][1]-1]
  print(sum(d2))


Fixed submission:
n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]

for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict 
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
d= defaultdict(int)
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    d[i]=1
for j in range(q):
  sm=0
  for k in range(l[j][0]-1,l[j][1]-1):
    sm+=d[k]
  print(sm)


Fixed submission:
n,q=map(int,input().split())
s=input()
d=[0]*(n+1)
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    d[i]=d[i-1]+1
  else:
    d[i]=d[i-1]

for j in range(q):
  l,r=map(int,input().split())
  print(d[r-1]-d[l-1])
Buggy python submission (verdict: Runtime Error):
n=int(input())
sys.setrecursionlimit(10 ** 6)
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))

Fixed submission:
n=int(input())
import sys
sys.setrecursionlimit(10 ** 6)
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))

Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))

Fixed submission:
n=int(input())
import sys
sys.setrecursionlimit(10 ** 6)
h=list(map(int,input().split()))
cos={0:0,1:abs(h[1]-h[0])}
def cost(x):
  if x not in cos:
    d1=cost(x-1)+abs(h[x]-h[x-1])
    d2=cost(x-2)+abs(h[x]-h[x-2])
    cos[x]=min(d1,d2)
    return cos[x]
  else:
    return cos[x]
  
print(cost(n-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
for i in range(n):
  for j in range(i+1,min(i+k+1,n)):
    d=dp[i]+abs(h[i]-h[j])
    if d<dp[j]:
      dp[j]=d
print(dp[n-1])      
      
      
  

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n
dp[0]=0
for i in range(n):
  for j in range(i+1,min(i+k+1,n)):
    d=dp[i]+abs(h[i]-h[j])
    if d<dp[j]:
      dp[j]=d
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(1,n+1):
  for j in range(w+1):
    if j-a[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
    
print(dp[n][w])

Fixed submission:
n,w=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(w+1)] for _ in range(n+1)]

for i in range(1,n+1):
  for j in range(w+1):
    if j-a[i-1][0]>=0:
      dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i-1][0]]+a[i-1][1])
    else:
      dp[i][j]=dp[i-1][j]
    
print(dp[n][w])
Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)

Fixed submission:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  elif f*f>p:
    a.append(p)
    break
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)

Fixed submission:
n,p=map(int,input().split())
from collections import Counter
a=[]
while p%2==0:
  a.append(2)
  p//=2
f=3
while f<=p:
  if p%f==0:
    a.append(f)
    p//=f
  elif f*f>p:
    a.append(p)
    break
  else:
      f+=2
c=Counter(a)
ans=1
for k,v in c.items():
  if v>=n:
    ans*=k**(v//n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
l=[[] for _ in range(n)]
l2=[]

for i in range(m):
  p,y=map(int,input().split())
  l[p-1].append(y)
  l2.append([p,y])
for m in l:
  m.sort()

for m in l2:
  print("{:06d}".format(m[0]) +"{:06d}".format(l[m[0]-1].index(m[1])+1))


Fixed submission:
n,m=map(int,input().split())
import bisect
l=[[] for _ in range(n)]
l2=[]

for i in range(m):
  p,y=map(int,input().split())
  bisect.insort_left(l[p-1],y)
  l2.append([p,y])

for m in l2:
  print("{:06d}".format(m[0]) +"{:06d}".format(bisect.bisect_left(l[m[0]-1],m[1])+1))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
for i in reversed(range(1,m//n+1)):
  if  (m-i*n)%i==0 :break
print(i)
  

Fixed submission:
n,m=map(int,input().split())
d=[]
f=1
while f*f<m+1:
  if m%f==0:
    d.append(f)
    d.append(m//f)
  f+=1
d.sort(reverse=True)
for i in d:
  if  (m-i*n)>=0 and (m-i*n)%i==0 :break
print(i)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
x=list(map(int,input().split()))

st=0
m=3*10**8
for i in range(n-1):
  if x[i]<0 and x[i+1]>=0:
    st=i+1

for i in range(n-k+2):
  mi=x[k+i-1]-x[i]+min(abs(x[k+i-1]),abs(x[i]))
  print(x[k+i-1],x[i],mi)
  if k+i<st or i>st:continue
  if mi <m:m=mi
print(m)

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

import bisect
c=bisect.bisect_left(x,0)
mt=2*10**8

for i in range(n-k+1):
  if i+k<c:continue
  mt=min(mt,2*abs(x[i])+abs(x[i+k-1]),abs(x[i])+2*abs(x[i+k-1]))
  if i+k-1 ==c-1:mt=min(mt,abs(x[i]))
  if i==c:mt=min(mt,x[i+k-1])
if n==k:
  if c!=n and c!=0:
    mt=min(2*abs(x[0])+x[-1],2*x[-1]+abs(x[0]))
  else:
    mt=max(abs(x[0]),abs(x[-1]))
print(mt)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(b,a[i]+1)
  for j in range(b1,n):
    sm+=n-bisect.bisect_left(c,b[j]+1)
print(sm)
  

Fixed submission:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(a,b[i])
  c1=n-bisect.bisect_left(c,b[i]+1)
  sm+=b1*c1
print(sm)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(b,a[i]+1)
  for j in range(b1,n):
    sm+=n-bisect.bisect_left(c,b[j]+1)
print(sm)
  

Fixed submission:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
sm=0
for i in range(n):
  b1=bisect.bisect_left(a,b[i])
  c1=n-bisect.bisect_left(c,b[i]+1)
  sm+=b1*c1
print(sm)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=-ord(s[i])+ord("z")+1
  if f<=k:
    l[i]="a"
    k-=f
l[-1]=chr(ord(l[-1])+k)
print("".join(l))

Fixed submission:
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=(-ord(s[i])+ord("z")+1)%26
  if f<=k:
    l[i]="a"
    k-=f

k=k%26
a=ord(l[-1])+k 
if a> ord("z"):a-=26
l[-1]=chr(a)
print("".join(l))

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=-ord(s[i])+ord("z")+1
  if f<=k:
    l[i]="a"
    k-=f
l[-1]=chr(ord(s[-1])+k)
print("".join(l))

Fixed submission:
s=input()
k=int(input())
l=list(s)

for i in range(len(s)):
  f=(-ord(s[i])+ord("z")+1)%26
  if f<=k:
    l[i]="a"
    k-=f

k=k%26
a=ord(l[-1])+k 
if a> ord("z"):a-=26
l[-1]=chr(a)
print("".join(l))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
curr = 7
for i in range(k):
  if curr%k:
    curr *= 10
    curr += 7
  else:
    print(i+1)
    break
else:
  print(-1)

Fixed submission:
k = int(input())
curr = 7
for i in range(k):
  if curr%k:
    curr *= 10
    curr += 7
    curr %= k
  else:
    print(i+1)
    break
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
curr = 7
for i in range(k):
  if curr%k:
    curr *= 10
    curr += 7
  else:
    print(i+1)
	break
else:
  print(-1)

Fixed submission:
k = int(input())
curr = 7
for i in range(k):
  if curr%k:
    curr *= 10
    curr += 7
    curr %= k
  else:
    print(i+1)
    break
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
from functools import reduce
n, k = map(int,input().split())
a = list(map(int,input().split()))
prod = reduce(lambda x,y: x*y ,a[:k])
ans = []
for i in range(k,n):
    prodt = (prod/a[i-k])*a[i]
    if prodt>prod:
        ans.append('Yes')
    else:
        ans.append('No')
    prod = prodt
ans = '\n'.join(ans)
print(ans)

Fixed submission:
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
from functools import reduce
n, k = map(int,input().split())
a = list(map(int,input().split()))
prod = a[0]
ans = []
for i in range(k,n):
    prod = a[i-k]
    prodt = a[i]
    if prodt>prod:
        ans.append('Yes')
    else:
        ans.append('No')
ans = '\n'.join(ans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
input = stdin.readline
def nCr(n,r):
    return fact[n]*(inv[n-r]%M)*(inv[r]%M)
M = 1000000007
k = int(input())
s = len(input().strip())
t = k+s
fact = [1]
p25 = [1]
for i in range(1,t+1):
    fact += [(fact[-1] * i)%M]
    if i<=k:
        p25  += [(p25[-1] * 25) % M]

inv = [1]*(t+1)
inv[t] = pow(fact[t], M-2, M)
for i in range(t-1, -1, -1):
    inv[i] = inv[i+1] * (i+1) % M


res = 0
for i in range(k+1):
    res+=nCr(t,t-i)*p25[i]
    res%=M
print(res)

Fixed submission:
def nCr(n,r):
    return fact[n]*(inv[n-r]%M)*(inv[r]%M)
M = 1000000007
k = int(input())
s = len(input())
t = k+s
fact = [1]
p25 = [1]
for i in range(1,t+1):
    fact += [(fact[-1] * i)%M]
    if i<=k:
        p25  += [(p25[-1] * 25) % M]

inv = [1]*(t+1)
inv[t] = pow(fact[t], M-2, M)
for i in range(t-1, -1, -1):
    inv[i] = inv[i+1] * (i+1) % M


res = 0
for i in range(k+1):
    #print(nCr(t,t-i))
    res+=nCr(t,t-i)*p25[i]
    #print(res)
    res%=M
    #print(res)
print(res)