TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
from fractions import gcd

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

agcd=gcd(a[0],a[1])
alcm=a[0]*a[1]//agcd
for i in range(n-2):
    agcd=gcd(alcm,a[i+2])
    alcm=alcm*a[i+2]//agcd
    
#print(alcm)
    
if 1==1:
    fmax=0
    for i in range(alcm):
        f=0
        for j in range(n):
            f=f+(i%a[j])
        if f>fmax:
            fmax=f
    print(fmax)


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

asum=0
for ai in a:
    asum+=(ai-1)
print(asum)


Verdicts: Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import numpy as np
from functools import reduce
from fractions import gcd

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

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

l = lcm(*A) 
print(((l-1) % A).sum())


# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr())
A -= 1
answer = A.sum()
print(answer)


Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N=input()
a=list(map(int,input().split()))
print(sum(a-1))



N=input()
a=list(map(int,input().split()))
print(sum([i-1 for i in a]))


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for k in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))





import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for i in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

print(ans_list)
ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))





import math

n = input()
a = input().split()
N = int(n)

ann = []
for i in range(N):
    ana = 1
    for j in range(i+1):
        ana = ana * int(a[j])
    ann.append(ana-1)

ans_list = []
for k in ann:
    ans = 0
    for j in range(N):
        ans += int(i % int(a[j]))
    ans_list.append(ans)

print(ans_list)
ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))





import math

n = input()
a = input().split()
N = int(n)

ans_list = []
ann = []
ana = 1
for j in range(N):
    ana = ana * int(a[j])
ana = ana -1
ans = 0
for k in range(N):
    ans += int(ana % int(a[k]))
ans_list.append(ans)

ans_list.sort()
ans_list.reverse()
print(str(ans_list[0]))







Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N = input()
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans += A[i]-1
print(ans)

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
  ans += A[i]-1
print(ans)


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

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

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

def lcm(a,b):
    return (a*b)//gcd(a,b)

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

ans2 = 0
for i in range(n):
    ans2 += ans%a[i]
print(ans2)

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

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

def lcm(a,b):
    return (a*b)//gcd(a,b)

ans = a[0]
for i in range(n-1):
    ans = lcm(ans,a[i+1])
ans-=1
ans2 = 0
for i in range(n):
    ans2 += ans%a[i]
    #print(ans2)
print(ans2)

Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import fraction
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)

def lcm(nums):
    return reduce(lcm_base, nums, 1)

n, a = input(), list(map(int, input().split()))
l = lcm(a)
sum = 0
for aa in a:
    sum += (l-1) % aa
print(sum)


from functools import reduce
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)


def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(nums):
    return reduce(lcm_base, nums, 1)

n, a = input(), list(map(int, input().split()))
l = lcm(a)
sum = 0
for aa in a:
    sum += (l-1) % aa
print(sum)


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import math

import math

n = int(input())
l = list(map(int,input().split()))

def lcm(a, b):
    return int(a * b / math.gcd(a, b))

llcm=1
for i in range(n):
    llcm= lcm(llcm,l[i])

c=0
for i in range(100000000000):
    c+=1

n = int(input())
l = list(map(int,input().split()))

cnt=0
f=0
for i in l:
    f += i-1
print(f)

Verdicts: Wrong Answer

Runtime Error

Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N = int(input())
a = [int(i) for i input().split()]
print(sum(a) - N)

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

print(sum(a) - N)


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

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

print(sum(s) - n)


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

print(sum(a) - n)


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in s))

n = int(input())
a = map(int, input().split())
print(sum(x-1 for x in a))


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
# C
from functools import reduce
from fractions import gcd
from functools import lru_cache

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

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

result = 0
mod = int(reduce(lcm, a))-1

for i in range(len(a)):
    result += mod % a[i] 

print(result)

# C
from functools import reduce
from fractions import gcd
from functools import lru_cache

@lru_cache(None)
def lcm(a, b):
    return int(a*b/gcd(a, b))

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

result = 0
mod = reduce(lcm, a)-1

for i in range(len(a)):
    result += mod % a[i] 

print(int(result))

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

print(sum(a) - n)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import fractions
from functools import reduce

def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)
def lcm_list(l):
    return reduce(lcm, l, 1)

