Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

h,n = list(map(int,input().split()))
inf = 100000000000000000000
dp = [inf]*(2*100000)
for i in range(-1,-100000,-1):
    dp[i] = 0
ls = [0]*n
for i in range(n):
    ls[i] = list(map(int,input().split()))
dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[i+1] = min(dp[i+1],dp[i+1-ls[j][0]]+ls[j][1])
print(dp[h])

Fixed submission:

h,n = list(map(int,input().split()))
inf = 100000000000000000000
dp = [inf]*(2*100000)
for i in range(-1,-100000,-1):
    dp[i] = 0
ls = [0]*n
for i in range(n):
    ls[i] = list(map(int,input().split()))
dp[0] = 0
for i in range(h):
    for j in range(n):
        dp[i+1] = min(dp[i+1],dp[i+1-ls[j][0]]+ls[j][1])
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
# 隣接リスト
graph = {i+1000*j:set() for i in range(n) for j in range(i+1,n)}
# 入次数を管理
st = {i+1000*j:0 for i in range(n) for j in range(i+1,n)}

#たどったかどうかチェック
check = {i+1000*j:True for i in range(n) for j in range(i+1,n)}

# 入次数が0の頂点の集まり
szero = []

#ソートされたやつたち
ans = []

for i in range(n):
    ls = list(map(int,input().split()))
    f = -1
    for p in ls:
        v = min(i,p-1) + 1000*(max(i,p-1))
        if f != -1:
            graph[f].add(v)
            st[v] += 1
        f = v

for v in st.keys():
    if st[v] == 0:szero.append(v)
count = 0
next_szero = []
while True:
    count += 1
    for i in szero:
        ans.append(i)
        for v in graph[i]:
            #if check[v]:check[v] = False
            #else:continue
            st[v] -= 1
            if st[v] == 0:
                next_szero.append(v)
    if len(next_szero) == 0:break
    szero = copy.deepcopy(next_szero)
    next_szero = []

if len(ans) != n*(n-1)//2:
    print(-1)
else:
    print(count)

Fixed submission:
n = int(input())
# 隣接リスト
graph = {i+1000*j:[] for i in range(n) for j in range(i+1,n)}
# 入次数を管理
st = {i+1000*j:0 for i in range(n) for j in range(i+1,n)}


# 入次数が0の頂点の集まり
szero = []

#ソートされたやつたち
ans = []

for i in range(n):
    ls = list(map(int,input().split()))
    f = -1
    for p in ls:
        v = min(i,p-1) + 1000*(max(i,p-1))
        if f != -1:
            graph[f].append(v)
            st[v] += 1
        f = v

for v in st.keys():
    if st[v] == 0:szero.append(v)
count = 0
next_szero = []
while True:
    count += 1
    for i in szero:
        ans.append(i)
        for v in graph[i]:
            st[v] -= 1
            if st[v] == 0:
                next_szero.append(v)
    if len(next_szero) == 0:break
    szero = next_szero
    next_szero = []

if len(ans) != n*(n-1)//2:
    print(-1)
else:
    print(count)
Buggy python submission (verdict: Runtime Error):
import sys
s = input()
t = input()

check = [False]*30
for c in s:
    i = ord(c) - ord("a")
    check[i] = True

for c in t:
    i = ord(c) - ord("a")
    if not check[i]:
        print(-1)
        sys.exit()

dp = [[0 for i in range(26)] for j in range(len(s))]

s = s + s

