Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def abc175c_walking_takahashi():
    x, k, d = map(int, input().split())
    x = -x if x < 0 else x
    num = math.ceil(x / d)
    if num > k:
        print(x-k*d)
        return
    else:
        k -= num
        x -= num*d
        if k % 2 == 0:
            print(abs(x))
        else:
            print(x+d)
abc175c_walking_takahashi()

Fixed submission:
import math

def abc175c_walking_takahashi():
    x, k, d = map(int, input().split())
    x = -x if x < 0 else x
    num = math.ceil(x / d)
    if num > k:
        print(x-k*d)
        return
    else:
        k -= num
        x -= num*d
        if k % 2 == 0:
            print(abs(x))
        else:
            print(x+d)
abc175c_walking_takahashi()
Buggy python submission (verdict: Time Limit Exceeded):
def abc172c_tsundoku():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    A = [0] * (n + 1)
    B = [0] * (m + 1)

    for i in range(1, n + 1):
        A[i] = A[i - 1] + a[i - 1]
        if A[i] > k:
            n = i - 1
            break
    for i in range(1, m + 1):
        B[i] = B[i - 1] + b[i - 1]
        if B[i] > k:
            m = i - 1
            break
    ans = 0
    for i in range(0, n+1):
        j = 0
        for j in range(0, m+1):
            if A[i] + B[j] > k:
                j -= 1
                break
        ans = max(i + j, ans)
    print(ans)


abc172c_tsundoku()

Fixed submission:
def abc172c_tsundoku():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    A = [0] * (n + 1)
    B = [0] * (m + 1)

    for i in range(1, n + 1):
        A[i] = A[i - 1] + a[i - 1]
        if A[i] > k:
            n = i - 1
            break
    for i in range(1, m + 1):
        B[i] = B[i - 1] + b[i - 1]
        if B[i] > k:
            m = i - 1
            break
    ans = 0
    for i in range(0, n + 1):
        j = max(ans - i, 0)
        if j > m or A[i] + B[j] > k: continue
        while j <= m:
            if A[i] + B[j] > k:
                j -= 1
                break
            j += 1
        j = min(m,j)
        ans = max(i + j, ans)
    print(ans)


abc172c_tsundoku()

Buggy python submission (verdict: Time Limit Exceeded):
def abc172c_tsundoku():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    A = [0] * (n+1)
    B = [0] * (m+1)

    for i in range(1, n+1):
        A[i] = A[i - 1] + a[i - 1]
    for i in range(1, m+1):
        B[i] = B[i - 1] + b[i - 1]
    ans = 0
    for i in range(0, n+1):
        if A[i] > k: break
        j = 0
        for j in range(0, m+1):
            if A[i] + B[j] > k:
                j -= 1
                break
        ans = max(i + j, ans)
    print(ans)

abc172c_tsundoku()

Fixed submission:
def abc172c_tsundoku():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    A = [0] * (n + 1)
    B = [0] * (m + 1)

    for i in range(1, n + 1):
        A[i] = A[i - 1] + a[i - 1]
        if A[i] > k:
            n = i - 1
            break
    for i in range(1, m + 1):
        B[i] = B[i - 1] + b[i - 1]
        if B[i] > k:
            m = i - 1
            break
    ans = 0
    for i in range(0, n + 1):
        j = max(ans - i, 0)
        if j > m or A[i] + B[j] > k: continue
        while j <= m:
            if A[i] + B[j] > k:
                j -= 1
                break
            j += 1
        j = min(m,j)
        ans = max(i + j, ans)
    print(ans)


abc172c_tsundoku()
Buggy python submission (verdict: Time Limit Exceeded):
def abc171d_replacing():
    n = int(input())
    a = list(map(int, input().split()))
    a_dict = {}
    for v in a:
        if a_dict.get(v) is None:
            a_dict[v] = 1
        else:
            a_dict[v] += 1
    q = int(input())
    s = []
    for _ in range(q):
        b, c = map(int, input().split())
        if b in a_dict.keys():
            if c in a_dict.keys():
                a_dict[c] += a_dict[b]
            else:
                a_dict[c] = a_dict[b]
            del a_dict[b]
        total = 0
        for k, v in a_dict.items():
            total += k * v
        s.append(total)

    for v in s:
        print(v)

abc171d_replacing()

