Problem:


Score : 100 points

Problem Statement

It is September 9 in Japan now.

You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Constraints

10≤N≤99

Input

Input is given from Standard Input in the following format:

N

Output

If 9 is contained in the decimal notation of N, print Yes; if not, print No.

Sample Input 1

29

Sample Output 1

Yes

The one's digit of 29 is 9.

Sample Input 2

72

Sample Output 2

No

72 does not contain 9.

Sample Input 3

91

Sample Output 3

Yes



Sample input:
29


Sample output:
Yes

Submission status: Runtime Error

Solution code:
n=input()
if n%10==9 or n//10==9:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#ABC73
n = input()
if(n[0]=="9" or n[1]=="9"):
    print(Yes)
else:
    print(No)

Submission status: Runtime Error

Solution code:
n = input()
if n[0] == "9" or n[1] == "9"
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
if '9'.in input():
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
if '9'.in(input()):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
if input().in('9'):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
a = input()
if a.count(9)==1 or a.count(9)==2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N=input()
if N.count(9)>=1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
N=int(input())
if N[0]=="9" or N[1]=="9":
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
l = set()
for i in range(n):
    tmp = int(input())
    l.remove(tmp) if tmp in l else l.add(tmp)
print(len(l))

Submission status: Runtime Error

Solution code:
n = int(input())
l = []
#l = [l.remove(int(input())) if int(input()) in l else int(input()) for i in range(n)]
for i in range(n):
    l.remove(int(input())) if int(input()) in l else l.append(int(input()))
print(len(l))

Submission status: Runtime Error

Solution code:
l = list(input())
print("Yes") if l in "9" else print("No")

Submission status: Runtime Error

Solution code:
l = list(input().split())
print("Yes") if l in "9" else print("No")

Submission status: Runtime Error

Solution code:
if input().find("9")>-1:
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
if input().find('9')>-1:
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
if input().find("9")>-1:
  print("Yes")
 else:
    print("No")

Submission status: Runtime Error

Solution code:
if input().find("9")>-1:
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
if '9' in N:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
#include <stdio.h>
#include <string.h>
#include <math.h>

int main(void){
        char s[1000000];
        scanf("%s", s);
        for (int i = 0; i < strlen(s); i++) {
                if (s[i]=='9') {
                        printf("Yes\n");
                        return 0;
                }
        }
        printf("No\n");
        return 0;
}

Submission status: Runtime Error

Solution code:
from itertools import permutations
import sys


input = sys.stdin.readline


N, M, R = (list)(map(int, input().split()))

#dest = (list)(map(lambda x: (int)(x)-1, input().split()))
dest = [x-1 for x in map(int, input().split())]


inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
    a, b, c = (list)(map(int, input().split()))
    mat[a-1][b-1] = mat[b-1][a-1] = c


for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in permutations(dest):
    tmp = 0
    for u, v in zip(l, l[1:]):
        tmp += mat[u][v]
    ans = min(ans, tmp)

print(ans)

Submission status: Runtime Error

Solution code:
def main():
  x, a = map(int, input().split())

  if (x-a) <= 0:
    print(0)
    return
  print(x-a)
  return

if __name__ == '__main__':
  main()

Submission status: Runtime Error

Solution code:
n=int(input())
paper=list()
for _ in range(n):
    a = input()
    if a in paper:
        paper.remove(a)
    else:
        paper.append(a)
print(len(paper))

Submission status: Runtime Error

Solution code:
from itertools import permutations

N,M,R=map(int,input().split())

r=list(map(int,input().split()))

for i in range(len(r)):
    r[i]-=1
    
A=[]
a=[]
for i in range(N):
    for j in range(N):
        a.append(1000000)
    A.append(a)
    a=[]
#print(A)

for i in range(M):
    a,b,c=map(int,input().split())
    A[a-1][b-1]=c
    A[b-1][a-1]=c
#print(A)

for c in range(N):
    for a in range(N):
        for b in range(N):
            A[a][b]=min(A[a][b],A[a][c]+A[c][b])
