Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]
li = [str(A.index(i+1) + 1) for i in range(N)]
print(" ".join(li))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
li = ["" for i in range(N)]
for i in range(N):
    li[A[i]-1] = str(i+1)
print(" ".join(li))
Buggy python submission (verdict: Runtime Error):
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = math.sqrt(gcd)
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Fixed submission:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
gcd = math.gcd(A, B)
ans = 1
sqrt = math.sqrt(gcd)
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Fixed submission:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())
gcd = math.gcd(A, B)
ans = 1
for i in range(2, min(gcd, 1000000)):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
print(ans)

Fixed submission:
import fractions
A, B = map(int, input().split())
gcd = fractions.gcd(A, B)
ans = 1
sqrt = gcd ** 0.5
for i in range(2, int(sqrt) + 2):
    if gcd % i == 0:
        ans += 1
        while True:
            gcd //= i
            if gcd % i != 0:
                break
if sqrt < gcd:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
N = len(S)

li = [0]
char = 'R'
for i in S:
    n = len(li)
    if i == char:
        li[n-1] += 1
    else:
        li.append(1)
        char = i
n = len(li)
ans = []
for i in range(len(li)//2):
    k = li[2*i] + li[2*i+1]
    for i in range(li[2*i] - 1):
        ans.append(0)
    if (k%2 == 0):
        ans.append(int(k/2))
        ans.append(int(k/2))
    else:
        if li[2*i]%2 == 0:
            ans.append(int(k//2))
            ans.append(int(k//2) + 1)
        else:
            ans.append(int(k//2) + 1)
            ans.append(int(k//2))
    for i in range(li[2*i+1] - 1):
        ans.append(0)

print(*ans)


Fixed submission:
S = input()
N = len(S)

li = [0]
char = 'R'
for i in S:
    n = len(li)
    if i == char:
        li[n-1] += 1
    else:
        li.append(1)
        char = i
n = len(li)
ans = []
for i in range(n//2):
    k = li[2*i] + li[2*i+1]
    for j in range(li[2*i] - 1):
        ans.append(0)
    if (k%2 == 0):
        ans.append(int(k/2))
        ans.append(int(k/2))
    else:
        if li[2*i]%2 == 0:
            ans.append(int(k//2))
            ans.append(int(k//2) + 1)
        else:
            ans.append(int(k//2) + 1)
            ans.append(int(k//2))
    for j in range(li[2*i+1] - 1):
        ans.append(0)

print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)

rec = [[1 for i in range(N)]]
while True:
    li = [0 for i in range(N)]
    n = len(rec)
    for i in range(N):
        if S[i] == 'R':
            li[i+1] += rec[n-1][i]
        else:
            li[i-1] += rec[n-1][i]
    if n >= 2:
        if li == rec[n-2]:
            break
    rec.append(li)
n = len(rec)
if n%2 == 0:
    print(*rec[n-2])
else:
    print(*rec[n-1])


Fixed submission:
S = input()
N = len(S)

li = [0]
char = 'R'
for i in S:
    n = len(li)
    if i == char:
        li[n-1] += 1
    else:
        li.append(1)
        char = i
n = len(li)
ans = []
for i in range(n//2):
    k = li[2*i] + li[2*i+1]
    for j in range(li[2*i] - 1):
        ans.append(0)
    if (k%2 == 0):
        ans.append(int(k/2))
        ans.append(int(k/2))
    else:
        if li[2*i]%2 == 0:
            ans.append(int(k//2))
            ans.append(int(k//2) + 1)
        else:
            ans.append(int(k//2) + 1)
            ans.append(int(k//2))
    for j in range(li[2*i+1] - 1):
        ans.append(0)

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = 1000000007
S = input()
l = len(S)
li = [1] + [0] * 12
work_lists = [[0] * 13 for i in range(6)]
for i in range(6):
    for x in range(10):
        work_lists[i][(x * (10 ** i)) % 13] = 1
for i in range(l):
    s = S[l - i - 1]
    if s == "?":
        work_li = work_lists[i % 6]
        next_li = [sum([work_li[j] * li[(k - j) % 13] for j in range(13)]) % K for k in range(13)]
    else:
        n = int(s)
        r = (n * (10 ** (i % 6))) % 13
        next_li = [li[(j - r) % 13] for j in range(13)]
    li = next_li
print(li[5])


Fixed submission:
K = 1000000007
S = input()
l = len(S)
li = [1] + [0] * 12
work_lists = [[0] * 13 for i in range(6)]
for i in range(6):
    for x in range(10):
        work_lists[i][(x * (10 ** i)) % 13] = 1
for i in range(l):
    s = S[l - i - 1]
    if s == "?":
        work_li = work_lists[i % 6]
        next_li = [sum([work_li[j] * li[(k - j) % 13] for j in range(13)]) % K for k in range(13)]
    else:
        n = int(s)
        r = (n * (10 ** (i % 6))) % 13
        next_li = [li[(j - r) % 13] for j in range(13)]
    li = next_li
print(li[5])

Buggy python submission (verdict: Time Limit Exceeded):
K = 1000000007
S = input()
l = len(S)
li = [1] + [0] * 12
for i in range(l):
    s = S[l - i - 1]
    if s == "?":
        work_li = [0] * 13
        next_li = [0] * 13
        for x in range(10):
            work_li[x * (10 ** i) % 13] = 1
        next_li = [sum([work_li[j] * li[(k - j) % 13] for j in range(13)]) for k in range(13)]
    else:
        n = int(s)
        r = (n * (10 ** i)) % 13
        next_li = [li[(j - r) % 13] for j in range(13)]
    li = [j % K for j in next_li]
print(li[5])


Fixed submission:
K = 1000000007
S = input()
l = len(S)
li = [1] + [0] * 12
work_lists = [[0] * 13 for i in range(6)]
for i in range(6):
    for x in range(10):
        work_lists[i][(x * (10 ** i)) % 13] = 1
for i in range(l):
    s = S[l - i - 1]
    if s == "?":
        work_li = work_lists[i % 6]
        next_li = [sum([work_li[j] * li[(k - j) % 13] for j in range(13)]) % K for k in range(13)]
    else:
        n = int(s)
        r = (n * (10 ** (i % 6))) % 13
        next_li = [li[(j - r) % 13] for j in range(13)]
    li = next_li
print(li[5])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
M = [0 for i in range(N)]

for i in range(A[0]+1):
    M[0] = i*2
    for j in range(N-1):
        M[j+1] = (A[j] - int(M[j]//2)) * 2
    if A[N-1] == int((M[0]//2) + ((M[N-1])//2) ):
        break;

for i in range(N):
    print(M[i], end=" ")


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
M = [0 for i in range(N)]

M[0] = 0
for j in range(N-1):
    M[j+1] = (A[j] - int(M[j]//2)) * 2

n = int((A[N-1] - M[0]//2 - M[N-1]//2)//2)

for i in range(N):
    if i%2 == 0:
        print(M[i] + 2*n, end=" ")
    else:
        print(M[i] - 2*n, end=" ")
Buggy python submission (verdict: Runtime Error):
import math

A,B,C,D = map(int,input().split())

gcd = math.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())

gcd = fractions.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)

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

A,B,C,D = map(int,input().split())

gcd = fractions.gcd(C,D)
lcm = int(C*D/gcd)

comp = int(((lcm//C) + (lcm//D) - 1) * ((B-A+1)//lcm))

for i in range((B-A+1)%lcm):
    if (A+i)%C == 0 or (A+i)%D == 0:
        comp += 1

print(B-A+1-comp)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())

gcd = fractions.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)

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

A,B,C,D = map(int,input().split())

gcd = math.gcd(C,D)
lcm = int(C*D/gcd)

comp = int(((lcm//C) + (lcm//D) - 1) * ((B-A+1)//lcm))

for i in range((B-A+1)%lcm):
    if (A+i)%C == 0 or (A+i)%D == 0:
        comp += 1

print(B-A+1-comp)


Fixed submission:
import fractions

A,B,C,D = map(int,input().split())

gcd = fractions.gcd(C,D)
lcm = int(C*D/gcd)

ans_A = int((A-1) - (A-1)//C - (A-1)//D + (A-1)//lcm)
ans_B = int(B - B//C - B//D + B//lcm)
print(ans_B - ans_A)
Buggy python submission (verdict: Runtime Error):
import math

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

B = [0] * (N - 1)
C = [0] * (N - 1)

for n in range(N - 1):
    if n == 0:
        B[0] = A[0]
        C[N - 2] = A[N - 1]
    else:
        B[n] = math.gcd(B[n - 1], A[n])
        C[N - n - 2] = math.gcd(A[N - n - 1], C[N - n - 1])

ans = 0
for n in range(N):
    if n == 0:
        ans = C[0]
    elif n == N - 1:
        ans = max(ans, B[N - 2])
    else:
        ans = max(ans, math.gcd(B[n - 1], C[n]))
print(ans)

Fixed submission:
from fractions import gcd

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

B = [0] * (N - 1)
C = [0] * (N - 1)

for n in range(N - 1):
    if n == 0:
        B[0] = A[0]
        C[N - 2] = A[N - 1]
    else:
        B[n] = gcd(B[n - 1], A[n])
        C[N - n - 2] = gcd(A[N - n - 1], C[N - n - 1])

ans = 0
for n in range(N):
    if n == 0:
        ans = C[0]
    elif n == N - 1:
        ans = max(ans, B[N - 2])
    else:
        ans = max(ans, gcd(B[n - 1], C[n]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N = int(input())
A = [int(i) for i in input().split()]
if N == 2:
  print(max(A[0],A[1]))
else:
  ans = -1
  for i in range(N):
    x = -1
    li = [A[i] for i in range(N)]
    li.pop(i)
    for j in range(N-2):
      if j == 0:
        x = fractions.gcd(li[0],li[1])
      else:
        x = fractions.gcd(x,li[j+1])
    if x > ans:
      ans = x
  print(ans)

Fixed submission:
from fractions import gcd

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

B = [0] * (N - 1)
C = [0] * (N - 1)

for n in range(N - 1):
    if n == 0:
        B[0] = A[0]
        C[N - 2] = A[N - 1]
    else:
        B[n] = gcd(B[n - 1], A[n])
        C[N - n - 2] = gcd(A[N - n - 1], C[N - n - 1])

ans = 0
for n in range(N):
    if n == 0:
        ans = C[0]
    elif n == N - 1:
        ans = max(ans, B[N - 2])
    else:
        ans = max(ans, gcd(B[n - 1], C[n]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
flag = True
for i in range(N, M//3 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
if flag:
    if M%2 == 0 and M//2 >= N:
        print(2)
    else:
        print(1)

Fixed submission:
N, M = map(int, input().split())
# また答えが見つかってなければTrue
flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(9):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
flag = True
for i in range(N, M//2 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
if flag:
    print(1)

Fixed submission:
N, M = map(int, input().split())
# また答えが見つかってなければTrue
flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(9):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
flag = True
for i in range(N, M//2 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
if flag:
    print(1)

Fixed submission:
N, M = map(int, input().split())
# また答えが見つかってなければTrue
flag = True
for i in range(N, M//10 + 1):
    if M%i == 0:
        print(M//i)
        flag = False
        break
for i in range(9):
    if flag and M%(10 - i) == 0 and M//(10 - i) >= N:
        print(10 - i)
        flag = False
if flag:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
for a in set(A):
  n = A.count(a)
  ans += int(n*(n-1)/2)
print(ans)

Fixed submission:
import collections
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
c = collections.Counter(A)
for a in set(A):
  n = c[a]
  ans += int(n*(n-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
for l in range(N):
  ans += A[l+1:].count(A[l])
print(ans)

Fixed submission:
import collections
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
c = collections.Counter(A)
for a in set(A):
  n = c[a]
  ans += int(n*(n-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M =map(int,input().split())
A = [0] + list(map(lambda x: int(x)%M,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
for l in range(N):
  for d in range(N-l):
    if (A[l+d+1]-A[l])%M == 0:
      ans += 1
print(ans)

Fixed submission:
import collections
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
c = collections.Counter(A)
for a in set(A):
  n = c[a]
  ans += int(n*(n-1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
A=[int(i) for i input().split()]
A.sort()
print(A[2]-A[0])

Fixed submission:
A=[int(i) for i in input().split()]
A.sort()
print(A[2]-A[0])

Buggy python submission (verdict: Runtime Error):
A=[int(i) for i ininput().split()]
A.sort()
print(A[2]-A[0])

Fixed submission:
A=[int(i) for i in input().split()]
A.sort()
print(A[2]-A[0])
Buggy python submission (verdict: Runtime Error):
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
i = 0
Mb = B[0]
while Mb > Ma:
  i += 1
  if i == N:
    Mb = 0
    B = B[:i]
  else:
    Mb = B[i]
H -= sum(B)
print(i+int(-(-H//Ma)))

Fixed submission:
N = int(input())
a = [int(n) for n in input().split()]
print(sum(a)-N)

Buggy python submission (verdict: Runtime Error):
N,H = map(int,input().split())
Ma = 1
B = []
for i in range(N):
    a,b = map(int,input().split())
    B.append(b)
    if a > Ma:
        Ma = a
B.sort()
B.reverse()
C = 0
i = 0
while i < len(B) and B[i] > Ma:
  i += 1
H -= sum(B[:i])
print(i+int(-(-H//Ma)))

Fixed submission:
N = int(input())
a = [int(n) for n in input().split()]
print(sum(a)-N)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
DIFFfix = SUM = sum(A)
for i in range(N-3):
  Q = sum(A[:i+2]); S = SUM - Q
  P = R = Pfix = Rfix = 0
  Qfix = Q; Sfix = S
  m = 0
  flag = True
  while flag:
    m += 1
    P += A[m-1]
    Q -= A[m-1]
    if abs(P-Q) < abs(Pfix - Qfix):
      Pfix = P; Qfix = Q
    else:
      flag = False
  m = 0
  flag = True
  while flag:
    m += 1
    R += A[i+m+1]
    S -= A[i+m+1]
    if abs(R-S) < abs(Rfix - Sfix):
      Rfix = R; Sfix = S
    else:
      flag = False
  DIFF = abs(max(Pfix,Qfix,Rfix,Sfix)-min(Pfix,Qfix,Rfix,Sfix))
  if DIFF < DIFFfix:
    DIFFfix = DIFF
print(DIFFfix)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Asum = [0]
for i in range(N):
  Asum.append(Asum[i] + A[i])
Diff = Asum[N]
m = 0; n = 2
for i in range(N-3):
  flag = True
  P = Asum[m]; Q = Asum[i+2] - Asum[m]
  while flag:
    m += 1
    if abs(Asum[i+2]-Asum[m]*2) < abs(P-Q):
      P = Asum[m]; Q = Asum[i+2] - Asum[m]
    else:
      flag = False
      m -= 1
  flag = True
  R = Asum[n] - Asum[i+2]; S = Asum[N] - Asum[n]
  while flag:
    n += 1
    if abs(Asum[N]-Asum[n]*2+Asum[i+2]) < abs(R-S):
      R = Asum[n] - Asum[i+2]; S = Asum[N] - Asum[n]
    else:
      flag = False
      n -= 1
  if max(P,Q,R,S)-min(P,Q,R,S) < Diff:
    Diff = max(P,Q,R,S)-min(P,Q,R,S)
print(Diff)
Buggy python submission (verdict: Time Limit Exceeded):
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]
m = N*N*(10**3)
for i in range(C):
  for j in range(C):
    for k in range(C):
      s = m
      if i!=j and j!=k and k!=i:
        s = 0
        for x in range(N):
          for y in range(N):
            if (x+y)%3 == 0:
              s += D[c[x][y]-1][i]
            elif (x+y)%3 == 1:
              s += D[c[x][y]-1][j]
            else:
              s += D[c[x][y]-1][k]
        if s < m:
          m = s
print(m)

Fixed submission:
import collections
N,C = map(int,input().split())
D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]
c0 = []; c1 = []; c2 = []
for x in range(N):
    for y in range(N):
        if (x+y)%3 == 0:
            c0.append(c[x][y])
        elif (x+y)%3 == 1:
            c1.append(c[x][y])
        else:
            c2.append(c[x][y])
cnt0 = collections.Counter(c0)
cnt1 = collections.Counter(c1)
cnt2 = collections.Counter(c2)
m = N*N*1000
for i in range(C):
    for j in range(C):
        for k in range(C):
            if i==j or j==k or k==i:
                s = N*N*1000
            else:
                s = 0
                for n in range(C):
                  s += D[n][i]*cnt0[n+1] + D[n][j]*cnt1[n+1] + D[n][k]*cnt2[n+1]
            if s < m:
                m = s
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

m = S.count('W')
x = 0

for i in range(N):
    x = S.count('E')
    if x < m:
        m = x

    if S[i] == 'W':
        S[i] = 'E'
    else:
        S[i] = 'W'

print(m)


Fixed submission:
N = int(input())
S = list(input())

m = N
x = S.count('E')

for i in S:
    if i == 'E':
        x = x - 1

    if x < m:
        m = x

    if i == 'W':
        x = x + 1

print(m)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

l = 0
r = 0
flag = True
check_list = [0 for j in range(20)]

while r < N:

    if flag:
        A_test = A[r]

        for k in range(20):

            if A_test % (2 ** (k+1))  != 0:
                check_list[k] = check_list[k] + 1
                A_test = A_test - (2 ** k)

            if check_list[k] > 1:
                flag = False

        if flag:
            counter = counter + (r - l + 1)

    else:
        ## moving l

        A_test = A[l-1]
        flag = True

        for k in range(20):

            if A_test % (2 ** (k+1))  != 0:
                check_list[k] = check_list[k] - 1
                A_test = A_test - (2 ** k)

            if check_list[k] > 1:
                flag = False

        if flag:
            counter = counter + (r - l + 1)

    if flag:
        r = r + 1
    else:
        l = l + 1

print(counter)

Fixed submission:
N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

l = 0
r = 0
flag = True
xor = 0
sum = 0

while r < N and l < N:
    if flag:
        xor ^= A[r]
        sum += A[r]
        if xor == sum:
            counter += (r - l + 1)
        else:
            flag = False
    else:
        xor ^= A[l-1]
        sum -= A[l-1]
        if xor == sum:
            counter += r - l + 1
            flag = True

    if flag:
        r += 1
    else:
        l += 1

print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

for i in range(N):
    d = 0
    flag = True
    check_list = [0 for j in range(20)]

    while flag:
        counter = counter + 1
        A_test = A[i+d]

        for k in range(20):

            if flag and A_test % (2 ** (k+1))  != 0 and check_list[k] > 0:
                counter = counter - 1
                d = 0
                flag = False

            elif A_test % (2 ** (k+1))  != 0:
                check_list[k] = check_list[k] + 1
                A_test = A_test - (2 ** k)


        if i + d + 1 >= N:
            flag = False
        else:
            d = d + 1

print(counter)


Fixed submission:
N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

l = 0
r = 0
flag = True
xor = 0
sum = 0

while r < N and l < N:
    if flag:
        xor ^= A[r]
        sum += A[r]
        if xor == sum:
            counter += (r - l + 1)
        else:
            flag = False
    else:
        xor ^= A[l-1]
        sum -= A[l-1]
        if xor == sum:
            counter += r - l + 1
            flag = True

    if flag:
        r += 1
    else:
        l += 1

print(counter)
Buggy python submission (verdict: Runtime Error):
x = input()
y = input()
z = input()

print(x[1] + y[2] + z[3])

Fixed submission:
x = input()
y = input()
z = input()

print(x[0] + y[1] + z[2])
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
print(-int((-a-b)//2)

Fixed submission:
a,b = map(int,input().split())
print(-int((-a-b)//2))
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
ans = N
for k in range(K):
    n = c.most_common()[k][0]
    ans -= c[n]
print(ans)


Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
print(N - sum([pair[1] for pair in c.most_common(K)]))

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
ans = 0
while len(c) > K:
    n = c.most_common()[-1][0]
    ans += c[n]
    del c[n]
print(ans)

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
import collections
c = collections.Counter(A)
print(N - sum([pair[1] for pair in c.most_common(K)]))
Buggy python submission (verdict: Runtime Error):
C1 = input()
C2 = input()
C2.reverse()
if C1 == C2:
  print('YES')
else:
  print('NO')

Fixed submission:
C1 = list(input())
C2 = list(input())
C2.reverse()
if C1 == C2:
  print('YES')
else:
  print('NO')