Problem:


Score : 100 points

Problem Statement

Takahashi wants to print a document with N pages double-sided, where two pages of data can be printed on one sheet of paper.

At least how many sheets of paper does he need?

Constraints

N is an integer.

1 \leq N \leq 100

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

5

Sample Output 1

3

By printing the 1-st, 2-nd pages on the 1-st sheet, 3-rd and 4-th pages on the 2-nd sheet, and 5-th page on the 3-rd sheet, we can print all the data on 3 sheets of paper.

Sample Input 2

2

Sample Output 2

1

Sample Input 3

100

Sample Output 3

50



Sample input:
5


Sample output:
3

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
S = []
C = []
for i in range(M):
    temp1,temp2 = map(int,input().split())
    S.append(temp1)
    C.append(temp2)

Flag = True
temp = [-1,-1,-1]
for i in range(M):
    if S[i] == 3:
        if temp[2] == -1:
            temp[2] = C[i]
        else:
            if temp[2] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 2:
        if temp[1] == -1:
            temp[1] = C[i]
        else:
            if temp[1] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 1:
        if temp[0] == -1:
            temp[0] = C[i]
        else:
            if temp[0] == C[i]:
                next
            else:
                Flag = False

a = ''
if Flag == False:
    print(-1)
elif temp[0] ==0:
    print(-1)
elif temp[2] == -1:
    if temp[1] == -1:
        print(temp[0])
    elif temp[0] == -1:
        print(int(str(1) + str(temp[1])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1])))
else:
    if temp[0] == -1 and temp[1] == -1:
        print(temp[2])
    elif temp[0] == -1 and temp[1] != -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[1]) + str(temp[2])))
    elif temp[0] != -1 and temp[1] == -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(0) + str(temp[2])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1]) + str(temp[2])))

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
S = []
C = []
for i in range(M):
    temp1,temp2 = map(int,input().split())
    S.append(temp1)
    C.append(temp2)

Flag = True
temp = [-1,-1,-1]
for i in range(M):
    if S[i] == 3:
        if temp[2] == -1:
            temp[2] = C[i]
        else:
            if temp[2] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 2:
        if temp[1] == -1:
            temp[1] = C[i]
        else:
            if temp[1] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 1:
        if temp[0] == -1:
            temp[0] = C[i]
        else:
            if temp[0] == C[i]:
                next
            else:
                Flag = False

a = ''
if Flag == False:
    print(-1)
elif temp[0] ==0:
    print(-1)
elif temp[2] == -1:
    if temp[1] == -1:
        print(temp[0])
    elif temp[0] == -1:
        print(int(str(1) + str(temp[1]))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1])))
else:
    if temp[0] == -1 and temp[1] == -1:
        print(temp[2])
    elif temp[0] == -1 and temp[1] != -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[1]) + str(temp[2])))
    elif temp[0] != -1 and temp[1] == -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(0) + str(temp[2])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1]) + str(temp[2])))

Submission status: Runtime Error

Solution code:
N,M=map(int, input().split())
SC=list(list(map(int, input().split())) for i in range(M))

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
sc=get_unique_list(SC)

if (N==3) & (max(sc)[0]!=3):
    sc.append([1,1])
if (N==2) & (max(sc)[0]!=2):
    sc.append([2,1])

res=0
if M==0:
    res=-1
for i in range(len(sc)):
    for j in range(len(sc)):
        if (i!=j) & (sc[i][0]==sc[j][0]):
            res=-1
            break
    break
for i in range(len(sc)):
    if (M!=1) & (sc[i][0]==1) & (sc[j][1]==0):
        res=-1
        break
if N<len(sc):
    res=-1
if res!=-1:
    for i in range(len(sc)):
        res = res + sc[i][1]*(10**(N-sc[i][0]))
print(res)

Submission status: Runtime Error

Solution code:
N = int(input())
if N % 2 == 0:
    print(int(N / 2))
