Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 0
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
odds = 0
evens2 = 0
evens4 = 0
for ai in a :
    if ai % 4 == 0 :
        evens4 += 1
    elif ai % 2 == 0 :
        evens2 += 1
    else :
        odds += 1

if evens4 >= odds :
    print('Yes')
elif odds - evens4 == 1 and evens2 == 0 :
    print('Yes')
else :
    print('No')
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

c = [[0 for i in range(w)] for j in range(h)]
fromL = True
x = 0
y = 0

for i in range(1, n+1) :
    for j in range(a[i-1]) :
        c[y][x] = i
        if w == 1 :
            y += 1
        elif j > 0 and x == w - 1 :
            y += 1
            fromL = False
        elif j > 0 and x == 0 :
            y += 1
            fromL = True
        elif fromL :
            x += 1
        else :
            x -= 1

for ci in c :
    print(*ci)

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

c = [[0 for i in range(w)] for j in range(h)]
fromL = True
x = 0
y = 0

for i in range(1, n+1) :
    for j in range(a[i-1]) :
        c[y][x] = i
        if w == 1 :
            y += 1
        elif fromL :
            if x == w - 1 :
                y += 1
                fromL = False
            else :
                x += 1
        else :
            if x == 0 :
                y += 1
                fromL = True
            else :
                x -= 1

for ci in c :
    print(*ci)
Buggy python submission (verdict: Runtime Error):
import sys

n,k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a) :
    print('IMPOSSIBLE')
    sys.exit()
elif k in a or 1 in a:
    print('POSSIBLE')
    sys.exit()

a.sort()
l = []
for i in range(n-1,-1,-1) :
    if a[i] < k :
        break
    else :
        l.append(a[i]-k)
else :
    l = list(set(l))

diff = [0]*(n-1)
for i in range(n-1) :
    diff[i] = a[i+1] - a[i]
else :
    diff = list(set(diff))
    diff.sort()

for d in diff :
    for ll in l :
        if ll%d == 0 or ll%d in diff :
            print('POSSIBLE')
            sys.exit()
else :
    print('IMPOSSIBLE')

Fixed submission:
def gcd(a, b) :
    if a < b :
        a,b = b,a
    if b == 0 :
        return a
    else :
        return gcd(b, a%b)


n,k = map(int, input().split())
a = list(map(int, input().split()))

g = a[0]
for i in range(n-1) :
    g = gcd(g,a[i+1])

if (k < max(a) and k%g == 0) or (k in a) :
    print('POSSIBLE')
else :
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
S = input()
chars = set(S)
ans = len(S)

for c in chas :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)

Fixed submission:
S = input()
chars = set(S)
ans = len(S)

for c in chars :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

print(ans)

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

for c in string.lowercase :
    if c not in S :
        continue

    X = S.split(c)
    ans = 0
    for str in X :
        ans = max(ans, len(str))

print(ans)

Fixed submission:
S = input()
chars = set(S)
ans = len(S)

for c in chars :
    m = max(len(_) for _ in S.split(c))
    ans = min(ans, m)

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

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) > 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Fixed submission:
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while mx != mn :
    if (mx-mn) == 1 :
        tmp_mx = h-B*mx
        tmp_mn = h-B*mn
        T_mx = sum(np.ceil(tmp_mx[tmp_mx>0]/(A-B)))
        T_mn = sum(np.ceil(tmp_mn[tmp_mn>0]/(A-B)))

        if T_mn == mn :
            ans = mn
        else :
            ans = mx

        break

    tmp = h-B*now
    T = sum(np.ceil(tmp[tmp>0]/(A-B)))
    if now >= T :
        ans = now
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(ans))

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

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while (mx-mn) <= 1 :
    if now >= sum(np.ceil(tmp[tmp>0]/(A-B))) :
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(mx))

Fixed submission:
import numpy as np
import math

N,A,B = map(int, input().split())
h = np.zeros(N)

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

ans = 0
mn = 0
mx = np.ceil(h.max()/B)
now = mx//2
while mx != mn :
    if (mx-mn) == 1 :
        tmp_mx = h-B*mx
        tmp_mn = h-B*mn
        T_mx = sum(np.ceil(tmp_mx[tmp_mx>0]/(A-B)))
        T_mn = sum(np.ceil(tmp_mn[tmp_mn>0]/(A-B)))

        if T_mn == mn :
            ans = mn
        else :
            ans = mx

        break

    tmp = h-B*now
    T = sum(np.ceil(tmp[tmp>0]/(A-B)))
    if now >= T :
        ans = now
        mx = now
    else :
        mn = now

    now = (mx+mn)//2

