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
091ff1628ea76dfcb5f74b82ce37c817
UNKNOWN
You are given a positive integer $n$, it is guaranteed that $n$ is even (i.e. divisible by $2$). You want to construct the array $a$ of length $n$ such that: The first $\frac{n}{2}$ elements of $a$ are even (divisible by $2$); the second $\frac{n}{2}$ elements of $a$ are odd (not divisible by $2$); all elements of...
["for _ in range(int(input())):\n n=int(input())\n if(n%4!=0):\n print('NO')\n elif(n%4==0):\n print('YES')\n a=[]\n for i in range(1,n//2+1):\n a.append(i*2)\n s=sum(a)\n s1=0\n for i in range(1,n//2):\n x=i*2-1\n a.append(x)\n ...
{"inputs": ["5\n2\n4\n6\n8\n10\n", "1\n199998\n", "3\n2\n4\n6\n"], "outputs": ["NO\nYES\n2 4 1 5\nNO\nYES\n2 4 6 8 1 3 5 11\nNO\n", "NO\n", "NO\nYES\n2 4 1 5\nNO\n"]}
INTRODUCTORY
PYTHON3
CODEFORCES
3,331
7fdca26a5ae00cbd42920bed248642d9
UNKNOWN
Pay attention to the non-standard memory limit in this problem. In order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled statically typed languages (e.g. C++). If you use Python, then submit solutions on PyPy. Try to write an efficient solut...
["for _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n keke = dict()\n for elem in ar:\n if elem in keke:\n keke[elem] += 1\n else:\n keke[elem] = 1\n ans = 0\n for i in range(n):\n num = ar[i]\n for j in range(i + ...
{ "inputs": [ "5\n9\n3 1 4 1 5 9 2 6 5\n3\n1 1 2\n5\n1 1 1 1 1\n8\n8 7 6 5 4 3 2 1\n1\n1\n", "7\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n2 1 3 1 3\n4\n4 3 4 3\n" ], "outputs": [ "5\n1\n0\n4\n0\n", "0\n0\n0\n0\n0\n0\n0\...
INTRODUCTORY
PYTHON3
CODEFORCES
3,403
2ade33375ea926879e1323cf7481d03a
UNKNOWN
You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \le x \le r_i$ holds, belong to the $i$-th segment. Your task is to choose the maximum by size (the number of segments) subset of the given set of segments such that each pair of segments i...
["import sys\nfrom collections import deque\n\ninput=sys.stdin.readline\n\nt=1\nt=int(input())\nfor _ in range(t):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):\n l,r=list(map(int,input().split()))\n val.add(l)\n val.add(r)\n seg.append((l,r...
{ "inputs": [ "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n2 5\n3 4\n4 4\n6 8\n7 7\n", "1\n1\n1 200000\n", "1\n1\n100000 100001\n" ], "outputs": [ "3\n4\n2\n7\n", "1\n", "1\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
14,785
bff65cffd0fd7ee6a59a00536323aa9f
UNKNOWN
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $h$ hours and $m$ minutes, where $0 \le hh < 24$ and $0 \le mm < 60$. We use 24-hour time format! Your task is to find the number of minutes before the New Year. You know that New Year co...
["a = int(input())\nfor i in range(a):\n x, y = map(int, input().split())\n t = x * 60 + y\n print(24*60 - t)", "import sys\ninput = sys.stdin.readline\ndef getInt(): return int(input())\ndef getVars(): return list(map(int, input().split()))\ndef getList(): return list(map(int, input().split()))\ndef getStr():...
{ "inputs": [ "5\n23 55\n23 0\n0 1\n4 20\n23 59\n", "5\n23 55\n22 30\n21 10\n20 21\n19 59\n", "1\n1 2\n" ], "outputs": [ "5\n60\n1439\n1180\n1\n", "5\n90\n170\n219\n241\n", "1378\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
7,742
e1cd3c68cd33acd928eb7e57b2f952a5
UNKNOWN
There is a robot on a coordinate plane. Initially, the robot is located at the point $(0, 0)$. Its path is described as a string $s$ of length $n$ consisting of characters 'L', 'R', 'U', 'D'. Each of these characters corresponds to some move: 'L' (left): means that the robot moves from the point $(x, y)$ to the poin...
["for _ in range(int(input())):\n n = int(input())\n s = input()\n balance = 0\n index = {0: 1}\n ans = [10**9]\n i = 1\n for x in s:\n if x == 'U':\n balance += 10 ** 9\n elif x == 'D':\n balance -= 10 ** 9\n elif x == 'L':\n balance += 1\n ...
{ "inputs": [ "4\n4\nLRUD\n4\nLURD\n5\nRRUDU\n5\nLLDDR\n", "1\n10\nRULLDRRULD\n", "1\n23\nRUURRDDLLUUURRRDDDLLLUD\n" ], "outputs": [ "1 2\n1 4\n3 4\n-1\n", "7 10\n", "22 23\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
13,133
f76f44929ef72360283b371053236157
UNKNOWN
You have $n$ students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the $i$-th student skill is denoted by an integer $a_i$ (different students can have the same skills). So, about the teams. Firstly, these two teams should have...
["from collections import defaultdict as dd\nfor _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n d=dd(int)\n for i in a:\n d[i]+=1\n ma=0\n r=len(d.keys())\n for i in d.keys():\n ma=max(ma,min(d[i]-1,r),min(d[i],r-1))\n print(ma)", "#!usr/bin/env pyt...
{ "inputs": [ "4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 4 3\n1\n1\n4\n1 1 1 3\n", "1\n9\n1 2 2 3 3 9 9 9 9\n", "5\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" ], "outputs": [ "3\n1\n0\n2\n", "3\n", "0\n0\n0\n0\n0\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
6,042
f4264969b3998b189acd8fcd82615215
UNKNOWN
You are given an array $a$ consisting of $n$ positive integers. Initially, you have an integer $x = 0$. During one move, you can do one of the following two operations: Choose exactly one $i$ from $1$ to $n$ and increase $a_i$ by $x$ ($a_i := a_i + x$), then increase $x$ by $1$ ($x := x + 1$). Just increase $x$ by $...
["t = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n l = list(map(int, input().split()))\n \n d = dict()\n d[0] = 0\n for v in l:\n vv = (k - v) % k\n if vv:\n if vv not in d:\n d[vv] = vv + 1\n else:\n d[vv...
{ "inputs": [ "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 5 10 8 9\n5 10\n20 100 50 20 100500\n10 25\n24 24 24 24 24 24 24 24 24 24\n8 8\n1 2 3 4 5 6 7 8\n", "1\n1 1000000000\n99999999\n", "1\n5 3\n20 100 50 20 1005002\n" ], "outputs": [ "6\n18\n0\n227\n8\n", "900000002\n", "11\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
6,770
1cdba08b4f5aaf06e46cb52e2a6dae55
UNKNOWN
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi, we can assign the cookie j to the...
["class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n res = 0\n heapq.heapify(g)\n s.sort()\n for num in s:\n if not g:\n break\n ...
{"fn_name": "findContentChildren", "inputs": [[[2, 3], [1, 1]], [[1,2,3], [1,1]], [[1,2], [1,2,3]]], "outputs": [0, 1, 2]}
INTRODUCTORY
PYTHON3
LEETCODE
5,886
class Solution: def findContentChildren(self, g: List[int], s: List[int]) -> int:
6d44a4ffbe4b97cce7f6983418ca6de7
UNKNOWN
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0. In Pascal's triangle, each number is the sum of the two numbers directly above it. Example: Input: 3 Output: [1,3,3,1] Follow up: Could you optimize your algorithm to use only O(...
["class Solution:\n def getRow(self, k):\n \"\"\"\n :type k: int\n :rtype: List[int]\n \"\"\"\n res = [1]\n cur = k\n for i in range(k//2):\n res += res[-1] * cur // (i+1),\n cur -= 1\n if k % 2 == 0:\n res = res + r...
{"fn_name": "getRow", "inputs": [[3], [0], [1]], "outputs": [[1,3,3,1], [1], [1,1]]}
INTRODUCTORY
PYTHON3
LEETCODE
4,231
class Solution: def getRow(self, rowIndex: int) -> List[int]:
ac70fbe8251ee3e66518b1191af2821a
UNKNOWN
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as...
["class Solution:\n def hammingWeight(self, n: int) -> int:\n count = 0\n while n!=0:\n n &= (n-1)\n count += 1\n return count", "class Solution:\n def hammingWeight(self, n: int) -> int:\n return len([x for x in bin(n) if x =='1'])", "class Solution:\n def ham...
{"fn_name": "hammingWeight", "inputs": [[11], [128], [4294967293]], "outputs": [3, 1, 31]}
INTRODUCTORY
PYTHON3
LEETCODE
952
class Solution: def hammingWeight(self, n: int) -> int:
abd6d5c6d012dee40655b47c9db4ac18
UNKNOWN
Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. You may assume the integer does not contain any leading zero, except the number 0...
["class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n carry=1\n for i in range(len(digits)-1, -1, -1):\n digits[i]+=carry\n if digits[i] > 9:\n digits[i]-=10\n ...
{"fn_name": "plusOne", "inputs": [[[1,2,3]], [[4,3,2,1]], [[0]]], "outputs": [[1,2,4], [4,3,2,2], [1]]}
INTRODUCTORY
PYTHON3
LEETCODE
5,639
class Solution: def plusOne(self, digits: List[int]) -> List[int]:
91dc94372aba883a0c9868b3889263cc
UNKNOWN
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B. -----Constraints----- - -1000 \leq A,B \leq 1000 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: A B -----Output----- Print the largest value among A+B, A-B and ...
["a,b=map(int,input().split(\" \"))\nprint(max(max(a+b,a*b),a-b))", "a, b = map(int, input().split())\n\nprint(max(a + b, a - b, a * b))", "a,b=map(int, input().split())\n\na_list=[a+b,a-b,a*b]\n\nprint(max(a_list))", "A, B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "a, b = map(int, input().split())\nprin...
{"inputs": ["3 1\n", "4 -2\n", "0 0\n"], "outputs": ["4\n", "6\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,126
e6c4d0f99de39c534dc2db55ca775b89
UNKNOWN
We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sq...
["def main():\n\tN, D = [int(n) for n in input().split(\" \")]\n\tcnt = 0\n\tfor i in range(N):\n\t\tX, Y = [int(x) for x in input().split(\" \")]\n\t\tif X ** 2 + Y ** 2 <= D ** 2:\n\t\t\tcnt += 1\n\tprint(cnt)\n\nmain()\n", "N,D = map(int,input().split())\n\nxy = [list(map(int,input().split())) for i in range(N)]\n\n...
{"inputs": ["4 5\n0 5\n-2 4\n3 4\n4 -4\n", "12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n", "20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n...
INTRODUCTORY
PYTHON3
ATCODER.JP
22,191
fc9172e93659ca22203bdf08e6cd2c4e
UNKNOWN
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. -----Constraints----- - 1?N?10^8 - N is an integer. -----Input----- Input is given from Standard Input in the following f...
["N = input()\nX = int(N)\nif X % sum(list(map(int, N))) == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\nfx = sum([int(i) for i in str(n)])\n\n\nif n % fx == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = str(inp...
{"inputs": ["12\n", "57\n", "148\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,931
bb7fb1b7da8d02d027f0635d42f4f88c
UNKNOWN
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from ...
["N=int(input())\nA=list(map(int,input().split()))\n\nSUM=abs(A[0])\nfor i in range(N):\n if i < N-1:\n SUM += abs(A[i+1]-A[i])\n else:\n SUM += abs(0-A[i])\n\nnow=0\nfor i in range(N):\n if i != N-1:\n diff = abs(A[i+1]-now)-abs(A[i]-now)-abs(A[i+1]-A[i])\n now = A[i]\n else:\n diff = abs(0-now)-abs...
{"inputs": ["3\n3 5 -1\n", "5\n1 1 1 2 0\n", "6\n-679 -2409 -3258 3095 -3291 -4462\n"], "outputs": ["12\n8\n10\n", "4\n4\n4\n2\n4\n", "21630\n21630\n19932\n8924\n21630\n19288\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
36,784
0fa7752843cd9f7b8506842cb5c7195f
UNKNOWN
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u. -----Constraints----- - c is a lowercase English letter. -----Input----- The input is given from Standard Input in the following format: c -----Output----- If c is a vowel, pri...
["c = input()\n\nvo = ['a','e','i','o','u']\nprint('vowel' if c in vo else 'consonant')", "\nc = str(input())\nvowels = ['a','e','i','o','u']\n\nif c in vowels:\n answer = \"vowel\"\nelse:\n answer = \"consonant\"\n\nprint(answer)\n", "C = input()\nif C in 'aiueo':\n print('vowel')\nelse:\n print('consonant...
{"inputs": ["a\n", "z\n", "s\n"], "outputs": ["vowel\n", "consonant\n", "consonant\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,339
6c2308af1c9a8ad5801789c9164102cb
UNKNOWN
Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones b...
["s= input()\ncolor = \"chokudai\"\nd = []\n\nfor c in s:\n if c != color:\n d.append(c)\n color = c\nprint(len(d)-1)", "s = input()\ncnt = 1\ncw = s[0]\nfor i in range(len(s)):\n if s[i] != cw: \n cnt += 1\n cw = s[i]\nprint(cnt - 1)", "S = str(input())\nSum = 0 \nfor i in range(len(S) - 1):\n...
{"inputs": ["BBBWW\n", "WWWWWW\n", "WBWBWBWBWB\n"], "outputs": ["1\n", "0\n", "9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
19,898
9543be8b54f1d8fdd8f62a8bf27dbf83
UNKNOWN
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. -----Constraints----- - 1 ≤ a,b ≤ 100 - a and b are integers. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- If the concaten...
["\n#ABC086B\na,b = input().split()\na += b\na = int(a)\nprint(\"Yes\" if int((a**.5))**2 == a else \"No\")", "a, b = input().split()\nab = int(a+b)\n\nfor j in range(ab):\n if j ** 2 <= ab:\n if j ** 2 == ab:\n print(\"Yes\")\n return\n else:\n print(\"No\")\n return", ...
{"inputs": ["1 21\n", "100 100\n", "12 10\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,333
62c8e54fb6b8a6d482b2ff6929877acb
UNKNOWN
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices. -----Constraints----- - 1≤N...
["# -1 0 1\u3092\u8db3\u3057\u305f\u3082\u306e\u306e\u3046\u3061\u6700\u5927\u5024\u3092\u6570\u3048\u308b\nn = int(input())\na = list(map(int, input().split()))\n# ai=0\u306e\u5834\u5408\u3082\u3042\u308b\u306e\u3067-1\u304c\u3042\u308a\u3048\u308b\u3053\u3068\u306b\u6ce8\u610f \u9069\u5f53\u306ba[0]\u3092-1\u306e\u65...
{"inputs": ["7\n3 1 4 1 5 9 2\n", "10\n0 1 2 3 4 5 6 7 8 9\n", "1\n99999\n"], "outputs": ["4\n", "3\n", "1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
28,532
83e356c45cabd5d5cdd592b5c80903cc
UNKNOWN
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black? -----Constraints----- - 1 \leq N \leq 100 - 0 \leq A \leq N^2 -----Inputs----- Input is given from Standard Input in the following format: N A ...
["print(int(input())**2 - int(input()))", "a=int(input())\nb=int(input())\nprint(a*a-b)", "n = int(input())\na = int(input())\nprint(n*n-a)", "N = int(input())\nA = int(input())\nprint((N*N - A))\n", "n = int(input())\na = int(input())\n\nprint(n*n-a)", "N = int(input())\nA = int(input())\nprint(N**2-A)", "n = int(inpu...
{"inputs": ["3\n4\n", "19\n100\n", "10\n0\n"], "outputs": ["5\n", "261\n", "100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
9,448
86d8c359812a39654bd2ef8cb2d430ce
UNKNOWN
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. -----Constraints----- - 1 \leq a,b,...
["a,b,c=map(int, input().split()) \nprint(\"YES\" if b-a==c-b else \"NO\")", "pole1, pole2, pole3 = map(int, input().split())\nif pole2 - pole1 == pole3 - pole2:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "# 058_a\na, ...
{"inputs": ["2 4 6\n", "2 5 6\n", "3 2 1\n"], "outputs": ["YES\n", "NO\n", "YES\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,146
726d4c0a889cd00793f40951114f3cd5
UNKNOWN
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? -----Constraints----- - 10≤N≤99 -----Input----- Input is given from Standard Input in the following format: N -----Output----- If 9 is contained in the decimal notation of N, print ...
["n = input()\nif '9' in n:\n print('Yes')\nelse:\n print('No')", "N = input()\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')", "print(('No', 'Yes')['9' in input()])", "N = str(input())\nif \"9\" in N:\n print('Yes')\nelse:\n print('No')", "n=int(input())\n\nif n%10==9 or n//10=...
{"inputs": ["29\n", "72\n", "91\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,915
ed8d86825c9a45e28b1bed276612de78
UNKNOWN
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a co...
["import bisect\n\nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\n\nindex = bisect.bisect_left(A,X)\nans = min(M-index,index)\nprint(ans)", "n,m,x=map(int, input().split())\na=[int(i) for i in input().split()]\n\ncount_1=0\nfor i in range(x):\n if i in a:\n count_1+=1\n \ncount_2...
{"inputs": ["5 3 3\n1 2 4\n", "7 3 2\n4 5 6\n", "10 7 5\n1 2 3 4 6 8 9\n"], "outputs": ["1\n", "0\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
28,408
68eaeb6851e45d1ec8b16821c916bc57
UNKNOWN
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i,...
["h,w=list(map(int,input().split()))\ndx=[0,1,0,-1] ; dy=[1,0,-1,0]\nA=[list(input()) for i in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if A[i][j]==\"#\":\n for q,e in zip(dx,dy):\n if 0<=i+q<h and 0<=j+e<w:\n if A[i+q][e+j]==\"#\":break\n ...
{"inputs": ["3 3\n.#.\n###\n.#.\n", "5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n", "11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
68,807
ceddb9e89c7b18f50c3001a67c95d7a7
UNKNOWN
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note t...
["a,b,c=list(map(int,input().split()))\nprint(('Yes'if a+b==c or b+c==a or c+a==b else'No'))\n", "a,b,c=map(int,input().split())\nif max(a,b,c)*2==a+b+c:print('Yes')\nelse:print('No')", "a,b,c = map(int,input().split())\nprint(\"Yes\" if a==b+c or b==a+c or c==a+b else \"No\")", "a,b,c = map(int,input().split())\nif a+...
{"inputs": ["10 30 20\n", "30 30 100\n", "56 25 31\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
21,511
bce00d87ed514526cc1db91a4d0f44a8
UNKNOWN
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and pla...
["a,b,c,d = map(int,input().split())\nab = a + b\ncd = c + d\nif ab > cd:\n print('Left')\nelif ab < cd:\n print('Right')\nelse:\n print('Balanced')", "A,B,C,D=map(int,input().split())\nif A+B>C+D :\n print(\"Left\")\nelif A+B==C+D :\n print(\"Balanced\")\nelse :\n print(\"Right\")", "A,B,C,D=map(int,input(...
{"inputs": ["3 8 7 1\n", "3 4 5 2\n", "1 7 6 4\n"], "outputs": ["Left\n", "Balanced\n", "Right\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
22,411
82138a598013f3ec29fcdaa8d4a6d606
UNKNOWN
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those p...
["n=int(input())\nF = [int(input().replace(\" \",\"\"),2) for _ in range(n)]\nP = [list(map(int,input().split())) for _ in range(n)]\n\ntotal = -10**9\nfor i in range(1,2**10):\n pgain = 0\n for f,p in zip(F,P):\n pgain += p[bin(f&i).count(\"1\")]\n if total < pgain:\n total = pgain\n k = ...
{"inputs": ["1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n", "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n", "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 ...
INTRODUCTORY
PYTHON3
ATCODER.JP
53,449
8d127982b8cc2a80d1602e1f59a6efa4
UNKNOWN
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. -----Constraints----- - 1≤A,B≤5 - |S|=A+B+1 - S consists of - and...
["a,b = list(map(int, input().split()))\ns = input()\ncount = 0\nans = 'Yes'\nfor i in range(a+b+1):\n if i == a:\n if s[i] != '-':\n ans = 'No'\n break\n else:\n if s[i] == '-':\n ans = 'No'\n break\nprint(ans)\n", "A, B = map(int, input().split())\nS = input()\nD = [ str(i) for i in range(...
{"inputs": ["3 4\n269-6650\n", "1 1\n---\n", "1 2\n7444\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,561
d485189b48d22fd85f1fa005c868e13d
UNKNOWN
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the ho...
["W,a,b=map(int,input().split());print([abs(a-b)-W,0][abs(a-b)<=W])", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif b<=c:\n if a+b>=c:\n print(0)\n else:\n print(c-b-a)\nelse:\n if a+c>=b:\n print(0)\n else:\n print(b-c-a)", "w,a,b = map(int, input().split())\nprint(max(0,b-a-w) if b >= a els...
{"inputs": ["3 2 6\n", "3 1 3\n", "5 10 1\n"], "outputs": ["1\n", "0\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,487
e193bbd6732dfe0abc8530ca556b5d05
UNKNOWN
Print all the integers that satisfies the following in ascending order: - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. -----Constraints----- - 1 \leq A \leq B \leq 10^9 - 1 \leq K \leq 100 - All values in input are integers. -----Inp...
["a, b, k = map(int,input().split())\nfor i in range(a,min(b,a+k-1)+1):\n print(i)\nfor i in range(max(b-k+1,a+k),b+1):\n print(i)", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\na, b, k = [int(num) for num in lines.pop(0).split(\" \")]\ns1 = set(range(a, min(b, a + k)))\ns2 = set(range...
{"inputs": ["3 8 2\n", "4 8 3\n", "2 9 100\n"], "outputs": ["3\n4\n7\n8\n", "4\n5\n6\n7\n8\n", "2\n3\n4\n5\n6\n7\n8\n9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,794
7ea23d505abac626f3d6151fa30ce906
UNKNOWN
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the upper...
["A,S,C=map(str,input().split())\nprint(\"A\"+S[0]+\"C\")", "s=input()\nprint(\"A\"+s[8]+\"C\")", "print(('A' + input().split()[1][0] + 'C'))\n", "a,b,c=map(str,input().split())\nprint('A'+b[0]+'C')", "lst = list(map(str, input().split()))\nprint(lst[0][0] + lst[1][0] + lst[2][0])", "arr = list(input().split())\nprint(...
{"inputs": ["AtCoder Beginner Contest\n", "AtCoder Snuke Contest\n", "AtCoder X Contest\n"], "outputs": ["ABC\n", "ASC\n", "AXC\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,779
aeb7bb140c9feda13c6ba24f03ad50b6
UNKNOWN
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. -----Constraints----- - 1 \leq A \leq 100 - 1 \leq B \leq 100 - 1 \leq X \leq 200 - All val...
["a, b, x = map(int, input().split())\nprint(\"YES\" if a <= x and x <= a+b else \"NO\")", "a,b,x=map(int, input().split())\nprint(\"YES\" if a+b>=x>=a else \"NO\")", "a,b,x = list(map(int,input().split()))\nif a<=x and a+b>=x:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, x= list(map(int, input().split()))\n\n...
{"inputs": ["3 5 4\n", "2 2 6\n", "5 3 2\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,057
6c10059ba552af0fa276768778f7aff8
UNKNOWN
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? -----Constraints----- - 1≤X≤10^9 - 1≤t≤10^9 - X and t are integers. -----I...
["x, t = list(map(int, input().split()))\nprint((max(0, x - t)))\n", "a,b=list(map(int,input().split()))\nif a <= b:\n print((0))\nelse:\n print((a-b))\n", "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,math,itertools,fractions\nsys.setrecursionlimit(...
{"inputs": ["100 17\n", "48 58\n", "1000000000 1000000000\n"], "outputs": ["83\n", "0\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,197
b4b3697e0bed56ebe8ac9312ec078b86
UNKNOWN
Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N. However, if the result exceeds 10^{18}, print -1 instead. -----Constraints----- - 2 \leq N \leq 10^5 - 0 \leq A_i \leq 10^{18} - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ......
["a=1\nfor i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18]\nprint(a)", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n if 0 in a:\n return 0\n\n max_value = 10 ** 18\n product = 1\n for i in a:\n product *= i\n if max_value < product:\n ret...
{"inputs": ["2\n1000000000 1000000000\n", "3\n101 9901 999999000001\n", "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0\n"], "outputs": ["1000000000000000000\n", "-1\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
20,916
d11c85cf7de243e2d9f3127496badf07
UNKNOWN
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. -----Constraints----- - N is an integer between 1 and 10000 (inclusive). - A is an integer between 0 and 1000 (inclusive). -----Input----- Input is given from Standard Input in the following f...
["n=int(input())\na=int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nprint('Yes' if (n % 500) <= a else 'No')", "n = int(input())\na = int(input())\nmod = n % ...
{"inputs": ["2018\n218\n", "2763\n0\n", "37\n514\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,044
60698cc4678fa66e03d01a646d731506
UNKNOWN
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Oth...
["X,A,B=list(map(int,input().split()))\nif A-B>=0:\n print(\"delicious\")\nelif -A+B<=X:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x,a,b = map(int,input().split())\n\nif a>=b: print('delicious')\nelif a+x+1>b: print('safe')\nelse: print('dangerous')", "import sys\n\nsys.setrecursionlimit(10 ** 8)\ni...
{"inputs": ["4 3 6\n", "6 5 1\n", "3 7 12\n"], "outputs": ["safe\n", "delicious\n", "dangerous\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,991
a5d3074c9e7609843b6ec12f8fc1a8a5
UNKNOWN
Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer. -----Constraints----- - 1 \leq N \leq 10^9 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print the largest squ...
["N = int (input ())\nx = 1\nwhile x**2 <= N:\n x += 1\nx -= 1\nprint (x**2)", "#\n# abc077 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\nimport math\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.st...
{"inputs": ["10\n", "81\n", "271828182\n"], "outputs": ["9\n", "81\n", "271821169\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,372
4a0b99bac18df99a74f5342d30869ecf
UNKNOWN
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he c...
["import sys\nreadline = sys.stdin.readline\ndef ceil(a, b):\n return -(-a//b)\n\ndef main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 0, 0\n for t, a in inp:\n if t >= scr_t and a >= scr_a:\n scr_t = t\n ...
{"inputs": ["3\n2 3\n1 1\n3 2\n", "4\n1 1\n1 1\n1 5\n1 100\n", "5\n3 10\n48 17\n31 199\n231 23\n3 2\n"], "outputs": ["10\n", "101\n", "6930\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
41,770
6b9ed73bae9617b4deaf9edb740e405a
UNKNOWN
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. -----Constraints----- - 2 ≤ |S| ≤ 26, where |S| denotes the length of S. - S consists of lowercase English letters. -----Input----- Input is given from Standard Input in the following format: S...
["import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\...
{"inputs": ["uncopyrightable\n", "different\n", "no\n"], "outputs": ["yes\n", "no\n", "yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,669
a92957f45079f53aa09a345943688293
UNKNOWN
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = E, and west if S_i = W. You will appoint one of the N people as the leader, then command the rest of them to ...
["n=int(input())\ns=input()\n\ncnt=s[1:].count(\"E\")\nans=cnt\n\nfor i in range(1,n):\n if s[i-1]==\"W\":\n cnt+=1\n if s[i]==\"E\":\n cnt-=1\n ans=min(ans,cnt)\n\nprint(ans)", "N = int(input())\nS = list(input())\n\ne_count = 0\nfor s in S:\n if s == 'E':\n e_count += 1\n\nmin_inv = float('infinity')\n ...
{"inputs": ["5\nWEEWW\n", "12\nWEWEWEEEWWWE\n", "8\nWWWWWEEE\n"], "outputs": ["1\n", "4\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
39,969
a60f1638433d52d37c9839dbe70799af
UNKNOWN
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? -----Constraints----- - 2≤N,M≤50 - 1≤a_i,b_i≤N - a_i ≠ b_i - All i...
["n,m = map(int, input().split())\nc = [0 for _ in range(n)]\nfor i in range(m):\n a,b = map(int, input().split())\n c[a-1] += 1\n c[b-1] += 1\nfor j in range(n):\n print(c[j])", "n,m = [int(x) for x in input().split()]\ncount = [0] * (n+1)\nfor i in range(m):\n a,b = [int(x) for x in input().split()]\n count[a] ...
{"inputs": ["4 3\n1 2\n2 3\n1 4\n", "2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n", "8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n"], "outputs": ["2\n2\n1\n1\n", "5\n5\n", "3\n3\n2\n2\n2\n1\n1\n2\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
20,944
6e7896c51b585a5b8ef7d53bdbb0e754
UNKNOWN
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When...
["N = int(input())\ns = []\n\nfor i in range(N):\n s.append(int(input()))\n \nS = sum(s)\n\nif S%10 != 0:\n print(S)\nelse:\n b = True\n for j in range(N):\n if s[j]%10 == 0:\n continue\n else:\n b = False\n if b:\n print(0)\n else:\n s.sort()\n for k in range(N):\n if s[k]%10 != 0...
{"inputs": ["3\n5\n10\n15\n", "3\n10\n10\n15\n", "3\n10\n20\n30\n"], "outputs": ["25\n", "35\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,851
ca965a51515e9e79017c4215fc9c4565
UNKNOWN
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ...
["#\n# abc096 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import Counter\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n ...
{"inputs": ["6\naabbca\n", "10\naaaaaaaaaa\n", "45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n"], "outputs": ["2\n", "1\n", "9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,511
ba7990346a681de06ba6217412b64ca4
UNKNOWN
The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given is a string S representing the weather in the town today. Predict the weather tomorrow. -----Constraints----- - S is Sunny, Cloudy, or Rainy. -----Input----- Input is given from Standard ...
["s=input()\n\nif s=='Sunny':\n print('Cloudy')\nif s=='Cloudy':\n print('Rainy')\nif s=='Rainy':\n print('Sunny')\n \n", "s=str(input())\nif s=='Sunny':\n print('Cloudy')\nelif s=='Cloudy':\n print('Rainy') \nelse:\n print('Sunny')", "S = input()\nweather = [\"Sunny\", \"Cloudy\", \"Rainy\"]\n \nprint(wea...
{"inputs": ["Sunny\n", "Rainy\n", "Cloudy\n"], "outputs": ["Cloudy\n", "Sunny\n", "Rainy\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
12,479
13e896c7ecb770e0ff95c1e9e82e3681
UNKNOWN
You are parking at a parking lot. You can choose from the following two fee plans: - Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. - Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. -----Constraints----- - 1≤N≤20 - 1≤A≤1...
["n, a, b = (int(n) for n in input().split())\nprint(min(n * a, b))", "N, A, B = map(int,input().split())\n\nif N*A > B:\n print(B)\nelse:\n print(N * A)", "N,A,B = list(map(int, input().split()))\n\nif N * A < B:\n x = N * A\nelse:\n x = B\nprint(x)\n", "# \u6570\u5024\u306e\u53d6\u5f97\nN,A,B = map(int,in...
{"inputs": ["7 17 120\n", "5 20 100\n", "6 18 100\n"], "outputs": ["119\n", "100\n", "100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
12,843
8565200e240119b7a54b827d84b5389a
UNKNOWN
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M ...
["n, m = list(map(int, input().split()))\n\nans = (1900 * m + 100 * (n - m)) * (2 ** m)\n\nprint(ans)\n", "N,M = map(int,input().split())\nprint(((N-M)*100+M*1900)*2**M)", "n, m = map(int, input().split())\nvalue = 1900*m+(n-m)*100\np = 2**m\nans = value*p\nprint(ans) ", "n, m = map(int, input().split())\nbase = m * 19...
{"inputs": ["1 1\n", "10 2\n", "100 5\n"], "outputs": ["3800\n", "18400\n", "608000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,892
c8114ef076322b83b0c40b941d72e6f7
UNKNOWN
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead. -----Constraints----- - 1 \leq |S| \leq 10^5 (|S| is the length of string S.) - ...
["S = input()\nalphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n\nfor a in alphabet:\n if a not in S:\n print(a)\n return\n \nprint('None')\n\n\n", "s = input()\nans = 'None'\nfor i in range(97, 123):\n...
{"inputs": ["atcoderregularcontest\n", "abcdefghijklmnopqrstuvwxyz\n", "fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg\n"], "outputs": ["b\n", "None\n", "d\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,711
634dad7463a35b130a23521d332d921a
UNKNOWN
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ......
["n = int(input())\nx = list(map(int,input().split()))\n\ny = sorted(x)\n\nans1 = y[n//2]\nans2 = y[n//2-1]\n\nfor i in x :\n if i < ans1 :\n print(ans1)\n else :\n print(ans2)\n", "import bisect\nn=int(input())\nx=list(map(int,input().split()))\nm=n//2\ny=sorted(x)\nfor i in range(n):\n if bisect....
{"inputs": ["4\n2 4 4 3\n", "2\n1 2\n", "6\n5 5 4 4 3 3\n"], "outputs": ["4\n3\n3\n4\n", "2\n1\n", "4\n4\n4\n4\n4\n4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
30,271
3dd08c0f784c132a07722506913faea8
UNKNOWN
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. -----Constraints----- - 4 \leq N \leq 10^5 - 1 \leq...
["n=int(input())\na=[int(i) for i in input().split()]\n\n\na.sort()\n\ncount=0\n\n\ndef get_num(a):\n count=1\n taishou = a.pop()\n while a!=[]:\n second=a.pop()\n if taishou==second:\n count+=1\n else:\n a.append(second)\n break\n if count==1:\n ...
{"inputs": ["6\n3 1 2 4 2 1\n", "4\n1 2 3 4\n", "10\n3 3 3 3 4 4 4 5 5 5\n"], "outputs": ["2\n", "0\n", "20\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
39,812
eb217179e15e554aace51d88149ca773
UNKNOWN
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ...
["n=int(input())\nd,x=map(int,input().split())\nfor i in range(n):\n t=int(input())\n x+=(d+t-1)//t\nprint(x)", "N = int(input())\nD,X = list(map(int,input().split()))\ncon = 0\nfor i in range(N):\n a = int(input())\n if a != 1:\n for i in range(1 , D + 1):\n if i % a == 1:\n con += 1\n elif a == 1:...
{"inputs": ["3\n7 1\n2\n5\n10\n", "2\n8 20\n1\n10\n", "5\n30 44\n26\n18\n81\n18\n6\n"], "outputs": ["8\n", "29\n", "56\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
22,931
518fc7b2a073f74eff5ee05f10f5fc70
UNKNOWN
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coi...
["a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\n\nfor i in range(a + 1):\n for j in range(b + 1):\n maisuuOf50 = (x - i * 500 - j * 100) / 50\n if 0 <= maisuuOf50 <= c:\n ans += 1\n\nprint(ans)\n", "def main():\n\n five_hundred = int(input())\n one_...
{"inputs": ["2\n2\n2\n100\n", "5\n1\n0\n150\n", "30\n40\n50\n6000\n"], "outputs": ["2\n", "0\n", "213\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,787
ac39a650d758429f8a0243619be2fd14
UNKNOWN
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. -----Constraints----- - -100≤A,B,C≤100 - A, B and C are all integers. -----Input----- Input is given from Standard Input in the following format: A B C -----Output----- If the condition is satisfied, print Ye...
["# 3 \u3064\u306e\u6574\u6570 A , B , C \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u6574\u6570 C \u304c A \u4ee5\u4e0a \u304b\u3064 B \u4ee5\u4e0b\u3067\u3042\u308b\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B,C = map(int,input().split())\n\nif C >= A and C <= B:\n print('Yes')...
{"inputs": ["1 3 2\n", "6 5 4\n", "2 2 2\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,742
f6cac25b5a2a9bcebb7ba77f3bdd1c50
UNKNOWN
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o...
["n,x=list(map(int,input().split()))\ny = [int(input()) for i in range(n)]\ny.sort()\nc = 0\nfor i in range(n):\n if c < x:\n c +=y[i]\n elif c > x:\n print((i-1))\n return\nd = sum(y)\nprint((((x-d)//y[0])+n))\n", "n,x=map(int,input().split())\na=[]\nfor i in range(n):\n m=int(input())\n a.append(m)\n x-...
{"inputs": ["3 1000\n120\n100\n140\n", "4 360\n90\n90\n90\n90\n", "5 3000\n150\n130\n150\n130\n110\n"], "outputs": ["9\n", "4\n", "26\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
17,041
4a26cb7bcc739c50f2eca19739b7caae
UNKNOWN
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get? -----Constraints----- - 1 \leq N \leq 2\times 10^5 - S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive). -----Input----- Input is given from ...
["n=int(input())\nstring_list=[input() for i in range(n)]\ncount = len(set(string_list))\nprint(count)", "def resolve():\n n = int(input())\n s = [input() for _ in range(n)]\n print(len(set(s)))\nresolve()", "N = int(input())\nmyset = set([])\nfor i in range(N):\n S = input()\n myset.add(S)\nprint((len(myset...
{"inputs": ["3\napple\norange\napple\n", "5\ngrape\ngrape\ngrape\ngrape\ngrape\n", "4\naaaa\na\naaa\naa\n"], "outputs": ["2\n", "1\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,473
69581512b85e14c04554cc7c0ef53f36
UNKNOWN
In AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows: - Rating 1-399 : gray - Rating 400-799 : brown - Rating 800-1199 : green - Rating 1200-1599 : cyan - Rating 1600-1999 : blue - Rating 2000-2399 : yellow - Rating 2400-2799 : orange - R...
["n = int(input())\na = list(map(int, input().split()))\n\nans = 0\nt = 400\nwhile t < 3201:\n for i in a:\n if i >= t-400 and i < t:\n ans += 1\n break\n t += 400\n\ns = 0\nfor i in a:\n if i >= 3200: s += 1\n\nif ans == 0: print(1, s)\nelse: print(ans, ans+s)", "n=int(input())\na=list(map(int,input()....
{"inputs": ["4\n2100 2500 2700 2700\n", "5\n1100 1900 2800 3200 3200\n", "20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n"], "outputs": ["2 2\n", "3 5\n", "1 1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
33,163
eb268666e59d4f5e6a03912dae5cab74
UNKNOWN
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is t...
["s = input()\nprint(s.count(\"o\")*100+700)", "print(input().count(\"o\")*100+700)", "s=input()\n\nnum=s.count('o')\n\nprint(700+100*num)", "# \u6587\u5b57\u5217\u306e\u5165\u529b\ns = input()\ncount = s.count(\"o\")\nprint(700 + 100 * count)", "s = input()\nres = 700\nfor i in s:\n if i == 'o':\n res += 100...
{"inputs": ["oxo\n", "ooo\n", "xxx\n"], "outputs": ["900\n", "1000\n", "700\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,103
fb7b1cf40ea3a1e5e270297e92127e08
UNKNOWN
Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either H or D, and carries the following information: If a=H, AtCoDeer is h...
["# \u5165\u529b\na, b = input().split()\n\n# \u51fa\u529b\n# a = 'H' \u306e\u3068\u304dat\u304f\u3093\u306f\u6b63\u76f4\u8005\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'D' and b == 'H':\n print('D')\nelif a == 'H' and b =='D':\n print('D')\nelif a == 'D' and b == 'D':\n print('H')", "a,b = input()...
{"inputs": ["H H\n", "D H\n", "D D\n"], "outputs": ["H\n", "D\n", "H\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
19,654
6456d6eea6e1335afc145e61cf9d001d
UNKNOWN
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds. The given input gua...
["\nS = input()\n\na = int(S[0])\nb = int(S[1])\nc = int(S[2])\nd = int(S[3])\n\nif a+b+c+d==7:\n print('{}+{}+{}+{}=7'.format(a,b,c,d))\nelif a+b+c-d==7:\n print('{}+{}+{}-{}=7'.format(a,b,c,d))\nelif a+b-c+d==7:\n print('{}+{}-{}+{}=7'.format(a,b,c,d))\nelif a+b-c-d==7:\n print('{}+{}-{}-{}=7'.format(a,b,...
{"inputs": ["1222\n", "0290\n", "3242\n"], "outputs": ["1+2+2+2=7\n", "0-2+9+0=7\n", "3+2+4-2=7\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,043
91af0090d9c1127da5d4684f5cce50d0
UNKNOWN
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information tha...
["def i_input(): return int(input())\n\n\ndef i_map(): return list(map(int, input().split()))\n\n\ndef i_list(): return list(map(int, input().split()))\n\n\ndef i_row(N): return [int(input()) for _ in range(N)]\n\n\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\n\n\nn = i_input()\naa=i_l...
{"inputs": ["5\n1 1 2 2\n", "10\n1 1 1 1 1 1 1 1 1\n", "7\n1 2 3 4 5 6\n"], "outputs": ["2\n2\n0\n0\n0\n", "9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "1\n1\n1\n1\n1\n1\n0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,784
9b875472787638c02345c9d1d24bff20
UNKNOWN
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a...
["x=int(input())\nans=0\na=0\nfor i in range(1,x+1):\n a+=i\n ans+=1\n if a>=x:\n print(ans)\n break", "import math\nx = int(input())\nans = math.ceil((-1 + math.sqrt(8 * x + 1)) / 2)\nprint(ans)", "x = int(input())\nt= 0\nwhile t*(t+1)//2 < x:\n t += 1\nprint(t)", "import math\nx = int(input())\n\ncnt = 0\...
{"inputs": ["6\n", "2\n", "11\n"], "outputs": ["3\n", "2\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,146
5415f0072b78795f216c38940af2b1a5
UNKNOWN
We call a 4-digit integer with three or more consecutive same digits, such as 1118, good. You are given a 4-digit integer N. Answer the question: Is N good? -----Constraints----- - 1000 ≤ N ≤ 9999 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- If N...
["n = input()\nprint(\"Yes\" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else \"No\")", "N = list(input())\nif N[0] == N[1] and N[0] == N[2]:\n print('Yes')\nelif N[1] == N[2] and N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n", "# 079a\n\ndef atc_079a(input_value: str) -> str:\n n = 3\n for i i...
{"inputs": ["1118\n", "7777\n", "1234\n"], "outputs": ["Yes\n", "Yes\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,111
ea3a037da3c7eb16035d04e0b58cebb1
UNKNOWN
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper p...
["n = int(input())\na_list = sorted([int(x) for x in input().split()])\nb_list = sorted([int(x) for x in input().split()])\nc_list = sorted([int(x) for x in input().split()])\n\nimport bisect\nsum = 0\nfor b in b_list:\n b_num = bisect.bisect_left(a_list,b)\n c_num = bisect.bisect_right(c_list,b)\n sum += b_nu...
{"inputs": ["2\n1 5\n2 4\n3 6\n", "3\n1 1 1\n2 2 2\n3 3 3\n", "6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n"], "outputs": ["3\n", "27\n", "87\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
56,564
95683f2da5f8b6e2255948bf3142f053
UNKNOWN
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F. When X a...
["x,y=input().split()\nif ord(x)<ord(y):print('<')\nelif ord(x)>ord(y):print('>')\nelse:print('=')", "X, Y = input().split()\n\ntemp = \"ABCDEF\"\n\nif temp.index(X) > temp.index(Y):\n print(\">\")\nelif temp.index(X) == temp.index(Y):\n print(\"=\")\nelse:\n print(\"<\")", "l = list(input().split())\nif len(s...
{"inputs": ["A B\n", "E C\n", "F F\n"], "outputs": ["<\n", ">\n", "=\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,673
2bc32ce571234152ffcafce3135c7432
UNKNOWN
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). . stands for an empty square, and # stands for a square containing ...
["# \u611a\u76f4\nh, w = map(int, input().split())\ntable = [list(input()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if table[i][j] == \".\":\n num = 0\n for y in [-1, 0, 1]:\n for x in [-1, 0, 1]:\n if 0 <= i + y < h and 0 <= j + x <...
{"inputs": ["3 5\n.....\n.#.#.\n.....\n", "3 5\n#####\n#####\n#####\n", "6 6\n#####.\n#.#.##\n####.#\n.#..#.\n#.##..\n#.#...\n"], "outputs": ["11211\n1#2#1\n11211\n", "#####\n#####\n#####\n", "#####3\n#8#7##\n####5#\n4#65#2\n#5##21\n#4#310\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
69,660
5975973213b5b544269a2c4126b963db
UNKNOWN
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: - Choo...
["def solve():\n N,M,K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n ret = 0\n\n A_cusum = [0]\n A_border_index = 0 # \u8d85\u3048\u308b\u3068\u304d\u306eindex\n for a_ in A:\n A_end = A_cusum[-1]\n if A_end+a_ > K:\n break\n\n A_cusum.app...
{"inputs": ["3 4 240\n60 90 120\n80 150 80 150\n", "3 4 730\n60 90 120\n80 150 80 150\n", "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000\n"], "outputs": ["3\n", "7\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
50,757
1e2ca9b397d6dc0024bc4968e0247f8e
UNKNOWN
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr...
["a,b,c,x,y = list(map(int,input().split()))\n\nif (a + b) <= 2 * c:\n print((a * x + b * y))\nelse:\n max_c = max(x,y)\n min_c = min(x,y)\n AB = 2 * c * max_c\n if x > y:\n SP = ((x - min_c) * a) + (2 * c * min_c)\n else:\n SP = ((y - min_c) * b) + (2 * c * min_c)\n print((min(AB,SP)))\n", "A, B, C, X, Y ...
{"inputs": ["1500 2000 1600 3 2\n", "1500 2000 1900 3 2\n", "1500 2000 500 90000 100000\n"], "outputs": ["7900\n", "8500\n", "100000000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,400
b875b9f77a17feaa2523ce9c53ab2118
UNKNOWN
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. -----Constraints----- - 1≤N≤10^3 -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the number of the positive divisors of N!, modulo 10^9+7. -----Sample Input----- 3 --...
["N = int(input())\nmod = 1000000007\nfrom collections import Counter\nY = Counter()\nfor i in range(2, N+1):\n M = i\n for j in range(2,i+1):\n while M % j == 0:\n Y[j] += 1\n M //= j\n\ndef product(X):\n res = 1\n for x in X:\n res *= x + 1\n res %= mod\n retu...
{"inputs": ["3\n", "6\n", "1000\n"], "outputs": ["4\n", "30\n", "972926972\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
62,236
d3ca4703625401579c3928f804673799
UNKNOWN
You are given a positive integer X. Find the largest perfect power that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. -----Constraints----- - 1 ≤ X ≤ 1000 - X is an integer. -----Input----- Input is given ...
["x=int(input())\nm=-1000\nif 1<=x<=3:\n print((1))\n return\nelse:\n for b in range(2,x+1):\n for p in range(2,11):\n if x>=b**p:\n m=max(m,b**p)\n \n\nprint(m)\n\n", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u3...
{"inputs": ["10\n", "1\n", "999\n"], "outputs": ["9\n", "1\n", "961\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
24,766
4e41905c84173428b511a7cb97af3624
UNKNOWN
An X-layered kagami mochi (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have...
["N = int(input())\nds = []\nmochidan = 0\nfor i in range(N):\n ds.append(int(input()))\n\nwhile ds:\n tmp = max(ds)\n ds = [j for j in ds if j < tmp]\n mochidan += 1\n\nprint(mochidan)", "N=int(input())\nd=set()\nfor _ in range(N):\n d.add(int(input()))\nprint((len(d)))\n", "N = int(input())\nint_list = [...
{"inputs": ["4\n10\n8\n8\n6\n", "3\n15\n15\n15\n", "7\n50\n30\n50\n100\n50\n80\n30\n"], "outputs": ["3\n", "1\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,591
f0771fb39cae16fa27197778dccfd529
UNKNOWN
Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z. ...
["s = input()\nfirst_a_index = s.index('A')\nlast_z_index = len(s) - list(reversed(s)).index('Z')\nprint(last_z_index - first_a_index)", "s = input()\nstart = len(s)\nend = 0\nans = 0\n\nfor i in range(len(s)):\n if s[i] == 'A':\n start = min(start , i)\n if s[i] == 'Z':\n end = max(end, i)\n ans...
{"inputs": ["QWERTYASDFZXCV\n", "ZABCZ\n", "HASFJGHOGAKZZFEGA\n"], "outputs": ["5\n", "4\n", "12\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,639
86c3bf3691cc7cf44541f5c5231b81ae
UNKNOWN
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: - Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. -----Constraints----- - 1 ...
["n = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(n):\n cnt = cnt | a[i]\n\nj = 0\nans = 0\nwhile 1:\n if (cnt >> j & 1 == 0):\n ans += 1\n j += 1\n else:\n break\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nl = []\nfor i in a:\n ...
{"inputs": ["3\n8 12 40\n", "4\n5 6 8 10\n", "6\n382253568 723152896 37802240 379425024 404894720 471526144\n"], "outputs": ["2\n", "0\n", "8\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,408
6c9ea55542591bc27fd47d8f49ebbcc6
UNKNOWN
Snuke loves working out. He is now exercising N times. Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. -----Constraints----- - 1 ...
["N = int(input())\n\n# N!\u3092(10^9+7)\u3067\u5272\u3063\u305f\u4f59\u308a\u3092\u6c42\u3081\u308b\n# N!\u305d\u306e\u3082\u306e\u3092\u6c42\u3081\u308b\u5fc5\u8981\u306f\u306a\u304f\u3001\n# x = i*x (mod 10^9+7) \u3068\u66f4\u65b0\u3057\u3066\u3044\u3051\u3070\u3088\u3044\nM = 10**9 + 7\ns = 1\nfor i in range(1, N+1...
{"inputs": ["3\n", "10\n", "100000\n"], "outputs": ["6\n", "3628800\n", "457992974\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,930
3dd5313487e04dbaddcde81834926c94
UNKNOWN
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? -----Constraints----- - 1≦N≦100 -----Input----- The input is given...
["N = int(input())\n \nans = int(N*(N+1)/2)\nprint(ans)", "n = int(input())\nprint((n*(n+1)//2))\n", "ans=0\nn=int(input())\nfor i in range(1,n+1):\n\tans+=i\n\t\nprint(ans)\n", "import math\nfrom datetime import date\n\ndef main():\n\t\t\n\tn = int(input())\n\tprint((n * (n + 1) // 2))\n\t\nmain()\n", "n=int(input())\...
{"inputs": ["3\n", "10\n", "1\n"], "outputs": ["6\n", "55\n", "1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,399
8806bde88218d118c8a0f78f019ff2d0
UNKNOWN
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the car...
["def main():\n N = int(input())\n A = list(map(int, input().split()))\n alice = 0\n bob = 0\n A.sort(reverse=True)\n for i, a in enumerate(A):\n if i%2 == 0:\n alice += a\n else:\n bob += a\n print((alice - bob))\n\ndef __starting_point():\n main()\n\n__start...
{"inputs": ["2\n3 1\n", "3\n2 7 4\n", "4\n20 18 2 18\n"], "outputs": ["2\n", "5\n", "18\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
25,278
a2d76404678593f2c5baabf6b4d18987
UNKNOWN
Takahashi participated in a contest on AtCoder. The contest had N problems. Takahashi made M submissions during the contest. The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA). The number of Takahashi's correct answers is the number of problems on which he received an AC once or...
["N, M = [int(n) for n in input().split()]\n\nsubmit = []\nAC = [0] * N\nWA = [0] * N\n\nfor i in range(M):\n p, s = [n for n in input().split()]\n p = int(p)\n\n if AC[p-1] == 1:\n continue\n\n if s == 'AC':\n AC[p-1] = 1\n \n elif s == 'WA':\n WA[p-1] += 1\n\npen = [x*y for x, y in...
{"inputs": ["2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "100000 3\n7777 AC\n7777 AC\n7777 AC\n", "6 0\n"], "outputs": ["2 2\n", "1 0\n", "0 0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,222
1a51b5012feb2fcf8ea27a200ec82573
UNKNOWN
Fennec is fighting with N monsters. The health of the i-th monster is H_i. Fennec can do the following two actions: - Attack: Fennec chooses one monster. That monster's health will decrease by 1. - Special Move: Fennec chooses one monster. That monster's health will become 0. There is no way other than Attack and Spe...
["n, k = map(int, input().split())\nH = list(map(int, input().split()))\nH.sort(reverse=True)\nprint(sum(H[k:]))", "N, K = list(map(int, input().split()))\nH = list(map(int, input().split()))\nif len(H) <= K:\n print((0))\nelse:\n print((sum(sorted(H)[:len(H)-K])))\n", "n, k = map(int, input().split())\nh = [int(s) f...
{"inputs": ["3 1\n4 1 5\n", "8 9\n7 9 3 2 3 8 4 6\n", "3 0\n1000000000 1000000000 1000000000\n"], "outputs": ["5\n", "0\n", "3000000000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,339
667fa66309fe4b5ef5d1342400a76bc6
UNKNOWN
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th ty...
["n = int(input())\nk = int(input())\nx = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += 2*min(k-x[i],x[i])\nprint(ans)", "n = int(input())\nk = int(input())\nli = list(map(int,input().split()))\n\ndis = 0\nfor i in range(n):\n dis += min(2*li[i],2*abs(li[i]-k))\n\nprint(dis)", "n = int(inpu...
{"inputs": ["1\n10\n2\n", "2\n9\n3 6\n", "5\n20\n11 12 9 17 12\n"], "outputs": ["4\n", "12\n", "74\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
21,342
c16c9d414aaffb4910475afd4a74ae30
UNKNOWN
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum...
["a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nsum = (min(a, b) + min(c, d))\nprint(sum)", "A, B, C, D = [int(input()) for i in range(4)]\n\nif A <= B:\n train = A\nelse:\n train = B\nif C <= D:\n bus = C\nelse:\n bus = D\n\nanswer = (train + bus)\nprint(answer)", "A = int(input...
{"inputs": ["600\n300\n220\n420\n", "555\n555\n400\n200\n", "549\n817\n715\n603\n"], "outputs": ["520\n", "755\n", "1152\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,946
90b6a6306ec37bac9749d4c18935978a
UNKNOWN
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the nu...
["n = int(input())\na = [int(x) for x in input().split()]\na.sort()\nmod = 10 ** 9 + 7\n\ndef p(p):\n ans = 1\n for i in range(p):\n ans *= 2\n ans %= mod\n return ans\n\nif n % 2 == 1:\n res = True\n for i in range(n):\n if a[i] != ((i + 1) // 2) * 2:\n res = False\n if res:\n print(p(n // 2))\n...
{"inputs": ["5\n2 4 4 0 2\n", "7\n6 4 0 2 4 0 2\n", "8\n7 5 1 1 7 3 5 3\n"], "outputs": ["4\n", "0\n", "16\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
48,210
4ba97bf8651baf5b187d1c4a72581837
UNKNOWN
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). -----Constraints----- - 1 \leq N \leq 10^4 - 1 \leq A \leq B \leq 36 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A B -...
["n, a, b = map(int, input().split())\n\nans = 0\nfor i in range(1, n + 1):\n val = 0\n for c in str(i):\n val += int(c)\n if a <= val <= b:\n ans += i\nprint(ans)", "N,A,B = list(map(int,input().split()))\nK = 0\nfor i in range(1,N+1):\n if A <= sum(map(int,str(i))) <= B:\n K += i\nprint(K)\...
{"inputs": ["20 2 5\n", "10 1 2\n", "100 4 16\n"], "outputs": ["84\n", "13\n", "4554\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
24,974
28aa04b3ebd3630a98d701f04216f650
UNKNOWN
This contest, AtCoder Beginner Contest, is abbreviated as ABC. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. -----Constraints----- - 100 ≤ N ...
["N = input()\nprint(\"ABC\"+N)", "print(\"ABC\"+input())", "print(\"ABC\"+input())", "print('ABC' + input())", "print(\"ABC\" + input())", "print(\"ABC\"+input())", "print(\"ABC\"+input())", "N = int(input())\nprint(f\"ABC{N}\")", "s = input()\n\nprint('ABC'+s)", "n = input()\nprint(\"ABC\" + n)", "print(\"ABC\"+input...
{"inputs": ["100\n", "425\n", "999\n"], "outputs": ["ABC100\n", "ABC425\n", "ABC999\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
4,702
952970cb681548e4c7d81703fd53a1ee
UNKNOWN
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called Takahashi when the month and the day are equal as numbers. For ex...
["a,b=map(int,input().split())\n\nif a>b:\n print(a-1)\nelse:\n print(a)", "n,m=map(int,input().split())\nif n > m:\n print(n-1)\nelse:print(n)", "a,b=map(int,input().split())\nif a>b:\n a-=1\nprint(a)", "a,b = map(int, input().split())\nif b>=a:\n print(a)\nelse:\n print(a-1)", "a,b = map(int,input().rst...
{"inputs": ["5 5\n", "2 1\n", "11 30\n"], "outputs": ["5\n", "1\n", "11\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,016
7ceaaa9a63a171e630558059d5b07876
UNKNOWN
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It i...
["#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tsample\n# CreatedDate: 2020-10-10 20:29:20 +0900\n# LastModified: 2020-10-10 20:37:38 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\n\n\ndef main():\n N = int(input())\n A = [0]\n visited = [0]*(N+1)\n for...
{"inputs": ["3\n3\n1\n2\n", "4\n3\n4\n1\n2\n", "5\n3\n3\n4\n2\n4\n"], "outputs": ["2\n", "-1\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,904
87c32618281eea09249e1c7d6fadfba5
UNKNOWN
You are playing the following game with Joisino. - Initially, you have a blank sheet of paper. - Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. - Then, you are asked a question: How many num...
["n=int(input())\nd=dict()\nfor _ in range(n):\n hoge=int(input())\n if d.get(hoge,0)==0:\n d[hoge]=1\n else:\n d[hoge]+=1\nans=0\nfor i in d.values():\n if i%2==1:\n ans+=1\nprint(ans)", "import collections\n\nn = int(input())\narr = [int(input()) for _ in range(n)]\n\nc = collections....
{"inputs": ["3\n6\n2\n6\n", "4\n2\n5\n5\n2\n", "6\n12\n22\n16\n22\n18\n12\n"], "outputs": ["1\n", "0\n", "2\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,440
7e6fd9813d500d808571b1963313dda5
UNKNOWN
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. -----Constraints----- - 1 \leq ...
["n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nfrom collections import Counter\ndic=Counter(a)\ndic=sorted(list(dic.items()),key=lambda x:x[1])\n\nans=0\ncnt=0\nl=max(len(dic)-k,0)\nfor i in dic:\n if cnt==l:\n break\n ans=ans+i[1]\n cnt=cnt+1\nprint(ans)\n", "N, K = map(int,input().split...
{"inputs": ["5 2\n1 1 2 2 5\n", "4 4\n1 1 2 2\n", "10 3\n5 1 3 2 4 1 1 2 3 4\n"], "outputs": ["1\n", "0\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
32,243
560e88f4d2ccf40dad41114a73c36e12
UNKNOWN
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,...
["N = int(input())\n\nT = 0\nX = 0\nY = 0\n\nfor i in range(N):\n t, x, y = list(map(int, input().split()))\n dt = t - T\n dx = abs(X - x)\n dy = abs(Y - y)\n dis = dx + dy\n if dt < dis:\n print(\"No\")\n break\n if (dt - dis) % 2 == 1:\n print(\"No\")\n break\n T = ...
{"inputs": ["2\n3 1 2\n6 1 1\n", "1\n2 100 100\n", "2\n5 1 1\n100 1 1\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
40,892
fca88f268b06b2a78a97370b7f163358
UNKNOWN
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. -----Constraints----- - a and b are integers. - 1 \leq a, b \leq 100 -----Input----- Input is given from Standard Input in the following format: a b -----Output----- Print x rounded up to the ne...
["a, b = map(int, input().split())\nprint(((a + b) + (2 - 1)) // 2)", "import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n # 1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n # 1 line n ints\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef...
{"inputs": ["1 3\n", "7 4\n", "5 5\n"], "outputs": ["2\n", "6\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,457
4f896dcca992bfc1aac5cc93d5e57ad6
UNKNOWN
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a bridge. Find the number of the edges that are bridges among the M edg...
["import sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\ndef NIJIGEN(H): return [list(input()) for i in range(H)]\ndef dfs(j):\n if j not in finish:\n finish.ad...
{"inputs": ["7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n", "3 3\n1 2\n1 3\n2 3\n", "6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n"], "outputs": ["4\n", "0\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
104,377
f37252dc0c1d950feb7a91fd0aaa8a71
UNKNOWN
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. -----Constraints----- - -100 \leq A,B,C \...
["import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()...
{"inputs": ["5 7 5\n", "1 1 7\n", "-100 100 100\n"], "outputs": ["7\n", "7\n", "-100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,561
4dcd14340d1207b1e6f3859b5f543558
UNKNOWN
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. - Operation 1: Pour 100A grams of water into the beaker. - Operation 2: Pour 100B grams of water into the beaker...
["a, b, c, d, e, f = map(int, input().split())\ns = set()\nfor i in range(30 // a + 1):\n for j in range(30 // b + 1):\n if 0 < (a * i + b * j) * 100 <= f:\n s = s | {a * i + b * j}\ns2 = set()\nfor i in range(3000 // c + 1):\n for j in range(3000 // d + 1):\n if c * i + d * j <= f:\n ...
{"inputs": ["1 2 10 20 15 200\n", "1 2 1 2 100 1000\n", "17 19 22 26 55 2802\n"], "outputs": ["110 10\n", "200 100\n", "2634 934\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,671
e2426f7fffbce24f02838e2aa6b387c9
UNKNOWN
The word internationalization is sometimes abbreviated to i18n. This comes from the fact that there are 18 letters between the first i and the last n. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. -----Constraints----- - 3 ≤ |s| ≤ 100 (|s| denotes...
["a = input()\nprint(f\"{a[0]}{len(a[1:-1])}{a[-1]}\")", "s = input()\nans = s[0] + str(len(s)-2) + s[-1]\nprint(ans)", "s = input()\nprint(s[0] + str(len(s)-2) + s[-1])", "s = input()\nprint((s[0]+str(len(s)-2)+s[len(s)-1]))\n", "import sys\n\n\ndef main():\n s = input()\n N = len(s)\n ans = s[0] + str(N - 2)...
{"inputs": ["internationalization\n", "smiles\n", "xyz\n"], "outputs": ["i18n\n", "s4s\n", "x1z\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
6,556
ea2b894a7251a3972d1d7bcef3087a82
UNKNOWN
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise. -----Constraints----- - C_{i,j}(1 \leq i \leq 2, 1...
["a = input()\nb = input()\n\nif a[:: -1] == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "P = input()\nQ = input()\n\nif P[::-1] == Q:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = input()\nb = input()\n\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')\n", "c1 = in...
{"inputs": ["pot\ntop\n", "tab\nbet\n", "eye\neel\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,103
796003695c573a1ca0f0e90fedf9e5d2
UNKNOWN
You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not. Also, we say that ...
["import sys\nstdin=sys.stdin\n\nip=lambda: int(sp())\nfp=lambda: float(sp())\nlp=lambda:list(map(int,stdin.readline().split()))\nsp=lambda:stdin.readline().rstrip()\nyp=lambda:print('Yes')\nnp=lambda:print('No')\n\ns=list(sp())\nk=ip()\n\nans=set()\n\nalpa=list(set(s))\nalpa.sort()\nch=0\nsiyou=[]\nfor i in range(len(...
{"inputs": ["aba\n4\n", "atcoderandatcodeer\n5\n", "z\n1\n"], "outputs": ["b\n", "andat\n", "z\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
34,183
45cc4e4d48f2ac78d90cee07b6156e64
UNKNOWN
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) poi...
["def main():\n w, h, n = list(map(int, input().split()))\n\n x_min = 0\n x_max = w\n y_min = 0\n y_max = h\n\n for _ in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n x_min = max(x_min, x)\n elif a == 2:\n x_max = min(x_max, x)\n ...
{"inputs": ["5 4 2\n2 1 1\n3 3 4\n", "5 4 3\n2 1 1\n3 3 4\n1 4 2\n", "10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n"], "outputs": ["9\n", "0\n", "64\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
52,702
196df35e80b703daf6eb0502b48f4eb1
UNKNOWN
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≤i≤N-1, there will be trains that run from Station i to S...
["def LIHW(h):\n return [list(map(int, input().split())) for _ in range(h)]\n\n\nN = int(input())\nX = LIHW(N-1)\n\nfor i in range(N-1):\n time = [0]*N\n time[i] = X[i][1]+X[i][0]\n for j in range(i+1, N-1):\n if time[j-1] <= X[j][1]:\n time[j] = X[j][1]+X[j][0]\n else:\n ...
{"inputs": ["3\n6 5 1\n1 10 1\n", "4\n12 24 6\n52 16 4\n99 2 2\n", "4\n12 13 1\n44 17 17\n66 4096 64\n"], "outputs": ["12\n11\n0\n", "187\n167\n101\n0\n", "4162\n4162\n4162\n0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
46,830
e403c7de707b128c8d5f0ee7a2c89554
UNKNOWN
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print ...
["H, W = map(int, input().split())\nfor _ in range(H):\n C = input()\n print(C)\n print(C)", "H,W = map(int,input().split())\nlis = []\n\nfor _ in range(H):\n C = input()\n lis.append(C)\n lis.append(C)\n\nfor i in lis:\n print(i)", "h,w=map(int,input().split())\nc = [input() for _ in range(h)]\n\nfor i in...
{"inputs": ["2 2\n*.\n.*\n", "1 4\n***.\n", "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n"], "outputs": ["*.\n*.\n.*\n.*\n", "***.\n***.\n", ".....***....***......
INTRODUCTORY
PYTHON3
ATCODER.JP
16,583
1fb781f53e1a6b427f73ef0c24d3f2fe
UNKNOWN
Given is a sequence of integers A_1, A_2, ..., A_N. If its elements are pairwise distinct, print YES; otherwise, print NO. -----Constraints----- - 2 ≤ N ≤ 200000 - 1 ≤ A_i ≤ 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ... A_N -----Outp...
["def N():\n return int(input())\ndef L():\n return list(map(int,input().split()))\ndef NL(n):\n return [list(map(int,input().split())) for i in range(n)]\nmod = pow(10,9)+7\n\n#import numpy as np\nimport sys\nimport math\nimport collections\n\nn =N()\na = L()\ns = set()\nfor i in range(n):\n if a[i] in s:\...
{"inputs": ["5\n2 6 1 4 5\n", "6\n4 1 3 1 6 2\n", "2\n10000000 10000000\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,731
2f9eda2ce0e046119c5c6a911cd9eb1b
UNKNOWN
There are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $w_i$. Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams with the same total weight. So, if there are $k$ teams $(a_1, b_1)$, ...
["for _ in range(int(input())):\n n = int(input())\n wt = list(map(int, input().split()))\n count = {}\n for x in wt:\n if x not in count:\n count[x] = 0\n count[x] += 1\n k = 0\n\n for s in range(101):\n temp = 0\n temp2 = 0\n for x in count:\n ...
{ "inputs": [ "5\n5\n1 2 3 4 5\n8\n6 6 6 6 6 6 8 8\n8\n1 2 2 1 2 1 1 2\n3\n1 3 3\n6\n1 1 3 4 2 2\n", "4\n14\n2 6 5 9 5 8 13 14 12 5 6 14 5 2\n36\n15 22 27 7 23 36 10 17 33 21 18 22 3 4 32 24 8 19 36 22 17 11 24 10 33 4 30 6 2 17 11 16 18 1 2 20\n2\n2 2\n12\n4 9 10 6 1 9 5 8 8 9 9 12\n" ], "outputs": [ ...
INTRODUCTORY
PYTHON3
CODEFORCES
8,454
031e26d7c854a74ac8a3debea747e48d
UNKNOWN
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor contains $x$ apartments each. Apartments are numbered starting from one...
["import sys\n\n \ndef main():\n #n = iinput()\n #k = iinput() \n #m = iinput() \n #n = int(sys.stdin.readline().strip()) \n #n, k = rinput()\n #n, m = rinput()\n #m, k = rinput()\n #n, k, m = rinput()\n #n, m, k = rinput()\n #k, n, m = rinput()\n #k, m, n = rinput() \n #m, k, n =...
{ "inputs": [ "4\n7 3\n1 5\n22 5\n987 13\n", "7\n7 3\n1 5\n22 5\n987 13\n7 3\n1 5\n22 5\n" ], "outputs": [ "3\n1\n5\n77\n", "3\n1\n5\n77\n3\n1\n5\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
11,656
09f6758f4ff430b2380d0cc16f472913
UNKNOWN
You want to perform the combo on your opponent in one popular fighting game. The combo is the string $s$ consisting of $n$ lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in $s$. I.e. if $s=$"abca" then you have to press 'a', then 'b', 'c' and 'a' again. You know t...
["from string import ascii_lowercase\n\nt = int(input())\n\nfor _ in range(t):\n n, m = [int(x) for x in input().split()]\n\n s = input()\n count = {x : 0 for x in ascii_lowercase}\n errors = [int(x) for x in input().split()]\n\n errors = sorted(errors)\n\n e_idx = 0\n for j, c in enumerate(s):\n ...
{ "inputs": [ "3\n4 2\nabca\n1 3\n10 5\ncodeforces\n2 8 3 2 9\n26 10\nqwertyuioplkjhgfdsazxcvbnm\n20 10 1 2 3 5 10 5 9 4\n", "1\n11 2\nthisisatest\n3 5\n" ], "outputs": [ "4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n0 0 9 4 5 3 0 0 0 0 0 0 0 0 9 0 0 3 1 0 0 0 0 0 0 0 \n2 1 1 2 9 2 2 2 5 2 2 ...
INTRODUCTORY
PYTHON3
CODEFORCES
6,020