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

Fixed submission:
import math
n, k = map(int, input().split())
p = 0
for i in range(1,n+1):
  temp = 1
  while i * temp < k:
    temp *= 2
  p += 1/temp
print(p/n)

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
p = 0
for i in range(1,n+1):
  tmp = 1
  while i * temp < k:
    temp *= 2
  p += 1/temp
print(p/n)

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
p = 0
for i in range(1,num):
  tmp = 1
  while i * temp < k:
    temp *= 2
  p += 1/temp
print(p/n)

Buggy submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
p = 0
for i in range(1,num):
  tmp = 1
  while i * temp < k:
    temp *= 2
  asn += 1/temp
print(p/n)
Problem p03014 (python)

Fixed submission:
import sys
from bisect import bisect_left
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

h, w = lmi()
s = [input() for i in range(h)]

a = [[] for i in range(h)]
al = [[] for i in range(h)]
b = [[] for i in range(w)]
bl = [[] for i in range(w)]
for i in range(h):
    k = 0
    for j in range(w):
        if s[i][j] == '.':
            k += 1
            if j == w-1:
                a[i].append(k)
                al[i].append(j)
        elif j != 0 and s[i][j-1] == '.':
            a[i].append(k)
            al[i].append(j-1)
            k = 0

for i in range(w):
    k = 0
    for j in range(h):
        if s[j][i] == '.':
            k += 1
            if j == h-1:
                b[i].append(k)
                bl[i].append(j)
        elif j != 0 and s[j-1][i] == '.':
            b[i].append(k)
            bl[i].append(j-1)
            k = 0
'''
print(a)
print(al)
print(b)
print(bl)
'''

ans = 0
for i in range(h):
    k = 0
    c = -1
    for j in range(w):
        if s[i][j] == '.':
            c = a[i][k]
            d = b[j][bisect_left(bl[j], i)]
            #print(c,d)
            ans = max(ans, c+d-1)
        elif j != 0 and s[i][j-1] == '.' and c != -1:
                k += 1
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
s = [input() for i in range(h)]

cnt = [[None] * w for i in range(h)]
for i in range(h):
    j = 0
    while j < w:
        if s[i][j] == '#':
            cnt[i][j] = 0
            j += 1
            continue
        l = 0
        while j+l < w:
            if s[i][j+l] == '#':
                break
            l += 1
        for k in range(l):
            cnt[i][j+k] = l
        j += l

for i in range(w):
    j = 0
    while j < h:
        if s[j][i] == '#':
            cnt[i][j] = 0
            j += 1
            continue
        l = 0
        while j+l < h:
            if s[j+l][i] == '#':
                break
            l += 1
        for k in range(l):
            cnt[j+k][i] += l
        j += l

ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j])
Problem p03061 (python)

Fixed submission:
def gcd(a,b):
    if a == 0:
        return b
    if b == 0:
        return a
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r
    return a


n = int(input())
A = [int(i) for i in input().split()]

L = [0] * n
L[0] = 0
L[1] = A[0]
for i in range(2,n):
    L[i] = gcd(L[i-1], A[i-1])

R = [0] * n
R[-1] = 0
R[-2] = A[-1]
for i in range(3,n+1):
    R[-i] = gcd(R[-i+1], A[-i+1])

M = [gcd(L[i],R[i]) for i in range(n)]

print(max(M))

Buggy submission (verdict: Runtime Error):
#import math
#from functools import reduce

def gcd(a,b):
    r = 1
    while r > 0:
        r = a % b
        a = b
        b = r

    return a


n = int(input())
a = [int(i) for i in input().split()]
L = [0] * (n-1)
for i in range(n-1):
    L[i] = gcd(a[i],a[i+1])

if n == 3:
    L.append(gcd(a[0],a[2]))

L.sort(reverse=True)

for l in L:
    c = 0
    for i in a:
        if i % l != 0:
            c += 1
    if c <= 1:
        ans = l
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

n = int(input())
a = [int(i) for i in input().split()]
L = [0] * n

