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
s851650423
p03160
u479638406
2,000
1,048,576
Wrong Answer
123
13,980
174
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 Stone i + 1 or Stone i + 2. 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.
n = int(input()) h = list(map(int, input().split())) dp = [0]*(n+1) for i in range(n): dp[i+1] = min(dp[i] + abs(h[i]-h[i-1]), dp[i-1] + abs(h[i]-h[i-2])) print(dp[-1])
s278483940
Accepted
125
13,928
196
n = int(input()) h = list(map(int, input().split())) dp = [0]*n dp[1] = abs(h[1]-h[0]) for i in range(2, n): dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2] + abs(h[i]-h[i-2])) print(dp[-1])
s911236031
p03997
u993435350
2,000
262,144
Wrong Answer
17
2,940
74
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)
s276407021
Accepted
19
3,060
75
a = int(input()) b = int(input()) h = int(input()) print((a + b) * h // 2)
s400816705
p03457
u076543276
2,000
262,144
Wrong Answer
436
12,516
654
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.
t = [] x = [] y = [] N = int(input()) s = [] for i in range(N): t1, x1, y1 = [int(i) for i in input().split()] t.append(t1) x.append(x1) y.append(y1) for i in range(N): if t[i] < x[i] + y[i]: s.append(0) else: if (t[i] % 2 == 1 and x[i] % 2 == 0 and y[i] % 2 == 0) or (t[i] % 2 == 1 and x[i] % 2 == 1 and y[i] % 2 == 1): s.append(0) elif (t[i] % 2 == 0 and x[i] % 2 == 1 and y[i] % 2 == 0) or (t[i] % 2 == 1 and x[i] % 2 == 0 and y[i] % 2 == 1): s.append(0) else: s.append(1) for i in s: if i == 0: print("NO") break else: print("YES")
s902745472
Accepted
486
12,560
780
t = [] x = [] y = [] N = int(input()) s = [] for i in range(N): t1, x1, y1 = [int(i) for i in input().split()] t.append(t1) x.append(x1) y.append(y1) for i in range(N): if i == 0 and t[i] < abs(x[i]) + abs(y[i]): s.append(0) elif i > 0 and t[i] - t[i - 1] < abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]): s.append(0) else: if (t[i] % 2 == 1 and x[i] % 2 == 0 and y[i] % 2 == 0) or (t[i] % 2 == 1 and x[i] % 2 == 1 and y[i] % 2 == 1): s.append(0) elif (t[i] % 2 == 0 and x[i] % 2 == 1 and y[i] % 2 == 0) or (t[i] % 2 == 0 and x[i] % 2 == 0 and y[i] % 2 == 1): s.append(0) else: s.append(1) for i in s: if i == 0: print("No") break else: print("Yes")
s702226369
p02694
u406767170
2,000
1,048,576
Wrong Answer
22
9,164
98
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
X = int(input()) M = 100 for i in range(10): M = int(M*1.01) print(str(i) + ":" + str(M))
s060496403
Accepted
23
9,156
115
X = int(input()) M = 100 year = 0 while 1==1: year += 1 M = int(M*1.01) if M >= X: break print(year)
s738220740
p03478
u574189773
2,000
262,144
Wrong Answer
36
3,416
250
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()) some_sum = 0 for num in range(n+1): tmp_num = num sum_num = 0 while tmp_num > 0: sum_num += tmp_num % 10 tmp_num //= 10 if a <= sum_num and sum_num <= b: some_sum += num print(num) print(some_sum)
s515150276
Accepted
28
3,060
251
n, a, b = map(int, input().split()) some_sum = 0 for num in range(n+1): tmp_num = num sum_num = 0 while tmp_num > 0: sum_num += tmp_num % 10 tmp_num //= 10 if a <= sum_num and sum_num <= b: some_sum += num #print(num) print(some_sum)
s420878533
p03228
u010437136
2,000
1,048,576
Wrong Answer
18
3,064
479
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.
import sys def solve(A,B,K): ab = [A,B] for i in range(K): if ab[0]%2!=0: ab[0]-=1 ab[1]+=ab[0]//2 ab[0]-=ab[0]//2 ab.reverse() if K%2!=0: return ab[1],ab[0] return ab[0],ab[1] def readQuestion(): ws = sys.stdin.readline().strip().split() A = int(ws[0]) B = int(ws[1]) C = int(ws[2]) return (A, B, C) def main(): print(solve(*readQuestion())) # Uncomment before submission # main()
s063397723
Accepted
17
3,192
489
import sys def solve(A,B,K): ab = [A,B] for i in range(K): if ab[0]%2!=0: ab[0]-=1 ab[1]+=ab[0]//2 ab[0]-=ab[0]//2 ab.reverse() if K%2!=0: print(ab[1],ab[0]) return print(ab[0],ab[1]) def readQuestion(): ws = sys.stdin.readline().strip().split() A = int(ws[0]) B = int(ws[1]) C = int(ws[2]) return (A, B, C) def main(): solve(*readQuestion()) # Uncomment before submission main()
s318552676
p03737
u779728630
2,000
262,144
Wrong Answer
17
2,940
53
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a, b, c = input().split() print( a[0] + b[0] + c[0] )
s543797883
Accepted
17
2,940
64
a, b, c = input().split() print( (a[0] + b[0] + c[0]).upper() )
s968976056
p03860
u636775911
2,000
262,144
Wrong Answer
17
2,940
47
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.
#coding:utf-8 s=input() s="A"+s[0]+"C" print(s)
s569921749
Accepted
17
2,940
58
#coding:utf-8 s=input().split() s="A"+s[1][0]+"C" print(s)
s298183163
p03162
u680851063
2,000
1,048,576
Wrong Answer
989
57,480
332
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
n = int(input()) l = [list(map(int, input().split())) for _ in range(n)] dp = [[0,0,0] for _ in range(n)] dp[0][0], dp[0][1], dp[0][2] = l[0][0], l[0][1], l[0][2] for i in range(1, n): for j in range(3): for k in range(3): if j != k: dp[i][k] = max(dp[i][k], dp[i-1][j] + l[i][k]) print(dp)
s965042533
Accepted
926
47,344
298
n = int(input()) l = [list(map(int, input().split())) for _ in range(n)] dp = [[0,0,0] for _ in range(n)] dp[0] = l[0] for i in range(1, n): for j in range(3): for k in range(3): if j != k: dp[i][j] = max(dp[i][j], dp[i-1][k] + l[i][j]) print(max(dp[-1]))
s890409728
p02748
u821265215
2,000
1,048,576
Wrong Answer
17
3,064
265
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
s = input() s_len = len(s) if s_len % 2: print("No") else: prev = 0 count = 0 for i in range(1, (s_len//2)+1): if s[prev:i*2] != "hi": print("No") break else: count += 1 prev = i * 2 if count == s_len // 2: print("Yes")
s709139465
Accepted
464
58,984
574
a, b, m = input().split() a, b, m = int(a), int(b), int(m) a_values = input().split() b_values = input().split() m_values = {} for i in range(m): m_values[i] = input().split() min_num = int(a_values[int(m_values[0][0]) - 1]) + int(b_values[int(m_values[0][1]) - 1]) - int(m_values[0][2]) for i in range(1, m): now = int(a_values[int(m_values[i][0]) - 1]) + int(b_values[int(m_values[i][1]) - 1]) - int(m_values[i][2]) if min_num > now: min_num = now now = int(min(a_values)) + int(min(b_values)) if min_num > now: print(now) else: print(min_num)
s606113618
p02578
u440608859
2,000
1,048,576
Wrong Answer
221
32,224
330
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
for _ in range(1): n=int(input()) a=list(map(int,input().split())) k=a[0] ans=0 for i in range(n): if i==0: m=a[i] a[i]=0 else: m=max(m,a[i]) a[i]=m-a[i] u=0 for i in range(n): ans+=max(0,a[i]-u) u=a[i] print(ans)
s370094785
Accepted
120
32,224
208
n=int(input()) a=list(map(int,input().split())) m=0 ans=0 for i in range(n): if i==0: m=max(a[i],m) else: if a[i]<m: ans+=m-a[i] else: m=a[i] print(ans)
s952976249
p03478
u168660441
2,000
262,144
Wrong Answer
33
3,060
194
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).
a = input().split() ans = 0 for i in range(int(a[0])+1): i=str(i) i.split() sum_num=0 for j in i: sum_num=int(j) if j>=a[1] and j<=a[2]: ans += 1 print(ans)
s723279800
Accepted
39
3,060
222
a = input().split() ans = 0 for i in range(int(a[0])+1): i=str(i) i.split() sum_num=0 for j in i: sum_num+=int(j) if sum_num>=int(a[1]) and sum_num<=int(a[2]): ans += int(i) print(ans)
s657346479
p02407
u264632995
1,000
131,072
Wrong Answer
20
7,352
68
Write a program which reads a sequence and prints it in the reverse order.
input() a = input().split() print(a) a.reverse() print(" ".join(a))
s454484594
Accepted
20
7,440
58
input() a = input().split() a.reverse() print(" ".join(a))
s398158866
p02927
u115110170
2,000
1,048,576
Wrong Answer
18
2,940
152
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()) ans = 0 for i in range(2,m+1): for i in range(22,d+1): if m == ((d//10) * (d%10)): ans += 1 print(ans)
s403740043
Accepted
18
2,940
185
m,d = map(int,input().split()) ans = 0 for i in range(2,m+1): for j in range(22,d+1): if j%10 <= 1: continue if i == ((j//10) * (j%10)): ans += 1 print(ans)
s018330502
p03494
u494811189
2,000
262,144
Wrong Answer
17
3,060
138
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n=int(input()) a = list(map(int, input().split())) count =0 for k in range(n): if a[k]%2==0: count += 1 else: print(count)
s241158217
Accepted
18
3,060
220
n=int(input()) a = list(map(int, input().split())) count =0 flag = "true" while flag=="true": for k in range(n): if a[k]%2==0: a[k] //= 2 else: flag = "false" break count += 1 print(count-1)
s596875020
p00019
u567380442
1,000
131,072
Wrong Answer
30
6,724
64
Write a program which reads an integer n and prints the factorial of n. You can assume that n ≤ 20\.
ret = 1 for i in range(2, int(input())): ret *= i print(ret)
s287758963
Accepted
30
6,716
68
ret = 1 for i in range(2, int(input()) + 1): ret *= i print(ret)
s283397806
p03380
u480138356
2,000
262,144
Wrong Answer
62
14,040
425
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.
import sys input = sys.stdin.readline def main(): N = int(input()) a = list(map(int, input().split())) ans1 = max(a) half = ans1 // 2 min_ = abs(a[0] - half) ans2 = a[0] for i in range(1, N): if a[i] != ans1: tmp = abs(a[i] - half) if tmp <= min_: ans2 = a[i] min_ = tmp print(ans1, ans2) if __name__ == "__main__": main()
s373210376
Accepted
63
14,432
424
import sys input = sys.stdin.readline def main(): N = int(input()) a = list(map(int, input().split())) ans1 = max(a) half = ans1 / 2 min_ = abs(a[0] - half) ans2 = a[0] for i in range(1, N): if a[i] != ans1: tmp = abs(a[i] - half) if tmp <= min_: ans2 = a[i] min_ = tmp print(ans1, ans2) if __name__ == "__main__": main()
s202930881
p02390
u175111751
1,000
131,072
Wrong Answer
30
7,496
55
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
s = int(input()) print(s // 3600, s // 60 % 60, s % 60)
s568552941
Accepted
30
7,652
77
s = int(input()) print('{0}:{1}:{2}'.format(s // 3600, s // 60 % 60, s % 60))
s991152455
p03370
u288786530
2,000
262,144
Wrong Answer
193
3,060
170
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
n, x = map(int, input().split()) m = [int(input()) for _ in range(n)] for i in m: x -= i s = 0 while x >= 0: x -= min(m) s += 1 ans = len(m) + s print(ans)
s776471397
Accepted
195
3,060
174
n, x = map(int, input().split()) m = [int(input()) for _ in range(n)] for i in m: x -= i s = 0 while x >= 0: x -= min(m) s += 1 ans = len(m) + s - 1 print(ans)
s012134583
p03729
u494748969
2,000
262,144
Wrong Answer
18
2,940
117
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
a, b, c = list(map(str, input().split())) if a[-1] == b[0] and b[-1] == c[0]: print("Yes") else: print("No")
s624451773
Accepted
17
2,940
117
a, b, c = list(map(str, input().split())) if a[-1] == b[0] and b[-1] == c[0]: print("YES") else: print("NO")
s005153832
p03524
u252828980
2,000
262,144
Wrong Answer
30
9,080
136
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
s = input() A = s.count("a") B = s.count("b") C = s.count("c") if max(A,B,C) - min(A,B,C) <= 1: print("Yes") else: print("No")
s966915302
Accepted
28
9,208
136
s = input() A = s.count("a") B = s.count("b") C = s.count("c") if max(A,B,C) - min(A,B,C) <= 1: print("YES") else: print("NO")
s225425127
p03485
u127856129
2,000
262,144
Wrong Answer
17
2,940
88
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
a,b=map(int,input().split()) c=a+b if c%2==0: print(c/2) else: print(int(c/2+1))
s868179061
Accepted
17
2,940
46
a,b=map(int,input().split()) print((a+b+1)//2)
s721220324
p03836
u253011685
2,000
262,144
Wrong Answer
30
9,208
144
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx,sy,tx,ty=map(int,input().split()) x=tx-sx y=ty-sy path="R"*x+"U"*(y+1)+"L"*x+"D"*(y+2)+"R"*(x+1)+"U"*(y+1)+"L"*(x+2)+"D"*y+"R"; print(path)
s053112693
Accepted
27
9,072
150
sx,sy,tx,ty=map(int,input().split()) x=tx-sx y=ty-sy path="U"*y+"R"*x+"D"*y+"L"*(x+1)+"U"*(y+1)+"R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U" print(path)
s186530793
p03476
u107639613
2,000
262,144
Time Limit Exceeded
2,206
11,944
1,402
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def get_sieve_of_eratosthenes(n): if not isinstance(n, int): raise TypeError('n is int type.') if n < 2: return [] prime = [2] limit = int(n**0.5) data = [i + 1 for i in range(2, n, 2)] while True: p = data[0] if limit < p: return prime + data prime.append(p) data = [e for e in data if e % p != 0] def main(): primes = get_sieve_of_eratosthenes(100000) like = [0] * 10**5 for i in range(3, 10**5): if i in primes and (i + 1) // 2 in primes: like[i] = 1 like = list(accumulate(like)) q = int(input()) for _ in range(q): l, r = map(int, input().split()) if l < 3: l = 3 if r < 3: print(0) continue print(like[r] - like[l - 1]) if __name__ == "__main__": main()
s500913963
Accepted
162
13,712
1,365
import sys from itertools import accumulate def input(): return sys.stdin.readline().strip() def get_sieve_of_eratosthenes(n): if not isinstance(n, int): raise TypeError('n is int type.') if n < 2: return [] prime = [1] * (n + 1) prime[0] = prime[1] = 0 for i in range(2, int(n**0.5) + 1): if not prime[i]: continue for j in range(i * 2, n + 1, i): prime[j] = 0 return prime def main(): primes = get_sieve_of_eratosthenes(100000) like = [0] * 10**5 for i in range(3, 10**5): if primes[i] and primes[(i + 1) // 2]: like[i] = 1 like = list(accumulate(like)) q = int(input()) for _ in range(q): l, r = map(int, input().split()) if l < 3: l = 3 if r < 3: print(0) continue print(like[r] - like[l - 1]) if __name__ == "__main__": main()
s481977084
p03433
u979078704
2,000
262,144
Wrong Answer
17
2,940
89
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()) if N % 500 <= A: print("YES") else: print("NO")
s384446163
Accepted
17
2,940
89
N = int(input()) A = int(input()) if N % 500 <= A: print("Yes") else: print("No")
s007745054
p03545
u733608212
2,000
262,144
Wrong Answer
18
3,064
363
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.
s = input() li = [i for i in s] global ans def cal(left, count, remaining): global ans if len(remaining) > 0: cal(left + "+" + remaining[0], count + int(remaining[0]), remaining[1:]) cal(left + "-" + remaining[0], count - int(remaining[0]), remaining[1:]) elif count == 7: ans = left cal(li[0], int(li[0]), li[1:]) print(ans)
s905581509
Accepted
17
3,064
367
s = input() li = [i for i in s] global ans def cal(left, count, remaining): global ans if len(remaining) > 0: cal(left + "+" + remaining[0], count + int(remaining[0]), remaining[1:]) cal(left + "-" + remaining[0], count - int(remaining[0]), remaining[1:]) elif count == 7: ans = left cal(li[0], int(li[0]), li[1:]) print(ans+"=7")
s572018318
p03557
u557494880
2,000
262,144
Wrong Answer
326
23,328
322
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())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() import bisect ans = 0 for i in range(N): b = B[i] x = bisect.bisect_left(A,b) y = bisect.bisect_right(C,b) if y == 0: break ans += x*y print(ans)
s984388278
Accepted
342
23,248
297
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() import bisect ans = 0 for i in range(N): b = B[i] x = bisect.bisect_left(A,b) y = N - bisect.bisect_right(C,b) ans += x*y print(ans)
s000745232
p03351
u668503853
2,000
1,048,576
Wrong Answer
17
2,940
125
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int,input().split()) if a+c >d: if a+b <= d and b+c <= d: print("Yes") else:print("No") else:print("Yes")
s849942812
Accepted
17
2,940
137
a,b,c,d=map(int,input().split()) if abs(a-c) >d: if abs(a-b) <= d and abs(b-c) <= d:print("Yes") else:print("No") else:print("Yes")
s314191165
p02659
u824237520
2,000
1,048,576
Wrong Answer
21
9,068
67
Compute A \times B, truncate its fractional part, and print the result as an integer.
a, b = input().split() b, c = b.split('.') print(int(a) * int(b))
s526938878
Accepted
25
9,148
71
a, b = map(int, input().replace('.', '').split()) print(a * b // 100)
s165354447
p02690
u713165870
2,000
1,048,576
Wrong Answer
27
9,032
246
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
if __name__ == "__main__": x = int(input()) is_get = False for a in range(1000000000): if is_get: break for b in range(-1*a, a, 1): if x == a**5 - b**5: is_get = True break print(f"{a} {b}")
s721543723
Accepted
25
9,184
282
def get_answer(): x = int(input()) is_get = False for a in range(1000000000): if is_get: break for b in range(-1*a, a, 1): if x == a**5 - b**5: is_get = True break print(f"{a-1} {b}") if __name__ == "__main__": get_answer()
s441131577
p03626
u846372029
2,000
262,144
Wrong Answer
17
3,060
276
We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors. Find the number of such ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner: * Each domino is represented by a different English letter (lowercase or uppercase). * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.
# Coloring Dominoes N = int(input()) s1 = input() s2 = input() c = 3 for i in range(N-1): if (s1[i]==s2[i]): if (s1[i+1]==s2[i+1]): c*=2 else: if (s1[i]!=s1[i+1]): if (s1[i+1]!=s2[i+1]): c*=3 print(c%1000000007)
s645327863
Accepted
17
3,060
282
# Coloring Dominoes N = int(input()) s1 = input() s2 = input() if (s1[0]==s2[0]): c = 3 else: c = 6 for i in range(N-1): if (s1[i]==s2[i]): c*=2 else: if (s1[i]!=s1[i+1]): if (s1[i+1]!=s2[i+1]): c*=3 print(c%1000000007)
s482659321
p03351
u802977614
2,000
1,048,576
Wrong Answer
28
2,940
98
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int,input().split()) if a+c<d or (a+b<d and b+c<d): print("Yes") else: print("No")
s017031666
Accepted
18
2,940
116
a,b,c,d=map(int,input().split()) if abs(c-a)<=d or (abs(a-b)<=d and abs(b-c)<=d): print("Yes") else: print("No")
s588811097
p03623
u600261652
2,000
262,144
Wrong Answer
17
2,940
66
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x, a, b = map(int, input().split()) print(min(abs(x-a), abs(x-b)))
s530412897
Accepted
17
3,060
78
x, a, b = map(int, input().split()) print("A" if abs(x-a) < abs(x-b) else "B")
s336621887
p02612
u517630860
2,000
1,048,576
Wrong Answer
29
9,156
25
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
print(int(input())%1000)
s658301205
Accepted
33
9,184
84
N = int(input()) if N == 0 or N%1000 == 0: print('0') else: print(1000 - N%1000)
s508782745
p03448
u505420467
2,000
262,144
Wrong Answer
52
3,060
211
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if a*500+j*100+k*50==x: ans+=1 print(ans)
s682455555
Accepted
51
3,060
211
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if i*500+j*100+k*50==x: ans+=1 print(ans)
s494034862
p04029
u792512290
2,000
262,144
Wrong Answer
17
2,940
39
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((1 + n) * n / 2)
s091605875
Accepted
17
2,940
40
n = int(input()) print((1 + n) * n // 2)
s154412315
p03351
u485305016
2,000
1,048,576
Wrong Answer
18
2,940
92
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print("YES") else: print("NO")
s710919126
Accepted
17
2,940
146
a,b,c,d = map(int,input().split()) if abs(c-a)<=d: print("Yes") elif abs(a-b)<=d and abs(b-c)<=d: print("Yes") else: print("No")
s841879790
p03048
u075628913
2,000
1,048,576
Wrong Answer
2,104
3,060
243
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()) count = 0 for ri in range(0, n+1, r): for gi in range(0, n+1, g): for bi in range(0, n+1, b): if ri + gi + bi == n: count += 1 elif ri + gi + bi < n: break print(count)
s085946437
Accepted
1,614
2,940
192
R, G, B, N = map(int, input().split()) count = 0 for r in range(0, N+1, R): for g in range(0, N+1-r, G): val = (N - r - g) if val % B == 0 and val >= 0: count += 1 print(count)
s989086758
p03129
u858428199
2,000
1,048,576
Wrong Answer
17
2,940
106
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
n,k=map(int, input().split()) a = n // 2 a += n % 2 print(a) if a >= k: print("YES") else: print("NO")
s145604838
Accepted
17
2,940
97
n,k=map(int, input().split()) a = n // 2 a += n % 2 if a >= k: print("YES") else: print("NO")
s987429303
p03387
u757117214
2,000
262,144
Wrong Answer
18
3,064
303
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
lst = list(map(int,input().split())) lst2 = list(map(lambda x: max(lst) - x, lst)) if lst2[0] % 2 == 0 and lst2[1] % 2 == 0: print(sum(lst2) // 2) elif lst2[0] % 2 != 0 and lst2[1] % 2 != 0: _sum = (lst2[0] - 1) + (lst2[1] - 1) print(_sum // 2 + 1) else: print((sum(lst2) + 1) // 2 + 1)
s083853861
Accepted
17
3,060
192
lst = list(map(int,input().split())) lst2 = list(map(lambda x: max(lst) - x, lst)) lst2.remove(0) if lst2[0] % 2 == lst2[1] % 2: print(sum(lst2) // 2) else: print((sum(lst2) + 3) // 2)
s850682492
p03547
u368796742
2,000
262,144
Wrong Answer
17
2,940
88
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
x,y = input().split() if x > y: print("<") elif x < y: print(">") else: print("=")
s740386331
Accepted
17
2,940
89
x,y = input().split() if x < y: print("<") elif x > y: print(">") else: print("=")
s913620903
p03971
u068142202
2,000
262,144
Wrong Answer
82
4,664
196
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
n, a, b = map(int, input().split()) s = list(input()) for i in s: if i == "a" and a != 0: a -= 1 print("Yes") elif i == b and b != 0: b -=1 print("Yes") else: print("No")
s305757329
Accepted
100
4,712
221
n, a, b = map(int, input().split()) s = list(input()) for i in s: if i == "a" and (a + b) != 0: a -= 1 print("Yes") elif i == "b" and (a + b) != 0 and b != 0: b -=1 print("Yes") else: print("No")
s320778404
p03543
u882831132
2,000
262,144
Wrong Answer
18
2,940
133
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N=input() ans=1 for i in range(len(N)-1): if N[i] == N[i+1]: ans+=1 else: ans=1 if ans>=3: print("Yes") else: print("No")
s552291835
Accepted
17
3,064
146
N=input() ans=1 for i in range(len(N)-1): if N[i] == N[i+1]: ans+=1 else: ans=1 if ans>=3: print("Yes") exit() print("No")
s995318357
p04044
u379424722
2,000
262,144
Wrong Answer
17
2,940
77
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
N,L = map(int,input().split()) L = sorted(input().split()) print(''.join(L))
s502966470
Accepted
18
3,060
112
N,L = map(int,input().split()) M = [] for i in range(N): M.append(input()) M = sorted(M) print(''.join(M))
s502033077
p03485
u992910889
2,000
262,144
Wrong Answer
17
2,940
46
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
A,B=map(int,input().split()) print((A+B)//2+1)
s558556101
Accepted
17
2,940
67
import math A,B=map(int,input().split()) print(math.ceil((A+B)/2))
s750072954
p03486
u138486156
2,000
262,144
Wrong Answer
18
3,064
310
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()) a = b = [] for i in range(len(s)): a.append(ord(s[i])) for i in range(len(t)): b.append(ord(t[i])) if min(a) < max(b): print("Yes") elif len(s) < len(t): for i in range(len(s)): if s[i] != t[i]: print("No") exit() print("Yes") exit() print("No")
s079132385
Accepted
17
3,060
218
s = list(input()) t = list(input()) n = len(s) m = len(t) s.sort() t.sort() t = t[-1::-1] a = b = "" for i in range(n): a += s[i] for i in range(m): b += t[i] if a < b: print("Yes") else: print("No")
s039843900
p03610
u013756322
2,000
262,144
Wrong Answer
49
3,316
82
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() ans = '' for c in s: if (len(s) % 2 == 1): ans += c print(ans)
s270364120
Accepted
17
3,188
22
print(input()[0::2])
s672966712
p03997
u638648846
2,000
262,144
Wrong Answer
17
2,940
62
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)
s898155305
Accepted
17
2,940
67
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
s642085841
p03854
u225388820
2,000
262,144
Wrong Answer
17
3,188
295
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() i=0 ans=True while i<=len(s)-1: if s[i:i+7]=='dreamer': i+=7 elif s[i:i+5]=='dream': i+=5 elif s[i:i+6]=='eraser': i+=6 elif s[i:i+5]=='erase': i+=5 else: ans=False break if ans: print('Yes') else: print('No')
s992149759
Accepted
28
3,188
293
s=input() i=len(s) ans=True while 3<=i: if s[i-7:i]=='dreamer': i-=7 elif s[i-5:i]=='dream': i-=5 elif s[i-6:i]=='eraser': i-=6 elif s[i-5:i]=='erase': i-=5 else: ans=False break if ans: print('YES') else: print('NO')
s348398519
p03636
u889989259
2,000
262,144
Wrong Answer
29
9,088
53
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
s = list(input()) print(s[0], len(s)-2, s[len(s)-1])
s876444100
Accepted
24
9,028
61
s = list(input()) print(s[0], len(s)-2, s[len(s)-1], sep='')
s594267326
p02742
u455533363
2,000
1,048,576
Wrong Answer
17
2,940
88
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 = map(int,input().split()) if (a*b)%2==1: print((a*b)//2+1) else: print(a*b/2)
s748539060
Accepted
17
2,940
148
a, b = map(int,input().split()) if a==1 or b==1: print(1) else: if a%2==1 and b%2==1: print(int((a*b-1)/2+1)) else: print(int(a*b/2))
s134600888
p03447
u475675023
2,000
262,144
Wrong Answer
18
2,940
48
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
print((int(input())-int(input()))//int(input()))
s695858960
Accepted
17
2,940
68
x=int(input()) a=int(input()) b=int(input()) print(x-a-((x-a)//b)*b)
s861308338
p03997
u441320782
2,000
262,144
Wrong Answer
17
2,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)
s178306412
Accepted
17
2,940
62
a=int(input()) b=int(input()) h=int(input()) print((a+b)*h//2)
s669135897
p02612
u849433300
2,000
1,048,576
Wrong Answer
25
9,148
31
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N//1000)
s598948518
Accepted
25
9,168
71
N = int(input()) if N%1000 == 0: print(0) else: print(1000- N%1000)
s545579834
p02606
u730807152
2,000
1,048,576
Wrong Answer
29
9,104
105
How many multiples of d are there among the integers between L and R (inclusive)?
l,r,d=map(int,input().split()) ans=0 for i in range(l,r): if i%d == 0: ans += 1 print(ans)
s596710209
Accepted
30
9,108
107
l,r,d=map(int,input().split()) ans=0 for i in range(l,r+1): if i%d == 0: ans += 1 print(ans)
s413848362
p03860
u581187895
2,000
262,144
Wrong Answer
17
2,940
64
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.
s = list(input().split()) print(s[0][0],s[1][0],s[2][0], end="")
s810669787
Accepted
17
2,940
47
a, b, c = input().split() print(a[0]+b[0]+c[0])
s331802121
p03501
u477343425
2,000
262,144
Wrong Answer
17
2,940
51
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
n,a,b = map(int, input().split()) ans = min(n*a, b)
s678116663
Accepted
18
2,940
61
n,a,b = map(int,input().split()) ans = min(n*a, b) print(ans)
s327981358
p03456
u110580875
2,000
262,144
Wrong Answer
17
3,060
131
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
import math a,b=(map(int,input().split())) num=str(a)+str(b) ans=int(math.sqrt(int(num))) print(ans if ans*ans==int(num) else"No")
s662540943
Accepted
17
2,940
133
import math a,b=(map(int,input().split())) num=str(a)+str(b) ans=int(math.sqrt(int(num))) print("Yes" if ans*ans==int(num) else"No")
s610318565
p03543
u626228246
2,000
262,144
Wrong Answer
17
2,940
69
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N = list(input()) print(N[0] == N[1] == N[2] or N[1] == N[2] == N[3])
s611401222
Accepted
17
2,940
89
N = list(input()) print("Yes" if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] else "No")
s579839866
p03433
u574464625
2,000
262,144
Wrong Answer
17
2,940
85
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()) if N%500 < A : print("YES") else : print("NO")
s900645100
Accepted
17
2,940
102
#infinity Coins n=int(input()) a=int(input()) if n%500 <= a : print("Yes") else : print("No")
s899887242
p03448
u806257533
2,000
262,144
Wrong Answer
25
3,064
785
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
big = int(input()) mid = int(input()) small = int(input()) input_money = int(input()) cnt = 0 for i in range(big+1): for j in range(mid+1): for k in range(small+1): if (input_money-500*i)>=0: money = (input_money-500*i) if money==0: cnt += 1 break if (money-100*j)>=0: money = (money-100*i) if money==0: cnt += 1 break if (money-50*j)>=0: money = (money-50*i) if money==0: cnt += 1 break else: continue break print(cnt)
s826928083
Accepted
51
3,060
266
big = int(input()) mid = int(input()) small = int(input()) input_money = int(input()) cnt = 0 for i in range(big+1): for j in range(mid+1): for k in range(small+1): if input_money==(500*i + 100*j + 50*k): cnt += 1 print(cnt)
s425500025
p03997
u708211626
2,000
262,144
Wrong Answer
27
9,116
56
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,b,c=[int(input()) for i in range(3)] print((a+b)*c/2)
s921304190
Accepted
29
9,156
59
a,b,c=[int(input()) for i in range(3)] print(int(a+b)*c//2)
s786201249
p03549
u329407311
2,000
262,144
Wrong Answer
18
2,940
109
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
N,M = map(int,input().split()) T = M * 1900 + (N-M) * 100 print( int(( (1/2)**M / (1-(1-(1/2)**M)) ) *T))
s933872673
Accepted
407
3,064
193
import math N,M = map(int,input().split()) T = M * 1900 + (N-M) * 100 p = (1/2)**M p2 = (1/2)**M ans = 0 for i in range(1,500000): ans += T * p2 * i p2 = p2 * (1-p) print(round(ans))
s541812719
p03854
u044442911
2,000
262,144
Wrong Answer
17
3,188
422
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`.
def main(): S = input() while True: if S[:5] == "dream": S = S[5:] elif S[:6] == "eraser": S = S[6:] elif S[:5] == "erase": S = S[5:] elif S[:6] == "dreamer": S = S[7:] else: print("No") break if len(S) == 0: print("Yes") break if __name__ == "__main__": main()
s782885634
Accepted
23
6,516
968
from re import match # f = open("./16/input_c2_2.txt") # return f.readline().rstrip() def main(): S = input() if match('(dreamer|eraser|erase|dream)+$', S): print("YES") else: print("NO") # while True: # result_1 = search('dreamer$', S) # result_4 = search('dream$', S) # if result_1: # S = S[:result_1.start()] # elif result_2: # S = S[:result_2.start()] # elif result_3: # S = S[:result_3.start()] # elif result_4: # S = S[:result_4.start()] # else: # print("NO") # break # if len(S) == 0: # print("YES") # break if __name__ == "__main__": main()
s879254667
p03369
u623814058
2,000
262,144
Wrong Answer
29
9,032
37
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.
print(input().count('o') * 200 + 700)
s564627426
Accepted
25
8,908
37
print(input().count('o') * 100 + 700)
s833276146
p03095
u143492911
2,000
1,048,576
Wrong Answer
35
3,188
138
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
n=int(input()) s=input() cnt=[0]*26 for i in s: cnt[ord(i)-97]+=1 print(cnt) ans=1 for i in range(26): ans*=cnt[i]+1 print(ans-1)
s072610466
Accepted
34
3,188
148
n=int(input()) s=input() m=10**9+7 cnt=[0]*26 for i in s: cnt[ord(i)-97]+=1 ans=1 for i in range(26): ans*=cnt[i]+1 ans%=m print(ans-1)
s891891922
p03919
u619819312
2,000
262,144
Wrong Answer
18
3,064
292
There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`.
h,w=map(int,input().split()) q=[list(map(str,input().split()))for i in range(h)] p=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] for i in range(h): for j in range(w): if q[i][j]=="snuke": print(p[i]+str(j+1))
s435947784
Accepted
20
2,940
168
h,w=map(int,input().split()) for i in range(h): q=list(input().split()) for j in range(w): if q[j]=="snuke": print(chr(ord("A")+j)+str(i+1))
s299581005
p03693
u039360403
2,000
262,144
Wrong Answer
17
2,940
69
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?
a=input().split() print('Yes' if int(a[0]+a[1]+a[2])%4==0 else 'No')
s716335034
Accepted
17
2,940
69
a=input().split() print('YES' if int(a[0]+a[1]+a[2])%4==0 else 'NO')
s583568162
p02401
u655518263
1,000
131,072
Wrong Answer
40
7,704
255
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
l = [str(i) for i in input().split()] a = int(l[0]) b = int(l[2]) op = l[1] if op == "+": print(a+b) elif op == "-": print(a-b) elif op == "*": print(a*b) elif op == "/": print(int(a/b)) elif l == ["0","?","0"]: pass
s815612538
Accepted
30
7,784
328
while True: l = [str(i) for i in input().split()] a = int(l[0]) b = int(l[2]) op = l[1] if op == "+": print(a+b) elif op == "-": print(a-b) elif op == "*": print(a*b) elif op == "/": print(a//b) elif op == "?": break
s684258947
p03473
u776871252
2,000
262,144
Wrong Answer
17
2,940
32
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
h = int(input()) print(24 - h)
s072912142
Accepted
17
2,940
39
h = int(input()) print(24 + (24 - h))
s351722733
p03545
u528482684
2,000
262,144
Wrong Answer
17
2,940
177
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.
S = input() op = ["+","-"] for a in op: for b in op: for c in op: shiki = S[0]+a+S[1]+b+S[2]+c+S[3]+"==7" if eval(shiki): print(shiki) exit()
s953984548
Accepted
17
2,940
179
S = input() op = ["+","-"] for a in op: for b in op: for c in op: shiki = S[0]+a+S[1]+b+S[2]+c+S[3] if eval(shiki)==7: print(shiki+"=7") exit()
s540396811
p02261
u390995924
1,000
131,072
Wrong Answer
30
8,128
571
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
import copy N = int(input()) bscs = [(int(c[-1]), c) for c in input().split(" ")] sscs = copy.copy(bscs) for i in range(N): j = N - 1 while j > i: if bscs[j][0] < bscs[j - 1][0]: tmp = bscs[j] bscs[j] = bscs[j - 1] bscs[j - 1] = tmp j -= 1 print(bscs) print("Stable") for i in range(N): minj = i for j in range(i, N): if sscs[j][0] < sscs[minj][0]: minj = j tmp = sscs[i] sscs[i] = sscs[minj] sscs[minj] = tmp print(sscs) print("Stable" if bscs == sscs else "Not Stable")
s411859932
Accepted
30
8,180
623
import copy N = int(input()) bscs = [(int(c[-1]), c) for c in input().split(" ")] sscs = copy.copy(bscs) for i in range(N): j = N - 1 while j > i: if bscs[j][0] < bscs[j - 1][0]: tmp = bscs[j] bscs[j] = bscs[j - 1] bscs[j - 1] = tmp j -= 1 print(" ".join([c[1] for c in bscs])) print("Stable") for i in range(N): minj = i for j in range(i, N): if sscs[j][0] < sscs[minj][0]: minj = j tmp = sscs[i] sscs[i] = sscs[minj] sscs[minj] = tmp print(" ".join([c[1] for c in sscs])) print("Stable" if bscs == sscs else "Not stable")
s904632355
p03556
u363836311
2,000
262,144
Wrong Answer
24
2,940
53
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
n=int(input()) t=1 while t*t<n: t+=1 print(t)
s321796506
Accepted
22
2,940
62
n=int(input()) t=1 while t*t<=n: t+=1 print((t-1)**2)
s873211581
p03836
u591295155
2,000
262,144
Wrong Answer
18
3,064
317
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx, sy, tx, ty = map(int,input().split()) keiro = "" for i in range(ty-sy): keiro += "U" for i in range(tx-sx): keiro += "R" keiro0 = keiro keiro = "" for i in range(ty-sy): keiro += "D" for i in range(tx-sx): keiro += "L" keiro1 = keiro ans = keiro0+keiro1+"LU"+keiro0+"RDDR"+keiro1+"LU" print(ans)
s789213878
Accepted
18
3,064
317
sx, sy, tx, ty = map(int,input().split()) keiro = "" for i in range(ty-sy): keiro += "U" for i in range(tx-sx): keiro += "R" keiro0 = keiro keiro = "" for i in range(ty-sy): keiro += "D" for i in range(tx-sx): keiro += "L" keiro1 = keiro ans = keiro0+keiro1+"LU"+keiro0+"RDRD"+keiro1+"LU" print(ans)
s002850682
p03477
u670180528
2,000
262,144
Wrong Answer
17
3,064
117
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d=map(int,input().split()) if a+b<c+d: print("Left") elif a+b>c+d: print("Right") else: print("Balanced")
s536660907
Accepted
17
2,940
118
a,b,c,d=map(int,input().split()) if a+b>c+d: print("Left") elif a+b<c+d: print("Right") else: print("Balanced")
s792577690
p02861
u375681664
2,000
1,048,576
Wrong Answer
17
3,064
294
There are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \sqrt{\left(x_i- x_j\right)^2+\left(y_i-y_j\right)^2}. There are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.
import math N=int(input()) X=[0]*N Y=[0]*N S=0 T=math.factorial(N) for i in range(N): X[i],Y[i]=map(int,input().split()) for j in range(N-1): for k in range(j+1,N): print(math.sqrt((X[j]-X[k])**2+(Y[j]-Y[k])**2)) S+=math.sqrt((X[j]-X[k])**2+(Y[j]-Y[k])**2) print(S*2/N)
s139528578
Accepted
17
3,064
243
import math N=int(input()) X=[0.0]*N Y=[0.0]*N S=0.0 for i in range(N): X[i],Y[i]=map(int,input().split()) for j in range(N-1): for k in range(j+1,N): S+=math.sqrt((X[j]-X[k])**2+(Y[j]-Y[k])**2) print(round(S*2/N,10))
s181515056
p02731
u317423698
2,000
1,048,576
Wrong Answer
25
9,380
178
Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L.
import sys def resolve(in_): L = int(in_.read()) return L ** -3 def main(): answer = resolve(sys.stdin) print(answer) if __name__ == '__main__': main()
s450999110
Accepted
20
9,212
195
import sys def resolve(in_): L = int(in_.read()) return (L / 3.0) ** 3 def main(): answer = resolve(sys.stdin) print(f'{answer:.12f}') if __name__ == '__main__': main()
s888479112
p03544
u100858029
2,000
262,144
Wrong Answer
18
2,940
108
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)
L = [2 if i==0 else 1 for i in range(100)] for n in range(100): L[n] = L[n-1]+L[n-2] print(L[int(input())])
s422942021
Accepted
18
2,940
111
L = [2 if i==0 else 1 for i in range(100)] for n in range(2,100): L[n] = L[n-1]+L[n-2] print(L[int(input())])
s408388255
p03759
u702018889
2,000
262,144
Wrong Answer
26
9,152
65
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a,b,c=map(int,input().split()) print("Yes" if b-a==c-b else "No")
s942541255
Accepted
28
9,148
65
a,b,c=map(int,input().split()) print("YES" if b-a==c-b else "NO")
s388053025
p02240
u662418022
1,000
131,072
Wrong Answer
30
6,008
809
Write a program which reads relations in a SNS (Social Network Service), and judges that given pairs of users are reachable each other through the network.
# -*- coding: utf-8 -*- from collections import deque if __name__ == '__main__': n, m = [int(s) for s in input().split(" ")] M = [[] for j in range(n)] for _ in range(m): u, v = [int(s) for s in input().split(" ")] M[u].append(v) M[v].append(u) color = [0] * n print(M) def dfs(u, c): color[u] = c for v in range(n): if v in M[u] and color[v] == 0: dfs(v, c) color[u] = c c = 1 for u in range(n): if color[u] == 0: dfs(u, c) c += 1 l = int(input()) for _ in range(l): p, q = [int(s) for s in input().split(" ")] if color[p] == color[q]: print("yes") else: print("no")
s100408127
Accepted
750
141,736
795
# -*- coding: utf-8 -*- from collections import deque import sys sys.setrecursionlimit(200000) if __name__ == '__main__': n, m = [int(s) for s in input().split(" ")] M = [set() for j in range(n)] for _ in range(m): u, v = [int(s) for s in input().split(" ")] M[u].add(v) M[v].add(u) color = [0] * n def dfs(u, c): color[u] = c for v in M[u]: if color[v] == 0: dfs(v, c) c = 1 for u in range(n): if color[u] == 0: dfs(u, c) c += 1 l = int(input()) for _ in range(l): p, q = [int(s) for s in input().split(" ")] if color[p] == color[q]: print("yes") else: print("no")
s087626917
p03679
u231122239
2,000
262,144
Wrong Answer
17
2,940
136
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(' ')) if b > a: print('delicious') elif b - a <= x: print('safe') else: print('dangerous')
s232840135
Accepted
19
2,940
137
x, a, b = map(int, input().split(' ')) if b <= a: print('delicious') elif b - a <= x: print('safe') else: print('dangerous')
s505032645
p03644
u106778233
2,000
262,144
Wrong Answer
27
9,104
75
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.
ans =0 n = int(input()) while n%2 ==0 : ans+= 1 n//=2 print(ans)
s473095529
Accepted
31
9,100
83
n = int(input()) for i in range(8): if 2**i> n: break print(2**(i-1))
s956459351
p03610
u140251125
2,000
262,144
Wrong Answer
35
3,188
98
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
# input s = input() ans = s[0] for i in range(len(s) // 2): ans = ans + s[2 * i] print(ans)
s014286836
Accepted
29
3,188
119
import math # input s = input() ans = '' for i in range(math.ceil(len(s) / 2)): ans = ans + s[2 * i] print(ans)
s437466167
p03574
u591287669
2,000
262,144
Wrong Answer
27
3,188
594
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
h,w = map(int,input().split()) arr=[] arr.append(['.']*(w+2)) for _ in range(h): arr.append(list('.'+input()+'.')) arr.append(['.']*(w+2)) ans=[] for i in range(h): ans.append([]) for j in range(w): tmpans=0 if arr[i+1][j+1]=='#': tmpans='#' else: for hh in range(3): for ww in range(3): if not(hh==1 and ww==1) and arr[i+hh][j+ww]=='#': tmpans+=1 tmpans=str(tmpans) ans[i].append(tmpans) print(arr) print(ans) for line in ans: print(''.join(line))
s379351906
Accepted
27
3,188
571
h,w = map(int,input().split()) arr=[] arr.append(['.']*(w+2)) for _ in range(h): arr.append(list('.'+input()+'.')) arr.append(['.']*(w+2)) ans=[] for i in range(h): ans.append([]) for j in range(w): tmpans=0 if arr[i+1][j+1]=='#': tmpans='#' else: for hh in range(3): for ww in range(3): if not(hh==1 and ww==1) and arr[i+hh][j+ww]=='#': tmpans+=1 tmpans=str(tmpans) ans[i].append(tmpans) for line in ans: print(''.join(line))
s918316768
p03796
u501451051
2,000
262,144
Wrong Answer
2,104
3,460
98
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
N = int(input()) double = 1 for i in range(1, N): double = double*i print(double%(10**9+7))
s651800841
Accepted
162
10,028
67
import math a = 10**9 + 7 print(math.factorial(int(input())) % a)
s971146305
p03485
u514118270
2,000
262,144
Wrong Answer
116
26,984
493
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
import sys import math import numpy as np import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) INF = 10**9 mod = 10**9+7 a,b = I() print(a*b//2)
s686970997
Accepted
120
27,136
497
import sys import math import numpy as np import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) INF = 10**9 mod = 10**9+7 a,b = I() print((a+b+1)//2)
s791963627
p02612
u698919163
2,000
1,048,576
Wrong Answer
27
9,136
100
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) for i in range(11): if N < 1000: break N = N - 1000 print(N)
s475335246
Accepted
34
9,156
112
N = int(input()) tmp = 0 for i in range(11): tmp += 1000 if tmp >= N: print(tmp-N) break
s937616305
p03303
u150641538
2,000
1,048,576
Wrong Answer
17
2,940
130
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.
s = input() w = int(input()) length = len(s) output = s[0] i = w while(i<length): output += s[w] i += w print(output)
s832769588
Accepted
17
2,940
129
s = input() w = int(input()) length = len(s) output = s[0] i = w while(i<length): output += s[i] i += w print(output)
s176923400
p03160
u443536265
2,000
1,048,576
Wrong Answer
126
13,980
245
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 Stone i + 1 or Stone i + 2. 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.
N = int(input()) li = list(map(int,input().split())) if len(li) == 1: print(li[0]) exit() dp = [0,abs(li[1]-li[0])] print(dp) for i in range(2,N): dp.append(min(dp[i-1]+abs(li[i]-li[i-1]), dp[i-2]+abs(li[i]-li[i-2]))) print(dp[N-1])
s151837840
Accepted
129
13,980
235
N = int(input()) li = list(map(int,input().split())) if len(li) == 1: print(li[0]) exit() dp = [0,abs(li[1]-li[0])] for i in range(2,N): dp.append(min(dp[i-1]+abs(li[i]-li[i-1]), dp[i-2]+abs(li[i]-li[i-2]))) print(dp[N-1])
s154127448
p03162
u606878291
2,000
1,048,576
Wrong Answer
430
37,288
544
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
def main(n, choices): results = [[0, 0, 0] for _ in range(n)] results[0] = choices[0] for i in range(1, n): results[i][0] = choices[i][0] + max(results[i - 1][1], results[i - 1][2]) results[i][1] = choices[i][1] + max(results[i - 1][0], results[i - 1][2]) results[i][2] = choices[i][2] + max(results[i - 1][0], results[i - 1][1]) return max(results[-1]) if __name__ == '__main__': N = int(input()) C = [] for _ in range(N): C.append(list(map(int, input().split()))) print(N, C)
s820776023
Accepted
639
49,128
394
import numpy as np N = int(input()) values = [tuple(map(int, input().split(' '))) for _ in range(N)] dp = [values[0]] for _ in range(N - 1): dp.append([0, 0, 0]) for i in range(1, N): prev = dp[i - 1] dp[i][0] = values[i][0] + max(prev[1], prev[2]) dp[i][1] = values[i][1] + max(prev[0], prev[2]) dp[i][2] = values[i][2] + max(prev[0], prev[1]) print(np.max(dp[N - 1]))
s464411966
p03589
u094191970
2,000
262,144
Wrong Answer
323
2,940
155
You are given an integer N. Find a triple of positive integers h, n and w such that 4/N = 1/h + 1/n + 1/w. If there are multiple solutions, any of them will be accepted.
n=int(input()) for h in range(1,3500): for n in range(1,3500): if h+n>=3500: continue w=3500-h-n if 4/n == 1/h+1/n+1/w: print(h,n,w) exit()
s104116708
Accepted
20
3,060
202
n=int(input()) for a in range(n//4+1,3501): for b in range((n*a)//(4*a-n),3501): if 4*a*b-n*b-a*n==0: continue c=(n*a*b)/(4*a*b-n*b-a*n) if c==int(c) and c>=1: print(a,b,int(c)) exit()
s801786380
p02388
u997714038
1,000
131,072
Wrong Answer
30
7,328
32
Write a program which calculates the cube of a given integer x.
x = float(input()) print(x ** 3)
s822200586
Accepted
20
7,616
30
x = int(input()) print(x ** 3)
s500677196
p03470
u490464064
2,000
262,144
Wrong Answer
17
2,940
181
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?
N=int(input()) N_list=[input() for i in range(N)] result_list=[] for i in range(len(N_list)): if i==(a for a in N_list): result_list.append(i) print(len(result_list))
s368948269
Accepted
17
2,940
95
N=int(input()) c=[] for i in range(N): c.append(int(input())) print(len(set(c)))
s859740695
p03007
u226108478
2,000
1,048,576
Wrong Answer
270
19,740
548
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
# -*- coding: utf-8 -*- def main(): from collections import deque n = int(input()) a = sorted(list(map(int, input().split()))) d = deque() for ai in a: d.append(ai) ans = list() count = n while count > 1: left = d.popleft() right = d.pop() ans.append((left, right)) tmp = left - right d.append(tmp) count -= 1 print(ans[-1][0] - ans[-1][1]) for i in range(len(ans)): print(ans[i][0], ans[i][1]) if __name__ == '__main__': main()
s244244926
Accepted
223
14,016
818
# -*- coding: utf-8 -*- def main(): n = int(input()) a = sorted(list(map(int, input().split()))) plus = [a[-1]] minus = [a[0]] # KeyInsight # See: # https://www.youtube.com/watch?v=TbobvdA6AlE for ai in a[1:-1]: if ai >= 0: plus.append(ai) else: minus.append(ai) print(sum(plus) - sum(minus)) for p in plus[1:]: print(minus[-1], p) minus[-1] -= p for m in minus: print(plus[0], m) plus[0] -= m if __name__ == '__main__': main()
s199827600
p03994
u623687794
2,000
262,144
Wrong Answer
143
5,428
311
Mr. Takahashi has a string s consisting of lowercase English letters. He repeats the following operation on s exactly K times. * Choose an arbitrary letter on s and change that letter to the next alphabet. Note that the next letter of `z` is `a`. For example, if you perform an operation for the second letter on `aaz`, `aaz` becomes `abz`. If you then perform an operation for the third letter on `abz`, `abz` becomes `aba`. Mr. Takahashi wants to have the lexicographically smallest string after performing exactly K operations on s. Find the such string.
s=list(input()) print(s) K=int(input()) i=0 while i<len(s): if i==len(s)-1: s[i]=chr(97+(ord(s[i])-97+K)%26) break if K<abs(123-ord(s[i]))%26: i+=1 elif K>=abs(123-ord(s[i]))%26: sub=abs(123-ord(s[i]))%26 s[i]="a" K-=sub i+=1 print("".join(s))
s152312608
Accepted
150
4,156
302
s=list(input()) K=int(input()) i=0 while i<len(s): if i==len(s)-1: s[i]=chr(97+(ord(s[i])-97+K)%26) break if K<abs(123-ord(s[i]))%26: i+=1 elif K>=abs(123-ord(s[i]))%26: sub=abs(123-ord(s[i]))%26 s[i]="a" K-=sub i+=1 print("".join(s))
s145118115
p02401
u088372268
1,000
131,072
Wrong Answer
20
7,648
287
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: data = list(input().split(" ")) a = int(data[0]) b = int(data[2]) if data[1] == "?": break elif data[1] == "+": print(a+b) elif data[1] == "-": print(a-b) elif data[1] == "*": print(a*b) else: print(a/b)
s086552583
Accepted
20
7,700
288
while True: data = list(input().split(" ")) a = int(data[0]) b = int(data[2]) if data[1] == "?": break elif data[1] == "+": print(a+b) elif data[1] == "-": print(a-b) elif data[1] == "*": print(a*b) else: print(a//b)
s210261719
p04012
u862757671
2,000
262,144
Wrong Answer
17
2,940
150
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w1 = [s for s in input()] w2 = [w1.count(a) for a in list(set(w1))] w3 = [w for w in w2 if w % 2 == 0] print(('YES' if len(w3) == len(w2) else 'NO'))
s569335610
Accepted
17
3,064
150
w1 = [s for s in input()] w2 = [w1.count(a) for a in list(set(w1))] w3 = [w for w in w2 if w % 2 == 0] print(('Yes' if len(w3) == len(w2) else 'No'))
s946389413
p03377
u278670845
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.
a,b,x = map(int,input().split()) if a>x: print("NO") elif a+b>x: print("NO") else: print("YES")
s448179553
Accepted
18
2,940
101
a,b,x = map(int,input().split()) if a>x: print("NO") elif a+b<x: print("NO") else: print("YES")
s149118932
p02397
u244493040
1,000
131,072
Wrong Answer
20
5,552
32
Write a program which reads two integers x and y, and prints them in ascending order.
print(*sorted(input().split()))
s615131351
Accepted
50
5,600
88
while 1: x,y = sorted(map(int,input().split())) if not (x or y): break print(x,y)
s381526102
p03378
u068142202
2,000
262,144
Wrong Answer
17
3,060
222
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
n, m, x = map(int, input().split()) A = list(map(int, input().split())) cost = 0 goal = min(x, (n - x)) for i in range(m): if A[i] >= x and x < goal: cost += 1 elif A[i] <= x and x > goal: cost += 1 print(cost)
s695303940
Accepted
19
3,188
283
n, m, x = map(int, input().split()) A = list(map(int, input().split())) cost = 0 for i in range(x, n+1): if A.count(i) > 0: cost += 1 cost_nomal = cost cost = 0 for i in range(1, x+1): if A.count(i) > 0: cost += 1 cost_reverse = cost print(min(cost_nomal,cost_reverse))