#
def ser(string :str,target :str,s :int):
    for i in range(s,len(string)):
        if string[i] == target:
            return i % (len(string)//2),i-1

# 指定した範囲に数字を埋める
def dig(ls,c,v,s,t):
    for i in range(s,t+1):
        ls[i][c] = v

for c in range(len(dp[0])):
    i = 0
    while i < len(dp):
        start = i
        print(i)
        v,i = ser(s,chr(c+ord("a")),i+1)
        dig(dp,c,v,start,min(i,len(dp)-1))
        i += 1

print(dp)

Fixed submission:
import sys
s = input()
t = input()

check = [False]*30
for c in s:
    i = ord(c) - ord("a")
    check[i] = True

for c in t:
    i = ord(c) - ord("a")
    if not check[i]:
        print(-1)
        sys.exit()

dp = [[-1 for i in range(26)] for j in range(len(s))]

s = s + s

#
def ser(string :str,target :str,s :int):
    for i in range(s,len(string)):
        if string[i] == target:
            return i % (len(string)//2),i-1

# 指定した範囲に数字を埋める
def dig(ls,c,v,s,t):
    for i in range(s,t+1):
        ls[i][c] = v

for c in range(len(dp[0])):
    if not check[c]:continue
    i = 0
    while i < len(dp):
        start = i
        v,i = ser(s,chr(c+ord("a")),i+1)
        dig(dp,c,v,start,min(i,len(dp)-1))
        i += 1

# 最初にうまいことやるために
import copy
ls = [0 if s[0] == chr(i + ord("a")) else dp[0][i] for i in range(len(dp[0]))]
dp.append(ls)

ans = 0
i = -1
for char in t:
    ikari = dp[i][ord(char) - ord("a")]
    if i >= ikari:
        ans += 1
    i = ikari
print(ans * (len(dp)-1) + 1 + i)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ls = [[x for x in input() + '#'] for i in range(n)] + [['#']*(m+1)]
yokodp = [[0 for x in range(m+1)] for i in range(n+1)]
for i in range(n+1):
    yoko = 0
    for j in range(m+1):
        if ls[i][j] == '#':
            yokodp[i][j] = yoko
            yoko = 0
        else:
            yoko += 1
for i in range(n,-1,-1):
    check = 0
    for j in range(m,-1,-1):
        if yokodp[i][j] != 0:
            check = yokodp[i][j]
        if ls[i][j] == '.':
            yokodp[i][j] = check
tatedp = [[0 for x in range(m+1)] for i in range(n+1)]            
for j in range(m+1):
    tate = 0
    for i in range(n+1):
        if ls[i][j] == '#':
            tatedp[i][j] = tate
            tate = 0
        else:
            tate += 1
for j in range(m,-1,-1):
    for i in range(n,-1,-1):
        if tatedp[i][j] != 0:
            check = tatedp[i][j]
        if ls[i][j] == '.':
            tatedp[i][j] = check
ans = 0
for i in range(n):
    for j in range(m):
        if ls[i][j] == '.':
            ans = max(ans,tatedp[i][j] + yokodp[i][j] - 1)
print(ans)


Fixed submission:
a = list(map(int,input().split()))
a.sort()
print(a[0]+a[1])
Buggy python submission (verdict: Runtime Error):
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])

Fixed submission:
ls = [int(input()) for i in range(5)]
k = int(input())
boo = False
for i in range(5):
    for j in range(5):
        if abs(ls[i] - ls[j]) > k:boo = True
if boo:print(':(')
else:print('Yay!')
Buggy python submission (verdict: Time Limit Exceeded):
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])

Fixed submission:
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ls = [0]*(len(A)*len(B))
for i in range(len(A)):
    for j in range(len(B)):
        ls[(i*len(B))+j] = A[i] + B[j]
ls.sort(reverse = True)
ls = ls[:k]
check_ls = []
for i in range(len(C)):
    for j in range(len(ls)):
        check_ls.append(C[i] + ls[j])
check_ls.sort(reverse = True)
for i in range(k):
    print(check_ls[i])
Buggy python submission (verdict: Runtime Error):
dgthd

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])

Buggy python submission (verdict: Runtime Error):
t

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])

Buggy python submission (verdict: Runtime Error):
d

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])

Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])

Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])

Buggy python submission (verdict: Runtime Error):
a

Fixed submission:
ls = {'A':'T','C':'G','T':'A','G':'C'}
print(ls[input()])
Buggy python submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(1000000000000000000000000000000000)
s = [x for x in input()]
t = [x for x in input()]
dp = [['' for i in range(len(s))] for j in range(len(t))]
def dppp(ns,nt):
    global dp,s,t
    if ns == len(s) or nt == len(t):return ''
    if dp[nt][ns] != '':return dp[nt][ns]
    if s[ns] == t[nt]:
        get = s[ns] + dppp(ns+1,nt+1)
    else:
        get = ''
    sgo = dppp(ns+1,nt)
    tgo = dppp(ns,nt+1)
    if len(sgo) >= len(tgo) and len(sgo) >= len(get):
        dp[nt][ns] = sgo
        return sgo
    elif len(tgo) >= len(sgo) and len(tgo) >= len(get):
        dp[nt][ns] = tgo
        return tgo
    else:
        dp[nt][ns] = get
        return get
ans = dppp(0,0)
print(ans)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
check = [0,abs(h[0]-h[1])] + [None]*(n-2)
for i in range(n-2):
    check[i+2] = min(check[i]+abs(h[i]-h[i+2]),check[i+1]+abs(h[i+1]-h[i+2]))
print(check[-1])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
for i in range(n,10000000000000000):
    if m%i == 0:
        n=i
        break