for i in range(n):
    aa = a[:]
    aa.pop(i)
    L[i] = reduce(math.gcd, aa)

print(max(L))
Problem p03078 (python)

Fixed submission:
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(x * y, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])

Buggy submission (verdict: Runtime Error):
x, y, z, k = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i in range(min(a * b, k)):
    for c in C:
        ABC.append(AB[i] + c)

ABC.sort(reverse=True)

for i in range(k):
    print(ABC[i])
Problem p03103 (python)

Fixed submission:
N, M = map(int, input().split())
d = [list(map(int, input().split())) for i in range(N)]
d.sort(key=lambda x:(x[0],x[1]))

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = dict([list(map(int, input().split()))[::-1] for i in range(N)])
d = sorted(d.items(), key=lambda x: x[1])
c = p = i = 0

while c < M:
    if c + d[i][0] <= M:
        c += d[i][0]
        p += d[i][1] * d[i][0]
        i += 1
    else:
        p += d[i][1] * (M - c)
        print(c)
        break

print(p)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
d = dict([list(map(int, input().split())) for i in range(N)])
d = sorted(d.items())

c = p = i = 0

while c < M:
    if c + d[i][1] <= M:
        c += d[i][1]
        p += d[i][0] * d[i][1]
        i += 1
    else:
        p += d[i][0] * (M - c)
        break

print(p)
Problem p03160 (python)

Fixed submission:
n = int(input())
H = [int(i) for i in input().split()]

H1 = [abs(H[i]-H[i-1]) for i in range(1,n)]
H2 = [abs(H[i]-H[i-2]) for i in range(2,n)]

D = [0]*n
D[1] = H1[0]

for i in range(2,n):
    D[i] = min(D[i-1] + H1[i-1], D[i-2] + H2[i-2])

