This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def array_left_rotation(a, n, k): | |
if k % n == 0: | |
return a | |
else: | |
return (a[k%n: ] + a[ :k%n]) | |
n, k = map(int, input().strip().split(' ')) | |
a = list(map(int, input().strip().split(' '))) | |
answer = array_left_rotation(a, n, k); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = int(input().strip()) | |
def wordCount(word): | |
global words | |
res = [item for item in words if item == word] | |
return len(res) | |
words = [input().strip() for i in range(N)] | |
N_Q = int(input().strip()) | |
query = [print (wordCount(input().strip())) for i in range(N_Q)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firstLine = [int(i) for i in input().strip().split(" ")] | |
secondLine = [int (j) for j in input().strip().split(" ")] | |
n = firstLine[1]%firstLine[0] | |
secondLine += secondLine[0:n] | |
secondLine = secondLine[n:] | |
[print (i, end = " ") for i in secondLine] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
first_line = [int(item) for item in input().strip().split(" ")] | |
N = first_line[0] | |
seqList = [[] for i in range(N)] | |
lastAns = 0 | |
def query1(x,y): | |
global N, seqList, lastAns | |
seqList[(x^lastAns) % N].append(y) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input().strip()) | |
for i in range(1,n+1): | |
if i%3 == 0 and i%5 == 0: | |
print ("FizzBuzz") | |
elif i % 3 == 0: | |
print ("Fizz") | |
elif i % 5 == 0: | |
print ("Buzz") | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
array = input().strip() | |
lst = [] | |
for i in range(len(array)): | |
if array[i] == '(' or array[i] == '[' or array[i] == '{': | |
lst.append(array[i]) | |
elif array[i] == ')': | |
if len(lst) != 0 and lst[len(lst)-1] == '(': | |
lst.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import sys | |
def get_num(n, strr): | |
num = [i for i in strr if i == n] | |
return (len(num)) | |
def adjust(strr): | |
flag = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import sqrt | |
def fibo(n): | |
return (((1+sqrt(5))**n - (1-sqrt(5))**n)/(2**n*sqrt(5))) | |
while True: | |
try: | |
n = int(input().strip()) | |
print (int(fibo(n))) | |
except(EOFError): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/python3 | |
import sys | |
s,t = input().strip().split(' ') | |
s,t = [int(s),int(t)] | |
a,b = input().strip().split(' ') | |
a,b = [int(a),int(b)] | |
m,n = input().strip().split(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Solution { | |
public static void main(String[] args) { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ |