Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]


def main():
    n = getN()
    nums = getList()
    index = [0 for i in range(n)]

    for i, num in enumerate(nums):
        if index[num - 1] == 0:
            index[num - 1] = i
        else:
            ida = i
            idb = index[num - 1]
            break

    side = n - (ida - idb)

    invmod = getinvmod(n+1)

    # print(invmod)
    #
    # print([(i * iv) % MOD for i, iv in enumerate(invmod)])
    ans = n + 1
    minus = 1
    print((ans - minus)%MOD)
    # print(side, ida, idb,"side")
    for i in range(1, n + 1):
        ans *= (n - i + 1)
        ans *= invmod[i + 1]
        ans %= MOD
        if i <= side:
            minus *= side - i + 1
            minus *= invmod[i]
            minus %= MOD

        else:
            minus = 0

        print((ans - minus) % MOD)
        # print(ans, minus)



if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]


def main():
    n = getN()
    nums = getList()
    index = [-1 for i in range(n)]

    for i, num in enumerate(nums):
        if index[num - 1] == -1:
            index[num - 1] = i
        else:
            ida = i
            idb = index[num - 1]
            break

    side = n - (ida - idb)

    invmod = getinvmod(n+1)

    # print(invmod)
    #
    # print([(i * iv) % MOD for i, iv in enumerate(invmod)])
    ans = n + 1
    minus = 1
    print((ans - minus)%MOD)
    # print(side, ida, idb,"side")
    for i in range(1, n + 1):
        ans *= (n - i + 1)
        ans *= invmod[i + 1]
        ans %= MOD
        if i <= side:
            minus *= side - i + 1
            minus *= invmod[i]
            minus %= MOD

        else:
            minus = 0

        print((ans - minus) % MOD)
        # print(ans, minus)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import copy
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(monsterss, n_attack, a, b):
    monsters = copy.copy(monsterss)
    attack = 0
    for monster in monsters:
        # monster -= n_attack * b
        if monster > 0:
            attack += math.ceil(max(0, (monster - b*n_attack)/(a-b)))

    return attack <= n_attack


def main():
    n, a, b = getList()
    monsters = []
    for i in range(n):
        monsters.append(getN())

    mn = 0
    mx = 10 ** 15
    while(mx - mn > 1):
        mid = (mn + mx) // 2
        if judge(monsters, mid, a, b):
            mx = mid
        else:
            mn = mid

    if judge(monsters, mn, a, b):
        print(mn)
    else:
        print(mx)



if __name__ == "__main__":
    main()

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import copy
from collections import deque

class SegTree():
    def __init__(self, n):
        self.value = [0 for i in range(n*2)]

MOD = 10 ** 9 + 7

def getinvmod(n):
    return [pow(i, MOD-2, MOD) for i in range(n+1)]

def judge(monsters, n_attack, a, b):
    attack = 0
    for monster in monsters:
        # monster -= n_attack * b
        if monster > 0:
            attack += math.ceil(max(0, (monster - b*n_attack)/(a-b)))

    return attack <= n_attack


def main():
    n, a, b = getList()
    monsters = []
    for i in range(n):
        monsters.append(getN())

    mn = 0
    mx = 10 ** 15
    while(mx - mn > 1):
        mid = (mn + mx) // 2
        if judge(monsters, mid, a, b):
            mx = mid
        else:
            mn = mid
        # print(monsters)

    if judge(monsters, mn, a, b):
        print(mn)
    else:
        print(mx)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
strs = input.split()
print("".join([a[0].upper() for a in strs]))

Fixed submission:
strs = input().split()
print("".join([a[0].upper() for a in strs]))
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(n)
aind = 0
for i , c in enumerate(s):
  if c == "A":
    aind =  i
    break
zind = 0
for i,c in enumerate(s):
  if c == "Z":
    zind = i
    
print(zind-aind)

Fixed submission:
s = input()
 
aind = 0
for i , c in enumerate(s):
  if c == "A":
    aind =  i
    break
zind = 0
for i,c in enumerate(s):
  if c == "Z":
    zind = i
    
print(zind-aind + 1)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

N = getN()
nums = getList()
dup = defaultdict(int)

for n in nums:
    dup[n] += 1

