Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [input() for i in range(n)]

f = [a for a in s if s.startswith('M')]
g = [b for b in s if s.startswith('A')]
h = [c for c in s if s.startswith('R')]
i = [d for d in s if s.startswith('C')]
j = [e for e in s if s.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)

Fixed submission:
n = int(input())
s = [input() for i in range(n)]

f = [a for a in s if a.startswith('M')]
g = [b for b in s if b.startswith('A')]
h = [c for c in s if c.startswith('R')]
i = [d for d in s if d.startswith('C')]
j = [e for e in s if e.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k=x:
        ans += 1
print(ans)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if 500*i+100*j+50*k==x:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
c = a * b
if c%2 == 0:
  print(Even)
else:
  print(Odd)

Fixed submission:
a, b = map(int, input().split())
c = a * b
if c%2 == 0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
z = y/1000
for i in range(1,n+1):
    for j in range(0, n+1-i):
        k = n - i- j
            if 10*i + 5*j + k == y:
                print('i j k')
                break
print('-1 -1 -1')

Fixed submission:
n, y = map(int, input().split())
z = y/1000
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i- j
        if 10*i + 5*j + k == z:
            print(i, j, k)
            exit(0)
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())
z = y/1000
while True:
    for i in range(1,n+1):
        for j in range(0, n+1-i):
            for k in range(0, n+1-i-j):
                if 10*i + 5*j + 1*k == y:
                    print('i j k')
                    break
print('-1 -1 -1')

Fixed submission:
n, y = map(int, input().split())
z = y/1000
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i- j
        if 10*i + 5*j + k == z:
            print(i, j, k)
            exit(0)
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())
z = y/1000
while True:
    for i in range(1,n+1):
        for j in range(0, n+1-i):
            for k in range(0, n+1-i-j):
                if 10*i + 5*j + 1*k == y:
                    print('i j k')
                    break
print('-1 -1 -1')

Fixed submission:
n, y = map(int, input().split())
z = y/1000
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i- j
        if 10*i + 5*j + k == z:
            print(i, j, k)
            exit(0)
print('-1 -1 -1')

Buggy python submission (verdict: Time Limit Exceeded):
n, y = map(int, input().split())
while True:
    for i in range(1,n+1):
        for j in range(0, n+1-i):
            for k in range(0, n+1-i-j):
                if 10000*i + 5000*j + 1000*k == y:
                    print('i j k')
                    break
print('-1 -1 -1')

Fixed submission:
n, y = map(int, input().split())
z = y/1000
for i in range(n+1):
    for j in range(n+1-i):
        k = n - i- j
        if 10*i + 5*j + k == z:
            print(i, j, k)
            exit(0)
print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
m = input()
print(24 - m)

Fixed submission:
m = int(input())
print(48 - m)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
  if a<= sum(int(c) for c in str(i)) <= b:
    ams += i
print(ans)

Fixed submission:
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
  if a<= sum(int(c) for c in str(i)) <= b:
    ans += i
print(ans)
Buggy python submission (verdict: Runtime Error):
print(input().count(1))

Fixed submission:
print(input().count('1'))

Buggy python submission (verdict: Runtime Error):
counter = 0
for s[i] in range(2):
  if s[i] == 1:
    counter += 1
  else:
    pass
print(counter)


Fixed submission:
print(input().count('1'))

Buggy python submission (verdict: Runtime Error):
s1 , s2, s3 = map(int, input().split())
print(s1 + s2 + s3)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))
count = 0
while True:
  for i in a_list:
    if i % 2 ==  1:
      break
    else:
      a_list = list(map(lambda x:x/2 , a_list))
      count += 1
print(count)
    
  