Fixed submission:
def abc171d_replacing():
    n = int(input())
    a = list(map(int, input().split()))
    a_dict = {}
    for v in a:
        if a_dict.get(v) is None:
            a_dict[v] = 1
        else:
            a_dict[v] += 1
    q = int(input())
    s = []
    total = 0
    for k, v in a_dict.items():
        total += k * v
    for _ in range(q):
        b, c = map(int, input().split())
        if b in a_dict.keys():
            total += (c * a_dict[b] - b * a_dict[b])
            if c in a_dict.keys():
                a_dict[c] += a_dict[b]
            else:
                a_dict[c] = a_dict[b]
            del a_dict[b]
        s.append(total)

    for v in s:
        print(v)


abc171d_replacing()
Buggy python submission (verdict: Runtime Error):
import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if p[idx] != x + i:
            print(x + i)
            return

abc170c_forbidden_list()

Fixed submission:
import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if idx >= n or p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if idx >= n or p[idx] != x + i:
            print(x + i)
            return


abc170c_forbidden_list()
Buggy python submission (verdict: Runtime Error):
import itertools

def abc167c_skill_up():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        v = list(map(int, input().split()))
        c.append(v[0])
        a.append(v[1:])
    pattern = itertools.product([0,1], repeat=n)
    best = float('inf')
    for p in pattern:
        cost = 0
        skill = [0] * n
        for i, v in enumerate(p):
            if v == 1:
                cost += c[i]
                if cost > best: break
                check = True
                for j in range(m):
                    skill[j] += a[i][j]
                    if skill[j] < x:
                        check = False
                if check:
                    best = cost
                    break
    if best == float('inf'):
        print('-1')
    else:
        print(best)
abc167c_skill_up()

Fixed submission:
import itertools

def abc167c_skill_up():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        v = list(map(int, input().split()))
        c.append(v[0])
        a.append(v[1:])
    pattern = itertools.product([0,1], repeat=n)
    best = float('inf')
    for p in pattern:
        cost = 0
        skill = [0] * m
        for i, v in enumerate(p):
            if v == 1:
                cost += c[i]
                if cost > best: break
                check = True
                for j in range(m):
                    skill[j] += a[i][j]
                    if skill[j] < x:
                        check = False
                if check:
                    best = cost
                    break
    if best == float('inf'):
        print('-1')
    else:
        print(best)
abc167c_skill_up()
Buggy python submission (verdict: Time Limit Exceeded):
def abc162d_rgb_triplets():
    n = int(input())
    s = input()
    r_cnt = [0] * n
    g_cnt = [0] * n
    b_cnt = [0] * n
    for i in range(n - 1, -1, -1):
        if i != n - 1:
            r_cnt[i] = r_cnt[i + 1]
            g_cnt[i] = g_cnt[i + 1]
            b_cnt[i] = b_cnt[i + 1]
        if s[i] == 'R':
            r_cnt[i] += 1
        elif s[i] == 'G':
            g_cnt[i] += 1
        else:
            b_cnt[i] += 1

    result = 0
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            if s[i] == s[j]: continue
            total = 0
            if 'R' not in (s[i] + s[j]):
                total = r_cnt[j + 1]
                if j+(j - i) < n and s[j+(j - i)] == 'R':
                    total -= 1
            if 'G' not in (s[i] + s[j]):
                total = g_cnt[j + 1]
                if j + (j - i) < n and s[j + (j - i)] == 'G':
                    total -= 1
            if 'B' not in (s[i] + s[j]):
                total = b_cnt[j + 1]
                if j + (j - i) < n and s[j + (j - i)] == 'B':
                    total -= 1
            result += total
    print(result)
abc162d_rgb_triplets()

Fixed submission:
def abc162d_rgb_triplets():
    n = int(input())
    s = input()
    r_cnt = 0
    g_cnt = 0
    b_cnt = 0
    for i in range(n - 1, -1, -1):
        if s[i] == 'R':
            r_cnt += 1
        elif s[i] == 'G':
            g_cnt += 1
        else:
            b_cnt += 1

    result = r_cnt * g_cnt * b_cnt
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = j + (j - i)
            if s[i] == s[j] or k >= n or s[i] == s[k] or s[j] == s[k]: continue
            result -= 1
    print(result)



