Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
 for i in range(1,10):$
   ^Ifor j in range(1,10):$
   ^I^Iprint i,"*",j,"=",i*j$

Fixed submission:
for i in range(1,10):
 for j in range(1,10):
  print "%dx%d=%d" %(i,j,i*j)

Buggy python submission (verdict: Runtime Error):
 for i in range(1,10):$
    for j in range(1,10):$
       print i,"*",j,"=",i*j$

Fixed submission:
for i in range(1,10):
 for j in range(1,10):
  print "%dx%d=%d" %(i,j,i*j)

Buggy python submission (verdict: Runtime Error):
 for i in range(1,10):
  for j in range(1,10):
    print i,"*",j,"=",i*j

Fixed submission:
for i in range(1,10):
 for j in range(1,10):
  print "%dx%d=%d" %(i,j,i*j)
Buggy python submission (verdict: Runtime Error):
import sys
from Config import DB
def add(lis,check_list):
    for index in range(len(lis)):
        if lis[index][0]==check_list[0]:
            lis[index][1]+=int(check_list[1])*int(check_list[2])
            return
    lis.append([check_list[0],int(check_list[1])*int(check_list[2])])

while True:
    num=int(raw_input())
    if num==0: break
    lis=[]
    for i in range(num):
        l=raw_input().split(" ")
        add(lis,l)
    c=0
    for ele in lis:
        if ele[1]>=1000000:
            print ele[0]
            c+=1
    if c==0: print "NA"

Fixed submission:

def add(lis,check_list):
    for index in range(len(lis)):
        if lis[index][0]==check_list[0]:
            lis[index][1]+=int(check_list[1])*int(check_list[2])
            return
    lis.append([check_list[0],int(check_list[1])*int(check_list[2])])

while True:
    num=int(raw_input())
    if num==0: break
    lis=[]
    for i in range(num):
        l=raw_input().split(" ")
        add(lis,l)
    c=0
    for ele in lis:
        if ele[1]>=1000000:
            print ele[0]
            c+=1
    if c==0: print "NA"
Buggy python submission (verdict: Runtime Error):
while True:
  try:
    a, b, c = map(int, input().split(","))
    
    rect_cnt += (a ** 2 + b ** 2 ==  c ** 2)
    dia_cnt += (a == b)

  except EOFError:
    break

print(rect_cnt)
print(dia_cnt)


Fixed submission:
rect_cnt = dia_cnt = 0

while True:
  try:
    a, b, c = map(int, input().split(","))
    
    rect_cnt += (a ** 2 + b ** 2 ==  c ** 2)
    dia_cnt += (a == b)

  except EOFError:
    break

print(rect_cnt)
print(dia_cnt)
Buggy python submission (verdict: Runtime Error):
#数列に対しy/nの判定をする
def solve(balls):

  #B, Cの一番上の数(ただし常にB <= Cを保つ)
  last_b = last_c = 0

  while balls:
    new = balls.pop(0)
    
    #new <= last_b <= last_c  --> 不可能
    if new <= last_b:
      print("NO")
      break
    
    #last_b < new <= last_c   --> Bを更新
    elif new <= last_c:
      last_b = new
    
    #last_b < last_c < new    --> Cを更新
    else:
      last_c = new
  
  else:
    print("YES")

      


while True:
  try:
    n = int(input())

    for i in range(n):
      balls = list(map(int, input().split()))
      solve(balls)

  except EOFError:
    break


Fixed submission:
#数列に対しy/nの判定をする
def solve(balls):

  #B, Cの一番上の数(ただし常にB <= Cを保つ)
  last_b = last_c = 0

  while balls:
    new = balls.pop(0)
    
    #new <= last_b <= last_c  --> 不可能
    if new <= last_b:
      print("NO")
      return
    
    #last_b < new <= last_c   --> Bを更新
    elif new <= last_c:
      last_b = new
    
    #last_b < last_c < new    --> Cを更新
    else:
      last_c = new
  
  print("YES")
  return

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

  for _ in range(n):
    balls = list(map(int, input().split()))
    solve(balls)

