message
stringlengths
2
65.1k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
0
108k
cluster
float64
14
14
__index_level_0__
int64
0
217k
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,994
14
189,988
Tags: binary search, data structures Correct Solution: ``` #If FastIO not needed, used this and don't forget to strip #import sys, math #input = sys.stdin.readline import os import sys from io import BytesIO, IOBase import heapq as h import bisect from types import GeneratorType BUFSIZE = 8192 class S...
output
1
94,994
14
189,989
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,995
14
189,990
Tags: binary search, data structures Correct Solution: ``` n = int(input()) from bisect import bisect_left as br a = [int(x) for x in input().split()] mn = [10 ** 10 for i in range(n)] mn[-1] = a[-1] for i in range(n - 2, -1 , -1): mn[i] = min(mn[i + 1], a[i]) ans = [0] * n for i in range(n): pos = br(mn, a[i]...
output
1
94,995
14
189,991
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,996
14
189,992
Tags: binary search, data structures Correct Solution: ``` n=int(input()) x=[int(q) for q in input().split()] l=[0]*n def search(i,l,h): pos=-1 while(h>=l): mid=(l+h)//2 if x[mid]<x[i]: pos=mid l=mid+1 else: h=mid-1 if pos!=-1: return pos-...
output
1
94,996
14
189,993
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,997
14
189,994
Tags: binary search, data structures Correct Solution: ``` n = int(input()) import bisect arr = list(map(int,input().strip().split()))[:n] mins = [0]*n mins[n-1] = arr[-1] for i in range(n-2,-1,-1): mins[i] = min(mins[i+1],arr[i]) ans = [] for i in range(n-1): if arr[i] <= mins[i+1]: ans.append(-1) ...
output
1
94,997
14
189,995
Provide tags and a correct Python 3 solution for this coding contest problem. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginning of the queue. The i-th walrus has the age eq...
instruction
0
94,998
14
189,996
Tags: binary search, data structures Correct Solution: ``` from bisect import * n = int(input()) a = list(map(int, input().split())) b = [0] * n for i in range(n - 1, -1, -1): b[i] = bisect_left(a, a[i], i + 1, n) - i - 2 a[i] = min(a[i + 1], a[i]) if i != n - 1 else a[i] print (*b) ```
output
1
94,998
14
189,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
94,999
14
189,998
Yes
output
1
94,999
14
189,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,000
14
190,000
Yes
output
1
95,000
14
190,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,001
14
190,002
Yes
output
1
95,001
14
190,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,002
14
190,004
Yes
output
1
95,002
14
190,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,003
14
190,006
No
output
1
95,003
14
190,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,004
14
190,008
No
output
1
95,004
14
190,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,005
14
190,010
No
output
1
95,005
14
190,011
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n walruses standing in a queue in an airport. They are numbered starting from the queue's tail: the 1-st walrus stands at the end of the queue and the n-th walrus stands at the beginni...
instruction
0
95,006
14
190,012
No
output
1
95,006
14
190,013
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,823
14
191,646
Tags: greedy Correct Solution: ``` n = int(input()) S = [input() for i in range(3)] bu = [] for s in S: cnt = {} mx = 0 for c in s: if c not in cnt: cnt[c] = 0 cnt[c] += 1 mx = max(mx, cnt[c]) if mx == len(s) and n == 1: bu.append(mx - 1) else: bu....
output
1
95,823
14
191,647
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,824
14
191,648
Tags: greedy Correct Solution: ``` n = int(input()) s1 = input() s2 = input() s3 = input() s = len(s1) d1, d2, d3 = dict(), dict(), dict() for i in s1: if i not in d1: d1[i] = 1 else: d1[i] += 1 for i in s2: if i not in d2: d2[i] = 1 else: d2[i] += 1 for i in s3: if i not in d3: d3[i] = 1 else: d3[i] ...
output
1
95,824
14
191,649
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,825
14
191,650
Tags: greedy Correct Solution: ``` def ct(s): a=[0]*26*2 for i in s: if ord(i)<97: a[ord(i)-65]+=1 else: a[ord(i)-97+26]+=1 return max(a) n=int(input()) s1=input() ln=len(s1) s1=ct(s1) s2=ct(input()) s3=ct(input()) s=[s1,s2,s3] for i in range(len(s)): if s[i]==ln ...
output
1
95,825
14
191,651
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,826
14
191,652
Tags: greedy Correct Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.s...
output
1
95,826
14
191,653
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,827
14
191,654
Tags: greedy Correct Solution: ``` n = int(input()) s1 = input().strip() s2 = input().strip() s3 = input().strip() d1 = [0 for _ in range(52)] d2 = [0 for _ in range(52)] d3 = [0 for _ in range(52)] maxi1 = 0 maxi2 = 0 maxi3 = 0 for i in s1: if ord(i) <= 90: j = ord(i) - 65 else: j = ord(i) - ...
output
1
95,827
14
191,655
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,828
14
191,656
Tags: greedy Correct Solution: ``` n = int(input()) a = input() b = input() c = input() def count(s, n): cnt = {} for c in s: cnt[c] = cnt.get(c, 0) + 1 maxc = 0 for c in cnt: if cnt[c] > maxc: maxc = cnt[c] if len(s) == maxc and n == 1: return maxc - 1 else: ret...
output
1
95,828
14
191,657
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,829
14
191,658
Tags: greedy Correct Solution: ``` n = int(input()) ku = input() si = input() ka = input() def bu2num(bu): dif = ord(bu) - ord('a') if dif >= 0 and dif < 26: return dif else: return ord(bu) - ord('A') + 26 def num2bu(num): return chr(ord('a') + num if num < 26 else ord('a') + num - 26) def bus(s): ...
output
1
95,829
14
191,659
Provide tags and a correct Python 3 solution for this coding contest problem. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her. The three friends are very smart so ...
instruction
0
95,830
14
191,660
Tags: greedy Correct Solution: ``` # your code goes here # your code goes here import collections n = int(input()) kuro = input() shiro = input() katie = input() lkuro, lshiro, lkatie = len(kuro), len(shiro), len(katie) ckuro = collections.Counter(kuro).most_common(1)[0][1] cshiro = collections.Counter(shiro).most_com...
output
1
95,830
14
191,661
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,831
14
191,662
Yes
output
1
95,831
14
191,663
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,832
14
191,664
Yes
output
1
95,832
14
191,665
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,833
14
191,666
Yes
output
1
95,833
14
191,667
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,834
14
191,668
Yes
output
1
95,834
14
191,669
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,835
14
191,670
No
output
1
95,835
14
191,671
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,836
14
191,672
No
output
1
95,836
14
191,673
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,837
14
191,674
No
output
1
95,837
14
191,675
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play ...
instruction
0
95,838
14
191,676
No
output
1
95,838
14
191,677
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,141
14
192,282
Tags: implementation Correct Solution: ``` n = int(input()) h=[0]*n m=[0]*n for i in range(n): h[i],m[i] = map(int,input().split()) k = int(input()) for i in range(n): if k>=h[i] and k<=m[i]: g=i break print(n-g) ```
output
1
96,141
14
192,283
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,142
14
192,284
Tags: implementation Correct Solution: ``` n = int(input()) lr = [list(map(int, input().split())) for _ in range(n)] k = int(input()) ans = n for lri in lr: if lri[0] <= k <= lri[1]: print(ans) break else: ans -= 1 ```
output
1
96,142
14
192,285
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,143
14
192,286
Tags: implementation Correct Solution: ``` n = int(input()) v = [] for i in range(n): v.append(int(input().split()[1])) p = int(input()) for pos, i in enumerate(v): if i >= p: print(n-pos) break ```
output
1
96,143
14
192,287
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,144
14
192,288
Tags: implementation Correct Solution: ``` n = int(input()) a = [] for i in range(n): l, r = map(int, input().split()) a.append(l) a.append(r) k = int(input()) i = 0 while a[i] < k: i += 1 print(n - i // 2) ```
output
1
96,144
14
192,289
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,145
14
192,290
Tags: implementation Correct Solution: ``` n = int(input()) tail = [] for i in range(n): a, b = map(int, input().split()) tail.append(b) m = int(input()) for i in range(m): if m <= tail[i]: print(n - i) break ```
output
1
96,145
14
192,291
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,146
14
192,292
Tags: implementation Correct Solution: ``` n=int(input()) lfi=[] for i in range(n): l=input().split() lfi.append([int(i) for i in l]) k=int(input()) for i in range(n): if(k>=lfi[i][0] and k<=lfi[i][1]): ans=i break print(n-ans) ```
output
1
96,146
14
192,293
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,147
14
192,294
Tags: implementation Correct Solution: ``` n = int(input()) start = [] end = [] for i in range(n): a,b = map(int,input().split()) start.append(a) end.append(b) k = int(input()) for i in range(n): if k in range(start[i],end[i]+1): break print(n-i) ```
output
1
96,147
14
192,295
Provide tags and a correct Python 3 solution for this coding contest problem. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least one page. Yesterday evening Nastya did not ma...
instruction
0
96,148
14
192,296
Tags: implementation Correct Solution: ``` n = int(input()) tmp = [] for i in range(n): tmp.append([int(x) for x in input().split(' ')]) k = int(input()) for i in range(n): if tmp[i][0] <= k <= tmp[i][1]: print(n - i) ```
output
1
96,148
14
192,297
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,149
14
192,298
Yes
output
1
96,149
14
192,299
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,150
14
192,300
Yes
output
1
96,150
14
192,301
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,151
14
192,302
Yes
output
1
96,151
14
192,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,152
14
192,304
Yes
output
1
96,152
14
192,305
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,153
14
192,306
No
output
1
96,153
14
192,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,154
14
192,308
No
output
1
96,154
14
192,309
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,155
14
192,310
No
output
1
96,155
14
192,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. After lessons Nastya decided to read a book. The book contains n chapters, going one after another, so that one page of the book belongs to exactly one chapter and each chapter contains at least...
instruction
0
96,156
14
192,312
No
output
1
96,156
14
192,313
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the c...
instruction
0
96,470
14
192,940
Tags: data structures, greedy Correct Solution: ``` n = int(input()) array = list(map(int, input().split())) cnt = 0 s = [0 for i in range(n)] s[n - 1] = 1 * (array[n - 1] == 0) for i in range(n - 2, -1, -1): s[i] = s[i + 1] + 1 * (array[i] == 0) for i in range(n): cnt += s[i] * (array[i] == 1) print(cnt) ```
output
1
96,470
14
192,941
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the c...
instruction
0
96,471
14
192,942
Tags: data structures, greedy Correct Solution: ``` n = int(input()) a = list(map(int,input().split())) res = 0 b = 0 for i in reversed(range(n)): if a[i]==1: res += b else: b += 1 print(res) ```
output
1
96,471
14
192,943
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the c...
instruction
0
96,473
14
192,946
Tags: data structures, greedy Correct Solution: ``` n = int(input()) arr = list(map(int, input().split())) zero_count = [0] * n zero_count[n - 1] = int(arr[n - 1] == 0) for i in reversed(range(n - 1)): zero_count[i] = zero_count[i + 1] + int(arr[i] == 0) res = 0 for i in range(n - 1): if arr[i] == 1: ...
output
1
96,473
14
192,947
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the c...
instruction
0
96,474
14
192,948
Tags: data structures, greedy Correct Solution: ``` def cows(n, lst): zeros, result = 0, 0 for i in range(n - 1, -1, -1): if lst[i] == 0: zeros += 1 else: result += zeros return result m = int(input()) a = [int(j) for j in input().split()] print(cows(m, a)) ```
output
1
96,474
14
192,949
Provide tags and a correct Python 3 solution for this coding contest problem. Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the c...
instruction
0
96,475
14
192,950
Tags: data structures, greedy Correct Solution: ``` #in the name of god #Mr_Rubick n=int(input()) a=list(map(int,input().split())) cnt,s=0,[0]*n s[n-1]=1*(a[n-1]==0) for i in range(n-2,-1,-1): s[i]=s[i+1]+1*(a[i]==0) for i in range(n): cnt+=s[i]*(a[i]==1) print(cnt) ```
output
1
96,475
14
192,951