abc162d_rgb_triplets()
Buggy python submission (verdict: Time Limit Exceeded):
def abc158d_string_formation():
    s = input()
    q = int(input())
    flip = 0
    for _ in range(q):
        query = list(input().split())
        if query[0] == '1':
            flip = 1-flip
        elif query[1] == '1':
            if flip == 0:
                s = query[2]+s
            else:
                s = s+query[2]
        else:
            if flip == 0:
                s = s+query[2]
            else:
                s = query[2]+s
    if flip == 1:
        s = ''.join(reversed(s))
    print(s)
abc158d_string_formation()

Fixed submission:
def abc158d_string_formation():
    from collections import deque
    s = deque(list(input()))
    q = int(input())
    flip = 0
    for _ in range(q):
        query = list(input().split())
        if query[0] == '1':
            flip = 1-flip
        elif query[1] == '1':
            if flip == 0:
                s.appendleft(query[2])
            else:
                s.append(query[2])
        else:
            if flip == 0:
                s.append(query[2])
            else:
                s.appendleft(query[2])
    if flip == 1:
        s = ''.join(reversed(s))
    else:
        s = ''.join(s)
    print(s)
abc158d_string_formation()
Buggy python submission (verdict: Runtime Error):
def abc151d_maze_master():
    h, w = map(int, input().split())
    s = []
    max_val = 0
    for i in range(h):
        s.append(input())
    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '#': continue
            flg = [[-1] * w for _ in range(h)]
            flg[hi][wi] = 0
            q = [(0, hi, wi)]
            heapq.heapify(q)
            while len(q) > 0:
                d, hj, wj = heapq.heappop(q)
                for dh, dw in zip([0, 0, 1, -1], [1, -1, 0, 0]):
                    if 0 <= hj + dh < h and 0 <= wj + dw < w and s[hj + dh][wj + dw] != '#' and \
                            (flg[hj + dh][wj + dw] == -1 or flg[hj + dh][wj + dw] > flg[hj][wj] + 1):
                        heapq.heappush(q, (d + 1, hj + dh, wj + dw))
                        flg[hj + dh][wj + dw] = flg[hj][wj] + 1
                # print(q)
            max_val = max(max_val, max([max(v) for v in flg]))
    print(max_val)


abc151d_maze_master()

Fixed submission:
import heapq


def abc151d_maze_master():
    h, w = map(int, input().split())
    s = []
    max_val = 0
    for i in range(h):
        s.append(input())
    for hi in range(h):
        for wi in range(w):
            if s[hi][wi] == '#': continue
            flg = [[-1] * w for _ in range(h)]
            flg[hi][wi] = 0
            q = [(0, hi, wi)]
            heapq.heapify(q)
            while len(q) > 0:
                d, hj, wj = heapq.heappop(q)
                for dh, dw in zip([0, 0, 1, -1], [1, -1, 0, 0]):
                    if 0 <= hj + dh < h and 0 <= wj + dw < w and s[hj + dh][wj + dw] != '#' and \
                            (flg[hj + dh][wj + dw] == -1 or flg[hj + dh][wj + dw] > flg[hj][wj] + 1):
                        heapq.heappush(q, (d + 1, hj + dh, wj + dw))
                        flg[hj + dh][wj + dw] = flg[hj][wj] + 1
                # print(q)
            max_val = max(max_val, max([max(v) for v in flg]))
    print(max_val)


abc151d_maze_master()
Buggy python submission (verdict: Runtime Error):
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def abc148c_snack():
    a, b = map(int, input().split())
    print(lcm(a, b))

abc148c_snack()

Fixed submission:
def lcm(x, y):
    import math
    return (x * y) // math.gcd(x, y)

def abc148c_snack():
    a, b = map(int, input().split())
    print(lcm(a, b))

abc148c_snack()
Buggy python submission (verdict: Time Limit Exceeded):
def mitsui2019d_lucky_pin():
    import itertools
    n = int(input())
    s = input()
    cnt = 0
    for t in itertools.product(range(0, 10), repeat=3):
        si = ''.join(map(str,t))
        for i in range(n - 2):
            if si[0] != s[i]: continue
            for j in range(i + 1, n - 1):
                if si[1] != s[j]: continue
                if si[2] in s[j + 1:]:
                    cnt += 1
                    break
            break
    print(cnt)


mitsui2019d_lucky_pin()

Fixed submission:
def mitsui2019d_lucky_pin():
    import itertools
    n = int(input())
    s = input()
    cnt = 0
    for t in itertools.product(range(0, 10), repeat=2):
        si = ''.join(map(str,t))
        for i in range(n - 2):
            if si[0] != s[i]: continue
            for j in range(i + 1, n - 1):
                if si[1] != s[j]: continue
                ss = set(list(s[j+1:]))
                cnt += len(ss)
                break
            break
    print(cnt)