main()
Buggy python submission (verdict: Time Limit Exceeded):
MAX = 50001

is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

def main():
  while True:
    n = int(input())
    if not n:
      break
    
    primes_less_than_n = [i for i in primes if i <= n // 2]
    ans = 0
    for i in primes_less_than_n:
      if i > n // 2:
        break
      if is_prime[n - i]:
        ans += 1
  
    print(ans)

main()


Fixed submission:
MAX = 50001

is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

def main():
  while True:
    n = int(input())
    if not n:
      break
        
    ans = 0
    for i in primes:
      if i > n // 2:
        break
      if is_prime[n - i]:
        ans += 1
  
    print(ans)

main()

Buggy python submission (verdict: Runtime Error):
MAX = 50001

is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

def main():
  while True:
    n = int(input())
    if not n:
      break
    
    ans = 0
    for i in primes_less_than_n:
      if is_prime[n - i]:
        ans += 1
  
    print(ans)

main()


Fixed submission:
MAX = 50001

is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
  if is_prime[i]:
    for j in range(i ** 2, MAX, i):
      is_prime[j] = False

primes = [i for i in range(MAX) if is_prime[i]]

def main():
  while True:
    n = int(input())
    if not n:
      break
        
    ans = 0
    for i in primes:
      if i > n // 2:
        break
      if is_prime[n - i]:
        ans += 1
  
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
while True:
  n = int(input())
  if not n:
    break

  start = int(input()) - 1 #開始の位置
  goal = int(input()) - 1  #あたりの位置
  d = int(input())
  
  nums = [[i for i in range(n)]] #各段での数字の並び
  bars = [] #横棒リスト
  
  for i in range(d):
    s = input()
    bars.append(s)
    new = nums[-1][:]
    for j in range(n - 1):
      if s[j] == "1": #横棒があれば入れ替え
        new[j], new[j + 1] = new[j + 1], new[j]

    nums.append(new)
  
  to_goal = nums[-1][goal] #あたりにたどり着くスタートの番号

  for i, status in enumerate(nums):
    to_goal_ind = status.index(to_goal) #to_goalの位置
    start_ind = status.index(start)     #startの位置
    ind1, ind2 = min(to_goal_ind, start_ind), max(to_goal_ind, start_ind)

    if ind2 - ind1 == 1:  #隣あっていた場合
      if bars[i][ind1] == "0" and (ind2 == n - 1 or bars[i][ind2] == "0"):  #隣り合う横棒がなければ出力
        print(i + 1, ind1 + 1)
        break
  else:
    print(1)



Fixed submission:
while True:
  n = int(input())
  if not n:
    break

  start = int(input()) - 1 #開始の位置
  goal = int(input()) - 1  #あたりの位置
  d = int(input())
  
  nums = [[i for i in range(n)]] #各段での数字の並び
  bars = [] #横棒リスト
  
  for i in range(d):
    s = input()
    bars.append(s)
    new = nums[-1][:]

    for j in range(n - 1):
      if s[j] == "1": #横棒があれば入れ替え
        new[j], new[j + 1] = new[j + 1], new[j]

    nums.append(new)
    
  to_goal = nums[-1][goal] #あたりにたどり着く初期位置
  
  if to_goal == start: #元からあたりにたどり着く場合
    print(0)

  else: #各段について、to_goalとスタートが隣り合うかチェック
    for i, status in enumerate(nums[1:]):
      to_goal_ind = status.index(to_goal) #to_goalの位置
      start_ind = status.index(start)     #startの位置
      ind1, ind2 = min(to_goal_ind, start_ind), max(to_goal_ind, start_ind)
  
      if (ind2 - ind1 == 1                               #隣り合っていて、 
          and bars[i][ind1] == "0"                       #該当位置と
          and (ind1 == 0 or bars[i][ind1 - 1] == "0")    #左と
          and (ind2 == n - 1 or bars[i][ind2] == "0")):  #右に、辺がなければ出力
          print(i + 1, ind1 + 1)
          break
    else:
      print(1)
Buggy python submission (verdict: Runtime Error):
two_dict = {}
for i in range(2001):
  two_dict[i] = min(i, 2000 - i) + 1 

while True:
  try:
    n = int(input())
    ans = 0
    for i in range(n + 1):
      ans += two_dict[i] * two_dict[n - i]
    print(ans)

  except EOFError:
    break



Fixed submission:
from collections import Counter

pair_dict = Counter()
for i in range(2001):
  pair_dict[i] = min(i, 2000 - i) + 1 

while True:
  try:
    n = int(input())
    ans = 0
    for i in range(n + 1):
      ans += pair_dict[i] * pair_dict[n - i]
    print(ans)

  except EOFError:
    break
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

def get_loop(a, m):
  count = 1
  while a ** count % m != 1:
    count += 1
  return count

while True:
  a1, m1, a2, m2, a3, m3 = map(int, input().split())
  if not a1:
    break
  loop_a = get_loop(a1, m1)
  loop_b = get_loop(a2, m2)
  loop_c = get_loop(a3, m3)
  loop_ab = loop_a * loop_b // gcd(loop_a, loop_b)
  loop_abc = loop_ab * loop_c // gcd(loop_ab, loop_c)
  print(loop_abc)


Fixed submission:
from math import gcd

def get_loop(a, m):
  count = 1
  acc = a
  while acc != 1:
    count += 1
    acc *= a
    acc %= m
  return count

while True:
  a1, m1, a2, m2, a3, m3 = map(int, input().split())
  if not a1:
    break
  loop_a = get_loop(a1, m1)
  loop_b = get_loop(a2, m2)
  loop_c = get_loop(a3, m3)
  loop_ab = loop_a * loop_b // gcd(loop_a, loop_b)
  loop_abc = loop_ab * loop_c // gcd(loop_ab, loop_c)
  print(loop_abc)

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

def get_loop(a, m):
  count = 1
  acc = a
  while acc % m != 1:
    count += 1
    acc *= a
  return count

while True:
  a1, m1, a2, m2, a3, m3 = map(int, input().split())
  if not a1:
    break
  loop_a = get_loop(a1, m1)
  loop_b = get_loop(a2, m2)
  loop_c = get_loop(a3, m3)
  loop_ab = loop_a * loop_b // gcd(loop_a, loop_b)
  loop_abc = loop_ab * loop_c // gcd(loop_ab, loop_c)
  print(loop_abc)


Fixed submission:
from math import gcd

def get_loop(a, m):
  count = 1
  acc = a
  while acc != 1:
    count += 1
    acc *= a
    acc %= m
  return count

while True:
  a1, m1, a2, m2, a3, m3 = map(int, input().split())
  if not a1:
    break
  loop_a = get_loop(a1, m1)
  loop_b = get_loop(a2, m2)
  loop_c = get_loop(a3, m3)
  loop_ab = loop_a * loop_b // gcd(loop_a, loop_b)
  loop_abc = loop_ab * loop_c // gcd(loop_ab, loop_c)
  print(loop_abc)
Buggy python submission (verdict: Runtime Error):
while True:
  h, w = map(int, input().split())
  if not h:
    break

  mp = [list("X" + input() + "X") for _ in range(h)]
  mp.insert(0, ["X"] * (w + 2))
  mp.append(["X"] * (w + 2))
  
  direct = ((0, 1), (0, -1), (1, 0), (-1, 0))

  def search(x, y, target):
    mp[y][x] = "X"
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] == target:
        search(nx, ny, target)
  
  ans = 0

  for x in range(1, w + 1):
    for y in range(1, h + 1):
      target = mp[y][x]
      if target != "X":
        search(x, y, target)
        ans += 1
  
  print(ans)


