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

Fixed submission:
#import numpy as np
words = lambda t : list(map(t, input().split()))



h,w = words(int)
wq = [0] * w

grid = []
for i in range(h):
    grid.append(list(input()))

ans = 0
for i in range(h):
    j = 0
    while j < w:
        #print(i,j, grid[i][j])
        if grid[i][j] == '#':
            wq[j] = 0
            j+=1
            continue
        k = 0
        while j+k < w:
            if grid[i][j+k] == '.':
                k += 1
            else:
                break
        #print(i,j,k)
        if k + h > ans:
            for x in range(j,j+k):
                vplus = 0
                if not wq[x] == 0:
                    vplus = wq[x]
                else:
                    for vi in range(i-1,-1,-1):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                    for vi in range(i+1,h):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                ans = max(ans, vplus+k)
                wq[x] = vplus
        j += k
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
words = lambda t : list(map(t, input().split()))



h,w = words(int)
wq = [0] * w

grid = []
for i in range(h):
    grid.append(list(input()))

ans = 0
for i in range(h):
    j = 0
    while j < w:
        #print(i,j, grid[i][j])
        if grid[i][j] == '#':
            wq[j] = 0
            j+=1
            continue
        k = 0
        while j+k < w:
            if grid[i][j+k] == '.':
                k += 1
            else:
                break
        #print(i,j,k)
        if k + h > ans:
            for x in range(j,j+k):
                vplus = 0
                if not wq[x] == 0:
                    vplus = wq[x]
                else:
                    for vi in range(i-1,-1,-1):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                    for vi in range(i+1,h):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                ans = max(ans, vplus+k)
                wq[x] = vplus
        j += k
print(ans)
Problem p03061 (python)

Fixed submission:
import math

words = lambda t : list(map(t, input().split()))


def gcd (a,b):
    if a > b:
        t = b
        b = a
        b = t
    v = b
    while (a % b != 0):
        t = a % b
        a = b
        b = t
        v = b
    return v


n = int(input())
a = words(int)

if n == 2:
    print(max(a[0],a[1]))

else:
    cgcdm1 = max(gcd(a[0],a[1]),gcd(a[1],a[2]),gcd(a[2],a[0]))
    allgcd = gcd(a[0],gcd(a[1],a[2]))

    for i in range(3,len(a)):
        cgcdm1 = max(gcd(cgcdm1,a[i]),allgcd)
        allgcd = gcd(allgcd, a[i])

    print(cgcdm1)


def gcd (a,b):
    if a > b:
        t = b
        b = a
        b = t
    v = b
    while (a % b != 0):
        t = a % b
        a = b
        b = t
        v = b
    return v

Buggy submission (verdict: Runtime Error):
import math

words = lambda t : list(map(t, input().split()))

n = int(input())
a = words(int)

if n == 2:
    print(max(a[0],a[1]))

else:
    cgcdm1 = max(math.gcd(a[0],a[1]),math.gcd(a[1],a[2]),math.gcd(a[2],a[0]))
    allgcd = math.gcd(a[0],math.gcd(a[1],a[2]))

    for i in range(3,n):
        cgcdm1 = max(math.gcd(cgcdm1,a[i]),allgcd)
        allgcd = math.gcd(allgcd, a[i])

    print(cgcdm1)
Problem p03095 (python)

Fixed submission:

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10**9 + 7

def main():
    n = int(input())
    s = input()

    counts = [0]*26
    for c in s:
        counts[indmap[c]] += 1

    #print(counts)
    total = 1
    for k in counts:
        total *= (k+1)

    print((total-1) % MOD)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10L**9 + 7L

def main():
    n = int(input())
    s = input()

    counts = [0L]*26
    for c in s:
        counts[indmap[c]] += 1L

    #print(counts)
    total = 1L
    for k in counts:
        total *= (k+1L)
        total % MOD
    print(total-1)

main()

Buggy submission (verdict: Runtime Error):

alphabet = "abcdefghijklmnopqrstuvwxyz"
indmap = {}
for i, c in enumerate(alphabet):
    indmap[c] = i

