Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03309 (python)

Fixed submission:
import numpy as np

n = int(input())
a = [int(x) for x in input().split()]

a2 = [a[i] - i - 1 for i in range(n)]
mean = sum(a2) / len(a2)
median = np.median(np.array(a2))
b = np.floor(median)
a3 = sum([abs(a2[i] - b) for i in range(n)])
b = np.ceil(median)
a4 = sum([abs(a2[i] - b) for i in range(n)])
print(int(min(a3, a4)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]

a2 = [a[i] - i - 1 for i in range(n)]
mean = sum(a2) / len(a2)
b = np.floor(mean)
a3 = sum([abs(a2[i] - b) for i in range(n)])
b = np.ceil(mean)
a4 = sum([abs(a2[i] - b) for i in range(n)])
print(int(min(a3, a4)))
Problem p03338 (python)

Fixed submission:
n = int(input())
s = input()
Max = 0
for i in range(1, len(s)): # i = 1
    length = len(set(s[:i]) & set(s[i:]))
    if length > Max:
        Max = length
print(Max)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
    cnt = 0
    for i in range(1, N):
        # スライスで部分文字列をつくって、set型に変換し、積集合で共通する英小文字を取得
        dup_cnt = set(S[:i]) & set(S[i:])
        # 共通する英小文字の数が現時点での最大値より大きいなら最大値を更新
        if cnt < len(dup_cnt):
            cnt = len(dup_cnt)
    print(cnt)
Problem p03352 (python)

Fixed submission:
import math
X = int(input())
res = 0
for b in range(1, int(math.sqrt(X))+1): # sqrt(X)付近まで探索
    for p in range(2, int(math.sqrt(X))+2): # sqrt(X)付近まで探索
        val = b**p
        if (val <= X) and (val > res): # X以下かつその値が最大値なら値を更新
            res = val
print(res)

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
res = 0
for b in range(1, int(math.sqrt(X))+1): # sqrt(X)付近まで探索
    for p in range(2, int(math.sqrt(X))+2): # sqrt(X)付近まで探索
        val = b**p
        if (val <= X) and (val > res): # X以下かつその値が最大値なら値を更新
            res = val
print(res)

Buggy submission (verdict: Runtime Error):
x = int(input())
res = 0
for b in range(1, int(math.sqrt(X))+1): # sqrt(X)付近まで探索
    for p in range(2, int(math.sqrt(X))+2): # sqrt(X)付近まで探索
        val = b**p
        if (val <= X) and (val > res): # X以下かつその値が最大値なら値を更新
            res = val
print(res)
Problem p03360 (python)

Fixed submission:
def f(a, b, c, k):
    abc = sorted([a, b, c])
    if k != 0:
        abc[2] *= 2 ** k
    print(sum(abc))

a, b, c = map(int, input().split())
k = int(input())
f(a, b, c, k)

Buggy submission (verdict: Runtime Error):
def f(a, b, c, k):
    abc = sorted([a, b, c])
    abc[2] *= 2 * k
    print(sum(abc))


f(map(int, input().split()), int(input()))
Problem p03400 (python)

Fixed submission:
n = int(input())
d, x = map(int, input().split())
a = [0] * n
for i in range(n):
    a[i] = int(input())
t = 0
for i in a:
    t += len([int(y) for y in range(1, d+1, i)])
print(x + t)

Buggy submission (verdict: Runtime Error):
n = int(input())
d, x = map(int, input().split())
a = [0] * n
for i in range(i):
    a[i] = int(input())
t = 0
for i in a:
    t += len([int(y) for y in range(1, d+1, i)])
print(x + t)
Problem p03408 (python)

Fixed submission:
# ABC091B

n = int(input())
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input())
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)

Buggy submission (verdict: Runtime Error):
# ABC091B

n = int(input)
s = [0] * n
for i in range(n):
    s[i] = input()
m = int(input)
t = [0] * m
for i in range(m):
    t[i] = input()

blue = {}
for c in s:
    if c in blue.keys():
        blue[c] += 1
    else:
        blue.setdefault(c, 1)
red = {}
for c in t:
    if c in red.keys():
        red[c] += 1
    else:
        red.setdefault(c, 1)

Max = 0
for blue_key, blue_value in blue.items():
    get = blue_value
    if blue_key in red.keys():
        for red_key, red_value in red.items():
            if blue_key == red_key:
                get -= red_value
                break
    Max = max(Max, get)
print(Max)
Problem p03424 (python)

