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

Fixed submission:
s = input()

class RL():
  def __init__(self, ind, r, l):
    self.ind = ind
    self.r = r
    self.l = l
  
  def calc(self):
      return [1 + self.r // 2 + (self.l // 2 + 1 if self.l % 2 == 1 else self.l // 2), 1 + self.l // 2 + (self.r // 2 + 1 if self.r % 2 == 1 else self.r // 2)]



r = 0
l = 0
ind = 0
rl = False

rls = {}

for i, c in enumerate(s):
  if c == 'R' and not rl:
    r += 1
    continue
  if c == 'R' and rl:
    rls[ind - 1] = RL(ind - 1, r - 1, l)
    r = 1
    l = 0
    rl = False
    continue
  if c == 'L' and not rl:
    ind = i
    rl = True
    continue
  if c == 'L' and rl:
    l += 1
    continue

rls[ind - 1] = (RL(ind - 1, r - 1, l))

ans = []

skip = False

for i in range(len(s)):
  if skip:
    skip = False
    continue
  if i in rls:
    skip = True
    ans += rls[i].calc()
  else:
    ans.append(0)

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

Buggy submission (verdict: Runtime Error):
s = input()

class RL():
  def __init__(self, ind, r, l):
    self.ind = ind
    self.r = r
    self.l = l
  
  def calc(self):
      return [1 + self.r // 2 + (self.l // 2 + 1 if self.l % 2 == 1 else self.l // 2), 1 + self.l // 2 + (self.r // 2 + 1 if self.r % 2 == 1 else self.r // 2)]
  
  def __str__(self):
    return f'{self.ind}: r {self.r} l {self.l}'


r = 0
l = 0
ind = 0
rl = False

rls = {}

for i, c in enumerate(s):
  if c == 'R' and not rl:
    r += 1
    continue
  if c == 'R' and rl:
    rls[ind - 1] = RL(ind - 1, r - 1, l)
    r = 1
    l = 0
    rl = False
    continue
  if c == 'L' and not rl:
    ind = i
    rl = True
    continue
  if c == 'L' and rl:
    l += 1
    continue

rls[ind - 1] = (RL(ind - 1, r - 1, l))

ans = []

skip = False

for i in range(len(s)):
  if skip:
    skip = False
    continue
  if i in rls:
    skip = True
    ans += rls[i].calc()
  else:
    ans.append(0)

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

Fixed submission:
A,B,C = map(int, input().split())

print(C - min(A-B, C))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

for i in range(N-1):
    if H[i] - H[i+1] > 1:
        print('No')
        exit()

print('Yes')
Problem p03013 (python)

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

broken = [0 for _ in range(n+1)]
for i in range(m):
    a = int(input())
    broken[a] = True

    
mod = 1000000007
dp = [0 for _ in range(n+2)]

dp[n] = 1
for i in range(n-1, -1, -1):
    if(broken[i]):
        dp[i] = 0
        continue

    dp[i] = (dp[i+1] + dp[i+2]) % mod

print(dp[0])

Buggy submission (verdict: Runtime Error):
from collections import deque


def Fibonacci(n): 
    if n<0: 
        print("Incorrect input") 
    # First Fibonacci number is 0 
    elif n==1: 
        return 1
    # Second Fibonacci number is 1 
    elif n==2: 
        return 2
    else: 
        return Fibonacci(n-1)+Fibonacci(n-2) 
        

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

A = deque()

for _ in range(M):
    A.append(int(input()))

pos = 0
diff = []
la = None

for a in A:
    if la and a - la == 1:
        print(0)
        exit()
    d = (a) - pos
    diff.append(d)
    pos = a
    la = a

# 最後の階段
diff.append(N - pos)
diff = list(filter(lambda x: False if x <= 0 else True, diff))
F = [Fibonacci(d) for d in diff]

_sum = 1
for f in F:
    _sum *= f

print(_sum // 1000000007)

Buggy submission (verdict: Runtime Error):
from collections import deque


def Fibonacci(n): 
    if n<0: 
        print("Incorrect input") 
    # First Fibonacci number is 0 
    elif n==1: 
        return 1
    # Second Fibonacci number is 1 
    elif n==2: 
        return 2
    else: 
        return Fibonacci(n-1)+Fibonacci(n-2) 
        

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

A = deque()

for _ in range(M):
    A.append(int(input()))

pos = 0
diff = []

for a in A:
    d = (a - 1) - pos
    diff.append(d)
    pos = a + 1

# 最後の階段
diff.append(N - pos)

diff = list(filter(lambda x: False if x <= 0 else True, diff))

F = [Fibonacci(d) for d in diff]

_sum = 1
for f in F:
    _sum *= f

print(_sum)
Problem p03038 (python)

Fixed submission:
from collections import deque

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

BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort()

BC.sort(key=lambda x:x[1], reverse=True)

D = deque([])
for bc in BC:
    b = bc[0]
    c = bc[1]

    for _ in range(b):
        D.append(c)

    if len(D) >= N: 
        break

for i in range(N):
    if A[i] < D[0]:
        A[i] = D[0]
        D.popleft()
        if not D:
            break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort()


BC = [[bc[1]] * bc[0] for bc in BC]
BC = [flat_bc for bc in BC for flat_bc in bc]

BC.sort(key=lambda x:x[1])
BC = BC[-N:]


for i in range(N):
    if A[i] < BC[-1]:
        A[i] = BC[-1]
        BC.pop()
        if not BC:
            break

print(sum(A))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))

BC = []
for _ in range(M):
    BC.append(tuple(map(int, input().split())))

A.sort()

BC.sort(key=lambda x:x[1])

BC = [[bc[1]] * bc[0] for bc in BC]
BC = [flat_bc for bc in BC for flat_bc in bc]

for i in range(N):
    if A[i] < BC[-1]:
        A[i] = BC[-1]
        BC.pop()

print(sum(A))
Problem p03077 (python)

Fixed submission:
import math

n = int(input())

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

bn = min(a, b, c, d, e)

print(4 + math.ceil(n / bn))

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))[:k]

