Problem:


Score: 100 points

Problem Statement

In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.

For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  

In this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi.

How many days from 2018-1-1 through 2018-a-b are Takahashi?

Constraints

a is an integer between 1 and 12 (inclusive).

b is an integer between 1 and 31 (inclusive).

2018-a-b is a valid date in Gregorian calendar.

Input

Input is given from Standard Input in the following format:

a b

Output

Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi.

Sample Input 1

5 5

Sample Output 1

5

There are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.

Sample Input 2

2 1

Sample Output 2

1

There is only one day that is Takahashi: 1-1.

Sample Input 3

11 30

Sample Output 3

11

There are eleven days that are Takahashi: 1-1, 2-2, 3-3, 4-4, 5-5, 6-6, 7-7, 8-8, 9-9, 10-10 and 11-11.



Sample input:
5 5


Sample output:
5

Submission status: Runtime Error

Solution code:
import math

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True
	

N = int(input())
count = 0
a_list = []

for i in range(5550):
	a = 10 * i + 1
	if is_prime(a):
		a_list.append(a)
		count += 1
		if count == N:
			break

print (' '.join(map(str, a_list)))

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
if a > b:
  print(a - 1)
else:
print(a)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
if a > b:
  print(a - 1)
else;
print(a)

Submission status: Runtime Error

Solution code:
x, y = map(int, input().split())
 
cnt = 0
for i in range(1, 13):
    for j in range(1, 13):
        if x == i and y >== j:
            cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
a,b,c = map(int(), input().split())
k = int(input())
kk=2**k
m = max(a,b,c)
al = a+b+c-m+kk*m
print(al)

Submission status: Runtime Error

Solution code:
a,b = map(int() , input().split())
count=0
for i in range(1,a+1):
    for n in range(1b+1):
        if i==n:
            count+=1

Submission status: Runtime Error

Solution code:
a,b = map(int, input().split())
count=0
for i in range(1,a+1):
    for n in range(1b+1):
        if i==n:
            count+=1

print(count)

Submission status: Runtime Error

Solution code:
a, b = int(input())

if b >= a:
    print(a)
else:
    print(a)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if a<=b:
  return a
else:
  return a-1

Submission status: Runtime Error

Solution code:
import sys

# pre process
X = [int(i) for i in input().split()]
H, W = X
grid = []
for row in range(H):
    grid.append([char for char in input()])



# solve
if H == 1 and W == 1:
    print('No')
    exit(0)
elif H == 1:
    for w in range(W):
        if grid[0][w] == "#":
            if w == 0:
                if not(grid[0][w+1] == '#'):
                    print("No")
                    exit(0)
            elif w == W-1:
                if not(grid[0][w-1] == '#'):
                    print("No")
                    exit(0)
            else:
                if not (grid[0][w - 1] == '#' or grid[0][w+1] == '#'):
                    print("No")
                    exit(0)
elif W == 1:
    for h in range(H):
        if grid[h][0] == "#":
            if h == 0:
                if not(grid[h+1][0] == '#'):
                    print("No")
                    exit(0)
            elif h == H-1:
                if not(grid[h-1][0] == '#'):
                    print("No")
                    exit(0)
            else:
                if not (grid[h-1][0] == '#' or grid[h+1][0] == '#'):
                    print("No")
                    exit(0)
