Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
n = [0]*N
n_used = [False]*N
if N > 1:
    n[0]=1
for i in range(0,M,1):
    s,c = map(int,input().split())
    if (n_used[s-1] and n[s-1]!=c) or (s==1 and c ==0 and N != 1):
        print(-1)
        exit()
    else:
        n[s-1]=c
        n_used[s-1]=True

print("{}{}{}".format(n[0],n[1],n[2]))

Fixed submission:
N,M = map(int,input().split())
n = [0]*N
n_used = [False]*N
if N > 1:
    n[0]=1
for i in range(0,M,1):
    s,c = map(int,input().split())
    if (n_used[s-1] and n[s-1]!=c) or (s==1 and c ==0 and N != 1):
        print(-1)
        exit()
    else:
        n[s-1]=c
        n_used[s-1]=True
st = "".join(list(map(str,n)))
print(st)
Buggy python submission (verdict: Time Limit Exceeded):
#Union Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N,M,K = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N+1)

friends = [[]for i in range(0,N+1,1)]
block = [[]for i in range(0,N+1,1)]
for i in range(0,M,1):
    a,b = map(int,input().split())
    friends[a].append(b)
    friends[b].append(a)
    unite(a,b)
for i in range(0,K,1):
    a,b=map(int,input().split())
    block[a].append(b)
    block[b].append(a)

countmem = [0]*N
for i in range(1,N+1,1):
    count = size(i)-1
    mem = []
    ma = mem.append
    for j in range(0,len(friends[i]),1):
        if same(i,friends[i][j]):
            count -=1
            ma(friends[i][j])
    for j in range(0,len(block[i]),1):
        if same(i,block[i][j]) and not(block[i][j] in mem):
            count -=1
    countmem[i-1]=count

print(*countmem)

Fixed submission:
#Union Find
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N,M,K = map(int,input().split())
#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N+1)

friends = [[]for i in range(0,N+1,1)]
block = [[]for i in range(0,N+1,1)]
for i in range(0,M,1):
    a,b = map(int,input().split())
    friends[a].append(b)
    friends[b].append(a)
    unite(a,b)
for i in range(0,K,1):
    a,b=map(int,input().split())
    block[a].append(b)
    block[b].append(a)

for i in range(1,N+1,1):
    friends[i].extend(block[i])
    set(friends[i])

countmem = [0]*N
for i in range(1,N+1,1):
    count = size(i)-1
    for j in range(0,len(friends[i]),1):
        if same(i,friends[i][j]):
            count -=1
    countmem[i-1]=count

print(*countmem)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left,bisect_right

TO_ACII = 97

N = int(input())
S = ["0"] + list(input())
Q = int(input())

ABC = [[]for i in range(0,26,1)]#該当文字a:0 b:1 ...z:26 が何文字目に出てきたかを保持する配列

for i in range(1,N+1,1):
    ABC[ord(S[i])-TO_ACII].append(i)

ans = []
for i in range(0,Q,1):
    q = list(input().split())
    if q[0]=="1":#文字変更
        changed = S[int(q[1])]
        ABC[ord(changed)-TO_ACII].pop(bisect_left(ABC[ord(changed)-TO_ACII],int(q[1])))
        ABC[ord(q[2])-TO_ACII].insert(bisect_left(ABC[ord(q[2])-TO_ACII],int(q[1])),int(q[1]))
        S[int(q[1])]=q[2]
    else:
        tmpans = 0
        for i in range(0,26,1):

            if bisect_right(ABC[i],int(q[1])-1)<len(ABC[i]) and int(q[2]) >= ABC[i][bisect_right(ABC[i],int(q[1])-1)]:
                tmpans+=1
        ans.append(tmpans)

for i in range(0,len(ans),1):
    print(ans[i])


Fixed submission:
from bisect import bisect_left,bisect_right

TO_ACII = 97

N = int(input())
S = ["0"] + list(input())
Q = int(input())

ABC = [[]for i in range(0,26,1)]#該当文字a:0 b:1 ...z:26 が何文字目に出てきたかを保持する配列

for i in range(1,N+1,1):
    ABC[ord(S[i])-TO_ACII].append(i)

