TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
e=0
ans=0
while c<k:
  if c<n and (a[d]>b[e] or (a[d]==b[e] and a[d+1]>=b[e+1])):
    c+=b[e]
    e+=1
    ans+=1
  elif d<m:
    c+=a[d]
    d+=1
    ans+=1
  else:
    break
if c==k:
  print(ans)
else:
  print(ans-1)

n,m,k=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
e=0
ans=0
while c<=k:
  if a[d]>=b[e]:
    c+=b[e]
    e+=1
    ans+=1
  else:
    c+=a[d]
    d+=1
    ans+=1
if c==k:
  print(ans)
else:
  print(ans-1)

n,m,k=int(input())
a=list(msp(int,input().split()))
b=list(msp(int,input().split()))
c=0
d=0
e=0
ans=0
while c<=k:
  if a[d]>=b[e]:
    c+=b[e]
    e+=1
    ans+=1
  else:
    c+=a[d]
    d+=1
    ans+=1
if c==k:
  print(ans)
else:
  print(ans-1)

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
d=0
e=0
ans=0
while c<=k:
  if c<n and (a[d]>b[e] or (a[d]==b[e] and a[d+1]>=b[e+1])):
    c+=b[e]
    e+=1
    ans+=1
  elif d<m:
    c+=a[d]
    d+=1
    ans+=1
  else:
    break
if c==k:
  print(ans)
else:
  print(ans-1)

n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aa = [0]
bb = [0]
 
for s in range(n):
    aa.append(aa[s] + a[s])
for s in range(m):
    bb.append(bb[s] + b[s])      
ans = 0
j = m
 
for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k - aa[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
from bisect import bisect_left, bisect_right, bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0]+a
b = [0]+b+[1e9+10]
ans = 0
for i in range(1, len(a)):
    a[i]+=a[i-1]
for i in range(1, len(b)):
    b[i]+=b[i-1]
for i in range(n+1):
    if a[i]>k: break
    rim = k-a[i]
    sub = bisect_left(b, rim)
    if sub == n+1: sub = n
    elif b[sub] != rim: sub-=1
    cnt = i+sub
    print(cnt)
    if ans<cnt: ans = cnt
print(ans)

# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header

n, m, k = map(int, input().split())
A = list(accumulate(map(int, input().split())))
B = list(accumulate(map(int, input().split())))
A=[0]+A
B=[0]+B
ans = []
for i in range(n+1):
    c = bisect_right(B, k-A[i])-1
    if c!=-1:
        ans.append(c+i)
print(max(ans))


Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
  

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

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[i] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)
  

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

a, b = [0], [0]

for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N+1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if len(A)>len(B):
    A += [0]*(len(A)-len(B))
elif len(B)>len(A):
    B += [0]*(len(B)-len(A))
print(A)
print(B)
time = 0
count = 0
i = 0
j = 0
goukei = 0
while time <= K:
    if A[i]>=B[j]:
        time += B[j]
        if time <= K:
            j +=1
            count += 1
    elif A[i] < B[j]:
        time += A[i]
        if time <= K:
            i += 1
            count +=1
print(count)

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = [0]
b = [0]
ans = 0
max_num = 0
j = M
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
for i in range(N+1):
    if a[i] > K:
        break
    else:
        while b[j] > K - a[i]:
            j -=1
            if j <0:
                break
    if K>= a[i] + b[j]:
        ans = max(ans,i + j)
print(ans)
        

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
 N, M, K = map(int, input().split())
2 A = list(map(int, input().split()))
3 B = list(map(int, input().split()))
4
5 a,b=[0],[0]
 6 for 7
8 for 9
i in range(N): a.append(a[i] + A[i]) i in range(M): b.append(b[i] + B[i])
10
11 ans,j=0,M
12 for 13
14
15
i in range(N + 1): ifa[i]>K:
break
while b[j] > K - a[i]:
j -= 1
ans = max(ans, i + j)
16
17
18 print(ans)

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

SumA=[0 for _ in range(N+1)]
SumB=[0 for _ in range(M+1)]
for i in range(1,N+1):
    SumA[i]=SumA[i-1]+A[i-1]
for i in range(1,M+1):
    SumB[i]=SumB[i-1]+B[i-1]

