Skip to main content

AU2340001_R_Priscilla

Submission at 2024-08-09 04:57:55

s=input("Enter your Name:")
print("Hello",s,"!!")

Submission at 2024-08-09 04:59:34

s=input('Enter your Name:')
print("Hello",s,"!!")

Submission at 2024-08-09 05:02:58

s=input('Enter your Name:')
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")
else:
print("Invalid")

Submission at 2024-08-09 05:03:56

s=input('Enter your Name:')
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")
else:
print("Invalid")

Submission at 2024-08-09 05:13:30

n=int(input("Enter the no. of inputs:"))
if n>=1 and n<=100:
for i in range(0,n):
s=input("Name:")
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")
else:
print("Invalid")


Submission at 2024-08-09 05:16:56

s=input("Enter your name:")
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")
else:
print("Invalid")

Submission at 2024-08-09 05:21:57

n=int(input("Enter no. of inputs:"))
if n>=1 and n<=100:
for i in range (0,n):
s=input("Enter your Name:")
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")


Submission at 2024-08-09 05:23:49

n=int(input("Enter no. of inputs:"))
if n>=1 and n<=100:
for i in range (0,n):
s=input("Enter your Name:")
if len(s)>=1 and len(s)<=100:
print("Hello",s,"!!")
else:
print("Name Invalid")
else:
print("Invalid")


Submission at 2024-08-09 05:26:40

print("Hello World!!")

Submission at 2024-08-09 05:40:55

n=int(input("Enter no. of inputs:"))
if n>=1 and n<=100:
for i in range (0,n):
s=input("Enter your Name:")
if len(s)>=1 and len(s)<=100:
print("Hello"+s+"!")

Submission at 2024-08-09 05:46:56

n=int(input("Input:"))
if n>=1 and n<=100:
for i in range (0,n):
s=input("Name")
if len(s)>=1 and len(s)<=100:
print("Hello"+s+"!")

Submission at 2024-08-09 05:50:54

n=int(input())
if n>=1 and n<=100:
for i in range (0,n):
s=input()
if len(s)>=1 and len(s)<=100:
print("Hello"+s+"!")

Submission at 2024-08-09 05:53:24

n=int(input())
if n>=1 and n<=100:
for i in range (0,n):
s=input()
if len(s)>=1 and len(s)<=100:
print("Hello"+s+"!")

Submission at 2024-08-16 04:56:24

def fibonacci(x):
if x>=0 and x<=10:
if x<=1:
return x
else:
return(fibonacci(x-1)+fibonacci(x-2))

def main():
x = int(input().strip())

# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))


if __name__ == "__main__":
main()

Submission at 2024-08-16 05:43:55

def is_power_of_two(n):
if n==1:
return true
if n<=0 and n%2!=0:
return false

return is_power_of_two(n/2)

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-08-16 05:49:56

def is_power_of_two(n):
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-08-16 06:33:04


def subsets(nums):
out=[]

def generate(sub,ind,nums):
if ind==len(nums):
out.append(sub)
return

generate(sub,ind+1,nums)

sub.append(nums[ind])
generate(sub,ind+1,nums)
sub.pop()
return out



def main():
line = input().strip()

nums = list(map(int, line.split()))

# Generate all subsets
result = subsets(nums)

# Sort subsets based on size and first element
result.sort(key=lambda x: (len(x), x if x else float('inf')))

# Print subsets
for subset in result:
print(subset)

if __name__ == "__main__":
main()

Submission at 2024-08-23 07:18:13

# Write the code from scratch, no boilerplate isrequired
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
if arr1[i]==arr1[i]:
print("true")
else:
print("false")

Submission at 2024-08-23 11:47:25

# Write the code from scratch, no boilerplate is required
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)

arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
if arr1[i]!=arr2[i]:
print("false")
break
if arr1[i]==arr2[i]:
print("true")
else:
print("false")

Submission at 2024-08-23 11:49:24

# Write the code from scratch, no boilerplate is required
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)

arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
if arr1[i]!=arr2[i]:
print("false")
break
if arr1[i]==arr2[i]:
print("true")
else:
print("false")

Submission at 2024-08-23 12:02:22

n=int(input())
count=0
list1=[]
for i in range(1,n+1):
if i%3==0 or i%5==0 or i%7==0:
list1.append(i)
count=count+i
print(count)



Submission at 2024-08-28 07:43:36

# Write the code from scratch, no boilerplate is required
# Write the code from scratch, no boilerplate isrequired
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
if arr1[i]==arr1[i]:
print()
print("true")
else:
print("false")

Submission at 2024-08-28 08:01:18

# Write the code from scratch, no boilerplate is required
# Write the code from scratch, no boilerplate isrequired
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
if arr1[i]==arr2[i]:
print("true")
break
else:
print("false")

Submission at 2024-08-28 08:31:23

# Write the code from scratch, no boilerplate is required
# Write the code from scratch, no boilerplate isrequired
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
for i in range(0,len(arr1)):
a=True
if arr1[i]!=arr2[i]:
a=False
break
if a:
print("true")
else:
print("false")
else:
print("false")

Submission at 2024-08-28 08:35:05

# Write the code from scratch, no boilerplate is required
# Write the code from scratch, no boilerplate isrequired
n = int(input("Enter the number of elements in the first list: "))
n1 = int(input("Enter the number of elements in the second list: "))

arr1 = []
arr2 = []

print("Enter elements for the first list:")
for _ in range(n):
ele = int(input())
arr1.append(ele)

print("Enter elements for the second list:")
for _ in range(n1):
ele = int(input())
arr2.append(ele)

# Sort both lists
arr1.sort()
arr2.sort()

# Check if lists are of the same length and all elements are the same
if len(arr1) == len(arr2):
all_match = True
for i in range(len(arr1)):
if arr1[i] != arr2[i]:
all_match = False
break
if all_match:
print("true")
else:
print("false")
else:
print("false")

Submission at 2024-08-29 07:33:13

# Write the code from scratch, no boilerplate is required
n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
a=True
for i in range(0,len(arr1)):
if arr1[i]!=arr2[i]:
a=False
print("false")

if a:
print("true")

else:
print("false")

Submission at 2024-08-29 09:02:30

n=int(input())
list1=[]
count=0
for i in range(n):
ele=int(input())
list1.append(ele)

for i in range(len(list1)):
str1=str(list1[i])
if len(str1)%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:06:52

n=int(input())
list1=[]
count=0
for i in range(n):
ele=int(input())
list1.append(ele)

for i in range(len(list1)):
if len(str(list1[i]))%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:08:14

n=int(input())
list1=[]


for i in range(n):
ele=int(input())
list1.append(ele)

count=0

for i in range(len(list1)):
if len(str(list1[i]))%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:12:57

n=int(input())
list1=[]


for i in range(n):
ele=int(input())
list1.append(ele)

count=0

for i in range(len(list1)):
if len(str(list1[i]))%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:29:14

n=int(input())
list1=[]

for i in range(n):
ele=int(input())
list1.append(ele)
count=0
for i in range(len(list1)):
str1=str(list1[i])
if len(str1)%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:29:53

n=int(input())
list1=[]

for i in range(n):
ele=int(input())
list1.append(ele)
count=0
for i in range(len(list1)):
str1=str(list1[i])
if len(str1)%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:30:41

n=int(input())
list1=[]

for i in range(n):
ele=int(input())
list1.append(ele)
count=0
for i in range(len(list1)):
if len(str(list1[i]))%2==0:
count=count+1
print(count)

Submission at 2024-08-29 09:39:57

def findKthMissingPositive(arr, K):
# Pointer to the current position in the array
index = 0
# The current number we're checking
current_number = 1
# Counter for the number of missing positives found
missing_count = 0

while missing_count < K:
# Check if current_number is in the array
if index < len(arr) and arr[index] == current_number:
# Move to the next element in the array
index += 1
else:
# Current number is missing from the array
missing_count += 1
if missing_count == K:
return current_number
# Move to the next number
current_number += 1

return current_number

# Example Usage
arr = [2, 3, 4, 7, 11]
K = 5
print(findKthMissingPositive(arr, K)) # Output: 9