ans = []
for i in range(0,Q,1):
    q = list(input().split())
    if q[0]=="1":#文字変更
        changed = S[int(q[1])]
        ABC[ord(changed)-TO_ACII].pop(bisect_left(ABC[ord(changed)-TO_ACII],int(q[1])))
        ABC[ord(q[2])-TO_ACII].insert(bisect_left(ABC[ord(q[2])-TO_ACII],int(q[1])),int(q[1]))
        S[int(q[1])]=q[2]
    else:
        tmpans = 0
        for i in range(0,26,1):

            if bisect_right(ABC[i],int(q[1])-1)<len(ABC[i]) and int(q[2]) >= ABC[i][bisect_right(ABC[i],int(q[1])-1)]:
                tmpans+=1
        ans.append(tmpans)

for i in range(0,len(ans),1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007#い　つ　も　の
n,k = map(int,input().split())

nCk = 1#nC0
ans = 1

if k > n-1:
    k = n-1

for i in range(1,k+1,1):
    nCk = (((nCk*(n-i+1))%MOD)*pow(i,1000000005,1000000007))%MOD
    ans = (ans%MOD + ((((nCk*nCk)%MOD)*(n-i)%MOD)*pow(n,1000000005,1000000007)%MOD)%MOD)%MOD

print(ans)


Fixed submission:
MOD = 1000000007#い　つ　も　の
n,k = map(int,input().split())

nCk = 1#nC0
ans = 1

if k > n-1:
    k = n-1

for i in range(1,k+1,1):
    nCk = (((nCk*(n-i+1))%MOD)*pow(i,1000000005,1000000007))%MOD
    ans = (ans%MOD + ((((nCk*nCk)%MOD)*(n-i)%MOD)*pow(n,1000000005,1000000007)%MOD)%MOD)%MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
pn =0
qn =0
count =0
for x in itertools.permutations(range(1,N+1,1)):
    count+=1
    tmp = " ".join(list(map(str,x)))
    if tmp == P:
        pn = count
    if tmp == Q:
        qn = count
print(abs(qn-pn))

Fixed submission:
import itertools

N = int(input())
P = input()
Q = input()
pn =0
qn =0
count =0
for x in itertools.permutations(range(1,N+1,1)):
    count+=1
    tmp = " ".join(list(map(str,x)))
    if tmp == P:
        pn = count
    if tmp == Q:
        qn = count
print(abs(qn-pn))
Buggy python submission (verdict: Runtime Error):
N = int(input())
nood = [[]for i in range(0,N+1,1)]
h_color = [1]*(N+1)
for i in range(1,N,1):
    a,b=map(int,input().split())
    nood[a].append([b,i])
    nood[b].append([a,i])

max_color_count = -1

def bfs(nowNood,preNood,preColor):
    global max_color_count
    colorCount=1
    for i in range(0,len(nood[nowNood]),1):
        if nood[nowNood][i][0]!=preNood:
            if colorCount == preColor:
                colorCount+=1
            h_color[nood[nowNood][i][1]]=colorCount
            bfs(nood[nowNood][i][0],nowNood,colorCount)
            max_color_count = max(max_color_count,colorCount)
            colorCount+=1

bfs(1,-1,-1)
print(max_color_count)
for i in range(1,N,1):
    print(h_color[i])






Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())
nood = [[]for i in range(0,N+1,1)]
h_color = [1]*(N+1)
for i in range(1,N,1):
    a,b=map(int,input().split())
    nood[a].append([b,i])
    nood[b].append([a,i])

max_color_count = -1

def bfs(nowNood,preNood,preColor):
    global max_color_count
    colorCount=1
    for i in range(0,len(nood[nowNood]),1):
        if nood[nowNood][i][0]!=preNood:
            if colorCount == preColor:
                colorCount+=1
            h_color[nood[nowNood][i][1]]=colorCount
            bfs(nood[nowNood][i][0],nowNood,colorCount)
            max_color_count = max(max_color_count,colorCount)
            colorCount+=1

bfs(1,-1,-1)
print(max_color_count)
for i in range(1,N,1):
    print(h_color[i])

Buggy python submission (verdict: Runtime Error):
N = int(input())
nood = [[]for i in range(0,N+1,1)]
h_color = [1]*(N+1)
for i in range(1,N,1):
    a,b=map(int,input().split())
    nood[a].append([b,i])
    nood[b].append([a,i])

max_color_count = -1
def bfs(nowNood,preNood,preColor):
    global max_color_count
    colorCount=1
    for i in range(0,len(nood[nowNood]),1):
        if nood[nowNood][i][0]!=preNood:
            if colorCount == preColor:
                colorCount+=1
            h_color[nood[nowNood][i][1]]=colorCount
            bfs(nood[nowNood][i][0],nowNood,colorCount)
        max_color_count = max(max_color_count,colorCount)
        colorCount+=1