Fixed submission:
n = int(input())
s = list(input().split())
if len(set(s)) == 3:
    print('Three')
else:
    print('Four')

Buggy submission (verdict: Runtime Error):
# ABC089B

n = int(input())
s = list(map(int, input().split()))
if len(set(s)) == 4:
    print('Three')
else:
    print('Four')

Buggy submission (verdict: Runtime Error):
# ABC089B

n = int(input())
s = list(map(int, input().split)))
if len(set(s)) == 4:
    print('Three')
else:
    print('Four')
Problem p03471 (python)

Fixed submission:
def f(n, y):
    for i in range(n+1):
        for j in range(n-i+1):
            k = n - i - j
            if k >= 0:
                if y == i*10000 + j*5000 + k*1000:
                    print(i, j, k)
                    return
    print(-1, -1, -1)

n, y = map(int, input().split())
f(n, y)

Buggy submission (verdict: Runtime Error):
# ABC085C

n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        k = n - i - j
        if k >= 0:
            if y == i*10000 + j*5000 + k*1000:
                print(i, j, k)
                return
print(-1, -1, -1)
Problem p03574 (python)

Fixed submission:
# ABC075B

import numpy as np

h, w = map(int, input().split())
board = np.reshape(np.array(np.repeat("@", (h+2)*(w+2))), (h+2, w+2))
for i in range(h):
    s = input()
    board[i+1, 1:w+1] = np.array(list(s))
for i in range(1, h+1):
    count = np.zeros(w, dtype=str)
    for j in range(1, w+1):
        if board[i,j] == '.':
            count[j-1] = str(\
                (board[i-1, j-1] == "#") + (board[i-1, j] == "#") + (board[i-1, j+1] == "#") +\
                (board[i  , j-1] == "#") + (board[i  , j] == "#") + (board[i  , j+1] == "#") +\
                (board[i+1, j-1] == "#") + (board[i+1, j] == "#") + (board[i+1, j+1] == "#"))
        elif board[i, j] == "#":
            count[j-1] = "#"
    print(''.join(count))

Buggy submission (verdict: Runtime Error):
# ABC075B

import numpy as np

h, w = map(int, input().split())
board = sp.reshape(np.array(np.repeat("@", (h+2)*(w+2))), (h+2, w+2))
for i in range(h):
    s = input()
    board[i+1, 1:w+1] = np.array(list(s))
for i in range(1, h+1):
    count = np.zeros(w, dtype=str)
    for j in range(1, w+1):
        if board[i,j] == '.':
            count[j-1] = str(\
                (board[i-1, j-1] == "#") + (board[i-1, j] == "#") + (board[i-1, j+1] == "#") +\
                (board[i  , j-1] == "#") + (board[i  , j] == "#") + (board[i  , j+1] == "#") +\
                (board[i+1, j-1] == "#") + (board[i+1, j] == "#") + (board[i+1, j+1] == "#"))
        elif board[i, j] == "#":
            count[j-1] = "#"
    print(''.join(count))

Buggy submission (verdict: Runtime Error):
# ABC075B

import numpy as np

h, w = map(int, input().split())
board = sp.reshape(np.array(sp.repeat("@", (h+2)*(w+2))), (h+2, w+2))
for i in range(h):
    s = input()
    board[i+1, 1:w+1] = np.array(list(s))
for i in range(1, h+1):
    count = np.zeros(w, dtype=str)
    for j in range(1, w+1):
        if board[i,j] == '.':
            count[j-1] = str(\
                (board[i-1, j-1] == "#") + (board[i-1, j] == "#") + (board[i-1, j+1] == "#") +\
                (board[i  , j-1] == "#") + (board[i  , j] == "#") + (board[i  , j+1] == "#") +\
                (board[i+1, j-1] == "#") + (board[i+1, j] == "#") + (board[i+1, j+1] == "#"))
        elif board[i, j] == "#":
            count[j-1] = "#"
    print(''.join(count))

Buggy submission (verdict: Runtime Error):
# ABC075B

import numpy as np

h, w = map(int, input().split())
board = sp.reshape(np.array(sp.repeat("@", (h+2)*(w+2))), (h+2, w+2))
for i in range(h):
    s = input()
    board[i+1, 1:w+1] = np.array(list(s))
