Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
RGB=[0,0,0]
for i in range(N):
  if S[i]=="R":
    RGB[0]+=1
  if S[i]=="G":
    RGB[1]+=1
  if S[i]=="B":
    RGB[2]+=1
ans=RGB[0]*RGB[1]*RGB[2]    
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    t=k+k-i
    if s1==s2:
      continue
    if t<=N-1:
      s3=S[t]
      if s3!=s1 and s3!=s2:
        ans-=1      
print(ans)        

Fixed submission:
N=int(input())
S=input()
ans=0
RGB=[0,0,0]
for i in range(N):
  if S[i]=="R":
    RGB[0]+=1
  if S[i]=="G":
    RGB[1]+=1
  if S[i]=="B":
    RGB[2]+=1
ans=RGB[0]*RGB[1]*RGB[2]    
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    t=k+k-i
    if s1==s2:
      continue
    if t<=N-1:
      s3=S[t]
      if s3!=s1 and s3!=s2:
        ans-=1      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    for t in range(k+1,N):
      s3=S[t]
      if s1==s2:
        break
      if s3==s1 or s3==s2:
        continue
      elif t-k != k-i:
        ans+=1
print(ans)        

Fixed submission:
N=int(input())
S=input()
ans=0
RGB=[0,0,0]
for i in range(N):
  if S[i]=="R":
    RGB[0]+=1
  if S[i]=="G":
    RGB[1]+=1
  if S[i]=="B":
    RGB[2]+=1
ans=RGB[0]*RGB[1]*RGB[2]    
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    t=k+k-i
    if s1==s2:
      continue
    if t<=N-1:
      s3=S[t]
      if s3!=s1 and s3!=s2:
        ans-=1      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
ans=0
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]    
    for t in range(k+1,N):
      s3=S[t]
      if s1==s2:
        break
      if s3==s1 or s3==s2:
        continue
      elif t-k != k-i:
        ans+=1
print(ans)        

Fixed submission:
N=int(input())
S=input()
ans=0
RGB=[0,0,0]
for i in range(N):
  if S[i]=="R":
    RGB[0]+=1
  if S[i]=="G":
    RGB[1]+=1
  if S[i]=="B":
    RGB[2]+=1
ans=RGB[0]*RGB[1]*RGB[2]    
for i in range(N-2):
  s1=S[i]
  for k in range(i+1,N-1):
    s2=S[k]
    t=k+k-i
    if s1==s2:
      continue
    if t<=N-1:
      s3=S[t]
      if s3!=s1 and s3!=s2:
        ans-=1      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    S.reverse()
  else:
    if A[1]=="1":
      S.appendleft(A[2])
    else:
      S.append(A[2])
ans="".join(S)
print(ans)

Fixed submission:
from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    count=(count+1)%2
  else:
    if A[1]=="1":
      if count==0:
        S.appendleft(A[2])
      else:
        S.append(A[2])
    else:
      if count==0:
        S.append(A[2])
      else:
        S.appendleft(A[2])
if count==1:
  S.reverse()
ans="".join(S)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    S.reverse()
  else:
    if A[1]=="1":
      S.appendleft(A[2])
    else:
      S.append(A[2])
ans="".join(S)
print(ans)

Fixed submission:
from collections import deque
S=deque(list(input()))
Q=int(input())
count=0
for i in range(Q):
  A=list(input().split())
  if A[0]=="1":
    count=(count+1)%2
  else:
    if A[1]=="1":
      if count==0:
        S.appendleft(A[2])
      else:
        S.append(A[2])
    else:
      if count==0:
        S.append(A[2])
      else:
        S.appendleft(A[2])
if count==1:
  S.reverse()
ans="".join(S)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS=Counter(listS).most_common()
ans=[]
MAX=listS[0][1]
for i in range(N):
  if listS[i][1]==MAX:
    ans+=[listS[i][0]]
  else:
    break   
ans.sort()
for i in ans:
  print(i)

Fixed submission:
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
MAX=max(counter)

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
    if count==MAX:
      print(listS[i+1])
  else:
    counter+=[count]
    count=1

Fixed submission:
N=int(input())
listS=[]
for i in range(N):
  S=input()
  listS+=[S]