Fixed submission:
import sys

sys.setrecursionlimit(100000)

while True:
  h, w = map(int, input().split())
  if not h:
    break

  mp = [list("X" + input() + "X") for _ in range(h)]
  mp.insert(0, ["X"] * (w + 2))
  mp.append(["X"] * (w + 2))
  
  direct = ((0, 1), (0, -1), (1, 0), (-1, 0))

  def search(x, y, target):
    mp[y][x] = "X"
    for dx, dy in direct:
      nx, ny = x + dx, y + dy
      if mp[ny][nx] == target:
        search(nx, ny, target)
  
  ans = 0

  for x in range(1, w + 1):
    for y in range(1, h + 1):
      target = mp[y][x]
      if target != "X":
        search(x, y, target)
        ans += 1
  
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def func(n):
  dic = Counter()
  rest = []
  for i in range(1, n):
    rest.append(i ** 2 % n)
  rest = list(set(rest))
  rest.sort()
  lenr = len(rest)
  
  for i in range(lenr):
    for j in range(i + 1, lenr):
      x, y = rest[i], rest[j]
      if y - x > n // 2:
        dic[n - (y - x)] += 2
      else:
        dic[y - x] += 2

  for i in range(1, (n + 1) // 2):
    print(dic[i])
while True:
  n = int(input())
  if n == 0:
    break
  func(n)


Fixed submission:
import itertools
def func(n):
  rest = {i ** 2 % n for i in range(1, n)}

  count = [0] * n
  for x, y in itertools.combinations(rest, 2):
    count[x - y] += 2

  for i in range(n // 2):
    print(count[i + 1] + count[n - i - 1])


def main():
  while True:
    n = int(input())
    if n == 0:
      break
    func(n)

main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def func(n):
  dic = Counter()
  rest = list({i ** 2 % n for i in range(1, n)})
  lenr = len(rest)
  rest.sort()
  half = n // 2
  
  for i in range(lenr):
    resti = rest[i]
    for j in range(i + 1, lenr):
      dff = rest[j] - resti
      if dff > half:
        dic[n - dff] += 2
      else:
        dic[dff] += 2

  for i in range(1, half + 1):
    print(dic[i])

def main():
  while True:
    n = int(input())
    if n == 0:
      break
    func(n)

main()


Fixed submission:
import itertools
def func(n):
  rest = {i ** 2 % n for i in range(1, n)}

  count = [0] * n
  for x, y in itertools.combinations(rest, 2):
    count[x - y] += 2

  for i in range(n // 2):
    print(count[i + 1] + count[n - i - 1])


def main():
  while True:
    n = int(input())
    if n == 0:
      break
    func(n)

main()
Buggy python submission (verdict: Time Limit Exceeded):
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2)) + 1):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n, -1, -1) if tf[i]]

