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
s225807551
p03860
u144980750
2,000
262,144
Wrong Answer
17
2,940
40
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
a=input().split() print("A"+a[1][0]+"B")
s383302189
Accepted
17
2,940
40
a=input().split() print("A"+a[1][0]+"C")
s291250205
p03470
u947748301
2,000
262,144
Wrong Answer
17
2,940
162
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
paper = int(input()) moti_list = [] li_uniq = [] for w in range(paper): paper = int(input()) moti_list.append(paper)
s029089737
Accepted
17
3,060
214
paper = int(input()) moti_list = [] li_uniq = [] for w in range(paper): paper = int(input()) moti_list.append(paper) li_uniq = list(set(moti_list)) print(len(li_uniq))
s550444885
p03069
u720384347
2,000
1,048,576
Wrong Answer
17
3,064
317
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.
S=list(input()) b = 0 w = 0 for i in range(len(S)): if(S[i]=="#"): b += 1 else: w += 1 b_ = w min_ = min([len(S)+1,w,b]) for i in range(len(S)): if(S[i]=="#"): b += 1 w_ = w-(i+1-b) min_ = min([w_+b_,min_]) print(min_)
s516614910
Accepted
175
4,840
307
N = int(input()) S=list(input()) b = 0 w = 0 for i in range(len(S)): if(S[i]=="#"): b += 1 else: w += 1 b_ = 0 min_ = min([w,b]) w_ = 0 for i in range(len(S)): if(S[i]=="#"): b_ += 1 else: w_ += 1 min_ = min([w-w_+b_,min_]) print(min_)
s356581774
p03457
u687553041
2,000
262,144
Wrong Answer
231
28,176
534
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.
import sys def dis(x0, y0, x1, y1): d = 0 d += abs(x0 - x1) d += abs(y0 - y1) return d if __name__ == '__main__': N = int(sys.stdin.readline()) lines = sys.stdin.readlines() ls = [] for line in lines: ls.append([int(i) for i in line.split()]) t, x, y = 0, 0, 0 for l in ls: d = dis(x, y, l[1], l[2]) # print(t, x, y, l, d) if (l[0] - t) % d == 0: t, x, y = l else: print('NO') break else: print('YES')
s670714409
Accepted
261
28,296
598
import sys def dis(x0, y0, x1, y1): d = 0 d += abs(x0 - x1) d += abs(y0 - y1) return d if __name__ == '__main__': N = int(sys.stdin.readline()) lines = sys.stdin.readlines() ls = [[0, 0, 0]] for line in lines: ls.append([int(i) for i in line.split()]) for i in range(1, len(ls)): d = dis(ls[i][1], ls[i][2], ls[i-1][1], ls[i-1][2]) t = ls[i][0] - ls[i-1][0] # print(ls[i], d, t) if d <= t and t % 2 == d % 2: continue else: print('No') break else: print('Yes')
s751963750
p03548
u536685012
2,000
262,144
Wrong Answer
30
3,060
138
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
n = list(map(int, input().split())) a = n[0] b = n[1] c = n[2] i = 0 l = a l -= c while l > b + c: i += 1 l -= b + c print(int(i))
s531627313
Accepted
30
2,940
145
n = list(map(int, input().split())) a = n[0] b = n[1] c = n[2] i = 0 l = a l -= c while l >= (b + c): i += 1 l -= (b + c) print(i)
s168340311
p03048
u957198490
2,000
1,048,576
Wrong Answer
1,500
3,060
171
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
r,g,b,n = map(int,input().split()) ans = 0 for i in range(int(n/r)+1): for j in range(int((n-r*i)+1)): if (n-r*i-g*j) % b == 0: ans += 1 print(ans)
s919967048
Accepted
1,519
3,060
169
r,g,b,n = map(int,input().split()) ans = 0 for i in range((n//r)+1): for j in range(((n-r*i)//g)+1): if (n-r*i-g*j) % b == 0: ans += 1 print(ans)
s619351491
p02865
u505181116
2,000
1,048,576
Wrong Answer
17
2,940
73
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n%2 == 0: print(int(n/2)+1) else: print(int(n/2))
s059224910
Accepted
18
2,940
74
n = int(input()) if n%2 == 0: print(int(n/2)-1) else: print(int(n/2))
s577306745
p00002
u256256172
1,000
131,072
Wrong Answer
30
7,556
53
Write a program which computes the digit number of sum of two integers a and b.
a, b = map(int, input().split()) print(len(str(a+b)))
s821134407
Accepted
20
7,692
92
import sys for line in sys.stdin: a, b = map(int, line.split()) print(len(str(a+b)))
s676521825
p04043
u559126797
2,000
262,144
Wrong Answer
17
2,940
92
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
a=input().split() if a.count('5')==2 and a.count('7')==1: print("Yes") else: print("No")
s385485592
Accepted
17
2,940
92
a=input().split() if a.count('5')==2 and a.count('7')==1: print("YES") else: print("NO")
s742811731
p03853
u044952145
2,000
262,144
Wrong Answer
24
3,700
111
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
H, M = map(int, input().split()) C = [input() for _ in range(H)] for row in C: print(*row) print(*row)
s287380514
Accepted
17
3,060
109
H, M = map(int, input().split()) C = [input() for _ in range(H)] for row in C: print(row) print(row)
s390504330
p02409
u922112509
1,000
131,072
Wrong Answer
20
5,608
596
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
n = int(input()) houses = 4 floors = 3 rooms = 10 official = [[[0 for k in range(rooms)] for j in range(floors)] for i in range(houses)] print(official) for a in range(n): info = [int(x) for x in input().rstrip().split()] b = info[0] - 1 f = info[1] - 1 r = info[2] - 1 v = info[3] currentFloor = official[b][f] print(currentFloor) currentFloor[r] += v print(official) for i in range(houses): for j in range(floors): roomList = [str(official[i][j][k]) for k in range(rooms)] print(' '.join(roomList)) print('#' * 20)
s022698601
Accepted
20
5,624
634
n = int(input()) houses = 4 floors = 3 rooms = 10 official = [[[0 for k in range(rooms)] for j in range(floors)] for i in range(houses)] for a in range(n): info = [int(x) for x in input().rstrip().split()] b = info[0] - 1 f = info[1] - 1 r = info[2] - 1 v = info[3] currentFloor = official[b][f] # print(currentFloor) currentFloor[r] += v for i in range(houses): for j in range(floors): for k in range(rooms): print(' ' + str(official[i][j][k]), end = '') print() if i < houses - 1: print('#' * 20)
s636443318
p03380
u785578220
2,000
262,144
Wrong Answer
84
14,428
147
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
N= map(int, input().split()) x = list(map(int, input().split())) m = max(x) M = m/2 s = float("INF") for i in x: s = min(s,abs(M-i)) print(m,s)
s010831073
Accepted
61
13,660
234
a = int(input()) x = list(map(float, input().split())) m = max(x) M = m/2 t = 0 s = float("INF") for i in x: #print(s,abs(M-i),i,M) if s >= abs(M-i): s = min(s,abs(M-i)) t = i print(str(int(m))+" "+str(int(t)))
s963677712
p03673
u603234915
2,000
262,144
Wrong Answer
131
26,180
326
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
def split_and_change(N, Array): Arr1 = [a for ind, a in enumerate(Array) if ind % 2 == 0] Arr2 = [a for ind, a in enumerate(Array) if ind % 2 != 0] if N % 2 == 0: return Arr2[::-1] + Arr1 else: return Arr1[::-1] + Arr2 print(split_and_change(int(input()), list(map(int, input().split()))))
s554419299
Accepted
46
21,572
242
def split_and_change(N, Array): Arr1 = Array[0::2] Arr2 = Array[1::2] if N % 2 == 0: return Arr2[::-1] + Arr1 else: return Arr1[::-1] + Arr2 print(" ".join(split_and_change(int(input()), input().split())))
s982618161
p03456
u672866777
2,000
262,144
Wrong Answer
29
9,012
282
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.
# -*- coding: utf-8 -*- import math a, b = map(int, input().split()) connected_num = int(str(a) + str(b)) c = int(math.sqrt(connected_num)) print(connected_num) if connected_num == c*c: print("Yes") else: print("No")
s434939079
Accepted
31
8,960
261
# -*- coding: utf-8 -*- import math a, b = map(int, input().split()) connected_num = int(str(a) + str(b)) c = int(math.sqrt(connected_num)) if connected_num == c*c: print("Yes") else: print("No")
s924594991
p03563
u147808483
2,000
262,144
Wrong Answer
17
2,940
42
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.
a=int(input()) b=int(input()) print(a+b/2)
s649999670
Accepted
17
2,940
35
print(-int(input())+2*int(input()))
s518534137
p03050
u952022797
2,000
1,048,576
Wrong Answer
2,104
3,696
593
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
# -*- coding: utf-8 -*- import sys import math from bisect import bisect_left from bisect import bisect_right import collections import copy input = sys.stdin.readline def main(): #R, G, B, N = map(int, input().split(" ")) N = int(input()) if N <= 2: print(0) sys.exit() ansans = N - 1 if N < 8: print(ansans) sys.exit() flg = True if N % 2 != 0: flg = False ans = 0 for i in range(N+1): if i == 0: continue if N // i == N % i: print(i) ans += i print(ans) if __name__ == "__main__": main()
s642699248
Accepted
120
4,016
589
# -*- coding: utf-8 -*- import sys import copy import collections from bisect import bisect_left from bisect import bisect_right def main(): N = int(input()) tmp = make_divisors(N) ans = [] for i in tmp: a = i - 1 if a == 0: continue if N // a == N % a: ans.append(a) print(sum(ans)) def make_divisors(n): divisors = [] for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.append(i) if i != n // i: divisors.append(n//i) return divisors if __name__ == "__main__": main()
s418578742
p03544
u305018585
2,000
262,144
Wrong Answer
17
2,940
114
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)
n = int( input()) a = [2,1] + [0]*(86-1) print(len(a)) for i in range(2,87) : a[i] =a[i-1]+a[i-2] print(a[n])
s944971513
Accepted
17
2,940
100
n = int( input()) a = [2,1] + [0]*(86-1) for i in range(2,87) : a[i] =a[i-1]+a[i-2] print(a[n])
s672440184
p04043
u850582941
2,000
262,144
Wrong Answer
18
3,060
366
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
A,B,C = map(int, input("").split()) if A == 5: if B == 5: if C == 7: print("YES") elif B == 7: if C == 5: print("YES") else: print("NO") else: print("NO") if A == 7: if B == 5: if C == 5: print("YES") else: print("NO") else: print("NO")
s404119686
Accepted
17
2,940
103
x = list(map(int, input().split())) x.sort() if x == [5, 5, 7]: print("YES") else: print("NO")
s093733235
p03449
u503901534
2,000
262,144
Wrong Answer
19
3,064
304
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()) a111 = list(map(int,input().split())) a222 = list(map(int,input().split())) al = [] sums = 0 for i in range(n): p = i for j in range(p): sums = sums + a111[j] for k in range(p,n): sums = sums + a222[k] al.append(sums) sums = 0 print(max(al))
s151763305
Accepted
19
3,064
306
n = int(input()) a111 = list(map(int,input().split())) a222 = list(map(int,input().split())) al = [] sums = 0 for i in range(n): p = i for j in range(p+1): sums = sums + a111[j] for k in range(p,n): sums = sums + a222[k] al.append(sums) sums = 0 print(max(al))
s705028296
p02927
u723444827
2,000
1,048,576
Wrong Answer
35
3,724
250
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 for m in range(M+1): for d in range(D): d_1 = d % 10 d_10 = d // 10 print(m, d_10, d_1) if (d_10 >= 2 and d_1 >= 2 and m == d_10*d_1): count += 1 print(count)
s093516385
Accepted
19
2,940
224
M, D = map(int,input().split()) count = 0 for m in range(M+1): for d in range(D+1): d_1 = d % 10 d_10 = d // 10 if (d_10 >= 2 and d_1 >= 2 and m == d_10*d_1): count += 1 print(count)
s401489486
p00013
u777299405
1,000
131,072
Wrong Answer
20
7,368
129
This figure shows railway tracks for reshuffling cars. The rail tracks end in the bottom and the top-left rail track is used for the entrace and the top- right rail track is used for the exit. Ten cars, which have numbers from 1 to 10 respectively, use the rail tracks. We can simulate the movement (comings and goings) of the cars as follow: * An entry of a car is represented by its number. * An exit of a car is represented by 0 For example, a sequence 1 6 0 8 10 demonstrates that car 1 and car 6 enter to the rail tracks in this order, car 6 exits from the rail tracks, and then car 8 and car 10 enter. Write a program which simulates comings and goings of the cars which are represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print numbers of cars which exit from the rail tracks in order. At the first, there are no cars on the rail tracks. You can assume that 0 will not be given when there is no car on the rail tracks.
stack = [] while True: try: n = int(input) except: break stack.append(n) if n else print(stack.pop())
s623596758
Accepted
20
7,532
131
stack = [] while True: try: n = int(input()) except: break stack.append(n) if n else print(stack.pop())
s188972248
p02972
u595952233
2,000
1,048,576
Wrong Answer
2,104
16,036
253
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
n = int(input()) a = list(map(int, input().split())) b = [0]*n for i in list(range(n))[::-1]: b[i] = sum([a[j] for j in range(n) if j%(i+1)==0])%2 if sum(b) == 0: print(0) else: print(' '.join(map(str, [i+1 for i in range(n) if b[i]==1])))
s676735253
Accepted
487
18,868
312
n = int(input()) a = list(map(int, input().split())) ans = [0]*n count = 0 for i in range(n-1, -1, -1): c = sum([ans[j] for j in range(i, n, i+1)])%2 if c != a[i]: count+=1 ans[i] = 1 print(count) ans = [i+1 for i in range(n) if ans[i]==1] if count > 0: print(' '.join(map(str, ans)))
s312707919
p02398
u193025715
1,000
131,072
Wrong Answer
30
6,716
107
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
a, b, c = map(int, input().split()) ans = 0 for i in range(a, b+1): if i % c == 0: ans += 1 print(ans)
s655598095
Accepted
40
6,724
107
a, b, c = map(int, input().split()) ans = 0 for i in range(a, b+1): if c % i == 0: ans += 1 print(ans)
s411124365
p03359
u611090896
2,000
262,144
Wrong Answer
17
2,940
62
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
a,b = map(int,input().split()) print( (a-1) if a>b else (a+1))
s716507296
Accepted
17
2,940
57
a,b = map(int,input().split()) print( a-1 if a>b else a)
s689021425
p03644
u457901067
2,000
262,144
Wrong Answer
17
2,940
79
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) ans = 1 while N > 0: N = N // 2 ans = ans * 2 print(ans)
s252007070
Accepted
17
2,940
79
N = int(input()) ans = 1 while N > 1: N = N // 2 ans = ans * 2 print(ans)
s886173258
p00102
u672822075
1,000
131,072
Wrong Answer
40
6,720
287
Your task is to develop a tiny little part of spreadsheet software. Write a program which adds up columns and rows of given table as shown in the following figure:
while True: n=int(input()) if not n: break a=[list(map(int,input().split())) for _ in range(n)] t=[[0 for _ in range(n+1)] for _ in range(n+1)] for i in range(n): for j in range(n): t[i][j]=a[i][j] t[i][n]+=a[i][j] t[n][j]+=a[i][j] t[n][n]+=a[i][j] print(a) print(t)
s618356129
Accepted
30
6,720
333
while True: n=int(input()) if not n: break a=[list(map(int,input().split())) for _ in range(n)] t=[[0 for _ in range(n+1)] for _ in range(n+1)] for i in range(n): for j in range(n): t[i][j]=a[i][j] t[i][n]+=a[i][j] t[n][j]+=a[i][j] t[n][n]+=a[i][j] for i in range(n+1): print("".join(map("{0:>5}".format,t[i])))
s680222203
p03068
u021916304
2,000
1,048,576
Wrong Answer
17
3,064
312
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 `*`.
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) def ism():return map(str,input().split()) def isl():return list(map(str,input().split())) n = ii() s = list(input()) k = ii() for i in s: if i != s[k-1]: i = '*' print(''.join(s))
s129212502
Accepted
17
3,064
330
def ii():return int(input()) def iim():return map(int,input().split()) def iil():return list(map(int,input().split())) def ism():return map(str,input().split()) def isl():return list(map(str,input().split())) n = ii() s = list(input()) k = ii() for i in range(len(s)): if s[i] != s[k-1]: s[i] = '*' print(''.join(s))
s649513197
p03738
u123745130
2,000
262,144
Wrong Answer
17
2,940
77
You are given two positive integers A and B. Compare the magnitudes of these numbers.
a=int(input()) b=int(input()) print(["GREATER","LESS","EQUAL"][(a>b)+(a==b)])
s994007503
Accepted
17
2,940
78
i=input a=int(i()) b=int(i()) print(["GREATER","LESS","EQUAL"][(b>=a)+(a==b)])
s536906007
p03469
u604655161
2,000
262,144
Wrong Answer
17
2,940
138
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
def ABC_85_A(): S = input() S = list(S) S[3] = '4' S = ''.join(S) print(S) if __name__ == '__main__': ABC_85_A()
s715302322
Accepted
17
2,940
138
def ABC_85_A(): S = input() S = list(S) S[3] = '8' S = ''.join(S) print(S) if __name__ == '__main__': ABC_85_A()
s836050024
p03469
u197078193
2,000
262,144
Wrong Answer
17
2,940
31
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
S = input() print('2018'+S[5:])
s304559951
Accepted
17
2,940
31
S = input() print('2018'+S[4:])
s508464160
p03369
u658993896
2,000
262,144
Wrong Answer
17
2,940
72
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
ans = 0 for x in input(): if x == 'o': ans += 100 print(ans)
s185005113
Accepted
17
2,940
76
ans = 0 for x in input(): if x == 'o': ans += 100 print(700+ans)
s949734947
p03523
u178079174
2,000
262,144
Wrong Answer
19
3,060
131
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
S = input() if S.replace('A', '') == 'KIHBR' and S.count('AA') == 0 and S.count('KIH') == 1: print('Yes') else: print('No')
s915348639
Accepted
17
2,940
131
S = input() if S.replace('A', '') == 'KIHBR' and S.count('AA') == 0 and S.count('KIH') == 1: print('YES') else: print('NO')
s737013043
p03693
u691501673
2,000
262,144
Wrong Answer
18
2,940
119
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r, g, b = map(int, input().split()) sum = r * 100 + g * 10 + b if sum % 4 == 0: print("Yes") else: print("No")
s926053877
Accepted
18
2,940
119
r, g, b = map(int, input().split()) sum = r * 100 + g * 10 + b if sum % 4 == 0: print("YES") else: print("NO")
s606720419
p03693
u867826040
2,000
262,144
Wrong Answer
17
2,940
42
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
i = int("".join(input().split())) print(i)
s337020675
Accepted
18
2,940
82
i = int("".join(input().split())) if i%4 == 0: print("YES") else: print("NO")
s861681681
p00161
u221679506
1,000
131,072
Wrong Answer
110
9,132
326
秋の体育祭が行われます。種目は徒競走、ボール運び、障害物競走、リレーの4種目です。参加チームは n チームで、この4種目の合計タイムが最も小さいチームが「優勝」、次に小さいチームが「準優勝」、そして、最下位より2番目のチームを「ブービー賞」として表彰したいと思います。 各チームの成績を入力として、「優勝」、「準優勝」、「ブービー賞」のチームを出力するプログラムを作成してください。 ただし、チームにはそれぞれ 1 から n のチーム番号が割り当てられています。
while True: n = int(input()) if n==0:break d={} for i in range(n): c,q,w,e,r,t,y,u,o = input().split() d[c] = (int(q)+int(e)+int(t)+int(u))*60+int(w)+int(r)+int(y)+int(o) ans = sorted(d.items(), key=lambda x: x[1]) print(ans) for j in [0,1,-2]: a,b = ans[j] print(a)
s435269724
Accepted
110
8,964
311
while True: n = int(input()) if n==0:break d={} for i in range(n): c,q,w,e,r,t,y,u,o = input().split() d[c] = (int(q)+int(e)+int(t)+int(u))*60+int(w)+int(r)+int(y)+int(o) ans = sorted(d.items(), key=lambda x: x[1]) for j in [0,1,-2]: a,b = ans[j] print(a)
s271741872
p03696
u844789719
2,000
262,144
Wrong Answer
25
3,316
405
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
import re strorig = input() closeFirst = re.search('^\)*',strorig).group(0) openLast = re.search('\(*$',strorig).group(0) strModified = '(' * len(list(closeFirst)) + strorig + ')' * len(list(openLast)) nums = [-1 if i == '(' else 1 for i in list(strModified)] sumnums = sum(nums) if sumnums < 0: result = strModified + ')' * (-1 * sumnums) else: result = '(' * sumnums + strModified print(result)
s051857608
Accepted
23
3,060
360
n = int(input()) s = input() def insertRecursively(string): for i in range(0, len(string)): part = string[0:i + 1] if 2 * part.count(')') > len(part): return insertRecursively('(' + string) if 2 * string.count('(') > len(string): return insertRecursively(string + ')') return string print(insertRecursively(s))
s880966708
p03997
u378691508
2,000
262,144
Wrong Answer
26
8,940
61
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
s690480358
Accepted
25
8,964
66
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
s232747544
p03713
u315485238
2,000
262,144
Wrong Answer
18
3,064
339
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
H,W=list(map(int,input().split())) def score(_list): return max(_list)-min(_list) answer=H*W for i in range(W//3,W//3+2): a=score([H*i, (W-i)*(H//2), (W-i)*(H-H//2)]) answer=min(a,answer) for i in range(H//3,H//3+2): a=score([W*i, (H-i)*(W//2), (H-i)*(W-W//2)]) answer=min(a,answer) print(answer)
s854293185
Accepted
254
3,064
436
H,W=list(map(int,input().split())) def score(_list): return max(_list)-min(_list) answer=H*W for i in range(1,W//2+1): a=score([H*i, (W-i)*(H//2), (W-i)*(H-H//2)]) b=score([H*i, H*((W-i)//2), H*(W-i-(W-i)//2)]) answer=min(a,b,answer) for i in range(1,H//2+1): a=score([W*i, (H-i)*(W//2), (H-i)*(W-W//2)]) b=score([W*i, W*((H-i)//2), W*(H-i-(H-i)//2)]) answer=min(a,b,answer) print(answer)
s457138108
p03399
u333139319
2,000
262,144
Wrong Answer
17
2,940
63
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,b,c,d]=[input() for i in range(4)] print(min(a,b)+min(c,d))
s374824141
Accepted
17
2,940
68
[a,b,c,d]=[int(input()) for i in range(4)] print(min(a,b)+min(c,d))
s416428827
p03161
u655612181
2,000
1,048,576
Wrong Answer
2,105
14,108
636
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \ldots, i + K. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
# given an array of Heights, jump from 1 to N with at most K sized jump to N # each jump incurs abs(H[j] - H[i]) cost # minimize cost of jumps from 1 to N # def frog(H, k): K = [0] * k n = len(H) for i in range(n): cost = 0 for j in range(1, min(i, k)): icost = abs(H[i] - H[i - j]) + K[len(K) - 1 - j] cost = min(icost, cost) if cost != 0 else icost K.append(cost) return cost assert frog([40, 10, 20, 70, 80, 10, 20, 70, 80, 60], 4) == 40 assert frog([10, 10], 100) == 0 N, k = map(int, input().split()) H = list(map(int, input().split())) ans = frog(H, k) print(ans)
s925293214
Accepted
1,785
14,612
985
# given an array of Heights, jump from 1 to N with at most K sized jump to N # each jump incurs abs(H[j] - H[i]) cost # minimize cost of jumps from 1 to N # def frog(H, k): if k > len(H): k = len(H) n = len(H) K = [0] * n inf = float("inf") for i in range(n): cost = 0 if i > 0: maxjump = i if i < k else k # min(i, k) cost = inf hi = H[i] # jump source going backwards from i-1 (smallest 1 sized jump) to i - maxjumps for j in range(i - 1, i - maxjump - 1, -1): jcost = abs(hi - H[j]) + K[j] if jcost < cost: cost = jcost K[i] = cost return cost assert frog([40, 10, 20, 70, 80, 10, 20, 70, 80, 60], 4) == 40 assert frog([10, 10], 100) == 0 assert frog([10, 20, 10], 1) == 20 if __name__ == "__main__": import sys s = sys.stdin.read() N, k, *H = map(int, s.split()) ans = frog(H, k) print(ans)
s954023318
p03369
u419963262
2,000
262,144
Wrong Answer
17
2,940
64
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
S=input() ans=700 for i in S: if i==0: ans+=100 print(ans)
s834057266
Accepted
17
2,940
67
S=input() ans=700 for i in S: if i=="o": ans+=100 print(ans)
s950967432
p03606
u226108478
2,000
262,144
Wrong Answer
21
3,188
363
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
# -*- coding: utf-8 -*- if __name__ == '__main__': group_count = int(input()) seated_numbers = [list(map(int, input().split())) for _ in range(group_count)] print(seated_numbers) total_person = 0 for line in seated_numbers: total_person += max(line) - min(line) + 1 print(total_person)
s995194497
Accepted
30
3,828
364
# -*- coding: utf-8 -*- def main(): n = int(input()) seats = [0] * 100000 count = 0 for i in range(n): left, right = map(int, input().split()) for j in range(left - 1, right): seats[j] = 1 for seat in seats: if seat == 1: count += 1 print(count) if __name__ == '__main__': main()
s993528354
p02692
u223663729
2,000
1,048,576
Wrong Answer
164
18,064
730
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
N, a, b, c, *S = open(0).read().split() N, a, b, c = map(int, (N, a, b, c)) ans = [] for s in S: if s == 'AB': ans.append('B' if a > b else 'A') if a> b: a -=1 b += 1 else: a += 1 b -= 1 elif s == 'AC': ans.append('C' if a > c else 'A') if a> c: a -=1 c += 1 else: a += 1 c -= 1 elif s == 'BC': ans.append('C' if b > c else 'B') if b> c: b -=1 c += 1 else: b += 1 c -= 1 if a < 0 or b < 0 or c < 0: print('No') exit() print(a, b, c) print('Yes') [print(r) for r in ans]
s079992476
Accepted
108
17,908
1,747
N, a, b, c, *S = open(0).read().split() N, a, b, c = map(int, (N, a, b, c)) flg = a*b*c == 0 and a+b+c == 2 ans = [] for i, s in enumerate(S): if s == 'AB': if flg and a*b == 1 and i < N-1: s_ = S[i+1] if s_ == 'AC': ans.append('A') a += 1 b -= 1 continue elif s_ == 'BC': ans.append('B') a -= 1 b += 1 continue ans.append('B' if a > b else 'A') if a > b: a -= 1 b += 1 else: a += 1 b -= 1 elif s == 'AC': if flg and a*c == 1 and i < N-1: s_ = S[i+1] if s_ == 'AB': ans.append('A') a += 1 c -= 1 continue elif s_ == 'BC': ans.append('C') a -= 1 c += 1 continue ans.append('C' if a > c else 'A') if a > c: a -= 1 c += 1 else: a += 1 c -= 1 elif s == 'BC': if flg and b*c == 1 and i < N-1: s_ = S[i+1] if s_ == 'AB': ans.append('B') b += 1 c -= 1 continue elif s_ == 'AC': ans.append('C') b -= 1 c += 1 continue ans.append('C' if b > c else 'B') if b > c: b -= 1 c += 1 else: b += 1 c -= 1 if a < 0 or b < 0 or c < 0: print('No') exit() print('Yes') [print(r) for r in ans]
s148964823
p03679
u502028059
2,000
262,144
Wrong Answer
17
2,940
137
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
x, a, b = map(int, input().split()) ans = 'dangerous' if (b - a) < 0: ans = 'delicious' elif (b - a) < x: ans = 'safe ' print(ans)
s576396161
Accepted
17
2,940
137
x, a, b = map(int, input().split()) ans = 'dangerous' if (b - a) <= 0: ans = 'delicious' elif(b - a) <= x: ans = 'safe' print(ans)
s745433887
p02412
u801346721
1,000
131,072
Wrong Answer
20
7,544
220
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while 1: n, x = map(int, input().split()) if n == 0 and x == 0: break counter = 0 for a in range(1, n+1): for b in range(1, n-1): for c in range(1, n-2): if a+b+c == x: counter += 1 print(counter)
s205069079
Accepted
40
7,648
248
while 1: n, x = map(int, input().split()) counter = 0 if n == 0 and x == 0: break y = (x+3) // 3 for a in range(y, n+1): for b in range(2, a): if (x-a-b) > 0 and (x-a-b) < b: counter += 1 print(counter)
s687449586
p02399
u921810101
1,000
131,072
Wrong Answer
20
5,608
62
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a,b = [int(x) for x in input().split()] print(a//b, a%b, a/b)
s154225796
Accepted
20
5,612
65
a,b = map(int, input().split()) print(f"{a//b} {a%b} {a/b:.5f}")
s698381261
p00001
u342537066
1,000
131,072
Wrong Answer
20
7,520
264
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.
lis=[]; for i in range(10): h=int(input()); lis.append(h); for i in range(10): for j in range(10): if lis[i]<lis[j]: a=lis[i]; lis[i]=lis[j]; lis[j]=a; for i in range(3): print(lis[i]);
s800527807
Accepted
20
7,616
268
lis=[]; for i in range(10): h=int(input()); lis.append(h); for i in range(10): for j in range(i+1,10): if lis[i]<lis[j]: a=lis[i]; lis[i]=lis[j]; lis[j]=a; for i in range(3): print(lis[i]);
s760652493
p02646
u358943774
2,000
1,048,576
Wrong Answer
21
9,196
180
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
i=(input().split()) j=(input().split()) k=(input()) A=int(i[0]) V=int(i[1]) B=int(j[0]) W=int(j[1]) T=int(k) print(B) if (B-A)+W*T <= V*T: print("YES") else: print("NO")
s007905399
Accepted
23
9,192
193
i=(input().split()) j=(input().split()) k=(input()) A=int(i[0]) V=int(i[1]) B=int(j[0]) W=int(j[1]) T=int(k) if abs(B-A)+W*T <= V*T: print("YES") elif abs(B-A)+W*T > V*T: print("NO")
s844815634
p03557
u229660384
2,000
262,144
Time Limit Exceeded
2,105
24,052
729
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
N = int(input()) A = list(map(int, input().split())) #A = [int(x) for x in input().split()] B = list(map(int, input().split())) C = list(map(int, input().split())) A.sort() B.sort() C.sort() total = 0 for i in range(N): low = -1 high = N while low < high: mid1 = (low + high) // 2 if A[mid1] < B[i]: low = mid1 if A[mid1] >= B[i]: high = mid1 if high == low: break low = -1 high = N while low < high: mid2 = (low + high) // 2 if C[mid2] <= B[i]: low = mid2 if C[mid2] > B[i]: high = mid2 if high == low: break total = total + (mid1 + 1) * (N - mid2) print(total)
s648258651
Accepted
902
23,616
396
N = int(input()) A = sorted([int(i) for i in input().split()]) B = [int(i) for i in input().split()] C = sorted([int(i)-1 for i in input().split()]) def bis(x,y): low = 0 high = N while low < high: mid = (low + high) // 2 if x[mid] < y: low = mid + 1 else: high = mid return low total = 0 for b in B: total += bis(A,b) * (N - bis(C,b)) print(total)
s689010276
p02742
u639387008
2,000
1,048,576
Wrong Answer
17
2,940
106
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
a,b= list(map(int,input("\nEnter the numbers : ").strip().split())) x=a*b if(x%2!=0): x=x+1 print(x//2)
s182867736
Accepted
17
3,060
133
import sys a,b= list(map(int,input().strip().split())) x=a*b if(a==1 or b==1): print(1) sys.exit() if(x%2!=0): x=x+1 print(x//2)
s446604212
p03478
u335278042
2,000
262,144
Wrong Answer
48
3,444
216
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
N,A,B = map(int,input().split()) r = 0 for i in range(1,N+1): print(i) stri = str(i) tmp = 0 for j in stri: tmp += int(j) if tmp >= A and tmp <= B: print(i) r += i print(r)
s215132903
Accepted
32
2,940
186
N,A,B = map(int,input().split()) r = 0 for i in range(1,N+1): stri = str(i) tmp = 0 for j in stri: tmp += int(j) if tmp >= A and tmp <= B: r += i print(r)
s726841162
p03067
u924594299
2,000
1,048,576
Wrong Answer
17
2,940
222
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a, b, c = (int(i) for i in input().split()) if a < b: if a < c and c < b: print('YES') else: print('NO') elif a > b: if b < c and c < a: print('YES') else: print('NO')
s011337881
Accepted
17
2,940
221
a, b, c = (int(i) for i in input().split()) if a < b: if a < c and c < b: print('Yes') else: print('No') elif a > b: if b < c and c < a: print('Yes') else: print('No')
s262349880
p02868
u550061714
2,000
1,048,576
Wrong Answer
2,105
28,900
374
We have N points numbered 1 to N arranged in a line in this order. Takahashi decides to make an undirected graph, using these points as the vertices. In the beginning, the graph has no edge. Takahashi will do M operations to add edges in this graph. The i-th operation is as follows: * The operation uses integers L_i and R_i between 1 and N (inclusive), and a positive integer C_i. For every pair of integers (s, t) such that L_i \leq s < t \leq R_i, add an edge of length C_i between Vertex s and Vertex t. The integers L_1, ..., L_M, R_1, ..., R_M, C_1, ..., C_M are all given as input. Takahashi wants to solve the shortest path problem in the final graph obtained. Find the length of the shortest path from Vertex 1 to Vertex N in the final graph.
N, M = map(int, input().split()) lrc_list = [] for _ in range(M): lrc_list.append(tuple(map(int, input().split()))) lrc_list.sort() way = [float('inf')] * N way[0] = 0 print(lrc_list) for lrc in lrc_list: for i in range(lrc[0], lrc[1]): way[i] = min(way[i], way[lrc[0] - 1] + lrc[2]) if way[N - 1] != float('inf'): print(way[N - 1]) else: print(-1)
s957607502
Accepted
1,684
238,276
558
import sys from collections import defaultdict import networkx as nx input = sys.stdin.buffer.readline N, M = map(int, input().split()) LR_dict = defaultdict(lambda: 10 ** 9) for _ in range(M): l, r, c = map(int, input().split()) LR_dict[(l, r)] = min(LR_dict[(l, r)], c) G = nx.DiGraph() G.add_nodes_from(range(1, N + 1)) G.add_weighted_edges_from([(x + 1, x, 0) for x in range(1, N)]) G.add_weighted_edges_from((l, r, c) for (l, r), c in LR_dict.items()) try: print(nx.dijkstra_path_length(G, 1, N)) except nx.NetworkXNoPath: print(-1)
s666437312
p02399
u137212517
1,000
131,072
Wrong Answer
30
6,740
60
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a, b = map(int, input().split()) print(a // b, a / b, a % b)
s167712368
Accepted
30
6,740
78
a, b = map(int, input().split()) print(a //b , a % b, "{0:.5f}".format(a / b))
s990090876
p03609
u037221289
2,000
262,144
Wrong Answer
17
2,940
51
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
X,t = map(int,input().split(' ')) print(min(X-t,0))
s014924467
Accepted
17
2,940
52
X,t = map(int,input().split(' ')) print(max(X-t,0))
s584872047
p03997
u724742135
2,000
262,144
Wrong Answer
20
2,940
143
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.
from sys import stdin a = int(stdin.readline().rstrip()) b = int(stdin.readline().rstrip()) h = int(stdin.readline().rstrip()) print((a+b)*h/2)
s645866857
Accepted
18
2,940
148
from sys import stdin a = int(stdin.readline().rstrip()) b = int(stdin.readline().rstrip()) h = int(stdin.readline().rstrip()) print(int((a+b)*h/2))
s068302055
p03997
u191423660
2,000
262,144
Wrong Answer
17
2,940
89
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()) S = ((a + b) * h) / 2 print(str(S))
s571253685
Accepted
17
2,940
94
a = int(input()) b = int(input()) h = int(input()) S = ((a + b) * h) / 2 print(str(int(S)))
s222115503
p04029
u597455618
2,000
262,144
Wrong Answer
17
2,940
33
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 = int(input()) print(n*(n+1)/2)
s753053645
Accepted
17
2,940
34
n = int(input()) print(n*(n+1)//2)
s162925560
p00101
u585391547
1,000
131,072
Wrong Answer
30
6,720
174
An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Your task is to write a program which replace all the words "Hoshino" with "Hoshina". You can assume that the number of characters in a text is less than or equal to 1000.
n=int(input()) for i in range(n): inputs=list(map(str,input().split())) for j in inputs: if j=="Hoshino": print("Hoshina",end=" ") else: print(j,end=" ") print()
s658973679
Accepted
30
6,716
78
n=int(input()) for i in range(n): print(input().replace("Hoshino","Hoshina"))
s785554305
p02923
u658801777
2,000
1,048,576
Wrong Answer
61
11,128
509
There are N squares arranged in a row from left to right. The height of the i-th square from the left is H_i. You will land on a square of your choice, then repeat moving to the adjacent square **on the right** as long as the height of the next square is not greater than that of the current square. Find the maximum number of times you can move.
while True: try: N = int(input()) H = map(int, input().split()) result = 0 pre = None l = 0 for i in H: if pre is None: pre = i continue if i <= pre: l += 1 else: if l > result: result = l l = 0 pre = i if l > result: result = l print(result) except EOFError: break
s402409430
Accepted
60
11,136
505
while True: try: N = int(input()) H = map(int, input().split()) result = 0 pre = None l = 0 for i in H: if pre is None: pre = i continue if i <= pre: l += 1 else: if l > result: result = l l = 0 pre = i if l > result: result = l print(result) except EOFError: break
s881399825
p03944
u102960641
2,000
262,144
Wrong Answer
19
3,064
285
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
w,h,n = map(int, input().split()) xya = [list(map(int, input().split())) for i in range(n)] lx = 0 rx = w ly = 0 ry = h for x,y,a in xya: if a == 1: lx = x elif a == 2: rx = x elif a == 3: ly = y else: ry = y ans = w * h - max(0,rx-lx) * max(0,ry-ly) print(ans)
s481952059
Accepted
17
3,064
309
w,h,n = map(int, input().split()) xya = [list(map(int, input().split())) for i in range(n)] lx = 0 rx = w ly = 0 ry = h for x,y,a in xya: if a == 1: lx = max(lx,x) elif a == 2: rx = min(rx,x) elif a == 3: ly = max(ly,y) else: ry = min(ry,y) ans = max(0,rx-lx) * max(0,ry-ly) print(ans)
s238830803
p02795
u509150616
2,000
1,048,576
Wrong Answer
23
9,112
178
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
def solve(H, W, N): c = 0 b = 0 L = max(H, W) while b < N: b += L c += 1 return c H = int(input()) W = int(input()) N = int(input())
s687207283
Accepted
27
9,172
199
def solve(H, W, N): c = 0 b = 0 L = max(H, W) while b < N: b += L c += 1 return c H = int(input()) W = int(input()) N = int(input()) print(solve(H, W, N))
s047611308
p03493
u001687078
2,000
262,144
Wrong Answer
17
2,940
41
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
s = input() int(s[0])+int(s[1])+int(s[2])
s060821833
Accepted
17
2,940
48
s = input() print(int(s[0])+int(s[1])+int(s[2]))
s864621300
p02412
u335511832
1,000
131,072
Wrong Answer
30
6,724
272
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: (n,x) = [int(i) for i in input().split()] if n==x==0: break goukei = 0 for i in range(1,n): for j in range(1,n): for k in range(1,n): if i+j+k == x: goukei += 1 print(goukei)
s937255660
Accepted
2,940
7,620
283
while True: n,x = [int(i) for i in input().split()] if n==x==0:break count=0 for i in range(1,n+1): for j in range(1,n): for k in range(1,n-1): if i+j+k==x and i>j>k and not i==j==k: count += 1 print(count)
s580328245
p03719
u699296734
2,000
262,144
Wrong Answer
26
9,048
91
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = map(int, input().split()) if a <= c <= b: print("Yse") else: print("No")
s304723555
Accepted
29
8,860
91
a, b, c = map(int, input().split()) if a <= c <= b: print("Yes") else: print("No")
s613254428
p03339
u652150585
2,000
1,048,576
Wrong Answer
162
20,520
326
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.
import sys import string import collections input=sys.stdin.readline n=int(input()) s=list(input()) #print(s) snum=[0 if i=='W' else 1 for i in s] #print(snum) a=sum(snum) l=[10**6] for i in range(0,n): if snum[i]==1: a-=1 l.append(a) elif snum[i]==0: a+=1 l.append(a-1) print(min(l))
s089536018
Accepted
157
19,956
220
n=int(input()) s=list(input()) ls=[0 if i=='W' else 1 for i in s] a=sum(ls) #print(a) l=[0]*n for i in range(n): if ls[i]==1: a-=1 l[i]=a elif ls[i]==0: a+=1 l[i]=a-1 print(min(l))
s232918936
p04030
u733337827
2,000
262,144
Wrong Answer
17
2,940
73
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?
s = input() print(s.replace('0b', '').replace('1b', '').replace('b', ''))
s977849185
Accepted
17
2,940
110
s = input() ans = s while 'B' in ans: ans = ans.lstrip('B').replace('0B', '').replace('1B', '') print(ans)
s924320072
p03545
u169200126
2,000
262,144
Wrong Answer
17
3,064
693
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.
import math inp = int(input()) a = int(inp / 1000) b = int((inp % 1000)/100) c = int((inp % 100)/10) d = int((inp % 10)) ''' d = inp % 10 inp //= 10 c = inp % 10 inp //= 10 b = inp % 10 inp //= 10 a = inp % 10 inp //= 10 ''' pm = 8 total = a siki = "a" for i in range(8): total = a siki = "a" if(i & 1): total += b siki += "+b" elif((i&1) != 1): total -= b siki += "-b" if((i>>1) &1 ): total += c siki += "+c" else: total -= c siki += "-c" if((i>>2) &1): total += d siki += "+d" else: total -= d siki += "-d" if (total == 7): print(siki)
s114631346
Accepted
17
3,064
752
inp = int(input()) a = int(inp / 1000) b = int((inp % 1000)/100) c = int((inp % 100)/10) d = int((inp % 10)) ''' d = inp % 10 inp //= 10 c = inp % 10 inp //= 10 b = inp % 10 inp //= 10 a = inp % 10 inp //= 10 ''' pm = 8 total = a for i in range(8): total = a siki = str(a) if(i & 1): total += b siki += '+' +str(b) elif((i&1) != 1): total -= b siki += '-' +str(b) if((i>>1) &1 ): total += c siki += '+' +str(c) else: total -= c siki += '-' +str(c) if((i>>2) &1): total += d siki += '+' +str(d) else: total -= d siki += '-' +str(d) if (total == 7): siki += "=7" print(siki) quit()
s111189223
p03228
u693566873
2,000
1,048,576
Wrong Answer
17
2,940
177
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 = [int(s) for s in input().split(' ')] print(A, B, K) for i in range(K): if i % 2: B //= 2 A += B else: A //= 2 B += A print ('%d %d' % (A, B))
s500820547
Accepted
17
2,940
161
A, B, K = [int(s) for s in input().split(' ')] for i in range(K): if i % 2: B //= 2 A += B else: A //= 2 B += A print ('%d %d' % (A, B))
s399327671
p03139
u859897687
2,000
1,048,576
Wrong Answer
18
2,940
52
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
n,a,b=map(int,input().split()) print(min(a,b),a+b-n)
s016536042
Accepted
17
2,940
59
n,a,b=map(int,input().split()) print(min(a,b),max(0,a+b-n))
s465590260
p04043
u264564865
2,000
262,144
Wrong Answer
17
2,940
227
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
import sys input = lambda: sys.stdin.readline().rstrip() yes = lambda boolean: print('Yes') if boolean else print('No') input_ints = lambda: list(map(int, input().split())) numbers = sorted(input_ints()) yes(numbers == [5,5,7])
s902913675
Accepted
17
2,940
83
n=list(map(int, input().split())) print('YES')if sorted(n)==[5,5,7]else print('NO')
s128262413
p00446
u546285759
1,000
131,072
Wrong Answer
30
7,724
1,084
次のような2人で行うカードゲームがある. * このゲームでは, 1から2nまでの各整数が書かれた全部で2n枚のカードを使用する. ここで,nは1以上100以下の整数である. * このカードを2人にn枚ずつ配る. * 次のルールに従って交互にカードを1枚ずつ場に出す. * 場にカードが出ていないならば, 好きなカードを出すことができる. * 場にカードが出ているならば, 最後に場に出たカードよりも大きい数の書かれたカードを出すことができる. * カードが出せる場合は,必ず場にカードを出す必要がある. * 出せるカードが無い場合はパスとなり,相手の番になる. このとき,場に出ているカードは無くなる. * ゲームは場にカードが出ていない状態で始める. * どちらかの手持ちのカードが無くなった時点でゲームは終了する. * ゲーム終了時に相手の持っているカードの枚数を得点とする. 太郎と花子は,このゲームで対戦することになった.ゲームは太郎の番から始める. 2人は共に,出すことのできるカードのうち必ず一番小さい数が書かれたカードを出すことにしている. 太郎に配られるカードが入力されたとき,太郎と花子の得点を出力するプログラムを作成せよ.
import bisect while True: n = int(input()) if n == 0: break tc = sorted([int(input()) for _ in range(n)]) hc = sorted([v for v in range(1, 2*n+1) if v not in tc]) ba = [] flag = True while tc and hc: if len(ba) == 0: try: if flag: tmp = tc.pop(0) flag = False else: tmp = hc.pop(0) flag = True except IndexError: pass ba = [tmp] continue last_card = ba[-1] if flag: x = bisect.bisect_left(tc, last_card) flag = False try: tmp = tc.pop(x) except IndexError: ba = [] continue else: x = bisect.bisect_left(hc, last_card) flag = True try: tmp = hc.pop(x) except IndexError: ba = [] continue ba.append(tmp) print(len(tc)) print(len(hc))
s902707829
Accepted
30
7,760
835
import bisect while True: n = int(input()) if n == 0: break card_set = [sorted(int(input()) for _ in range(n)), []] card_set[1] = sorted({i for i in range(1, 2*n+1)}.difference(card_set[0])) card = turn = 0 flag = 1 ba = [] while flag: if len(ba) == 0: card = card_set[turn].pop(0) ba.append(card) flag = 0 if len(card_set[turn])==0 else 1 turn = 0 if turn else 1 continue last_card = ba[-1] x = bisect.bisect_left(card_set[turn], last_card) try: card = card_set[turn].pop(x) ba.append(card) except IndexError: ba = [] flag = 0 if len(card_set[turn])==0 else 1 turn = 0 if turn else 1 print(*[len(cet) for cet in card_set[::-1]], sep='\n')
s790027132
p02284
u007270338
2,000
131,072
Wrong Answer
30
5,636
1,455
Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node containing $k$. * print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.
#coding:utf-8 N = int(input()) trees = [list(input().split()) for i in range(N)] class BinaryTree: def __init__(self,key,p=None,l=None,r=None): self.key = key self.p = p self.l = l self.r = r def Insert(root,z): y = None x = root while x != None: y = x if z.key < x.key: x = x.l else: x = x.r z.p = y if y == None: root = z elif z.key < y.key: y.l = z else: y.r = z return root def preOrder(root): x = root if x == None: return global preList preList.append(x.key) preOrder(x.l) preOrder(x.r) def inOrder(root): x = root if x == None: return inOrder(x.l) global inList inList.append(x.key) inOrder(x.r) def Find(root,target): x = root if x == None: return if x.key == target: print("yes") return Find(x.l,target) Find(x.r,target) print("no") root = None for data in trees: if data[0] == "insert": z = BinaryTree(int(data[1])) root = Insert(root,z) if data[0] == "find": Find(root, data[1]) if data[0] == "print": inList = [] preList = [] inOrder(root) a = " ".join([str(num) for num in inList]) print(a) preOrder(root) a = " ".join([str(num) for num in preList]) print(a)
s507135205
Accepted
7,240
121,624
1,580
#coding:utf-8 class MakeTree(): def __init__(self, key, p=None, l=None, r=None): self.key = key self.p = p self.l = l self.r = r def Insert(root,value): y = None x = root z = MakeTree(value) while x != None: y = x if x.key > z.key: x = x.l else: x = x.r z.p = y if y == None: root = z elif z.key < y.key: y.l = z else: y.r = z return root def Find(u, target): y = None x = u while x != None and target != x.key: y = x if x.key > target: x = x.l else: x = x.r if x == None: print("no") else: print("yes") def inParse(u): if u == None: return inParse(u.l) global inParseList inParseList.append(u.key) inParse(u.r) def preParse(u): if u == None: return global preParseList preParseList.append(u.key) preParse(u.l) preParse(u.r) root = None n = int(input()) inParseList = [] preParseList = [] for i in range(n): order = list(input().split()) if order[0] == "insert": root = Insert(root, int(order[1])) elif order[0] == "print": inParse(root) preParse(root) print(" " + " ".join([str(i) for i in inParseList])) print(" " + " ".join([str(i) for i in preParseList])) preParseList = [] inParseList = [] elif order[0] == "find": Find(root, int(order[1]))
s542817975
p03795
u597017430
2,000
262,144
Wrong Answer
18
2,940
46
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 - 200 * N //15)
s804195386
Accepted
17
2,940
49
N = int(input()) print(N * 800 - 200 * (N //15))
s882422205
p03486
u940102677
2,000
262,144
Wrong Answer
17
2,940
103
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = list(input()) t = list(input()) s.sort() t.sort() print("Yes" if "".join(s) < "".join(t) else "No")
s684153284
Accepted
17
2,940
115
s = list(input()) t = list(input()) s.sort() t.sort() t.reverse() print("Yes" if "".join(s) < "".join(t) else "No")
s777105034
p02612
u551967750
2,000
1,048,576
Wrong Answer
32
9,008
30
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
s = int(input()) print(s%1000)
s358283644
Accepted
28
9,092
78
s = int(input()) if s%1000 == 0: c=0 else: c = 1000 - ( s%1000 ) print(c)
s479003506
p02389
u726789377
1,000
131,072
Wrong Answer
20
7,652
100
Write a program which calculates the area and perimeter of a given rectangle.
data = input().split() a = data[0] b = data[1] print (int(a) * int(b)) print (2 * (int(a) + int(b)))
s407443427
Accepted
20
5,588
93
data = input().split() a = data[0] b = data[1] print(int(a) * int(b), 2 * (int(a) + int(b)))
s212495299
p02402
u591403647
1,000
131,072
Wrong Answer
20
5,584
139
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
n = int(input()) # ns = list(map(int, input().split())) print(*ns[::-1])
s206265474
Accepted
30
6,580
90
n = int(input()) # ns = list(map(int, input().split())) print(min(ns),max(ns),sum(ns))
s504854560
p03369
u972658925
2,000
262,144
Wrong Answer
17
2,940
110
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
s = list(input()) count = 0 for i in range(len(s)): if i == "o": count += 1 print(700 + count*100)
s222955526
Accepted
17
2,940
98
s = list(input()) count = 0 for i in s: if i == "o": count += 1 print(700 + count*100)
s730198672
p03564
u667949809
2,000
262,144
Wrong Answer
17
2,940
121
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
n=int(input()) k=int(input()) a=1 for i in range(n): if a*2>a+k: a=a*2 else: a=a+k print(a)
s575925017
Accepted
18
2,940
114
n=int(input()) k=int(input()) a=1 for i in range(n): if a*2>a+k: a=a+k else: a=a*2 print(a)
s255069071
p02265
u657361950
1,000
131,072
Wrong Answer
20
5,612
1,797
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
import sys class Node: def __init__(self, value): self.value = value self.prev = None self.next = None class DoublyLinkedList: def __init__(self): self.head = None self.tail = None self.size = 0 def get_size(self): return self.size def is_empty(self): return self.size == 0 def appendToHead(self, value): node = Node(value) if self.head == None and self.tail == None: self.head = self.tail = node else: node.next = self.head self.head.prev = node self.head = node self.size += 1 def removeFirst(self): if self.is_empty(): return if self.size == 1: self.head = self.head = None else: self.head = self.head.next self.head.prev = None self.size -= 1 def removeLast(self): if self.is_empty(): return if self.size == 1: self.head = self.tail = None else: self.tail = self.tail.prev self.tail.next = None self.size -= 1 def remove(self, value): if self.is_empty(): return if self.head.value == value: self.removeFirst() else: node = self.head.next while node != None: if node.value == value: node.prev.next = node.next if node.next != None: node.next.prev = node.prev self.size -= 1 break else: node = node.next def print(self): node = self.head while node != None: sys.stdout.write(str(node.value)) node = node.next if node != None: sys.stdout.write(' ') n = int(input()) dll = DoublyLinkedList() for i in range(n): cmd = str(input()) if cmd == 'deleteFirst': dll.removeFirst() elif cmd == 'deleteLast': dll.removeLast() else: cmd, value = cmd.split() if cmd == 'insert': dll.appendToHead(int(value)) elif cmd == 'delete': dll.remove(int(value)) else: print('Unknown command:' + cmd) dll.print()
s110815613
Accepted
4,520
227,600
2,223
class Node(object): def __init__(self, num, prv = None, nxt = None): self.num = num self.prv = prv self.nxt = nxt class DoublyLinkedList(object): def __init__(self): self.start = self.last = None def insert(self, num): new_elem = Node(num) if self.start is None: self.start = self.last = new_elem else: new_elem.nxt = self.start self.start.prv = new_elem self.start = new_elem def delete_num(self, target): it = self.start while it is not None: if it.num == target: if it.prv is None and it.nxt is None: self.start = self.last = None else: if it.prv is not None: it.prv.nxt = it.nxt else: self.start = self.start.nxt if it.nxt is not None: it.nxt.prv = it.prv else: self.last = self.last.prv break it = it.nxt def delete_start(self): if self.start is self.last: self.start = self.last = None else: self.start.nxt.prv = None self.start = self.start.nxt def delete_last(self): if self.start is self.last: self.start = self.last = None else: self.last.prv.nxt = None self.last = self.last.prv def get_content(self): ret = [] it = self.start while it is not None: ret.append(it.num) it = it.nxt return ' '.join(ret) def _main(): from sys import stdin n = int(input()) lst = DoublyLinkedList() for _ in range(n): cmd = stdin.readline().strip().split() if cmd[0] == 'insert': lst.insert(cmd[1]) elif cmd[0] == 'delete': lst.delete_num(cmd[1]) elif cmd[0] == 'deleteFirst': lst.delete_start() elif cmd[0] == 'deleteLast': lst.delete_last() print(lst.get_content()) if __name__ == '__main__': _main()
s858453516
p03556
u492447501
2,000
262,144
Wrong Answer
17
2,940
30
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
print(int(int(input())**0.5))
s734024566
Accepted
17
3,060
38
print(int(int(int(input())**0.5)**2))
s989036681
p02257
u055885332
1,000
131,072
Wrong Answer
20
5,656
412
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.
import math def PrimeNum(a): x=math.sqrt(a) x=int(x) tmp=1 if a==1: tmp=0 elif a==2: tmp==1 elif a>3 and a<9: for i in range(2,a): st=a%i if st==0: tmp=0 break else: for i in range(2,x): st=a%i if st == 0: tmp=0 break #print("::::",a,x,st,tmp) return tmp n=int(input()) p=[] att=0 for i in range(n): p.append(int(input())) att+=PrimeNum(p[i]) print(att,p)
s481123471
Accepted
400
6,016
443
import math def PrimeNum(a): x=math.sqrt(a) x=int(x) tmp=1 if a==1: tmp=0 elif a==2: tmp==1 elif a>3 and a<9: for i in range(2,a): st=a%i if st==0: tmp=0 break else: for i in range(2,x+1): st=a%i if st == 0: tmp=0 break #print("::::",a,x,st,tmp) return tmp n=int(input()) p=[] att=0 for i in range(n): p.append(int(input())) att+=PrimeNum(p[i]) print(att)
s628578020
p04043
u484856305
2,000
262,144
Wrong Answer
17
3,064
96
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
abc=list(map(str,input().split())) if abc.count("7") ==2: print("YES") else: print("NO")
s085719462
Accepted
19
2,940
118
abc=list(map(str,input().split())) if abc.count("7") ==1 and abc.count("5")==2: print("YES") else: print("NO")
s674998225
p02603
u307516601
2,000
1,048,576
Time Limit Exceeded
2,206
9,200
386
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
import sys sys.setrecursionlimit(10**6) n = int(input()) A = list(map(int, input().split())) ans = 1000 def dfs(money, share, day): global ans if day > n: ans = max(ans, money) return max_buy = money//A[day-1] max_sel = share for n_buy in range(-max_sel, max_buy+1): dfs(money-n_buy*A[day-1], share+n_buy, day+1) dfs(1000,0,1) print(ans)
s161583724
Accepted
31
9,192
272
import sys sys.setrecursionlimit(10**6) n = int(input()) A = list(map(int, input().split())) CurrentMoney = 1000 for i in range(0, n-1): Stocks = 0 if A[i] < A[i+1]: Stocks = CurrentMoney // A[i] CurrentMoney += (A[i+1] - A[i]) * Stocks print(CurrentMoney)
s592847797
p03563
u010437136
2,000
262,144
Wrong Answer
18
2,940
286
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.
def solve(a,b): return b+(b-a) def readQuestion(): a = sys.stdin.readline().strip() b = sys.stdin.readline().strip() return (int(a),int(b)) def main(): a ,b = readQuestion() answer = solve(a ,b) print(answer) #if __name__ == '__main__': # main()
s077028226
Accepted
18
2,940
296
import sys def solve(a,b): return b+(b-a) def readQuestion(): a = sys.stdin.readline().strip() b = sys.stdin.readline().strip() return (int(a),int(b)) def main(): a ,b = readQuestion() answer = solve(a ,b) print(answer) if __name__ == '__main__': main()
s002022273
p03548
u191557685
2,000
262,144
Wrong Answer
57
3,824
328
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
import sys; lines = sys.stdin.readlines(); stdIn = {}; for i, line in enumerate(lines): chairSize,humanSize,spaceSize = map(int, line.split()); total = 0; maxSize = 0; while total*(spaceSize+humanSize) <= chairSize: print(maxSize); total = total+1; print (total-1);
s837305708
Accepted
35
3,060
332
import sys; lines = sys.stdin.readlines(); stdIn = {}; for i, line in enumerate(lines): chairSize,humanSize,spaceSize = map(int, line.split()); total = 0; maxSize = 0; while total*(humanSize)+(total-1)*(spaceSize)+spaceSize*2 <= chairSize: total = total+1; print (total-1);
s288354943
p03852
u086503932
2,000
262,144
Wrong Answer
17
3,064
400
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() l = ['maerd','remaerd', 'esare', 'resare'] def test(S,l): tmpS = S while len(tmpS) > 0: if tmpS[::-1] in l: print('YES') return if tmpS[-1:-6:-1] in l: tmpS = tmpS[:-5] elif tmpS[-1:-7:-1] in l: tmpS = tmpS[:-6] else: print('NO') return print('YES') return test(S,l)
s683970474
Accepted
17
2,940
73
print('vowel')if input() in ['a','e','i','o','u'] else print('consonant')
s932844605
p03854
u075595666
2,000
262,144
Wrong Answer
18
3,316
901
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
s = input() while True: S = s if len(S) < 5: print('No') break if S == 'dream' or S == 'erase': print('Yes') break else: if S[0] == 'd': if S[7] == 'a': T ='dream' if S[:5] == T: S = S[5:] T = "" if S == "": print('Yes') break s = S else: print('No') break else: T = 'dreamer' if S[:7] == T: S = S[7:] T = "" if S == "": print('Yes') break s = S else: print('No') break if S[0] == 'e': if len(S) >= 6 and S[5] == 'r': T = 'eraser' if S[:6] == T: S = S[6:] T = "" if S == "": print('Yes') break s = S else: print('No') break else: T = 'erase' if S[:5] == T: S = S[5:] T = "" if S == "": print('Yes') break s = S else: print('No') break else: print('No')
s470960692
Accepted
19
3,188
161
S=input() S=S.replace('eraser','') S=S.replace('erase','') S=S.replace('dreamer','') S=S.replace('dream','') if S=='': print('YES') else: print('NO')
s628749758
p03434
u814986259
2,000
262,144
Wrong Answer
17
3,060
171
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
N=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) alice=0 bob=0 for i in range(N): if i % 2==1: alice+=a[i] else: bob+=a[i] print(alice-bob)
s901389810
Accepted
18
3,060
171
N=int(input()) a=list(map(int,input().split())) a.sort(reverse=True) alice=0 bob=0 for i in range(N): if i % 2==0: alice+=a[i] else: bob+=a[i] print(alice-bob)
s750764385
p03495
u292810930
2,000
262,144
Wrong Answer
2,109
34,164
465
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
import numpy as np N, K = map(np.int, input().split()) alist = np.array(list(map(np.int, input().split()))) keys = np.sort(np.array(list(set(alist)))) values = np.zeros(len(keys)) for i in range(len(keys)): values[i] = np.sum(alist == keys[i]) balls = dict(zip(keys, values)) balls=dict(sorted(balls.items(), key=lambda x: x[1])) number = len(list(balls.keys())) - K if number <= 0: print(0) else: print(np.int(np.sum(list(balls.values())[:number])))
s220181074
Accepted
178
41,500
271
import collections N, K = map(int, input().split()) alist = collections.Counter(map(int, input().split())) number = max(0,len(alist) - K ) answer = 0 if number == 0: print(0) else: for a in alist.most_common()[-number:]: answer += a[1] print(answer)
s898465522
p04045
u597455618
2,000
262,144
Wrong Answer
151
9,104
432
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
def dfs(A: list): if len(A) > nn: return if len(A) and (x := int("".join(A))) >= n and ans[0] > x: ans[0] = x return for v in d: if v == "0" and len(A) == 0: next A.append(v) dfs(A) A.pop() n, k = map(int, input().split()) d = sorted(list(set([str(i) for i in range(10)]) - set(input().split()))) nn = len(str(n))+1 ans = [10**7] dfs([]) print(ans)
s833351283
Accepted
153
9,212
435
def dfs(A: list): if len(A) > nn: return if len(A) and (x := int("".join(A))) >= n and ans[0] > x: ans[0] = x return for v in d: if v == "0" and len(A) == 0: next A.append(v) dfs(A) A.pop() n, k = map(int, input().split()) d = sorted(list(set([str(i) for i in range(10)]) - set(input().split()))) nn = len(str(n))+1 ans = [10**7] dfs([]) print(ans[0])
s309921723
p03563
u156677492
2,000
262,144
Wrong Answer
19
2,940
106
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()) x = 1 for i in range(N): if x < K: x *= 2 else: x += K print(x)
s024534012
Accepted
17
2,940
47
R = int(input()) G = int(input()) print(2*G-R)
s471568115
p03853
u427344224
2,000
262,144
Wrong Answer
17
3,060
160
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
H, W = map(int, input().split()) c_list = [] for i in range(H): c = input().split() c_list.append(c) c_list.append(c) for c in c_list: print(c)
s792919077
Accepted
17
3,060
163
H, W = map(int, input().split()) c_list = [] for i in range(H): c = input().split() c_list.append(c) c_list.append(c) for c in c_list: print(c[0])
s639558395
p03565
u474270503
2,000
262,144
Wrong Answer
2,104
3,064
549
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
S0=input() S1=list(S0) T=list(input()) T1=['0']*len(T) is_break=0 for i in range(1 << len(T)): if is_break: break for j in range(len(T)): T1[j]='?' if i&(1<<j) else T[j] T2=''.join(T1) if S0.find(T2)+1: print(S0, T2) j=0 for i in range(S0.find(T2),S0.find(T2)+len(T)): S1[i]=T[j] j+=1 is_break=1 break if is_break==0: print("UNRESTORABLE") exit(0) print(S1) for i in range(len(S1)): if S1[i]=='?': S1[i]='a' S2=''.join(S1) print(S2)
s384306322
Accepted
18
3,064
493
S=list(input()) T=list(input()) A=[] for i in range(len(S)-len(T)+1): is_ok=1 for j in range(i, i+len(T)): if S[j]!=T[j-i] and S[j]!='?': is_ok=0 if is_ok: tmp=S[:] is_con=1 for j in range(i, i+len(T)): tmp[j]=T[j-i] A.append(tmp) if len(A)==0: print("UNRESTORABLE") exit(0) B=[] for a in A: for i in range(len(a)): if a[i]=='?': a[i]='a' B.append(''.join(a)) B.sort() print(B[0])
s802160303
p00003
u933096856
1,000
131,072
Wrong Answer
40
7,680
160
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
n=int(input()) for i in range(n): a,b,c=map(int, input().split()) if a > b+c and b > c+a and c > b+a: print('YES') else: print('NO')
s010781114
Accepted
40
7,568
170
n=int(input()) for i in range(n): a=list(map(int, input().split())) a.sort() if a[2]**2 == a[1]**2+a[0]**2: print('YES') else: print('NO')
s389625937
p03377
u996672406
2,000
262,144
Wrong Answer
18
2,940
101
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
l = input().split() if l[0] <= l[2] and l[2] <= (l[0] + l[1]): print("YES") else: print("NO")
s157415525
Accepted
17
2,940
113
l = input().split() if int(l[0]) <= int(l[2]) <= (int(l[0]) + int(l[1])): print("YES") else: print("NO")
s708659840
p03433
u170183831
2,000
262,144
Wrong Answer
17
2,940
72
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
n = int(input()) a = int(input()) print('Yes' if n % 500 >= a else 'No')
s905152469
Accepted
17
2,940
73
n = int(input()) a = int(input()) print('Yes' if n % 500 <= a else 'No')
s458610589
p03697
u694422786
2,000
262,144
Wrong Answer
17
2,940
63
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
a,b=map(int,input().split()) print('a+b'if a+b<10 else 'error')
s847928722
Accepted
17
2,940
62
a,b=map(int,input().split()) print(a+b if a+b<10 else 'error')
s599669302
p03861
u200887663
2,000
262,144
Wrong Answer
18
2,940
163
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()) count=0 div=a//x md=a % x mn=a+(x-md) count=(b-mn+1)//x amari=(b-mn+1) % x if amari==0 : print(count) else : print(count+1)
s597224885
Accepted
18
2,940
124
a,b,x=map(int,input().split()) def fn(n,x) : if n<0 : return 0 else : return n//x +1 print(fn(b,x)-fn(a-1,x))