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 = 3
S = [list(map(int, input().split())) for _ in range(N)]
n_guess = int(input())
guesses = set([int(input()) for _ in range(n_guess)])
dic = {}
for r in range(N):
  for c in range(N):
    dic[S[r][c]]=(r,c)

for g in guesses:
  if g in dic:
    (r, c) = dic[g]
    S[r][c] = -1
# print(S)
for i in range(N):
  if sum(S[i]) == -3:
    print('Yes')
    quit()
    
for i in range(N):
  if sum([S[_][i] for _ in range(N)]) == -3:
    print('Yes')
    quit()
    
if all([S[i][N-i-1]==-1 for i in range(N)]) or \
   all([S[i][i]==-1 for i in range(N)]):
   	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
import sys
from io import StringIO
import unittest

class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]

def resolve():
    n,m,k=map(int, sys.stdin.readline().strip().split())
    #list(map(int,input().strip().split()))

    uf = UnionFind(n)

    res=[[] for i in range(n)]
    frd=[0 for i in range(n)]
    blk=[0 for i in range(n)]

    for i in range(m):
        #a,b=list(map(int,input().strip().split()))
        a,b=map(int, sys.stdin.readline().strip().split())
        a-=1
        b-=1
        uf.Unite(a,b)
        frd[a]+=1
        frd[b]+=1
    
    for i in range(k):
        #a,b=list(map(int,input().strip().split()))
        a,b=map(int, sys.stdin.readline().strip().split())
        a-=1
        b-=1
        if uf.isSameGroup(a,b):
            blk[a]+=1
            blk[b]+=1
    
    rescnt=[]

    for i in range(n):
        ri=uf.Count(i)-1-blk[i]-frd[i]
        rescnt.append(str(ri))
        ##rescnt.append(str(n-uf.size(i)-len(blk[i])))
    
    print(" ".join(rescnt))

resolve()

Submission status: Runtime Error

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

if m == 0:
    print(-1)
    exit()


for i in l:
    if i[0] == 1 and i[1] == 0:
        continue
    if ans[i[0]-1] >= i[1]:
        ans[i[0]-1] = i[1]

for i in range(n):
    if ans[i] == 9283749384736:
        ans[i] = 0

s = int("".join(list(map(str, ans))))
if len(str(s)) == n:
    print(s)
else:
    print(-1)

Submission status: Runtime Error

Solution code:
return int(int(input())/2)

Submission status: Runtime Error

Solution code:
n = input()
return int(n/2)

Submission status: Runtime Error

Solution code:
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

def get_circle_center_and_radius(x1, y1, x2, y2, x3, y3):
    """
    3点を通る円の中心と半径を取得
    """
    d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
    if d==0:
        return(0)
    x = ((y1 - y3) * (y1 ** 2 - y2 ** 2 + x1 ** 2 - x2 ** 2) - (y1 - y2) * (y1 ** 2 - y3 ** 2 + x1 ** 2 - x3 ** 2)) / d
    y = ((x1 - x3) * (x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) - (x1 - x2) * (x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2)) / -d
    #r = math.sqrt((x - x1) ** 2 + (y - y1) ** 2)
    return (x, y)
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
#S=[list(map(int,input().split())) for i in range(N)]
N,K=map(int,input().split())
XYC=[list(map(int,input().split())) for i in range(N)]
if K==1:
    print(0)
    exit()
count=10**18

if N>=2:
    nlst=combinations(list(range(N)),2)

    for n1,n2 in nlst:
        x1,y1,c1=XYC[n1]
        x2,y2,c2=XYC[n2]
        A=c1+c2
        X=(x1*c1+x2*c2)/A
        Y=(y1*c1+y2*c2)/A
        count1=[]
        for x,y,c in XYC:
            count1.append(((X-x)**2+(Y-y)**2)**0.5*c)
        count1.sort()
        #print(X,Y,count1)
        count=min(count,count1[K-1])

if N>=3:
    nlst=combinations(list(range(N)),3)
    for n1,n2,n3 in nlst:
        x1,y1,c1=XYC[n1]
        x2,y2,c2=XYC[n2]
        x3,y3,c3=XYC[n3]
        C=get_circle_center_and_radius(c1*x1,c1*y1,c2*x2,c2*y2,c3*x3,c3*y3)
        if C:
            X,Y=C
        else:
            continue
        X,Y=X/A,Y/A

        count1=[]
        for x,y,c in XYC:
            count1.append(((X-x)**2+(Y-y)**2)**0.5*c)
        count1.sort()

        count=min(count,count1[K-1])