Submission at 2024-08-29 09:46:41

def findKthMissingPositive(arr, K):
# Pointer to the current position in the array
index = 0
# The current number we're checking
current_number = 1
# Counter for the number of missing positives found
missing_count = 0

while missing_count < K:
# Check if current_number is in the array
if index < len(arr) and arr[index] == current_number:
# Move to the next element in the array
index += 1
else:
# Current number is missing from the array
missing_count += 1
if missing_count == K:
return current_number
# Move to the next number
current_number += 1

return current_number
n=int(input())
K=int(input())
arr=[]
for i in range(n):
ele=int(input())
arr.append(i)


print(findKthMissingPositive(arr, K)) # Output: 9

Submission at 2024-08-29 09:53:27

n=int(input())
n1=int(input())
arr1=[]
arr2=[]
for i in range(n):
ele=int(input())
arr1.append(ele)
for i in range(n1):
ele=int(input())
arr2.append(ele)
arr1.sort()
arr2.sort()
if len(arr1)==len(arr2):
a=True
for i in range(0,len(arr1)):
if arr1[i]!=arr2[i]:
a=False
print(False)

if a:
print(True)

else:
print(False)

Submission at 2024-08-30 04:34:07

def is_power_of_two(n:int) -> int:
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))


def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-08-30 04:34:42

def is_power_of_two(n):
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))


def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-08-30 04:35:32

def is_power_of_two(n):
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))


def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-08-30 04:48:40

'''
class node:
def __init__(self):
self.data = None
self.next = None
'''

def reverseLinkedList(head):
curr_head=head
prev=None

while head:
next_node=curr_head.next
prev=curr_head.next
curr_head=prev


# Write your logic here


Submission at 2024-08-30 05:07:47

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
power=x**n
return power
pow(x,n)

def main():
x=input().split()
n=input().split()
print(math.floor(pow(x,n)))

main()

Submission at 2024-08-30 05:10:13

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
power=math.pow(x,n)
return power
pow(x,n)

def main():
x=float(input().split())
n=float(input().split())
print(math.floor(pow(x,n)))

main()

Submission at 2024-08-30 05:11:32

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
power=math.pow(x,n)
return power
pow(x,n)

def main():
x=float(input())
n=float(input())
print(math.floor(pow(x,n)))

main()

Submission at 2024-08-30 05:12:02

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
power=math.pow(x,n)
return power
pow(x,n)

def main():
x=float(input())
n=float(input())
print(math.floor(pow(x,n)))

main()

Submission at 2024-08-30 05:27:57

# Write code from scratch
import math
n=int(input())
list1=[]
list2=[]
list3=[]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(len(list1)):
list3[i]=max(list1[i])+max(list2[i])
print(list3)



Submission at 2024-08-30 05:29:37

# Write code from scratch

n=int(input())
list1=array([])
list2=array([])
list3=array([])
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(len(list1)):
list3[i]=array.max(list1[i])+array.max(list2[i])
print(list3)



Submission at 2024-08-30 05:45:22

# Write code from scratch
str1=input()
def palindrome(str1):
str2=str1[::-1]
for i in range(len(str1)):
if str1[i]!=str2[i]:
return "NO"
else:
return "YES"
return palindrome(str1)
print(palindrome(str1))

Submission at 2024-08-30 05:53:45


r=int(input())
c=int(input())
l=[]
m=[]
for i in range(r):
for j in range(c):
ele=int(input())
l.append(ele)
m.append(l)
print(m.flatten(m))





Submission at 2024-08-30 05:56:46

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
if x>=-1000 and x<=1000:
return math.pow(x,n)
else:
return
return pow(x,n)

def main():
x=float(input())
n=float(input())
print(math.floor(pow(x,n)))

main()

Submission at 2024-08-30 05:58:46

# write from scratch, create a function named Pow(x:int , n:int)
import math
def pow(x,n):
if x>=-1000 and x<=1000:
return x**n
else:
return
return pow(x,n)

def main():
x=float(input())
n=float(input())
print(pow(x,n))

main()

Submission at 2024-08-30 05:59:59

# write from scratch, create a function named Pow(x:int , n:int)

def pow(x,n):
if x>=-1000 and x<=1000:
return x**n
else:
return
return pow(x,n)

def main():
x=float(input())
n=float(input())
print(int(pow(x,n)))

main()

Submission at 2024-08-30 06:00:56

# write from scratch, create a function named Pow(x:int , n:int)

def pow(x,n):
if x>=-1000 and x<=1000:
return x**n
else:
return
return pow(x,n)


x=float(input())
n=float(input())
print(int(pow(x,n)))

Submission at 2024-08-30 06:02:32

# write from scratch, create a function named Pow(x:int , n:int)

def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)


x=float(input())
n=float(input())
print(int(pow(x,n)))

Submission at 2024-08-30 06:06:36

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=[]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(len(list1)):
a=list1[i]
b=list2[i]
list3[i]=max(a)+max(b)
print(list3)



Submission at 2024-08-30 06:07:54

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=[]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(len(list1)):
list3[i]=max(list1[i],list2[i])


print(list3)



Submission at 2024-08-30 06:13:21

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=[0,2,3,4,5]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(len(list1)):


list3[i]=max(list1[i],list2[i])

print(list3)



Submission at 2024-08-30 06:14:55

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=[]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(n):
ele=int(input(0))
list3.append(ele)
for i in range(len(list1)):
list3[i]=max(list1[i],list2[i])

print(list3)



Submission at 2024-08-30 06:15:57

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=[]
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)
for i in range(n):
ele=int(input())
list3.append(ele)
for i in range(len(list1)):
list3[i]=max(list1[i],list2[i])

print(list3)



Submission at 2024-08-30 06:18:50

# Write code from scratch
n=int(input())
list1=[]
list2=[]
list3=list1
for i in range(n):
ele=int(input())
list1.append(ele)
for i in range(n):
ele=int(input())
list2.append(ele)

for i in range(len(list1)):
list3[i]=max(list1[i],list2[i])

print(list3)



Submission at 2024-08-30 06:23:51

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input())
n=float(input())
print(int(pow(x,n)))


main()

Submission at 2024-09-02 07:40:37

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input().strip())
n=float(input().strip())
print(int(pow(x,n)))


main()

Submission at 2024-09-02 07:41:19

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input().strip())
n=float(input().strip())
print(int(pow(x,n)))


main()

Submission at 2024-09-02 07:43:19

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input().strip())
n=float(input().strip())
print(int(pow(x,n)))


main()
if __name__ == "__main__":
main()

Submission at 2024-09-02 07:43:38

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input().strip())
n=float(input().strip())
print(int(pow(x,n)))


main()
if __name__ == "__main__":
main()

Submission at 2024-09-02 07:44:16

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x,n):
if x>=-1000 and x<=1000 and n<1000 and n>-1000:
return x**n
else:
return x
return pow(x,n)

def main():
x=float(input())
n=float(input())
print(int(pow(x,n)))


main()
if __name__ == "__main__":
main()

Submission at 2024-09-02 07:46:10

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x, n):
# Ensure n is an integer for exponentiation
if isinstance(n, int):
if -1000 <= x <= 1000 and -1000 < n < 1000:
return x ** n
else:
return x
else:
return x

def main():
try:
x = float(input("Enter the base (x): "))
n = int(float(input("Enter the exponent (n): "))) # Convert to integer
result = pow(x, n)
print(int(result)) # Convert the result to integer before printing
except ValueError:
print("Invalid input. Please enter valid numbers.")

if __name__ == "__main__":
main()

Submission at 2024-09-02 07:47:03

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x, n):
# Ensure n is an integer for exponentiation
if isinstance(n, int):
if -1000 <= x <= 1000 and -1000 < n < 1000:
return x ** n
else:
return x
else:
return x

def main():
try:
x = float(input())
n = int(float(input()) # Convert to integer
result = pow(x, n)
print(int(result)) # Convert the result to integer before printing
except ValueError:
print("Invalid input. Please enter valid numbers.")

if __name__ == "__main__":
main()

Submission at 2024-09-02 07:49:02

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x, n):
# Ensure n is an integer for exponentiation
if isinstance(n, int):
if -1000 <= x <= 1000 and -1000 < n < 1000:
return x ** n
else:
return x
else:
return x