e = []

for va in a:
    for vb in b:
        e.append(va+vb)

e.sort(reverse=True)

e = e[:k]

d = []
for vc in c:
    for ve in e:
        d.append(vc+ve)

d.sort(reverse=True)
d = d[:k]

for vd in d:
    print(vd)
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())

to = [[] for _ in range(N)]
visited = [False] * N

def dfs(v):
    if sum(visited) == N:
        return 1 
    
    ret = 0
    for u in to[v]:
        if not visited[u]:
            visited[u] = True
            ret += dfs(u)
            visited[u] = False  # 最も深い点から帰ってくる道中に、始点を除く全ての点を未訪問にする => 他のパスを辿ることが可能になる

    return ret


for _ in range(M):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

visited[0] = True
print(dfs(0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())

to = [[] for _ in range(N)]
visited = [False] * N

def dfs(v):
    n_visited = sum([1 if v else 0 for v in visited])
    if n_visited == N:
        return 1 
    
    ret = 0
    for u in to[v]:
        if not visited[u]:
            visited[u] = True
            ret += dfs(u)
            visited[u] = False  # 最も深い点から帰ってくる道中に、始点を除く全ての点を未訪問にする => 他のパスを辿ることが可能になる

    return ret


for _ in range(N):
    a, b = map(int, input().split())
    to[a-1].append(b-1)
    to[b-1].append(a-1)

visited[0] = True
print(dfs(0))
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#print("A=",A)
#print("B=",B)

count = 0
for i in range(N+1):
    if i == 0:
        taosita = B[i]-max((B[i]-A[i]),0)
        count = taosita
        B[i]= B[i]-taosita
#        print("i=0")
    elif i!=N:
        #1つ前の勇者
        taosita1 = B[i-1]-max((B[i-1]-A[i]),0)
        count =count + taosita1
        A[i] = A[i]-taosita1
        #今回の勇者
        taosita2 = B[i]-max((B[i]-A[i]),0)
        count =count + taosita2
        B[i]= B[i]-taosita2
    if i == N:
        #1つ前の勇者
        taosita3 = B[i-1]-max((B[i-1]-A[i]),0)
        count =count + taosita3
#        A[i] = A[i]-taosita1
print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
#print("A=",A)
#print("B=",B)

count = 0
for i in range(N+1):
    if i == 0:
        taosita = B[i]-max((B[i]-A[i]),0)
        count = taosita
        B[i]= B[i]-taosita
#        print("i=0")
    elif i!=N
        #1つ前の勇者
        taosita1 = B[i-1]-max((B[i-1]-A[i]),0)
        count =count + taosita1
        A[i] = A[i]-taosita1
        #今回の勇者
        taosita2 = B[i]-max((B[i]-A[i]),0)
        count =count + taosita2
        B[i]= B[i]-taosita2
    if i == N:
        #1つ前の勇者
        taosita3 = B[i-1]-max((B[i-1]-A[i]),0)
        count =count + taosita3
#        A[i] = A[i]-taosita1
print(count)
Problem p03072 (python)

Fixed submission:
N = int(input())
H = list(map(int,input().strip().split(" ")))
maxH = H[0]
look = 1
for i in range(N-1):
  if H[i+1] >= maxH:
    look = look + 1
    maxH = H[i+1]
print(look)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = input().split()
maxH = H[0]
look = 1
for i in range(N-1):
	if N == 1:
    	print(1)
	elif H[i+1] >= maxH:
    	look = look + 1
    	maxH = H[i+1]
  	else:
    	maxH = maxH
print(look)
Problem p03012 (python)

Fixed submission:
# stdin
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
N = int(ss[0])
W = [int(i) for i in ss[1].split(" ")]
print(min([abs(sum(W[T:]) - sum(W[:T])) for T in range(N)]))

Buggy submission (verdict: Runtime Error):
# stdin
INPUT_SENTENCES = 2
ss = [input() for i in range(INPUT_SENTENCES)]
N = int(ss[0])
W = [int(i) for i in ss[1].split(" ")]
print(min([abs(sum(W[T:]) - sum(W[:T])) for T in range(N))
Problem p02951 (python)

Fixed submission:
input_num=input().split()# 2 4 5のような入力
input_num=[int(num) for num in input_num]#intへ変換

A,B,C=input_num

cup_1=B
cup_2=C

cup_1=B+cup_2
cup_2=0

if cup_1>=A:
    cup_1=A
    cup_2=B+C-cup_1
    print(cup_2)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n=input()
n=int(n)
input_h=input().split()# 2 4 5のような入力
input_h=[int(num) for num in input_h]#intへ変換

for idx in range(n-1):

    if input_h[idx]<=input_h[idx+1]:
        continue
    elif input_h[idx]-1==input_h[idx+1]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
n=input()
n=int(n)
input_h=input().split()# 2 4 5のような入力
input_h=[int(num) for num in input_h]#intへ変換

for idx in range(n-1):

    if input_h[idx]<=input_h[idx+1]:
        continue
    elif input_h[idx]-1==input_h[idx+1]:
        continue
    else:
        print("No")
        break
else:
    print("Yes")
Problem p02959 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
y=0
for i in range(n):
    v=max(0,a[i]-y)
    if v<=b[i]:
        s+=a[i]
        y=b[i]-v
    elif v>b[i]:
        s+=b[i]+y
        y=0
print(s+min(a[-1],y))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
s=0
y=0
for i in range(n+1):
    v=max(0,a[i]-y)
    if v<=b[i]:
        s+=a[i]
        y=b[i]-v
    elif v>b[i]:
        s+=b[i]+y
        y=0
print(s)
Problem p02987 (python)

Fixed submission:
s=list(input())
s.sort()
if s[0] == s[1] and s[2]==s[3] and s[0] != s[2]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
li = list(map(int,input().slice()))
cnt=0
for i in range(1,n-1):
    if li[i-1]<li[i]<li[i+1]:
        cnt+=1
    elif li[i-1]>li[i]>li[i+1]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
    s=list(input())
    s.sort()
    if s[0] == s[1] and s[2]==s[3] and s[0]!=s[2]:
        print("Yes")
    else:
        print("No")
Problem p03327 (python)

Fixed submission:
a=int(input())
print("ABC" if a<1000 else "ABD")

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
print("ABD" if a<1000 else "ABC")

Buggy submission (verdict: Runtime Error):
a=map(int,input().split())
print("ABC" if a<1000 else "ABD")
Problem p03834 (python)

Fixed submission:
s=input()
print(s.replace(","," "))

Buggy submission (verdict: Runtime Error):
s=input()
print(s.replace("\,"," ")
Problem p02990 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,K = map(int,input().split())
Max = 2001
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(1,K+1):
    print(Comb(K-1,i-1)*Comb(N-K+1,i)%mod)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
Max = 2001
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod

for i in range(1,K+1):
    print(Comb(K-1,i-1)*Comb(N-K+1,i))
Problem p03003 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[0]*(M+1) for i in range(N+1)]

for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            dp[n+1][m+1] = (dp[n+1][m]+dp[n][m+1]+1)%mod
        else:
            dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]

print((dp[N][M]+1)%mod)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[0]*(M+1) for i in range(N+1)]

for n in range(N):
    for m in range(M):
        if S[n] == T[m]:
            dp[n+1][m+1] = (dp[n+1][m]+dp[n][m+1]+1)%mod
        else:
            dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]

