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

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

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = list(map(int, input().split()))

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    
    for s in d:
      count += switch_states[s-1]
      
    if count % 2 != P[di]:
      ans -= 1
      break

  ans += 1
        
        
print(ans)

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

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = map(int, input().split())

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    for s in d:
      count += switch_states[s-1]
      if count % 2 == P[di]:
        ans += 1
        
        
print(ans)

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

ds = []
for _ in range(M):
  ds.append(list(map(int, input().split()))[1:])

P = map(int, input().split())

ans = 0

for i in range(2**N):
  switch_states = [(i >> j) & 1 for j in range(N)]
  
  for di, d in enumerate(ds):
    count = 0
    for s in d:
      count += switch_states[s-1]
      if count % 2 == P[di]:
        ans += 1
        
        
print(ans)
Problem p03037 (python)

Fixed submission:
N, M = map(int, input().split())
 
left, right = 1, N
 
for _ in range(M):
  L, R = map(int, input().split())
  
  left = max(L, left)
  right = min(R, right)

ans = right - left + 1 if left <= right else 0 
print(ans)

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

hashset = None

for _ in range(M):
	for L, R in map(int, input().split()):
      if hashset is None:
        hashset = set(range(L, R+1))
      else:
        hashset = hashset & set(range(L, R+1))

print(len(hashset))
Problem p02780 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    ps = LI()
    sum_ = [0]
    for i in range(1, 1000+2):
        sum_.append(sum_[i-1] + i)
    kitai = [ke / (i + 1) for i, ke in enumerate(sum_[1:])]
    kitai2 = [kitai[i-1] for i in ps]
    ans = []
    for i in range(n-k+1):
        if i == 0:
            ans.append(sum(kitai2[0:k]))
        else:
            ans.append(ans[i-1] - kitai2[i-1] + kitai2[i+k-1])
    print(max(ans))




if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    ps = LI()
    sum_ = [0]
    for i in range(1, 1000+1):
        sum_.append(sum_[i-1] + i)
    kitai = [ke / (i + 1) for i, ke in enumerate(sum_[1:])]
    kitai2 = [kitai[i-1] for i in ps]
    ans = []
    for i in range(n-k):
        if i == 0:
            ans.append(sum(kitai2[0:0+k]))
        else:
            ans.append(ans[i-1] - kitai2[i-1] + kitai2[i+k-1])
    print(max(ans))



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    ps = LI()
    sum_ = [0]
    for i in range(1, 1000+1):
        sum_.append(sum_[i-1] + i)
    kitai = [k / (i + 1) for i, k in enumerate(sum_[1:])]
    kitai2 = [kitai[i-1] for i in ps]
    ans = []
    for i in range(n-k):
        ans.append(sum(kitai2[i:i+k]))
    print(max(ans))



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

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(60)]
    ans = 0
    for i in range(60):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for j in range(60):
            v, i = i % 2, i // 2
            keta[j] += v
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i] % MOD
        ans = ans % MOD

    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    kaizyo = [1]
    kaizyo_append = kaizyo.append
    keta = [0 for i in range(59)]
    ans = 0
    for i in range(59):
        kaizyo_append(kaizyo[i] * 2 % MOD)
    for i in a_s:
        for i, v in enumerate(bin(i)[:1:-1]):
            keta[i] += int(v)
    # print(kaizyo)
    # print(keta)
    for i, v in enumerate(keta):
        c = v * (n-v) % MOD
        ans += c * kaizyo[i]
        ans = ans % MOD
        # print(ans, c, kaizyo[i])

    print(ans)
if __name__ == '__main__':
    main()
Problem p02845 (python)

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    a_s = LI()
    d = [0, 0, 0]
    ans = 1
    for i in a_s:
        flag = True
        tmp = 0
        for index, j in enumerate(d):
            # print(i, j)
            if j == i:
                tmp += 1
                if flag:
                    d[index] += 1
                    flag = False
        ans = ans * tmp % MOD
        # print(d, tmp, i, ans)
    print(ans)





