Problem:


Score : 100 points

Problem Statement

You are given a three-digit positive integer N.

Determine whether N is a palindromic number.

Here, a palindromic number is an integer that reads the same backward as forward in decimal notation.

Constraints

100≤N≤999

N is an integer.

Input

Input is given from Standard Input in the following format:  

N

Output

If N is a palindromic number, print Yes; otherwise, print No.

Sample Input 1

575

Sample Output 1

Yes

N=575 is also 575 when read backward, so it is a palindromic number. You should print Yes.

Sample Input 2

123

Sample Output 2

No

N=123 becomes 321 when read backward, so it is not a palindromic number. You should print No.

Sample Input 3

812

Sample Output 3

No



Sample input:
575


Sample output:
Yes

Submission status: Runtime Error

Solution code:
#coding=UTF-8
#import math math.gcd was added in ver 3.5
import fractions

N=int(input())
ans=1
for idx in range(0,N,1):
    T=int(input())
    ans=ans*T// fractions.gcd(ans,T)

print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
if (N[0]==N[-1]):
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
N=input()
if (N[0]==N[-1]):
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
N=input()
if N[0]==N[-1]:
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
N=int (input())
if N[0]==N[-1]:
    print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
s = input()
a = len(s)
for i in s:
    if s[i] == s[a - 1 -i] :
        b = 1
    else:
        b = 0
        break


if b == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
sec = input().split(' ')
#sec = ['0','75','25','100']
#sec = ['0','33','66','99']
#print(sec[0],sec[1],sec[2],sec[3])
#開始時間選定
start = max(sec[0],sec[2])
#print('開始:' + start)
#終了時間選定
end = min(sec[1],sec[3])
#print('終了:' + end)
kekka =(int(end) - int(start))
if kekka < 1:
	kekka = 0
	print(kekka)
else:
	print(kekka)

Submission status: Runtime Error

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

print a, b, c, d

if a >= c:
    ans = b - c
else:
    ans = d - a

if ans < 0:
    print 0
else:
    print ans

Submission status: Runtime Error

Solution code:
a=input()
b=input()
c=input()
d=input()
fast=max(int(a),int(c))
last=min(int(b),int(d))
print max(0,int(last-fast))

Submission status: Runtime Error

Solution code:
a=input()
b=input()
c=input()
d=input()
if a<c:
    fast=c
else:
    fast=a
if b<d:
    last=b
else:
    last=d

if b<c:
    print("0")
else:
    print(last-fast)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
 
a = int(input())
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
    
N = int(input())
Ts = [None for i in range(N)]

a = int(input())
b = 0
for i in range(N-1):
    b = int(input())
    a = (a*b) // gcd(a,b)
    
print(a)

Submission status: Runtime Error

Solution code:



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

if(b<c):print (0)
elif(b==c):
    if(b == 0):print(0)
    else:print(1)
else:
    start = a if a>c else c
    end = b if b<d else d
    print(end - start)

Submission status: Runtime Error

Solution code:
import fractions

def lcm(a,b):
    g = fractions.gcd(a,b)
    return (a/g) * b

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(ans,t)

print(int(ans))

Submission status: Runtime Error

Solution code:
import sys
from scipy.sparse import*
f=lambda*z:map(int,sys.stdin.readline().split())
n,=f();a,b,c=zip(*map(f,[0]*~-n));q,k=f()
z=csgraph.dijkstra(csr_matrix((c,(a,b)),[n+1]*2),0,k)
for _ in range(q):x,y=f();print int(z[x]+z[y])

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if a<b:
     c=a
     a=b
     b=c
     
    c=a%b
    
    if c==0:
     return a
    else:
     return b
 
def lcm(a,b):
    c=gcd(a,b)
    return a/c*b
 
 
 
n=int(input())
t=[0]*n
 
for lop2 in range(n):
    t[lop2]=int(input())
 
ans=t[0]
 
for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if a<b:
     c=a
     a=b
     b=c
     
    c=a%b
    return b
 