n = int(input())
a = list(map(int, input().split()))
f = 0
for j in range(n):
    f += (lcm_list(a) - 1) % a[j]
print(f)


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 5 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 9 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(10 ** 8 // n):
    f = 0
    for j in range(n):
        f += i % a[j]
    print(f)
    ans.append(f)
print(max(ans))


n = int(input())
a = list(map(int, input().split()))
f = 0
ans = 0
for i in range(n):
    ans += a[i]
print(ans - n)


Verdicts: Time Limit Exceeded

Wrong Answer

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
7
994 518 941 851 647 2 581

n = int(input())                                                                                                                     
a = map(int, input().split())                                                                               
print(sum([aa-1 for aa in a]))                                                                                                        


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
def mode_max(N, arr):

    maximum = 0

    for i in range(1, 100001):

        current = 0

        for a in arr:

            current += i % a

        maximum = max(maximum, current)

    return maximum

n = int(input())

arr = [int(a) - 1 for a in input().split()]

print(sum(arr))

Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
# -*- coding: utf-8 -*-
import math
import operator
from functools import reduce
def gcd(a,b):
    c = 0
    while a != b:
        if a&1==b&1==0:
            a, b = a>>1, b>>1
            c += 1
        elif min(a,b) == 0:
            a = max(a,b)
        else:
            a, b = max(a,b)%min(a,b), min(a,b)
    return a*2**c


def lcm(a,b):
    return (a*b)//gcd(a,b)

def solve():
    N = int(input())
    *A, = map(int, input().split())
    m = reduce(lcm, A) - 1
    print(m)
    s = sum([m%a for a in A])

    return str(s)

if __name__ == '__main__':
    print(solve())

# -*- coding: utf-8 -*-
import math
import operator
from functools import reduce
def gcd(a,b):
    c = 0
    while a != b:
        if a&1==b&1==0:
            a, b = a>>1, b>>1
            c += 1
        elif min(a,b) == 0:
            a = max(a,b)
        else:
            a, b = max(a,b)%min(a,b), min(a,b)
    return a*2**c


def lcm(a,b):
    return (a*b)//gcd(a,b)

def solve():
    N = int(input())
    *A, = map(int, input().split())
    m = reduce(lcm, A) - 1
    s = sum([m%a for a in A])

    return str(s)

if __name__ == '__main__':
    print(solve())


Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split())
print(sum(a)-n)
        

         

n = int(input())
a = list(map(int,input().split()))
print(sum(a)-n)
        

         

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a = input().split(" ")

max = a[0]
for i in range(1,n) :
    if max < a[i] :
        max = a[i]

f = 0
for j in range(1,int(max)) :
    for d in range(0,n) :
        f[j] += j//a[d]

max1 = 0
for i in range(1,int(max)):
    if max1 < f[i] :
        max1 = f[i]

print(max1)

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

a.sort()

for m in range(0,int(a[n])) :
    for j in range(0,n) :
        f[m] += m//a[j]

f.sort()

print(f[n])

N = int(input())
a = [int(i) for i in input().split()]
print(sum(a)-N)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

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

saidai = 0
for i in range(min(A), Max(A)*2):
    cnt = 0
    for j in range(N):
        cnt += i%A[j]
    saidai = max(saidai, cnt)

print(saidai)

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

print(sum(A)-N)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
from fractions import gcd
from functools import reduce
def lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0

n = input()

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

mlcm = 1
for x in set(xs):
  mlcm = lcm(mlcm, x)

mlcm -= 1
mlcm = int(mlcm)
print(sum([ mlcm%x for x in xs]))

from fractions import gcd
def lcm(a,b): return abs(a * b)/gcd(a,b) if a and b else 0

n = input()

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

from functools import reduce

mlcm = int(reduce(lcm, xs))

mlcm -= 1
print(sum([ mlcm%x for x in xs]))

n = input()
xs = [int(x)-1 for x in input().split()]
print(sum(xs))

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = input()
arr = list(map(int, input().split()))

def f(m, a):
    return sum([m % i for i in a])

def gcd(a, b):
    while b > 0:
	if a < b: a, b = b, a
        r = a % b
	a = b
        b = r
    return a

lcm = arr[0]
for i in range(1, len(arr)):
    lcm = lcm * arr[i] // gcd(lcm, arr[i])


