[
  {
    "path": "2 arrays.py",
    "content": "n = int(input())\narr = list(map(int,input().split()))\nbrr = list(map(int,input().split()))\naneg = 0\nbneg = 0\nasum = 0\nbsum = 0\nfor i in range(n):\n    if arr[i]== -1:\n        aneg +=1\n    else:\n        asum +=arr[i]\n    if brr[i] == -1:\n        bneg +=1\n    else:\n        bsum +=brr[i]\nd = abs(asum - bsum)       \nif aneg ==bneg:\n    print(\"Infinite\")\n\nif (bsum-asum)>0 and aneg != bneg:\n    if aneg == 0:\n        print(0)\n    if aneg==1:\n        print(1)\n    elif aneg>1:\n        print(d+1)\n        \nif (asum-bsum)>0 and aneg!=bneg:\n    if bneg == 0:\n        print(0)\n    if bneg==1:\n        print(1)\n    elif bneg>1:\n        print(d+1)\n        \n"
  },
  {
    "path": "@K R-r-riddikulus! once again.py",
    "content": "n,d = map(int,input().split())\na = list(map(int,input().split()))\nprint(*(a[d:]+a[:d]))\n#print(*(a[d:]+a[:d]))\n"
  },
  {
    "path": "A Special Number.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\ndef getSum(n):\n    su = 0\n    while n!=0:\n        rem = n%10\n        su += rem\n        n = n//10\n        \n    return su\n\nn = int(input())\nli = []\nfor i in range(n):\n    x = int(input())\n    for i in range(x,10000000000):\n        su = getSum(i)\n        if su%4 == 0:\n            print(i)\n            break\n"
  },
  {
    "path": "A beauty factor.py",
    "content": "# Simple Brute Force implementation \n#First we check that whether the length (k) is 9 or not because if k ==9  then we can have only 1 number that is 123456789 becz number must be distinct and greater than zero.\n# Step 2 : If start with the smallest number and remove all zero and indentical number (1231 here 1 is repeated two times which should not be as each number must be distinct) and\n# check there beautyFactor . if they match print it else increment the number and recursivly check it len of the number is equal to k.\n\n\ndef checkBeautyFactor(n):\n    su = 0\n    for i in str(n):\n        su+= int(i)\n        \n    if len(str(su))>1:\n        su = checkBeautyFactor(str(su))\n        \n    return su\n\nb,k = map(int,input().split())\n\n\nif k == 9:\n    if b==9:\n        print(123456789)\n    else:\n        print(-1)\nelse:\n    n = \"1\" + \"0\"*(k-1)\n    while True:\n        if \"0\" in str(n):\n            n = int(n)\n            n+=1\n            continue\n        n = str(n)\n        if len(set(n)) != len(n):\n            n = int(n)\n            n+=1\n            continue\n            \n        beautyFactor = checkBeautyFactor(str(n))\n        \n        if beautyFactor == b:\n            print(n)\n            break\n            \n        n = int(n)\n        n+=1\n        if len(str(n))>k:\n            print(-1)\n            break\n"
  },
  {
    "path": "Achhe Din.py",
    "content": "testCase = int(input())\nfrom collections import Counter\nfor _ in range(testCase):\n    n = int(input())\n    ide = Counter(list(map(int,input().split())))\n    print(list(ide.keys())[list(ide.values()).index(1)])\n"
  },
  {
    "path": "Add Alternate Elements of 2-Dimensional Array.py",
    "content": "a,b,c,d,e,f,g,h,i = map(int,input().split())\n\nprint(a+c+e+g+i)\nprint(b+d+f+h)\n"
  },
  {
    "path": "Alien language.py",
    "content": "n = int(input())\nfor i in range(n):\n    first_word = input()\n    second_word = input()\n    for i in second_word:\n        if i in first_word:\n            print(\"YES\")\n            break\n    else:\n        print(\"NO\")\n"
  },
  {
    "path": "All Vowels.py",
    "content": "n = int(input())\ns = input()\na = 0\ne=0\ni=0\no=0\nu=0\nfor j in range(n):\n    if s[j]=='a':\n        a+=1\n    if s[j]=='e':\n        e+=1\n    if s[j]=='i':\n        i+=1\n    if s[j]=='o':\n        o+=1\n    if s[j]=='u':\n        u+=1\n        \nif a>0 and e>0 and i>0 and o>0 and u>0:\n    print(\"YES\")\nelse:\n    print(\"NO\")\n        \n"
  },
  {
    "path": "AltF4 and the beetles.py",
    "content": "\nfor _ in range(int(input())):\n    n,a,b,c = map(int,input().split())\n    \n    #store the beetles with 0 or 1 \n    #0 means start time \n    # 1 means end time \n    beetles  = []\n    \n    for i in range(n):\n        x,y = map(int,input().split())\n        beetles.append((x,0))\n        beetles.append((y,1))\n        \n    # sort the array with my giving start time pripority and taking the consideration that endtime is less than the \n    #previous once\n    beetles.sort(key = lambda b: b[0]*2+ b[1])\n    \n    total = n*a\n    # since we have added a in starting , now we are adding b and substracting a\n    ba = b-a\n    cb = c-b\n    max_ = total\n    #checking whether the its the start time or end time \n    # If it is start time we are adding ba\n    #if end time we are adding cb\n    for b in beetles:\n        if b[1]==0:\n            total += ba\n        else:\n            total += cb\n        max_ = max(max_,total)\n    print(max_)\n"
  },
  {
    "path": "Anagrams.py",
    "content": "from collections import Counter\n# Write your code here\ndef cc(a,b):\n    p = Counter(a)\n    q = Counter(b)\n    print(sum((q-p).values())+sum((p-q).values()))\n\n\n\nn  = int(input())\nfor _ in range(n):\n    a = input()\n    b = input()\n    cc(a,b)\n"
  },
  {
    "path": "Anshul, Usama And Punishment - A.py",
    "content": "n = int(input())\nl = [20,30,40,90,80]\nif n>len(l):\n    for i in range(5,n+1):\n        if i%2==0:\n            l.append(2*l[i-2])\n        else:\n            l.append(3*l[i-2])\ny=0\nfor i in range(n):\n    for j in range(i+1,n):\n        ma = abs(l[i]+l[j])+abs(l[i]-l[j])\n        y  = max(y,ma)\nprint(y)\n"
  },
  {
    "path": "Anti-palindrome strings.py",
    "content": "# Simple Solution First sort the string if sorted string is palindrome then print (-1) else print the sorted string. Because if the sorted string is palindrome then \n# the string will be something like this aaaaaa,bbbbb,ccccc,etc\n\n# Write your code here\nt = int(input())\nfor _ in range(t):\n    inp = input()\n    s = ''.join(sorted(inp))\n    if s == s[::-1]:\n        print(-1)\n    else:\n        print(s)\n"
  },
  {
    "path": "Arjit and Apex.py",
    "content": "t = int(input())\nfor _ in range(t):\n    m,n = map(int,input().split())\n    d = dict()\n    new = dict()\n    for i in range(m):\n        p,q = map(int,input().split())\n        d[i] = (p,q)\n    for i in range(n):\n        p,q = map(int,input().split())\n        new[i] = (p,q)\n    g,h = map(int,input().split())\n    g_c = 0\n    h_c=0\n    \n    i = 0\n    j = 0\n    while i<len(d):\n        while j<len(new):\n            if new[j][0]==d[i][0]:\n                g_c+=1\n                if new[j][1]==d[i][1]:\n                    h_c+=1\n                \n                i+=1\n            j+=1\n        break\n    #print(h_c,g_c)\n    if h_c == h:\n        print(\"Great\")\n    elif g_c == g:\n        print(\"Good\")\n    else:\n        print(\":(\")\n"
  },
  {
    "path": "Array operations.py",
    "content": "# Knowledge of Kadane algorithm \n#To understand the below algorithm I highly recommend you to visit https://www.geeksforgeeks.org/maximum-subarray-sum-possible-after-removing-at-most-one-subarray/ \n\n\ndef kadaneSum(arr,n):\n    new_arr = [0]*n\n    curr_sum = s = 0\n    for i in range(n):\n        if curr_sum<0:\n            curr_sum = 0\n        if curr_sum + arr[i] >s:\n            s = curr_sum + arr[i]\n        curr_sum = curr_sum + arr[i]\n        new_arr[i] = s\n    return new_arr\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    li = list(map(int,input().split()))\n    pre_sum = kadaneSum(li,n)\n    post_sum = kadaneSum(li[::-1],n)\n    post_sum = post_sum[::-1]\n    ans = 0\n    for i in range(n-1):\n        ans = max(ans,pre_sum[i]+post_sum[i+1])\n\n    print(ans)\n"
  },
  {
    "path": "ArrayGame.py",
    "content": "n,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\na.sort()\nb.sort(reverse=True)\np=0\nif n>m:\n    for i in range(m):\n        if a[i]<b[i]:\n            p+=b[i]-a[i]\n        else:\n            break\nelse:\n    for i in range(n):\n        if a[i]<b[i]:\t\n            p+=b[i]-a[i]\n        else:\n            break\nprint(p)\n"
  },
  {
    "path": "Bag Of Numbers.py",
    "content": "n=input().split()\nif (len(n)<4):\n    n[0]=\"output\"\nelse:\n    n[0]=\"output:\"\nprint(*n)\n"
  },
  {
    "path": "Best Index.py",
    "content": "\n## Explaination : \n'''\nStep 1 : First we will find out till what index the zeroth index can go for example consider the array [1,3,1,2,5] here the zeroth index can go till index 2 and\nk = 2 k = partition that is 1,2,3. This k will tell us the much indeed information to solve the question this tells us that how many elements are picked .So \nIf for index zeroth the k value is 2 we can't have k >2 for any other index.(TRY with example ). \n\nThe above step is done from line 20 to 30.\n\nStep 2: Now we will start a loop from index 1 as we have already cover the case for index 0. \n      2.a : We will first substract the previous value as we have added that in the step 1 and we don't need that now(because we have increase the index).\n      2.b : Then we will check whether the index 0 has reach the end or not: if index 0 has reach the end then the next index won't have same k value. \n          Therefore we will decrese the k and subtract those value from the initialSum.\n          \n          If the index 0 has not reach the end :: Only one element is added.(Try to analyze with example )\n'''\n\n# Write your code here\nn = int(input())\na = list(map(int,input().split()))\nstart = 1\nk = 2\nwhile start<=n:\n    start += k\n    k+=1\n\nstart -= k-1\nk-=2\ninitialSum = sum(a[:start])\nma = initialSum\n\nfor i in range(1,n):\n    initialSum -= a[i-1]\n    if start<n:\n        initialSum += a[start]\n        start+=1\n    else:\n        k-=1\n        initialSum -= sum(a[n-k:n])\n        start -= k\n    if initialSum > ma:\n        ma =initialSum\nprint(ma)\n"
  },
  {
    "path": "Biased Chandan.py",
    "content": "n = int(input())\nx=[]\nfor i in range(n):\n    inq = int(input())\n    if inq == 0:\n        if len(x)>0:\n            x.pop()\n    else:\n        x.append(inq)\nprint(sum(x))\n"
  },
  {
    "path": "Binary Queries.py",
    "content": "n,q = map(int,input().split())\nl =list(map(int,input().split()))\nq2 = [[ None for _ in range(3)] for _ in range(q)] \nfor i in range(q):\n    \n    q2[i] = list(map(int,input().split()))\n    if q2[i][0] ==1:\n        if l[q2[i][1]-1] ==0:\n            l[q2[i][1]-1]=1\n        else:\n            l[q2[i][1]-1]=0\n    else:\n         \n        if l[q2[i][2]-1]==0:\n            print('EVEN')\n        else:\n            print('ODD')\n"
  },
  {
    "path": "Breakup App.py",
    "content": "n = int(input())\nresult = {}\nmsg = []\nfor _ in range(n):\n    msg.append(list(input().split()))\nfor i in range(n):\n    for j in range(len(msg[i])):\n        if msg[i][j].isdigit():\n            if msg[i][j] not in result:\n                result[msg[i][j]]=0\n            if msg[i][0] == 'G:':\n                result[msg[i][j]]+=2\n            else:\n                result[msg[i][j]]+=1\nif len(result) == 0:\n    print('No Date')\nelse:\n    Keymax = max(result, key= lambda x: result[x]) \n    if Keymax == '19' or Keymax == '20':\n        print('Date')\n    else:\n        print('No Date')\n"
  },
  {
    "path": "Bricks Game.py",
    "content": "n =  int(input())\ntemp = n\nfor i in range(temp):\n    n = n - i \n    if n<=0 :\n        print(\"Patlu\")\n        break\n    \n    n = n - i*2\n    if n<=0:\n        print(\"Motu\")\n        break\n"
  },
  {
    "path": "CAn you solve it?.py",
    "content": "testCase = int(input())\nfor _ in range(testCase):\n    n = int(input())\n    l = list(map(int,input().split()))\n    mi = []\n    ma = []\n    for i in range(n):\n        ma.append(l[i]+i)\n        mi.append(l[i]-i)\n    print(max((max(mi)-min(mi)),(max(ma)-min(ma))))\n"
  },
  {
    "path": "Chandu and Consecutive Letters.py",
    "content": "n = int(input())\nfor i in range(n):\n    s = input()\n    st = []\n    for i in range(len(s)):\n        if len(st)==0:\n            st.append(s[i])\n        elif st[-1]==s[i]:\n            pass\n        else:\n            st.append(s[i])\n    print(''.join(st))\n    \n"
  },
  {
    "path": "Char Sum.py",
    "content": "d = {}\nn = input()\ns = 'abcdefghijklmnopqrstuvwxyz'\nfor i,j in enumerate(s):\n    d[j] = i+1\ncost = 0\nfor i in n:\n    cost += d[i]\n\nprint(cost)\n"
  },
  {
    "path": "Charged Up Array.py",
    "content": "\nT = int(input())\nm = pow(10,9)+7\nfor _ in range(T):\n    N = int(input())\n    A = list(map(int, input().split()))\n    s=0\n    ch= int(pow(2,N)//2)\n    for i in range(N):\n        if A[i]>=ch:\n            s+=A[i]\n    print(s%m)\n"
  },
  {
    "path": "Cost of balloons.py",
    "content": "test_cases = int(input())\nfor i in range(test_cases):\n    p,g = map(int, input().split())\n    n = int(input())\n\n    cost = 0\n    lower = min(p,g)\n    maximum = max(p,g)\n    p1_total = 0\n    p2_total = 0\n    for i in range(n):\n        p1,p2 = map(int, input().split())\n        p1_total += p1\n        p2_total += p2\n\n    if p1_total >= p2_total:\n        cost += p1_total*lower\n        cost += p2_total*maximum\n    else:\n        cost += p2_total*lower\n        cost += p1_total*maximum\n    print(cost)\n"
  },
  {
    "path": "Count Divisors.py",
    "content": "l,r,k = map(int,input().split())\nc=0\nfor i in range(l,r+1):\n    if i%k==0:\n        #print(i)\n        c+=1\nprint(c)\n"
  },
  {
    "path": "Counting Triangles.py",
    "content": "n = int(input())\nl = []\nfor _ in range(n):\n    a = tuple(map(int,input().split()))\n    a = sorted(a)\n    \n    l.append(tuple(a))\n\nfrom collections import Counter\n\nd = Counter(l)\nans = 0\nfor k,v in d.items():\n    if v ==1 :\n        ans+=1\n        \nprint(ans)\n"
  },
  {
    "path": "Crazy Kangaroo.py",
    "content": "t = int(input())\nfor _ in range(t):\n    a,b,m = map(int,input().split())\n    ans =0 \n    for i in range(a,b+1):\n        if i%m == 0 :\n            ans +=1\n    print(ans)\n"
  },
  {
    "path": "Dedication Level = Infinity.py",
    "content": "n= int(input())\nl = [[0 for i in range(2)]for i in range(n)]\nfor i in range(n):\n    l[i] = list(input().split())\nfor i in range(n):\n    l[i][1]  = int(l[i][1])\nl.sort(key = lambda x:x[1],reverse = True)\nfor i in range(3):\n    print(l[i][0])\n"
  },
  {
    "path": "Determining numbers.py",
    "content": "# Write your code here\nfrom collections import Counter\n\nn = int(input())\narr = list(map(int,input().split()))\na = Counter(arr)\nans = []\nfor k,v in a.items():\n    if v==1:\n        ans.append(k)\n        \nans.sort()\n        \nprint(*ans)\n"
  },
  {
    "path": "Difficult Characters.py",
    "content": "n = int(input())\nfor _ in range(n):\n    s = input()\n    from collections import Counter\n    s2 = 'abcdefghijklmnopqrstuwvxyz'\n    \n    d = Counter(s2) \n    for i in range(len(s)):\n        if s[i] in s2:\n            if d[s[i]]:\n                d[s[i]]+=1\n            else:\n                d[s[i]]=1\n                #print(d[s[i]])\n        else:\n            d[s[i]]=0\n            \n    ans = sorted(d.items(), key = lambda x : (x[1],-ord(x[0])))\n    for i in range(len(ans)):\n        print(ans[i][0],end = ' ')\n    print('\\n')\n"
  },
  {
    "path": "Digital Sequence.py",
    "content": "a=int(input())\nb=list(input().split())\nmax=0\nfor i in range(10):\n    i=str(i)\n    count=0\n    for j in b:\n        if(i in j):\n            count=count+1\n    if(count>max):\n        max=count\nprint(max)\n"
  },
  {
    "path": "Distribute chocolates.py",
    "content": "#Logic : Since there are n students and each student will recienve atleast one chocalate and the next student will receive k+1(Assuming k is the no.of chocolate given to first student)\n# then next student will get k+2,k+3.... so on\n# Minimum no.of chocolate n student will get will be n*(n+1)//2 where n = no.of student\n#Step 2: Calculate the chocalte left that is : c - ( Minimum no.of chocolate)\n# Step3 : Ans = chocalte left % n\n#Let us understand via example : c = 20 n = 3\n# Since there are 3 student they are bound to recieve 6 chocolate \n#chocolateLeft = 20 -6 = 14\n# If we divide 14 //3 we get 4 \n# therefore we can give each student 4 more chocolate that 5,6,7 = 18\n#Therefore ans  = 20 - 18\n#Below is a shortcut way to calculate the above\n\n\n\nt = int(input())\nfor _ in range(t):\n    c,n = map(int,input().split())\n    minimumChocolates = (n*(n+1))//2\n    if minimumChocolates >= c:\n        print(c)\n    else:\n        c = c - minimumChocolates\n        ans = c%n\n        print(ans)\n"
  },
  {
    "path": "Divisibility.py",
    "content": "#If the last element contions zero then only we can divide the number formed by taking the last number by 10\n# Therefore we only need to check that whether the last element of the last number is zero or not.\n\nN = int(input())\narr = list(map(int,input().split()))\nele = arr[N-1]\nif ele % 10 == 0:\n    print(\"Yes\")\nelse:\n    print(\"No\")\n"
  },
  {
    "path": "Divisible.py",
    "content": "n = int(input())\ns = list(input().split())\n\nhalf = n/2\nx = []\nfor i in range(n):\n    if i < half:\n        x.append(s[i][0])\n    else:\n        x.append(s[i][-1:])\n\ntemp = ''.join(x)\n\nif (int(temp) % 11 == 0):\n    print(\"OUI\")\nelse:\n    print(\"NON\")\n"
  },
  {
    "path": "Does it Divide?.py",
    "content": "\ndef prime(n) : \n  \n    # Corner cases \n    if (n <= 1) : \n        return 0\n    if (n <= 3) : \n        return 1\n  \n    # This is checked so that we can skip  \n    # middle five numbers in below loop \n    if (n % 2 == 0 or n % 3 == 0) : \n        return 0\n  \n    i = 5\n    while(i * i <= n) : \n        if (n % i == 0 or n % (i + 2) == 0) : \n            return 0\n        i = i + 6\n  \n    return 1\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    x = prime(n)\n    if n==2:\n        print('NO')\n    elif n==1:\n        print('YES')\n    elif x==1:\n        print('YES')\n    elif x==0:\n        y = prime(n+1)\n        \n        \n        if y==1:\n            print('NO')\n        else:\n            print('YES')\n"
  },
  {
    "path": "Duration.py",
    "content": "t = int(input())\nfor _ in range(t):\n    sh,sm,eh,em = list(map(int,input().split()))\n    starting_min = sh*60 + sm\n    ending_min = eh*60 + em\n    temp = ending_min  - starting_min\n    if temp>=60:\n        hr = int(temp/60)\n        mi = temp - hr*60\n    else:\n        hr = 0\n        mi = temp\n    print(hr,mi)\n"
  },
  {
    "path": "EEDC Lab.py",
    "content": "n = int(input())\na = list(map(int,input().split()))\n\ntmp_sum = sum(a)\nlucky = []\nif n == 1:\n    lucky.append(1)\nelse:\n    for i in range(n):\n        if i == 0:\n            lucky.append(0)\n        else:\n            lucky.append(lucky[i-1])\n        #print(lucky)\n        if (tmp_sum - a[i])%3 == 0:\n            if i == 0:\n                if a[n-1] == 0:\n                    lucky[i]+=1\n            elif i == n-1:\n                if a[n-2] == 0:\n                    lucky[i]+=1\n            else:\n                if (a[i-1]+a[n-1])%10 == 0:\n                    lucky[i]+=1\nlucky.insert(0,0)   \nq = int(input())\nfor _ in range(q):\n    l,r = map(int,input().split())\n    print(lucky[r] - lucky[l-1])\n"
  },
  {
    "path": "Easy Sum Set Problem.py",
    "content": "n = int(input())\na = list(map(int,input().split()))\nm = int(input())\nc = list(map(int,input().split()))\nl=[]\nfor i in range(n):\n    for j in range(m):\n        x = c[j]-a[i]\n        l.append(x)\n    \nfrom collections import Counter\nl  = Counter(l)\nans = []\nfor k,v in l.items():\n    if v==n:\n        ans.append(k)\nans  =sorted(ans)\nprint(' '.join(map(str, ans)))\n"
  },
  {
    "path": "Easy one.py",
    "content": "from collections import Counter,defaultdict\nt = int(input())\nfor _ in range(t):\n    n,q = map(int,input().split())\n    arr = list(map(int,input().split()))\n    d = defaultdict(int)\n    d = Counter(arr)\n    for _ in range(q):\n        temp = int(input())\n        print(d[temp])\n"
  },
  {
    "path": "Equal elements",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\n\nt = int(input())\ndef find(arr,ele,n):\n    ans = 0\n    for i in range(n):\n        temp = abs(ele-arr[i])\n        if temp == 1 or temp%2 !=0:\n            ans += 1\n    return ans\nfor _ in range(t):\n    n = int(input())\n    arr = list(map(int,input().split()))\n    l = []\n    for i in range(n):\n        if arr[i]%2 == 0:\n            l.append(2)\n        else:\n            l.append(1)\n    x = n + 1\n    for k in range(1,3):\n        x2 = find(arr,k,n)\n        x = min(x,x2)\n    print(x)\n"
  },
  {
    "path": "Equalize strings.py",
    "content": "n = int(input())\nx = input()\ny = input()\nc = 0\nl = 0\nfor i in range(n):\n    if x[i] != y[i]:\n        c+=1\n    else:\n        if c > 0:\n            l += 1\n            c =0\nif c >0:\n    l+=1\n    \nprint(l)\n"
  },
  {
    "path": "Erasing an array.py",
    "content": "#When we encounter 1,0 sequence we have inversion and we can't erase the solution \n#Therefore the simple solution here is to just count the number of inversion that is the sequence of 1 follwed by 0.\n\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    arr = list(map(int,input().split()))\n    c = 1\n    for i in range(n-1):\n        if arr[i] == 1 and arr[i+1]==0:\n            c+=1\n    print(c)\n"
  },
  {
    "path": "Exchanging money.py",
    "content": "import math\n\nn,q = map(int,input().split())\narr = list(map(int,input().split()))\n\ng= arr[0]\nfor i in range(n):\n    g = math.gcd(g,arr[i])\n    \nfor i in range(q):\n    q1 = int(input())\n    if q1%g==0:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n"
  },
  {
    "path": "Factorial!.py",
    "content": "import math\nn = int(input())\nprint(math.factorial(n))\n"
  },
  {
    "path": "Find Product.py",
    "content": "x = pow(10,9)+7\nn  = int(input())\nl = list(map(int,input().split()))\nans =1\nfor i in range(n):\n    ans = (ans*l[i])%x\nprint(ans)\n"
  },
  {
    "path": "Find the String.py",
    "content": "t = int(input())\nfrom collections import Counter\nfor _ in range(t):\n    n,m = map(int,input().split())\n    matrix = {}\n    for i in range(n):\n        a = list(input())\n        matrix[i] = Counter(a)\n    s = input()\n    l = len(s)\n    c = 0\n    c = 0\n    for i in range(len(s)):\n        #print(\"fdefd\",s[i],i)\n        if i<n:\n            if s[i] in matrix[i] and matrix[i][s[i]]>0:\n                matrix[i][s[i]] -=1\n                #print(matrix[i],s[i])\n                c+=1\n        else:\n            j = i%n\n            if s[i] in matrix[j] and matrix[j][s[i]]>0:\n                matrix[j][s[i]] -=1\n                #print(\"Else\",matrix[j])\n                c+=1\n    if c==l:\n        print(\"Yes\")\n    else:\n        print(\"No\")\n"
  },
  {
    "path": "Finding the Subarrays.py",
    "content": "n = int(input())\nl1 = list(map(int,input().split()))\nma = pow(10,7)\nind1= [0]*(ma)\nind2 = [0]*(ma)\ntemp=0 \n\nfor i in range(n):\n    r = sum(l1)\n    l = 0\n    for j in range(i,n):\n        l+= l1[j]\n        r = r - l1[j]\n        if(n== j-i+1 or l/(j-i+1)>r/(n-j+i-1)):\n            #print(r)\n            ind1[temp] = i+1\n            ind2[temp] = j+1\n            #print(ind1[temp],ind2[temp])\n            temp+=1\nprint(temp)\nfor i,j in zip(ind1,ind2):\n    if i>0 or j>0:\n        print(i,j)\n"
  },
  {
    "path": "Finding vaccines.py",
    "content": "# Simple Brute force \n# Since the interaction are between \"C\" and \"G\" RNA we calculate the number of \"C\" and \"G\" molecule in virus and in vaccine and then calculate the score\n\n# Write your code here\nnoOfVaccine = int(input())\nlenOfVirus = int(input())\nvirus = input()\nv = [0]*2\nfor i in virus:\n    if i == 'C':\n        v[0] += 1\n    elif i == 'G':\n        v[1] += 1\n\nans = 0\nnumber = 0\nfor j in range(noOfVaccine):\n    le = int(input())\n    vacc = input()\n    temp = [0]*2        #A temp array used to keep the count of \"C\" and \"G\" molecule \n    for i in vacc:\n        if i == 'C':\n            temp[0]+=1\n        elif i =='G':\n            temp[1]+=1\n    score = v[0]*temp[1] + v[1]*temp[0]\n    if score > ans:\n        ans = score\n        number = j+1\n\nprint(number)\n"
  },
  {
    "path": "Fredo and Large Numbers.py",
    "content": "import sys\n \ndef index(t,f,ma,p,q,s,d):\n    if f>ma:\n        return 0 \n    if t==0:\n        for k,v in d.items():\n            \n            if v >= f:\n                return k\n    else:\n        if f not in s:\n            return 0\n        else:\n            return p[q.index(f)]\nfrom collections import OrderedDict\n \nn = sys.stdin.readline()\narray = list(map(int, sys.stdin.readline().split()))\nd = OrderedDict()\nfor i in array:\n    #print(i)\n    if i in d:\n        d[i] +=1\n    else:\n        d[i] = 1\n#print(d)\n \nma= max(d.values())\nk = list(d.keys())\nv = list(d.values())\ns = set(v)\n \n \nfor i in range(int(sys.stdin.readline())):\n    t,f = map(int, sys.stdin.readline().split())\n    print(index(t,f,ma,k,v,s,d))\n"
  },
  {
    "path": "Frequency of Students.py",
    "content": "# Write your code here\nn = int(input())\nd = {}\nfor _ in range(n):\n    x = input()\n    if x in d:\n        d[x]+=1\n    else:\n        d[x]=1\nfor k,v in sorted(d.items()):\n    print(k, v)\n"
  },
  {
    "path": "Going to office.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nd = int(input())\noc,of,od = map(int,input().split())\ncs,cb,cm,cd = map(int,input().split())\ntemp = d- of\nif temp > 0:\n    costOnline = oc+ temp*od\nelse:\n    costOnline = oc\n\ntime = d//cs\ncostOffline = cb + cm*time + cd*d\n\nif costOnline<=costOffline:\n    print(\"Online Taxi\")\n\nelse:\n    print(\"Classic Taxi\")\n"
  },
  {
    "path": "Grid and phrase.py",
    "content": "n,m = map(int,input().split())\nmatrix = []\nfor i in range(n):\n    a= list(input())\n    matrix.append(a)\nc=0\n#horizontal\nfor i in range(n):\n        for j in range(m):\n            if m-j>=4:\n                #print(m,j,i)\n                if matrix[i][j]=='s' and matrix[i][j+1]=='a' and matrix[i][j+2]=='b' and matrix[i][j+3]=='a':\n                    #print(\"yes\")\n                    c+=1\n                    \n#Vertical\nfor j in range(m):\n    #ro\n    for i in range(n):\n        if n-i>=4:\n            \n            if matrix[i][j]=='s' and matrix[i+1][j]=='a' and matrix[i+2][j]=='b' and matrix[i+3][j]=='a':\n                c+=1\n                \n                \n\nfor i in range(n):\n    for j in range(m):\n        if n-i>=4 and m-j>=4:\n            #print(i,j)\n            #print(matrix[i][j], matrix[i+1][j+1], matrix[i+2][j+2], matrix[i+3][j+3])\n            if matrix[i][j]=='s' and matrix[i+1][j+1]=='a' and matrix[i+2][j+2]=='b' and matrix[i+3][j+3]=='a':\n                #print(\"yes\")\n                c+=1\n\nfor i in range(n-1,0,-1):\n    for j in range(m):\n        if i+1 >= 4 and m-j>=4:\n            if matrix[i][j]=='s' and matrix[i-1][j+1]=='a' and matrix[i-2][j+2]=='b' and matrix[i-3][j+3]=='a':\n                #print(\"ds\")\n                c+=1\n                \n                \n                \nprint(c)\n"
  },
  {
    "path": "Hackers with Bits.py",
    "content": "n = int(input())\nl = input()\n\ns1 = l.count('1')\ns2 = l.count('0')\ns= l.split('0')\n\nm  = 0\nfor i in range(len(s)-1):\n    z=s[i].count(\"1\")+s[i+1].count(\"1\")\n    if(z>m):\n        m=z\nif(s2==0):\n    print(s1)\nelif(s1==0):\n    print(0)\nelif(s1>m):\n    print(m+1)\nelse:\n    print(m)\n"
  },
  {
    "path": "Hamiltonian and Lagrangian.py",
    "content": "n  = int(input())\nl = list(map(int,input().split()))[::-1]\npq = []\npq.append(l[0])\nm = l[0]\nfor i in range(1,n):\n    if l[i]>=m:\n        pq.append(l[i])\n        m=l[i]\nprint(*pq[::-1])\n"
  },
  {
    "path": "Hello.py",
    "content": "print('Hello Kirti')\n"
  },
  {
    "path": "Help Jarvis!.py",
    "content": "t = int(input())\nfor i in range(t):\n    \n    l = input()\n    li = []\n    for i in l:\n        li.append(int(i))\n    mi = min(li)\n    m = max(li)\n    c=0\n    arr = []\n    for i in range(mi,m+1):\n        arr.append(i)\n    if sorted(li)==sorted(arr):\n        print('YES')\n    else:\n        print('NO')\n"
  },
  {
    "path": "Honey Bees.py",
    "content": "for _ in range(int(input())):\n    n, m = map(int, input().split())\n    M = [list(map(int, input().split())) for __ in range(n)]\n    \n    for k in range(int(input())):\n        t, x, y = map(int,input().split())\n        s = 0\n        if t == 1:\n            if y % 2 == 0:\n                if x-1 >= 0:\n                    s += M[x-1][y]\n                if x+1 < n:\n                    s += M[x+1][y]\n                if y-1 >= 0:\n                    s += M[x][y-1]\n                if y+1 < m:\n                    s += M[x][y+1]\n                if x-1 >= 0 and y-1 >= 0:\n                    s += M[x-1][y-1]\n                if x-1 >= 0 and y+1 < m:\n                    s += M[x-1][y+1]\n                print(s)\n            else:\n                if x-1 >= 0:\n                    s += M[x-1][y]\n                if y-1 >= 0:\n                    s += M[x][y-1]\n                if y+1 < m:\n                    s += M[x][y+1]\n                if x+1 < n and y-1 >= 0:\n                    s += M[x+1][y-1]\n                if x+1 < n:\n                    s += M[x+1][y]\n                if x+1 < n and y+1 < m:\n                    s += M[x+1][y+1]\n                print(s)\n        else:\n            if y % 2 == 0:\n                if x-2 >= 0 and y-1 >= 0:\n                    s += M[x-2][y-1]\n                if x-2 >= 0:\n                    s += M[x-2][y]\n                if x-2 >= 0 and y+1 < m:\n                    s += M[x-2][y+1]\n                if x-1 >= 0 and y-2 >= 0:\n                    s += M[x-1][y-2]\n                if y-2 >= 0:\n                    s += M[x][y-2]\n                if x+1 < n and y-2 >= 0:\n                    s += M[x+1][y-2]\n                if x+1 < n and y-1 >= 0:\n                    s += M[x+1][y-1]\n                if x+2 < n:\n                    s += M[x+2][y]\n                if x+1 < n and y+1 < m:\n                    s += M[x+1][y+1]\n                if y+2 < m:\n                    s += M[x][y+2]\n                if x+1 < n and y+2 < m:\n                    s += M[x+1][y+2]\n                if x-1 >= 0 and y+2 < m:\n                    s += M[x-1][y+2]\n                print(s)\n            else:\n                if x-1 >= 0 and y-1 >= 0:\n                    s += M[x-1][y-1]\n                if x-2 >= 0:\n                    s += M[x-2][y]\n                if x-1 >= 0 and y+1 < m:\n                    s += M[x-1][y+1]\n                if x-1 >= 0 and y-2 >= 0:\n                    s += M[x-1][y-2]\n                if y-2 >= 0:\n                    s += M[x][y-2]\n                if x+1 < n and y-2 >= 0:\n                    s += M[x+1][y-2]\n                if x+2 < n and y-1 >= 0:\n                    s += M[x+2][y-1]\n                if x+2 < n:\n                    s += M[x+2][y]\n                if x+2 < n and y+1 < m:\n                    s += M[x+2][y+1]\n                if x+1 < n and y+2 < m:\n                    s += M[x+1][y+2]\n                if y+2 < m:\n                    s += M[x][y+2]\n                if x-1 >= 0 and y+2 < m:\n                    s += M[x-1][y+2]\n                print(s)\n"
  },
  {
    "path": "ICPC Team Management.py",
    "content": "t = int(input())\n\nfor _ in range(t):\n    n,k = map(int,input().split())\n    \n    from collections import Counter\n    d = Counter()\n    \n    s = 0\n    for i in range(n):\n        temp = input()\n        d[len(temp)] +=1\n        \n    c=0\n    for x,v in d.items():\n        #print(v)\n        if v%k==0:\n            c+=1\n        \n\n    if c==len(d):\n        print(\"Possible\")\n        \n    else:\n        print(\"Not possible\")\n"
  },
  {
    "path": "James and the menus.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nn,m = map(int,input().split())\nlis = []\nfor i in range(n):\n    temp = list(map(int,input().split()))\n    lis.append(temp)\n\nmx = [0]*m\nsu = [0]*n\nfor i in range(n):\n    for j in range(m):\n        mx[j] = max(mx[j],lis[i][j])\n        su[i] += lis[i][j]\n\n\ncn = [0]*n\ngoodNumber = 0\nfor i in range(n):\n    for j in range(m):\n        if mx[j] == lis[i][j]:\n            cn[i]+=1\n        goodNumber = max(goodNumber,cn[i])\n\n\nindex = []\nfor i in range(len(cn)):\n    if goodNumber == cn[i]:\n        index.append(i)\n\nansSum = 0\nansIndex = 0\nif len(index)>1:\n    for i in range(len(index)):\n        temp = su[index[i]]/4\n        if temp>ansSum:\n            ansSum = temp\n            ansIndex = index[i]\n\n    print(ansIndex+1)\n\nelse:\n    print(index[0]+1)\n"
  },
  {
    "path": "LAL Evaluation.py",
    "content": "n,m = map(int,input().split())\narr = list(map(int,input().split()))\n\nd = dict()\nc= 0\nfor i in range(n):\n    temp = m-arr[i]\n    if d.get(temp):\n\n        #print(arr[i],temp)\n        c+= d[temp]\n    if d.get(arr[i]):\n        d[arr[i]] +=1\n    else:\n        d[arr[i]] =1   \nprint(c)\n"
  },
  {
    "path": "Length of Valley",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\ndef area(arr,n):\n    stack = []\n    right_index = [0]*n\n    index = 0\n    while index<n:\n        if len(stack)==0 or arr[stack[-1]]<arr[index]:\n            stack.append(index)\n            index += 1\n        else:\n            while len(stack)>0:\n                x = stack.pop()\n                right_index[x]= index\n    \n    while len(stack)>0:\n        x = stack.pop()\n        right_index[x]= index\n        \n    \n    return right_index\n\n\ndef l_area(arr,n):\n    stack = []\n    left_index = [0]*n\n    index = 0\n    while index<n:\n        if len(stack)==0 or arr[stack[-1]]<arr[index]:\n            stack.append(index)\n            index += 1\n        else:\n            while len(stack)>0:\n                x = stack.pop()\n                left_index[x]= index\n    \n    while len(stack)>0:\n        x = stack.pop()\n        left_index[x]= index\n        \n    \n    return left_index\n\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    arr = list(map(int,input().split()))\n    left_index = l_area(arr[::-1],n)\n    left_index = left_index[::-1]\n    for i in range(n):\n        left_index[i] = n - left_index[i] + 1\n    right_index = area(arr,n)\n    ans = [0]*n\n    for i in range(n):\n        ans[i] = right_index[i] - left_index[i] + 1\n    print(*ans,sep =' ')\n"
  },
  {
    "path": "Life, the Universe, and Everything.py",
    "content": "while True:\n    n = int(input())\n    if n == 42:\n        break\n    else:\n        print(n)\n"
  },
  {
    "path": "Lift queries.py",
    "content": "test_case = int(input())\na = 0\nb = 7\nfor i in range(test_case):\n    f = int(input())\n    temp = abs(f-a)\n    temp2 = abs(f-b)\n    if temp <= temp2:\n        a = f\n        print('A')\n    else:\n        b = f\n        print('B')\n"
  },
  {
    "path": "Little Monk and Balanced Parentheses.py",
    "content": "n = int(input())\na = list(map(int,input().split()))\ns = []\nans = 0\n \nfor i in range(0,n):\n    if a[i] > 0:\n        s.append(i)\n    elif a[i] < 0:\n        if s and a[i] == -a[s[-1]]:\n            s.pop()\n            if not s:\n                temp = -1\n            else:\n                temp = s[-1]\n            ans = max(ans,i - temp)\n        else:\n            s.append(i)\n \nprint(ans) \n"
  },
  {
    "path": "Little_Jhool_psychic_powers.py",
    "content": "#Basics of Implementation\n#hackerearth\n#Little Jhool Psychic Powers\n#Solution\n\nn = input()\nif '111111' in n:\n    print(\"Sorry, sorry!\")\n    \nelif \"000000\" in n:\n    print(\"Sorry, sorry!\")\n\nelse:\n    print(\"Good luck!\" )\n"
  },
  {
    "path": "Long ATM Queue.py",
    "content": "# Write your code here\nn = int(input())\nl = list(map(int,input().split()))\nc=1\nfor i in range(n-1):\n    if l[i+1]<l[i]:\n        c+=1\nprint(c)\n"
  },
  {
    "path": "Lunch boxes.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\n\nt = int(input())\nfor _ in range(t):\n    n,m =  map(int,input().split())\n    a = list(map(int,input().split()))\n    a.sort()\n    count = 0\n    su = 0\n    for i in range(len(a)):\n        if a[i]+su <= n:\n            su+=a[i]\n            count+=1\n\n    print(count)\n"
  },
  {
    "path": "MYSTERY.py",
    "content": "while True:\n    try:\n        n = int(input())\n        s = bin(n)\n        print(s.count('1'))\n    except:\n        break\n"
  },
  {
    "path": "Manna's First Name.py",
    "content": "t = int(input())\nword  = 'SUVO'\nword1 = 'SUVOJIT'\nfor _ in range(t):\n    s = input()\n    c = s.count(word)\n    c2 = s.count(word1)\n    print('SUVO = {}, SUVOJIT = {}'.format(c-c2,c2))\n"
  },
  {
    "path": "Mark The Answer.py",
    "content": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nc=0\nskip=0\nfor i in range(n):\n    if l[i]<=k and skip<2:\n        #print(l[i])\n        c+=1\n    else:\n        skip+=1\nprint(c)\n"
  },
  {
    "path": "Mathematically beautiful numbers.py",
    "content": "#Step 1 : We first find out the powers of numbes smaller than or equal to x.Eg x = 91 ,k = 3 so we first find out [1,3,9,27,81]\n#Step 2 : We start a loop and subtract the largest number one by one from x and simulatensly check whether they are equal or not.\n#Step 3 : If they are equal print - YES else NO\n\n'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nt = int(input())\nfor _ in range(t):\n    x,k = map(int,input().split())\n    options = [1]\n    val = k\n    count = 1\n    while val<=x:\n        count+=1\n        options.append(val)\n        val = k**count\n        \n    total = options.pop()\n\n    while total <= x:\n        dif = x - total\n        options = [i for i in options if i<= dif]\n        try:\n            total += options.pop()\n        except:\n            break\n\n            \n    if total == x:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n"
  },
  {
    "path": "Maximize the Earning.py",
    "content": "s=int(input())\nfor i in range(s):\n    n,r = map(int,input().split())\n    l = list(map(int,input().split()))\n    \n    c=0\n    ma = 0.5\n    for i in range(len(l)):\n        if l[i]>ma:\n            ma = l[i]\n            c+=1\n    print(c*r)\n"
  },
  {
    "path": "Maximize the modulo function.py",
    "content": "'''\nThis code uses two formula to solve that is :\nif c = a + b then \nc mod(n) = [ a mod(n) + b mod(n)] mod(n)\nexample: c = 15\na = 7 \nb = 8\nn = 2\n15mod(2) = 1\n7mod(2) = 1\n8mod(2) = 0\n[1+0]mod(2) = 1\n\n2nd formula:\n\nab mod(n) = [(a mod(n))(b mod(n))]mod(n)\n'''\n\n# Write your code here\ndef solve(k, n,m):\n \n    pre = [0]\n    for c in n:\n        pre += [(pre[-1] * 10 + int(c))%k]\n    ans = pre[-1]%k\n    suf = 0\n    cur_pow = 1\n    for i in range(m - 1, -1, -1):\n        ans = max(ans, (pre[i] * cur_pow%k + suf) % k)\n        suf += cur_pow * int(n[i])\n        suf = suf%k\n        cur_pow = cur_pow * 10%k\n            \n \n        \n    return ans\nif __name__ == \"__main__\":\n    T = int(input().strip())\n    for problem in range(1, T + 1):\n        n,k = map(int, input().split())\n        A = input()\n        print(solve(k, A,n))\n"
  },
  {
    "path": "Maximum Of K- size subarrays (Deque).py",
    "content": "n,m= map(int,input().split())\nl = list(map(int,input().split()))\nx=[]\nfor i in range(0,n):\n    if len(l[i:m+i])==m:\n        x.append(max(l[i:m+i]))\nprint(*x)\n"
  },
  {
    "path": "Maximum Sum.py",
    "content": "n = int(input())\narr=  list(map(int,input().split()))\ns = 0\nc = 0\nfor i in range(len(arr)):\n    if arr[i]>=0:\n        s += arr[i]\n        c +=1\n        \nif s==0 and c==0:\n    s = max(arr)\n    c = 1\nprint(s,c)\n"
  },
  {
    "path": "Maximum goodness.py",
    "content": "n = int(input())\nl = list(map(int,input().split()))\n\nans = [1]\nle = [1]\n#d = {}\n#d[1] =1\nfor i in range(1,n):\n    \n    if l[i]==1:\n        if ans[i-1]+ 1 >=1:\n            \n            ans.append(ans[i-1]+1)\n            #d[ans[i-1]+1] = i+1\n            le.append(le[-1]+1)\n            #print(i+1,d[ans[i-1]+1])\n        else:\n            #d[1] = 1\n            le.append(1)\n            ans.append(1)\n    else:\n        ans.append(ans[i-1]-1)\n        le.append(le[-1]+1)\n        \nx= []\nma = max(ans)\nfor i in range(len(ans)):\n    if ans[i]==ma:\n        x.append(i)\nfinal_ans= []\nfor i in range(len(x)):\n    final_ans.append(le[x[i]])\n    \nprint(max(final_ans))\n"
  },
  {
    "path": "Maximum occurrence.py",
    "content": "l = list(input())\nfrom collections import Counter\nd = Counter(l)\ntemp = max(d.values())\nli = []\nfor k,v in d.items():\n    if v==temp:\n        li.append(k)\n        \nli.sort(key= lambda x: ord(x))\nprint(li[0],d[li[0]])\n"
  },
  {
    "path": "Maze Problem.py",
    "content": "def issafe(p,q,arr):\n    #print(type(p),type(n))\n    if p<n and p>=0 and q<n and q>=0 and arr[p][q]==1:\n        #print(\"Sdsdsd\")\n        return True\n    return False\n    \ndef solve(arr,i,j,sol):\n    #print(n)\n    if i==n-1 and j==n-1:\n        sol[i][j]=1\n        return True\n    #print(i,j)\n    if issafe(i,j,arr)==True:\n        sol[i][j]=1\n        #print(sol)\n        \n        if solve(arr,i,j+1,sol)==True:\n            return True\n        if solve(arr,i+1,j,sol)==True:\n            return True\n        sol[i][j]=0\n        return False\n        \n        \nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    arr =[]\n    sol = [[ 0 for i in range(n) ] for i in range(n)]\n\n    for i in range(n):\n        x = list(map(int,input().split()))\n        arr.append(x)\n        \n    if solve(arr,0,0,sol) ==True:\n        print(\"POSSIBLE\")\n    else:\n        print(\"NOT POSSIBLE\")\n"
  },
  {
    "path": "Memorise Me!.py",
    "content": "from collections import Counter\nn= int(input())\na = list(map(int,input().split()))\nm = int(input())\np = Counter(a)\nfor i in range(m):\n    x = int(input())\n    if p[x]:\n        print(p[x])\n    else:\n        print('NOT PRESENT')\n"
  },
  {
    "path": "Micro and Array Update.py",
    "content": "n= int(input())\nfor _ in range(n):\n    le,k  = map(int,input().split())\n    array = list(map(int,input().split()))\n    x = k-min(array)\n    if x>0:\n        print(x)\n    else:\n        print(0)\n"
  },
  {
    "path": "Min-Max.py",
    "content": "n = int(input())\narr = list(map(int,input().split()))\nma = max(arr)\nmi = min(arr)\n\ns = sum(arr)\n\na1_max = s-mi\na2_min = s-ma\nprint(a2_min,a1_max)\n"
  },
  {
    "path": "Mind Palaces.py",
    "content": "def binar(arr,l,r,x):\n    if r >=l:\n        mid = int(l+ (r-l)/2)\n        if arr[mid]==x:\n            return mid\n        elif arr[mid]>x:\n            return binar(arr,l,mid-1,x)\n        else:\n            return binar(arr,mid+1,r,x)\n    else:\n        return -1\n\nn,m = map(int,input().split())\narray = []\nfor i in range(n):\n    temp = list(map(int,input().split()))\n    array.append(temp)\n    \nq  = int(input())\nfor _ in range(q):\n    x = int(input())\n    f =0\n    for i in range(n):\n        t = binar(array[i],0,len(array[i])-1,x)\n        if t!= -1:\n            f=1\n            break\n    if f==1:\n        print(i,t)\n    else:\n        print(\"-1 -1\")\n                \n"
  },
  {
    "path": "Minimum Add to Make Parentheses Valid.py",
    "content": "s = input()\n\nop = '('\ncl = ')'\nst = [s[0]]\nfor i in range(1,len(s)):\n    #print(st)\n    if st:\n        temp =s[i]\n        if temp == cl:\n            \n            if op == st[-1]:\n                st.pop()\n                \n            else:\n                st.append(s[i])\n        else:\n            st.append(s[i])\n    else:\n        st.append(s[i])\n\nprint(len(st))\n"
  },
  {
    "path": "Minimum moves.py",
    "content": "n = int(input())\nfor _ in range(n):\n    x,y = map(int,input().split())\n    if x<0 or y<0 or y>x:\n        print(-1)\n    else:\n        print(max(x,y))\n"
  },
  {
    "path": "Modify Sequence.py",
    "content": "n = int(input())\nl = list(map(int,input().split()))\n\n\n\nfor i in range(n-1):\n    if l[i]<=l[i+1]:\n        l[i+1] = l[i+1]-l[i]\n    else:\n        print('NO')\n        break\nelse:\n    if l[n-1]==0:\n        print('YES')\n    else:\n        print('NO')\n"
  },
  {
    "path": "Modulo Strength.py",
    "content": "#NOTE array b is used to store the count of number of student that have same strength\n\n# Write your code here\nn,k = map(int,input().split())\na = list(map(int,input().split()))\nb = [0]*k\nfor i in range(n):\n    b[a[i]%k] += 1\nans = 0\nfor i in range(k):\n    ans += b[i]*(b[i]-1)\n\nprint(ans)\n"
  },
  {
    "path": "Monk And the operations.py",
    "content": "def abs_sum(row):\n    s =0\n    for i in range(len(row)):\n        s += abs(row[i])\n    return s\n    \ndef abs_add(row,v1):\n    l = len(row)\n    for i in range(l):\n        row[i] += v1\n    x = abs_sum(row)\n    return x\n    \n\nn,m= map(int,input().split())\n\n#input Matrix\nmatrix = []\nfor i in range(n):\n    a = list(map(int,input().split()))\n    matrix.append(a)\n\nv1,v2,v3,v4 = map(int,input().split())\n\n#convert n rows into n column\ncol =[]\nfor i in range(m):\n    a = []\n    for j in range(n):\n        a.append(matrix[j][i])\n    col.append(a)\n\n#row sum and update check   \nf_sum1=0\nfor i in range(n):\n    sum1=abs_sum(matrix[i])\n    x=0\n    temp = abs_add(matrix[i],v1)\n    temp_2 = abs(len(matrix[i])*v2)\n    if temp< temp_2:\n        x = temp_2\n    else:\n        x = temp\n    if x>sum1:\n        sum1 = x\n        \n    #print(sum1,i)\n    f_sum1 += sum1\n    \nc_sum1=0\nfor i in range(m):\n    sum1=abs_sum(col[i])\n    x12 = 0\n    temp = abs_add(col[i],v3)\n    temp_1 = abs(len(col[i])*v4)\n    if temp< temp_1:\n        x12= temp_1\n    else:\n        x12 = temp\n        \n    if x12>sum1:\n        sum1 =x12\n    #print(sum1,i)\n    c_sum1 += sum1\n    \nif c_sum1>f_sum1:\n    print(c_sum1)\nelse:\n    print(f_sum1)\n"
  },
  {
    "path": "Monk Takes a Walk.py",
    "content": "t = int(input())\nfor _ in range(t):\n    s = input()\n    s = s.lower()\n    c=0\n    for i in range(len(s)):\n        \n        if s[i] =='a' or s[i] =='e' or s[i] =='i' or s[i] =='o' or s[i] =='u':\n            c+=1\n    print(c)\n"
  },
  {
    "path": "Monk Teaches Palindrome.py",
    "content": "t = int(input())\nfor _ in range(t):\n    s = input()\n    n = len(s)\n    if s == s[::-1]:\n        if n%2==0:\n            print(\"YES EVEN\")\n        else:\n            print(\"YES ODD\")\n    else:\n        print(\"NO\")\n"
  },
  {
    "path": "Monk and Inversions.py",
    "content": "t = int(input())\nfor _ in range(t):\n    n= int(input())\n    matrix = []\n    for i in range(n):\n        a = list(map(int,input().split()))\n        matrix.append(a)\n        #print(matrix)\n    c=0\n    for i in range(n):\n        for j in range(n):\n            for p in range(n):\n                for q in range(n):\n                    if i<=p and j<=q:\n                        if matrix[i][j]>matrix[p][q]:\n                            c+=1\n    print(c)\n"
  },
  {
    "path": "Monk and Lucky Minimum.py",
    "content": "testCase  = int(input())\nfrom collections import Counter\nfor _ in range(testCase):\n    n = int(input())\n    l = list(map(int,input().split()))\n    p  = Counter(l)\n    x = min(l)\n    if p[x]%2==0:\n        print('Unlucky')\n    else:\n        print(\"Lucky\")\n"
  },
  {
    "path": "Monk and Power of Time.py",
    "content": "n = int(input())\ncall = list(map(int,input().split()))\nideal = list(map(int,input().split()))\n\ndef check(a,b):\n    if a[0] == b[0]:\n        return True\n    return False\n\nc=0\nwhile len(call)>0:\n    if check(call,ideal)==True:\n        call = call[1:]\n        ideal = ideal[1:]\n        c+=1\n    else:\n        call = call[1:n]+call[:1]\n        #print(call)\n        c+=1\n\nprint(c)\n"
  },
  {
    "path": "Monk and Rotation.py",
    "content": "testCase  = int(input())\nfor _ in range(testCase):\n    n,k = map(int,input().split())\n    l = list(map(int,input().split()))\n    x = k%n\n    print(*(l[n-x:]+l[:n-x]))\n        \n"
  },
  {
    "path": "Monk and Welcome Problem.py",
    "content": "n= int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = [0]*n\nfor i in range(n):\n    c[i] = a[i]+b[i]\nprint(*c)\n"
  },
  {
    "path": "Most Frequent.py",
    "content": "from collections import Counter\nn =int(input())\nl = Counter(list(map(int,input().split())))\nx = 100000\nfor k,v in l.items():\n    if v==max(l.values()):\n        x = min(x,k)\nprint(x)\n"
  },
  {
    "path": "Multiple occurrences.py",
    "content": "# Simple Brute force implementation\n# Only thing to note here is that in the dictonary/HaspMap we are storing key and list of values \n\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    a = list(map(int,input().split()))\n    d= {}\n\n    for i in range(len(a)):\n        try:\n            if d[a[i]]:\n                d[a[i]].append(i+1)\n        except:\n            d[a[i]] = [i+1]\n\n\n    ans = 0\n    for k,v in d.items():\n        if len(v)>=2:\n            ans += v[-1] - v[0]\n\n    print(ans)\n"
  },
  {
    "path": "N - Co Ordinates (Pair Practice).py",
    "content": "from collections import Counter\nn = int(input())\nd = Counter()\nfor i in range(n):\n    x = tuple(map(int,input().split()))\n    d[x]+=1\n\n \n        \nfor k,v in sorted(d.items()):\n    print(*k,v)\n"
  },
  {
    "path": "Neutralisation of charges.py",
    "content": "n = int(input())\ns =input()\n\n\nl = list(s)\nstack = []\nstack.append(l[0])\nfor i in range(1,len(l)):\n    stack.append(l[i])\n    try:\n        if stack[-1] and stack[-2]:\n            if stack[-1]==stack[-2]:\n                stack.pop()\n                stack.pop()\n    except:\n        pass\nprint(len(stack))\n\nprint(''.join(stack))\n"
  },
  {
    "path": "Not in Range.py",
    "content": "k = sum([i for i in range(1,1000001)])\nt = int(input())\nl = []\nfor _ in range(t):\n    x,y = map(int,input().split())\n    l.append([x,y])\n    \nl = sorted(l)\nfor i in range(len(l)-1):\n    #print(i)\n    if(l[i+1][0]<=l[i][1]):\n        l[i+1][0] = l[i][1]+1\n\nfor i in range(len(l)):\n    if(l[i][0]>l[i][1]):\n        l[i] = 0\nfor i in range(len(l)):\n    if(l[i]!=0):\n        e = (l[i][1]*(l[i][1]+1))//2\n        o = (l[i][0]*(l[i][0]+1))//2\n        p = e-o+l[i][0]\n        k-=p\nprint(k)\n"
  },
  {
    "path": "Number of cycles.py",
    "content": "#Simple Cycles - No.of closed figure . \n#Hint - See Pattern\n\n# Write your code here\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    ans = 1\n    ans += (n-1)*n\n    print(ans)\n"
  },
  {
    "path": "Number of steps.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nn = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncount = 0\nmi = min(a)\ni = 0\nwhile i <n:\n    if a[i]>=b[i]:\n        while a[i]>mi:\n            a[i] -= b[i]\n            count+=1\n    if a[i] < mi:\n            mi = a[i]\n            i = 0\n    if a[i] != mi:\n        count = -1\n        break\n    i+=1 \n\nprint(count)\n\n#A rare test case :\n#         n=2\n#        a = [3,2]\n#        b = [2,1]\n# then all a's element should be 1\n"
  },
  {
    "path": "Pair Sum.py",
    "content": "n,m= map(int,input().split())\nfrom collections import Counter\narr = list(map(int,input().split()))\nd = Counter(arr)\n\n\nflag = 0\nfor i in range(n):\n    temp = m - arr[i]\n    if d[temp]:\n        if arr[i]==temp and d[temp]==1:\n            continue\n        print(\"YES\")\n        flag = 1\n        break\nif flag==0:\n    \n    print(\"NO\")\n"
  },
  {
    "path": "Pairs.py",
    "content": "def isPrime(n) : \n  \n    # Corner cases\n    allprime = [True for i in range(ma+1)]\n\n    p=2\n    x = [0]*(n+1)\n    while (p*p<=n):\n        if allprime[p]==True:\n        \n            for i in range(p*p,n+1,p):\n                allprime[i] = False\n        p+=1\n    for i in range(2,len(allprime)):\n        if allprime[i]:\n            x[i] = x[i-1]+1\n        else:\n            x[i] = x[i-1]\n    return x\nma = 100005\nx = isPrime(ma)\nt = int(input())\nfor _ in range(t):\n    m,n = list(map(int,input().split()))\n    if m==1:\n        m =2\n    \n    #print(\"ALl Prime lsit\",allprime)\n    no_of_prime = x[n]-x[m-1]\n    print(no_of_prime*(n-m-no_of_prime+1))\n"
  },
  {
    "path": "Palindromic String.py",
    "content": "n  = input()\nif n== n[::-1]:\n    print('YES')\nelse:\n    print('NO')\n"
  },
  {
    "path": "Passing the Parcel.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nn  = int(input())\nst = [True]*n\nsong = input()\nne = len(song)\nc = 0\nj=0\ni=0\nwhile c<n-1:\n    #print(i)\n    if i>=ne:\n        i = i%ne\n    if j>=n:\n        j = j%n\n    if song[i] =='a':\n        if st[j] != False:\n            i+=1\n            #st[j] == True\n            j+=1\n        else:\n            j+=1\n    elif song[i] == 'b':\n        #print(\"sdsds\")\n        if st[j] != False:\n            c+=1\n            i+=1\n            st[j] = False\n            j+=1\n        else:\n            j+=1\n\nfor i in range(len(st)):\n    if st[i] == True:\n        print(i+1)\n        break\n"
  },
  {
    "path": "Pepper and Contiguous Even Subarray.py",
    "content": "t= int(input())\nfor _ in range(t):\n    n = int(input())\n    l = list(map(int,input().split()))\n    c=0\n    x=[-1]\n    for i in range(n):\n        if l[i]%2==0:\n            c+=1\n            x.append(c)\n        else:\n            c=0\n    print(max(x))\n"
  },
  {
    "path": "Perfect Subarray.py",
    "content": "n = int(input())\nl = list(map(int,input().split()))\n\nimport math\ndef checkperfect(n):\n    i = int(math.sqrt(n))\n    if n==i*i:\n        return True\n    else:\n        return False\n\n\nc=0\nfor i in range(n):\n    s= 0\n    for j in range(i,n):\n        s+=l[j]\n        if checkperfect(s):\n            c+=1\nprint(c)\n"
  },
  {
    "path": "Permute the Array.py",
    "content": "t = int(input())\nfrom collections import Counter\nfor _ in range(t):\n    n,k = map(int,input().split())\n    arr = list(map(int,input().split()))\n    count = int(n/k)\n    a= Counter(arr)\n    l2 = 0\n    for p12,v in a.items():\n        if v==count:\n            l2+=1\n            #print(l1)\n        elif v>count:\n            temp = int((v/count))\n            l2+=temp\n            #print(temp)\n    if l2 ==k:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n"
  },
  {
    "path": "Polygon Possibility",
    "content": "t= int(input())\nfor _ in range(t):\n    n = int(input())\n    l = list(map(int,input().split()))\n    s = sum(l)\n    for i in range(len(l)):\n        if l[i]>=s-l[i]:\n            print('No')\n            break\n    else:\n        print('Yes')\n"
  },
  {
    "path": "Prasun the detective.py",
    "content": "p = input().lower()\nq = input().lower()\n\np =p.replace(\" \",\"\")\n\nq = q.replace(\" \",\"\")\n\nimport re\np = re.sub('[^a-z0-9]','',p)\nq= re.sub('[^a-z0-9]','',q)\nif sorted(p)==sorted(q):\n    print('YES')\nelse:\n    print('NO')\n"
  },
  {
    "path": "Prime Number.py",
    "content": "# Write your code here\ndef prime(x):\n    l = [True for i in range(x+1)]\n    p=2\n    while (p*p <= x):\n        if l[p]==True:\n            for i in range(2*p,x+1,p):\n                l[i] = False\n        p+=1\n    for i in range(2,x+1):\n        if l[i]:\n            print(i,end=' ')\n            \nn  = int(input())\nprime(n)\n"
  },
  {
    "path": "Priority Interview.py",
    "content": "n = int(input())\n\nx_y = []\nfor i in range(n):\n    a,b = map(int,input().split())\n    x_y.append([a,b])\nx_y.sort(key = lambda x : x[1],reverse = True)\nx_y.sort(key = lambda x : x[0])\n\nfor i in range(len(x_y)):\n    print(x_y[i][1],end = ' ')\n"
  },
  {
    "path": "README.md",
    "content": "# HackerEarth Solutions\nContains hackerearth solutions in python3\n"
  },
  {
    "path": "Rain Sound.py",
    "content": "t = int(input())\nfor _ in range(t):\n    l,r,s = map(int,input().split())\n    if s > r:\n        print(-1,-1)\n    else:\n        mi = int(((l-1)/s) + 1)\n        ma = r//s\n        if mi>ma:\n            print(-1,-1)\n        else:\n            print(mi,ma)\n"
  },
  {
    "path": "Rectangles to squares.py",
    "content": "# Write your code here\nimport math\nm,n = map(int,input().split())\nx = math.gcd(m,n)\nif x>1:\n    print(\"Yes\")\nelse:\n    print(\"No\")\n"
  },
  {
    "path": "Reversed Linked List.py",
    "content": "class node:\n    def __init__(self,data):\n        self.data = data\n        self.next = None\n\nclass linkedList:\n    \n    def __init__(self):\n        self.head = None\n        \n\n\n    def printl(self):        \n        t =self.head\n        \n        while t:\n            print(t.data,end = ' ')\n            t = t.next\n            \n    def atLast(self,new_data):\n        new_node = node(new_data)\n        if self.head is None: \n            self.head = new_node \n            return\n        \n        \n        temp = self.head\n        while temp.next:\n            temp = temp.next\n            \n        temp.next = new_node\n        new_node.next = None\n        \n    \n                    \n    def addElement(self,lis):\n        lis = lis[::-1]\n        for i in range(len(lis)):\n            nl.atLast(lis[i])\n        \n            \n                \n        \n    def reverse(self):\n        temp = self.head\n        lis = []\n        while temp:\n            #print(temp.data)\n            if int(temp.data)%2==0:\n                lis.append(temp.data)\n                temp = temp.next\n            else:\n                if len(lis)>0:\n                    nl.addElement(lis)\n                    lis = []\n                nl.atLast(temp.data)\n                temp = temp.next\n                \n            \n        if len(lis)>0:\n            nl.addElement(lis)\n        \n        \nl = linkedList()\nnl = linkedList()\nt = int(input())\narr = list(map(int,input().split()))\nfor i in range(len(arr)):\n    l.atLast(arr[i])\nl.reverse()\nnl.printl()\n        \n"
  },
  {
    "path": "Robotic moves.py",
    "content": "# We only need to calculate for x axis since y axis part will be zero.\n#For any more query feel free to mail me.\n\nt = int(input())\nfor i in range(t):\n    n = int(input())\n    print(n*(n+1))\n"
  },
  {
    "path": "Roy and Profile Picture.py",
    "content": "l  = int(input())\nt = int(input())\nfor _ in  range(t):\n    m,n = map(int,input().split())\n    if m < l or n<l:\n        print(\"UPLOAD ANOTHER\")\n    elif m==n:\n        print(\"ACCEPTED\")\n    else:\n        print(\"CROP IT\")\n"
  },
  {
    "path": "Roy and Symmetric Logos.py",
    "content": "def symmetric(matrix,n):\n    for i in range(n):\n        for j in range(n):\n            if int(matrix[i][0][j]) != int(matrix[n-1-i][0][j]):\n                return 'NO'\n            if int(matrix[i][0][j]) != int(matrix[i][0][n-1-j]):\n                return 'NO'\n    return 'YES'\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    matrix = []\n    for i in range(n):\n        temp = list((input().split()))\n        matrix.append(temp)\n    print(symmetric(matrix,n))\n"
  },
  {
    "path": "Saul Goodman's Problem Statement.py",
    "content": "from collections import defaultdict \n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    ans=0\n    d1=defaultdict(int)\n    d2=defaultdict(int)\n    for i in range(n):\n    \n        a,b=map(int,input().split())\n        ans+=d1[a+b]\n        ans+=d2[a-b]\n        #print(\"sdsd\",ans)\n        \n        \n        d1[a+b]+=1 \n        d2[a-b]+=1 \n        #print(d1,d2)\n    print(ans)\n"
  },
  {
    "path": "Save Mrinal.py",
    "content": "n = int(input())\nl = list(map(int,input().split()))\nm = int(input())\ni=0\ntemp = []\nwhile i!=m:\n    qq=[int(x) for x in input().split()]\n    temp.extend(qq)\n\n    if len(temp)>=2:\n        p= temp.pop(0)\n        q = temp.pop(0)\n\n    \n    \n        new_array = l[p-1:q]\n        print(len(set(new_array)))\n        i+=1\n\n    else:\n        pass\n"
  },
  {
    "path": "Seating Arrangement.py",
    "content": "def find(a):\n    ch = a%12\n    if ch==1:\n        print(a+11,'WS')\n    elif ch==0:\n        print(a-11,'WS')\n    elif ch==6:\n        print(a+1,'WS')\n    elif ch==7:\n        print(a-1,'WS')\n\n        \n    elif ch==2:\n        print(a+9,'MS')\n    elif ch==3:\n        print(a+7,'AS')\n    elif ch==4:\n        print(a+5,'AS')\n    elif ch==5:\n        print(a+3,'MS')\n    elif ch==8:\n        print(a-3,'MS')\n    elif ch==9:\n        print(a-5,'AS')\n    elif ch==10:\n        print(a-7,'AS')\n    else:\n        print(a-9,'MS')\n\n\nn = int(input())\nfor i in range(n):\n    a = int(input())\n    find(a)\n"
  },
  {
    "path": "Seven-Segment Display.py",
    "content": "# Write your code here\nd = {'0': 6,\n     '1': 2,\n     '2': 5,\n     '3': 5,\n     '4':4,\n    '5':5,\n    '6':6,\n    '7':3,\n    '8':7,\n    '9':6}\nt  = int(input())\n\nfor _ in range(t):\n    n = input()\n    no_of_matchstick = 0\n    for i in n:\n        no_of_matchstick += d[i]\n\n    #Case 1 Max number when the no_of Matchstick is even\n    if no_of_matchstick%2 == 0:\n        x = int(no_of_matchstick/2)\n        number = ''\n        for i in range(x):\n            number = number + '1'\n    else:\n        x = int((no_of_matchstick-3)/2)\n        number = '7'\n        for i in range(x):\n            number = number + '1'\n\n    print(number)\n"
  },
  {
    "path": "Simon cannot sleep.py",
    "content": "import math\nh,m = map(int,input().split(\":\"))\ntemp = h*60*60 + m*60\na = 0\nd = 3927.272727272727\n\nans = temp/d + 1\nprint(math.floor(ans))\n"
  },
  {
    "path": "Simple Search.py",
    "content": "n= int(input())\nl = list(map(int,input().split()))\nk = int(input())\nfor  i in range(n):\n    if l[i]==k:\n        print(i)\n"
  },
  {
    "path": "SnackDown Contest.py",
    "content": "t = int(input())\nfor _ in range(t):\n    n = int(input())\n    p = list(map(int,input().split()))\n    q = list(map(int,input().split()))\n    \n    p= p[1:]\n    q = q[1:]\n    z = p+q\n    z1 = list(set(z))\n    \n    if len(z1)==n:\n        print('YES')\n    else:\n        print('NO')\n"
  },
  {
    "path": "Speed.py",
    "content": "testCase  = int(input())\nfor _ in range(testCase):\n    n = int(input())\n    l = list(map(int,input().split()))\n    c=1\n    ma = l[0]\n    \n    for i in range(1,n):\n        if l[i]<=ma:\n            #print(l[i])\n            c+=1\n            ma = l[i]\n    print(c)\n"
  },
  {
    "path": "Split Houses.py",
    "content": "n = int(input())\ns = input()\nconsecutive_house = []\ntemp = 0\narr = ['']*n\nfor i,j in enumerate(s):\n    if j == 'H':\n        arr[i] = 'H'\n        temp += 1 \n        if i == n-1:\n            consecutive_house.append(temp)\n    else:\n        arr[i] = 'B'\n        if temp > 0:\n            consecutive_house.append(temp)\n            temp = 0\n            \nif len(consecutive_house) == 0 or max(consecutive_house) == 1:\n    print('YES')\n    print(''.join(arr))\nelse:\n    print('NO')\n"
  },
  {
    "path": "Stack and Queue <Nissan>.py",
    "content": "n , k = map(int,input().split())\nl = list(map(int,input().split()))\n\ns = 0\nfor i in range(k):\n    s += l[i]\n    \nm = s\n#print(m)\nfor i in range(k-1):\n    #print(\"sds\",i)\n    s = s - l[k-i-1] + l[n-1-i]\n    if s>=m:\n        m=s\nprint(m)\n"
  },
  {
    "path": "Statistics.py",
    "content": "# Write your code here\nn = int(input())\narr = []\nfor i in range(n):\n    l = input().split()\n    arr.append(l)\n    \nfrom collections import Counter,OrderedDict \n\nd = Counter(OrderedDict())\nfor i in range(len(arr)):\n    x = str(arr[i][1])\n    #print(x,type(x))\n    if d[x]:\n        d[x]+=1\n    else:\n        d[x]=1\n    \n    \ntemp = max(d.values())\n\nfor k,v in d.items():\n    if v==temp:\n        print(k)\n        break\nprint(d['football'])\n"
  },
  {
    "path": "Strange Game.py",
    "content": "testcase = int(input())\nfor _ in range(testcase):\n    le,k = map(int,input().split())\n    alice = list(map(int,input().split()))\n    bob=list(map(int,input().split()))\n    x = max(bob)+1\n    t=0\n    for i in range(le):\n        if x-alice[i]>0:\n            t += (x-alice[i])*k\n    print(t)\n"
  },
  {
    "path": "String.py",
    "content": "from collections import Counter\nn = int(input())\nst = input()\np = Counter(st)\nprint(n - max(p.values()))\n"
  },
  {
    "path": "Sumita and equal array.py",
    "content": "t = int(input())\nfor _ in range(t):\n    n,x,y,z = map(int,input().split())\n    l = list(map(int,input().split()))\n    for i in range(n):\n        while l[i]%x==0:\n            l[i] = l[i]/x\n        while l[i]%y==0:\n            l[i] = l[i]/y\n        while l[i]%z==0:\n            l[i] = l[i]/z\n    for i in range(1,n):\n        if l[i]!=l[i-1]:\n            print(\"She can't\")\n            break\n    else:\n        print('She can')\n"
  },
  {
    "path": "Takeoff.py",
    "content": "t = int(input())\nfor i in range(t):\n    n,p,q,r = map(int,input().split())\n    c=0\n    for i in range(1,n+1):\n        if (i%p==0)and (i%q!=0)and (i%r!=0):\n            c+=1\n        if (i%p!=0)and (i%q==0)and (i%r!=0):\n            c+=1\n        if (i%p!=0)and (i%q!=0)and (i%r==0):\n            c+=1\n    print(c)\n"
  },
  {
    "path": "Terrible Chandu.py",
    "content": "n = int(input())\nfor i in range(n):\n    a = input()\n    print(a[::-1])\n"
  },
  {
    "path": "The Amazing Race.py",
    "content": "\n\n# Write your code here\n# To understand the question go to link : https://www.geeksforgeeks.org/largest-rectangle-under-histogram/\nt = int(input())\nfor _ in range(t):\n    n= int(input())\n    ar = list(map(int,input().split()))\n    flist = [0]*n\n    stack = list()\n    i=0\n    while i<n:\n        if not stack or ar[stack[-1]]>=ar[i]:\n            stack.append(i)\n            #print(stack)\n            i+=1\n        else:\n            top = stack.pop()\n            if not stack:\n                flist[top] = top\n                #print(\"flidggfd\",flist[top])\n            else:\n                #print(\"top\",top)\n                flist[top] = top-stack[-1]\n                #print(\"flist\",flist[i])\n    while stack:\n        top = stack.pop()\n        if not stack:\n            flist[top] = top\n            #print(\"sdfdf\",flist[top])\n        else:\n                #print(\"top\",top)\n                flist[top] = top-stack[-1]\n                #print(\"flist\",flist[i])\n    blist = [0]*n\n    br = ar[::-1]\n    #print(br)\n    stack1 = list()\n    i=0\n    while i<n:\n        if not stack1 or br[stack1[-1]]>=br[i]:\n            stack1.append(i)\n            #print(stack1)\n            i+=1\n        else:\n            top = stack1.pop()\n            if not stack1:\n                blist[top] = top\n                #print(\"flidggfd\",blist[top])\n            else:\n                #print(\"top\",top)\n                blist[top] = top-stack1[-1]\n                #print(\"flist\",flist[i])\n    while stack1:\n        top = stack1.pop()\n        if not stack1:\n            blist[top] = top\n            #print(\"sdfdf\",blist[top])\n        else:\n                #print(\"top\",top)\n                blist[top] = top-stack1[-1]\n                #print(\"flist\",flist[i])\n    backlist = blist[::-1]\n    res_list = [] \n    for i in range(0, len(backlist)): \n        res_list.append(backlist[i] + flist[i])\n    sight  = []\n    for i in range(1,len(res_list)+1):\n        sight.append((i*res_list[i-1])%1000000007)\n    temp = sight.index(max(sight))+1\n    print(temp)\n"
  },
  {
    "path": "The Monk and Kundan.py",
    "content": "def index(ref,x):\n    for i in range(len(ref)):\n        if ref[i]==x:\n            return i\n            \nref = 'abcdefghijklmnopqrstuvwxyz1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nref  = list(ref)\nn = int(input())\nfor i in range(n):\n    l = list(input().split())\n    \n\n    \n    s=0\n    for i in range(len(l)):\n        for j in range(len(l[i])):\n            t= index(ref,l[i][j])\n            s+=j+ t\n    print(s*len(l))\n"
  },
  {
    "path": "The best Internet Browser.py",
    "content": "from fractions import Fraction\nt = int(input())\nfor _ in range(t):\n    s = input()\n    n = len(s)\n    c=0\n    for j in range(4,n-4):\n        #print(s[i])\n        if (s[j] != 'a') and  (s[j] != 'e') and (s[j]!= 'i') and (s[j] != 'o') and (s[j] !='u') :\n            c+=1\n\n    print(c+4,end ='')\n    print('/',end = '')\n    print(n)\n"
  },
  {
    "path": "Thief and Warehouses.py",
    "content": "def solve (array, n):\n    stack = []\n    i=0\n    max_a=0\n    area = 0\n    while i<len(array):\n        if  not stack or (array[stack[-1]]<=array[i]):\n            stack.append(i)\n            i+=1\n            #print(stack)\n        else:\n            top = stack.pop()\n            if stack:\n                area = array[top]*(i-1-stack[-1])\n            else:\n                area =  array[top]*(i)\n        max_a = max(max_a,area)\n    while stack:\n        top = stack.pop()\n        if stack:\n                area = array[top]*(i-1-stack[-1])\n        else:\n            area =  array[top]*(i)\n            \n        max_a = max(max_a,area)\n    return max_a\n    # Write your code here\n\nT = int(input())\nfor _ in range(T):\n    n = int(input())\n    Ar = list(map(int, input().split()))\n\n    out_ = solve(Ar, n)\n    print (out_)\n"
  },
  {
    "path": "Toggle String.py",
    "content": "n = input()\nprint(n.swapcase())\n"
  },
  {
    "path": "Two Strings.py",
    "content": "from collections import Counter\ndef check(a,b):\n    p = Counter(a)\n    q = Counter(b)\n    if sum((p-q).values())==0:\n        print('YES')\n    else:\n        print('NO')\n\n\nn = int(input())\nfor _ in range(n):\n    a,b = input().split()\n    check(a,b)\n"
  },
  {
    "path": "VC pairs.py",
    "content": "test_cases = int(input())\nfor _ in range(test_cases):\n    n = int(input())\n    s = input()\n    count = 0\n\n    for i in range(n-1):\n        if s[i] != 'a' and s[i] != 'e' and s[i] != 'i' and s[i] != 'o' and s[i] != 'u' :\n            if s[i+1] == 'a' or s[i+1] == 'e' or s[i+1] == 'i' or s[i+1] == 'o' or s[i+1] == 'u' :\n                count += 1\n\n    print(count)\n"
  },
  {
    "path": "Vada Pav List.py",
    "content": "n = int(input())\nl = []\nfor i in range(n):\n    x = input()\n    l.append(x)\n\nl = list(set(l))\nl.sort()\nprint(len(l))\nfor i in l:\n    print(i)\n"
  },
  {
    "path": "Weighing the Stones.py",
    "content": "from collections import Counter\ntestCase = int(input())\nfor _ in range(testCase):\n    n = int(input())\n    rupam = list(map(int,input().split()))\n    ankit =  list(map(int,input().split()))\n    r =Counter(rupam)\n    a = Counter(ankit)\n    mr_k= 0\n    mr_v=0\n    for k,v in r.items():\n        #print(k,v)\n        if v>=mr_v:\n            if v>mr_v:\n                mr_v = v\n                mr_k = k\n            else:\n                if k>mr_k:\n                    mr_k = k\n                    mr_v = v\n                \n                \n                \n    mr = max(r.keys())\n    if r[mr]>=mr_v:\n        mr_k = mr\n\n        \n    ma_k= 0\n    ma_v=0\n    for k,v in a.items():\n        #print(k,v)\n        if v>=ma_v:\n            if v>ma_v:\n                ma_v = v\n                ma_k = k\n            elif v==ma_v:\n                if k>ma_k:\n                    ma_k = k\n                    ma_v = v\n            \n            \n    #print(ma_k)\n    ma = max(a.keys())\n    if a[ma]>=ma_v:\n        ma_k = ma   \n    \n            \n    if mr_k>ma_k:\n        print('Rupam')\n    elif mr_k<ma_k:\n        print('Ankit')\n    else:\n        print(\"Tie\")\n"
  },
  {
    "path": "Wet Clothes.py",
    "content": "n,m,g = input().split()\nt = list(map(int,input().split()))\na = list(map(int,input().split()))\ngap =[]\nfor i in range(len(t)-1):\n    x = t[i+1]-t[i]\n    gap.append(x)\n    \nm = max(gap)\nc=0\nfor i in range(len(a)):\n    if a[i]<=m:\n        c+=1\nprint(c)\n"
  },
  {
    "path": "Word Queries.py",
    "content": "'''\n# Sample code to perform I/O:\n\nname = input()                  # Reading input from STDIN\nprint('Hi, %s.' % name)         # Writing output to STDOUT\n\n# Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail\n'''\n\n# Write your code here\nclass TrieNode:\n    def __init__(self):\n        self.EndofWord =False\n        self.children  = [None]*26\n        self.word_count = 0\n        \nclass Trie:\n    def __init__(self):\n        self.root = self.getNode()\n        \n    def getNode(self):\n        return TrieNode()\n    \n    def charToint(self,char):\n        return ord(char) -ord('a')\n    \n    def insert(self,key):\n        temp = self.root\n        l = len(key)\n        for i in range(l):\n            #print(i)\n            x = self.charToint(key[i])\n            #print(\"This is x\",x)\n            if not temp.children[x]:\n                temp.children[x] = self.getNode()\n            temp = temp.children[x]\n            temp.word_count +=1\n        temp.EndofWord = True\n        \n \n        \n    def get_prefix(self,key):\n        temp =self.root\n        for i in range(len(key)):\n            x = self.charToint(key[i])\n            if  not temp.children[x]:\n                return None\n            temp = temp.children[x]\n        return temp\n    \n    \n    def find(self,key):\n        node = self.get_prefix(key)\n        #print(node)\n        return node.word_count if node else 0\n        \nt = Trie()\n\n\nn,q = map(int,input().split())\nfor i in range(n):\n    t.insert(input())\n    \n    \nfor i in range(q):\n    x = t.find(input())\n    print(x)\n"
  },
  {
    "path": "balanced brackets.py",
    "content": "n = int(input())\nfor _ in range(n):\n    s = list(input())\n    op = [\"{\",\"[\",\"(\"]\n    cl = [\"}\",\"]\",\")\"]\n    \n    st = [s[0]]\n    for i in range(1,len(s)):\n        if st:\n            temp =s[i]\n            if temp in op:\n                st.append(temp)\n            else:\n                ind = cl.index(s[i])\n                if st[-1]==op[ind]:\n                    st.pop()\n        else:\n            st.append(s[i])\n    if len(st)>0:\n        print(\"NO\")\n    else:\n        print(\"YES\")\n"
  },
  {
    "path": "e-maze-in.py",
    "content": "n = input()\nx,y = 0,0\nfor i in n:\n    if i == 'L':\n        x -= 1\n    elif i == 'R':\n        x += 1\n    elif i == 'U':\n        y += 1\n    elif i == 'D':\n        y -= 1\nprint(x,y)\n"
  },
  {
    "path": "square sub matrix.py",
    "content": "t = int(input())\nfor _ in range(t):\n    n,m = map(int,input().split())\n    matrix = []\n    for i in range(n):\n        x = list(map(int,input().split()))\n        matrix.append(x)\n    m2 = [[0 for _ in range(m)] for _ in range(n)]\n\n    ma= 0 \n    for i in range(n):\n        for j in range(m):\n            if i==0 or j==0:\n                #print(i,j)\n                m2[i][j] = matrix[i][j]\n                if ma<m2[i][j]:\n                    ma  = m2[i][j]\n            elif matrix[i][j]==0:\n                m2[i][j] =0\n            else:\n                m2[i][j] = matrix[i][j] + min(m2[i-1][j],m2[i-1][j-1],m2[i][j-1])\n                if m2[i][j] >ma:\n                    ma = m2[i][j]\n    print(ma*ma)\n"
  },
  {
    "path": "super reduced strings.py",
    "content": "s = input()\nstack = [s[0]]\nfor i in range(1,len(s)):\n    if stack:\n        \n        if stack[-1]== s[i]:\n            #print(\"ssds\",stack)\n            stack.pop()\n        else:\n            stack.append(s[i])\n    else:\n\n        stack.append(s[i])\n    #stack.append(s[i])\nif len(stack)>0:\n    print(''.join(stack))\nelse:\n    print('Empty String')\n"
  },
  {
    "path": "zoos.py",
    "content": "# Write your code here\ns = input()\n\nfrom collections import Counter\nd = Counter(s)\nif d['z']*2 == d['o']:\n    print(\"Yes\")\nelse:\n    print(\"No\")\n"
  }
]