def lcm(a,b):
    c=gcd(a,b)
    return a/c*b
 
 
 
n=int(input())
t=[0]*n
 
for lop2 in range(n):
    t[lop2]=int(input())
 
ans=t[0]
 
for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:

def gcd(a,b):
    if a<b:
        d=a
        a=b
        b=d
    c=a%b

    if c==0:
        return b
    else:
        return gcd(b,c)

def lcm(a,b):
    c=gcd(a,b)
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:

def gcd(a,b):
        return b


def lcm(a,b):
    c=gcd(a,b);
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:

def gcd(a,b):
            return b


def lcm(a,b):
    c=gcd(a,b);
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:

def gcd(a,b):
    if a<b:
        d=a;
        a=b;
        b=d;
    c=a%b

    if c==0:
        return b
    else:
        return gcd(b,c)

def lcm(a,b):
    c=gcd(a,b);
    return a/c*b

n=int(input())
t=[0]*n

for lop2 in range(n):
    t[lop2]=int(input())

ans=t[0]

for lop in range(1,n):
    ans=lcm(ans,t[lop])
print(int(ans))

Submission status: Runtime Error

Solution code:
n=input()
if n[0]==n[-1]:
  return 'Yes'
else:
  return 'No'

Submission status: Runtime Error

Solution code:
N = int(input())
T = [int(input()) for i in range(N)]

import fractions
def lcm(a, b):
    if gcd != 0:
        return (a * b) // gcd
    else:
        return 0

gcd = 1
x = 0

for i in range(N):
    for j in range(N):
        gcd = int(fractions.gcd(T[i] , T[j]))
        x = max(lcm(T[i], T[j]), x)

print(x)

Submission status: Runtime Error

Solution code:
n = int(input())

lcm = 0
gcd = 0

for i in range(n):
    t = int(input())
    if(i == 0):
        lcm, gcd = t, t
        continue
    lcm = t
    r = gcd % t
    while(r!=0):
        lcm = r
        r = t % r
    gcd *= t
    gcd //= lcm
print(gcd)

Submission status: Runtime Error

Solution code:
a=input()
b=.join(reversed(a));
if(a==b):
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
a=input()
b=reverse(a);
if a==b:
 print('Yes')
else:
 print('No')

Submission status: Runtime Error

Solution code:
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1
dmax = 10**14 + 1
depth = [dmax for _ in range(N+1)]
depth[K] = 0

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Submission status: Runtime Error

Solution code:

class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int,input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q,K = list(map(int,input().split()))
K = K - 1

depth = [-1] * N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to == p:
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for _ in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Submission status: Runtime Error

Solution code:
class edge():
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

N = int(input())
tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))
Q, K = list(map(int, input().split()))
K = K - 1

depth = [0]*N
def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)
DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Submission status: Runtime Error

Solution code:
N = int(input())

class edge:
    def __init__(self,_to,_cost):
        self.to = _to;
        self.cost = _cost;

tree = [[] for i in range(N)]

for i in range(N-1):
    a,b,c = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    tree[a].append(edge(b,c))
    tree[b].append(edge(a,c))

Q, K = list(map(int, input().split()))
K = K - 1
depth = [0]*N

def DFS(v,p,d):
    depth[v] = d
    for e in tree[v]:
        if e.to==p :
            continue
        DFS(e.to, v, d + e.cost)

DFS(K,-1,0)

for q in range(Q):
    x,y = list(map(int, input().split()))
    x = x - 1
    y = y - 1
    print(depth[x] + depth[y])

Submission status: Runtime Error

Solution code:
import sys
x = input()
d = {}
dist = {}
for i in range(1, x+1):
    d[i] = []
    dist[i] = 0
for i in range(x-1):
    num1, num2, num3 = map(int, sys.stdin.readline().split())
    d[num1].append((num2, num3))
    d[num2].append((num1, num3))