else:
    print(int((N - 1) / 2 + 1)

Submission status: Runtime Error

Solution code:
import sys
ANS = []
N, M = map(int, input().split())
for j in range(N):
  ANS.append(0)
for i in range(M):
  s, c = map(int, input().split())
  ANS[s-1] = c
 
if ANS[0] == 0:
  print(-1)
  sys.exit()
 
NEW = 0
for i in range(1,N):
  NEW += ANS[-i] * (10**(i))
 
print(NEW)

Submission status: Runtime Error

Solution code:
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    N, M, K = lr()
    fri = [[] for _ in range(N)]
    for i in range(M):
        a, b = lr()
        fri[a-1].append(b-1)
        fri[b-1].append(a-1)
    blo = [[] for _ in range(N)]
    for i in range(K):
        c, d = lr()
        blo[c-1].append(d-1)
        blo[d-1].append(c-1)

    can = [[] for _ in range(N)]
    for i in range(N):
        vis = [False for _ in range(N)]
        s = [i]
        while len(s) > 0:
            v = s.pop()
            vis[v] = True
            for j in fri[v]:
                if vis[j]:
                    continue
                s.append(j)
                if j not in fri[i] and j not in blo[i] and j not in can[i]:
                    can[i].append(j)
    ans = []
    for i in range(N):
        ans.append(len(can[i]))
    print(*ans, sep=' ')
resolve()

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
e,d,f=map(int,input().split())
g,h,i=map(int,input().split())
bingo = [a,b,c,d,e,f,g,h,i]
a_list= []
yes = 0
N = int(input())
for i in range(0,N):
    b = int(input())
    if b in bingo:
        a_list.append(bingo.index(b))
if 0 in a_list:
    if 1 in a_list:
        if 2 in a_list:
            yes = 1
    if 3 in a_list:
        if 6 in a_list:
            yes = 1
    if 4 in a_list:
        if 8 in a_list:
            yes = 1
if 1 in a_list:
    if 4 in a_list:
        if 7 in a_list:
            yes = 1
if 2 in a_list:
    if 4 in a_list:
        if 6 in a_list:
            yes = 1
    if 5 in a_list:
        if 8 in a_list:
            yes = 1
if 3 in a_list:
    if 4 in a_list:
        if 5 in a_list:
            yes = 1
if 6 in a_list:
    if 7 in a_list:
        if 8 in a_list:
            yes = 1
if yes == 1:
    print("Yes")
if yes == 0:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
ANS = []
N, M = map(int, input().split())
for j in range(N):
  ANS.append(0)
for i in range(M):
  s, c = map(int, input().split())
  ANS[s-1] = c
 
if ANS[0] == 0:
  print(-1)
  sys.exit()
 
NEW = 0
for i in range(N):
  NEW += ANS[-i-1] * (10**(i+1))
 
print(NEW)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
s=[0]*M
c=[0]*M
ans=[0]*N
s_1i=[]
s_2i=[]
s_3i=[]
for i in range(M):
    s[i],c[i]=map(int,input().split())
flg=0
for i in range(M):
    if s[i]==1 and c[i]==0:
        flg+=1
for i in range(M):
    if s[i]==1:
        s_1i.append(c[i])
    elif s[i]==2:
        s_2i.append(c[i])
    elif s[i]==3:
        s_3i.append(c[i])
if len(s_1i)>=2:
    if s_1i.count(s_1i[0])!=len(s_1i):
        flg+=1
if len(s_2i)>=2:
    if s_2i.count(s_2i[0])!=len(s_2i):
        flg+=1
if len(s_3i)>=2:
    if s_3i.count(s_3i[0])!=len(s_3i):
        flg+=1
if flg>=1:
    print("-1")
else:
    if (1 not in s) and (N!=1):
        ans[0]=1
    for i in range(M):
        ans[s[i]-1]=c[i]
    for i inrange(N):
        print(ans[i],end="")

Submission status: Runtime Error

Solution code:
n, m, k = map(int, input().split())

friend = [[] for _ in range(n)]
block = [[] for _ in range(n)]

for _ in range(m):
  a, b = map(int, input().split())
  friend[a-1].append(b-1)
  friend[b-1].append(a-1)
  
for _ in range(k):
  c, d = map(int, input().split())
  block[c-1].append(d-1)
  block[d-1].append(c-1)
  
groups = []
active = [True] * n
belong = [0] * n
g_index = 0
while any(active):
  idx = active.index(True)
  g = [idx]
  active[idx] = False
  belong[idx] = g_index
  stack = [idx]
  while stack:
    v = stack.pop()
    for i in friend[v]:
      if active[i]:
        stack.append(i)
        active[i] = False
        belong[i] = g_index
        g.append(i)
  groups.append(g)
  g_index += 1
  
for i in range(n):
  size = len(groups[belong[i]]) - 1
  for j in groups[belong[i]]:
    if j in friend[i] or j in block[i]:
      size -= 1
  print(size, end=' ')

Submission status: Runtime Error

Solution code:
l=[]
for i in range(3):
    l.append(list(map(int, input().split())))
n = int(input())
for i in range(n):
    m = int(input())

    for j in range(3):
        for k in range(3):
            if l[j][k] == m:
                l[j][k] = -1
o=0
p=0
for j in range(3):
    for k in range(3):
        o+=l[j][k]
        p+=l[k][j]
    if o==-3 or p==-3:
        print('Yes')
        exit()
    o=0
    p=0
if l[0][0]+l[1][1]+l[2][2]==-3 or l[0][2]+l[1][1]+l[2][0]==-3:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
lines = sys.stdin.readlines()

digits = int(lines[0][0])

nums = [l.split() for l in lines[1:]]
result = ['0'] * digits

digit_set = set()
for num in nums:
    num_index = int(num[0])-1
    num_value = num[1]
    if num_index in digit_set and result[num_index] != num_value:
        print(-1)
        break
    digit_set.add(num_index)
    result[num_index] = num_value
else:
    if digits > 1 and result[0] == '0':
        print(-1)
    else:
        print(''.join(result))

Submission status: Runtime Error

Solution code:
first_line = input().split()
second_line = input().split()
third_line = input().split()
 
first_line = [int(i) for i in first_line]
second_line = [int(i) for i in second_line]
third_line = [int(i) for i in third_line]
N = input()
N = int(N)

B  = [] 
for i in range(N):
    inp  =input()
    inp = int(inp)
    B.append(inp)


# arr = [[0]*3]*3
# print(arr)
# for i in range(3):
#     arr[0][i]= first_line[i]
#     print(arr)
# print(arr)
# for i in range(3):
#     arr[1][i]= second_line[i]
# for i in range(3):
#     arr[2][i]= third_line[i]

arr = []
arr.append(first_line)
arr.append(second_line)
arr.append(third_line)
carr = [[False for i in range(3)] for j in range(3)]

print(arr)
for b in B:
    for i in range(3):
        for j  in range(3):
            if b == arr[i][j]:
                # print(b, carr)
                carr[i][j] = True

# print(carr)

def yoko(carr):
    for i in range(3):
        for j in range(3):
            if carr[i][j] != True:
                break
        return  True
    
    return False


def tate(carr):
    for i in range(3):
        for j in range(3):
            if carr[j][i] != True:
                break
        return  True
    
    return False

def naname (carr):
    for i in range(3):
        if carr[i] != True:
            for j in range(3):
                if carr[3-j-1] != True:
                    return False
            return True    
    return True


def checker(carr):
    # if tate:
    #     print('tate')
    # if yoko:
    #     print('yoko')
    # if naname:
    #     print('naname')
    
    if not tate  and not yoko and not naname:
        return 'No'
    else:
        return 'Yes' 



print(checker(carr))

Submission status: Runtime Error

Solution code:
import collections

N = int(input())
S = input()
Q = int(input())
querys = [list(map(str, input().split())) for i in range(Q)]
for i in range(Q):
    query = querys[i]
    if query[0] == "1":
        qi = int(query[1])
        S = S[:qi-1] + query[2] + S[qi:]
    else:
        c = collections.Counter(S[int(query[1]) - 1:int(query[2])])
        print(len(c))

Submission status: Runtime Error

Solution code:
list_1 = list(map(int,input().split()))
list_2 = list(map(int,input().split()))
list_3 = list(map(int,input().split()))

#n,m = map(int,raw_input().split())
#list_a = []
#for i in range(M) 
list_a=list_1


for x in list_2:
    list_a.append(x)


for x in list_3:
    list_a.append(x)


N = int(input())
#list_b = [int(x) for x in input().split()]
#list_b = list(map(int,input().split()))


list_b=[]
for k in range(N):
    b=int(input())
    list_b.append(b)


list_c = [0,0,0,0,0,0,0,0,0]
for i in range(N):
    for j in range(9):
        if list_a[j] == list_b[i]:
            list_c[j] = 1

flag=0
if list_c[0]==1 and list_c[1]==1 and list_c[2]==1:
    flag=1
if list_c[3]==1 and list_c[4]==1 and list_c[5]==1:
    flag=1
if list_c[6]==1 and list_c[7]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[3]==1 and list_c[6]==1:
    flag=1
if list_c[1]==1 and list_c[4]==1 and list_c[7]==1:
    flag=1
if list_c[2]==1 and list_c[5]==1 and list_c[8]==1:
    flag=1
if list_c[0]==1 and list_c[4]==1 and list_c[8]==1:
    flag=1
if list_c[2]==1 and list_c[4]==1 and list_c[6]==1:
    flag=1
    
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

def func():
    n,m = [int(i) for i in input().split(" ")]
    pibot = 10**(m-1)
    dic = {}

    for i in range(m):
        tmp = [int(i) for i in input().split(" ")]

        if tmp[0] not in dic.keys():
            dic[tmp[0]] = tmp[1]
        else:
            if dic[tmp[0]] != tmp[1]:
                print("-1")
                return

    a = [0] * m
    for key in dic.keys():
        a[key-1] = dic[key]

    tmp_s = ""
    for i in a:
        tmp_s += str(i)

    if int(tmp_s) < pibot:
        tmp_s = "-1"

    print(tmp_s)

if __name__ == "__main__":
    func()

Submission status: Runtime Error

Solution code:

N, M = map(int, input().split())
SC = set(sorted([tuple(map(int, input().split())) for _ in range(M)]))

ans = [-1] * N
for s, c in SC:
    if ans[s-1] == -1:
        ans[s-1] = c
if N >= 2:
    if ans[0] == -1 or ans[0] == 0:
        print(-1)
        exit()
kotae = ''
for a in ans:
    if a == -1:
        kotae += '0'
    else:
        kotae += str(a)
print(kotae)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
q = int(input())
for i in range(q):
	c=list(input().split())
	if c[0]=="1":
		s=s[:int(c[1])-1]+c[2]+s[int(c[1]):]
	else:
		print(len(set(s[int(c[1])-1:int(c[2])])))

Submission status: Runtime Error

Solution code:
bingo = []
for i in range(3):
    array = list(map(int, input().strip().split()))
    bingo.append(array)

N = int(input())
number = []

for j in range(N):
    number.append(int(input()))

result = []
for n in range(N):
    for t in range(3):
        for y in range(3):
            if(bingo[t][y] == number[n]):
                result.append([t,y])

bingo_a = 'No'
for r in range(len(result)):
    for t in range(3):
        t_a = 0
        for y in range(3):
            if(result[r][0] == t or result[r][1] == y):
                t_a = t_a + 1
        if(t_a == 3):
            bingo_a = 'Yes'

for r in range(len(result)):
    for y in range(3):
        y_a = 0
        for t in range(3):
            if(result[r][0] == t or result[r][1] == y):
                y_a = y_a + 1
        if(y_a == 3):   
            bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 0):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 2):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