MOD = 10L**9L + 7L

def main():
    n = int(input())
    s = input()

    counts = [0L]*26
    for c in s:
        counts[indmap[c]] += 1L

    #print(counts)
    total = 1L
    for k in counts:
        total *= (k+1L)
        total % MOD
    print(total-1)

main()
Problem p03231 (python)

Fixed submission:
import fractions as math

def lcm(x,y):
    return (x * y) // math.gcd(x,y)

def main():
    (n,m) = map(int, input().split())
    s = input()
    t = input()

    nmlcm = lcm(n,m)
    nn = nmlcm // n
    mm = nmlcm // m
    nnmmlcm = lcm(nn,mm)

    for i in range(nmlcm // nnmmlcm):
        #print(nnmmlcm*i)
        if s[nnmmlcm*i//nn] != t[nnmmlcm*i//mm]:
            print(-1)
            return
    print(nmlcm)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import fractions as math

def lcm(x,y):
    return (x * y) // math.gcd(x,y)

if __name__ == "__main__":
    main()

def main():
    (n,m) = map(int, input().split())
    s = input()
    t = input()

    nmlcm = lcm(n,m)
    nn = nmlcm // n
    mm = nmlcm // m

    for i in range(lcm(n,m)):
        if i%nn == 0 and i%mm == 0 and s[i//nn] != t[i//mm]:
            print(-1)
            return
    print(nmlcm)
Problem p03246 (python)

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

if n == 2:
    if l[0] == l[1]:
        print(1)
    else:
        print(0)
else:
    a = []
    b = []
    for i in range(n):
        if i % 2 == 0:
            a.append(l[i])
        else:
            b.append(l[i])

    da = {}
    for e in a:
        if e not in da:
            da[e] = (1,e)
        else:
            da[e] = (da[e][0]+1,da[e][1])

    db = {}
    for e in b:
        if e not in db:
            db[e] = (1,e)
        else:
            db[e] = (db[e][0]+1,db[e][1])

    da[-1] = (0,-1)
    db[-1] = (0,-1)

    la = list(reversed(sorted(list(da.values()))))
    lb = list(reversed(sorted(list(db.values()))))
    #print(la)
    #print(lb)



    if la[0][1] == lb[0][1]:
        ans = n- (la[0][0] + max(la[1][0],lb[1][0]))
    else:
        ans = n - (la[0][0] + lb[0][0])
    print(ans)

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

if n == 2:
    if l[0] == l[1]:
        print(1)
    else:
        print(0)
else:
    a = []
    b = []
    for i in range(n):
        if i % 2 == 0:
            a.append(l[i])
        else:
            b.append(l[i])

    da = {}
    for e in a:
        if e not in da:
            da[e] = (1,e)
        else:
            da[e] = (da[e][0]+1,da[e][1])

    db = {}
    for e in b:
        if e not in db:
            db[e] = (1,e)
        else:
            db[e] = (db[e][0]+1,db[e][1])

    la = list(reversed(sorted(list(da.values()))))
    lb = list(reversed(sorted(list(db.values()))))
    #print(la)
    #print(lb)

    la[-1] = (0,-1)
    lb[-1] = (0,-1)

    if la[0][1] == lb[0][1]:
        ans = n- (la[0][0] + max(la[1][0],lb[1][0]))
    else:
        ans = n - (la[0][0] + lb[0][0])
    print(ans)
Problem p03361 (python)

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

cs = []
cs.append("." * (b+2))
for i in range(a):
  s = "." + input() + "."
  cs.append(s)
cs.append("." * (b+2))

ans = True
for i in range(a):
  for j in range(b):
    if cs[i][j] == "#":
      if cs[i-1][j] == "." and cs[i][j-1] == "." and cs[i+1][j] == "." and cs[i][j+1] == ".":
        ans = False
        break
    if not ans:
      break
  if not ans:
    break
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b = list(map(int, input().spit()))

cs = []
cs.append("." * (b+2))
for i in range(a):
  s = "." + input() + "."
  cs.append(s)
cs.append("." * (b+2))

ans = True
for i in range(a):
  for j in range(b):
    if cs[i][j] == "#":
      if cs[i-1][j] == "." and cs[i][j-1] == "." and cs[i+1][j] == "." and cs[i][j+1] == ".":
        ans = False
        break
    if not ans:
      break
  if not ans:
    break
if ans:
  print("Yes")
else:
  print("No")
Problem p03435 (python)

Fixed submission:
mat = []
 
for i in range(3):
  a = list(map(int, input().split()))
  mat.append(a)
  
ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
mat = []
 
for i in range(3):
  a = list(map(int, input().split()))
 
ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] and mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] and mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True
 
if ans:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
mat = []

for i in range(3):
  a = list(map(int, input().split()))

ans = False
if mat[1][0] - mat[0][0] == mat[1][1] - mat[0][1] == mat[1][2] - mat[0][2]:
  if mat[2][0] - mat[0][0] == mat[2][1] - mat[0][1] == mat[2][2] - mat[0][2]:
    ans = True

if ans:
  print("Yes")
else:
  print("No")
Problem p02760 (python)

Fixed submission:
a =[list(map(int, input().split())) for i in range(3)] 
n=int(input())
ans = 'No'
for i in range(n):
    d = int(input())
    for i in range(3):
        for j in range(3):
            if d == a[i][j]:
                a[i][j]=0

if a[0][0] == 0 and a[1][1] == 0 and a[2][2]==0:
    ans = 'Yes'
elif a[0][2] == 0 and a[1][1] == 0 and a[2][0]==0:
    ans = 'Yes'
else: 
    for l in a:
        if sum(l)==0:
            ans = 'Yes'
            break
    for l in zip(*a):
        if sum(l)==0:
            ans = 'Yes'
            break
        

print(ans)

Buggy submission (verdict: Runtime Error):
import math
h,w = map(int, input().split())
print(1 if h==1 or w==1 else math.ceil(h*w/2) )
Problem p02791 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
ans = 0
m = 200001
for i in p:
    if i<m:
        ans+=1
        m=i
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if a==0 or b==0 or (a<0 and b>0):
    print(0)
elif b<0 and (b-a)%2==0:
    print('Negative')
else:
    print('Positive')

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
if b==0 or (a<=0 and b>=0):
    print(0)
elif (a<0 and (0-a)%2==1) or (a<0 and b<0 and (b-a)%2==0):
    print('Negative')
else:
    print('Positive')
Problem p02971 (python)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a2 = sorted(a, reverse = True)
for i in a:
    print(a2[0] if i!=a2[0] else a2[1])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]