print(count)

Submission status: Runtime Error

Solution code:
root = [i for i in range(N + 1)]
size = [1] * (N + 1)
 
def find(x):
  y = root[x]
  if x == y:
    return x
  else:
    z = find(y)
    root[x] = z
    return z

def union(x, y):
  rx = find(x)
  ry = find(y)
  sx = size[rx]
  sy = size[ry]
  if rx == ry:
    return 0
  else:
    if sx >= sy:
      root[ry] = rx
      size[rx] = sx + sy
    else:
      root[rx] = ry
      size[ry] = sx + sy
    return sx * sy

Submission status: Runtime Error

Solution code:
vs = input().split(' ')
N = int(vs[0])
M = int(vs[1])
valueMap = [10 for i in range(M)]

for i in range(N):
  vs = input().split(' ')
  t_i = int(vs[0]) - 1
  t_v = int(vs[1])

  if (valueMap[t_i] > t_v and t_v != 0):
    valueMap[t_i] = t_v
valueMap = list(map(lambda v: 0 if v == 10 else v, valueMap))

if (len(valueMap) != 1 and valueMap[0] == 0):
  print(-1)
else:
  print("".join(map(str, valueMap)))

Submission status: Runtime Error

Solution code:
N = input()
N = N//2
print(N)

Submission status: Runtime Error

Solution code:
N = int(input().split())

print(N//2) if N%2==0 else print(N//2 +1)

Submission status: Runtime Error

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

ans = ['' for _ in range(N)]

for _ in range(M):
    s, c = map(str, input().split())
    if (ans[int(s)-1] != '') and (ans[int(s)-1] != c):
        print("-1")
        break
    else:
        ans[int(s)-1] = c
else:
    if (N > 1) and (ans[0] == ''):
        ans[0] = '1'
    ans = ['0' if s == '' else s for s in ans]

    if (N > 1) and (ans[0] == '0'):
        print("-1")
    else:
        print(''.join(ans))

Submission status: Runtime Error

Solution code:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
import sys
input=sys.stdin.readline
n,m,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]
cd = [list(map(int,input().split())) for i in range(k)]
num = [0]*(n+1)
g = [[] for i in range(n+1)]
uf = UnionFind(n+1)
for a,b in ab:
  g[a].append(b)
  g[b].append(a)
  uf.union(a,b)
for c,d in cd:
  if uf.same(c,d) == True:
    g[c].append(d)
    g[d].append(c)
for i in range(1,n+1):
  print(uf.size(i)-len(g[i])-1,end=" ")

Submission status: Runtime Error

Solution code:
#C - Guess The Number
n,m = list(map(int,input().split()))
tmp = []
s = []
c = []
flg = False
counter = 0
ans = 0
tmp = [input() for i in range(m)]
for i in tmp:
    i.split()
    s.append(i[0])
    c.append(i[2])
if(n ==3):
  for j in range(100,1000):
    if(flg == True):
      break
    list_j = list(str(j))
    counter = 0
    for k in s:
        if(list_j[int(k)-1] != c[counter]):
          break
        if(list_j[int(k)-1] == c[counter]):
          counter += 1
          if(counter == len(c)):
            flg = True
            break
    if(flg == True):
      ans = j
      break
if(n ==2):
  for j in range(10,100):
    if(flg == True):
      break
    list_j = list(str(j))
    counter = 0
    for k in s:
        if(list_j[int(k)-1] != c[counter]):
          break
        if(list_j[int(k)-1] == c[counter]):
          counter += 1
          if(counter == len(c)):
            flg = True
            break
    if(flg == True):
      ans = j
      break
if(n ==1):
  for j in range(0,10):
    if(flg == True):
      break
    list_j = list(str(j))
    counter = 0
    for k in s:
        if(list_j[int(k)-1] != c[counter]):
          break
        if(list_j[int(k)-1] == c[counter]):
          counter += 1
          if(counter == len(c)):
            flg = True
            break
    if(flg == True):
      ans = j
      break