else:
    for h in range(H):
        for w in range(W):
            if grid[h][w] == "#":
                # 枠の内側
                if h != 0 and h != H-1 and w != 0 and w != W-1:
                    if not(grid[h+1][w] == "#" or grid[h-1][w] == '#' or grid[h][w-1] == '#' or grid[h][w+1] == '#'):
                        print("No")
                        exit(0)
                # 枠の上ふち
                elif h == 0:
                    if w == 0:
                        if not(grid[h+1][w] == "#" or grid[h][w+1] == '#'):
                            print("No")
                            exit(0)
                    elif w == W-1:
                        if not(grid[h+1][w] == "#" or grid[h][w-1] == '#'):
                            print("No")
                            exit(0)
                    else:
                        if not (grid[h + 1][w] == "#" or grid[h][w - 1] == '#' or grid[h][w + 1] == '#'):
                            print("No")
                            exit(0)
                # 枠の下ふち
                elif h == H-1:
                    if w == 0:
                        if not (grid[h - 1][w] == "#" or grid[h][w + 1] == '#'):
                            print("No")
                            exit(0)
                    elif w == W-1:
                        if not (grid[h - 1][w] == "#" or grid[h][w - 1] == '#'):
                            print("No")
                            exit(0)
                    else:
                        if not (grid[h - 1][w] == "#" or grid[h][w - 1] == '#' or grid[h][w + 1] == '#'):
                            print("No")
                            exit(0)
                # 枠の左ふち
                elif w == 0:
                    if not (grid[h + 1][w] == "#" or grid[h-1][w] == '#' or grid[h][w + 1] == '#'):
                        print("No")
                        exit(0)
                # 枠の左ふち
                elif w == W-1:
                    if not (grid[h + 1][w] == "#" or grid[h - 1][w] == '#' or grid[h][w -1] == '#'):
                        print("No")
                        exit(0)
print('Yes')

Submission status: Runtime Error

Solution code:
x = input().split(" ")
if x[0] <= x[1] :
    print(x[0])
else:
    print(x[0]-1)

Submission status: Runtime Error

Solution code:
if b >= a:
    print(a)
else:
    print(a-1)

Submission status: Runtime Error

Solution code:
import sys
y = sys.stdin.readline()

xx = y.rstrip()

i = 0
x = 0
while True:
    if x > int(xx):
        break
    i += 1
    x = i*i
print((i-1)*(i-1))

Submission status: Runtime Error

Solution code:
a , b = (int(i) for i in input().split())
if a <= b :
    print('{}'.format(a)
else :
    print('{}'.format(a-1))

Submission status: Runtime Error

Solution code:
a , b = (int(i) for i in input().split())
if a >= b :
    print('{}'.format(a)
else b < a :
    print('{}'.format(b))

Submission status: Runtime Error

Solution code:
x, y = map(int, input().split())
ans = x - 1
if x <= y: 
    ans++
print(ans)

Submission status: Runtime Error

Solution code:
l = list(map(int, input().split()))
K = int(input())

l.sort()
for i in range(K):
    l[0] = 2*l[0]
    
print(l[0] + l[1] + l[2])

Submission status: Runtime Error

Solution code:
a,b,c = [int(i) for i in input().split()]
k = int(input())
max = max(a,b,c)
tmp = a+b+c - max

for i in range(k):
    max = max*2

print(tmp+max)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if b<=a:
  if a = 1 or a = 12 :
    print(a)
  else:
    print(a+1)
else:
  print(a)

Submission status: Runtime Error

Solution code:
a,b = map(int,input().split())
if b<=a:
  if a = 1:
    print(a)
  else:
    print(a+1)
else:
  print(a)

Submission status: Runtime Error

Solution code:
m=1000
while(2**i<m):
    i+=1
m=2**i
print(m)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split)
print(a if a<=b else a-1)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split)
print(a-b if b<a else a-b+1)

Submission status: Runtime Error

Solution code:
list = raw_input().split()
if list[0] <= list[1]:
  print list[0]
else:
  print list[0] - 1

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
arr = [list(input()) for i in range(N)]
newmat = [[0 for i in range(M)] for j in range(N)]
nocheck = 0
count = 0
for i in range(N):
    for j in range(M):
        if arr[i][j] is '#':
            newmat[i][j] = 1
        else:
            newmat[i][j] = 0