Fixed submission:
n = int(input())
a_list = list(map(int, input().split()))
ans = 0
while True:
  if [i for i in a_list if i % 2 == 1]:
      break
  a_list = list(map(lambda x:x/2 , a_list))
  ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  F = [int(i) for i in input().split()]

  rest = sum(A) - K
  if rest <= 0: return 0

  _min = min(F)
  cost = 0

  while True:
    _sum = sum([cost // f for f in F])
    if _sum >= rest: return cost
    cost += _min

print(solve())


Fixed submission:
import numpy as np

def solve():
  N, K = map(int,input().split())
  A = np.array(input().split(), np.int64)
  F = np.array(input().split(), np.int64)

  A.sort()
  F.sort()
  F=F[::-1]
  a_sum = A.sum()
  low, high = -1, 10**13

  while low + 1 < high:
      mid = (low + high) // 2
      if np.minimum(A, mid // F).sum() >= a_sum - K:
          high = mid
      else:
          low = mid
  return high

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  F = [int(i) for i in input().split()]

  rest = sum(A) - K
  if rest <= 0: return 0

  _max = max(F)
  r = sum([_max // f for f in F])
  cost = _max // r

  while True:
    _sum = sum([cost // f for f in F])
    if _sum >= rest: return cost
    cost += 1

print(solve())


Fixed submission:
import numpy as np

def solve():
  N, K = map(int,input().split())
  A = np.array(input().split(), np.int64)
  F = np.array(input().split(), np.int64)

  A.sort()
  F.sort()
  F=F[::-1]
  a_sum = A.sum()
  low, high = -1, 10**13

  while low + 1 < high:
      mid = (low + high) // 2
      if np.minimum(A, mid // F).sum() >= a_sum - K:
          high = mid
      else:
          low = mid
  return high

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  F = [int(i) for i in input().split()]

  rest = sum(A) - K
  cost = 0

  while True:
    if rest <= 0: return cost
    cost += 1
    rest -= len([0 for f in F if cost % f == 0])

print(solve())


Fixed submission:
import numpy as np

def solve():
  N, K = map(int,input().split())
  A = np.array(input().split(), np.int64)
  F = np.array(input().split(), np.int64)

  A.sort()
  F.sort()
  F=F[::-1]
  a_sum = A.sum()
  low, high = -1, 10**13

  while low + 1 < high:
      mid = (low + high) // 2
      if np.minimum(A, mid // F).sum() >= a_sum - K:
          high = mid
      else:
          low = mid
  return high

print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
  N, K = map(int, input().split())
  H = [int(i) for i in input().split()]
  return len(list(filter(lambda h: h >= K, H)))

print(solve())

Fixed submission:
def solve():
  N = int(input())
  A = sorted([(i, int(v)) for i, v in enumerate(input().split())])
  sortedList = [-1] * N
  for i, a in A:
    sortedList[a - 1] = str(i + 1)
  return ' '.join(sortedList)

print(solve())
Buggy python submission (verdict: Runtime Error):
from math import gcd

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def solve():
  A, B = map(int, input().split())
  return len(set(prime_factorize(gcd(A, B)))) + 1

print(solve())

Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def solve():
  A, B = map(int, input().split())
  return len(set(prime_factorize(gcd(A, B)))) + 1

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

MOD = 10 ** 9 + 7

def mult(a, b):
  return ((a % MOD) * (b % MOD)) % MOD

def solve():
  N = int(input())
  S = list(map(lambda c: c == 'W', input())) # W: True, B: False
  if S[0] or S[2 * N - 1]: return 0

  D = [ True ] * (2 * N) # L: True, R: False
  d = True
  for i in range(1, N * 2):
    if S[i] == S[i - 1]: d = not d
    D[i] = d

  C = 1
  c = 0
  for d in D:
    if d: c += 1
    else:
      C *= c
      c -= 1
      if c < 0: return 0

  return mult(factorial(N), C) if c == 0 else 0

print(solve())

Fixed submission:
MOD = 10 ** 9 + 7

def solve():
  N = int(input())
  S = [s == 'W' for s in input()] # W: True, B: False
  if S[0] or S[2 * N - 1]: return 0

  ans = 1
  cnt = 1
  d = True # L: True, R: False
  for i in range(1, N * 2):
    if S[i] == S[i - 1]: d = not d
    if d: cnt += 1
    else:
      ans = (ans * cnt) % MOD
      cnt -= 1

  for i in range(1, N + 1): ans = (ans * i) % MOD

  return ans if cnt == 0 else 0

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

MOD = 10 ** 9 + 7

def mult(a, b):
  return ((a % MOD) * (b % MOD)) % MOD

def solve():
  N = int(input())
  S = input()
  if S[0] != 'B' or S[-1] != 'B': return 0

  D = 'L'
  for i in range(1, N * 2):
    d = D[-1]
    if S[i] != S[i - 1]: D += d
    else: D += 'L' if d == 'R' else 'R'

  if D.count('L') != D.count('R'): return 0

  C = 1
  c = 0
  for d in D:
    if d == 'L': c += 1
    else:
      C *= c
      c -= 1
      if c < 0: return 0

  return mult(factorial(N), C)

print(solve())

Fixed submission:
MOD = 10 ** 9 + 7

def solve():
  N = int(input())
  S = [s == 'W' for s in input()] # W: True, B: False
  if S[0] or S[2 * N - 1]: return 0

  ans = 1
  cnt = 1
  d = True # L: True, R: False
  for i in range(1, N * 2):
    if S[i] == S[i - 1]: d = not d
    if d: cnt += 1
    else:
      ans = (ans * cnt) % MOD
      cnt -= 1

  for i in range(1, N + 1): ans = (ans * i) % MOD

  return ans if cnt == 0 else 0

print(solve())
Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split()]

if M % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(N + 1)]
used_e = [False] * M
ans = []

for i in range(M):
    A, B = map(int, input().split())
    E[A].append((B, i))
    E[B].append((A, i))

visited = [False] * (N + 1)


def dfs(prev, v):
    if visited[v]: return
    visited[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]: cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev: continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True


dfs(0, 1)

for a in ans: print(*a)


Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10**8)

N, M = [int(i) for i in input().split()]

if M % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(N + 1)]
used_e = [False] * M
ans = []

for i in range(M):
    A, B = map(int, input().split())
    E[A].append((B, i))
    E[B].append((A, i))

visited = [False] * (N + 1)


def dfs(prev, v):
    if visited[v]: return
    visited[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]: cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev: continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True


dfs(0, 1)

for a in ans: print(*a)

Buggy python submission (verdict: Runtime Error):
def solve():
  N, M = map(int, input().split())
  graph = [[] for i in range(N)]
  cnt = 0
  for i in range(M):
    A, B = map(lambda v: int(v) - 1, input().split())
    graph[A].append(B)
    graph[B].append(A)
  if M % 2 == 1:
    print(-1)
    return

  while cnt < N:
    for i in range(N):
      if len(graph[i]) % 2 == 1: continue
      for j in graph[i]:
        print(i + 1, j + 1)
        graph[j].remove(i)
        cnt += 1

solve()

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10**8)

N, M = [int(i) for i in input().split()]

if M % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(N + 1)]
used_e = [False] * M
ans = []

for i in range(M):
    A, B = map(int, input().split())
    E[A].append((B, i))
    E[B].append((A, i))

visited = [False] * (N + 1)


def dfs(prev, v):
    if visited[v]: return
    visited[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]: cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev: continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True


dfs(0, 1)

for a in ans: print(*a)
Buggy python submission (verdict: Runtime Error):
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return
  return ans

print(solve())


Fixed submission:
def solve():
  N, A, B = map(int, input().split())
  return min(N * A, B)

print(solve())
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
  return ans

print(solve())


Fixed submission:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return 0
  return ans

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for _i in range(L, R + 1):
    i = _i % 2019
    if i == 0: return 0
    v = i * (i + 1) % 2019
    for _j in range(_i + 1, R + 1):
      ans = min(ans, v)
      v += i
      v %= 2019
  return ans

print(solve())

Fixed submission:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return 0
  return ans

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R + 1):
    if i % 2019 == 0: return 0
    v = i * (i + 1) % 2019
    for j in range(i + 1, R + 1):
      ans = min(ans, v)
      v += i
      v %= 2019
  return ans

print(solve())

Fixed submission:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return 0
  return ans

print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R + 1):
    for j in range(i + 1, R + 1):
      ans = min(ans, (i * j) % 2019)
  return ans

print(solve())

Fixed submission:
def solve():
  L, R = map(int, input().split())
  ans = 2019
  for i in range(L, R):
    for j in range(i + 1, R + 1):
      v = i * j % 2019
      if v < ans: ans = v
      if ans == 0: return 0
  return ans

print(solve())
Buggy python submission (verdict: Runtime Error):
import math

def solve():
  A, B, C, D = map(int, input().split())
  A = A - 1
  CD = C * D // math.gcd(C, D)
  num_C = (B // C) - (A // C)
  num_D = (B // D) - (A // D)
  num_CD = (B // CD) - (A // CD)
  return B - A - num_C - num_D + num_CD

print(solve())


Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def solve():
  A, B, C, D = map(int, input().split())
  A = A - 1
  CD = C * D // gcd(C, D)
  num_C = (B // C) - (A // C)
  num_D = (B // D) - (A // D)
  num_CD = (B // CD) - (A // CD)
  return B - A - num_C - num_D + num_CD

print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
  N = int(input())
  S = input()
  stones = []
  look = S[0]
  cnt = 0

  if S[0] == '.': stones.append(0)
  for s in S:
    if look == s: cnt += 1
    else:
      stones.append(cnt)
      cnt = 1
      look = s
  stones.append(cnt)
  if S[N - 1] == '#': stones.append(0)

  count = sum(stones[1::2])
  ans = count

  for i in range(0, len(stones), 2):
    count = count + stones[i] - stones[i + 1]
    if ans > count: ans = count
  return ans

print(solve())


Fixed submission:
def solve():
  A, B, C = map(int, input().split())
  return 'Yes' if min(A, B) < C and C < max(A, B) else 'No'

print(solve())
Buggy python submission (verdict: Runtime Error):
def solve():
  N = int(input())
  S = input()
  stones = []
  look = S[0]
  cnt = 0

  if S[0] == '.': stones.append(0)
  for s in S:
    if look == s: cnt += 1
    else:
      stones.append(cnt)
      cnt = 1
      look = s
  stones.append(cnt)
  if S[N - 1] == '#': stones.append(0)

  count = sum(stones[1::2])
  ans = count

  for i in range(0, N - 2, 2):
    count = count + stones[i] - stones[i + 1]
    if ans > count: ans = count
  return ans

print(solve())

Fixed submission:
def solve():
  N = int(input())
  S = input()
  stones = []
  look = S[0]
  cnt = 0

  if S[0] == '.': stones.append(0)
  for s in S:
    if look == s: cnt += 1
    else:
      stones.append(cnt)
      cnt = 1
      look = s
  stones.append(cnt)
  if S[N - 1] == '#': stones.append(0)

  count = sum(stones[1::2])
  ans = count

  for i in range(0, len(stones), 2):
    count = count + stones[i] - stones[i + 1]
    if ans > count: ans = count
  return ans

print(solve())
Buggy python submission (verdict: Runtime Error):
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

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

AB.sort(reverse=True)
AB = AB[:min(3001, X * Y * Z + 1)]
ABC = []
for ab in AB:
  for c in C:
    ABC.append(ab + c)
ABC.sort(reverse=True)
print(*ABC[:K], sep='\n')


Fixed submission:
def solve():
  ABCDEF = [int(input()) for i in range(5)]
  K = int(input())
  return ':(' if max(ABCDEF) - min(ABCDEF) > K else 'Yay!'

print(solve())
Buggy python submission (verdict: Runtime Error):
import re

def solve():
  S = input()
  parts = re.split(r'[^ACGT]', S)
  return max(*map(lambda s: len(s), parts))

print(solve())


Fixed submission:
import re

def solve():
  S = input()
  parts = re.split(r'[^ACGT]', S)
  return max(list(map(lambda s: len(s), parts)))

print(solve())
Buggy python submission (verdict: Runtime Error):
N, MOD = int(input()), 10 ** 9 + 7
dp = [ [ [ [0] * 4 ] * 4 ] * 4 ] * 101
'''
長さ0の文字列は1
0, 1, 2に関する制約しかないので、Sは、333Sと考えても問題がない
'''
dp[0][3][3][3] = 1

for length in range(N):
  for i in range(4):
    for j in range(4):
      for k in range(4):
        if dp[length][i][j][k] == 0: continue
        for a in range(a):
          if a == 2 and i == 1 and j == 0: continue
          if a == 2 and i == 0 and j == 1: continue
          if a == 1 and i == 2 and j == 0: continue
          if a == 2 and i == 1 and k == 0: continue
          if a == 2 and j == 1 and k == 0: continue
          dp[length + 1][a][i][j] += dp[length][i][j][k]
          dp[length + 1][a][i][j] %= MOD

ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans += dp[N][i][j][k]
      ans %= MOD

print(ans)


Fixed submission:
N, MOD = int(input()), 10 ** 9 + 7
memo = [{} for i in range(N+1)]

def ok(last4):
	for i in range(4):
		t = list(last4)
		if i >= 1:
			t[i-1], t[i] = t[i], t[i-1]
		if ''.join(t).count('AGC') >= 1:
			return False
	return True

def dfs(cur, last3):
	if last3 in memo[cur]:
		return memo[cur][last3]
	if cur == N:
		return 1
	ret = 0
	for c in 'ACGT':
		if ok(last3 + c):
			ret = (ret + dfs(cur + 1, last3[1:] + c)) % MOD
	memo[cur][last3] = ret
	return ret

print(dfs(0, 'TTT'))
Buggy python submission (verdict: Runtime Error):
def solve():
  N = int(input())
  M = (N - 2) * 2
  for i in range(3, N + 1):
    print(f'1 {i}\n{i - 1} {i}')

solve()


Fixed submission:
N = int(input())

def solve(N):
  fmt = '{} {}'
  ans = []
  sub = []
  if N % 2 == 1:
    ans = solve(N - 1)
    for i in range(1, N):
      ans.append(fmt.format(i, N))
  else:
    for i in range(1, N + 1):
      for j in range(i + 1, N + 1):
        if j == N - i + 1: continue
        ans.append(fmt.format(i, j))
  return ans

ans = solve(N)
print(len(ans))
[print(a) for a in ans]
Buggy python submission (verdict: Runtime Error):
L = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [(A[i], L[A[i]]) for i in range(M)]

X = [0] + ([-1] * N)
for i in range(1, N+1):
  for b in B:
    X[i] = max(X[i], X[i-b[1]] * 10 + b[0])

print(X[N])


Fixed submission:
L = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6]

N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [(A[i], L[A[i]]) for i in range(M)]

X = [0] + ([-1] * N)
for i in range(1, N+1):
  for b in B:
    if b[1] <= i:
      X[i] = max(X[i], X[i-b[1]] * 10 + b[0])

print(X[N])
Buggy python submission (verdict: Runtime Error):
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c == 0: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())


Fixed submission:
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 and c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())

Buggy python submission (verdict: Runtime Error):
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())


Fixed submission:
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 and c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())

Buggy python submission (verdict: Runtime Error):
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())


Fixed submission:
def solve():
  count = [0] * 4
  for i in range(3):
    A, B = map(int, input().split())
    count[A - 1] += 1
    count[B - 1] += 1

  time = [0] * 2
  for c in count:
    if c != 1 and c != 2: continue
    time[c - 1] += 1

  return 'YES' if time[0] == 2 and time[1] == 2 else 'NO'

print(solve())