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

Fixed submission:
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,M=pin()
    cond=M<N
    print(["unsafe","safe"][cond])
#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
#s_cu = [] 
counter = [0] * 2019

counter[0] += 1
temp=""
for i in range(1, n+1):
    c=s.pop()
    temp = c + (temp if i != 1 else "")
    #s_cu.append(temp)
    counter[int(temp) % 2019] += 1

ans = 0
for i in counter:
    ans += (i * (i - 1)) // 2

print(ans)
Problem p02712 (python)

Fixed submission:
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    ans=0
    for i in range(1,k+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    
    
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())

def resolve():
    k,=pin()
    ans=0
    for i in range(1,k+1):
        if i%3!=0 and i%5!=0:
            ans+=i
    print(ans)
    
    
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じ,るの忘れてるだろ
"""
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """15"""
        output = """60"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000"""
        output = """266666333332"""
        self.assertIO(input, output)


if __name__ == "__main__":
   　resolve()
Problem p02829 (python)

Fixed submission:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)






def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
        
#input
def resolve():
    A=[0,1,2,3]
    A[int(input())]=0
    A[int(input())]=0
    print(sorted(A)[-1])
    #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
1"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """1
2"""
        output = """3"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans = a+b if (b%a==0) else b-a
print(ans)

Buggy submission (verdict: Runtime Error):
list=[1,2,3]
for i in range(2):
    list.pop(int(input())-1)
print(list[-1])
Problem p03127 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())




def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(m))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    A=tupin()
    
    from math import gcd

    temp=A[0]
    for i in range(1,N):
          temp=gcd(temp,A[i])
    print(temp)
    
#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    A=tupin()
    
    from math import gcd

    temp=A[0]
    for i in range(N-1):
          temp=gcd(temp,A[i])
    print(temp)
#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())




def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(m))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())

import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)

print(gcd_list(m))
Problem p03137 (python)

Fixed submission:
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
入力Pを何個かの塊にわかる
塊の中では1個の駒による操作が行われる、
1回にとなりの1ますに歯科移動できない
すなわちそのなかでの最大と最小の差の絶対値

"""
#solution:
#潜 影 蛇 手 ! !
N,M=pin()
P=sorted(list(pin()))#大小関係を整理する
#print("*",P)
PP=[abs(P[j+1]-P[j]) for j in range(M-1)]
#print(PP)
Q=sorted(PP)
#print(Q)
if N>=M:#この場合必ず1個の拠点に1個以上のコマが置けるのでこのままでいい
    print(0)
else:
    for i in range(N-1):
        Q.pop()
    print(sum(Q))

Buggy submission (verdict: Runtime Error):
入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
入力Pを何個かの塊にわかる
塊の中では1個の駒による操作が行われる、
1回にとなりの1ますに歯科移動できない
すなわちそのなかでの最大と最小の差の絶対値

"""
#solution:
#潜 影 蛇 手 ! !
N,M=pin()
P=sorted(list(pin()))#大小関係を整理する
#print("*",P)
PP=[abs(P[j+1]-P[j]) for j in range(M-1)]
#print(PP)
Q=sorted(PP)
#print(Q)
if N>=M:#この場合必ず1個の拠点に1個以上のコマが置けるのでこのままでいい
    print(0)
else:
    for i in range(N-1):
        Q.pop()
    print(sum(Q))
Problem p03208 (python)

Fixed submission:
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    H=[int(input()) for i in range(N)]
    H.sort()
    #print(H)
    ans=1000000000
    for i in range(N-K+1):
        ans=min(H[i+K-1]-H[i],ans)
    print(ans)
#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    H=[int(input()) for i in range(N)]
    H.sort()
    ans=1000000000
    for i in range(N-K+1):
        temp=[H[i],H[i+1],H[i+2]]
        xam=max(temp)
        nim=min(temp)
        ans=min(xam-nim,ans)
    print(ans)
#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tup(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,K=pin()
    H=[int(input()) for i in range(N)]
    H.sort()
    ans=1000000000
    for i in range(N-K+1):
        temp=[H[i],H[i+1],H[i+2]]
        xam=max(temp)
        nim=min(temp)
        ans=min(xam-nim,ans)
    print(ans)
#%%submit!
resolve()
Problem p03345 (python)

Fixed submission:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    
    k=K%2
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    if k%2:t=(-1)*t
    print(t)
    #print(A,B,C)


#%%submit!
resolve()

Buggy submission (verdict: Runtime Error):
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    for i in range(K):
        x,y,z=B+C,C+A,A+B
        A,B,C=x,y,z
        t=(A-B)
        if abs(t)>10**18:print("Unfair");return
    print(t)
    
#%%submit!    
resolve()

Buggy submission (verdict: Runtime Error):
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,K=pin()
    for i in range(K)
        x,y,z=B+C,C+A,A+B
        A,B,C=x,y,z
    t=(A-B)
    if abs(t)>10**18:print("Unfair");return
    print(t)
    