def main():
try:
x = float(input())
n = int(float(input())) # Convert to integer
result=pow(x, n)
print(int(result)) # Convert the result to integer before printing
except ValueError:
print("Invalid input. Please enter valid numbers.")

if __name__ == "__main__":
main()

Submission at 2024-09-02 07:52:07

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x, n):
# Ensure n is an integer for exponentiation
if isinstance(n, int):
if -1000 <= x <= 1000 and -1000 < n < 1000:
return x ** n
else:
return x
else:
return pow(x,n)

def main():
try:
x = float(input())
n = int(float(input())) # Convert to integer
result=pow(x, n)
print(int(result)) # Convert the result to integer before printing
except ValueError:
print("Invalid input. Please enter valid numbers.")

if __name__ == "__main__":
main()

Submission at 2024-09-06 05:26:17

# Write Code from Scratch
m=int(input())
n=int(input())
l=[]
for i in range(m):
row=[]
for j in range(n):
ele=int(input())
row.append(ele)
l.append(row)

for i in range(m):
for j in range(n):
l[i][j]=l[j][i]
print(l)

Submission at 2024-09-09 07:41:57

# Write Code from Scratch
m=int(input())
n=int(input())
l=[]
for i in range(m):
row=[]
for j in range(n):
ele=int(input())
row.append(ele)
l.append(row)
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[i][j]=l[j][i]
print(transposed)

Submission at 2024-09-09 07:44:45

# Write Code from Scratch
m=int(input())
n=int(input())
l=[]
for i in range(m):
row=[]
for j in range(n):
ele=int(input())
row.append(ele)
l.append(row)
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[i][j]=l[j][i]
for row in transposed:
print(row)

Submission at 2024-09-09 08:04:23

# Write Code from Scratch
m=int(input())
n=int(input())
l=[]
for i in range(m):
row=[]
for j in range(n):
ele=int(input())
row.append(ele)
l.append(row)
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i]=l[i][j]
for row in transposed:
print(row)

Submission at 2024-09-09 08:06:16

# Write Code from Scratch
def read_matrix(m, n):
"""Reads an m x n matrix from user input."""
matrix = []
for i in range(m):
row = []
for j in range(n):
try:
ele = int(input(f"Enter element at position ({i},{j}): "))
row.append(ele)
except ValueError:
print("Invalid input! Please enter an integer.")
return None
matrix.append(row)
return matrix

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(row)

def main():
try:
m = int(input("Enter number of rows: "))
n = int(input("Enter number of columns: "))

if m <= 0 or n <= 0:
print("Number of rows and columns must be positive integers.")
return

matrix = read_matrix(m, n)
if matrix is None:
return

transposed = transpose_matrix(matrix)
print("Transposed matrix:")
print_matrix(transposed)

except ValueError:
print("Invalid input! Please enter integers for the number of rows and columns.")
except Exception as e:
print(f"An error occurred: {e}")

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:07:34

# Write Code from Scratch
def read_matrix(m, n):

matrix = []
for i in range(m):
row = []
for j in range(n):
try:
ele = int(input(f"Enter element at position ({i},{j}): "))
row.append(ele)
except ValueError:
print()
return None
matrix.append(row)
return matrix

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(row)

def main():
try:
m = int(input())
n = int(input())

if m <= 0 or n <= 0:
print("Number of rows and columns must be positive integers.")
return

matrix = read_matrix(m, n)
if matrix is None:
return

transposed = transpose_matrix(matrix)

print_matrix(transposed)

except ValueError:
print("Invalid input! Please enter integers for the number of rows and columns.")
except Exception as e:
print(f"An error occurred: {e}")

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:08:31

# Write Code from Scratch
def read_matrix(m, n):

matrix = []
for i in range(m):
row = []
for j in range(n):
try:
ele = int(input())
row.append(ele)
except ValueError:
print()
return None
matrix.append(row)
return matrix

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(row)

def main():
try:
m = int(input())
n = int(input())

if m <= 0 or n <= 0:
print("Number of rows and columns must be positive integers.")
return

matrix = read_matrix(m, n)
if matrix is None:
return

transposed = transpose_matrix(matrix)

print_matrix(transposed)

except ValueError:
print("Invalid input! Please enter integers for the number of rows and columns.")
except Exception as e:
print(f"An error occurred: {e}")

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:16:15

# Write Code from Scratch
def read_matrix():
"""Reads a matrix from user input."""
try:
# Read the dimensions
m, n = map(int, input().split())

if m <= 0 or n <= 0:
return None

matrix = []

# Read the matrix elements
print(f"Enter the matrix elements ({m} rows and {n} columns):")
for i in range(m):
row = list(map(int, input().split()))
if len(row) != n:
print(f"Error: Expected {n} elements in row {i}, but got {len(row)}.")
return None
matrix.append(row)

return matrix

except ValueError:
print("Invalid input! Please enter integers for dimensions and matrix elements.")
return None

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(" ".join(map(str, row)))

def main():
matrix = read_matrix()
if matrix is None:
return

transposed = transpose_matrix(matrix)

print_matrix(transposed)

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:17:23

# Write Code from Scratch
def read_matrix():
"""Reads a matrix from user input."""
try:
# Read the dimensions
m, n = map(int, input().split())

if m <= 0 or n <= 0:
return None

matrix = []

# Read the matrix elements

for i in range(m):
row = list(map(int, input().split()))
if len(row) != n:
print(f"Error: Expected {n} elements in row {i}, but got {len(row)}.")
return None
matrix.append(row)

return matrix

except ValueError:
print("Invalid input! Please enter integers for dimensions and matrix elements.")
return None

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(" ".join(map(str, row)))

def main():
matrix = read_matrix()
if matrix is None:
return

transposed = transpose_matrix(matrix)

print_matrix(transposed)

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:19:30

def is_power_of_two(n:int) -> int:
# Write your logic here
def is_power_of_two(n):
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))



def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:20:24

def is_power_of_two(n):
if n==1 or n==2:
return "true"
elif n<2:
return "false"

return is_power_of_two(n**(1/2))

def main():
n = int(input().strip())

# Determine if n is a power of two
print(is_power_of_two(n))

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:27:33

def read_matrix():
"""Reads a matrix from user input."""
try:
# Read the dimensions
m, n = map(int, input().split())

if m <= 0 or n <= 0:

return None

matrix = []

# Read the matrix elements

for i in range(m):
row = list(map(int, input().split()))
if len(row) != n:
print(f"Error: Expected {n} elements in row {i}, but got {len(row)}.")
return None
matrix.append(row)

return matrix

except ValueError:
print("Invalid input! Please enter integers for dimensions and matrix elements.")
return None

def transpose_matrix(matrix):
"""Transposes the given matrix."""
if not matrix:
return []
m = len(matrix)
n = len(matrix[0])
transposed = [[0] * m for _ in range(n)]
for i in range(m):
for j in range(n):
transposed[j][i] = matrix[i][j]
return transposed

def print_matrix(matrix):
"""Prints the matrix."""
for row in matrix:
print(" ".join(map(str, row)))

def main():
matrix = read_matrix()
if matrix is None:
return

transposed = transpose_matrix(matrix)

print_matrix(transposed)

if __name__ == "__main__":
main()

Submission at 2024-09-09 08:40:56

def read_array(size):
"""Reads an array of integers from user input."""
return [int(input()) for _ in range(size)]

def are_permutations(arr1, arr2):
"""Checks if two arrays are permutations of each other."""
if len(arr1) != len(arr2):
return False
return sorted(arr1) == sorted(arr2)

def main():
# Read sizes of the arrays
n,n1 = map(int(input().split()))


if n != n1:
print(False)
return

# Read the arrays

arr1 = read_array(n)


arr2 = read_array(n1)

# Check if arrays are permutations of each other
if are_permutations(arr1, arr2):
print(True)
else:
print(False)

if __name__ == "__main__":
main()


Submission at 2024-09-09 08:43:02