for i in range(1, h+1):
    count = sp.zeros(w, dtype=str)
    for j in range(1, w+1):
        if board[i,j] == '.':
            count[j-1] = str(\
                (board[i-1, j-1] == "#") + (board[i-1, j] == "#") + (board[i-1, j+1] == "#") +\
                (board[i  , j-1] == "#") + (board[i  , j] == "#") + (board[i  , j+1] == "#") +\
                (board[i+1, j-1] == "#") + (board[i+1, j] == "#") + (board[i+1, j+1] == "#"))
        elif board[i, j] == "#":
            count[j-1] = "#"
    print(''.join(count))
Problem p03606 (python)

Fixed submission:
n = int(input())
s = 0
for i in range(n):
    l, r = map(int, input().split())
    s += r - l +1
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
lr = [0] * n
for i in range(n):
    lr[i] = list(map(int, int().split()))
s = 0
for i, j in lr:
    s += j - i + 1
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
lr = [0] * n
for i in range(n):
    lr[i] = list(map(int, int().split()))
s = 0
for i in range(0, len(lr), 2):
    s += lr[i+1] - lr[i] + 1
print(s)
Problem p03658 (python)

Fixed submission:
n, k = map(int, input().split())
l = list(map(int, input().split()))
l = sorted(l)
l = l[::-1]
print(sum(l[:k]))

Buggy submission (verdict: Runtime Error):
n, k = map(int, l.split())
l = list(map(int, l.split()))
l = sorted(l)
l = l[::-1]
print(sum(l[:k]))
Problem p03673 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], end=" ")
    print(*odd)
else:
    print(*odd[::-1], end=" ")
    print(*even)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
even = []
odd = []
for i in range(n):
    if i % 2:
        even.append(a[i])
    else:
        odd.append(a[i])
if n % 2 == 0:
    print(*even[::-1], *odd)
else:
    print(*odd[::-1], *even)
Problem p03838 (python)

Fixed submission:
# AGC008A

def func(x, y):
    if y >= x:
        if x >= 0:
            return y - x
        else:
            if y > 0:
                if abs(x) > abs(y):
                    return 1 - x - y
                else:
                    return 1 + x + y
            elif y <= 0:
                return y - x
    else:
        if x >= 0:
            if y < 0:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 - x - y
            elif y == 0 or y == 1:
                return x + 1
            else:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 + y - x
        else:
            return 2 + x - y

x, y = map(int, input().split())
print(func(x, y))

Buggy submission (verdict: Runtime Error):
# AGC008A

def func(x, y):
    if y >= x:
        if x >= 0:
            return y - x
        else:
            if y > 0:
                if abs(x) > abs(y):
                    return 1 - x - y
                else:
                    return 1 + x + y
            elif y <= 0:
                return y - x
    else:
        if x >= 0:
            if y < 0:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 - x - y
            elif y == 0 or y == 1:
                return x + 1
            else:
                if abs(x) > abs(y):
                    return 1 + x + y
                else:
                    return 1 + y - x
        else:
            return 2 + x - y

