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

Fixed submission:
import math
def main():
  N = int(input())
  if (N < 1 or N > 50000):
    print(":(")

  estimatedX1 = math.floor(N / 1.08)
  estimatedX2 = math.ceil(N / 1.08)
  
  if (math.floor(estimatedX1 * 1.08) == N):
    print(math.floor(estimatedX1))
  elif (math.floor(estimatedX2 * 1.08) == N):
    print(math.floor(estimatedX2))
  else:
    print(":(")

main()

Buggy submission (verdict: Runtime Error):
import math
def main():
  N = int input()
  if (N < 1 || N > 50000):
    print(":(")
    return
  estimatedX1 = math.floor(N / 1.08)
  estimatedX2 = math.ceil(N / 1.08)
  
  if (round.floor(estimatedX1 * 1.08) == N):
    print(round.floor(estimatedX1 * 1.08))
  elif (round.floor(estimatedX2 * 1.08) == N):
    print(round.floor(estimatedX2 * 1.08))
  else:
    print(":(")

main()
Problem p02841 (python)

Fixed submission:
ip=input().strip()
while((len)==0):
  ip=input().strip()
m,d=map(int,ip.split())
m1,d1=map(int,input().split())
odd=[1,3,5,7,8,10,12]
eve=[4,6,9,11]
if m in odd:
  if(d==31):
    print(1)
  else:
    print(0)
elif m in eve:
  if(d==30):
    print(1)
  else:
    print(0)
else:
  if(d==28):
    print(1)
  else:
    print(0)

Buggy submission (verdict: Runtime Error):
ip=input().strip()
while((len)==0):
  ip=input().strip()
m,d=map(int,ip.split())
m1,d1=map(int,input().split())
odd=[1,3,5,7,8,10,12]
eve=[4,6,9,11]
if m in odd:
  if(d==31):
    print(1)
  else:
    print(0)
elif m in even:
  if(d==30):
    print(1)
  else:
    print(0)
else:
  if(d==28):
    print(1)
  else:
    print(0)
Problem p02842 (python)

Fixed submission:
import math
N = int(input())

n1 = N / 1.08

if math.floor(math.floor(n1)*1.08) == N:
    print(math.floor(n1))
elif math.floor(math.floor(n1 + 1)*1.08) == N:
    print(math.floor(n1 + 1))
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
N = int(input())

n1 = N / 1.08

if round(n) == n:
    print(n)
else:
    print(":(")
Problem p02921 (python)

Fixed submission:
S = input()
T = input()
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
S, T = map(input().split())
cnt=0
for i in {1,2,3}:
    if S[i-1]==T[i-1]:
        C+=1
print cnt
Problem p02866 (python)

Fixed submission:
import sys
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D)
    result = 1
    if D[0] != 0 or count[0] != 1:
        print(0)
        return
    for i in range(max(D)):
        result *= count[i] ** count[i + 1]
    print(result % 998244353)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
from collections import Counter

input = sys.stdin.readline


def main():
    N = int(input())
    D = list(map(int, input().split()))
    count = Counter(D[1:])
    if D[0] != 0:
        # 頂点1に対しては、0以外有り得ない
        print(0)
        return
    results = [0, count[1]]
    for d in sorted(count.keys())[1:]:
        results.append(results[d - 1] * math.factorial(count[d]))
    print(sum(results[2:]) % 998244353)


if __name__ == "__main__":
    main()
Problem p02888 (python)

Fixed submission:
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            print(l, a, b, j, index, index - j - 1)
            hoge += index - j - 1
    print(hoge)
    # sum([str(i) for i in


if __name__ == "__main__":
    main()
Problem p02900 (python)

Fixed submission:
import fractions
import sys

input = sys.stdin.readline


def factorization(n):
    primes = []
    while n % 2 == 0:
        primes.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            primes.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        primes.append(n)
    return primes


def main():
    a, b = list(map(int, input().split()))

    # 素因数分解
    g = fractions.gcd(a, b)
    print(len(set(factorization(g))) + 1)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import fractions