if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    t1, t2 = LI()
    a1, a2 = LI()
    b1, b2 = LI()

    if a1 < b1:
        tmp = b1
        b1 = a1
        a1 = tmp

        tmp = b2
        b2 = a2
        a2 = tmp

    l1 = (a1 - b1) * t1
    l2 = (a2 - b2) * t2
    l3 = l1 + l2

    if l3 == 0:
        print("infinity")
        return
    if l3 > 0:
        print(0)
        return
    ans = 1
    if l1 % (-l3) == 0:
        print(ans + 2 * (l1 // (-l3)) - 1)
        return
    print(ans + 2 * (l1 // (-l3)))






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

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return str(sys.stdin.readline())

def main():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(int(n / 2 * (n - 1)))

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

Fixed submission:
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(n  * (n - 1) // 2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(n * (n - 1)　/ 2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n = II()
    print(int((n / 2 * (n - 1)))

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

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF=10**9+7
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    n, k = LI()
    graph=[[] for i in range(n)]
    for i in range(n-1):
        a,b=LI()
        graph[a-1].append(b-1)
        graph[b-1].append(a-1)
    ans=1
    check=[False]*n
    stack=[0]
    ans=1
    while len(stack)>0:
        x=stack.pop()
        check[x]=True
        count=0
        for i in graph[x]:
            if not check[i]:
                count+=1
                stack.append(i)
        if x==0:
            temp=1
            for i in range(count):
                temp=temp*(k-1-i)%INF
            ans=ans*temp%INF
        else:
            temp=1
            for i in range(count):
                temp=temp*(k-2-i)%INF
            ans=ans*temp%INF
    print((ans*k)%INF)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))

def main():
    n, k = LI()
    g = [[] for i in range(n+1)]
    for i in range(n-1):
        a, b = LI()
        g[a].append(b)
        g[b].append(a)

    s = 1
    Q = [s]
    ans = k
    Qappend = Q.append
    searched = [0] * (n*1)
    searched[s] = 1
    while len(Q) != 0:
        v = Q.pop()
        if v == s:
            cand = k - 1
        else:
            cand = k - 2
        for i in g[v]:
            if searched[i] == 1:
                continue
            searched[i] = 1
            ans *= cand
            cand -= 1
            Qappend(i)
        ans = ans % MOD
    print(ans % MOD)


if __name__ == "__main__":
    main()
Problem p02991 (python)

Fixed submission:
import sys
from fractions import gcd
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, m = LI()
    g = [[] for i in range(3*(n+1))]
    for i in range(m):
        u, v = LI()
        g[u].append(v + n + 1)
        g[u + n + 1].append(v + 2*(n + 1))
        g[u + 2*(n + 1)].append(v)

    s, t = LI()

    Q = deque([s])
    searched = [0 for i in range(3*(n+1))]
    searched[s] = 1
    depth = [0 for i in range(3*(n+1))]
    while len(Q) != 0:
        v = Q.popleft()
        for i in g[v]:
            if i == t:
                depth[i] = depth[v] + 1
                print(depth[i]//3)
                return
            if searched[i] == 0:
                depth[i] = depth[v] + 1
                Q.append(i)
                searched[i] = 1
    print(-1)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, m = LI()
    g = [set() for i in range(n+1)]
    new_g = [set() for i in range(n+1)]
    new_gg = [set() for i in range(n+1)]
    for i in range(m):
        u, v = LI()
        g[u].add(v)
    s, t = LI()
    for i in range(n+1):
        new = set()
        for j in g[i]:
            new = new | g[j]
        new_g[i] = new_g[i] | new

    for i in range(n+1):
        new = set()
        for j in new_g[i]:
            new = new | g[j]
        new_gg[i] = new_gg[i] | new

    Q = deque([s])
    searched = [0 for i in range(n+1)]
    searched[s] = 1
    depth = [0 for i in range(n+1)]
    while len(Q) != 0:
        v = Q.popleft()
        for i in last[v]:
            if i == t:
                depth[i] = depth[v] + 1
                print(depth[i])
                return
            if searched[i] == 0:
                depth[i] = depth[v] + 1
                Q.append(i)
                searched[i] = 1
    print(-1)


if __name__ == "__main__":
    main()
Problem p02993 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
from collections import defaultdict

num  = S()
for i in range(3):
    if num[i] == num[i+1]:
        print("Bad")
        break
else:
    print("Good")

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

a, b, c, d = LI()
a = a-1

cd = int(c * d / gcd(c, d))
cs = b // c - a // c
ds = b // d - a // d
cds = b // (cd) - a // (cd)
print(b - a - cs - ds + cds)
Problem p02995 (python)

Fixed submission:
import sys
from fractions import gcd
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

a, b, c, d = LI()
a = a-1

cd = int(c * d / gcd(c, d))
cs = b // c - a // c
ds = b // d - a // d
cds = b // (cd) - a // (cd)
print(b - a - cs - ds + cds)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
from collections import defaultdict
import math

a, b, c, d = LI()
a = a-1

cd = int(c * d / math.gcd(c, d))
cs = b // c - a // c
ds = b // d - a // d
cds = b // (cd) - a // (cd)
print(b - a - cs - ds + cds)
Problem p02999 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

x ,a = LI()
if x>= a:
    print(10)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import default

x ,a = LI()
if x>= a:
    print(10)
else:
    print(0)
Problem p03029 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

a, i = LI()
print(int((a * 3 + i) / 2))

Buggy submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return int(input())
from collections import defaultdict
import bisect

n, q = LI()
ds = []
stx = []
ans = [-1 for i in range(q)]
for i in range(n):
    s, t, x = LI()
    stx.append((s, t, x))
for i in range(q):
    d = SI()
    ds.append(d)
# stx = sorted(stx, key=lambda x: x[2])
for s, t, x in stx:
    sx = s - x
    tx = t - x
    i1 = bisect.bisect_left(ds, sx)
    i2 = bisect.bisect_left(ds, tx)
    for i in range(i1, i2):
        if ans[i] == -1 or ans[i] > x:
            ans[i] = x
for i in ans:
    print(i)
Problem p03047 (python)

Fixed submission:
n, k = [int(i) for i in input().split()]
print(n - k + 1)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            # divisors.append(i)
            if i != n // i and i != (n // i - 1) :
                divisors.append(n//i - 1)
    return divisors

n = int(input())
print(sum(make_divisors(n)))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
print n - k + 2

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
return n - k + 1
Problem p02683 (python)

Fixed submission:
n,m,x = map(int,input().split())
A = [[] for _ in range(n)]
for i in range(n):
    A[i] = list( map(int,input().split()) )
    
flag = 0
min_charge = 10**7

for i in range(2**n):
    which = format(i, '#020b')[-n:]
    
    #print(which,end = ':')
    
    charge = 0
    skill = [0 for _ in range(m)]
    for j in range(n):
        if which[j]=='1':
            charge += A[j][0]
            for k in range(m):
                skill[k]+=A[j][k+1]
    flag_skill = 1
    for l in range(m):
        if skill[l] < x:
            flag_skill = 0
    
    
    #print(skill,end=':')
    #print(charge,end=':')    
    
    if flag_skill ==1:
        min_charge = min(min_charge,charge)
    
    #print(flag_skill)

if min_charge == 10**7:
    print(-1)
else:
    print(min_charge)

Buggy submission (verdict: Runtime Error):
n,m,x = map(int,input().split())
A = [[] for _ in range(n)]
for i in range(n):
    A[i] = list( map(int,input().split()) )
    
flag = 0
min_charge = 10**7

for i in range(2**n):
    which = format(i, '#010b')[-n:]
    
    #print(which,end = ':')
    
    charge = 0
    skill = [0 for _ in range(m)]
    for j in range(n):
        if which[j]=='1':
            charge += A[j][0]
            for k in range(m):
                skill[k]+=A[j][k+1]
    flag_skill = 1
    for l in range(m):
        if skill[l] < x:
            flag_skill = 0
    
    
    #print(skill,end=':')
    #print(charge,end=':')    
    
    if flag_skill ==1:
        min_charge = min(min_charge,charge)
    
    #print(flag_skill)

if min_charge == 10**7:
    print(-1)
else:
    print(min_charge)
Problem p02780 (python)

Fixed submission:
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = np.array(p)
e = (p+1)/2
sum_e = []
sum_e.append(np.sum(e[:k]))
for i in range(n-k):
    sum_e.append(sum_e[-1]-e[i]+e[k+i])
print(max(sum_e))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = np.array(p)
e = (p+1)/2
sum_e = []
sum_e.append(np.sum(e[:k]))
for i in range(n-k):
    sum_e.append(sum_e[-1]-e[i]+e[k+i])
print(max(sum_e))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int,input().split())
p = list(map(int,input().split()))
p = np.array(p)
e = (p+1)/2
sum_e = []
sum_e.append(np.sum(e[:k]))
for i in range(n-k):
    sum_e.append(sum_e[-1]-e[i]+e[k+i])
print(max(sum_e))
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split())
penalty = [0]*n
did = [0]*n
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if did[p-1]==0:
            penalty[p-1] +=1
    else:
        did[p-1]=1
for i in range(n):
    penalty[i]*=did[i]
print(sum(did),sum(penalty))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
penalty = np.zeros(n)
did = np.zeros(n)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if did[p-1]==0:
            penalty[p-1] +=1
    else:
        did[p-1]=1
penalty = penalty*did
print(int(sum(did)),int(sum(penalty)))

Buggy submission (verdict: Runtime Error):
import numpy as np
n,m = map(int,input().split())
penalty = np.zeros(n)
done = np.zeros(n)
for i in range(m):
    p,s = input().split()
    p = int(p)
    if s == 'WA':
        if done[p-1]==0:
            penalty[p-1] +=1
    else:
        done[p-1]=1
penalty = penalty*done
print(int(sum(done)),int(sum(penalty)))
Problem p02601 (python)

Fixed submission:

a, b, c = map(int, input().split())
k = int(input())

while a >= b and k > 0:
    b *= 2
    k -= 1

while b >= c and k > 0:
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):

a, b, c = 7, 4, 2
k = int(input())

while a >= b and k > 0:
    b *= 2
    k -= 1

while b >= c and k > 0:
    c *= 2
    k -= 1

if a < b < c:
    print("Yes")
else:
    print("No")
Problem p02602 (python)

Fixed submission:

n, k = map(int, input().split())
a = list(map(int, input().split()))

res = list()

for i in range(k, n):
    if a[i - k] < a[i]:
        res.append("Yes")
    else:
        res.append("No")

for r in res:
    print(r)

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

n, k = map(int, input().split())
a = list(map(int, input().split()))

res = list()

res.append(np.prod(a[:k]))
tmp = res[0]

for i in range(k, n):
    tmp /= a[i - k]
    tmp *= a[i]
    res.append(tmp)

for i in range(1, n - k + 1):
    if res[i - 1] < res[i]:
        print("Yes")
    else:
        print("No")