poss = len(dup.keys())
dupdup = 0
for val in dup.values():
    if val % 2 == 0:
        dupdup += 1

if dupdup % 2 == 0:
    print(poss)
else:
    print(poss-1)

Fixed submission:
from collections import defaultdict
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

N = getN()
nums = getList()
dup = defaultdict(int)

for n in nums:
    dup[n] += 1

poss = len(dup.keys())
dupdup = 0
for val in dup.values():
    if val % 2 == 0:
        dupdup += 1

if dupdup % 2 == 0:
    print(poss)
else:
    print(poss-1)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

nums=list(map(int,input().split))
tmp=nums[0]
ans=0
for num in nums[1:]:
  if (nuw-tmp)*a<=b: 
    ans+=(num-tmp!)*a
  else:
    ans+=b
  tmp=num

print(ans)

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

nums=list(map(int,input().split()))
tmp=nums[0]
ans=0
for num in nums[1:]:
  if (num-tmp)*a<=b: 
    ans+=(num-tmp)*a
  else:
    ans+=b
  tmp=num

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input().strip()
l = len(s)

if (l + s[0] == s[-1]) % 2:
  print("First")
else:
  print("Second")

Fixed submission:
s = input().strip()
l = len(s)
 
if (l + (s[0] == s[-1])) % 2:
  print("First")
else:
  print("Second")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ratio = []
for i in range(N):
  ratio.append([int(j) for j in input().split(" ")])
               
vote = ratio[0]

for i in range(len(ratio)-1):
  if ratio[i+1][0] >= vote[0] and ratio[i+1][1] >= vote[1]:
    vote = ratio[i+1]
  
  else:
    a0 = 0
    b0 = 0
    if ratio[i+1][0] < vote[0]:
      seed = ratio[i+1][0]
      base = ratio[i+1][0]
      while(True):
        seed += base
        
        if seed >= vote[0]:
          break
      a0 = seed
      a1 = int(seed * ratio[i+1][1]/ratio[i+1][0])
      la = [a0,a1] 
    
    if ratio[i+1][1] < vote[1]:
      seed = ratio[i+1][1]
      base = ratio[i+1][1]
      while(True):
        seed += base
        if seed >= vote[1]:
          break
      b1 = seed
      b0 = int(seed * ratio[i+1][0]/ratio[i+1][1])
      lb = [b0,b1]
    if a0 > b0:
      vote = [la[0],la[1]]
    else:
      vote = [lb[0],lb[1]]
    
print(sum(vote))

Fixed submission:
N = int(input())
ratio = []
for i in range(N):
  ratio.append([int(j) for j in input().split(" ")])
               
vote = ratio[0]

for i in range(len(ratio)-1):
  if ratio[i+1][0] >= vote[0] and ratio[i+1][1] >= vote[1]:
    vote = ratio[i+1]
  
  else:
    a0 = 0
    b0 = 0
    if ratio[i+1][0] < vote[0]:
      seed = ratio[i+1][0]
      mul = vote[0]//ratio[i+1][0]
      if vote[0]%ratio[i+1][0] != 0:
        mul += 1
      seed *= mul
      a0 = seed
      a1 = mul * ratio[i+1][1]
      la = [a0,a1] 
    
    if ratio[i+1][1] < vote[1]:
      seed = ratio[i+1][1]
      base = ratio[i+1][1]
      
      mul = vote[1]//ratio[i+1][1]
      if vote[1]%ratio[i+1][1] != 0:
        mul += 1
      seed *= mul
      b1 = seed
      b0 = mul * ratio[i+1][0]
      lb = [b0,b1]
    if a0 > b0:
      vote = [la[0],la[1]]
    else:
      vote = [lb[0],lb[1]]
print(sum(vote))
Buggy python submission (verdict: Runtime Error):
def dig_check(i,d):
    for k in [int(j) for j in str(i)]:
        if k in d:
            return False
    return True


N,K = input.split()
N = int(N)

d = [int(i) for i in input.split()]

for i in range(10001):
    if i > N :
        if dig_check(i,d):
            print(i)
            break


Fixed submission:
def dig_check(i,d):
    for k in [int(j) for j in str(i)]:
        if k in d:
            return False
    return True


N,K = input().split()
N = int(N)