def read_array(size):
"""Reads an array of integers from user input."""
return list(map(int, input().split()))

def are_permutations(arr1, arr2):
"""Checks if two arrays are permutations of each other."""
if len(arr1) != len(arr2):
return False
return sorted(arr1) == sorted(arr2)

def main():
# Read sizes of the arrays
sizes = input().strip()
n, n1 = map(int, sizes.split())

if n != n1:
print(False)
return

# Read the arrays
arr1 = read_array(n)
arr2 = read_array(n1)

# Check if arrays are permutations of each other
if are_permutations(arr1, arr2):
print(True)
else:
print(False)

if __name__ == "__main__":
main()


Submission at 2024-09-09 10:35:29

def read_array():
"""Reads an array of integers from input."""
return list(map(int, input().split()))

def main():
# Read the sizes of the two arrays
try:
n, n1 = map(int, input().split())
arr1 = read_array()
if len(arr1) != n:
return

arr2 = read_array()
if len(arr2) != n1:
return

arr1.sort()
arr2.sort()
if arr1 == arr2:
print("true")
else:
print("false")

except ValueError:
print("Invalid input format. Please enter integers separated by spaces.")
except EOFError:
print("No input provided")

if __name__ == "__main__":
main()

Submission at 2024-09-09 10:37:54

n=int(input())
count=0

for i in range(1,n+1):
if i%3==0 or i%5==0 or i%7==0:
count=count+i
print(count)

Submission at 2024-09-09 10:48:08

def read_array():
return list(map(int, input().split()))
def main():
try:
count=0
n=int(input())
list1=read_array()
for i in range(len(list1)):
if len(str(list1[i]))%2==0:
count=count+1
print(count)

except EOFError:
print("No input provided")
if __name__ == "__main__":
main()

Submission at 2024-09-09 10:54:32

# write from scratch, create a function named Pow(x:int , n:int)
def pow(x, n):
# Ensure n is an integer for exponentiation

if -1000 <= x <= 1000 and -1000 < n < 1000:
return x ** n
else:
return pow(x,n)

def main():
try:
x,n = map(float,input().split())
# Convert to integer
result=pow(x, n)
print(int(result)) # Convert the result to integer before printing
except ValueError:
print("Invalid input. Please enter valid numbers.")

if __name__ == "__main__":
main()

Submission at 2024-09-09 11:03:40

# Write code from scratch
def read_array():
return list(map(int,input().split()))
def main():
try:
n=int(input())
list1= read_array()
list2= read_array()
list3=list1
for i in range(len(list1)):
list3[i]=max(list1[i],list2[i])
print(list3)
except EOFError:
print("Invalid")
if __name__=="__main__":
main()

Submission at 2024-09-09 11:05:10

# Write code from scratch
def read_array():
"""Reads a line of input and converts it to a list of integers."""
return list(map(int, input().split()))

def main():
try:
# Read the size of the lists
n = int(input())

# Read the two lists
list1 = read_array()
list2 = read_array()

# Ensure both lists have the expected length
if len(list1) != n or len(list2) != n:
print("Invalid input lengths")
return

# Create list3 where each element is the max of corresponding elements from list1 and list2
list3 = [max(list1[i], list2[i]) for i in range(n)]

# Print the resulting list
print(list3)

except ValueError:
print("Invalid input format")
except EOFError:
print("No input provided")

if __name__ == "__main__":
main()

Submission at 2024-09-09 11:06:51

# Write code from scratch
def read_array():
"""Reads a line of input and converts it to a list of integers."""
return list(map(int, input().split()))

def main():
try:
# Read the size of the lists
n = int(input().strip())

# Read the two lists
list1 = read_array()
list2 = read_array()

# Check if both lists have the length equal to n
if len(list1) != n or len(list2) != n:
print("Invalid input lengths")
return

# Create list3 where each element is the max of corresponding elements from list1 and list2
list3 = [max(list1[i], list2[i]) for i in range(n)]

# Print the resulting list
print(" ".join(map(str, list3)))

except ValueError:
print("Invalid input format")
except EOFError:
print("No input provided")

if __name__ == "__main__":
main()

Submission at 2024-09-09 11:08:32

# Write code from scratch
def read_array():
"""Reads a line of input and converts it to a list of integers."""
return list(map(int, input().split()))

def main():
try:
# Read the size of the lists
n = int(input().strip())

# Read the two lists
list1 = read_array()
list2 = read_array()

# Check if both lists have the length equal to n
if len(list1) != n or len(list2) != n:
print("Invalid input lengths")
return

# Create list3 where each element is the max of corresponding elements from list1 and list2
list3 = [max(list1[i], list2[i]) for i in range(n)]

# Print the resulting list
print(list3)


except EOFError:
print("No input provided")

if __name__ == "__main__":
main()

Submission at 2024-09-09 11:10:00

# Write code from scratch
def read_array():
"""Reads a line of input and converts it to a list of integers."""
return list(map(int, input().split()))

def main():
try:
# Read the size of the lists
n = int(input().strip())

# Read the two lists
list1 = read_array()
list2 = read_array()

# Check if both lists have the length equal to n
if len(list1) != n or len(list2) != n:
print("Invalid input lengths")
return

# Create list3 where each element is the max of corresponding elements from list1 and list2
list3 = [max(list1[i], list2[i]) for i in range(n)]

# Print the resulting list
print(" ".join(map(str,list3)))


except EOFError:
print("No input provided")

if __name__ == "__main__":
main()

Submission at 2024-09-09 11:33:50

