wrong_submission_id
stringlengths 10
10
| problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 131k
1.05M
| wrong_status
stringclasses 2
values | wrong_cpu_time
float64 10
40k
| wrong_memory
float64 2.94k
3.37M
| wrong_code_size
int64 1
15.5k
| problem_description
stringlengths 1
4.75k
| wrong_code
stringlengths 1
6.92k
| acc_submission_id
stringlengths 10
10
| acc_status
stringclasses 1
value | acc_cpu_time
float64 10
27.8k
| acc_memory
float64 2.94k
960k
| acc_code_size
int64 19
14.9k
| acc_code
stringlengths 19
14.9k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s382268242 | p02409 | u476441153 | 1,000 | 131,072 | Wrong Answer | 20 | 5,628 | 388 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that โv persons left. Assume that initially no person lives in the building. | a = [[0 for i in range(10)] for j in range(12)]
n = int(input())
for i in range(n):
b,f,r,v = map(int, input().split())
a[f-1][r-1] = v
for i in range(1,13):
for y in range(10):
if y==9:
print(a[i-1][y],end='')
else:
print(a[i-1][y],end='')
print(" ",end='')
print()
if i != 12 and i%3==0:
print ("#"*20)
| s027060032 | Accepted | 20 | 5,612 | 288 | n = int(input())
a = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
for _ in range(n):
b, f, r, v = map(int, input().split())
a[b-1][f-1][r-1] += v
for i in range(4):
for j in range(3):
print(' '+' '.join(map(str, a[i][j])))
if i != 3:
print('#'*20)
|
s426265049 | p03149 | u102960641 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 93 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | a = set(map(int, input().split()))
if a == set([1,9,7,4]):
print("Yes")
else:
print("No") | s000917355 | Accepted | 20 | 3,316 | 93 | a = set(map(int, input().split()))
if a == set([9,1,7,4]):
print("YES")
else:
print("NO") |
s424785924 | p03998 | u072717685 | 2,000 | 262,144 | Wrong Answer | 18 | 3,316 | 657 | 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 current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1โฆiโฆ|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game. | aa = input()
bb = input()
cc = input()
def kansu(char,a,b,c):
print("im called {} {} {} {}".format(char,a,b,c))
if char == 'a':
if not a:
return 'a'
else:
char = a[0:1]
a = a[1:]
r = kansu(char,a,b,c)
elif char == 'b':
if not b:
return 'b'
else:
char = b[0:1]
b = b[1:]
r = kansu(char,a,b,c)
else:
if not c:
return 'c'
else:
char = c[0:1]
c =c[1:]
r = kansu(char,a,b,c)
return r
charc = aa[0:1]
aa = aa[1:]
kansu(charc,aa,bb,cc) | s663001420 | Accepted | 18 | 2,940 | 144 | ss = {i:list(input()) for i in "abc"}
x = ss['a'].pop(0)
while True:
if not ss[x]:
print(x.upper())
break
else:
x = ss[x].pop(0) |
s748238502 | p03251 | u607865971 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 392 | Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out. | from sys import stdin
n, m, x, y = [int(x) for x in stdin.readline().rstrip().split()]
xList = [int(x) for x in stdin.readline().rstrip().split()]
yList = [int(x) for x in stdin.readline().rstrip().split()]
isOk = True
xMax = max(xList)
yMin = min(yList)
ret = [int(z) for z in range(xMax+1, yMin+1) if (x < z) and (z <= y)]
if len(ret) > 0:
print("War")
else:
print("No War") | s351215709 | Accepted | 18 | 3,060 | 252 | N, M, x, y = [int(x) for x in input().split()]
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
X.append(x)
Y.append(y)
maX = max(X)
miY = min(Y)
ans = ""
if maX < miY:
ans = "No War"
else:
ans = "War"
print(ans)
|
s971346122 | p03493 | u199290844 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 67 | 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. | arr = [int(i) for i in input().rstrip().split(' ')]
print(sum(arr)) | s559731684 | Accepted | 17 | 2,940 | 53 | arr = [int(i) for i in list(input())]
print(sum(arr)) |
s051097609 | p02612 | u686536081 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,036 | 25 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | print(int(input())%1000)
| s345002774 | Accepted | 27 | 9,140 | 36 | print((1000-int(input())%1000)%1000) |
s929422584 | p04029 | u264265458 | 2,000 | 262,144 | Wrong Answer | 23 | 3,316 | 31 | 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? | a=int(input())
print((a+1)*a/2) | s422583682 | Accepted | 17 | 2,940 | 36 | a=int(input())
print(int((a+1)*a/2)) |
s733256523 | p02399 | u992449685 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 83 | Write a program which reads two integers a and b, and calculates the following values: * a รท b: d (in integer) * remainder of a รท b: r (in integer) * a รท b: f (in real number) | a, b = map(int, input().split())
print('{} {} {}'.format(int(a/b), a % b, a / b))
| s961821099 | Accepted | 20 | 5,600 | 87 | a, b = map(int, input().split())
print('{} {} {:.5f}'.format(int(a/b), a % b, a / b))
|
s519999349 | p03814 | u923712635 | 2,000 | 262,144 | Wrong Answer | 53 | 3,516 | 162 | 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()
num_A = 0
num_B = 0
for ind,i in enumerate(s):
if(num_A == 0 and i == 'A'):
num_A = ind
if(i == 'Z'):
num_Z = ind
print(num_B - num_A + 1) | s679401142 | Accepted | 51 | 3,516 | 166 | s = input()
num_A = -1
num_Z = -1
for ind,i in enumerate(s):
if(num_A == -1 and i == 'A'):
num_A = ind
if(i == 'Z'):
num_Z = ind
print(num_Z - num_A + 1)
|
s863025211 | p03777 | u706828591 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | 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 honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest. | x, y = input().split()
if(x != y):
print("H")
else:
print("D") | s959785444 | Accepted | 17 | 2,940 | 68 |
x, y = input().split()
if(x != y):
print("D")
else:
print("H") |
s899176144 | p03963 | u633450100 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | 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. | N,K = [int(i) for i in input().split()]
answer = K
for i in range(N-1):
answer *= K-1 | s433475178 | Accepted | 19 | 2,940 | 101 | N,K = [int(i) for i in input().split()]
answer = K
for i in range(N-1):
answer *= K-1
print(answer) |
s151906036 | p03836 | u787562674 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 210 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him. | sx, sy, tx, ty = map(int, input().split())
yu = "U" * (ty - sy)
xr = "R" * (tx - sx)
yd = "D" * (ty - sy)
xl = "L" * (tx - sx)
print(yu + xr + yd + xl + "L" + yu + "U" + xr + "R" + yd + "DD" + xl + "L" + "U") | s626695925 | Accepted | 17 | 3,060 | 222 | sx, sy, tx, ty = map(int, input().split())
yu = "U" * (ty - sy)
xr = "R" * (tx - sx)
yd = "D" * (ty - sy)
xl = "L" * (tx - sx)
print(yu + xr + yd + xl + "L" + yu + "U" + xr + "R" + "D" + "R" + yd + "D" + xl + "L" + "U")
|
s582577049 | p03568 | u226155577 | 2,000 | 262,144 | Wrong Answer | 255 | 3,316 | 263 | We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even? | n = int(input())
*A, = map(int, input().split())
from itertools import product
ans = 0
for P in product(range(3), repeat=10):
even = 0
for i in range(n):
b = A[i] + P[i] - 1
even |= (b % 2) == 0
if even:
ans += 1
print(ans)
| s340911596 | Accepted | 269 | 3,316 | 260 | n = int(input())
*A, = map(int, input().split())
from itertools import product
ans = 0
for P in product(range(3), repeat=n):
even = 0
for i in range(n):
b = A[i] + P[i] - 1
even |= (b % 2) == 0
if even:
ans += 1
print(ans) |
s468278544 | p03399 | u804048521 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 108 | 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 total fare when the optimal choices are made for trains and buses. | A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(min(A+C, A-D), min(B-C, B-D))) | s482103432 | Accepted | 17 | 2,940 | 108 | A = int(input())
B = int(input())
C = int(input())
D = int(input())
print(min(min(A+C, A+D), min(B+C, B+D))) |
s779029691 | p02608 | u063896676 | 2,000 | 1,048,576 | Wrong Answer | 719 | 9,176 | 364 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | # coding: utf-8
def main():
N = int(input())
fs = [0] * N
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
i = (x**2) + (y**2) + (z**2) + (x+y) + (y+z) + (z+x)
if i <= N:
fs[i-1] += 1
for i in range(N):
print(fs[i])
main()
# print(main())
| s853445286 | Accepted | 744 | 9,136 | 364 | # coding: utf-8
def main():
N = int(input())
fs = [0] * N
for x in range(1, 100):
for y in range(1, 100):
for z in range(1, 100):
i = (x**2) + (y**2) + (z**2) + (x*y) + (y*z) + (z*x)
if i <= N:
fs[i-1] += 1
for i in range(N):
print(fs[i])
main()
# print(main())
|
s877207036 | p02850 | u255943004 | 2,000 | 1,048,576 | Wrong Answer | 2,105 | 59,068 | 968 | Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors. | N = int(input())
AB = []
for _ in range(N-1):
AB.append([int(i) for i in input().split()])
from collections import defaultdict as ddict
tree_children = ddict(set)
tree_parent = ddict(int)
for ab in AB:
tree_children[ab[0]].add(ab[1])
tree_parent[ab[1]] = ab[0]
max_col = 0
for key in tree_children.keys():
max_col = max(len(tree_children[key])+1,max_col)
ans = [0] * (N-1)
for i in range(2,N+1):
available = list(range(1,max_col+1))
children = tree_children[i]
parent = tree_parent[i]
if parent != 1 and ans[parent-2] != 0:
available.remove(ans[parent-2])
p_children = tree_children[parent]
if p_children != set():
for p_child in p_children:
if ans[p_child-2] != 0:
available.remove(ans[p_child-2])
if children != set():
for child in children:
if ans[child-2] != 0:
available.remove(ans[child-2])
ans[i-2] = available[0] | s931474700 | Accepted | 659 | 44,344 | 804 | N = int(input())
AB = [[]]*(N-1)
for i in range(N-1):
AB[i] = list(map(int,input().split()))
from collections import defaultdict as ddict
from collections import deque
tree = ddict(list)
B = [0]*(N-1)
for i,ab in enumerate(AB):
tree[ab[0]].append(ab[1])
B[i] = ab[1]
C = [0]*N
Q = deque([1])
while Q:
q = Q.popleft()
c = 0
for w in tree[q]:
c += 1 + int(C[q-1] == c+1)
C[w-1] = c
Q.append(w)
print(max(C))
for b in B:
print(C[b-1])
|
s370401180 | p04043 | u416258526 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 117 | 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 the phrases once, in some order. | num_list = list(input().split())
if num_list.count(5)==2 and num_list.count(7)==1:
print('YES')
else:
print('NO') | s579591082 | Accepted | 17 | 2,940 | 124 | num_list = list(input().split())
if num_list.count("5")==2 and num_list.count("7")==1:
print('YES')
else:
print('NO')
|
s965238273 | p03997 | u263226212 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 125 | 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. | # -*- coding: utf-8 -*-
# input
a = int(input())
b = int(input())
h = int(input())
# solve & output
print((a + b) * h / 2)
| s442169914 | Accepted | 17 | 2,940 | 130 | # -*- coding: utf-8 -*-
# input
a = int(input())
b = int(input())
h = int(input())
# solve & output
print(int((a + b) * h / 2))
|
s113460307 | p03644 | u620846115 | 2,000 | 262,144 | Wrong Answer | 29 | 9,148 | 31 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | n = int(input())
print(n - n%2) | s272834765 | Accepted | 28 | 9,176 | 83 | n = int(input())
ans = 0
for i in range(8):
if 2**i <= n:
ans=2**i
print(ans) |
s209519158 | p02647 | u216015528 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 32,936 | 418 | We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations. | import copy
n, k = map(int, input().split())
a = list(map(int, input().split()))
b = [1] * n
for _ in range(k):
for i in range(n):
light = 0
for j in range(n):
if i < j:
if (j - a[j] - 0.5) < i:
light += 1
else:
if (j + a[j] + 0.5) > i:
light += 1
b[i] = light
a = copy.deepcopy(b)
print(a) | s325607401 | Accepted | 691 | 124,392 | 1,270 | # ac
import sys
import numpy as np
from numba import njit
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
@njit('(i8[::1],)', cache=True)
def update(a):
n = len(a)
b = np.zeros_like(a)
for i, x in enumerate(a):
l = max(0, i - x)
r = min(n - 1, i + x)
b[l] += 1
if r + 1 < n:
b[r + 1] -= 1
b = np.cumsum(b)
return b
n, k = map(int, readline().split())
a = np.array(read().split(), np.int64)
k = min(k, 41)
for _ in range(k):
a = update(a)
print(' '.join(map(str, a))) |
s458456107 | p03729 | u713539685 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 97 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`. | A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
print('Yes')
else:
print('No') | s149094605 | Accepted | 17 | 2,940 | 97 | A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
print('YES')
else:
print('NO') |
s836060220 | p03815 | u934868410 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 51 | Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90ยฐ toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total. | x = int(input())
print((x//11) * 2 + (x % 11 > 5)) | s520543626 | Accepted | 17 | 2,940 | 64 | x = int(input())
print((x//11) * 2 + (x % 11 > 0) + (x%11 > 6)) |
s953731930 | p03556 | u296150111 | 2,000 | 262,144 | Wrong Answer | 22 | 2,940 | 83 | 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. | n=int(input())
for i in range(n):
if i*i>n:
print(i-1)
break
else:
continue | s992955104 | Accepted | 24 | 2,940 | 84 | n=int(input())
a=1
while a<=n+2:
if a*a<=n:
a+=1
else:
print((a-1)**2)
break |
s469120872 | p03455 | u125269142 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = map(int, input().split())
if a * b % 2 == 0:
print('even')
else:
print('odd') | s748247268 | Accepted | 17 | 2,940 | 95 | a, b = map(int, input().split())
c = a * b
if c % 2 == 0:
print('Even')
else:
print('Odd') |
s708065525 | p03377 | u499259667 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | 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. | a,b,x=map(int,input().split())
print("YES" if x<=a+b and b<=x else "NO") | s498027104 | Accepted | 17 | 2,940 | 72 | a,b,x=map(int,input().split())
print("YES" if x<=a+b and a<=x else "NO") |
s341988613 | p03493 | u063614215 | 2,000 | 262,144 | Wrong Answer | 149 | 12,392 | 106 | 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. | import numpy as np
s_list = [int(i) for i in list(input())]
ans = np.count_nonzero(s_list!=0)
print(ans) | s359761181 | Accepted | 17 | 2,940 | 97 | s = input()
counter = 0
for i in range(len(s)):
if s[i]=='1':
counter += 1
print(counter) |
s868014597 | p02390 | u737311644 | 1,000 | 131,072 | Wrong Answer | 20 | 7,708 | 100 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | a=int(input())
h=int(int(a)/3600)
b=int((int(a)-h*3600)/60)
s=int((int(a)-h*3600-b*60))
print(h,b,s) | s258433772 | Accepted | 20 | 5,588 | 104 | a=int(input())
h1=a//3600
h2=a%3600
m=h2//60
s=h2%60
h1=str(h1)
m=str(m)
s=str(s)
print(h1+":"+m+":"+s)
|
s627427041 | p03546 | u188745744 | 2,000 | 262,144 | Wrong Answer | 302 | 17,788 | 304 | Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0โคi,jโค9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}โ -1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end. | N,M=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(10)]
s=[list(map(int,input().split())) for i in range(N)]
from scipy.sparse.csgraph import floyd_warshall
l=floyd_warshall(l)
print(l)
ans=0
for i in s:
for j in i:
ans+=0 if j == -1 else l[j][1]
print(int(ans)) | s156824485 | Accepted | 432 | 27,716 | 295 | N,M=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(10)]
s=[list(map(int,input().split())) for i in range(N)]
from scipy.sparse.csgraph import floyd_warshall
l=floyd_warshall(l)
ans=0
for i in s:
for j in i:
ans+=0 if j == -1 else l[j][1]
print(int(ans)) |
s746665809 | p02392 | u698693989 | 1,000 | 131,072 | Wrong Answer | 20 | 7,524 | 172 | Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No". | x=input().split()
y=list(map(int,x))
a=y[0]
b=y[1]
c=y[2]
if a<b<c:
print("OK")
else:
print("NG") | s133521109 | Accepted | 20 | 5,596 | 121 | list=input().split()
a=int(list[0])
b=int(list[1])
c=int(list[2])
if a < b and b < c:
print("Yes")
else:
print("No")
|
s782151852 | p02260 | u424720817 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 343 | Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i โ mini. | times = int(input())
numbers = list(map(int, input().split()))
count = 0
minj = 0
for i in range(times):
minj = i
for j in range(i, times, 1):
if numbers[j] < numbers[minj]:
minj = j
count += 1
numbers[i], numbers[minj] = numbers[minj], numbers[i]
print(' '.join(map(str, numbers)))
print(count)
| s887986832 | Accepted | 20 | 5,600 | 362 | times = int(input())
numbers = list(map(int, input().split()))
count = 0
minj = 0
for i in range(times):
minj = i
for j in range(i, times, 1):
if numbers[j] < numbers[minj]:
minj = j
if i != minj:
numbers[i], numbers[minj] = numbers[minj], numbers[i]
count += 1
print(' '.join(map(str, numbers)))
print(count)
|
s564971342 | p03698 | u203843959 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 109 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | S=list(input())
sset=set()
for s in S:
sset.add(s)
if len(sset)==26:
print("yes")
else:
print("no") | s869064852 | Accepted | 17 | 2,940 | 113 | S=list(input())
sset=set()
for s in S:
sset.add(s)
if len(sset)==len(S):
print("yes")
else:
print("no") |
s464950903 | p03360 | u471289663 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 196 | 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 operations? | a, b, c = map(int, input().split())
k = int(input())
ans = a+b+c
m = 100
if m > a:
m = a
if m > b:
m = b
if m > c:
m = c
ans = ans - m
for i in range(k):
m = m*2
print(ans + m)
| s850540422 | Accepted | 17 | 3,064 | 196 | a, b, c = map(int, input().split())
k = int(input())
ans = a+b+c
m = -100
if m < a:
m = a
if m < b:
m = b
if m < c:
m = c
ans = ans - m
for i in range(k):
m = m*2
print(ans + m) |
s229930822 | p03359 | u266569040 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | 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 example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi? | a,b = map(int,input().split())
print(a) if a<b else print(a-1) | s331935629 | Accepted | 17 | 2,940 | 63 | a,b = map(int,input().split())
print(a) if a<=b else print(a-1) |
s250221177 | p03555 | u699295339 | 2,000 | 262,144 | Wrong Answer | 154 | 12,508 | 146 | 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. | import numpy as np
up_ = np.array(list(reversed(input())))
lo = np.array(list(input()))
if (up_ == lo).any():
print('Yes')
else:
print('No') | s288485297 | Accepted | 149 | 12,508 | 146 | import numpy as np
up_ = np.array(list(reversed(input())))
lo = np.array(list(input()))
if (up_ == lo).all():
print('YES')
else:
print('NO') |
s559544297 | p02418 | u175224634 | 1,000 | 131,072 | Wrong Answer | 20 | 5,556 | 202 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | def judg_unit(ss,pp):
sss = ss + ss + ss
result = sss.find(pp)
if result != -1:
return True
else :
return False
s = str(input())
p = str(input())
print(judg_unit(s,p))
| s820571472 | Accepted | 20 | 5,560 | 202 | def judg_unit(ss,pp):
sss = ss + ss + ss
result = sss.find(pp)
if result != -1:
return "Yes"
else :
return "No"
s = str(input())
p = str(input())
print(judg_unit(s,p))
|
s800633363 | p03448 | u940102677 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 215 | 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 coin are different. | A = int(input())
B = int(input())
C = int(input())
X = int(input()) / 50
count = 0
a = 0
while a <= A:
b = 0
while b <= B:
r = X - 10*a - 2*b
if r >= 0:
count += min(r, C) + 1
b += 1
a += 1 | s591530486 | Accepted | 18 | 3,064 | 228 | A = int(input())
B = int(input())
C = int(input())
X = int(input()) / 50
count = 0
a = 0
while a <= A:
b = 0
while b <= B:
r = X - 10*a - 2*b
if r >= 0 and r <= C:
count += 1
b += 1
a += 1
print(count) |
s859138002 | p02659 | u494058663 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,100 | 81 | Compute A \times B, truncate its fractional part, and print the result as an integer. | a,b = map(float,input().split())
ans = a*b
print(ans)
ans= ans//1
print(int(ans)) | s569909291 | Accepted | 25 | 9,820 | 106 | from decimal import Decimal
a,b = map(str,input().split())
a = Decimal(a)
b = Decimal(b)
print((a*b)//1) |
s798724264 | p02612 | u353919145 | 2,000 | 1,048,576 | Wrong Answer | 31 | 8,968 | 302 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | money=int(input())
name=0
if money%1000==name:
print(name)
print("you can pay the exact price")
elif money//1000!=0:
remainder=money%1000
dividend=money//1000
print(dividend)
print(f"We will use {dividend} 1000-yen bills to pay the price and receive {remainder} yen in change.") | s622624843 | Accepted | 29 | 9,140 | 166 | money=int(input())
yen_bills=1000
if yen_bills>=money:
print(yen_bills-money)
else:
while yen_bills<money:
yen_bills+=1000
print(yen_bills-money)
|
s253262596 | p03623 | u006425112 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | 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 on a number line is represented by |s-t|. | import sys
x, a, b = map(int, sys.stdin.readline().split())
print(min(abs(x-a), abs(x-b))) | s889845811 | Accepted | 18 | 2,940 | 121 | import sys
x, a, b = map(int, sys.stdin.readline().split())
if abs(x-a) > abs(x-b):
print("B")
else:
print("A") |
s963087214 | p02612 | u892923530 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,084 | 65 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | N = int(input())
if N%1000 == 0:
print(0)
else:
print(N%1000) | s330241142 | Accepted | 31 | 9,148 | 72 | N = int(input())
if N%1000 == 0:
print(0)
else:
print(1000 - N%1000) |
s589424158 | p03163 | u479638406 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 7,668 | 440 | There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home. | def dynamic():
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W + 1)]*(N + 1)
for i in range(N):
w = wv[i][0]
v = wv[i][1]
for sum_w in range(W+1):
if sum_w - w >= 0:
dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w] + v)
dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])
return dp[N][W]
print(dynamic()) | s831053805 | Accepted | 218 | 15,456 | 197 | import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W + 1)
for n in range(N):
w, v = map(int, input().split())
dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(int(dp[-1])) |
s177970475 | p00075 | u498511622 | 1,000 | 131,072 | Wrong Answer | 30 | 7,536 | 215 | ่ฅๆบใฏๅคใใฎๆไบบ็
ใฎๅๅ ใจใใฆๆใใใใฆใใพใใ้ๅปใซใใใฆใฏใไธ้จใฎไพๅคใ้คใใฐใ้ซๆ ก็ใซใฏ็ก็ธใชใใฎใงใใใใใใใ้ๅบฆใฎๅ้จๅๅผท็ญใฎใใใซ้ๅไธ่ถณใจใชใใใใใใฏในใใฌในใซใใ้้ฃ็ใจใชใใใจใใ้็พๅฎ็ใชใใจใจใฏใใใชใใชใฃใฆใใพใใ้ซๆ ก็ใซใจใฃใฆใๅๅ้ขๅฟใๆใใญใฐใชใใชใๅ้กใซใชใใใใใใพใใใ ใใใงใใใชใใฏใไฟๅฅๅฎคใฎๅ
็ใฎๅฉๆใจใชใฃใฆใ็ๅพใฎใใผใฟใใ่ฅๆบใฎ็ใใฎใใ็ๅพใๆขใๅบใใใญใฐใฉใ ใไฝๆใใใใจใซใชใใพใใใ ๆนๆณใฏ BMI (Body Mass Index) ใจใใๆฐๅคใ็ฎๅบใใๆนๆณใงใใBMIใฏๆฌกใฎๅผใงไธใใใใพใใ BMI = 22 ใๆจๆบ็ใงใ25 ไปฅไธใ ใจ่ฅๆบใฎ็ใใใใใพใใ ๅใ
ใฎ็ๅพใฎไฝ้ใ่บซ้ทใฎๆ
ๅ ฑใใ BMI ใ็ฎๅบใใ25 ไปฅไธใฎ็ๅพใฎๅญฆ็ฑ็ชๅทใๅบๅใใใใญใฐใฉใ ใไฝๆใใฆใใ ใใใ | total=0
s=0
i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=i+0.5
print(total)
if isinstance(result,float):
print(round(result))
else:
print(result) | s177258271 | Accepted | 20 | 7,416 | 121 | while True:
try:
a,b,c=map(float,input().split(','))
bmi=b/c**2
if bmi>=25:
print(int(a))
except:
break |
s465215843 | p03760 | u227082700 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 98 | 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 characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password. | a,b,s=input(),input(),""
for i in range(len(a)-1):s+=a[i]+b[i]
if len(a)!=len(b):s+=a[-1]
print(s) | s762979360 | Accepted | 17 | 2,940 | 106 | s=input()
t=input()
ans=""
for i in range(len(t)):
ans+=s[i]+t[i]
if len(s)-len(t):ans+=s[-1]
print(ans) |
s592874942 | p02612 | u046247133 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,156 | 139 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | def Next(): return input()
def NextInt(): return int(Next())
N = NextInt()*0.001
import math
ans = math.ceil(N)
print(int(ans*1000-N*1000)) | s353672482 | Accepted | 35 | 9,024 | 154 | def Next(): return input()
def NextInt(): return float(Next())
N = round(NextInt()*0.0010, 3)
import math
ans = math.ceil(N)
print(int(ans*1000-N*1000)) |
s738337118 | p03377 | u846652026 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 79 | 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. | a,b,c = map(int, input().split())
print("Yes" if a <= c and a+b >= c else "No") | s830326304 | Accepted | 18 | 2,940 | 79 | a,b,c = map(int, input().split())
print("YES" if a <= c and a+b >= c else "NO") |
s263130624 | p03470 | u755180064 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 83 | 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 a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? | t = int(input())
s = set()
for i in range(t):
s.add(int(input()))
print(len(s)) | s113641928 | Accepted | 17 | 2,940 | 135 | if __name__ == '__main__':
t = int(input())
s = []
for i in range(t):
s.append(int(input()))
print(len(set(s))) |
s015024959 | p03141 | u623687794 | 2,000 | 1,048,576 | Wrong Answer | 481 | 32,548 | 233 | There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end". | from collections import deque
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key = lambda x:x[0]-x[1])
ans=0
for i in range(n):
if i%2==0:
ans+=l[i//2][0]
else:
ans-=l[n-1-(i//2)][1]
print(ans) | s900389385 | Accepted | 462 | 32,552 | 235 | from collections import deque
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort(key = lambda x:x[0]+x[1],reverse=True)
ans=0
for i in range(n):
if i%2==0:
ans+=l[i][0]
else:
ans-=l[i][1]
print(ans)
|
s742058455 | p00002 | u123596571 | 1,000 | 131,072 | Wrong Answer | 30 | 7,532 | 90 | Write a program which computes the digit number of sum of two integers a and b. | while True:
try:
a,b = map(int, input().split())
except:
break
print(len(str(a+b))) | s357175729 | Accepted | 20 | 7,620 | 113 | while True:
try:
a,b = map(int,input().split())
except:
exit()
print(len(str(a+b))) |
s341486431 | p03162 | u962197874 | 2,000 | 1,048,576 | Wrong Answer | 1,075 | 5,876 | 158 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains. | n=int(input())
a,b,c=0,0,0
for i in range(n):
x,y,z=map(int,input().split())
a,b,c=max(b,c)+x,max(a,c)+y,max(a,b)+z
print(a,b,c)
print(max(a,b,c)) | s209292146 | Accepted | 386 | 3,060 | 141 | n=int(input())
a,b,c=0,0,0
for i in range(n):
x,y,z=map(int,input().split())
a,b,c=max(b,c)+x,max(a,c)+y,max(a,b)+z
print(max(a,b,c)) |
s110856756 | p03845 | u336325457 | 2,000 | 262,144 | Wrong Answer | 24 | 3,060 | 259 | 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 drink i(1โฆiโฆM), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. | N=int(input())
T=input().split()
M=int(input())
for i in range(M):
time=0
P=input().split()
drink=int(P[0])
for ti in T:
k=0
if(int(T[k]) == drink):
time+=int(P[1])
k+=1
else:
time+=int(ti)
k+=1
print(time)
| s625263070 | Accepted | 21 | 3,060 | 231 | N=int(input())
T=input().split()
M=int(input())
for i in range(M):
time=0
P=input().split()
drink=int(P[0])
for k in range(N):
if(k+1 == drink):
time+=int(P[1])
else:
time+=int(T[k])
print(time)
|
s438407042 | p03495 | u266569040 | 2,000 | 262,144 | Wrong Answer | 2,105 | 25,760 | 3,085 | 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. |
import sys
variety = 0
element1 = 0
def main():
n, k = input().split()
#N = int(n)
K = int(k)
numeric = input().split()
numeric = [int(x) for x in numeric]
ใฎๅคๅฎใขใซใดใชใบใ
numeric.sort()
#print(numeric)
vary = []
TypeDetermination(numeric, vary)
#print(variety,vary)
count = [0 for i in range(variety)]
if variety > K:
TypeOfNumber(vary, numeric, count)
else:
print(0)
sys.exit()
dicNum = {}
makeDictionary(vary, count, dicNum)
#print(dicNum)
ballcount = 0
ball = []
if len(count) > K:
ball=list(dicNum.values())
#print(ball)
for i in range(K):
ball[i] = 0
#print(ball)
for i in range(len(ball)):
ballcount += ball[i]
print(ballcount)
def TypeDetermination(numeric, vary):
global element1,variety
for element in numeric:
if element1 is not numeric:
variety += 1
element1 = element
vary.append(element1)
def TypeOfNumber(vary, numeric, count):
global variety
N = variety
for i in range(N):
for j in range(len(numeric)):
if vary[i] == numeric[j]:
count[i] += 1
def makeDictionary(vary, count, dicNum):
for i in range(len(count)):
dicNum[vary[i]] = count[i]
sorted(dicNum.items(), key=lambda x: x[1])
if __name__ == "__main__":
main()
| s230913398 | Accepted | 204 | 39,316 | 318 | import collections
N,K = map(int,input().split())
ball = [int(j) for j in input().split()]
kind = dict(collections.Counter(ball))
if len(kind) <= K:
print(0)
else:
skind = sorted(kind.items(),key=lambda x: x[1])
sumNum = 0
for i in range(len(skind)-K):
sumNum += skind[i][1]
print(sumNum) |
s925073575 | p03048 | u771804983 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 13,780 | 214 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this? | R,G,B,N=map(int,input().split())
counter=0
for r in range(N+1):
for g in range(N+1):
b=(N-r*R-g*G)/B
if b.is_integer() and b>=0:
print(r,g)
counter += 1
print(counter)
| s857937369 | Accepted | 19 | 3,060 | 133 | R,G,B,N=map(int,input().split())
a=[0]*(N+1)
a[0]=1
for i in [R,G,B]:
for j in range(N+1-i):
a[j+i]+=a[j]
print(a[N])
|
s163290099 | p03814 | u964998676 | 2,000 | 262,144 | Wrong Answer | 59 | 3,516 | 165 | 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`. | str = input('')
start = 0
end = 0
for x in range(len(str)):
if str[x] == 'A' and start != 0:
start = x
elif str[x] == 'Z':
end = x
print(end - start + 1) | s487242424 | Accepted | 17 | 3,500 | 81 | str = input('')
start = str.find('A')
end = str.rfind('Z')
print(end - start + 1) |
s500843100 | p02415 | u629874472 | 1,000 | 131,072 | Wrong Answer | 20 | 5,536 | 35 | Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string. | char = input()
print(char.lower())
| s662930264 | Accepted | 20 | 5,548 | 38 | char = input()
print(char.swapcase())
|
s096144535 | p03555 | u569272329 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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. | x = str(input())
y = str(input())
if x == y[::-1]:
print("Yes")
else:
print("No")
| s425130468 | Accepted | 17 | 2,940 | 90 | x = str(input())
y = str(input())
if x == y[::-1]:
print("YES")
else:
print("NO")
|
s033635433 | p03992 | u685244071 | 2,000 | 262,144 | Wrong Answer | 16 | 2,940 | 64 | This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s. | s = input()
a = s[0:4]
b = s[4:-1]
print('{} {}.format(a, b)') | s568837627 | Accepted | 17 | 2,940 | 62 | s = input()
a = s[:4]
b = s[-8:]
print('{} {}'.format(a, b)) |
s325003969 | p03578 | u024804656 | 2,000 | 262,144 | Wrong Answer | 291 | 47,968 | 412 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems. | N = int(input())
DS = input().split()
D = {}
for i in range(N):
if DS[i] not in D:
D[DS[i]] = 0
D[DS[i]] += 1
M = int(input())
T = input().split()
flg = True
for i in range(M):
if T[i] in D:
D[T[i]] -= 1
if D[T[i]] < 0:
print('No')
flg = False
break
else:
print('No')
flg = False
break
if flg:
print('Yes')
| s927744621 | Accepted | 258 | 47,968 | 413 | N = int(input())
DS = input().split()
D = {}
for i in range(N):
if DS[i] not in D:
D[DS[i]] = 0
D[DS[i]] += 1
M = int(input())
T = input().split()
flg = True
for i in range(M):
if T[i] in D:
D[T[i]] -= 1
if D[T[i]] < 0:
print('NO')
flg = False
break
else:
print('NO')
flg = False
break
if flg:
print('YES')
|
s507126336 | p03385 | u627747800 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,060 | 547 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | #!/usr/bin/env python
# coding: utf-8
#
def main(input_str):
checker = {}
checker['a'] = False
checker['b'] = False
checker['c'] = False
if 3 != len(list(input_str)):
print('No')
return
for s in list(input_str):
checker[s] = True
if checker['a'] and checker['b'] and checker['c']:
print('Yes')
return
print('No')
return
if __name__ == '__main__':
while True:
try:
main(input().strip())
except EOFError:
pass
| s396174384 | Accepted | 17 | 3,060 | 515 | #!/usr/bin/env python
# coding: utf-8
#
def main(input_str):
checker = {}
checker['a'] = False
checker['b'] = False
checker['c'] = False
if 3 != len(list(input_str)):
print('No')
return
for s in list(input_str):
checker[s] = True
if checker['a'] and checker['b'] and checker['c']:
print('Yes')
return
print('No')
return
if __name__ == '__main__':
try:
main(input().strip())
except EOFError:
pass
|
s401691878 | p03645 | u411858517 | 2,000 | 262,144 | Wrong Answer | 736 | 55,600 | 416 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him. | N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
if 1 == L[i][0]:
s.append(L[i][1])
if 1 == L[i][1]:
s.append(L[i][0])
for i in range(M):
if N == L[i][0]:
g.append(L[i][1])
if M == L[i][1]:
g.append(L[i][0])
if set(g)&set(s):
print('POSSIBLE')
else:
print('IMPOSSIBLE') | s880987594 | Accepted | 788 | 61,228 | 416 | N, M = map(int, input().split())
L = [list(map(int, input().split())) for i in range(M)]
s = []
g = []
for i in range(M):
if 1 == L[i][0]:
s.append(L[i][1])
if 1 == L[i][1]:
s.append(L[i][0])
for i in range(M):
if N == L[i][0]:
g.append(L[i][1])
if N == L[i][1]:
g.append(L[i][0])
if set(g)&set(s):
print('POSSIBLE')
else:
print('IMPOSSIBLE') |
s409064902 | p03574 | u279229189 | 2,000 | 262,144 | Wrong Answer | 33 | 3,188 | 964 | 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 a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. | tmp = (input().split(" "))
H = int(tmp[0])
W = int(tmp[1])
datas = [input() for i in range(0, H, 1)]
array = []
for data in datas:
tmp = [x for x in list(data)]
array.append(tmp)
for i in range(0, H, 1):
for j in range(0, W, 1):
cnt = 0
if array[i][j] == "#":
continue
else:
for l in range(-1, 2, 1):
for m in range(-1, 2, 1):
no1 = i + l
no2 = j + m
if l == no1 and m == no2:
continue
try:
if no1 < 0 or no2 < 0:
continue
else:
if array[no1][no2] == "#":
cnt += 1
else:
pass
except:
pass
array[i][j] = str(cnt)
for x in (array):
print("".join(x))
| s238607554 | Accepted | 31 | 3,188 | 921 | tmp = (input().split(" "))
H = int(tmp[0])
W = int(tmp[1])
datas = [input() for i in range(0, H, 1)]
array = []
for data in datas:
tmp = [x for x in list(data)]
array.append(tmp)
for i in range(0, H, 1):
for j in range(0, W, 1):
cnt = 0
if array[i][j] == "#":
continue
else:
for l in range(-1, 2, 1):
for m in range(-1, 2, 1):
no1 = i + l
no2 = j + m
if i == no1 and j == no2:
continue
try:
if no1 < 0 or no2 < 0:
continue
else:
if array[no1][no2] == "#":
cnt += 1
else:
pass
except:
pass
array[i][j] = str(cnt)
for x in (array):
print("".join(x))
|
s071532127 | p03680 | u791110052 | 2,000 | 262,144 | Wrong Answer | 161 | 12,804 | 167 | 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 is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons. | n = int(input())
a = [int(input()) for _ in range(n)]
count = 1
i = 0
while count < n:
i = a[i] - 1
if i == 1:
print(count)
break
count += 1
print(-1)
| s849279082 | Accepted | 158 | 12,988 | 183 | n = int(input())
a = [int(input()) for _ in range(n)]
count = 1
i = 0
while count < n:
i = a[i] - 1
if i == 1:
print(count)
break
count += 1
if count >= n:
print(-1) |
s571897223 | p02615 | u333700164 | 2,000 | 1,048,576 | Wrong Answer | 150 | 31,372 | 240 | Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into? | n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
if n%2==0:
m=n//2
ans=0
for i in range(m):
ans+=2*a[i]
ans-=a[0]
else:
m=n//2
ans=0
for i in range(m):
ans+=2*a[i]
ans+=a[m]
ans-=a[0]
print(ans,a) | s290382873 | Accepted | 140 | 31,536 | 238 | n=int(input())
a=list(map(int,input().split()))
a.sort()
a=a[::-1]
if n%2==0:
m=n//2
ans=0
for i in range(m):
ans+=2*a[i]
ans-=a[0]
else:
m=n//2
ans=0
for i in range(m):
ans+=2*a[i]
ans+=a[m]
ans-=a[0]
print(ans) |
s055790956 | p01101 | u064320529 | 8,000 | 262,144 | Wrong Answer | 2,460 | 32,368 | 778 | Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally. | maxes=[]
cnt=0
while True:
s=input()
d=s.split()
n=int(d[0])
m=int(d[1])
if n==0 and m==0:
break
s=input()
d=s.split()
a=[]
for i in range(n):
if int(d[i]) in a:
n-=1
else:
a.append(int(d[i]))
p=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
for j in range(i+1,n):
p[i][j]=(a[i]+a[j])
max=0
for i in range(n):
for j in range(i+1,n):
if p[i][j]>m:
continue
if max<p[i][j]:
max=p[i][j]
if max==0:
maxes.append(-1)
else:
maxes.append(max)
cnt+=1
for i in range(cnt):
if maxes[i]==-1:
print("NONE")
else:
print(maxes[i])
| s716989607 | Accepted | 3,030 | 32,276 | 716 | maxes=[]
cnt=0
while True:
s=input()
d=s.split()
n=int(d[0])
m=int(d[1])
if n==0 and m==0:
break
s=input()
d=s.split()
a=[]
for i in range(n):
a.append(int(d[i]))
p=[[0 for i in range(n)] for j in range(n)]
for i in range(n):
for j in range(i+1,n):
p[i][j]=(a[i]+a[j])
max=0
for i in range(n):
for j in range(i+1,n):
if p[i][j]>m:
continue
if max<p[i][j]:
max=p[i][j]
if max==0:
maxes.append(-1)
else:
maxes.append(max)
cnt+=1
for i in range(cnt):
if maxes[i]==-1:
print("NONE")
else:
print(maxes[i])
|
s850603525 | p03474 | u840958781 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 239 | 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. | a,b=map(int,input().split())
s=input()
ans=0
for i in range(a+b+1):
if i==a and s[i]=="-":
ans+=1
print("a")
elif i!=a and s[i].isdecimal()==True:
ans+=1
if ans==a+b+1:
print("Yes")
else:
print("No") | s510928463 | Accepted | 17 | 3,060 | 220 | a,b=map(int,input().split())
s=input()
ans=0
for i in range(a+b+1):
if i==a and s[i]=="-":
ans+=1
elif i!=a and s[i].isdecimal()==True:
ans+=1
if ans==a+b+1:
print("Yes")
else:
print("No") |
s273075703 | p03339 | u748241164 | 2,000 | 1,048,576 | Wrong Answer | 161 | 21,072 | 317 | 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 face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | N = int(input())
S = str(input())
west = 0
for i in range(N):
if S[i] == "W":
west += 1
ans_list = [0] * N
for i in range(N):
if S[i] == "W":
west -= 1
if i != 0:
if S[i - 1] == "E":
west += 1
#ans_list[i] = min(west, N - west)
ans_list[i] = west
#print(ans_list)
print(min(ans_list))
| s446887376 | Accepted | 184 | 9,716 | 259 | N = int(input())
S = str(input())
count = 0
for i in range(N):
if S[i] == "E":
count += 1
ans = 10 ** 10
for i in range(N):
if S[i] == "E":
count -= 1
if i != 0:
if S[i - 1] == "W":
count += 1
ans = min(ans, count)
print(ans)
|
s833501437 | p02409 | u756958775 | 1,000 | 131,072 | Wrong Answer | 30 | 7,580 | 300 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that โv persons left. Assume that initially no person lives in the building. | x = [[[0 for k in range(10)]for j in range(3)]for i in range(4)]
n = int(input())
for i in range(n):
[b, f, r, v] = map(int, input().split())
x[b-1][f-1][r-1] += v
for b in range(4):
for f in range(3):
tmp = list(map(str, x[b][f]))
print(" ".join(tmp))
print("#"*20) | s337207493 | Accepted | 20 | 7,736 | 320 | x = [[[0 for k in range(10)]for j in range(3)]for i in range(4)]
n = int(input())
for i in range(n):
[b, f, r, v] = map(int, input().split())
x[b-1][f-1][r-1] += v
for b in range(4):
for f in range(3):
tmp = list(map(str, x[b][f]))
print(" "+" ".join(tmp))
if b!=3:
print("#"*20) |
s930810317 | p03436 | u474270503 | 2,000 | 262,144 | Wrong Answer | 26 | 3,188 | 1,178 | We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`. | class BFS():
def __init__(self, H, W, maze):
self.H = H
self.W = W
self.maze = maze
self.distance = [[0 for i in range(self.W)] for j in range(self.H)]
self.sx = 0
self.sy = 0
self.gx = W-1
self.gy = H-1
def bfs(self):
queue = []
queue.insert(0, (self.sx, self.sy))
self.distance[self.sx][self.sy] = 0
while len(queue):
x, y = queue.pop()
if x == self.gx and y == self.gy:
break
for i in range(0, 4):
nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
if (0 <= nx and nx < self.W and 0 <= ny and ny < self.H and self.maze[ny][nx] != '#' and self.distance[ny][nx] == 0):
queue.insert(0, (nx, ny))
self.distance[ny][nx] = self.distance[y][x] + 1
return self.distance[self.gy][self.gx]
H, W = list(map(int, input().split()))
sw=[list(input()) for _ in range(H)]
bfs=BFS(H, W, sw)
distance=bfs.bfs()
print(distance)
init_white=0
for i in range(H):
init_white+=sw[i].count('.')
print(init_white-(distance+1) if distance!=0 else -1)
| s557928583 | Accepted | 26 | 3,188 | 1,161 | class BFS():
def __init__(self, H, W, maze):
self.H = H
self.W = W
self.maze = maze
self.distance = [[0 for i in range(self.W)] for j in range(self.H)]
self.sx = 0
self.sy = 0
self.gx = W-1
self.gy = H-1
def bfs(self):
queue = []
queue.insert(0, (self.sx, self.sy))
self.distance[self.sx][self.sy] = 0
while len(queue):
x, y = queue.pop()
if x == self.gx and y == self.gy:
break
for i in range(0, 4):
nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]
if (0 <= nx and nx < self.W and 0 <= ny and ny < self.H and self.maze[ny][nx] != '#' and self.distance[ny][nx] == 0):
queue.insert(0, (nx, ny))
self.distance[ny][nx] = self.distance[y][x] + 1
return self.distance[self.gy][self.gx]
H, W = list(map(int, input().split()))
sw=[list(input()) for _ in range(H)]
bfs=BFS(H, W, sw)
distance=bfs.bfs()
init_white=0
for i in range(H):
init_white+=sw[i].count('.')
print(init_white-(distance+1) if distance!=0 else -1)
|
s641339699 | p03543 | u185523406 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 158 | 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**? | # -*- coding: utf-8 -*-
str = input()
if int(str[0:2]) % 111 == 0:
print("Yes")
elif int(str[1:3]) % 111 == 0:
print("Yes")
print("No")
| s782849405 | Accepted | 17 | 2,940 | 164 | # -*- coding: utf-8 -*-
str = input()
if int(str[0:3]) % 111 == 0:
print("Yes")
elif int(str[1:4]) % 111 == 0:
print("Yes")
else:
print("No")
|
s689132874 | p03555 | u277802731 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 110 | 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. | #77a
a=input()
b=input()
if a[0]==b[-1] and a[1]==b[1] and a[-1]==b[0]:
print('Yes')
else:
print('No') | s844220457 | Accepted | 17 | 2,940 | 110 | #77a
a=input()
b=input()
if a[0]==b[-1] and a[1]==b[1] and a[-1]==b[0]:
print('YES')
else:
print('NO') |
s544107807 | p03644 | u256464928 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 176 | Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times. | n = int(input())
if n < 2:
print(1)
elif n < 3:
print(2)
elif n < 5:
print(4)
elif n < 9:
print(8)
elif n < 17:
print(16)
elif n < 33:
print(32)
else:
print(64)
| s580538962 | Accepted | 19 | 2,940 | 36 | print(2**(len(bin(int(input())))-3)) |
s862842747 | p04030 | u030726788 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 203 | 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 empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | import sys
S=list(input())
print(S)
outp=""
for i in S:
if(i=="0"):
outp+="0"
elif(i=="1"):
outp+="1"
else:
if(len(outp)!=0):
outp = outp[0:-1]
print(outp) | s998051244 | Accepted | 17 | 3,060 | 194 | import sys
S=list(input())
outp=""
for i in S:
if(i=="0"):
outp+="0"
elif(i=="1"):
outp+="1"
else:
if(len(outp)!=0):
outp = outp[0:-1]
print(outp) |
s811654294 | p03591 | u497285470 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 104 | Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`. | i = input()
if len(i) < 4:
print('NO')
elif i[:4] == 'YAKI':
print('YES')
else:
print('NO') | s532976542 | Accepted | 17 | 2,940 | 104 | i = input()
if len(i) < 4:
print('No')
elif i[:4] == 'YAKI':
print('Yes')
else:
print('No') |
s659746563 | p02401 | u922633376 | 1,000 | 131,072 | Wrong Answer | 20 | 7,512 | 370 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | if __name__ == "__main__":
while True:
a,op,b = map(str,input().split())
if op is "+":
print("%d"%(int(a)+int(b)))
elif op is "-":
print("%d"%(int(a)-int(b)))
elif op is "*":
print("%d"%(int(a)*int(b)))
elif op is "/":
print("%d"%(int(a)-int(b)))
else:
break | s180074611 | Accepted | 20 | 7,668 | 370 | if __name__ == "__main__":
while True:
a,op,b = map(str,input().split())
if op is "+":
print("%d"%(int(a)+int(b)))
elif op is "-":
print("%d"%(int(a)-int(b)))
elif op is "*":
print("%d"%(int(a)*int(b)))
elif op is "/":
print("%d"%(int(a)/int(b)))
else:
break |
s522316469 | p03659 | u374051158 | 2,000 | 262,144 | Wrong Answer | 446 | 24,800 | 240 | 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 sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|. | n = int(input())
a = list(map(int, input().split()))
s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
subsum += a[i]
remain = s - subsum
print(subsum, remain)
res = min(res, abs(remain-subsum))
print(res) | s912872726 | Accepted | 177 | 24,820 | 214 | n = int(input())
a = list(map(int, input().split()))
s = sum(a)
subsum = 0
res = 1001001001001001
for i in range(n-1):
subsum += a[i]
remain = s - subsum
res = min(res, abs(remain-subsum))
print(res) |
s879596365 | p01359 | u798803522 | 8,000 | 131,072 | Wrong Answer | 20,870 | 12,616 | 572 | As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as โWestern calendarโ in Japan. The other calendar system is era-based calendar, or so-called โJapanese calendar.โ This system comes from ancient Chinese systems. Recently in Japan it has been a common way to associate dates with the Emperors. In the era- based system, we represent a year with an era name given at the time a new Emperor assumes the throne. If the era name is โAโ, the first regnal year will be โA 1โ, the second year will be โA 2โ, and so forth. Since we have two different calendar systems, it is often needed to convert the date in one calendar system to the other. In this problem, you are asked to write a program that converts western year to era-based year, given a database that contains association between several western years and era-based years. For the simplicity, you can assume the following: 1. A new era always begins on January 1st of the corresponding Gregorian year. 2. The first year of an era is described as 1. 3. There is no year in which more than one era switch takes place. Please note that, however, the database you will see may be incomplete. In other words, some era that existed in the history may be missing from your data. So you will also have to detect the cases where you cannot determine exactly which era the given year belongs to. | inputnum,outputnum = (int(n) for n in input().split(' '))
data = {}
while True:
for i in range(inputnum):
temp = input().split(' ')
data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1,int(temp[2])]
for o in range(outputnum):
targ = int(input())
for k,v in data.items():
if v[0] <= targ <= v[1]:
print(k + ' ' + str(targ-v[0] + 1))
break
else:
print("Unknown")
inputnum,outputnum = (int(n) for n in input().split(' '))
if inputnum == outputnum == 0:
break | s605280988 | Accepted | 4,560 | 7,948 | 576 | inputnum,outputnum = (int(n) for n in input().split(' '))
while True:
data = {}
for i in range(inputnum):
temp = input().split(' ')
data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1,int(temp[2])]
for o in range(outputnum):
targ = int(input())
for k,v in data.items():
if v[0] <= targ <= v[1]:
print(k + ' ' + str(targ-v[0] + 1))
break
else:
print("Unknown")
inputnum,outputnum = (int(n) for n in input().split(' '))
if inputnum == outputnum == 0:
break |
s286883620 | p03997 | u416258526 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | 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. | a = int(input())
b = int(input())
h = int(input())
print((a*b)//h) | s463885119 | Accepted | 17 | 2,940 | 69 | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2) |
s606303228 | p03798 | u353919145 | 2,000 | 262,144 | Wrong Answer | 219 | 6,388 | 1,329 | Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2โคiโคN-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`. | #!/usr/bin/env python3
n = int(input())
s = input()
t = []
l = []
for i in range(n):
t.append("S")
for i in range(n):
if i+1 <= n-1:
if (s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W"):
if t[i-1] == "S":
t[i+1] = "W"
else:
t[i+1] = "S"
else:
t[i+1] = t[i]
else:
if ((s[i] == "x" and t[i] == "S") or (s[i] == "o" and t[i] == "W")) and t[0] == t[i-1]: t = "-1"
elif ((s[i] == "x" and t[i] == "W") or (s[i] == "o" and t[i] == "S")) and t[0] != t[i-1]: t = "-1"
for i in range(n):
l.append("W")
for i in range(n):
if i+1 <= n-1:
if (s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W"):
if l[i-1] == "S":
l[i+1] = "W"
else:
l[i+1] = "S"
else:
l[i+1] = l[i]
else:
if(s[i] == "x" and l[i] == "S") or (s[i] == "o" and l[i] == "W") and t[0] == l[i-1]: l = "-1"
elif (s[i] == "x" and l[i] == "W") or (s[i] == "o" and l[i] == "S") and t[0] != l[i-1]: l = "-1"
if t != "-1" and l == "-1":
for i in t:
print(i,end ="")
elif t == "-1" and l != "-1":
for i in l:
print(i,end ="")
elif t == l:print("-1")
else:
for i in t:
print(i,end ="")
| s114501463 | Accepted | 551 | 3,572 | 1,306 | def addleave(p):
for i in range(1, n-1):
if s[i]=="o":
if p[i]=="S":
p += "S" if p[i-1]=="S" else "W"
else:
p += "W" if p[i-1]=="S" else "S"
else:
if p[i]=="S":
p += "W" if p[i-1]=="S" else "S"
else:
p += "S" if p[i-1]=="S" else "W"
return p
def solve():
result = addleave("SS")
if check(result):
return result
result = addleave("SW")
if check(result):
return result
result = addleave("WS")
if check(result):
return result
result = addleave("WW")
if check(result):
return result
return -1
def check(res):
flag = True
for i in range(n):
if res[(i + n - 1) % n] == res[(i + n + 1) % n] and res[i]=="S" and s[i]=="o":
pass
elif res[(i + n - 1) % n] != res[(i + n + 1) % n] and res[i]=="S" and s[i]=="x":
pass
elif res[(i + n - 1) % n] == res[(i + n + 1) % n] and res[i]=="W" and s[i]=="x":
pass
elif res[(i + n - 1) % n] != res[(i + n + 1) % n] and res[i]=="W" and s[i]=="o":
pass
else:
flag = False
return flag
if __name__=="__main__":
n = int(input())
s = input()
print(solve()) |
s411619322 | p02697 | u788260274 | 2,000 | 1,048,576 | Wrong Answer | 81 | 9,700 | 328 | You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given. | from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
n,m = list(map(int, input().split()))
for i in range(1,m+1):
print(i,n-i+1)
| s655080267 | Accepted | 84 | 9,648 | 484 | from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
n,m = list(map(int, input().split()))
p = m // 2
for i in range(p):
print(p-i,p+2+i)
q = m // 2 + 1
if m % 2 == 1:
for i in range(q):
print(m+q-i,m+q+i+1)
else:
for i in range(q-1):
print(m+q-i,m+q+i+1)
|
s487468457 | p03433 | u797550216 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 113 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | n = int(input())
a = int(input())
c = n // 500
one = n - c
if one <= a:
print('Yes')
else:
print('No') | s263764132 | Accepted | 20 | 3,316 | 118 | n = int(input())
a = int(input())
c = n // 500
one = n - c*500
if one <= a:
print('Yes')
else:
print('No')
|
s501251579 | p03565 | u293359059 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 836 | 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 thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`. | def CountE(x):
cnt = 0
ind = 0
temp = 1
for i in range(len(x)-1, 0, -1):
if x[i] == "?" and x[i] == x[i-1]:
temp += 1
cnt = temp
ind = i-1
else:
temp = 1
return cnt, ind
Sp = input()
T = input()
s = [i for i in Sp]
t = [i for i in T]
flg = 0
cnt = 0
ind = 0
if t[0] in s:
if len(t) <= len(s)-s.index(t[0]):
s[s.index(t[0]):s.index(t[0])+len(t)-1] = t
else:
flg = 1
else:
if len(t) > s.count("?") or s.count("?") < 2:
flg = 1
else:
cnt, ind = CountE(s)
if cnt >= len(t):
s[ind:ind+len(t)-1] = t
else:
flg = 1
if flg == 0:
for i in range(len(s)):
if s[i] == "?":
s[i] = "a"
ans = "".join(s)
print(ans if flg == 0 else "UNRESTORABLE") | s148144194 | Accepted | 18 | 3,064 | 408 | S = input()
T = input()
flg = 0
ans = ""
temp = ""
for i in range(len(S)):
flg = 0
if len(S[i:]) < len(T):
break
for j in range(len(T)):
if S[i:][j] != T[j] and S[i:][j] != "?":
flg = 1
if flg == 0:
temp = (S[0:i]+T+S[i+len(T):]).replace("?", "a")
if temp < ans or ans == "":
ans = temp
print(ans if ans != "" else "UNRESTORABLE") |
s576310572 | p02612 | u374395860 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,048 | 40 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | N = int(input())
A = N % 1000
print(A) | s711247406 | Accepted | 27 | 9,088 | 92 | N = int(input())
A = N % 1000
if A == 0:
print(0)
else:
B = 1000 - A
print(B)
|
s040020106 | p03623 | u010090035 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 86 | 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 on a number line is represented by |s-t|. | x,a,b=map(int,input().split())
if(abs(x-a)>=abs(x-b)):
print(b)
else:
print(a) | s927749257 | Accepted | 17 | 2,940 | 90 | x,a,b=map(int,input().split())
if(abs(x-a)>=abs(x-b)):
print("B")
else:
print("A") |
s097852928 | p02616 | u135389999 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 31,796 | 1,367 | Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive). | num = (10 ** 9) + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 1
r = 0
r_f = 0
l = n - 1
l_f = 1
a.sort()
if n == 1:
ans = a[0]
elif a[0] * a[-1] > 0:
if a[0] < 0:
if k % 2 == 0:
for i in range(k):
ans *= (a[i] % num)
else:
for i in range(k):
ans *= (a[-(i + 1)] % num)
else:
for i in range(k):
ans *= (a[-i - 1] % num)
else:
while k != 1:
if r_f == 0 and l_f == 0:
if abs(a[r]) >= abs(a[l]):
ans *= (a[r] % num)
r += 1
if a[r] >= 0:
r_f = 1
else:
ans *= (a[l] % num)
l -= 1
if a[l] <= 0:
l_f = 1
elif r_f == 1 and l_f == 0:
ans *= (a[l] % num)
l -= 1
if a[l] <= 0:
l_f = 1
elif r_f == 0 and l_f == 1:
ans *= (a[r] % num)
r += 1
if a[r] >= 0:
r_f = 1
else:
if abs(a[r]) >= abs(a[l]):
ans *= (a[r] % num)
r += 1
else:
ans *= (a[l] % num)
l -= 1
k -= 1
if ans < 0:
ans *= a[r]
else:
ans *= a[l]
print(ans % num) | s026246346 | Accepted | 193 | 31,608 | 1,730 | num = (10 ** 9) + 7
n, k = map(int, input().split())
a = list(map(int, input().split()))
plus = []
minus = []
zero = 0
ans = 1
for i in a:
if i > 0:
plus.append(i)
elif i < 0:
minus.append(-i)
else:
zero += 1
plus.sort()
minus.sort()
p_l = len(plus)
m_l = len(minus)
cnt = 0
def tail_num(p):
return p[-1] * p[-2]
if k == 1:
print(max(a) % num)
elif zero > n - k:
print(0)
elif zero == n - k:
for i in plus:
ans = (i * ans) % num
for j in minus:
ans = (ans * j) % num
if m_l % 2 == 0:
print(ans)
else:
print(-ans % num)
elif len(plus) == 0:
if k % 2 == 0:
for j in range(k):
ans = ans * (minus[-(j + 1)]) % num
print(ans % num)
else:
if 0 in a:
print(0)
else:
for j in range(k):
ans = ans * (minus[j]) % num
print(-ans % num)
else:
if k % 2 == 1:
ans = ans * plus.pop() % num
p_l -= 1
for i in range(k//2):
if p_l >= 2 and m_l >= 2:
if tail_num(minus) >= tail_num(plus):
ans = ans * tail_num(minus) % num
minus.pop()
minus.pop()
m_l -= 2
else:
ans = ans * tail_num(plus) % num
plus.pop()
plus.pop()
p_l -= 2
else:
if p_l <= 1:
ans = ans * tail_num(minus) % num
minus.pop()
minus.pop()
m_l -= 2
else:
ans = ans * tail_num(plus) % num
plus.pop()
plus.pop()
p_l -= 2
print(ans)
|
s815246666 | p03623 | u462538484 | 2,000 | 262,144 | Wrong Answer | 19 | 3,316 | 76 | 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 on a number line is represented by |s-t|. | n, a, b = map(int, input().split())
print("A" if (a - n) < (b - n) else "B") | s838748843 | Accepted | 17 | 2,940 | 82 | x, a, b = map(int, input().split())
print("A" if abs(a - x) < abs(b - x) else "B") |
s670708414 | p03407 | u578953945 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 160 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | A,B,C = map(int,input().split())
COIN=[1,5,10,100,500]
if A in COIN and B in COIN:
if A + B >= C:
print('Yes')
else:
print('No')
else:
print('No') | s961434407 | Accepted | 17 | 2,940 | 85 | A,B,C = map(int,input().split())
if (A + B) >= C:
print('Yes')
else:
print('No')
|
s631083276 | p03958 | u472534477 | 1,000 | 262,144 | Wrong Answer | 81 | 3,700 | 453 | There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 โค i โค T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before. Compute the minimum number of days on which the same type of cake as the previous day will be eaten. | K,T=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i,an in enumerate(a):
b.append([an,i])
ex = -1
ans = 0
if T == 1:
print(K-1)
else:
for i in range(K):
list.sort(b, reverse=True)
if ex == b[0][1] and b[0][0] == b[1][0]:
b[1][0] -= 1
else:
b[0][0] -= 1
if ex == b[0][1]:
ans+=1
print(b)
ex = b[0][1]
if b[0][1] == 0 and b[1][1] == 0:
break
print(ans)
| s033517509 | Accepted | 73 | 3,064 | 499 | K,T=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i,an in enumerate(a):
b.append([an,i])
ex = -1
ans = 0
if T == 1:
print(K-1)
else:
for i in range(K):
list.sort(b, reverse=True)
if ex == b[0][1] and b[1][0] != 0:
b[1][0] -= 1
ex = b[1][1]
if b[0][1] == 0 and b[1][1] == 0:
break
else:
b[0][0] -= 1
if ex == b[0][1]:
ans+=1
ex = b[0][1]
if b[0][1] == 0 and b[1][1] == 0:
break
print(ans)
|
s615680962 | p03488 | u617515020 | 2,000 | 524,288 | Wrong Answer | 1,025 | 10,264 | 491 | A robot is put at the origin in a two-dimensional plane. Initially, the robot is facing in the positive x-axis direction. This robot will be given an instruction sequence s. s consists of the following two kinds of letters, and will be executed in order from front to back. * `F` : Move in the current direction by distance 1. * `T` : Turn 90 degrees, either clockwise or counterclockwise. The objective of the robot is to be at coordinates (x, y) after all the instructions are executed. Determine whether this objective is achievable. | from copy import copy
s = input() + "T"
x,y = map(int, input().split())
d = [len(p) for p in s.split("T")]
x = d[0]
d_x = d[2::2]
d_y = d[1::2]
xs = set([x])
ys = set([0])
dpx = [x in xs]
for d in d_x:
xs_ = set()
for x in xs:
xs_.add(x+d)
xs_.add(x-d)
dpx.append(x in xs_)
xs = copy(xs_)
dpy = []
for d in d_y:
ys_ = set()
for y in ys:
ys_.add(y+d)
ys_.add(y-d)
dpy.append(y in ys_)
ys = copy(ys_)
if dpx[-1] and dpy[-1]: print("Yes")
else: print("No") | s639013608 | Accepted | 1,019 | 10,396 | 495 | from copy import copy
s = input() + "T"
x,y = map(int, input().split())
d = [len(p) for p in s.split("T")]
init = d[0]
d_x = d[2::2]
d_y = d[1::2]
xs = set([init])
ys = set([0])
dpx = [x in xs]
for d in d_x:
xs_ = set()
for u in xs:
xs_.add(u+d)
xs_.add(u-d)
dpx.append(x in xs_)
xs = copy(xs_)
dpy = []
for d in d_y:
ys_ = set()
for v in ys:
ys_.add(v+d)
ys_.add(v-d)
dpy.append(y in ys_)
ys = copy(ys_)
if dpx[-1] and dpy[-1]: print("Yes")
else: print("No") |
s787913746 | p03377 | u997641430 | 2,000 | 262,144 | Wrong Answer | 20 | 3,316 | 73 | 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. | A,B,X=map(int,input().split())
if A+B>=X>=A:print('Yes')
else:print('No') | s550321728 | Accepted | 18 | 2,940 | 73 | A,B,X=map(int,input().split())
if A<=X<=A+B:print('YES')
else:print('NO') |
s406747459 | p03415 | u314050667 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | 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 bottom-right corner of the grid, from the top-left to bottom-right. | s1 = input()
s2 = input()
s3 = input()
print(s1[0],s2[1],s3[2]) | s153951680 | Accepted | 17 | 2,940 | 64 | s1 = input()
s2 = input()
s3 = input()
print(s1[0]+s2[1]+s3[2]) |
s714681611 | p03944 | u984351908 | 2,000 | 262,144 | Wrong Answer | 24 | 3,064 | 671 | 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) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 โฆ i โฆ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting. | w, h, n = list(map(int, input().split()))
xya = []
for i in range(n):
xya.append(list(map(int, input().split())))
min_x_1 = w
max_x_2 = 0
min_y_3 = h
max_y_4 = 0
for i in range(n):
ai = xya[i][2]
if ai == 1:
if xya[i][0] < min_x_1:
min_x_1 = xya[i][0]
if ai == 2:
if xya[i][0] > max_x_2:
max_x_2 = xya[i][0]
if ai == 3:
if xya[i][1] < min_y_3:
min_y_3 = xya[i][1]
if ai == 4:
if xya[i][1] > max_y_4:
max_y_4 = xya[i][1]
x = max_x_2 - min_x_1
if x <= 0:
print("0")
else:
y = max_y_4 - min_y_3
if y <= 0:
print("0")
else:
print(x * y)
| s346333607 | Accepted | 23 | 3,064 | 671 | w, h, n = list(map(int, input().split()))
xya = []
for i in range(n):
xya.append(list(map(int, input().split())))
max_x_1 = 0
min_x_2 = w
max_y_3 = 0
min_y_4 = h
for i in range(n):
ai = xya[i][2]
if ai == 1:
if xya[i][0] > max_x_1:
max_x_1 = xya[i][0]
if ai == 2:
if xya[i][0] < min_x_2:
min_x_2 = xya[i][0]
if ai == 3:
if xya[i][1] > max_y_3:
max_y_3 = xya[i][1]
if ai == 4:
if xya[i][1] < min_y_4:
min_y_4 = xya[i][1]
x = min_x_2 - max_x_1
if x <= 0:
print("0")
else:
y = min_y_4 - max_y_3
if y <= 0:
print("0")
else:
print(x * y)
|
s445967467 | p03090 | u794173881 | 2,000 | 1,048,576 | Wrong Answer | 23 | 3,612 | 258 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem. | n = int(input())
if n%2 ==0:
print(n*(n+1)//2-n-1)
else:
print((n-1)*n//2)
if n%2 ==1:
for i in range(n-1):
print(i+1,n)
n = n-1
if n%2 ==0:
wa = n+1
for i in range(n):
for j in range(i+1,n):
if wa != i+j+2:
print(i+1,j+1) | s141203982 | Accepted | 17 | 3,064 | 374 | n = int(input())
li = []
for i in range(0,(n//2)*2):
if i+1 < n-i:
li.append([i+1,n-i-n%2])
else:
break
if n%2 == 1:
li.append([n])
if len(li) > 2:
li.append(li[0])
count = 0
for i in range(1,len(li)):
for j in li[i-1]:
for k in li[i]:
count += 1
print(count)
for i in range(1,len(li)):
for j in li[i-1]:
for k in li[i]:
print(j,k) |
s568629310 | p03495 | u743164083 | 2,000 | 262,144 | Wrong Answer | 293 | 50,600 | 451 | 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. | from collections import Counter
n, k = list(map(int, input().split()))
balls = list(map(int, input().split()))
b_list = set(balls)
nums = len(b_list)
yoso, s_yoso = [], []
counter = Counter(balls)
kakikae, t = 0, 1
if nums > k:
for i, v in counter.most_common():
yoso += [v]
if nums <= k:
print(0)
else:
s_yoso = sorted(yoso, reverse=True)
while nums - k > t:
kakikae += s_yoso[t-1]
t += 1
print(kakikae) | s679383487 | Accepted | 147 | 45,424 | 254 | from collections import Counter
n, k = list(map(int, input().split()))
a = Counter(map(int, input().split()))
a = list(a.items())
a.sort(key=lambda x: x[1])
opt = len(a) - k
ans = 0
if opt > 0:
for i in range(opt):
ans += a[i][1]
print(ans)
|
s877944173 | p00043 | u197615397 | 1,000 | 131,072 | Wrong Answer | 30 | 6,008 | 1,102 | 1 ใ 9 ใฎๆฐๅญใ 14 ๅ็ตใฟๅใใใฆๅฎๆใใใใใบใซใใใใพใใไธใใใใ 13 ๅใฎๆฐๅญใซใใใฒใจใคๆฐๅญใไปใๅ ใใฆๅฎๆใใใพใใ ใใบใซใฎๅฎๆๆกไปถใฏ * ๅใๆฐๅญใ๏ผใค็ตใฟๅใใใใใฎใๅฟ
ใใฒใจใคๅฟ
่ฆใงใใ * ๆฎใใฎ12 ๅใฎๆฐๅญใฏใ๏ผๅใฎๆฐๅญใฎ็ตใฟๅใใ๏ผใคใงใใ ๏ผๅใฎๆฐๅญใฎ็ตใฟๅใใๆนใฏใๅใๆฐๅญใ๏ผใค็ตใฟๅใใใใใฎใใใพใใฏ๏ผใคใฎ้ฃ็ถใใๆฐๅญใ็ตใฟๅใใใใใฎใงใใใใ ใใ9 1 2 ใฎใใใชไธฆใณใฏ้ฃ็ถใใๆฐๅญใจใฏ่ชใใใใพใใใ * ๅใๆฐๅญใฏ4 ๅใพใงไฝฟใใพใใ 13 ๅใฎๆฐๅญใใใชใๆๅญๅใ่ชญใฟ่พผใใงใใใบใซใๅฎๆใใใใจใใงใใๆฐๅญใๆ้ ใซๅ
จใฆๅบๅใใใใญใฐใฉใ ใไฝๆใใฆใใ ใใใใชใใ1ใ9 ใฎใฉใฎๆฐๅญใไปใๅ ใใฆใใใบใซใๅฎๆใใใใใจใใงใใชใใจใใฏ 0 ใๅบๅใใฆใใ ใใใ ไพใใฐไธใใใใๆๅญๅใ 3456666777999 ใฎๅ ดๅ ใ2ใใใใใฐใ 234 567 666 77 999 ใ3ใใใใใฐใ 33 456 666 777 999 ใ5ใใใใใฐใ 345 567 666 77 999 ใ8ใใใใใฐใ 345 666 678 77 999 ใจใใใตใใซใ2 3 5 8 ใฎใใใใใฎๆฐๅญใไปใๅ ใใใใใจใใบใซใฏๅฎๆใใพใใใ6ใใงใๆดใใพใใใ5 ๅ็ฎใฎไฝฟ็จใซใชใใฎใงใใใฎไพใงใฏไฝฟใใชใใใจใซๆณจๆใใฆใใ ใใใ | from collections import deque
try:
while True:
a = list(sorted(map(int, input())))
result = []
for i in range(1, 10):
if a.count(i) == 4:
continue
_a = sorted(a+[i])
dq = deque([(_a, 0)])
while dq:
hand, mentu = dq.popleft()
if mentu == 5:
if not hand:
result.append(i)
break
continue
if hand.count(hand[0]) >= 2:
dq.append((hand[2:], mentu+1))
if hand.count(hand[0]) >= 3:
dq.append((hand[3:], mentu+1))
if hand.count(hand[0]+1) > 0 and hand.count(hand[0]+2) > 0:
_hand = hand[:]
del _hand[0]
del _hand[_hand.index(hand[0]+1)]
del _hand[_hand.index(hand[0]+2)]
dq.append((_hand, mentu+1))
print(" ".join(map(str, result)) if result else 0)
except EOFError as e:
print(e)
exit()
| s997133066 | Accepted | 30 | 6,008 | 1,164 | from collections import deque
try:
while True:
a = list(sorted(map(int, input())))
result = []
for i in range(1, 10):
if a.count(i) == 4:
continue
_a = sorted(a+[i])
dq = deque([(_a, 0)])
while dq:
hand, mentu = dq.popleft()
if mentu == 5:
if not hand:
result.append(i)
break
continue
elif mentu > 5:
continue
current = hand[0]
if hand.count(current) >= 2:
dq.append((hand[2:], mentu+1))
if hand.count(current) >= 3:
dq.append((hand[3:], mentu+1))
if current+1 in hand and current+2 in hand:
_hand = hand[:]
del _hand[0]
del _hand[_hand.index(current+1)]
del _hand[_hand.index(current+2)]
dq.append((_hand, mentu+1))
print(" ".join(map(str, result)) if result else 0)
except EOFError:
exit()
|
s139865182 | p03730 | u787059958 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 201 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`. | a,b,c = map(int, input().split())
if(((a%2==0 or b%2==0) and c%2==0) or ((a%2==1 or b%2==1) and c%2==1)):
if((a-b)%2==c%2):
print('Yes')
else:
print('No')
else:
print('No') | s906699957 | Accepted | 17 | 2,940 | 162 | a,b,c = map(int, input().split())
t = False
for i in range(1,b+1):
if((a*i)%b==c):
t=True
break
if(t):
print('YES')
else:
print('NO') |
s463458198 | p00001 | u150984829 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 69 | There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order. | h=sorted([int(input())for _ in range(10)])
print(h[9:6:-1],sep='\n')
| s396705901 | Accepted | 20 | 5,600 | 59 | print(*sorted(int(input())for _ in[0]*10)[:6:-1],sep='\n')
|
s565275302 | p02393 | u313089641 | 1,000 | 131,072 | Wrong Answer | 20 | 7,636 | 80 | Write a program which reads three integers, and prints them in ascending order. | x = input()
# x = str('6 2 5')
a = [int(n) for n in x.split()]
a.sort()
print(a) | s300334653 | Accepted | 20 | 7,468 | 84 | x = input()
#x = str('6 2 5')
a = [n for n in x.split()]
a.sort()
print(' '.join(a)) |
s615899058 | p02279 | u742013327 | 2,000 | 131,072 | Wrong Answer | 30 | 7,728 | 1,721 | A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node." Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ : * node ID of _u_ * parent of _u_ * depth of _u_ * node type (root, internal node or leaf) * a list of chidlren of _u_ If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent. A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node** The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_. The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_. Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1. Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input. **Fig. 2** | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
class RootedTree:
def __init__(self, node, parent_node):
self.id = node[0]
self.parent = parent_node
self.item = node[2:]
self.children = []
self.depth = 0
self.type = None
self.next_id_node = None
if parent_node == None:
self.type = "root"
else:
parent_node.type = "internal node"
self.type = "leaf"
self.depth = parent_node.depth + 1
def filled(self):
return len(self.children) == len(self.item)
def show_self(self):
if self.parent == None:
parent_id = -1
else:
parent_id = self.parent.id
print("node " + str(self.id) + ":" + " parent = " + str(parent_id) + ", depth = " + str(self.depth)+ ", " + self.type + ", " + str(self.item))
def make_tree(trees):
root = None
target_node = None
for node in trees:
if target_node == None:
root = RootedTree(node, None)
target_node = root
root.show_self()
else:
child = RootedTree(node, target_node)
child.show_self()
target_node.next_id_node = child
target_node.children.append(child)
target_node = child
while target_node.filled():
target_node = target_node.parent
if not target_node:
break
return root
def main():
n_trees = int(input())
trees = [[int(a) for a in input().split()] for i in range(n_trees)]
make_tree(trees)
if __name__ == "__main__":
main() | s737826575 | Accepted | 780 | 66,012 | 2,417 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_A&lang=jp
"""
class RootedTree:
def __init__(self):
self.id = None
self.child = []
self.parent = -1
self.node_type = "root"
self.depth = 0
def show(self):
print("node {}: parent = {}, depth = {}, {}, {}".format(self.id, self.parent, self.depth, self.node_type, self.child))
def cal_depth(tree, node, cur_depth):
node.depth += cur_depth
#node.show()
for index in node.child:
cal_depth(tree, tree[index], cur_depth + 1)
def make_tree(tree_data):#?????????,?ยจ???????n^2
tree = [RootedTree() for i in range(len(tree_data))]
for data in tree_data:
focus = tree[data[0]]
focus.id = data[0]
if data[2:]:
focus.child = data[2:]
for child_index in data[2:]:
tree[child_index].parent = data[0]
if tree_data[[a[0] for a in tree_data].index(child_index)][2:]:
tree[child_index].node_type = "internal node"
else:
tree[child_index].node_type = "leaf"
root_index = [n.node_type for n in tree].index("root")
cal_depth(tree, tree[root_index], 0)
return tree
"""
def set_tree_data(tree, target, parent, depth):
tree[target]["depth"] += depth
tree[target]["parent"] = parent
for c in tree[target]["child"]:
set_tree_data(tree, c, target, depth + 1)
def make_tree_revision(tree_data, n_tree):
tree = [{"parent": None, "depth":0, "child" : None} for i in range(n_tree)]
root = sum(range(n_tree))
for node_data in tree_data:
tree[node_data[0]]["child"] = node_data[2:]
root -= sum(node_data[2:])
set_tree_data(tree, root, -1, 0)
return tree
def main():
n_tree = int(input())
tree_data = [[int(a) for a in input().split()] for i in range(n_tree)]
for i, node in enumerate(make_tree_revision(tree_data, n_tree)):
category = "root"
if (not node["parent"] == -1) and node["child"]:
category = "internal node"
elif not node["parent"] == -1:
category = "leaf"
print("node {}: parent = {}, depth = {}, {}, {}".format(i, node["parent"], node["depth"], category, node["child"]))
if __name__ == "__main__":
main() |
s052866316 | p03636 | u260036763 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 47 | 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. | s = input()
print(s[0] + str(len(s)-2) + s[-0]) | s837304856 | Accepted | 18 | 2,940 | 69 | s = input()
c = 0
for i in s:
c += 1
print(s[0] + str(c-2) + s[-1]) |
s924404543 | p03387 | u987164499 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 259 | You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations. | from sys import stdin
li = list(map(int,stdin.readline().rstrip().split()))
li.sort(reverse = True)
point = 0
su = sum(li)%2
sai = li[0]%2
if su != sai:
li[0] += 1
point += 1
for i in range(1,len(li)):
point += (li[0]-li[i])//2
print(point) | s205890114 | Accepted | 17 | 2,940 | 132 | li = list(map(int,input().split()))
li.sort()
lin = li[:]
if sum(li)%2 != 3*li[2]%2:
lin[2] += 1
print((lin[2]*3-sum(li))//2) |
s724113291 | p02258 | u843404779 | 1,000 | 131,072 | Wrong Answer | 20 | 7,572 | 221 | You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) ร 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ . | n = int(input())
r_first = int(input())
max_r = r_first
min_r = r_first
for _ in range(n - 1):
r = int(input())
if r > max_r:
max_r = r
if r < min_r:
min_r = r
ans = max_r - min_r
print(ans) | s839530350 | Accepted | 530 | 15,512 | 204 | n = int(input())
R = list()
for _ in range(n):
R.append(int(input()))
ans = R[1] - R[0]
min_R = R[0]
for i in range(1, n):
ans = max(ans, R[i] - min_R)
min_R = min(min_R, R[i])
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.