def search_twin(prime_lst):
  prime_lst2 = prime_lst[1:]
  for x, y in zip(prime_lst, prime_lst2):
    if x - y == 2:
      return (y, x)

while True:
  n = int(input())
  if n == 0:
    break
  prime_lst = primes(n)
  print(*search_twin(prime_lst))


Fixed submission:
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2)) + 1):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def add_twin(prime_lst, twin_lst):
  prime_lst2 = prime_lst[1:]
  for x, y in zip(prime_lst, prime_lst2):
    if y - x == 2:
      twin_lst.append(y)

def search_twin(x, twin_lst):
  left = 0
  right = len(twin_lst)
  while left + 1 < right:
    mid = (left + right) // 2
    if twin_lst[mid] > x:
      right = mid
    elif twin_lst[mid] < x:
      left = mid
    else:
      return x
  return twin_lst[left]

prime_lst = primes(10000)
twin_lst = []
add_twin(prime_lst, twin_lst)

while True:
  n = int(input())
  if n == 0:
    break
  a = search_twin(n, twin_lst)
  print(a - 2, a)
Buggy python submission (verdict: Runtime Error):
end = [1,1,1,1,1]
while True:
  n = int(input())
  if n == 0:
    break
  mp = [[0] * 5 for _ in range(4000)]
  height = [0] * 5
  cnt = 0
  for i in range(n):
    d, p, q = map(int, input().split())
    q -= 1
    cnt += p
    if d == 1:
      pos = max(height[q:q + p])
      mp[pos][q:q + p] = [1] * p
      if mp[pos] == end:
        cnt -= 5
        mp.pop(pos)
        mp.append([0] * 5)
        for x in range(5):
          for y in range(i * 5 - 1, -1, -1):
            if mp[y][x] == 1:
              height[x] = y + 1
              break
          else:
            height[x] = 0
      else:
        height[q:q + p] = [pos + 1] * p

    if d == 2:
      pop_flag = False
      pos = height[q]
      for y in range(pos, pos + p):
        mp[y][q] = 1
      for y in range(pos + p - 1, pos - 1, -1):
        if mp[y] == end:
          cnt -= 5
          mp.pop(y)
          mp.append([0] * 5)
          pop_flag = True
      
      if pop_flag:
        for x in range(5):
          for y in range(i * 5 - 1, -1, -1):
            if mp[y][x] == 1:
              height[x] = y + 1
              break
          else:
            height[x] = 0
      else:
        height[q] += p
  
  print(cnt)