# Write Code from Scratch here
def ispowerofthree(n):
if n <= 0:
return False
if n == 1:
return True
if n%3==0:
return True
else:
return False
return ispowerofthree(n//3)
def main():
n=int(input().strip())
print(ispowerofthree(n))

if __name__=="__main__":
main()


Submission at 2024-09-09 11:40:35

# Write code from scratch here

def count_fre(str1,n):
count=0
for i in range(len(str1)):
if n==str1[i]:
return count=count+1
else:
return count_fre(str1,n)
def main():
str1,n=map(input().split())
print(count_fre(str1,n))
if __name__=="__main__":
main()



Submission at 2024-09-11 07:05:09

# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def read_array(n):
try:
return list(map(int, input().split()))
except ValueError:
print("Invalid input. Please enter integers only.")
return []
def traverse_linked_list(head):
result=[]
while head!=None:
print(head.val,end=" ")
head=head.next
result.append(head)
return result

def main():
try:
n=int(input().strip())
l=read_array(n)
head=ListNode(l[0])
current=head
for i in l[1:]:
current.next=ListNode(i)
current=current.next
print(traverse_linked_list(head))
except EOFError:
print("Input was not provided or input ended unexpectedly.")
except ValueError:
print("Invalid input. Please ensure you enter a valid integer for the number of elements.")
if __name__=="__main__":
main()

Submission at 2024-09-11 07:15:06

def subsets(nums):
if nums == []:
return [[]]
x = subsets(nums[1:])
return x + [[nums[0]] + y for y in x]



def main():
line = input().strip()
nums = list(map(int, line.split()))

# Generate all subsets
result = subsets(nums)

# Sort subsets based on size and first element
result.sort(key=lambda x: (len(x), x if x else float('inf')))

# Print subsets
for subset in result:
print(subset)

if __name__ == "__main__":
main()

Submission at 2024-09-11 07:56:45

# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def read_array(n):
return list(map(int,input().split()))
def get_nth_node(head, index):

if head is None:
print(-1)

if index == 1:
print(head.val)
else:
get_nth_node(head.next, index-1)

def main():
n=int(input().strip())
l=read_array(n)
k=int(input().strip())
head=ListNode(l[0])
return get_nth_node(head,k)

if __name__=="__main__":
main()

Submission at 2024-09-11 07:58:34

# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next

def read_array(n):
return list(map(int, input().split()))

def get_nth_node(head, index):
current = head
count = 1
while current is not None:
if count == index:
print(current.val)
return
current = current.next
count += 1
print(-1) # Index is out of bounds

def main():
n = int(input().strip())
l = read_array(n)
k = int(input().strip())

if not l:
print(-1)
return

# Create the linked list from the array
head = ListNode(l[0])
current = head
for value in l[1:]:
current.next = ListNode(value)
current = current.next

get_nth_node(head, k)

if __name__ == "__main__":
main()

Submission at 2024-09-11 08:14:04

# Write code from scratch here
def count_fre(str1,n):
count=0
if not str1:
return 0
for i in str1:
if i==n:
count=count+1
return count
return count_fre(str1,n)


def main():
str1,n=input().split()

print(count_fre(str1,n))
if __name__=="__main__":
main()

Submission at 2024-10-04 05:47:21

# Write Python code from scratch
def wait(temperature,n):
n=len(temperature)
m=max(temperature)
j=0
answer=[]
for i in range(len(temperature)):
if temperature[i]<m:
if m==temperature[i]:
j=i
i=i-j

answer.append(i)
else:
answer.append(0)
return answer
def read_array():
return list(map(int,input().split()))
def print_array(t):
print(t,end=" ")
def main():
n=int(input().strip())
temp=read_array()
t=wait(temp,n)
print_array(t)
main()

Submission at 2024-10-04 05:52:54

# Write Python Code from scratch
def t(bloomDay,n,k):
low=0
high=max(bloomDay)
while low<=high:
mid=low+high//2
for i in bloomDay:
if i>mid:
n+=1
low=mid+1
else:
high=mid-1

Submission at 2024-10-04 06:01:36

# Write Python code from scratch
def anagram(s,t):
if len(s)==len(t):
for i in range(len(s)):
for j in range(len(t)):
if s[i]==t[j]:
return True
else:
return False
else:
return False
def main():
s=input().strip()
t=input().strip()
print(anagram(s,t))
main()

Submission at 2024-10-04 06:18:40

# Write code from scratch here
def wait(array,n,k):
n=len(array)
t=1
c=0
for i in range(n):
if array[i]==k:
if k>1:
t=array[i]-1
k=k-1
c=c+1
array.append(k)
del array[i]
if k==0:
array.pop()
c=c+1
return c
def read_array():
return list(map(int,input().split()))
def main():
n=int(input().strip())
array=read_array()
k=int(input().strip())
print(wait(array,n,k))
main()

Submission at 2024-10-16 08:02:25

def daily_temperatures(temperatures):
n = len(temperatures)
answer = [0] * n # Initialize the answer array with 0s

for i in range(n):
# Check for the next warmer temperature
for j in range(i + 1, n):
if temperatures[j] > temperatures[i]:
answer[i] = j - i # Number of days to wait
break # Break out once we find the next warmer temperature

return answer

def read_array():
return list(map(int, input().split()))

def print_array(arr):
print(" ".join(map(str, arr))) # Print the array as space-separated values

def main():
n = int(input().strip())
temperatures = read_array() # Read the array of temperatures
result = daily_temperatures(temperatures) # Get the result
print_array(result) # Print the result

main()

Submission at 2024-10-16 08:08:11

# Write Python Code from scratch
def min_days(bloomDay, m, k):
n = len(bloomDay)

# Edge case: if we need more bouquets than we have flowers
if m * k > n:
return -1

# Binary search bounds
low, high = min(bloomDay), max(bloomDay)

def can_make_bouquets(mid):
bouquets = 0
flowers = 0

for day in bloomDay:
if day <= mid: # If the flower has bloomed by 'mid'
flowers += 1 # Increment the count of blooming flowers
# If we have enough adjacent flowers to make a bouquet
if flowers == k:
bouquets += 1 # We can make one bouquet
flowers = 0 # Reset the count for the next bouquet
else:
flowers = 0 # Reset if we hit a flower that has not bloomed

return bouquets >= m # Return True if we can make at least m bouquets

# Binary search to find the minimum number of days
while low < high:
mid = (low + high) // 2
if can_make_bouquets(mid):
high = mid # Try for an earlier day
else:
low = mid + 1 # Move to a later day

return low # Return the minimum day found

def main():
# Read input values
n, m, k = map(int, input().split())
bloomDay = list(map(int, input().split()))

# Get the minimum days to make m bouquets
result = min_days(bloomDay, m, k)

# Print the result
print(result)

# Example usage:
main()

Submission at 2024-10-16 08:09:57

# Write Python code from scratch
def anagram(s, t):
# If lengths are not the same, they can't be anagrams
if len(s) != len(t):
return False

# Create a dictionary to count the occurrences of each character
char_count = {}

# Count characters in the first string
for char in s:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1

# Decrease the count based on the second string
for char in t:
if char in char_count:
char_count[char] -= 1
else:
return False # Found a character in t not in s

# Check if all counts are zero
for count in char_count.values():
if count != 0:
return False

return True

def main():
s = input().strip()
t = input().strip()
print(anagram(s, t))

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:11:26

# Write Python code from scratch
def anagram(s, t):
# If lengths are not the same, they can't be anagrams
if len(s) != len(t):
return "false"

# Create a dictionary to count the occurrences of each character
char_count = {}

# Count characters in the first string
for char in s:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1

# Decrease the count based on the second string
for char in t:
if char in char_count:
char_count[char] -= 1
else:
return "false" # Found a character in t not in s

# Check if all counts are zero
for count in char_count.values():
if count != 0:
return "false"

return "true"

def main():
s = input().strip()
t = input().strip()
print(anagram(s, t))

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:14:14

# Write code from scratch here
def time_to_buy_tickets(tickets, k):
time = 0
while tickets[k] > 0: # While the k-th person has tickets left to buy
for i in range(len(tickets)):
if tickets[i] > 0: # Only consider people who still need to buy tickets
time += 1 # Increment the time for each ticket buying operation
tickets[i] -= 1 # Person buys one ticket
# If the current person is the one we're interested in
if i == k and tickets[i] == 0: # Check if they have finished buying
return time # Return the total time taken
return time # Just a fallback, though the loop should return first

def read_array():
return list(map(int, input().split()))

def main():
n = int(input().strip()) # Read the number of people
tickets = read_array() # Read the tickets array
k = int(input().strip()) # Read the position k
result = time_to_buy_tickets(tickets, k) # Calculate the time for the k-th person
print(result) # Print the result

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:19:19

# Write code from scratch.
def minimum_sum(num):
# Convert the number to a list of its digits
digits = [int(d) for d in str(num)]

# Sort the digits in ascending order
digits.sort()

# Create two new numbers from the sorted digits
new1 = digits[0] * 10 + digits[2] # Forming the first number
new2 = digits[1] * 10 + digits[3] # Forming the second number

# Return the minimum sum of new1 and new2
return new1 + new2

def main():
num = int(input().strip()) # Read the four-digit number from input
result = minimum_sum(num) # Get the minimum sum
print(result) # Print the result

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:25:55

# Write code from scratch.
def minimum_sum(num):
# Convert the number to a list of its digits
digits = []
for d in str(num):
digits.append(int(d))

# Sort the digits in ascending order
digits.sort()

# Create two new numbers from the sorted digits
new1 = digits[0] * 10 + digits[2] # Forming the first number
new2 = digits[1] * 10 + digits[3] # Forming the second number

# Return the minimum sum of new1 and new2
return new1 + new2

def main():
num = int(input().strip()) # Read the four-digit number from input
result = minimum_sum(num) # Get the minimum sum
print(result) # Print the result

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:26:20

# Write code from scratch.
def minimum_sum(num):
# Convert the number to a list of its digits
digits = []
for d in str(num):
digits.append(int(d))

# Sort the digits in ascending order
digits.sort()

# Create two new numbers from the sorted digits
new1 = digits[0] * 10 + digits[2] # Forming the first number
new2 = digits[1] * 10 + digits[3] # Forming the second number

# Return the minimum sum of new1 and new2
return new1 + new2

def main():
num = int(input().strip()) # Read the four-digit number from input
result = minimum_sum(num) # Get the minimum sum
print(result) # Print the result

# Call the main function to execute the program
main()

Submission at 2024-10-16 08:35:24

from collections import deque # Don't touch this line

def rev(n,q):
str1=str(q)
str2=str1.reverse()
v=[]
for i in str2:
v.append(int(i))
return v
def read_array():
return list(map(int,input.split()))
def print_array(arr):
print(" ".join(map(str, arr)))

def main():
n = int(input.strip())
q = read_array()
print_array(n,q)
main()




Submission at 2024-10-16 08:36:56

from collections import deque  # Don't touch this line

def rev(q):
# Reverse the deque using the reverse method
q.reverse()
# Convert deque to a list of integers
return list(q)

def read_array():
# Fixing the input reading to use input() function correctly
return list(map(int, input().split()))

def print_array(arr):
# Printing the array in a space-separated format
print(" ".join(map(str, arr)))

def main():
n = int(input().strip()) # Read the size of the array
q = deque(read_array()) # Read the array into a deque
reversed_array = rev(q) # Reverse the deque
print_array(reversed_array) # Print the reversed array

main()




Submission at 2024-10-23 04:33:14

# Write Python code from scratch
def min_poison_duration(n, h, attack_times):
# Binary search on the minimum poison duration k
low, high = 1, h

while low < high:
mid = (low + high) // 2
total_damage = 0

# Calculate the total damage for current k = mid
for i in range(n - 1):
total_damage += min(mid, attack_times[i+1] - attack_times[i])

total_damage += mid # The last attack always contributes `mid` damage

# Check if the total damage is enough
if total_damage >= h:
high = mid # Try smaller k
else:
low = mid + 1 # Increase k

return low

# Input Reading
n, h = map(int, input().split())
attack_times = list(map(int, input().split()))

# Output the result
print(min_poison_duration(n, h, attack_times))

Submission at 2024-10-25 05:30:51

# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
for i in range(len(t)):
char=s[i]
if char in char_count:
return "true"
elif char not

Submission at 2024-10-25 05:38:33

# write code from scratch
def compare(s,t):

for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 05:39:03

# write code from scratch
def compare(s,t):

for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 05:39:23

# write code from scratch
def compare(s,t):

for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 05:39:36

# write code from scratch
def compare(s,t):

for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 05:39:59

# write code from scratch
def compare(s,t):

for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 05:45:47

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
stack.append(node.right)
stack.append(node.left)
peek=stack[-1]
elif peek.node.right and


# code here

Submission at 2024-10-25 05:45:51

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
stack.append(node.right)
stack.append(node.left)
peek=stack[-1]
elif peek.node.right and


# code here

Submission at 2024-10-25 05:59:32


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 05:59:33


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 05:59:50


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:00:13


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:00:28


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:00:44


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:01:04


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:01:23


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:01:41


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:02:12


# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:05:55

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.right is not node.right:
return "true"
else:
return "false"
# Your Code Here

Submission at 2024-10-25 06:06:24

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.right is not node.right:
return "true"
else:
return "false"
# Your Code Here

Submission at 2024-10-25 06:06:41

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.right is not node.right:
return "true"
else:
return "false"
# Your Code Here

Submission at 2024-10-25 06:12:24

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
ans.append(node.left)
stack.append(node.right)
node=node.left
else:
node=stack.pop()
return ans




# code here
# code here

Submission at 2024-10-25 06:14:07

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
ans.append(node.left.val)
stack.append(node.right.val)
node=node.left.val
else:
node=stack.pop()
return ans




# code here
# code here

Submission at 2024-10-25 06:16:55

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.left is not node.right:
return "false"
else:
return "true"
# Your Code Here

Submission at 2024-10-25 06:17:12

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.left is not node.right:
return "false"
else:
return "true"
# Your Code Here

Submission at 2024-10-25 06:17:24

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isSymmetric(self, root):
node=root
if node.left is not node.right:
return "false"
else:
return "true"
# Your Code Here

Submission at 2024-10-25 06:35:39

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
ans.append(node.left)

node=node.left
else:
stack.append(node.right)
node=stack.pop()
return ans




# code here
# code here

Submission at 2024-10-25 06:46:15

# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
for i,(char,word) in enumerate(char_count):
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:46:58

# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
for i,(char,word) in enumerate(char_count):
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:46:58

# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
for i,(char,word) in enumerate(char_count):
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:47:58

# write code from scratch
def wordpattern(s,t):
s.split()
char_count={}
word_count={}
if len(s)!=len(t):
return "false"
for i in range(len(t)):
char=s[i]
word=t[i]
if char in char_count.keys() and word in char_count.values():
return "true"
else:
return "false"


def main():
s=input().strip()
t=input()
print(wordpattern(s,t))
main()

Submission at 2024-10-25 06:57:23

'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''

#Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
node=root
listvisited=None
stack=[]
ans=[]
if not node:
return
while stack or node:
if node:
stack.append(node.right)
stack.append(node.left)
peek=stack[-1]
if peek.right!=listvisited and postOrder(peek.right)!=listvisited:
ans.append(node.left)
return [ans]


# code here


# code here

Submission at 2024-10-25 06:58:22

# write code from scratch
def compare(s,t):
for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 06:58:38

# write code from scratch
def compare(s,t):
for i in range(len(t)):
if s[i] not in t:
return "false"
else:
return "true"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 07:01:10

# write code from scratch
def compare(s,t):
for i in range(len(t)):
count=0
if s[i] in t:
count=+1
if count>1:
return "false"
else:
return "true"
else:
return "false"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 07:01:47

# write code from scratch
def compare(s,t):
for i in range(len(t)):
count=0
if s[i] in t:
count=+1
if count>1:
return "false"
else:
return "true"
else:
return "false"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 07:02:55

# write code from scratch
def compare(s,t):
for i in range(len(t)):
count=0
if s[i] not in t:
return "false"
else:
return "false"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-10-25 07:03:10

# write code from scratch
def compare(s,t):
for i in range(len(t)):
count=0
if s[i] not in t:
return "false"
else:
return "false"
def main():
ransomNote=input().strip()
magazine=input().strip()
print(compare(ransomNote,magazine))
main()

Submission at 2024-11-04 07:57:08

# write code from scratch
def wordpattern(s, t):
words = t.split() # Split the string t into words
char_count = {}
word_count = {}

if len(s) != len(words): # Check if lengths match
return "false"

for i in range(len(s)):
char = s[i]
word = words[i]

# Check the mapping for characters to words
if char in char_count:
if char_count[char] != word:
return "false" # Different word for the same character
else:
char_count[char] = word # Map the character to the word

# Check the mapping for words to characters
if word in word_count:
if word_count[word] != char:
return "false" # Different character for the same word
else:
word_count[word] = char # Map the word to the character

return "true" # If all checks pass, the mapping is consistent

def main():
s = input().strip()
t = input().strip()
print(wordpattern(s, t))

main()

Submission at 2024-11-04 07:58:46

# write code from scratch
def compare(s, t):
char_count = {}

# Count characters in the magazine (t)
for char in t:
if char in char_count:
char_count[char] += 1
else:
char_count[char] = 1

# Check if we can create the ransom note (s)
for char in s:
if char in char_count and char_count[char] > 0:
char_count[char] -= 1 # Use one occurrence of the character
else:
return "false" # Not enough characters to create the ransom note

return "true" # All characters matched

def main():
ransomNote = input().strip()
magazine = input().strip()
print(compare(ransomNote, magazine))

main()

Submission at 2024-11-04 08:01:25

# Node Class:
class Node:
def __init__(self, val):
self.data = val
self.left = None
self.right = None

# Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
if not root:
return []

stack = []
ans = []
last_visited = None # Keep track of the last visited node

while stack or root:
# Go to the leftmost node
while root:
stack.append(root)
root = root.left

# Peek the node from the stack
peek = stack[-1]

# If the right child is null or already visited, visit the node
if not peek.right or peek.right == last_visited:
ans.append(peek.data) # Add the node's value to the result
last_visited = stack.pop() # Mark this node as visited
else:
# Move to the right child
root = peek.right

return ans # Return the post-order traversal list

# Example usage:
def main():
# Creating a sample tree
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)

