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

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

if B>= A*C:
    print(C)
else:
    print(B//A)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
class UnionFind():
    def __init__(self,n):
        self.data = [-1] * n
    
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.data[x] < self.data[y]:
            x, y = y, x  # swap
        self.data[x] += self.data[y]
        self.data[y] = x
    
    def find(self, x):
        if self.data[x] < 0:
            return x
        self.data[x] = self.find(self.data[x])
        return self.data[x]

    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def size(self, x):
        return self.data[self.find(x)]
        
# END CUT HERE

def ABC120_D():
    n, m = mi()
    a = [0] * m
    b = [0] * m
    for i in range(m):
        a[i], b[i] = mi()
        
    uf = UnionFind(n)
    ans = [0] * (m + 1)
    ans[m] = n * (n - 1) // 2

    for i in range(m - 1, -1, -1):
        a[i] -= 1
        b[i] -= 1
        ans[i] = ans[i + 1]
        if uf.same(a[i], b[i]):
            continue
        
        x = uf.size(a[i])
        y = uf.size(b[i])
        ans[i] -= x * y
        
        uf.unite(a[i],b[i])
    
    for i in range(1, m + 1):
        print(ans[i])



if __name__ == '__main__':
    ABC120_D()
Problem p03109 (python)

Fixed submission:
S = list(map(int, input().split('/')))

if 1 <= S[1] <= 4:
    print('Heisei')
elif S[1] == 4 and S[2] == 30:
    print('Heisei')
else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
import bisect

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
ｓ.insert(0, -f_inf)
t.insert(0, -f_inf)
ｓ.append(f_inf)
t.append(f_inf)

for i in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), max(abs(x-s[s_index-1]), abs(x-t[t_index-1])), 2*abs(x-s[s_index-1])+abs(x-t[t_index]), 2*abs(x-s[s_index])+abs(x-t[t_index-1]), abs(x-s[s_index-1])+2*abs(x-t[t_index]), abs(x-s[s_index])+2*abs(x-t[t_index-1])))
Problem p03125 (python)

Fixed submission:
A,B = map(int,input().split())
# N = int(input())
if B%A == 0:
    print(A+B)
else:
    print(B-A)

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

A = list(map(int,input().split()))
dp = [False for i in range(N+10)]
memo = [[] for i in range(N+10)]
taiou = [[1,2],[2,5],[3,5],[4,4],[5,5],[6,6],[7,3],[8,7],[9,6]]
matchi = []
for i in range(1,10):
    if i in A:
        matchi.append(taiou[i-1])
matchi = sorted(matchi,key = lambda x:-x[0])
matchi = sorted(matchi,key = lambda x:x[1])
# for i in range(1,len(matchi)):
#     if matchi[i][1] == matchi[i-1][1]:

minma = matchi[0][1]
# print(matchi)
# print(minma)
# dp[0] = F
for i in range(len(matchi)):
    dp[matchi[i][1]] = True
    memo[matchi[i][1]].append(matchi[i][0])
for i in range(N):
    for j in range(len(matchi)):
        if dp[i-matchi[j][1]]:
            dp[i] = True
            memo[i] = memo[i] + memo[i-matchi[j][1]]
            memo[i].append(matchi[j][0])
            break