ans = 0
for rr in range(len(result)):
    if(result[rr][0] == 0 or result[rr][1] == 2):
        ans = ans + 1
    if(result[rr][1] == 1 or result[rr][1] == 1):
        ans = ans + 1
    if(result[rr][0] == 2 or result[rr][1] == 0):
        ans = ans + 1
if(ans == 3):
    bingo_a = 'Yes'

print(bingo_a)
print(result)

Submission status: Runtime Error

Solution code:
N, M = map(int,(input().split()))
table = [input().split() for l in range(M)]
ans = 0
array1 = []
array2 = []
array3 = []
keta1 = -1
keta2 = -1
keta3 = -1
s1 = 0
s2 = 0
s3 = 0
for k in range(M):
    for j in range(2):
        table[k][j] = int(table[k][j])

for k in range(M):
    if table[k][0] == 1:
        if table[k][1] == 0 or (not(table[k][1] in array1) and s1 == 1):
            keta1 = -1
        else:
            keta1 = table[k][1]
        s1 = 1
        array1.append(table[k][1])

    elif table[k][0] == 2:
        if not(table[k][1] in array2) and s2 ==1:
            keta2 = -1
        else:
            keta2 = table[k][1]
        s2 = 1
        array2.append(table[k][1])
    else:
        if not(table[k][1] in array3) and s3 == 1:
            keta3 = -1
        else:
            keta3 = table[k][1]
        s3 = 1
        array3.append(table[k][1])

