problem_id stringlengths 32 32 | name stringclasses 1
value | problem stringlengths 200 14k | solutions stringlengths 12 1.12M | test_cases stringlengths 37 74M | difficulty stringclasses 3
values | language stringclasses 1
value | source stringclasses 7
values | num_solutions int64 12 1.12M | starter_code stringlengths 0 956 |
|---|---|---|---|---|---|---|---|---|---|
8d3642fad65f4101184f326de35b3c9c | UNKNOWN | Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$.
In one minute each friend independently from other friends can change the position $x$ b... | ["t=int(input())\nfor nt in range(t):\n\ta,b,c=map(int,input().split())\n\tprint (max(0,abs(a-b)+abs(b-c)+abs(a-c)-4))", "for _ in range(int(input())):\n a,b,c = map(int, input().split())\n pd = abs(a-b) + abs(b-c) + abs(a-c)\n for x in range(-1, 2):\n for y in range(-1, 2):\n for z in range(... | {
"inputs": [
"8\n3 3 4\n10 20 30\n5 5 5\n2 4 3\n1 1000000000 1000000000\n1 1000000000 999999999\n3 2 5\n3 2 6\n",
"5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n10 5 8\n"
],
"outputs": [
"0\n36\n0\n0\n1999999994\n1999999994\n2\n4\n",
"0\n0\n0\n0\n6\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 5,117 | |
1ec1e0788af83ef027d08b960186e4d3 | UNKNOWN | We call two numbers $x$ and $y$ similar if they have the same parity (the same remainder when divided by $2$), or if $|x-y|=1$. For example, in each of the pairs $(2, 6)$, $(4, 3)$, $(11, 7)$, the numbers are similar to each other, and in the pairs $(1, 4)$, $(3, 12)$, they are not.
You are given an array $a$ of $n$ (... | ["def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n = read_int()\n a = list(read_ints())\n cnt = [0 for i in range(101)]\n even = 0\n for ai in a:\n cnt[ai] += 1\n if ai % 2 == 0:\... | {
"inputs": [
"7\n4\n11 14 16 12\n2\n1 8\n4\n1 1 1 1\n4\n1 2 5 6\n2\n12 13\n6\n1 6 3 10 5 8\n6\n1 12 3 10 5 8\n",
"1\n4\n1 1 1 8\n"
],
"outputs": [
"YES\nNO\nYES\nYES\nYES\nYES\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,310 | |
7fbc8ef6cd836648798855246dd144d6 | UNKNOWN | The only difference between easy and hard versions is the maximum value of $n$.
You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$.
The positive integer is called good if it can be represented as a sum of distinct powers ... | ["for _ in range(int(input())):\n\tn = int(input())\n\n\tbits = ['1']\n\twhile int(''.join(bits), 3) < n:\n\t\tbits.append('1')\n\t\n\t\n\tfor i in range(len(bits)):\n\t\tbits[i] = '0'\n\t\tif int(''.join(bits), 3) < n:\n\t\t\tbits[i] = '1'\n\t\n\tprint(int(''.join(bits), 3))\n", "def base3(n):\n # 17 -> [2, 2, 1] (... | {
"inputs": [
"7\n1\n2\n6\n13\n14\n3620\n10000\n",
"100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66... | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,317 | |
2ac86388e18689790b16a92ed5a76e54 | UNKNOWN | The only difference between easy and hard versions is constraints.
There are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i = p_i$ the kid will give his book to himself). It is guaranteed that all values of $p_i$ are distinct... | ["for _ in range(int(input())):\n n = int(input())\n P = list(map(int, input().split()))\n ans = [0] * n\n for i in range(n):\n if ans[i] == 0:\n now = i\n cnt = 0\n cll = []\n while True:\n now = P[now] - 1\n cnt += 1\n ... | {
"inputs": [
"6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3\n",
"20\n6\n3 6 4 2 5 1\n6\n2 4 1 3 5 6\n7\n5 2 1 4 6 7 3\n6\n3 6 4 2 5 1\n9\n5 8 2 6 4 7 9 1 3\n9\n3 2 6 8 5 7 9 1 4\n8\n8 4 6 5 2 1 7 3\n5\n3 1 2 5 4\n10\n2 4 3 5 6 10 7 9 1 8\n2\n2 1\n1\n1\n5\n3 2 5 4 1\n3\n1 3 2\n8\n2... | INTRODUCTORY | PYTHON3 | CODEFORCES | 16,876 | |
0abbf9f299da6eae4728cec91ca54089 | UNKNOWN | There are $n$ Christmas trees on an infinite number line. The $i$-th tree grows at the position $x_i$. All $x_i$ are guaranteed to be distinct.
Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all. Non-integer points cannot be occupied by anything.
There are $m$ people ... | ["from queue import deque\n\nn, m = map(int, input().split())\narr = list(map(int, input().split()))\narr.sort()\n\nused = set(arr)\nq = deque()\nfor i in range(n):\n q.append([arr[i] - 1, 1, -1])\n q.append([arr[i] + 1, 1, 1])\n\nret = []\ns = 0\nwhile m:\n x, l, dr = q.popleft()\n a = x + dr\n if not a... | {"inputs": ["2 6\n1 5\n", "3 5\n0 3 1\n"], "outputs": ["8\n2 3 -1 0 6 4 \n", "7\n5 2 4 -1 -2 \n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 13,279 | |
0ad4caae383a0f8401c643eec194e621 | UNKNOWN | You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$.
You have to answer $t$ independent test cases.
-----Input-----
The fir... | ["import sys\n\n\ndef read_int():\n return int(sys.stdin.readline())\n\n\ndef read_ints():\n return list(map(int, sys.stdin.readline().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n, s = read_ints()\n a = [0] + [int(i) for i in str(n)]\n ds = sum(a)\n cost = 0\n idx = len(a) - 1\n ... | {
"inputs": [
"5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1\n",
"1\n1000000000000000000 1\n"
],
"outputs": [
"8\n0\n500\n2128012501878\n899999999999999999\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 15,420 | |
d1e3099d0e229b8d899035f809865791 | UNKNOWN | There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.
In one move, you can choose some contiguous segment $[l; r]$ consisting of books (i.e. for each $i$... | ["for _ in range(int(input())):\n\tn=int(input())\n\ts=list(map(int,input().split()))\n\tl=s.index(1)\n\tr=n-s[::-1].index(1)\n\tans=0\n\tfor i in range(l,r):\n\t\tans+=1-s[i]\n\tprint(ans)", "def solve():\n n = int(input())\n lst = list(map(int,input().split()))\n while len(lst) > 0 and lst[-1] == 0:\n ... | {
"inputs": [
"5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n",
"1\n8\n0 0 0 1 1 1 1 1\n"
],
"outputs": [
"2\n0\n2\n4\n1\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,231 | |
84921be8b6c281cb5b08e140ebf18d21 | UNKNOWN | You are given two integers $n$ and $k$.
Your task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to ma... | ["n = int(input())\nfor i in range(n):\n\tl, ch = map(int, input().split())\n\tfor j in range(l):\n\t\tprint(chr(j % ch + ord('a')), end='')\n\tprint()\n", "# import sys\n# sys.stdin = open(\"F:\\\\Scripts\\\\input\",\"r\")\n# sys.stdout = open(\"F:\\\\Scripts\\\\output\",\"w\")\n\n\nMOD = 10**9 + 7\nI = lambda:list(ma... | {
"inputs": [
"3\n7 3\n4 4\n6 2\n",
"66\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\... | INTRODUCTORY | PYTHON3 | CODEFORCES | 4,825 | |
4aea1a7567f01add7f841d93dafe2b10 | UNKNOWN | There are $n$ candies in a row, they are numbered from left to right from $1$ to $n$. The size of the $i$-th candy is $a_i$.
Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob — from right to left. The game ends if all the candies are eaten.
The process ... | ["from fractions import Fraction\nimport bisect\nimport os\nfrom collections import Counter\nimport bisect\nfrom collections import defaultdict\nimport math\nimport random\nimport heapq as hq\nfrom math import sqrt\nimport sys\nfrom functools import reduce, cmp_to_key\nfrom collections import deque\nimport threading\nf... | {
"inputs": [
"7\n11\n3 1 4 1 5 9 2 6 5 3 5\n1\n1000\n3\n1 1 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 1\n7\n1 1 1 1 1 1 1\n",
"3\n1\n1\n1\n1\n1\n1\n"
],
"outputs": [
"6 23 21\n1 1000 0\n2 1 2\n6 45 46\n2 2 1\n3 4 2\n4 4 3\n",
"1 1 0\n1 1 0\n1 1 0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,104 | |
757074102d6aaa4beebcaa1658545dfe | UNKNOWN | You are given two arrays $a$ and $b$ both consisting of $n$ positive (greater than zero) integers. You are also given an integer $k$.
In one move, you can choose two indices $i$ and $j$ ($1 \le i, j \le n$) and swap $a_i$ and $b_j$ (i.e. $a_i$ becomes $b_j$ and vice versa). Note that $i$ and $j$ can be equal or differ... | ["import sys\ninput = sys.stdin.readline\nrInt = lambda: int(input())\nmInt = lambda: list(map(int, input().split()))\nrLis = lambda: list(map(int, input().split()))\n\nt = int(input())\nfor _ in range(t):\n n, k = mInt()\n a = rLis()\n b = rLis()\n a.sort()\n b.sort(reverse = True)\n for i in range(k... | {
"inputs": [
"5\n2 1\n1 2\n3 4\n5 5\n5 5 6 6 5\n1 2 5 4 3\n5 3\n1 2 3 4 5\n10 9 10 10 9\n4 0\n2 2 4 3\n2 4 2 3\n4 4\n1 2 2 1\n4 4 5 4\n",
"1\n6 1\n1 4 2 23 15 13\n5 6 4 1 15 24\n"
],
"outputs": [
"6\n27\n39\n11\n17\n",
"81\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,287 | |
1d6b32fb1da4783aa5521828e1484ad9 | UNKNOWN | You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.
Let: $a_i$ for all $i$ from $1$ to $n-1$ be the time required to go from the ... | ["n, c = list(map(int, input().split()))\na = [int(ai) for ai in input().split()]\nb = [int(bi) for bi in input().split()]\n\ndpa, dpb = [0] * n, [0] * n\ndpa[1], dpb[1] = a[0], c + b[0]\nfor i in range(1, n - 1):\n dpa[i + 1], dpb[i + 1] = min(dpa[i], dpb[i]) + a[i], min(dpa[i] + c, dpb[i]) + b[i]\n\nprint(*(min(dp... | {
"inputs": [
"10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n",
"10 1\n3 2 3 1 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n"
],
"outputs": [
"0 7 13 18 24 35 36 37 40 45 \n",
"0 2 4 7 8 11 13 14 16 17 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,093 | |
368d4e52e949be442202a86b3dd4fa3b | UNKNOWN | For the given integer $n$ ($n > 2$) let's write down all the strings of length $n$ which contain $n-2$ letters 'a' and two letters 'b' in lexicographical (alphabetical) order.
Recall that the string $s$ of length $n$ is lexicographically less than string $t$ of length $n$, if there exists such $i$ ($1 \le i \le n$), t... | ["#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [l... | {"inputs": ["7\n5 1\n5 2\n5 8\n5 10\n3 1\n3 2\n20 100\n", "7\n8 18\n19 11\n20 5\n15 19\n19 15\n20 6\n10 28\n"], "outputs": ["aaabb\naabab\nbaaba\nbbaaa\nabb\nbab\naaaaabaaaaabaaaaaaaa\n", "abaaabaa\naaaaaaaaaaaaabaaaab\naaaaaaaaaaaaaaaababa\naaaaaaaabaabaaa\naaaaaaaaaaaaabbaaaa\naaaaaaaaaaaaaaaabbaa\naabbaaaaaa\n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 5,256 | |
017ddb02b3f8c3a29e38e5c59c82dc0e | UNKNOWN | Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array; for the array $[1, 2, 3, 4]$ ME... | ["import sys\nfrom heapq import *\ninput = sys.stdin.readline\n\nquer, m = list(map(int, input().split()))\n\nvals = list(range(m))\nq = []\nfor v in vals:\n heappush(q, v)\n\nout = []\nfor _ in range(quer):\n nex = int(input()) % m\n vals[nex] += m\n heappush(q, vals[nex])\n\n new = heappop(q)\n whil... | {
"inputs": [
"7 3\n0\n1\n2\n2\n0\n0\n10\n",
"4 3\n1\n2\n1\n2\n"
],
"outputs": [
"1\n2\n3\n3\n4\n4\n7\n",
"0\n0\n0\n0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 2,500 | |
55151f2f85d90be8f46309507160db08 | UNKNOWN | We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array:
The array consists of $n$ distinct positive (greater than $0$) integers. The array contains two elements $x$ and $y$ (these elements are known for you) such that $x < y$. If you sort the arr... | ["def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n, x, y = read_ints()\n d = y - x\n for i in range(n - 1, 0, -1):\n if d % i == 0:\n d //= i\n l = min(n - (i + 1), (x - ... | {
"inputs": [
"5\n2 1 49\n5 20 50\n6 20 50\n5 3 8\n9 13 22\n",
"1\n2 1 49\n"
],
"outputs": [
"1 49 \n10 20 30 40 50 \n20 26 32 38 44 50 \n3 8 13 18 23 \n1 4 7 10 13 16 19 22 25 \n",
"1 49 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,968 | |
cfaf77f6f7ad94a7a79bd3c107ba5847 | UNKNOWN | You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...
You are given an array of integers. Sort it in non-descending order.
-----Input-----
The input consists of a ... | ["import time\nimport random\n\nl = list(map(int, input().split()))\nassert len(l) == l[0] + 1\nl = l[1:]\nl.sort()\n\nv = [0 for i in range(10 ** 4)]\nfor i in range(4 * 10**5):\n v[random.randrange(0, len(v))] = random.randrange(-1000, 1000)\n\nprint(' '.join(map(str, l)))\n", "l = list(map(int, input().split()))\... | {
"inputs": [
"3 3 1 2\n",
"10 54 100 27 1 33 27 80 49 27 6\n"
],
"outputs": [
"1 2 3 \n",
"1 6 27 27 27 33 49 54 80 100 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 4,845 | |
ef4538747a02309bd1de63c4119e3c5a | UNKNOWN | You are given an array $a$ consisting of $n$ integers.
In one move, you can choose two indices $1 \le i, j \le n$ such that $i \ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of ass... | ["for _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n a, b = 0, 0\n for elem in ar:\n if elem % 2 == 0:\n a = 1\n else:\n b = 1\n if sum(ar) % 2 == 1:\n print('YES')\n elif a == 1 == b:\n print('YES')\n else:\n ... | {
"inputs": [
"5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1\n",
"1\n1\n114\n"
],
"outputs": [
"YES\nNO\nYES\nNO\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 8,464 | |
922e3c01b1238dd35522f13af26d1388 | UNKNOWN | A permutation of length $n$ is an array $p=[p_1,p_2,\dots,p_n]$, which contains every integer from $1$ to $n$ (inclusive) and, moreover, each number appears exactly once. For example, $p=[3,1,4,2,5]$ is a permutation of length $5$.
For a given number $n$ ($n \ge 2$), find a permutation $p$ in which absolute difference... | ["T = int(input())\nfor _ in range(T):\n n = int(input())\n if n <= 3:\n print(-1)\n else:\n left = []\n for i in range(1, n + 1, 2):\n left.append(i)\n right = []\n right.append(4)\n right.append(2)\n for i in range(6, n + 1, 2):\n right.a... | {"inputs": ["6\n10\n2\n4\n6\n7\n13\n", "7\n4\n3\n5\n4\n4\n4\n4\n"], "outputs": ["2 4 1 3 6 8 5 9 7 10 \n-1\n2 4 1 3 \n2 4 1 5 3 6 \n2 4 1 5 7 3 6 \n2 4 1 3 6 8 5 7 10 12 9 13 11 \n", "2 4 1 3 \n-1\n2 4 1 5 3 \n2 4 1 3 \n2 4 1 3 \n2 4 1 3 \n2 4 1 3 \n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,118 | |
34ba9b01f43c31333c89c16420edbb4f | UNKNOWN | You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.
An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $i$ ($0 \le i \le n - 1$) the equality... | ["\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\n\tod=0\n\tev=0\n\n\tfor i in range(n):\n\t\tif(i&1):\n\t\t\tif(a[i]%2==0):\n\t\t\t\tod+=1\n\t\telse:\n\t\t\tif(a[i]&1):\n\t\t\t\tev+=1\n\n\tif(od!=ev):\n\t\tprint(-1)\n\telse:\n\t\tprint(od)", "for _ in range(int(input())):\n ... | {
"inputs": [
"4\n4\n3 2 7 6\n3\n3 2 6\n1\n7\n7\n4 9 2 1 18 3 0\n",
"7\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n"
],
"outputs": [
"2\n1\n-1\n0\n",
"0\n0\n0\n0\n0\n0\n0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,546 | |
3f6184ac5366fd6c56ece836026c24b5 | UNKNOWN | You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder).
Your task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's impossible to do that.
You have to answer $t$ independent test cases... | ["for testcase in range(int(input())):\n n = int(input())\n cnt2, cnt3 = 0, 0\n while n % 2 == 0:\n n //= 2\n cnt2 += 1\n while n % 3 == 0:\n n //= 3\n cnt3 += 1\n\n if n > 1 or cnt3 < cnt2:\n print(-1)\n continue\n\n print(2 * cnt3 - cnt2)\n", "# for _ in ran... | {
"inputs": [
"7\n1\n2\n3\n12\n12345\n15116544\n387420489\n",
"1\n999838675\n"
],
"outputs": [
"0\n-1\n2\n-1\n-1\n12\n36\n",
"-1\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,518 | |
0ded652bbeb540be8350e061f7eaec93 | UNKNOWN | The only difference between easy and hard versions is the size of the input.
You are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.
You are also given an integer $k$. Your task is to change the minimum number of characters in the initial string $s$ so that after the changes there ... | ["import sys\ndef countR(ip):\n c=0\n for i in ip:\n if(i=='R'):\n c+=1\n return c\n \ndef countB(ip):\n c=0\n for i in ip:\n if(i=='B'):\n c+=1\n return c\n \ndef countG(ip):\n c=0\n for i in ip:\n if(i=='G'):\n c+=1\n return c\n# s... | {
"inputs": [
"3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n",
"1\n18 2\nRBGGGRBBGRRBBGGGGB\n"
],
"outputs": [
"1\n0\n3\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 19,650 | |
187866f49ce75652eda44618f5049968 | UNKNOWN | You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots , a_n$.
In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $[2, 1, 4]$ you can obtain the following array... | ["for i in range(int(input())):\n n=int(input())\n l1=list(map(int,input().split()))\n type1=0\n type2=0\n ans=0\n for item in l1:\n if item%3==0:\n ans+=1\n elif item%3==1:\n type1+=1\n else :\n type2+=1\n x=min(type1,type2)\n ans+=x\n ty... | {
"inputs": [
"2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2\n",
"1\n5\n3 3 3 3 3\n"
],
"outputs": [
"3\n3\n",
"5\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 13,127 | |
6be9fee0c09d94f3863ca75d8355da78 | UNKNOWN | You are given a permutation of length $n$. Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2, 3, 1, 5, 4]$ is a permutation, but $[1, 2, 2]$ is not a permutation ($2$ appears twice in the array) and $[1, 3, 4]$ is also not a permutation ($n=... | ["q = int(input())\nfor qi in range(q):\n n = int(input())\n a = list(map(int, input().split()))\n used = [False] * n\n for t in range(n):\n for i in range(len(a) - 1, 0, -1):\n if used[i]:\n continue\n if a[i] < a[i - 1]:\n a[i], a[i - 1] = a[i - 1... | {
"inputs": [
"4\n5\n5 4 1 3 2\n4\n1 2 4 3\n1\n1\n4\n4 3 2 1\n",
"1\n5\n4 2 3 5 1\n"
],
"outputs": [
"1 5 2 4 3 \n1 2 3 4 \n1 \n1 4 3 2 \n",
"1 4 2 3 5 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,961 | |
c723dc1e9556fc2c13a0a9896df0b2f7 | UNKNOWN | There are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation).
Students want to start a round dance. A clockwise round dance can be started if the student $2$ comes... | ["'''input\n5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n\n'''\nimport sys\nfrom collections import defaultdict as dd\nfrom itertools import permutations as pp\nfrom itertools import combinations as cc\nfrom collections import Counter as ccd\nfrom random import randint as rd\nfrom bisect import bisect_le... | {
"inputs": [
"5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n",
"1\n12\n12 3 4 5 6 7 8 9 10 11 1 2\n"
],
"outputs": [
"YES\nYES\nNO\nYES\nYES\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,094 | |
a27648b30a743a0c532b2c43880914ad | UNKNOWN | Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.
Suppose the kid who recieves the minimum number of candies has $a$ candies and the kid who recieves... | ["q = int(input())\nfor z in range(q):\n n, k = map(int, input().split())\n x = n // k\n n -= x * k\n m = min(k // 2, n)\n print(x * k + m)", "t = int(input())\nfor i in range(t):\n\tn, k = list(map(int, input().split()))\n\tz = n // k\n\tn -= z * k\n\tprint(z * k + min(n, k // 2))\n", "import sys\ninput... | {
"inputs": [
"5\n5 2\n19 4\n12 7\n6 2\n100000 50010\n",
"1\n1233212 4\n"
],
"outputs": [
"5\n18\n10\n6\n75015\n",
"1233212\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 9,380 | |
9c6972c485fa53c65bd129d6e3d1a622 | UNKNOWN | You are given two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$). Represent the number $n$ as the sum of $k$ positive integers of the same parity (have the same remainder when divided by $2$).
In other words, find $a_1, a_2, \ldots, a_k$ such that all $a_i>0$, $n = a_1 + a_2 + \ldots + a_k$ and... | ["t=int(input())\nfor i in range (t):\n n,k=map(int,input().split())\n if n-k+1>0 and (n-k+1)%2==1:\n print(\"YES\")\n print(*([1]*(k-1)), n-k+1)\n elif n-k*2+2>0 and (n-k*2+2)%2==0:\n print(\"YES\")\n print(*([2]*(k-1)), n-k*2+2)\n else:\n print(\"NO\")", "t = int(input()... | {
"inputs": [
"8\n10 3\n100 4\n8 7\n97 2\n8 8\n3 10\n5 3\n1000000000 9\n",
"7\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n"
],
"outputs": [
"YES\n2 2 6\nYES\n1 1 1 97\nNO\nNO\nYES\n1 1 1 1 1 1 1 1\nNO\nYES\n1 1 3\nYES\n2 2 2 2 2 2 2 2 999999984\n",
"NO\nNO\nNO\nNO\nNO\nNO\nNO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 9,330 | |
3486f033b21db73cc5e64ebec51c2663 | UNKNOWN | Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the... | ["from sys import stdin,stdout\nimport sys\nimport math\n\nt=int(stdin.readline())\nfor i in range(t):\n a=list(map(int,stdin.readline().split()))\n print(sum(a)//2)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "for i in range(int(input())):\n a = list(map(int, input().split()))\n p... | {
"inputs": [
"4\n1 3 4\n1 10 100\n10000000000000000 10000000000000000 10000000000000000\n23 34 45\n",
"1\n111 2 3\n"
],
"outputs": [
"4\n55\n15000000000000000\n51\n",
"58\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 8,191 | |
1fb4a986458d0b68a9532ed108386e4e | UNKNOWN | You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. You want to split it into exactly $k$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuf... | ["from sys import stdin\nc=int(stdin.readline().strip())\nfor cas in range(c):\n n,m=list(map(int,stdin.readline().strip().split()))\n s=list(map(int,stdin.readline().strip().split()))\n sm=0\n ans=[]\n ind=-1\n for i in range(n):\n if m==1:\n ind=i\n break\n sm+=s[... | {
"inputs": [
"3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2\n",
"1\n1 1\n2\n"
],
"outputs": [
"YES\n1 3 5\nNO\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 24,075 | |
7ec85a48ca6704beafc9bf495f674d37 | UNKNOWN | Reverse bits of a given 32 bits unsigned integer.
Note:
Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whet... | ["class Solution:\n def reverseBits(self, n: int) -> int:\n rev = ''\n for i in reversed(bin(n)[2:]):\n rev = rev + i\n rev = rev + '0'*(32-len(rev)) \n \n return int(rev, 2)", "class Solution:\n def reverseBits(self, n: int) -> int:\n a = bin(n)[2:]\n z... | {"fn_name": "reverseBits", "inputs": [[43261596], [4294967293]], "outputs": [964176192, 3221225471]} | INTRODUCTORY | PYTHON3 | LEETCODE | 811 |
class Solution:
def reverseBits(self, n: int) -> int:
|
7d716ba7d58926cd7c30e6e439a29ea1 | UNKNOWN | Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
Example:
Input: 5
Output:
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
] | ["class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n res = [[1]]\n for i in range(1,numRows):\n res.append(list(map(lambda x, y : x + y, res[-1]+[0], [0]+res[-1])))\n return res[:numRow... | {"fn_name": "generate", "inputs": [[5], [1]], "outputs": [[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]], [[1]]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 9,494 |
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
|
5abe52963e0c3daa180b01f395b689fa | UNKNOWN | =====Problem Statement=====
You are given an integer N followed by N email addresses. Your task is to print a list containing only valid email addresses in lexicographical order.
Valid email addresses must follow these rules:
It must have the username@websitename.extension format type.
The username can only contain let... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport re\nn=int(input())\nar=[]\nfor i in range(0,n):\n s=input()\n t=re.search(r\"^[a-zA-Z][\\w-]*@[a-zA-Z0-9]+\\.[a-zA-Z]{1,3}$\",s)\n if t:\n ar.append(s)\nar.sort() \nprint(ar)\n"] | {"inputs": ["3\nlara@hackerrank.com\nbrian-23@hackerrank.com\nbritts_54@hackerrank.com", "2\nharsh@gmail\niota_98@hackerrank.com"], "outputs": ["['brian-23@hackerrank.com', 'britts_54@hackerrank.com', 'lara@hackerrank.com']", "['iota_98@hackerrank.com']"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 281 |
def fun(s):
# return True if s is a valid email, else return False
def filter_mail(emails):
return list(filter(fun, emails))
if __name__ == '__main__':
n = int(input())
emails = []
for _ in range(n):
emails.append(input())
filtered_emails = filter_mail(emails)
filtered_emails.sort()
prin... |
c081b26f4db2bd4cc7c47e8a2f7563d7 | UNKNOWN | =====Problem Statement=====
Let's learn some new Python concepts! You have to generate a list of the first N fibonacci numbers, 0 being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list.
Concept
The map() function applies a function to every member... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\ndef sqr(a):\n return a*a*a\nn=int(input())\nif(n==0):\n print(\"[]\")\nelif(n==1):\n print(\"[0]\")\nelse:\n ar=[0]*n\n ar[0]=0\n ar[1]=1\n for i in range(2,n):\n ar[i]=ar[i-1]+ar[i-2]\n\n ar=list(map(sqr,ar))\n p... | {"inputs": ["5", "6"], "outputs": ["[0, 1, 1, 8, 27]", "[0, 1, 1, 8, 27, 125]"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 332 |
cube = lambda x: # complete the lambda function
def fibonacci(n):
# return a list of fibonacci numbers
if __name__ == '__main__':
n = int(input())
print(list(map(cube, fibonacci(n)))) |
eebff2404d07a9705f773d3e621b9b0f | UNKNOWN | =====Problem Statement=====
You are given a valid XML document, and you have to print the maximum level of nesting in it. Take the depth of the root as 0.
=====Input Format=====
The first line contains N, the number of lines in the XML document.
The next N lines follow containing the XML document.
=====Output Format=... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nxml_str=\"\"\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n xml_str=xml_str+tmp_str\n \nimport xml.etree.ElementTree as etree\ntree = etree.ElementTree(etree.fromstring(xml_str))\nroot=tree.getroot()\nar=[]\ndef cnt_node(node):... | {"inputs": ["6\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n</feed>", "11\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle la... | INTRODUCTORY | PYTHON3 | HACKERRANK | 645 |
import xml.etree.ElementTree as etree
maxdepth = 0
def depth(elem, level):
global maxdepth
# your code goes here
if __name__ == '__main__':
n = int(input())
xml = ""
for i in range(n):
xml = xml + input() + "\n"
tree = etree.ElementTree(etree.fromstring(xml))
depth(tree.getroot()... |
a459ecd2696a2a0d57a48d6921f36573 | UNKNOWN | =====Problem Statement=====
Let's dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers.
Concept
A valid mobile number is a ten digit number starting with a 7, 8, or 9.
=====Input Format=====
The first line contains an int... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n len_tmp_str=len(tmp_str)\n if(len_tmp_str!=10):\n ##print \"LENGTH PROBLEM\"\n print(\"NO\")\n elif(tmp_str[0]!=\"7\" and tmp_str[0]!=\"8\" and tmp_str[0]!=\"9\"):\... | {"inputs": ["2\n9587456281\n1252478965", "3\n8F54698745\n9898959398\n879546242"], "outputs": ["YES\nNO", "NO\nYES\nNO"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 924 |
# Enter your code here. Read input from STDIN. Print output to STDOUT |
55b8e2cbd8a92cb145556d73b232a17e | UNKNOWN | =====Function Descriptions=====
Objective
Today, we're learning about a new data type: sets.
Concept
If the inputs are given on one line separated by a space character, use split() to get the separate values in the form of a list:
>> a = raw_input()
5 4 3 2
>> lis = a.split()
>> print (lis)
['5', '4', '3', '2']
If ... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nm=int(input())\nset_a_str_ar=input().strip().split()\nset_a_ar=list(map(int,set_a_str_ar))\nn=int(input())\nset_b_str_ar=input().strip().split()\nset_b_ar=list(map(int,set_b_str_ar))\n\nset_a_set=set(set_a_ar)\nset_b_set=set(set_b_ar)\nset_a_dif_s... | {"inputs": ["4\n2 4 5 9\n4\n2 4 11 12", "2\n8 -10\n3\n5 6 7"], "outputs": ["5\n9\n11\n12", "-10\n5\n6\n7\n8"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 834 | |
63db0ec8cfd7c9c7ab496320c3ddbf8f | UNKNOWN | =====Function Descriptions=====
collections.namedtuple()
Basically, namedtuples are easy to create, lightweight object types.
They turn tuples into convenient containers for simple tasks.
With namedtuples, you don’t have to use integer indices for accessing members of a tuple.
Example
Code 01
>>> from collections imp... | ["n = int(input())\ncol_list = list(input().split())\nmarks_col = col_list.index(\"MARKS\")\nmarks_list = []\nfor i in range(n):\n info_list = list(input().split())\n marks_list.append(float(info_list[marks_col]))\nprint((sum(marks_list)/n))\n", "#!/usr/bin/env python3\n\nfrom collections import namedtuple\n\ndef... | {"inputs": ["5\nID MARKS NAME CLASS \n1 97 Raymond 7 \n2 50 Steven 4 \n3 91 Adrian 9 \n4 72 Stewart 5 \n5 80 Peter 6", "5\nMARKS CLASS NAME ID ... | INTRODUCTORY | PYTHON3 | HACKERRANK | 778 |
# Enter your code here. Read input from STDIN. Print output to STDOUT |
623e6b183f2f52f595ce804db1257ecf | UNKNOWN | =====Problem Statement=====
Given an integer, n, perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of 2 to 5, print Not Weird
If n is even and in the inclusive range of 6 to 20, print Weird
If n is even and greater than 20, print Not Weird
=====Input Format====... | ["#!/bin/python3\n\nimport sys\n\n\nN = int(input().strip())\nn= N\nw = 'Weird'\nnw = 'Not Weird'\nif n % 2 == 1:\n print(w)\nelif n % 2 == 0 and (n>=2 and n<5):\n print(nw)\nelif n % 2 == 0 and (n>=6 and n<=20):\n print(w)\nelif n % 2 == 0 and (n>20):\n print(nw) \n", "def __starting_point():\n n = i... | {"inputs": ["3", "24"], "outputs": ["Weird", "Not Weird"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 458 |
#!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input().strip())
check = {True: "Not Weird", False: "Weird"}
print(check[
n%2==0 and (
n in range(2,6) or
n > 20)
])
|
266601d64b581f092d9a34f2e511203c | UNKNOWN | =====Problem Statement=====
You are given a valid XML document, and you have to print its score. The score is calculated by the sum of the score of each element. For any element, the score is equal to the number of attributes it has.
=====Input Format=====
The first line contains N, the number of lines in the XML docu... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nxml_str=\"\"\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n xml_str=xml_str+tmp_str\n \ncnt=xml_str.count(\"='\")\nprint(cnt)\n", "def get_attr_number(node):\n return len(node.attrib) + sum([get_attr_number(child) for child ... | {"inputs": ["6\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n</feed>", "11\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle la... | INTRODUCTORY | PYTHON3 | HACKERRANK | 337 |
import sys
import xml.etree.ElementTree as etree
def get_attr_number(node):
# your code goes here
if __name__ == '__main__':
sys.stdin.readline()
xml = sys.stdin.read()
tree = etree.ElementTree(etree.fromstring(xml))
root = tree.getroot()
print(get_attr_number(root)) |
71db99d7376d1f2e045511fb461b6f68 | UNKNOWN | =====Problem Statement=====
You are given four points A, B, C and D in a 3-dimensional Cartesian coordinate system. You are required to print the angle between the plane made by the points A, B, C and B, C, D in degrees(not radians). Let the angle be PHI.
Cos(PHI) = (X.Y)/|X|Y| where X = AB x BC and Y = BC x CD.
Here, ... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\n\nimport math\ndef custom_diff(a,b):\n res0 = a[0] - b[0]\n res1 = a[1] - b[1]\n res2 = a[2] - b[2]\n return [res0,res1,res2]\n\ndef dot_product(a,b):\n return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]\n\ndef abs_val(a):\n tmp_val=a[0]*a[0]+... | {"inputs": ["0 4 5\n1 7 6\n0 5 9\n1 7 2", "5 8.8 9\n4 -1 3\n7 8.7 3.3\n4.4 5.1 6.3"], "outputs": ["8.19", "5.69"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 1,649 |
import math
class Points(object):
def __init__(self, x, y, z):
def __sub__(self, no):
def dot(self, no):
def cross(self, no):
def absolute(self):
return pow((self.x ** 2 + self.y ** 2 + self.z ** 2), 0.5)
if __name__ == '__main__':
points = list()
for i in range(4):
... |
e1bdff6083a183c73d89fba9a421f463 | UNKNOWN | =====Problem Statement=====
In this challenge, the task is to debug the existing code to successfully execute all provided test files.
Consider that vowels in the alphabet are a, e, i, o, u and y.
Function score_words takes a list of lowercase words as an argument and returns a score as follows:
The score of a single w... | ["def 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\... | {"inputs": ["2\nhacker book\n", "3\nprogramming is awesome\n"], "outputs": ["4\n", "4\n"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 758 |
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... |
8cb8dcc5e0723258853ada64cc93b039 | UNKNOWN | =====Problem Statement=====
You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral.
=====Input Format=====
A single line of input containing a string of Roman characters.
====... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport re\ndef my_func(s):\n s = s.upper()\n ##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)\n 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)\n if(s==\"MMMM\"):\n ... | {"inputs": ["CDXXI", "DXXVIIII"], "outputs": ["True", "False"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 464 |
regex_pattern = r"" # Do not delete 'r'.
import re
print(str(bool(re.match(regex_pattern, input())))) |
0ce6330be85da3177b3ab8d1dab53682 | UNKNOWN | =====Problem Statement=====
Let's dive into decorators! You are given N mobile numbers. Sort them in ascending order then print them in the standard format shown below:
+91 xxxxx xxxxx
The given mobile numbers may have +91, 91 or 0 written before the actual 10 digit number. Alternatively, there may not be any prefix a... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nar=[]\nfor i in range(0,n):\n tmp_str=input()\n tmp_str=tmp_str[len(tmp_str)-10:]\n ar.append(tmp_str)\n \nar.sort()\nfor i in range(0,len(ar)):\n print((\"+91 \"+ar[i][:5]+\" \"+ar[i][5:]))\n"] | {"inputs": ["3\n07895462130\n919875641230\n9195969878", "3\n09191919191\n9100256236\n+919593621456"], "outputs": ["+91 78954 62130\n+91 91959 69878\n+91 98756 41230", "+91 91002 56236\n+91 91919 19191\n+91 95936 21456"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 298 |
def wrapper(f):
def fun(l):
# complete the function
return fun
@wrapper
def sort_phone(l):
print(*sorted(l), sep='\n')
if __name__ == '__main__':
l = [input() for _ in range(int(input()))]
sort_phone(l)
|
0bca649246140b1afcae01e3e72853d5 | UNKNOWN | =====Problem Statement=====
The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal.
=====Example=====
marks key:value pairs are
'alpha': [20,30,40]
'beta':... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nar={}\nfor i in range(0,n):\n s=input()\n ss=s.split(\" \")\n n=ss[0]\n m1=float(ss[1])\n m2=float(ss[2])\n m3=float(ss[3])\n m_avg=(m1+m2+m3)/3.0\n ar[n]=\"%.2f\" % m_avg\ns_name=input()\nprint((ar[s_name])... | {"inputs": ["3\nKrishna 67 68 69\nArjun 70 98 63\nMalika 52 56 60\nMalika", "2\nHarsh 25 26.5 28\nAnurag 26 28 30\nHarsh"], "outputs": ["56.00", "26.50"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 742 |
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input() |
8b9402ca08fcc495d23796cf5a2ccaa5 | UNKNOWN | =====Problem Statement=====
Let's use decorators to build a name directory! You are given some information about N people. Each person has a first name, last name, age and sex ('M' or 'F'). Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed fi... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nar=[]\nn=int(input())\nfor i in range(0,n):\n str_ar=input().strip().split()\n user_name=str_ar[0]+\" \"+str_ar[1]\n user_age=int(str_ar[2])\n user_sex=str_ar[3]\n user_new_name=\"\"\n if(user_sex==\"M\"):\n user_new_name=... | {"inputs": ["3\nMike Thomson 20 M\nRobert Bustle 32 M\nAndria Bustle 30 F", "5\nLaura Moser 50 F\nTed Moser 50 M\nYena Dixit 50 F\nDiya Mirza 50 F\nRex Dsouza 51 M"], "outputs": ["Mr. Mike Thomson\nMs. Andria Bustle\nMr. Robert Bustle", "Ms. Laura Moser\nMr. Ted Moser\nMs. Yena Dixit\nMs. Diya Mirza\nMr. Rex Dsouza"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 522 |
import operator
def person_lister(f):
def inner(people):
# complete the function
return inner
@person_lister
def name_format(person):
return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1]
if __name__ == '__main__':
people = [input().split() for i in range(int(input())... |
99748d1965c7e8aea5e99cf6b17c520c | UNKNOWN | =====Problem Statement=====
Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0≤i≤x;0≤j≤y;0≤k≤z. Please use... | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nx=int(input())\ny=int(input())\nz=int(input())\nn=int(input())\nprint([ [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 ])\n", "def __starting_point():\n x = int(input())\n y = int(input())\n z = int(inpu... | {"inputs": ["1\n1\n1\n2", "2\n2\n2\n2"], "outputs": ["[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]", "[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 2], [0, 2, 1], [0, 2, 2], [1, 0, 0], [1, 0, 2], [1, 1, 1], [1, 1, 2], [1, 2, 0], [1, 2, 1], [1, 2, 2], [2, 0, 1], [2, 0, 2], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 2, 0... | INTRODUCTORY | PYTHON3 | HACKERRANK | 492 |
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input()) |
e94b27c15ae9f82ecc6dcde454a6138b | UNKNOWN | =====Problem Statement=====
For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct up to two decimal places.
=====Input Format=====
One line of input... | ["# Enter your code here. Read input from STDIN. Print output to \n\n\nimport math\n\nclass ComplexNumber(object): \n def __init__(self, real, compl): \n self.real = real \n self.compl = compl\n pass\n def __str__(self):\n if (self.compl >= 0):\n return '{0:.2f}'.format(self... | {"inputs": ["2 1\n5 6", "5.9 6\n9 10"], "outputs": ["7.00+7.00i\n-3.00-5.00i\n4.00+17.00i\n0.26-0.11i\n2.24+0.00i\n7.81+0.00i", "14.90+16.00i\n-3.10-4.00i\n-6.90+113.00i\n0.62-0.03i\n8.41+0.00i\n13.45+0.00i"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 1,876 |
import math
class Complex(object):
def __init__(self, real, imaginary):
def __add__(self, no):
def __sub__(self, no):
def __mul__(self, no):
def __truediv__(self, no):
def mod(self):
def __str__(self):
if self.imaginary == 0:
result = "%.2f... |
23584ab5b6ae30839ddda0df1d0bb10e | UNKNOWN | Snuke signed up for a new website which holds programming competitions.
He worried that he might forget his password, and he took notes of it.
Since directly recording his password would cause him trouble if stolen,
he took two notes: one contains the characters at the odd-numbered positions, and the other contains the... | ["q=str(input())\ne=str(input())\na=len(q)\nb=len(e)\nc=\"\"\nif a==b:\n for i in range(a):\n c+=q[i]\n c+=e[i]\nelse:\n for i in range(b):\n c+=q[i]\n c+=e[i]\n c+=q[a-1]\n\nprint(c)", "o = input()\ne = input()\npassword = \"\"\n\nfor i in range(len(o)):\n password += o[i]\n if len(e) > i:\n ... | {"inputs": ["xyz\nabc\n", "atcoderbeginnercontest\natcoderregularcontest\n"], "outputs": ["xaybzc\n", "aattccooddeerrbreeggiunlnaerrccoonntteesstt\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 21,496 | |
278ff6aa2669a17f37144ed9ba42c63a | UNKNOWN | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is... | ["from collections import deque\n\nS = input()\n\nans = deque([])\n\nfor s in S:\n if s==\"B\":\n if ans:\n ans.pop()\n else:\n ans.append(s)\n \nprint(\"\".join(ans))", "a = list(input())\n\nb = []\n\nfor i in range(int(len(a))):\n\tt = a[int(i)]\n\tif t == \"0\":\n\t\tb.append(\"... | {"inputs": ["01B0\n", "0BB1\n"], "outputs": ["00\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 23,894 | |
2005e88cda0c51d60ce7586eac203502 | UNKNOWN | N persons are standing in a row. The height of the i-th person from the front is A_i.
We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:
Condition: Nobody in front of the person is taller than the person. Here, the height of a pe... | ["N = int(input())\nA = list(map(int,input().split()))\nT = 0\nfor i in range(len(A)-1):\n if (A[i] > A[i + 1]):\n T += A[i] - A[i +1]\n A[i+1] = A[i] \nprint(T)", "n=int(input())\na=list(map(int, input().split()))\nans=0\nfor i in range(1,n):\n\tif a[i] < a[i-1]:\n\t\tans += a[i-1] - a[i]\n\t\ta[i] =... | {"inputs": ["5\n2 1 5 4 3\n", "5\n3 3 3 3 3\n"], "outputs": ["4\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 24,220 | |
40e2d0d128a66e1c1e36994d5253e3d3 | UNKNOWN | Alice, Bob and Charlie are playing Card Game for Three, as below:
- At first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.
- The players take turns. Alice goes first.
- If the curren... | ["A = input()\nB = input()\nC = input()\nturn = 'a'\nwhile True:\n if turn == 'a':\n if len(A) == 0:\n print('A')\n break\n turn = A[0]\n A = A[1:]\n elif turn == 'b':\n if len(B) == 0:\n print('B')\n break\n turn = B[0]\n B = B[1:]\n else:\n if len(C) == 0:\n print('C')... | {"inputs": ["aca\naccc\nca\n", "abcb\naacb\nbccc\n"], "outputs": ["A\n", "C\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 45,656 | |
d3630389eb33d6dd6f37bef2725964bd | UNKNOWN | Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of ... | ["haiku = list(map(int, input().split()))\nif haiku == [5, 5, 7] or haiku == [5, 7, 5] or haiku == [7, 5, 5]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "a,b,c=map(int,input().split())\nb5=0\nb7=0\nif a==5:\n b5+=1\nif a==7:\n b7+=1\nif b==5:\n b5+=1\nif b==7:\n b7+=1\nif c==5:\n b5+=1\nif c==7:\n b7+=1\nif b5==... | {"inputs": ["5 5 7\n", "7 7 5\n"], "outputs": ["YES\n", "NO\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 16,918 | |
5c1ee998babc7c9980f1f0e56a2bb954 | UNKNOWN | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
- L_0=2
- L_1=1
- L_i=L_{i-1}+L_{i-2} (i≥2)
-----Constraints-----
- 1≤N≤86
- It is guaranteed that the answer is less tha... | ["n=int(input())\na,b=2,1\nfor i in range(n):\n nxt=a+b\n a,b=b,nxt\nprint(a)", "n=int(input())\ndef fibonacci(n):\n fib = [2, 1]\n for i in range(2, n):\n fib.append(fib[i - 2] + fib[i - 1])\n \n return fib[n -1]\nprint(fibonacci(n+1))", "n = int(input())\nlucas = [2,1]\nfor i in range(2,n... | {"inputs": ["5\n", "86\n"], "outputs": ["11\n", "939587134549734843\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 16,095 | |
99b112ab2a521ed07053572880a3a46a | UNKNOWN | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.
An example of a trapezoid
Find the area of this trapezoid.
-----Constraints-----
- 1≦a≦100
- 1≦b≦100
- 1≦h≦100
- All input values are integers.
- h is even.
-----Input-----
The input is given from Stan... | ["\na = int(input())\nb = int(input())\nh = int(input())\ns = (a+b)*h/2\nprint(int(s))", "# \u5165\u529b\na = int(input())\nb = int(input())\nh = int(input())\n\n# \u51e6\u7406\narea = (a + b) * h // 2\n\n# \u51fa\u529b\nprint(area)", "a,b,h=list(map(int,(input(),input(),input())))\nprint(((a+b)*h//2))\n\n", "a = int(i... | {"inputs": ["3\n4\n2\n", "4\n4\n4\n"], "outputs": ["7\n", "16\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,478 | |
c8a46dc0a35e9c0aa611fff19a311ae4 | UNKNOWN | Given are N integers A_1,\ldots,A_N.
Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).
-----Constraints-----
- 2 \leq N \leq 2\times 10^5
- 0 \leq A_i \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following f... | ["(N), *D = [list(map(int, s.split())) for s in open(0)]\nV = D[0]\nA = V.pop(N[0]-1)\nM = 1000000000 + 7\nR=0\nfor value in reversed(V):\n R = R + ((A) * value) % M\n A = A + value\nprint(R % M)", "def main():\n N=int(input())\n CONST= 10**9+7\n Output = 0\n lis = list(map(int,input().split())) \n ... | {"inputs": ["3\n1 2 3\n", "4\n141421356 17320508 22360679 244949\n"], "outputs": ["11\n", "437235829\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 26,548 | |
16d428dbc4cbb095be75f9ffc5cc15c3 | UNKNOWN | AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this inte... | ["rgb = list(map(int, input().split()))\n\nl = ''.join(str(n) for n in rgb)\nif int(l)%4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = list(map(int, input().split()))\nprint((\"YES\" if (r * 100 + g * 10 + b) % 4 == 0 else \"NO\"))\n", "# A - RGB Cards\n# https://atcoder.jp/contests/abc064/tasks/abc064_a... | {"inputs": ["4 3 2\n", "2 3 4\n"], "outputs": ["YES\n", "NO\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,945 | |
51e3ac1502a93830ff72638fe3cdd461 | UNKNOWN | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
- Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after K ... | ["a,b,c=list(map(int,input().split()))\nk=int(input())\n\nx=max(a,b,c)\n\nprint(((a+b+c)-x+x*(2**k)))\n", "a,b,c=map(int,input().split())\nk=int(input())\nprint(a+b+c+max(a,b,c)*(2**k-1))", "A, B, C = map(int, input().split())\nK = int(input())\n\nX = sorted([A, B, C])\nfor _ in range(K):\n X[-1] *= 2\n \nprint(s... | {"inputs": ["5 3 11\n1\n", "3 3 4\n2\n"], "outputs": ["30\n", "22\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,106 | |
7009ec6050aa25cc0be3e362f5b4a0db | UNKNOWN | Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautiful.
-----Constraints-----
- 1 \leq |w| \leq 100
- w consists of ... | ["import sys\nimport string\nw = input()\na_z = string.ascii_letters\nfor i in a_z:\n if w.count(i) & 1:\n print('No')\n return\nprint('Yes')", "# import math\n# import statistics\na=input()\n#b,c=int(input()),int(input())\nc=[]\nfor i in a:\n c.append(i)\n#e1,e2 = map(int,input().split())\n# f = li... | {"inputs": ["abaccaba\n", "hthth\n"], "outputs": ["Yes\n", "No\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 19,545 | |
2d67bfce9ac9bb116b1c2f9a98a3a6a0 | UNKNOWN | There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,... | ["n, k = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(n)]\n\nab.sort()\n\nnum_sum = 0\n\nfor a, b in ab:\n num_sum += b\n if num_sum >= k:\n print(a)\n return\n", "N, K = map(int, input().split())\narr = [0]*(10**5+1)\n\nfor i in range(N):\n a,b = map(int,... | {"inputs": ["3 4\n1 1\n2 2\n3 3\n", "10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n"], "outputs": ["3\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 30,400 | |
aa4236458216d621223c54d834c89d3f | UNKNOWN | There are N balls placed in a row.
AtCoDeer the deer is painting each of these in one of the K colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls.
-----Constraints-----
- 1≦N≦1000
- 2≦K≦1000
- The corre... | ["n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n, k = list(map(int, input().split()))\nprint((k*pow(k-1, n-1)))\n", "N,K = map(int,input().split())\nP = K\nfor i in range(N-1):\n P *= K-1\nprint(P)", "N, K=map(int, input().split(\" \"))\n\nprint(K*(K-1)**(N-1))", "N, K = map(int, input().split())\n\nans = K ... | {"inputs": ["2 2\n", "1 10\n"], "outputs": ["2\n", "10\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 8,955 | |
4ebb83496fce134e7a8f464d5df63cf0 | UNKNOWN | There is a circular pond with a perimeter of K meters, and N houses around them.
The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.
When traveling between these houses, you can only go around the pond.
Find the minimum distance that needs to be ... | ["k, n = map(int, input().split())\npoints = list(map(int, input().split()))\n\ndist = []\nfor i in range(n):\n if i != n-1:\n distance = points[i+1] - points[i]\n else:\n distance = points[0]+k - points[i]\n dist.append(distance)\n\nmax = dist[0]\nfor j in range(1, len(dist), 1):\n if max < d... | {"inputs": ["20 3\n5 10 15\n", "20 3\n0 5 15\n"], "outputs": ["10\n", "10\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 24,906 | |
b1ed8ddad87af6e4d4a4765eaba85154 | UNKNOWN | There are two rectangles.
The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.
The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.
Print the area of the re... | ["a,b,c,d=map(int, input().split()) \nprint(max(a*b,c*d))", "A, B, C, D = map(int, input().split())\n\nS1 = A * B\nS2 = C * D\n\nprint(max(S1, S2))", "a,b,c,d = map(int, input().split())\n\nprint(max(a*b, c*d))", "a, b, c, d = map(int, input().split())\nlist01 = [a * b, c * d]\nprint(max(list01))", "# 052\n\n# 1.\u50... | {"inputs": ["3 5 2 7\n", "100 600 200 300\n"], "outputs": ["15\n", "60000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,655 | |
d5a881ec674ba6a87482d558699a9e59 | UNKNOWN | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA,... | ["c = int(input())\n\nr = [\"AC\", \"WA\", \"TLE\", \"RE\"]\na = { i:0 for i in r}\n\nfor i in range(c):\n s = input()\n a [s] += 1\n\nfor rr in r:\n print(rr + \" x \" + str(a[rr]))", "n = int(input())\nl = []\nfor i in range(n):\n l.append(input().rstrip())\n \nprint('AC x ' + str(l.count('AC')))\nprint('W... | {"inputs": ["6\nAC\nTLE\nAC\nAC\nWA\nTLE\n", "10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n"], "outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "AC x 10\nWA x 0\nTLE x 0\nRE x 0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 29,169 | |
d76b04a30f01de751c231666ff26f14b | UNKNOWN | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
-----Constraints-----
- 1≤M≤23
- M is an integer.
-----Input-----
Input is given from Standard Input in the following format:
M
-----Output-----
If we have x hours until New Year at M o'clock on 30th, December, print x.
--... | ["time=int(input())\nAns=48-time\nprint(Ans)", "#\u300012\u670830\u65e5\u306eM\u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u307e\u3067\u306f\u4f55\u6642\u9593\u304b\u3001\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nM = int(input())\nprint(48 - M) #30\u65e531\u65e5\u306e\u5408\u8a0848\u6642\u9593\u304b\... | {"inputs": ["21\n", "12\n"], "outputs": ["27\n", "36\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 6,319 | |
32b2859be298b312326531d86d356cc1 | UNKNOWN | You are given two integers A and B as the input. Output the value of A + B.
However, if A + B is 10 or greater, output error instead.
-----Constraints-----
- A and B are integers.
- 1 ≤ A, B ≤ 9
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
If A + B is 10 or great... | ["# A - Restricted\n# https://atcoder.jp/contests/abc063/tasks/abc063_a\n\nA, B = list(map(int, input().split()))\n\nresult = A + B\nif result >= 10:\n print('error')\nelse:\n print(result)\n", "l = input().split()\n\nans = int(l[0]) + int(l[1])\n\nif 10 <= ans:\n print('error')\nelse:\n print(ans)", "a, b = ... | {"inputs": ["6 3\n", "6 4\n"], "outputs": ["9\n", "error\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 12,770 | |
407b8d9597fbfcb4a079f8163a07bddf | UNKNOWN | It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.
There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.
Find the minimum distance to be traveled when AtCoDeer can start an... | ["N=int(input())\nA=list(map(int, input().split()))\n\nprint(max(A)-min(A))", "n = int(input())\nli = list(map(int,input().split()))\nli.sort()\nprint(li[-1]-li[0])", "N = int(input())\na = list(map(int, input().split()))\nprint(max(a)-min(a))", "N = int(input())\nlist = sorted(map(int,input().split()))\n\nprint(list[N... | {"inputs": ["4\n2 3 7 9\n", "8\n3 1 4 1 5 9 2 6\n"], "outputs": ["7\n", "8\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 13,837 | |
5bc1217e35f47c6d6d25513f5f9d66bf | UNKNOWN | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.
Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
-----Constraints-----
- x and y are integers.
- 1 ≤ x < y ≤ 12
-----Input-----
Input is given from Stand... | ["n1 = [1, 3, 5, 7, 8, 10, 12]\nn2 = [4, 6, 9, 11]\n\na, b = list(map(int, input().split()))\nprint((\"Yes\" if a in n1 and b in n1 or a in n2 and b in n2 else \"No\"))\n", "lst1 = [4,6,9,11]\nlst2 = [2]\nlst3 = [1,3,5,7,8,10,12]\nx,y = map(int,input().split())\nif x in lst1 and y in lst1:\n print('Yes')\nelif x in ... | {"inputs": ["1 3\n", "2 4\n"], "outputs": ["Yes\n", "No\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 23,058 | |
ce290302ac9b6d6322d087637cdb1d56 | UNKNOWN | AtCoDeer the deer found two positive integers, a and b.
Determine whether the product of a and b is even or odd.
-----Constraints-----
- 1 ≤ a,b ≤ 10000
- a and b are integers.
-----Input-----
Input is given from Standard Input in the following format:
a b
-----Output-----
If the product is odd, print Odd; if it i... | ["a, b = map(int, input().split())\nif a*b %2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nif a % 2 == 0:\n print('Even')\nelif b % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a,b=map(int, input().split())\n\nif a*b%2==0:\n print(\"Even\")\nelse:\n print(\"Odd... | {"inputs": ["3 4\n", "1 21\n"], "outputs": ["Even\n", "Odd\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,169 | |
532f892ae42b4d4be34bd9cbe2b0de4e | UNKNOWN | Snuke loves puzzles.
Today, he is working on a puzzle using S- and c-shaped pieces.
In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:
Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.
Find the m... | ["n, m = [int(x) for x in input().split()]\nans = min(n, m // 2)\nans += (m - ans * 2) // 4\nprint(ans)", "N,M=map(int,input().split())\nans=0\nif 2*N<=M:\n ans+=N\n M-=2*N\nelse:\n ans+=(M//2)\n M-=(M//2)*2\nans+=(M//4)\nprint(ans)", "def main():\n n, m = map(int, input().split())\n\n if m - 2 * n >= 0:\n ... | {"inputs": ["1 6\n", "12345 678901\n"], "outputs": ["2\n", "175897\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,930 | |
5e916720978e3ef223e6f7d423cd6741 | UNKNOWN | Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N.
Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).
Also, there are M kinds of drinks offered to the contestants, numbered 1 through M.
If Joisino takes dr... | ["N = int(input())\nT = [int(TN) for TN in input().split()]\nSumT = sum(T)\nM = int(input())\nPX = [[] for TM in range(0,M)]\nfor TM in range(0,M):\n PX[TM] = [int(TPX) for TPX in input().split()]\nfor TM in range(0,M):\n print(SumT-T[PX[TM][0]-1]+PX[TM][1])", "n = int(input())\nli = list(map(int,input().split())... | {"inputs": ["3\n2 1 4\n2\n1 1\n2 3\n", "5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n"], "outputs": ["6\n9\n", "19\n25\n30\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 27,620 | |
c7aed97e00cd42ba6e04b491ddc81328 | UNKNOWN | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.
She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).
However, as mentioned before, she is very pa... | ["import itertools\n\ndef cal(N, target_num, keta):\n answer = float('inf')\n for p in itertools.product(target_num, repeat=keta):\n temp = 0\n for i, num in enumerate(p):\n temp += num * 10**i\n \n if temp >= N:\n answer = min(answer, temp)\n\n return answ... | {"inputs": ["1000 8\n1 3 4 5 6 7 8 9\n", "9999 1\n0\n"], "outputs": ["2000\n", "9999\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 39,229 | |
813c53d8b5eea7cc38d171f30a3d1590 | UNKNOWN | There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.
Obs. i is said to be good when its elevation is higher than those of all observatories that can be re... | ["N,M = map(int,input().split())\nhigh = list(map(int,input().split()))\nans = [0]*N\ncnt = 0\nfor i in range(M):\n a,b = map(int,input().split())\n ans[a-1] = max(high[b-1],ans[a-1])\n ans[b-1] = max(ans[b-1],high[a-1])\n\nfor j in range(N):\n if ans[j] < high[j]:\n cnt += 1\nprint(cnt)", "N, M = li... | {"inputs": ["4 3\n1 2 3 4\n1 3\n2 3\n2 4\n", "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n"], "outputs": ["2\n", "3\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 42,609 | |
b33ab3376c5f160ec1831bf64e6293b0 | UNKNOWN | Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
- Operation A: The displayed value is doubled.
- Operation B: The displayed value increases by K.
Square1001 needs to perform these operations N times in total.
Find the minim... | ["#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\nk = int(input())\n\nans = 1\nfor i in range(n):\n if ans*2 <= (ans+k):\n ans *= 2\n else:\n ans += k\n # print(ans)\nprint(ans)\n", "N = int(input())\nK = int(input())\n\nvalue = 1\n\nfor i in range(N):\n if(... | {"inputs": ["4\n3\n", "10\n10\n"], "outputs": ["10\n", "76\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,067 | |
d11ff4ddcbc1f5c61c36cce91a28be02 | UNKNOWN | Given is an integer x that is greater than or equal to 0, and less than or equal to 1.
Output 1 if x is equal to 0, or 0 if x is equal to 1.
-----Constraints-----
- 0 \leq x \leq 1
- x is an integer
-----Input-----
Input is given from Standard Input in the following format:
x
-----Output-----
Print 1 if x is equal... | ["X=int(input())\nprint(1-X)", "x = int(input())\nprint(1 if x == 0 else 0)", "num = int(input())\nif num == 0:\n print(1)\nelif num == 1:\n print(0)", "x=int(input())\n\nif x==0:\n print((1))\nelse:\n print((0))\n\n", "x=int(input())\nprint(1 if x==0 else 0)", "x=int(input())\nif x==0:\n print(1)\nelse:... | {"inputs": ["1\n", "0\n"], "outputs": ["0\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 6,055 | |
0aca57b60386139fa9c0e79743be34aa | UNKNOWN | You are given a string S consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.
All strings that can be obtained in this way can be evaluated as formulas.
Evaluate a... | ["import copy\n\ns=input()\nl=len(s)\nans=0\n\nif l==1:\n ans+=int(s)\n print(ans)\n \nelse:\n for i in range(2**(l-1)):\n t=copy.deepcopy(s)\n f=[]\n ch=0\n for j in range(l-1):\n if ((i>>j)&1):\n t=t[:j+1+ch]+'+'+t[j+1+ch:]\n ch+=1\n \n if '+' in t:\n \n y=list(map(... | {"inputs": ["125\n", "9999999999\n"], "outputs": ["176\n", "12656242944\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 33,039 | |
d3a020479c388f23e227d8005fd3bca7 | UNKNOWN | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
Here, both Snuke and Raccoon have to take at least one card.
Let the ... | ["import sys\nimport itertools\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN = ini(... | {"inputs": ["6\n1 2 3 4 5 6\n", "2\n10 -10\n"], "outputs": ["1\n", "20\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 31,045 | |
2340c5e77ed9a853b2c045bf7f600fec | UNKNOWN | Snuke has a favorite restaurant.
The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.
So far, Snuke has ordered N meals at the restaurant.
Let the amount of money Snuke has paid to the restaurant be... | ["# \uff11\u98df\uff18\uff10\uff10\u5186\u3092N\u98df\u98df\u3079\u305f\nN = int( input() )\nx = int( 800 * N )\n\n# \uff11\uff15\u98df\u98df\u3079\u308b\u3054\u3068\u306b\uff12\uff10\uff10\u5186\u3082\u3089\u3048\u308b\n\ny = N // 15 * 200\n\nprint( x - y )", "N = int(input())\nprint(N * 800 - N // 15 * 200)", "N = i... | {"inputs": ["20\n", "60\n"], "outputs": ["15800\n", "47200\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,409 | |
969780f91c2674a8876b88577ffc9fdc | UNKNOWN | We have a 3×3 square grid, where each square contains a lowercase English letters.
The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.
Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bott... | ["cij = [list(input()) for _ in range(3)]\n\nprint(cij[0][0] + cij[1][1] + cij[2][2])", "def resolve():\n matrix = []\n for i in range(3):\n line = input()\n matrix.append(line)\n ans = \"\"\n for i in range(3):\n ans += matrix[i][i]\n print(ans)\nresolve()", "print(\"\".join(input()... | {"inputs": ["ant\nobe\nrec\n", "edu\ncat\nion\n"], "outputs": ["abc\n", "ean\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 9,133 | |
413b521961a05e54d9386e1e125d047d | UNKNOWN | Snuke has a grid consisting of three squares numbered 1, 2 and 3.
In each square, either 0 or 1 is written. The number written in Square i is s_i.
Snuke will place a marble on each square that says 1.
Find the number of squares on which Snuke will place a marble.
-----Constraints-----
- Each of s_1, s_2 and s_3 is ei... | ["s=input()\ncount=0\nfor i in range(len(s)):\n if(s[i]==\"1\"):\n count+=1\nprint(count)", "a=input()\nprint((a.count('1')))\n", "# -*- coding: utf-8 -*-\n# \u6574\u6570\u306e\u5165\u529b\ns = input()\nnumber = \"1\"\n\ncount = s.count(number)\nprint(count)", "print(input().count(\"1\"))", "cnt = 0\nfor s in... | {"inputs": ["101\n", "000\n"], "outputs": ["2\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 8,734 | |
35e00c74f4ee02f5b342b7ac245f8bbf | UNKNOWN | There is a hotel with the following accommodation fee:
- X yen (the currency of Japan) per night, for the first K nights
- Y yen per night, for the (K+1)-th and subsequent nights
Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.
-----Constraints-----
- 1 \leq N, K \leq 10000
... | ["\nN = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif K < N:\n ans = K*X + (N-K)*Y\nelse:\n ans = N*X\nprint(ans)", "N, K, X, Y = [int(input()) for _ in range(4)]\nprint(X * min(K, N) + Y * max(0, N - K))", "n,k,x,y = [int(input()) for _ in range(4)]\n\nif k <= n:\n sum = (x * k) + (y ... | {"inputs": ["5\n3\n10000\n9000\n", "2\n3\n10000\n9000\n"], "outputs": ["48000\n", "20000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 17,817 | |
c5077d9fefc8421e171cbad2042edd66 | UNKNOWN | Joisino wants to evaluate the formula "A op B".
Here, A and B are integers, and the binary operator op is either + or -.
Your task is to evaluate the formula instead of her.
-----Constraints-----
- 1≦A,B≦10^9
- op is either + or -.
-----Input-----
The input is given from Standard Input in the following format:
A op... | ["a, o, b = input().split()\nif o == '+':\n print((int(a) + int(b)))\nelse:\n print((int(a) - int(b)))\n", "a, op, b = input().split()\n\na = int(a)\nb = int(b)\n\nif op == \"+\":\n S = a + b\nelse:\n S = a - b\n\nprint(S)\n", "A, op, B = input().split()\nif op == '-':\n print((int(A) - int(B)))\nelse:\n ... | {"inputs": ["1 + 2\n", "5 - 7\n"], "outputs": ["3\n", "-2\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,252 | |
b72cdbdc6caaedb1dd40f7476065507a | UNKNOWN | Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.
You are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.
-----Constraints-----
- 1 ≦ x ≦ 3{,}000
... | ["x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "print('ABC' if int(input())<1200 else 'ARC')", "x = int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif x < 1200 :\n print( \"ABC\" )\nelse:\n print( \"ARC\" )", "print(\"ABC\" if int(inp... | {"inputs": ["1000\n", "2000\n"], "outputs": ["ABC\n", "ARC\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,889 | |
019054178ba33f359df65db2fbc2d25d | UNKNOWN | Snuke is buying a bicycle.
The bicycle of his choice does not come with a bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for each hand.
The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.
Find the min... | ["# A - ringring\n# https://atcoder.jp/contests/abc066/tasks/abc066_a\n\na = list(map(int, input().split()))\n\na.sort()\nprint((a[0] + a[1]))\n", "a, b, c = map(int, input().split())\n\nprint(min(a+b, b+c, c+a))", "# A - ringring\ndef main():\n abc = list(map(int, input().split()))\n abc.sort()\n cnt = 0\n\n ... | {"inputs": ["700 600 780\n", "10000 10000 10000\n"], "outputs": ["1300\n", "20000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 12,405 | |
614ce4c391dff612a14b1de94273f921 | UNKNOWN | You are given a image with a height of H pixels and a width of W pixels.
Each pixel is represented by a lowercase English letter.
The pixel at the i-th row from the top and j-th column from the left is a_{ij}.
Put a box around this image and output the result. The box should consist of # and have a thickness of 1.
---... | ["H, W = map(int, input().split())\ns = '#' * (W + 2)\ndata = []\ndata.append(s)\nfor i in range(H):\n data.append('#' + str(input()) + '#')\ndata.append(s)\n \nfor i in range(H + 2):\n print(data[i])", "h, w = map(int, input().split())\na = [input() for _ in range(h)]\nfor i in range(h+2):\n if i == 0 or i ... | {"inputs": ["2 3\nabc\narc\n", "1 1\nz\n"], "outputs": ["#####\n#abc#\n#arc#\n#####\n", "###\n#z#\n###\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 20,667 | |
8771505050a8aeee118055085b333a44 | UNKNOWN | You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.
Find the maximum value taken by x during the... | ["N = int(input())\nS = input()\nres = 0\ntmp = 0\nfor s in S:\n if s == 'I':\n tmp += 1\n elif s == 'D':\n tmp -= 1\n \n res = max(res, tmp)\n\nprint(res)\n", "n=int(input())\ns=input()\nx=0\nans=0\nfor i in range(n):\n if s[i]==\"I\":\n x+=1\n else:\n x-=1\n ans=max(ans,x)\nprint(ans)... | {"inputs": ["5\nIIDID\n", "7\nDDIDDII\n"], "outputs": ["2\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 18,479 | |
fbdcabff2e729c8396767090bb1a5624 | UNKNOWN | Find the number of palindromic numbers among the integers between A and B (inclusive).
Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
-----Constraints-----
- 10000 \leq A \leq B \leq 99999
- All input values are int... | ["a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n c = str(i)\n l = len(c)\n d = l // 2\n cnt = 0\n for i in range(d):\n if c[i] == c[-i-1]:\n cnt += 1\n if cnt == d:\n ans += 1\nprint(ans)", "A,B = list(map(str,input().split()))\nLa = [int(A[:3]),int(A[3:])]\... | {"inputs": ["11009 11332\n", "31415 92653\n"], "outputs": ["4\n", "612\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 20,774 | |
e9c2fea75c616c1078b54c5fd1836387 | UNKNOWN | AtCoDeer the deer recently bought three paint cans.
The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.
Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.
Since he is forgetful, he might... | ["a=list(map(int,input().split()))\nprint(len(set(a)))", "s = list(map(int,input().split()))\nprint(len(set(s)))", "lst = input().split()\nif len(lst) == len(set(lst)):\n\tprint('3')\nif len(lst)-1 == len(set(lst)):\n\tprint('2')\nif len(lst)-2 == len(set(lst)):\n\tprint('1')\n", "l = input().split()\nprint((len(set(l)... | {"inputs": ["3 1 4\n", "3 3 33\n"], "outputs": ["3\n", "2\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,658 | |
eb44ed541080f4b81506c1c2e9cb8399 | UNKNOWN | Snuke has N sticks.
The length of the i-th stick is l_i.
Snuke is making a snake toy by joining K of the sticks together.
The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.
-----Constraints-----
- 1 \leq K \leq N \leq 50
- 1 \leq l_i... | ["N,K=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nsum=0\nfor i in range(K) :\n sum+=l[i]\nprint(sum)", "n,k=map(int,input().split())\ndata=list(map(int,input().split()))\ny=sorted(data)\ns=0\nfor i in range(0,k):\n s=s+y[n-1-i]\nprint(s)", "n,k=map(int,input().split())\nl=list(... | {"inputs": ["5 3\n1 2 3 4 5\n", "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n"], "outputs": ["12\n", "386\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,171 | |
9db2a84571798cd2143e07aeaa13cb68 | UNKNOWN | Snuke lives at position x on a number line.
On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B.
Find out which store is closer to Snuke's residence.
Here, the distance between two points s and t... | ["x, a, b = (int(x) for x in input().split())\nif abs(a-x) < abs(b-x):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nif abs(x - a) < abs(x - b): print('A')\nelse: print('B')", "x, a, b = map(int, input().split())\nprint(\"AB\"[abs(x-a)>abs(x-b)::2])", "x,a,b = map(int,input().split(... | {"inputs": ["5 2 7\n", "1 999 1000\n"], "outputs": ["B\n", "A\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,608 | |
ea7d77ce5bd5e3072020f3a086bafa1c | UNKNOWN | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Wr... | ["s=input()\nprint(\"2018\"+s[4:])", "def main():\n s = input()\n print(f\"2018{s[4:]}\")\n\n\nmain()", "print(input().replace('2017','2018'))", "y, m, d = list(map(str, input().split('/')))\nprint(('2018' + '/' + m + '/' + d))\n", "S = input()\nprint(S.replace('7', '8', 1))", "s = input()\nprint(s.replace('7', '... | {"inputs": ["2017/01/07\n", "2017/01/31\n"], "outputs": ["2018/01/07\n", "2018/01/31\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 5,735 | |
8cab75d920b04f8b66c420e6681c2a35 | UNKNOWN | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S_1,...,S_n tomorrow.
He is excited and already thinking of what string he will create.
Since he does not know the string on the headline... | ["# \u3072\u3063\u304f\u308a\u304b\u3048\u3059\u306e\u304b\u3068\u304a\u4fdd\u3063\u305f\u3089180\u5ea6\u53cd\u8ee2\u3060\u3063\u305f\nn = int(input())\nd = []\nfor _ in range(n):\n s = list(input())\n d.append(s)\n\nd = sorted(d, key=lambda dd: len(dd), reverse=True)\nbase = {}\nfor c in d[0]:\n if c not in b... | {"inputs": ["3\ncbaa\ndaacc\nacacac\n", "3\na\naa\nb\n"], "outputs": ["aac\n", "\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 37,558 | |
5c17759f78d31f4b5277333deed147d1 | UNKNOWN | Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
-----Constr... | ["N = int(input())\nans = 0\nfor _ in range(N):\n a, b = map(int, input().split())\n ans += b - a + 1\nprint(ans)", "N = int(input())\nans = 0\nfor _ in range(N):\n l, r = map(int, input().split())\n ans += r-l+1\n\nprint(ans)", "with open(0) as f:\n N, *lr = map(int, f.read().split())\nprint(sum(lr[1::2])-s... | {"inputs": ["1\n24 30\n", "2\n6 8\n3 3\n"], "outputs": ["7\n", "4\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,520 | |
6dac46a7ea16b113ca5d34df6c90da28 | UNKNOWN | In K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
-----Constraints-----
- 2 ≤ n, m ≤ 10... | ["a, b = map(int, input().split())\nprint((a - 1) * (b - 1))", "n,m = map(int,input().split())\n\nprint((n-1)*(m-1))", "m, n = map(int, input().split())\nprint((m - 1) * (n - 1))", "a,b = map(int,input().split())\nprint((a-1)*(b-1))", "x,y=map(int,input().split())\n\nprint((x-1)*(y-1))", "n, m = list(map(int, input().s... | {"inputs": ["3 4\n", "2 2\n"], "outputs": ["6\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 7,397 | |
238ec6f4fd934b89e8f6b6c80c5f091d | UNKNOWN | Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether Snuke can give cookies to his three goats so that each of them can ... | ["A, B = map(int, input().split())\nC = A + B\n\nprint(\"Possible\" if A%3==0 or B%3==0 or C%3==0 else \"Impossible\")", "A, B = map(int, input().split())\n\nif A%3 and B%3 and (A+B)%3:\n print(\"Impossible\")\nelse:\n print(\"Possible\")", "A, B = map(int, input().split())\n\n# A, B, A+B \u306e\u3044\u305a\u308c\u30... | {"inputs": ["4 5\n", "1 1\n"], "outputs": ["Possible\n", "Impossible\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 19,706 | |
b3dca7dd08118d9374070f5eb0ddc105 | UNKNOWN | E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.
One more ... | ["# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 02:20:36 2020\n\n@author: liang\n\"\"\"\nS = input()\nT = input()\n\nS = S[::-1]\nT = T[::-1]\n\nres = list()\n\nfor i in range(len(S)-len(T)+1):\n flag = True\n for j in range(len(T)):\n if S[i+j] == \"?\" or S[i+j] == T[j]:\n continue\n ... | {"inputs": ["?tc????\ncoder\n", "??p??d??\nabc\n"], "outputs": ["atcoder\n", "UNRESTORABLE\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 62,187 | |
a933233a0c3be7704cad52948dbe1f7f | UNKNOWN | Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:
- Let the current rating of the user be a.
- Suppose that the performance of the user in the contest is... | ["# \u73fe\u5728\u3068\u76ee\u6a19\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u53d6\u5f97\nR = int(input())\nG = int(input())\n\n# \u76ee\u6a19\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u306a\u308b\u305f\u3081\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6570\u5024\u3092\u8a08\u7b97\nTarget = (G * ... | {"inputs": ["2002\n2017\n", "4500\n0\n"], "outputs": ["2032\n", "-4500\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 13,202 | |
f6e34a6b946297e6ab2346a88f30ad63 | UNKNOWN | Given head, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected ... | ["class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n if head == None:\n return False\n \n slow = head\n fast = head.next\n \n while slow != fast:\n if fast is None or fast.next is None:\n return False\n slow = slow... | {"fn_name": "hasCycle", "inputs": [[[3,2,0,-4], 1], [[1,2], 0], [[1], -1]], "outputs": [[true], [true], [false]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 2,225 |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def hasCycle(self, head: ListNode) -> bool:
|
b194f7e5e676fd7822c67b098935bcac | UNKNOWN | Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1... | ["class Solution:\n def twoSum(self, nums, target):\n tmp = {}\n for i in range(len(nums)):\n if target - nums[i] in tmp:\n return(tmp[target - nums[i]], i)\n else:\n tmp[nums[i]] = i;\n \n \"\"\"\n :type nums: List[int]... | {"fn_name": "twoSum", "inputs": [[[2,7,11,15], [9]], [[3,2,4], [6]], [[3,3], [6]]], "outputs": [[0,1], [1,2], [0,1]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 11,200 |
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.