# print(dp)
# print(memo)
maxi = N
for i in range(N//minma,0,-1):
    if dp[N-i*minma]:
        maxi = i
        # print(maxi)
        break

ans = sorted([matchi[0][0]]*maxi + memo[N-maxi*minma],reverse = True)
for i in range(len(ans)):
    print(ans[i],sep='',end='')
print('')

Buggy submission (verdict: Runtime Error):
import bisect

f_inf = float('inf')


def cal(syurui, d, index):
    if d == 'e':
        return syurui[index]
    elif d == 'w':
        return syurui[index - 1]


A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()

for i in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s, x)
    t_index = bisect.bisect_left(t, x)
    if s_index == len(s) and t_index == len(t):
        print(max(abs(x-s[s_index-1]), abs(x-t[t_index-1])))
    elif s_index == len(s):
        ｓ.insert(0, -f_inf)
        t.insert(0, -f_inf)
        print(min(max(abs(x-s[s_index]), abs(x-t[t_index])),
                  2*abs(x-s[s_index])+abs(x-t[t_index+1]), abs(x-s[s_index])+2*abs(x-t[t_index+1])))
    elif t_index == len(t):
        ｓ.insert(0, -f_inf)
        t.insert(0, -f_inf)
        print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), 2*abs(x-s[s_index+1])+abs(x-t[t_index]),
                  abs(x-s[s_index+1])+2*abs(x-t[t_index])))
    else:
        ｓ.insert(0, -f_inf)
        t.insert(0, -f_inf)
        print(min(max(abs(x-s[s_index]), abs(x-t[t_index])), max(
            abs(x-s[s_index+1]), abs(x-t[t_index+1])), 2*abs(x-s[s_index+1])+abs(x-t[t_index]), 2*abs(x-s[s_index])+abs(x-t[t_index+1]), abs(x-s[s_index+1])+2*abs(x-t[t_index]), abs(x-s[s_index])+2*abs(x-t[t_index+1])))
Problem p03165 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
def lcs(s, t):
    '''s,tは文字列をリスト化したもの'''
    n = len(s)
    m = len(t)
    s.append('$')
    t.append('%')
    dp = [[0 for _j in range(m + 2)] for _i in range(n + 2)]
    dp[0][0] = 0
    for i in range(n+1):
        for j in range(m+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]))
    # return dp[n][m]
    '''復元する'''
    length = dp[n][m]
    ans = ['']*(length+1)
    while(length > 0):
        if(s[n] == t[m]):
            ans[length] = s[n]
            n-=1
            m-=1
            length-=1
        elif(dp[n+1][m+1] == dp[n][m+1]):
            n-=1
        else:
            m-=1
    return ''.join(ans[1:])
# END CUT HERE

def ALDS1_10_C():
    q = ii()
    for _ in range(q):
        s = li()
        t = li()
        print(lcs(s, t))

def EDPC_F():
    s = li()
    t = li()
    print(lcs(s,t))


if __name__ == '__main__':
    # ALDS1_10_C()
    EDPC_F()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template

# BEGIN CUT HERE
def lcs(s, t):
    '''s,tは文字列をリスト化したもの'''
    n = len(s)
    m = len(t)
    s.insert(0, '$')
    t.insert(0, '%')
    dp = [[0 for _j in range(m + 2)] for _i in range(n + 2)]
    dp[0][0] = 0
    for i in range(n+1):
        for j in range(m+1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            dp[i][j + 1] = max(dp[i][j + 1], dp[i][j])
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + (s[i] == t[j]))
    # return dp[n][m]
    '''復元する'''
    length = dp[n][m]
    ans = ['']*(length+1)
    while(length > 0):
        if(s[n] == t[m]):
            ans[length] = s[n]
            n-=1
            m-=1
            length-=1
        elif(dp[n][m] == dp[n - 1][m]):
            n-=1
        else:
            m-=1
    return ''.join(ans)
# END CUT HERE

def ALDS1_10_C():
    q = ii()
    for _ in range(q):
        s = li()
        t = li()
        print(lcs(s, t))

def EDPC_F():
    s = li()
    t = li()
    print(lcs(s,t))


if __name__ == '__main__':
    # ALDS1_10_C()
    EDPC_F()
Problem p03170 (python)

Fixed submission:
import sys
# gcd
# from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
# from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, K = mi()
a = lmi()
dp = [False] * (K + 1)

for i in range(1, K + 1):
    for j in a:
        if i >= j and not dp[i - j]:
            dp[i] = True

if dp[K]:
    print("First")
else:
    print("Second")

Buggy submission (verdict: Runtime Error):
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, K = mi()
a = lmi()
a.insert(0, -12)
dp = [False] * (K + 1)

for i in range(1, K + 1):
    for j in a:
        if i >= j and not dp[i - j]:
            dp[i] = True