n = input()
arr = list(map(int, input().split()))

def f(m, a):
    return sum([m % i for i in a])

def gcd(a, b):
    while b > 0:
        if a < b: a, b = b, a
        r = a % b
        a = b
        b = r
    return a

lcm = arr[0]
for i in range(1, len(arr)):
    lcm = lcm * arr[i] // gcd(lcm, arr[i])

print(f(lcm -1, arr))


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N = int(input())
a = list(map(int,input().split()))

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

ans = 0

for i in range(N):
    ans += (lcm(a)-1)%a[i]
    
print(ans)

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

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

ans = 0
pi = 1

for i in range(N):
    pi *= a[i]

for i in range(N):
    ans += (pi-1)%a[i]
    
print(ans)

Verdicts: Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a=map(int, input().split())
print(sum(a) - len(a))

n = int(input())
a=list(map(int, input().split()))
print(sum(a) - len(a))

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
def gcd(x,y):
    x,y = max(x,y),min(x,y)
    while(y>0):
        x,y = y,x%y
    print(x)
def lcm(a,b):
    return(int(a*b/gcd(a,b)))

n = int(input())
a = list(map(int,input().split()))
least_common_multiple = 1
for i in range(n):
    least_common_multiple = lcm(least_common_multiple,a[i])
ans = 0
for i in range(n):
    ans += (least_common_multiple-1)%a[i]
print(ans)

import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))-1
print(a.sum())

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n=int(input())
a=list(int,input().split())
print(sum(a)-n)

n=int(input())
a=list(map(int,input().split()))
print(sum(a)-n)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import math
from functools import reduce
input()
ip = input().split()
data = []
for i in ip:
    data.append(int(i))

def lcmB(x,y):
    return x * y/math.gcd(int(x),int(y))

def lcm(num):
    return reduce(lcmB,num)

print(int(lcm(data) - 1))

input()
ip = input().split()
data = []
ans = 0
for i in ip:
    ans += int(i) - 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = input()
l = list(map(int,input().split()))
print(sum(l)-n)

n = input()
l = list(map,input().split())
print(sum(l)-n)

n = int(input())
l = list(map(int,input().split()))
print(sum(l)-n)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
from functools import reduce

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

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

def lcm_base(a, b):
  return a * b / gcd(a, b)

def lcm(n):
  return reduce(lcm_base, n)

f = 0
for i in a:
  f += lcm(a) - 1 % i

print(int(f))


from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(n):
    return reduce(lcm, n)


n = int(input())
a = list(map(int, input().split()))
m = lcm_list(a) - 1
ans = 0
for i in range(n):
    ans += m % a[i]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))


def f(m):
    return np.sum(np.mod(alist, m))


max_num = 0
for m in range(1, np.max(alist)):
    num = f(m)
    if num > max_num:
        max_num = num

print(max_num - N)


import numpy as np
N = int(input())
alist = np.array(list(map(int, input().split())))
print(np.sum(alist - 1))


Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
# ans

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

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

ans = 0

for m in range(2, 10000000):
  s = 0
  for i in range(N):
    s += m % a[i]
  ans = max(s, ans)
  
print(ans)

N = int(input())
a = list(map(int, input().split()))
print(sum(a) - N)

Verdicts: Runtime Error

Time Limit Exceeded

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import sys
readline = sys.stdin.readline
n = int(readline())
print(sum([int(i) for i in readline().split()] - n)

import sys
readline = sys.stdin.readline
n = int(readline())
print(sum([int(i) for i in readline().split()]) - n)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
a = ai()
x = lma()
print(sum(x)-a)

def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a = ai()
x = lma()
print(sum(x)-a)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):

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

ans = 0
for aa in a:
    ans+=a-1
    
print(ans)


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

ans = 0
for aa in a:
    ans+=aa-1
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n,a=open(0);print(eval(a.replace(" ","+")+"-"+n[:-1]))

n,a=open(0);print(eval(a.replace(" ","+")+"-"+n))

print(-int(input())+sum(map(int,input().split())))

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
7
994 518 941 851 647 2 581


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

ans = 0
for a in ai:
    ans += a - 1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
print(-int(input())+sum(map(input().split(),int)))

