Posts

Showing posts from February, 2021

Codechef 24

 https://www.codechef.com/MARCH20B/problems/CHPINTU for _ in range(int(input())):     n,m=map(int,input().split())     a=[int(i) for i in input().split()]     b=[int(i) for i in input().split()]     d={}     d=dict(d)     for i in a:         d[i]=0     for i in range(len(a)):         d[a[i]]+=b[i]     print(min(d.values()))

Codechef 23:

https://www.codechef.com/MARCH20B/problems/ENGXOR  def Bits(n):              count = 0             while (n):                  n &= (n-1)                   count+= 1                            return count  for _ in range(int(input())):     n,q=map(int,input().split())     a=[int(i) for i in input().split()]     for _ in range(q):         p=int(input())         even=0         odd=0         for i in a:             if Bits(p^i)%2 ==0:                 even+=1             else:                 odd+=1 ...

Codechef22

 https://www.codechef.com/AUG20B/problems/CHEFWARS: for _ in range(int(input())):     n,k=input().split()     n=int(n)     k=int(k)          while k!=0:         n=n-k         k=k//2     if n>0:         print(0)     else:         print(1)               

Codechef 21:

https://www.codechef.com/LTIME87B/problems/MODEFREQ  for i in range(int(input())):     n=int(input())     arr=[int(i) for i in input().split()]     dict1={}     for i in arr:         if i in dict1:             dict1[i]+=1         else:             dict1[i]=1     dict2={}     for i in dict1:         if dict1[i] in dict2:             dict2[dict1[i]]+=1         else:             dict2[dict1[i]]=1     a=sorted(dict2.items(), key =                   lambda kv:(kv[1], kv[0]))          min1=a[-1][0]     for i in range(1,len(a)):         if a[-i][1] == a[-i-1][1]:             min1=a[-i-1][0] ...

codechef20

 https://www.codechef.com/LTIME83B/problems/FFL for _ in range(int(input())):     n,k=input().split()     n=int(n)     k=int(k)          arr1=[int(i) for i in input().split()]     arr2=[int(i) for i in input().split()]     flag=0     flag1=0          for i in range(n):         if arr2[i]==0:             if flag==0:               min1=arr1[i]             else:                 flag=1                 if arr1[i]<min1:                     min1=arr1[i]             flag=1         else:             if flag1==0:               ...

Codechef 19:

https://www.codechef.com/submit/COVID19 for _ in range(int(input())):     n=int(input())          arr=[int(i) for i in input().split()]     min1=[]     c=0     d=[]     for i in range(n-1):         min1.append(arr[i+1]-arr[i])     min1.append(20)     for i in min1:         if int(i) <= 2:             c+=1         else:             d.append(c)             c=0      print(min(d)+1,max(d)+1)                       

Codechef 18 :

  for _ in range(int(input())):     n=int(input())          arr1=[int(i) for i in input().split()]          arr2=[int(i) for i in input().split()]          sum1=0     sum2=0     side=0     https://www.codechef.com/LTIME84B/problems/WWALK     for i in range(n):         if sum1==sum2:             if arr1[i] == arr2[i]:                 side+=arr1[i]                      sum1+=arr1[i]         sum2+=arr2[i]              print(side)                       

CodeChef Problem 17 :

https://www.codechef.com/LTIME84B/problems/LOSTWKND  for _ in range(int(input())):     arr=[int(i) for i in input().split()]          p=arr[-1]          arr=arr[0:5]     sum1=0     for i in arr:         sum1+=i     if sum1*p <=120:         print("No")     else:         print("Yes")         

Code chef problem 16

 https://www.codechef.com/JUNE20B/problems/EOEO for _ in range(int(input())):     n=int(input())     count=0              if n%2 == 0:             a=n             count1=0             while a%2==0:                 a=a//2                 count1+=1             l=2 ** (count1+1)             count=n//l                      else:         count=n//2                       print(count)                                                     ...

Codechef Problem 15

https://www.codechef.com/JUNE20B/problems/CHFICRM  for _ in range(int(input())):     n=int(input())     a=[int(i) for i in input().split()]     flag=0     dict={5:0,10:0,15:0}     if a[0]<=5:         for i in a:             if i==5:                 dict[5]+=1                 flag=1             elif i==10:                 if dict[5]>0:                     dict[10]+=1                     dict[5]-=1                     flag=1                 else:                     flag=0       ...

Code chef problem :14

 https://www.codechef.com/JUNE20B/problems/XYSTR for _ in range(int(input())):     a=input()     a=list(a)     count1=0     i=0     while i<len(a):         if a[i]=='x' and (i+1) != len(a):             if a[i+1]=='y':                 count1+=1                 i=i+2                 continue         else :             if (i+1) != len(a):                 if a[i+1]=='x' :                     count1+=1                     i=i+2                     continue                      i...