#%%submit!    
resolve()
Problem p03821 (python)

Fixed submission:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

#繰り返し自乗法だよ
#これはnのp乗をmで割ったあまりをだすよ
def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans
#mod上でのaの逆元を出すよ
"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))
#逆元を使うと容易に頑張れるｃ
def conbination(n,a,mod=10**9+7):
    #cはイラない
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
#操作から作れるものの組み合わせは何個かー＞同じものでも違う方法で構成できるかから考える方法もある
"""
"""

#solution:

#input
N,=pin()
ans=0
A,B=[],[]
for _ in range(N):
    a,b=pin()
    A.append(a)
    B.append(b)
for i in range(N-1,-1,-1):
    #print("b-a=",(B[i]-A[i])%B[i])
    temp=(B[i]-A[i]-ans)%B[i]
    #print(temp)
    ans+=temp
print(ans)
#print(h)
#print(m)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())

"""
"""

#solution:

#input
x,y=pin()
t=abs(y)-abs(x)
if x*y<0:
    t=abs(t)+1
elif t*(y-x)<0:
    t=abs(t)+2
print(t)
#print(["No","Yes"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
Problem p02729 (python)

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

result = 0
if(n >=1):
    result = result + n*(n-1)/2

if(m >=1):
    result = result + m*(m-1)/2

print(int(result))

Buggy submission (verdict: Runtime Error):
import utility

n,m = map(int, input().split(" "))

result = 0
if(n >=1):
    result = result + n*(n-1)/2

if(m >=1):
    result = result + m*(m-1)/2

print(int(result))
Problem p02707 (python)

Fixed submission:
N=int(input())
A=[int (x) for x in input().split()]
p=[0]*N
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N=int(input())
A=[int (x) for x in input().split()]
p=[0]*N
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np

N=int(input())
A=[int (x) for x in input().split()]
p=[0]*N
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
#A = np.array([int(i) for i in input().split()])
#A = [int (x) for x in input().split()]
#N=int(input())

N=int(input())
A=[int (x) for x in input().split()]
p=[0]*N
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
#A = np.array([int(i) for i in input().split()])
#N=int(input())

N=int(input())
A = np.array([int(i) for i in input().split()])
p=np.zeros(N)
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))

Buggy submission (verdict: Runtime Error):
import numpy as np
#A = np.array([int(i) for i in input().split()])
#N=int(input())

N=int(input())
A = np.array([int(i) for i in input().split()])
p=np.zeros(N)
for i in range(N-1):
    p[A[i]-1]+=1
for i in range(N):
    print(int(p[i]))
Problem p02759 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
  print(int(N/2))