print(D[-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
I = float('inf')
H = [int(i) for i in input().split()]
H1 = [abs(H[i]-H[i-1]) for i in range(1,n)] + [I]
H2 = [abs(H[i]-H[i-2]) for i in range(2,n)] + [I]*2

def dfs(c,a):
    if c >= n - 1:
        return a
    else:
        r1 = dfs(c + 1, a + H1[c])
        r2 = dfs(c + 2, a + H2[c])
        return min(r1,r2)


print(dfs(0,0))
Problem p03081 (python)

Fixed submission:
N, Q = list(map(int, input().split()))
s = input()

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if pl < N - 1 and s[pl + 1] == lt[q]:
            pl += 1
        if pr <= N - 1 and s[pr] == lt[q]:
            pr += 1
    else:
        if pr > 0 and s[pr - 1] == lt[q]:
            pr -= 1
        if pl >= 0 and s[pl] == lt[q]:
            pl -= 1

print(max(pr - pl -1, 0))

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

lt = []
ld = []

for q in range(Q):
    t, d = input().split()
    lt.append(t)
    ld.append(d)

pl = -1
pr = N

for q in range(Q-1, -1, -1):
    if ld[q] == 'L':
        if s[pl + 1] == lt[q]:
            pl += 1
    else:
        if s[pr - 1] == lt[q]:
            pr -= 1

print(max(pr - pl -1, 0))
Problem p03351 (python)

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

if (abs(b - a) <= d and abs(c - b) <= d) or abs(a - c) <= d:
    print("Yes")
else:
    print("No")

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

f1 = ""
f2 = ""
f3 = ""
f4 = ""
f5 = ""
for a1 in range(0, len(s)):
	for a2 in range(a1 + 1, len(s) + 1):
		w = s[a1:a2]
		if w != f1 and w != f2 and w != f3 and w != f4 and w != f5:
			if f5 == "" or w < f5:
				f5 = w
			if f4 == "" or f5 < f4:
				t = f4
				f4 = f5
				f5 = t
			if f3 == "" or f4 < f3:
				t = f3
				f3 = f4
				f4 = t
			if f2 == "" or f3 < f2:
				t = f2
				f2 = f3
				f3 = t
			if f1 == "" or f2 < f1:
				t = f1
				f1 = f2
				f2 = t

if K == 1:
	print(f1)
if K == 2:
	print(f2)
if K == 3:
	print(f3)
if K == 4:
	print(f4)
if K == 5:
	print(f5)
Problem p03361 (python)

Fixed submission:
h, w = map(int, input().split())
masu = [[0 for x in range(w)] for y in range(h)]
for y in range(0, h):
    z = list(input())
    for x in range(0, w):
        masu[y][x] = z[x]
hantei = "Yes"
for y in range(0, h):
    for x in range(0, w):
        if (masu[y][x] == "#"):
            if (not((y > 0 and masu[y - 1][x] == "#") or (y < h - 1 and masu[y + 1][x] == "#") or (x > 0 and masu[y][x - 1] == "#") or (x < w - 1 and masu[y][x + 1] == "#"))):
                hantei = "No"
print (hantei)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
masu = [[0 for y in range(h)] for x in range(w)]
for y in range(0, h):
    z = list(input())
    for x in range(0, w):
        masu[y][x] = z[x]
hantei = "Yes"
for y in range(0, h):
    for x in range(0, w):
        if (masu[y][x] == "#"):
            if (not((y > 0 and masu[y - 1][x] == "#") or (y < h - 1 and masu[y + 1][x] == "#") or (x > 0 and masu[y][x - 1] == "#") or (x < w - 1 and masu[y][x + 1] == "#"))):
                hantei = "No"
print (hantei)
Problem p02842 (python)

Fixed submission:
n=int(input()) 
flag = False
for i in range(100*n,100*(n+1)):
  if i%108 == 0:
    x = int(i//108)
    print(x)
    flag = True
    break
if flag == False:
  print(':(')

Buggy submission (verdict: Runtime Error):
n=int(input()) 
flag = False
for i in range(100*n,100*(n+1)):
  if i%108 == 0:
    x == int(i//108)
    print(x)
    flag == True
    break
if flag == False:
  print(':(')

Buggy submission (verdict: Runtime Error):
n=int(input()) 
flag == False
for i in range(100*n,100*(n+1)):
  if i%108 == 0:
    x == int(i//108)
    print(x)
    flag == True
    break
if flag == False:
  print(':(')
Problem p03644 (python)

Fixed submission:
N = int(input())
l = [1,2,4,8,16,32,64][::-1]
for i in l:
  if N >= i:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [1,2,4,8,16,32,64]{[::-1]
for i in l:
  if N >= i:
    print(i)
    break
Problem p03086 (python)

Fixed submission:
A = list(input())
S = ['A','C','G','T']
count = 0
a = []
a.append(count)
for i in A:
  if i in S:
    count += 1
    a.append(count)
  else:
    count = 0
print(max(a))

Buggy submission (verdict: Runtime Error):
A = list(input())
S = ['A','C','G','T']
count = 0
a = []
for i in A:
  if i in S:
    count += 1
  else:
    a.append(count)
    count = 0
print(max(a))
Problem p03146 (python)

Fixed submission:
A = int(input())
p = A
C = []
while A not in C:
  C.append(A)
  if A % 2 == 0:
    A = A//2
  else:
    A = A*3+1
print(len(C)+1)

Buggy submission (verdict: Runtime Error):
A = int(input())
p = A
count = 0
if A = 1:
  count == 0
else:
  count =2
while A != 1:
  if A % 2 == 0:
    A = A // 2
    count = count + 1
  else:
    A = A * 3 + 1
    count = count + 1
print(count)
Problem p03251 (python)

Fixed submission:
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
x = max(X,max(A))
y = min(Y,min(B))
 
if Y >= x and y > X and y > x:
  print('No War')
else:
  print('War')

Buggy submission (verdict: Runtime Error):
N,M,X,Y = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
a = max(A)
b = min(B)

flag = a>0 and b>0
if flag and a-b <= 0 and (Y < a and b <= X) and a<b:
  print('No War')
elif not flag and a-b >= 0 and (Y > a and b => X) and a>b:
  print('No War')
else:
  ('War')
Problem p03254 (python)

Fixed submission:
A,B = map(int,input().split())
X =list(map(int,input().split()))
X = sorted(X)
count = 0
j=len(X)
if B == sum(X):
  print(len(X))
else:
  for i in range(A):
    a = X.pop(0)
    B=B - a
    if B >= 0:
      count += 1
    if B >= 0 and count == j:
      count = count -1
  print(count)

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
X =list(map(int,input().split()))
X = sorted(X)
count = 0
if B == sum(X):
  print(len(X))
elif B >= min(x):
  print(0)
else:
  for i in range(A):
    a = X.pop(0)
    B=B - a
    if B >= 0:
      count += 1
  print(count)
Problem p03284 (python)

Fixed submission:
a,b = map(int,input().split())
c = a % b == 0
if c:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
A = int(input())
if (A%4 == 3 or A%4 == 0 or A%7 == 4 or A%7== 0) and A != 3:
  print('Yes')
else:
  print('No')
Problem p03285 (python)

Fixed submission:
A = int(input())
Flag = False
for i in range((A//4)+1):
  for j in range((A//7)+1):
    if 4*i + 7*j == A:
      Flag = True
if Flag:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = int(input())
if (A%4 == 3 or A%4 == 0 A%7 == 4 or A%7 == 0) and A != 3:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = int(input())
if (A%4 == 3 or A%4 == 0 A%7 == 4 or A%7) and A != 3:
  print('Yes')
else:
  print('No')
Problem p03293 (python)

Fixed submission:
A = input()
B = input()
t = False
for a in range(len(A)):
  k=A[a:len(A)]+A[:a]
  if k == B:
    t = True
    break;
    
if t:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
for a in range(len(A)):
  k=A[a:len(A)]+A[:a]
  if k == B:
    t = True
    break;
    
if t:
  print('Yes')
else:
  print('No')
Problem p03316 (python)

Fixed submission:
A = input()
B = int(A)
b = 0
for _ in range(len(A)):
  b += B % 10
  B = B//10
if int(A) % b == 0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = input()
m = 0
for i in range(A):
  c = set(B[:i])
  a = set(B[i:])
  l = a & c
  m = max(m,len(l))
print(m)
Problem p03544 (python)

Fixed submission:
l_0 = 2
l_1 = 1
A = int(input())
if A == 0:
  print(l_0)
elif A == 1:
  print(l_1)
else:
  for i in range(A-1):
    if i%2 != 0:
      p = l_1
      l_1 = l_0 + l_1
      l_0 = p
    else:
      p = l_1
      l_1 = l_0 + l_1
      l_0 = p
  print(max(l_0,l_1))

Buggy submission (verdict: Runtime Error):
l_0 = 2
l_1 = 1
A = int(input())
if 　A == 0:
  print(l_0)
elif A == 1:
  print(l_1)
else:
  for i in range(1,A+1):
    if i%2 != 0
	    l_1 = l_0 + L_1 
    else:
      l_0 = l_0 + L_1
Problem p03610 (python)

Fixed submission:
A = input()
a =[A[i] for i in range(0,len(A),2)]
print(','.join(a).replace(',',''))

Buggy submission (verdict: Runtime Error):
A = input()
a =[A[i] for i in range(0,len(A)+1,2)]
print(','.join(a).replace(',',''))
Problem p03680 (python)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
Next = 1
for i in range(N):
  if Next == 2:
    Next = A[Next-1]
    p = i
    break;
  else:
    Next = A[Next-1]
    p = -1
print(p)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
Next = 0
for i in range(N):
  if Next == 2:
    Next = A[Next]
    p = i
    break;
  else:
    Next = A[Next-1]
    p = -1
print(p)
Problem p03993 (python)

Fixed submission:
p = int(input())
ans = 0
*A,= map(int,input().split())
for j,i in enumerate(A):
  if A[A[j]-1]==j+1:
    ans+=1
print(ans//2)

Buggy submission (verdict: Runtime Error):
p = int(input())
A = list(map(int,input().split()))
a = list(range(1,p+1))
count = 0
for j,i in zip(a,A):
  if i == a[A.index(j)]:
    count += 1
print(count//2)
Problem p03998 (python)

Fixed submission:
A = input() + ' '
B = input() + ' '
C = input() + ' '
s = A[0]
while(len(A) != 0 and s != ' ' ) and  (len(B) != 0 and s != ' ') and (len(B) != 0 and s != ' '):
  if s == 'a':
    s = A[0]
    A = A[1:]
  elif s == 'b':
    s = B[0]
    B = B[1:]
  else:
    s = C[0]
    C = C[1:]
  if s == ' ':
    break;
  else:
    p = s
print(p.upper())

Buggy submission (verdict: Runtime Error):
aca
accc
ca

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()
s = A[0]
while(len(A) != 0) and  (len(B) != 0) and (len(B) != 0):
    if s == 'a':
      s = A[0]
      A = A[1:]
    elif s == 'b':
      s = B[0]
      B = B[1:]
    else:
      s = C[0]
      C = C[1:]
print(s.upper())
Problem p04033 (python)

Fixed submission:
A,B =  map(int,input().split())
b = []
count = 0
if A <0 and B<0:
  A =A + B
if A <= 0 and B >= 0:
  print('Zero')
elif A<0 and A % 2 == 0:
  print('Negative')
else:
  print('Positive')

Buggy submission (verdict: Runtime Error):
A,B =  map(int,input().split())
b = []
Zeroflag = False
count = 0
for i in range(A,B+1,1):
  b.append(i)
if 0 in b:
  zeroflag = True
for i in b:
  if i < 0:
    count += 1
if zeroflag:
  print('Zero')
elif count %2 == 0:
  print('Positive')
else:
  print('Negative')

Buggy submission (verdict: Runtime Error):
A,B =  map(int,input().split())
b = []
Zeroflag = False
count = 0
for i in range(A,B+1,1):
  b.append(i)
if 0 in b:
  zeroflag = True
for i in b:
  if i < 0:
    count += 1
if zeroflag:
  print('Zero')
elif count %2 == 0:
  print('Positive')
else:
  print('Negative')
Problem p02947 (python)

Fixed submission:
from collections import Counter
n = int(input())
s = list(map(lambda x: ''.join(sorted(x)) ,[list(input()) for i in range(n)]))
ans = 0
for i in Counter(s).values():
    ans += int(i*(i-1) / 2)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import math
n = int(input())
s = list(map(lambda x: ''.join(sorted(x)) ,[list(input()) for i in range(n)]))
ans = 0
for i in Counter(s).values():
    ans += int(math.factorial(i) / 2)
print(ans)
Problem p02995 (python)

Fixed submission:
a, b , c, d = map(int, input().split())
def num_cm(a, b, m):
    if a % m == 0:
        return (b//m) - (a//m) + 1 
    else:
        return (b//m) - (a//m)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a    
lcm = (c * d) // gcd(c, d)
ans =  b - a + 1 - num_cm(a, b, c) - num_cm(a, b, d) + num_cm(a, b, lcm)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a, b , c, d = map(int, input().split())
def num_cm(a, b, m):
    if a % m == 0:
        return (b//m) - (a//m) + 1 
    else:
        return (b//m) - (a//m)
lcm = (c * d) // math.gcd(c, d)
ans =  b - a + 1 - num_cm(a, b, c) - num_cm(a, b, d) + num_cm(a, b, lcm)
print(ans)
Problem p03044 (python)

Fixed submission:
from collections import deque
N = int(input())
A = [list(map(int, input().split())) for _ in range(N-1)]

T = [[] for _ in range(N)]
for i in range(N-1):
    u, v = A[i][0] - 1, A[i][1] - 1
    d = A[i][2] % 2 
    T[u].append([v, d])
    T[v].append([u, d])

visited = [True] + [False] * (N-1)
ans = [0] * N
que = deque([0]) 
while len(que) > 0:
    q = que.popleft()
    for v, d in T[q]:
        if visited[v]:
            pass
        else:
            que.append(v)
            visited[v] = True
            ans[v] = (ans[q] + d) % 2
            
for a in ans:
    print(a)

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

T = [[] for _ in range(N)]
for i in range(N-1):
    u, v = A[i][0] - 1, A[i][1] - 1
    d = A[i][2] % 2 
    T[u].append([v, d])
    T[v].append([u, d])

visited = [True] + [False] * (N-1)
ans = [0] * N
def find(i):
    if visited[i]:
        for t in T[i]:
            if visited[t[0]]:
                pass
            else:
                ans[t[0]] = t[1]
                visited[t[0]] = True
                find(t[0])

find(0)                
            
for a in ans:
    print(a)
Problem p03085 (python)

Fixed submission:
b = input()

dic = {'A':'T', 'T':'A', 'C':'G', 'G':'C' }

print(dic[b])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for _ in range(Q)]

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i: i+2] == 'AC' else 0)
ans = [t[LR[i][1] - 1] - t[LR[i][0] - 1] for i in range(Q)]    

print(*ans, sep='\n')
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
num = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [0]*(N+1)
INF = -float('inf')

for i in range(1, N+1):
    dp[i] = max([dp[i-num[j]] if i - num[j] >= 0 else INF for j in A]) + 1

A.sort(reverse = True)
ans = ''
tmp = N
while tmp > 0:
    for a in A:
        if tmp-num[a] >=0:
            if dp[tmp-num[a]] == dp[tmp] - 1:
                break
    ans += str(a)
    tmp -= num[a]
    
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
num = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

dp = [0]*(N+1)
INF = -float('inf')

for i in range(1, N+1):
    dp[i] = max([dp[i-num[j]] if i - num[j] >= 0 else INF for j in A]) + 1

A.sort(reverse = True)
ans = ''
tmp = N
while tmp > 0:
    for a in A:
        if dp[tmp-num[a]] == dp[tmp] - 1:
            ans += str(a)
            break
    else:
        ans += str(a)
    tmp -= num[a]
    
print(ans)
Problem p02923 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
c=0
mx=0
for i in range(n-1):
  if a[i]>=a[i+1]:
    c+=1
    if mx<c:
        mx=c
  if a[i]<a[i+1]:
    c=0
print(mx)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(n):
  if a[i]>=a[i+1]:
    c+=1
  if a[i]<a[i+1]:
    c=0
print(c)
Problem p02845 (python)

Fixed submission:
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    A = read_ints()
    print(solve(N, A))


MOD = 1000000007


def solve(N, A):
    c = 1
    nums = [0, 0, 0]

    for a in A:
        z = nums.count(a)
        if z == 0:
            return 0
        c *= z
        c %= MOD
        nums[nums.index(a)] = a + 1

    return c


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/python3

import os
import sys


def main():
    N = read_int()
    A = read_ints()
    print(solve(N, A))


MOD = 1000000007


def solve(N, A):
    c = 1
    nums = [0, 0, 0]

    for a in A:
        z = nums.count(a)
        c *= z
        c %= MOD
        nums[nums.index(a)] = a + 1

    return c


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


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

Fixed submission:
def solve(target):
    n = int(target / 100)
    if n * 100 <= target <= n * 105:
        print(1)
    else:
        print(0)

solve(int(input()))

Buggy submission (verdict: Runtime Error):
def solve(target):
    n = int(target / 100)
    if n  100 <= target <= n  105:
        print(1)
    else:
        print(0)

solve(int(input()))
Problem p03047 (python)

Fixed submission:
n,k = map(int,input().split())
print(n-k+1)

Buggy submission (verdict: Runtime Error):
    n,k = map(int,input().split())
    print(n-k+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().spolit())
print(n-k+1)