Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def feed_runrun(answer, burger_dimension, appetite):
    if appetite == 0:
        return answer

    burger_size = 2 ** (burger_dimension + 2) - 3
    # 食べきれないなら小さくして試す
    if appetite < burger_size:
        return feed_runrun(answer, burger_dimension - 1, appetite - 1)

    amount_of_p = 2 ** (burger_dimension + 1) - 1
    if appetite == burger_size + 1:
        return answer + amount_of_p + 1
    return feed_runrun(answer + amount_of_p + 1, burger_dimension, appetite - burger_size - 1)


n, x = map(int, input().split())
print(feed_runrun(0, n, x))

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

answer = 0
red = x

searching_index = n
while red > 0:
    for i in reversed(range(searching_index + 1)):
        length = 2**(i + 2) - 3
        if red >= length:
            if red >= length + 1:
                answer += 1
                red -= 1
            searching_index = i
            answer += 2**(i+1) - 1
            red -= length
            break
        red -= 1

print(answer)

Buggy python submission (verdict: Runtime Error):
def feed_runrun(answer, burger_dimension, appetite):
    if appetite == 0:
        return answer

    burger_size = 2 ** (burger_dimension + 2) - 3
    # 食べきれない
    if appetite < burger_size:
        return feed_runrun(answer, burger_dimension - 1, appetite - 1)
    # 食べきれるので, 食べる
    amount_of_p = 2 ** (burger_dimension + 1) - 1
    return feed_runrun(answer + amount_of_p + 1, burger_dimension, appetite - burger_size - 1)


n, x = map(int, input().split())
print(feed_runrun(0, n, x))

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

answer = 0
red = x

searching_index = n
while red > 0:
    for i in reversed(range(searching_index + 1)):
        length = 2**(i + 2) - 3
        if red >= length:
            if red >= length + 1:
                answer += 1
                red -= 1
            searching_index = i
            answer += 2**(i+1) - 1
            red -= length
            break
        red -= 1

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
nums = list(map(int, input().split()))
n = nums[0]
m = nums[1]

codes = []
prefectures = []


class Prefecture:
    def __init__(self, id, list):
        self.id = id
        self.list = list


for i in range(m):
    codes.append(list(map(int, input().split())))

for code in codes:
    exist = False
    for prefecture in prefectures:
        if code[0] == prefecture.id:
            prefecture.list.append(code[1])
            exist = True
            break
    if not exist:
        prefectures.append(Prefecture(code[0], [code[1]]))

for prefecture in prefectures:
    prefecture.list = sorted(prefecture.list)

for code in codes:
    for prefecture in prefectures:
        if code[0] == prefecture.id:
            for i in range(len(prefecture.list)):
                if code[1] == prefecture.list[i]:
                    print(str(code[0]).zfill(6) + str(i+1).zfill(6))
                    break
            break

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

prefectures = []

i = 0
while i < m:
    p, y = map(int, input().split())
    prefectures.append((i, p, y))
    i += 1
prefectures.sort(key=lambda x: x[2])

answers = []
ranks = [1 for i in range(n + 1)]
for i, p, y in prefectures:
    answers.append((i, str(p).zfill(6) + str(ranks[p]).zfill(6)))
    ranks[p] += 1

answers.sort()

for i, answer in answers:
    print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
nums = list(map(int, input().split()))
n = nums[0]
m = nums[1]

codes = []
prefectures = []


class Prefecture:
    def __init__(self, id, list):
        self.id = id
        self.list = list


for i in range(m):
    codes.append(list(map(int, input().split())))

for code in codes:
    exist = False
    for prefecture in prefectures:
        if code[0] == prefecture.id:
            prefecture.list.append(code[1])
            exist = True
            break
    if not exist:
        prefectures.append(Prefecture(code[0], [code[1]]))

for prefecture in prefectures:
    prefecture.list = sorted(prefecture.list)

for code in codes:
    for prefecture in prefectures:
        if code[0] == prefecture.id:
            for i in range(len(prefecture.list)):
                if code[1] == prefecture.list[i]:
                    print(str(code[0]).zfill(6) + str(i+1).zfill(6))
            break

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

prefectures = []

i = 0
while i < m:
    p, y = map(int, input().split())
    prefectures.append((i, p, y))
    i += 1
prefectures.sort(key=lambda x: x[2])