Codechef Problem :13

 https://www.codechef.com/JUNE20B/problems/PRICECON for _ in range(int(input())):     n,k=input().split()     n=int(n)     k=int(k)     a=[int(i) for i in input().split()]     sum1=0     for i in a:         if i>k:             sum1=sum1+(i-k)     print(sum1)

Code chef:12

 https://www.codechef.com/submit/CHEFEZQ for _ in range(int(input())):          n,k=input().split()          n=int(n)     k=int(k)     arr=[int(i) for i in input().split()]          sum1=0     for i in arr:         sum1+=i          print(sum1//k + 1)         

Code chef :11

 https://www.codechef.com/submit/CVDRUN for _ in range(int(input())):          n,k,x,y=map(int,input().split(" "))     n=int(n)     k=int(k)     x=int(x)     y=int(y)          flag=0     for i in range(n):         x=(x+k)%n         if x==y:             print('YES')             flag=1             break          if flag==0:         print("NO")                   

Code chef problem 10:

https://www.codechef.com/COOK125B/problems/ATTENDU for _ in range(int(input())):     n=int(input())     b=input()          count=0     for i in b:         if i=='0':             count+=1              if count<=30:         print("YES")     else:         print("NO")

CodeChef Problem 9:

 https://www.codechef.com/LTIME91B/problems/SEDARR for _ in range(int(input())):     n,k=input().split()     n=int(n)     k=int(k)          arr=[int(i) for i in input().split()]          sum1=0     for i in arr:         sum1+=i          if sum1%k ==0:         print(0)     else:         print(1)         

Code Chef Problem 8:

https://www.codechef.com/submit/DECODEIT  for _ in range(int(input())):          n=int(input())     str1=input()     char1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p']     str11=""     for i in range(1,n+1):         if i%4!=0:             if str1[i-1]=='0':                 l=len(char1)//2                 char1=char1[0:l]             else:                 l=len(char1)                 char1=char1[(l//2):l]         else:             if str1[i-1]=='0':                 str11+=char1[0]             else:             ...

Code chef Problem 7:

https://www.codechef.com/submit/DIVTHREE  for _ in range(int(input())):     n,k,d=input().split()     n=int(n)     k=int(k)     d=int(d)     arr=[int(i) for i in input().split()]     sum1=0          for i in arr:         sum1+=i          if sum1>=k:         days=sum1//k         if days >d:             print(d)         else:             print(days)     else:         print(0)     

Codechef problem 6

Maximum Function for i in range(int(input())):     n=int(input())     arr=[int(i) for i in input().split()]          arr.sort(reverse=True)     sum1=abs(arr[0]-arr[n-1])+ abs(arr[0]-arr[n-2])+ abs(arr[n-2]-arr[n-1])          print(sum1)                               

Codechef problem 5:

Ashishgup and Interviews   import math for _ in range(int(input())):     n,k=input().split()     n=int(n)     k=int(k)     arr=[int(i) for i in input().split()]          count=0     count1=0     flag1=0     for i in range(n):         if arr[i]>k:             flag1=1         if arr[i]>-1:             count+=1         if arr[i]==0 or arr[i]==1:             count1+=1              if count<math.ceil(n/2):         print("Rejected")     elif flag1==1:         print("Too Slow")     elif count1 == n:         print("Bot")     elif (flag1==0 or count>math.ceil(n/2)):         print("Accepted")...

Codechef Problem 4:

 Highest Divisor : n=int(input()) max1=1 for i in range(1,11):     if (n%i ==          0):             max1=i print(max1)     

Code chef Problem 3:

PAIR ME: for _ in range(int(input()))  :       n=3     arr=[int(i) for i in input().split()]          for i in range(n-1,0,-1):         for j in range(i):             if arr[j]>arr[j+1]:                 tmp=arr[j]                 arr[j]=arr[j+1]                 arr[j+1]=tmp     if arr[0] + arr[1] ==arr[2]:         print("YES")     else:         print('NO')

Codechef Problem 2

 EVEN SUM for _ in range(int(input())):     n=int(input())     arr=[int(i) for i in input().split()]     odd=0     for i in range(n):         if (arr[i]%2 !=             0):             odd =(odd                     + 1)     if (odd %2 ==         0):         print(1)     else:         print(2)                  

Codechef Problem

  EVEN DIFFERENCES: for i in range(int(input())):     n=int(input())     arr=[int(i) for i in input().split()]     count=0     count1=0     for i in range(n):         if arr[i]%2!=0:             count+=1         else:             count1+=1     if count1<count:         print(count1)     else:         print(count)