q, k = map(int, raw_input().split())
vis = set()
vis.add(k)
current = [k]
newnode = []
while True:
    for i in range(len(current)):
        for j in range(len(d[current[i]])):
            if d[current[i]][j][0] not in vis:
                dist[d[current[i]][j][0]] = dist[current[i]]+d[current[i]][j][1]
                vis.add(d[current[i]][j][0])
                newnode.append(d[current[i]][j][0])
    if len(newnode) == 0:
        break
    current = []
    current = newnode
    newnode = []

for i in range(q):
    num1, num2 = map(int, sys.stdin.readline().split())
    hold = 0
    hold1 =0
    print dist[num1] + dist[num2]

Submission status: Runtime Error

Solution code:
a=[int(d) for d in str(n)];
if b==a[-1:];
	return True
else: 
	return False

Submission status: Runtime Error

Solution code:
import sys


# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    inf = 10 ** 20
    n = read_int()
    adj = [[] for u in range(n)]
    for i in range(n - 1):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append((b, c))
        adj[b].append((a, c))

    q, k = read_int_list()
    k -= 1
    d = [inf for u in range(n)]

    d[k] = 0
    Q = [(k, -1)]
    while Q:
        u, parent = Q.pop(0)
        for v, w in adj[u]:
            if v == parent:
                continue
            d[v] = d[u] + w
        Q.extend([(v, u) for v, w in adj[u] if v != parent])

    res = [0] * q
    for i in range(q):
        x, y = map(int, input().split())
        res[i] = d[x-1] + d[y-1]
    print(*res, sep='\n')


main()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define  rep(i,n) for(li i=0;i<(n);i++)
#define  red(i,n) for(li i=(n)-1;i>=0;i--)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using vi = vector<li>;
using vs = vector<string>;


int main()
{
    char a,b;
    cin>>a>>b>>b;
    cout<<(a==b?"Yes\n":"No\n");    
    
    return 0;
}

Submission status: Runtime Error

Solution code:
n = list(input())
if n[0]==n[2]:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n = list(input())
if n[0]==n[2]:
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
def main():
    N = int(input().strip())
    res = int(input().strip())
    if N == 1:
        print(res)
        return
    for _ in range(1, N):
        t = int(input().strip())
        res = lcm(res, t)
    print(res)


def lcm(a, b):
    return (a * b) / gcd(a, b)


def gcd(a, b):
    if b == 0:
        return a
    if b == 1:
        return 1
    if b > a:
        return gcd(b, a)
    else:
        return gcd(b, a % b)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a*b // gcd(a, b)

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
print(reduce(lcm, T))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

def lcm(a, b):
    return int(a*b / gcd(a, b))

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))
print(reduce(lcm, T))

Submission status: Runtime Error

Solution code:
N = int(input())
g = {i: []for i in range(1, N+1)}    

cache = {}
def dfs(g,start,end):
    stack = [(start, [start], 0)]
    while stack:
        (v, path, length) = stack.pop()
        for next,l in g[v]:
            if next in path: continue
            if next == end:
                return length + l
            else:
                stack.append((next, path + [next], length + l))

for i in range(N-1):
    a, b, c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
Q, K = map(int,input().split())

for v in range(1,N+1):
    cache[v] = dfs(g,v,K)

for q in range(Q):
    x, y = map(int,input().split())
    print(cache[x] + cache[y])

Submission status: Runtime Error

Solution code:
import math as m
from functools import reduce
 
n=int(input())
l=[]
def f(a,b):
    return int(a*b/m.gcd(a,b))
for i in range(n):
    l.add(int(input()))
print(reduce(f,l))

Submission status: Runtime Error

Solution code:
# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
  	lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(len[-1])


nlcm(t)

Submission status: Runtime Error

Solution code:
a,_b=input()
if a==b:
  print("YES")
else:
  print("No")

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import sys
 