def binary_search(Time,IndexA):
    if Time>K:
        return 0 
    l=0
    r=M
    c=(l+r)//2
    while r-l>1:
        if Time+SumB[c]>K: r=c
        if Time+SumB[c]<=K: l=c
        c=(l+r)//2
    if Time+SumB[r]>K: IndexB=l
    else: IndexB=r
    NumOfBooks=IndexA+IndexB
    return NumOfBooks

MaxNumOfBooks=0
for IndexA in range(N+1):
    NumOfBooks=binary_search(SumA[IndexA],IndexA)
    if MaxNumOfBooks<NumOfBooks: MaxNumOfBooks=NumOfBooks
print(MaxNumOfBooks)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
from sys import stdin
n,m,k = map(int, stdin.readline().rstrip().split())
a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))

A = [0]
B = [0]
ans,res = 0,0
for i in range(0, n):
    A.append(A[i]+a[i])
for i in range(0, m):
    B.append(B[i]+b[i])

def ans(A, B):
    for i in range(0, n + 1):
        j = 0
        while A[i] + B[j + 1] <= k:
            j += 1
            if j == len(B) - 1:
                break

        ans = max(ans, i + j)
    return ans

if A[1] > k and B[1] > k:
    print(0)
else:
    res = ans(A, B)
    print(res)

from sys import stdin

n, m, k = map(int, stdin.readline().rstrip().split())

a = list(map(int, stdin.readline().rstrip().split()))
b = list(map(int, stdin.readline().rstrip().split()))

A,B = [0],[0]

for i in range(n):
    A.append(A[i]+a[i])

for i in range(m):
    B.append(B[i]+b[i])

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

print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
while b[j] > K - a[i]:
    j -= 1
ans = max(ans, i + j)
print(ans)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
ans = max(ans, i + j)
print(ans)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):

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

max=0

A.insert(0, 0)
A = numpy.cumsum(A)
B.insert(0,0)
B = numpy.cumsum(B)

ans,j=0,M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j-=1

    ans=max(ans,i+j)

print(ans)

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

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j=0,M

for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j-=1
    
    ans = max(ans,i+j)

print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int, input().split())
INF = int(1e18)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = A[:]
B = B[:]
i, j = 0, 0
mcnt = 0
tmp = M+1
ccnt = 0
while tmp != 0:
  ccnt += 1
  tmp //= 2
LA = [0 for _ in range(N+1)]
LB = [0 for _ in range(M+1)]
for i in range(N):
  LA[i+1] = LA[i] + A[i]
for i in range(M):
  LB[i+1] = LB[i] + B[i]
for i in range(N+1):
  l, r = 0, M+1
  d = (l + r) // 2
  if LA[i] <= K:
    if LB[M] + LA[i] <= K:
      mcnt = max(i + M, mcnt)
    else:
      for j in range(ccnt + 1):
        if LB[d] + LA[i] <= K:
          l = d
          d = (l + r) // 2
        else:
          r = d
          d = (l + r) // 2
      print(d)
      mcnt = max(i + d, mcnt)
  else:
    break
print(mcnt)

N, M, K = map(int, input().split())
INF = int(1e18)
A = list(map(int, input().split()))
B = list(map(int, input().split()))
i, j = 0, 0
mcnt = 0
tmp = M+1
ccnt = 0
while tmp != 0:
  ccnt += 1
  tmp //= 2
LA = [0 for _ in range(N+1)]
LB = [0 for _ in range(M+1)]
for i in range(N):
  LA[i+1] = LA[i] + A[i]
for i in range(M):
  LB[i+1] = LB[i] + B[i]
for i in range(N+1):
  l, r = 0, M+1
  d = (l + r) // 2
  if LA[i] <= K:
    if LB[M] + LA[i] <= K:
      mcnt = max(i + M, mcnt)
    else:
      for j in range(ccnt + 1):
        if LB[d] + LA[i] <= K:
          l = d
          d = (l + r) // 2
        else:
          r = d
          d = (l + r) // 2
      mcnt = max(i + d, mcnt)
  else:
    break
print(mcnt)


Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
A.reverse()
B.reverse()

