Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  y=x%k
z=k-y
if z >=y:
  print(y)
else:
  print(z)
  

Fixed submission:
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  x=x%k
z=abs(k-x)
if z >=x:
  print(x)
else:
  print(z)

Buggy python submission (verdict: Time Limit Exceeded):
list=list(map(int,input().split()))
x=list[0]
k=list[1]
y=abs(x-k)
while y>=k:
  y=abs(y-k)
z=k-y
if z >=y:
  print(y)
else:
  print(z)
  

Fixed submission:
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  x=x%k
z=abs(k-x)
if z >=x:
  print(x)
else:
  print(z)

Buggy python submission (verdict: Runtime Error):
list=list(map(int,input().split()))
k=list[1]
y=max(list)%min(list)
z=k-y
if z >=y:
  print(y)
else:
  print(z)
  

Fixed submission:
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  x=x%k
z=abs(k-x)
if z >=x:
  print(x)
else:
  print(z)

Buggy python submission (verdict: Time Limit Exceeded):
list=list(map(int,input().split()))
x=list[0]
k=list[1]
y=abs(x-k)
while y>=k:
  y=abs(y-k)
z=k-y
if z >=y:
  print(y)
else:
  print(z)
  

Fixed submission:
list=list(map(int,input().split()))
x=list[0]
k=list[1]
if list[0]>=list[1]:
  x=x%k
z=abs(k-x)
if z >=x:
  print(x)
else:
  print(z)
Buggy python submission (verdict: Runtime Error):
from collections import deque
a=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k=a:
    s=q.popleft()
    if s-1>=0:
      q.aapend(s*10+s-1)
      n=n+1
    q.append(s*10+s)
    k=k+1
    if s+1<=9:
      q.append(s*10+s+1)
      k=k+1
  print(q.pop())
 
if a<=9:
  print(a)
else:
  dfs(9)

Fixed submission:
from collections import deque
a=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k<=a:
    s=q.popleft()
    if s%10-1>=0:
      q.append(s*10+s%10-1)
      k=k+1
      if k==a:
        print(q.pop())
    q.append(s*10+s%10)
    k=k+1
    if k==a:
        print(q.pop())
    if s%10+1<=9:
      q.append(s*10+s%10+1)
      k=k+1
      if k==a:
        print(q.pop())
  
 
if a<=9:
  print(a)
else:
  dfs(9)

Buggy python submission (verdict: Runtime Error):
from collections import deque
a=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k=a:
    s=q.popleft()
    if s-1>=0:
      q.aapend(s*10+s-1)
      n=n+1
    q.append(s*10+s)
    k=k+1
    if s+1<=9:
      q.append(s*10+s+1)
      k=k+1
  print(q.pop())

if a<=9:
  print(a)
else:
  dfs(9)
  
    
  
  

Fixed submission:
from collections import deque
a=int(input())
q=deque([1,2,3,4,5,6,7,8,9])
def dfs(k):
  while k<=a:
    s=q.popleft()
    if s%10-1>=0:
      q.append(s*10+s%10-1)
      k=k+1
      if k==a:
        print(q.pop())
    q.append(s*10+s%10)
    k=k+1
    if k==a:
        print(q.pop())
    if s%10+1<=9:
      q.append(s*10+s%10+1)
      k=k+1
      if k==a:
        print(q.pop())
  
 
if a<=9:
  print(a)
else:
  dfs(9)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def min_distance(i,j):
    return min(abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))
               
n,x,y=list(map(int,input().split()))
x=x-1
y=y-1
dp=[]
for i in range(n):
    for j in range(n):
        dp.append(min_distance(i,j))
dic=Counter(dp)
for i in range(1,n):
    print(int(dic[i]/2))
    
        
     

Fixed submission:
from collections import Counter
def min_distance(i,j):
    return min(abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))
               
n,x,y=list(map(int,input().split()))
x=x-1
y=y-1
dp=[]
for i in range(n-1):
    for j in range(i+1,n):
        dp.append(min_distance(i,j))