for i in range(N):
    for j in range(M):
        if newmat[i][j] == 1:
            count += 1
            if i == 0 and j == 0:
                if newmat[i][j+1] == 0 and newmat[i+1][j] == 0:
                    nocheck = 1
                    break
            elif i == 0 and j == (M-1):
                if newmat[i][j-1] == 0 and newmat[i+1][j] == 0:
                    nocheck = 1
                    break
            elif i == (N-1) and j == 0:
                if newmat[i][j+1] == 0 and newmat[i-1][j] == 0:
                    nocheck = 1
                    break
            elif i == (N-1) and j == (M-1):
                if newmat[i][j-1] == 0 and newmat[i-1][j] == 0:
                    nocheck = 1
                    break
            elif i == 0 and j != 0:
                if newmat[i][j+1] == 0 and newmat[i+1][j] == 0 and newmat[i][j-1] == 0:
                    nocheck = 1
                    break
            elif i != 0 and j == 0:
                if newmat[i][j + 1] == 0 and newmat[i + 1][j] == 0 and newmat[i-1][j] == 0:
                    nocheck = 1
                    break
            elif i == (N-1) and j != (M-1):
                if newmat[i][j+1] == 0 and newmat[i-1][j] == 0 and newmat[i][j-1] == 0:
                    nocheck = 1
                    break
            elif i != (N-1) and j == (M-1):
                if newmat[i-1][j] == 0 and newmat[i+1][j] == 0 and newmat[i][j-1] == 0:
                    nocheck = 1
                    break

            else:
                if newmat[i][j + 1] == 0 and newmat[i + 1][j] == 0 and newmat[i][j - 1] == 0 and newmat[i-1][j]:
                    nocheck = 1

if(nocheck == 0 and count != 1):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 5
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime and num % 5 == 1:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = [next(prime_gene) for _ in range(N)]
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 5
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = []

while len(ans) < N:
    prime = next(prime_gene)
    if prime % 5 == 1:
        ans.append(prime)
print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())


def is_prime(n):
    for i in range(1, n):
        if i != 1 and n % i == 0:
            return False
    return True


def prime_numbers():
    num = 2
    while True:
        is_num_prime = is_prime(num)
        if is_num_prime:
            yield num
        num += 1


prime_gene = prime_numbers()
ans = []

while len(ans) < 5:
    prime = next(prime_gene)
    if prime % 5 == 1:
        ans.append(prime)
print(ans)

Submission status: Runtime Error

Solution code:
k = int(input())
l = [2, 7, 17, 37, 47, 67, 97, 107, 127, 137, 157, 167, 197, 227, 257, 277, 307, 317, 337, 347, 367, 397, 457, 467, 487, 547, 557, 577, 587, 607, 617, 647, 677, 727, 757, 787, 797, 827, 857, 877, 887, 907, 937, 947, 967, 977, 997]
print(" ".join(map(str,l[0:k])))

Submission status: Runtime Error

Solution code:
N = int(input())
lis = [i for i in range(2,55555)]
primes = []
p=1
while(p*p < 55555):
  p = lis.pop(0)
  primes.append(p)
  for num in lis:
    if num%p == 0: lis.remove(num)
primes = primes + lis
print(' '.join(map(str, primes[:N])))

Submission status: Runtime Error

Solution code:
a,b,c,d = map(int ,input().split())

if abs(b - a) <= d or abs(c - b) <= d or abs(a - c) <= d:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
S = []
flag = True
for i in range(h):
    r = list(input())
    S.append(r)
for i in range(0,h-1):
    for j in range(0,w-1):
        if S[i][j]=='#' and S[i-1][j]=='.' and S[i][j-1]=='.' and S[i+1][j]=='.' and S[i][j+1]=='.':
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
k = int(input())
m = max(a,b,c)
output = m*2**k+a+b+c-m
print(output)

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
k = int(input())
maxnum = max(a,b,c)
output = maxnum*2**k+a+b+c-maxnum
print(output)

Submission status: Runtime Error

Solution code:
#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(W):
	s = input()
	s_list = list(s)
	S.append(s_list)