d = [int(i) for i in input().split()]

for i in range(100001):
    if i >= N :
        if dig_check(i,d):
            print(i)
            break
Buggy python submission (verdict: Runtime Error):
def getlist():
    return list(map(int, input().split()))
  
a,b = getList()
lis = []
for i in range(a):
  lis.append(input().strip())
  
lis.sort()
print("".join(lis))

Fixed submission:
def getlist():
    return list(map(int, input().split()))
  
a,b = getlist()
lis = []
for i in range(a):
  lis.append(input().strip())
  
lis.sort()
print("".join(lis))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1, N):
    temp = N-i
    j = 1
    low = []
    up = []
    while j**2<=temp:
        if temp%j==0:
            low.append(j)
            if j!=temp//j:
                up.append(temp//j)
        j+=1
    ans+=len(low+up[::-1])
print(ans)

Fixed submission:
N = int(input())
ans = 0
temp = N-1
for i in range(1, N):
    j = temp//i
    ans+=j
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(int)
N, X, M = map(int, input().split())
A = [X]
ans = X
if N>1:
    temp = 1
    dic[X]=temp
    for i in range(2, N+1):
        a = A[-1]*A[-1]%M
        if dic[a]>0:

            fir = dic[a]
            break
        A.append(a)
        ans+=a
        temp+=1
        dic[a]=temp
    T = temp-fir+1#周期
    Tsum = 0 #周期の和
    TempSum = 0 #後半あまりの和
    M=N-fir+1 # 先頭のぞく 
    amari = M%T # 後半あまり
    for k in dic:
        if dic[k]>=fir and dic[k]<=temp:
            Tsum+=k
        if dic[k]>=fir and dic[k]<fir+amari:
            TempSum += k
    ans+=TempSum
    ans+=Tsum*(M//T-1)
    print(ans)
else:
    print(ans)

Fixed submission:
from collections import defaultdict
dic = defaultdict(int)
N, X, M = map(int, input().split())
A = [X]
ans = X
fir = -1
if N>1:
    temp = 1
    dic[X]=temp
    for i in range(2, N+1):
        a = A[-1]*A[-1]%M
        if dic[a]>0:
            fir = dic[a]
            break
        A.append(a)
        ans+=a
        temp+=1
        dic[a]=temp
    if fir!=-1:
        T = temp-fir+1#周期
        Tsum = 0 #周期の和
        TempSum = 0 #後半あまりの和
        M=N-fir+1 # 先頭のぞく 
        amari = M%T # 後半あまり
        for k in dic:
            if dic[k]>=fir and dic[k]<=temp:
                Tsum+=k
            if dic[k]>=fir and dic[k]<fir+amari:
                TempSum += k
        ans+=TempSum
        ans+=Tsum*(M//T-1)
    print(ans)
else:
    print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(int)
N, X, M = map(int, input().split())
A = [X]
ans = X

temp = 1
dic[X]=temp
for i in range(2, N+1):
    a = A[-1]*A[-1]%M
    if dic[a]>0:
        
        fir = dic[a]
        break
    A.append(a)
    ans+=a
    temp+=1
    dic[a]=temp
T = temp-fir+1#周期
Tsum = 0 #周期の和
TempSum = 0 #後半あまりの和
M=N-fir+1 # 先頭のぞく 
amari = M%T # 後半あまり
for k in dic:
    if dic[k]>=fir and dic[k]<=temp:
        Tsum+=k
    if dic[k]>=fir and dic[k]<fir+amari:
        TempSum += k
ans+=TempSum
ans+=Tsum*(M//T-1)
print(ans)

Fixed submission:
from collections import defaultdict
dic = defaultdict(int)
N, X, M = map(int, input().split())
A = [X]
ans = X
fir = -1
if N>1:
    temp = 1
    dic[X]=temp
    for i in range(2, N+1):
        a = A[-1]*A[-1]%M
        if dic[a]>0:
            fir = dic[a]
            break
        A.append(a)
        ans+=a
        temp+=1
        dic[a]=temp
    if fir!=-1:
        T = temp-fir+1#周期
        Tsum = 0 #周期の和
        TempSum = 0 #後半あまりの和
        M=N-fir+1 # 先頭のぞく 
        amari = M%T # 後半あまり
        for k in dic:
            if dic[k]>=fir and dic[k]<=temp:
                Tsum+=k
            if dic[k]>=fir and dic[k]<fir+amari:
                TempSum += k
        ans+=TempSum
        ans+=Tsum*(M//T-1)
    print(ans)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(list)
inf = 10**6
N = int(input())
l = []
z = []
xma, xmi, yma, ymi = 0, inf, 0, inf
for _ in range(N):
    x, y = map(int, input().split())
    xma = max(xma, x)
    yma = max(yma, y)
    xmi = min(xmi, x)
    ymi = min(ymi, y)
    l.append([x, y])
    z.append(x+y)
z.sort()
ans = z[-1]-z[0]

for t in l:
    a = t[0]+t[1]
    dic[a].append(t)
for u in dic:
    dic[u].sort()
    b = dic[u][-1][0]-dic[u][0][0]
    ans = max(2*b,ans)
    
l1, l2, l3, l4 = [], [], [], []
for k in l:
    if k[0]==xma:
        l1.append([k[1], k[0]])
    elif k[1]==yma:
        l2.append([k[0], k[1]])
    elif k[0]==xmi:
        l3.append([k[1], k[0]])
    elif k[1]==ymi:
        l4.append([k[0], k[1]])
l1.sort()
l2.sort()
l3.sort()
l4.sort()
print(xma, xmi, yma, ymi)
print(l1, l2, l3, l4)
ans = max(ans, abs(l1[0][1]-l3[-1][1])+abs(l1[0][0]-l3[-1][0]))
ans = max(ans, abs(l1[-1][1]-l3[0][1])+abs(l1[-1][0]-l3[0][0]))
ans = max(ans, abs(l2[0][1]-l4[-1][1])+abs(l2[0][0]-l4[-1][0]))
ans = max(ans, abs(l2[-1][1]-l4[0][1])+abs(l2[-1][0]-l4[0][0]))

print(ans)

Fixed submission:
N = int(input())
z = []
zz = []
for _ in range(N):
    x, y = map(int, input().split())
    zz.append(x-y)
    z.append(x+y)
z.sort()
zz.sort()
ans = z[-1]-z[0]
ans = max(ans, zz[-1]-zz[0])

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(list)
inf = 10**6
N = int(input())
l = []
z = []
xma, xmi, yma, ymi = 0, inf, 0, inf
for _ in range(N):
    x, y = map(int, input().split())
    xma = max(xma, x)
    yma = max(yma, y)
    xmi = min(xmi, x)
    ymi = min(ymi, y)
    l.append([x, y])
    z.append(x+y)
z.sort()
ans = z[-1]-z[0]

for t in l:
    a = t[0]+t[1]
    dic[a].append(t)
for u in dic:
    dic[u].sort()
    b = dic[u][-1][0]-dic[u][0][0]
    ans = max(2*b,ans)
    
l1, l2, l3, l4 = [], [], [], []
for k in l:
    if k[0]==xma:
        l1.append([k[1], k[0]])
    elif k[0]==yma:
        l2.append([k[0], k[1]])
    elif k[1]==xmi:
        l3.append([k[1], k[0]])
    elif k[1]==ymi:
        l4.append([k[0], k[1]])
l1.sort()
l2.sort()
l3.sort()
l4.sort()
       
ans = max(ans, abs(l1[0][1]-l3[-1][1])+abs(l1[0][0]-l3[-1][0]))
ans = max(ans, abs(l1[-1][1]-l3[0][1])+abs(l1[-1][0]-l3[0][0]))
ans = max(ans, abs(l2[0][1]-l4[-1][1])+abs(l2[0][0]-l4[-1][0]))
ans = max(ans, abs(l2[-1][1]-l4[0][1])+abs(l2[-1][0]-l4[0][0]))

print(ans)

Fixed submission:
N = int(input())
z = []
zz = []
for _ in range(N):
    x, y = map(int, input().split())
    zz.append(x-y)
    z.append(x+y)
z.sort()
zz.sort()
ans = z[-1]-z[0]
ans = max(ans, zz[-1]-zz[0])

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
ans = 1001
if len(s)-len(t)==0:
    temp = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            temp+=1
    ans = min(ans, temp)
else:
    for i in range(len(s)-len(t)):
        temp = 0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                temp+=1
        ans = min(ans, temp)
print(ans)

Fixed submission:
s = input()
t = input()
ans = 1001
if len(s)-len(t)==0:
    temp = 0
    for j in range(len(t)):
        if s[j]!=t[j]:
            temp+=1
    ans = min(ans, temp)
else:
    for i in range(len(s)-len(t)):
        temp = 0
        for j in range(len(t)):
            if s[i+j]!=t[j]:
                temp+=1
        ans = min(ans, temp)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
A = list(map(int, input().split()))
ans1 = "pairwise coprime"
ans2 = "setwise coprime"
ans3 = "not coprime"

def func(number):
    factor = []
    div = 2
    s = math.sqrt(number)
    while div < s:
        div_cnt = 0
        while number % div == 0:
            div_cnt += 1
            number //= div
        if div_cnt != 0:
            factor.append(div)
        div += 1
    if number > 1:
        factor.append(number)
        
    return set(factor)

a = math.gcd(A[0], A[1])
for i in range(2, N):
    a = math.gcd(a, A[i])

if a==1:
    b = True
    l = func(A[0])
    for i in range(1, N):
        
        if l&func(A[i])==set():
            l=l|func(A[i])
        else:
            b=False
            break
    if b:
        print(ans1)
    else:
        print(ans2)
        
        
    
else:
    print(ans3)



Fixed submission:
import math
N = int(input())
A = list(map(int, input().split()))
ans1 = "pairwise coprime"
ans2 = "setwise coprime"
ans3 = "not coprime"

a = math.gcd(A[0], A[1])
for i in range(2, N):
    a = math.gcd(a, A[i])

if a==1:
    b = True
    l = [0]*(10**6+1)
    x = [0]*(10**6+1)
    x[0]=1
    x[1]=1
    for i in range(2, 10**6+1):
        if x[i]==0:
            for j in range(i, 10**6+1, i):
                x[j]=i

    for y in A:
        s=set()
        if y==1:
            continue
        elif y==x[y]:
            s |= {y}        #素因数のリスト
        else:
            while y!=x[y]: #素数になるまで
                s|={x[y]}  
                y//=x[y]
                if y==x[y]:
                    s|={x[y]}
                    break
        for i in s:
            l[i]+=1
            if l[i]>=2:
                b=False
                break
                
        
    if b:
        print(ans1)
    else:
        print(ans2)
        
        
    
else:
    print(ans3)
Buggy python submission (verdict: Time Limit Exceeded):
R, C, K = map(int, input().split())
dp = [[[0]*4 for _ in range(R+1)] for _ in range(C+1)]
val = [[0]*(R+1) for _ in range(C+1)]

for i in range(K):
    r, c, v = map(int, input().split())
    val[c][r] = v

for i in range(1, C+1):
    for j in range(1, R+1):
        dp[i][j][0] = max(max(dp[i][j-1]), dp[i-1][j][0])
        if val[i][j]>0:
            dp[i][j][1] = max(dp[i-1][j][0]+val[i][j], dp[i-1][j][1], max(dp[i][j-1])+val[i][j])
            dp[i][j][2] = max(dp[i-1][j][1]+val[i][j], dp[i-1][j][2])
            dp[i][j][3] = max(dp[i-1][j][2]+val[i][j], dp[i-1][j][3])
        else:
            dp[i][j][1] = dp[i-1][j][1]
            dp[i][j][2] = dp[i-1][j][2]
            dp[i][j][3] = dp[i-1][j][3]           
#print(dp)
print(max(dp[-1][-1]))

Fixed submission:
R, C, K = map(int, input().split())
dp0 = [[0]*(R+1) for _ in range(C+1)]
dp1 = [[0]*(R+1) for _ in range(C+1)]
dp2 = [[0]*(R+1) for _ in range(C+1)]
dp3 = [[0]*(R+1) for _ in range(C+1)]
val = [[0]*(R+1) for _ in range(C+1)]

for i in range(K):
    r, c, v = map(int, input().split())
    val[c][r] = v

for i in range(1, C+1):
    for j in range(1, R+1):
        temp = max(dp0[i][j-1], dp1[i][j-1])
        temp = max(dp2[i][j-1], temp)
        temp = max(dp3[i][j-1], temp)
        dp0[i][j] = max(temp, dp0[i-1][j])
        if val[i][j]>0:
            dp1[i][j] = max(dp0[i-1][j]+val[i][j], dp1[i-1][j],temp+val[i][j])
            dp2[i][j] = max(dp1[i-1][j]+val[i][j], dp2[i-1][j])
            dp3[i][j] = max(dp2[i-1][j]+val[i][j], dp3[i-1][j])
        else:
            dp1[i][j] = dp1[i-1][j]
            dp2[i][j] = dp2[i-1][j]
            dp3[i][j] = dp3[i-1][j]

print(max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1],dp3[-1][-1]))
Buggy python submission (verdict: Runtime Error):
D = int(input())
C = list(map(int, input().split()))
S = []
con= 0
for _ in range(D):
    S.append(list(map(int, input().split())))
t = [-1]*D
best = [0]*D
last = [0]*26

for i in range(D-4):#1日ごと
    
    score = [-1]*26
    
    for x in range(26):#どの問題を選ぶか
        if i==0:
            con = 0
        else:
            con = best[i-1]
        
        con += S[i][x]
        #last[x] = i+1
        for j in range(26): #減少量の計算 #問題ごと
            if not j==x:
                con -= C[j]*(i-last[j]+1)

        score[x]=con
    m = -100000
    ii = 0
    for k in range(26):
        if m<score[k]:
            m=score[k]
            ii=k
    
    last[ii]=i+1
    best[i]=score[ii]
    t[i]=ii+1



p2 = [0]*(26**2)
for i in range(26):
    for j in range(26):
        #print(i*26+j)
        p2[i*26+j]+=S[D-4][i]
        p2[i*26+j]+=S[D-3][j]
        for k in range(26):
            if not k==i:
                p2[i*26+j] -= C[k]*(25-last[k])
        for k in range(26):
            if not k==j:
                if k==i:
                    p2[i*26+j] -= C[k]*2
ma = 0
ind = 0
for h in range(26**2):
    if p2[h]>ma:
        ma=p2[h]
        ind = h
t[D-4]= h//26+1
t[D-3]=h%26+1
last[t[D-4]]=361
last[t[D-3]]=362



p2 = [0]*(26**2)
for i in range(26):
    for j in range(26):
        #print(i*26+j)
        p2[i*26+j]+=S[D-2][i]
        p2[i*26+j]+=S[D-1][j]
        for k in range(26):
            if not k==i:
                p2[i*26+j] -= C[k]*(25-last[k])
        for k in range(26):
            if not k==j:
                if k==i:
                    p2[i*26+j] -= C[k]*2
ma = 0
ind = 0
for h in range(26**2):
    if p2[h]>ma:
        ma=p2[h]
        ind = h
t[D-2]= h//26 +1
t[D-1]=h%26 +1
        
    
    
    
    
for i in range(D):
    print(t[i])
#print(best)



Fixed submission:
D = int(input())
C = list(map(int, input().split()))
S = []
con= 0
for _ in range(D):
    S.append(list(map(int, input().split())))
t = [-1]*D
best = [0]*D
last = [0]*26

for i in range(D):#1日ごと
    for x in range(26):#どの問題を選ぶか
        if i==0:
            con = 0
        else:
            con = best[i-1]
        
        con += S[i][x]
        last[x] = i+1
        for j in range(26): #減少量の計算 #問題ごと
            con -= C[j]*(i-last[j]+1)
            
        if con>best[i]:
            last[x]=i+1
            best[i]=con
            t[i]=x+1
            
#print(best)
for i in range(D):
  print(t[i])
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
#dp = [0]*10**7+1

def fac(n):
    arr = []
    temp = n
    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
ans = 1

for i in range(2, n+1):
    li = fac(i)
    #print(li)
    temp=1
    for j in li:
        temp*=j[-1]+1
    
    ans+=temp*i
print(ans)

Fixed submission:
n= int(input())
dp=[1]*n

for i in range(2, n+1):
    k=1
    while i*k<=n:
        dp[i*k-1]+=1
        k+=1
ans = 0
for i in range(1, n+1):
    ans+=i*dp[i-1]
print(ans)