N = int(input())
A = [int(_) for _ in input().split()]
print(sum(A) - N)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
from functools import reduce
import fractions
N = int(input())
t = tuple(map(int,input().split()))

def lcm(x,y):
  return x*y/fractions.gcd(x,y)

m=reduce(lcm, t)-1
ans=0
for i in t:
  ans+=m%i
print(int(ans))

from functools import reduce
import fractions
N = int(input())
t = tuple(map(int,input().split()))

def lcm(x,y):
  return x*y/fractions.gcd(x,y)

m=reduce(lcm, t)-1
ans=0
for i in t:
  ans+=m%i
print(ans)

N = int(input())
t = tuple(map(int,input().split()))
ans=0
for i in t:
  ans+=i-1
print(ans)

Verdicts: Time Limit Exceeded

Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a = (int(i) for i in input().split())
print(sum(a)-len(a))

N = int(input())
a = list(map(int, input().split()))
print(sum(a)-N)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import sys


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a


def lcm(a, b):
  return a*b/gcd(a, b)

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

lcm_num = lcm(a[0], a[1])

for i in range(2, n):
    lcm_num = lcm(lcm_num, a[i])

ans = 0
for i in range(n):
    ans += (lcm_num-1) % a[i]

print(int(ans))
  


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


# 



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

print(int(ans))
  


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
a = list(map(int,input().split()))
x = min(3000,gcd(a[i] for i in range(n)))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))


n = int(input())
a = list(map(int,input().split()))
x = min(3000,reduce(gcd,_ for _ in a))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))

n = int(input())
a = list(map(int,input().split()))
x = min(3000,gcd(_ for _ in a))
m = [0]*x

for i in range(x):
    for j in a:
        m[i] += m%j

print(max(m))

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

print(sum(a)-n)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n=int(input())
L=[list(map(int, input().split())) for i in range(D)]
print(sum(L)-n)

n=int(input())
L=list(map(int, input().split()))
print(sum(L)-n)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N=int(input)
print(sum(list(map(int, input().split())))-N)

N=int(input())
print(sum(list(map(int, input().split())))-N)


Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input())
ns = map(int, input().split())
print(sum(ns)-len(ns))

n = int(input())
ns = list(map(int, input().split()))
print(sum(ns)-len(ns))

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
N = int(input())
ANs = list(map(int,input().split()))
 
def lcm_base(x, y):
	return (x * y) // gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)
 
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

N = int(input())
ANs = list(map(int,input().split()))
 
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
 
def lcm_base(x, y):
	return (x * y) // gcd(x, y)
	
lcmNum = ANs[0]
for a in ANs[1:]:
	lcmNum = lcm_base(lcmNum,a)
	
#print(lcmNum)
 
f = 0
for a in ANs:
	f += (lcmNum-1)%a
print(f)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    A=list(map(int,input().split()))
    maxMod=max(A)
    for a in range(maxMod*2):
        total=0
        for b in range(n):
            mod=A[b]
            total+=a%mod
        print(total)
main()

# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    A=list(map(int,input().split()))
    total=0
    m=1
    for a in A:
        m*=a
    m-=1
    for a in range(n):
        mod=A[a]
        total+=m%mod
    print(total)
main()

Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))

input()
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a, b):
	return a * b // gcd (a, b)
li  = list(map(int,input().split(" ")))
s  = lcm(li[0],li[1])
for i in range(len(li)-2):
    s = lcm (s,li[i+2])
def f(m):
    r = 0
    for i  in li:
        r += m%i
    return r
print(f(s-1))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

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

lst.sort(reverse=True)
print(abs(lst[0] - lst[1]) + abs(lst[1] - lst[2]))

N = int(input())

lst = list(map(int, input().split()))

sum = 0
for i in lst:
  sum += i-1
print(sum)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n=input()
box=[int(input())-1 for i in range(int(n))]
print(sum(box))

print(-int(input())+sum(map(int,input().split())))

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
sa = list(map(int,input().split()))
ans = 0
for i in sa:
    ans += (i-1)
print(ans)

aaa = input()
sa = list(map(int,input().split()))
ans = 0
for i in sa:
    ans += (i-1)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):

コンテスト時間: 2018-07-21(土) 21:00 ~ 2018-07-21(土) 22:40 (100分)AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出結果
 順位表
 バーチャル順位表
 コードテスト
 解説