#print(A)

ans=10000000
for i in permutations(r,len(r)):
    cnt=0
    for j in range(len(i)-1):
        cnt+=A[i[j]][i[j+1]]
    if ans>cnt:
        ans=cnt
print(ans)

Submission status: Runtime Error

Solution code:
N=map(int,input().replace("",",").split())
if 9 in N:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = list(map(str, input().split()))
if n in '9':
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
if n in '9':
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n = list(input().split())
if n in '9':
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64

int main(){
    int n;
    cin >> n;
    if(n%10==9 or n/10==9) cout << "Yes" << endl;
    else cout <<"No"<< endl;
}

Submission status: Runtime Error

Solution code:
a=int(input())

b=list(a)

if(b[0]==9 or b[1]==9):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def main():
    N = int(input())

    paper = []

    for i in range(N):
        # Aのi番目
        ai = int(input())
        for p in range(len(paper)):
            if paper[p] < ai:
                continue
            elif paper[p] == ai:
                paper.remove(ai)
                break
            else:
                paper.insert(p, ai)
                break

    print(len(paper))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a = list(input())
if a[0] == "9" or a[1] == "9":
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
a = list(input())
if a[0] = "9" or a[1] = "9":
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
a = list(input())
if a[0] = 9 or a[1] = 9:
  print(Yes)
else:
  print(No)

Submission status: Runtime Error

Solution code:
from itertools import permutations
N,M,R = map(int,input().split())
r = list(map(int,input().split()))