mitsui2019d_lucky_pin()
Buggy python submission (verdict: Time Limit Exceeded):
def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        for j in range(1, min(i+1, k+1)):
            dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])

edu_dp_a_frog2()

Fixed submission:
def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i+1, k+1))])
        # for j in range(1, min(i+1, k+1)):
        #     dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])

edu_dp_a_frog2()

Buggy python submission (verdict: Time Limit Exceeded):
def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        for j in range(1, k+1):
            if i >= j:
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
            else:
                break
    print(dp[n-1])

edu_dp_a_frog2()

Fixed submission:
def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i+1, k+1))])
        # for j in range(1, min(i+1, k+1)):
        #     dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])

edu_dp_a_frog2()
Buggy python submission (verdict: Time Limit Exceeded):
def edu_dp_d_knapsack1():
    n, c = map(int, input().split())
    w, v = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0] * (c+1) for _ in range(n)]
    dp[0][w[0]] = v[0]
    for i in range(1, n):
        for j in range(0, c+1):
            dp[i][j] = dp[i-1][j]
            if j >= w[i]:
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]]+v[i])
    print(max(dp[n-1]))

edu_dp_d_knapsack1()

Fixed submission:
def edu_dp_d_knapsack1():
    n, c = map(int, input().split())
    w, v = [], []
    for _ in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[0] * (c + 1) for _ in range(n)]
    dp[0][w[0]] = v[0]
    for i in range(1, n):
        for j in range(0, c + 1):
            dp[i][j] = dp[i - 1][j]
            if j >= w[i]:
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i])
    print(max(dp[n - 1]))
edu_dp_d_knapsack1()
Buggy python submission (verdict: Time Limit Exceeded):
def edu_dp_e_knapsack2():
    n, c = map(int, input().split())
    w, v = [0], [0]
    for _ in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[float('inf')] * 100001 for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(1, n+1):
        for j in range(0, 100001):
            dp[i][j] = dp[i-1][j]
            if j >= v[i]:
                dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]]+w[i])
    ans = 100000
    while dp[n][ans]>c:ans-=1
    print(ans)
edu_dp_e_knapsack2()

Fixed submission:
def edu_dp_e_knapsack2():
    n, c = map(int, input().split())
    w, v = [0], [0]
    for _ in range(n):
        a, b = map(int, input().split())
        w.append(a)
        v.append(b)
    dp = [[float('inf')] * 100001 for _ in range(n + 1)]
    dp[0][0] = 0
    for i in range(1, n + 1):
        for j in range(0, 100001):
            dp[i][j] = dp[i - 1][j]
            if j >= v[i]:
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i])
    ans = 100000
    while dp[n][ans] > c: ans -= 1
    print(ans)
edu_dp_e_knapsack2()
Buggy python submission (verdict: Runtime Error):
import numpy as np
P=998244353
N,K=map(int,input().split())
LR=[]
for _ in range(K):
  l,r=map(int,input().split())
  LR+=range(l,r+1)
LR=list(set(LR))
LR=np.array(LR)
c=[0]*N
c[0]=1
for k in range(N):
  S=list(LR[LR<=k])
  while len(S):
    c[k]+=c[k-S[-1]]%P
    S.pop()
print(c[-1]%P)

Fixed submission:
a=input()
print(a+"s" if a[-1]!="s" else a+"es")

Buggy python submission (verdict: Runtime Error):
import numpy as np
P=998244353
N,K=map(int,input().split())
LR=[]
for _ in range(K):
  l,r=map(int,input().split())
  LR+=range(l,r+1)
LR=list(set(LR))
LR=np.array(LR)
c=[0]*N
c[0]=1
for k in range(N):
  S=LR[LR<=k]
  while len(S):
    c[k]+=c[k-S[-1]]%P
    S=S[:-1]
print(c[-1]%P)