if(flg == True):
    print(ans)
else:
    print('-1')

Submission status: Runtime Error

Solution code:
a,b,c  = map(int, input().split())
d,e,f  = map(int, input().split())
g,h,i  = map(int, input().split())
n=int(input())
A = []
for j in range(n):
    A.append(int(input()))
if (a in A) and (b in A) and (c in A):
    print("Yes")
elif d in A and e in A and f in A:
    print("Yes")
elif g in A and h in A and i in A:
    print("Yes")
elif a in A and d in A and g in A:
    print("Yes")
elif b in A and e in A and h in A:
    print("Yes")
elif c in A and f in A and i in A:
    print("Yes")
elif a in A and e in A and i in A:
    print("Yes")
elif c in A and e in A and g in A:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
c=-1
d=0
f=0
g=0
N, M = map(int, input().split())
list = []
for i in range(M):
    a,b=input().split()
    list.append((int(a), int(b)))

for i in range(M):
	if list[i][0]>N and list[i][0]+list[i][1]==1:
		print(c)
		f=1
		break
	for j in range(i+1,M):
		if list[i][0]==list[j][0]:
			g=1
			if list[i][0]!=list[j][0]:
				print(c)
				f=1
				break
	if f==1:
		break
	if g==0:
		d+=list[i][1]*(10**(M-list[i][0]))
	g=0
if f==0:
	print(d)

Submission status: Runtime Error

Solution code:
a = input().split()
n = int(a[0])
m = int(a[1])

d = {}
ret = True
for i in range(m):
  a = input().split()
  s = int(a[0])
  c = int(a[1])
  if (d.get(s,-1) != -1) & (d.get(s,-1) != c):
    ret = False
  if (s == 1) & (c == 0):
    ret = False
  if s > n:
    ret = False
  d[s] = c

p = ""    
for i in range(1,n+1):
  if d.get(i,-1) == -1:
    if (i == 1) & (n >1):
      p += "1"
    else:
      p += "0"
  else:
    p += str(d[i])
if ret:
  print(p)
else:
  print("-1")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1

    for i in range(n):
        if num_list[i] == 'X':
            num_list[i] = '1' if i == 0 else '0'

    return ''.join(num_list)

print(ans())

Submission status: Runtime Error

Solution code:
for i in range(3):
    a = []
    for j in range(3):
      	a = input().split()
        a = [int(x) for x in a]
    A.append(a)
N = int(input())
C = []
for _ in range(3):
    C.append(np.zeros(3))
 
for _ in range(N):
    b = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == b: C[i][j] = 1
 
for i in range(3):
    if sum(C[:][i]) == 3:
        print('Yes')
        break
    elif sum(C[i][:]) == 3:
        print('Yes')
        break
if C[1][1]+C[2][2]+C[0][0] == 3:
    print('Yes')
elif C[0][2]+C[1][1]+C[2][0] == 3:
    print('Yes')
else: print('No')

Submission status: Runtime Error

Solution code:
N,M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
num = [0,0,0]
for i in range(M):
    if N == 3 and sc[i][0] == 1 and sc[i][1] == 0 or N == 2 and sc[i][0] == 2 and sc[i][1] == 0: # or sc[i][1] == 0 and sc[i][0] == 2 and  #値が０かつそれが１００の位 or 値が０かつそれが１０の位かつ１００がない
        print("-1")
        exit()
    else:
        for j in range(M-1):
            if sc[i][0] == sc[j+1][0]:
                if sc[i][1] != sc[j+1][1]:
                    print("-1")
                    exit()
                else:
                    #if sc[i][1] not in num:
                    num[sc[i][0]-1] = sc[i][1]
            else:
                num[sc[i][0]-1] = sc[i][1]
NUM = num[0] * 100 + num[1] * 10 + num[2]
print(NUM)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
s, c = [], []
for i in range(m):
    a, b = map(int, input().split())
    s.append(a), c.append(b)

dicts = {}

ans = [0 for i in range(n)]
b = 0