bfs(1,-1,-1)
print(max_color_count)
for i in range(1,N,1):
    print(h_color[i])

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
N = int(input())
nood = [[]for i in range(0,N+1,1)]
h_color = [1]*(N+1)
for i in range(1,N,1):
    a,b=map(int,input().split())
    nood[a].append([b,i])
    nood[b].append([a,i])

max_color_count = -1

def bfs(nowNood,preNood,preColor):
    global max_color_count
    colorCount=1
    for i in range(0,len(nood[nowNood]),1):
        if nood[nowNood][i][0]!=preNood:
            if colorCount == preColor:
                colorCount+=1
            h_color[nood[nowNood][i][1]]=colorCount
            bfs(nood[nowNood][i][0],nowNood,colorCount)
            max_color_count = max(max_color_count,colorCount)
            colorCount+=1

bfs(1,-1,-1)
print(max_color_count)
for i in range(1,N,1):
    print(h_color[i])
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007

X,Y = map(int,input().split())
x,y = (2*X-Y)//3,(2*Y-X)//3#行動１、行動２を起こす回数
if (2*X-Y)%3 != 0 or (2*Y-X)%3 != 0 or x < 0 or y < 0 or(x==0 and y==0):
    print(0)
    exit()
ans =1
for i in range(x+y,0,-1):
    ans = ((ans%MOD)*i)%MOD
for i in range(x,0,-1):
    ans = ((ans%MOD)*pow(i,MOD-2,MOD))%MOD
for i in range(y,0,-1):
    ans = ((ans%MOD)*pow(i,MOD-2,MOD))%MOD

print(ans)


Fixed submission:
MOD = 1000000007

X,Y = map(int,input().split())
x,y = (2*X-Y)//3,(2*Y-X)//3#行動１、行動２を起こす回数
if (2*X-Y)%3 != 0 or (2*Y-X)%3 != 0 or x < 0 or y < 0 or(x==0 and y==0):
    print(0)
    exit()
ans =1
for i in range(x+y,0,-1):
    ans = ((ans%MOD)*i)%MOD
for i in range(x,0,-1):
    ans = ((ans%MOD)*pow(i,MOD-2,MOD))%MOD
for i in range(y,0,-1):
    ans = ((ans%MOD)*pow(i,MOD-2,MOD))%MOD

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

A,B = map(int,input().split())
G = math.gcd(A,B)
count = 0
p = 1
for i in range(1,math.ceil(math.sqrt(G))+1,1):
    if G%i ==0:
        if math.gcd(p,i)==1:
            count +=1
            p = p*i
print(count)

Fixed submission:
import math

A,B = map(int,input().split())
G = math.gcd(A,B)

N = G
#素因数分解
sep = []
for i in range(2,int(math.sqrt(N))+2,1):
    if N % i ==0:
        count = 0
        while N % i == 0:
            N = N//i
            count += 1
        sep.append([i,count])
if N != 1:
    sep.append([N,1])

print(len(sep)+1)

Buggy python submission (verdict: Runtime Error):
import fractions as math

A,B = map(int,input().split())
G = math.gcd(A,B)
count = 0
p = 1
for i in range(1,math.ceil(math.sqrt(G))+1,1):
    if G%i ==0:
        if math.gcd(p,i)==1:
            count +=1
            p = p*i
print(count)

Fixed submission:
import math

A,B = map(int,input().split())
G = math.gcd(A,B)

N = G
#素因数分解
sep = []
for i in range(2,int(math.sqrt(N))+2,1):
    if N % i ==0:
        count = 0
        while N % i == 0:
            N = N//i
            count += 1
        sep.append([i,count])
if N != 1:
    sep.append([N,1])

print(len(sep)+1)

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

A,B = map(int,input().split())
G = math.gcd(A,B)
count = 0
p = 1
for i in range(1,math.ceil(math.sqrt(G))+1,1):
    if G%i ==0:
        if math.gcd(p,i)==1:
            count +=1
            p = p*i
print(count)

Fixed submission:
import math

A,B = map(int,input().split())
G = math.gcd(A,B)