if s1 != 1:
    keta1 = 1
if s2 != 1:
    keta2 = 0
if s3 != 1:
    keta3 = 0

if keta1 == -1 or keta2 == -1 or keta3 == -1:
    ans = -1
else:
    ans = keta1 * 100 + keta2 * 10 + keta3

print(ans)

Submission status: Runtime Error

Solution code:
n,m,k = map(int,input().split())
num = [1 for _ in range(n)]
pre = [i for i in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = [a]
  B = [b]
  la = 1
  lb = 1
  while a != pre[a]:
    a = pre[a]
    A.append(a)
    la += 1
  while b != pre[b]:
    b = pre[b]
    B.append(b)
    lb += 1
  #print(a,b)
  if a != b:
    if la > lb:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
    else:
      pre[a] = b
      for aa in B:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
root = []
cnt = [0 for _ in range(n)]
for i in range(n):
  I = int(i)
  while I != pre[I]:
    I = pre[I]
  root.append(I)
  cnt[I] += 1
#print(pre)
#print(root)
#print(cnt)
ans = []
for i in range(n):
  ans.append(cnt[root[i]]-num[i])
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

Submission status: Runtime Error

Solution code:
import math
N= n_in()
print(math.ceil(N/2))

Submission status: Runtime Error

Solution code:
# ABC 157 C
list_s=[]
list_c=[]
Flag=0
N,M= map(int,input().split())

for i in range(M):
    s,c= map(int,input().split())
    list_s.append(s)
    list_c.append(c)
    if s in list_s:
        x=list_s.index(s)
        n=list_c[x]

        if n!=c:
            Flag=1

if 1 in list_s:
    in1=list_s.index(1)
    n1=list_c[in1]
    if n1==0:
        Flag=1
else :
    n1=1

if 2 in list_s:
    in2=list_s.index(2)
    n2=list_c[in2]
else :
    n2=0

if 3 in list_s:
    in3=list_s.index(3)
    n3=list_c[in3]
else :
    n3=0

if N==1 and n1==0:
    Flag=0
    
if Flag==0:
    if N==1:
        if M==0:
            print(0)
        else:
            print(n1)
    if N==2:
        print(10*n1+n2)
    if N==3:
        print(100*n1+10*n2+n3)
else :
    print(-1)

Submission status: Runtime Error

Solution code:
1<= N and N<=100

N = input()
if N%2 ==0:
  n = N/2
else:
  n = N/2+1
  
print(int(n))

Submission status: Runtime Error

Solution code:
bingo = [ input().split() for j in range(3)]
N = int(input())
b = []
for n in range(N):
	b.append(input())
count = 0
total = 0
p = 'No'
for x in range(N):
	for i in range(3):
		for j in range(3):
			count = count + 1
			if bingo[i][j] == b[x]:
				total = total + count
	count = 0
	if total == 6 or total == 12 or total == 15 or total == 18 or total == 24 or total == 33 or total == 36 or total == 27 or total == 30 or total == 39 or total == 31 or total == 25 or total == 32:
		p = 'Yes'
		break
print(p)

Submission status: Runtime Error

Solution code:
    N, M = list(map(int, input().split(' ')))
    r = [ None for i in range(N) ]
     
    illegal = False
    for i in range(M):
      s, c = list(map(int, input().split(' ')))
      if r[s-1] is not None and r[s-1] != c:
        illegal = True
        break
      r[s-1] = c
     
    v = -1
    if not illegal:
      for i in range(N):
        if r[i] is None:
          if i == 0 and N != 1:
            r[i] = 1
          else:
            r[i] = 0
      v = sum(r[i] * 10**i for i in range(N))
      if v < 10**(N-1) and not (N == 1 and v == 0):
        v = -1
     
    print(v)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
Output = [0] * N
num = ""

for i in range(M):
    s,c = map(int,input().split())
    if(Output[s-1]==0 or Output[s-1]>c):
        Output[s-1] = c
    if(c==0):
        print(-1)

if(Output[0]==0):
    print(-1)
else:
    for i in Output:
        if(i>9):
            print(-1)
        num += str(i)
    print(num)

Submission status: Runtime Error

Solution code:
N = input().split()
Page = N%2
print(Page)

Submission status: Runtime Error

Solution code:
import sys

input = sys.stdin.readline


def main():
    n, m = map(int, input().split())
    if m == 0:
        print(10 ** (n - 1))
        return

    numbers = [-1 for _ in range(n)]
    ret = ''
    for _ in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            ret = -1

        if numbers[s - 1] == -1:
            numbers[s - 1] = c
        elif numbers[s - 1] != c:
            ret = -1

    if ret == -1:
        print(ret)
        return

    for i in range(len(numbers)):
        if numbers[i] == -1:
            if i == 0:
                numbers[i] = 1
            else:
                numbers[i] = 0
        if numbers[i] < 0 or numbers[i] > 9:
            ret = -1
            break
        ret += str(numbers[i])

    print(int(ret))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import itertools
import sys

[a,b,c] = [int(x) for x in input().split()]
[d,e,f] = [int(x) for x in input().split()]
[g,h,i] = [int(x) for x in input().split()]
N = int(input())
num_list = []
for i in range(N):
  n = int(input())
  num_list.append(n)
set_list = [{a,b,c},{d,e,f},{g,h,i},{a,d,g},{b,e,h},{c,f,i},{a,e,i},{c,e,g}]
the_set = set(num_list) & set([a,b,c,d,e,f,g,h,i])
v = itertools.permutations(the_set,3)
for i in v:
  if set(i) in set_list:
    print('Yes')
    sys.exit()
print('No')

Submission status: Runtime Error

Solution code:
A1_1,A1_2,A1_3 = map(int, input().split())
A2_1,A2_2,A2_3 = map(int, input().split())
A3_1,A3_2,A3_3 = map(int, input().split())
N =int(input())
B = []
for _ in range(N+3):
    B.append(input())

a=str('yes')
b=str('no')
if A1_1 in B and A1_2 in B and A1_3 in B:
     print(a)
elif A2_1 in B and A2_2 in B and A2_3 in B:
    print(a)
elif A3_1 in B and A3_2 in B and A3_3 in B:
     print(a)
elif A1_1 in B and A2_1 in B and A3_1 in B:
    print(a)
elif A1_2 in B and A2_2 in B and A3_2 in B:
    print(a)
elif A1_3 in B and A2_3 in B and A3_3 in B:
    print(a)
elif A1_1 in B and A2_2 in B and A3_3 in B:
     print(a)
elif A1_3 in B and A2_2 in B and A3_1 in B:
    print(a)
else:
    print(b)

Submission status: Runtime Error

Solution code:
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0

if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
a = []
for i in range(3):
  tmp = input()
  a.append(list(map(int, tmp.split())))

n = int(input())
b = []
for j in range(n):
    b.append(int(input()))

# print(a)
# print(b)

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
           a[i][j] = 0
# print(a)

def check(a):
    #　たてビンゴ
    for i in range(3):
        if (a[i][0] == 0 & a[i][1] == 0 & a[i][2] == 0):
            print('Yes')
            exit()
    # 横ビンゴ
        if a[i] == [0, 0, 0]:
            print('Yes')
            exit()
    # 斜めビンゴ
    if a[0][0] == 0 & a[1][1] == 0 & a[2][2] == 0:
            print('Yes')
            exit()
    if a[0][2] == 0 & a[1][1] == 0 & a[2][0] == 0:
            print('Yes')
            exit()
    print('No')

check(a)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for _ in range(M)]