print((dp[N][M]+1)%mod)
Problem p03012 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
W = list(map(int,input().split()))
ans = inf
for t in range(N):
    ans = min(ans,abs(sum(W[:t])-sum(W[t:])))

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
W = list(map(int,input().split()))
ans = inf
for t in range(N):
    ans = min(ans,abs(sum(W[:t])-sum(W[t:])))

print(ans)
Problem p03013 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
c = [0]*(N+1)
c[0] = 1
c[1] = 1
ans = 1
a = []
al = 0
for i in range(2,N+1):
    c[i] = c[i-1]+c[i-2]
    c[i] %= mod
for i in range(M):
    ai = int(input())
    if i == 0:
        a.append(ai)
    else:
        if ai - al == 1:
            print(0)
            exit()
        else:
            a.append(ai)
    al = ai
if M == 0:
    print(c[N])
    exit()
for i in range(M):
    if i == 0:
        ans *= c[a[i]-1]
        ans %= mod
    if i == M-1:
        ans *= c[N-a[i]-1]
        ans %= mod
    else:
        if a[i+1] != a[i]:
            ans *= c[a[i+1]-a[i]-2]
            ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
bool = [True]*(N+1)
dp = [0]*(N+1)
for i in range(M):
    a = int(input())
    bool[a] = False