a2 = sorted(set(a), reverse = True)
for i in a:
    print(a2[0] if i!=a2[0] else a2[1])
Problem p03076 (python)

Fixed submission:
import math
m = [int(input()) for i in range(5)]
n = 10
ans = 0
for i in m:
    ans+= math.ceil(i/10)*10
    if i%10!=0:
        n = min(n, i%10)
print(ans-10+n)

Buggy submission (verdict: Runtime Error):
import math
fp = 10
ans = 0
for i in range(5):
    a = int(input())
    ans+= math.ceil(a/10)*10
    if a%10!=0:
    fp =  min(fp, a%10)
print(ans+fp-10 if fp@!=10 else ans )
Problem p03351 (python)

Fixed submission:
a,b,c,d = map(int, input().split())
print('Yes' if (abs(a-b)<=d and abs(c-b)<=d) or abs(a-c)<=d else 'No')

Buggy submission (verdict: Runtime Error):
x = int(input())
ans = 1
for i in range(2,x+1):
    j = 2
    while i **j <= x:
        ans = max(ans, i**j)
        j+=1
print(ans)
Problem p03971 (python)

Fixed submission:
n,a,b = map(int, input().split())
s = input()
p = a+b
cnt = 0
bcnt = 0
for i in range(n):
    if s[i] == 'a' and cnt < p:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < p and bcnt < b:
        print('Yes')
        cnt+=1
        bcnt+=1
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
x1 = math.ceil(n/1.08)
print(':(' if math.floor(x1*1.08) != n else x1)
Problem p03102 (python)

