=P:
12 | print(D1-1)
13 | else:
14 | while(amt=P:
23 | print(D2-1)
24 | else:
25 | while(amt
9 and i<80:
11 | nrisk+=1
12 | else:
13 | risk+=1
14 | num = risk//d + (nrisk//d)
15 | if risk%d!=0:
16 | num+=1
17 | if nrisk%d!=0:
18 | num+=1
19 | print(num)
--------------------------------------------------------------------------------
/Platforms/Codechef/input.txt:
--------------------------------------------------------------------------------
1 | 1
2 | 3
3 | 3
4 | 1 2 3
--------------------------------------------------------------------------------
/Platforms/Codechef/javarun.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 | prog_name = "*.java"
4 | os.system(f'javac -d Java-Classes {prog_name}')
5 | t1 = time.time()
6 | os.system(f'java -cp Java-Classes ANITGUY2 local')
7 | t2 = time.time()
8 | print("TIME TAKEN: ",t2-t1)
--------------------------------------------------------------------------------
/Platforms/Codechef/output.txt:
--------------------------------------------------------------------------------
1 | 3
2 |
--------------------------------------------------------------------------------
/Platforms/Codeforces/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Codeforces/.gitkeep
--------------------------------------------------------------------------------
/Platforms/Codeforces/Avoid_Trygub.py:
--------------------------------------------------------------------------------
1 | for t in range(int(input())):
2 | n = int(input())
3 | s = input()
4 | ss = "trygub"
5 | k =0
6 | cnt=0
7 | l=[]
8 | for i in range(n):
9 | if s[i]=='b':
10 | cnt+=1
11 | for i in range(cnt):
12 | print('b',end='')
13 | for i in range(n):
14 | if s[i]=='b':
15 | continue
16 | print(s[i], end='')
17 | print()
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/Platforms/Codeforces/Buy_the_String.py:
--------------------------------------------------------------------------------
1 | for _ in " "*int(input()):
2 | n,c1,c2,h = map(int, input().split())
3 | s = input()
4 | cnt1, cnt2 =0, 0
5 | for i in s:
6 | if i=='0':
7 | cnt1+=1
8 | else:
9 | cnt2+=1
10 |
11 | if c1+h 0 and i< n-1 and (l[i+1] < m or l[i-1]< m)):
18 | print(i+1)
19 | return
20 | print(-1)
21 |
22 |
23 | for t in range(int(input())):
24 | solve()
25 |
--------------------------------------------------------------------------------
/Platforms/Codeforces/Domino_piling.py:
--------------------------------------------------------------------------------
1 | m,n = map(int, input().split())
2 | print(m*n//2)
--------------------------------------------------------------------------------
/Platforms/Codeforces/Find_The_Array.py:
--------------------------------------------------------------------------------
1 | import math
2 | for t in range(int(input())):
3 | n = int(input())
4 | a = list(map(int,input().split()))
5 | b = []
6 | for i in a:
7 | k = 2**int(math.log2(i))
8 | if i-k<(2*k)-i or 2*k>10**9:
9 | b.append(k)
10 | else:
11 | b.append(2*k)
12 | print(*b, sep = ' ')
--------------------------------------------------------------------------------
/Platforms/Codeforces/Maximum_GCD.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | def main():
4 | n = int(input())
5 | print(n//2)
6 |
7 | t = int(input())
8 | for _ in range(t):
9 | main()
--------------------------------------------------------------------------------
/Platforms/Codeforces/Non_Substring_Subsequence.py:
--------------------------------------------------------------------------------
1 | import sys
2 | sys.stdin = open('input.txt', 'r')
3 | sys.stdout = open('output.txt', 'w')
4 | for _ in range(int(input())):
5 | n, q = map(int,input().split())
6 | s = input()
7 |
8 | for i in range(q):
9 | i, j = map(int,input().split())
10 | i = i-1
11 | j = j-1
12 | left = s[i]
13 | right = s[j]
14 | a=b=0
15 | f = "NO"
16 | i -=1
17 | j+=1
18 | while(i>=0 or j=0 and s[i]==left:
20 | f="YES"
21 | break
22 | if j=bridge:
21 | #print(bridge, n)
22 | ans+=int(str(n)[0])
23 | else:
24 | ans+=int(str(n)[0])-1
25 | print(ans)
26 |
27 |
28 | for t in range(int(input())):
29 | main()
--------------------------------------------------------------------------------
/Platforms/Codeforces/Pleasant Pairs.py:
--------------------------------------------------------------------------------
1 | import math
2 | # import sys
3 | # sys.stdin = open('input.txt', 'r')
4 | # sys.stdout = open('output.txt', 'w+')
5 |
6 | # Check Youtube for explanation
7 |
8 | for t in range(int(input())):
9 | n = int(input())
10 | arr = [(el, i+1) for i,el in enumerate(list(map(int,input().split())))]
11 | arr.sort()
12 | cnt, limit = 0, 2*n
13 |
14 | limReached = False
15 | for i in range(n-1):
16 | for j in range(i+1, n):
17 | mul = arr[i][0]*arr[j][0]
18 | if(mul>limit):
19 |
20 | break
21 | if(mul==arr[i][1]+arr[j][1]):
22 | #print(arr[i], arr[j])
23 | cnt+=1
24 |
25 | print(cnt)
26 |
27 |
--------------------------------------------------------------------------------
/Platforms/Codeforces/Same Differences.py:
--------------------------------------------------------------------------------
1 | import math
2 | from collections import defaultdict
3 | # import sys
4 | # sys.stdin = open('input.txt', 'r')
5 | # sys.stdout = open('output.txt', 'w+')
6 |
7 |
8 | for t in range(int(input())):
9 | d = defaultdict(int)
10 | n = int(input())
11 | arr = list(map(int,input().split()))
12 | cnt = 0
13 | for i in range(n):
14 | d[arr[i]-(i+1)]+=1
15 | for val in d.values():
16 | if val>1:
17 | cnt+= val*(val-1)//2
18 | # print(*d.values())
19 | print(cnt)
--------------------------------------------------------------------------------
/Platforms/Codeforces/Shifting Stacks.py:
--------------------------------------------------------------------------------
1 | import sys
2 | sys.stdin = open('input.txt', 'r')
3 | sys.stdout = open('output.txt', 'w')
4 |
5 | for t in range(int(input())):
6 | n = int(input())
7 | l = list(map(int,input().split()))
8 | f = True
9 | if len(l)==1:
10 | print("YES")
11 | continue
12 | psum = []
13 | s = 0
14 | for i in range(len(l)):
15 | psum.append(i+s)
16 | s = s+i
17 | currSum = 0
18 | for i in range(len(l)):
19 | currSum+=l[i]
20 | if currSum
2 | #include
3 |
4 | using std::vector;
5 | using std::pair;
6 |
7 |
8 | int reach(vector > &adj, int x, int y) {
9 | //write your code here
10 | return 0;
11 | }
12 |
13 | int main() {
14 | size_t n, m;
15 | std::cin >> n >> m;
16 | vector > adj(n, vector());
17 | for (size_t i = 0; i < m; i++) {
18 | int x, y;
19 | std::cin >> x >> y;
20 | adj[x - 1].push_back(y - 1);
21 | adj[y - 1].push_back(x - 1);
22 | }
23 | int x, y;
24 | std::cin >> x >> y;
25 | std::cout << reach(adj, x - 1, y - 1);
26 | }
27 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/1_finding_exit_from_maze/reachability.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 | def reach(adj, x, y):
6 | #write your code here
7 | return 0
8 |
9 | if __name__ == '__main__':
10 | input = sys.stdin.read()
11 | data = list(map(int, input.split()))
12 | n, m = data[0:2]
13 | data = data[2:]
14 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
15 | x, y = data[2 * m:]
16 | adj = [[] for _ in range(n)]
17 | x, y = x - 1, y - 1
18 | for (a, b) in edges:
19 | adj[a - 1].append(b - 1)
20 | adj[b - 1].append(a - 1)
21 | print(reach(adj, x, y))
22 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/2_adding_exits_to_maze/ConnectedComponents.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/2_adding_exits_to_maze/ConnectedComponents.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/2_adding_exits_to_maze/connected_components.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using std::vector;
5 | using std::pair;
6 |
7 | int number_of_components(vector > &adj) {
8 | int res = 0;
9 | //write your code here
10 | return res;
11 | }
12 |
13 | int main() {
14 | size_t n, m;
15 | std::cin >> n >> m;
16 | vector > adj(n, vector());
17 | for (size_t i = 0; i < m; i++) {
18 | int x, y;
19 | std::cin >> x >> y;
20 | adj[x - 1].push_back(y - 1);
21 | adj[y - 1].push_back(x - 1);
22 | }
23 | std::cout << number_of_components(adj);
24 | }
25 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/2_adding_exits_to_maze/connected_components.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 |
6 | def number_of_components(adj):
7 | result = 0
8 | #write your code here
9 | return result
10 |
11 | if __name__ == '__main__':
12 | input = sys.stdin.read()
13 | data = list(map(int, input.split()))
14 | n, m = data[0:2]
15 | data = data[2:]
16 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
17 | adj = [[] for _ in range(n)]
18 | for (a, b) in edges:
19 | adj[a - 1].append(b - 1)
20 | adj[b - 1].append(a - 1)
21 | print(number_of_components(adj))
22 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/debug.log:
--------------------------------------------------------------------------------
1 | [1104/123102.978:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
2 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/week1_graph_decomposition1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week1_graph_decomposition1/week1_graph_decomposition1.pdf
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/1_cs_curriculum/Acyclicity.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/1_cs_curriculum/Acyclicity.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/1_cs_curriculum/acyclicity.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using std::vector;
5 | using std::pair;
6 |
7 | int acyclic(vector > &adj) {
8 | //write your code here
9 | return 0;
10 | }
11 |
12 | int main() {
13 | size_t n, m;
14 | std::cin >> n >> m;
15 | vector > adj(n, vector());
16 | for (size_t i = 0; i < m; i++) {
17 | int x, y;
18 | std::cin >> x >> y;
19 | adj[x - 1].push_back(y - 1);
20 | }
21 | std::cout << acyclic(adj);
22 | }
23 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/1_cs_curriculum/acyclicity.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 |
6 | def acyclic(adj):
7 | return 0
8 |
9 | if __name__ == '__main__':
10 | input = sys.stdin.read()
11 | data = list(map(int, input.split()))
12 | n, m = data[0:2]
13 | data = data[2:]
14 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
15 | adj = [[] for _ in range(n)]
16 | for (a, b) in edges:
17 | adj[a - 1].append(b - 1)
18 | print(acyclic(adj))
19 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/2_order_of_courses/Toposort$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/2_order_of_courses/Toposort$FastReader.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/2_order_of_courses/Toposort.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/2_order_of_courses/Toposort.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/2_order_of_courses/toposort.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 | def dfs(adj, used, order, x):
6 | #write your code here
7 | pass
8 |
9 |
10 | def toposort(adj):
11 | used = [0] * len(adj)
12 | order = []
13 | #write your code here
14 | return order
15 |
16 | if __name__ == '__main__':
17 | input = sys.stdin.read()
18 | data = list(map(int, input.split()))
19 | n, m = data[0:2]
20 | data = data[2:]
21 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
22 | adj = [[] for _ in range(n)]
23 | for (a, b) in edges:
24 | adj[a - 1].append(b - 1)
25 | order = toposort(adj)
26 | for x in order:
27 | print(x + 1, end=' ')
28 |
29 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/StronglyConnected$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/StronglyConnected$FastReader.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/StronglyConnected.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/StronglyConnected.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/strongly_connected.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using std::vector;
6 | using std::pair;
7 |
8 | int number_of_strongly_connected_components(vector > adj) {
9 | int result = 0;
10 | //write your code here
11 | return result;
12 | }
13 |
14 | int main() {
15 | size_t n, m;
16 | std::cin >> n >> m;
17 | vector > adj(n, vector());
18 | for (size_t i = 0; i < m; i++) {
19 | int x, y;
20 | std::cin >> x >> y;
21 | adj[x - 1].push_back(y - 1);
22 | }
23 | std::cout << number_of_strongly_connected_components(adj);
24 | }
25 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/3_intersection_reachability/strongly_connected.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 | sys.setrecursionlimit(200000)
6 |
7 |
8 | def number_of_strongly_connected_components(adj):
9 | result = 0
10 | #write your code here
11 | return result
12 |
13 | if __name__ == '__main__':
14 | input = sys.stdin.read()
15 | data = list(map(int, input.split()))
16 | n, m = data[0:2]
17 | data = data[2:]
18 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
19 | adj = [[] for _ in range(n)]
20 | for (a, b) in edges:
21 | adj[a - 1].append(b - 1)
22 | print(number_of_strongly_connected_components(adj))
23 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/debug.log:
--------------------------------------------------------------------------------
1 | [1111/201509.793:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
2 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/week2_graph_decomposition2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week2_graph_decomposition2/week2_graph_decomposition2.pdf
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/1_flight_segments/BFS$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/1_flight_segments/BFS$FastReader.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/1_flight_segments/BFS.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/1_flight_segments/BFS.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/1_flight_segments/bfs.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using std::vector;
6 | using std::queue;
7 |
8 | int distance(vector > &adj, int s, int t) {
9 | //write your code here
10 | return -1;
11 | }
12 |
13 | int main() {
14 | int n, m;
15 | std::cin >> n >> m;
16 | vector > adj(n, vector());
17 | for (int i = 0; i < m; i++) {
18 | int x, y;
19 | std::cin >> x >> y;
20 | adj[x - 1].push_back(y - 1);
21 | adj[y - 1].push_back(x - 1);
22 | }
23 | int s, t;
24 | std::cin >> s >> t;
25 | s--, t--;
26 | std::cout << distance(adj, s, t);
27 | }
28 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/Bipartite$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/Bipartite$FastReader.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/Bipartite.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/Bipartite.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/bipartite.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | using std::vector;
6 | using std::queue;
7 |
8 | int bipartite(vector > &adj) {
9 | //write your code here
10 | return -1;
11 | }
12 |
13 | int main() {
14 | int n, m;
15 | std::cin >> n >> m;
16 | vector > adj(n, vector());
17 | for (int i = 0; i < m; i++) {
18 | int x, y;
19 | std::cin >> x >> y;
20 | adj[x - 1].push_back(y - 1);
21 | adj[y - 1].push_back(x - 1);
22 | }
23 | std::cout << bipartite(adj);
24 | }
25 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/2_bipartite/bipartite.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 | import queue
5 |
6 | def bipartite(adj):
7 | #write your code here
8 | return -1
9 |
10 | if __name__ == '__main__':
11 | input = sys.stdin.read()
12 | data = list(map(int, input.split()))
13 | n, m = data[0:2]
14 | data = data[2:]
15 | edges = list(zip(data[0:(2 * m):2], data[1:(2 * m):2]))
16 | adj = [[] for _ in range(n)]
17 | for (a, b) in edges:
18 | adj[a - 1].append(b - 1)
19 | adj[b - 1].append(a - 1)
20 | print(bipartite(adj))
21 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/week3_paths_in_graphs1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week3_paths_in_graphs1/week3_paths_in_graphs1.pdf
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/1_minimum_flight_cost/Dijkstra$pair.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/1_minimum_flight_cost/Dijkstra$pair.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/1_minimum_flight_cost/Dijkstra.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/1_minimum_flight_cost/Dijkstra.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/1_minimum_flight_cost/dijkstra.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 | import queue
5 |
6 |
7 | def distance(adj, cost, s, t):
8 | #write your code here
9 | return -1
10 |
11 |
12 | if __name__ == '__main__':
13 | input = sys.stdin.read()
14 | data = list(map(int, input.split()))
15 | n, m = data[0:2]
16 | data = data[2:]
17 | edges = list(zip(zip(data[0:(3 * m):3], data[1:(3 * m):3]), data[2:(3 * m):3]))
18 | data = data[3 * m:]
19 | adj = [[] for _ in range(n)]
20 | cost = [[] for _ in range(n)]
21 | for ((a, b), w) in edges:
22 | adj[a - 1].append(b - 1)
23 | cost[a - 1].append(w)
24 | s, t = data[0] - 1, data[1] - 1
25 | print(distance(adj, cost, s, t))
26 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/NegativeCycle$pair.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/NegativeCycle$pair.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/NegativeCycle.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/NegativeCycle.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/negative_cycle.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | using std::vector;
5 |
6 | int negative_cycle(vector > &adj, vector > &cost) {
7 | //write your code here
8 | return 0;
9 | }
10 |
11 | int main() {
12 | int n, m;
13 | std::cin >> n >> m;
14 | vector > adj(n, vector());
15 | vector > cost(n, vector());
16 | for (int i = 0; i < m; i++) {
17 | int x, y, w;
18 | std::cin >> x >> y >> w;
19 | adj[x - 1].push_back(y - 1);
20 | cost[x - 1].push_back(w);
21 | }
22 | std::cout << negative_cycle(adj, cost);
23 | }
24 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/2_detecting_anomalies/negative_cycle.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 |
3 | import sys
4 |
5 |
6 | def negative_cycle(adj, cost):
7 | #write your code here
8 | return 0
9 |
10 |
11 | if __name__ == '__main__':
12 | input = sys.stdin.read()
13 | data = list(map(int, input.split()))
14 | n, m = data[0:2]
15 | data = data[2:]
16 | edges = list(zip(zip(data[0:(3 * m):3], data[1:(3 * m):3]), data[2:(3 * m):3]))
17 | data = data[3 * m:]
18 | adj = [[] for _ in range(n)]
19 | cost = [[] for _ in range(n)]
20 | for ((a, b), w) in edges:
21 | adj[a - 1].append(b - 1)
22 | cost[a - 1].append(w)
23 | print(negative_cycle(adj, cost))
24 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/3_exchanging_money/ShortestPaths$pair.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/3_exchanging_money/ShortestPaths$pair.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/3_exchanging_money/ShortestPaths.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/3_exchanging_money/ShortestPaths.class
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/debug.log:
--------------------------------------------------------------------------------
1 | [1120/213810.562:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
2 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/week4_paths_in_graphs2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week4_paths_in_graphs2/week4_paths_in_graphs2.pdf
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/1_connecting_points/ConnectingPoints.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class ConnectingPoints {
4 | private static double minimumDistance(int[] x, int[] y) {
5 | double result = 0.;
6 | //write your code here
7 | return result;
8 | }
9 |
10 | public static void main(String[] args) {
11 | Scanner scanner = new Scanner(System.in);
12 | int n = scanner.nextInt();
13 | int[] x = new int[n];
14 | int[] y = new int[n];
15 | for (int i = 0; i < n; i++) {
16 | x[i] = scanner.nextInt();
17 | y[i] = scanner.nextInt();
18 | }
19 | System.out.println(minimumDistance(x, y));
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/1_connecting_points/connecting_points.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | using std::vector;
8 |
9 | double minimum_distance(vector x, vector y) {
10 | double result = 0.;
11 | //write your code here
12 | return result;
13 | }
14 |
15 | int main() {
16 | size_t n;
17 | std::cin >> n;
18 | vector x(n), y(n);
19 | for (size_t i = 0; i < n; i++) {
20 | std::cin >> x[i] >> y[i];
21 | }
22 | std::cout << std::setprecision(10) << minimum_distance(x, y) << std::endl;
23 | }
24 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/1_connecting_points/connecting_points.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 | import sys
3 | import math
4 |
5 | def minimum_distance(x, y):
6 | result = 0.
7 | #write your code here
8 | return result
9 |
10 |
11 | if __name__ == '__main__':
12 | input = sys.stdin.read()
13 | data = list(map(int, input.split()))
14 | n = data[0]
15 | x = data[1::2]
16 | y = data[2::2]
17 | print("{0:.9f}".format(minimum_distance(x, y)))
18 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/2_clustering/Clustering.java:
--------------------------------------------------------------------------------
1 | import java.util.Scanner;
2 |
3 | public class Clustering {
4 | private static double clustering(int[] x, int[] y, int k) {
5 | //write your code here
6 | return -1.;
7 | }
8 |
9 | public static void main(String[] args) {
10 | Scanner scanner = new Scanner(System.in);
11 | int n = scanner.nextInt();
12 | int[] x = new int[n];
13 | int[] y = new int[n];
14 | for (int i = 0; i < n; i++) {
15 | x[i] = scanner.nextInt();
16 | y[i] = scanner.nextInt();
17 | }
18 | int k = scanner.nextInt();
19 | System.out.println(clustering(x, y, k));
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/2_clustering/clustering.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | using std::vector;
9 | using std::pair;
10 |
11 |
12 |
13 | double clustering(vector x, vector y, int k) {
14 | //write your code here
15 | return -1.;
16 | }
17 |
18 | int main() {
19 | size_t n;
20 | int k;
21 | std::cin >> n;
22 | vector x(n), y(n);
23 | for (size_t i = 0; i < n; i++) {
24 | std::cin >> x[i] >> y[i];
25 | }
26 | std::cin >> k;
27 | std::cout << std::setprecision(10) << clustering(x, y, k) << std::endl;
28 | }
29 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/2_clustering/clustering.py:
--------------------------------------------------------------------------------
1 | #Uses python3
2 | import sys
3 | import math
4 |
5 | def clustering(x, y, k):
6 | #write your code here
7 | return -1.
8 |
9 |
10 | if __name__ == '__main__':
11 | input = sys.stdin.read()
12 | data = list(map(int, input.split()))
13 | n = data[0]
14 | data = data[1:]
15 | x = data[0:2 * n:2]
16 | y = data[1:2 * n:2]
17 | data = data[2 * n:]
18 | k = data[0]
19 | print("{0:.9f}".format(clustering(x, y, k)))
20 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/week5_spanning_trees.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/EXTRA/Coursera-Algorithms-On-Graphs/week5_spanning_trees/week5_spanning_trees.pdf
--------------------------------------------------------------------------------
/Platforms/EXTRA/Google Kickstart/Round A/K-Goodness String/Solution.py:
--------------------------------------------------------------------------------
1 | for t in range(int(input())):
2 | n, k = map(int,input().split())
3 | s = input()
4 | c =0
5 | for i in range(1,n//2+1):
6 | if s[i-1]!=s[n-i]:
7 | c+=1
8 | ans = abs(k-c)
9 | print(f"Case #{t+1}: {ans}")
--------------------------------------------------------------------------------
/Platforms/EXTRA/Largest-Independent-Set-Problem/Question.md:
--------------------------------------------------------------------------------
1 | # Largest Largest Independent Set Problem
2 | > Given a Binary Tree of size N, find the size of the Largest Independent Set(LIS) in it. A subset of all tree nodes is an independent set if there is no edge between any two nodes of the subset. Your task is to complete the function LISS(), which finds the size of the Largest Independent Set.
3 |
4 | For example:
5 | Consider the following binary tree.The LIS is
6 | LIS: [10, 40, 60, 70, 80]
7 | Size: 5.
8 |
9 | 
--------------------------------------------------------------------------------
/Platforms/EXTRA/Maximum-sum-increasing-subsequence/README.md:
--------------------------------------------------------------------------------
1 | # Question:
2 | Given an array arr of N positive integers, the task is to find the maximum sum increasing subsequence of the given array.
--------------------------------------------------------------------------------
/Platforms/EXTRA/Maximum-sum-of-Non-adjacent-nodes/Question.md:
--------------------------------------------------------------------------------
1 | # Maximum sum of Non-adjacent nodes
2 |
3 | > Given a binary tree with a value associated with each node, we need to choose a subset of these nodes such that sum of chosen nodes is maximum under a constraint that no two chosen node in subset should be directly connected that is, if we have taken a node in our sum then we can’t take its any children in consideration and vice versa.
4 |
5 | 
6 |
--------------------------------------------------------------------------------
/Platforms/EXTRA/Minimum Difference Subsets!/README.md:
--------------------------------------------------------------------------------
1 | # Problem Description
2 |
3 | Given an integer array A containing N integers.
4 |
5 | You need to divide the array A into two subsets S1 and S2 such that the absolute difference between their sums is minimum.
6 |
7 | Find and return this minimum possible absolute difference.
8 |
9 | NOTE:
10 |
11 | Subsets can contain elements from A in any order (not necessary to be contiguous).
12 | Each element of A should belong to any one subset S1 or S2, not both.
13 | It may be possible that one subset remains empty.
14 |
15 |
16 | Problem Constraints
17 | 1 <= N <= 100
18 |
19 | 1 <= A[i] <= 100
20 |
21 |
22 |
23 | Input Format
24 | First and only argument is an integer array A.
25 |
26 |
27 |
28 | Output Format
29 | Return an integer denoting the minimum possible difference among the sums of two subsets.
--------------------------------------------------------------------------------
/Platforms/EXTRA/String-Subsequence/Question.md:
--------------------------------------------------------------------------------
1 | # String Subsequence
2 | > Given two strings S1 and S2, find the number of times the second string occurs in the first string, whether continuous or discontinuous.
3 |
4 | Example 1:
5 |
6 | Input:
7 | S1 = geeksforgeeks
8 | S2 = gks
9 | Output: 4
10 | Explaination: For the first 'g' there
11 | are 3 ways and for the second 'g' there
12 | is one way. Total 4 ways.
--------------------------------------------------------------------------------
/Platforms/GFG/Count pairs with given sum.md:
--------------------------------------------------------------------------------
1 | ```java
2 | class Solution {
3 | int getPairsCount(int[] arr, int n, int k) {
4 | // code here
5 | int cnt =0;
6 | Map map = new HashMap<>();
7 | for (int i = 0; i < arr.length; i++) {
8 | int complement = k - arr[i];
9 | if (map.containsKey(complement)) {
10 | cnt+= map.get(complement);
11 | }
12 | map.put(arr[i], map.getOrDefault(arr[i],0)+1);
13 | }
14 | return cnt;
15 | }
16 | }
17 | ```
--------------------------------------------------------------------------------
/Platforms/GFG/Longest substring to form a Palindrome.md:
--------------------------------------------------------------------------------
1 | ### Given a string S which only contains lowercase alphabets. Find the length of the longest substring of S such that the characters in it can be rearranged to form a palindrome.
2 |
3 | > REFER Explanation : https://www.geeksforgeeks.org/longest-substring-whose-characters-can-be-rearranged-to-form-a-palindrome/
4 |
5 |
--------------------------------------------------------------------------------
/Platforms/Hackerearth/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/.gitkeep
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Input_expectations.java:
--------------------------------------------------------------------------------
1 | package Hackerearth;
2 |
3 | import java.util.*;
4 | public class Input_expectations {
5 | public static void main(String args[] ) throws Exception {
6 | Scanner sc= new Scanner(System.in);
7 | int t = sc.nextInt();
8 | int cnt=0;
9 | for(int i = 0; i < t; i++){
10 |
11 | int n;
12 | if(sc.hasNext()){
13 | n = sc.nextInt();
14 | while(n>0 && sc.hasNext())
15 | {
16 | sc.nextInt();
17 | n-=1;
18 | }
19 | cnt+=n;
20 | }
21 | else
22 | {
23 | cnt+=1;
24 | }
25 | }
26 | sc.close();
27 | System.out.println(cnt);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League$FastReader.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League$pair.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League$pair.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_And_Champions_League.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication$FastReader.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication$FastReader.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication$pair.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication$pair.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RohanTrix/Competitive-Practice/b14aae7dbd778d8cdf743c77a1f8d25b3048937e/Platforms/Hackerearth/Java-Classes/Monk_and_Multiplication.class
--------------------------------------------------------------------------------
/Platforms/Hackerearth/cpprun.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 | prog_name = ".c"
4 | os.system(f'g++ -o out {prog_name}')
5 | t1 = time.time()
6 | os.system("out")
7 | t2 = time.time()
8 | print("TIME TAKEN: ",t2-t1)
--------------------------------------------------------------------------------
/Platforms/Hackerearth/input.txt:
--------------------------------------------------------------------------------
1 | 3 4
2 | 1 2 4
--------------------------------------------------------------------------------
/Platforms/Hackerearth/javarun.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 | prog_name = "*.java"
4 | os.system(f'javac -d Java-Classes {prog_name}')
5 | t1 = time.time()
6 | os.system(f'java -cp Java-Classes Monk_And_Champions_League local')
7 | t2 = time.time()
8 | print("TIME TAKEN: ",t2-t1)
--------------------------------------------------------------------------------
/Platforms/Hackerearth/output.txt:
--------------------------------------------------------------------------------
1 | 11
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Problem Solving Solution Repo
--------------------------------------------------------------------------------
/autocommit.py:
--------------------------------------------------------------------------------
1 | import os
2 | import time
3 | while(True):
4 | if os.system('git diff --exit-code')==0:
5 | print(0)
6 | time.sleep(60)
7 | f = open('helloworld.txt','w')
8 | f.write(str(time.time()))
9 | f.close()
10 | continue
11 | os.system('git add-commit -m "Committed changes"')
12 | os.system('git push -u origin master')
13 | time.sleep(60)
14 |
--------------------------------------------------------------------------------
/file_name_maker.py:
--------------------------------------------------------------------------------
1 | s = input("File Name: ")
2 | dtype = input("File type: ")
3 | print('_'.join(s.split())+f'.{dtype}')
--------------------------------------------------------------------------------