t = 0
cnt = 0
c1, c2 = A.pop(), B.pop()
while True:
    
    if t >= K or (t + c1 > K and t + c2 > K):
        break


    if (t + c1 <= K and t + c2 <= K):
        l1 = [c1]
        sum_1 = c1
        for a in A[-1]:
            if t + a <= K:
                l1.append(a)
                sum_1 += a
            else:
                break
        l2 = [c2]
        sum_2 = c2
        for b in B[-1]:
            if t + b <= K:
                l2.append(b)
                sum_2 += b
            else:
                break
        
        if sum_1 <= sum_2:
            t += sum_1
            cnt += len(l1)
            for i in range(len(l1)-1):
                A.pop()
            c1 = A.pop() if bool(A) else 100000000000
        else:
            t += sum_2
            cnt += len(l2)
            for i in range(len(l2)-1):
                B.pop()
            c2 = B.pop() if bool(B) else 100000000000

    elif t + c1 <= K:
        
        t += c1
        cnt += 1
        c1 = A.pop() if bool(A) else 100000000000
    else:
        if t + c2 <= K:
            t += c2
            cnt += 1
            c2 = B.pop() if bool(B) else 100000000000

print(cnt)


N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
aa = 0
bb = 0
for i in A:
    aa += i
    a.append(aa)
for j in B:
    bb += j
    b.append(bb)

ans = 0
cnt = 0
lb = len(b)-1
for i in range(len(a)):
    cnt = a[i]
    if(cnt > K):
        break
    for j in reversed(range(lb)):
        tmp = cnt + b[j]
        if(tmp > K):
            lb = j
        else:
            ans = max(i+j, ans)
            break

print(ans)

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

a = [0]
b = [0]
aa = 0
bb = 0
for i in A:
    aa += i
    a.append(aa)
for j in B:
    bb += j
    b.append(bb)

ans = 0
lb = len(b)
j = len(b)-1
for i in range(len(a)):
    if(a[i] > K):
        break
    while(a[i]+b[j] > K):
        j -= 1
    ans = max(ans, i+j)

print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
 
a = [0]
b = [0]
for i in range(n):
  a.append(a[i]+A[i])
for j in range(m):
  b.append(b[j]+B[j])
#print(a,b)
 
ans = 0
j = m
for i in range(n+1):
  if a[i] > k:
    break
  while (k - a[i]) < b[j]:
    j -= 1
    if j == -1:
      break
  
  ans = max(ans, i+j)
     
print(ans)

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
 
a = [0]
b = [0]
for i in range(n):
  a.append(a[i]+A[i])
for j in range(m):
  b.append(b[j]+B[j])
#print(a,b)
 
ans = 0
j = m
for i in range(n+1):
  if a[i] > k:
    break
  while (k - a[i]) < b[j]:
    j -= 1
    if j == -1:
      break
  
  ans = max(ans, i+j)
     
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import math
import copy



# n = int(input())

target_1 = [int(x) for x in input().split()]

N = target_1[0]
M = target_1[1]
K = target_1[2]

target_2 = [int(x) for x in input().split()]
target_2.reverse()
target_3 = [int(x) for x in input().split()]
target_3.reverse()
result = 0

for i in range(1, N + 1):
    
    left = K - sum(target_2[0:i])
    if left < 0:
        break
    result = max(result, i - 1)
    for j in range(1, M + 1):
        
        left_t = left - sum(target_3[0:j])
        if left_t < 0:
            break
        result = max(result, i + j)


print(result)


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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])

for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=[map(int,input().split())]
b=[map(int,input().split())]

aa,bb=[0],[0]
for i in range(n):
  aa.append(aa[i]+a[i])
for i in range(m):
  bb.append(bb[i]+b[i])
ans,j=0,m
for i in range(n+1):
  if aa[i]>k:
    break
  while b[j]>k-aa[i]:
    j -= 1
  ans=max(ans,i+j)
print(ans)

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

aa,bb=[0],[0]
for i in range(n):
  aa.append(aa[i]+a[i])
for i in range(m):
  bb.append(bb[i]+b[i])
ans,j=0,m
for i in range(n+1):
  if aa[i]>k:
    break
  while bb[j] > k-aa[i]:
    j -= 1
  ans=max(ans,i+j)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

ans=0
count=0
i,j=0,0
while ans<k:
  if i > n-1:
    num=b[j]
  if j > m-1:
    num=a[i]
  else:
    num=min(a[i],b[j])
    if num==a[i]:
      i+=1
      count+=1
      ans+=num
    else:
      j+=1
      count+=1
      ans+=num
  