dp[0]=dp[1]=1
for i in range(2,N+1):
    if bool[i-1]:
        dp[i] += dp[i-1]
        dp[i] %= mod
    if bool[i-2]:
        dp[i] += dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
c = [0]*(N+1)
c[0] = 1
c[1] = 1
c[2] = 2
ans = 1
a = []
for i in range(3,N+1):
    c[i] = c[i-1]+c[i-2]
for i in range(M):
    ai = int(input())
    a.append(ai)
for i in range(M-1):
    if a[i+1]-a[i] <= 1:
        print(0)
        exit()
for i in range(M):
    if i == 0:
        ans *= c[a[i]-1]
        ans %= mod
    if i == M-1:
        ans *= c[N-a[i]-1]
        ans %= mod
    else:
        ans *= c[a[i+1]-a[i]-2]
        ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
c = [0]*(N+1)
c[0] = 1
c[1] = 1
c[2] = 2
ans = 1
a = []
for i in range(3,N+1):
    c[i] = c[i-1]+c[i-2]
for i in range(M):
    ai = int(input())
    a.append(ai)
for i in range(1,M-1):
    if a[i+1]-a[i] == 1:
        print(0)
        exit()
for i in range(M):
    if i == 0:
        ans *= c[a[i]-1]
        ans %= mod
    if i == M-1:
        ans *= c[N-a[i]-1]
        ans %= mod
    else:
        ans *= c[a[i+1]-a[i]-2]
        ans %= mod
print(ans)
Problem p03053 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

H,W = map(int,input().split())
A = list(list(input()) for _ in range(H))
dirc = [(0,1),(1,0),(0,-1),(-1,0)]
q = deque()
for i in range(H):
    for j in range(W):
        if A[i][j] =="#":
            A[i][j] = 0
            q.append((i,j))
ans = 0
while q:
    y,x = q.popleft()
    for dy,dx in dirc:
        if 0<=dy+y<H and 0<=dx+x<W and A[dy+y][dx+x]==".":
            A[dy+y][dx+x] = A[y][x]+1
            ans = max(ans,A[dy+y][dx+x])
            q.append((dy+y,dx+x))

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
l = 1
r = w
u = 1
d = h
for s,t in zip(s[::-1],t[::-1]):
    if t == "R":
        l = max(l-1,1)
    elif t == "L":
        r = min(r+1,w)
    elif t =="U":
        d = min(d+1,h)
    else:
        u = max(u-1,1)

    if s == "L":
        l += 1
    elif s =="R":
        r -=1
    elif s =="U":
        u+=1
    else:
        d-=1
    if l > r or u > d:
        print('NO')
        exit()
if u <= sr <= d and l <= sc <= r:
    print("YES")
else:
    print("NO")
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

X_diff = [X[i+1]-X[i] for i in range(m-1)]
X_diff.sort(reverse=True)

if n >= m:
    print(0)
