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

Fixed submission:
h,w=map(int,input().split())
ans=[]
import sys
def s(a,b):
    for i in range(a):
        s=a*b
        x=i*b
        y=((a-i)//2)*b
        z=s-x-y

        d=(a-i)*(b//2)
        e=s-x-d
        ma=max(x,y,z)
        mi=min(x,y,z)
        mc=max(x,e,d)
        mn=min(x,e,d)
        res=min((ma-mi),(mc-mn))
        ans.append(res)
    return min(ans)
        
f=s(h,w)
g=s(w,h)
print(min(f,g))
    
# print(ans)
# print(min(ans))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=[]
import sys
def s(a,b):
    if a%3==1:
        s=a*b
        x=(a//3)*b
        y=((a-(a//3))//2)*b
        z=s-x-y

        e=(a-(a//3))*(b//2)
        d=s-x-e
        ma=max(x,y,z)
        mi=min(x,y,z)
        mc=max(x,e,d)
        mn=min(x,e,d)
        return(min((ma-mi),(mc-mn)))
    elif a%3==2:
        s=a*b
        x=((a//3)+1)*b
        y=((a-(a//3)-1)//2)*b
        z=s-x-y
        e=(a-(a//3)-1)*(b//2)
        d=s-x-e
        ma=max(x,y,z)
        mi=min(x,y,z)
        mc=max(x,e,d)
        mn=min(x,e,d)
        return(min((ma-mi),(mc-mn)))
j=min(h,w)
if (h%3==0)or(w%3==0):
    print(0)
elif j==1:
    print(1)
    sys.exit()
    
else:
    k=s(h,w)
    ans.append(k)
    r=s(w,h)
    ans.append(r)
    
# print(ans)
print(min(ans))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
ans=[]
import sys
def s(a,b):
    if a%3==1:
        s=a*b
        x=(a//3)*b
        y=((a-(a//3))//2)*b
        z=s-x-y

        e=(a-(a//3))*(b//2)
        d=s-x-e
        ma=max(x,y,z)
        mi=min(x,y,z)
        mc=max(x,e,d)
        mn=min(x,e,d)
        return(min((ma-mi),(mc-mn)))
    elif a%3==2:
        s=a*b
        x=((a//3)+1)*b
        y=((a-(a//3)-1)//2)*b
        z=s-x-y
        e=(a-(a//3)-1)*(b//2)
        d=s-x-e
        ma=max(x,y,z)
        mi=min(x,y,z)
        mc=max(x,e,d)
        mn=min(x,e,d)
        return(min((ma-mi),(mc-mn)))

if h<w:
    h,w=w,h
if (h%3==0)or(w%3==0):
    print(0)
else:
    k=s(h,w)
    ans.append(k)
    r=s(w,h)
    ans.append(r)
    
# print(ans)
print(min(ans))
Problem p03739 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
sum=0
cnt=0
# 奇数+
for i in range(n):
    sum+=a[i]
    if i%2==0:
        if sum>=0:
            cnt+=(sum+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-sum)
            sum=1
cnt_sbst=cnt
# 奇数-
cnt=0
sum=0
for i in range(n):
    sum+=a[i]
    if i%2==1:
        if sum>=0:
            cnt+=(sum+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-sum)
            sum=1
cnt_plus=cnt
ans=min(cnt_plus,cnt_sbst)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
sum=0
cnt=0
# 奇数+
for i in range(n):
    sum+=a[i]
    if i%2==0:
        if sum>=0:
            cnt+=(sum+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-sum)
            sum=1
cnt_sbst=cnt
# 奇数-
cnt=0
sum=0
for i in range(n):
    z+=a[i]
    if i%2==1:
        if sum>=0:
            cnt+=(sum+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-sum)
            sum=1
cnt_plus=cnt
ans=min(cnt_plus,cnt_sbst)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
import sys
sum=0
cnt=0
# 奇数+
for i in range(n):
    z+=a[i]
    if i%2==0:
        if z<0:
            sum=z
        else:
            cnt+=(z+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-sum)
            sum=1
cnt_sbst=cnt
# 奇数-
for i in range(n):
    z+=a[i]
    if i%2==1:
        if sum>=0:
            cnt+=(z+1)
            sum=-1
    else:
        if sum<=0:
            cnt+=(1-z)
            sum=1
cnt_plus=cnt
ans=min(cnt_plus,cnt_sbst)
print(ans)
Problem p03828 (python)

Fixed submission:
n=int(input())
mod=10**9+7
arr = {}
def factorization(k):
    temp=k
    for i in range(2,int(-(-k**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp//=i
            if i in arr:
                arr[i]+=cnt
            else:
                arr[i]=cnt
    if temp!=1:
        if temp in arr:
                arr[temp]+=1
        else:
            arr[temp]=1
    if arr==[]:
        if k in arr:
                arr[k]+=1
        else:
            arr[k]=1
for i in range(1,n+1):
    factorization(i)
ans=1

for value in arr.values():
    ans*=(value+1)
    
# print(arr)
print(ans%mod)




# x=0
# k = ans
# for i in range(1,int(k**0.5)+1):
#     if k%i==0:
#         x+=1
#         if i!=n//i:
#             x+=1
# print(x%mod)

Buggy submission (verdict: Runtime Error):
n=int(input())
import math
mod=10**9+7
ans = math.factorial(n)
x=0
k = ans
for i in range(1,int(k**0.5)+1):
    if k%i==0:
        x+=1
        if i!=n//i:
            x+=1
print(x%mod)
Problem p03844 (python)

Fixed submission:
x = input().split()
a = int(x[0])
c = int(x[2])
if x[1] == '+':
    print(a + c)
elif x[1] == '-':
    print(a - c)
else:
    print('error')

Buggy submission (verdict: Runtime Error):
a,b,c = input().split()
a = int(a)
c = int(b)

if b == '+':
    print(a + c)
elif b == '-':
    print(a - c)
else:
    print('error')
Problem p02917 (python)

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

a = [0]*n
b.append(1000000)

a[0] = b[0]
for i in range(1,n):
    a[i] = min(b[i],b[i-1])

print(sum(a))

Buggy submission (verdict: Runtime Error):
n=int(input())
b = list(map(int,input().split()))
b.append(1000000)
li = []
for i in range(n-1):
    if((b[i]>0) and b[i] <= b[i+1] ):
        li.append(b[i])

print(sum(li)+min(li))
Problem p04045 (python)

Fixed submission:
def UnlikeNum(nums,price):
    for num in nums:
        if(str(num) in str(price)):
            return True
    
    return False

N, K = map(int,input().split())
D = list(map(int,input().split()))
while(UnlikeNum(D,N)):
    N+=1
print(N)

Buggy submission (verdict: Runtime Error):
def UnlikeNum(nums,price):
    for num in nums:
        if(str(num) in str(price)):
            return True
    
    return False

N, K = map(int,input().split())
D = [int(input()) for k in range(K)]
while(UnlikeNum(D,N)):
    N+=1
print(N)
Problem p02553 (python)

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

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print(max(a*c, b*c, b*d a*d))
Problem p02573 (python)

Fixed submission:
from collections import deque

N, M = map(int, input().split())
friends = [[] for _ in range(N+1)]
for __ in range(M):
  a, b = map(int, input().split())
  friends[a].append(b)
  friends[b].append(a)
checked = [0 for ___ in range(N+1)]
answer = 1
for i in range(1, N+1):
  friend = deque(friends[i])
  cnt = 0
  while(len(friend) > 0):
    f = friend.popleft()
    if checked[f] != 0:
      continue
    else:
      checked[f] = 1
      cnt += 1
      for ff in friends[f]:
        friend.append(ff)
  answer = max(answer, cnt)
print(answer)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N, M = map(int, input().split())
f_uf = UnionFind(self, N)
for _ in range(M):
  a, b = map(int, input().split())
  f_uf.union(a-1, b-1)
answer = 1
for i in range(N):
  answer = max(answer, f_uf.size(i))
print(answer)
Problem p02583 (python)

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

answer = 0

if N < 3:
  print(answer)
  exit()

sticks.sort()

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if sticks[i] + sticks[j] > sticks[k] and sticks[i] != sticks[j] and sticks[j] != sticks[k]:
        answer += 1
print(answer)

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

answer = 0

if N < 3:
  print(answer)
  exit()

sticks = list(dict.fromkeys(sticks))

for i in range(N-2):
  for j in range(i+1, N-1):
    for k in range(j+1, N):
      if sticks[i] + sticks[j] > sticks[k]:
        answer += 1
Problem p02613 (python)

Fixed submission:
N=int(input())
scores=[input() for _ in range(N)]
AC=WA=TLE=RE=0
for score in scores:
  if score == 'AC':
    AC += 1
  elif score == 'WA':
    WA += 1
  elif score == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Buggy submission (verdict: Runtime Error):
scores=[input() for _ in range(N)]
AC=WA=TLE=RE=0
for score in scores:
  if score == 'AC':
    AC += 1
  elif score == 'WA':
    WA += 1
  elif score == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))

Buggy submission (verdict: Runtime Error):
N=int(input())
scores=[input() for _ in range(N)]
AC=WA=TLE=RE=0
for score in scores:
  if score == 'AC':
    AC += 1
  elseif score == 'WA':
    WA += 1
  elseif score == 'TLE':
    TLE += 1
  else:
    RE += 1
print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))
Problem p02614 (python)

Fixed submission:
import copy
 
H, W, K = map(int, input().split())
tiles = [list(input()) for _ in range(H)]
count  = 0
 
for num in range(2**(H+W)):
  copied_tiles = copy.deepcopy(tiles)
  for i in range(H+W):
    if num>>i&1:
      if i < H:
        for j in range(W):
          copied_tiles[i][j] = 'R'
      else:
        for j in range(H):
          copied_tiles[j][i-H] = 'R'
  black_c = 0
  for i in range(H):
    for j in range(W):
      if copied_tiles[i][j] == '#':
        black_c += 1
  if black_c == K:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
import copy

H, W, K = map(int, input().split())
tiles = [list(input().split()) for _ in range(H)]
count  = 0

for num in range(2**(H+W)):
  copied_tiles = copy.deepcopy(tiles)
  for i in range(H+W):
    if num>>i&1:
      if i < H:
        for j in range(W):
          copied_tiles[i][j] = 'R'
      else:
        for j in range(H):
          copied_tiles[j][i-H] = 'R'
  black_c = 0
  for i in range(H):
    for j in range(W):
      if copied_tiles[i][j] == '#':
        black_c += 1
  if black_c == K:
    count += 1
print(count)
Problem p02628 (python)

Fixed submission:
N, K = map(int, input().split())
prices = list(map(int, input().split()))

prices.sort()
print(sum(prices[:K]))

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

prices.sort()
print(sum(prices[:K]))
Problem p02640 (python)

Fixed submission:
X, Y = map(int, input().split())
for crane in range(X+1):
  turtle = X - crane
  if crane * 2 + turtle * 4 == Y:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
X, Y ＝ map(int, input().split())
for crane in range(X+1):
  turtle = X - crane
  if crane * 2 + turtle * 4 == Y:
    print('Yes')
    exit()
print('No')

Buggy submission (verdict: Runtime Error):
X, Y ＝ map(int, input().split())
for crane in X:
  turtle = X - crane
  if crane * 2 + turtle * 4 == Y:
    print('Yes')
    exit()
print('No')
Problem p02691 (python)

Fixed submission:
from collections import Counter

N = int(input())
nums = list(map(int, input().split()))

A = [i + n for i, n in enumerate(nums, start=1)]
B = [j - n for j, n in enumerate(nums, start=1)]
BC = Counter(B)
answer = 0
for a in A:
  answer += BC[a]
print(answer)

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
nums = [0] + list(map(int, input().split()))

A = [i + n for n in enumerate(nums, start=1)]
B = [j - n for n in enumerate(nums, start=1)]
BC = Counter(B)
answer = 0
for a in A:
  answer += BC[a]
print(answer)
Problem p02732 (python)

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
counts = [0 for _ in range(N+1)]
for num in nums:
  counts[num] += 1
combination = 0
for count in counts:
  if count >= 2:
    combination += (count*(count-1))//2
for num in nums:
  print(combination-counts[num]+1)

Buggy submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int, input().split()))
counts = [0 for _ in range(N+1)]
for num in nums:
  counts[num] += 1
combination = 0
for count in counts:
  if count >= 2
    combination += (count*(count-1))//2
for i in range(1, N+1):
  print(combination-counts[i]+1)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
digits = [-1 for _ in range(N+1)]
for __ in range(M):
  digit, num = map(int, input().split())
  if digit == 1 and num == 0 and N != 1:
    print(-1)
    exit()
  elif digits[digit] != -1 and num != digits[digit]:
    print(-1)
    exit()
  else:
    digits[digit] = num
answer = 0
for i in range(1, N+1):
  if digits[i] == -1:
    if i == 1 and N != 1:
      answer += 1*10**(N-i)
  else:
    answer += digits[i]*10**(N-i)
print(answer)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
digits = [-1 for _ in range(N+1)]
for __ in range(M):
  digit, num = map(int, input().split())
  if digit = 1 and num == 0:
    print(-1)
    exit()
  elif digits[digit] != -1 and num != digits[digit]:
    print(-1)
  else:
    digits[digit] = num
answer = 0
for i in range(1, N+1):
  if digits[i] == -1:
    if i == 1:
      answer += 1*10*(N-i)
  else:
    answer += digits[i]*10*(N-i)
print(answer)
Problem p02802 (python)

Fixed submission:
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_list = [0 for __ in range(N+1)]
ac_cnt = 0
wa_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[int(problem)] == 0 and result == 'AC':
    ac_cnt += 1
    results[int(problem)] = 1
  elif results[int(problem)] == 0 and result == 'WA':
    wa_list[int(problem)] += 1
for i in range(1, N+1):
  if results[i] == 1:
    wa_cnt += wa_list[i]
print(ac_cnt, wa_cnt)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
results = [0 for _ in range(N+1)]
wa_cnt = 0
ac_cnt = 0
for _ in range(M):
  problem, result = input().split()
  if results[problem] == 0 and result == 'AC':
    ac_cnt += 1
    results[problem] = 1
  elif results[problem] == 0 and result == 'WA':
    wa_cnt += 1
print(ac_cnt, wa_cnt)
Problem p02900 (python)

Fixed submission:
A, B = map(int, input().split())
a = set([])
b = set([])
n = 1
while n**2 <= max(A, B):
  if A%n == 0 and n**2 <= A:
    a.add(n)
    a.add(A//n)
  if B%n == 0 and n**2 <= B:
    b.add(n)
    b.add(B//n)
  n += 1
ab = a & b
ab.discard(1)
ab = list(ab)
answer = 0
for i, n in enumerate(ab):
  prime = True
  for j, m in enumerate(ab):
    if i != j and n%m == 0:
      prime = False
      break
  if prime:
    answer += 1
print(answer+1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
a = set(1)
b = set(1)
n = 2
while n**2 > max(A, B):
  if A%n == 0 and n**2 <= A:
    a.add(n)
    a.add(A//n)
  if B%n == 0 and n**2 <= B:
    b.add(n)
    b.add(B//n)
ab = a & b
ab = list(ab)
answer = 0
for i, n in enumerate(ab):
  prime = True
  for j, m in enumerate(ab):
    if i != j and n%m == 0:
      prime = False
      break
  if prime:
    answer += 1
print(answer)
Problem p02909 (python)

Fixed submission:
S = input()
W = ['Sunny', 'Cloudy', 'Rainy']
for i, w in enumerate(W):
  if S == w:
    print(W[(i+1)%3])
    break

Buggy submission (verdict: Runtime Error):
S = input()
W = ['Sunny', 'Cloudy', 'Rainy']
for i, w in enumerate(W):
  if S = w:
    print(W[(i+1)%3])
    break
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
        else:
            continue
        break
    print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
        else:
            continue
        break
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
        else:
            continue
        break
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
else:
    mod_l = L%2019
    mod_r = R%2019
    ans = 2019
    for i in range(mod_l, mod_r+1):
        for j in range(i+1, mod_r+1):
            if (i * j)%2019 == 0:
                ans = 0
                break
            ans = min(ans, (i * j)%2019)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

div_l = L//2019
div_r = R//2019
div_ll = L//673
div_rr = R//673

ans = 0
if div_l == div_r and div_ll == dir_rr:
  mod_l = L%2019
  mod_r = R%2019
  ans = mod_l * (mod_l+1)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

div_l = L//2019
div_r = R//2019
div_ll = L//673
div_rr = R//673

ans = 0
if div_l == div_r and div_ll == dir_rr:
  mod_l = L%2019
  mod_r = R%2019
  ans = mod_l * (mod_l+1)
print(ans)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

div_l = L//2019
div_r = R//2019
div_ll = L//673
div_rr = R//673

ans = 0
if div_l == div_r and div_ll == dir_rr:
  mod_l = L%2019
  mod_r = R%2019
  ans = mod_l * (mod_l+1)
print(ans)
Problem p02988 (python)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
C = 0
for i in range(N):
    if i == 0 or i == N-1:
        continue
    elif (P[i] > P[i-1] and P[i+1] > P[i]) or (P[i-1] > P[i] and P[i] > P[i+1]):
        C += 1
print(C)

Buggy submission (verdict: Runtime Error):
S = input()
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[0] != S[3]) or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print('No')
Problem p03030 (python)

Fixed submission:
N = int(input())
SP = [list(input().split()) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:int(x[1]), reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if sorted_SP[i][0] == SP[j][0] and sorted_SP[i][1] == SP[j][1]:
      print(j+1)
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
SP = [list(input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
SP = [list(map(int, input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverse=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == sorted_SP[j][0] and SP[i][1] == sorted_SP[j][1]:
      print(j+1)
      break

Buggy submission (verdict: Runtime Error):
N = int(input())
SP = [list(map(int, input().split())) for i in range(N)]

sorted_SP = sorted(SP, key=lambda x:x[1], reverxe=True)
sorted_SP = sorted(sorted_SP, key=lambda x:x[0])

for i in range(N):
  for j in range(N):
    if SP[i][0] == SP[j][0] and SP[i][1] == SP[j][1]:
      print(j+1)
      break
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if (i >> k-1)&1 == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)

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

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)

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

def check(ar):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[1::]:
            if ar[k-1] == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    return (cnt == M)


def dfs(n, ar):
    if n == 0:
        if check(ar):
            return 1
        else:
            return 0
    else:
        return dfs(n-1, ar.append(0)) + dfs(n-1, ar.append(1))
arr = []
ans = dfs(N, arr)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = mtp(int, input().split())
ks = [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))

ans = 0
for i in range(2**M):
    cnt = 0
    for j in range(M):
        count = 0
        for k in ks[j][1::]:
            if (i >> k-1)&1 == 1:
                count += 1
        if count%2 == p[j]:
            cnt += 1
    if cnt == M:
        ans += 1
print(ans)