# Performing post-order traversal
print(postOrder(root)) # Output: [4, 5, 2, 3, 1]

main()

Submission at 2024-11-04 08:02:31

# Node Class:
class Node:
def __init__(self, val):
self.data = val
self.left = None
self.right = None

# Function to return a list containing the postorder traversal of the tree.
def postOrder(root):
if not root:
return []

stack = []
ans = []
last_visited = None # Keep track of the last visited node

while stack or root:
# Go to the leftmost node
while root:
stack.append(root)
root = root.left

# Peek the node from the stack
peek = stack[-1]

# If the right child is null or already visited, visit the node
if not peek.right or peek.right == last_visited:
ans.append(peek.data) # Add the node's value to the result
last_visited = stack.pop() # Mark this node as visited
else:
# Move to the right child
root = peek.right

return ans # Return the post-order traversal list



Submission at 2024-11-04 08:04:12

# Definition for a singly linked list node.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next

def addTwoNumbers(l1: ListNode, l2: ListNode) -> ListNode:
# Initialize a dummy head for the result linked list
dummy_head = ListNode(0)
current = dummy_head
carry = 0 # This will hold the carry value during addition

# Traverse both linked lists
while l1 or l2 or carry:
# Get the values from the current nodes, defaulting to 0 if None
val1 = l1.val if l1 else 0
val2 = l2.val if l2 else 0