#計算
for i in range(0, W-1, 1):
	for j in range(0, H-1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		

#出力
if flag == True:
	print("Yes")

else:
	print("No")

Submission status: Runtime Error

Solution code:
#Grid Repainting 2

#初期化
S = []
p = []
flag = True

#入力
H,W = map(int, input().split())
for i in range(W):
	s = input()
	s_list = list(s)
	S.append(s_list)

#計算
for i in range(0, H-1, 1):
	for j in range(1, W-1, 1):
		if S[i][j] == "#" and S[i+1][j] == "." and S[i][j+1] == "."  and S[i-1][j] == "." and S[i][j-1] == "." :
			flag = False
		

#出力
if flag == True:
	print("Yes")

else:
	print("No")

Submission status: Runtime Error

Solution code:
a, b = map(int, input())
th = a-1
if a<b:
    print(th)
else:
    print(th+1)

Submission status: Runtime Error

Solution code:

A,B,C=map(int,input().split())
K=int(input())
a=0
 
if A<=B:
    d=B
else:
    d=A
if d>C: a="aiueo"
else:
	d=C;

if d==A:
	all=B+C
if d==B:
	all=A+C
if d==C:
	all=B+A

while a<K:
	d*=2
	a+=1

all+=d
print (all)

Submission status: Runtime Error

Solution code:
a = list(int(i) for i in input().split())
k = int(input())

maximum_sum = a[0] + a[1] + a[2] + max(a)*((2**k)-1)
print('{}'.format(maximum_sum))

Submission status: Runtime Error

Solution code:
#Day of Takahashi

#入力
a, b = map(int, input().split())

#計算
if a > b:
	ans = a-1

if a < b:
	ans = a

#出力
print("{}".format(ans))

Submission status: Runtime Error

Solution code:
#Day of Takahashi

#入力
a, b = map(int, input().split())

#計算
if a > b:
	ans = b

if a < b:
	ans = a

#出力
print("{}".format(ans))

Submission status: Runtime Error

Solution code:
import math
N = int(input())

l = [i for i in range(55556)]
l[1] = 0
for i in l[1:]:
    if i > math.sqrt(55556): break
    if i == 0 :continue
    for j in range(2*i,55556,i): l[j] = 0

prime = [i for i in l if (l != 0 and (i - 3)%10 == 0)]
print(" ".join(map(str,prime[:N])))

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
r = "Yes"
for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == "#" and s[i - 1][j] == "." and s[i + 1][j] == "." and s[i][j - 1] == "." and s[i][j + 1] == ".":
          r = "No"
print(r)

Submission status: Runtime Error

Solution code:
A,B,C=map(int,input().split())
k=int(input())
m=max(A,B,C)
print(A+B+C-m+m*2**k)

Submission status: Runtime Error

Solution code:
a,b=input().split()
print(a)
count=0
for i in range(a-1):
    count+=1
if a<b:
    count+=1
print(count)

Submission status: Runtime Error

Solution code:
a,b = input().split()

if a>b:
    print(a-1)
else:
    print(a)

Submission status: Runtime Error

Solution code:
a = input()
b = input()

if a>b:
    print(a-1)
else:
    print(a)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
mass=[]
frame=[["."]*(w+2) for i in range(h+2)]
for i in range(h):
    mass.append(list(input()))
for i in range(h):
    for j in range(w):
        frame[i+1][j+1]=mass[i][j]
for i in range(1,h):
        for j in range(1,w):
            if frame[i][j]=="#" and frame[i][j]!=frame[i][j+1] and frame[i][j]!=frame[i+1][j] and frame[i][j]!=frame[i][j-1] and frame[i][j]!=frame[i-1][j]:
                    print("No")
                    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
count = 0

for m in range(1, a+1):5 5
  for d in range(1, b+1):
    if (m-d == 0):
      count += 1

print(count)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
k=int(input())
if 0<k<11 and 0<a<=50 and 0<b<=50 and 0<c<=50: 
    l=[a,b,c]
    l.reverse()
    l[0]=l[0]*(2**k)
else:
    print("No")
print(sum(l))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def main():
    h, w = map(int, raw_input().split())

    square = []
    for i in range(h):
        square.append(raw_input())

    for i in range(h):
        for j in range(w):
            if square[i][j] == '.':
                continue
            else:
                if check(square, i, j, h, w):
                    continue
                else:
                    print("No")
                    exit()

    print("Yes")

def check(square, i, j, h, w):
    if i-1 >= 0:
        if square[i-1][j] == '#':
            return True
    if i+1 < h:
        if square[i+1][j] == '#':
            return True
    if j-1 >= 0:
        if square[i][j-1] == '#':
            return True
    if j+1 < w:
        if square[i][j+1] == '#':
            return True

    return False

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
c,d=map(int,input().split())

if a>b:
 print(a-1)
else:
 print(a)

Submission status: Runtime Error

Solution code:
a,b=map(int,raw_input().split())

if a>b:
 print(a-1)
else:
 print(a)

Submission status: Runtime Error

Solution code:
a,b=map(input().split(" "))

if a>b:
 print(a-1)
else:
 print(a)

Submission status: Runtime Error

Solution code:
a,b=map(input().split(""))

if a>b:
 print(a-1)
else:
 print(a)

Submission status: Runtime Error

Solution code:
a=raw_input()
b=raw_input()

if a>b:
 print(a-1)
else:
 print(a)

Submission status: Runtime Error

Solution code:
a=raw_input()
b=raw_input()

if a>b:
 print(a-1)
else:
 print(a);

Submission status: Runtime Error

Solution code:
a,b,c=map(int ,input().split())
K=int(input())

max=a
if b>max:
    max=b
if c>max:
    max=c
sum=a+b+c-max
for i in range(K):
    max*=2
print(sum+max)

Submission status: Runtime Error

Solution code:
x=int(input())
y=int(input())
if(x<=y):
 print(x)
else:
 z=x-1
 print(z)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
  numbers = list(map(int, input().split()))
  k = int(input())
  sum = 0
  for i in range(3):
    if i == numbers.index(max(numbers)):
      sum += max(numbers) * pow(2, k)
    else:
      sum += numbers[i]
  print(sum)

Submission status: Runtime Error

Solution code:
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * pow(2, k)
  else:
    sum += numbers[i]
print(sum)

Submission status: Runtime Error

Solution code:
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * (2 ** k) 
  else:
    sum += numbers[i]
print(sum)

Submission status: Runtime Error

Solution code:
numbers = list(map(int, input().split()))
k = int(input())
sum = 0
for i in range(3):
  if i == numbers.index(max(numbers)):
    sum += max(numbers) * (2 ^ k) 
  else:
    sum += numbers[i]
print(sum)

Submission status: Runtime Error

Solution code:
a=(int,input())
b=(int,input())
if a>b:
   print(a-1)
else:
   print(a)

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

k = input()
k = int(k)

print(max(a * 2 * k + b + c, a + b * 2 * k + c, a + b + c * 2 * k))

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":

    date = input().replace("　", " ").split(" ")

    if date[0] <= date[1]:
        print(date[0])
    else:
        print(date[0]-1)

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    date = input().split(" ")
    if date[0] <= date[1]:
        print(date[0])
    else:
        print(date[0]-1)

Submission status: Runtime Error

Solution code:
A, B, C = map(int,input().split())
K = int(input())
L = [A, B, C]
S = sorted(L)

print(S[2] * 2 ** K + S[0] + S[1])

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split( ))
k = int(input())