d = [[float('inf') for _ in range(N)] for _ in range(N)]
for _ in range(M):
    a,b,c = map(int,input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
for i in range(N):
    d[i][i]=0
from scipy.sparse import csgraph
d = csgraph.floyd_warshall(d)
ans = float('inf')
for seq in permutations(r):
    s = 0
    for j in range(R-1):
        s += d[seq[j]-1][seq[j+1]-1]
    ans = min(ans,s)
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
b=set()
for i in range(N):
    a=int(input())
    if  a in b:
        b.remove(a)
    else:
        b.add(a)
print(len(b))

Submission status: Runtime Error

Solution code:
N=int(input())
b=set()
for i in range(N):
    a=input()
    if  a in b:
        b.remove(a)
    else:
        b.add(a)
print(len(b))

Submission status: Runtime Error

Solution code:
n = int(input())

if "9" in n:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
# input
N_lst = [int(x) for x in list(input()]

if N_lst[0] == 9 or N_lst[1] == 9:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from itertools import permutations
def read(): return list(map(int, input().split()))
 
 
INF = 114514810
 
 
def wf(d):
    N = len(d[0])
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if d[i][j] > d[i][k] + d[k][j]:
                    d[i][j] = d[i][k] + d[k][j]
    return d
 
 
def calc_dist(p, d):
    dist = 0
    for i in range(len(p) - 1):
        if d[p[i]][p[i + 1]] >= INF:
            return INF
        dist += d[p[i]][p[i + 1]]
    return dist
 
 
def main():
    N, M, R = read()
    r = map(lambda x: x - 1, sorted(read()))
    d = [[INF for i in range(N)] for j in range(N)]
 
    for i in range(M):
        a, b, c, = read()
        a -= 1
        b -= 1
        d[a][b] = d[b][a] = c
 
    d = wf(d)
 
    min_dist = INF
    for p in list(permutations(r)):
        min_dist = min(min_dist, calc_dist(p, d))
 
    print(min_dist)
 
 
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
a=""
a=input()
ans=0
for i in range(len(a)):
	if a[i]=='9':
		ans=1
if ans==1:
	print 'Yes'
if ans==0:
	print 'No'

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    string N;
    cin >> N;
    cout << (N[0] == '9' || N[1] == '9' ? "Yes" : "No") << endl; 
    return 0;
}

Submission status: Runtime Error

Solution code:
a = int(input())
print(["No", "Yes"][a//10 == 9 or a%10 == 9]

Submission status: Runtime Error

Solution code:
a = str(input())
if a[0] == '9' || a[1] == '9':
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:

a = str(input())
if a[0] == 9 || a[1] == 9:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
a=list(input().split())
if a[0]==9 or a[1]==9:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
x = 0

for i in range(n):
    a.append(list(map(int,input().split())))

for b in range(n):
    x += a[b][-1] - a[b][0] + 1

print(x)

Submission status: Runtime Error

Solution code:
#-*- coding: utf-8 -*-
print(['No', 'Yes'][input().count('9')])

Submission status: Runtime Error

Solution code:
#include <stdio.h>

int main() {
    int N;

    scanf("%d", &N);

    if ( (N % 10 == 9) || (N / 10 == 9) ) {
        puts("Yes");
    }
    else {
        puts("No");
    }

    return 0;
}

Submission status: Runtime Error

Solution code:
N = input()
if "9" in n:
    print("Yes")
else:
    printI("No")

Submission status: Runtime Error

Solution code:
n = int(input())

if n in '9':
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
print("YNeos"["9"not in input()::2])
print("Yes"if"9"in input()else"No")

Submission status: Runtime Error

Solution code:
import collections

num = int(input())
inps = []
for x in range(0,num):
  # inp[x] = int(input())
  inp = int(input())
  inps.append(inp)

# print(inps)
count = collections.Counter(inps)
# print(count.keys())

ans = 1

for x in range(0,int(len(count))):
  if int(count[x]) % 2 == 1:
  	ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
a = int(input())
if "9" in a:
  print("Yes")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
def Warshall_Floyd(edges,N):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
  return edges

import itertools
N, M, R = map(int,input().split())
r = list(map(int,input().split()))
A=[[float("inf") for i in range(N)] for j in range(N)]
for m in range(M):
  a, b, c = map(int,input().split())
  A[a-1][b-1] = c
  A[b-1][a-1] = c

ans = float("inf")
for road in list(itertools.permutations(r)):
  length = 0
  for i in range(R-1):
    length += A[road[i]-1][road[i+1]-1]
  ans = min(ans, length)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 09:36:44 2017

@author: kotania
"""

N = int(input())
lrList = [""]*N
for n in range(0,N):
    lrList[n] = input()

sum = 0
for lr in lrList:
    sum += (int(lr.split()[1]) - int(lr.split()[0]) + 1)
    
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
 
nums = []
sum = 0
for i in range(0,N):
    num = input()
    if num in nums:
        nums.remove(num)
        sum -= 1
    else:
        nums.append(num)
        sum +=  1
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())

nums = []
sum = 0
for i in range(0,N):
    num = input()
    if num in nums:
        nums.remove(num)
    else:
        nums.append(num)
        sum = sum + 1
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input())
if N >= 90 or (N+1)%10 is 0:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
N = input()
if N >= 90:
    print("Yes")
elif (N+1)%10 is 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
if N >= 90:
    print("Yes")
elif (N+1)%10 is 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
# 今日、日本は9月9日である。
# 2桁の整数Nが与えられる。
# Nに9が含まれるか調べ、含まれていればYes、そうでなければNoを出力する

def September9(num):
    if (num // 10) == 9:
        print("Yes")
    elif (num % 10) == 9:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    N = int( input())
        
    September9(N) # September9()の実行
    

~

Submission status: Runtime Error

Solution code:
"""
    N×N のマス目があります。
    このマス目の各マスを白色または黒色に塗ることにしました  (すべてのマスをどちらか片方の色に塗ります)。
    ちょうど A マスを白色に塗るとき、黒色に塗ることになるマスはいくつあるでしょうか。
"""

"""
    標準入力は以下の形式で与えられる
    -------------------------------
    N
    A
"""

"""
    N,Aの条件
    ------------------
    1 <= N & N <= 100
    0 <= A & A <= N**2
"""

"""
    出力
    -----------------
    黒色に塗るマスの個数を出力する
"""

if __name__ == "__main__":

# Nの入力チェック---------------------------------------------------
    while True:   
        try:
            N = int( input("整数Nを入力してください。:") )
            if (1 <= N) & (N <= 100):
                break
            else:
                print("入力が規定の範囲内に収まっていません。")
                print("--------------------------------------")

        except ValueError:
            print("Nの入力エラーです")
            print("--------------------------------------")            

# Aの入力チェック----------------------------------------------------
    while True:   
        try:
            A = int( input("整数Aを入力してください。:") )
            if (1 <= A) & (A <= N*N):
                break
            else:
                print("入力が規定の範囲内に収まっていません。")
                print("--------------------------------------")

        except ValueError:
            print("Aの入力エラーです")
            print("--------------------------------------")            

# 関数の実行--------------------------------------------------
    print(" ###### Result ######")
    print(N**2 - A)

Submission status: Runtime Error

Solution code:

n = raw_input()

n_dec = int(n) / 10
n_one = int(n) % 10

if(n_one ==9):
    print("Yes")
elif(n_dec == 9):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
if n[0]==9 or n[1]==9:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(n)
if l[0] == 9 or l[1] == 9:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0
for _ in range(N):
    l, r = map(int, input().split())
    ans += (r - l) + 1
print(ans)

Submission status: Runtime Error

Solution code:
a = map(int,list(input()))
if (a[0] == 9 or a[1] == 9):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = int(input())

if (a//10 == 9 || a%10 == 9):
    print("yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = int(input())

if (a/10 == 9 || a%10 == 9):
    print("yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a = int(input())
b = a[0]
c = a[1]
if b==9 or c==9:
print("Yes")
else:
print("No")

Submission status: Runtime Error

Solution code:
N = int(input())
if int(N/10)==9:
        print("Yes")
    elif int(((N-9)%10)) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    i = 0
    N = int(input())
    if N-90>0:
        i = 1
    x = (N-9)/10
    if x == int(x):
        i = 1
    if i == 1:
        print(Yes)
    else:
        print(No)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N = int(input())
    if N-90>0:
        i = 1
    x = (N-9)/10
    if x == int(x):
        i = 1
    if i == 1:
        print(Yes)
    else:
        print(No)

Submission status: Runtime Error

Solution code:
if __name__ == '__main__':
    N = int(input())
    if N-90>0:
        print(Yes)
        return
    x = (N-9)/10
    if x == int(x):
        print(Yes)
        return
    print(No)

Submission status: Runtime Error

Solution code:
    if [1 for c in input() if c == '9']:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
a = input()
a.find("9")
if a !== -1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
c=[0]*100010
N=int(input())
for _ in range(N):
  a,b=map(int,input().split())
  c[a] += 1
  c[b+1] -= 1
for i in range(len(c)-1):
  c[i+1] += c[i]
print(sum(c))

Submission status: Runtime Error

Solution code:
#実行時間を短く
import sys

data = set()
N = int(sys.stdin.readline())

for i in range(N):
    num = int(sys.stdin.readline())
    if num in data:
        data.remove(num)
    else:
        data.add(num)
print(len(data))

Submission status: Runtime Error

Solution code:
#coding: utf_8
#実行時間が長い
"""N = int(input())
data = []
for i in range(N):
    num = int(input())
    if num in data:
        data.remove(num)
    else:
        data.append(num)
print(len(data))"""

#実行時間を短く
import sys

data = set()
N = int(sys.stdin.readline())

for i in range(N):
    num = int(sys.stdin.readline())
    if num in data:
        data.remove(num)
    else:
        data.add(num)
print(len(data))

Submission status: Runtime Error

Solution code:
paper = [0,0,0,0,0,0,0,0,0,0]
N = int(input())
for _ in range(N):
    number = int(input())
    paper[number] += 1
sum = 0
for x in range(10)
    if paper[x] % 2 == 1
        sum += 1
print(sum)

Submission status: Runtime Error

Solution code:
N = int(input.())
if N+10 >= 100 or (N+1) % 10 == 0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N = raw_input()
N = int(N)

a = {}
for i in range(N):
	s_input = raw_input()
	if s_input in a:
		del a[s_input]
	else:
		a[s_input] = s_input

print(len(a))

Submission status: Runtime Error

Solution code:
N = raw_input()
N = int(N)

a = {}
for i in range(N):
	s_input = raw_input()
	s_input = int(s_input)
	if s_input in a:
		del a[s_input]
	else:
		a[s_input] += 1

print(len(a))

Submission status: Runtime Error

Solution code:
N = raw_input()
N = int(N)

a = []
for i in range(N):
	s_input = input()
	s_input = int(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)

print(len(a))

Submission status: Runtime Error

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

a = []
for i in range(N):
	s_input = raw_input()
	s_input = int(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)

print(len(a))

Submission status: Runtime Error

Solution code:
N = raw_input()
N = int(N)

a = []
for i in range(N):
	s_input = raw_input()
	s_input = long(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)

print(len(a))

Submission status: Runtime Error

Solution code:
N = raw_input()
N = int(N)

a = []
for i in range(N):
	s_input = raw_input()
	s_input = int(s_input)
	if s_input in a:
		a.remove(s_input)
	else:
		a.append(s_input)
	a.sort()

print(len(a))

Submission status: Runtime Error

Solution code:
n = int(input())
fst = n % 10
snd = n / 10

if (fst == 9) || (snd == 9):
    print("Yes")
elif :
    print("No")

Submission status: Runtime Error

Solution code:
p = input()
if p % 10 == 9:
  print ("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
str=list(input())
if str[0]=='9' || str[1]=='9':
  print('yes')
else:
  print('no')

Submission status: Runtime Error

Solution code:
N = int(input())
a = [int(input()) for i in range(N)]
n = N
for i in range(N-1):
	j = i + 1
	while j <= N-1:
		if a[i] != a[j]:
			j += 1
		else:
			n -= 2
			break		
print(n)

Submission status: Runtime Error

Solution code:
a = int(input())
b = a // 10
c = a % 10

if b == 9 or c == 9
 print("yes")
 else
  print("no")

Submission status: Runtime Error

Solution code:
a = int(input())
b = a // 10
c= a % 10

if b == 9 or c == 9
 print("Yes")
 else
  print("No")

Submission status: Runtime Error

Solution code:
import numpy as np
N=input()
x=[]
dict={}
for i in range(N):
    a=raw_input()
    if a in dict:
        dict[a]+=1
    else:
        dict[a]=1

print np.sum(np.array(dict.values())%2)

Submission status: Runtime Error

Solution code:
from itertools import permutations

N, M, R = map(int, input().split())
r = map(int, input().split())
 
INF = float("inf")
d = [[INF] * (N + 1) for _ in range(N + 1)]
for n in range(1, N + 1):
    d[n][n] = 0

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a][b] = c
    d[b][a] = c

for k in range(1, N + 1):
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            if d[i][j] > d[i][k] + d[k][j]:
                d[i][j] = d[i][k] + d[k][j]

ans = INF
for p in permutations(r):
    cnt = 0
    for i in range(len(p) - 1):
        p1, p2 = p[i:i + 2]
        cnt += d[p1][p2]
    ans = min(cnt, ans)

print(ans)

Submission status: Runtime Error

Solution code:
from itertools import permutations
 
N,M,R = map(int, input().split())
r = list(map(int,input().split()))
 
dis = [[float('inf')]*(N+1) for _ in range(N+1)]
for i in range(1, N+1):
	dis[i][i] = 0
for i in range(M):
    Ai, Bi, Ci = map(int, input().split())
    if dis[Ai][Bi] > Ci:
        dis[Ai][Bi] = Ci
        dis[Bi][Ai] = Ci
for k in range(1, N+1):    # Warshall-Floyd
    for i in range(1, N+1):
        for j in range(i, N+1):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]
 
ans = float('inf')
for p in permutations(r):
    cnt = 0
    for i in range(len(p)-1):
        cnt += dis[p[i]][p[i+1]]
    ans = min(ans, cnt)
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import permutations
 
N,M,R = map(int, input().split())
r = list(map(int,input().split()))
 
dis = [[float('inf')]*(N+1) for _ in range(N+1)]
for i in range(N+1):
	dis[i][i] = 0
for i in range(M):
    Ai, Bi, Ci = map(int, input().split())
    if dis[Ai][Bi] > Ci:
        dis[Ai][Bi] = Ci
        dis[Bi][Ai] = Ci
for k in range(1, N+1):    # Warshall-Floyd
    for i in range(1, N+1):
        for j in range(i, N+1):
            if dis[i][j] > dis[i][k] + dis[k][j]:
                dis[i][j] = dis[i][k] + dis[k][j]
 
ans = float('inf')
for p in permutations(r):
    cnt = 0
    for i in range(len(p)-1):
        cnt += dis[p[i]][p[i+1]]
    ans = min(ans, cnt)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
list = []
for i in range(n):
    a = bay(input())
    if a in list:
        list.remove(a)
    else:
        list.append(a)
print(len(list))

Submission status: Runtime Error

Solution code:
n = int(input())
list = []
for i in range(n):
    a = str(input())
    if a in list:
        list.remove(a)
    else:
        list.append(a)
print(len(list))

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0
nums = set([])
for _ in range(N):
    A = int(input())
    if A in nums:
        ans -= 1
        nums.discard(A)
    else:
        ans += 1
        nums.add(A)
print(ans)

Submission status: Runtime Error

Solution code:
n,m,r=map(int,input().split())
r=list(map(int,input().split()))
cost=[[99999999 if i!=j else 0 for j in range(n)] for i in range(n)]
for _ in range(m):
    a,b,c=map(int,input().split())
    cost[a-1][b-1]=cost[b-1][a-1]=c
for k in range(n):
    for i in range(n):
        for j in range(n):
            cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j])
c=[[cost[y-1][x-1] for x in r] for y in r]
print(max(map(max,c)))

Submission status: Runtime Error

Solution code:
import sys
from itertools import permutations
 
def read_int_list():
    return list(map(int, input().split()))
 
 
def main():
    def floyd_warshall():
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    dd = d[i][k] + d[k][j]
                    if dd < d[i][j]:
                        d[i][j] = dd
 
    n, m, r = read_int_list()
    v = read_int_list()
    v = [x - 1 for x in v]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n):
        d[i][i] = 0
    for i in range(m):
        a, b, c = read_int_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
    floyd_warshall()
    res = float('inf')
    for p in permutations(v):
        s = 0
        for i in range(r - 1):
            s += d[p[i]][p[i + 1]]
        if s < res:
            res = s
    print(res)
 
 
main()

Submission status: Runtime Error

Solution code:
print("Yes" if 9 in input() else "No")

Submission status: Runtime Error

Solution code:
from scipy.sparse import*
(N,M,R),r,*t=[map(int,i.split())for i in __import__("sys").stdin]
a,b,c=zip(*t)
l=csgraph.dijkstra(csr_matrix((c,(a,b)),[N+1]*2),0)
print(min(sum(int(l[i][j])for i,j in zip(a[:-1],a[1:]))for a in __import__("itertools").permutations(r)))

Submission status: Runtime Error

Solution code:
n = int(input())
a = []
ans = 0
for i in range(n):
    a.append(int(input()))
set_a = set(a)
for i in set_a:
    ans += a.count(i) % 2
print(ans)

Submission status: Runtime Error

Solution code:
import itertools

N,M,R = map(int, input().split())
r = map(int, input().split())
l = [[1e9 for i in range(N+1)] for i in range(N+1)]

for i in range(M):
    a,b,c = map(int, input().split())
    l[a][b] = l[b][a] = c

for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            t = l[i][k] + l[k][j]
            if l[i][j] > t: l[i][j] = t

ans = 1e9
for a in itertools.permutations(r):
    s = 0
    for i,j in zip(a[:-1],a[1:]):
        s += l[i][j]
    if ans > s: ans = s

print(ans)

Submission status: Runtime Error

Solution code:
from collections import Counter

def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, m, r = read_line(int, int, int)

rs = [int(r) for r in input().split()]

cities = Counter()

routes = {}
costs = {}
for _ in range(m):
    a, b, c = read_line(int, int, int)

    cities[a] = 1
    cities[b] = 1

    if a in routes:
        routes[a][b] = c
    else:
        routes[a] = { b : c }

    if b in routes:
        routes[b][a] = c
    else:
        routes[b] = { a : c }

for a in cities.keys():
    for b in cities.keys():
        if a not in costs:
            costs[a] = {}
        if b not in costs[a]:
            if a in routes and b in routes[a]:
                costs[a][b] = routes[a][b]
            else:
                costs[a][b] = 100000 + 1

# print('*')

keys = list(cities.keys())

for k in keys:
    for i in keys:
        for j in keys:
            c = costs[a][k] + costs[k][b]
            if a != b and costs[a][b] > c:
                costs[a][b] = c

# print('*')

def cost(selected):
    c = 0
    for i in range(len(selected) - 1):
        a = selected[i]
        b = selected[i + 1]
        c += costs[a][b]
    return c

smallest = 100000 + 1

def f(selected, rest):
    global smallest
    if len(rest) == 0:
        c = cost(selected)
        if smallest > c:
            smallest = c
    else:
        for i in range(len(rest)):
            r = rest[i]
            rest_copy = rest[:]
            del rest_copy[i]
            if cost(selected + [r]) < smallest:
                f(selected + [r], rest_copy)

f([], keys)
print(smallest)

Submission status: Runtime Error

Solution code:
n = int(input())
arr = {}
for i in range(n):
    num = int(input())
    if num in arr:
        arr.remove(num)
    else:
        arr.add(num)
print(len(arr))

Submission status: Runtime Error

Solution code:
list = []
n = int(input())
for i in xrange(n):
    add = int(input())
    if(add in list):
        list.remove(add)
    else:
        list.append(add)
print(len(list))

Submission status: Runtime Error

Solution code:
A=int(input())
if 9 in A
print(Yes):
else(No):

Submission status: Runtime Error

Solution code:
n = int(input())
A = [int(input()) for i in range(n)]

b = list()
lenB = 0
for a in A:
    b.append(a)
    lenB += 1
    if len(set(b)) != lenB:
        b.pop(-1)
        b.remove(a)
        lenB -= 2
print(len(b))

Submission status: Runtime Error

Solution code:
list = [[]] * 100000
total = 0

x = input()

for i in range(0, int(x)):
    y = input()
    if int(y) in list[int(y) % 100000]:
        list[int(y) % 100000].remove(int(y))
        total -= 1
    else:
        list[int(y) % 100000].append(int(y))
        total += 1

print(total)

Submission status: Runtime Error

Solution code:
from itertools import permutations
N, M, R = [int(i) for i in input().split()]
r = [int(i) - 1 for i in input().split()]
V = N
# Define infinity as the large enough value. This value will be
# used for vertices not connected to each other
INF  = 10000000
 
graph = [[INF for i in range(N)] for j in range(N)]
 
for m in range(M):
    A, B, C  = [int(i) for i in input().split()]
    A = A - 1
    B = B - 1
    graph[A][B] = C
    graph[B][A] = C
 
# Solves all pair shortest path via Floyd Warshall Algrorithm
def floydWarshall(graph):
    dist = graph
    for k in range(V):
 
        # pick all vertices as source one by one
        for i in range(V):
 
            # Pick all vertices as destination for the
            # above picked source
            for j in range(V):
 
                # If vertex k is on the shortest path from 
                # i to j, then update the value of dist[i][j]
                dist[i][j] = min(dist[i][j] ,
                                  dist[i][k]+ dist[k][j]
                                )
    return(dist)
 
new_graph = floydWarshall(graph)
smallest_dist = INF
for sub_permute in permutations(r):
    tmp = 0
    for i in range(R-1):
        tmp += new_graph[sub_permute[i]][sub_permute[i+1]]
    smallest_dist = min(smallest_dist, tmp)
print(smallest_dist)