# Calculate the sum of the two values and the carry
total = val1 + val2 + carry
carry = total // 10 # Calculate new carry
current.next = ListNode(total % 10) # Create a new node with the digit

# Move the current pointer to the next node
current = current.next

# Move to the next nodes in l1 and l2, if available
if l1:
l1 = l1.next
if l2:
l2 = l2.next

return dummy_head.next # Return the next node of dummy head as the result

# Example Usage
def print_linked_list(head):
while head:
print(head.val, end=" -> ")
head = head.next
print("None")

Submission at 2024-11-04 08:05:01

# Definition for a singly linked list node.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def addTwoNumbers(l1: ListNode, l2: ListNode) -> ListNode:
# Initialize a dummy head for the result linked list
dummy_head = ListNode(0)
current = dummy_head
carry = 0 # This will hold the carry value during addition

# Traverse both linked lists
while l1 or l2 or carry:
# Get the values from the current nodes, defaulting to 0 if None
val1 = l1.val if l1 else 0
val2 = l2.val if l2 else 0

# Calculate the sum of the two values and the carry
total = val1 + val2 + carry
carry = total // 10 # Calculate new carry
current.next = ListNode(total % 10) # Create a new node with the digit

# Move the current pointer to the next node
current = current.next

# Move to the next nodes in l1 and l2, if available
if l1:
l1 = l1.next
if l2:
l2 = l2.next

return dummy_head.next # Return the next node of dummy head as the result

# Example Usage
def print_linked_list(head):
while head:
print(head.val, end=" -> ")
head = head.next
print("None")

Submission at 2024-11-04 08:08:34

class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next

class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
# Initialize a dummy head for the result linked list
dummy_head = ListNode(0)
current = dummy_head
carry = 0 # This will hold the carry value during addition

# Traverse both linked lists
while l1 or l2 or carry:
# Get the values from the current nodes, defaulting to 0 if None
val1 = l1.val if l1 else 0
val2 = l2.val if l2 else 0

# Calculate the sum of the two values and the carry
total = val1 + val2 + carry
carry = total // 10 # Calculate new carry
current.next = ListNode(total % 10) # Create a new node with the digit

# Move the current pointer to the next node
current = current.next

# Move to the next nodes in l1 and l2, if available
if l1:
l1 = l1.next
if l2:
l2 = l2.next

return dummy_head.next # Return the next node of dummy head as the result

@staticmethod
def print_linked_list(head):
while head:
print(head.val, end=" -> ")
head = head.next
print("None")

# Example usage:
def main():
# Creating two linked lists for the numbers 342 and 465
l1 = ListNode(2)
l1.next = ListNode(4)
l1.next.next = ListNode(3)

l2 = ListNode(5)
l2.next = ListNode(6)
l2.next.next = ListNode(4)

# Create an instance of Solution
solution = Solution()

# Adding the two numbers
result = solution.addTwoNumbers(l1, l2)

# Print the result linked list
solution.print_linked_list(result) # Output should be 7 -> 0 -> 8 -> None

if __name__ == "__main__":
main()



Submission at 2024-11-04 08:10:31

# Write your code from scratch here
def custom_permutation(order: str, s: str) -> str:
# Create a dictionary to count occurrences of each character in s
count = {}
for char in s:
if char in count:
count[char] += 1
else:
count[char] = 1

# Build the result based on the order string
result = []
for char in order:
if char in count:
result.append(char * count[char]) # Append the character multiplied by its count

# Append characters not in order, preserving their order in s
for char in s:
if char not in order and char in count:
result.append(char * count[char]) # Append remaining characters

return ''.join(result) # Join the list into a string and return it

# Example usage
def main():
# Input format: two space-separated strings
input_data = input().strip().split()
order = input_data[0]
s = input_data[1]

# Get the custom permutation
result = custom_permutation(order, s)

# Print the result
print(result)

if __name__ == "__main__":
main()

Submission at 2024-11-04 08:11:21

# Write your code from scratch here
def custom_permutation(order: str, s: str) -> str:
# Create a dictionary to count occurrences of each character in s
count = {}
for char in s:
if char in count:
count[char] += 1
else:
count[char] = 1

# Build the result based on the order string
result = []
for char in order:
if char in count:
result.append(char * count[char]) # Append the character multiplied by its count

# Append characters not in order, preserving their order in s
for char in s:
if char not in order and char in count:
result.append(char * count[char]) # Append remaining characters

return ''.join(result) # Join the list into a string and return it

# Example usage
def main():
# Input format: two space-separated strings
input_data = input().strip().split()
order = input_data[0]
s = input_data[1]

# Get the custom permutation
result = custom_permutation(order, s)

# Print the result
print(result)

if __name__ == "__main__":
main()

Submission at 2024-11-04 08:13:15

# Write code from scratch
def max_candy_types(candyType):
# Calculate the number of candies
n = len(candyType)

# Count unique types of candies
unique_types = len(set(candyType))

# Alice can eat n / 2 candies
max_eatable = n // 2

# The maximum different types she can eat is the minimum of unique types and half the candies
return min(unique_types, max_eatable)

# Example usage
def main():
# Read the number of candies
n = int(input().strip())

# Read the candy types
candyType = list(map(int, input().strip().split()))

# Get the maximum number of different candy types
result = max_candy_types(candyType)

# Print the result
print(result)

if __name__ == "__main__":
main()

Submission at 2024-11-04 08:15:12

# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next

def findIntersection(head1, head2):
# Create a dummy node to facilitate the result linked list
dummy = ListNode(0)
current = dummy

# Pointers for both linked lists
pointer1 = head1
pointer2 = head2

# Iterate through both linked lists
while pointer1 and pointer2:
if pointer1.val == pointer2.val:
# If values are equal, add to the intersection list
current.next = ListNode(pointer1.val)
current = current.next

# Move both pointers forward
pointer1 = pointer1.next
pointer2 = pointer2.next
elif pointer1.val < pointer2.val:
# Move pointer1 forward
pointer1 = pointer1.next
else:
# Move pointer2 forward
pointer2 = pointer2.next

# Return the next node of the dummy, which is the head of the result list
return dummy.next



Submission at 2024-11-22 05:05:07

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))
def main():

