1This is the best online compler for python which I've used.
2Probably you will find it on the top of your search resluts too.
3
4https://www.programiz.com/python-programming/online-compiler/
1w3schools has another compiler option
2https://www.w3schools.com/python/trypython.asp?filename=demo_compiler
1from sys import stdin
2from collections import deque
3
4def beauty(n,m,s,x,y):
5 degree=[0 for i in range(n)]
6 graph={i:[] for i in range(n)}
7 for i in range(m):
8 x[i]-=1
9 y[i]-=1
10 graph[x[i]].append(y[i])
11 degree[y[i]]+=1
12 q=deque()
13 for i in range(n):
14 if degree[i]==0:
15 q.append(i)
16 count=0
17 ans=0
18 dp=[[0 for i in range(26)]for i in range(n)]
19 while count<n and q:
20 a=q.popleft()
21 count+=1
22 dp[a][ord(s[a])-97]+=1
23 for i in graph[a]:
24 for j in range(26):
25 dp[i][j]=max(dp[i][j],dp[a][j])
26 degree[i]-=1
27 if degree[i]==0:
28 q.append(i)
29 if count!=n:
30 return -1
31 else:
32 ans=0
33 for i in range(n):
34 ans=max(ans,max(dp[i]))
35 return ans
36