for i in range(m):
    if s[i] == 1 and c[i] == 0:
        print('-1')
        break
    if s[i] not in dicts:
        dicts[s[i]] = c[i]
    elif s[i] in dicts and dicts[s[i]] != c[i]:
        print('-1')
        break

    if i == m - 1:
        for j in range(n + 1):
            if j in dicts:
                ans[j - 1] = dicts[j]
        # print(ans)
        for j in range(n):
            b += ans[n - j - 1] * (10 ** j)
        if b >= 10 ** (n - 1) and b <= (10 ** n) - 1:
            print(b)
        elif b == 0 and n == 1:
            print(b)
        else:
            print(b + 10 ** (n - 1))

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split())
a += list(map(int, input().split())
a += list(map(int, input().split())
A = []
N = int(input())
b = list(int(input()) for i in range(N))

for i in range(9):
    if a[i] in b[i]:
        A[i] = "maru"

if A[0] == A[1] == A[2] or A[3] == A[4] == A[5] or A[6] == A[7] == A[8] or A[2] == A[4] == A[6]:
    print("yes")
elif A[0] == A[3] == A[6] or A[1] == A[4] == A[7] or A[2] == A[5] == A[8]:
    print("yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
lst = [[] for _ in range(n)]
for _ in range(m):
    s, c = map(int, input().split())
    nums = append([s-1,c])

print(nums)

Submission status: Runtime Error

Solution code:
a = int(imput())
if a // 2 == 0 : print(a/2)
if a // 2 != 0 : print((a+1)/2)

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
from copy import deepcopy

N, M, K = map(int, input().split())
FRIENDS = [list(map(int, input().split())) for _ in range(M)]
BLOCKS = [list(map(int, input().split())) for _ in range(K)]

def search(i, friends):
    copied_friends = deepcopy(friends)
    res = []
    for a, b in friends:
        if a == i:
            copied_friends.remove([a, b])
            res.append(b)    
        if b == i:
            copied_friends.remove([a, b])
            res.append(a)
    
    return res, copied_friends

    
def find(i, j, friends):
    for a, b in friends:
        if a == i and b == j:
            return True
        if b == i and a == j:
            return True
    
    return False

    
def dfs(i, friends):
    if len(friends) == 0:
        return [i]

    targets, new_friends = search(i, friends)
    for t in targets:
        if targets.count(t) <= 1:
            targets += dfs(t, new_friends)
        
    return targets


results = []
for i in range(1, N+1):
    targets = list(set(dfs(i, FRIENDS)))
    targets = filter(lambda x: not find(x, i, FRIENDS), targets)
    targets = filter(lambda x: not find(x, i, BLOCKS), targets)

    results.append(len(list(targets)))

print(" ".join(map(str, results)))

Submission status: Runtime Error

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

fail = False
result = {}
for i in range(0, m):
    s, c = map(int, input().split())
    key = n-s
    if key in result and result[key] != c:
        fail = True
        break
    result[key] = c

if not(n-1 in result) or result[n-1] == 0:
   fail = True

if fail:
    print(-1)
else:
    res = 0
    for i in range(0, n):
        if i in result:
            res += 10 ** i * result[i]
    print(res)

Submission status: Runtime Error

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

listans = [-1] * n
ans = 0

for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        ans = -1
    if listans[int(s)-1] != c:
        if listans[int(s)-1] == "0":
            listans[int(s)-1] = c
        else :
            ans = -1

if ans == 0:
    if n > 1 and listans[0] == "0":
        listans[0] = "1"
    ans = int("".join([str(li) for li in listans]))

print(ans)

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)]

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

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


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i][i] != True:
            flag1 = 1

        if carr[i][3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False

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

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a1 = na()
a2 = na()
a3 = na()

A = a1+a2+a3
C = [0,0,0,0,0,0,0,0,0]

n = ni()

for i in range(n):
    b = ni()
    if b in A:
        C[A.index(b)] = 1
    if sum(C[0:3]) == 3 or sum(C[3:6])==3 or sum(C[6:9]) == 3 or sum(C[::4]) == 3 or sum(C[2:7:2]) == 3 or sum(C[0::3]) == 3 or sum(C[1::3]) == 3 or sum(C[2::3]) == 3:
        print('Yes')
        exit()

print("No")

Submission status: Runtime Error

Solution code:
#Input
l_A =  [[0 for i in range(3)] for j in range(3)]
l_A[0] = list(map(int, input().split()))
l_A[1] = list(map(int, input().split()))
l_A[2] = list(map(int, input().split()))

def detect_BINGO(l_Atf):
    #print(l_Atf)
    #横
    for i in range(3):
        f_detect = True
        for j in range(3):
            #print(f_detect, l_Atf[i][j])
            f_detect = f_detect and l_Atf[i][j]
        if(f_detect):
            #print("横" + str(i))
            return True
    #縦
    for i in range(3):
        f_detect = True
        for j in range(3):
            f_detect = f_detect and l_Atf[j][i]
        if(f_detect):
            #print("縦" + str(i))
            return True
    #斜
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][i]
    if(f_detect):
        #print("斜＼")
        return True
    f_detect = True
    for i in range(3):
        f_detect = f_detect and l_Atf[i][3-1-i]
    if(f_detect):
        #print("斜／")
        return True
    
    #BINGOなし
    return False