コードテスト
言語

ソースコード
)
1
N = int(input())
2
a = list(map(int, input().split()))
3
a.sort(reverse=True)
4
​
5

6
ans = 0
7
val1, val2 = a[0], a[1]
8
while 1:
9
  if val1 % val2 == 0:
10
    ans = a[0]*a[1]/val2
11
    break
12
  else:
13
    tmp = val2
14
    val2 = val1 % val2
15
    val1 = tmp
16
​
17
for i in range(2, N):
18
  val1, val2 = ans, a[i]
19
  while 1:
20
    if val1 % val2 == 0:
21
      ans = ans*a[i]/val2
22
      break
23
    else:
24
      tmp = val2
25
      val2 = val1 % val2
26
      val1 = tmp
27
​
28
f_ans = 0
29
for i in range(N):
30
  f_ans += (ans-1)%a[i]
31
print(int(f_ans))
32
  
33
      
34
  
※ 512 KiB まで
※ ソースコードは「Main.拡張子」で保存されます

  
標準入力
7
994 518 941 851 647 2 581
※ 512 KiB まで

終了コード	0
実行時間	17 ms
メモリ	2964 KB
標準出力
4527

標準エラー出力
FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights reserved.

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

ans = 0
for i in range(N):
  ans += a[i]-1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
import numpy as np

n = int(input())

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

x = np.gcd.reduce(a)-1

ans = 0

for i in a:
    ans += x%a
    
print(ans)


n = int(input())

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

print(sum(a)-n)


Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

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

from functools import reduce

def gcd(a, b):
    while b:
      a, b = b, a % b
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

N = input()
a_list = map(int, input().split())

m = lcm(list(a_list)) - 1
fm = 0

for i in a_list:
    fm = fm+(m%i)

print(fm)

# -*- coding:utf-8 -*-

from functools import reduce

def gcd(a, b):
    while b:
      a, b = b, a % b
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

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

m = lcm(a_list) - 1
fm = 0

for i in a_list:
    fm = fm+(m % i)

print(fm)