Fixed submission:
N,M,C = [int(i) for i in input().split()]

B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(N)]

rez = [0]*N

for i in range(M):
  for j in range(N):
    rez[j] += B[i]*A[j][i]

count = 0
for i in rez:
  if i+C>0:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
H,W = [int(i) for i in input().split()]

h1 = H//2
h2 = H-h1

w2 = W//2
w1 = W-w2

if H==1 or W==1:
  print(1)
else:
  print(h2*w1+h1*w2)
Problem p03456 (python)

Fixed submission:
a,b = [int(i) for i in input().split()]

res = int(str(a)+str(b))**0.5
if int(res)==res:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b = [int(i) for in input().split()]

res = int(str(a)+str(b))**0.5
if int(res)==res:
  print("Yes")
else:
  print("No")
Problem p02866 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
# from collections import defaultdict, deque
# from math import sqrt, gcd, factorial, tan, pi, sin, cos
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

MOD = 998244353

def solve():
    n = int(input())
    d = [int(x) for x in input().split()]
    f = [0] * n
    for e in d:
        f[e] += 1
    
    ok = f[0] == 1 and d[0] == 0
    z = 0
    ans = 1
    for i in range(1, n):
        if (f[i] == 0): z = 1
        if (z and f[i]): ok = 0
        ans *= pow(f[i-1], f[i], MOD)
        ans %= MOD
    print(ans * ok)




t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)

"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
from math import sqrt, gcd, factorial, tan, pi, sin, cos
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

MOD = 998244353

def solve():
    n = int(input())
    d = [int(x) for x in input().split()]
    f = [0] * n
    for e in d:
        f[e] += 1
    
    ok = f[0] == 1
    z = 0
    ans = 1
    for i in range(1, n):
        if (f[i] == 0): z = 1
        if (z and f[i]): ok = 0
        ans *= pow(f[i-1], f[i], MOD)
        ans %= MOD
    print(ans * ok)




t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()



"""
1 -> (1, 2) -> (2 ** 3, 3) -> (3, 1)

"""
Problem p03049 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from collections import deque
from math import sqrt
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

# n = int(input())



def solve():
    n = int(input())
    ans = 0
    a = 0
    b = 0
    c = 0
    for _ in range(n):
        s = input()
        a += s[-1] == 'A' and s[0] != 'B'
        b += s[0] == 'B' and s[-1] != 'A'
        c += s[0] == 'B' and s[-1] == 'A'
        ans += s.replace('AB', "*").count('*')
    if (a+b) > 0:
        print(ans + c + min(a, b))
    else:
        if c:
            c -= 1
        print(ans + c)
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""




"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque
from math import sqrt, gcd
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

# n = int(input())



def solve():
    n = int(input())
    ans = 0
    a = 0
    b = 0
    for _ in range(n):
        s = input()
        a += s[-1] == 'A'
        b += s[0] == 'B'
        ans += s.replace('AB', "*").count('*')
    print(ans + min(a, b))
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""




"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
from math import sqrt, gcd
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

# n = int(input())



def solve():
    n = int(input())
    ans = 0
    a = 0
    b = 0
    for _ in range(n):
        s = input()
        a += s[-1] == 'A'
        b += s[0] == 'B'
        ans += s.replace('AB', "*").count('*')
    print(ans + min(a, b))
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""




"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque
from math import sqrt, gcd, factorial
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline()[:-1]

# n = int(input())



def solve():
    n = int(input())
    ans = 0
    a = 0
    b = 0
    for _ in range(n):
        s = input()
        a += s[-1] == 'A'
        b += s[0] == 'B'
        ans += s.replace('AB', "*").count('*')
    print(ans + min(a, b))
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""