dic=Counter(dp)
for i in range(1,n):
    print(int(dic[i]))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from collections import Counter
#入力
n,x,y=list(map(int,input().split()))
x=x-1
y=y-1
#幅優先探索　i番目いけるdp
def bfs(i):
    dp=[float("INF")]*n
    q=deque([i])
    dp[i]=0
    while len(q)>0:
        p=q.popleft()
        if 0<=p-1<=n-1 and dp[p]+1<dp[p-1]:
            dp[p-1]=dp[p]+1
            q.append(p-1)
        if 0<=p+1<=n-1 and dp[p]+1<dp[p+1]:
            dp[p+1]=dp[p]+1
            q.append(p+1)
        if  p==x and dp[p]+1<=dp[y]:
            dp[y]=dp[p]+1
            q.append(y)
        if  p==y and dp[p]+1<=dp[x]:
            dp[x]=dp[p]+1
            q.append(x)
    return Counter(dp)
 
answer_list={}
answer_list=Counter(answer_list)
for i in range(n):
    answer_list=answer_list+bfs(i)
for i in range(1,n):
    print(int(answer_list[i]/2))
    
    

Fixed submission:
from collections import Counter
def min_distance(i,j):
    return min(abs(i-j),abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j))
               
n,x,y=list(map(int,input().split()))
x=x-1
y=y-1
dp=[]
for i in range(n-1):
    for j in range(i+1,n):
        dp.append(min_distance(i,j))
dic=Counter(dp)
for i in range(1,n):
    print(int(dic[i]))
Buggy python submission (verdict: Runtime Error):
X,Y,A,B,C=list(map(int,input().split()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
kouho=p[:X]+q[:Y]
kouho.sort()
for i in range(C):
    kouho[i]=max(kouho[i],r[i])
print(sum(kouho))



Fixed submission:
X,Y,A,B,C=list(map(int,input().split()))
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
kouho=p[:X]+q[:Y]
kouho.sort()
for i in range(min(C,X+Y)):
    kouho[i]=max(kouho[i],r[i])
print(sum(kouho))
Buggy python submission (verdict: Runtime Error):
print((L**3)/27)

Fixed submission:
L=int(input())
print((L**3)/27)
Buggy python submission (verdict: Runtime Error):
a,b=list(map(float,input().split()))
import sys
for i in range(100000):
  if int(i*8/100)==a and int(i*10/100)==b:
    print(i)
    sys.exit()
print(-1)

  
  

Fixed submission:
s=list(input())
if ("A" not in s) or ("B" not in s):
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
s=list(input())
if (A not in s) or (B not in s):
  print("No")
else:
  print("Yse")

Fixed submission:
s=list(input())
if ("A" not in s) or ("B" not in s):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and (ans[0]==0　or ans[0]==-1)
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

  

Fixed submission:
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and (ans[0]==0 or ans[0]==-1):
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and ans[0]==0　or ans[0]==-1
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

  

Fixed submission:
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and (ans[0]==0 or ans[0]==-1):
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and ans[0]==0　or -1
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))

  

Fixed submission:
import sys
n,m=list(map(int,input().split()))
ans=[-1 for i in range(n)]

for i in range(m):
  s,c=list(map(int,input().split()))
  if n!=1 and s==1 and c==0:
    print(-1)
    sys.exit()
  if ans[s-1]==-1 or ans[s-1]==c:
    ans[s-1]=c
  else:
    print(-1)
    sys.exit()

    
if n==1 and (ans[0]==0 or ans[0]==-1):
  print(0)
  sys.exit()
if ans[0]==-1:
  ans[0]=1
for i in range(1,n):
  if ans[i]==-1:
    ans[i]=0