answers = []
ranks = [1 for i in range(n + 1)]
for i, p, y in prefectures:
    answers.append((i, str(p).zfill(6) + str(ranks[p]).zfill(6)))
    ranks[p] += 1

answers.sort()

for i, answer in answers:
    print(answer)
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split()))

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 100000
bug2 = [0] * 100000

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)

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

nums1 = nums[0::2]
nums2 = nums[1::2]

bug1 = [0] * 1000000
bug2 = [0] * 1000000

for num in nums1:
    bug1[num] += 1

for num in nums2:
    bug2[num] += 1

max_v_1 = max(bug1)
max_i_1 = bug1.index(max_v_1)
max_v_2 = max(bug2)
max_i_2 = bug2.index(max_v_2)

if max_i_1 == max_i_2:
    bug1[max_i_1] = 0
    bug2[max_i_2] = 0
    sec_max_v_1 = max(bug1)
    sec_max_v_2 = max(bug2)
    print(n - min(max_v_1, max_v_2) - max(sec_max_v_1, sec_max_v_2))
else:
    print(n - max_v_1 - max_v_2)
Buggy python submission (verdict: Runtime Error):
def is_upper_case(s):
  return not (ord('a') <= ord(s) <= ord('z'))

S = input()

if S[0] != 'A':
  print("WA")
  exit()

if S[2:-1].count('C') != 1:
  print("WA")
  exit()

upper_num = map(is_upper_case, S).count(True)

if upper_num != 2: # expected only 'A', 'C'
  print("WA")
  exit()

print("AC")


Fixed submission:
def isNotLower(s):
  return not (ord('a') <= ord(s) <= ord('z'))

S = input()

if S[0] != 'A':
  print("WA")
  exit()

if S[2:-1].count('C') != 1:
  print("WA")
  exit()

upper_limit = 2 # only 'A', 'C'
for s in S:
  if isNotLower(s):
    upper_limit -= 1

  if upper_limit < 0:
    print("WA")
    exit()

print("AC")
Buggy python submission (verdict: Runtime Error):
input()
nums = input().split()
result = 18 # 制約 Ai < 10^9より
for num in nums:
  num = int(num)
  div_times = 0
  while (num & 1) == 0:
    num = num >> 1
    div_times += 1
  if div_times < result:
    result = div_times
print(result)

Fixed submission:
marbleNum = input().count("1")
print(marbleNum)

Buggy python submission (verdict: Runtime Error):
input()
nums = input().split()
result = 18 # 制約 Ai < 10^9より
for num in nums:
  num = int(num)
  div_times = 0
  while (num & 1) == 0:
    num = num >> 1
    div_times += 1
  if div_times < result:
    result = div_times
print(result)

Fixed submission:
marbleNum = input().count("1")
print(marbleNum)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

A = [ input() for _ in range(N) ]
B = [ input() for _ in range(M) ]

for i in range(N-M+1):
  for _ in range(A[i].count(B[0])):
    l = A[i].index(B[0], l)
    result = True
    for k in range(1, M):
      if B[k] != A[i+k][l:l+len(B[k])]:
        result = False
        break
    if result:
      print("Yes")
      exit()
    l += 1
      
print("No")

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

A = [ input() for _ in range(N) ]
B = [ input() for _ in range(M) ]

for i in range(N-M+1):
  for _ in range(A[i].count(B[0])):
    l = A[i].index(B[0])
    result = True
    for k in range(1, M):
      if B[k] != A[i+k][l:l+len(B[k])]:
        result = False
        break
    if result:
      print("Yes")
      exit()
    l += 1
      
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
attends = [int(each) for each in input().split(' ')]
ordered = attends.copy()
ordered.sort()
for each in ordered:
    print(attends.index(each) + 1, end=' ')