if dp[K]:
    print("First")
else:
    print("Second")
Problem p03210 (python)

Fixed submission:
N = int(input())

if N == 3:
    print("YES")
elif N == 5:
    print("YES")
elif N == 7:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())

if n == 3:
  print("YES")
elif n == 5:
  print("YES")
elif n == 7:
  print("YES")
Problem p03309 (python)

Fixed submission:
from statistics import median

N = int(input())
A = list(map(int,input().split()))
Asort = sorted([A[i]-i-1 for i in range(N)])
# print(Asort)

b_tmp = int(median(Asort))

submin = [abs(A[i]-b_tmp-i-1) for i in range(N)]
# print(submin)
minA = sum(submin)

print(minA)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Asort = sorted([A[i]-i-1 for i in range(N)])

if N%2 == 0:
    b_tmp = Asort[N//2]
else:
    b_tmp = (Asort[N//2] + Asort[N//2 + 1])// 2
# print(b_tmp)
minA = 10**9
for b in range(b_tmp-1,b_tmp+2):
    submin = [abs(A[i]-b-i-1) for i in range(N)]
    # print(submin)
    minA = min(sum(submin),minA)

print(minA)
Problem p03550 (python)

Fixed submission:
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
# fin = open('in_4.txt', 'r')
# sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    # †私は証明のない決め打ちを提出しました†
    if N == 1:
        print(abs(a[-1]-W))
    elif abs(a[-1] - W) > abs(a[-1] - a[-2]):
        print(abs(a[-1] - W))
    else:
        print(abs(a[-1] - a[-2]))

Buggy submission (verdict: Runtime Error):
import sys
# gcd
from fractions import gcd
# 切り上げ，切り捨て
# from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
# from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
# from collections import Counter
# import math
# from functools import reduce
#
# input関係の定義
fin = open('in_4.txt', 'r')
sys.stdin = fin
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Z = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"

    # write code
    # †私は証明のない決め打ちを提出しました†
    if N == 1:
        print(abs(a[-1]-W))
    elif abs(a[-1] - W) > abs(a[-1] - a[-2]):
        print(abs(a[-1] - W))
    else:
        print(abs(a[-1] - a[-2]))
Problem p02657 (python)

Fixed submission:
list = input().split(" ")

a = int(list[0])
b = int(list[1])

print(a * b)

Buggy submission (verdict: Runtime Error):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return print(-1)
    return print(score)

check(a1 , b2)

Buggy submission (verdict: Runtime Error):
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  now = 10 ** 18
  if '0' in b:
    return print(0)
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return print(-1)
    
    return print(score)

check(a1 , b2)
Problem p02658 (python)

Fixed submission:
a1 = int(input())
b2 = input().split(" ")

def check(a , b):
  score = 1
  if '0' in b:
    return 0
  else:
    for i in range(a):
      score *= int(b[i])
      if score > 10 ** 18:
        return -1
    
    return score

print(check(a1 , b2))

Buggy submission (verdict: Runtime Error):
a = int(input())

score = 1
for i in range(a):
  b = int(input())
  score *= b
 
if score > 10 ** 18:
  print(-1)
else:
  print(score)
Problem p02784 (python)

Fixed submission:
H, N = map(int, input().split())
A = list(map(int,input().split()))

sum = 0

for i in range(len(A)):
    sum += A[i]

if(sum >= H):
    print("Yes")
else:
    print("No")

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

sum = 0

for i in range(A.length()):
    sum += A[i]

if(sum >= H):
    print("Yes")
else:
    print("No")
Problem p02642 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.sort()
amax = a[-1]
isok = [True]*(amax+1)
ans = 0
if n == 1:
    print(1)
    exit()
for i in range(n):
    x = a[i]
    if isok[x]:
        if i == 0 and a[i] != a[i+1]:
            ans += 1
        elif i == n-1 and a[i] != a[i-1]:
            ans += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            ans += 1
        orix = x
        while x<=amax:
            isok[x]=False
            x+=orix
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
amax = a[-1]
isok = [True]*(amax+1)
ans = 0

for i in range(n):
    x = a[i]
    if isok[x]:
        if i == 0 and a[i] != a[i+1]:
            ans += 1
        elif i == n-1 and a[i] != a[i-1]:
            ans += 1
        elif a[i] != a[i+1] and a[i] != a[i-1]:
            ans += 1
        orix = x
        while x<=amax:
            isok[x]=False
            x+=orix
print(ans)
Problem p02683 (python)

Fixed submission:
n,m,x=map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]

ans = 1234567890123

for bit in range(1<<n):
    syu = [0]*m
    cost = 0
    for i in range(n):
        if (bit>>i)&1:
            cost += ca[i][0]
            for j in range(1,m+1):
                syu[j-1] += ca[i][j]
    ok = True
    for i in range(m):
        if syu[i] < x:
            ok = False

    if ok:
        ans = min(ans,cost)
print(ans if ans != 1234567890123 else -1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)

n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
inf = float('inf')

def solve(s):
    if len(s) == n:
        res = 0
        li = [0]*n
        for i in range(n):
            if s[i] == '1':
                res += ca[i][0]
                for j in range(m):
                    li[j] += ca[i][j+1]

        if all(a >= x for a in li):
            return res
        else:
            return inf
    
    else:
        return min(solve(s+'1'), solve(s+'0'))

print(solve(""))
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
ans = [-1] * 4

for _ in range(m):
    s,c=map(int,input().split())
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()
    
if n == 1:
    print(ans[1] if ans[1]!=-1 else 0)
else:
    if ans[1] == 0:
        print(-1)
        exit()
    if ans[1] == -1:
        ans[1] = 1
    for i in range(2,n+1):
        if ans[i] == -1:
            ans[i] = 0
    res = 0
    for i in range(1,n+1):
        res*=10
        res += ans[i]
    print(res)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans =[-1] * (n+1)
for _ in range(m):
    s,c = map(int,input().split())
    if ans[s] == -1 or ans[s] == c:
        ans[s] = c
    else:
        print(-1)
        exit()

for i in range(1,n+1):
    if ans[i] == -1:
        ans[i] = 0
if ans[1] == 0:
    print(-1)
else:
    print(ans[1]*100 + ans[2]*10+ans[3])
Problem p02768 (python)

Fixed submission:
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
        res %= mod
        res *= pow(i+1,mod-2,mod)
        res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
    for i in range(nu):
        res/=i+1
    res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)
Problem p02788 (python)

Fixed submission:
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort()

import collections
pq=collections.deque()

ans = 0
totalDamage = 0


for i in range(n):
    x,h = xh[i]
    while len(pq) > 0 and pq[0][0] < x:
        totalDamage -= pq[0][1]
        pq.popleft()
    h -=totalDamage
    if h <= 0:
        continue
    num = (h + a -1) //a
    ans += num
    dam = num*a
    totalDamage += dam
    pq.append((x+2*d,dam))

print(ans)

Buggy submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=itemgetter(0))

