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

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,a,b = inpl()
def calc(x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

    for i in range(1, x+1):
        ret *= pow(i,mod-2,mod)
        ret %= mod

    return ret%mod

ans = pow(2,N,mod)-1 - calc(a) - calc(b)
print(ans%mod)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,a,b = inpl()
def calc(N,x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

    for i in range(1, x+1):
        ret *= pow(i,mod-2,mod)
        ret %= mod

    return ret%mod

ans = pow(2,N,mod)-1 - calc(a) - calc(b)
print(ans%mod)
Problem p02811 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

K,X = inpl()
if K*500 >= X:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time,os
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

# In[]:
debug = os.getcwd()[0] == "C"
debug

# In[]:
if DEBUG:
    K,X = 2,900
else:
    K,X = inpl()

# In[]:
if K*500 >= X:
    print("Yes")
else:
    print("No")
Problem p02839 (python)

Fixed submission:


H, W = map(int, input().split())

amap = [list(map(int, input().split())) for i in range(H)]
bmap = [list(map(int, input().split())) for i in range(H)]
dist_map = [[amap[y][x] - bmap[y][x] for x in range(W)] for y in range(H)]

mid = 80 * 80 * 5 // 2
# mid = 20
dp = [[1 << mid] * W for y in range(H)]

dp[0][0] = ((1 << (dist_map[0][0] + mid)) | (1 << (mid - dist_map[0][0])))


for x in range(1, W):
    y = 0
    d = abs(dist_map[y][x])
    dp[y][x] = (dp[y][x - 1] << d) | (dp[y][x - 1] >> d)


for y in range(1, H):
    x = 0
    d = abs(dist_map[y][x])
    dp[y][x] = (dp[y - 1][x] << d) | (dp[y - 1][x] >> d)


for y in range(1, H):
    for x in range(1, W):
        d = abs(dist_map[y][x])
        dp[y][x] = (dp[y][x - 1] << d) | (dp[y][x - 1] >> d) | ((dp[y - 1][x] << d) | (dp[y - 1][x] >> d))


ans = dp[-1][-1]

for i in range(mid + 1):
    if (ans & (1 << (mid - i))) or (ans & (1 << (mid + i))):
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):


H, W = map(int, input().split())

amap = [list(map(int, input().split())) for i in range(H)]
bmap = [list(map(int, input().split())) for i in range(H)]
dist_map = [[amap[y][x] - bmap[y][x] for x in range(W)] for y in range(H)]

# mid = 80 * 80 * 5 // 2
mid = 20
dp = [[1 << mid] * W for y in range(H)]

dp[0][0] = ((1 << (dist_map[0][0] + mid)) | (1 << (mid - dist_map[0][0])))


for x in range(1, W):
    y = 0
    d = abs(dist_map[y][x])
    dp[y][x] = (dp[y][x - 1] << d) | (dp[y][x - 1] >> d)


for y in range(1, H):
    x = 0
    d = abs(dist_map[y][x])
    dp[y][x] = (dp[y - 1][x] << d) | (dp[y - 1][x] >> d)


for y in range(1, H):
    for x in range(1, W):
        d = abs(dist_map[y][x])
        dp[y][x] = (dp[y][x - 1] << d) | (dp[y][x - 1] >> d) | ((dp[y - 1][x] << d) | (dp[y - 1][x] >> d))


ans = dp[-1][-1]

for i in range(mid + 1):
    if (ans & (1 << (mid - i))) or (ans & (1 << (mid + i))):
        print(i)
        exit()
Problem p02845 (python)

Fixed submission:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
AA = inpl()

cnts = [0]*(N+1)
cnts[-1] = 3

ans = 1
for a in AA:
    ans *= (cnts[a-1] - cnts[a])
    ans %= mod
    cnts[a] += 1


print(ans)

Buggy submission (verdict: Runtime Error):
c = [0]*(int(input())+1)
c[-1] = 3
ans = 1
for a in list(map(int, input().split())):
    ans = (ans * (cnts[a-1] - cnts[a]))%mod
    cnts[a] += 1
print(ans)
Problem p02857 (python)

Fixed submission:

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()


def kiku(a):
    print("?",' '.join(map(str,list(range(a,a+N)))))


kiku(1)

T = input()
if T == '-1':
    sys.exit(-1)

baseT = T

setL = {1}
setR = {N+1}
bmid = INF
bbmid = INF
while True:
    L = max(setL)
    R = min(setR)

    if abs(R-L) == 1:
        break

    mid = (L + R)//2
    kiku(mid)
    T = input()
    if T == baseT:
        setL.add(mid)
    else:
        setR.add(mid)

X = R

def kikuX(i,X):
    print("?",' '.join(map(str,list(range(X,X+N-1)))),str(i))

ans = [0]*(2*N)

Reds = []
Blues = []

for i in range(1,X):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T

for i in range(X+N-1,N*2+1):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T




for i in range(X,X+N-1):
    k = Reds[:N//2] + Blues[:N//2] + [i]
    print("?", ' '.join(map(str,k)))
    ans[i-1] = input()[0]

print('!', ''.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()


def kiku(a):
    print("?",' '.join(map(str,list(range(a,a+N)))))


kiku(1)

T = input()
if T == '-1':
    sys.exit(-1)

baseT = T

L = 1
R = N+1
bmid = INF
while True:
    mid = (L + R)//2
    kiku(mid)
    T = input()
    if T == baseT:
        L = mid
    else:
        R = mid
    if abs(bmid-mid) == 1 and bT != T:
        break
    else:
        bmid = mid
        bT = T

X = max(bmid,mid)

def kikuX(i,X):
    print("?",' '.join(map(str,list(range(X,X+N-1)))),str(i))

ans = [0]*(2*N)

Reds = []
Blues = []

for i in range(1,X):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T

for i in range(X+N-1,N*2+1):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T




for i in range(X,X+N-1):
    k = Reds[:N//2-1] + Blues[:N//2-1] + [i]
    print("?", ' '.join(map(str,k)))
    ans[i] = input()[0]

print('!', ''.join(map(str,ans)))
Problem p02945 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B = inpl()
print(max(A+B,A-B,A*B))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
print = sys.stdout.write
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

A,B = inpl()
print(max(A+B,A-B,A*B))
Problem p03044 (python)

Fixed submission:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())

lines = defaultdict(set)
for i in range(N-1):
    u,v,w = inpl()
    u,v = u-1,v-1
    lines[u].add((v,w))
    lines[v].add((u,w))

ans = [0]*N

def dfs(s,c):
    global ans
    for t,d in list(lines[s]):
        if ans[t] == 0:
            if d%2 == 0:
                ans[t] = c
                dfs(t,c)
            else:
                ans[t] = -c
                dfs(t,-c)


dfs(0,1)
for a in ans:
    if a == -1:
        print(0)
    else:
        print(1)

Buggy submission (verdict: Runtime Error):
N = int(input())
lines = [[] for _ in range(N)]
for _ in range(N-1):
  i,j,w = map(int,input().split())
  lines[i-1].append((j-1,w))
  lines[j-1].append((i-1,w))

ans = [-1]*N 
def dfs(s, c):
  if ans[s] != -1:
    return
  else:
    ans[s] = c
    for t,w in lines[s]:
      if w%2==0:
        dfs(t,c)
      else:
        dfs(t,c^1)
      
dfs(0, 0)

print('\n'.join(map(str,ans)))
Problem p03078 (python)

Fixed submission:
import bisect

X,Y,Z,K = list(map(int,input().split()))
AA = list(map(int,input().split()))
BB = list(map(int,input().split()))
CC = list(map(int,input().split()))
MAX = max(max(AA),max(BB),max(CC))

AB = []
for a in AA:
  for b in BB:
    AB.append(a+b)
    
AB.sort()
XY = len(AB)

def check(n):
  cnt = 0
  for c in CC:
    cnt += (XY - bisect.bisect_left(AB,n-c))
  return cnt >= K

OK = 0
NG = MAX*3+100
while NG - OK >1:
  mid = (OK+NG)//2
  if check(mid):
    OK = mid
  else:
    NG = mid
    
    
ans = []
for c in CC:
    n = bisect.bisect_left(AB,OK-c)
    for i in range(n,XY):
      ans.append(c+AB[i])
      
ans.sort(reverse=True)
for YUI in range(K):
  print(ans[YUI])

Buggy submission (verdict: Runtime Error):
import bisect

X,Y,Z,K = list(map(int,input().split()))
AA = list(map(int,input().split()))
BB = list(map(int,input().split()))
CC = list(map(int,input().split()))
MAX = max(max(AA),max(BB),max(CC))

AB = []
for a in AA:
  for b in BB:
    AB.append(a+b)
    
AB.sort()
XY = len(AB)

def check(n):
  cnt = 0
  for c in CC:
    cnt += (XY - bisect.bisect_left(AB,n-c))
  return cnt >= K

OK = 0
NG = MAX*3+100
while NG - OK >1:
  mid = (OK+NG)//2
  if check(mid):
    OK = mid
  else:
    NG = mid
    
    
ans = []
for c in CC:
    n = bisect.bisect_left(AB,OK-c)
    for i in range(n,XY):
      ans.append(c+AB[i])
      
ans.sort(reverse=True)
for YUI in ans:
  print(

Buggy submission (verdict: Runtime Error):
import bisect

X,Y,Z,K = list(map(int,input().split()))
AA = list(map(int,input().split()))
BB = list(map(int,input().split()))
CC = list(map(int,input().split()))
MAX = max(max(AA),max(BB),max(CC))

AB = []
for a in AA:
  for b in BB:
    AB.append(a+b)
    
AB.sort()
XY = X*Y

def check(n):
  cnt = 0
  for c in CC:
    cnt += XY - bisect.bisect_left(AB,n-c)
  return cnt >= K

OK = 0
NG = MAX*3+100
while OK-NG >1:
  mid = (OK+NG)//2
  if check(mid):
    OK = mid
  else:
    NG = mid
    
ans = []
for c in CC:
    n = bisect.bisect_left(AB,n-c)
    for i in range(n,XY):
      ans.append(c+AB[i])
      
ans.sort(reverse=Ture)
for YUI in ans:
  print(YUI)
Problem p03141 (python)

Fixed submission:
N = int(input())
ABs = [list(map(int,input().split())) for i in range(N)]
li = []
for A,B in ABs:
  li.append([A+B,A,B])
  
li.sort(reverse=True)
flag = True
ans1 = ans2 = 0
for S,A,B in li:
  if flag:
    ans1 += A
  else:
    ans2 += B
  flag = not flag
  
print(ans1-ans2)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ABs = []
for _ in range(N):
    A,B = inpl()
    ABs.append([A+B,A,B])

ABs.sort(reversed=True)
t = a = 0

for i,[AB,A,B] in enumerate(ABs):
    if i%2 == 0:
        t += A
    else:
        a += B

print(t-a)

Buggy submission (verdict: Runtime Error):
N = int(input())
ABs = [list(map(int,input.split())) for i in rane(N)]
li = []
for A,B in ABs:
  li.append([A+B,A,B])
  
li.sort(reverse=True)
flag = True
ans1 = ans2 = 0
for S,A,B in li:
  if flag:
    ans1 += A
  else:
    ans2 += B
  flag = not flag
  
print(ans1-ans2)
Problem p03167 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

H,W = inpl()
MAP = [['#']*(W+2)] + [['#']+list(input())+['#'] for y in range(H)] + [['#']*(W+2)]

dp = [[0]*(W+2) for y in range(H+2)]
dp[1][0] = 1

for x in range(1,W+1):
    for y in range(1,H+1):
        if MAP[y][x] == '.':
            dp[y][x] = (dp[y-1][x] + dp[y][x-1])%mod

print(dp[H][W])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import numpy as np
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

H,W = inpl()
MAP = [['#']*(W+2)] + [['#']+list(input())+['#'] for y in range(H)] + [['#']*(W+2)]

dp = np.zeros((H+2,W+2),dtype=np.int)
dp[1][0] = 1

for x in range(1,W+1):
    for y in range(1,H+1):
        if MAP[y][x] == '.':
            dp[y][x] = (dp[y-1][x] + dp[y][x-1])%mod

print(dp[H][W])
Problem p03194 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


# 先にふるってprimesを作る
def hurui(N):
    koho = list(range(2,N))
    prime = []
    limit = math.sqrt(koho[-1])
    while True:
        p = koho[0]
        if limit <= p:
            prime = prime + koho
            break
        else:
            prime.append(p)
            koho = [e for e in koho if e%p != 0]

    return prime

# N を素因数分解
def factorization(N):
    ans = defaultdict(int)
    L = len(primes)
    pind = 0
    while N > 1:
        p = primes[pind]
        while N%p == 0:
            N //= p
            ans[p] += 1
        pind += 1
        if pind >= L:
            ans[N] += 1
            break
    return ans

N,P = inpl()

primes = hurui(int(math.sqrt(P))+3)
facs = factorization(P)

ans = 1
for p,n in facs.items():
    if n >= N:
        ans *= p**(n//N)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


# 先にふるってprimesを作る
def hurui(N):
    koho = list(range(2,N))
    prime = []
    limit = math.sqrt(koho[-1])
    while True:
        p = koho[0]
        if limit <= p:
            prime = prime + koho
            break
        else:
            prime.append(p)
            koho = [e for e in koho if e%p != 0]

    return prime

# N を素因数分解
def factorization(N):
    ans = defaultdict(int)
    pind = 0
    while N > 1:
        p = primes[pind]
        while N%p == 0:
            N //= p
            ans[p] += 1
        pind += 1

    return ans


N,P = inpl()

primes = hurui(int(math.sqrt(P))+1)
facs = factorization(P)

ans = 1
for p,n in facs.items():
    if n >= N:
        ans *= p*(n//N)

print(ans)
Problem p03251 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,M,X,Y = inpl()
X = max(max(inpl()),X)
Y = min(min(inpl()),Y)
if X < Y:
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,M,X,Y = inpl()
X = max(inpl(),X)
Y = min(inpl(),Y)
if X < Y:
    print("No War")
else:
    print("War")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,M,X,Y = inpl()
X = max(inpl(),X)
Y = mrin(inpl(),Y)
if X < Y:
    print("No War")
else:
    print("War")
Problem p03268 (python)

Fixed submission:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,K = inpl()

if K%2 == 1:
	print((N//K)**3)
else:
	ans = (N//K)**3
	tmp = N//K
	if N%K >= K//2:
		tmp += 1
	ans += tmp**3
	print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 998244353
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K,N = inpl()

MAX = 20000
fac = [1]*(MAX+1)
for i in range(1,MAX+1):
	fac[i] = (fac[i-1]*i)%mod

gyakugen = [1]*(MAX+1)
gyakugen[MAX] = pow(fac[MAX],mod-2,mod)
for i in range(MAX,0,-1):
	gyakugen[i-1] = (gyakugen[i]*i)%mod

def Comb(n,k):#nCk
	return (fac[n]*gyakugen[k]*gyakugen[n-k])%mod

#K=k,N=n,0pair = 0
def calc(k,n,i):
	x = (i-2)//2
	k -= x
	n -= x
	if k == 1:
		if n <= 1:
			return n
		else:
			return 0
	elif k < 1:
		return 0
	tmp = 0
	for j in range(2):
		zb = n-j
		zm = k-2
		tmp += Comb(zb+zm,min(zb,zm))%mod
	tmp %= mod
	tmp *= pow(2,x,mod)
	return tmp

ans = []
for i in range(2,K+2):
	if i%2 == 0:
		pairs = (i-2)//2
		tmp = 0
		for p0 in range(pairs+1):
			tmp += calc(K-p0*2,N,i-p0*2)*Comb(pairs,p0)%mod
			tmp %= mod
	ans.append(tmp)
	print(tmp)

ans = ans[::-1]

for i in range(1,K):
	print(ans[i])
Problem p03294 (python)

Fixed submission:
#a = int(input())
#b,c = map(int,input().split())
#s = input()
#list_s = list(input())
#list_int = list(map(int,input().split()))

#list = [0 for i in range(n)]
#dp = [[0 for i in range(A)] for j in range(B)]

#list_int 並べて出力 print (' '.join(map(str,ans_li)))
#list_str 並べて出力 print (' '.join(list))

# 2進数 format(10, 'b') # '1010'

# aa=[int(input()) for i in range(n)]

#for i,name in enumerate(list)

''' 二次元配列を一列ずつ
for i in ans:
	print(*i)
'''
''' heapq
queue = []
heapq.heapify(queue) #heapqの作成
heapq.heappush(queue,num) #numのpush(値の追加)
pop = heapq.heappop(queue) #numのpop(最小値の出力)
pop = heapq.heappushpop(queue,num) #push -> pop

'''

from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7

#最大公約数
def gcd(a,b):
	while b:
		a,b = b, a%b
	return a

#最小公倍数
def lcm(a,b):
	return a*b // gcd(a,b)

N = int(input())
aa = list_int = list(map(int,input().split()))

mod = 1

for i in range(N):
	mod = lcm(aa[i],mod)

mod -= 1
ans = 0
for i in range(N):
	ans += mod%aa[i]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
print(sum(map(int,input.split()))-N)
Problem p03359 (python)

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

if b >= a:
	print (a)
else:
	print (a-1)

Buggy submission (verdict: Runtime Error):
import math

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True
	

N = int(input())
count = 0
a_list = []

for i in range(5550):
	a = 10 * i + 1
	if is_prime(a):
		a_list.append(a)
		count += 1
		if count == N:
			break

print (' '.join(map(str, a_list)))
Problem p03361 (python)

Fixed submission:
H,W = map(int, input().split())

table = []

for i in range(H):
	table.append(list(input()))

counter = 0
	
def check(x,y):
	counter = 0
			
	if x > 0:
		if table[y][x-1] == '#':
			counter += 1
			
	if x < W-1:
		if table[y][x+1] == '#':
			counter += 1
	
	if y > 0:
		if table[y-1][x] == '#':
			counter += 1
	
	if y < H-1:
		if table[y+1][x] == '#':
			counter += 1
	
	if counter == 0:
		print('No')
		quit()
			
	

for y in range(H):
	for x in range(W):
		if table[y][x] == '#':
			check(x,y)

print ('Yes')

Buggy submission (verdict: Runtime Error):

H,W = map(int, input().split())

table = []

for i in range(H):
	table.append(list(input()))


def check(x,y):
	if table[y-1][x]=='#' or table[y+1][x]=='#' or table[y][x-1]=='#' or table[y][x+1]=='#' :
		return
	else:
		print ('No')
		quit()
		

for y in range(H):
	for x in range(W):
		check(x,y)

print ('Yes')
Problem p03362 (python)

Fixed submission:
import math

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True
	

N = int(input())
count = 0
a_list = []

for i in range(5550):
	a = 10 * i + 1
	if is_prime(a):
		a_list.append(a)
		count += 1
		if count == N:
			break

print (' '.join(map(str, a_list)))

Buggy submission (verdict: Runtime Error):
def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True
	

N = int(input())
count = 0
a_list = []

for i in range(5550):
	a = 10 * i + 1
	if is_prime(a):
		a_list.append(a)
		count += 1
		if count == N:
			break

print (' '.join(map(str, a_list)))