matches = []
for i in range(0, 1000):
    if len(str(i)) == N:
        temp = True
        for s, c in sc:
            if str(i)[s - 1] != str(c):
                temp = False
        if temp: matches.append(i)
print(-1) if len(matches) == 0 else print(min(matches))

Submission status: Runtime Error

Solution code:
def main():
    n, m = [int(e) for e in input().split()]
    S, C = zip(*[[int(e) for e in input().split()] for i in range(m)])

    ans = 0
    D = {}
    for si, ci in zip(S, C):
        if D.get(si) == ci:
            continue

        if D.get(si) is not None:
            print(-1)
            exit()

        ans += 10**(n - si) * ci
        D[si] = ci

    if len(str(ans)) != n:
        print(-1)
        exit()

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())

num = [0] * N

P = [list(map(int,input().split())) for i in range(M)]

for i in range(M + 1):
    if i == M:
        if N == 1:
            print("".join([str(n) for n in num]))
            break
        elif num[0] == 0:
            num[0] = 1
            print("".join([str(n) for n in num]))
            break
        else:
            print("".join([str(n) for n in num]))
            break
    elif P[i][0] == 1 and P[i][1] == 0:
        if N == 1:
            continue
        else:
            print(-1)
            break
    elif num[P[i][0] - 1] == 0 or num[P[i][0] - 1] == P[i][1]:
        num[P[i][0] - 1] = P[i][1]
    else:
        print(-1)
        break