import sys

input = sys.stdin.readline


def primesfrom2to(n):
    """ Input n>=6, Returns a array of primes, 2 <= p < n """
    sieve = np.ones(n // 3 + (n % 6 == 2), dtype=np.bool)
    for i in range(1, int(n ** 0.5) // 3 + 1):
        if sieve[i]:
            k = 3 * i + 1 | 1
            sieve[k * k // 3 :: 2 * k] = False
            sieve[k * (k - 2 * (i & 1) + 4) // 3 :: 2 * k] = False
    return np.r_[1, 2, 3, ((3 * np.nonzero(sieve)[0][1:] + 1) | 1)]


def main():
    a, b = list(map(int, input().split()))
    # 10 ** 12
    # 愚直だと公約数を求めるだけでも時間切れする
    # 互いに素な公約数がほぼ素数などでは？
    g = fractions.gcd(a, b)
    print(len([i for i in primesfrom2to(g) if g % i == 0]))


if __name__ == "__main__":
    main()
Problem p02923 (python)

Fixed submission:
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    if n == 1:
        print(0)
        return
    # 連続した場合、同値
    acc = list(accumulate([H[i] < H[i + 1] for i in range(n - 1)]))
    x, y = Counter(acc).most_common(1)[0]
    print(y if x == 0 else y - 1)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from itertools import accumulate
from collections import Counter

input = sys.stdin.readline


def main():
    n = int(input())
    H = list(map(int, input().split()))
    print(
        Counter(accumulate([H[i] < H[i + 1] for i in range(n - 1)])).most_common(1)[0][
            1
        ]
        - 1
    )


if __name__ == "__main__":
    main()
Problem p02936 (python)

Fixed submission:
import sys
 
input = sys.stdin.readline
 
 
def main():
    n, q = [int(i) for i in input().split()]
    scores = [0] * (n + 1)
    lines = sorted([[int(i) for i in input().split()] for _ in range(n - 1)])
    counter = [[int(i) for i in input().split()] for _ in range(q)]
    for index, score in counter:
        scores[index] += score
 
    for a, b in lines:
        scores[b] += scores[a]
    print(*scores[1:])
 
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def get_children(parent, child_dict):
    children = child_dict.get(parent, [])
    for child in children:
        yield from get_children(child, child_dict)
    yield parent


def main():
    n, q = [int(i) for i in input().split()]
    scores = [0 for i in range(n)]
    lines = [[int(i) for i in input().split()] for _ in range(n - 1)]
    counter = [[int(i) for i in input().split()] for _ in range(q)]
    child_dict = {}
    for parent, child in lines:
        if parent not in child_dict:
            child_dict[parent] = [child]
        else:
            child_dict[parent].append(child)
    for parent, count in counter:
        for child in get_children(parent, child_dict):
            scores[child - 1] += count
    print(' '.join(map(str, scores)))


if __name__ == "__main__":
    main()
Problem p02947 (python)

Fixed submission:
import sys
from functools import reduce
from operator import mul
from collections import Counter

input = sys.stdin.readline


def cmb(n, r):
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for _, v in Counter(lines).most_common():
        if v == 1:
            break
        count += cmb(v, 2)
    print(count)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math

input = sys.stdin.readline


def main():
    n = int(input())
    lines = ["".join(sorted(input().strip())) for _ in range(n)]
    count = 0
    for text in set(lines):
        txt_cnt = lines.count(text)
        count += int(math.factorial(txt_cnt) / math.factorial(txt_cnt - 2)) // 2
    print(count)


if __name__ == "__main__":
    main()
Problem p02953 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]

    flg = True
    max_ = -1
    for h in H:
        if h < max_:
            flg = False
            break
        if h == max_:
            continue
        max_ = h - 1
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    H = [int(i) for i in input().split()]
    # マスの高さを1つ引くくすること
    # なにもしない
    # 単調非減少ってなんだ
    # 左より低くならないようにすれば良いっぽいな
    # N = 10 ** 5
    # h = 10 ** 9
    # example:
    # 1 2 1 1 -> 1 1 1 1 -> Yes
    # 1 2 2 1 -> 1 2 1 1 -> No
    # 1 2 3 1 -> 1 2 2 1 -> No
    # 1 100 1 1 -> 1 99 1 1 -> No
    #

    cnt = 0
    # とりあえず、愚直に書いてみる
    a = None
    b = H[0]
    for i in range(1, n + 1):
        c = H[i]
        sa = c - b
        if sa < -1:
            cnt = 2
            break
        elif sa < 0:
            if a and a == b:
                cnt = 2
                break
            cnt += 1
        a = b
        b = c
        if cnt > 1:
            break
    print("Yes" if cnt <= 1 else "No")


if __name__ == "__main__":
    main()
Problem p03000 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    n, x = [int(i) for i in input().split()]
    l_list = [int(i) for i in input().split()]
    n += 1
    d = 0
    num = 1
    for i in range(1, n):
        d = d + l_list[i - 1] * (i <= n + 1)
        if d > x:
            break
        num += 1
    print(num)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n, x = [int(i) for i in input().split()]
    l_list = [int(i) for i in input().split()]
    d_list = [0]
    d = d_list[0]
    for i in range(1, n):
        d = d + l_list[i - 1] * (i <= n + 1)
        d_list.append(d)
    print(len(filter(lambda i: i <= x, d_list)))


if __name__ == "__main__":
    main()
Problem p03076 (python)

Fixed submission:
import sys


def main():
    input = sys.stdin.readline
    ryori_list = [int(input()) for _ in range(5)]
    loss_list = [10 - (r % 10) for r in ryori_list if r % 10] or [0]
    print(sum(ryori_list) + sum(loss_list) - max(loss_list))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys


def main():
    input = sys.stdin.readline
    ryori_list = [int(input()) for _ in range(5)]
    loss_list = [10 - (r % 10) for r in ryori_list if r % 10]
    print(sum(ryori_list) + sum(loss_list) - max(loss_list))


if __name__ == "__main__":
    main()
Problem p03086 (python)

Fixed submission:
row = input()
lenght = len(row)
max_moji = 0
for i in range(lenght):
    if row[i] in 'ACGT':
        moji = 1
        for j in range(i + 1, lenght):
            if row[j] in 'ACGT':
                moji += 1
            else:
                break
        max_moji = moji if moji > max_moji else max_moji
    if max_moji == lenght - i:
        break
print(max_moji)

Buggy submission (verdict: Runtime Error):
import re
print(len(max(re.sub(r'[^ACGT]', ' ', input()).split())))

Buggy submission (verdict: Runtime Error):
import re
len(max(re.sub(r'[^ACGT]', ' ', input()).split()))

Buggy submission (verdict: Runtime Error):
len(max(re.sub(r'[^ACGT]', ' ', input()).split()))
Problem p03087 (python)

Fixed submission:
import sys
from itertools import accumulate


def main():
    input = sys.stdin.readline
    n, q = [int(i) for i in input().split()]
    s = input().strip()
    qs = [[int(i) for i in input().split()] for _ in range(q)]
    hoges = [0] + [1 if s[i : i + 2] == "AC" else 0 for i in range(n - 1)]
    hoges = list(accumulate(hoges))
    for (l, r) in qs:
        print(hoges[r - 1] - hoges[l - 1])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n, q = [int(i) for i in input().aplit()]
s = input()
for _ in range(q):
    l, r = [int(i) for i in input().aplit()]
    print(
        len([i for i in [a + b for a, b in zip(s[l-1: r], s[l: r+1])] if i == 'AC']))
Problem p03239 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    n, t = map(int, input().split())
    routes = list(
        filter(lambda x: x[1] <= t, [list(map(int, input().split())) for _ in range(n)])
    )
    if routes:
        print(min(routes)[0])
    else:
        print("TLE")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n, t = map(int, input().split())
    routes = filter(
        lambda x: x[1] <= t, [list(map(int, input().split())) for _ in range(n)]
    )
    if routes:
        print(min(routes)[0])
    else:
        print("TLE")


if __name__ == "__main__":
    main()
Problem p03240 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = sorted(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = z + abs(x - cx) + abs(y - cy)

            if h < 1:
                continue
            if all([z == max(h - abs(x - cx) - abs(y - cy), 0) for x, y, z in points]):
                print(cx, cy, h)
                return


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    points = reversed(
        [[int(i) for i in input().split()] for _ in range(n)],
        key=lambda x: x[2],
        reverse=True,
    )
    print(points)
    hoge = 101
    for cx in range(hoge):
        for cy in range(hoge):
            x, y, z = points[0]
            h = max(z + abs(x - cx) + abs(y - cy), 0)
            # print(h, [max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points])
            if h == 0:
                continue
            if all(
                [h == max(z + abs(x - cx) + abs(y - cy), 0) for x, y, z in points[1:]]
            ):
                print(cx, cy, h)
                break


if __name__ == "__main__":
    main()
Problem p03293 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    s = input().strip()
    t = input().strip()
    print("Yes" if any([s[-i:] + s[:-i] == t for i in range(len(s))]) else "No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    s = input().strip()
    t = input().strip()
    print('Yes' if any([s[-i:] + s[:-i] == t for i in range(len(s))]) 'No')


if __name__ == "__main__":
    main()
Problem p03547 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    x, y = input().split()
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    x, y = map(int, input().split())
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()
Problem p03693 (python)

Fixed submission:
import sys

input = sys.stdin.readline


def main():
    print("YES" if int("".join(input().split())) % 4 == 0 else "NO")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys

input = sys.stdin.readline


def main():
    print("YES" if int(input()) % 4 == 0 else "NO")


if __name__ == "__main__":
    main()
Problem p02848 (python)

Fixed submission:
def change_str(moto_str):
    global Nnew
    global str_list
    global change_list

    for i in range(len(change_list)):
       if change_list[i] == moto_str:
            num = i+Nnew
            if num > 25:
                num = num - 26
    return change_list[num]

Nnew = int(input())
str = input()
str_list = list(str)
change_list = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i in range(len(str_list)):
    str_list[i] = change_str(str_list[i])


print(*str_list,sep='')

Buggy submission (verdict: Runtime Error):
def change_str(moto_str):
    global Nnew
    global str_list
    global change_list

    for i in range(len(change_list)):
       if change_list[i] == moto_str:
            num = i+Nnew
            if num > 25:
                num = num - 25
    return change_list[num]

Nnew = int(input())
str = input()
str_list = list(str)
change_list = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]

for i in range(len(str_list)):
    str_list[i] = change_str(str_list[i])


print(*str_list,sep='')
Problem p02900 (python)

Fixed submission:
x,y = map(int,input().split())
 
#print(x,y)
 
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
x_li=(make_divisors(x))
y_li=(make_divisors(y))
z_li=(list(set(x_li)&set(y_li)))
#print(z_li)
 
import math
count=1

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
 
    return True
for n in z_li:
  if(is_prime(n)==True):
    count=count+1
print(count)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
listA=[] #appendのために宣言が必要
i=0
a=[]
b=[]
c=[]
while True:
    try:
        if(i%2==0):
          i=i+1
          a1,b1=(list(map(int,input().split())))
          a.append(a1)
          b.append(b1)
          #listA.append(list(map(int,input().split())))
        else:
          i=i+1
          c.append(list(map(int,input().split())))	
    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#print(a)
#print(b)
#print(*c)
#偶数はa,b
get_=[]
money=[]
kei=0
for i in range(m):
  get_.extend(c[i])
  kei=kei+a[i]
  if(len(list(set(get_)))==n):
    money.append(kei)
  
print(min(money))
Problem p02909 (python)

Fixed submission:
t=input()
if(t=="Sunny"):
  print("Cloudy")
elif(t=="Cloudy"):
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

n,m=listA[0]

maxA=sorted(listA[1])
kei=0
kei_list=[]
j=0
m1=m
for j in range(m,0,-1):
  	m=m1
    kei=0
    for i in range(n):
        kei=kei + maxA[-i]//(2**(m-j))
        j=j-1
    kei_list.append(kei)
        
print(min(kei_list))
#print(n,k,q)
"""
point=[k]*n
Problem p03211 (python)

Fixed submission:
S = input()

ans = 1e10
for i in range(len(S)-2):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()

ans = 1e10
for i in range(7):
    ans = min(ans, abs(int(S[i:i+3])-753))
print(ans)
Problem p03229 (python)

Fixed submission:
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()

PLUS = A[int((N+1)//2):]
MINUS = A[:int((N+1)//2)]
#print(PLUS, MINUS)
ans = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans += MINUS[-1] - PLUS[0]
else:
    ans += sum(MINUS[-2:])

PLUS = A[int(N//2):]
MINUS = A[:int(N//2)]
#print(PLUS, MINUS)
ans2 = sum(PLUS)*2 - sum(MINUS)*2
if N%2==0:
    ans2 += MINUS[-1] - PLUS[0]
else:
    ans2 -= sum(PLUS[:2])

print(max(ans, ans2))

Buggy submission (verdict: Runtime Error):
def solve(pos):
    start = pos
    ans = 0
    a = 0
    b = N - 1
    for i in range(N-1):
        if a==start:
            a += 1
        elif b==start:
            b -= 1
        if abs(A[a]-A[pos])>=abs(A[b]-A[pos]):
            ans += abs(A[a]-A[pos])
            pos = a
            a += 1
        else:
            ans += abs(A[b]-A[pos])
            pos = b
            b -= 1
        #print(ans, a, b)
    #print(ans)
    return ans

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()

if N<=10000:
    pos_list = list(range(N))
else:
    M = (a+b)/2
    for i in range(N-1):
        if A[i]<=M and M<A[i+1]:
            break
    a = max(0, i - 500)
    b = min(N - 1, i + 500)
    pos_list = list(range(a, b+1))
    if pos_list[0]!=0:
        pos_list = [0] + pos_list
    if pos_list[-1]!= N - 1:
        pos_list.append(N-1)
#print(pos_list)

ans = 0
for pos in pos_list:
    tmp = solve(pos)
    ans = max(ans, tmp)
print(ans)
Problem p03323 (python)

Fixed submission:
A, B = list(map(int, input().split()))
if A<9 and B<9:
    print('Yay!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
A, B = list(map(int, input()))
if A<9 and B<9:
    print('Yay!')
else:
    print(':(')
Problem p03324 (python)

Fixed submission:
D, N = list(map(int, input().split()))
if N==100:# and D==0:
    print((N+1)*100**D)
else:
    print(N*100**D)

Buggy submission (verdict: Runtime Error):
D, N = list(map(int, input().split()))
if N==100 and D==0
    print(101)
else:
    print(N*100**D)
Problem p03342 (python)

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

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# many TLEs & 2 WAs

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

S = [0]
X = [0]
#check = []
for i in range(N):
    S.append(S[-1] + A[i])
    X.append(X[-1] ^ A[i])
    #if A[i]==0 or bin(A[i]).count('1')==1:
    #    check.append(i+1)
    #    if i>0:
    #        check.append(i)
#check = list(set(check))

#print(A)
#print(S)
#print(X)
#print(check)

ans = N
for i in range(1, N):
#for s in check:
    j = i + 1
    while S[j]-S[i-1]==X[j]^X[i-1]:
        j += 1
        if j==N:
            break
    ans += j - i - 1
    #for j in range(s+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        #if S[j]-S[s-1]==X[j]^X[s-1]:#xor(i, j):
            #print(s,j)
            #ans += 1
print(ans)