Fixed submission:
a=input()
print(a+"s" if a[-1]!="s" else a+"es")
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
  def __init__(self, n):
    self.parents=[i for i in range(n)]
    self.rank=[0]*n

  def find(self, x):
    if self.parents[x]==x:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]

  def unite(self, x, y):
    x=self.find(x)
    y=self.find(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        self.parents[x]=y
      else:
        self.parents[y]=x
        if self.rank[x]==self.rank[y]:
          self.rank[x]+=1

  def same(self,x,y):
    return self.find(x)==self.find(y)

N,M=map(int,input().split())
uf=UnionFind(N)
for _ in range(M):
  a,b=map(int,input().split())
  uf.unite(a-1,b-1)
par=uf.parents
ans=0
parset=set(par)
for p in parset:
  s=par.count(p)
  ans=max(ans,s)
print(ans)

Fixed submission:
def find(x):
  if par[x] < 0:
    return x
  else:
    tank = []
    while par[x] >= 0:
      tank.append(x)
      x = par[x]
    for elt in tank:
      par[elt] = x
    return x

def unite(x,y):
  x = find(x)
  y = find(y)
    
  if x == y:
    return False
  else:
    if par[x] > par[y]:
      x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def same(x,y):
  return find(x) == find(y)

def size(x):
  return -par[find(x)]

N,M=map(int,input().split())
par = [-1]*N
for _ in range(M):
  a,b=map(int,input().split())
  unite(a-1,b-1)
print(-min(par))

Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind:
  def __init__(self, n):
    self.parents=[i for i in range(n)]
    self.rank=[0]*n

  def find(self, x):
    if self.parents[x]==x:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]

  def unite(self, x, y):
    x=self.find(x)
    y=self.find(y)
    if x!=y:
      if self.rank[x]<self.rank[y]:
        self.parents[x]=y
      else:
        self.parents[y]=x
        if self.rank[x]==self.rank[y]:
          self.rank[x]+=1

  def same(self,x,y):
    return self.find(x)==self.find(y)

N,M=map(int,input().split())
uf=UnionFind(N)
for _ in range(M):
  a,b=map(int,input().split())
  uf.unite(a-1,b-1)
par=uf.parents
ans=0
for p in par:
  s=par.count(p)
  ans=max(ans,s)
print(ans)

Fixed submission:
def find(x):
  if par[x] < 0:
    return x
  else:
    tank = []
    while par[x] >= 0:
      tank.append(x)
      x = par[x]
    for elt in tank:
      par[elt] = x
    return x

def unite(x,y):
  x = find(x)
  y = find(y)
    
  if x == y:
    return False
  else:
    if par[x] > par[y]:
      x,y = y,x
    par[x] += par[y]
    par[y] = x
    return True

def same(x,y):
  return find(x) == find(y)

def size(x):
  return -par[find(x)]

N,M=map(int,input().split())
par = [-1]*N
for _ in range(M):
  a,b=map(int,input().split())
  unite(a-1,b-1)
print(-min(par))
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))
scores=[]
for i in range(N-K+1):
  score=1
  for j in range(i,i+K):
    score*=A[j]
  scores.append(score)

for i in range(len(scores)-1):
  if scores[i+1]>scores[i]:
    print("Yes")
  else:
    print("No")

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N-K):
  if A[i]<A[i+K]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
score += a.pop(0)
if n%2==1:
  score += sum(a[:(n-3)//2])*2
else:
  score += sum(a[:(n-3)//2])*2 + a[(n-3)//2]
print(score)  

Fixed submission:
n=int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
score = a.pop(0)
if n%2==1:
  score += sum(a[:(n-1)//2-1])*2 + a[(n-1)//2-1]
else:
  score += sum(a[:(n-1)//2])*2
print(score)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sumA=[0]
for i in range(N):
  sumA.append(sumA[-1]+A[i])
sumB=[0]
for i in range(M):
  sumB.append(sumB[-1]+B[i])

ans=0
for i in range(N+1):
  k=K-sumA[i]
  if k<0:
    break
  l=len([x for x in sumB if x<=k])-1
  ans=max(ans,i+l)
print(ans)

Fixed submission:
import bisect
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
sumA=[0]
for i in range(N):
  sumA.append(sumA[-1]+A[i])
sumB=[0]
for i in range(M):
  sumB.append(sumB[-1]+B[i])

ans=0
for i in range(N+1):
  k=K-sumA[i]
  if k<0:
    break
  l=bisect.bisect_right(sumB,k)-1
  ans=max(ans,i+l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans = 0
for j in range(1,N+1):
  for i in range(1,N+1):
    if i % j == 0:
      ans += i
print(ans)

Fixed submission:
N = int(input())

def cnt(n):
  c = 0
  for i in range(1, N+1):
    n = N // i
    j  = i * n
    c += (i + j) * n // 2
  return c

print(cnt(N))