#Process
l_Atf = [[False for i in range(3)] for j in range(3)]
for i in range(int(input())):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if(l_A[j][k] == b):
                l_Atf[j][k] = True
    #print(l_Atf)

f_bingo = detect_BINGO(l_Atf)

#Output
if(f_bingo):
    print("Yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

        a = int(sys.stdin.readline().rstrip())

    print(int(a // 2 if a % 2 == 0 else a // 2 + 1))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def cross_gugge(A):
  if A[0][0] == 1 and A[1][1] == 1 and A[2][2] == 1:
    ans += 1
  elif A[0][2] == 1 and A[1][1] == 1 and A[2][0] == 1:
    ans += 1
    
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
B = [int(input()) for i in range(N)]
ans = 0
for i in range(3):
  for j in range(3):
    for k in B:
      if A[i][j] == k:
        A[i][j] = 1
for i in range(3):
  if A[i].count(1) == 3:
    ans += 1
  elif A[0][i] == 1 and A[1][i] == 1 and A[2][i] == 1:
    ans += 1
cross_gugge(A)
if ans > 0:
  print("Yes")
else:
  print("No")

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]:
                carr[i][j] = True
                print(b, carr)

print(carr)

def yoko(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[i][j] != True:
                print('pass',i,j)
                flag = 1
        if flag == 0 :
            return True    
    return False


def tate(carr):
    for i in range(3):
        flag = 0
        for j in range(3):
            if carr[j][i] != True:
                flag = 1
                break
        if flag == 0:

            return  True
    
    return False

def naname (carr):
    flag2 = 0
    flag1 = 0
    for i in range(3):
        if carr[i] != True:
            flag1 = 1

        if carr[3-i-1] != True:
            flag2 = 1;
    if flag1==0 or flag2 ==0:
        return True
    else:
        return False


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:
A11,A12,A13,A21,A22,A23,A31,A32,A33 = map(int,input().split(" "))
bingo = [A11,A12,A13,A21,A22,A23,A31,A32,A33]
bingo = ",".join(map(str,bingo))
N = int(input())
for i in range(N):
    b = input()
    if b in bingo:
        bingo.replace(b,True)
    else:
        pass
Bingo = bingo.split(",")
Flag = False
if Bingo[0] == Bingo[1] == Bingo[2]==True:
    Flag = True
if Bingo[3] == Bingo[4] == Bingo[6]==True:
    Flag = True
if Bingo[6] == Bingo[7] == Bingo[8]==True:
    Flag = True
if Bingo[0] == Bingo[3] == Bingo[6]==True:
    Flag = True
if Bingo[1] == Bingo[4] == Bingo[7]==True:
    Flag = True
if Bingo[2] == Bingo[5] == Bingo[8]==True:
    Flag = True
if Bingo[0] == Bingo[4] == Bingo[8]==True:
    Flag = True
if Bingo[2] == Bingo[4] == Bingo[6]==True:
    Flag = True
else:
    pass
if flag == True:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
n, m = map(int, input().split())
r = [-1] * n

for _ in range(m):
    s, c = map(int, input().split())
    if r[s-1] == -1 or r[s-1] == c:
        r[s-1] = c
    else:
        print(-1)
        sys.exit(0)

if r[0] == 0:
    print(-1)
    sys.exit(0)
if r[0] == -1 and n > 1:
    r[0] = 1

n_r = [0 if i == -1 else i for i in r]
result = ''.join([str(i) for i in n_r])
print(result)

Submission status: Runtime Error

Solution code:
def main():
  N=int(input())
  S=str(input())
  Q=int(input())
  Q1=[]
  Q2=[]
  Q3=[]
  for i in range(Q):
    i1,i2,i3=map(str,input().split())
    Q1+=[i1]
    Q2+=[i2]
    Q3+=[i3]
  Slist=[]
  for i in range(N):
    Slist+=[S[i]]
  tf=[[0 for  i in range(26)] for i in range(N+1)]
  for i in range(1,N):
    n=ord(Slist[i])-97
    tf[i][n]=tf[i-1][n]+1
  for i in range(Q):
    if int(Q1[i])==1:
      n=ord(Slist[int(Q2[i])-1])-97
      tf[int(Q2[i])-1][n]-=1
      Slist[int(Q2[i])-1]=Q3[i]
      n=ord(Q3[i])-97
      tf[int(Q2[i])-1][n]+=1
    elif int(Q1[i])==2:
      l=Q2[i]-2
      r=Q3[i]-1
      t=0
      for i in range(26):
        if tf[r][i]>tf[l][i]:
          t+=1
      print(t)
if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
N = input()

if N % 2 == 0:
  unpo = N / 2
  print(unpo)
else:
  unpo = (N / 2) + 1
  print(unpo)

Submission status: Runtime Error

Solution code:
import numpy as np
x = input()
y = input()
z = input()
xa = x.split(" ")
ya = y.split(" ")
za = z.split(" ")
A = np.array([xa,ya,za])
N = int(input())
b =[]
C = np.array([["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"],["Nomark", "Nomark", "Nomark"]])
for i in range(1,N+1):
    b.append(input())
for m in range(0,3):
    for n in range(0,3):
        if A[m, n] in b:
            C[m,n] = "Maru"
tate = str(np.count_nonzero(C == 'Maru', axis=0))

yoko = str(np.count_nonzero(C == 'Maru', axis=1))

if "3" in tate or "3" in yoko:
    print('Yes')
elif C[0,0] == "Maru" and C[1,1] == "Maru" and C[2,2] == "Maru":
    print("Yes")
elif C[0,2] == "Maru" and C[1,1] == "Maru" and C[2,0] == "Maru":
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A11, A12, A13 = (int(x) for x in input().split())
A21, A22, A23 = (int(x) for x in input().split())
A31, A32, A33 = (int(x) for x in input().split())

N = int(input())

b_list = list()
for i in range(0, N):
    i = int(input())
    b_list.append(i)

A_list = [A11, A12, A13, A21, A22, A23, A31, A32, A33]

for b in b_list:
    for i in range(0, 9):
        if A_list[i] == b:
            A_list[i] = 0

X, Y, Z = 0, 0, 0
for i in range(0, 3):
    k = 3 * i
    if A_list[k] + A_list[k + 1] + A_list[k + 2] == 0:
        X = X + 1
    elif A_list[i] + A_list[i + 3] + A_list[i + 6] == 0:
        Y = Y + 1
    elif A_list[0] + A_list[4] + A_list[8] == 0:
        Z = Z + 1
    elif A_list[2] + A_list[4] + A_list[6] == 0:
        Z = Z + 1
    else:
        continue

if (X+Y+Z) >= 1:
    print('Yes')
else:
    print('No')

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:
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i]= map(int, input().split())

if M==0:
  A = 10**(N-1)
else:
  A = 0

X = []
for j in range(M):
  if S[j] in X:
    X.append(S[j])
  else:
    A +=(10**((N-S[j])))*C[j]
    X.append(S[j])

str_B = list(str(A))

for k in range(M):
  if str_B[S[k]-1] != str(C[k]):
    A = -1

if A < 10**(N-1):
  A = -1

print(A)

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'
t_a = 0
for r in range(len(result)):
    for t in range(3):
        for y in range(3):
            if(result[r][0] == t and result[r][1] == y):
                t_a += 1
        if(t_a == 3):
            bingo_a = 'Yes'

y_a = 0
for r in range(len(result)):
    for y in range(3):
        for t in range(3):
            if(result[r][0] == t and result[r][1] == y):
                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)