lis = [A,B,C]
max_num = max(A,B,C)

lis.remove(max_num)

rui = 2 ** k

nibai = max_num * rui


a = lis[0]
b = lis[1]
print(a + b + nibai)

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split())
k = int(input())


lis = [A,B,C]
max_num = max(A,B,C)

lis.remove(max_num)

rui = 2 ** k

nibai = max_num * rui


a = lis[0]
b = lis[1]
print(a + b + nibai)

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split())
k = int(input())

lis = [A,B,C]
max_num = max(A,B,C)

lis.remove(max_num)

nibai = max_num * 2

nibai = nibai*k

a = lis[0]
b = lis[1]
print(a + b + nibai)

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())

if a < b:
    print(a,"日")

elif a > b:
    a = a - 1
    print(a,"日")

elif a == b:
    print(a,"日")

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
j = 0
if a == b:
    print("高橋は",a,"日")

Submission status: Runtime Error

Solution code:
p=input
*x,=map(int, p().split())
print(sum(x)+max(x)*(2**int(p())-1))

Submission status: Runtime Error

Solution code:
from itertools import product

H, W = map(int, input().split())

s = []
for i in range(H):
    s.append(list(input()))

for h, w in [(h, w) for h, w in product(range(H), range(W)) if s[h][w] != '.']:
    R = False
    if h > 0 and s[h - 1][w] == '#':
        # 上
        R = True
    if h < H - 1 and s[h + 1][w] == '#':
        # 下
        R = True
    if w > 0 and s[h][w - 1] == '#':
        # 左
        R = True
    if w < W - 1 and s[h][w + 1] == '#':
        # 右
        R = True

    if not R:
        print('No')
        exit()