N = G
#素因数分解
sep = []
for i in range(2,int(math.sqrt(N))+2,1):
    if N % i ==0:
        count = 0
        while N % i == 0:
            N = N//i
            count += 1
        sep.append([i,count])
if N != 1:
    sep.append([N,1])

print(len(sep)+1)
Buggy python submission (verdict: Runtime Error):
S = input()
dic = {"Sunny":"Cloudy","Rainy":"Sunny","Cloudy":"Rainy"}
print(dic(S))

Fixed submission:
S = input()
dic = {"Sunny":"Cloudy","Rainy":"Sunny","Cloudy":"Rainy"}
print(dic[S])
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7

S = list(input())
pre = [0]*13
now = [0]*13
pre[0]=1

for i in range(0,len(S),1):
    now =[0]*13
    if S[i]=="?":
        for k in range(0,10,1):
            for j in range(0,13,1):
                now[j] = (now[j] + pre[(j - (k*pow(10,len(S)-i-1,13))%13)%13])%MOD
    else:
        for j in range(0,13,1):
            now[j] = pre[(j - (int(S[i])*pow(10,len(S)-i-1,13))%13)%13]
    
    for j in range(0,13,1):
        pre[j]=now[j]

print(now[5])

Fixed submission:
s = input()
 
mod = 10**9+7
n = len(s)
res = [1] + [0] * 12
for ss in s:
    dp = [0] * 13
    for i in range(13):
        dp[(10*i)%13] = res[i]
    dp += dp
 
    if ss == '?':
        for i in range(13):
            res[i] = sum(dp[i+4:i+14])
    else:
        for i in range(13):
            res[i] = dp[i+13-int(ss)]
    res = [v%mod for v in res]
print(res[5])
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
S = [list(input()) for i in range(0,H,1)]

teraseru_H = [[0 for i in range(0,W,1)]for j in range(0,H,1)]
teraseru_W = [[0 for i in range(0,W,1)]for j in range(0,H,1)]

left = -1
for i in range(0,H,1):
    left=-1
    for j in range(0,W,1):
        if S[i][j]=="#":
            if left!=-1:
                for k in range(left,j,1):
                    teraseru_H[i][k] = j-left
                left=-1

        else:#"."
            if left==-1:
                left=j
    if left!=-1:
        for k in range(left,W,1):
            teraseru_H[i][k] = W-left
    left=-1

left = -1
for j in range(0,W,1):
    left=-1
    for i in range(0,H,1):
        if S[i][j]=="#":
            if left!=-1:
                for k in range(left,i,1):
                    teraseru_W[k][j] = i-left
                left=-1
        else:#"."
            if left==-1:
                left=i
    if left!=-1:
        for k in range(left,H,1):
            teraseru_W[k][j] = H-left
    left=-1

ans = 0

for i in range(0,H,1):
    for j in range(0,W,1):
        ans = max(ans,teraseru_H[i][j]+teraseru_W[i][j]-1)
print(ans)

Fixed submission:
H,W = map(int,input().split())
S = [list(input()) for i in range(0,H,1)]

teraseru_H = [[0 for i in range(0,W,1)]for j in range(0,H,1)]
teraseru_W = [[0 for i in range(0,W,1)]for j in range(0,H,1)]

left = -1
for i in range(0,H,1):
    left=-1
    for j in range(0,W,1):
        if S[i][j]=="#":
            if left!=-1:
                for k in range(left,j,1):
                    teraseru_H[i][k] = j-left
                left=-1

        else:#"."
            if left==-1:
                left=j
    if left!=-1:
        for k in range(left,W,1):
            teraseru_H[i][k] = W-left
    left=-1

left = -1
for j in range(0,W,1):
    left=-1
    for i in range(0,H,1):
        if S[i][j]=="#":
            if left!=-1:
                for k in range(left,i,1):
                    teraseru_W[k][j] = i-left
                left=-1
        else:#"."
            if left==-1:
                left=i
    if left!=-1:
        for k in range(left,H,1):
            teraseru_W[k][j] = H-left
    left=-1

ans = 0

for i in range(0,H,1):
    for j in range(0,W,1):
        ans = max(ans,teraseru_H[i][j]+teraseru_W[i][j]-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
a = [int(input())for i in range(5)]
k = int(input())
print( "Yay!" if max(a)-min(b) > k else ":(" )

Fixed submission:
a = [int(input())for i in range(5)]
k = int(input())
print( "Yay!" if max(a)-min(a) <= k else ":(" )
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input())
h,w = map(int,input())
print((H-h)*(W-w))

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