Fixed submission:
end = [1,1,1,1,1]
while True:
  n = int(input())
  if n == 0:
    break
  mp = [[0] * 5 for _ in range(6000)]
  height = [0] * 5
  cnt = 0
  for i in range(n):
    d, p, q = map(int, input().split())
    q -= 1
    cnt += p
    if d == 1:
      pos = max(height[q:q + p])
      mp[pos][q:q + p] = [1] * p
      if mp[pos] == end:
        cnt -= 5
        mp.pop(pos)
        mp.append([0] * 5)
        for x in range(5):
          for y in range(i * 5 - 1, -1, -1):
            if mp[y][x] == 1:
              height[x] = y + 1
              break
          else:
            height[x] = 0
      else:
        height[q:q + p] = [pos + 1] * p

    if d == 2:
      pop_flag = False
      pos = height[q]
      for y in range(pos, pos + p):
        mp[y][q] = 1
      for y in range(pos + p - 1, pos - 1, -1):
        if mp[y] == end:
          cnt -= 5
          mp.pop(y)
          mp.append([0] * 5)
          pop_flag = True
      
      if pop_flag:
        for x in range(5):
          for y in range(i * 5 - 1, -1, -1):
            if mp[y][x] == 1:
              height[x] = y + 1
              break
          else:
            height[x] = 0
      else:
        height[q] += p
  
  print(cnt)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst))



Fixed submission:
from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst, len_prime):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if i < len_prime and prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)
len_prime = len(prime_lst)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst, len_prime))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop as hpop
from heapq import heappush as hpush

while True:
  n, m = map(int, input().split())
  
  if not n:
    break
  
  cost_edges = [[] for _ in range(m)]
  time_edges = [[] for _ in range(m)]

  for _ in range(n):
    a, b, c, t = map(int, input().split())
    cost_edges[a - 1].append((c, b - 1))
    cost_edges[b - 1].append((c, a - 1))
    time_edges[a - 1].append((t, b - 1))
    time_edges[b - 1].append((t, a - 1))
  
  k = int(input())

  for _ in range(k):
    start, goal, r = map(int ,input().split())
    start -= 1
    goal -= 1
    
    if r:
      edges = time_edges
    else:
      edges = cost_edges

    que = [(0, start)]
    visited = [False for _ in range(m)]
    
    while que:
      score, station = hpop(que)
      visited[station] = True
      
      if station == goal:
        print(score)
        break

      for c, to_station in edges[station]:
        if not visited[to_station]:
          hpush(que, (score + c, to_station))