print(count)

n,m,k=3,4,730
a=[60,90,120]
b=[80,150,80,150]

ans=0
count=0
i,j=0,0
if a[i]>k:
  print(0)
  exit()
elif b[j]>k:
  print(0)
  exit()
elif sum(a)+sum(b)<=k:
  print(n+m)
  exit()
else:
  while ans<=k:
    if i > n-1:
      num=b[j]
    elif j > m-1:
      num=a[i]
    else:
      num=min(a[i],b[j])
      if num==a[i]:
        i+=1
        count+=1
        ans+=num
      else:
        j+=1
        count+=1
        ans+=num

if num==k:
  print(count)
else:
  print(count-1)


n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

for a in A:
  A[a]+=A[a+1]
  
for b in B:
  B[b]+=B[b+1]

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


n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

asum=[0]
bsum=[0]

for i in range(n):
  asum.append(asum[i]+A[i])
  
for j in range(m):
  bsum.append(bsum[j]+B[j])

ans=0
ko=m
for i in range(n+1):
  if asum[i]>k:
    break
  while asum[i]+bsum[ko]>k:
    ko-=1
  ans=max(ans,i+ko)
  
print(ans)


n,m,k=map(int,input().split())
A=[0]+list(map(int,input().split()))
B=[0]+list(map(int,input().split()))

for a in A:
  A[a]+=A[a+1]
  
for b in B:
  B[b]+=B[b+1]

ans=0
op=m
for i in range(n+1):
  while A[i]+B[op]>k:
    op-=1
   
  ans=max(ans,i+op)
  
print(ans)

n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

asum=[0]
bsum=[0]

for i in range(n):
  asum.append(asum[i]+A[i])
  
for j in range(m):
  bsum.append(bsum[j]+B[j])

ans=0
ko=m
for i in range(n+1):
  if asum[i]>k:
    break
  while asum[i]+bsum[ko]>k:
    ko-=1
  ans=max(ans,i+ko)
  
print(ans)


Verdicts: Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Runtime Error

Accepted
Problem: We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it.  It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M).  Consider the following action:    * Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk.  How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading.

Submission attempts (in order):
n, m, k = map(int, input().split())
a = [int(v) for v in input().split()]
b = [int(v) for v in input().split()]
ans = []
for _ in range(n + m):
    if len(a) > 0 and len(b) > 0 and a[0] <= b[0] and a[0] <= k:
        k -= a[0]
        ans.append(a[0])
        a.pop(0)
    elif len(a) > 0 and len(b) > 0 and b[0] <= a[0] and b[0] <= k:
        k -= b[0]
        ans.append(b[0])
        b.pop(0)
    elif len(a) == 0 and len(b) > 0 and b[0] <= k:
        k -= b[0]
        ans.append(b[0])
        b.pop(0)
    elif len(b) == 0 and len(a) > 0 and a[0] <= k:
        k -= a[0]
        ans.append(a[0])
        a.pop(0)

n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(n):
    a.append(a[i] + A[i])

for i in range(m):
    b.append(b[i] + B[i])

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

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
print(www)

a=int(input())
ans=0
for i in range(a):
  x=a//i
  ans+=((a+1)a)/2
print(ans)