print(int(ans))
Buggy python submission (verdict: Runtime Error):
    X = int(input())
     
    L = 0
    for t in range(1, X) :
        L += t
        if L >= X :
            print(t)
            break

Fixed submission:
X = int(input())
     
L = 0
for i in range(1, X+1) :
  L += i
  if L >= X :
    print(i)
    break

Buggy python submission (verdict: Runtime Error):
X = int(input())

L = 0
for i in range(1, X) :
    L += i
    if L >= X :


Fixed submission:
X = int(input())
     
L = 0
for i in range(1, X+1) :
  L += i
  if L >= X :
    print(i)
    break
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
ans = N
for i in range(N-1, -1, -1) :
    psum = 0
    for j in range(i, -1, -1) :
        if psum+a[j] < K :
            psum += a[j]
        else :
            ans = min(ans, j)

print(ans)

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

a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys

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

def isNecessary(now) :
    psum = 0
    for i in range(N) :
        if i == now :
            continue
        psum += a[i]
        if psum >= K :
            return False
    else :
        return True

S = sum(a)
ans = 0
a = sorted(a, reverse=True)
l, r = 0, N-1
now = N//2
while True :
    if isNecessary(now) :
        r = now
    else :
        l = now
    now = (l+r)//2
    if r == l :
        if N==1 and a[0]<K :
            print(1)
        else :
            print(r)

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

a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)

print(ans)
Buggy python submission (verdict: Runtime Error):
n, h, w = map(int, input().split())
print((n - h + 1) * (n - w + 1))

Fixed submission:
n = int(input())
h = int(input())
w = int(input())
print((n - h + 1) * (n - w + 1))
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split())
costs, times = [map(int, input().split()) for i in range(n)]

min_cost = 1001  # 最小コストを入れる変数。初期値は制約上のMAX + 1 にしておく
for cost, time in zip(costs, times):
    if time <= t and cost < min_cost:
        min_cost = cost

if min_cost < 1000:
    print(min_cost)
else:
    print('TLE')

Fixed submission:
n, t = map(int, input().split())
_list = [input() for i in range(n)]
costs, times = [], []
for elem in _list:
    # print(elem)  # debug
    cost, time = map(int, elem.split())
    costs.append(cost)
    times.append(time)

min_cost = 1001  # 最小コストを入れる変数。初期値は制約上のMAX + 1 にしておく
for cost, time in zip(costs, times):
    if time <= t and cost < min_cost:
        min_cost = cost  # 時間内 and costがこれまでの最小コストより小さければ更新

if min_cost <= 1000:
    print(min_cost)
else:
    print('TLE')
Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

count = 0
i = 0
while x * i <= b:
    if x * i >= a:
        count += 1
    i += 1

print(count)

Fixed submission:
import math
from decimal import Decimal
a, b, x = map(int, input().split())
a, b, x = Decimal(a), Decimal(b), Decimal(x)

min_bai = math.ceil(a/x)  # xの倍数で最小
max_bai = math.floor(b/x)  # xの倍数で最大
x_bai = max_bai - min_bai + 1

# print(min_bai)  # debug
# print(max_bai)  # debug
print(x_bai)

Buggy python submission (verdict: Time Limit Exceeded):
a, b, x = map(int, input().split())

count = 0
for i in range(a, b+1):
    # print(i)  # debug
    if i % x == 0:  # 余りが0 = 割り切れる
        count += 1

print(count)


Fixed submission:
import math
from decimal import Decimal
a, b, x = map(int, input().split())
a, b, x = Decimal(a), Decimal(b), Decimal(x)

min_bai = math.ceil(a/x)  # xの倍数で最小
max_bai = math.floor(b/x)  # xの倍数で最大
x_bai = max_bai - min_bai + 1

# print(min_bai)  # debug
# print(max_bai)  # debug
print(x_bai)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout

def main():
    N = (int)(stdin.readline())
    graph = dict()

    for i in range(N-1):
        edge = stdin.readline().split()
        ai = (int)(edge[0])
        bi = (int)(edge[1])

        if ai in graph.keys():
            graph[ai].append(bi)
        else:
            graph[ai] = [bi]
        
        if bi in graph.keys():
            graph[bi].append(ai)
        else:
            graph[bi] = [ai]

    mid_node = bfs(graph, 1)[0]
    
    longest_path = bfs(graph, mid_node)[1]
    
    if longest_path % 3 == 1:
        print("second")
    else:
        print("first")

def bfs(graph, node):

    result = -1
    last_level = set()
    visited = set()

    last_level.add(node)
    visited.add(node)

    length = 0

    while len(last_level) > 0:
        
        new_level = set()

        length += 1

        for last_node in last_level:
            result = last_node
            for neighbor in graph[last_node]:
                if neighbor not in visited:
                    new_level.add(neighbor)
                    visited.add(neighbor)
        last_level = new_level
    
    return result, length - 1