import collections
pq=collections.deque()

ans = 0
totalDamage = 0


for i in range(n):
    x,h = xh[i]
    if len(pq) and pq[0][0] < x:
        totalDamage -= pq[0][1]
        pq.popleft()
    h -=totalDamage
    if h <= 0:
        continue
    num = (h + a -1) //a
    ans += num
    dam = num*a
    totalDamage += dam
    pq.append((x+2*d,dam))

print(ans)

Buggy submission (verdict: Runtime Error):
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort(key=itemgetter(0))

import collections
q=collections.deque()

ans = 0
totalDamage = 0


for i in range(n):
    x,h = xh[i]
    if len(q) and q[0][0] < x:
        totalDamage -= q[0][1]
        q.popleft()
    h -=totalDamage
    if h <= 0:
        continue
    num = (h + a -1) //a
    ans += num
    dam = num*a
    totalDamage += dam
    q.append((x+2*d,dam))

print(ans)
Problem p02812 (python)

Fixed submission:
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
		cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
for i in range(n-2):
	if s[i:i+3] == "ABC":
	[]	cnt+=1
print(cnt)
Problem p02823 (python)

Fixed submission:
x,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min( a + (b-a-1)//2, x - b + 1 + (b-a-1)//2) )

Buggy submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
if (b-a)%2 == 0:
    print((b-a)//2)
else:
    print(min( a + (b-a-1)//2, n - b + 1 + (b-a-1)//2) )
Problem p02850 (python)

Fixed submission:
from queue import deque

n=int(input())
ab = [list(map(int,input().split()))for i in range(n-1)]
g = [[]for i in range(n)]
for i,j in ab:
    g[i-1].append(j-1)
ans = {}
banColor = [-1]*n

q = deque([])
q.append(0)
ma = 0

while q:
    nord = q.popleft()
    offset = 0
    for idx,value in enumerate(g[nord]):
        if idx ==banColor[nord]:
            offset += 1
        ans[(nord,value)]= idx + offset
        banColor[value] = idx+offset
        q.append(value)
        ma = max(ma,idx+offset+1)
print(ma)
for i,j in ab:
    print(ans[(i-1,j-1)]+1)

Buggy submission (verdict: Runtime Error):

AtCoder Beginner Contest 146
 日本語 
 sawakee (Guest) 
コンテスト時間: 2019-11-24(日) 21:00 ~ 2019-11-24(日) 22:40 (100分)AtCoderホームへ戻る
 トップ
 問題
 質問
 提出
 提出結果
 順位表
 バーチャル順位表
 コードテスト
 解説
D - Coloring Edges on Tree / 
実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 
400
 点

問題文
N
 頂点の木 
G
 が与えられます。 頂点には 
1
 から 
N
 までの番号がついており、
i
 本目の辺は頂点 
a
i
 と頂点 
b
i
 を結んでいます。

G
 の辺を何色かで塗り分けることを考えます。 このとき、各頂点について、その頂点を端点に持つ辺の色がすべて相異なるようにしたいです。

上記の条件を満たす塗り分けの中で、使用する色の数が最小であるようなものを 
1
 つ構築してください。

制約
2
≤
N
≤
10
5
1
≤
a
i
<
b
i
≤
N
入力はすべて整数
与えられるグラフは木である
入力
入力は以下の形式で標準入力から与えられる。

N

a
1
 
b
1

a
2
 
b
2

⋮

a
N
−
1
 
b
N
−
1

出力
出力は 
N
 行からなる。

1
 行目に使用する色の数 
K
 を出力せよ。

i
+
1
 行目 
(
1
≤
i
≤
N
−
1
)
 に 
i
 番目の辺の色を表す整数 
c
i
 を出力せよ。ここで 
1
≤
c
i
≤
K
 でなければならない。

問題文中の条件を満たし、使用する色の数が最小であるような塗り分けが複数存在するときは、そのうちのどれを出力しても構わない。

入力例 1 
Copy
3
1 2
2 3
出力例 1 
Copy
2
1
2
入力例 2 
Copy
8
1 2
2 3
2 4
2 5
4 7
5 6
6 8
出力例 2 
Copy
4
1
2
3
4
1
1
2
入力例 3 
Copy
6
1 2
1 3
1 4
1 5
1 6
出力例 3 
Copy
5
1
2
3
4
5
言語
ソースコード
1
​
※ 512 KiB まで
※ ソースコードは「Main.拡張子」で保存されます




FacebookTwitterHatena共有
ルール 用語集
利用規約 プライバシーポリシー 個人情報保護方針 企業情報 よくある質問 お問い合わせ 資料請求
Copyright Since 2012 ©AtCoder Inc. All rights reserved.
 ページトップ
Problem p02921 (python)

Fixed submission:
s=input()
t=input()
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s,t=map(int,input().split())
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
s,t=map(int,input().split())
ans=0
for i in range(3):
	if s[i]==t[i]:
		ans+=1
print(nas)