else:
    print(X[-1] - X[0] - sum(X_diff[:n-1]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
X = list(map(int,input().split()))
X.sort()

X_diff = [X[i+1]-X[i] for i in range(m-1)]
X_diff.sort(reverse=True)

if n >= m:
    print(0)
else:
    print(X[-1] - X[0] - sum(X_diff[:N-1]))
Problem p03242 (python)

Fixed submission:
n = list(input())
for i in range(len(n)):
  if n[i] == "1":
    n[i] = "9"
  else:
    n[i] = "1"
l = map(str,n)
print("".join(l))

Buggy submission (verdict: Runtime Error):
n = input()
for i in range(len(n)):
  if n[i] == "1":
    n[i] = "9"
  else:
    n[i] = "1"
print(n)
Problem p03291 (python)

Fixed submission:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

S = input()
l = len(S)
d = {"A":1,"B":2,"C":3}

dp = [0 for _ in range(4)]
dp[0] = 1
for i in range(l):
    if S[i] == "?":
        dp = [dp[0]*3,dp[1]*3+dp[0],dp[2]*3+dp[1],dp[3]*3+dp[2]]
        for j in range(4):
            dp[j] %= mod
    else:
        j = d[S[i]]
        dp[j] += dp[j-1] % mod

print(dp[3]%mod)

Buggy submission (verdict: Runtime Error):
S = input()
l = len(S)
d = {"A":1,"B":2,"C":3}

dp = [0 for _ in range(4)]
dp[0] = 1
for i in range(l):
    if S[i] == "?":
        dp = [dp[0]*3,dp[1]*3+dp[0],dp[2]*3+dp[1],dp[3]*3+dp[2]]
        for j in range(4):
            dp[j] %= mod
    else:
        j = d[S[i]]
        dp[j] += dp[j-1] % mod

print(dp[3]%mod)
Problem p03295 (python)

Fixed submission:
inf = 10**10

N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
ab.sort(reverse=True)
ans = 0
tmp = inf
for i in range(M):
    if ab[i][1] > tmp:
        continue
    else:
        ans += 1
        tmp = ab[i][0]
print(ans)

Buggy submission (verdict: Runtime Error):
#取り除く橋は西側が出来るだけ大きいやつから取り除いても無駄がない
#（なぜならそうでない橋を取り除いた後にも上の橋を取り除かねばならないので）
N,M = map(int,input().split())
ab =[list(map(int,input().split())) for i in range(M)]
ab.sort(reverse=True)
ans = 0
tmp = inf
for i in range(M):
    if ab[i][1] > tmp:
        continue
    else:
        ans += 1
        tmp = ab[i][0]
print(ans)
Problem p03326 (python)

Fixed submission:
N,M = map(int,input().split())
x=[]
y=[]
z=[]
for i in range(N):
    xi,yi,zi = map(int,input().split())
    x.append(xi)
    y.append(yi)
    z.append(zi)
ppp =[]
ppm =[]
pmp =[]
mpp =[]
mmp =[]
mpm =[]
pmm =[]
mmm =[]
for i in range(N):
    xp = x[i]
    xm = -x[i]
    yp = y[i]
    ym = -y[i]
    zp = z[i]
    zm = -z[i]
    ppp.append(xp+yp+zp)
    ppm.append(xp+yp+zm)
    pmp.append(xp+ym+zp)
    mpp.append(xm+yp+zp)
    mmp.append(xm+ym+zp)
    mpm.append(xm+yp+zm)
    pmm.append(xp+ym+zm)
    mmm.append(xm+ym+zm)
ppp.sort(reverse=True)
ppm.sort(reverse=True)
pmp.sort(reverse=True)
mpp.sort(reverse=True)
mmp.sort(reverse=True)
mpm.sort(reverse=True)
pmm.sort(reverse=True)
mmm.sort(reverse=True)
print(max(sum(ppp[0:M]),sum(ppm[0:M]),sum(pmp[0:M]),sum(mpp[0:M]),sum(mmp[0:M]),sum(mpm[0:M]),sum(pmm[0:M]),sum(mmm[0:M])))

Buggy submission (verdict: Runtime Error):
import itertools
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
from collections import Counter
inf = 10**10
from itertools import*


n,m = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]
res = 0
for (a,b,c) in product([-1,1],[-1,1],[-1,1]):
    tmp=[]
    for x,y,z in X:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    res = max(res,sum(tmp[:m]))

print(res)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
X = [list(map(int,input().split())) for i in range(n)]
res = 0
for (a,b,c) in product([-1,1],[-1,1],[-1,1]):
    tmp=[]
    for x,y,z in X:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    res = max(res,sum(tmp[:m]))

print(res)