Fixed submission:
from heapq import heappop as hpop
from heapq import heappush as hpush

def main():
  
  while True:
    n, m = map(int, input().split())
    
    if not n:
      break
    
    cost_edges = [[] for _ in range(m)]
    time_edges = [[] for _ in range(m)]
  
    for _ in range(n):
      a, b, c, t = map(int, input().split())
      cost_edges[a - 1].append((c, b - 1))
      cost_edges[b - 1].append((c, a - 1))
      time_edges[a - 1].append((t, b - 1))
      time_edges[b - 1].append((t, a - 1))
    
    k = int(input())
  
    for _ in range(k):
      start, goal, r = map(int ,input().split())
      start -= 1
      goal -= 1
      
      if r:
        edges = time_edges
      else:
        edges = cost_edges
  
      que = [(0, start)]
      visited = [False for _ in range(m)]
      
      while True:
        score, station = hpop(que)
        visited[station] = True
        
        if station == goal:
          print(score)
          break
  
        for c, to_station in edges[station]:
          if not visited[to_station]:
            hpush(que, (score + c, to_station))

main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def get_par(x, par_lst):
  if x == par_lst[x]:
    return x
  ret = get_par(par_lst[x], par_lst)
  #par_lst[x] = ret
  return ret

def main():
  while True:
    n, m = map(int, input().split())
    if n == 0:
      break
    par_lst = [i for i in range(n)]
    counter = Counter()
    flag = False
    if m == 0:
      print("yes")
      continue
    for _ in range(m):
      u, v = map(int, input().split())
      u -= 1
      v -= 1
      counter[u] += 1
      counter[v] += 1
      pu, pv = get_par(u, par_lst), get_par(v, par_lst)
      if pu == pv:
        flag = True
      else:
        par_lst[pu] = pv
    
    if counter.most_common()[0][1] > 2:
      flag = True
    if flag:
      print("no")
    else:
      print("yes")
main()


Fixed submission:
from collections import Counter
def get_par(x, par_lst):
  if x == par_lst[x]:
    return x
  ret = get_par(par_lst[x], par_lst)
  par_lst[x] = ret
  return ret

def main():
  while True:
    n, m = map(int, input().split())
    if n == 0:
      break
    par_lst = [i for i in range(n)]
    counter = [0] * n
    flag = False
    for _ in range(m):
      u, v = map(int, input().split())
      u -= 1
      v -= 1
      counter[u] += 1
      counter[v] += 1
      pu, pv = get_par(u, par_lst), get_par(v, par_lst)
      if pu == pv:
        flag = True
      else:
        par_lst[pu] = pv
    
    if max(counter) > 2:
      flag = True
    if flag:
      print("no")
    else:
      print("yes")
main()
Buggy python submission (verdict: Time Limit Exceeded):
while True:
  n = input()
  if n == "0000":
    break
  if n.count(n[0]) == 4:
    print("NA")
    continue
  cnt = 0
  while n != "6174":
    cnt += 1
    l = int("".join(sorted(list(str(n)), reverse=True)))
    s = int("".join(sorted(list(str(n)))))
    n = str(l - s)
  print(cnt)





Fixed submission:
while True:
  n = input()
  if n == "0000":
    break
  if n.count(n[0]) == 4:
    print("NA")
    continue
  cnt = 0
  while n != "6174":
    cnt += 1
    l = "".join(sorted(list(n), reverse=True))
    s = "".join(sorted(list(n)))
    n = str(int(l) - int(s)).zfill(4)
  print(cnt)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  print(int(lst[bl(lst, q)] == q))


Fixed submission:
from bisect import bisect_left as bl

n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
  if a % 2 == 0:
    ind += a
  else:
    ind -= a
  ind = ind % len(lst)
  lst.pop(ind)
  ind = ind % len(lst)

qlst = list(map(int, input().split()))
for q in qlst:
  print(int(q in lst))