wari = []
count = 0
for i in range(1,A+B):
    if A%i==0 and B%i==0:
        if count == K:
            wari.append(i)
print(wari[len(wari)-K])

Fixed submission:
A,B,K = map(int,input().split())

wari = []
count = 0
for i in range(1,A+B):
    if A%i==0 and B%i==0:
        wari.append(i)
print(wari[len(wari)-K])

Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

count = 0
for i in range(A+B):
    if A%i==0 and B%i==0:
        count +=1
        if count == K:
            print(i)
            break

Fixed submission:
A,B,K = map(int,input().split())

wari = []
count = 0
for i in range(1,A+B):
    if A%i==0 and B%i==0:
        wari.append(i)
print(wari[len(wari)-K])
Buggy python submission (verdict: Runtime Error):
#bit全探索の亜種(4種全探索)
#itertools.product([0,1,2,3],repeat=N)

import itertools
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(0,N,1)]

ans = 10**10
for ABCD in itertools.product([0,1,2,3],repeat=N):
    tmp = [[] for i in range(4)]
    for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
    score = 0
    owaowari = False
    for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
    if owaowari: continue
    score+=abs(A-sum(tmp[0]))
    score+=abs(B-sum(tmp[1]))
    score+=abs(C-sum(tmp[2]))
    ans = min(ans,score)
    if score == 120:

print(ans)


Fixed submission:
#bit全探索の亜種(4種全探索)
#itertools.product([0,1,2,3],repeat=N)

import itertools
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(0,N,1)]

ans = 10**10
for ABCD in itertools.product([0,1,2,3],repeat=N):
    tmp = [[] for i in range(4)]
    for i in range(0,N,1):
        tmp[ABCD[i]].append(l[i])
    score = 0
    owaowari = False
    for i in range(3):#Dはくっ付ける必要なし
        if len(tmp[i])==0:
            owaowari = True
            break
        score+=10*max(len(tmp[i])-1,0)
    if owaowari: continue
    score+=abs(A-sum(tmp[0]))
    score+=abs(B-sum(tmp[1]))
    score+=abs(C-sum(tmp[2]))
    ans = min(ans,score)


print(ans)
Buggy python submission (verdict: Runtime Error):
#左右それぞれで一番近い神社
#その神社それぞれの左右それぞれで一番近い寺
#はい２ぶたん
from bisect import bisect_right

A,B,Q = map(int,input().split())
s = [int(input())for i in range(A)]
t = [int(input())for i in range(B)]

ans = []
for i in range(0,Q,1):
    q = int(input())
    sr = min(bisect_right(s,q),A-1)
    sl = max(0,sr-1)

    tr = min(bisect_right(t,q),B-1)
    tl = max(0,sl-1)


    ans.append(min(
    abs(q-s[sr])+ abs(t[min(bisect_right(t,s[sr]),B-1)]-s[sr]),
    abs(q-s[sl])+ abs(t[min(bisect_right(t,s[sl]),B-1)]-s[sl]),
    abs(q-t[tr])+ abs(s[min(bisect_right(s,t[tr]),A-1)]-t[tr]),
    abs(q-t[tl])+ abs(s[min(bisect_right(s,t[tl]),A-1)]-t[tl]),
    abs(q-s[sr])+ abs(t[max(bisect_right(t,s[sr])-1,0)]-s[sr]),
    abs(q-s[sl])+ abs(t[max(bisect_right(t,s[sl])-1,0)]-s[sl]),
    abs(q-t[tr])+ abs(s[max(bisect_right(s,t[tr])-1,0)]-t[tr]),
    abs(q-t[tl])+ abs(s[max(bisect_right(s,t[tl])-1,0)]-t[tl]))
    )

for i in range(0,Q,1):
    print(ans[i])

Fixed submission:
import bisect
 
A, B, Q = map(int, input().split())
INF = float('inf')
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
 
for i in range(Q):
    x = int(input())
    b = bisect.bisect_right(s, x)
    d = bisect.bisect_right(t, x)
    ans = INF
    for S in [s[b-1], s[b]]:
        for T in [t[d-1], t[d]]:
            ans1 = abs(S-x) + abs(S-T)
            ans2 = abs(T-x) + abs(T-S)
            ans = min(ans, ans1, ans2)
    print(ans)