Verdicts: Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n = int(input().strip())
data = list(map(int, input().split())
print (sum(data) - n)

n = int(input().strip())
data = list(map(int, input().split()))

print (sum(data) - n)

Verdicts: Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = lis(map(int, input().split()))

    main(n, a)


def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = [int(input()) for _ in range(n)]

    main(n, a)


def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
from functools import reduce
from operators import mul

n = int(input())
a = list(map(int, input().strip()))

m = reduce(mul, a) - 1
ans = 0
for ai in a:
  ans += mul % ai

print(ans)


from functools import reduce
from operators import mul
 
n = int(input())
a = list(map(int, input().strip()))
 
m = reduce(mul, a) - 1
ans = 0
for ai in a:
  ans += m % ai
 
print(ans)


from functools import reduce
from operator import mul
n = int(input())
a = list(map(int, input().split()))

m = reduce(mul, a) - 1
ans = 0
for ai in a:
    ans += m % ai
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
print(sum([a-1 int(s) for s in input().split()])

N = input()

print(sum([int(s) for s in input().split()]))

N = input()

print(sum([int(s)-1 for s in input().split()]))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: You are given N positive integers a_1, a_2, ..., a_N.  For a non-negative integer m, let f(m) = (m\ mod\ a_1) + (m\ mod\ a_2) + ... + (m\ mod\ a_N).  Here, X\ mod\ Y denotes the remainder of the division of X by Y.  Find the maximum value of f.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return gcd(b,a)
    if b==0:
        return(a)
    else:
        return gcd(a,a%b)
g=A[0]
seki=A[0]
for i in range(1,n):
    g=gcd(g,A[i])
    seki*=A[i]
lcm=seki//(g**(n-1))

cnt=0
for j in range(n):
    cnt += (lcm-1) % A[j]
print(cnt)

n=int(input())
A=list(map(int,input().split()))
def gcd(a,b):
    if b>a:
        return gcd(b,a)
    if b==0:
        return(a)
    else:
        return gcd(b,a%b)
g=A[0]
seki=A[0]
for i in range(1,n):
    g=gcd(g,A[i])
    seki*=A[i]
lcm=seki//(g**(n-1))
cnt=0
for j in range(n):
    cnt += (lcm-1) % A[j]
print(cnt)

Verdicts: Wrong Answer

Accepted
Problem: There are N islands lining up from west to east, connected by N-1 bridges.  The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.  One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:  Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.  You decided to remove some bridges to meet all these M requests.  Find the minimum number of bridges that must be removed.

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


S = [[0 for j in range(2)] for i in range(M)]

for i in range(M):
    X,L=map(int,input().split())
    S[i][0]=X
    S[i][1]=L


T=sorted(S,key=lambda x:x[1])




count=1
last=T[0][1]
print(T)
for i in range(1,M):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)



N,M=map(int,input().split())


S = [[0 for j in range(2)] for i in range(M)]

for i in range(M):
    X,L=map(int,input().split())
    S[i][0]=X
    S[i][1]=L


T=sorted(S,key=lambda x:x[1])




count=1
last=T[0][1]
#print(T)
for i in range(1,M):
    if T[i][0]>=last:
        count+=1
        last=T[i][1]
print(count)



Verdicts: Wrong Answer

Accepted
Problem: There are N islands lining up from west to east, connected by N-1 bridges.  The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.  One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:  Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.  You decided to remove some bridges to meet all these M requests.  Find the minimum number of bridges that must be removed.

Submission attempts (in order):
import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache




n,k=map(int,input().split())
A=list(map(int,input().split()))
#n,k=5,3
#A=[-30,-10,10,20,40]
ans=inf
for i in range(n-k+1):
    ans=min(ans, abs(A[i])+abs(A[i]-A[i+k-1]), abs(A[i+k-1])+abs(A[i+k-1]-A[i]) )
print(ans)

n,m=map(int,input().split())
A=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1 ;b-=1
    A.append([a,b])

A=sorted(A, key=lambda x:x[1])
ans=0
last=-5000
for l in A:
    #print(a,b)
    if last<l[0]:
        ans+=1
        last=l[1]-1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: There are N islands lining up from west to east, connected by N-1 bridges.  The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.  One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:  Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.  You decided to remove some bridges to meet all these M requests.  Find the minimum number of bridges that must be removed.

Submission attempts (in order):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,m=MI()
lis=[]
for i in range(m):
    lis.append(LI())
lis.sort(key=lambda x:x[1])
print(lis)
bri=0
count=0
for i in range(m):
    if bri<=lis[i][0]:
        bri=lis[i][1]
        count+=1
        
print(count)

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()
n,m=MI()
lis=[]
for i in range(m):
    lis.append(LI())
lis.sort(key=lambda x:x[1])
#print(lis)
bri=0
count=0
for i in range(m):
    if bri<=lis[i][0]:
        bri=lis[i][1]
        count+=1
        
print(count)

Verdicts: Wrong Answer

Accepted
Problem: There are N islands lining up from west to east, connected by N-1 bridges.  The i-th bridge connects the i-th island from the west and the (i+1)-th island from the west.  One day, disputes took place between some islands, and there were M requests from the inhabitants of the islands:  Request i: A dispute took place between the a_i-th island from the west and the b_i-th island from the west. Please make traveling between these islands with bridges impossible.  You decided to remove some bridges to meet all these M requests.  Find the minimum number of bridges that must be removed.

Submission attempts (in order):
n, m = map(int, input().split())
wars = {}
for i in range(m):
  a, b = map(int, input().split())
  if a in frontiers.keys():
    frontiers[a] = min(frontiers[a], b)
  else:
    wars[a] = b

cuts = 0
frontier = 10**6

for i in range(1, n):
  if i in frontiers.keys():
    antis = min(frontier, wars[i])
  if i + 1 == frontier:
    cuts += 1
    frontier = 10**6
    
print(cuts)


n, m = map(int, input().split())
frontiers = {}
for i in range(m):
  a, b = map(int, input().split())
  if a in frontiers.keys():
    frontiers[a] = min(frontiers[a], b)
  else:
    frontiers[a] = b

cuts = 0
frontier = 10**6

for i in range(1, n):
  if i in frontiers.keys():
    frontier = min(frontier, frontiers[i])
  if i + 1 == frontier:
    cuts += 1
    frontier = 10**6
    
print(cuts)


Verdicts: Runtime Error

Accepted