Fixed submission:
from operator import itemgetter
n = int(input())
ordered_info = [ [i, int(num)] for i, num in zip(range(n), input().split(' '))]
ordered_info.sort(key = itemgetter(1))
ans = ''
for i, _ in ordered_info:
    print(i+1, end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
attends = [int(each) for each in input().split(' ')]
ordered = sorted(attends)
for each in ordered:
    print(attends.index(each) + 1, end=' ')


Fixed submission:
from operator import itemgetter
n = int(input())
ordered_info = [ [i, int(num)] for i, num in zip(range(n), input().split(' '))]
ordered_info.sort(key = itemgetter(1))
ans = ''
for i, _ in ordered_info:
    print(i+1, end=' ')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
attends = [int(each) for each in input().split(' ')]
ordered = sorted(attends)
ans = ''
for each in ordered:
    ans += str(attends.index(each) + 1) + ' '
print(ans)

Fixed submission:
from operator import itemgetter
n = int(input())
ordered_info = [ [i, int(num)] for i, num in zip(range(n), input().split(' '))]
ordered_info.sort(key = itemgetter(1))
ans = ''
for i, _ in ordered_info:
    print(i+1, end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1

print(len(set(prime_num[0])&set(prime_num[1])))


Fixed submission:
A = [int(i) for i in input().split()]

prime_num = [[],[]]

prime_num[0].append(1)
prime_num[1].append(1)

for i in range(2):
    a = 2
    n = A[i]
    while A[i] >= a*a:
        if n%a == 0:
            prime_num[i].append(a)
            n /= a
        else:
            a+=1
    prime_num[i].append(n)
    

#print(prime_num)
print(len(set(prime_num[0])&set(prime_num[1])))
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]

for seikaisha in list_seikaisha:
    list_pt=[x-1 for x in list_pt]
    list_pt[seikaisha]=list_pt[seikaisha]+1

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in list_pt:
    print(f(pt))

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

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]

for seikaisha in list_seikaisha:
    list_pt[seikaisha]=list_pt[seikaisha]+1
list_pt=[x-Q for x in list_pt]

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in list_pt:
    print(f(pt))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N,K,Q=map(int,input().split())

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]
arr_pt=np.array(list_pt)

for seikaisha in list_seikaisha:
    arr_pt=arr_pt-1
    arr_pt[seikaisha]=arr_pt[seikaisha]+1

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in arr_pt:
    print(f(pt))


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

list_seikaisha =[]

for i in range(Q):
    list_seikaisha.append(int(input())-1)

list_pt=[K for i in range(N)]

for seikaisha in list_seikaisha:
    list_pt[seikaisha]=list_pt[seikaisha]+1
list_pt=[x-Q for x in list_pt]

list_YN=[]
f=lambda pt:"Yes" if pt>=1 else "No"
for pt in list_pt:
    print(f(pt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))

import collections
odd = collections.defaultdict(lambda : 0)
even = collections.defaultdict(lambda: 0)

for index, i in enumerate(li):
    if index % 2 == 0:
        even[i] += 1
    elif index % 2 != 0:
        odd[i] += 1

# odd = list(filter(lambda x: x % 2 != 0, li))
sorted_odd = [(k, odd[k]) for k in sorted(odd, key=odd.get, reverse=True)]
max_odd = sorted_odd[0]
# even = list(filter(lambda x: x % 2 == 0, li))
sorted_even = [(k, even[k]) for k in sorted(even, key=even.get, reverse=True)]
max_even = sorted_even[0]

if max_odd[0] == max_even[0] and len(sorted_odd) == 1 and len(sorted_even) == 1:
    print(int(n / 2))
elif max_odd[0] == max_even[0]:
    if len(sorted_odd) >= 2:
        print(int(n/2 - sorted_odd[1] + n/2 - max_even[1]))
    elif len(sorted_even) >= 2:
        print(int(n/2 - sorted_even[1] + n/2 - max_odd[1]))
else:
    print(int(n/2 - max_odd[1] + n/2 - max_even[1]))




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

even = []
odd = []

for index, i in enumerate(li):
    if index % 2 == 0:
        even.append(i)
    elif index % 2 != 0:
        odd.append(i)

from collections import Counter
so_ev = Counter(even).most_common(2)
so_od = Counter(odd).most_common(2)

if so_ev[0][0] == so_od[0][0]:
    if len(so_ev) == 1 and len(so_od) == 1:
        print(n - so_ev[0][1])
    else:
        print(min(n - so_ev[1][1] - so_od[0][1], n - so_ev[0][1] - so_od[1][1]))