ans=map(str, ans)
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求めればいい。ただし100000007で割ったあまりでなくてはならない
#まずは2^nを求める
def pow(x,n,m):
  if n==0:
    return 1
  res=pow(x*x%m,n//2,m)
  if n%2==1:
    res=res*x%m
  return res
#コンビネーションを求める
fac=[0 for i in range(n+1)]
inv=[0 for i in range(n+1)]
finv=[0 for i in range(n+1)]
fac[0]=1
fac[1]=1
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,n+1):
  fac[i]=fac[i-1]*i%1000000007
  #iの逆数を求める。
  #mod　p=1000000007の世界で逆元を求める
  #p=(p//a)*a+(p%a)
  #mod pをとると a=-(p//a)*(p%a)^-1
  inv[i]=1000000007-(1000000007//i)*inv[1000000007%i]%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007
  
def combinations(n,k):
  return fac[n]*finv[k]*finv[n-k]%1000000007

print(pow(2,n,1000000007)-combinations(n,a)-combinations(n,b)-1)

  
  
  


Fixed submission:
n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求めればいい。ただし100000007で割ったあまりでなくてはならない
#まずは2^nを求める
def pow(x,n,m):
  if n==0:
    return 1
  res=pow(x*x%m,n//2,m)
  if n%2==1:
    res=res*x%m
  return res

#コンビネーションを求める
c=max(a,b)
inv=[0 for i in range(c+1)]
finv=[0 for i in range(c+1)]
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,c+1):
  #iの逆数を求める。
  #mod　p=1000000007の世界で逆元を求める
  #p=(p//a)*a+(p%a)
  #mod pをとると a=-(p//a)*(p%a)^-1
  inv[i]=1000000007-(1000000007//i)*inv[1000000007%i]%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007
def kaizyou(k):
  num=1
  for i in range(n-k+1,n+1):
    num=num*i%1000000007
  return num

def combinations(k):
  return kaizyou(k)*finv[k]%1000000007

print((pow(2,n,1000000007)-combinations(a)-combinations(b)-1)%1000000007)
Buggy python submission (verdict: Runtime Error):
k=list(map(int,input().split())))
from collections import Counter
l=Counter(k)
if len(l)==2:
  print("Yes")
else:
  print("No")
  
  

Fixed submission:
k=list(map(int,input().split()))
from collections import Counter
l=Counter(k)
if len(l)==2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s,t=list(input())
a,b=list(map(int,input().split()))
u=input()

if u==s:
  print(a-1)
else:
  print(b-1)

Fixed submission:
s,t=list(input().split())
a,b=list(map(int,input().split()))
u=input()
 
if u==s:
  print(str(a-1)+" "+str(b))
else:
  print(str(a)+" "+str(b-1))
Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=[]
for i in range(n):
  ans.append("x")
print("",join(ans))

Fixed submission:
s=input()
n=len(s)
ans=[]
for i in range(n):
  ans.append("x")
print("".join(ans))

Buggy python submission (verdict: Runtime Error):
s=input()
n=len(s)
ans=0
for i in range(n):
  ans.append("x")
print("",join(ans))


Fixed submission:
s=input()
n=len(s)
ans=[]
for i in range(n):
  ans.append("x")
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
  a_num,b_num=map(int,input().split())
  a.append(a_num)
  b.append(b_num)

#dpテーブル　dp[i+1][j]=i番目までの魔法を用いて体力をj以上減らす時の消耗の最小値
dp=[[float("INF") for i in range(h+1)] for j in range(n+1)]
#初期条件
dp[0][0]=0
for i in range(n):
  for j in range(h+1):
    #i番目の魔法を使わない時
    if a[i]>j:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+b[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i])

print(dp[n][h])
  

Fixed submission:
h,n=list(map(int,input().split()))
a=[]
b=[]
for i in range(n):
  a_num,b_num=map(int,input().split())
  a.append(a_num)
  b.append(b_num)

#dpテーブル　dp[i+1][j]=i番目までの魔法を用いて体力をj以上減らす時の消耗の最小値
dp=[[float("INF") for i in range(h+1)] for j in range(n+1)]
#初期条件
dp[0][0]=0
for i in range(n):
  for j in range(h+1):
    #i番目の魔法を使わない時
    if a[i]>j:
      dp[i+1][j]=min(dp[i][j],dp[i+1][0]+b[i])
    else:
      dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i])

print(dp[n][h])
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
if n%2!=0:
  print("No")