if __name__ == "__main__":
    main()

Fixed submission:
from sys import stdin, stdout

def main():
    N = (int)(stdin.readline())
    graph = dict()
	
    if N == 1:
      print("First")
      return
    if N == 2:
      print("Second")
      return
    
    for i in range(N-1):
        edge = stdin.readline().split()
        ai = (int)(edge[0])
        bi = (int)(edge[1])

        if ai in graph.keys():
            graph[ai].append(bi)
        else:
            graph[ai] = [bi]
        
        if bi in graph.keys():
            graph[bi].append(ai)
        else:
            graph[bi] = [ai]

    mid_node = bfs(graph, 1)[0]
    
    longest_path = bfs(graph, mid_node)[1]
    
    if longest_path % 3 == 1:
        print("Second")
    else:
        print("First")

def bfs(graph, node):

    result = -1
    last_level = set()
    visited = set()

    last_level.add(node)
    visited.add(node)

    length = 0

    while len(last_level) > 0:
        
        new_level = set()

        length += 1

        for last_node in last_level:
            result = last_node
            for neighbor in graph[last_node]:
                if neighbor not in visited:
                    new_level.add(neighbor)
                    visited.add(neighbor)
        last_level = new_level
    
    return result, length - 1

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

r=input().split()
n=int(r[0])
k=int(r[1])
h=sorted([int(x.strip()) for x in sys.stdin.readlines()])

d=[h[x+1]-h[x] for x in range(n-1)]

rui=[0]+[sum(d[:x+1]) for x in range(len(d))]

dd=[rui[x+k-1]-rui[x] for x in range(n-k+1)]
ans=min(dd)
            
print(ans)

Fixed submission:
import sys

r=input().split()
n=int(r[0])
k=int(r[1])
h=sorted([int(x.strip()) for x in sys.stdin.readlines()])

d=[h[x+k-1]-h[x] for x in range(n-k+1)]
ans=min(d)
            
print(ans)
Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())
 
an=X//A
bn=X//B
cn=X//C
 
counter = 0
 
for i in range(an):
  for j in range(bn):
    for k in range(cn):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())

 
counter = 0
 
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
X=int(input())

an=X/A
bn=X/B
cn=X/C

counter = 0

for i in range(an):
  for j in range(bn):
    for k in range(cn):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())

 
counter = 0
 
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      x = 500*i+100*j+50*k
      if X == x:
        counter += 1
print(counter)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    else:
      A[i] = A[i] / 2    
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

Fixed submission:
li = list(input())
count = 0
for i in range(3):
  if li[i] == '1':
    count += 1
print(count)

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

counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] / 2    
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)

Fixed submission:
li = list(input())
count = 0
for i in range(3):
  if li[i] == '1':
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] % 2    
      
  counter += 1
  if end_judge == 1:
    break

Fixed submission:
li = list(input())
count = 0
for i in range(3):
  if li[i] == '1':
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
  	if A[i]%2 == 1:
      end_judge = 1
    else:
      A[i] = A[i] % 2    
  counter += 1
  if end_judge == 1:
    break

print(counter)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
 
counter = 0
end_judge = 0
while 1:
  
  for i in range(n):
    if A[i]%2 == 1 or A[i]==0:
      end_judge = 1
    A[i] = A[i] / 2    
      
  if end_judge == 1:
    break    
  counter += 1
  
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int, input().split())
count = 0
for x in range(k+1):
    for y in range(x, k+1):
        for z in range(y, k+1):
            if x+y+z==s:
                if x==y and y==z:
                    count += 1
                elif x==y or y==z or z==x:
                    count += 3
                else:
                    count += 6
print(count)
print("\n")



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

counter = 0

#すべての値が等しい場合 i = j = k
if S%3 == 0:
    counter += 1

for i in range(K):
    yz = S - i
    #2つの値が等しい場合 i < j = k
    if yz%2 == 0 and yz/2 <= K and yz/2 > i:
        counter += 3
    # 2つの値が等しい場合 i = j < k
    if yz - i <= K and yz - i > i:
        counter += 3
    #すべての値が異なる場合 i < j < k
    for j in range(i+1, K):
        k = S - i - j
        if k > j and k <= K:
            counter += 6

print(counter)
print("\n")
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = ""
count = 0
while 1:
    count = 0

    T = "dreamer" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(7):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "dream" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(5):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "eraser" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(6):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    T = "erase" + T
    if S[-len(T)::] != T:
        count += 1
        t = list(T)
        for i in range(5):
            t.pop(0)
        T = ''.join(t)
    else:
        continue

    if count == 4:
        break