else:
    print(n - so_ev[0][1] - so_od[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
dx = [-1, -1, -1, 0, 1, 1, 1, 0]
dy = [1, 0, -1, -1, -1, 0, 1, 1]

# 0 裏 1 表
n, m = map(int, input().split())
count = 0
if n == 1 or m == 1:
    for i in range(n):
        for j in range(m):
            xy_count = 0
            for x, y in zip(dx, dy):
                if i + y == -1 or i + y == n or j + x == -1 or j + x == m:
                    continue
                # lis[i + y][j + x] = not lis[i + y][j + x]
                xy_count += 1
            if xy_count % 2 == 0:
                count += 1
    print(count)
else:
    print(n * m - (2 * n + 2 * m - 4))

Fixed submission:
n, m = map(int, input().split())
print(abs(n * m - (2 * n + 2 * m - 4)))
Buggy python submission (verdict: Time Limit Exceeded):
import math


def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False

q = input()
lr = []
max_num = 0
input_list = sieve_of_erastosthenes(100000)
prime_list = [i for i, b in enumerate(input_list) if b == True]
for ii in xrange(q):
    tmp = map(int, raw_input().split(" "))
    count = 0
    # max_num = max(max(tmp), max_num)
    # lr.append(tmp)
    for j in xrange(tmp[0], tmp[1] + 1):
        if j in prime_list and (j + 1) / 2 in prime_list:
            count += 1

    print count


Fixed submission:
import math
import sys

def sieve_of_erastosthenes(num):
    input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]
    input_list[0] = input_list[1] = False
    input_list[2] = input_list[3] = input_list[5] = True
    sqrt = math.sqrt(num)

    for serial in range(3, num, 2):

        if serial >= sqrt:
            return input_list

        for s in range(serial ** 2, num, serial):
            input_list[s] = False

q = input()
lr = []
max_num = 0
INF = sys.maxint
input_list = sieve_of_erastosthenes(100000)
# prime_list = [i for i, b in enumerate(input_list) if b == True]
prime_list_append = []
sum_count = 0
for index, i in enumerate(input_list):
    if i and input_list[(index + 1) / 2]:
        # print i, (index + 1)/2, sum_count
        sum_count += 1
        prime_list_append.append(sum_count)
    else:
        prime_list_append.append(sum_count)

for ii in xrange(q):
    tmp = map(int, raw_input().split(" "))
    # count = 0
    # for j in prime_list_append[tmp[0]:tmp[1]]:
    #     count += 1
    print prime_list_append[tmp[1]] - prime_list_append[tmp[0]-1]
Buggy python submission (verdict: Runtime Error):
t=raw_input().split(“”)
count=0
for i in t:
    if i == “1”:
        count+=1
print count

Fixed submission:
t=list(raw_input())
count=0
for i in t:
    if i == "1":
        count+=1
print count
Buggy python submission (verdict: Runtime Error):
raw_input()
t=map(int, raw_input().split(" "))
count=0

while True:
    for i in t:
        flag=True
        if i % 2 != 0:
            flag=False
    if !flag:
        break
    else:
        t = [x / 2 for x in t]
        count+=1
        
print count

Fixed submission:
raw_input()
t=map(int, raw_input().split(" "))
count=0

while True:
    flag=True
    for i in t:
        if i % 2 != 0:
            flag=False
    if not flag:
        break
    else:
        t = [x / 2 for x in t]
        count+=1
        
print count
Buggy python submission (verdict: Time Limit Exceeded):
sum_num = 1
for i in range(1, int(input()) + 1):
    sum_num *= (i % (10**9 + 7))
print(sum_num % (10**9 + 7))

Fixed submission:
sum_num = 1
for i in range(1, int(input()) + 1):
    sum_num = (sum_num * i) % (10**9 + 7)
print(sum_num)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
import sys

if n > int(m / 2):
    print(int(m / 2))
    sys.exit(0)

while True:
    if n > (m - 2) / 2:
        break
    else:
        n += 1
        m -= 2
print(int(m / 2))

Fixed submission:
n, m = map(int, input().split())
import sys

if n > int(m / 2):
    print(int(m / 2))
    sys.exit(0)

print(n + int((m - n * 2) / 4))
Buggy python submission (verdict: Time Limit Exceeded):
def getZ_index(input_list):
    for index, i in enumerate(reversed(input_list)):
        if i == 'Z':
            return len(input_list) - index
    return 0


lis = list(input())
max_num = 0
for index, i in enumerate(lis):
    if i == 'A':
        if 'Z' in lis[index: len(lis)]:
            max_num = max(max_num, getZ_index(
                lis[index: len(lis)]))
print(max_num)


Fixed submission:
s = list(input())
print(len(s) - list(reversed(s)).index('Z') - s.index('A'))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

count = 0
if int(s / 3) == 0:
    for x in range(s + 1):
        for y in range(s + 1):
            for z in range(s + 1):
                if x + y + z == s:
                    count += 1
else:
    for x in range(max(k, int(s / 3) + 1)):
        for y in range(max(k, int(s / 3) + 1)):
            for z in range(max(k, int(s / 3) + 1)):
                if x + y + z == s:
                    count += 1

print(count)

Fixed submission:
k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y and s - x - y <= k:
            count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count += 1

print(count)

Fixed submission:
k, s = map(int, input().split())

count = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y and s - x - y <= k:
            count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
num, jet = (input().split())

height = list(map(int, input().split()))
ans = 0

for n in height:
    if n >= int(jet):
        ans += 1
    else:
        continue

print(ans)



Fixed submission:
n = int(input())


if n % 2 == 0:
    print(0.5)
else:
    print((n//2 + 1)/n)
Buggy python submission (verdict: Runtime Error):
import math
n, c = map(int, input().split())

a = input()
print(math.ceil((n-1)//(c-1)))


Fixed submission:
s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)

Buggy python submission (verdict: Runtime Error):
n, c = map(int, input().split())
print((n-1)//(c-1))


Fixed submission:
s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)

Buggy python submission (verdict: Runtime Error):
S = input()
Sum =sum(int(i) for i in str(S))
if int(S) % Sum == 0:
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)

Buggy python submission (verdict: Runtime Error):
s = input().split()
n = int(input())
a +=s.count('+')
b  -= s.count('-')
print(n-a-b)


Fixed submission:
s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)

Buggy python submission (verdict: Runtime Error):
s = input().split()
n = int(input())
n +=s.count('+')
n  -= s.count('-')
print(n)



Fixed submission:
s = input()
n, m  = s.count('+'), s.count('-')
print(n-m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if(N == 1):
  return(1)
elif(N %2 == 0):
  return(0.5)
elif(N %2 == 1):
  return((N+1)/(2*N))

Fixed submission:
N = int(input())
if(N == 1):
  print(1)
elif(N %2 == 0):
  print(0.5)
elif(N %2 == 1):
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N = int(input())

print(f'{(N+1)//2/N}')

Fixed submission:
N = int(input())

print((N+1)//2/N)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)+1):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Fixed submission:
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
ans = "1"
for i in range(k+1):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)

Fixed submission:
s = input()
n = len(s)
k = int(input())
ans = "1"
for i in range(min(n, k)):
    ss = s[i]
    if ss != "1":
        ans = ss
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
flag = False
for x in range(100):
    for y in range(100):
        flag = (4*x+7*y==n)
if flag:
    print("Yes")
else
    print("No")

Fixed submission:
n = int(input())
flag = False
for x in range(100):
    for y in range(100):
        if 4*x+7*y==n:
            flag = True
if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    for j in range(16):
        if (i >> j) & 1:
                temp += (-2) ** (2 *j)
    ps[i] = temp

"""
for index, value in enumerate(ps):
    print(bin(index)[2:].zfill(16), value)
"""

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    for j in range(16):
        if (i >> j) & 1:
                temp2 += (-2) ** (2 *j + 1)
    n2 = n - temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)

Fixed submission:
import bisect
n = int(input())
ps = [0] * (1 << 16)
for i in range(1 << 16):
    temp = 0
    for j in range(16):
        if (i >> j) & 1:
                temp += (-2) ** (2 *j)
    ps[i] = temp

pattern1 = None
pattern2 = None

for i in range(1 << 16):
    temp2 = 0
    for j in range(16):
        if (i >> j) & 1:
                temp2 += (-2) ** (2 *j + 1)
    n2 = n - temp2
    pattern1 = bisect.bisect_left(ps, n2)
    if pattern1 != (1 << 16) and ps[pattern1] == n2:
        pattern2 = bin(i)[2:].zfill(16)
        pattern1 = bin(pattern1)[2:].zfill(16)
        break

ans = ""
for i in range(16):
    ans += pattern2[i]
    ans += pattern1[i]
    
true_ans = ""
flag = False
for i in range(len(ans)):
    if ans[i]=="1":
        true_ans += "1"
        flag = True
    elif flag:
        true_ans += "0"

if true_ans == "":
    true_ans = "0"
        
print(true_ans)