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
s651824877
p03813
u583507988
2,000
262,144
Wrong Answer
17
2,940
65
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
x = int(input()) if x < 120: print('ABC') else: print('ARC')
s861970657
Accepted
28
8,952
65
x = int(input()) if x < 1200: print('ABC') else: print('ARC')
s542946936
p03089
u418120992
2,000
1,048,576
Wrong Answer
17
3,060
352
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
n = int(input()) a = [int(i) - 1 for i in input().split()] ans = [] while len(a): key = -1 for i, j in enumerate(a): if i == j: ans.append(i) key = i break if key == -1: break else: a.remove(key) if len(ans) != n: print(-1) else: for i in ans[::-1]: print(i)
s807564087
Accepted
18
3,060
336
n = int(input()) a = [int(i) - 1 for i in input().split()] ans = [] while len(a): key = -1 for i, j in enumerate(a): if i == j: key = i if key == -1: break else: a.remove(key) ans.append(key + 1) if len(ans) != n: print(-1) else: for i in ans[::-1]: print(i)
s852212282
p03524
u993622994
2,000
262,144
Wrong Answer
43
3,188
308
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
S = input() dic = {} for s in S: dic[s] = dic.get(s, 0) + 1 L = dic.values() sum_L = sum(L) max_n = max(L) min_n = min(L) if (sum_L - max_n) // 2 == min_n: if max_n == min_n: print('No') else: print('Yes') elif max_n == 1 and sum_L == 1: print('Yes') else: print('No')
s982597167
Accepted
46
3,956
253
S = list(input()) dic = {'a': 0, 'b': 0, 'c': 0} for s in S: dic[s] += 1 while dic['a'] > 0 and dic['b'] > 0 and dic['c'] > 0: dic['a'] -= 1 dic['b'] -= 1 dic['c'] -= 1 if max(dic.values()) >= 2: print('NO') else: print('YES')
s584410275
p00423
u546285759
1,000
131,072
Wrong Answer
100
5,616
352
A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14
while True: n = int(input()) if n == 0: break score = {"A": 0, "B": 0} for _ in range(n): A, B = map(int, input().split()) if A > B: score["A"] += A elif A < B: score["B"] += B else: score["A"] += A score["B"] += B print(score["A"], score["B"])
s215506563
Accepted
110
5,616
279
while True: n = int(input()) if n == 0: break score = [0, 0] for _ in range(n): A, B = map(int, input().split()) if A == B: score[0] += A score[1] += B else: score[A < B] += A+B print(*score)
s302690685
p03828
u761529120
2,000
262,144
Wrong Answer
30
3,568
2,160
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
import math from collections import defaultdict N = int(input()) def make_prime_list_2(num): if num < 2: return [] prime_list = [i for i in range(num + 1)] prime_list[1] = 0 num_sqrt = math.sqrt(num) for prime in prime_list: if prime == 0: continue if prime > num_sqrt: break for non_prime in range(2 * prime, num, prime): prime_list[non_prime] = 0 return [prime for prime in prime_list if prime != 0] def search_divisor_num_of_factorial_num(num): if num <= 0: return 0 elif num == 1 or num == 2: return 1 else: dict_counter = defaultdict(int) dict_memo = defaultdict(list) for a_num in range(2, num + 1): num_sqrt = math.ceil(math.sqrt(a_num)) prime_list = make_prime_list_2(num_sqrt) に入れるためのkeyを残しておく now_num = a_num for prime in prime_list: while a_num % prime == 0: if a_num in dict_memo: for memo in dict_memo[a_num]: dict_counter[memo] += 1 dict_memo[now_num].append(memo) a_num = 1 else: dict_counter[prime] += 1 dict_memo[now_num].append(prime) a_num //= prime if a_num != 1: dict_counter[a_num] += 1 dict_memo[now_num].append(a_num) divisor_num = 1 dict_fact = dict(dict_counter) for value in dict_fact.values(): divisor_num *= (value + 1) return divisor_num mod = 10 ** 9 + 7 print(search_divisor_num_of_factorial_num(N) % mod)
s241549614
Accepted
38
3,316
430
import math from collections import defaultdict N = int(input()) d = defaultdict(int) def division(n,d): flag = True tmp = n // 2 + 1 for num in range(2, tmp): while n % num == 0: flag = False n //= num d[num] += 1 if flag: d[n] += 1 return for n in range(2,N+1): division(n,d) ans = 1 for i in d.values(): ans *= (i+1) print(ans%(10**9+7))
s931476885
p04011
u266171694
2,000
262,144
Wrong Answer
17
2,940
101
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n = int(input()) k = int(input()) x = int(input()) y = int(input()) print(max(k - n, 0) * y + n * x)
s831147831
Accepted
17
2,940
109
n = int(input()) k = int(input()) x = int(input()) y = int(input()) print(max(n - k, 0) * y + min(n, k) * x)
s772012287
p03386
u543954314
2,000
262,144
Wrong Answer
2,238
2,065,176
114
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a, b, k = map(int, input().split()) l = [i for i in range(a, b)] l = set(l[:k-1] + l[-k:]) for i in l: print(i)
s167012407
Accepted
18
3,060
166
a, b, k = map(int, input().split()) l = [i for i in range(a, min(a+k,b+1))] + [i for i in range(max(a, b-k+1), b+1)] for i in sorted(set(l), key=l.index): print(i)
s072141090
p03162
u496009935
2,000
1,048,576
Wrong Answer
392
30,780
354
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()) X = [0]*n for i in range(n): t = list(map(int, input().split())) X[i] = t dp = [[0, 0, 0]]*n dp[0] = X[0] for i in range(1, n): dp[i][0] = max(dp[i-1][1]+X[i][0], dp[i-1][2]+X[i][0]) dp[i][1] = max(dp[i-1][0]+X[i][1], dp[i-1][2]+X[i][1]) dp[i][2] = max(dp[i-1][0]+X[i][2], dp[i-1][1]+X[i][2]) print(max(dp[-1]))
s178350157
Accepted
419
50,220
370
n = int(input()) X = [0]*n for i in range(n): t = list(map(int, input().split())) X[i] = t dp = [[0, 0, 0] for _ in range(n)] dp[0] = X[0] for i in range(1, n): dp[i][0] = max(dp[i-1][1]+X[i][0], dp[i-1][2]+X[i][0]) dp[i][1] = max(dp[i-1][0]+X[i][1], dp[i-1][2]+X[i][1]) dp[i][2] = max(dp[i-1][0]+X[i][2], dp[i-1][1]+X[i][2]) print(max(dp[-1]))
s695467873
p03369
u128623739
2,000
262,144
Wrong Answer
17
2,940
168
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
# -*- coding: utf-8 -*- a = input() b = a.count('o') print(b) if b == 3: print(1000) elif b == 2: print(900) elif b == 1: print(800) else: print(700)
s191942486
Accepted
17
2,940
159
# -*- coding: utf-8 -*- a = input() b = a.count('o') if b == 3: print(1000) elif b == 2: print(900) elif b == 1: print(800) else: print(700)
s585116422
p03380
u940102677
2,000
262,144
Wrong Answer
109
14,052
159
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
n = int(input()) a = list(map(int,input().split())) a.sort() q = a[-1] p = a[0] m = q for x in a: if abs(q//2-x)<m: p = x m = abs(q//2-x) print(p,q)
s399419143
Accepted
104
14,064
157
n = int(input()) a = list(map(int,input().split())) a.sort() p = a[-1] q = a[0] m = p for x in a: if abs(p-2*x)<m: q = x m = abs(p-2*x) print(p,q)
s189528532
p03493
u970405667
2,000
262,144
Wrong Answer
17
2,940
85
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.
num = map(int, input().split()) a = 0 for i in num: if i == 1: a += 1 print(a)
s535382029
Accepted
17
3,064
88
s = input() a = [int(c) for c in s] b = 0 for i in a: if i == 1: b += 1 print(b)
s556341170
p02401
u907607057
1,000
131,072
Wrong Answer
20
5,612
436
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.
import sys def main(): while True: list1 = [i for i in sys.stdin.readline().split()] if '?' in list1: break a, b, op = int(list1[0]), int(list1[2]), list1[1] if op == '+': print(a + b) elif op == '-': print(a - b) elif op == '*': print(a * b) else: print(a / b) return if __name__ == '__main__': main()
s941444871
Accepted
20
5,608
441
import sys def main(): while True: list1 = [i for i in sys.stdin.readline().split()] if '?' in list1: break a, b, op = int(list1[0]), int(list1[2]), list1[1] if op == '+': print(a + b) elif op == '-': print(a - b) elif op == '*': print(a * b) else: print(int(a / b)) return if __name__ == '__main__': main()
s246650318
p03353
u046187684
2,000
1,048,576
Wrong Answer
18
3,064
444
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
def solve(string): s, k = string.split() k = int(k) chars = sorted(set(s)) exists = [] def dfs(base): exists.append(base) print(exists) if len(exists) >= k: return for c in chars: if base + c in s: dfs(base + c) for c in chars: dfs(c) return exists[k - 1] if __name__ == '__main__': print(solve('\n'.join([input(), input()])))
s756357540
Accepted
18
3,060
426
def solve(string): s, k = string.split() k = int(k) chars = sorted(set(s)) exists = [] def dfs(base): exists.append(base) if len(exists) >= k: return for c in chars: if base + c in s: dfs(base + c) for c in chars[:3]: dfs(c) return exists[k - 1] if __name__ == '__main__': print(solve('\n'.join([input(), input()])))
s098973222
p03193
u314050667
2,000
1,048,576
Wrong Answer
20
3,064
208
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
n, h, w = map(int, input().split()) a,b = [],[] for _ in range(n): ta, tb = map(int, input().split()) a.append(ta) b.append(tb) cnt = 0 for i in range(n): if a[i] >= h and b[i] > w: cnt += 1 print(cnt)
s657681905
Accepted
20
3,060
209
n, h, w = map(int, input().split()) a,b = [],[] for _ in range(n): ta, tb = map(int, input().split()) a.append(ta) b.append(tb) cnt = 0 for i in range(n): if a[i] >= h and b[i] >= w: cnt += 1 print(cnt)
s968493970
p03556
u731028462
2,000
262,144
Wrong Answer
149
12,392
57
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.
import numpy as np int(10**(np.log10(int(input()))/2))**2
s036713314
Accepted
17
2,940
56
import math x = int(input()) print(int(math.sqrt(x))**2)
s642874323
p03729
u677037479
2,000
262,144
Wrong Answer
17
2,940
169
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]: if b[-1] == c[0]: print("Yes") elif b[-1] != c[0]: print("No") elif a[-1] != b[0]: print("No")
s431230885
Accepted
17
2,940
169
a,b,c = input().split() if a[-1] == b[0]: if b[-1] == c[0]: print("YES") elif b[-1] != c[0]: print("NO") elif a[-1] != b[0]: print("NO")
s491154610
p02612
u491221924
2,000
1,048,576
Wrong Answer
26
9,036
20
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 = input() print(n)
s156351949
Accepted
27
9,096
78
n = int(input()) if n % 1000 == 0: print(0) else: print(1000 - n%1000)
s217977223
p03448
u651946953
2,000
262,144
Wrong Answer
17
3,060
417
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()) x=int(x/50) countlist=[] for e in range(0,a): if x < e*10: break else: x -= e*10 count=0 for f in range(0,b): if x < f*2 : break else: if x-f*2 <= c : count = count +1 countlist.append(count) print(countlist)
s281393479
Accepted
26
3,060
436
#define a=int(input()) b=int(input()) c=int(input()) x=int(input()) count=0 countlist=[] #sorting for e in range(0,a+1): if e*500 <= x: y=x-e*500 for f in range(0,b+1): if f*100 <= y: z=y-100*f for g in range(0,c+1): if g*50 == z : count = count +1 print(count)
s076220190
p04043
u393881437
2,000
262,144
Wrong Answer
17
2,940
99
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.
s = list(map(int, input().split())) print('Yes' if s.count(5) == 2 and s.count(7) == 1 else 'No' )
s858031484
Accepted
17
2,940
99
s = list(map(int, input().split())) print('YES' if s.count(5) == 2 and s.count(7) == 1 else 'NO')
s773626116
p02612
u819362132
2,000
1,048,576
Wrong Answer
31
9,032
28
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()) print(N%1000)
s744881996
Accepted
30
8,996
66
N=int(input()) if N%1000==0: print(0) else: print(1000-N%1000)
s770518102
p03610
u653485478
2,000
262,144
Wrong Answer
50
4,596
83
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() list_s = list(s) for i in range(0, len(s), 2): print(list_s[i])
s146667563
Accepted
29
3,956
109
s = input() list_s = list(s) ans_s = "" for i in range(0, len(s), 2): ans_s += list_s[i] print(ans_s)
s020030260
p03415
u913662443
2,000
262,144
Wrong Answer
25
8,812
63
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]+s1[1]+s1[2])
s512826042
Accepted
21
8,968
57
a = input() b = input() c = input() print(a[0]+b[1]+c[2])
s419323539
p03455
u417794477
2,000
262,144
Wrong Answer
17
2,940
108
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()) result = a * b if result % 2 == 0: print("Odd") else: print("Even")
s957211478
Accepted
17
2,940
109
a, b = map(int,input().split()) result = a * b if result % 2 == 0: print("Even") else: print("Odd")
s890097217
p03054
u691018832
2,000
1,048,576
Wrong Answer
22
3,768
440
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`. The game consists of N steps. The i-th step proceeds as follows: * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece. * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece. Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done. Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally.
h, w, n = map(int, input().split()) r, c = map(int, input().split()) s = input() t = input() ans = 0 L_s, L_t = s.count('L'), t.count('L') R_s, R_t = s.count('R'), t.count('R') U_s, U_t = s.count('U'), t.count('U') D_s, D_t = s.count('D'), t.count('D') if R_s-L_t+c > w: ans += 1 if R_t-L_s+c < 0: ans += 1 if D_t-U_s+r < 0: ans += 1 if D_s-U_t+r > h: ans += 1 if ans >= 1: ans = 'No' else: ans = 'Yes' print(ans)
s722893686
Accepted
219
3,888
616
h, w, n = map(int, input().split()) ar, ac = map(int, input().split()) s = input() t = input() r = ac l = ac u = ar d = ar ans = False for i in range(n): if s[i] == "R": r += 1 if s[i] == "L": l -= 1 if s[i] == "U": u -= 1 if s[i] == "D": d += 1 if l==0 or r==w+1 or u==0 or d==h+1: print("NO") ans = True break if t[i] == "R" and l != w: l += 1 if t[i] == "L" and r != 1: r -= 1 if t[i] == "U" and d != 1: d -= 1 if t[i] == "D" and u != h: u += 1 if ans != True: print("YES")
s226236225
p04043
u672898046
2,000
262,144
Wrong Answer
17
2,940
160
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.
l = input().split() c_7 = 0 c_5 = 0 for i in l: if i == 7: c_7 += 1 if i == 5: c_5 += 1 if c_7 == 1 and c_5 == 2: print("YES") else: print("NO")
s389622865
Accepted
17
2,940
176
A = list(map(int, input().split())) c_7 = 0 c_5 = 0 for i in A: if i == 7: c_7 += 1 if i == 5: c_5 += 1 if c_7 == 1 and c_5 == 2: print("YES") else: print("NO")
s312418039
p03399
u317440328
2,000
262,144
Wrong Answer
18
3,188
164
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()) Total=0 if(A>=B): Total=A else: Total=B if(C>=D): Total=Total+C else: Total=Total+D print(Total)
s938714630
Accepted
18
3,060
164
A=int(input()) B=int(input()) C=int(input()) D=int(input()) Total=0 if(A>=B): Total=B else: Total=A if(C>=D): Total=Total+D else: Total=Total+C print(Total)
s725820332
p03095
u570522509
2,000
1,048,576
Wrong Answer
41
3,188
137
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
N=int(input()) S=input() d={} for c in S: d[c] = d[c]+1 if d.__contains__(c) else 1 ans=1 for a,b in d.items(): ans*=(b+1) print(ans)
s531241201
Accepted
42
3,316
162
N=int(input()) S=input() d={} for c in S: d[c] = d[c]+1 if d.__contains__(c) else 1 mod=int(1e9+7) ans=1 for a,b in d.items(): ans= ans*(b+1)%mod print(ans-1)
s605309057
p02608
u261427665
2,000
1,048,576
Wrong Answer
1,116
62,556
347
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).
a = int(input()) b = round(a**0.5) + 1 print(b) x = [] for i in range(1,b): for j in range(1,b): for k in range(1,b): l = i**2 + j**2 + k**2 + i*j + j*k + k*i x.append(l) print(x) t = [0] * a for i in range(0,len(x)): if x[i] <= a: t[x[i]-1] = t[x[i]-1] + 1 print(t,len(t)) for i in t: print(i)
s297722157
Accepted
1,054
48,932
314
a = int(input()) b = round(a**0.5) + 1 x = [] for i in range(1,b): for j in range(1,b): for k in range(1,b): l = i**2 + j**2 + k**2 + i*j + j*k + k*i x.append(l) t = [0] * a for i in range(0,len(x)): if x[i] <= a: t[x[i]-1] = t[x[i]-1] + 1 for i in t: print(i)
s499699686
p02411
u605525736
1,000
131,072
Wrong Answer
30
6,716
340
Write a program which reads a list of student test scores and evaluates the performance for each student. The test scores for a student include scores of the midterm examination m (out of 50), the final examination f (out of 50) and the makeup examination r (out of 100). If the student does not take the examination, the score is indicated by -1. The final performance of a student is evaluated by the following procedure: * If the student does not take the midterm or final examination, the student's grade shall be F. * If the total score of the midterm and final examination is greater than or equal to 80, the student's grade shall be A. * If the total score of the midterm and final examination is greater than or equal to 65 and less than 80, the student's grade shall be B. * If the total score of the midterm and final examination is greater than or equal to 50 and less than 65, the student's grade shall be C. * If the total score of the midterm and final examination is greater than or equal to 30 and less than 50, the student's grade shall be D. However, if the score of the makeup examination is greater than or equal to 50, the grade shall be C. * If the total score of the midterm and final examination is less than 30, the student's grade shall be F.
while True: (m, f, r) = [int(i) for i in input().split()] if m == f == r == -1: break total = m + f if m == -1 or f == -1 or total < 30: print('F') elif total < 50 and r < 50: print('D') elif total < 65: print('C') elif total < 85: print('B') else: print('A')
s935084891
Accepted
30
6,720
339
while True: (m,f,r) = [int(i) for i in input().split()] if m == f == r == -1: break total = m + f if m == -1 or f == -1 or total < 30: print('F') elif total < 50 and r < 50: print('D') elif total < 65: print('C') elif total < 80: print('B') else: print('A')
s897786956
p03408
u409064224
2,000
262,144
Wrong Answer
18
3,064
739
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
n = int(input()) s,t = list(),list() for i in range(n): s.append(input()) else: m = int(input()) for i in range(m): t.append(input()) s.sort() t.sort() s_ = set(s) t_ = set(t) s_,t_ = list(s_),list(t_) st_ = s_ + t_ st = set(st_) res_list = list(st) lo = len(res_list) res_co = [0]*lo for i in range(lo): res_co[i] += s.count(res_list[i]) res_co[i] -= t.count(res_list[i]) point = res_co.index(max(res_co)) #print(res_list) #print(res_co) print(point) #print(res_list[point])
s832600419
Accepted
18
3,064
523
n = int(input()) s,t = list(),list() for i in range(n): s.append(input()) m = int(input()) for i in range(m): t.append(input()) s.sort() t.sort() s_ = set(s) t_ = set(t) s_,t_ = list(s_),list(t_) st_ = s_ + t_ st = set(st_) res_list = list(st) lo = len(res_list) res_co = [0]*lo for i in range(lo): res_co[i] += s.count(res_list[i]) res_co[i] -= t.count(res_list[i]) #point = res_co.index(max(res_co)) #print(res_list) #print(res_co) if max(res_co) >= 0: print(max(res_co)) else: print(0)
s518458514
p02613
u376324032
2,000
1,048,576
Wrong Answer
27
9,116
242
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) S = list(map(str, input().split())) a = S.count("AC") w = S.count("WA") t = S.count("TLE") r = S.count("RE") print("AC x" + " " + str(a)) print("WA x" + " " + str(w)) print("TLE x" + " " + str(t)) print("RE x" + " " + str(r))
s163855146
Accepted
153
16,300
243
N = int(input()) S = [str(input()) for i in range(N)] a = S.count("AC") w = S.count("WA") t = S.count("TLE") r = S.count("RE") print("AC x" + " " + str(a)) print("WA x" + " " + str(w)) print("TLE x" + " " + str(t)) print("RE x" + " " + str(r))
s763741302
p03449
u486097876
2,000
262,144
Wrong Answer
20
3,064
401
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
N = int(input()) G1 = [int(i) for i in input().split()] G2 = [int(i) for i in input().split()] one = [0 for i in range(N)] two = [0 for i in range(N)] i = j = 0 for i in range(N): for j in range(i+1): one[i] = one[i] + G1[j] for k in range(i,N): two[i] = two[i] + G2[k] sum = 0 for i in range(N): if sum < one[i] + two[N-1]: sum = one[i] + two[N-1] print(sum)
s537870811
Accepted
20
3,064
399
N = int(input()) G1 = [int(i) for i in input().split()] G2 = [int(i) for i in input().split()] one = [0 for i in range(N)] two = [0 for i in range(N)] i = j = 0 for i in range(N): for j in range(0,i+1): one[i] = one[i] + G1[j] for k in range(i,N): two[i] = two[i] + G2[k] sum = 0 for i in range(N): if sum < one[i] + two[i]: sum = one[i] + two[i] print(sum)
s853516341
p03053
u921773161
1,000
1,048,576
Wrong Answer
1,056
12,020
651
You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. HW characters from A_{11} to A_{HW} represent the colors of the squares. A_{ij} is `#` if the square at the i-th row from the top and the j-th column from the left is black, and A_{ij} is `.` if that square is white. We will repeatedly perform the following operation until all the squares are black: * Every white square that shares a side with a black square, becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.
H, W = map(int, input().split()) A = [[] for _ in range(H)] inf = 1000000007 for i in range(H): A[i] = list(input()) for j in range(W): if A[i][j] == '.': A[i][j] = inf elif A[i][j] == '#': A[i][j] = 0 for i in range(H): for j in range(1, W): A[i][j] = min(A[i][j-1]+1, A[i][j]) for i in range(H): for j in range(W-2, -1, -1): A[i][j] = min(A[i][j+1]+1, A[i][j]) for i in range(1, H): for j in range(0, W): A[i][j] = min(A[i-1][j]+1, A[i][j]) for i in range(H-2, -1, -1): for j in range(1, W): A[i][j] = min(A[i+1][j]+1, A[i][j]) print(max(max(A)))
s855250058
Accepted
613
29,076
703
import numpy as np H, W = map(int, input().split()) A = [[] for _ in range(H)] inf = 10 ** 7 for i in range(H): A[i] = list(input()) for j in range(W): if A[i][j] == '.': A[i][j] = inf elif A[i][j] == '#': A[i][j] = 0 A = np.array(A) #print(A) for j in range(1, W): A[:,j] = np.minimum(A[:,j-1]+1, A[:,j]) #print(A) for j in range(W-2, -1, -1): A[:,j] = np.minimum(A[:,j+1]+1, A[:,j]) #print(A) for i in range(1, H): A[i,:] = np.minimum(A[i-1,:]+1, A[i,:]) #print(A) for i in range(H-2, -1, -1): A[i,:] = np.minimum(A[i+1,:]+1, A[i,:]) #print(A) ans = np.max(A) # ans_list.append(max(A[i])) print(ans)
s056323987
p04043
u865413330
2,000
262,144
Wrong Answer
18
2,940
96
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.
l = list(input().split()) print("YES") if l.count("5") == 2 & l.count("7") == 1 else print("NO")
s132845092
Accepted
17
2,940
100
l = list(input().split()) print("YES") if (l.count("5") == 2) & (l.count("7") == 1) else print("NO")
s480249827
p03494
u409417260
2,000
262,144
Time Limit Exceeded
2,104
5,484
253
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
def checkCanHalf(ary): for item in ary: if(item % 2 != 0): return False return True n = range(int(input())) ary = map(int, input().split()) cnt = 0 while checkCanHalf(ary) == True: ary = map(lambda x: x / 2, ary) cnt += 1 print(cnt)
s002710740
Accepted
19
3,060
275
def checkCanHalf(ary): for item in ary: if(item % 2 != 0): return False return True n = range(int(input())) ary = list(map(int, input().split())) cnt = 0 while checkCanHalf(ary) == True: for i in range(len(ary)): ary[i] = ary[i]/2 cnt += 1 print(cnt)
s502838864
p03759
u662441712
2,000
262,144
Wrong Answer
17
2,940
90
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a, b, c = map(int, input().split()) if b-a == c-b: print('Yes') else: print('No')
s969461681
Accepted
17
2,940
90
a, b, c = map(int, input().split()) if b-a == c-b: print('YES') else: print('NO')
s243041047
p03494
u377236950
2,000
262,144
Wrong Answer
18
2,940
139
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
num = list(map(int,input().split())) count = 0 while not all([n%2 for n in num]): num = [n/2 for n in num] count += 1 print(count)
s047897497
Accepted
19
3,060
151
a = input() num = list(map(int,input().split())) count = 0 while not any([n%2 for n in num]): num = [n/2 for n in num] count += 1 print(count)
s817863009
p03044
u671446913
2,000
1,048,576
Wrong Answer
413
23,752
218
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
N = int(input()) keirolist = [tuple(map(int, input().split())) for i in range(N-1)] ans = [0 for i in range(N+1)] for (u, v, w) in keirolist: if w % 2 == 0: ans[u] = 1 ans[v] = 1 [print(a) for a in ans[1:]]
s883736850
Accepted
865
58,508
454
N = int(input()) keirolist = [tuple(map(int, input().split())) for i in range(N-1)] graph = [[] for _ in range(N+1)] for (u, v, w) in keirolist: graph[u].append([v, w]) graph[v].append([u, w]) root = 1 dist = [-1 for _ in range(N+1)] dist[root] = 0 stack = [root] while stack: idx = stack.pop() for i, w in graph[idx]: if dist[i] == -1: dist[i] = dist[idx] + w stack.append(i) [print(0 if d % 2 == 0 else 1) for d in dist[1:]]
s592883209
p03407
u058592821
2,000
262,144
Wrong Answer
17
2,940
85
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 = (int(i) for i in input().split()) print('Yes') if a+b <= c else print('No')
s434152127
Accepted
17
2,940
91
a, b, c = (int(i) for i in input().split()) if a+b >= c: print('Yes') else: print('No')
s838756933
p03796
u721425712
2,000
262,144
Wrong Answer
17
2,940
122
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
def fact(n): if n == 1: return n else: return n*fact(n-1) n = int(input()) print(n%(10**9+7))
s999050508
Accepted
231
3,980
63
import math n = int(input()) print(math.factorial(n)%(10**9+7))
s862131400
p03149
u844789719
2,000
1,048,576
Wrong Answer
17
2,940
101
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".
if sorted([int(_) for _ in input().split()]) == [1, 4, 7, 9]: print('Yes') else: print('No')
s937158392
Accepted
17
2,940
98
if sorted(input()) == [' ', ' ', ' ', '1', '4', '7', '9']: print('YES') else: print('NO')
s930700612
p03494
u171276253
2,000
262,144
Wrong Answer
17
3,060
146
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
import math s = list(map(int, input().split())) ans = float('inf') for i in s: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print(ans)
s685008685
Accepted
18
3,060
173
import math num = int(input()) s = list(map(int, input().split())) ans = float('inf') for i in s: ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1) print(round(ans))
s049548394
p03304
u278492238
2,000
1,048,576
Wrong Answer
18
2,940
148
Let us define the _beauty_ of a sequence (a_1,... ,a_n) as the number of pairs of two adjacent elements in it whose absolute differences are d. For example, when d=1, the beauty of the sequence (3, 2, 3, 10, 9) is 3. There are a total of n^m sequences of length m where each element is an integer between 1 and n (inclusive). Find the beauty of each of these n^m sequences, and print the average of those values.
n, m, d = list(map(int, input().split())) if d == 0: C = float(1/n) else: C = float((2*(n-d))/n) r = C * (m-1) print("{0:.9f}".format(r))
s565930414
Accepted
17
2,940
153
n, m, d = list(map(int, input().split())) if d == 0: C = float(1/n) else: C = float((2*(n-d))/(n*n)) r = C * (m-1) print("{0:.10f}".format(r))
s582108079
p02401
u747594996
1,000
131,072
Wrong Answer
30
6,744
411
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.
def main(): flag = True while flag: s1, tr, s2 = input().split() s1, s2 = int(s1), int(s2) if tr == "+": print(s1 + s2) elif tr == "-": print(s1 - s2) elif tr == "*": print(s1 * s2) elif tr == "/": print(s1 / s2) else: flag = False break if __name__=="__main__": main()
s753525908
Accepted
30
6,724
412
def main(): flag = True while flag: s1, tr, s2 = input().split() s1, s2 = int(s1), int(s2) if tr == "+": print(s1 + s2) elif tr == "-": print(s1 - s2) elif tr == "*": print(s1 * s2) elif tr == "/": print(s1 // s2) else: flag = False break if __name__=="__main__": main()
s414307813
p02646
u204616996
2,000
1,048,576
Wrong Answer
21
9,180
135
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) X=abs(A-B) Y=V-W if X>=Y*T: print('YES') else: print('NO')
s873662535
Accepted
23
9,180
135
A,V=map(int,input().split()) B,W=map(int,input().split()) T=int(input()) X=abs(A-B) Y=V-W if X<=Y*T: print('YES') else: print('NO')
s114447528
p03150
u168416324
2,000
1,048,576
Wrong Answer
28
8,932
179
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
s=input() key="keyence" li=[] for i in range(len(key)): li.append([key[:i],key[i:]]) for i in li: if i[0] in s and i[1] in s: print("Yes") break else: print("No")
s970298539
Accepted
30
9,092
256
s=input() key="keyence" li=[] for i in range(len(key)): li.append([key[:i],key[i:]]) for i in li: #print("{} {}".format(s[:len(i[0])],s[-len(i[1]):])) if s[:len(i[0])]==i[0] and s[-len(i[1]):]==i[1]: print("YES") break else: print("NO")
s274858893
p02308
u629780968
1,000
131,072
Wrong Answer
20
5,696
620
For given a circle $c$ and a line $l$, print the coordinates of the cross points of them.
import math def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(p0,p1,p2): a=p1-p0 b=p2-p0 pro = a * dot(a, b) / (abs(a) ** 2) t=p0+pro return t def get_cross_point(p0,p1,p2): pro=projection(p0,p1,p2) e =(p1-p0)/abs(p1-p0) base = math.sqrt(r*r-(abs(pro-p2)**2)) ans_small=pro-e*base ans_big=pro+e*base return ans_small.real,ans_small.imag,ans_big.real,ans_big.imag cx, cy, r = map(int, input().split()) p2=complex(cx,cy) q = int(input()) for _ in range(q): x0,y0,x1,y1=map(int,input().split()) p0=complex(x0,y0) p1=complex(x1,y1) print(*get_cross_point(p0,p1,p2))
s736563046
Accepted
20
5,740
921
import math def dot(a, b): return a.real * b.real + a.imag * b.imag def projection(p0,p1,p2): a=p1-p0 b=p2-p0 pro = a * dot(a, b) / (abs(a) ** 2) t=p0+pro return t def get_cross_point(p0,p1,p2): pro=projection(p0,p1,p2) e =(p1-p0)/abs(p1-p0) base = (r**2 - abs(pro-p2)**2)**0.5 if (pro-e*base).real == (pro+e*base).real: if (pro-e*base).imag < (pro+e*base).imag: ans1=pro-e*base ans2=pro+e*base else: ans1=pro+e*base ans2=pro-e*base elif (pro-e*base).real < (pro+e*base).real: ans1=pro-e*base ans2=pro+e*base else: ans1=pro+e*base ans2=pro-e*base return ans1.real, ans1.imag,ans2.real,ans2.imag cx, cy, r = map(int, input().split()) p2=complex(cx,cy) q = int(input()) for _ in range(q): x0,y0,x1,y1=map(int,input().split()) p0=complex(x0,y0) p1=complex(x1,y1) print("{:.8f} {:.8f} {:.8f} {:.8f}".format(*get_cross_point(p0,p1,p2)))
s679758351
p03407
u449555432
2,000
262,144
Wrong Answer
17
2,940
65
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());print('Yes' if a+b<=c/2 else 'No')
s148824913
Accepted
19
3,060
63
a,b,c=map(int,input().split());print('Yes' if a+b>=c else 'No')
s660607848
p03471
u841348630
2,000
262,144
Wrong Answer
696
3,060
251
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
N, Y = list(map(int, input().split())) flg = False for i in range(N+1): for j in range(N+1-i): if 1000*i + 5000*j + 10000*(N-i-j) == Y: ans = i,j,N-i-j flg = True if flg: print(*ans) else: print(-1,-1,-1)
s672710356
Accepted
704
3,064
251
N, Y = list(map(int, input().split())) flg = False for i in range(N+1): for j in range(N+1-i): if 10000*i + 5000*j + 1000*(N-i-j) == Y: ans = i,j,N-i-j flg = True if flg: print(*ans) else: print(-1,-1,-1)
s490285172
p03433
u782654209
2,000
262,144
Wrong Answer
17
2,940
79
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()) print('Yes') if N%500==A%500 else print('No')
s725549300
Accepted
17
2,940
75
N = int(input()) A = int(input()) print('Yes') if A>=N%500 else print('No')
s173923328
p02865
u617659131
2,000
1,048,576
Wrong Answer
17
2,940
68
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n % 2 == 0: print((n/2)-1) else: print(n//2)
s356888452
Accepted
17
2,940
69
n = int(input()) if n % 2 == 0: print((n//2)-1) else: print(n//2)
s477074578
p02414
u024715419
1,000
131,072
Wrong Answer
30
7,744
576
Write a program which reads a $n \times m$ matrix $A$ and a $m \times l$ matrix $B$, and prints their product, a $n \times l$ matrix $C$. An element of matrix $C$ is obtained by the following formula: \\[ c_{ij} = \sum_{k=1}^m a_{ik}b_{kj} \\] where $a_{ij}$, $b_{ij}$ and $c_{ij}$ are elements of $A$, $B$ and $C$ respectively.
n,m,l = map(int,input().split()) a = [[0 for i in range(m)] for j in range(n)] b = [[0 for i in range(l)] for j in range(m)] c = [[0 for i in range(l)] for j in range(n)] for i in range(n): mat_tmp = list(map(int,input().split())) for j in range(m): a[i][j] = mat_tmp[j] for i in range(m): mat_tmp = list(map(int,input().split())) for j in range(l): b[i][j] = mat_tmp[j] for i in range(n): for j in range(l): for k in range(m): c[i][j] += a[i][k]*b[k][i] for i in range(n): print(' '.join(str(x) for x in c[i]))
s810363420
Accepted
500
8,940
576
n,m,l = map(int,input().split()) a = [[0 for i in range(m)] for j in range(n)] b = [[0 for i in range(l)] for j in range(m)] c = [[0 for i in range(l)] for j in range(n)] for i in range(n): mat_tmp = list(map(int,input().split())) for j in range(m): a[i][j] = mat_tmp[j] for i in range(m): mat_tmp = list(map(int,input().split())) for j in range(l): b[i][j] = mat_tmp[j] for i in range(n): for j in range(l): for k in range(m): c[i][j] += a[i][k]*b[k][j] for i in range(n): print(' '.join(str(x) for x in c[i]))
s844871555
p02409
u548252256
1,000
131,072
Wrong Answer
20
5,616
317
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.
num = int(input()) list2 = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)] for i in range(num): b,f,r,v = map(int,input().split(" ")) list2[b-1][f-1][r-1] = v for i in range(4): for j in range(3): print(" ",end="") print(*list2[i][j]) print("####################")
s557125937
Accepted
20
5,624
332
num = int(input()) list2 = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)] for i in range(num): b,f,r,v = map(int,input().split(" ")) list2[b-1][f-1][r-1] += v for i in range(4): for j in range(3): print(" ",end="") print(*list2[i][j]) if i != 3: print("####################")
s282053690
p03457
u179987763
2,000
262,144
Wrong Answer
502
22,932
519
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
def check_rote(a, b, t, x, y): cost_min = abs(a - x) + abs(b - y) if cost_min <= t and (t - cost_min) % 2 == 0: return True else: return False n = int(input()) rotes = [] for i in range(n): rotes.append(tuple((int(x) for x in input().split()))) print(rotes) copy_t = 0 copy_a = 0 copy_b = 0 for i in rotes: t, a, b = i if not check_rote(a, b, t - copy_t, copy_a, copy_b): print("No") break copy_t = t copy_a = a copy_b = b else: print("Yes")
s526709889
Accepted
474
17,292
505
def check_rote(a, b, t, x, y): cost_min = abs(a - x) + abs(b - y) if cost_min <= t and (t - cost_min) % 2 == 0: return True else: return False n = int(input()) rotes = [] for i in range(n): rotes.append(tuple((int(x) for x in input().split()))) copy_t = 0 copy_a = 0 copy_b = 0 for i in rotes: t, a, b = i if not check_rote(a, b, t - copy_t, copy_a, copy_b): print("No") break copy_t = t copy_a = a copy_b = b else: print("Yes")
s762266199
p02619
u000513658
2,000
1,048,576
Wrong Answer
38
9,396
499
Let's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.
#B D = int(input()) c = [0] + list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(D)] t = list(map(int, input().split())) last = [0] * 27 manzoku = [0] * 27 for i in range(1, D+1): for j in range(1, 27): if last[j] != 0: manzoku[j] -= c[j] * (i - last[j]) manzoku[s[i-1].index(max(s[i-1]))] += max(s[i-1]) last[s[i-1].index(max(s[i-1]))] = i result = 0 for k in range(27): result += manzoku[k] print(result)
s616469889
Accepted
38
9,292
414
#B D = int(input()) c = [0] + list(map(int, input().split())) s = [list(map(int, input().split())) for _ in range(D)] last = [0] * 27 manzoku = [0] * 27 for i in range(1, D+1): t = int(input()) manzoku[t] += s[i-1][t-1] last[t] = i for j in range(1, 27): manzoku[j] -= c[j] * (i - last[j]) result = 0 for k in range(27): result += manzoku[k] print(result)
s965450032
p03339
u693953100
2,000
1,048,576
Wrong Answer
20
3,676
57
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.
input() s = input() print(min(s.count('E'),s.count('W')))
s825095010
Accepted
297
17,880
356
n = int(input()) s = input() imosw = [] imose = [] imosw.append(0); imose.append(0); for i in range(n): if s[i]=='W': imosw.append(imosw[i]+1) imose.append(imose[i]) else: imosw.append(imosw[i]) imose.append(imose[i]+1) res = 100000000000 for i in range(n): res = min(imosw[i]+imose[n]-imose[i+1],res) print(res)
s532843377
p02744
u220114950
2,000
1,048,576
Wrong Answer
17
2,940
191
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
str = 'abcdefghijklmnop' def bt(n,m,s): if n == 0: print(s) return for c in range(m): bt(n-1,m,s+str[c]) #introduce another character bt(n-1,m+1,s+str[m]) n = int(input())
s840409297
Accepted
117
4,412
202
str = 'abcdefghijklmnop' def bt(n,m,s): if n == 0: print(s) return for c in range(m): bt(n-1,m,s+str[c]) #introduce another character bt(n-1,m+1,s+str[m]) n = int(input()) bt(n,0,'')
s261686961
p03370
u633000076
2,000
262,144
Wrong Answer
359
3,064
267
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
shurui,total=map(int,input().split(" ")) s=[int(input())for i in range(shurui)] remain=total-sum(s) print(remain) flag=True count=len(s) while flag==True: if remain-min(s)>=0: remain=remain-min(s) count+=1 else: flag=False print(count)
s984058084
Accepted
359
3,064
268
shurui,total=map(int,input().split(" ")) s=[int(input())for i in range(shurui)] remain=total-sum(s) #print(remain) flag=True count=len(s) while flag==True: if remain-min(s)>=0: remain=remain-min(s) count+=1 else: flag=False print(count)
s573031879
p03474
u551437236
2,000
262,144
Wrong Answer
17
3,064
377
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() num = ["0","1","2","3","4","5","6","7","8","9"] check = True for i in range(a): if not s[i] in num: check = False break if s[a+1] != "-": check = False for j in range(b): if not s[j+a+1] in num: check = False break if check == True: print("Yes") if check == False: print("No")
s448786466
Accepted
17
3,060
315
a, b = map(int, input().split()) s = input() def is_int(s): try: int(s) return True except ValueError: return False ans = 0 if is_int(s[0:a]) == True: if s[a] == "-": if is_int(s[a+1:]) == True: print("Yes") ans = 1 if ans == 0: print("No")
s451347073
p03214
u590211278
2,525
1,048,576
Wrong Answer
202
6,044
250
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
from statistics import mean N = int(input()) a=list(map(int,input().split(' '))) avg=mean(a) b=[] for i in range(N): b.append(abs(a[i]-avg) ) #print(min(b)) c=sorted(b) for i in range(N): if c[i]==min(b): print(i) exit(0)
s510564126
Accepted
145
5,660
251
from statistics import mean N = int(input()) a=list(map(int,input().split(' '))) avg=mean(a) b=[] for i in range(N): b.append(abs(a[i]-avg) ) #print(min(b)) for i in range(N): if b[i]==min(b): print(i) exit(0)
s319624377
p03024
u027557357
2,000
1,048,576
Wrong Answer
17
2,940
72
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
a=input().count("x") if a >= 8 : print("No") else : print("Yes")
s338037760
Accepted
17
2,940
72
a=input().count("x") if a >= 8 : print("NO") else : print("YES")
s708093632
p03371
u115682115
2,000
262,144
Wrong Answer
48
3,064
437
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
A,B,AB,AX,BY = map(int,input().split()) sum = 0 if A >= AB*2 and B >= AB*2: while AX >0 and BY >0: AX -=1 BY -=1 sum += AB*2 if AX>=1: sum += AB*2*AX elif BY>=1: sum += AB*2*BY elif (A+B) >= AB*2: while AX >0 and BY >0: AX -=1 BY -=1 sum += AB*2 print(sum) if AX>=1 or BY>=1: sum += A*AX+B*BY else: sum += A*AX+B*BY print(sum)
s718979968
Accepted
17
3,060
177
A,B,AB,AX,BY = map(int,input().split()) a = min(A+B, 2*AB) if AX <= BY: ans = a * AX + (BY - AX) * min(B, 2*AB) else: ans = a * BY + (AX - BY) * min(A, 2*AB) print(ans)
s524589686
p03131
u140251125
2,000
1,048,576
Wrong Answer
17
2,940
165
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
# input k, a, b = map(int, input().split()) ans = 1 + k if b <= a + 2: print(ans) else: i = a - 1 ans = 1 + i + ((b - a) * (k - i) // 2) print(ans)
s419337983
Accepted
17
3,060
221
# input k, a, b = map(int, input().split()) ans = 1 + k if b <= a + 2: print(ans) else: if (k - a + 1) % 2 == 0: i = a - 1 else: i = a ans = 1 + i + ((b - a) * (k - i) // 2) print(ans)
s097943020
p03433
u916098128
2,000
262,144
Wrong Answer
17
2,940
87
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()) n = n % 500 if a <= n : print('Yes') else : print('No')
s973368118
Accepted
17
2,940
87
n=int(input()) a=int(input()) n = n % 500 if a >= n : print('Yes') else : print('No')
s273860178
p03477
u165538494
2,000
262,144
Wrong Answer
17
2,940
146
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d=map(int,input().split()) suma=a+b sumb=c+d if suma<sumb: print('Left') elif suma==sumb: print('Balance') else: print('Right')
s731394983
Accepted
19
2,940
147
a,b,c,d=map(int,input().split()) suma=a+b sumb=c+d if suma>sumb: print('Left') elif suma==sumb: print('Balanced') else: print('Right')
s231631490
p03607
u231552419
2,000
262,144
Wrong Answer
2,104
3,700
192
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
N = int(input()) ans = 0 nums = [] for _ in range(N): A = int(input()) if A in nums: ans -= 1 nums.remove(A) else: ans += 1 nums.append(A) print(A)
s203999969
Accepted
223
11,884
194
N = int(input()) ans = 0 nums = set() for _ in range(N): A = int(input()) if A in nums: ans -= 1 nums.remove(A) else: ans += 1 nums.add(A) print(ans)
s490309416
p03845
u371132735
2,000
262,144
Wrong Answer
19
3,064
270
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 = list(map(int,input().split())) M = int(input()) print("N : {}, T : {}, M : {}".format(N,T,M)) for i in range(M): ans = 0 p,x = map(int,input().split()) for j in range(N): if j+1 == p: ans += x else: ans += T[j] print(ans)
s904609944
Accepted
19
3,060
224
N = int(input()) T = list(map(int,input().split())) M = int(input()) for i in range(M): ans = 0 p,x = map(int,input().split()) for j in range(N): if j+1 == p: ans += x else: ans += T[j] print(ans)
s871231160
p03251
u726439578
2,000
1,048,576
Wrong Answer
18
3,064
257
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.
n,m,x,y=map(int,input().split()) xl=list(map(int,input().split())) yl=list(map(int,input().split())) zl=[i for i in range(x+1,y)] flag=False for i in zl: if i>sum(xl) and sum(yl)>=i: flag=True if flag: print("War") else: print("No war")
s762456503
Accepted
19
3,060
262
n,m,x,y=map(int,input().split()) xl=list(map(int,input().split())) yl=list(map(int,input().split())) zl=[i for i in range(x+1,y)] flag=False for i in zl: if i>max(xl) and min(yl)>=i: flag=True if flag: print("No War") else: print("War")
s005561501
p02392
u628732336
1,000
131,072
Wrong Answer
20
7,396
97
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
a, b, c = [int(1) for i in input().split()] if a < b < c: print("Yes") else: print("No")
s649739760
Accepted
30
7,668
98
a, b, c = [int(i) for i in input().split()] if a < b < c: print("Yes") else: print("No")
s666884871
p00008
u646461156
1,000
131,072
Wrong Answer
30
5,588
150
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
n=int(input()) ans=0 for i in range(10): for j in range(10): for k in range(10): for l in range(10): if i+j+k+l==n: ans+=1 print(ans)
s382635990
Accepted
60
5,632
185
import itertools while True: try: n=int(input()) except EOFError: break ans=0 for (i,j,k) in itertools.product(range(10),range(10),range(10)): ans+=(0<=n-(i+j+k)<=9) print(ans)
s794529911
p03477
u039623862
2,000
262,144
Wrong Answer
17
2,940
128
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d = map(int, input().split()) a += b c += d if a<c: print('Left') if a==c: print('Balanced') if a>c: print('Right')
s044240359
Accepted
17
2,940
127
a,b,c,d = map(int, input().split()) a += b c += d if a>c: print('Left') if a==c: print('Balanced') if a<c: print('Right')
s786209142
p03479
u845333844
2,000
262,144
Wrong Answer
18
2,940
82
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
x,y=map(int,input().split()) z=y//x ans=0 while(z>=2): z//=2 ans+=1 print(ans)
s223135061
Accepted
31
2,940
74
x,y=map(int,input().split()) ans=0 while(x<=y): x*=2 ans+=1 print(ans)
s101524332
p02244
u022407960
1,000
131,072
Wrong Answer
50
8,664
1,586
The goal of 8 Queens Problem is to put eight queens on a chess-board such that none of them threatens any of others. A queen threatens the squares in the same row, in the same column, or on the same diagonals as shown in the following figure. For a given chess board where $k$ queens are already placed, find the solution of the 8 queens problem.
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 2 2 5 3 output: ......Q. Q....... ..Q..... .......Q .....Q.. ...Q.... .Q...... ....Q... """ import sys N = 8 FREE, NOT_FREE = -1, 1 def generate_board(_q_list): for queen in _q_list: x, y = map(int, queen) init_q_check[x][y] = True return init_q_check def print_board(): # for j in range(N): # return None for i in range(N): line = [] for j in range(N): if row[i] == j: line.append('Q') else: line.append('.') print(*line, sep='') return None def recursive(i): if i == N: print_board() return None for j in range(N): if ((col[j] is NOT_FREE) or (dpos[i + j] is NOT_FREE) or (dneg[i - j + N - 1] is NOT_FREE)): continue row[i] = j col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE recursive(i + 1) row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE return q_check if __name__ == '__main__': _input = sys.stdin.readlines() q_num = int(_input[0]) q_list = map(lambda x: x.split(), _input[1:]) # initialize row, col = ([FREE] * N for _ in range(2)) dpos, dneg = ([FREE] * (2 * N - 1) for _ in range(2)) init_q_check = [[False] * N for _ in range(N)] q_check = generate_board(q_list) ans = recursive(0)
s586271072
Accepted
40
7,816
1,446
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 2 2 2 5 3 output: ......Q. Q....... ..Q..... .......Q .....Q.. ...Q.... .Q...... ....Q... """ import sys N = 8 FREE, NOT_FREE = -1, 1 def generate_board(_q_list): for queen in _q_list: x, y = map(int, queen) init_q_check[x][y] = True return init_q_check def print_board(): for i in range(N): for j in range(N): if q_check[i][j]: if row[i] != j: return None for i in range(N): print(''.join(('Q' if row[i] == j else '.' for j in range(N)))) return None def recursive(i): if i == N: print_board() return None for j in range(N): if ((col[j] is NOT_FREE) or (dpos[i + j] is NOT_FREE) or (dneg[i - j + N - 1] is NOT_FREE)): continue row[i] = j col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE recursive(i + 1) row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE return q_check if __name__ == '__main__': _input = sys.stdin.readlines() q_num = int(_input[0]) q_list = map(lambda x: x.split(), _input[1:]) # initialize row, col = ([FREE] * N for _ in range(2)) dpos, dneg = ([FREE] * (2 * N - 1) for _ in range(2)) init_q_check = [[False] * N for _ in range(N)] q_check = generate_board(q_list) ans = recursive(0)
s463623610
p03377
u267325300
2,000
262,144
Wrong Answer
17
2,940
101
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 and A <= X: print("Yes") else: print("No")
s882415163
Accepted
17
2,940
101
A, B, X = map(int, input().split()) if A + B >= X and A <= X: print("YES") else: print("NO")
s273546344
p02615
u292746386
2,000
1,048,576
Wrong Answer
228
49,900
277
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?
import numpy as np N = int(input()) A = np.array([int(i) for i in input().split()]) A_sort = np.sort(A) print(A_sort) score = 0 score += A_sort[-1] for i in range(0, (N-2)//2): score += A_sort[-2-i] * 2 if (N-2) % 2 == 1: score += A_sort[-3-i] print(score)
s361663807
Accepted
227
50,076
278
import numpy as np N = int(input()) A = np.array([int(i) for i in input().split()]) A_sort = np.sort(A) #print(A_sort) score = 0 score += A_sort[-1] for i in range(0, (N-2)//2): score += A_sort[-2-i] * 2 if (N-2) % 2 == 1: score += A_sort[-3-i] print(score)
s666662462
p02412
u888737393
1,000
131,072
Wrong Answer
20
7,532
439
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: n,x = list(map(int, input().split())) if n == x == 0: break num_set = [] for i in range(1,n+1): for j in range(1,n+1): for k in range(1,n+1): if i + j + k == x: li = [i,j,k] sorted_list = sorted(li) if not sorted_list in num_set: num_set.append(sorted_list) print(len(num_set))
s312382476
Accepted
3,350
7,684
384
while True: n,x = list(map(int, input().split())) if n == x == 0: break num_set = [] for i in range(1,n+1): for j in range(1,n+1): for k in range(1,n+1): if i < j < k and i+j+k ==x: li = [i,j,k] if not li in num_set: num_set.append(li) print(len(num_set))
s927981623
p03998
u525423408
2,000
262,144
Wrong Answer
17
3,064
387
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.
a=input() b=input() c=input() flag = "a" while 1: if flag=="a": if a=="": print("a") break flag=a[0] a=a[1:] elif flag=="b": if b=="": print("b") break flag=b[0] b=b[1:] elif flag=="c": if c=="": print("c") break flag=c[0] c=c[1:]
s072725361
Accepted
17
3,064
387
a=input() b=input() c=input() flag = "a" while 1: if flag=="a": if a=="": print("A") break flag=a[0] a=a[1:] elif flag=="b": if b=="": print("B") break flag=b[0] b=b[1:] elif flag=="c": if c=="": print("C") break flag=c[0] c=c[1:]
s730380148
p03719
u561422857
2,000
262,144
Wrong Answer
17
2,940
87
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
ls = list(map(int, input().split())) print("YES" if ls[0] <= ls[2] <= ls[1] else "NO")
s292042107
Accepted
17
2,940
87
ls = list(map(int, input().split())) print("Yes" if ls[0] <= ls[2] <= ls[1] else "No")
s600981644
p03493
u884959062
2,000
262,144
Time Limit Exceeded
2,104
28,276
94
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.
e = input().split() while True: print('take') tmp = e[0].replace('0', '') print(len(tmp))
s276457547
Accepted
19
3,064
65
e = input().split() tmp = e[0].replace('0', '') print(len(tmp))
s729347777
p03139
u543954314
2,000
1,048,576
Wrong Answer
18
2,940
66
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
n, a, b = map(int, input().split()) print(max(a,b), max(a+b-n, 0))
s816086172
Accepted
17
2,940
67
n, a, b = map(int, input().split()) print(min(a,b), max(a+b-n, 0))
s348287387
p03971
u846226907
2,000
262,144
Wrong Answer
265
13,352
535
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
import numpy as np import sys input = sys.stdin.readline N,A,B = map(int,input().split()) S = input() nai = 0 gai = 0 goukaku = 0 for i in range(len(S)): if S[i] != 'c': goukaku+=1 for i in range(len(S)): if S[i] == 'a': nai+=1 if (i+1) < goukaku: print("Yes") else: print("No") elif S[i] == 'b': gai+=1 if (i+1) < goukaku and gai <= B: print("Yes") else: print("No") elif S[i] == 'c': print("No")
s841629761
Accepted
251
13,336
512
import numpy as np import sys input = sys.stdin.readline N,A,B = map(int,input().split()) S = input() nai = 0 gai = 0 goukaku = 0 for i in range(len(S)): if S[i] == 'a': nai+=1 if goukaku < A+B: goukaku+=1 print("Yes") else: print("No") elif S[i] == 'b': gai+=1 if goukaku < A+B and gai <= B: goukaku+=1 print("Yes") else: print("No") elif S[i] == 'c': print("No")
s620452100
p02742
u461592867
2,000
1,048,576
Wrong Answer
17
3,064
269
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
# -*- coding: utf-8 -*- h, w = map(int, input().split()) w1 = w2 = 0 if w % 2 == 0: w1 = w / 2 w2 = w / 2 else: w1 = (w + 1) / 2 w2 = w / 2 if h % 2 == 0: print((h / 2 * w1) + (h / 2 * w2)) else: print(((h + 1) / 2 * w1) + ((h - 1) / 2 * w2))
s813101550
Accepted
17
3,060
286
# -*- coding: utf-8 -*- h, w = map(int, input().split()) if h == 1 or w == 1: print(1) elif h % 2 == 0 and w % 2 == 0: print(int(h/2*w)) elif h % 2 == 0 and w % 2 != 0: print(int(h/2*w)) elif h % 2 != 0 and w % 2 == 0: print(int(h*w/2)) else: print(int((h*w+1)/2))
s705944033
p03795
u729707098
2,000
262,144
Wrong Answer
17
2,940
95
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
n = int(input()) answer = 1 for i in range(1,n+1): answer = (answer*i)%(10**9+7) print(answer)
s366658482
Accepted
17
2,940
52
n = int(input()) a = (n-n%15)//15 print(800*n-200*a)
s237967279
p02612
u749359783
2,000
1,048,576
Wrong Answer
31
9,144
30
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()) print(N%1000)
s561548173
Accepted
31
9,140
38
N = int(input()) print((10000-N)%1000)
s044665987
p03068
u194440952
2,000
1,048,576
Wrong Answer
19
3,316
320
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
# -*- coding: utf-8 -*- n = int(input()) s = str(input()) k = int(input()) index_num = [n for n, v in enumerate(s) if v == s[k-1]] ans = list("*"*n) index_num = list(index_num) for i in range(0, len(index_num)): print(index_num[i]) ans[index_num[i]] = s[k-1] print("".join(ans))
s023628260
Accepted
17
3,064
296
# -*- coding: utf-8 -*- n = int(input()) s = str(input()) k = int(input()) index_num = [n for n, v in enumerate(s) if v == s[k-1]] ans = list("*"*n) index_num = list(index_num) for i in range(0, len(index_num)): ans[index_num[i]] = s[k-1] print("".join(ans))
s182769017
p03139
u960513073
2,000
1,048,576
Wrong Answer
17
2,940
106
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
n,a,b = list(map(int, input().split())) if n > a+b: ans = 0 else: ans = a+b-n print(max(a,b), ans)
s961010724
Accepted
17
2,940
106
n,a,b = list(map(int, input().split())) if n > a+b: ans = 0 else: ans = a+b-n print(min(a,b), ans)
s089488705
p03623
u804339040
2,000
262,144
Wrong Answer
17
3,060
381
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 = input().split() x = int(x) a = int(a) b = int(b) print("x = ", x) print("a = ", a) print("b = ", b) if x < a: distance_xa = a - x else: distance_xa = x - a print("distance_xa = ", distance_xa) if x < b: distance_xb = b - x else: distance_xb = x - b print("distance_xb = ", distance_xb) if distance_xa < distance_xb: print("A") else: print("B")
s095841880
Accepted
18
3,060
390
x, a, b = input().split() x = int(x) a = int(a) b = int(b) #print("x = ", x) #print("a = ", a) #print("b = ", b) if x < a: distance_xa = a - x else: distance_xa = x - a if x < b: distance_xb = b - x else: distance_xb = x - b #print("distance_xb = ", distance_xb) if distance_xa < distance_xb: print("A") else: print("B")
s220010445
p03574
u591779169
2,000
262,144
Wrong Answer
27
3,316
452
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.
h, w = map(int, input().split()) s = [list(input()) for i in range(h)] for i in range(h): for j in range(w): if s[i][j] == ".": cnt = 0 for dx in [-1, 0, 1]: for dy in [-1, 0, 1]: if 0 <= dx + j <= (w-1) and 0 <= dy + h <= (h-1): if s[i+dy][j+dx] == "#": cnt += 1 s[i][j] = str(cnt) for k in s: print("".join(k))
s015105135
Accepted
29
3,188
487
h, w = map(int, input().split()) s = [list(input()) for i in range(h)] for i in range(h): for j in range(w): if s[i][j] == '#': continue cnt = 0 for dx in [-1, 0, 1]: for dy in [-1, 0, 1]: if 0 <= dy + i < h and 0 <= dx + j < w: if s[i+dy][j+dx] == '#': cnt += 1 else: continue s[i][j] = str(cnt) for k in s: print("".join(k))
s545703402
p02401
u476441153
1,000
131,072
Wrong Answer
20
7,576
292
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.
while True : a,b,c = list(input().split()) x = int(a) y = int(c) if (b == "?"): break elif (b == "+"): print (x+y) elif (b == "-"): print (x-y) elif (b == "*"): print (x*y) elif (b == "/"): print (x/y) break
s082534354
Accepted
60
7,700
273
while True : a,b,c = input().split() a = int(a) c = int(c) if (b == "+"): print (a+c) elif (b == "-"): print (a-c) elif (b == "*"): print (a*c) elif (b == "/"): print (a//c) elif (b == "?"): break
s784720039
p03068
u066455063
2,000
1,048,576
Wrong Answer
17
2,940
141
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
N = int(input()) S = list(input()) K = int(input()) K = S[K-1] for i in range(N): if S[i] != K: S[i] = "*" print(S)
s557158642
Accepted
17
3,060
150
N = int(input()) S = input() K = int(input()) K = S[K-1] S = list(S) for i in range(N): if S[i] != K: S[i] = "*" S = "".join(S) print(S)
s669591593
p03563
u869728296
2,000
262,144
Wrong Answer
18
2,940
45
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
R=int(input()) G=int(input()) print(G/2-R)
s258946291
Accepted
18
2,940
45
R=int(input()) G=int(input()) print(G*2-R)
s142803374
p03351
u982591663
2,000
1,048,576
Wrong Answer
17
2,940
150
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a, b, c, d = map(int, input().split()) c2a = abs(c-a) c2b2a = abs(c-b) + abs(b-a) if c2a <= d or c2b2a <= d: print("Yes") else: print("No")
s380922504
Accepted
18
2,940
163
a, b, c, d = map(int, input().split()) c2a = abs(c-a) c2b = abs(c-b) b2a = abs(b-a) if c2a <= d or c2b <= d and b2a <= d: print("Yes") else: print("No")
s301603424
p03854
u398846051
2,000
262,144
Wrong Answer
18
3,188
140
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s=input() s.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","") if s: print("NO") else: print("YES")
s403312734
Accepted
19
3,188
146
if input().replace("eraser"," ").replace("erase"," ").replace("dreamer"," ").replace("dream"," ").strip(): print("NO") else: print("YES")
s754416357
p03761
u957872856
2,000
262,144
Wrong Answer
22
3,064
347
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
n = int(input()) S = [list(input()) for i in range(n)] A = set(S[0]) L = [] for a in A: b = True for i in range(1, n): if a not in S[i]: b = False if b: L.append(a) ans = 100 w = "" for l in L: for i in range(n): cnt = 0 for s in S[i]: if l == s: cnt += 1 ans = min(ans, cnt) w += l*ans print(w)
s209700920
Accepted
21
3,316
334
import collections n = int(input()) s = [input() for i in range(n)] if n == 1: print("".join(sorted(s[0]))) else: c = [] for i in s: c.append(collections.Counter(i)) a = c[0] & c[1] for i in range(2, n): a &= c[i] ans = [] a = a.most_common() for i in a: ans.append(i[0]*i[1]) print("".join(sorted(ans)))
s584049675
p03659
u912115033
2,000
262,144
Wrong Answer
2,104
138,064
160
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())) m = 10**10 for i in range(1,n): print(a[:i], a[i:]) m = min(m, abs(sum(a[:i])-sum(a[i:]))) print(m)
s982485337
Accepted
175
24,832
163
n = int(input()) a = list(map(int,input().split())) sa = sum(a) x = a[0] m = abs(sa-2*x) for i in range(1,n-1): x += a[i] m = min(m, abs(sa-2*x)) print(m)
s456975230
p03844
u856232850
2,000
262,144
Wrong Answer
17
2,940
117
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
a = list(input().split()) b = int(a[0]) c = int(a[2]) print(a[1]) if a[1] == '+': print(b+c) else: print(b-c)
s291602132
Accepted
17
2,940
105
a = list(input().split()) b = int(a[0]) c = int(a[2]) if a[1] == '+': print(b+c) else: print(b-c)
s783100548
p03997
u878138257
2,000
262,144
Wrong Answer
18
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/2)
s859536528
Accepted
17
2,940
73
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s326206310
p03378
u982762220
2,000
262,144
Time Limit Exceeded
2,104
3,060
244
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
N, M, X = map(int, input().split()) A = list(map(int, input().split())) left, right = 0, M while right - left > 1: mid = (left + right) // 2 if A[mid] > X: mid = left if A[mid] < X: mid = right res = max(mid, M - mid) print(res)
s277931377
Accepted
17
2,940
179
N, M, X = map(int, input().split()) A = list(map(int, input().split())) idx = 0 while idx < M: if A[idx] > X: break idx += 1 res = min(idx, M - idx) print(res)
s957803766
p04043
u075595666
2,000
262,144
Wrong Answer
17
2,940
129
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.
a,b,c = map(int,(input().split())) l = [a,b,c] if int(l.count(5)) == 2 and int(l.count(7)) == 1: print(True) else: print(False)
s150686404
Accepted
17
2,940
129
a,b,c = map(int,(input().split())) l = [a,b,c] if int(l.count(5)) == 2 and int(l.count(7)) == 1: print('YES') else: print('NO')
s267827631
p02406
u067975558
1,000
131,072
Wrong Answer
30
6,724
96
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
n = int(input()) a = [] for x in range(3,n + 1): if x % 3 == 0: a = a + [x] print(a)
s697384810
Accepted
50
6,748
109
for i in range(3, int(input()) + 1): if i % 3 == 0 or '3' in str(i): print('', i, end='') print()