else:
  print(int(N//2 +1))

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

if N % 2 == 0:
  print(N/2)
else:
  print(N//2　+1)
Problem p02773 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
s = sorted(S)
import collections
c = collections.Counter(s)
C = c.most_common()
 
a = C[0][1]
b = []
for i in range(len(C)):
  if a == C[i][1]:
    b.append(C[i][0])
  else:
    break
B = sorted(b)
 
for i in B:
  print(i)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
s = sorted(S)
import collections
c = collections.Counter(s)
C = c.most_common()

a = C[0][1]
b = []
for i in range(N):
  if a == C[i][1]:
    b.append(C[i][0])
  else:
    break
B = sorted(b)

for i in B:
  print(i)
Problem p02777 (python)

Fixed submission:
S,T = map(str,input().split())
A,B = map(int,input().split())
U = input()

if U == S:
  A -=1
else:
  B -= 1

print(str(A) +" " + str(B))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
P = list(map(int, input().split()))
 
A = 0
for i in range(N-K+1):
  B = 0
  for j in range(K):
    B += (1 + P[i+j])/2
    if B > A:
      A = B
 
print(A)
Problem p02819 (python)

Fixed submission:
X = int(input())
if X == 2:
    print(2)
    exit()
while True:
    N = int(X**0.5)
    for i in range(1,N):
        if X % (i+1) == 0:
            break
        else:
          if i == N - 1:
            print(X)
            exit()
    X += 1

Buggy submission (verdict: Runtime Error):
X = int(input())
while True:
  for i in range(1,N):
    if X % (i+1) == 0:
      break
    else:
      if i == N - 1:
        print(X)
        exit()
  X += 1

Buggy submission (verdict: Runtime Error):
X = int(input())
while True:
  for i in range(1,N):
    if X % (i+1) == 0:
      break
    else:
      if i == N - 1:
        print(X)
        exit()
  X += 1
Problem p02836 (python)

Fixed submission:
S = input()
N = len(S)
n = N // 2
A = 0

if N % 2 == 0:
  T = S[:n]
  U = S[:n-1:-1]
else:
  T = S[:n]
  U = S[:n:-1]
for i in range(n):
  if T[i] != U[i]:
    A += 1
print(A)

Buggy submission (verdict: Runtime Error):
S = input()
N = len(S)
n = N // 2
A = 0

if N % 2 == 0:
  T = S[:n]
  U = S[n::-1].reverse()
print(T)
print(U)
Problem p03013 (python)

Fixed submission:
N,M = map(int,input().split())
a = set(int(input()) for x in range(M))
A = [0]*(N+1)
mod = 1000000007
A[0] = 1
if not(1 in a):
  A[1] = 1
for i in range(2,N+1):
    if i in a:
      A[i] = 0
    else:
      A[i] = (A[i-2] + A[i-1]) % mod
print(A[N])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
A = [0]*N
if not(1 in a):
  A[0] = 1
if not(2 in a):
  A[1] = 1 + A[0]

for i in range(2,N):
    if i+1 in a:
      A[i] = 0
    else:
      A[i] = A[i-2] + A[i-1]
print(A[N-1] %1000000007)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
A = [0]*N
if not(1 in a):
  A[0] = 1
if not(2 in a):
  A[1] = 1 + A[0]

for i in range(2,N):
  A[i] = A[i-2] + A[i-1]
  if i+1 in a:
    A[i] = 0
  A[i] %= 1000000007
print(A[N-1])
Problem p02623 (python)

Fixed submission:
import numpy as np
import sys
read = sys.stdin.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

ans = 0
left = M
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.buffer.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

left = 0
for i, b in enumerate(B):
    if b > K:
        left = i - 1
        break

ans = 0
if A[-1] + B[-1] <= K:
    ans = N + M
else:
    for i in range(len(A)):
        if A[i] > K:
            break

        while A[i] + B[left] > K:
            left -= 1

        ans = max(ans, left + i)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
read = sys.stdin.buffer.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

left = M
for i, b in enumerate(B):
    if b > K:
        left = i

ans = 0
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)
Problem p02695 (python)

Fixed submission:
import sys
input = sys.stdin.readline

from itertools import combinations_with_replacement as cwr

def main():
    N, M, Q = map(int, input().split())
    I = [list(map(int, input().split())) for _ in range(Q)]
    J = cwr(range(1, M+1), N)
    ans = []

    for j in J:
        tmp = 0
        for i in I:
            a, b, c, d = i
            tmp += d if j[b-1] - j[a-1] == c else 0
        ans.append(tmp)

    print(max(ans))

    
if __name__  == '__main__':
    main()

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

import numpy as np

def main():
    N, M, Q = map(int, input().split())
    I = [list(map(int, input().split())) for _ in range(Q)]
    A = np.array([M] * N)
    ans = []
    
    j = 1
    while True:
        if A[-1] == 1:
            break
        
        tmp = 0
        for i in I:
            a, b, c, d = i
            tmp += d if A[b-1] - A[a-1] == c else 0

        ans.append(tmp)

        if A[0] == 1:
            n = A[j]
            A[:j+1] = n - 1
            if n - 1 == 1:
                j += 1
        else:
            A[0] -= 1
            
    print(max(ans))    


if __name__ == '__main__':
    main()
Problem p02862 (python)

Fixed submission:
import math

x, y = map(int, input().split())
mod = 10 ** 9 + 7
a = (2 * y - x) / 3
b = (2 * x - y) / 3

if (not a.is_integer()) or (not b.is_integer()) or \
    (a < 0) or (b < 0):
    print(0)
else:
    a, b = int(a), int(b)
    I = [1] * (a + b + 1)
    for n in range(1, a+b+1):
        I[n] = I[n-1] * n
        I[n] %= mod
    i, j, k = I[a+b], I[a], I[b]
    j = pow(j, mod-2, mod)
    k = pow(k, mod-2, mod)

    ans = i * j * k
    ans %= mod
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

x, y = map(int, input().split())
mod = 10 ** 9 + 7
a = (2 * y - x) / 3
b = (2 * x - y) / 3

if (not a.is_integer()) or (not b.is_integer()):
    print(0)
else:
    a, b = int(a), int(b)
    I = [1] * (a + b + 1)
    for n in range(1, a+b+1):
        I[n] = I[n-1] * n
        I[n] %= mod
    i, j, k = I[a+b], I[a], I[b]
    j = pow(j, mod-2, mod)
    k = pow(k, mod-2, mod)

    ans = i * j * k
    ans %= mod
    print(ans)
Problem p02912 (python)

Fixed submission:
import heapq

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
q = []
for a in A:
    heapq.heappush(q, -a)
    
for _ in range(M):
    tmp = -heapq.heappop(q)
    heapq.heappush(q, -(tmp//2))
print(-sum(q))
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
mod = 1e+9+7
dp = [0]*(n+1)
dp[0] = 1
isPass = [1]*(n+1)
for _ in range(m):
    a = int(input())
    isPass[a] = 0
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if isPass[j]:
            dp[j] += dp[i]
            dp[j] %= mod
print(int(dp[n]))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
dp = [0] * (N+1)
dp[0] = 1
e = 1e9 + 7
for i in range(1, N+1):
    if i not in A:
        if i == 1:
            dp[i] = 1
            continue
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % e
print(int(dp[N])