a,b=input().split()
print(minimize(int(a),int(b))

main()

Submission at 2024-11-22 05:06:28

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))
def main():
for i in range(2):
a,b=input().split()
print(minimize(int(a),int(b))

print(main())

Submission at 2024-11-22 05:18:20

# write code from scratch
def dist(arr1,arr2,d):
for i range(m):
for j in range(n):
count=arr1[i]
if arr1[i]-arr2[j]>=d:
count+=1
return count
def read_array():
return list(map(int(),input().split()))

def main():
m,n,d=input().split(" ")
arr1.read_array()
arr2.read_array()
print(dist(arr1,arr2,d))


Submission at 2024-11-22 05:24:46

# write code from scratch
def dist(arr1,arr2,d):
for i in range(m):
for j in range(n):
count=arr1[i]
if arr1[i]-arr2[j]>=d:
count+=1
return count
def read_array():
return list(map(int(),input().split()))

def main():
m,n,d=map(int(),input().split())
arr1=read_array()
arr2=read_array()
print(dist(arr1,arr2,int(d))

main()

Submission at 2024-11-22 05:30:35

# Write Code From Scratch Here
def sum1(arr):
for i in arr:
i=i+1
return i
def read_array():
return list(map(int(),input.split()))

n=int(input().strip())
arr=read_array()
print(sum1(arr))

Submission at 2024-11-22 05:34:11

# Write Code From Scratch Here
def sum1(arr):
for i in arr:
i=i+1
return i
def read_array():
return list(map(int(),input.split()))
def main():
n=int(input().strip())
arr=read_array()
print(sum1(arr))

main()

Submission at 2024-11-22 05:35:41

# Write Code From Scratch Here
def sum1(arr,n):
for i in range(n):
arr[i]=arr[i+1]+arr[i]
return arr[i]
def read_array():
return list(map(int(),input.split()))
def main():
n=int(input().strip())
arr=read_array()
print(sum1(arr))

main()

Submission at 2024-11-22 05:36:16

# Write Code From Scratch Here
def sum1(arr,n):
for i in range(n-1):
arr[i]=arr[i+1]+arr[i]
return arr[i]
def read_array():
return list(map(int(),input.split()))
def main():
n=int(input().strip())
arr=read_array()
print(sum1(arr,n))

main()

Submission at 2024-11-22 05:37:48

# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int(),input.split()))
def main():
n=int(input().strip())
arr=read_array()
print(sum1(arr,n))

main()

Submission at 2024-11-22 05:47:56

# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print("*",end=" ")
for k in range(2*i-1,0,-1):
print("*",end="")
print("*",end="")

Submission at 2024-11-22 05:55:52

# write code from scratch
n=int(input().strip())
arr1=list(map(int(),input().split()))
dict1={}
for char in dict1:
if char in arr1:
dict1[arr1[char]]+=1
else:
dict1[arr1[char]]=1

c=min(dict1[arr1[char]])
print(c)


for i range(len(arr1)):
print(min(arr1))

Submission at 2024-11-22 06:01:30

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isBST(self, root):

if not root:
return false

else:
return false
# Your Code Here

Submission at 2024-11-22 06:05:37

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isBST(self, root,key):
if not root:
return "false"




else:
return "true"
# Your Code Here

Submission at 2024-11-22 06:07:28

'''
class Node:
def __init__(self, val):
self.right = None
self.data = val
self.left = None
'''

class Solution:
def isBST(self, root):
if not root:
return "false"
if root.left<root and root.right>root:
return "true"
else:
return "false"
# Your Code Here

Submission at 2024-11-22 06:13:49

# write code from scratch
n=int(input())
arr1=list(map(int().input().split()))
score=0
for i in range(0,n):
for j in range(i,n):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:18

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:18

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:18

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:22

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:22

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:16:25

# write code from scratch
n=input()
arr1=list(map(int().input().split()))
score=0
for i in range(0,int(n)):
for j in range(i,int(n)):
if a[i]==a[j]:
score+=1
print(score)

Submission at 2024-11-22 06:18:01


# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int(),input.split()))
n=int(input().strip())
arr=read_array()
print(sum1(arr,n))


Submission at 2024-11-22 06:19:49


# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int(),input().split()))
n=int(input().strip())
arr=read_array()
print(sum1(arr,n))


Submission at 2024-11-22 06:26:07

# write code from scratch
# write code from scratch
n=int(input().strip())
arr1=list(map(int(),input().split()))
dict1={}
for char in dict1:
if char in arr1:
dict1[arr1[char]]+=1
else:
dict1[arr1[char]]=1

c=min(dict1[arr1[char]])
print(dic1[arr1[char]])


for i range(len(arr1)):
print(min(arr1))

Submission at 2024-11-22 06:31:45

# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int(),input().split()))
n=int(input().strip())
arr=read_array()
print(sum1(arr,n))

Submission at 2024-11-22 06:35:38


# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print(" ")
for k in range(2*i-1,0,-1):
print("*",end=" ")
print(" ")

Submission at 2024-11-22 06:37:59

# Write Code From Scratch Here
# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int(),input().split()))
n=int(input())
arr=read_array()
print(sum1(arr,n))

Submission at 2024-11-22 06:41:00

# Write Code From Scratch Here
def sum1(arr,n):
for i in range(n-1):
arr[i]=arr[i+1]+arr[i]
return sum(arr)
def read_array():
return list(map(int,input().split()))
n=int(input())
arr=read_array()
print(sum1(arr,n))

Submission at 2024-11-22 06:42:09

# Write Code From Scratch Here
def sum1(arr,n):
return sum(arr)
def read_array():
return list(map(int,input().split()))
n=int(input())
arr=read_array()
print(sum1(arr,n))

Submission at 2024-11-22 06:46:57

# Write Code From Scratch Here
# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))
def main():
for i in range(2):
a,b=map(int,input().split())
print(minimize(a,b)

main()

Submission at 2024-11-22 06:46:58

# Write Code From Scratch Here
# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))
def main():
for i in range(2):
a,b=map(int,input().split())
print(minimize(a,b)

main()

Submission at 2024-11-22 06:46:59

# Write Code From Scratch Here
# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))
def main():
for i in range(2):
a,b=map(int,input().split())
print(minimize(a,b)

main()

Submission at 2024-11-22 06:48:59

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))

for i in range(2):
a,b=map(int,input().split())
print(minimize(a,b)


Submission at 2024-11-22 06:49:00

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))

for i in range(2):
a,b=map(int,input().split())
print(minimize(a,b)


Submission at 2024-11-22 06:53:19

# write code from scratch
# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print()
for k in range(2*i-1,0,-1):
print("*",end=" ")
print()

Submission at 2024-11-22 06:53:22

# write code from scratch
# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print()
for k in range(2*i-1,0,-1):
print("*",end=" ")
print()

Submission at 2024-11-22 06:53:23

# write code from scratch
# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print()
for k in range(2*i-1,0,-1):
print("*",end=" ")
print()

Submission at 2024-11-22 06:53:28

# write code from scratch
# write code from scratch
n=int(input())
for i in range(n):
for j in range(0,i):
print("*",end=" ")
print()
for k in range(2*i-1,0,-1):
print("*",end=" ")
print()

Submission at 2024-11-22 06:59:39

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))

def main():
for i in range(2):
try:
a,b=map(int,input().split())
print(minimize(a,b))
main()

Submission at 2024-11-22 07:01:21

# Write Code From Scratch Here
def minimize(a,b):
for c in range(0,b):
return min((c-a)+(b-c))

def main():
for i in range(2):
try:
a,b=map(int,input().split())
print(minimize(a,b))
main()

Submission at 2024-11-22 07:06:07

# write code from scratch
# write code from scratch
def dist(arr1,arr2,d):
for i in range(m):
for j in range(n):
count=arr1[i]
if arr1[i]-arr2[j]>=d:
count+=1
return count
def read_array():
return list(map(int(),input().split()))

def main():
m,n,d=map(int(),input().split())
arr1=read_array()
arr2=read_array()
print(dist(arr1,arr2,int(d))

main()

Submission at 2024-11-22 07:07:26

# write code from scratch
# write code from scratch
def dist(arr1,arr2,d):
for i in range(m):
for j in range(n):
count=arr1[i]
if arr1[i]-arr2[j]>=d:
count+=1
return count
def read_array():
return list(map(int,input().split()))

def main():
m,n,d=map(int,input().split())
arr1=read_array()
arr2=read_array()
print(dist(arr1,arr2,d))

main()

Submission at 2024-11-22 07:07:41

# write code from scratch
# write code from scratch
def dist(m,n,arr1,arr2,d):
for i in range(m):
for j in range(n):
count=arr1[i]
if arr1[i]-arr2[j]>=d:
count+=1
return count
def read_array():
return list(map(int,input().split()))

def main():
m,n,d=map(int,input().split())
arr1=read_array()
arr2=read_array()
print(dist(m,n,arr1,arr2,d))

main()