output_description
stringlengths
15
956
submission_id
stringlengths
10
10
status
stringclasses
3 values
problem_id
stringlengths
6
6
input_description
stringlengths
9
2.55k
attempt
stringlengths
1
13.7k
problem_description
stringlengths
7
5.24k
samples
stringlengths
2
2.72k
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s099270018
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a, b, c = (int(i) for i in input().split()) for i in range(a): c -= 1 count += 1 if c == 0 or i == a - 1: break for j in range(b): c -= 1 count += 1 if c <= 0: count += b - j - 1 break elif j == b - 1: count += 2 break else: count += 1 print(count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s275680075
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
line = input().split() list =[] for i in line: list.append(int(i)) min1 = min(list[1:3]) count = 0 list[1]-=min1 list[2]-=min1 count += min1*2 c = list[1] list.remove(list[1]) min2 = min(list) list[0]-=min2 list[1]-=min2 count += min2 count += c if list[0] == 0 && list[1] > 0: count += 1 print(count)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s282935260
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
a = int(input()) # スペース区切りの整数の入力 b, c = map(int, input().split()) # 文字列の入力 s = input() # 出力 print("{} {}".format(a + b + c, s))
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s327877711
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
#input_str = input() input_str = '8 8 1' A, B, C = input_str.split() A = int(A) B = int(B) C = int(C) if A + B > C + 1: print(C*2+1) else print((A+B)*2+1
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print the maximum number of tasty cookies that Takahashi can eat. * * *
s366965060
Runtime Error
p03186
Input is given from Standard Input in the following format: A B C
#! /usr/bin/env python3 # -*- coding: utf-8 -*- A, B, C = [int(x) for x in input().split()] if B >= C: as = C + B elif (C-B) >= A: as = B + A + C else: as = C + B print(as)
Statement Takahashi has A untasty cookies containing antidotes, B tasty cookies containing antidotes and C tasty cookies containing poison. Eating a cookie containing poison results in a stomachache, and eating a cookie containing poison while having a stomachache results in a death. As he wants to live, he cannot eat one in such a situation. Eating a cookie containing antidotes while having a stomachache cures it, and there is no other way to cure stomachaches. Find the maximum number of tasty cookies that Takahashi can eat.
[{"input": "3 1 4", "output": "5\n \n\nWe can eat all tasty cookies, in the following order:\n\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n * A tasty cookie containing antidotes\n * A tasty cookie containing poison\n * An untasty cookie containing antidotes\n * A tasty cookie containing poison\n\n* * *"}, {"input": "5 2 9", "output": "10\n \n\n* * *"}, {"input": "8 8 1", "output": "9"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s349732461
Accepted
p02797
Input is given from Standard Input in the following format: N K S
s = input().split() n, k, s = int(s[0]), int(s[1]), int(s[2]) x = s + 1 if s < 10**9 else s - 1 res = [str(s)] * k + [str(x)] * (n - k) print(" ".join(res))
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s908291874
Runtime Error
p02797
Input is given from Standard Input in the following format: N K S
n = int(input()) xl = (map(int, input().split()) for _ in range(n)) w = [(x - l, x + l) for x, l in xl] w = sorted(w, key=lambda x: x[1]) cur = w[0][1] res = 1 for l, r in w[1:]: if l >= cur: res += 1 cur = r print(res)
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s040345549
Accepted
p02797
Input is given from Standard Input in the following format: N K S
n, ko, aim = map(int, input().split()) l = [aim for i in range(ko)] d = 10**9 - 1 if aim == 10**9 else 10**9 f = [d for i in range(n - ko)] ll = l + f print(*ll, sep=" ")
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s965899279
Accepted
p02797
Input is given from Standard Input in the following format: N K S
NKS = input().split(" ") N = int(NKS[0]) K = int(NKS[1]) S = int(NKS[2]) out = "" other = 10**9 if S != 10**9 else (10**9) - 1 for i in range(K): out += str(S) + " " for i in range(K, N): out += str(other) + ("" if i == N - 1 else " ") print(out)
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s825080462
Wrong Answer
p02797
Input is given from Standard Input in the following format: N K S
# -*- coding: utf-8 -*- import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") sys.setrecursionlimit(10**9) INF = float("inf") MOD = 10**9 + 7 N, K, S = MAP() acc1 = [0] * (N - K + 1) acc2 = [0] * K for i in range(K): acc2[i] = S * (i + 1) acc = acc1 + acc2 A = [0] * N for i in range(N - 1, -1, -1): A[i] = acc[i + 1] - acc[i] print(*A)
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s007619266
Accepted
p02797
Input is given from Standard Input in the following format: N K S
# 入力が10**5とかになったときに100ms程度早い import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): """ H is number of rows """ return [list(map(int, read().split())) for _ in range(H)] def read_map(H): """ H is number of rows 文字列で与えられた盤面を読み取る用 """ return [read()[:-1] for _ in range(H)] def read_col(H, n_cols): """ H is number of rows n_cols is number of cols A列、B列が与えられるようなとき """ ret = [[] for _ in range(n_cols)] for _ in range(H): tmp = list(map(int, read().split())) for col in range(n_cols): ret[col].append(tmp[col]) return ret N, K, S = read_ints() INF = 10**9 MIN = 1 ans = [] for _ in range(K): ans.append(S) if S != INF: for _ in range(N - K): ans.append(INF) else: for _ in range(N - K): ans.append(MIN) print(*ans)
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s237638060
Accepted
p02797
Input is given from Standard Input in the following format: N K S
a, b, c = list(map(int, input().split())) p = 1 x = [c] * a while c % p == 0: p = p + 1 for i in range(b, a): x[i] = p print(*x)
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s886477749
Wrong Answer
p02797
Input is given from Standard Input in the following format: N K S
N, K, S = map(int, input().split()) ans = [min(i + 1, S) for i in range(N)] k = 0 for n in range(N): for r in range(n, N): if sum(ans[n : r + 1]) == S: k += 1 if k > K: for n in range(1, abs(k - K) + 1): ans[-n] = S + 1 if k < K: for n in range(1, K - k + 1): ans[-n] = S - ans[-n - 1] for x in ans: print(x, end=" ") print()
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print a sequence satisfying the condition, in the following format: A_1 A_2 ... A_N * * *
s375129109
Wrong Answer
p02797
Input is given from Standard Input in the following format: N K S
print("".join(["3", "10", "3", "10"]))
Statement Given are three integers N, K, and S. Find a sequence A_1, A_2, ..., A_N of N integers between 1 and 10^9 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists. * There are exactly K pairs (l, r) of integers such that 1 \leq l \leq r \leq N and A_l + A_{l + 1} + \cdots + A_r = S.
[{"input": "4 2 3", "output": "1 2 3 4\n \n\nTwo pairs (l, r) = (1, 2) and (3, 3) satisfy the condition in the statement.\n\n* * *"}, {"input": "5 3 100", "output": "50 50 50 30 70"}]
Print the number of possible (ordered) pairs of two matrices A and B (modulo 10^9+7). * * *
s330366668
Wrong Answer
p03885
The input is given from Standard Input in the following format: N c_{1, 1} ... c_{1, N} : c_{N, 1} ... c_{N, N}
from numpy import * P = 10**9 + 7 N = int(input()) C = array([input().split() for _ in range(N)], int8) r = linalg.matrix_rank(C) p = ones(N + 1, int64) for n in range(1, N + 1): p[n] = p[n - 1] * 2 % P d = zeros((N + 1, N + 1, N + 1), int64) d[:, 0, 0] = 1 for M in range(1, N + 1): d[:, M, :M] += d[:, M - 1, :M] * p[:M] % P d[:, M, 1 : M + 1] += d[:, M - 1, 0:M] * (p[:, None] - p[None, 0:M]) % P d[:, M, :] %= P print( sum( d[N, N, n] * d[N, n, r] % P * pow(2, N * (N - n), P) % P for n in range(r, N + 1) ) % P * pow(int(d[N, N, r]), P - 2, P) % P )
Statement Snuke received two matrices A and B as birthday presents. Each of the matrices is an N by N matrix that consists of only 0 and 1. Then he computed the product of the two matrices, C = AB. Since he performed all computations in modulo two, C was also an N by N matrix that consists of only 0 and 1. For each 1 ≤ i, j ≤ N, you are given c_{i, j}, the (i, j)-element of the matrix C. However, Snuke accidentally ate the two matrices A and B, and now he only knows C. Compute the number of possible (ordered) pairs of the two matrices A and B, modulo 10^9+7.
[{"input": "2\n 0 1\n 1 0", "output": "6\n \n\n* * *"}, {"input": "10\n 1 0 0 1 1 1 0 0 1 0\n 0 0 0 1 1 0 0 0 1 0\n 0 0 1 1 1 1 1 1 1 1\n 0 1 0 1 0 0 0 1 1 0\n 0 0 1 0 1 1 1 1 1 1\n 1 0 0 0 0 1 0 0 0 0\n 1 1 1 0 1 0 0 0 0 1\n 0 0 0 1 0 0 1 0 1 0\n 0 0 0 1 1 1 0 0 0 0\n 1 0 1 0 0 1 1 1 1 1", "output": "741992411"}]
Print the number of possible (ordered) pairs of two matrices A and B (modulo 10^9+7). * * *
s228935979
Wrong Answer
p03885
The input is given from Standard Input in the following format: N c_{1, 1} ... c_{1, N} : c_{N, 1} ... c_{N, N}
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**7) import numpy as np MOD = 10**9 + 7 N = int(readline()) C = np.array([line.split() for line in readlines()], np.int8) def rank(A): if (A == 0).all(): return 0 i = np.nonzero(A[:, 0])[0] if len(i) == 0: return rank(A[:, 1:]) i = i[0] temp = A[i].copy() A[i] = A[0] A[0] = temp A[1:] ^= A[1:, 0][:, None] * A[0][None, :] return 1 + rank(A[1:, 1:]) r = rank(C) pow2 = np.ones(301, dtype=np.int64) for n in range(1, 301): pow2[n] = pow2[n - 1] * 2 % MOD # N次元空間から、M本のベクトルを選んで、D次元部分空間を生成する方法の個数 dp = np.zeros((301, 301, 301), dtype=np.int64) dp[:, 0, 0] = 1 for M in range(1, 301): dp[:, M, :M] += dp[:, M - 1, :M] * pow2[:M] % MOD dp[:, M, 1 : M + 1] += dp[:, M - 1, 0:M] * (pow2[:, None] - pow2[None, 0:M]) % MOD dp[:, M, :] %= MOD # C=ABのrankがrとなる方法の総数 x = 0 for n in range(r, N + 1): x += dp[N, N, n] * dp[N, n, r] % MOD * pow(2, N * (N - n), MOD) % MOD answer = x * pow(int(dp[N, N, r]), MOD - 2, MOD) % MOD print(answer)
Statement Snuke received two matrices A and B as birthday presents. Each of the matrices is an N by N matrix that consists of only 0 and 1. Then he computed the product of the two matrices, C = AB. Since he performed all computations in modulo two, C was also an N by N matrix that consists of only 0 and 1. For each 1 ≤ i, j ≤ N, you are given c_{i, j}, the (i, j)-element of the matrix C. However, Snuke accidentally ate the two matrices A and B, and now he only knows C. Compute the number of possible (ordered) pairs of the two matrices A and B, modulo 10^9+7.
[{"input": "2\n 0 1\n 1 0", "output": "6\n \n\n* * *"}, {"input": "10\n 1 0 0 1 1 1 0 0 1 0\n 0 0 0 1 1 0 0 0 1 0\n 0 0 1 1 1 1 1 1 1 1\n 0 1 0 1 0 0 0 1 1 0\n 0 0 1 0 1 1 1 1 1 1\n 1 0 0 0 0 1 0 0 0 0\n 1 1 1 0 1 0 0 0 0 1\n 0 0 0 1 0 0 1 0 1 0\n 0 0 0 1 1 1 0 0 0 0\n 1 0 1 0 0 1 1 1 1 1", "output": "741992411"}]
Print the area of the largest rectangle.
s984202823
Wrong Answer
p02328
The input is given in the following format. $N$ $h_1$ $h_2$ ... $h_N$
N = int(input()) (*H,) = map(int, input().split()) st = [(0, -1)] ans = 0 for i in range(N): h = H[i] while h < st[-1][0]: h0, j = st.pop() ans = max(ans, (i - j) * h0) if st[-1][0] < h: st.append((h, i)) while st: h0, j = st.pop() ans = max(ans, (N - j) * h0) print(ans)
Largest Rectangle in a Histogram A histogram is made of a number of contiguous bars, which have same width. For a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area.
[{"input": "8\n 2 1 3 5 3 4 2 1", "output": "12\n \n\n![](https://judgeapi.u-aizu.ac.jp/resources/images/IMAGE2_DPL_3_histogram)"}, {"input": "3\n 2 0 1", "output": "2"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s173403675
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) N = INT() preo = LIST() ino = LIST() posto = [] def rec(l): if len(l) == 0: return # preorderから次の値を取り出す x = preo.pop(0) for i in range(len(l)): if l[i] == x: # preorderの値と一致したら、そこから左右に分割 rec(l[:i]) rec(l[i + 1 :]) posto.append(x) return rec(ino) print(*posto)
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s227768150
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
class Node: def __init__(self, parent=-1, left=-1, right=-1): self.parent = parent self.left = left self.right = right def postorder(ns, i, post): if ns[i].left != -1: postorder(ns, ns[i].left, post) if ns[i].right != -1: postorder(ns, ns[i].right, post) post.append(str(i + 1)) def poio_node(ns, po, io): p = po[0] i = io.index(p) if i != 0: ns[p].left = po[1] ns[po[1]].parent = p poio_node(ns, po[1 : i + 1], io[:i]) if i != len(io) - 1: ns[p].right = po[i + 1] ns[po[1 + i]].parent = p poio_node(ns, po[i + 1 :], io[i + 1 :]) def min1(n): return n - 1 n = int(input()) po = list(map(int, input().split())) io = list(map(int, input().split())) po = list(map(min1, po)) io = list(map(min1, io)) ns = [Node() for i in range(n)] poio_node(ns, po, io) post = [] postorder(ns, po[0], post) print(" ".join(post))
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s326256086
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
n = int(input().rstrip()) pre_map = input().rstrip().split(" ") pre_map = map(int, pre_map) in_list = input().rstrip().split(" ") in_list = list(map(int, in_list)) result = [] def reconst(left, right): if left >= right: return 0 c_of_pre = next(pre_map) c_of_in = in_list.index(c_of_pre) reconst(left, c_of_in) reconst(c_of_in + 1, right) result.append(str(c_of_pre)) reconst(0, n) print(" ".join(result))
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s288398831
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
class BinaryNode: def __init__(self, parent=-1, left=-1, right=-1, depth=-1, height=-1): self.parent = parent self.left = left self.right = right self.depth = depth self.height = height class BinaryTree(list): def __init__(self, obj): if isinstance(obj, int): super().__init__([BinaryNode() for _ in range(obj)]) self.len = obj elif isinstance(obj, list): super().__init__(obj) self.len = len(obj) else: raise TypeError("arg should be int or list of binarynodes") self.root = None # def __getitem__(self, idxs): # if isinstance(idxs, tuple): # return BinaryTree(list(self)[idxs]) # return super().__getitem__(idxs) def set_node(self, id, left, right): self[id].left = left self[id].right = right if left > -1: self[left].parent = id if right > -1: self[right].parent = id def __set_depth(self, id, depth): self[id].depth = depth if self[id].left > -1: self.__set_depth(self[id].left, depth + 1) if self[id].right > -1: self.__set_depth(self[id].right, depth + 1) def set_depth(self): self.__set_depth(self.root, 0) def __set_height(self, id): if id == -1: return -1 height = 1 + max( self.__set_height(self[id].left), self.__set_height(self[id].right) ) self[id].height = height return height def set_height(self): self.__set_height(self.root) def set_root(self): for i in range(self.len): if self[i].parent == -1: self.root = i break def get_nodetype(self, i): if self[i].parent == -1: return "root" elif self[i].left == -1 and self[i].right == -1: return "leaf" else: return "internal node" def get_sibling(self, i): parent = self[i].parent if parent == -1: return -1 if self[parent].left == i: return self[parent].right else: return self[parent].left def get_degree(self, i): return (self[i].left > -1) * 1 + (self[i].right > -1) * 1 def set_all(self): self.set_root() self.set_depth() self.set_height() def print(self): for i in range(self.len): print( "node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format( i, self[i].parent, self.get_sibling(i), self.get_degree(i), self[i].depth, self[i].height, self.get_nodetype(i), ) ) def __preorder(self, id): if id == -1: return [] return [id] + self.__preorder(self[id].left) + self.__preorder(self[id].right) def order_list(self, order_type): if order_type == 0: return self.__preorder(self.root) elif order_type == 1: return self.__inorder(self.root) else: return self.__postorder(self.root) def order_str(self, order_type): return " ".join(map(str, self.order_list(order_type))) def __inorder(self, id): if id == -1: return [] return self.__inorder(self[id].left) + [id] + self.__inorder(self[id].right) def __postorder(self, id): if id == -1: return [] return self.__postorder(self[id].left) + self.__postorder(self[id].right) + [id] def get_root(preorder, inorder, num, tree): root = preorder[0] if num == 1: return root root_idx = inorder.index(root) left_inorder = inorder[:root_idx] left_preorder = preorder[1 : 1 + root_idx] left_num = root_idx right_inorder = inorder[root_idx + 1 :] right_preorder = preorder[1 + root_idx :] right_num = num - root_idx - 1 if left_num > 0: left = get_root(left_preorder, left_inorder, left_num, tree) if left > -1: tree[root].left = left tree[left].parent = root if right_num > 0: right = get_root(right_preorder, right_inorder, right_num, tree) if right > -1: tree[root].right = right tree[right].parent = root return root def main(): n = int(input()) preorder = input().split(" ") preorder = list(map(lambda x: int(x) - 1, preorder)) inorder = input().split(" ") inorder = list(map(lambda x: int(x) - 1, inorder)) tree = BinaryTree(n) tree.root = get_root(preorder, inorder, n, tree) print(" ".join(map(lambda x: str(x + 1), tree.order_list(2)))) if __name__ == "__main__": main()
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s013820438
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
class Node: left = -1 right = -1 def get_root_index(first: int, end: int) -> int: """inorder[first:end]の根のインデックスを取得する。 根: inorder[first:end]を左部分木と右部分木に分割するノード """ # inorder[first:end]の要素でpreorderの一番手前にあるものが、 # inorder[first:end]を左部分木と右部分木に分割するノード。 # そのインデックスを返す。 for pre in preorder: for j in range(first, end): if pre == inorder[j]: return j def get_root(first, end) -> int: """inorder[first:end]の根のノードを返す。""" root_ix = get_root_index(first, end) if root_ix is not None: return inorder[root_ix] else: return -1 def set_nodes(first: int, end: int): root_ix = get_root_index(first, end) if first + 1 < root_ix: set_nodes(first, root_ix) if root_ix + 1 < end - 1: set_nodes(root_ix + 1, end) nodes[inorder[root_ix]].left = get_root(first, root_ix) nodes[inorder[root_ix]].right = get_root(root_ix + 1, end) def set_postorder(node_id: int) -> None: """後行順巡回で得られる節の番号を保存する。 Args: node_id (int): [description] """ left = nodes[node_id].left if left != -1: set_postorder(left) right = nodes[node_id].right if right != -1: set_postorder(right) postorder.append(node_id) N = int(input()) nodes = [Node() for i in range(N + 1)] preorder = [int(i) for i in input().split()] inorder = [int(i) for i in input().split()] set_nodes(0, N) postorder = [] set_postorder(get_root(0, N)) print(" ".join(map(str, postorder)))
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s107212742
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
# coding: utf-8 # Your code here! class Node: def __init__(self, id): self.id = id self.parent = -1 self.left = -1 self.right = -1 N = int(input()) nodes = [Node(i + 1) for i in range(N)] preorders = [int(i) - 1 for i in input().split()] inorders = [int(i) - 1 for i in input().split()] def dfs(nodes, preo, ino): if not preo: return root = preo[0] i = ino.index(root) if i != 0: nodes[root].left = preo[1] nodes[preo[1]].parent = root dfs(nodes, preo[1 : i + 1], ino[:i]) if i != len(ino) - 1: nodes[root].right = preo[i + 1] nodes[preo[i + 1]].parent = root dfs(nodes, preo[i + 1 :], ino[i + 1 :]) def postorder(nodes, root, result): node = nodes[root] if node.left != -1: postorder(nodes, node.left, result) if node.right != -1: postorder(nodes, node.right, result) result.append(root + 1) dfs(nodes, preorders, inorders) result = [] postorder(nodes, preorders[0], result) print(*result)
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s274849485
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
class Node: def __init__(self, num, left, right): self.value = num self.left = left self.right = right EmptyTree = None def make_node(num, left, right): return Node(num, left, right) def value(tree): return tree.value def left(tree): return tree.left def right(tree): return tree.right def is_empty(tree): return tree == EmptyTree def make_leaf(num): return make_node(num, EmptyTree, EmptyTree) # ????????¢?´¢??¨??¨??????????????????tree???x?????????????????°????????¨????????? def add_node(tree, x): if is_empty(tree): return make_leaf(x) elif x < value(tree): return make_node(value(tree), add_node(left(tree), x), right(tree)) else: return make_node(value(tree), left(tree), add_node(right(tree), x)) def make_binary_search_tree(a): tree = EmptyTree # ????????????????????¶: # ????????????i???????????£?????¨????????¨????¬????????????????????????§?????? # a?????????i???????????§???????´????????????¢?´¢??¨tree???????????????????????? for num in a: tree = add_node(tree, num) return tree def inorder(tree): if is_empty(tree): return [] return inorder(left(tree)) + [value(tree)] + inorder(right(tree)) def preorder(tree): if is_empty(tree): return [] return [value(tree)] + preorder(left(tree)) + preorder(right(tree)) def postorder(tree): if is_empty(tree): return [] return postorder(left(tree)) + postorder(right(tree)) + [value(tree)] # ?????????????????¨????§??????¨???????????¨?????????????¨??????????????????? def calc(tree): if is_empty(right(tree)) or is_empty(left(tree)): return value(tree) if value(tree) == "+": return calc(right(tree)) + calc(left(tree)) elif value(tree) == "-": return calc(right(tree)) - calc(left(tree)) elif value(tree) == "*": return calc(right(tree)) * calc(left(tree)) elif value(tree) == "/": return calc(right(tree)) / calc(left(tree)) def recover(preorder, inorder): # preorder??????????????????root # root???inorder??????????????¢??? # inorder??????root????¢?????????? # ?????????????????????Node??????????????£???????????????????????£????????? if len(inorder) == 0: return EmptyTree root_val = preorder[0] idx = inorder.index(root_val) left = inorder[:idx] right = inorder[idx + 1 :] return make_node( root_val, recover(preorder[1:], left), recover(preorder[1 + len(left) :], right) ) n = input() pre = list(map(int, input().split())) ino = list(map(int, input().split())) t = recover(pre, ino) t = map(str, postorder(t)) print(" ".join(t))
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s978284612
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write N = int(readline()) s0 = map(int, readline().split()) s1 = map(int, readline().split()) st0 = [] st1 = [] que = deque() q = next(s1, None) j = -1 ans = [] for v in s0: while st1 and st1[-1] != j: ans.append(st1.pop()) st1.append(v) st0.append(v) j = v while st0 and st0[-1] == q: j = st0.pop() q = next(s1, None) while st1: ans.append(st1.pop()) print(*ans)
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Print the sequence of node IDs obtained by the postorder tree walk in a line. Put a single space character between adjacent IDs.
s751950766
Accepted
p02282
In the first line, an integer $n$, which is the number of nodes in the binary tree, is given. In the second line, the sequence of node IDs obtained by the preorder tree walk is given separated by space characters. In the second line, the sequence of node IDs obtained by the inorder tree walk is given separated by space characters. Every node has a unique ID from $1$ to $n$. Note that the root does not always correspond to $1$.
class Tree: def __init__(self): self.nodes = {} self.nodes[-1] = None def add_node(self, id): if id not in self.nodes: self.nodes[id] = Node(id) def add_child(self, parent_id, left_id, right_id): self.add_node(parent_id) self.add_node(left_id) self.add_node(right_id) self.nodes[parent_id].add_child(self.nodes[left_id], self.nodes[right_id]) def root(self): for node in self.nodes.values(): if node and node.nodetype() == "root": return node class Node: def __init__(self, id): self.id = id self.parent = self.left = self.right = None self.depth = self.height = 0 def add_child(self, left, right): self.left = left self.right = right self.update_height() for child in self.children(): child.parent = self child.update_depth() def update_height(self): if self.degree(): self.height = max([child.height + 1 for child in self.children()]) if self.parent: self.parent.update_height() def update_depth(self): self.depth = self.parent.depth + 1 for child in self.children(): child.update_depth() def nodetype(self): if self.parent: if self.degree(): return "internal node" else: return "leaf" else: return "root" def degree(self): return len(self.children()) def children(self): return [child for child in [self.left, self.right] if child] def sibling(self): if self.parent and self.parent.degree() == 2: if self.parent.left == self: return self.parent.right.id else: return self.parent.left.id else: return -1 def __str__(self): return "node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format( self.id, self.parent.id if self.parent else -1, self.sibling(), self.degree(), self.depth, self.height, self.nodetype(), ) def walk(self, order): orders = { "Preorder": [self, self.left, self.right], "Inorder": [self.left, self, self.right], "Postorder": [self.left, self.right, self], } for node in orders[order]: if node == self: yield node elif node: for childnode in node.walk(order): yield childnode def make_tree(tree, preorder, inorder): if len(preorder) == 0: return -1 root_id = preorder[0] root_index = inorder.index(root_id) left_id = make_tree(tree, preorder[1 : root_index + 1], inorder[:root_index]) right_id = make_tree(tree, preorder[root_index + 1 :], inorder[root_index + 1 :]) tree.add_child(root_id, left_id, right_id) return root_id n = int(input()) preorder = list(map(int, input().split())) inorder = list(map(int, input().split())) tree = Tree() root_id = make_tree(tree, preorder, inorder) print(*[node.id for node in tree.nodes[root_id].walk("Postorder")])
Reconstruction of a Tree Write a program which reads two sequences of nodes obtained by the preorder tree walk and the inorder tree walk on a binary tree respectively, and prints a sequence of the nodes obtained by the postorder tree walk on the binary tree.
[{"input": "5\n 1 2 3 4 5\n 3 2 4 1 5", "output": "3 4 2 5 1"}, {"input": "4\n 1 2 3 4\n 1 2 3 4", "output": "4 3 2 1"}]
Replace every character in S with `x` and print the result. * * *
s381887102
Accepted
p02778
Input is given from Standard Input in the following format: S
score = input() leng = len(score) answer = "x" * leng print(answer)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s825370004
Accepted
p02778
Input is given from Standard Input in the following format: S
s = str(input()) x = len(s) s1 = "" for i in range(0, x): s1 += "x" print(s1)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s308851114
Accepted
p02778
Input is given from Standard Input in the following format: S
import sys input_methods = ["clipboard", "file", "key"] using_method = 0 input_method = input_methods[using_method] IN = lambda: map(int, input().split()) mod = 1000000007 # +++++ def main(): s = input() ret = "x" * len(s) print(ret) # +++++ isTest = False def pa(v): if isTest: print(v) def input_clipboard(): import clipboard input_text = clipboard.get() input_l = input_text.splitlines() for l in input_l: yield l if __name__ == "__main__": if sys.platform == "ios": if input_method == input_methods[0]: ic = input_clipboard() input = lambda: ic.__next__() elif input_method == input_methods[1]: sys.stdin = open("inputFile.txt") else: pass isTest = True else: pass # input = sys.stdin.readline ret = main() if ret is not None: print(ret)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s842247877
Accepted
p02778
Input is given from Standard Input in the following format: S
ans = ["x"] * len(input()) print("".join(ans))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s700751408
Accepted
p02778
Input is given from Standard Input in the following format: S
converted = ["x" for _ in range(len(input()))] print("".join(converted))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s463453581
Accepted
p02778
Input is given from Standard Input in the following format: S
print("x" * len(list(input())))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s347224782
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
string = "sardine" print(string.replace("sardine", "xxxxxxx"))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s115628147
Accepted
p02778
Input is given from Standard Input in the following format: S
print("x" * int(len(input())))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s611497181
Runtime Error
p02778
Input is given from Standard Input in the following format: S
print("x" * len(int(input())))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s193325214
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
print(len(input()) * "*")
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s542602960
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
print("×" * len(input()))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s755220786
Accepted
p02778
Input is given from Standard Input in the following format: S
S = input() char_list = list(S) new_list = [] for char in char_list: char = "x" new_list.append(char) output = "".join(new_list) print(output)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s208015304
Accepted
p02778
Input is given from Standard Input in the following format: S
# ABC154 -virtual # A # B if True: print("x" * len(input())) # C if False: N = int(input()) A = [int(i) for i in input().split()] print("YES" if len(A) == len(set(A)) else "NO") # D # E # F
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s747475132
Runtime Error
p02778
Input is given from Standard Input in the following format: S
n = int(input()) a = [int(i) for i in input().split()] count1 = 0 count2 = 0 for i in a: if i % 2 == 0: count1 += 1 if i % 3 == 0 or i % 5 == 0: count2 += 1 else: pass if count1 == count2: print("APPROVED") else: print("DENIED")
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s705234066
Runtime Error
p02778
Input is given from Standard Input in the following format: S
N, A, B = map(int, input().split()) rest = N - A - B if A == 0: print(0) elif N > A + B: answer = A + rest print(answer) elif A <= N <= A + B: print(A) elif A >= N: print(N)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s707464254
Runtime Error
p02778
Input is given from Standard Input in the following format: S
n = input().strip() for i in range(1, n + 1): if i == n: print("x") else: print("x", end="")
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s295399253
Accepted
p02778
Input is given from Standard Input in the following format: S
number = len(input()) print("x" * number)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s289211201
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
input1 = len(input()) print("X" * input1)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s577556409
Runtime Error
p02778
Input is given from Standard Input in the following format: S
u = input() for i in len(u): u[i] = "x" print(u)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s671994294
Runtime Error
p02778
Input is given from Standard Input in the following format: S
num = input() ad = "" for i in num: ad.append("x") print(ad)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s181354856
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
c = input() # print(len(c)) print("×" * len(c))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s261675525
Accepted
p02778
Input is given from Standard Input in the following format: S
sn = len(input()) print("x" * sn)
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s243713856
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
print("" * len(input()))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s800681255
Runtime Error
p02778
Input is given from Standard Input in the following format: S
a, b = map(str, input().split()) c, d = map(int, input().split()) n = input() if n == a: print(str(c - 1) + " " + str(d)) else: print(str(c) + " " + str(d - 1))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Replace every character in S with `x` and print the result. * * *
s564711884
Wrong Answer
p02778
Input is given from Standard Input in the following format: S
print("".join(["*"] * len(input())))
Statement Given is a string S. Replace every character in S with `x` and print the result.
[{"input": "sardine", "output": "xxxxxxx\n \n\nReplacing every character in S with `x` results in `xxxxxxx`.\n\n* * *"}, {"input": "xxxx", "output": "xxxx\n \n\n* * *"}, {"input": "gone", "output": "xxxx"}]
Print the answer. * * *
s743826326
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input().count("2"))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s394418799
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a = input() print(a.count('1')
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s003988839
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input().count("0"))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s142072082
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input(),count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s072930780
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(eval(input() + "%9"))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s711930589
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s=input() print(s.count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s566340198
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input(),count('1')
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s383975722
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
square = input() squList = [i for i in square] print(squList.count("1"))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s183743176
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a, b = map(int, input().split()) if (a * b) % 2 == 0: print('Even') else: print('Odd')
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s650572355
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
% input ex."101" masu = input() i=0 out=0 while i< len(masu): out+=masu[i] print(out)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s384994015
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
str(s) = input() count = 0 for v in range(1, 4): if 1 in s[v]: count += 1 print(count)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s996188784
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s = input() cnt = 0 for i in s: if s[] == 1: cnt+=1 else: cnt = cnt
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s261509153
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
for int(j) in input(): if j == 1: Count += 1 print(Count)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s216056093
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
A=input() cnt=0 if A[0]=='1': cnt++ if A[1]=='1': cnt++ if A[2]=='1': cnt++ print(cnt)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s555926040
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s = input() cout = 0 for a in s: if a == "1" cout += 1 print(cout)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s943084777
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a,b,c = input().split() i=0 if a==1: i++ if b==1: i++ if c==1: i++ print(i)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s940565759
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s=input() count=0 for i for range(3): if s[i]=='1': count+=1 print(count)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s099285760
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
import sys from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt, ceil, floor from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache, reduce from operator import xor INF = float("inf") sys.setrecursionlimit(10**7) # 4近傍(右, 下, 左, 上) dy = [0, -1, 0, 1] dx = [1, 0, -1, 0] def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W def main(): s = input() print(s.count("1")) if __name__ == "__main__": main()
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s201188628
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s = int(input()) l = list() a = s // 100 b = (s - a * 100) // 10 l.append(s // 100) l.append((s - a * 100) // 10) l.append((s - a * 100 - b * 10)) print(l.count(1))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s702526137
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
# coding= utf-8 lol = input("") S1 = int(lol[0:0]) S2 = int(lol[1:1]) S3 = int(lol[2:2]) Ss = [S1, S2, S3] cnt = 0 Ss.sort() for 1 in Ss: cnt += 1 del Ss[0] else: print(cnt) break
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s733166314
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
str1 = input() s_list = list(str1) str_len = len(str1) n = 0 for i in range(str_len): if == s_list[i]: n = n + 1 print(n)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s449832665
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
S = int(input()) if S[0] == 0 and S[1] == 0 and S[2] == 0: print("0") elif S[0] == 1 and S[1] == 0 and S[2] == 0: print("1") elif S[0] == 0 and S[1] == 1 and S[2] == 0: print("1") elif S[0] == 0 and S[1] == 0 and S[2] == 1: print("1") elif S[0] == 1 and S[1] == 1 and S[2] == 0: print("2") elif S[0] == 0 and S[1] == 1 and S[2] == 1: print("2") elif S[0] == 1 and S[1] == 0 and S[2] == 1: print("2") else: print("3")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s226772683
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
from bisect import bisect_right N, K = list(map(int, input().split())) A = list(map(int, input().split())) A.sort() S = set(A) S = list(S) B = [] def bisectsearch_right(L, a): i = bisect_right(L, a) return i for i in S: a = A[0] j = bisect_right(A, a) B += [j] del A[:j] B.sort() # print(B) C = B[: len(S) - K] print(sum(C))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s741091648
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
A, B, C = input() print(int(A) + int(B) + int(C))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s707944684
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
number = list(map(int, input())) print(number.count(1))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s382015151
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
arr = map(int, input().split()) print(sum(arr))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s784358977
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s=int(input()) print(s.count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s655020173
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s=input() print(s.count(“1”))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s776915960
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
xs = map(int, input().split(" ")) print(sum(xs))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s905701558
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a = list(input()) print(a.count('1')
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s112935091
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input().count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s818752712
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(sum[map(int, input())])
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s953201921
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
data = list(lambda x: int(x), input().strip().split()) print(sum(data))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s887526482
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
instr = input() out = 0 if instr[0] == "1": out += 1 if instr[1] == "1": out += 1 if instr[2] == "1": out += 1 print(out)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s354014953
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
s = input() x = 0 t = s % 100 u = s % 10 v = s % 1 if t == 1: x++ if u == 1: x++ if v == 1: x++ print(x)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s091070334
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
N=int(input) A=list(int(input().split())) ans=0 flag=True if flag==True: for i in range(N) if A[i]%2==0: A[i]=A[i]/2 else: flag=False break ans+=1 else: break print(ans)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s787133794
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a = str(input()).split("1") print(len(a) - 1)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s019079281
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
sss = input() print(sss.count("1"))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s691505139
Accepted
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(sum([int(c) for c in input()]))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s545952328
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
data = [x for x in input().rstrip()] print(data.count(1))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s369206227
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
str=int(input()) a=0 if str[0]==1: a++ if str[1]==1: a++ if str[2]==1: a++ print(a)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s768454730
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
n = input() a = list(map(int, input().split())) for i in range(n): while True: a[i] *= 1/2 if a[i]%2!=0 || a[i] = 0: break print(min(a))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s355876956
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
S=str(input()) print(S.count(”1”))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s013683077
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(input().count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s105806012
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
a = input().count("1")
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s405083040
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
li = input().split() c = 0 for i in range(0,3): if li[i]=='1': c++ print(c)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s293204243
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
count = 0 for s in input(): if s = '1': count += 1 print(count)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s406826196
Wrong Answer
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
print(sum(a == 1 for a in map(int, input().split())))
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]
Print the answer. * * *
s292096556
Runtime Error
p03493
Input is given from Standard Input in the following format: s_{1}s_{2}s_{3}
list = list(input()) for i in len(list): n = 0: if list[i] ==1: n =+ 1 print(n)
Statement 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.
[{"input": "101", "output": "2\n \n\n * A marble will be placed on Square 1 and 3.\n\n* * *"}, {"input": "000", "output": "0\n \n\n * No marble will be placed on any square."}]