Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03003 (python)

Fixed submission:
N,M=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
mod=1000000007

dp=[[0 for j in range(M+1)] for i in range(N+1)]
Sum=[[0 for j in range(M+1)] for i in range(N+1)]

for i in range(1,N+1):
	for j in range(1,M+1):
		if S[i-1]==T[j-1]:
			dp[i][j]=Sum[i-1][j-1]
#			for k in range(1,i):
#				for l in range(1,j):
#					dp[i][j]+=dp[k][l]
			dp[i][j]+=1
		Sum[i][j]=(Sum[i-1][j]+Sum[i][j-1]-Sum[i-1][j-1]+dp[i][j])%mod

print(Sum[N][M]+1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
mod=1_000_000_007

dp=[[0 for j in range(M)] for i in range(N)]

for i in range(N):
	for j in range(M):
		if S[i]==T[j]:
			for k in range(i):
				for l in range(j):
					dp[i][j]+=dp[k][l]
			dp[i][j]+=1

ans=1
for i in range(N):
	for j in range(M):
		ans+=dp[i][j]
		ans%=mod

print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
S=list(map(int,input().split()))
T=list(map(int,input().split()))
mod=1_000_000_007

dp=[[0 for j in range(M)] for i in range(N)]

for i in range(N):
	for j in range(M):
		if S[i]==T[j]:
			for k in range(i):
				for l in range(j):
					dp[i][j]+=dp[k][l]
			dp[i][j]+=1

ans=1
for i in range(N):
	for j in range(M):
		ans+=dp[i][j]
		ans%=mod

print(ans)
Problem p02759 (python)

Fixed submission:
#!/usr/bin/env python3
N = int(input())
print((N + 1) // 2)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
def func(a, i):
    return {a[0]:i, a[1]:i+1, a[2]:i+2}
A = {}
for i in range(3):
    A.update(func(input().split(), 3*i))
N = int(input())
b = [A.get(input(), -1) for _ in range(N)]
bingo = [[0, 1, 2], [3, 4, 5], [6, 7, 8],
         [0, 3, 6], [1, 4, 7], [2, 5, 8],
         [0, 4, 8], [2, 4, 6]]
for i in bingo:
    if set(i) <= set(b):
        print("Yes")
        break
else:
    print("No")
Problem p02790 (python)

Fixed submission:
#!/usr/bin/env python3
a, b = input().split(" ")
A = a * int(b)
B = b * int(a)
print(sorted([A, B])[0])

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
a, b = input().split(" ")
for i in range(a):
    a += a
for i in range(b):
    b += b
print(sorted([a, b])[0])
Problem p02793 (python)

Fixed submission:
#!/usr/bin/env python3
from fractions import gcd
N = input()
A = list(map(int, input().split(" ")))
def lcm(x, y):
    return (x * y) // gcd(x, y)
tmp = 1
for i in A:
    tmp = lcm(tmp, i)
print(sum([tmp // i for i in A]) % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
from fractions import gcd
N = input()
A = list(map(int, input().split(" ")))
def lcm(x, y):
    return (x * y) // gcd(x, y)
tmp = 1
for i in A:
    tmp = lcm(tmp, i)
print(int(sum([tmp / i for i in A]) % (10**9 + 7)))
Problem p02951 (python)

Fixed submission:
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
if C-(A-B) >= 0:
    print(C-(A-B))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
youki1 = B
youki2 = C
youki21 = A-B
youki2 = youki2 - youki21
print(youki2)a = input().split()
A = int(a[0])
B = int(a[1])
C = int(a[2])
print(C-(A-B))
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a)
for _ in range(m):
  tmp_min = heapq.heappop(a)
  heapq.heappush(a, (-1)*(-tmp_min//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import bisect
n,m=map(int,input().split())
a=list(map(int, input().split()))
if len(a)==1:
  print(int(a[0]/(2**m)))
  exit(0)
a=sorted(a)
while 0<m:
  x=a.pop(-1)
  y=x//a[-1]
  if y>m:
    y=m
  x=int(x/(2**y))
  bisect.insort_right(a, x)
  m-=y
print(sum(a))
Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
def f(x,y):
  return nCr_mod(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
mod=10**9+7
com=[]
def comb(n=10):
  def c(n,k): 
    return 1 if(k<=0 or n<=k) else c(n-1, k-1) + c(n-1, k)
  for i in range(n):
      com.append([c(i,j) for j in range(i+1)])
def nCr(n,r):
    return com[n][r]
comb()
def f(x,y):
  return nCr(x-1,y-1)
r=n-k+2
for i in range(1,k+1):
  bule=f(k,i)
  red=f(r,i+1)
  print((bule*red)%mod)
Problem p02834 (python)

Fixed submission:
import sys

sys.setrecursionlimit(200000)
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]

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

def tdfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        distt[to] = distt[x] + 1
        tdfs(to, x)

def adfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        dista[to] = dista[x] + 1
        adfs(to, x)

tdfs(u)
adfs(v)
ans = 0

for i in range(1, n+1):
    if distt[i] >= dista[i]:continue
    l = distt[i]
    k = dista[i] - distt[i]
    ans = max(ans, k - 1 + l)

print(ans)

Buggy submission (verdict: Runtime Error):
n,u,v = map(int,input().split())
edge = [[] for i in range(n+1)]
distt = [0 for i in range(n+1)]
dista = [0 for i in range(n+1)]

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

def tdfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        distt[to] = distt[x] + 1
        tdfs(to, x)

def adfs(x, last = -1):
    for to in edge[x]:
        if(to == last):continue
        dista[to] = dista[x] + 1
        adfs(to, x)

tdfs(u)
adfs(v)
ans = 0

for i in range(1, n+1):
    if distt[i] >= dista[i]:continue
    l = distt[i]
    k = dista[i] - distt[i]
    ans = max(ans, k - 1 + l)

print(ans)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())
if a >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = string(input())
if a >= 3200:
  print(s)
else:
  print('red')
Problem p02773 (python)

Fixed submission:
import collections
from collections import Counter

n = int(input())
ls = [input() for i in range(n)]    
c = Counter(ls).most_common()

count = c[0][1]
ans = []

for i in range(len(c)):
    if c[i][1] == count:
        ans.append(c[i][0])
    else:
        break   
ans = sorted(ans)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            ans.append(p[i][0])
        else:
            break   
    ans = sorted(ans
    for i in ans:
      print(i)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
ls = [input() for i in range(n)]    
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
if c.most_common()[0][1] == 1:
    ls.sort()
    for i in ls:
        print(i)
else:
    c.sort()
    for i in range(len(c)):
        p = c.most_common()
        if p[i][1] == count:
            print(p[i][0])
        else:
            break
Problem p02793 (python)

Fixed submission:
import fractions
N = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
count = 0
for i in a:
    count += ans//i
print(count%(10**9+7))

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
max_a = max(a)
min_a = min(a)
ab = 0

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

if max_a % 2 == 0:
    for i in range(n):
        if a[i] % 2 == 1:
            ab = (lcm(a[i+1], a[i]))
            break
else:
    ab = (lcm(max_a, min_[i]))
    
if ab == 0:
    print(n)
else:   
    ans = 0
    for i in a:
        ans += ab//i

    print(ans)
Problem p02820 (python)

Fixed submission:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = []
for i in range(n):
    if t[i] == "r":
        if len(ls) >= k:
            if ls[-k] != "r":
                ans += p
                ls.append("r")
            else:
                ls.append("x")
        else:
            ans += p
            ls.append("r")
    elif t[i] == "s":
        if len(ls) >= k:
            if ls[-k] != "s":
                ans += r
                ls.append("s")
            else:
                ls.append("x")
        else:
            ans += r
            ls.append("s")
    else:
        if len(ls) >= k:
            if ls[-k] != "p":
                ans += s
                ls.append("p")
            else:
                ls.append("x")
        else:
            ans += s
            ls.append("p")
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
ans = 0
ls = list
for i in range(k):
    if t[i] == "r":
        ls.append("p")
        ans += p
    elif t[i] == "s":
        ls.append("r")
        ans += r
    elif t[i] == "p":
        ls.append("s")
        ans += s
        
for i in range(n):
        if ls[-k] != "r":
            ans += p
            ls.append("p")
        else:
            ls.append("x")
    elif t[i] == "s":
        if ls[-k] != "s":
            ans += r
            ls.append("r")
        else:
            ls.append("x")
    else:
        if ls[-k] != "p":
            ans += s
            ls.append("s")
        else:
            ls.append("x")
print(ans)
Problem p02831 (python)

Fixed submission:
import math
import fractions

a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02881 (python)

Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

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)

    #divisors.sort()
    return divisors

n = int(input())

if is_prime(n) == True:
    print(n-1)
else:
    ls = (make_divisors(n))
    if (n / ls[-1]) == ls[-1]:
        print(ls[-1]+ls[-1]-2)
    else:
        print(ls[-1]+ls[-2]-2)

Buggy submission (verdict: Runtime Error):
ls = []

n = int(input())

if n % 2 != 0:
    print(n-1)
else:
    for i in range(1,round(n/2)):
        if n % i == 0:
            ls.append(i)
        
        
    length = len(ls)
    ans = ls[length-1]
    ans2 = (round(n/ans))
    print(ans+ans2-2)
Problem p02912 (python)

Fixed submission:
import math
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
import math
n,m = map(int,input().split())
a = list(map(lambda x: -int(x),input().split()))
print(a)
heapq.heapify(a)
for i in range(m):
    a_max = heapq.heappop(a)
    heapq.heappush(a,-(-a_max//2))
print(-sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)

if n == 1:
    print(a[0]//(2**m))
else:
    for i in range(m):
        if m < 1:
            a[0] = a[0]//(2**y)
            break
        else:
            a[a.index(max(a))] = a[a.index(max(a))]//(2**y)
            m -= 1
    
    print(sum(a))
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n*n*n)

Buggy submission (verdict: Runtime Error):
n = int(input())
b = list(map(int,input().split()))
ans = 0

for i in range(n-2):
    ans += min(b[i],b[i+1])  

if n == 2:
    print(min(b)*2)
else:
    print(ans+b[-1]+min(b))
Problem p03242 (python)

Fixed submission:
s = list(input())
for i in range(len(s)):
    if s[i] == "9":
        s[i] = "1"
    elif s[i] == "1":
        s[i] = "9"
for i in s:
    print(i,end="")

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
  if ls[i] == "9":
    ls[i] = "1"
  elif ls[i] == "1":
    ls[i] = "9":
for i in s:
  print(i,end="")

Buggy submission (verdict: Runtime Error):
s = list(input())
for i in s:
  if i == 9:
    i = 1
  elif i == 1:
    i = 9:
for i in s:
  print(i,end="")
Problem p03835 (python)

Fixed submission:
k,s = map(int,input().split())
n = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if z <= k and z >= 0 and x+y+z==s:
            n += 1
print(n)

Buggy submission (verdict: Runtime Error):
k,s = map(int,input().split())
n = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-(x+y)
        if z <= k and z > 0=:
            if x+y+z==s:
                n += 1
                
print(n)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
print(int(a)*int(b[0]+b[2]+b[3])//100)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=float(input())
a*=int(b*100)
print(int(a/100))

Buggy submission (verdict: Runtime Error):
a=int(input())
b=float(input())
a*=int(b*100)
print(int(a/100))
Problem p03317 (python)

Fixed submission:
n,k,*_=map(int,open(0).read().split())
print(0--~-n//~-k)

Buggy submission (verdict: Runtime Error):
n,k=int(input().split());print(0--~-n//~-k)

Buggy submission (verdict: Runtime Error):
n,k=map(int,open(0).split())
print(0--~-n//~-k)

Buggy submission (verdict: Runtime Error):
a,b=int(input())
for x in input().split():
  print(x)
Problem p02762 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n, m, k = input().strip().split()
n, m, k = int(n), int(m), int(k)
friends = [0] + [[] for _ in range(n)]
blocks = [0] + [[] for _ in range(n)]

for _ in range(m):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    friends[p1].append(p2)
    friends[p2].append(p1)
for _ in range(k):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    blocks[p1].append(p2)
    blocks[p2].append(p1)

connected_num = 0
def dfs(graph, current, seen, connected_id):
    global connected_num
    seen[current] = connected_id
    connected_num += 1

    children = graph[current]
    for c in children:
        if seen[c] != -1:
            continue
        dfs(graph, c, seen, connected_id)

seen = [-1] * (n + 1)
connected_id = 0
connected = []
for i in range(1, n + 1):
    if seen[i] != -1:
        continue
    dfs(friends, i, seen, connected_id)
    connected.append(connected_num)
    connected_num = 0
    connected_id += 1

ans = []
for i in range(1, n + 1):
    i_connected_id = seen[i]
    exclude = 0
    for f in friends[i]:
        f_connected_id = seen[f]
        if i_connected_id == f_connected_id:
            exclude += 1
    for b in blocks[i]:
        b_connected_id = seen[b]
        if i_connected_id == b_connected_id:
            exclude += 1
    ans.append(str(connected[i_connected_id] - exclude - 1))

print(' '.join(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m, k = input().strip().split()
n, m, k = int(n), int(m), int(k)
friends = [0] + [[] for _ in range(n)]
blocks = [0] + [[] for _ in range(n)]

for _ in range(m):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    friends[p1].append(p2)
    friends[p2].append(p1)
for _ in range(k):
    p1, p2 = input().strip().split()
    p1, p2 = int(p1), int(p2)
    blocks[p1].append(p2)
    blocks[p2].append(p1)

connected_num = 0
def dfs(graph, current, seen, connected_id):
    global connected_num
    seen[current] = connected_id
    connected_num += 1

    children = graph[current]
    for c in children:
        if seen[c] != -1:
            continue
        dfs(graph, c, seen, connected_id)

seen = [-1] * (n + 1)
connected_id = 0
connected = []
for i in range(1, n + 1):
    if seen[i] != -1:
        continue
    dfs(friends, i, seen, connected_id)
    connected.append(connected_num)
    connected_num = 0
    connected_id += 1

ans = []
for i in range(1, n + 1):
    i_connected_id = seen[i]
    exclude = 0
    for f in friends[i]:
        f_connected_id = seen[f]
        if i_connected_id == f_connected_id:
            exclude += 1
    for b in blocks[i]:
        b_connected_id = seen[b]
        if i_connected_id == b_connected_id:
            exclude += 1
    ans.append(str(connected[i_connected_id] - exclude - 1))

print(' '.join(ans))
Problem p02793 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

import collections

lcm_pf = collections.defaultdict(int)
for i, v in enumerate(a):
    j = 2
    pf = {}
    while j ** 2 <= v:
        ext = 0
        while v % j == 0:
            ext += 1
            v //= j
        if ext:
            pf[j] = ext
            lcm_pf[j] = max(lcm_pf[j], ext)
        j += 1
    if v != 1:
        pf[v] = 1
        lcm_pf[v] = max(lcm_pf[v], 1)

lcm = 1
for p in lcm_pf:
    lcm = lcm * (p ** lcm_pf[p])

ans = 0
for v in a:
    ans = ans + (lcm // v)
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))
MOD = 10 ** 9 + 7

import collections

lcm_pf = collections.defaultdict(int)
for i, v in enumerate(a):
    j = 2
    pf = {}
    while j ** 2 <= v:
        ext = 0
        while v % j == 0:
            ext += 1
            v //= j
        if ext:
            pf[j] = ext
            lcm_pf[j] = max(lcm_pf[j], ext)
        j += 1
    if v != 1:
        pf[v] = 1
        lcm_pf[v] = max(lcm_pf[v], 1)

lcm = 1
for p in lcm_pf:
    lcm = lcm * (p ** lcm_pf[p])

ans = 0
for v in a:
    #ans = ans + (lcm // v)) % MOD
    ans = ans + (lcm // v)) % MOD
print(ans % MOD)
Problem p02623 (python)

Fixed submission:
### 解答


#入力はじめ

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

#入力終わり


#累積和とる

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

B_wa = [0]
for i in range(M) :
    B_wa.append(B_wa[i]+B[i])

#累積和計算おわり


ans = 0
for i in range(M+1):#Bを順番に増やしていくよー
    A_use = K-B_wa[i]
    if A_use<0: #Bだけでこえてる
        break
    
    ##Aは最大で何冊よめるかな
    A_MAX = 0
    start = 0
    end = N
    while  end-start>=1 : #調べるのが2個以上
        now = int((start + end+1)/2) #切り上げ
        if A_wa[now]==A_use :  #A[i]がKと一致
            A_MAX = now #ここが最大
            break
        elif A_wa[now]<A_use : #A[i]がKより小さい
            start = now #目的の値はここ以上のとこにある
            A_MAX = now #現時点での最大値
        else : #A[i]がKより大きい
            end = now-1#目的の値はここより小さい
    ##Aの最大探すの終わり
    
    #これ最大？
    if A_MAX+i>ans :
        ans=A_MAX+i

#コンソールにだす
print(ans)

Buggy submission (verdict: Runtime Error):
### 解答


#入力はじめ

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

#入力終わり


#累積和とる

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

B_wa = [0]
for i in range(M) :
    B_wa.append(B_wa[i]+B[i])

#累積和計算おわり


ans = 0
end = N #二分探索の後に設定しなおしたいので先に設定しておく

for i in range(M+1):#Bを順番に増やしていくよー
    A_use = K-B_wa[i]
    if A_use<0: #Bだけでこえてる
        break
    
    ##Aは最大で何冊よめるかな
    A_MAX = 0
    start = 0
    while  end-start>=1 : #調べるのが2個以上
        now = int((start + end+1)/2) #切り上げ
        if A_wa[now]==A_use :  #A[i]がKと一致
            A_MAX = now #ここが最大
            break
        elif A_wa[now]<A_use : #A[i]がKより小さい
            start = now #目的の値はここ以上のとこにある
            A_MAX = now #現時点での最大値
        else : #A[i]がKより大きい
            end = now-1#目的の値はここより小さい
    ##Aの最大探すの終わり
    
    #これ最大？
    if A_MAX+i>ans :
        ans=A_MAX+i

    end=A_MAX　#endの再設定

#コンソールにだす
print(ans)
Problem p02793 (python)

Fixed submission:
import math


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


MOD = 1000000007

N = int(input())

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

lcm_ = 1
for a in A:
    lcm_ = lcm(lcm_, a)

ans = 0
for a in A:
    ans += lcm_ // a

ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd


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


MOD = 1000000007

N = int(input())

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

lcm_ = 1
for a in A:
    lcm_ = lcm(lcm_, a)

ans = 0
for a in A:
    ans += lcm_ / a

ans %= MOD
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math


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


MOD = 1000000007

N = int(input())

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

lcm_ = 1
for a in A:
    lcm_ = lcm(lcm_, a)

ans = 0
for a in A:
    ans += lcm_ / a

ans %= MOD
print(int(ans))
Problem p02984 (python)

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

n=int(input())
arr=[int(i) for i in input().split()]
sum=0
for i in range(n):
    sum+=arr[i]
sum//=2
ans=0
for x in range(0,1):
    ex=0
    i=x
    while(True):
        ex+=arr[i]
        i+=2
        i%=n
        if (i+1)%n==x:
            ex+=arr[i]
            break

    ans=((ex-sum))
io=0
while(io!=n):
    print(ans*2,end=" ")
    ans=arr[(io)%n]-ans
    io+=1

Buggy submission (verdict: Runtime Error):
# your code goes here
import numpy as np
n=int(input())
arr=[[0]*n]
arr=arr*n
#print(arr)

A=np.array(arr)
for i in range(n):
	A[i][i]=1
	#print(A)
	A[i][(i+1)%n]=1
#print(A)

B=np.linalg.inv(A)
c=[int(i) for i in input().split()]
C=np.array(c)
x=np.matmul(C,B)
#print(x)
for i in range(-1,x.shape[0]-1):
	print(int(x[i%n]*2),end=" ")
Problem p02623 (python)

Fixed submission:
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)

Buggy submission (verdict: Runtime Error):
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 = (ans, i + j)
print(ans)
Problem p02819 (python)

Fixed submission:
x = int(input())
if x == 2:
    print(2)
    exit()
elif x == 3:
    print(3)
    exit()
while True:
    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            c = False
            break
        c = True
    if c == True:
        print(x)
        break
    elif c == False:
        x += 1

Buggy submission (verdict: Runtime Error):
x = int(input())
while True:
    for i in range(2,int(x**0.5)+1):
        if x % i == 0:
            c = False
            break
        c = True
    if c == True:
        print(x)
        break
    elif c == False:
        x += 1