Buggy python submission (verdict: Runtime Error):
A,B =map(int,input().split())
for i in range(1,4,1):
    if (A*B*C) %2 ==1:
        print("Yes")
print("No")


Fixed submission:
A,B =map(int,input().split())
for i in range(1,4,1):
    if (A*B*i) %2 ==1:
        print("Yes")
        exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
#累積xor
#累積和

N = int(input())
A = [0] + list(map(int,input().split()))

#累積xor
ruiseki_xor = [A[i] for i in range(N+1)]
for i in range(1,N+1,1):
    ruiseki_xor[i]=ruiseki_xor[i-1]^A[i]

#累積和
ruiseki = [0]*(N+1)
for i in range(1,N+1,1):
    ruiseki[i]=ruiseki[i-1]+A[i]

ans = 0
cersol = 1
for i in range(1,N+1,1):
    ans += max(cersol,i)-i
    for j in range(max(cersol,i),N+1,1):
        if ruiseki[j]-ruiseki[i-1] == ruiseki_xor[j]^ruiseki_xor[i-1]:
            ans += 1
        else:
            cersol = j-1
            break
        
        

print(ans)


Fixed submission:
#累積xor
#累積和

N = int(input())
A = [0] + list(map(int,input().split()))

#累積xor
ruiseki_xor = [A[i] for i in range(N+1)]
for i in range(1,N+1,1):
    ruiseki_xor[i]=ruiseki_xor[i-1]^A[i]

#累積和
ruiseki = [0]*(N+1)
for i in range(1,N+1,1):
    ruiseki[i]=ruiseki[i-1]+A[i]

ans = 0
cersol = 1
for i in range(1,N+1,1):
    ans += cersol-i
    for j in range(cersol,N+1,1):
        if ruiseki[j]-ruiseki[i-1] == ruiseki_xor[j]^ruiseki_xor[i-1]:
            ans += 1
            cersol = j
        else:
            cersol = j
            break
        
        

print(ans)
Buggy python submission (verdict: Runtime Error):
#サンプルが罠ってパターンもあるんだぜ


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

N = int(input())
primes = get_sieve_of_eratosthenes(5000)
ans=[]

inde=0
while len(ans)<N:
    if primes[inde]%5 == 1:
        ans.append(primes[inde])
    inde+=1

print(" ".join(ans))


Fixed submission:
#サンプルが罠ってパターンもあるんだぜ


def get_sieve_of_eratosthenes(n):
    if not isinstance(n, int):
        raise TypeError("n is int-type.")
    if n < 2:
        raise ValueError("n is more than 2")
    data = [i for i in range(2, n + 1)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data

N = int(input())
primes = get_sieve_of_eratosthenes(5000)
ans=[]

inde=0
while len(ans)<N:
    if primes[inde]%5 == 1:
        ans.append(primes[inde])
    inde+=1

print(" ".join(list(map(str,ans))))
Buggy python submission (verdict: Runtime Error):
A,B,K = map(int,input().split())

X = list(range(A,B+1,1))
ans = X[0:K]+X[len(X)-K:len(X)]
ans = list(set(ans))
for i in range(len(ans)):
    print(ans[i])

Fixed submission:
A,B,K = map(int,input().split())

for i in range(A,B+1,1):
    if i-A < K or B-i < K:
        print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

a = [int(input()) for i in range(N)]

tmp = 0
count = 1
tmp = a[0]

while tmp != 2 and tmp != 1:
    count += 1
    tmp = a[tmp-1]

if tmp == 2:
    print(count)
else:
    print(-1)

Fixed submission:
N = int(input())

a = [int(input())-1 for i in range(N)]
owari = [0]*N

tmp = 0
count = 0

while owari[tmp] == 0 and tmp != 1:
    count += 1
    owari[tmp]=1
    tmp = a[tmp]

if tmp == 1:
    print(count)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
is_alive = [0]*8#各ランク

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

count_over=0

for i in range(0,N,1):
    if a[i]>=3200:
        count_over +=1
    else:
        is_alive[a[i]//400]=1

print(max(1,sum(is_alive)),min(sum(is_alive)+count_over))

Fixed submission:
is_alive = [0]*8#各ランク

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

count_over=0

for i in range(0,N,1):
    if a[i]>=3200:
        count_over +=1
    else:
        is_alive[a[i]//400]=1

print(max(1,sum(is_alive)),sum(is_alive)+count_over)