_id
stringlengths
2
5
partition
stringclasses
2 values
text
stringlengths
5
289k
language
stringclasses
1 value
meta_information
dict
title
stringclasses
1 value
d8701
test
# Enter your code here. Read input from STDIN. Print output to STDOUT n=int(input()) for i in range(0,n): tmp_str=input() len_tmp_str=len(tmp_str) if(len_tmp_str!=10): ##print "LENGTH PROBLEM" print("NO") elif(tmp_str[0]!="7" and tmp_str[0]!="8" and tmp_str[0]!="9"): ##print "START PROBLEM" print("NO") else: check=1 for i in tmp_str: if(i>="0" and i<="9"): continue else: check=0 break if(check==1): print("YES") else: ##print "NUMBER PROBLEM" print("NO")
PYTHON
{ "starter_code": "\n# Enter your code here. Read input from STDIN. Print output to STDOUT", "url": "https://www.hackerrank.com/challenges/validating-the-phone-number/problem" }
d8702
test
# Enter your code here. Read input from STDIN. Print output to STDOUT m=int(input()) set_a_str_ar=input().strip().split() set_a_ar=list(map(int,set_a_str_ar)) n=int(input()) set_b_str_ar=input().strip().split() set_b_ar=list(map(int,set_b_str_ar)) set_a_set=set(set_a_ar) set_b_set=set(set_b_ar) set_a_dif_set=set_a_set.difference(set_b_set) set_b_dif_set=set_b_set.difference(set_a_set) res_set=set_a_dif_set.union(set_b_dif_set) res_ar=list(res_set) res_ar.sort() for i in res_ar: print(i)
PYTHON
{ "starter_code": "\n", "url": "https://www.hackerrank.com/challenges/symmetric-difference/problem" }
d8703
test
n = int(input()) col_list = list(input().split()) marks_col = col_list.index("MARKS") marks_list = [] for i in range(n): info_list = list(input().split()) marks_list.append(float(info_list[marks_col])) print((sum(marks_list)/n))
PYTHON
{ "starter_code": "\n# Enter your code here. Read input from STDIN. Print output to STDOUT", "url": "https://www.hackerrank.com/challenges/py-collections-namedtuple/problem" }
d8704
test
#!/bin/python3 import sys N = int(input().strip()) n= N w = 'Weird' nw = 'Not Weird' if n % 2 == 1: print(w) elif n % 2 == 0 and (n>=2 and n<5): print(nw) elif n % 2 == 0 and (n>=6 and n<=20): print(w) elif n % 2 == 0 and (n>20): print(nw)
PYTHON
{ "starter_code": "\n#!/bin/python3\n\nimport math\nimport os\nimport random\nimport re\nimport sys\n\n\n\nif __name__ == '__main__':\n n = int(input().strip())\n check = {True: \"Not Weird\", False: \"Weird\"}\n\n print(check[\n n%2==0 and (\n n in range(2,6) or \n n > 20)\n ])\n", "url": "https://www.hackerrank.com/challenges/py-if-else/problem" }
d8705
test
# Enter your code here. Read input from STDIN. Print output to STDOUT xml_str="" n=int(input()) for i in range(0,n): tmp_str=input() xml_str=xml_str+tmp_str cnt=xml_str.count("='") print(cnt)
PYTHON
{ "starter_code": "\nimport sys\nimport xml.etree.ElementTree as etree\n\ndef get_attr_number(node):\n # your code goes here\n\nif __name__ == '__main__':\n sys.stdin.readline()\n xml = sys.stdin.read()\n tree = etree.ElementTree(etree.fromstring(xml))\n root = tree.getroot()\n print(get_attr_number(root))", "url": "https://www.hackerrank.com/challenges/xml-1-find-the-score/problem" }
d8706
test
# Enter your code here. Read input from STDIN. Print output to STDOUT import math def custom_diff(a,b): res0 = a[0] - b[0] res1 = a[1] - b[1] res2 = a[2] - b[2] return [res0,res1,res2] def dot_product(a,b): return a[0]*b[0]+a[1]*b[1]+a[2]*b[2] def abs_val(a): tmp_val=a[0]*a[0]+a[1]*a[1]+a[2]*a[2] return math.sqrt(tmp_val) def cross(a, b): c = [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]] return c a_str_ar=input().strip().split() b_str_ar=input().strip().split() c_str_ar=input().strip().split() d_str_ar=input().strip().split() a=list(map(float,a_str_ar)) b=list(map(float,b_str_ar)) c=list(map(float,c_str_ar)) d=list(map(float,d_str_ar)) ab=custom_diff(b,a) bc=custom_diff(c,b) cd=custom_diff(d,c) x=cross(ab,bc) y=cross(bc,cd) cosphi_top=dot_product(x,y) cosphi_bottom=abs_val(x)*abs_val(y) cosphi=cosphi_top/cosphi_bottom res=math.degrees(math.acos(cosphi)) print(("%.2f" %res))
PYTHON
{ "starter_code": "\nimport math\n\nclass Points(object):\n def __init__(self, x, y, z):\n\n def __sub__(self, no):\n\n def dot(self, no):\n\n def cross(self, no):\n \n def absolute(self):\n return pow((self.x ** 2 + self.y ** 2 + self.z ** 2), 0.5)\n\nif __name__ == '__main__':\n points = list()\n for i in range(4):\n a = list(map(float, input().split()))\n points.append(a)\n\n a, b, c, d = Points(*points[0]), Points(*points[1]), Points(*points[2]), Points(*points[3])\n x = (b - a).cross(c - b)\n y = (c - b).cross(d - c)\n angle = math.acos(x.dot(y) / (x.absolute() * y.absolute()))\n\n print(\"%.2f\" % math.degrees(angle))", "url": "https://www.hackerrank.com/challenges/class-2-find-the-torsional-angle/problem" }
d8707
test
def is_vowel(letter): return letter in ['a', 'e', 'i', 'o', 'u', 'y'] def score_words(words): score = 0 for word in words: num_vowels = 0 for letter in word: if is_vowel(letter): num_vowels += 1 if num_vowels % 2 == 0: score += 2 else: score += 1 return score
PYTHON
{ "starter_code": "\ndef is_vowel(letter):\n return letter in ['a', 'e', 'i', 'o', 'u', 'y']\n\ndef score_words(words):\n score = 0\n for word in words:\n num_vowels = 0\n for letter in word:\n if is_vowel(letter):\n num_vowels += 1\n if num_vowels % 2 == 0:\n score += 2\n else:\n ++score\n return score\n\n\nn = int(input())\nwords = input().split()\nprint(score_words(words))", "url": "https://www.hackerrank.com/challenges/words-score/problem" }
d8708
test
# Enter your code here. Read input from STDIN. Print output to STDOUT import re def my_func(s): s = s.upper() ##res=re.match(r'^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$',s) res=re.search(r'^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$',s) if(s=="MMMM"): print("False") else: if res: print("True") else: print("False") my_func(input())
PYTHON
{ "starter_code": "\nregex_pattern = r\"\"\t# Do not delete 'r'.\n\nimport re\nprint(str(bool(re.match(regex_pattern, input()))))", "url": "https://www.hackerrank.com/challenges/validate-a-roman-number/problem" }
d8709
test
# Enter your code here. Read input from STDIN. Print output to STDOUT n=int(input()) ar=[] for i in range(0,n): tmp_str=input() tmp_str=tmp_str[len(tmp_str)-10:] ar.append(tmp_str) ar.sort() for i in range(0,len(ar)): print(("+91 "+ar[i][:5]+" "+ar[i][5:]))
PYTHON
{ "starter_code": "\ndef wrapper(f):\n def fun(l):\n # complete the function\n return fun\n\n@wrapper\ndef sort_phone(l):\n print(*sorted(l), sep='\\n')\n\nif __name__ == '__main__':\n l = [input() for _ in range(int(input()))]\n sort_phone(l) \n\n\n", "url": "https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem" }
d8710
test
# Enter your code here. Read input from STDIN. Print output to STDOUT n=int(input()) ar={} for i in range(0,n): s=input() ss=s.split(" ") n=ss[0] m1=float(ss[1]) m2=float(ss[2]) m3=float(ss[3]) m_avg=(m1+m2+m3)/3.0 ar[n]="%.2f" % m_avg s_name=input() print((ar[s_name]))
PYTHON
{ "starter_code": "\nif __name__ == '__main__':\n n = int(input())\n student_marks = {}\n for _ in range(n):\n name, *line = input().split()\n scores = list(map(float, line))\n student_marks[name] = scores\n query_name = input()", "url": "https://www.hackerrank.com/challenges/finding-the-percentage/problem" }
d8711
test
# Enter your code here. Read input from STDIN. Print output to STDOUT ar=[] n=int(input()) for i in range(0,n): str_ar=input().strip().split() user_name=str_ar[0]+" "+str_ar[1] user_age=int(str_ar[2]) user_sex=str_ar[3] user_new_name="" if(user_sex=="M"): user_new_name="Mr. "+user_name else: user_new_name="Ms. "+user_name ar.append([user_new_name,user_age]) l = sorted(ar, key=lambda tup: tup[1]) for i in range(0,n): print((l[i][0]))
PYTHON
{ "starter_code": "\nimport operator\n\ndef person_lister(f):\n def inner(people):\n # complete the function\n return inner\n\n@person_lister\ndef name_format(person):\n return (\"Mr. \" if person[3] == \"M\" else \"Ms. \") + person[0] + \" \" + person[1]\n\nif __name__ == '__main__':\n people = [input().split() for i in range(int(input()))]\n print(*name_format(people), sep='\\n')", "url": "https://www.hackerrank.com/challenges/decorators-2-name-directory/problem" }
d8712
test
# Enter your code here. Read input from STDIN. Print output to STDOUT x=int(input()) y=int(input()) z=int(input()) n=int(input()) print([ [i,j,k] for i in range(x+1) for j in range(y+1) for k in range(z+1) if i+j+k != n ])
PYTHON
{ "starter_code": "\nif __name__ == '__main__':\n x = int(input())\n y = int(input())\n z = int(input())\n n = int(input())", "url": "https://www.hackerrank.com/challenges/list-comprehensions/problem" }
d8713
test
# Enter your code here. Read input from STDIN. Print output to import math class ComplexNumber(object): def __init__(self, real, compl): self.real = real self.compl = compl pass def __str__(self): if (self.compl >= 0): return '{0:.2f}'.format(self.real) +'+'+ '{0:.2f}'.format(self.compl) +'i' return '{0:.2f}'.format(self.real) +'-'+ '{0:.2f}'.format(abs(self.compl)) +'i' def __add__(x, y): return ComplexNumber(x.real+y.real, x.compl+y.compl) def __sub__(x, y): return ComplexNumber(x.real-y.real, x.compl-y.compl) def __mul__(x, y): return ComplexNumber(x.real*y.real - x.compl*y.compl, x.compl*y.real + x.real*y.compl) def __truediv__(x, y): return ComplexNumber((x.real*y.real + x.compl*y.compl) / (y.real*y.real + y.compl*y.compl), (x.compl*y.real - x.real*y.compl) / (y.real*y.real + y.compl*y.compl)) def mod(self): return ComplexNumber(math.sqrt(self.real*self.real + self.compl*self.compl), 0) help = list(map(float, input().split(' '))) x = ComplexNumber(help[0], help[1]) help = list(map(float, input().split(' '))) y = ComplexNumber(help[0], help[1]) print(x+y) print(x-y) print(x*y) print(x/y) print(x.mod()) print(y.mod())
PYTHON
{ "starter_code": "\nimport math\n\nclass Complex(object):\n def __init__(self, real, imaginary):\n \n def __add__(self, no):\n \n def __sub__(self, no):\n \n def __mul__(self, no):\n\n def __truediv__(self, no):\n\n def mod(self):\n\n def __str__(self):\n if self.imaginary == 0:\n result = \"%.2f+0.00i\" % (self.real)\n elif self.real == 0:\n if self.imaginary >= 0:\n result = \"0.00+%.2fi\" % (self.imaginary)\n else:\n result = \"0.00-%.2fi\" % (abs(self.imaginary))\n elif self.imaginary > 0:\n result = \"%.2f+%.2fi\" % (self.real, self.imaginary)\n else:\n result = \"%.2f-%.2fi\" % (self.real, abs(self.imaginary))\n return result\n\nif __name__ == '__main__':\n c = map(float, input().split())\n d = map(float, input().split())\n x = Complex(*c)\n y = Complex(*d)\n print(*map(str, [x+y, x-y, x*y, x/y, x.mod(), y.mod()]), sep='\\n')", "url": "https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problem" }
d8714
test
q=str(input()) e=str(input()) a=len(q) b=len(e) c="" if a==b: for i in range(a): c+=q[i] c+=e[i] else: for i in range(b): c+=q[i] c+=e[i] c+=q[a-1] print(c)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc058/tasks/abc058_b" }
d8715
test
from collections import deque S = input() ans = deque([]) for s in S: if s=="B": if ans: ans.pop() else: ans.append(s) print("".join(ans))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc043/tasks/abc043_b" }
d8716
test
N = int(input()) A = list(map(int,input().split())) T = 0 for i in range(len(A)-1): if (A[i] > A[i + 1]): T += A[i] - A[i +1] A[i+1] = A[i] print(T)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc176/tasks/abc176_c" }
d8717
test
A = input() B = input() C = input() turn = 'a' while True: if turn == 'a': if len(A) == 0: print('A') break turn = A[0] A = A[1:] elif turn == 'b': if len(B) == 0: print('B') break turn = B[0] B = B[1:] else: if len(C) == 0: print('C') break turn = C[0] C = C[1:]
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc045/tasks/abc045_b" }
d8718
test
haiku = list(map(int, input().split())) if haiku == [5, 5, 7] or haiku == [5, 7, 5] or haiku == [7, 5, 5]: print("YES") else: print("NO")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc042/tasks/abc042_a" }
d8719
test
n=int(input()) a,b=2,1 for i in range(n): nxt=a+b a,b=b,nxt print(a)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc079/tasks/abc079_b" }
d8720
test
a = int(input()) b = int(input()) h = int(input()) s = (a+b)*h/2 print(int(s))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc045/tasks/abc045_a" }
d8721
test
(N), *D = [list(map(int, s.split())) for s in open(0)] V = D[0] A = V.pop(N[0]-1) M = 1000000000 + 7 R=0 for value in reversed(V): R = R + ((A) * value) % M A = A + value print(R % M)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc177/tasks/abc177_c" }
d8722
test
rgb = list(map(int, input().split())) l = ''.join(str(n) for n in rgb) if int(l)%4 == 0: print('YES') else: print('NO')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc064/tasks/abc064_a" }
d8723
test
a,b,c=list(map(int,input().split())) k=int(input()) x=max(a,b,c) print(((a+b+c)-x+x*(2**k)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc096/tasks/abc096_b" }
d8724
test
import sys import string w = input() a_z = string.ascii_letters for i in a_z: if w.count(i) & 1: print('No') return print('Yes')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc044/tasks/abc044_b" }
d8725
test
n, k = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort() num_sum = 0 for a, b in ab: num_sum += b if num_sum >= k: print(a) return
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc061/tasks/abc061_c" }
d8726
test
n,k=map(int,input().split()) print(k*(k-1)**(n-1))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc046/tasks/abc046_b" }
d8727
test
k, n = map(int, input().split()) points = list(map(int, input().split())) dist = [] for i in range(n): if i != n-1: distance = points[i+1] - points[i] else: distance = points[0]+k - points[i] dist.append(distance) max = dist[0] for j in range(1, len(dist), 1): if max < dist[j]: max = dist[j] dist.remove(max) ans = 0 for k in dist: ans += k print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc160/tasks/abc160_c" }
d8728
test
a,b,c,d=map(int, input().split()) print(max(a*b,c*d))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc052/tasks/abc052_a" }
d8729
test
c = int(input()) r = ["AC", "WA", "TLE", "RE"] a = { i:0 for i in r} for i in range(c): s = input() a [s] += 1 for rr in r: print(rr + " x " + str(a[rr]))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc173/tasks/abc173_b" }
d8730
test
time=int(input()) Ans=48-time print(Ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc084/tasks/abc084_a" }
d8731
test
# A - Restricted # https://atcoder.jp/contests/abc063/tasks/abc063_a A, B = list(map(int, input().split())) result = A + B if result >= 10: print('error') else: print(result)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc063/tasks/abc063_a" }
d8732
test
N=int(input()) A=list(map(int, input().split())) print(max(A)-min(A))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc064/tasks/abc064_b" }
d8733
test
n1 = [1, 3, 5, 7, 8, 10, 12] n2 = [4, 6, 9, 11] a, b = list(map(int, input().split())) print(("Yes" if a in n1 and b in n1 or a in n2 and b in n2 else "No"))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc062/tasks/abc062_a" }
d8734
test
a, b = map(int, input().split()) if a*b %2 == 0: print("Even") else: print("Odd")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc086/tasks/abc086_a" }
d8735
test
n, m = [int(x) for x in input().split()] ans = min(n, m // 2) ans += (m - ans * 2) // 4 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc055/tasks/arc069_a" }
d8736
test
N = int(input()) T = [int(TN) for TN in input().split()] SumT = sum(T) M = int(input()) PX = [[] for TM in range(0,M)] for TM in range(0,M): PX[TM] = [int(TPX) for TPX in input().split()] for TM in range(0,M): print(SumT-T[PX[TM][0]-1]+PX[TM][1])
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc050/tasks/abc050_b" }
d8737
test
import itertools def cal(N, target_num, keta): answer = float('inf') for p in itertools.product(target_num, repeat=keta): temp = 0 for i, num in enumerate(p): temp += num * 10**i if temp >= N: answer = min(answer, temp) return answer def __starting_point(): N, K = map(int, input().split()) # N円の品物、K個の嫌いな数字 D = set(list(map(int, input().split()))) # 嫌いな数字のリスト base = set(range(10)) target_num = base - D keta = len(str(N)) answer = min(cal(N, target_num, keta), cal(N, target_num, keta+1)) print(answer) __starting_point()
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc042/tasks/arc058_a" }
d8738
test
N,M = map(int,input().split()) high = list(map(int,input().split())) ans = [0]*N cnt = 0 for i in range(M): a,b = map(int,input().split()) ans[a-1] = max(high[b-1],ans[a-1]) ans[b-1] = max(ans[b-1],high[a-1]) for j in range(N): if ans[j] < high[j]: cnt += 1 print(cnt)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc166/tasks/abc166_c" }
d8739
test
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**6) n = int(input()) k = int(input()) ans = 1 for i in range(n): if ans*2 <= (ans+k): ans *= 2 else: ans += k # print(ans) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc076/tasks/abc076_b" }
d8740
test
X=int(input()) print(1-X)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc178/tasks/abc178_a" }
d8741
test
import copy s=input() l=len(s) ans=0 if l==1: ans+=int(s) print(ans) else: for i in range(2**(l-1)): t=copy.deepcopy(s) f=[] ch=0 for j in range(l-1): if ((i>>j)&1): t=t[:j+1+ch]+'+'+t[j+1+ch:] ch+=1 if '+' in t: y=list(map(int,t.split('+'))) for u in y: ans+=u else: ans+=int(t) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc045/tasks/arc061_a" }
d8742
test
import sys import itertools sys.setrecursionlimit(10 ** 8) ini = lambda: int(sys.stdin.readline()) inl = lambda: [int(x) for x in sys.stdin.readline().split()] ins = lambda: sys.stdin.readline().rstrip() debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw)) N = ini() A = inl() def solve(): B = list(itertools.accumulate(A, initial=0)) s = 0 ans = 10 ** 12 for i in range(N - 1, 0, -1): s += A[i] ans = min(ans, abs(s - B[i])) return ans print(solve())
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc067/tasks/arc078_a" }
d8743
test
# 1食800円をN食食べた N = int( input() ) x = int( 800 * N ) # 15食食べるごとに200円もらえる y = N // 15 * 200 print( x - y )
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc055/tasks/abc055_a" }
d8744
test
cij = [list(input()) for _ in range(3)] print(cij[0][0] + cij[1][1] + cij[2][2])
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc090/tasks/abc090_a" }
d8745
test
s=input() count=0 for i in range(len(s)): if(s[i]=="1"): count+=1 print(count)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc081/tasks/abc081_a" }
d8746
test
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if K < N: ans = K*X + (N-K)*Y else: ans = N*X print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc044/tasks/abc044_a" }
d8747
test
a, o, b = input().split() if o == '+': print((int(a) + int(b))) else: print((int(a) - int(b)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc050/tasks/abc050_a" }
d8748
test
x = int(input()) if x < 1200: print('ABC') else: print('ARC')
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc053/tasks/abc053_a" }
d8749
test
# A - ringring # https://atcoder.jp/contests/abc066/tasks/abc066_a a = list(map(int, input().split())) a.sort() print((a[0] + a[1]))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc066/tasks/abc066_a" }
d8750
test
H, W = map(int, input().split()) s = '#' * (W + 2) data = [] data.append(s) for i in range(H): data.append('#' + str(input()) + '#') data.append(s) for i in range(H + 2): print(data[i])
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc062/tasks/abc062_b" }
d8751
test
N = int(input()) S = input() res = 0 tmp = 0 for s in S: if s == 'I': tmp += 1 elif s == 'D': tmp -= 1 res = max(res, tmp) print(res)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc052/tasks/abc052_b" }
d8752
test
a,b = map(int,input().split()) ans = 0 for i in range(a,b+1): c = str(i) l = len(c) d = l // 2 cnt = 0 for i in range(d): if c[i] == c[-i-1]: cnt += 1 if cnt == d: ans += 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc090/tasks/abc090_b" }
d8753
test
a=list(map(int,input().split())) print(len(set(a)))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc046/tasks/abc046_a" }
d8754
test
N,K=map(int,input().split()) l=list(map(int,input().split())) l.sort(reverse=True) sum=0 for i in range(K) : sum+=l[i] print(sum)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc067/tasks/abc067_b" }
d8755
test
x, a, b = (int(x) for x in input().split()) if abs(a-x) < abs(b-x): print("A") else: print("B")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc071/tasks/abc071_a" }
d8756
test
s=input() print("2018"+s[4:])
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc085/tasks/abc085_a" }
d8757
test
# ひっくりかえすのかとお保ったら180度反転だった n = int(input()) d = [] for _ in range(n): s = list(input()) d.append(s) d = sorted(d, key=lambda dd: len(dd), reverse=True) base = {} for c in d[0]: if c not in base: base[c] = 1 else: base[c] += 1 for s in d[1:]: tmp = {} for c in s: if c not in tmp: tmp[c] = 1 else: tmp[c] += 1 for k, v in base.items(): if k in tmp and base[k] >= 1: base[k] = min(base[k], tmp[k]) else: base[k] = -1 ans = [] for k, v in base.items(): if v > 0: ans.append(k * v) ans = sorted(ans) ans = "".join(ans) print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc058/tasks/arc071_a" }
d8758
test
N = int(input()) ans = 0 for _ in range(N): a, b = map(int, input().split()) ans += b - a + 1 print(ans)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc073/tasks/abc073_b" }
d8759
test
a, b = map(int, input().split()) print((a - 1) * (b - 1))
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc069/tasks/abc069_a" }
d8760
test
A, B = map(int, input().split()) C = A + B print("Possible" if A%3==0 or B%3==0 or C%3==0 else "Impossible")
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc067/tasks/abc067_a" }
d8761
test
# -*- coding: utf-8 -*- """ Created on Mon Sep 28 02:20:36 2020 @author: liang """ S = input() T = input() S = S[::-1] T = T[::-1] res = list() for i in range(len(S)-len(T)+1): flag = True for j in range(len(T)): if S[i+j] == "?" or S[i+j] == T[j]: continue else: flag = False if flag == True: ans = "" for k in range(len(S)): if i <= k <= i + len(T)-1: #print(T[k-i]) ans += T[k-i] elif S[k] != "?": #print("B") ans += S[k] else: #print("C") ans += "a" ans = ans[::-1] res.append(ans) if res: res.sort() print((res[0])) else: print("UNRESTORABLE") #print(S) #print(T)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc076/tasks/abc076_c" }
d8762
test
# 現在と目標のレーティングを取得 R = int(input()) G = int(input()) # 目標のレーティングになるためのパフォーマンスの数値を計算 Target = (G * 2) - R # 計算結果を出力 print(Target)
PYTHON
{ "starter_code": "", "url": "https://atcoder.jp/contests/abc076/tasks/abc076_a" }
d8763
test
# !/usr/bin/env python3 # coding: UTF-8 # Modified: <23/Jan/2019 08:06:42 PM> # ✪ H4WK3yE乡 # Mohd. Farhan Tahir # Indian Institute Of Information Technology (IIIT),Gwalior # Question Link # # # ///==========Libraries, Constants and Functions=============/// import sys inf = float("inf") mod = 1000000007 def get_array(): return list(map(int, sys.stdin.readline().split())) def get_ints(): return list(map(int, sys.stdin.readline().split())) def input(): return sys.stdin.readline() # ///==========MAIN=============/// def main(): for tc in range(int(input())): l1, r1, l2, r2 = get_ints() if l1 != l2: print(l1, l2) else: print(l1, r2) def __starting_point(): main() __starting_point()
PYTHON
{ "starter_code": "", "url": "https://codeforces.com/problemset/problem/1108/A" }
d8764
test
class Solution: def hasCycle(self, head: ListNode) -> bool: if head == None: return False slow = head fast = head.next while slow != fast: if fast is None or fast.next is None: return False slow = slow.next fast = fast.next.next return True
PYTHON
{ "starter_code": "\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, x):\n# self.val = x\n# self.next = None\nclass Solution:\n def hasCycle(self, head: ListNode) -> bool:\n ", "url": "https://leetcode.com/problems/linked-list-cycle/" }
d8765
test
class Solution: def twoSum(self, nums, target): tmp = {} for i in range(len(nums)): if target - nums[i] in tmp: return(tmp[target - nums[i]], i) else: tmp[nums[i]] = i; """ :type nums: List[int] :type target: int :rtype: List[int] """
PYTHON
{ "starter_code": "\nclass Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n ", "url": "https://leetcode.com/problems/two-sum/" }