if T == S:
    print("YES")
else:
    print("NO")

Fixed submission:
S = input()
S = S[::-1]
L = len(S)

d = ["dreamer", "dream", "eraser", "erase"]
for i in range(4):
    d[i] = d[i][::-1]

count = 0
end = False
yes = False

while 1:
    judge = 0
    for i in range(4):
        if S[count:(len(d[i])+count)] == d[i]:
            count += len(d[i])
            if count == L:
                end = True
                yes = True
        else:
            judge += 1
    if end or judge == 4:
        break

if yes:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
sub = []
for i, a in enumerate(A, 1):
    sub.append(a - i)
    ans += abs(a - i)

#print(sub)

#b = min(sub)
for b in range(min(sub), max(sub) + 1):
    #cand = 0
    cand = sum([abs(s - b) for s in sub])
    #for s in sub:
    #    cand += abs(s - b)
    ans = min(ans, cand)
print(ans)


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

for i, a in enumerate(A):
    A[i] = a - i

A = sorted(A)
b = A[len(A)//2]

ans = 0
for a in A:
    ans += abs(a - b)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 0
sub = []
for i, a in enumerate(A, 1):
    sub.append(a - i)
    ans += abs(a - i)

#print(sub)

#b = min(sub)
for b in range(min(sub), max(sub) + 1):
    cand = 0
    for s in sub:
        cand += abs(s - b)
    ans = min(ans, cand)
print(ans)


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

for i, a in enumerate(A):
    A[i] = a - i

A = sorted(A)
b = A[len(A)//2]

ans = 0
for a in A:
    ans += abs(a - b)

print(ans)
Buggy python submission (verdict: Runtime Error):
d, n = map(int, input().split())

start = pow(n, d)

elif n == 100:
    print(pow(100, d) * (n + 1))
else:
    print(pow(100, d) * n)



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

start = pow(n, d)

if n == 100:
    print(pow(100, d) * (n + 1))
else:
    print(pow(100, d) * n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

m = n

for i in range(n):

    turn = s[:i].count('W') + s[i+1:].count('E')

    m = min(turn, m)

print(m)

Fixed submission:
n = int(input())
s = input()

m = n
turn = s[1:].count('E')
m = min(turn, m)
for i in range(1, n):
    if s[i-1] == 'W': turn += 1
    if s[i] == 'E': turn -= 1

    m = min(turn, m)

print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

m = n

for i in range(n):
    west = s[:i]
    east = s[i+1:]

    turn = west.count('W') + east.count('E')

    m = min(turn, m)

print(m)

Fixed submission:
n = int(input())
s = input()

m = n
turn = s[1:].count('E')
m = min(turn, m)
for i in range(1, n):
    if s[i-1] == 'W': turn += 1
    if s[i] == 'E': turn -= 1

    m = min(turn, m)

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))


m = 0

for i in range(n-1):
    s = xor = a[i]
    for j in range(i+1, n):
        xor = xor ^ a[j]
        s += a[j]
        if xor == s:
            m += 1
        else:
            break

print(m+n)

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

cur = a[0]
ans = 0
rp = 1

for lp in range(n):
    while rp < n and cur & a[rp] == 0:
        cur += a[rp]
        rp += 1
    ans += rp - lp
    cur -= a[lp]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))


m = 0

for i in range(n-1):
    s = xor = a[i]
    for j in range(i+1, n):
        xor = xor ^ a[j]
        s += a[j]
        if xor == s:
            m += 1

print(m+n)

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

cur = a[0]
ans = 0
rp = 1

for lp in range(n):
    while rp < n and cur & a[rp] == 0:
        cur += a[rp]
        rp += 1
    ans += rp - lp
    cur -= a[lp]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

p = []
impossible = []
flag = False
for i in range(2, 55556):
    if is_prime(i):
        p.append(i)
    
        if len(p) >= n:
            L = list(combinations(p, n))
            #for im in impossible:
                #if im in L:
            #    L.remove(im)
            for l in L:
                for l5 in list(combinations(l, 5)):
                    if is_prime(sum(l5)):
                        flag = False
                        #if not l in impossible:
                        #impossible.append(l)
                        break
                    flag = True
                if flag:
                    break
            if flag:
                break

if flag:
    print(' '.join(map(str, l)))

Fixed submission:
import math

n = int(input())

def is_prime(x):
    if x < 2: return False
    if x == 2 or x == 3 or x == 5: return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False

    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

A = []
for a in range(11, 55555, 10):
    if is_prime(a):
        A.append(a)
        if len(A) == n:
            break
print(' '.join(map(str, A)))