print(int(m/i))

Fixed submission:
n = int(input())
for i in range(n-1):
    a = int(input())
    b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b) 

Fixed submission:
n = int(input())
for i in range(n-1):
    a = int(input())
    b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b) 

Fixed submission:
n = int(input())
for i in range(n-1):
    a = int(input())
    b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b)
Buggy python submission (verdict: Runtime Error):
num = input()
x = [int(i) for i in num]
for i in range(len(x)):
    if x[i] == 1:
        x[i] = "9"
    else:
        x[i] = "1"
mojiretu = ','.join(x)
print(int(mojiretu))


Fixed submission:
num = input()
x = [int(i) for i in num]
for i in range(len(x)):
    if x[i] == 1:
        x[i] = "9"
    else:
        x[i] = "1"
mojiretu = ''.join(x)
print(int(mojiretu))
Buggy python submission (verdict: Runtime Error):
abc = list(map(int,input().split()))
abc.sort()
pritn((abc[2]*10)+abc[1]+abc[0])

Fixed submission:
abc = list(map(int,input().split()))
abc.sort()
print((abc[2]*10)+abc[1]+abc[0])
Buggy python submission (verdict: Runtime Error):
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x => 0:
        b += 1
    else:
        break
if x == 0:
    print(b)
else:
    print(b-1)

Fixed submission:
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x >= 0:
        b += 1
        N -= 1
    else:
        break
if x == 0:
    print(b)
else:
    if N == 0:
        print(b-1)
    else:
        print(b)

Buggy python submission (verdict: Runtime Error):
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x => 0:
        b += 1
    else:
        break
print(b)

Fixed submission:
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x >= 0:
        b += 1
        N -= 1
    else:
        break
if x == 0:
    print(b)
else:
    if N == 0:
        print(b-1)
    else:
        print(b)

Buggy python submission (verdict: Runtime Error):
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= I
    if x => 0:
        b += 1
    else:
        break
print(b)

Fixed submission:
N,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
b = 0
for i in a:
    x -= i
    if x >= 0:
        b += 1
        N -= 1
    else:
        break
if x == 0:
    print(b)
else:
    if N == 0:
        print(b-1)
    else:
        print(b)
Buggy python submission (verdict: Runtime Error):
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
words = []
for i in range(N):
    words.append(input())
hantei = 0
for i in range(N-1):
    a = [x for x in words[i]]
    b = [x for x in words[i+1]]
    if a[len(a)-1] == b[1]:
        pass
    else:
        hantei += 1
        break
if hantei == 0 and is_unique(words) == True:
    print("Yes")
else:
    print("No")


Fixed submission:
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
words = []
for i in range(N):
    words.append(input())
hantei = 0
for i in range(N-1):
    a = [x for x in words[i]]
    b = [x for x in words[i+1]]
    if a[len(a)-1] == b[0]:
        pass
    else:
        hantei += 1
        break
if hantei == 0 and is_unique(words) == True:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    gct = numbers[0]
    for i in range(len(numbers)-1):
        r = numbers[i+1] % gct
        while r != 0:
            ka = r
            r = gct
            gct = ka
            r = r % gct
    return gct
u.append(X)
u.sort()
sa = []
for i in range(len(u)-2):
    sa.append(u[i+1]-u[i])
print(gcd_list(sa))

Fixed submission:
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    gct = numbers[0]
    for i in range(len(numbers)-1):
        r = numbers[i+1] % gct
        while r != 0:
            ka = r
            r = gct
            gct = ka
            r = r % gct
    return gct
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
if len(sa) > 1:
    print(gcd_list(sa))
else:
    print(sa[0])

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
print(gcd_list(sa))


Fixed submission:
N,X = map(int,input().split())
u = list(map(int,input().split()))
def gcd_list(numbers):
    gct = numbers[0]
    for i in range(len(numbers)-1):
        r = numbers[i+1] % gct
        while r != 0:
            ka = r
            r = gct
            gct = ka
            r = r % gct
    return gct
u.append(X)
u.sort()
sa = []
for i in range(len(u)-1):
    sa.append(u[i+1]-u[i])
if len(sa) > 1:
    print(gcd_list(sa))
else:
    print(sa[0])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
numbers = [x for x in range(1,N+1)]
a = 0
for i in numbers:
    for j in numbers:
        for k in numbers:
            if (i+j) % K == 0 and (i+k) % K == 0 and (k+j) % K == 0:
                a += 1
            else:
                pass
print(a)