x, y = map(int, input().split())
print(f(x, y))
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int, input().split())
print((a+b)*h//2)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int, input().split())
print((a + b) * h // 2)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int, input().split())
print((a + b) * h // 2)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int, input().split())
print((a + b) * h // 2)
Problem p04012 (python)

Fixed submission:
w = input()
# index, count = np.unique(list(w), return_counts=True)
d = {}
for c in w:
    if c in d.keys():
        d[c] += 1
    else:
        d.setdefault(c, 1)
for i, j in d.items():
    if j % 2 == 1:
        print('No')
        break
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import numpy as np
w = input()
index, count = np.unique(list(w), return_counts=True)
if all(count % 2 == 0):
    print('Yes')
else:
    print('No')
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

A.sort()

if A[0] == 0:
  print(0)
  exit()

ans = 1
for a in A[::-1]:
  ans *= a
  if ans > 10**18:
    print('-1')
    break
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = list(map(int, input().split()))

ans = math.prod(A)

print('-1' if ans > 10**18 else ans)
Problem p03796 (python)

Fixed submission:
n = int(input())
result = 1
for i in range(1, n+1):
  result *= i
  result %= 10**9+7
print(result)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
result = math.prod([i for i in range(1, n+1)])
print(result%(10**9+7))
Problem p02583 (python)

Fixed submission:
n=int(input())
l=list(map(int, input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      if a != b and b != c and a != c:
        ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int, input().split()))
d={}
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c = l[i],l[j],l[k]
      if d[(a,b,c)]: continue
      d[(a,b,c)]=1
      ans+=max(a,b,c)<(b+c+a-max(a,b,c))
print(ans)
Problem p02602 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    a = LI()
    for i in range(n - k):
        if a[i] >= a[i + k]:
            print("No")
        else:
            print("Yes")
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')

#solve
def solve():
    n, k = LI()
    a = LI()
    for i in range(k - 1):
        if a[i] > a[i + k]:
            print("No")
        else:
            print("Yes")
    return


#main
if __name__ == '__main__':
    solve()
Problem p02606 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(b//c-(a-1)//c)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[0]*(n+1)
for i in range(10**2+1):
  for j in range(10**2+1):
    for k in range(10**2+1):
      tmp=i**2+j**2+k**2+i*j+j*k+k*i
      if tmp<=n:
        l[tmp]+=1
for li in l:
  print(li)
Problem p02615 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 0
    a = a[::-1]
    for i in range(1, n):
        ans += a[i // 2]
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    a = LI()
    a.sort()
    ans = 0
    a = a[::-1]
    for i in range(n):
        ans += ans[(i + 1) // 2]
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()
Problem p02651 (python)

Fixed submission:
for i in range(int(input())):
  input()
  t=[]
  for i,j in zip(map(int,input().split()[::-1]),input()[::-1]):
    for k in t:i^=k*(i^k<i)
    if i and j=="0":t.append(i)
    if i and j=="1":print(1);break
  else:print(0)

Buggy submission (verdict: Runtime Error):
for i in range(int(input())):
  input()
  t=[]
  for i,j in reversed(zip(map(int,input().split()),input())):
    for k in t:i^=x*(i^x<i)
    if i and j=="0":t.append(i)
    if i and j=="1":print(1);break
  else:print(0)
Problem p02664 (python)

Fixed submission:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    t = S()
    for i in t:
        if i == "?":
            print("D", end="")
        else:
            print(i, end="")
    print()
    return


#main
if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
    #!/usr/bin/env python3
    from collections import defaultdict,deque
    from heapq import heappush, heappop
    from bisect import bisect_left, bisect_right
    import sys, random, itertools, math
    sys.setrecursionlimit(10**5)
    input = sys.stdin.readline
    sqrt = math.sqrt
    def LI(): return list(map(int, input().split()))
    def LF(): return list(map(float, input().split()))
    def LI_(): return list(map(lambda x: int(x)-1, input().split()))
    def II(): return int(input())
    def IF(): return float(input())
    def S(): return input().rstrip()
    def LS(): return S().split()
    def IR(n): return [II() for _ in range(n)]
    def LIR(n): return [LI() for _ in range(n)]
    def FR(n): return [IF() for _ in range(n)]
    def LFR(n): return [LI() for _ in range(n)]
    def LIR_(n): return [LI_() for _ in range(n)]
    def SR(n): return [S() for _ in range(n)]
    def LSR(n): return [LS() for _ in range(n)]
    mod = 1000000007
    inf = float('INF')

    #solve
    def solve():
        t = S()
        for i in t:
            if i == "?":
                print("D", end="")
            else:
                print(i, end="")
        print()
        return


    #main
    if __name__ == '__main__':
        solve()
Problem p02667 (python)

Fixed submission:
t=input()
n=len(t)
pos=[]
sum=0
for i in range(n):
  if t[i]=="1":
    sum+=1
  else:
    pos.append(sum)
x=(sum+1)//2*((sum+2)//2)
sz=len(pos)
cnt=0
res=[]
for i in range(sz):
  if ((pos[i]&1)^(cnt&1)):
    sum+=1
    cnt+=1
    x+=(sum+1)//2
  else:
    res.append(i)
res=res[::-1]
odd=0
even=0
for i in range(len(res)):
  sum+=1
  if i&1:
    odd = sz - res[i] - even
    x+=(sum+1)//2-odd
  else:
    even=sz-res[i]-odd
    x+=(sum+1)//2-even
print(x)

Buggy submission (verdict: Runtime Error):
T=input()
n=len(T)
i=r=a=0
for c in T:
  k=i-r
  if c=='0':
    r+=!k&1
  else:
    a+=i//2-k//2+(!k&1)*(n-i)
  i+=1
print(a)

Buggy submission (verdict: Runtime Error):
T=input()
n=len(t)
i=r=a=0
for c in T:
  k=i-r
  if c=='0':
    r+=k&1
  else:
    a+=i//2-k//2+(k&1)*(n-i)
  i+=1
print(a)

Buggy submission (verdict: Runtime Error):
T=input()
n=len(t)
i=r=a=0
for c in T:
  k=i-r
  if c=='0':r+=k&1
  else:a+=i//2-k//2+(k&1)*(n-i)
print(a)