Submission status: Runtime Error

Solution code:
#coding: utf-8
N = map(int, input().split())
if N % 2 == 1:
   print((N+1)/2)
else:
    print(N/2)

Submission status: Runtime Error

Solution code:
n=int(input(n))
print(n//2+n%2)

Submission status: Runtime Error

Solution code:
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
    
print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 2 <= 0 :
    print(n / 2)
elif n % 2 >= 1 :
    print(n // 2 +　1)

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 2 <= 0 :
    print(n / 2)
elif n % 2 = 1 :
    print(n // 2 +　1)

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 2 = 0 :
    print(n / 2)
elif n % 2 = 1 :
    print(n // 2 +　1)

Submission status: Runtime Error

Solution code:
n=input()
sei=n/2
tmp=n%2
if tmp==0:
    
else:
    sei=sei+1
print(sei)

Submission status: Runtime Error

Solution code:
import sys
bingo = [[],[],[]]
 
for i in range(3):
  a, b, c = map(int,input().split())
  bingo[i].append(a)
  bingo[i].append(b)
  bingo[i].append(c)
  
N = int(input())
  
for i in range(N):
  S = int(input())
  for j in range(3):
    if S in bingo[j]:
      for k in range(3):
        if S == bingo[j][k]:
          bingo[j][k] = 'ok'
          
ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[i][j] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
for i in range(3):
  for j in range(3):
    if bingo[j][i] == 'ok':
      ANS += 1
      if ANS == 3:
        print("Yes")
        sys.exit()
  ANS = 0
 
if bingo[1][1] == 'ok':
  if bingo[0][0] == 'ok' and bingo[2][2] == 'ok':
    print("Yse")
    sys.exit()
  elif bingo[0][2] == 'ok' and bingo[2][0] == 'ok':
    print("Yse")
    sys.exit()
  else:
    print("No")
    sys.exit()

Submission status: Runtime Error

Solution code:
N=map(int, input().split())
if N % 2 == 1:
   print((N+1)/2)
else:
    print(N/2)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())                            # 1行2列
List=[list(map(int,input().split())) for i in range(M)] # N行C列・・・Cは任意


if N == 1:
	answer = ' '
elif N == 2:
	answer = '  '
elif N == 3:
	answer = '   '

ok = 0
for search in List:
	# search[0]:桁数
	# search[1]:値
	if answer[search[0]-1] == str(search[1]) or answer[search[0]-1] == ' ':
		if N != 1 and search[0] == 1 and search[1] == 0:
			ok = -1
			break
		else:
			anslist = list(answer)
			anslist[search[0]-1] = str(search[1])
			answer = ''.join(anslist)
	else:
		ok = -1
		break

if ok == -1:
	print(-1)
else:
	for i in range(N):
		if answer[i] == ' ':
			anslist = list(answer)
			
			if i == 0 and N != 1:
				anslist[i] = '1'
			else:
				anslist[i] = '0'
			
			answer = ''.join(anslist)
	print(answer)

Submission status: Runtime Error

Solution code:
bingo = []
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
bingo.append(list(map(int, input().split(' '))))
matched = [[False for _ in range(3)] for _ in range(3)]
N = int(input())
for n in range(N):
    num = int(input())
    for i in range(3):
        for j in range(3):
            if bingo[i][j] == num:
                matched[i][j] = True
is_bingo = False
if matched[0][0] and matched[1][1] and matched[2][2]:
    is_bingo = True
if matched[0][2] and matched[1][1] and matched[2][0]:
    is_bingo = True
if matched[0][0] and matched[0][1] and matched[0][2]:
    is_bingo = True
if matched[1][0] and matched[1][1] and matched[1][2]:
    is_bingo = True
if matched[2][0] and matched[2][1] and matched[2][2]:
    is_bingo = True
if matched[0][0] and matched[1][0] and matched[2][0]:
    is_bingo = True
if matched[0][1] and matched[1][1] and matched[2][1]:
    is_bingo = True
if matched[0][2] and matched[1][2] and matched[2][2]:
    is_bingo = True
if is_bingo:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
if n % 2 = 0 :
    print(n / 2)
elif n % 2 = 1 :
    print(n / 2 +　0.5)