print('Yes')

Submission status: Runtime Error

Solution code:
a = int(input())
b = int(input())
if a<b:
  print(a)
else:
  print(b)

Submission status: Runtime Error

Solution code:
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1


primeN = [2]
for i in range(2,10000):
    for j in range(len(primeN)):
        if i % primeN[j] == 0:
            break
        else:
            if j == len(primeN) - 1:
                primeN.append(i)
n=int(input())
ans=[]

for i  in primeN:
    if i%5==1:
      ans.append(i)
    if len(ans)==n:
        for x in ans:
            print(x,end=" ")
        exit()

Submission status: Runtime Error

Solution code:
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if (a<=b){
			System.out.println(a);
		}else{
			System.out.println(a-1);
		}
	}
}

Submission status: Runtime Error

Solution code:
n=int(input())
p=[3,13,23,43,53,73,103,113,163,173,193,223,233,263,283,293,313,353,373,383,443,463,503,563,593,613,643,653,673,683,733,743,773,823,853,863,883,953,983,1013,1033,1063,1093,1103,1123,1153,1163,1193,1213,1223,1283,1303,1373,1423,1433,1453,1483,1493]
for i in range(n):
    print(p[i],end=' ')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-


def is_sosu(x):
    for i in range(2, x):
        if x % i == 0:
            return False
    return True

N = int(input())
sosu = []
for candidate in range(2, 55555):
    if is_sosu(candidate) and candidate % 5 == 1:
        sosu.append(candidate)
        if len(sosu) >= N:
            break
print(' '.join([str(s) for s in sosu]))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat May 05 21:59:05 2018

