Skip to content

Instantly share code, notes, and snippets.

View Svastikkka's full-sized avatar
🏛️
Working in Bengaluru

Manshu Sharma Svastikkka

🏛️
Working in Bengaluru
View GitHub Profile
def solve(n,k):
pos=n//2
if n%2!=0:
pos=pos+1
if k<=pos:
return 1+(k-1)*2
else:
k=k-pos
return 2+(k-1)*2
## Read input as specified in the question.
## Print output as specified in the question.
n=int(input())
if n%2==0:
print("YES")
else:
print("NO")
import math
n=int(input())
print(math.factorial(n))
import math
def find_lcm(a, b):
return abs(a * b) // math.gcd(a, b)
t=int(input())
for i in range(t):
n,m,k=map(int,input().split())
l = sorted(list(map(int,input().split())))
num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)
t=int(input())
for i in range(t):
n = int(input())
print((n * (n + 1) // 2) + 1)
def solve(n):
if n < 9:
return n
else:
return (n%9) + (10 * solve(n//9))
while True:
try:
n = int(input())
print(solve(n))
except ValueError :
'''
# Sample code to perform I/O:
name = input() # Reading input from STDIN
print('Hi, %s.' % name) # Writing output to STDOUT
# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
'''
# Write your code here
import math
x=int(input())
y=int(input())
print(math.gcd(x,y))
## Read input as specified in the question.
## Print output as specified in the question.
arr=list(map(int,input().split()))
i=len(arr)-1
while i>0:
i=i-1
if arr[i]!=-1:
print(arr[i],end=" ")
for i in range(int(input())):
n=int(input())
m=list(map(int,input().split()))
c=n-1
while c>0 and m[c-1]>=m[c]:c-=1
while c>0 and m[c-1]<=m[c]:c-=1
print(c)