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
s038373258
p02842
u945181840
2,000
1,048,576
Wrong Answer
18
3,064
196
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
from math import floor N = int(input()) n = int(N / 1.08) for i in range(-1, 2): answer = floor((n + i) * 1.08) if answer == N: print(answer) exit() else: print(':(')
s396033392
Accepted
17
2,940
175
from math import floor N = int(input()) n = int(N / 1.08) for i in range(-2, 2): if floor((n + i) * 1.08) == N: print(n + i) exit() else: print(':(')
s648209972
p02850
u733377702
2,000
1,048,576
Wrong Answer
708
46,548
1,156
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
N = int(input()) sides = [] side_colors = [0] * (N - 1) に使う色 point_sides = [0] * N point_colors = [set() for i in range(N)] for i in range(N - 1): s, e = map(int, input().split()) sides.append([s - 1, e - 1]) point_sides[s - 1] += 1 point_sides[e - 1] += 1 max_color_num = max(point_sides) point_of_max_side_num = point_sides.index(max_color_num) color_id = 1 for i in range(N - 1): s = sides[i][0] e = sides[i][1] if s == point_of_max_side_num or e == point_of_max_side_num: point_colors[s].add(color_id) point_colors[e].add(color_id) side_colors[i] = color_id color_id += 1 for i in range(N - 1): s = sides[i][0] e = sides[i][1] if s != point_of_max_side_num and e != point_of_max_side_num: for j in range(1, max_color_num + 1): if (j not in point_colors[s]) and (j not in point_colors[e]): point_colors[s].add(j) point_colors[e].add(j) side_colors[i] = j break print(max_color_num) for side_color in side_colors: print(side_color)
s542047606
Accepted
1,401
100,116
2,137
from collections import deque N = int(input()) vertex_neighbor_vertices = {} vertex_colors = {} sides = [] side_color = {} def add_neighbors(start, end): neighbors_of_s = set() if start in vertex_neighbor_vertices: neighbors_of_s = vertex_neighbor_vertices[start] else: vertex_neighbor_vertices[start] = neighbors_of_s neighbors_of_s.add(end) def init_colors(vertex): colors = set() if vertex not in vertex_colors: vertex_colors[vertex] = colors def get_unused_color(colors_of_sv, colors_of_ev, color_start): for i in range(color_start, N + 1): if (i not in colors_of_sv) and (i not in colors_of_ev): return i for i in range(N - 1): s, e = map(int, input().split()) sides.append((s, e)) add_neighbors(s, e) add_neighbors(e, s) init_colors(s) init_colors(e) max_color_num = 0 max_neighbor_vertex = 0 for k, v in vertex_neighbor_vertices.items(): if len(v) > max_color_num: max_color_num = len(v) max_neighbor_vertex = k print(max_color_num) visited = set() q = deque([max_neighbor_vertex]) while q: vertex = q.popleft() visited.add(vertex) color_start = 1 for neighbor in vertex_neighbor_vertices[vertex]: if neighbor in visited: continue q.append(neighbor) color = get_unused_color(vertex_colors[vertex], vertex_colors[neighbor], color_start) color_start = color + 1 vertex_colors[vertex].add(color) vertex_colors[neighbor].add(color) side_color[(vertex, neighbor)] = color for s, e in sides: color = 0 if (s, e) in side_color: color = side_color[(s, e)] else: color = side_color[(e, s)] print(color)
s929277436
p03162
u844005364
2,000
1,048,576
Wrong Answer
242
24,308
351
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.
import sys input = sys.stdin.readline n = int(input()) abc = [[int(i) for i in input().split()] for j in range(n)] def happy(n, abc): da, db, dc = 0, 0, 0 for a, b, c in abc: na = max(db, dc) + a nb = max(dc, da) + b nc = max(da, db) + c da, db, dc = na, nb, nc return max(da, db, dc) print(happy(n, abc))
s127753074
Accepted
252
24,308
355
import sys input = sys.stdin.readline n = int(input()) abc = [[int(i) for i in input().split()] for j in range(n)] def happy(n, abc): da, db, dc = 0, 0, 0 for a, b, c in abc: na = max(db, dc) + a nb = max(dc, da) + b nc = max(da, db) + c da, db, dc = na, nb, nc return max(da, db, dc) print(happy(n, abc))
s164146348
p03068
u742385708
2,000
1,048,576
Wrong Answer
17
3,060
244
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()) word = input() word_list=[] word_num = int(input()) for i in range(len(word)): word_list.append(word[i]) if str(word[i]) == str(word[word_num -1]): word_list[i] = '*' print(" ".join(list(map(str,word_list))))
s151335560
Accepted
17
3,060
243
N = int(input()) word = input() word_list=[] word_num = int(input()) for i in range(len(word)): word_list.append(word[i]) if str(word[i]) != str(word[word_num -1]): word_list[i] = '*' print("".join(list(map(str,word_list))))
s967290629
p02690
u815763296
2,000
1,048,576
Wrong Answer
134
9,196
288
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
import sys X = int(input()) L = [] for i in range(1000): a = int(i**5) L.append(a) for j in range(len(L)): if X == L[j]-a: print(j, i) sys.exit() elif X == L[j]+a: ans = i*-1 print(j, ans) sys.exit()
s532929456
Accepted
26
8,936
288
import sys X = int(input()) L = [] for i in range(1000): a = int(i**5) L.append(a) for j in range(len(L)): if X == a-L[j]: print(i, j) sys.exit() elif X == a+L[j]: ans = j*-1 print(i, ans) sys.exit()
s265799308
p03997
u403986473
2,000
262,144
Wrong Answer
18
3,064
753
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.
sa = input() sb = input() sc = input() def judges(lis): if lis[0] == 'a': judge=1 elif lis[0] == 'b': judge=2 else: judge=3 return judge import sys judge = 1 while(1): if judge == 1: try: judge = judges(sa) sa = sa[1:] # print(sa) except IndexError: print('A') break elif judge == 2: try: judge = judges(sb) sb = sb[1:] # print(sb) except IndexError: print('B') break else: try: judge = judges(sc) sc = sc[1:] # print(sc) except IndexError: print('C') break
s101802663
Accepted
17
2,940
72
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h/2))
s298041267
p03563
u172773620
2,000
262,144
Wrong Answer
2,104
3,060
212
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.
n = int(input()) k = int(input()) num = 1000000000000000000000 for i in range(n): cost = 1 for j in range(i): cost = cost*2 for j in range(n-i): cost = cost + k num = min(cost, num) print(num)
s517744777
Accepted
20
3,316
47
r = int(input()) g = int(input()) print(2*g-r)
s257143962
p03449
u223646582
2,000
262,144
Wrong Answer
18
3,060
177
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()) A1=[int(i) for i in input().split()] A2=[int(i) for i in input().split()] score=[] for i in range(N): sum=A1[:i+1]+A2[i:] score.append(sum) print(max(score))
s644786017
Accepted
18
3,060
183
N=int(input()) A1=[int(i) for i in input().split()] A2=[int(i) for i in input().split()] score=[] for i in range(N): s=sum(A1[:i+1])+sum(A2[i:]) score.append(s) print(max(score))
s250727912
p03448
u617315626
2,000
262,144
Wrong Answer
51
3,064
262
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()) count = 0 for k in range(0,a): for j in range(0,b): for i in range(0,c): total = 500*k + 100*j + 50*i if total == x: count += 1 print(count)
s190987264
Accepted
58
3,060
261
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count = 0 for k in range(a+1): for j in range(b+1): for i in range(c+1): total = 500*k + 100*j + 50*i if total == x: count += 1 print(count)
s438090030
p03861
u438662618
2,000
262,144
Wrong Answer
17
2,940
61
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
a, b, x = map(int, input().split()) print((b - a + 1) // x)
s108282426
Accepted
17
2,940
100
a, b, x = map(int, input().split()) ans = b // x - a // x if a % x == 0 : ans += 1 print(ans)
s853242875
p03408
u571969099
2,000
262,144
Wrong Answer
19
3,188
300
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()) a = {} for _ in range(n): s = input() if s in a: a[s] += 1 else: a[s] = 1 m = int(input()) for _ in range(m): s = input() if s in a: a[s] -= 1 else: a[s] = -1 ans = 0 for i in a: if a[i] > 0: ans += a[i] print(ans)
s911774778
Accepted
19
3,060
287
n = int(input()) a = {} for _ in range(n): s = input() if s in a: a[s] += 1 else: a[s] = 1 m = int(input()) for _ in range(m): s = input() if s in a: a[s] -= 1 else: a[s] = -1 ans = 0 for i in a: ans = max(ans,a[i]) print(ans)
s599207277
p02618
u374802266
2,000
1,048,576
Wrong Answer
35
9,204
138
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows. * The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative. * Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}. * If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)). Please schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.
d=int(input()) c=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(d)] for i in range(365): print(i%26)
s794251544
Accepted
35
9,392
157
d=int(input()) c=list(map(int,input().split())) s=[list(map(int,input().split())) for _ in range(d)] for d in range(365): print(s[d].index(max(s[d]))+1)
s496142962
p03608
u010110540
2,000
262,144
Wrong Answer
2,104
10,244
1,003
There are N towns in the State of Atcoder, connected by M bidirectional roads. The i-th road connects Town A_i and B_i and has a length of C_i. Joisino is visiting R towns in the state, r_1,r_2,..,r_R (not necessarily in this order). She will fly to the first town she visits, and fly back from the last town she visits, but for the rest of the trip she will have to travel by road. If she visits the towns in the order that minimizes the distance traveled by road, what will that distance be?
from collections import defaultdict from itertools import permutations import heapq INF = float('inf') N, M, R = map(int, input().split()) r = list(map(int, input().split())) memo = [[INF for _ in range(N)] for _ in range(N)] Adj_list = defaultdict(set) for i in range(M): a, b, c = map(int, input().split()) if memo[a-1][b-1]: memo[a-1][b-1] = min(memo[a-1][b-1], c) Adj_list[a-1].add((b-1, memo[a-1][b-1])) Adj_list[b-1].add((a-1, c)) print(Adj_list) def dijkstra(x, vertex): d = [INF] * x d[vertex] = 0 hq = [(0, vertex)] while hq: u = heapq.heappop(hq)[1] for (v, c) in Adj_list[u]: if d[v] > d[u] + c: d[v] = d[u] + c heapq.heappush(hq, (d[u]+c, v)) return d t_dis = 0 ans = INF for each in permutations(r): for i in range(R-1): d = dijkstra(N, each[i]-1) t_dis += d[each[i+1]-1] ans = min(ans, t_dis) # print(each, d, t_dis) print(ans)
s952014434
Accepted
1,733
4,656
852
from itertools import permutations import sys def main(): N, M, R = map(int, sys.stdin.readline().split()) r = [i - 1 for i in map(int, sys.stdin.readline().split())] d = [[float('inf')] * N for _ in range(N)] for i in range(N): d[i][i] = 0 for i in range(M): a, b, c = map(int,sys.stdin.readline().split()) d[a-1][b-1] = c d[b-1][a-1] = c for k in range(N): for i in range(N): for j in range(N): if d[i][j] > d[i][k] + d[k][j]: d[i][j] = d[i][k] + d[k][j] ans = 10**12 for each in permutations(r): t_dis = 0 for i in range(R-1): t_dis += d[each[i]][each[i+1]] ans = min(ans, t_dis) print(ans) if __name__ == '__main__': main()
s760180432
p03044
u565149926
2,000
1,048,576
Wrong Answer
2,108
18,924
474
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()) to = [list()] * N cost = [list()] * N for i in range(N-1): a, b, w = map(int, input().split()) to[a-1].append(b-1) to[b-1].append(a-1) cost[a-1].append(w) cost[b-1].append(w) ans = [-1] * N q = [0] while len(q): v = q.pop(0) for i in range(len(to[v])): u = to[v][i] w = cost[v][i] if ans[u] != -1: continue ans[u] = (ans[v] + w) % 2 q.append(u) print("\n".join(map(str, ans)))
s378525864
Accepted
634
44,952
394
from collections import deque N = int(input()) vw = [[] for _ in range(N)] for i in range(N-1): a, b, w = map(int, input().split()) vw[a-1].append((b-1, w)) vw[b-1].append((a-1, w)) ans = [-1] * N q = deque([(0, 0)]) while q: a, w = q.popleft() ans[a] = w % 2 for b, c in vw[a]: if ans[b] == -1: q.append((b, w + c)) print("\n".join(map(str, ans)))
s349063616
p03795
u186838327
2,000
262,144
Wrong Answer
17
2,940
42
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()) print(800*n - 200*(n%15))
s694467312
Accepted
18
2,940
43
n = int(input()) print(800*n - 200*(n//15))
s382138207
p03456
u757274384
2,000
262,144
Wrong Answer
17
2,940
132
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a,b = input().split() n = int("".join(list(a) + list(b))) m = math.sqrt(n) if n == m: print("Yes") else: print("No")
s068494545
Accepted
17
3,060
153
import math a,b = input().split() n = int("".join(list(a) + list(b))) m = int(math.floor(math.sqrt(n))) if n == m**2: print("Yes") else: print("No")
s221028042
p03495
u046187684
2,000
262,144
Wrong Answer
22
3,316
233
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
from collections import Counter def solve(string): n, k, *a = map(int, string.split()) count = Counter(a) return str(sum(sorted(count.values(), reverse=True)[k:])) if __name__ == '__main__': print(solve(input()))
s570667844
Accepted
94
33,848
255
from collections import Counter def solve(string): n, k, *a = map(int, string.split()) count = Counter(a) return str(sum(sorted(count.values(), reverse=True)[k:])) if __name__ == '__main__': print(solve('\n'.join([input(), input()])))
s923103943
p03645
u492447501
2,000
262,144
Wrong Answer
2,107
53,788
320
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
N, M = map(int, input().split()) atb = [list(map(int, input().split())) for _ in range(M)] flg = 0 for i in range(2, N, 1): if [1, i] in atb: print(1, i) if [i, N] in atb: print("POSSIBLE") flg = 1 if flg==0: print("IMPOSSIBLE")
s565255117
Accepted
1,060
69,828
573
import sys import copy N,M = map(int, input().split()) def dfs(node, count): if seen[node]==True: return seen[node]=True if node==(N-1) and count==2: print("POSSIBLE") sys.exit() elif count==2: return count = count + 1 seen[node]=True for next_node in V[node]: dfs(next_node, count) return V = [] seen = [False]*N for i in range(N): V.append(set()) for i in range(M): *l, = map(int, input().split()) V[l[0]-1].add(l[1]-1) V[l[1]-1].add(l[0]-1) dfs(0, 0) print("IMPOSSIBLE")
s874884935
p03387
u836157755
2,000
262,144
Wrong Answer
17
3,064
227
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
from math import ceil a, b, c = map(int, input().split()) MAX = max(max(a,b),c) distance = (MAX-a) + (MAX-b) + (MAX-c) if distance % 2 == 0: print(distance/2) elif distance % 2 == 1: print(int(ceil(distance/2) + 1))
s066634852
Accepted
17
3,064
232
from math import ceil a, b, c = map(int, input().split()) MAX = max(max(a,b),c) distance = (MAX-a) + (MAX-b) + (MAX-c) if distance % 2 == 0: print(int(distance/2)) elif distance % 2 == 1: print(int(ceil(distance/2) + 1))
s939708425
p03448
u204358360
2,000
262,144
Wrong Answer
18
2,940
161
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.
X =int(input()) pattern = [x+y+z for z in range(0,X+1,50) for y in range(0,X+1,100) for x in range(0,X+1,500)] print(len(list(filter(lambda x:x==X,pattern))))
s962521054
Accepted
38
7,320
324
a=int(input()) b=int(input()) c=int(input()) X = int(input()) fifty = [x for x in range (0,X+1,500)][:a+1] hundred = [x for x in range (0,X+1,100)][:b+1] five_hundred = [x for x in range (0,X+1,50)][:c+1] pattern = [x+y+z for x in fifty for y in hundred for z in five_hundred] print(len(list(filter(lambda x:x==X,pattern))))
s629165030
p02602
u491550356
2,000
1,048,576
Wrong Answer
2,206
31,552
243
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
N, K = map(int, input().split()) A = list(map(int, input().split())) val = 1 for i in range(K-1): val *= A[i] for i in range(K-1, N): if i != K-1: val /= A[i-K] val *= A[i] if val > K: print("Yes") else: print("No")
s112100878
Accepted
140
31,752
157
N, K = map(int, input().split()) A = list(map(int, input().split())) for i in range(K, N): if A[i] > A[i-K]: print("Yes") else: print("No")
s321217281
p03597
u667024514
2,000
262,144
Wrong Answer
18
2,940
46
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
N = int(input()) A = int(input()) print(N*2-A)
s762735973
Accepted
17
2,940
49
N = int(input()) A = int(input()) print((N**2)-A)
s000456483
p04030
u093500767
2,000
262,144
Wrong Answer
19
2,940
144
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
list = map(str, input().split()) ans = [] for i in list: if i=="B": del ans[-1] else: ans.append(i) print("".join(ans))
s900246610
Accepted
17
2,940
157
list = input() ans = [] for i in list: if i=="B" and len(ans)!=0: ans.pop() elif i=="0" or i=="1": ans.append(i) print("".join(ans))
s789259159
p03605
u393253137
2,000
262,144
Wrong Answer
17
2,940
61
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
n=input() if "9" in n: print("YES") else: print("No")
s344698118
Accepted
17
2,940
44
n=input() print("Yes" if "9" in n else "No")
s007251868
p03494
u929138803
2,000
262,144
Wrong Answer
17
3,064
208
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.
count = 0 flg = 0 a = list(map(int,input().split())) while True: for i in a: if i%2 != 0: flg = 1 if flg == 0: a = list(map(lambda x: int(x/2), a)) count += 1 else: break print(count)
s138113163
Accepted
19
3,060
221
count = 0 flg = 0 n = input() a = list(map(int,input().split())) while True: for i in a: if i%2 != 0: flg = 1 if flg == 0: a = list(map(lambda x: int(x/2), a)) count += 1 else: break print(count)
s348053181
p03827
u399721252
2,000
262,144
Wrong Answer
17
2,940
122
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
s = input() x = 0 max_x = 0 for i in s: if i == "D": x -= 1 else: x += 1 max_x = max(x, max_x) print(max_x)
s520575073
Accepted
18
2,940
134
n = input() s = input() x = 0 max_x = 0 for i in s: if i == "D": x -= 1 else: x += 1 max_x = max(x, max_x) print(max_x)
s692905637
p03583
u185948224
2,000
262,144
Wrong Answer
480
3,060
336
You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted.
import math N = int(input()) jdg = True for h in range(math.ceil(N/4), 3501): if jdg: for n in range(h, 3501): num = 4*h*n - N*h - N*n if num > 0: if (N * n * h) % num == 0: jdg = False break else: break w = N*h*n//(num) print(*[h, n, w])
s460807386
Accepted
465
3,064
307
import math N = int(input()) jdg = True for h in range(math.ceil(N/4), 3501): for n in range(h, 3501): num = 4*h*n - N*h - N*n if num > 0: if (N * n * h) % num == 0: jdg = False break if not jdg: break w = N*h*n//(num) print(*[h, n, w])
s057137636
p02975
u102445737
2,000
1,048,576
Wrong Answer
84
14,484
755
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
import sys,heapq,math,resource from collections import deque,defaultdict printn = lambda x: sys.stdout.write(x) inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) DBG = True # and False R = 10**9 + 7 def ddprint(x): if DBG: print(x) def setrlim(): sys.setrecursionlimit(250000) soft,hard = resource.getrlimit(RLIMIT_STACK) # setrlimit works on ubuntu (and atcoder), but not on WSL #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard)) n = inn() a = inl() h = {} ddprint(n) ddprint(a) for x in a: h[x] = (1 if x not in h else h[x]+1) if len(h.keys()) == 3 and h[a[0]] == h[a[1]] and h[a[2]] == h[a[1]]: print('Yes') else: print('No')
s154009741
Accepted
75
14,612
965
import sys,heapq,math,resource from collections import deque,defaultdict printn = lambda x: sys.stdout.write(x) inn = lambda : int(input()) inl = lambda: list(map(int, input().split())) inm = lambda: map(int, input().split()) DBG = True and False R = 10**9 + 7 def ddprint(x): if DBG: print(x) def setrlim(): sys.setrecursionlimit(250000) soft,hard = resource.getrlimit(RLIMIT_STACK) # setrlimit works on ubuntu (and atcoder), but not on WSL #resource.setrlimit(RLIMIT_STACK, (128*1024*1024,hard)) n = inn() a = inl() h = {} ddprint(n) ddprint(a) for x in a: h[x] = (1 if x not in h else h[x]+1) b = list(h.keys()) x = a[0] if a[0]!=0 else a[1] if len(h.keys()) == 3 and h[b[0]] == h[b[1]] and h[b[2]] == h[b[1]] and (b[0]^b[1])==b[2]: print('Yes') elif len(h.keys()) == 2 and (b[0]==0 or b[1]==0) and h[0]*2 == h[x]: print('Yes') elif len(h.keys()) == 1 and b[0]==0: print('Yes') else: print('No')
s210913949
p03485
u744034042
2,000
262,144
Wrong Answer
17
2,940
85
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a, b = map(int, input().split()) c = (a+b)/2 print("c" if int(c) == c else "c + 1/2")
s861737083
Accepted
17
2,940
106
a, b = map(int, input().split()) if (a+b)/2 == (a+b)//2: print(int((a+b)/2)) else: print((a+b)//2 + 1)
s451622001
p03815
u762557532
2,000
262,144
Wrong Answer
17
2,940
122
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
x = int(input()) ans = 2 * ((x - 1) // 11) + ((x - 1) % 11 > 6) + 1 print(ans)
s143901718
Accepted
17
2,940
122
x = int(input()) ans = 2 * ((x - 1) // 11) + ((x - 1) % 11 > 5) + 1 print(ans)
s291074271
p01831
u078042885
5,000
524,288
Wrong Answer
30
7,396
63
You are in front of a linear gimmick of a game. It consists of $N$ panels in a row, and each of them displays a right or a left arrow. You can step in this gimmick from any panel. Once you get on a panel, you are forced to move following the direction of the arrow shown on the panel and the panel will be removed immediately. You keep moving in the same direction until you get on another panel, and if you reach a panel, you turn in (or keep) the direction of the arrow on the panel. The panels you passed are also removed. You repeat this procedure, and when there is no panel in your current direction, you get out of the gimmick. For example, when the gimmick is the following image and you first get on the 2nd panel from the left, your moves are as follows. * Move right and remove the 2nd panel. * Move left and remove the 3rd panel. * Move right and remove the 1st panel. * Move right and remove the 4th panel. * Move left and remove the 5th panel. * Get out of the gimmick. You are given a gimmick with $N$ panels. Compute the maximum number of removed panels after you get out of the gimmick.
input() s=input() print(len(s)-min(s.find('>'),s.rfind('<')-1))
s847051004
Accepted
20
7,836
67
n=int(input()) s=input() print(n-min(s.find('>'),n-s.rfind('<')-1))
s010180745
p03494
u794652722
2,000
262,144
Wrong Answer
18
3,060
300
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.
N = int(input()) A = list(map(int,input().split())) def even_check(A): for i in range(N): if A[i]%2 != 0: return False break return True total_cnt = 0 while even_check(A): for i in range(N): A[i] = A[i]/2 total_cnt += 1 print(total_cnt)
s525872299
Accepted
19
2,940
307
N = int(input()) A = list(map(int,input().split())) def even_check(A): cnt = 0 for i in range(N): if A[i]%2 == 0: cnt += 1 if cnt == N: return True total_cnt = 0 while even_check(A): for i in range(N): A[i] = A[i]/2 total_cnt += 1 print(total_cnt)
s234357781
p03399
u424967964
2,000
262,144
Wrong Answer
17
2,940
105
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 = [ i for i in range(4)] for i in range(4): a[i]=int(input()) print(max(a[0],a[1])+max(a[2],a[3]))
s923196173
Accepted
17
2,940
105
a = [ i for i in range(4)] for i in range(4): a[i]=int(input()) print(min(a[0],a[1])+min(a[2],a[3]))
s105938671
p03479
u167681750
2,000
262,144
Wrong Answer
21
3,060
271
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 = list(map(int, (input().split()))) num = X counter = 0 if num == 1: counter += 1 num += 1 for i in range (1, Y): if num >= Y: print(num,counter) break else: print(num) counter += 1 num *= 2 print(counter)
s212128057
Accepted
20
3,316
224
X, Y = list(map(int, (input().split()))) num = X counter = 0 if num == 1: counter += 1 num += 1 for i in range (1, Y): if num > Y: break else: counter += 1 num *= 2 print(counter)
s189175464
p03023
u309141201
2,000
1,048,576
Wrong Answer
30
9,028
28
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
n = int(input()) print(90*n)
s037757475
Accepted
23
8,964
33
n = int(input()) print(180*(n-2))
s441888726
p03643
u137667583
2,000
262,144
Wrong Answer
17
2,940
20
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
print("ABC",input())
s770512471
Accepted
17
2,940
31
print("ABC{0}".format(input()))
s151249099
p04031
u202570162
2,000
262,144
Wrong Answer
17
2,940
73
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
n=int(input()) a=[int(i) for i in input().split()] print(round(sum(a)/n))
s493451517
Accepted
17
2,940
101
n=int(input()) a=[int(i) for i in input().split()] x=round(sum(a)/n) print(sum((x-i)**2 for i in a))
s781177475
p02854
u822725754
2,000
1,048,576
Wrong Answer
103
26,060
193
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
n = int(input()) A = list(map(int, input().split())) s = sum(A) i = 0 half = s / 2 neibor = 0 for i in range(n): if neibor >= half: break else: neibor += A[i] print(int(neibor - half))
s822654140
Accepted
108
26,220
305
n = int(input()) A = list(map(int, input().split())) s = sum(A) i = 0 half = s / 2 neibor = 0 for i in range(n+1): if neibor >= half: break else: neibor += A[i] aneibor = neibor - A[i-1] if abs(s-aneibor*2) < abs(neibor-(s-neibor)): print(abs(s-aneibor*2)) else: print(abs(neibor-(s-neibor)))
s647521891
p02407
u666221014
1,000
131,072
Wrong Answer
20
7,348
42
Write a program which reads a sequence and prints it in the reverse order.
print(" ".join(reversed(input().split())))
s110906679
Accepted
40
7,436
56
num = input() print(" ".join(reversed(input().split())))
s144364827
p03251
u736729525
2,000
1,048,576
Wrong Answer
18
3,064
436
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.
def main(): N, M, X, Y = tuple(int(x) for x in input().split(" ")) Xs = list(int(x) for x in input().split(" ")) Ys = list(int(x) for x in input().split(" ")) Xs.sort() Ys.sort() print(Xs) print(Ys) if Xs[-1] < Ys[0]: for n in range(Xs[-1]+1, Ys[0]+1): if X < n <= Y: print("No War") return print("War") if __name__ == "__main__": main()
s775976998
Accepted
48
3,064
408
def main(): N, M, X, Y = tuple(int(x) for x in input().split(" ")) Xs = list(int(x) for x in input().split(" ")) Ys = list(int(x) for x in input().split(" ")) Xs.sort() Ys.sort() if Xs[-1] < Ys[0]: for n in range(Xs[-1]+1, Ys[0]+1): if X < n <= Y: print("No War") return print("War") if __name__ == "__main__": main()
s019565786
p03494
u776311944
2,000
262,144
Wrong Answer
29
9,184
397
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.
N = int(input()) A = list(map(int, input().split())) res = float('inf') for i in A: cnt = 0 while True: if i % 2 == 1: res = cnt if res == 0: print(0) exit() elif cnt < res: res = cnt break else: break i = i // 2 cnt += 1 print(res)
s195297500
Accepted
25
9,140
375
N = int(input()) A = list(map(int, input().split())) res = float('inf') for i in A: cnt = 0 while True: if i % 2 == 1: if cnt == 0: print(0) exit() elif cnt < res: res = cnt break else: break i = i // 2 cnt += 1 print(res)
s900565723
p03815
u619197965
2,000
262,144
Wrong Answer
17
2,940
86
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
from math import ceil x=int(input()) ans=ceil(x/11)*2 print(ans if x%11==0 else ans-1)
s447303825
Accepted
19
2,940
84
x=int(input()) print(2*(x//11)+(x%11)//6+((x%11)%6)//5+(1 if ((x%11)%6)%5>0 else 0))
s306088913
p03795
u410118019
2,000
262,144
Wrong Answer
17
2,940
36
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()) print(n*800-n%15*200)
s801685181
Accepted
17
2,940
39
n=int(input()) print(n*800-(n//15)*200)
s850448042
p03379
u284363684
2,000
262,144
Wrong Answer
2,206
30,812
278
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
# input N = int(input()) X = list(map(int, input().split())) center = N // 2 - 1 for ind in range(N): if ind == 0: target = X[1:] elif ind == N - 1: target = X[:ind] else: target = X[:ind] + X[ind + 1:] print(target[center])
s856931064
Accepted
194
30,836
349
# input N = int(input()) X = list(map(int, input().split())) l, r = N // 2 - 1, N // 2 sort_x = sorted(X) lx, rx = sort_x[l], sort_x[r] if lx == rx: for i in range(N): print(lx) else: for ind in range(N): target = X[ind] if target <= lx: print(rx) if target >= rx: print(lx)
s595672055
p03544
u687044304
2,000
262,144
Time Limit Exceeded
2,104
3,188
269
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
# -*- coding:utf-8 -*- def solve(): N = int(input()) L0 = 2 L1 = 1 i = 2 while True: ans = L0 + L1 if i == N: break L0 = L1 L1 = ans print(ans) if __name__ == "__main__": solve()
s175773086
Accepted
18
3,060
328
# -*- coding:utf-8 -*- def solve(): N = int(input()) if N == 1: print(1) return L0 = 2 L1 = 1 i = 2 while True: ans = L0 + L1 if i == N: break L0 = L1 L1 = ans i += 1 print(ans) if __name__ == "__main__": solve()
s112805321
p02842
u425762225
2,000
1,048,576
Wrong Answer
34
2,940
179
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
def solve(n): for i in range(50000): x = i + 1 if int(x * 1.08) == n: return x return -1 N = input() ans = solve(N) print(":(" if ans == -1 else ans)
s620110888
Accepted
35
9,108
487
#!/usr/bin/env python3 # from numba import njit # from collections import Counter # from itertools import accumulate # import numpy as np # from heapq import heappop,heappush # from bisect import bisect_left def solve(n): for x in range(50000): if x * 108 // 100 == n: return x return ":(" def main(): N = int(input()) # N,M = map(int,input().split()) # a = list(map(int,input().split())) print(solve(N)) return if __name__ == '__main__': main()
s699392486
p02417
u316584871
1,000
131,072
Wrong Answer
20
5,544
79
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
s = str(input()) for i in range(97,123): print(chr(i),':',s.count(chr(i)))
s954423188
Accepted
20
5,560
100
import sys s=sys.stdin.read().lower() for i in range(97,123): print(chr(i),':',s.count(chr(i)))
s919713908
p03359
u858436319
2,000
262,144
Wrong Answer
17
2,940
71
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
A, B = map(int,input().split()) if A < B: print(A) else: print(A-1)
s121185867
Accepted
17
2,940
72
A, B = map(int,input().split()) if A <= B: print(A) else: print(A-1)
s921654895
p03778
u244836567
2,000
262,144
Wrong Answer
24
9,124
161
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
a,b,c=input().split() a=int(a) b=int(b) c=int(c) if b<=c: if a+b>=c: print(0) else: print(c-b) else: if a+c>=b: print(0) else: print(b-c)
s371201272
Accepted
27
9,132
165
a,b,c=input().split() a=int(a) b=int(b) c=int(c) if b<=c: if a+b>=c: print(0) else: print(c-b-a) else: if a+c>=b: print(0) else: print(b-c-a)
s354591803
p03456
u798731634
2,000
262,144
Wrong Answer
17
2,940
148
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a, b = map(str, input().split()) c = a + b if math.sqrt(int(c)) - round(math.sqrt(int(c))) == 0: print("True") else: print("No")
s042291908
Accepted
17
2,940
147
import math a, b = map(str, input().split()) c = a + b if math.sqrt(int(c)) - round(math.sqrt(int(c))) == 0: print("Yes") else: print("No")
s681814017
p03997
u478266845
2,000
262,144
Wrong Answer
17
3,064
78
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()) ans = (a+b)*h/2 print(ans)
s506057849
Accepted
17
2,940
84
a = int(input()) b = int(input()) h= int(input()) ans = int((a+b)*h/2) print(ans)
s205843568
p03852
u069129582
2,000
262,144
Wrong Answer
17
2,940
131
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
s=input() s=s.replace('dreamer','').replace('dream','').replace('eraser','').replace('erase','') if s:print('NO') else:print('YES')
s550774416
Accepted
17
2,940
75
c=input() a=['a','i','u','e','o'] print('vowel' if c in a else 'consonant')
s085608934
p03574
u379340657
2,000
262,144
Wrong Answer
23
3,188
334
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().strip().split()) F = [] for _ in range(h): F.append(list(input())) for i in range(h): for j in range(w): if F[i][j] == ".": u = max(i-1,0) d = min(i+2,h) l = max(j-1,0) r = min(j+2,w) n = F[u:d][l:r].count(".") F[i][j] = str(n) for line in F: print("".join(line))
s182982974
Accepted
24
3,188
378
h,w = map(int, input().strip().split()) F = [] for _ in range(h): F.append(list(input())) for i in range(h): for j in range(w): if F[i][j] == ".": u = max(i-1,0) d = min(i+2,h) l = max(j-1,0) r = min(j+2,w) n = 0 for line in F[u:d]: n += line[l:r].count("#") F[i][j] = str(n) for line in F: print("".join(line))
s400551226
p03339
u626337957
2,000
1,048,576
Wrong Answer
239
15,256
227
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
N = int(input()) S = input() leader = [0] * (N) sum_e = 0 sum_w = 0 for i in range(N): leader[i] += sum_e leader[N-i-1] += sum_w if S[i] == 'E': sum_e += 1 if S[N-i-1] == 'W': sum_w += 1 print(N-max(leader))
s002278522
Accepted
231
15,292
225
N = int(input()) S = input() leader = [0] * (N) sum_e = 0 sum_w = 0 for i in range(N): leader[i] += sum_e leader[N-i-1] += sum_w if S[i] == 'E': sum_e += 1 if S[N-i-1] == 'W': sum_w += 1 print(N-max(leader)-1)
s291453659
p03068
u129978636
2,000
1,048,576
Wrong Answer
17
3,060
213
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=input() k=int(input()) a=s[k-1] t=[] for i in range(n): if(s[i] == a): t.append('*') else: t.append(s[i]) continue for j in range(n): print(t[j],end='') print()
s421835561
Accepted
17
3,060
213
n=int(input()) s=input() k=int(input()) a=s[k-1] t=[] for i in range(n): if(s[i] == a): t.append(s[i]) else: t.append('*') continue for j in range(n): print(t[j],end='') print()
s734932806
p03090
u223646582
2,000
1,048,576
Wrong Answer
81
3,316
227
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
N = int(input()) print(N//2) for i in range(1, N): for j in range(i+1, N+1): if N % 2 == 0: if i+j == N+1: print(i, j) else: if i+j == N: print(i, j)
s798105963
Accepted
24
3,612
148
N = int(input()) print(N*(N-1)//2-N//2) for i in range(1, N+1): for j in range(i+1, N+1): if i+j != N//2*2+1: print(i, j)
s961395248
p03150
u999503965
2,000
1,048,576
Wrong Answer
29
8,996
152
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() n=len(s) ans="No" for i in range(n): for j in range(1,n+1): num=s[:i]+s[j:] if num == "keyence": ans="Yes" print(ans)
s056040840
Accepted
27
9,060
153
s=input() n=len(s) ans="NO" for i in range(n): for j in range(1,n+1): num=s[:i]+s[j:] if num == "keyence": ans="YES" print(ans)
s361652128
p03795
u178192749
2,000
262,144
Wrong Answer
17
2,940
48
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()) cnt = n%15 print(800*n-200*cnt)
s635895805
Accepted
17
3,068
49
n = int(input()) cnt = n//15 print(800*n-200*cnt)
s667230037
p03762
u497625442
2,000
262,144
Wrong Answer
139
18,556
241
On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
n,m = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) P = 10**9+7 def xx(x,n): t = 0 for i in range(n-1): t = (t + i*(n-(i-1)) * (x[i+1]-x[i])) % P return t print((xx(x,n) * xx(y,m)) % P)
s644134603
Accepted
170
18,576
284
n,m = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) P = 10**9+7 def s(n,i): return i * (n-(i-1)) def xx(x,n): t = 0 for i in range(n-1): t = (t + s(n-1,i+1) * (x[i+1]-x[i])) % P return t R = (xx(x,n) * xx(y,m)) % P print(R)
s810297442
p02393
u811841526
1,000
131,072
Wrong Answer
30
7,560
58
Write a program which reads three integers, and prints them in ascending order.
xs=map(int,input().split()) ' '.join(map(str, sorted(xs)))
s255319029
Accepted
20
5,584
85
input_list = map(int, input().split()) print(' '.join(map(str, sorted(input_list))))
s559926711
p02927
u465246274
2,000
1,048,576
Wrong Answer
19
3,060
200
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
m,d = map(int,input().split()) count=0 if d<20: print(0) else: for i in range(1,m+1): for j in range(20, d+1): a = j//10 b = j%10 if i == a*b: count+=1 print(count)
s192673824
Accepted
33
3,060
225
m,d = map(int,input().split()) count=0 if d<20: print(count) else: for i in range(1,m+1): for j in range(20, d+1): a = j//10 b = j%10 if b>=2: if i == a*b: count+=1 print(count)
s679116025
p03959
u543954314
2,000
262,144
Wrong Answer
155
19,608
711
Mountaineers Mr. Takahashi and Mr. Aoki recently trekked across a certain famous mountain range. The mountain range consists of N mountains, extending from west to east in a straight line as Mt. 1, Mt. 2, ..., Mt. N. Mr. Takahashi traversed the range from the west and Mr. Aoki from the east. The height of Mt. i is h_i, but they have forgotten the value of each h_i. Instead, for each i (1 ≤ i ≤ N), they recorded the maximum height of the mountains climbed up to the time they reached the peak of Mt. i (including Mt. i). Mr. Takahashi's record is T_i and Mr. Aoki's record is A_i. We know that the height of each mountain h_i is a positive integer. Compute the number of the possible sequences of the mountains' heights, modulo 10^9 + 7. Note that the records may be incorrect and thus there may be no possible sequence of the mountains' heights. In such a case, output 0.
n = int(input()) mount = [0]*n a = list(map(int, input().split())) b = list(map(int, input().split())) mount[0] = a[0] mount[-1] = b[-1] pat = 1 mod = 10**9+7 for i in range(1,n-1): if a[i] > a[i-1]: if mount[i] != 0 and mount[i] != a[i]: print(0) break else: mount[i] = a[i] if b[n-i-1] > b[n-1]: if mount[n-i-1] != 0 and mount[n-i-1] != b[n-i-1]: print(0) break else: mount[n-i-1] = b[n-i-1] else: for i in range(1,n-1): if mount[i]== 0: if mount[i+1] == 0: pat = pat*mount[i-1]%mod mount[i] = mount[i-1] else: this = min(mount[i-1],mount[i+1]) pat = pat*this%mod mount[i] = this print(pat)
s872193167
Accepted
451
19,520
861
n = int(input()) mount = [0]*n a = list(map(int, input().split())) b = list(map(int, input().split())) mount[0] = a[0] mount[-1] = b[-1] pat = 1 mod = 10**9+7 for i in range(1,n): if a[i] > a[i-1]: if mount[i] != 0 and mount[i] != a[i]: print(0) exit() else: mount[i] = a[i] if b[n-i-1] > b[n-i]: if mount[n-i-1] != 0 and mount[n-i-1] != b[n-i-1]: print(0) exit() else: mount[n-i-1] = b[n-i-1] for i in range(n): if mount[i] == 0: dx = 1 while mount[i+dx] == 0: dx += 1 this = min(mount[i-1],mount[i+dx]) pat = pat*(this**dx)%mod for j in range(dx): mount[i+j] = this a2 = [0]*n b2 = [0]*n a2[0] = mount[0] b2[-1] = mount[-1] for i in range(1,n): a2[i] = max(mount[i],a2[i-1]) b2[n-i-1] = max(mount[n-i-1],b2[n-i]) if a != a2 or b != b2: print(0) else: print(pat)
s379685607
p03162
u884077550
2,000
1,048,576
Wrong Answer
390
3,060
155
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
n = int(input()) a,b,c = 0,0,0 for _ in range(n): x, y, z = map(int, input().split()) a,b,c = max(y,z)+a,max(x,z)+b,max(x,y)+c print(max(a,b,c))
s385032655
Accepted
470
3,064
237
n = int(input()) dp = list(map(int, input().split())) for i in range(1,n): arr = list(map(int, input().split())) dp[0],dp[1],dp[2] = arr[0] + max(dp[1],dp[2]),arr[1] + max(dp[0],dp[2]),arr[2] + max(dp[0],dp[1]) print(max(dp))
s279331054
p04029
u174040991
2,000
262,144
Wrong Answer
31
8,844
95
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
n = '' command = input() for i in command: if i =="B": n=n[:-1] else: n+=i print(n)
s073115321
Accepted
26
8,924
78
n = int(input()) total = 0 for i in range(1,n+1): total += i print(total)
s441347978
p03447
u331464808
2,000
262,144
Wrong Answer
18
2,940
103
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
x = int(input()) a = int(input()) b = int(input()) t = 0 while x - a -b*t>0: t +=1 print(x - a -b*t)
s295241095
Accepted
17
2,940
65
x = int(input()) a = int(input()) b = int(input()) print((x-a)%b)
s079594238
p02238
u798803522
1,000
131,072
Wrong Answer
20
7,740
664
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
def dfs(vertice,connect,went,v_time): global time for v in connect[vertice]: if not went[v]: time += 1 went[v] = time dfs(v,connect,went,v_time) else: time += 1 v_time[vertice] = time time = 1 vertices = int(input()) connect = {} for i in range(vertices): temp = input() if temp[2] == "0": connect[i] = [] else: connect[i] = [int(n) - 1 for n in temp[4:].split(" ")] went = [0 for n in range(vertices)] v_time = [0 for n in range(vertices)] went[0] = time for i in range(vertices): if not v_time[i]: dfs(i,connect,went,v_time) print(went) print(v_time)
s053228742
Accepted
30
8,144
701
from collections import defaultdict def dfs(here, connect, visited, answer): global time answer[here][1] = time time += 1 visited[here] = 1 for c in connect[here]: if not visited[c]: dfs(c, connect, visited, answer) answer[here][2] = time time += 1 v_num = int(input()) connect = defaultdict(list) for _ in range(v_num): inp = [int(n) - 1 for n in input().split(" ")] connect[inp[0]].extend(sorted(inp[2:])) answer = [[n + 1 for m in range(3)] for n in range(v_num)] time = 1 visited = [0 for n in range(v_num)] for i in range(v_num): if not visited[i]: dfs(i, connect, visited, answer) for v in range(v_num): print(*answer[v])
s781775901
p03762
u373958718
2,000
262,144
Wrong Answer
133
18,576
253
On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7. That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
n,m=map(int,input().split()) X=list(map(int,input().split())) Y=list(map(int,input().split())) xsum=0;ysum=0;mod=10**9+7 for i,x in enumerate(X): xsum+=x*(i-(n-1-i)) for i,y in enumerate(Y): ysum+=y*(i-(m-1-i)) print(xsum, ysum) print(xsum * ysum % mod)
s853510212
Accepted
128
18,576
235
n,m=map(int,input().split()) X=list(map(int,input().split())) Y=list(map(int,input().split())) xsum=0;ysum=0;mod=10**9+7 for i,x in enumerate(X): xsum+=x*(i-(n-1-i)) for i,y in enumerate(Y): ysum+=y*(i-(m-1-i)) print(xsum * ysum % mod)
s196722294
p00598
u943441430
1,000
131,072
Wrong Answer
30
5,624
2,320
Let _A, B, C, D, E_ be sets of integers and let _U_ is a universal set that includes all sets under consideration. All elements in any set are different (no repetitions). u - **union** of two sets, _AuB_ = { _x ∈ U_ : _x ∈ A_ or _x ∈ B_} is the set of all elements which belong to _A_ or _B_. i - **intersection** of two sets, _AiB_ = { _x ∈ U_ : _x ∈ A_ and _x ∈ B_} is the set of all elements which belong to both _A_ and _B_. d - **difference** of two sets, _AdB_ = { _x ∈ U_ : _x ∈ A_, _x ∉ B_} is the set of those elements of _A_ which do not belong to _B_. s - **symmetric difference** of two sets, _AsB_ = ( _AdB_ ) _u_ ( _BdA_ ) consists of those elements which belong to _A_ or _B_ but not to both. c - **complement** of a set, _cA_ = { _x ∈ U_ : _x ∉ A_}, is set of elements which belong to _U_ but do not belong to _A_. Unary operator _c_ has higest precedence. The universal set _U_ is defined as a union of all sets specified in data. Your task is to determine the result of an expression, which includes sets, set operations and parenthesis (any number of parenthesis and any correct enclosure of parenthesis may take place).
import sys def rpn(str): r = [] stack = [] for i in range(0, len(str)): c = str[i] if c in "idsu": while len(stack) > 0: if stack[-1] in "idsuc": a = stack.pop() r.extend(a) else: break stack.extend(c) elif c == "c": stack.extend(c) elif c == "(": stack.extend(c) elif c == ")": while len(stack) > 0: a = stack.pop() if a == "(": break r.extend(a) else: r.extend(c) while len(stack) > 0: a = stack.pop() r.extend(a) return r def intersect(a, b): r = [] for e in a: if e in b: r.extend([e]) return r def union(a, b): r = list(set(a + b)) return r def diff(a, b): r = [] for e in a: if e not in b: r.extend([e]) return r def universal(sets): r = [] for v in sets.values(): r.extend(v) r = list(set(r)) return r def calc(rpn, sets): stack = [] U = universal(sets) for c in rpn: if c in "iuds": op2 = stack.pop() op1 = stack.pop() if c == "i": x = intersect(op1, op2) stack.append(x) elif c == "u": x = union(op1, op2) stack.append(x) elif c == "d": x = diff(op1, op2) stack.append(x) elif c == "s": x = diff(op1, op2) y = diff(op2, op1) z = union(x, y) stack.append(z) elif c == "c": op1 = stack.pop() x = diff(U, op1) stack.append(x) else: stack.append(sets[c]) return stack.pop() lno = 0 sets = {} name = "" for line in sys.stdin: lno += 1 if lno % 2 == 1: name = line.strip().split()[0] elif name != "R": elem = list(map(int, line.strip().split())) sets[name] = elem else: e = rpn(line.strip()) result = calc(e, sets) result.sort() for n in result: print(n, end = " ") print()
s912923047
Accepted
20
5,632
2,387
import sys def rpn(str): r = [] stack = [] for i in range(0, len(str)): c = str[i] if c in "idsu": while len(stack) > 0: if stack[-1] in "idsuc": a = stack.pop() r.extend(a) else: break stack.extend(c) elif c == "c": stack.extend(c) elif c == "(": stack.extend(c) elif c == ")": while len(stack) > 0: a = stack.pop() if a == "(": break r.extend(a) else: r.extend(c) while len(stack) > 0: a = stack.pop() r.extend(a) return r def intersect(a, b): r = [] for e in a: if e in b: r.extend([e]) return r def union(a, b): r = list(set(a + b)) return r def diff(a, b): r = [] for e in a: if e not in b: r.extend([e]) return r def universal(sets): r = [] for v in sets.values(): r.extend(v) r = list(set(r)) return r def calc(rpn, sets): stack = [] U = universal(sets) for c in rpn: if c in "iuds": op2 = stack.pop() op1 = stack.pop() if c == "i": x = intersect(op1, op2) stack.append(x) elif c == "u": x = union(op1, op2) stack.append(x) elif c == "d": x = diff(op1, op2) stack.append(x) elif c == "s": x = diff(op1, op2) y = diff(op2, op1) z = union(x, y) stack.append(z) elif c == "c": op1 = stack.pop() x = diff(U, op1) stack.append(x) else: stack.append(sets[c]) return stack.pop() lno = 0 sets = {} name = "" for line in sys.stdin: lno += 1 if lno % 2 == 1: name = line.strip().split()[0] elif name != "R": elem = list(map(int, line.strip().split())) sets[name] = elem else: e = rpn(line.strip()) result = calc(e, sets) result.sort() if len(result) > 0: print(" ".join([str(n) for n in result])) else: print("NULL") sets = {}
s887070956
p03228
u137667583
2,000
1,048,576
Wrong Answer
17
3,064
396
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a,b,k = map(int,input().split()) for i in range(k): if(i%2==0): if(a%2==0): b = b+(a/2) a = a-(a/2) else: a = a-1 b = b+(a/2) a = a-(a/2) else: if(b%2==0): a = a+(b/2) b = b-(b/2) else: b = b-1 a = a+b/2 b = b-(b/2) print(a,b)
s670380629
Accepted
17
3,064
406
a,b,k = map(int,input().split()) for i in range(k): if(i%2==0): if(a%2==0): b = b+(a/2) a = a-(a/2) else: a = a-1 b = b+(a/2) a = a-(a/2) else: if(b%2==0): a = a+(b/2) b = b-(b/2) else: b = b-1 a = a+b/2 b = b-(b/2) print(int(a),int(b))
s121890450
p02842
u510565553
2,000
1,048,576
Wrong Answer
18
3,060
127
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
import math n = input() n = int(n) a = n / 1.08 b = (n+1) / 1.08 x = math.ceil(n) if n == b: print(":(") else: print(x)
s888497095
Accepted
17
2,940
127
import math n = input() n = int(n) a = n / 1.08 b = (n+1) / 1.08 x = math.ceil(a) if x >= b: print(":(") else: print(x)
s396951580
p03386
u745997547
2,000
262,144
Wrong Answer
17
3,060
207
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 = list(map(int, input().split())) for i in range(K): n = A + i if A<=n and n<=B: print(n) for i in range(K): n = B - K + i if A<=n and n<=B and n>A + K - 1: print(n)
s986720640
Accepted
21
3,316
211
A, B, K = list(map(int, input().split())) for i in range(K): n = A + i if A<=n and n<=B: print(n) for i in range(K): n = B - (K-1) + i if A<=n and n<=B and n>A + K - 1: print(n)
s524224139
p02601
u941645670
2,000
1,048,576
Wrong Answer
28
9,172
202
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
a,b,c=map(int, input().split()) k = int(input()) for i in range(k): if a > b: b = b*2 elif b > c: c = c*2 print(a,b,c) if a < b and b < c: print("Yes") else: print("No")
s782814410
Accepted
31
9,168
191
a,b,c=map(int, input().split()) k = int(input()) for i in range(k): if a >= b: b = b*2 elif b >= c: c = c*2 if a < b and b < c: print("Yes") else: print("No")
s384298440
p03503
u222841610
2,000
262,144
Wrong Answer
339
3,316
490
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
n = int(input()) f = [list(map(int,input().split())) for _ in range(n)] p = [list(map(int,input().split())) for _ in range(n)] a = [] count = 0 point = [] PP = [] for _ in range(1024,2048): a.append(list(map(int,list(bin(_)[3:])))) for k in range(1024): for i in range(n): for j in range(10): if f[i][j] == a[k][j]: count += 1 point.append(p[i][count]) count = 0 PP.append(sum(point)) point = [] print (max(PP))
s103802880
Accepted
367
3,316
506
n = int(input()) f = [list(map(int,input().split())) for _ in range(n)] p = [list(map(int,input().split())) for _ in range(n)] a = [] count = 0 point = [] PP = [] for _ in range(2**10+1,2**10*2): a.append(list(map(int,list(bin(_)[3:])))) for k in range(2**10-1): for i in range(n): for j in range(10): if f[i][j]&a[k][j] == 1: count += 1 point.append(p[i][count]) count = 0 PP.append(sum(point)) point = [] print (max(PP))
s430821503
p03377
u410996052
2,000
262,144
Wrong Answer
19
2,940
122
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 x-a<0: print("No") elif x-a>=0 and x-a<=b: print("Yes") else: print("No")
s457091361
Accepted
17
2,940
93
a,b,x = map(int, input().split()) if a<=x and x<=a+b: print("YES") else: print("NO")
s952894601
p03129
u572012241
2,000
1,048,576
Wrong Answer
18
3,060
435
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
import heapq from sys import stdin input = stdin.readline # n = int(input()) n,k = map(int, input().split()) # a = list(map(int,input().split())) # ab=[] # a,b = map(int, input().split()) # ab.append([a,b]) def main(): if (n+2-1)//2 <k: print("No") else: print("Yes") if __name__ == '__main__': main()
s685087637
Accepted
18
3,060
435
import heapq from sys import stdin input = stdin.readline # n = int(input()) n,k = map(int, input().split()) # a = list(map(int,input().split())) # ab=[] # a,b = map(int, input().split()) # ab.append([a,b]) def main(): if (n+2-1)//2 <k: print("NO") else: print("YES") if __name__ == '__main__': main()
s818575624
p03385
u152671129
2,000
262,144
Wrong Answer
17
2,940
46
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s = list(input()) print(s == ['a', 'b', 'c'])
s315049492
Accepted
17
2,940
88
s = list(input()) answer = 'Yes' if sorted(s) == ['a', 'b', 'c'] else 'No' print(answer)
s001733556
p03433
u606043821
2,000
262,144
Wrong Answer
17
2,940
171
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()) a = 0 for i in range(20): if N > 500*i: a + 500 else: continue b = N - a if b <= A: print("Yes") else: print("No")
s844812045
Accepted
17
2,940
183
N = int(input()) A = int(input()) a = 0 for i in range(20): if N >= 500*(i+1): a = 500*(i+1) else: continue b = N - a if b <= A: print("Yes") else: print("No")
s136284632
p03943
u599547273
2,000
262,144
Wrong Answer
17
2,940
115
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
a, b, c = map(int, input().split(" ")) if a+b == c or b+c == a or c+b == b: print("Yes") else: print("No")
s931107736
Accepted
17
2,940
115
a, b, c = map(int, input().split(" ")) if a+b == c or b+c == a or c+a == b: print("Yes") else: print("No")
s726829179
p02534
u073646027
2,000
1,048,576
Wrong Answer
25
9,144
31
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
k = int(input()) print("ALC"*k)
s235595864
Accepted
22
9,080
31
k = int(input()) print("ACL"*k)
s273767973
p03163
u704158845
2,000
1,048,576
Wrong Answer
201
14,440
228
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
N,W = map(int,input().split()) wv = [list(map(int,input().split())) for _ in range(N)] import numpy as np dp = np.zeros(W+1,dtype=np.int64) for w,v in wv: np.maximum(dp[w:],dp[:-w]+v,out=dp[w:]) print(dp) print(dp.max())
s406200725
Accepted
172
14,264
214
N,W = map(int,input().split()) wv = [list(map(int,input().split())) for _ in range(N)] import numpy as np dp = np.zeros(W+1,dtype=np.int64) for w,v in wv: np.maximum(dp[w:],dp[:-w]+v,out=dp[w:]) print(dp.max())
s923477464
p03695
u416773418
2,000
262,144
Wrong Answer
17
3,064
416
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
n = int(input()) a = list(map(int, input().split())) b = [0] * 9 for i in range(n): for j in range(9): if 400 * j <= a[i] < 400 * (j + 1) - 1 and j != 8: b[j] += 1 elif j == 8 and a[i] >= 400 * j: b[j] += 1 m = 0 M = 0 for i in range(8): if b[i] != 0: m += 1 M += 1 M += b[8] if M > 8: M = 8 if m == 0 and b[8] !=0: m == 1 print(b) print(m, M)
s115901487
Accepted
18
3,064
374
n = int(input()) a = list(map(int, input().split())) b = [0] * 9 for i in range(n): for j in range(9): if 400 * j <= a[i] <= 400 * (j + 1) - 1 and j != 8: b[j] += 1 elif j == 8 and a[i] >= 400 * j: b[j] += 1 m = 0 M = 0 for i in range(8): if b[i] != 0: m += 1 M += 1 M += b[8] if m == 0: m = 1 print(m, M)
s052462060
p03545
u164471280
2,000
262,144
Wrong Answer
18
3,060
287
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
# -*- coding: utf-8 -*- import sys abcd = input() n = len(abcd)-1 for i in range(3**n): t = abcd[0] for j in range(n): if (i >> j & 1): t += '+' else: t += '-' t += abcd[j+1] if eval(t) == 7: print(t) sys.exit()
s139081838
Accepted
17
3,060
305
# -*- coding: utf-8 -*- import sys abcd = input() n = len(abcd)-1 for i in range(3**n): t = abcd[0] for j in range(n): if (i >> j & 1): t += '+' else: t += '-' t += abcd[j+1] if eval(t) == 7: t += '=7' print(t) sys.exit()
s214369654
p03130
u114366889
2,000
1,048,576
Wrong Answer
17
3,064
300
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
Inp1 = list(input().split()) Inp1.extend(input().replace(' ','')) Inp1.extend(input().replace(' ','')) Inp_dict = {'1':0,'2':0,'3':0,'4':0} for i in Inp1: Inp_dict[i] +=1 ans = list() for k in Inp_dict.keys(): if Inp_dict[k] == 2 : ans.extend(k) if len(ans) == 2: print('Yes') else: print('No')
s529188468
Accepted
17
3,064
300
Inp1 = list(input().split()) Inp1.extend(input().replace(' ','')) Inp1.extend(input().replace(' ','')) Inp_dict = {'1':0,'2':0,'3':0,'4':0} for i in Inp1: Inp_dict[i] +=1 ans = list() for k in Inp_dict.keys(): if Inp_dict[k] == 2 : ans.extend(k) if len(ans) == 2: print('YES') else: print('NO')
s523542125
p03378
u736729525
2,000
262,144
Wrong Answer
18
2,940
184
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 = [int(x) for x in input().split()] A = [int(x) for x in input().split()] cell = [0] * (N+1) for a in A: cell[a] = 1 print(cell) print(min(sum(cell[:X]), sum(cell[X:])))
s158939357
Accepted
18
2,940
172
N, M, X = [int(x) for x in input().split()] A = [int(x) for x in input().split()] cell = [0] * (N+1) for a in A: cell[a] = 1 print(min(sum(cell[:X]), sum(cell[X:])))
s485754536
p03814
u476048753
2,000
262,144
Wrong Answer
24
3,944
151
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
s = input() N = len(s) substr = "" for i in range(N): if s[i] == "A": substr = s[i:] break index = substr.rfind("Z") print(substr[:index])
s679143648
Accepted
19
3,500
49
s = input() print(s.rfind('Z') - s.find('A') + 1)
s023017082
p03370
u260036763
2,000
262,144
Wrong Answer
17
2,940
105
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.
N, X = map(int, input().split()) m = [int(input()) for i in range(N)] print(N + int((N - sum(m))/min(m)))
s297325420
Accepted
17
2,940
102
N, X = map(int, input().split()) m = [int(input()) for i in range(N)] print(N + (X - sum(m))// min(m))
s126588022
p03816
u791838908
2,000
262,144
Wrong Answer
54
17,204
50
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
N = input() A = input() print(len(set(A.split())))
s152750719
Accepted
76
17,204
214
N = int(input()) A = input() list_A = A.split() set_A = set(list_A) i = 0 for a in list_A: if a in set_A: i += 1 i = i - len(set_A) if i % 2 == 0: print(N - i) else: print(N - (i +1))
s373770059
p03494
u546440137
2,000
262,144
Wrong Answer
27
9,240
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.
N=int(input()) x=list(map(int,input().split())) for i in range(N): count=0 while x[i]%2==0: x[i]/=2 count+=1 print(count)
s248017516
Accepted
32
9,128
150
N=int(input()) x=list(map(int,input().split())) count=[0]*N for i in range(N): while x[i]%2==0: x[i]/=2 count[i]+=1 print(min(count))
s050241553
p02399
u452958267
1,000
131,072
Wrong Answer
30
7,616
81
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
# -*- coding: utf-8 -* a, b = map(int, input().split()) print(a//b, a % b, a / b)
s815795013
Accepted
30
7,624
100
# -*- coding: utf-8 -* a, b = map(int, input().split()) print('%d %d %.5f' % (a // b, a % b, a / b))
s617621875
p03729
u811436126
2,000
262,144
Wrong Answer
18
2,940
102
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a, b, c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('Yes') else: print('No')
s572507122
Accepted
18
2,940
102
a, b, c = input().split() if a[-1] == b[0] and b[-1] == c[0]: print('YES') else: print('NO')
s189661881
p02276
u798796508
1,000
131,072
Wrong Answer
20
5,592
376
Quick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, inturn, less than or equal to each element of A[q+1..r]. It also computes the index q. In the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r). Your task is to read a sequence A and perform the Partition based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Note that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].
n = int(input()) a = list(map(int, input().split())) s = 0 last = a[-1] for i in range(n-1): if a[i] <= last: tmp = a[i] a[i] = a[s] a[s] = tmp s += 1 tmp = a[-1] a[-1] = a[s] a[s] = tmp for i in range(1, s): print(a[i], end=' ') print('[' + str(a[s]) + '] ', end='') for i in range(s+1, n-1): print(a[i], end=' ') print(a[n-1])
s450509786
Accepted
180
16,380
376
n = int(input()) a = list(map(int, input().split())) s = 0 last = a[-1] for i in range(n-1): if a[i] <= last: tmp = a[i] a[i] = a[s] a[s] = tmp s += 1 tmp = a[-1] a[-1] = a[s] a[s] = tmp for i in range(0, s): print(a[i], end=' ') print('[' + str(a[s]) + '] ', end='') for i in range(s+1, n-1): print(a[i], end=' ') print(a[n-1])
s166784899
p02288
u112247126
2,000
131,072
Wrong Answer
20
7,644
665
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
def maxHeapify(heap, i): while (i + 1) * 2 <= len(heap): left = (i + 1) * 2 - 1 right = (i + 1) * 2 if heap[i] < heap[left]: tmp = heap[i] heap[i] = heap[left] heap[left] = tmp i = left elif heap[i] < heap[right]: tmp = heap[i] heap[i] = heap[right] heap[right] = tmp i = right else: break def buildMaxHeap(heap): for i in range(len(heap), 1): maxHeapify(heap, i) n = int(input()) heap = list(map(int, input().split())) buildMaxHeap(heap) out = '' for key in heap: out += ' str(key)' print(out)
s431189675
Accepted
1,140
65,484
590
def maxHeapify(heap, i): left = (i + 1) * 2 - 1 right = (i + 1) * 2 largest = left if left < len(heap) and heap[left] > heap[i] else i largest = right if right < len(heap) and heap[right] > heap[largest] else largest if largest != i: heap[i], heap[largest] = heap[largest], heap[i] maxHeapify(heap, largest) def buildMaxHeap(heap): for i in range(len(heap) // 2, -1, -1): maxHeapify(heap, i) n = int(input()) heap = list(map(int, input().split())) buildMaxHeap(heap) out = '' for key in heap: out += (' {}'.format(str(key))) print(out)
s769977709
p04029
u752898745
2,000
262,144
Wrong Answer
17
2,940
70
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
def candy(N): return (N**2 +N)/2 N = int(input()) print(candy(N))
s771994543
Accepted
17
2,940
71
def candy(N): return (N**2 +N)//2 N = int(input()) print(candy(N))
s861094767
p03457
u583010173
2,000
262,144
Wrong Answer
363
3,064
413
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.
# -*- coding: utf-8 -*- n = int(input()) t_bef = 0 x_bef = 0 y_bef = 0 flag = 0 for i in range(n): t, x, y = [int(x) for x in input().split()] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x, y if check < 0: print('No') flag = 1 break if check % 2 != 0: print('No') flag = 1 break if flag == 0: print('YES')
s512558251
Accepted
365
3,064
425
# -*- coding: utf-8 -*- n = int(input()) t_bef, x_bef, y_bef, flag = 0, 0, 0, 0 travel = [] for i in range(n): t, x, y = [int(x) for x in input().split()] check = (t - t_bef) - abs(x_bef - x) - abs(y_bef - y) t_bef, x_bef, y_bef = t, x, y if check < 0: print('No') flag = 1 break if check % 2 != 0: print('No') flag = 1 break if flag == 0: print('Yes')
s736157512
p00001
u040533857
1,000
131,072
Wrong Answer
30
6,724
124
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
spam = [int(input()) for i in range(0, 10)] spam.sort() spam.reverse() for i in range(1, 3): print('{}'.format(spam[i]))
s162624028
Accepted
30
6,724
110
spam = [int(input()) for i in range(0, 10)] spam.sort() spam.reverse() for i in range(0,3): print(spam[i])
s825653859
p03338
u475598608
2,000
1,048,576
Wrong Answer
18
3,060
160
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
N=int(input()) S=str(input()) ans=0 for i in range(1,N): X=set(S[:i]) Y=set(S[i:]) print(X) print(Y) X&=Y ans=max(ans,len(X)) print(ans)
s061991380
Accepted
17
3,064
135
N=int(input()) S=str(input()) ans=0 for i in range(1,N): X=set(S[:i]) Y=set(S[i:]) X&=Y ans=max(ans,len(X)) print(ans)
s673212766
p03359
u319818856
2,000
262,144
Wrong Answer
17
2,940
153
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
def day_of_takahashi(a: int, b: int) -> int: return (a - 1) + (1 if a <= b else 0) if __name__ == "__main__": a, b = map(int, input().split())
s955677687
Accepted
18
2,940
201
def day_of_takahashi(a: int, b: int) -> int: return (a - 1) + (1 if a <= b else 0) if __name__ == "__main__": a, b = map(int, input().split()) ans = day_of_takahashi(a, b) print(ans)
s754382994
p04012
u710515311
2,000
262,144
Wrong Answer
28
8,844
255
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
import sys input = sys.stdin.readline def solve(): w = list(input()) s = set(w) for i in s: if len([x for x in w if x == i]) % 2 == 1: print('No') exit() print('Yes') if __name__ == "__main__": solve()
s433021664
Accepted
29
9,076
264
import sys input = sys.stdin.readline def solve(): w = list(input().rstrip()) s = set(w) for i in s: if len([x for x in w if x == i]) % 2 == 1: print('No') exit() print('Yes') if __name__ == "__main__": solve()
s030910774
p03471
u466143662
2,000
262,144
Wrong Answer
2,104
3,064
352
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=map(int,input().split()) moji="-1 -1 -1" for i in range(n): y1=y-10000*i for j in range(n-i): y2=y1-5000*j for k in range(n-i-j): y3=y2-1000*k if y3==0: moji=str(i)+ " " + str(j) + " " + str(k) break else: continue print(moji)
s117183588
Accepted
656
3,060
284
n,y=map(int,input().split()) moji="-1 -1 -1" for i in range(n+1): y1=y-10000*i for j in range(n-i+1): y2=y1-5000*j-1000*(n-i-j) if y2==0: moji=str(i)+ " " + str(j) + " " + str(n-i-j) break else: continue print(moji)
s884939791
p03399
u777028980
2,000
262,144
Wrong Answer
18
2,940
84
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
A=int(input()) B=int(input()) C=int(input()) D=int(input()) print(max(A,B)+max(C,D))
s089426857
Accepted
18
2,940
84
A=int(input()) B=int(input()) C=int(input()) D=int(input()) print(min(A,B)+min(C,D))