Fixed submission:
n,k = map(int,input().split())
num = (n // k) ** 3
if k % 2 == 0:
    if n - ((n // k) * k) < k // 2:
        print(num * 2)
    else:
        print(num + ((n // k + 1) ** 3))
else:
    print(num)
Buggy python submission (verdict: Runtime Error):
a = list(int(input().split()))
print((a[0]-1)*(a[1]-1))

Fixed submission:
a = list(input().split())
a = list(int(x) for x in a)
print((a[0]-1)*(a[1]-1))
Buggy python submission (verdict: Runtime Error):
S = int(input())
K = int(input())
numbers = (int(x) for x in str(S))
for i in range(5*(10**15)):
    times = 0
    temporary = []
    while times <= K:
        for a in numbers:
            times += a
            for j in renge(a):
                temporary.append(a)
    numbers = temporary
print(numbers[K-1])

Fixed submission:
s = input()
k = int(input())
if s[0] != '1':
    print(s[0])
else:
    ans = 1
    for i in range(k):
        if s[i] != '1':
            ans = s[i]
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = ''
for i in range(30):
    if n == 0:
        break
    if n % 2 ** (i + 1) == 0: 
        ans = ans + '0'
    else:
        n -= (-2)**i
        ans = ans + '1'
print(int(ans))

Fixed submission:
n = int(input())
ant = 0
if n == 0:
    ant = 1
ans = ''
for i in range(10000):
    if n == 0:
        break
    if n % 2 ** (i + 1) == 0: 
        ans = '0' + ans
    else:
        n -= (-2)**i
        ans = '1' + ans
if ant == 0:
    print(ans)
else:
    print('0')
Buggy python submission (verdict: Runtime Error):
#おかしの問題
n,m = map(int,input().split())
number = list(int(input().split()))
a = []
#ここから書きかえ
for i in range(n):
    for j in range(n-i):
            b=[]
            for k range(i+1):
                b.append(number[j+k-1])
            if sum(b)%m == 0:
                a.append(1)
            else:
                pass
print(len(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
check = {};ios = [a[0]%m]*n
for i in range(n-1):
    ios[i+1] = (a[i+1] + ios[i])%m
    check[ios[i]] = 0
check[ios[n-1]] = 0
for i in range(len(ios)):
    check[ios[i]%m] += 1
ans = 0
for i in range(n):
    num = check[ios[i]];check[ios[i]] = 'finish'
    if num == 'finish':continue
    if ios[i] % m == 0:ans += num
    ans += (num * (num - 1))//2
print(ans)

Buggy python submission (verdict: Runtime Error):
#おかしの問題
n,m = map(int,input().split())
number = list(int(input().split()))
a = []
#ここから書きかえ
for i in range(n):
    for j in range(n-i):
            b=[]
            for k range(n):
                b.append(number[j+k+1])
            if sum(b)%m == 0:
                a.append(1)
            else:
                pass
print(len(a))

Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
check = {};ios = [a[0]%m]*n
for i in range(n-1):
    ios[i+1] = (a[i+1] + ios[i])%m
    check[ios[i]] = 0
check[ios[n-1]] = 0
for i in range(len(ios)):
    check[ios[i]%m] += 1
ans = 0
for i in range(n):
    num = check[ios[i]];check[ios[i]] = 'finish'
    if num == 'finish':continue
    if ios[i] % m == 0:ans += num
    ans += (num * (num - 1))//2
print(ans)

Buggy python submission (verdict: Runtime Error):
#おかしの問題
n,m = int(input().split())
number = list(int(input().split()))
a = []
#ここから書きかえ
for i in range(n):
    for j in range(n-i):
            b=[]
            for k range(n):
                b.append(number[j+k+1])
            if sum(b)%m == 0:
                a.append(1)
            else:
                pass
print(len(a))

#








Fixed submission:
n,m = map(int,input().split())
a = list(map(int,input().split()))
check = {};ios = [a[0]%m]*n
for i in range(n-1):
    ios[i+1] = (a[i+1] + ios[i])%m
    check[ios[i]] = 0
check[ios[n-1]] = 0
for i in range(len(ios)):
    check[ios[i]%m] += 1
ans = 0
for i in range(n):
    num = check[ios[i]];check[ios[i]] = 'finish'
    if num == 'finish':continue
    if ios[i] % m == 0:ans += num
    ans += (num * (num - 1))//2
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(1,n+1):
    b.append(a[i-1] - i)
b.sort
if n % 2 != 0:
    B = b[int((n-1)/2)]
    ans = 0
    for i in range(n):
        ans += abs(a[i]-i-1-B)
    print(ans)
else:
    big = b[int((n)/2)]
    smo = b[int(n-2/2)]
    smoB = int((big+smo)/2)
    bigB = smoB + 1
    big = smo = 0
    for i in range(n):
        big += abs(a[i]-i-1-bigB)
    for i in range(n):
        smo += abs(a[i]-i-1-smoB)
    print(min(big,smo))

Fixed submission:
n = int(input())
def get_gcd(a, b): #最大公約数を求める関数
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return get_gcd(b, a % b)
def get_lcm(a, b, gcd): #みたまんまそういうやつです
    lcm = a * b // gcd
    return lcm
print(int((2 * n) / get_gcd(2,n)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(1,n+1):
    b.append(a[i-1] - i)
b.sort
if n % 2 != 0:
    B = b[int((n+1)/2)]
    ans = 0
    for i in range(n):
        ans += abs(a[i]-i-1-B)
    print(ans)
else:
    big = b[int((n+2)/2)]
    smo = b[int(n/2)]
    smoB = int((big+smo)/2)
    bigB = smoB + 1
    big = smo = 0
    for i in range(n):
        big += abs(a[i]-i-1-bigB)
    for i in range(n):
        smo += abs(a[i]-i-1-smoB)
    print(min(big,smo))

Fixed submission:
from statistics import median 
n = int(input())
a = list(map(int,input().split()))
ls = []
for i in range(n):
    ls.append(a[i] - i - 1)
b = median(ls)
if b % 1 == 0:
    ans = 0
    b = int(b)
    for i in range(n):
        ans += abs(a[i] - (b + i + 1))
    print(ans)
else:
    bigans = smallans = 0
    for i in range(n):
        bigans += abs(a[i] - (int(b) + i + 2))
        smallans += abs(a[i] - (int(b) + i + 1))
    print(min(bigans,smallans))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

bitruiseki = [[0]*21 for i in range(n+1)]

for i in range(n):
    ref = a[i]
    for j in range(20,-1,-1):
        if ref >= (1 << j):
            bitruiseki[i+1][j] = bitruiseki[i][j] + 1
            ref %= (1 << j)
        else:
            bitruiseki[i+1][j] = bitruiseki[i][j]

def check(l,r):
    for i in range(21):
        if bitruiseki[r][i] - bitruiseki[l][i] <= 1:
            pass
        else:
            return False
    return True

# 尺取り
ans = 0
right = 1
for i in range(n+1):
    right = max(right,i)
    if right < n:
        while (check(i,right+1) and right < n):
            right += 1
            if right == n:break
    ans += right - i
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

bitruiseki = [[0]*21 for i in range(n+1)]

for i in range(n):
    ref = a[i]
    for j in range(20,-1,-1):
        if ref >= (1 << j):
            bitruiseki[i+1][j] = bitruiseki[i][j] + 1
            ref %= (1 << j)
        else:
            bitruiseki[i+1][j] = bitruiseki[i][j]

def check(l,r):
    for i in range(21):
        if bitruiseki[r][i] - bitruiseki[l][i] <= 1:
            pass
        else:
            return False
    return True

# 尺取り
ans = 0
right = 1
for i in range(n+1):
    right = max(right,i)
    if right < n:
        while (check(i,right+1) and right < n):
            right += 1
            if right == n:break
    ans += right - i
print(ans)
Buggy python submission (verdict: Runtime Error):
from numpy import cumsum
from collections import Counter
import math
def count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
wa = list(cumsum(a))
wa.append(0)
c = Counter(wa)
keys = set(wa)
ans = 0
for i in keys:
    num = c[i]
    if num >= 2:
        ans += count(num,2)
    else:
        pass
print(ans)


Fixed submission:
from numpy import cumsum
from collections import Counter
import math
def count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n = int(input())
a = list(map(int,input().split()))
wa = list(cumsum(a))
wa.append(0)
c = Counter(wa)
keys = set(wa)
ans = 0
for i in keys:
    num = c[i]
    if num >= 2:
        ans += count(num,2)
    else:
        pass
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().input())
if max(a,b,c) % 2 == (a + b + c) % 2:
	print((3 * max(a,b,c) - (a + b + c)) // 2)
else:
	print((3 * (max(a,b,c) + 1) - (a + b + c)) // 2)

Fixed submission:
a,b,c = map(int,input().split())
if max(a,b,c) % 2 == (a + b + c) % 2:
	print((3 * max(a,b,c) - (a + b + c)) // 2)
else:
	print((3 * (max(a,b,c) + 1) - (a + b + c)) // 2)