import math
a=int(input())
b=list(i+1 for i in range(a))
www=0
for j in b:
  c=[x+1 for x in range(int(math.sqrt(j)//1))]
  for y in c:
    if j%y==0:
      if not j==y*y:
        www=+j*2
      else:
        www+=j
print(www)

import math
a=int(input())
b=list(i+1 for i in range(a))
www=0
for j in b:
  c=[x+1 for x in range(int(math.sqrt(j)//1))]
  for y in c:
    if j%y==0:
      if not j/y==y:
        www=+j*2
      else:
        www+=j
print(www)

a=int(input())
b=(a)//2+1
ans=0
for i in range(1,b,1):
  x=a//i
  ans+=((x**2+x)//2)*i
ans+=(a**2+a+b-b**2)//2
print(ans)

Verdicts: Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n=int(imput())

ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i

  ans+=(i*y*(y+1)/2)



print(ans)

n=int(input())
 
ans=0
for i in range(n):
  i=i+1
  a=i
  y=n//i
 
  ans+=(i*y*(y+1)/2)
 
 
 
print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
n=int(input())
s=time.time()
factors=defaultdict(lambda:[])
for i in range(2,3300):
    if(i not in factors):
        for j in range(i,10000001,i):
            factors[j].append(i)
ans=1
# print(factors)
# print(time.time()-s)
for i in range(2,n+1):
    tt=1
    tn=i
    for j in factors[i]:
        temp=0
        while(tn%j==0):
            temp+=1
            tn=tn//j
        tt*=(temp+1)
    if(tn!=1):
        tt*=2
    ans+=i*tt
print(ans)
# print(time.time()-s)





import math
import time
from collections import defaultdict,deque
from sys import stdin,stdout
from bisect import bisect_left,bisect_right
def find(a):
    return (a*(a+1))//2
n=int(input())
ans=0
for i in range(1,n+1):
    ans+=i*find(n//i)
print(ans)





Verdicts: Time Limit Exceeded

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def solve(n):
    ans = 0
    for i in range(1,n+1):
        y = n//i
        print(y)
        ans += (y*(y+1)*i)/2
    return ans

def main():
    n = int(input())
    print(int(solve(n)))

if __name__ == "__main__":
    main()


def solve(n):
    ans = 0
    for i in range(1,n+1):
        y = n//i
        ans += (y*(y+1)*i)/2
    return ans

def main():
    n = int(input())
    print(int(solve(n)))

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


def main_chk():
    N = int(input())

    ans = 0
    for i in range(1,N+1):
        m = N // i
        ans += ( m + 1 ) * m * i / 2

    print(ans)
main_chk()


import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re


def main_chk():
    N = int(input())

    ans = 0
    for i in range(1,N+1):
        m = N // i
        ans += ( m + 1 ) * m * i / 2

    print(math.floor(ans))
main_chk()


Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input())
ans = 0
for i in range(1,n+1):
  ans += i * (1+n//i) * (n//i) / 2
print(ans)

primes = [2]
li = [[],[]]
f_ans = [0]
def f(x):
  if x==1:
    f_ans.append(1)
    return 1
  if x==2:
    f_ans.append(2)
    return 2
  flag = True
  for i in range(len(primes)):
    if x%primes[i]==0:
      tmp = li[x//primes[i]][:]
      tmp[i] += 1
      li.append(tmp)
      f_ans.append(f_ans[x//primes[i]]//tmp[i]*(tmp[i]+1))
      return f_ans(x)
    else:
      li.append([0]*len(primes)+[1])
      f_ans.append(2)
      primes.append(x)
      return 2

n = int(input())
sum = 0
for i in range(1,n+1):
  sum += i * f(i)
print(sum)

n = int(input())
ans = 0
for i in range(1,n+1):
  ans += i * (1+n//i) * (n//i) // 2
print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())
ans = 0
ans += N*(N+1)/2

for i in range(2, N+1):
    N_case = N // i
    ans += N_case*(N_case + 1)*i//2

print(ans)


N = int(input())
ans = 0
ans += N*(N+1)//2

if N >= 2:
    for i in range(2, N+1):
        N_case = N // i
        ans += N_case*(N_case + 1)*i//2

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n=int(input())
ans=0
for i in range(1,n+1):
	x=math.floor(n/i)
	ans+=(x*(x+1)*i)/2
print(int(ans))

import math
n=int(input())
ans=0
for i in range(1,n+1):
	x=math.floor(n/i)
	ans+=(x*(x+1)*i)/2
print(int(ans))

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def divisors(n):
    i = 1
    cnt = 0
    while i*i <= n:
        if n % i == 0:
            cnt += 1
            if i * i != n:
                cnt += 1
        i += 1
    return cnt

n = int(input())
ans = 0
for i in range(1, n + 1):
    ans += i * divisors(i)

def cal(b, e):
    return ((b + (e//b) * b) * (e//b))//2

n = int(input())
ans = 0

for i in range(1, n+1):
    ans += cal(i, n)

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input())

result = 0
for i in range(1,(n // 2 + 1)):
    terms = n // i
    result += terms * (terms * i + i) // 2

terms = n - n // 2
result += terms * (n // 2 + n) // 2

print(result)

n = int(input())

result = 0
for i in range(1,(n // 2 + 1)):
    terms = n // i
    result += terms * (terms * i + i) // 2

terms = n - n // 2
result += terms * (n // 2 + 1 + n) // 2

print(result)

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())
a=0
for i in range(1,n+1):
  x,y=i,(n//i)*i
  a+=((n//i)*(x+y)//2)
print(a)

n=int(input())
ans=0
for i in range(1,n+1):
    x,y=i,(n//i)*i
    ans+=((n//i)*(x+y)//2)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
# D - Sum of Divisors
from numba import njit


@njit
def main():
    N = int(input())
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    print(res)


if __name__ == "__main__":
    main()


# D - Sum of Divisors
from numba import njit


@njit
def solve(N):
    res = 0
    for a in range(1, N + 1):
        for b in range(1, N // a + 1):
            res += a * b
    return res


def main():
    N = int(input())
    print(solve(N))


if __name__ == "__main__":
    main()


Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def main():
    N = int(input())
    tot = 0
    for d in range(1, N+1):
        nd = N//d
        tot += (d * (nd + 1) * nd) // 2

    print(tot)



N = int(input())
tot = 0
for d in range(1, N+1):
    nd = N//d
    tot += (d * (nd + 1) * nd) // 2

print(tot)




Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

from my_module import main

N = int(read())
print(main(N))


import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    div = np.zeros(N+1, np.int64)
    for n in range(1, N+1):
      div[::n] += 1
    div *= np.arange(N + 1)
    return div.sum()

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


import sys
import numba

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@numba.njit('(i8,)', cache=True)
def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

N = int(read())
print(main(N))


Verdicts: Runtime Error

Time Limit Exceeded

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):

def make_divisors(n): をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    
    return divisors


import sys
input = sys.stdin.readline
N = int(input())

#DP
f_dp =[0]*(N+1)

ans =[]
for i in range(N,0,-1):
    if f_dp[i] ==0:
        f =make_divisors(i)
        f.sort(reverse=True)
        f_dp[i] =len(f)
        for j in range(len(f)-1):
            f_dp[f[j+1]] =f_dp[f[j]]-1
    ans.append(i *f_dp[i])
print(sum(ans))

#https://www.youtube.com/watch?v=3gFnZhZlAF8



import sys
input = sys.stdin.readline
N = int(input())
ans =0
for i in range(1,N+1):
    n =N//i 
    ans +=n*(2*i +(n-1)*i)//2
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n=int(input())
def make_divisors(n):
    lower_divisors = []
    upper_divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)

    upper_divisors.reverse()
    return n+len(lower_divisors + upper_divisors)
sumi=0
for i in range(1,n+1):
    sumi+=make_divisors(i)
print(sumi)

n=int(input())
ans=0
for i in range(n):
  y=n//i
  ans+=y*(y+1)*i//2
print(ans)

n=int(input())
ans=0
for i in range(1,n+1):
  y=n//i
  ans+=y*(y+1)*i//2
print(ans)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import numpy as np
from numba import njit


@njit('(i8)', cache=True)
def solve(x):
    count = np.zeros(x + 1, dtype=np.int64)
    for i in range(1, x + 1):
        for j in range(i, x + 1, i):
            count[j] += j
    return count.sum()


if __name__ == "__main__":
    x = int(input())
    print(solve(x))



import numpy as np
from numba import njit
 
@njit('i8(i8)', cache=True)
def solve(x):
    count = np.ones(x + 1, dtype=np.int8)
    for i in range(2,x+1):
        for j in range(i,x+1,i)
            count[j] += 1
    return int(np.sum(np.arange(x + 1) * count))
 
if __name__== "__main__":
    x = int(input())
    print(solve(x))

import numpy as np
from numba import njit


@njit('i8(i8)', cache=True)
def solve(x):
    count = np.zeros(x + 1, dtype=np.int64)
    for i in range(1, x + 1):
        for j in range(i, x + 1, i):
            count[j] += j
    return count.sum()


if __name__ == "__main__":
    x = int(input())
    print(solve(x))



Verdicts: Runtime Error

Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
# coding:utf-8
import sympy
n = int(input())

ans = 0
for i in range(1, n + 1):
    ans += i * sympy.divisors(i)
print(ans)


# coding:utf-8
n = int(input())
ans = 0

for i in range(1, n + 1):
    tmp = n // i
    ans += i * tmp * (tmp + 1) // 2
print(ans)


Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input())

ans = 0
for x in range(1, n + 1):
    ans += (x + n//x * x) * (n // x) / 2
    
print(ans)

n = int(input())

ans = 0
for x in range(1, n + 1):
    ans += (x + n//x * x) * (n // x) / 2
    
print(int(ans))

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import numpy as np
def divisor_num(n):
    if n == 1:
        return 1
    arr = []
    temp = n
    for i in range(2,int(np.sqrt(n))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)
    
    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)
    
    ans = 1
    for num in arr:
        ans *= num+1
    
    return ans

n = int(input())
total = 0
for i in range(1,n+1):
    total += i*divisor_num(i)


import numpy as np
def divisor_num(n):
    if n == 1:
        return 1
    arr = []
    temp = n
    for i in range(2,int(np.sqrt(n))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)
    
    if temp!=1:
        arr.append(1)

    if arr==[]:
        arr.append(1)
    
    ans = 1
    for num in arr:
        ans *= num+1
    
    return ans

n = int(input())
total = 0
for i in range(1,n+1):
    total += i*divisor_num(i)

n = int(input())

ans = 0
for i in range(1,n+1):
    num = n//i
    ans += num*(i+i*num)//2

print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
N = int(input())

t = 0

for i in range (1,N+1):
  p = N//i
  t += i*p*(1+p)/2
  

print(t)

N = int(input())

t = 0

for i in range (1,N+1):
  p = N//i
  t += i*p*(1+p)/2
  

print(int(t))

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input().strip())
a = 0
for i in range(1, n+1):
  a += i*((n//i)*(n//i+1)//2)
 print(a)

n = int(input())
a = n * (n+1) // 2
for i in range(2, n+1):
  c = n // i
  a += i * (c * (c+1) // 2)
print(a)

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input())
ans = 0
for i in arnge(1, n + 1):
  for j in range(1, n + 1, i):
    ans += j
print(ans)


n = int(input())
ans = 0
for i in range(1, n + 1):
  for j in range(1, n + 1, i):
    ans += j
print(ans)


n = int(input())
s = 0
for k in range(1, n + 1):
  m = n // k
  s += k * m * (m + 1) // 2
print(s)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
n = int(input())
ans = 0

for x in range(1, n+1):
  k = n//x
  ans += n*(2*x + (n-1)*x)//2
  
print(ans)

n=int(input())
ans=0
for i in range(1,n+1):
  k=n//i
  ans+=i*(k*(k+1)//2)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def main():
    n = int(input())
    ans = 0

    for i in range(1, n+1):
        y = n // i
        ans = (y+1)*y*i//2
    print(ans)

if __name__ == '__main__':
    main()

def main():
    n = int(input())
    ans = 0
 
    for i in range(1, n+1):
        y = n // i
        ans += (y+1)*y*i//2
    print(ans)
 
if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
print(sum((j:=i+1)(x:=n//j)*(x+1)*i//2for i in range(n:=int(input()))))

n=int(input());print(sum((x:=n//i)*(x+1)*i//2 for i in range(1,n+1)))

Verdicts: Runtime Error

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
def factorization(n):
    arr = []
    temp = n
    ans = 0
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    ans = 0
    for i in range(1,n+1):
        fact =1
        arr = factorization(i)
        for a in arr:
            fact *= a[1]+1
        ans += n*fact
    print(ans)


if __name__ == '__main__':
    main()

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    ans = 0
    sumn = lambda x: x*(x+1)//2
    for i in range(1,n+1):
        r = n//i
        ans += i*(sumn(r))
    print(ans)


if __name__ == '__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: For a positive integer X, let f(X) be the number of positive divisors of X.  Given a positive integer N, find \sum_{K=1}^N K\times f(K).

Submission attempts (in order):
import numpy as np

N = int(input())

count = 0
for i in range(1, (N+1)//2+1):
  count += int(np.ceil((N+1)/i)) * (N - (N)%i) // 2 


print(count)

import numpy as np

N = int(input())

count = 0
for i in range(1, N+1):
    count += (N // i) * (i + i * (N//i)) // 2


print(count)

Verdicts: Wrong Answer

Accepted