def main():
	n = int(input())
	vers = [list(map(int, input().split())) for _ in range(n - 1)]
	q, k = list(map(int, input().split()))
	queries = [list(map(int, input().split())) for _ in range(q)]
 
	#n = 10 ** 5
	#vers = [[i + 1, i + 2, 10 ** 9] for i in range(n - 1)]
 
	new_vers = mapping(n, vers)
	dist = calcMinDist(n, new_vers, k, queries)
	calcQueries(dist, queries, k)
	
def mapping(n, vers):
	new_vers = {i :[] for i in range(n)}
	for ver in vers:
		new_vers[ver[0] - 1].append((ver[1], ver[2]))
		new_vers[ver[1] - 1].append((ver[0], ver[2]))
	return new_vers
 
def calcMinDist(n, new_vers, k, queries):
	dist = [- 1 for _ in range(n)]
	flag = [False for _ in range(n)]
	dist[k - 1] = 0
	flag[k - 1] = True
	dfs(new_vers, dist, flag, k)
	return dist
 
def dfs(new_vers, dist, flag, frm):
	flag[frm - 1] = True
	vs = new_vers[frm - 1]
	for v in vs:
		if flag[v[0] - 1] == False:
			dist[v[0] - 1] = dist[frm - 1] + v[1]
			new_ver, dist, flag, _ = dfs(new_vers, dist, flag, v[0])
 
	return [new_vers, dist, flag, frm]
 
def calcQuery(dist, query, k):
	print(dist[query[0] - 1] + dist[query[1] - 1])
 
def calcQueries(dist, queries, k):
	for query in queries:
		calcQuery(dist, query, k)
 
if __name__ == '__main__':
	sys.setrecursionlimit(1000000)
	main()

Submission status: Runtime Error

Solution code:
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

return result

Submission status: Runtime Error

Solution code:
start = 0
end = len(N) - 1
result = True

while start < end: 
    if N[start] == N[end]: 
        start += 1
        end -= 1
    else:
        result = False
        break

return resul

Submission status: Runtime Error

Solution code:
a = input().split()
ast = int(a[0])
aen = int(a[1])
bst = int(a[2])
ben = int(a[3])
if ast > ben or bst > aen:
    print("0")
elif ast < bst and aen < ben:
    print(aen - bst)
elif ast < bst and aen > ben:
    print(ben - bst)
elif bst < ast and ben < aen:
    print(ben -ast)
elif bst < ast and ben > aen:
    print(aen - ast)
elif ast == bst and aen < ben:
    print(aen - ast)
elif ast == bst and aen > ben:
    print(ben - ast)
elif ast < bst and aen == ben:
    print(ben - bst)
elif ast > bst and aen == ben:
    print(aen - ast)
elif ast == bst and aen == ben:
    print(aen - ast)
else:
    print("0")

Submission status: Runtime Error

Solution code:
from fractions import gcd

def lcm(a, b):
  return a*b/gcd(a, b)

N = int(input())
T = list(int(input()) for i in range(N))
T = list(set(T))
T.sort()
a = lcm(T[0], T[1])
for i in T[2:]:
    a = lcm(a, i)
print(int(a))

Submission status: Runtime Error

Solution code:
a=input().split()
if(a[0]==a[2]):
 print("Yes")
else:
 print("No")

Submission status: Runtime Error

Solution code:
a=input().split
if(a[0]==a[2]):
 print("Yes")
else:
 print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

if c <= b:
  if b <= d:
    print(b - c)
  else:
    print(d - c)
else:
  print(0)

Submission status: Runtime Error

Solution code:
A,B,C,D = map(int, input().split())
if D<A or B<C: print("0")
elif A<C and D<B: print(D-C)
elif C<A and B<D: print(B-A)
elif D-A < B-C: print(D-A)
else: print(B-C)

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

if c <= b:
	print(b - c)
else:
	print(0)

Submission status: Runtime Error

Solution code:
A,B,C,D = map(int, input().split())
if D<A or B<C: print("0")
else if D-A < B-C: print(D-A)
else: print(B-C)

Submission status: Runtime Error

Solution code:
N = input()
if N[0] == N[2]: print(Yes)