"""
Problem p03231 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    s = input()
    t = input()
    g = gcd(n, m)
    ans = n * m // g
    a, b = n // g, m // g
    x, y = 0, 0
    for i in range(g):
        if s[x] != t[y]:
            print(-1)
            return
        x += a
        y += b
    print(ans)
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 2 2 2 2

"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    s = input()
    t = input()
    g = gcd(n, m)
    ans = n * m // g
    a, b = n // g, m // g
    x, y = 0, 0
    for i in range(g):
        if s[x] != x[y]:
            print(-1)
            return
        x += a
        y += b
    print(ans)
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 2 2 2 2

"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    s = input()
    t = input()
    l = n * m // gcd(n, m)
    if n * m != l:
        if n > m:
            n, m = m, n
            s, t = t, s
        ok = 1
        for i in range(n):
            if s[i] != t[i * l // n]:
                ok = 0
        if ok:
            print(l)
        else:
            print(-1)
    else:
        print(l)

    




        
    

    
    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

2 2 2 2 2

"""
Problem p03612 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x)-1 for x in input().split()]
    ans = 0
    for i in range(n):
        if a[i] == i:
            if i + 1 < n:
                a[i], a[i+1] = a[i+1], a[i]
            else:
                a[i], a[i-1] = a[i-1], a[i]
            ans += 1

    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x)-1 for x in input().split()]
    ans = 0
    for i in range(n):
        if a[i] == i:
            if 1:
                a[i], a[i+1] = a[i+1], a[i]
            elif i + 1 == n:
                a[i], a[i-1] = a[i-1], a[i]
            ans += 1

    print(ans)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""
Problem p02772 (python)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
ans = True
for i in li:
  if i % 2 == 1:
    continue
  else:
    if i % 3 != 0 and i % 5 != 0:
      ans = False
      break
if ans:
  print("APPROVED")
else:
  print("DENIED")

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
ans = true
for i in li:
  if i % 2 == 1:
    ans = false
    break
  else:
    if i % 3 != 0 and i % 5 != 0:
      ans = false
      break
if ans:
  print("APPROVED")
else:
  print("DENIED")
Problem p02958 (python)

Fixed submission:
def main(li):
    count = 0
    for i in range(len(li)):
        if li[i] != i + 1:
            count += 1
    if count in [0, 2]:
        return True
    else:
        False


if __name__ == '__main__':
    n = int(input())
    li = list(map(int, input().split()))
    if main(li):
        print('YES')
    else:
        print('NO')

Buggy submission (verdict: Runtime Error):
def main(li):
    count = 0
    for i in range(len(li)):
        if li[i] != i + 1:
            count += 1
    if count == 2 or count == 0:
      return True
   	else:
      return False


if __name__ == '__main__':
    li = list(map(int, input().split()))
    if main(li):
        print('YES')
    else:
        print('NO')
Problem p02988 (python)

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

ans = 0
for i in range(1, n-1):
  if li[i-1] > li[i] and li[i+1] < li[i]:
    ans += 1
  if li[i-1] < li[i] and li[i+1] > li[i]:
    ans += 1
print(ans)

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

ans = 0
for i in range(1, n-1):
  if li[i-1] > li[i] and li[i+1] < li[i]:
    ans += 1
  if if li[i-1] < li[i] and li[i+1] > li[i]:
    ans += 1
print(ans)
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
  print(B)
elif A <= 12 and A >= 6:
  print(B//2)
elif A <= 5:
  print("0")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
t_list = [[0] * 2 for _ in range(M)]
ans = 0
is_change = False
for i in range(M):
  t_list[i] = list(map(int, input().split()))
bottom = t_list[i][0]
up = t_list[i][1]
for i in range(M):
  t_bottom = t_list[i][0]
  t_up = t_list[i][1]
  if t_bottom > bottom and t_bottom <= up:
    bottom = t_bottom
    is_change = True
  if t_up < up and t_up >= bottom :
    up = t_up
    is_change = True
if is_change:
  print(ans)
else:
  print("0")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A >= 13:
  print(B)
elif A <= 12 and A > 6:
  print(B//2)
else if A <= 5:
  print("0")