else:
  if s[:int(n/2)]==s[int(n/2):]:
    print("Yes")
  else:
    print("No")

Fixed submission:
a=int(input())
print(a*a)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
if n%2!=0:
  print("No")
else:
  if s[:int(n//2)]==s[int(n//2):]:
    print("Yes")
  else:
    print("No")

Fixed submission:
a=int(input())
print(a*a)

Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
if n%2!=0:
  print("No")
else:
  if s[:n//2]==s[n//2:]:
    print("Yes")
  else:
    print("No")

Fixed submission:
a=int(input())
print(a*a)

Buggy python submission (verdict: Runtime Error):
import math
def distance(x1,x2,y1,y2):
  d=math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d
count=int(input())
zahyou=[]
for i in range(count):
  a=input().split(" ")
  zahyou.append(a)

lenth=0
for i in zahyou:
  for j in zahyou:
    lenth=lenth+distance(int(i[0]),int(j[0]),int(i[1]),int(j[1]))
print(lenth/count)

Fixed submission:
a=int(input())
print(a*a)
Buggy python submission (verdict: Runtime Error):
n=input()
if n%2!=0:
  print("No")
else:
  if n[:n//2]==n[n//2:]:
    print("Yes")
  else:
    print("No")

Fixed submission:
a=int(input())
b=input()
if a%2 == 0:
  if b[:a//2]==b[a//2:]:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import math
a=int(input())
list=[]
for i in range(1,int(math.sqrt(a))+1):
  if a%i==0:
    list.append(i+int(a/i)-2)
b=min(list)
print(b)

Fixed submission:
a = input().split(" ")
if int(a[0]) <= 9 and int(a[1]) <= 9:
  print(int(a[0])*int(a[1]))
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
kuku=[]
for i in range(1,10):
  for j in range(1,10):
    kuku.append(i*j)
  
a=int(input())
if a in kuku:
  print("Yes")
else:
  print("No")
  

Fixed submission:
a = input().split(" ")
if int(a[0]) <= 9 and int(a[1]) <= 9:
  print(int(a[0])*int(a[1]))
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
a=int(input())
print(a*a)

Fixed submission:
a = input().split(" ")
if int(a[0]) <= 9 and int(a[1]) <= 9:
  print(int(a[0])*int(a[1]))
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=[0 for i in range(n)]

for i in range(n):
  ans[a[i]-1]=i+1
  
l=""  
for i in ans:
  l=l+str(i)+" "
  
  
print(l)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  dic[i+1]=a[i]
 
dic2 = sorted(dic.items(), key=lambda x:x[1])
 
ans=""
for i in dic2:
  print(i[0],end=" ")
  
  
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  dic[i+1]=a[i]

dic2 = sorted(dic.items(), key=lambda x:x[1])

ans=""
for i in dic2:
  ans=ans+str(i[0])+" "
  
  
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  dic[i+1]=a[i]
 
dic2 = sorted(dic.items(), key=lambda x:x[1])
 
ans=""
for i in dic2:
  print(i[0],end=" ")
  
  
  
print(ans)
Buggy python submission (verdict: Runtime Error):
s=list(input())
for i in range(len(s)):
  if i%2==0 and s[i]=="L":
    print("No")
    sys.exit()
  if i%2==1 and s[i]=="R":
    print("No")
    sys.exit()
print(Yes)

Fixed submission:
import sys
s=list(input())
for i in range(len(s)):
  if i%2==0 and s[i]=="L":
    print("No")
    sys.exit()
  if i%2==1 and s[i]=="R":
    print("No")
    sys.exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort(reverse=True)
a=a+[0]

i=0
while(1):
  while a[0]>=a[1]:
    a[0]=a[0]/2
    i=i+1
    if i==m:
      break
  if i==m:
    break
  a.sort(reverse=True)
 
ans=0
for i in range(n):
  ans=ans+int(a[i])
print(ans)

  

Fixed submission:
#リストの挿入と最大値の取得を同時に行う
#そのようなものを高速でできるデータ構造としてheapq(優先度つきqがあげられる)
#最大値を取得する関数はheapqには入ってないためリストの要素を-1倍してから最小値を求めればいい
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
a=list(map(lambda x:x*(-1),a))

import heapq
heapq.heapify(a)
for i in range(m):
  min_a=heapq.heappop(a)*(-1)
  heapq.heappush(a,min_a//2*(-1))
print(sum(a)*(-1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))

ans=[]
sum=0


for i in range(1,n):
  if h[i]<=h[i-1]:
    sum=sum+1
    ans.append(sum)
  else:
    sum=0
  

print(max(ans))


    
  

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

ans=[]
sum=0


for i in range(1,n):
  if h[i]<=h[i-1]:
    sum=sum+1
    ans.append(sum)
  else:
    sum=0
  
if len(ans)==0:
  print(0)
else:
  print(max(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
  sum=sum+1/a[i]
print(1/ans)



Fixed submission:
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
  sum=sum+1/a[i]
print(1/sum)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

s=[]
for i in range(n):
  read=list(input())
  read.sort()
  s.append(read)

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

print(ans)

  
  

Fixed submission:
n=int(input())
from collections import Counter
s=[]
for i in range(n):
  read=list(input())
  read.sort()
  s.append("".join(read))

ans=0
dic=Counter(s)
for i in dic:
  ans=ans+dic[i]*(dic[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
from collections import Counter
s=[]
for i in range(n):
  read=list(input())
  s.append(Counter(read))

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

print(ans)


Fixed submission:
n=int(input())
from collections import Counter
s=[]
for i in range(n):
  read=list(input())
  read.sort()
  s.append("".join(read))

ans=0
dic=Counter(s)
for i in dic:
  ans=ans+dic[i]*(dic[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
from collections import Counter
s=[]
for i in range(n):
  s.append(list(input()))

ans=0
for i in range(n-1):
  dic=Counter(s[i])
  for j in range(i+1,n):
    dic2=Counter(s[j])
    if dic==dic2:
      ans=ans+1

print(ans)

 

Fixed submission:
n=int(input())
from collections import Counter
s=[]
for i in range(n):
  read=list(input())
  read.sort()
  s.append("".join(read))

ans=0
dic=Counter(s)
for i in dic:
  ans=ans+dic[i]*(dic[i]-1)//2
print(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=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=ans+1
print(ans)
Buggy python submission (verdict: Runtime Error):
l,r=list(map(int,input().split()))
s=[]
if r-l>2050:
  print(0)
else:
  for i in range(l,r+1):
    s.append(i%2019)
  s.sort()
  print(s[0]*s[1])
  
  

Fixed submission:
s=list(input())
s=s+["R"]
n=len(s)-1
ans_list=[0 for i in range(n)]

flg_1=0
flg_2=0
start=0
for i in range(1,n+1):
  if s[i-1]=="R" and s[i]=="L":
    flg_1=i
  elif s[i-1]=="L" and s[i]=="R":
    flg_2=i
    if (flg_2-start)%2==0:
      if (flg_1-start)%2!=0:
        ans_list[flg_1-1]=(flg_2-start)//2
        ans_list[flg_1]=(flg_2-start)//2
      else:
        ans_list[flg_1-1]=(flg_2-start)//2
        ans_list[flg_1]=(flg_2-start)//2
    else:
      if (flg_1-start)%2!=0:
        ans_list[flg_1-1]=(flg_2-start)//2+1
        ans_list[flg_1]=(flg_2-start)//2
      else:
        ans_list[flg_1-1]=(flg_2-start)//2
        ans_list[flg_1]=(flg_2-start)//2+1
    start=i

for i in ans_list:
  print(str(i)+str(" "),end="")
Buggy python submission (verdict: Runtime Error):
r=int(input())
print(3*a*a)


Fixed submission:
r=int(input())
print(3*r*r)
Buggy python submission (verdict: Runtime Error):
n,k=list(map(int,input().split()))
l=[]
for i in range(n):
  l.append(k+i)
l.sort()
if max(l)=>0 and min(l)<=0:
  print(sum(l))
elif max(l)<0:
  print(sum(l)-l[n-1])
else:
  print(sum(l)-l[0])
  

Fixed submission:
n,k=list(map(int,input().split()))
l=[]
for i in range(n):
  l.append(k+i)
l.sort()
if max(l)>=0 and min(l)<=0:
  print(sum(l))
elif max(l)<0:
  print(sum(l)-l[n-1])
else:
  print(sum(l)-l[0])
Buggy python submission (verdict: Runtime Error):
n,m=list(map(int,input().split(" ")))
a=[]
for i in range(m):
  a.append(int(input()))
dp=[float("inf") for i in range(n)]
dp[0]=0
if 1 in a:
  dp[1]=0
else:
  dp[1]=1
for i in range(2,n):
  if (i-1 not in a)and(i-2 not in a):
    dp[i]=dp[i-1]+dp[i-2]
  elif (i-1 not in a)and(i-2 in a):
    dp[i]=dp[i-1]
  elif (i-1 in a)and(i-2 not in a):
    dp[i]=dp[i-2]
  else:
    dp[i]=0
print(n)

Fixed submission:
n,m=list(map(int,input().split(" ")))
a=[]
dp=[float("inf") for i in range(n+1)]
for i in range(m):
  a=int(input())
  dp[a]=0
dp[0]=1
if dp[1] != 0:
  dp[1]=1
for i in range(2,n+1):
  if dp[i]!=0:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)
Buggy python submission (verdict: Runtime Error):
if (a==0 and b==0) or (a>=13 and b>=13):
  print("NA")
elif 0<a<=12 and 0<a<=12:
  print("AMBIGUOUS")
elif 0<a<12:
  print("MMYY")
else:
  print("YYMM")
  
  

Fixed submission:
s=list(input())
s=list(map(int,s))

a=s[0]*10+s[1]
b=s[2]*10+s[3]

if (a==0 and b==0) or (a>=13 and b>=13) or (a==0 and b>=13) or (a>=13 and b==0):
  print("NA")
elif 0<a<=12 and 0<b<=12:
  print("AMBIGUOUS")
elif 0<a<=12:
  print("MMYY")
else:
  print("YYMM")
Buggy python submission (verdict: Runtime Error):
s=list(input())
n=len(s)
sum=0
ans=[]
check=["A","T","C","G"]
for i in range(n):
  if s[i] in check:
    sum=sum+1
  else:
    ans.append(sum)
    sum=0
print(max(ans))

Fixed submission:
s=list(input())
n=len(s)
sum=0
ans=0
check=["A","T","C","G"]
for i in range(n):
  if s[i] in check:
    sum=sum+1
  else:
    ans=max(ans,sum)
    sum=0
print(max(ans,sum))

Buggy python submission (verdict: Runtime Error):
s=list(input())
t=[]
for i in range(len(s)):
    if s[i]!="A" and s[i]!="C" and s[i]!="G"and s[i]!="T":
        t.append(i)
t=[-1]+t
u=[]
for i in range(len(t)-1):
    u.append(t[i+1]-t[i])
print(max(u)-1)
        
        
        

Fixed submission:
s=list(input())
n=len(s)
sum=0
ans=0
check=["A","T","C","G"]
for i in range(n):
  if s[i] in check:
    sum=sum+1
  else:
    ans=max(ans,sum)
    sum=0
print(max(ans,sum))
Buggy python submission (verdict: Runtime Error):
n,q=list(map(int,input().split()))
s=list(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int(input().split())))
A=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    A.append(1)
  else:
    A.append(0)
check=[0]+A
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]]-check[l[i]+1])

    
  

Fixed submission:
from itertools import accumulate
n,q=list(map(int,input().split()))
s=list(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
A=[]
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="C":
    A.append(1)
  else:
    A.append(0)
check=[0]+A+[0]
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-1]-check[l[i]-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
for i in range(n,m+1):
  if m%i==0:
    print(m//i)
    exit()
    

Fixed submission:
n,m=map(int,input().split())
for i in range(n,10**8):
  if m%i==0:
    print(m//i)
    exit()
print(1)