listS.sort()
counter=[]
count=1
for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    counter+=[count]
    count=1
    
counter+=[count]    
MAX=max(counter)
count=1

for i in range(N-1):
  if listS[i]==listS[i+1]:
    count+=1
  else:
    count=1
  if count==MAX:
    print(listS[i])
    
if MAX==1:
  print(listS[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
ans=1
for i in range(1,N):
  MIN=min(P[0:i])
  if MIN>=P[i]:
    ans+=1
print(ans)    

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
ans=0
MIN=10**6
for i in range(N):
  MIN=min(MIN,P[i])
  if MIN>=P[i]:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
prime=[2]
for i in range(3,10**5+10**4):
  for k in prime:
    if i%k==0:
      break
    if k==prime[-1]:
      prime+=[i]
for i in prime:
  if i>=X:
    ans=i
    break
print(ans)    

Fixed submission:
X=int(input())
prime=[2]
for i in range(3,10**5+10**4):
  for k in prime:
    if i%k==0:
      break
    if k==prime[-1]:
      prime+=[i]
for i in prime:
  if i>=X:
    ans=i
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)+1
LEFT=[0]
RIGHT=[0]
left=0
right=0
for i in range(N-1):
  if S[i]==">":
    left=0
  else:
    left+=1
  LEFT+=[left]
for i in range(N-2,-1,-1):
  if S[i]=="<":
    right=0
  else:
    right+=1
  RIGHT=[right]+RIGHT
ans=0  
for i in range(N):  
  ans+=max(LEFT[i],RIGHT[i])
print(ans)  

Fixed submission:
import itertools
S=input()
N=len(S)+1
ans=0
KEY=[]
gr=itertools.groupby(list(S))
i=0
for key,group in gr:
  n=len(list(group))
  ans+=n*(n+1)//2
  KEY+=[n]
  if key==">" and i!=0:
    ans-=min(KEY[i-1],KEY[i])
  i+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
N=len(S)+1
LEFT=[0]
RIGHT=[0]
left=0
right=0
for i in range(N-1):
  if S[i]==">":
    left=0
  else:
    left+=1
  LEFT+=[left]
for i in range(N-2,-1,-1):
  if S[i]=="<":
    right=0
  else:
    right+=1
  RIGHT.insert(0,right)
ans=0  
for i in range(N):  
  ans+=max(LEFT[i],RIGHT[i])
print(ans)  

Fixed submission:
import itertools
S=input()
N=len(S)+1
ans=0
KEY=[]
gr=itertools.groupby(list(S))
i=0
for key,group in gr:
  n=len(list(group))
  ans+=n*(n+1)//2
  KEY+=[n]
  if key==">" and i!=0:
    ans-=min(KEY[i-1],KEY[i])
  i+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect, bisect_left
 
N= int(input())
L= list(map(int,input().split()))
L.sort()
 
ans = 0
for i in range(N-2):
  a=L[i]
  for k in range(i+1,n-1):
    b=s[k]
    t=bisect_left(L,a+b)
    ans+=t-k-1
print(ans)

Fixed submission:
from bisect import bisect, bisect_left
 
N=int(input())
L=list(map(int,input().split()))
L.sort()
 
ans = 0
for i in range(N-2):
  a=L[i]
  for k in range(i+1,N-1):
    b=L[k]
    t=bisect_left(L,a+b)
    ans+=t-k-1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
listL=list(map(int,input().split()))
listL.sort()
ans=0
for i in range(N-1,2,-1):
  for k in range(i-1,1,-1):
    t=math.ceil(k/2)
    d=listL[i]-listL[k]
    half=math.ceil((k-t)/4)
    while (d-listL[t]<=0 or d-listL[t+1]>0) and t!=0 and t!=k-1:
      third=listL[t]
      if d-third>=0:
        t=t-half
      else:
        t=t+half
      half=half//2+1
      print(half,t) 
    ans+=k-t+1
print(ans)        

Fixed submission:
from bisect import bisect, bisect_left
 
N=int(input())
L=list(map(int,input().split()))
L.sort()
 
ans = 0
for i in range(N-2):
  a=L[i]
  for k in range(i+1,N-1):
    b=L[k]
    t=bisect_left(L,a+b)
    ans+=t-k-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
listL=list(map(int,input().split()))
listL.sort()
ans=0
for i in range(0,N-2):
  for k in range(i+1,N-1):
    for t in range(k+1,N):
      IF=listL[i]+listL[k]-listL[t]
      if IF>0:
        ans+=1
      else:
        break
print(ans)

Fixed submission:
from bisect import bisect, bisect_left
 
N=int(input())
L=list(map(int,input().split()))
L.sort()
 
ans = 0
for i in range(N-2):
  a=L[i]
  for k in range(i+1,N-1):
    b=L[k]
    t=bisect_left(L,a+b)
    ans+=t-k-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
listL=list(map(int,input().split()))
listL.sort()
ans=0
for i in range(0,N-2):
  for k in range(i+1,N-1):
    for t in range(k+1,N):
      IF=listL[i]+listL[k]-listL[t]
      if IF>0:
        ans+=1
      else:
        break
print(ans)

Fixed submission:
from bisect import bisect, bisect_left
 
N=int(input())
L=list(map(int,input().split()))
L.sort()
 
ans = 0
for i in range(N-2):
  a=L[i]
  for k in range(i+1,N-1):
    b=L[k]
    t=bisect_left(L,a+b)
    ans+=t-k-1
print(ans)
Buggy python submission (verdict: Runtime Error):
S=int(input())
x1=0
y1=0
y2=0
x3=0
S1=S**(1/2)
for i in range(int(S1)+1,0,-1):
  if int((S/i)**2)==(S//i)**2:
    ans=i
    break
x2=ans
y3=S//ans
print(x1,y1,x2,y2,x3,y3)

Fixed submission:
S=int(input())
x1=0
y1=0
x2=10**9
y2=1
x3=10**9-S%(10**9)
y3=S//(10**9)+1
if S!=10**18:
  print(x1,y1,x2,y2,x3,y3)
else:
  y3=10**9
  x3=0
  print(x1,y1,x2,y2,x3,y3)

Buggy python submission (verdict: Runtime Error):
S=int(input())
x1=0
y1=0
y2=0
x3=0
S1=S**(1/2)
print(S1)
for i in range(int(S1)+1,0,-1):
  if (S/i)**2==(S//i)**2:
    ans=i
    break
x2=ans
y3=S//ans
print(x1,y1,x2,y2,x3,y3)

Fixed submission:
S=int(input())
x1=0
y1=0
x2=10**9
y2=1
x3=10**9-S%(10**9)
y3=S//(10**9)+1
if S!=10**18:
  print(x1,y1,x2,y2,x3,y3)
else:
  y3=10**9
  x3=0
  print(x1,y1,x2,y2,x3,y3)
Buggy python submission (verdict: Runtime Error):
import itertools
L,R=map(int,input().split())
if R-L>=2019:
  print(0)
else:
  MIN=2018  
  list1=list(range(L,R+1))
  list2=list(itertools.combinations(list1,2))
  for i in range(len(list2)):
    a=list2[i][0]*list2[i][1]%2019
    MIN=min(MIN,a)
print(MIN)    

Fixed submission:
import itertools
L,R=map(int,input().split())
if R-L>=2019:
  print(0)
else:
  MIN=2018  
  list1=list(range(L,R+1))
  list2=list(itertools.combinations(list1,2))
  for i in range(len(list2)):
    a=list2[i][0]*list2[i][1]%2019
    MIN=min(MIN,a)
  print(MIN)
Buggy python submission (verdict: Runtime Error):
S=input()
list1=list(S)
if list1[0]==list1[2]==list1[3]==list1[4]:
  print("No")
else:
  if list1[0]==list1[1] and list1[2]==list1[3]:
    print("Yes")
  elif list1[0]==list1[2] and list1[1]==list1[3]:
    print("Yes")
  elif list1[0]==list1[3] and list1[1]==list1[2]:
    print("Yes")
  else:
    print("No")

Fixed submission:
S=input()
list1=list(S)
if list1[0]==list1[1]==list1[2]==list1[3]:
  print("No")
else:
  if list1[0]==list1[1] and list1[2]==list1[3]:
    print("Yes")
  elif list1[0]==list1[2] and list1[1]==list1[3]:
    print("Yes")
  elif list1[0]==list1[3] and list1[1]==list1[2]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
N,K=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(K):
  ans=combinations_count(N-K+1,i+1)*combinations_count(K-1,i)
  ANS=ans%(10**9+7)
  print(ANS)

Fixed submission:
import math
N,K=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(K):
  if N-K>i:
    ans=combinations_count(N-K+1,i+1)*combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  elif N-K==i:
    ans=combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import math
N,K=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(K):
  ans=combinations_count(N-K+1,i+1)*combinations_count(K-1,i)
  print(ans%(10**9+7))

Fixed submission:
import math
N,K=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(K):
  if N-K>i:
    ans=combinations_count(N-K+1,i+1)*combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  elif N-K==i:
    ans=combinations_count(K-1,i)
    ANS=ans%(10**9+7)
    print(ANS)
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N,map(int,input().split())
if L>=0:
  print((N-1)*(L-1)+int(N*(N+1)/2)-1)
else:
  if L+N>=0:
    print(N*(L-1)+int(N*(N+1)/2))
  else:
    print(N*(L-1)+int(N*(N+1)/2)-(L+N-1))

Fixed submission:
N,L=map(int,input().split())
if L>=0:
  print((N-1)*(L-1)+int(N*(N+1)/2)-1)
else:
  if L+N>0:
    print(N*(L-1)+int(N*(N+1)/2))
  else:
    print(N*(L-1)+int(N*(N+1)/2)-(L+N-1))
Buggy python submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())
setAB=set(range(A,B+1))
setC=range(A,B+1,C)
setD=range(A,B+1,D)
setCD=set(setC+setD)
ans=len(setAB)-len(setCD)
print(ans)

Fixed submission:
import fractions
A,B,C,D=map(int,input().split())
listA=range(A)
listB=range(B+1)
listC=range(0,B+1,C)
listAC=range(0,A,C)
listD=range(0,B+1,D)
listAD=range(0,A,D)
listCD=range(0,B+1,C*D//fractions.gcd(C,D))
listACD=range(0,A,C*D//fractions.gcd(C,D))
lenA=len(listA)
lenB=len(listB)
lenC=len(listC)
lenAC=len(listAC)
lenD=len(listD)
lenAD=len(listAD)
lenCD=len(listCD)
lenACD=len(listACD)
ans=lenB-lenA-lenC+lenAC-lenD+lenAD+lenCD-lenACD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D=map(int,input().split())
ans=0
for i in range(A,B+1):
  if i%C!=0 and i%D!=0:
    ans+=1
print(ans)    

Fixed submission:
import fractions
A,B,C,D=map(int,input().split())
listA=range(A)
listB=range(B+1)
listC=range(0,B+1,C)
listAC=range(0,A,C)
listD=range(0,B+1,D)
listAD=range(0,A,D)
listCD=range(0,B+1,C*D//fractions.gcd(C,D))
listACD=range(0,A,C*D//fractions.gcd(C,D))
lenA=len(listA)
lenB=len(listB)
lenC=len(listC)
lenAC=len(listAC)
lenD=len(listD)
lenAD=len(listAD)
lenCD=len(listCD)
lenACD=len(listACD)
ans=lenB-lenA-lenC+lenAC-lenD+lenAD+lenCD-lenACD
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
listA=list(map(int,input().split()))
listB=[abs(i) for i in listA]
MAX=max(listA)
MIN=min(listA)
listD=heapq.nsmallest(2,listA)
ans=sum(listB)
if MAX<=0:
  print(ans+MAX)
elif MIN<=0:
  print(ans)   
else:
  print(ans-MIN*2)
listC=sorted(listA)  
for i in range(len(listA)-2):
  if listC[i+1]>=0:
    print(MIN,listC[i+1])
    MIN=MIN-listC[i+1]
  else:
    print(MAX,listC[i+1])
    MAX=MAX-listC[i+1]
print(MAX,MIN)

Fixed submission:
N=int(input())
listA=list(map(int,input().split()))
listB=[abs(i) for i in listA]
MAX=max(listA)
MIN=min(listA)
ans=sum(listB)
if MAX<=0:
  print(ans+MAX*2)
elif MIN<=0:
  print(ans)   
else:
  print(ans-MIN*2)
listC=sorted(listA)  
for i in range(len(listA)-2):
  if listC[i+1]>=0:
    print(MIN,listC[i+1])
    MIN=MIN-listC[i+1]
  else:
    print(MAX,listC[i+1])
    MAX=MAX-listC[i+1]
print(MAX,MIN)
Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
for i in range(1,N):
  if listA[i-1][0]!=listA[i][0]:
    listN=listA[before:i]
    listN.sort(key=itemgetter(1),reverse=True)
    listANS+=listN
    before=i

  if i==N-1:
    listN=listA[before:N]
    listN.sort(key=itemgetter(1),reverse=True)
    listANS+=listN

for i in range(N):
  print(listANS[i][2])

Fixed submission:
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
if N!=1:
  for i in range(1,N):
    if listA[i-1][0]!=listA[i][0]:
      listN=listA[before:i]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
      before=i
 
    if i==N-1:
      listN=listA[before:N]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
else:
  listANS=listA
for i in range(N):
  print(listANS[i][2])

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
print(listA)
before=0
for i in range(1,N):
  if listA[i-1][0]!=listA[i][0]:
    listN=listA[before:i]
    listN.sort(key=itemgetter(1),reverse=True)
    listANS+=listN
    before=i

  if i==N-1:
    listN=listA[before:N]
    listN.sort(key=itemgetter(1),reverse=True)
    listANS+=listN

for i in range(N):
  print(listANS[i][2])

Fixed submission:
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
if N!=1:
  for i in range(1,N):
    if listA[i-1][0]!=listA[i][0]:
      listN=listA[before:i]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
      before=i
 
    if i==N-1:
      listN=listA[before:N]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
else:
  listANS=listA
for i in range(N):
  print(listANS[i][2])

Buggy python submission (verdict: Runtime Error):
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
for i in range(1,N):
  before=0
  if listA[i-1][0]!=listA[i][0] or i==N-1:
    listN=listA[before:i+1]
    listN.sort(key=itemgetter(1),reverse=True)
    listANS+=listN
    before=i
for i in range(N):
  print(listANS[i][2])

Fixed submission:
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
if N!=1:
  for i in range(1,N):
    if listA[i-1][0]!=listA[i][0]:
      listN=listA[before:i]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
      before=i
 
    if i==N-1:
      listN=listA[before:N]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
else:
  listANS=listA
for i in range(N):
  print(listANS[i][2])
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(){
  int A,B;
  cin >>A>>B;
  if (A>=13){
    cout <<B;
  }  
  else if (A>=6){
    cout <<B/2;
  }  
  else{
    cout <<0;
  }
}  

Fixed submission:
A,B=map(int,input().split())
if A>=13:
  print(B)
if 6<=A<13:
  print(int(B/2))
if A<=5:
  print(0)
Buggy python submission (verdict: Runtime Error):
print(N-K+1)

Fixed submission:
N,K=map(int,input().split())
print(N-K+1)
Buggy python submission (verdict: Runtime Error):
ABCDE=[]
modABCDE=[]
for i in range(5):
  ABCDE+=[int(input())]
  if ABCDE[i]%10!=0:
    modABCDE+=[ABCDE[i]%10]  
MIN=min(modABCDE)
ans=sum(ABCDE)-sum(modABCDE)+(len(modABCDE)-1)*10+MIN
print(ans)

Fixed submission:
ABCDE=[]
modABCDE=[]
for i in range(5):
  ABCDE+=[int(input())]
  if ABCDE[i]%10!=0:
    modABCDE+=[ABCDE[i]%10]  
if modABCDE!=[]:
  MIN=min(modABCDE)
else:
  MIN=10  
ans=sum(ABCDE)-sum(modABCDE)+(len(modABCDE)-1)*10+MIN
print(ans)
Buggy python submission (verdict: Runtime Error):
N,Q=map(int,input().split())
S=input()
listS=list(S)
ans=0
listAC=[ans]
for k in range(1,N+1):
  if listS[k-1]=="A" and listS[k]=="C":
    ans+=1
  listAC+=[ans]  
for i in range(Q):
  l,r=map(int,input().split())
  ans=listAC[r-1]-listAC[l-1] 
  print(ans)    

Fixed submission:
N,Q=map(int,input().split())
S=input()
listS=list(S)
ans=0
listAC=[ans]
for k in range(1,N):
  if listS[k-1]=="A" and listS[k]=="C":
    ans+=1
  listAC+=[ans]  
for i in range(Q):
  l,r=map(int,input().split())
  ans=listAC[r-1]-listAC[l-1] 
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,Q=map(int,input().split())
S=input()
listS=list(S)
for i in range(Q):
  l,r=map(int,input().split())
  ans=0
  for k in range(l,r):
    if listS[k-1]=="A" and listS[k]=="C":
      ans+=1
  print(ans)

Fixed submission:
N,Q=map(int,input().split())
S=input()
listS=list(S)
ans=0
listAC=[ans]
for k in range(1,N):
  if listS[k-1]=="A" and listS[k]=="C":
    ans+=1
  listAC+=[ans]  
for i in range(Q):
  l,r=map(int,input().split())
  ans=listAC[r-1]-listAC[l-1] 
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
h=list(map(int,input().split()))

cost=[10**9]*n
cost[0]=0
for i in range(1,n):
  for j in range(1,min(i+1,k+1)):
    cost[i]=min(cost[i],cost[i-j]+abs(h[i]-h[i-j]))
print(cost[-1])

Fixed submission:
N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=[10**9]*N
cost[0]=0
for i in range(1,N):
  for k in range(1,K+1):
    if i-k>=0:
      cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[N-1]      
print(ans)

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

cost=[0]*n
for i in range(1,n):
  cost[i]=min( [cost[i-j]+abs(h[i]-h[i-j]) for j in range(1,min(i+1,k+1))] )
print(cost[-1])

Fixed submission:
N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=[10**9]*N
cost[0]=0
for i in range(1,N):
  for k in range(1,K+1):
    if i-k>=0:
      cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[N-1]      
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,W=map(int,input().split())
listN=[[0 for i in range(W+1)] for k in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for k in range(1,W+1):
    if k>=w:
      listN[i+1][k]=max(listN[i][k],listN[i][k-w]+v)
    else:
      listN[i+1][k]=listN[i][k]     
ans=listN[N][W]
print(ans)

Fixed submission:
N,W=map(int,input().split())
listN=[[0 for i in range(W+1)] for k in range(N+1)]
for i in range(N):
  w,v=map(int,input().split())
  for k in range(1,W+1):
    if k>=w:
      listN[i+1][k]=max(listN[i][k],listN[i][k-w]+v)
    else:
      listN[i+1][k]=listN[i][k]     
ans=listN[N][W]
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
N,K=map(int,input().split())
L=range(1,N+1)
T=0
for i in itertools.permutations(L, r=3):
  int(a,b,c) for a,b,c in i:
    if a+b%K==0 and b+c%K==0 and c+a%K==0:
      T+=1
print(T) 

Fixed submission:
N,K=map(int,input().split())
if K%2==0:
  a=N//(K//2)
  b=N//K
  c=a-b
  ans=b**3+c**3
  print(ans)
else:
  a=N//K
  ans=a**3
  print(ans)
Buggy python submission (verdict: Runtime Error):
N,M,X=map(int,input().split())
listA=list(map(int,input().split()))
for i in range(M-1):
  if listA[i]<X<listA[i+1]:
    ans=min(i+1,M-i-1)
  elif listA[i]==0:
    ans=min(i,M-i-1)
print(ans)

Fixed submission:
N,M,X=map(int,input().split())
listA=list(map(int,input().split()))
for i in range(M-1):
  if listA[i]<X<listA[i+1]:
    ans=min(i+1,M-i-1)
  elif listA[i]==0:
    ans=min(i,M-i-1)
if X<listA[0] or listA[M-1]<X:
  ans=0
print(ans)
Buggy python submission (verdict: Runtime Error):
list1=[map(str,input().split())]
if set(list1)==[a,b,c]:
  print(Yes)
else:
  print(No)

Fixed submission:
list1=list(input())
if set(list1)=={"a","b","c"}:
  print("Yes")
else:
  print("No")