@author: ashida
"""


import numpy as np

H, W = map(int, raw_input().split())

S = np.zeros((H, W))

d_flag = 0

for i in range(H):
    tmp = list(raw_input())
    for j in range(W):
        if tmp[j] == "#":
            S[i, j] = 1
            d_flag = 1
        else:
            S[i, j] = 0



for i in range(H):
    for j in range(W):
        if S[i, j] == 1:
            flag = 0
            if i>1:
                a1 = S[i-1, j]
            else:
                a1 = 0
            if j>1:
                a2 = S[i, j-1]
            else:
                a2 = 0
            if i<H-1:
                a3 = S[i+1, j]
            else:
                a3 = 0
            if j<W-1:
                a4 = S[i, j+1]
            else:
                a4 = 0
            if a1+a2+a3+a4 == 0:
                d_flag = 0
                
if d_flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def isPrime(x):
	for i in range(2,min(x,236)):
		if x%i == 0:
			return False
	return True
n,a,p = int(input()),[],2
while n > 0:
	if isPrime(p):
		a.append(str(p))
		n -= 1
	p += 5
print(" ".join(a))

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())

inpt =[]
for h in H:
    i = str(input())
    inpt.append(i)

string = 'No'

for h in range(H):
    for w in range(W):
        if h == H-1 or w == W-1:
            continue
        if inpt[h][w] == '#':
            if inpt[h+1][w] == '#' or inpt[h][w+1] == '#':
                 string = 'Yes'
                 
print(string)

Submission status: Runtime Error

Solution code:
a, b = map(int, input().split())
print(a if b>=a else a-1)
a, b = map(int, input().split())
print(a if b>=a else a-1)

Submission status: Runtime Error

Solution code:

H, W = map(int, input().split())

inpt =[]
for h in H:
    i = str(input())

string = 'No'

for h in range(H):
    for w in range(W):
        if h == H-1 or w == W-1:
            continue
        if inpt[h][w] == '#':
            if inpt[h+1][w] == '#' or inpt[h][w+1] == '#':
                 string = 'Yes'
                 
print(string)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

tmp=list(map(int,input().split()))
tmp.sort()
K=int(input())
ans=tmp[0]+tmp[1]+(tmp[2]*(2**K))
print(ans)

Submission status: Runtime Error

Solution code:
a,b = input()

Submission status: Runtime Error

Solution code:
import math

#print(math.floor(math.sqrt(4)))
sosu = [2]
for i in range(3,2020):
    root_i = math.sqrt(i)
    cand = True
    for j in sosu:
        if j > root_i : break
        if i % j == 0:
            cand = False
            break
    if cand :
        sosu.append(i)
#print(sosu)    
N = int(input())
print(*sosu[:N])

Submission status: Runtime Error

Solution code:
h,w = map(int, input().split())
bord = [list(input()) for n in range(w)]
Answer = 0
for y in range(len(bord)):
    for x in range(len(bord[0])):
        if bord[y][x]=='#':
            if y==0:
                if x==0:
                    if bord[y][x+1]=='#': 
                        Answer=1;continue
                    if bord[y+1][x]=='#':
                        Answer=1;continue
                elif x==h-1:
                    if bord[y][x-1]=='#':
                        Answer=1
                        continue
                    if bord[y+1][x]=='#':
                        Answer=1;continue
                else:
                    if bord[y][x+1]=='#':
                        Answer=1;continue
                    if bord[y][x-1]=='#':
                        Answer=1;continue
                    if bord[y+1][x]=='#':
                        Answer=1;continue
            elif y==w-1:
                if x==0:
                    if bord[y][x+1]=='#':
                        Answer=1;continue
                    if bord[y-1][x]=='#':
                        Answer=1;continue
                elif x==h-1:
                    if bord[y][x-1]=='#':
                        Answer=1;continue
                    if bord[y-1][x]=='#':
                        Answer=1;continue
                else:
                    if bord[y][x+1]=='#':
                        Answer=1;continue
                    if bord[y][x-1]=='#':
                        Answer=1;continue
                    if bord[y-1][x]=='#':
                        Answer=1;continue
            elif x==0:
                if bord[y+1][x]=='#':
                    Answer=1;continue
                if bord[y-1][x]=='#':
                    Answer=1;continue
                if bord[y][x+1]=='#':
                    Answer=1;continue
            elif x==h-1:
                if bord[y+1][x]=='#':
                    Answer=1;continue
                if bord[y-1][x]=='#':
                    Answer=1;continue
                if bord[y][x-1]=='#':
                    Answer=1;continue
            else:
                if bord[y+1][x]=='#':
                    Answer=1;continue
                if bord[y-1][x]=='#':
                    Answer=1;continue
                if bord[y][x-1]=='#':
                    Answer=1;continue
                if bord[y][x+1]=='#':
                    Answer=1;continue
if Answer == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
p = []
def is_prime_trial_division(n):
    if n < 2:
        return False
    else:
        for i in range(2, n):
            if i * i > n:
                break
            elif n % i == 0:
                return False
        return True
for i in range(2,55555):
    if is_prime_trial_division(i):
        p.append(i)
N = int(input())
s = ""
for i in range(N):
    s += str(p[5500+i*2]) + " "
s = s[:-1]
print(s)

Submission status: Runtime Error

Solution code:
import itertools
def mark(s, x):
    for i in range(x + x, len(s), x):
        s[i] = False

def sieve(n):
    s = [True] * n
    for x in range(2, int(n**0.5) + 1):
        if s[x]: mark(s, x)
    return [i for i in range(0,n) if s[i] and i > 1]

n = int(input())
A = sieve(55555)
A.remove(2)
A.remove(3)
A.remove(5)
A.remove(7)
B = [2,3,5,7]
C = []
for i in A:
    if len(B) == n:
        break
    B.append(i)
    C = list(itertools.combinations(B,5))
    for j in C:
        if sum(j) in A:
            B.remove(i)
            break
for i in B:
    print(i,end=' ')

Submission status: Runtime Error

Solution code:
import math

N = int(raw_input())

def genprimes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]

primes = genprimes(55556)

ans = []
for p in primes:
    if str(p)[-1] == '1':
        ans.append(p)

print(' '.join(map(str, ans[:N])))