input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
N = int(eval(input())) A = [int(i)-1 for i in input().split()] ans = 0 for i,a in enumerate(A): if i == A[a] and i < a: ans += 1 print(ans)
N = int(eval(input())) A = [int(i) - 1 for i in input().split()] print((len([1 for i, a in enumerate(A) if i == A[a] and i < a])))
p03993
N = int(eval(input())) A = [int(i) for i in input().split()] arr = [[False for i in range(N)] for j in range(N)] cnt = 0 for ind, val in enumerate(A): arr[ind][val-1] = True if arr[val-1][ind] == True: cnt += 1 print(cnt)
N = int(eval(input())) A = [int(i) for i in input().split()] cnt = 0 for i, a in enumerate(A): if A[a-1]-1 == i: cnt += 1 print((cnt//2))
p03993
N = int(eval(input())) A = [int(e)-1 for e in input().split()] ad = [set() for _ in range(N)] for i, a in enumerate(A): ad[a].add(i) ans = 0 for i, a in enumerate(A): if a in ad[i]: ans += 1 print((ans//2))
N = int(eval(input())) A = [int(e)-1 for e in input().split()] ans = 0 for i, a in enumerate(A): if A[a] == i: ans += 1 ans //= 2 print(ans)
p03993
N = int(eval(input())) li = [int(i) for i in input().split()] # タプルを作って裏返したペアが存在するかどうか tupple = [] for i in range(N) : s = str(i+1) + ' ' + str(li[i]) tupple.append(s) c = 0 for tup in tupple : t = tup.split() needle = t[1] + ' ' + t[0] if needle in tupple : c += 1 print((...
N = int(eval(input())) li = [int(i) for i in input().split()] c = 0 for i in range(1,N+1) : # iを基準に行って帰ってこれればOK if (i == li[li[i-1]-1]) : c += 1 print((c//2))
p03993
a,p=list(map(int,input().split())) pye=int((a*3+p)/2) print(pye)
a,p=list(map(int,input().split())) print((int((a*3+p)/2)))
p03029
A, P = list(map(int, input().split())) P = A * 3 + P print((P // 2))
A, P = list(map(int, input().split())) print(((A * 3 + P) // 2))
p03029
a,p = list(map(int,input().split())) print(((3*a+p)//2))
a,b = list(map(int,input().split())) print(((3*a+b)//2))
p03029
import math i=list(map(int,input().split())) a=i[0]*3+i[1] print((math.floor(a/2)))
a,p=list(map(int,input().split())) print(((a*3+p)//2))
p03029
a,p = list(map(int, input().split())) n = 3*a ans = (n+p) // 2 print(ans)
a,p = list(map(int, input().split())) num =(3*a + p)//2 print(num)
p03029
A, P = list(map(int, input().split())) print(((A * 3 + P) // 2))
A, P = list(map(int, input().split())) P += A * 3 print((P // 2))
p03029
A,P = list(map(int,input().split())) print(((A*3+P)//2))
a, p = list(map(int, input().split())) print(((a * 3 + p) // 2))
p03029
A,P = list(map(int,input().split())) a=((P + A * 3) // 2) print(a)
A,P = list(map(int,input().split())) print(((P + A * 3) // 2))
p03029
#!usr/bin/env python3 from collections import defaultdict from collections import deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, ...
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline()...
p03029
A,P = list(map(int,input().split())) n = 3*A+P print((n//2))
A,P = list(map(int,input().split())) print(((3*A+P)//2))
p03029
A, P = list(map(int, input().split())) P += A * 3 pie = P // 2 print(pie)
def resolve(): a, p = list(map(int, input().split())) print(((a*3+p) // 2)) return if __name__ == "__main__": resolve()
p03029
A,P = list(map(int,input().split())) print(((3*A+P)//2))
print((eval(input().replace(" ","*3+"))//2))
p03029
A, P = list(map(int, input().split())) P += 3 * A print((P//2))
a,p=list(map(int,input().split())) print((int((3 * a + p) / 2)))
p03029
A, P = list(map(int, input().split())) x = (A * 3) + P if x >= 2: y = x / 2 else: y = 0 print((int(y)))
A, P = list(map(int, input().split())) x = A*3 + P print((x//2))
p03029
A,P = list(map(int,input().split())) P = P + A*3 print((P//2))
A,P = list(map(int,input().split())) P += A*3 print((P//2))
p03029
A, P = list(map(int, input().split())) print(((A * 3 + P) // 2))
a, p = list(map(int, input().split())) print(((a*3 + p) // 2))
p03029
#coding:utf-8 N,Q = list(map(int,input().split())) rank = [0 for i in range(N)] class Tree: def __init__(self,par,key): self.par = par self.key = key List = [Tree(i,i) for i in range(N)] for i in range(Q): com, x,y = list(map(int,input().split())) while type(x) != int or List[x...
#coding:utf-8 import time N,Q = list(map(int,input().split())) rank = [0 for i in range(N)] class Tree: def __init__(self,par,key): self.par = par self.key = key List = [Tree(i,i) for i in range(N)] for i in range(Q): com, x,y = list(map(int,input().split())) x1,y1 = x,y ...
p02343
#coding:utf-8 import time N,Q = list(map(int,input().split())) rank = [0 for i in range(N)] class Tree: def __init__(self,par,key): self.par = par self.key = key List = [Tree(i,i) for i in range(N)] for i in range(Q): com, x,y = list(map(int,input().split())) x1,y1 = x,y ...
#coding:utf-8 import time N,Q = list(map(int,input().split())) rank = [0 for i in range(N)] class Tree: def __init__(self,par,key): self.par = par self.key = key List = [Tree(i,i) for i in range(N)] def unit(x,y): while List[x].par != x: x = List[x].par a = rank[x...
p02343
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 12 0 1 4 0 2 3 1 1 2 1 3 4 1 1 4 1 3 2 0 1 3 1 2 4 1 3 0 0 0 4 1 0 2 1 3 0 output: 0 0 1 1 1 0 1 1 """ import sys class UnionFind(object): __slots__ = ('size', 'rank', 'p_list') def __init__(self, size): ...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 12 0 1 4 0 2 3 1 1 2 1 3 4 1 1 4 1 3 2 0 1 3 1 2 4 1 3 0 0 0 4 1 0 2 1 3 0 output: 0 0 1 1 1 0 1 1 """ import sys class UnionFind(object): __slots__ = ('size', 'rank', 'p_list') def __init__(self, size): ...
p02343
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 12 0 1 4 0 2 3 1 1 2 1 3 4 1 1 4 1 3 2 0 1 3 1 2 4 1 3 0 0 0 4 1 0 2 1 3 0 output: 0 0 1 1 1 0 1 1 """ import sys class UnionFind(object): __slots__ = ('size', 'tree_height_rank_list', 'ancestor_list') def...
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 12 0 1 4 0 2 3 1 1 2 1 3 4 1 1 4 1 3 2 0 1 3 1 2 4 1 3 0 0 0 4 1 0 2 1 3 0 output: 0 0 1 1 1 0 1 1 """ import sys class UnionFind(object): __slots__ = ('size', 'tree_height_rank_list', 'ancestor_list') def...
p02343
n, q = list(map(int, input().split())) s =[set([i]) for i in range(n)] p =[i for i in range(n)] for i in range(q): com, x, y = list(map(int, input().split())) if com: if y in s[p[x]]: print((1)) else: print((0)) else: s[p[x]] = s[p[x]] | s[p[y]] p_x_tmp = p[x] ...
def find(x): global s if s[x] == x: return x s[x] = find(s[x]) return s[x] n, q = list(map(int, input().split())) s =[i for i in range(n)] for i in range(q): com, x, y = list(map(int, input().split())) if com: if find(x) == find(y): print((1)) else: prin...
p02343
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = [[i] for i in range(n)] def unite(sets, v1, v2): s1 = None s2 = None for s in sets: if v1 in s and v2 in s: return None elif v1 in s: s1 = s elif v2 in s: ...
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = set([frozenset([i]) for i in range(n)]) def unite(sets, v1, v2): s1 = None s2 = None for s in sets: if v1 in s and v2 in s: return None elif v1 in s: s1 = s elif v...
p02343
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = set(frozenset([i]) for i in range(n)) def unite(sets, v1, v2): s1 = None s2 = None t_s = frozenset([v1, v2]) for s in sets: if t_s <= s: return None elif s1 and s2: br...
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = set([frozenset([i]) for i in range(n)]) def unite(sets, v1, v2): s1 = None s2 = None t_s = {v1, v2} for s in sets: if t_s <= s: return None elif v1 in s: s1 = s ...
p02343
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = set([frozenset([i]) for i in range(n)]) def unite(sets, v1, v2): s1 = None s2 = None t_s = {v1, v2} for s in sets: if t_s <= s: return None elif v1 in s: s1 = s ...
import sys f_i = sys.stdin n, q = list(map(int, f_i.readline().split())) S = set(frozenset([i]) for i in range(n)) def unite(sets, v1, v2): s1 = None s2 = None for s in sets: if v1 in s and v2 in s: return None elif v1 in s: s1 = s elif...
p02343
#! python3 # disjoint_set_union_find_tree.py n, q = [int(x) for x in input().split(' ')] sets = [set([i]) for i in range(n)] def unite(Sx, Sy): return Sx | Sy def search(x): global sets flag = False for i in range(len(sets)): if x in sets[i]: flag = True ...
#! python3 # disjoint_set_union_find_tree.py class UnionFindTree(): def __init__(self, n): self.par = [i for i in range(n+1)] self.rank = [0] * (n+1) def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) ...
p02343
n,m = list(map(int,input().split())) arr = [] for i in range(n): arr.append(i) def root(i): t = i while arr[t] != t: t = arr[t] return t for i in range(m): query,x,y = list(map(int,input().split())) if query == 0: arr[root(y)] = x else : print(1 if root(x) == root(y) else 0)
n,m = list(map(int,input().split())) arr = [] for i in range(n): arr.append(i) def root(i): t = i while arr[t] != t: t = arr[t] return t for i in range(m): query,x,y = list(map(int,input().split())) if query == 0: if root(y) == root(x): next else : arr[root(y)] = root(x) ...
p02343
from sys import stdin high = [0] * 10000 par = [i for i in range(10000)] def findSet(x): if par[x] == x: return x par[x] = findSet(par[x]) return par[x] def unite(x, y): x = findSet(x) y = findSet(y) if x == y: return if high[x] > high[y]: par[y] = x; else: par[x] = ...
from sys import stdin n, q = map(int, stdin.readline().split()) ans = [] ans_append = ans.append high = [0] * n par = [i for i in range(n)] def findSet(x): if par[x] == x: return x par[x] = findSet(par[x]) return par[x] def unite(x, y): x = findSet(x) y = findSet(y) if x == y: retur...
p02343
# encoding: "utf-8" class Unreachable(Exception): pass def main(): n, q = [int(x) for x in input().split()] setlist = list() for i in range(n): setlist.append({i}) for _ in range(q): run(setlist) def run(setlist): com, x, y = [int(x) for x in input().split()]...
# encoding: "utf-8" class Unreachable(Exception): pass def main(): n, q = [int(x) for x in input().split()] setlist = list() for i in range(n): setlist.append({i}) commands = list() for _ in range(q): com, x, y = [int(x) for x in input().split()] commands...
p02343
class DisjointSet(): def __init__(self): self.parent = None def ancestor(elems, x): s = elems[x] while s.parent is not None: s = s.parent return s def unite(elems, x, y): parent = DisjointSet() ancestor(elems, x).parent = parent ancestor(elems, y).parent = ...
class DisjointSet(): def __init__(self): self.parent = None def ancestor(elems, x): s = elems[x] while s.parent is not None: s = s.parent return s def unite(elems, x, y): ax = ancestor(elems, x) ay = ancestor(elems, y) if ax is not ay: parent = Dis...
p02343
from sys import stdin class DisjointSet(): def __init__(self): self.parent = None self.ancestor = self def ancestor(elems, x): s = elems[x].ancestor while s.parent is not None: s = s.parent elems[x].ancestor = s return s def unite(elems, x, y): ax ...
class DisjointSetElement(): def __init__(self): self.parent = None self.anc = self def ancestor(self): s = self.anc while s.parent is not None: s = s.parent self.anc = s return s def unite(self, y): ax = self.ancestor() ...
p02343
class DisjointSetElement(): def __init__(self): self.parent = None self.anc = self def ancestor(self): s = self.anc while s.parent is not None: s = s.parent self.anc = s return s def unite(self, y): ax = self.ancestor() ...
class DisjointSetElement(): def __init__(self, x): self.parent = x self.rank = 0 class DisjointSet(): def __init__(self, n): self.elems = [DisjointSetElement(n) for n in range(n)] def _find_set(self, x): if x != self.elems[x].parent: self.elems[x].p...
p02343
# coding=utf-8 def unite(sets, x, y): sx = [s for s in sets if x in s][0] sy = [s for s in sets if y in s][0] if sx == sy: return sets else: newSets = [] newSets.append(set.union(sx, sy)) newSets += [s for s in sets if x not in s and y not in s] retu...
# coding=utf-8 def unite(sets, x, y): sx = [s for s in sets if x in s][0] # print sx if y in sx: return sets else: newSets = [s for s in sets if x not in s and y not in s] sy = [s for s in sets if y in s][0] # print sy newSets.append(set.union(sx, sy...
p02343
#!/usr/bin/python3 class UnionFindTree: def __init__(self, x): self.parent = self self.id = x def find(self): if self.id == self.parent.id: return self else: return self.parent.find() # main n, q = list(map(int, input().split())) nodes ...
#!/usr/bin/python3 class UnionFindTree: def __init__(self, x): self.parent = self self.id = x self.rank = 0 def find(self): if self.id == self.parent.id: return self else: return self.parent.find() # main n, q = list(map(int, in...
p02343
# -*- coding: utf-8 -*- class DisjointSets: ''' Implementing disjoint sets using disjoint sets forests structure. --- methods --- __init__(size): size should be the number of elements in this disjoint sets unite(x, y): unite sets that contain x and y into a new set same(x, y): check if ...
# -*- coding: utf-8 -*- class DisjointSets: ''' Implementing disjoint sets using disjoint sets forests structure. --- methods --- __init__(size): size should be the number of elements in this disjoint sets unite(x, y): unite sets that contain x and y into a new set same(x, y): check if ...
p02343
#!/usr/bin/env python from sys import stdin def main(): n, q = (int(s) for s in stdin.readline().split()) s = [{i} for i in range(n)] for _ in range(q): com, x, y = (int(s) for s in stdin.readline().split()) if com: for si in s: if x in si and y i...
#!/usr/bin/env python from sys import stdin def main(): n, q = (int(s) for s in stdin.readline().split()) s = [{i} for i in range(n)] for _ in range(q): com, x, y = (int(s) for s in stdin.readline().split()) if com: if x in s[x] and y in s[x]: pri...
p02343
def main(): n,q = list(map(int,input().split())) ds = DisjointSet(n) for i in range(q): com,x,y = list(map(int,input().split())) if com: if ds.root[x] == ds.root[y]: print(1) else: print(0) else: ds.un...
def main(): n,q = list(map(int,input().split())) ds = DisjointSet(n) for i in range(q): com,x,y = list(map(int,input().split())) if com: ds.findSet(x) ds.findSet(y) if ds.parent[x] == ds.parent[y]: print(1) else: ...
p02343
n, q = list(map(int, input().split())) set_list = [{i} for i in range(n)] set_dict = list(range(n)) while q: op, x, y = list(map(int, input().split())) if op: print((1 if set_dict[x] == set_dict[y] else 0)) else: idx_x, idx_y = set_dict[x], set_dict[y] set_y = set_list[i...
def find(x): global set_list if set_list[x] == x: return x result = set_list[x] = find(set_list[x]) return result n, q = list(map(int, input().split())) set_list = list(range(n)) while q: op, x, y = list(map(int, input().split())) if op: print((1 if find(x) == fi...
p02343
def unite(x, y, s_list): x_list = None y_list = None for s in s_list: if x in s and y in s: x_list = s.copy() y_list = s.copy() del s elif x in s: x_list = s.copy() del s elif y in s: y_list = s.copy(...
def make_set(x, disjoint): disjoint[x] = x def find_set(x, disjoint): if x not in list(disjoint.keys()): make_set(x, disjoint) if x != disjoint[x]: disjoint[x] = find_set(disjoint[x], disjoint) return disjoint[x] def link(x, y, disjoint): disjoint[y] = x def unite(x, ...
p02343
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10000) N, Q = tuple(map(int, input().split())) tree = [[-1, 1] for _ in range(N)] # [next, rank] def find(i): if tree[i][0] == -1: group = i else: group = find(tree[i][0]) return group def unite(x, y): px =...
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10000) N, Q = tuple(map(int, input().split())) tree = [[-1, 1] for _ in range(N)] # [next, rank] def find(i): if tree[i][0] == -1: group = i else: group = find(tree[i][0]) tree[i][0] = group return group ...
p02343
class UnionFind: def __init__(self,n): self.parent = {} for i in range(n): self.parent[i] = i def get_root(self,x): r = x depth = 0 while self.parent[r]!=r: r = self.parent[r] depth += 1 return r,depth def un...
class UnionFind: def __init__(self,n): self.parent = {} for i in range(n): self.parent[i] = i def get_root(self,x): r = x depth = 0 path = [r] while self.parent[r]!=r: r = self.parent[r] path.append(r) ...
p02343
import sys def solve(): n, q = map(int, sys.stdin.readline().split()) uf = UnionFind(n) for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: uf.unite(x, y) else: print(1 if uf.same(x, y) else 0) class UnionFin...
import sys def solve(): n, q = map(int, sys.stdin.readline().split()) uf = UnionFind(n) for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: uf.unite(x, y) else: print(1 if uf.same(x, y) else 0) class UnionFind: ...
p02343
import sys def solve(): n, q = map(int, sys.stdin.readline().split()) uf = UnionFind(n) ans = [] for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: uf.unite(x, y) else: ans.append(1 if uf.is_same(x, y) else 0) ...
import sys def solve(): n, q = map(int, sys.stdin.readline().split()) ds = [[i] for i in range(n)] n2s = [i for i in range(n)] ans = [] for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: merge(ds, n2s, x, y) else: ...
p02343
import sys sys.setrecursionlimit(10**5) def solve(): n, q = map(int, sys.stdin.readline().split()) uf = UnionFind(n) ans = [] for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: uf.unite(x, y) else: ans.append...
import sys def solve(): n, q = map(int, sys.stdin.readline().split()) uf = UnionFind(n) ans = [] for lp in range(q): c, x, y = map(int, sys.stdin.readline().split()) if c == 0: uf.unite(x, y) else: ans.append(1 if uf.same(x, y) else 0) ...
p02343
A, B = list(map(int, input().split(' '))) def is_palindromic(n): sep_idx = len(n) // 2 if n[:sep_idx] == n[sep_idx+1:][::-1]: return True return False count = 0 for n in range(A, B+1): n_str = str(n) if is_palindromic(n_str): count += 1 print(count)
A, B = list(map(int, input().split(' '))) def is_palindromic(n): s, t = n % 10, (n // 10000) % 10 u, v = (n // 10) % 10, (n // 1000) % 10 if s == t and u == v: return True return False count = 0 for n in range(A, B+1): if is_palindromic(n): count += 1 print(count)
p03416
A, B = list(map(int, input().split())) print((len([1 for i in range(A,B+1) if str(i)[0:]==str(i)[::-1]])))
a,b=list(map(int,input().split()));count=0 for i in range(a,b+1): c=str(i) if c==c[::-1]: count+=1 print(count)
p03416
import sys def input(): return sys.stdin.readline().rstrip() if __name__ == "__main__": a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]: count += 1 print(count)
import sys def input(): return sys.stdin.readline().rstrip() if __name__ == "__main__": a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): s = str(i) if s[0] == s[-1] and s[1] == s[-2]: count += 1 print(count)
p03416
a, b = list(map(int, input().split())) ans = 0 for i in range(a,b+1): if str(i) == str(i)[::-1]: ans += 1 print(ans)
a, b = list(map(int, input().split())) ans = 0 for i in range(1,10): for j in range(0,10): for k in range(0,10): x = 10000*i + 1000*j + 100*k + 10*j + i if a <= x <= b: ans += 1 print(ans)
p03416
a,b = list(map(int,input().split())) c = 0 f = 1 for i in range(a,b+1): if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]: c += 1 print(c)
a,b = list(map(int,input().split())) c = 0 for i in range(a,b+1): if str(i) == str(i)[::-1]: c += 1 print(c)
p03416
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = sum(1 for i in range(A, B+1) if str(i)==str(i)[::-1]) print(ans)
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): i = str(i) if i == i[::-1]: ans += 1 print(ans)
p03416
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): i = str(i) if i == i[::-1]: ans += 1 print(ans)
# coding: utf-8 import sys input = sys.stdin.readline A, B = list(map(int, input().split())) ans = 0 for i in range(1, 10): for j in range(10): for k in range(10): val = 10000*i + 1000*j + 100*k + 10*j + i if A <= val <= B: ans+=1 print(ans)
p03416
def main(): a, b = list(map(int,input().split())) r = 0 for i in range(a, b + 1): r += str(i) == str(i)[::-1] print(r) if __name__ == '__main__': main()
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): a, b = list(map(int, input().split())) r = 0 for i1 in range(a, b + 1): stri1 = str(i1) r += stri1 == stri1[::-1] print(r) if __name__ == '__main__': main()
p03416
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): a, b = list(map(int, input().split())) r = 0 for i1 in range(a, b + 1): stri1 = str(i1) r += stri1 == stri1[::-1] print(r) if __name__ == '__main__': main()
import sys read = sys.stdin.read readlines = sys.stdin.readlines def main(): a, b = list(map(int, input().split())) r = 0 for i1 in range(a, b + 1): c1 = i1 // 10000 == i1 % 10 c2 = ((i1 // 1000) % 10) == ((i1//10)%10) r += c1 and c2 print(r) if __name__ == '__main__...
p03416
a,b = list(map(int, input().split())) c = 0 for i in range(a, b+1): s = str(i) sr = "".join(list(reversed(s))) if s== sr: c+=1 print(c)
a,b = list(map(int, input().split())) res = 0 for i in range(a, b + 1): s1 = str(i) s2 = s1[::-1] if s1 == s2: res += 1 print(res)
p03416
N = {} #10000以上key以下の回文数の個数 cnt = 0 for i in range(10000, 100000): L = list(str(i)) if L == list(reversed(L)): cnt += 1 N[i] = cnt A, B = list(map(int, input().split())) print((N[B]-N[A-1] if A > 10000 else N[B]))
A, B =list(map(int, input().split())) num_palin = [0] * (B+1) for i in range(1,B+1): if str(i) == str(i)[::-1]: num_palin[i] = num_palin[i-1] + 1 else: num_palin[i] = num_palin[i-1] print((num_palin[B]-num_palin[A-1]))
p03416
# ABC090B - Palindromic Numbers a, b = list(map(int, input().rstrip().split())) count = 0 for i in range(a, b + 1): lst = list(map(int, list(str(i)))) if lst[0] == lst[4] and lst[1] == lst[3]: count += 1 print(count)
# ABC090B - Palindromic Numbers def main(): a, b = list(map(int, input().rstrip().split())) cnt = 0 for i in range(a, b + 1): s = str(i) if s == s[::-1]: cnt += 1 print(cnt) if __name__ == "__main__": main()
p03416
a,b = list(map(int,input().split())) count = 0 for i in range(b-a+1): if str(a+i) == str(a+i)[::-1]: count += 1 print(count)
a,b=list(map(int,input().split())) ans=0 for i in range(a,b+1): if i==int(str(i)[::-1]): ans+=1 print(ans)
p03416
a,b=list(map(int, input().split())) cnt=0 for i in range(a,b+1): n=list(str(i)) if n==list(reversed(n)): cnt+=1 print(cnt)
from sys import stdin nii=lambda:list(map(int,stdin.readline().split())) lnii=lambda:list(map(int,stdin.readline().split())) a,b=nii() ans=0 for i in range(a,b+1): s=str(i) if s==s[::-1]: ans+=1 print(ans)
p03416
a, b = list(map(int, input().split())) total = 0 for i in range(a, b+1): if i == int(str(i)[::-1]): total += 1 print(total)
a, b = list(map(int, input().split())) total = 0 for i in range(a, b+1): if (i%10 == i//10000%10) and (i//10%10 == i//1000%10): total += 1 print(total)
p03416
A,B=list(map(int,input().split())) cnt = 0 for i in range(A,B+1): if str(i)[0] == str(i)[-1]: if str(i)[1] == str(i)[-2]: cnt += 1 print(cnt)
A,B=list(map(int,input().split())) cnt = 0 for i in range(A,B+1): if str(i) == str(i)[::-1]:cnt += 1 print(cnt)
p03416
A, B = list(map(int, input().split())) print((sum([1 for i in range(A, B + 1) if str(i) == str(i)[::-1]])))
A, B = list(map(int, input().split())) print((sum([1 for i in range(A, B + 1) if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]])))
p03416
a , b = input().split() a = int(a) b = int(b) count=0 for i in range(a,b+1): test = list(str(i)) if (test[0] == test[4]) and (test[1]==test[3]): count=count+1 print(count)
A,B=list(map(int,input().split())) ct=0 for i in range(A,B+1): s=str(i) if s==s[::-1]: ct+=1 print(ct)
p03416
a,b = list(map(int,input().split())) ans = 0 for i in range(a,b+1): s = list(str(i)) if s == s[::-1]: ans += 1 print(ans)
a,b=list(map(int,input().split())) print((sum(str(i)==str(i)[::-1] for i in range(a,b+1))))
p03416
A,B = (int(i) for i in input().split()) count = 0 for i in range(B-A+1): number = A+i charnum = str(number) if(charnum[0]==charnum[4] and charnum[1]==charnum[3]): count = count + 1 print(count)
A,B = (int(i) for i in input().split()) count = 0 for i in range(A,B+1): s = str(i) if s[0]==s[4] and s[1]==s[3]: count += 1 print(count)
p03416
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): target = str(i) if target == target[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): if i//10000 == (i//1) % 10 and (i//1000) % 10 == (i//10) % 10: count += 1 print(count)
p03416
a, b = list(map(int, input().split())) nums = [x for x in range(a, b+1) if str(x)[0] == str(x)[-1] and str(x)[1] == str(x)[-2]] print((len(nums)))
a, b = list(map(int, input().split())) nums = [] for i in range(a, b+1): str_i = str(i) if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]: nums.append(i) print((len(nums)))
p03416
A, B = list(map(int,input().split())) a = "" c = 0 for i in range(A, B+1): a = str(i) if a[0] == a[-1] and a[1] == a[-2]: c += 1 print(c)
A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): I = str(i) if I[0] == I[4] and I[1] == I[3]: ans += 1 print(ans)
p03416
A, B = list(map(int, input().split())) count = 0 for i in range(A, B+1): if(str(i) == str(i)[::-1]): count += 1 print(count)
A, B = list(map(int, input().split())) count = 0 for i in range(10): for j in range(10): for k in range(10): if(A <= 10000*i + 1000*j + 100*k + 10*j +i <= B): count += 1 print(count)
p03416
def test(): a,b = list(map(int,input().split())) count = 0 for i in range(a,b+1): j = list(map(int,list(str(i)))) if j[0] == j[4] and j[1] == j[3]: count += 1 print(count) if __name__ == "__main__": test()
def test(): a,b = list(map(int,input().split())) count = 0 for i in range(a,b+1): if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]: count += 1 print(count) if __name__ == "__main__": test()
p03416
a, b = list(map(int, input().split())) ans = 0 for i in range(a, b+1): if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]: ans += 1 print(ans)
a, b = list(map(int, input().split())) ans = 0 for i in range(a, b+1): s = str(i) if s[0] == s[4] and s[1] == s[3]: ans += 1 print(ans)
p03416
a, b = list(map(int, input().split())) count = 0 for i in range(a, b + 1): x = list(str(i)) y = x[::-1] if x == y: count += 1 print(count)
a, b = list(map(int, input().split())) count = 0 for i in range(a, b + 1): x = str(i) y = x[::-1] if x == y: count += 1 print(count)
p03416
A, B = list(map(int, input().split())) res = 0 for i in range(A, B+1): if str(i) == str(i)[::-1]: res += 1 print(res)
A, B = list(map(int, input().split())) res = 0 for i in range(10): for j in range(10): for k in range(10): cand = int(''.join([str(i), str(j), str(k), str(j), str(i)])) if A <= cand <= B: res += 1 print(res)
p03416
# Problem: # Python Try import sys # from collections import defaultdict # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): return list(map(int, sys.stdin.readline().split())) ...
# Problem: https://atcoder.jp/contests/abc090/tasks/abc090_b # Python 2nd Try import sys # from collections import defaultdict # import heapq,copy # from collections import deque def II(): return int(sys.stdin.readline()) def MI(): return list(map(int, sys.stdin.readline().split())) def LI(): retu...
p03416
A,B=list(map(int,input().split())) ans=0 for i in range(A,B+1): s=str(i) l=len(s) if all( s[j]==s[l-1-j] for j in range(l) ): ans+=1 print(ans)
A,B=list(map(int,input().split())) ans=0 for i in range(A,B+1): s=str(i) if all( s[j]==s[4-j] for j in range(3) ): ans+=1 print(ans)
p03416
def sumNum(num, sums): if num == 0: return sums sums += num % 10 num = num // 10 return sumNum(num, sums) A, B = [int(i) for i in input().rstrip().split(' ')] cnt = 0 for i in range(A, B+1): arr = [i for i in list(str(i))] if not arr[0] == arr[-1]: continue ...
A, B = [int(i) for i in input().rstrip().split(' ')] cnt = 0 for i in range(A, B+1): arr = [i for i in list(str(i))] if not arr[0] == arr[-1]: continue asc = ''.join(arr) desc = ''.join(list(reversed(arr))) if asc == desc: cnt += 1 print(cnt)
p03416
a,b=list(map(int,input().split())) count=0 for i in range(a,b+1): l1=list(str(i)) l2=l1[::-1] if l1==l2 : count+=1 print(count)
#n=int(input()) a,b=list(map(int,input().split())) #l=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] count=0 for i in range(a,b+1): istr=str(i) if istr[0]==istr[4] and istr[1]==istr[3]: count+=1 print(count)
p03416
a,b = list(map(int, input().split())) cnt = 0 for i in range(a,b+1): tmp = list(map(int,list(str(i)))) if tmp==list(reversed(tmp)): cnt+=1 print(cnt)
a,b = list(map(int, input().split())) cnt = 0 for i in range(a,b+1): tmp = list(str(i)) if tmp==list(reversed(tmp)): cnt+=1 print(cnt)
p03416
a,b = list(map(int,input().split())) cnt = 0 for i in range(a,b+1): i = list(str(i)) if i == i[::-1]: cnt += 1 print(cnt)
n,m = list(map(int,input().split())) cnt = 0 for i in range(n,m+1): s = str(i) if s == s[::-1]: cnt +=1 print(cnt)
p03416
# author: kagemeka # created: 2019-11-06 21:30:22(JST) import sys # import collections # import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator def main(): a, b = (int(x) for...
import sys from bisect import bisect_left as bi_l, bisect_right as bi_r a, b = list(map(int, sys.stdin.readline().split())) def main(): palindromic_nums = [] for i in range(1, 10): for j in range(10): for k in range(10): x = [i, j, k, j, i] palind...
p03416
import sys from bisect import bisect_left as bi_l, bisect_right as bi_r a, b = list(map(int, sys.stdin.readline().split())) def main(): palindromic_nums = [] for i in range(1, 10): for j in range(10): for k in range(10): x = [i, j, k, j, i] palind...
import sys def cnt(n): m = str(n) l = len(m) if l == 1: return n + 1 tot = 0 tot += pow(10, (l - 1) // 2) * (int(m[0]) - 1) tot += pow(10, l // 2) - 1 - 9 * pow(10, l // 2 - 1) * (l & 1 ^ 1) while l >= 2: l -= 2 if l == 0: tot += m[1] >= m[0] elif l == 1:...
p03416
A,B = list(map(int, input().split())) AB = list(range(A, B+1)) N = B-A+1 count = 0 for i in range(N): count += (1 if str(AB[i]) == str(AB[i])[::-1] else 0) print(count)
A,B = list(map(int, input().split())) count = 0 for i in range(A, B+1): count += (1 if str(i) == str(i)[::-1] else 0) print(count)
p03416
a, b = list(map(int, input().split())) count = 0 for i in range(a,b+1): b1 = i%10 s = i//10 b2 = s%10 t = s//10 u = t//10 a2 = u%10 v = u//10 a1 = v%10 if a1 == b1 and a2 == b2: count += 1 print(count)
A, B = list(map(int, input().split())) count = 0 for n in range(A, B+1): if n//10000 == n%10 and (n//1000)%10 == (n//10)%10: count += 1 print(count)
p03416
A, B = list(map(int, input().split())) cnt = 0 for i in range(A, B+1): l = list(str(i)) if l == list(reversed(l)): cnt += 1 print(cnt)
A, B = list(map(int, input().split())) cnt = 0 for i in range(A, B+1): l = str(i) if l == l[::-1]: cnt += 1 print(cnt)
p03416
# ABC 090: B – Palindromic Numbers a, b = [int(s) for s in input().split()] number_of_parindromics = 0 for i in range(a, b + 1): if str(i) == str(i)[::-1]: number_of_parindromics += 1 print(number_of_parindromics)
# ABC 090: B – Palindromic Numbers a, b = list(map(int, input().split())) nums = 0 for i in range(a, b + 1): i_str = str(i) nums = nums + 1 if i_str == i_str[::-1] else nums print(nums)
p03416
a, b = list(map(int, input().split())) cnt = 0 for i in range(a, b+1): i = str(i) if i[0] == i[-1] and i[1] == i[-2]: cnt += 1 print(cnt)
a, b = list(map(int, input().split())) cnt = 0 for i in range(10): for j in range(10): for k in range(10): c = 10000*i+1000*j+100*k+10*j+i if a <= c <= b: cnt += 1 print(cnt)
p03416
A,B = list(map(int,input().split())) n=0 for i in range(A,B+1): if i == int(str(i)[::-1]): n+=1 print(n)
A,B = list(map(int,input().split())) ans = 0 for i in range(A,B+1): s = str(i) if s == s[::-1]: ans += 1 print(ans)
p03416
a,b = list(map(int,input().split())) count = 0 for i in range(a,b+1): s = str(i) l = len(s) if all(s[j] == s[l-j-1] for j in range(l)): count += 1 print(count)
a,b = list(map(int,input().split())) count = 0 for i in range(a,b+1): s = str(i) if s == s[::-1]: count += 1 print(count)
p03416
a,b = list(map(int, input().split())) cnt = 0 itr = b - a for i in range(a,b+1): m = str(i) if m[0] == m[4] and m[1] == m[3]: cnt += 1 print(cnt)
a, b = list(map(int, input().split())) cnt = 0 for i in range(a, b+1): si = str(i) if si[0] == si[4] and si[1] == si[3]: cnt += 1 print(cnt)
p03416
a, b = list(map(int, input().split())) sum_n = 0 for i in range(a, b + 1): if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]: sum_n += 1 print(sum_n)
a, b = list(map(int, input().split())) sum_s = 0 for i in range(a, b + 1): s = str(i) if s[0] == s[-1] and s[1] == s[-2]: sum_s += 1 print(sum_s)
p03416
a,b = list(map(int,input().split())) c = 0 for i in range(a,b+1): new = list(reversed(list(str(i)))) if new == list(str(i)): c += 1 print(c)
a,b = list(map(int,input().split())) c = 0 for i in range(a,b+1): if list(str(i)) == list(str(i))[::-1]: c += 1 print(c)
p03416
a,b = list(map(int,input().split())) c = 0 for i in range(a,b+1): if list(str(i)) == list(str(i))[::-1]: c += 1 print(c)
a,b = list(map(int,input().split())) c = 0 for i in range(a,b+1): if str(i) == str(i)[::-1]: c += 1 print(c)
p03416
a,b = list(map(int,input().split())) ans = 0 for i in range(a,b+1): x = str(i) flag = 1 for j in range(len(x) // 2): if x[j] != x[-(j+1)]: flag = 0 ans += flag print(ans)
def is_palindrome(s): for i in range(len(s) // 2 + 1): if s[i] != s[-i-1]: return False return True a,b = list(map(int, input().split())) ans = 0 for i in range(a,b+1): if is_palindrome(str(i)): ans += 1 print(ans)
p03416
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): t_list = list(str(i)) if t_list[0] == t_list[4] and t_list[1] == t_list[3]: count += 1 print(count)
a, b = list(map(int, input().split())) c = 0 for i in range(a, b+1): s = str(i) t = s[4] + s[3] if s[0] + s[1] == t : c += 1 print(c)
p03416
a,b=list(map(int,input().split())) count=0 for i in range(a,b+1): if str(i)==str(i)[::-1]: count+=1 print(count)
a,b=list(map(int,input().split())) print((sum(i==i[::-1]for i in map(str,list(range(a,b+1))))))
p03416
a, b = list(map(int, input().split())) count = 0 for i in range(a, b+1): if str(i) == str(i)[::-1]: count += 1 print(count)
a, b = list(map(int, input().split())) ans = 0 for num in range(a, b+1): s = str(num) if s[0] == s[4] and s[1] == s[3]: ans += 1 print(ans)
p03416
A, B = list(map(int, input().split())) ans = 0 for i in range(A, B + 1): num = str(i) rev = num[::-1] if num == rev: ans += 1 print(ans)
A, B = list(map(int, input().split())) ans = 0 for n in range(A, B + 1): num = str(n) if num == num[::-1]: ans += 1 print(ans)
p03416
a, b = list(map(int, input().split())) tmp=str(a) c=0 for i in range(a,b+1): tmp=str(i) tmp2="" for s in range(len(tmp)): tmp2=tmp2+tmp[len(tmp)-1-s] if tmp==tmp2: c=c+1 print(c)
def main(): #1. input a, b = list(map(int, input().split())) ans = 0 #2. from A to B for i in range(a, b+1): #2.1. judge if the number is palindromic if (str(i)[0]==str(i)[4]) and (str(i)[1]==str(i)[3]): ans = ans+1 #3. output print(ans) if __...
p03416