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
s770240643
p02645
u089786098
2,000
1,048,576
Wrong Answer
20
9,008
44
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
a = input() a = str(a) print(a[0],a[1],a[2])
s443425220
Accepted
24
8,960
24
a = input() print(a[:3])
s173709562
p03378
u186838327
2,000
262,144
Wrong Answer
18
2,940
134
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())) min(len([b for b in a if b < x]), len([c for c in a if c >x]))
s523414579
Accepted
18
2,940
141
n, m, x = map(int, input().split()) a = list(map(int, input().split())) print(min(len([b for b in a if b < x]), len([c for c in a if c >x])))
s742275139
p03437
u810356688
2,000
262,144
Wrong Answer
18
2,940
229
You are given positive integers X and Y. If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it. If it does not exist, print -1.
import sys def input(): return sys.stdin.readline().rstrip() def main(): x,y=map(int,input().split()) if x==y or y%x==0: print(-1) sys.exit() else: print(x) if __name__=='__main__': main()
s246291578
Accepted
17
3,060
325
import sys def input(): return sys.stdin.readline().rstrip() def main(): x,y=map(int,input().split()) if x==y or x%y==0: print(-1) sys.exit() else: for i in range(2,10*6): if x*i % y!=0: print(x*i) sys.exit() if __name__=='__main__': main()
s593488433
p03369
u448655578
2,000
262,144
Wrong Answer
19
2,940
96
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.
toppings = list(input()) ans = 700 for i in toppings: if i == "○": ans += 100 print(ans)
s524133923
Accepted
17
2,940
94
toppings = list(input()) ans = 700 for i in toppings: if i == "o": ans += 100 print(ans)
s824438488
p02694
u366836739
2,000
1,048,576
Wrong Answer
22
9,232
219
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?
# coding: utf-8 def main(): x = int(input()) money = 100 year = 0 while money <= x: year += 1 money *= 1.01 money = money//1 print(year) if __name__ == '__main__': main()
s967714402
Accepted
23
9,232
218
# coding: utf-8 def main(): x = int(input()) money = 100 year = 0 while money < x: year += 1 money *= 1.01 money = money//1 print(year) if __name__ == '__main__': main()
s738771509
p03543
u950567701
2,000
262,144
Wrong Answer
17
3,060
188
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**?
a = input() li = [] for s in a: li.append(s) count = 0 for i in range(1,4): if li[i] == li[i-1]: count += 1 else: count =0 if count >= 3: print("Yes") else: print("No")
s134285046
Accepted
17
2,940
221
a = input() li = [] for s in a: li.append(s) count = 0 for i in range(1,4): if li[i] == li[i-1]: count += 1 if count == 2: break else: count = 0 if count >= 2: print("Yes") else: print("No")
s395151183
p02613
u977961492
2,000
1,048,576
Wrong Answer
137
16,276
186
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N=int(input()) S=[input() for i in range(N)] print("AC x" + str(S.count("AC"))) print("WA x" + str(S.count("WA"))) print("TLE x" + str(S.count("TLE"))) print("RE x" + str(S.count("RE")))
s194586360
Accepted
140
16,224
183
n=int(input()) s=[input() for i in range(n)] print("AC x "+str(s.count("AC"))) print("WA x "+str(s.count("WA"))) print("TLE x "+str(s.count("TLE"))) print("RE x "+str(s.count("RE")))
s584743960
p00002
u661290476
1,000
131,072
Wrong Answer
20
7,536
49
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)))
s190651706
Accepted
20
5,592
119
while True: try: a, b = map(int, input().split()) print(len(str(a + b))) except: break
s257403288
p02399
u596870465
1,000
131,072
Wrong Answer
20
5,600
89
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()) d = a // b r = a%b f = float(a/b) print(d,r,f)
s740284863
Accepted
20
5,600
71
a, b = map(int,input().split()) print("%d %d %.5f" % (a/b, a%b, a/b))
s084324993
p03945
u594956556
2,000
262,144
Wrong Answer
48
3,188
139
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
s=input() n=len(s) count=0 if n==1: print(0) exit() iro=s[0] for i in range(1,n): if s[i]==iro: count+=1 iro=s[i] print(count)
s088495780
Accepted
44
3,188
148
s=input() n=len(s) count=0 if n==1: print(0) exit() iro=s[0] for i in range(1,n): now=s[i] if now!=iro: count+=1 iro=now print(count)
s233298065
p03964
u503901534
2,000
262,144
Wrong Answer
20
2,940
251
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
n = int(input()) kouho = 0 for i in range(n): t,a = map(int,input().split()) s = t + a if kouho <= s: kouho = s else: j = 1 while kouho > s: s = s * j j = j + 1 kouho = s print(s)
s347653924
Accepted
21
3,064
265
n = int(input()) import math as m t1 , a1 = map(int,input().split()) tt = t1 aa = a1 for i in range(n-1): t, a = map(int,input().split()) n = ((max((tt//t),(aa//a)))) if tt > t*n or aa> a*n: n = n + 1 tt = t * n aa = a * n print(tt + aa)
s702147101
p03486
u412563426
2,000
262,144
Wrong Answer
18
3,060
237
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= input() t= input() ss = sorted(s) tt = sorted(t) sss = "".join(ss) ttt = "".join(tt) A = [sss, ttt] A.sort() if A[0] == sss: print("Yes") else: print("No")
s096127913
Accepted
18
3,064
214
s= input() t= input() if s == t: print("No") exit() ss = sorted(s) tt = sorted(t, reverse=True) sss = "".join(ss) ttt = "".join(tt) A = [sss, ttt] A.sort() if A[0] == sss: print("Yes") else: print("No")
s417361080
p03436
u935558307
2,000
262,144
Wrong Answer
65
4,204
872
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
from collections import deque H,W = map(int,input().split()) maze = [list(input()) for i in range(H)] blackCount = 0 for row in maze: for tile in row: if tile=="#": blackCount += 1 dist = [[-1 for i in range(W)]for j in range(H)] dist[0][0] = 1 que = [[0,0]] patterns = [[1,0],[-1,0],[0,1],[0,-1]] shortestStep = 0 while que: print(que) now = que.pop(0) nowH = now[0] nowW = now[1] nowStep = dist[nowH][nowW] for pattern in patterns: nextH = nowH + pattern[0] nextW = nowW + pattern[1] if nextH == H-1 and nextW == W-1: shortestStep = nowStep + 1 break if 0 <= nextH <= H-1 and 0 <= nextW <= W-1 and maze[nextH][nextW]!="#" and dist[nextH][nextW]==-1: dist[nextH][nextW] = nowStep + 1 que.append([nextH,nextW]) print(H*W-(shortestStep + blackCount))
s293779150
Accepted
27
3,316
843
from collections import deque H,W = map(int,input().split()) maze = [list(input()) for _ in range(H)] default = 0 for i in range(H): for j in range(W): if maze[i][j] == ".": default += 1 que = deque() que.append((0,0,1)) patterns = [(1,0),(-1,0),(0,1),(0,-1)] count = 0 while que: y,x,cost = que.popleft() if y == H-1 and x == W-1: count = cost break for a,b in patterns: if 0<=y+a<H and 0<=x+b<W and maze[y+a][x+b]==".": maze[y+a][x+b] = "o" que.append((y+a,x+b,cost+1)) if count == 0: print(-1) else: print(default-count)
s346495106
p02796
u934788990
2,000
1,048,576
Wrong Answer
477
20,104
235
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
n = int(input()) xl = [] for i in range(n): x,l = map(int,input().split()) xl.append([x-l,x+l]) xl.sort() ans = -10**10 count = 0 for j in range(n): if xl[i][1] > ans: count +=1 ans = xl[i][0] print(count)
s333111822
Accepted
508
20,104
236
n = int(input()) xl = [] for i in range(n): x,l = map(int,input().split()) xl.append([x+l,x-l]) xl.sort() ans = -10**10 count = 0 for j in range(n): if xl[j][1] >= ans: count +=1 ans = xl[j][0] print(count)
s552573520
p02615
u440161695
2,000
1,048,576
Wrong Answer
113
31,504
76
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
N=int(input()) A=list(map(int,input().split())) A.sort() print(sum(A[:N-1]))
s759047794
Accepted
151
31,484
232
N=int(input()) A=list(map(int,input().split())) A=sorted(A,reverse=True) ans=0 for i in range((N//2)+1): for j in range(2): ans+=A[i] if N%2==1: ans-=A[i] else: ans=ans-(A[i]*2) if N//2!=0: ans-=A[0] print(max(ans,0))
s906712433
p03486
u187205913
2,000
262,144
Wrong Answer
17
3,060
173
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 = input() t = input() s = list(s) t = list(t) s_ = sorted(s) t_ = sorted(t) for i in range(len(s_)): if not s_[i]<t[i]: print('No') exit() print('Yes')
s031095991
Accepted
17
3,060
157
s = input() t = input() s = list(s) t = list(t) s_ = sorted(s) t_ = sorted(t) t_.reverse() if ''.join(s_)<''.join(t_): print('Yes') else: print('No')
s411366376
p00093
u150984829
1,000
131,072
Wrong Answer
30
5,752
171
西暦 a 年から b 年までの間にあるすべてのうるう年を出力するプログラムを作成してください。 うるう年の条件は、次のとおりとします。ただし、0 < a ≤ b < 3,000 とします。与えられた期間にうるう年がない場合には "NA"と出力してください。 * 西暦年が 4 で割り切れる年であること。 * ただし、100 で割り切れる年はうるう年としない。 * しかし、400 で割り切れる年はうるう年である。
for e in iter(input,'0 0'): s,t=map(int,e.split()) u=[y for y in range(s+1,t)if y%4==0 and y%100!=0 or y%400==0] if u: for y in u:print(y) else:print('NA') print()
s851623828
Accepted
30
5,724
159
p=print b=1 for e in iter(input,'0 0'): b or p() b=f=0;s,t=map(int,e.split()) for y in range(s,t+1): if(y%4==0)*(y%100)or y%400==0:p(y);f=1 f or p('NA')
s795120359
p02831
u270467412
2,000
1,048,576
Wrong Answer
17
3,060
206
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
A, B = map(int, input().split()) lcm = 1 cont = 1 while cont == 1: if A % B == 0 or B % A == 0: lcm = min(A, B) break if A < B: B = B % A elif A > B: A = A % B print(A * B / lcm)
s736569503
Accepted
17
3,060
237
A, B = map(int, input().split()) AA = A BB = B lcm = 1 cont = 1 while cont == 1: if A % B == 0 or B % A == 0: lcm = min(A, B) break if A < B: B = B % A elif A > B: A = A % B ans = int(AA * BB / lcm) print(ans)
s736669889
p03853
u609061751
2,000
262,144
Wrong Answer
17
3,060
187
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).
import sys input = sys.stdin.readline H, W = [int(x) for x in input().split()] C = [] for _ in range(H): C.append(input().rstrip()) for _ in range(2): for i in C: print(i)
s009257020
Accepted
18
3,060
187
import sys input = sys.stdin.readline H, W = [int(x) for x in input().split()] C = [] for _ in range(H): C.append(input().rstrip()) for i in C: for _ in range(2): print(i)
s112127357
p03555
u911153222
2,000
262,144
Wrong Answer
17
2,940
175
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a = input() b = input() a_reversed = sorted(a, reverse=True) b_reversed = sorted(b, reverse=True) if a == b_reversed and b == a_reversed: print('Yes') else: print('No')
s425741404
Accepted
17
2,940
184
a = input() b = input() a_reversed = ''.join(list(reversed(a))) b_reversed = ''.join(list(reversed(b))) if a == b_reversed and b == a_reversed: print('YES') else: print('NO')
s308870252
p02270
u150984829
1,000
131,072
Time Limit Exceeded
9,990
5,588
266
In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively.
import sys n,k=map(int,input().split()) w=list(map(int,sys.stdin.readlines())) def check(P): i=0 for _ in[0]*k: s=0 while s+w[i]<=P: s+=w[i];i+=1 if i==n: return n return i l,r=max(w),sum(w) while l<r: m=(l+r)//2 if check(m)>=n:r=m else:l=m print(r)
s831860999
Accepted
230
15,824
297
import sys def s(): n,k=map(int,input().split()) w=list(map(int,sys.stdin.readlines())) def f(): c=t=0 for j in w: t+=j if t>m: t=j c+=1 if c>=k:return 0 return 1 l,r=max(w),sum(w) while l<r: m=(l+r)//2 if f():r=m else:l=m+1 print(r) if'__main__'==__name__:s()
s485864595
p03377
u756988562
2,000
262,144
Wrong Answer
17
2,940
95
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A,B,X = map(int,input().split(" ")) if X-A <B and A <X: print("Yes") else: print("No")
s299702084
Accepted
17
2,940
168
A,B,X = map(int,input().split(" ")) judge = True for i in range(B): temp = A+i if temp == X: print("YES") judge =False if judge: print("NO")
s522528243
p03478
u024890678
2,000
262,144
Wrong Answer
31
9,244
650
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()) ans_list = [] for i in range(1, n+1): if i <= 9: if a <= i <= b: ans_list.append(i) elif 10 <= i <= 99: i10 = i // 10 i1 = i % 10 if a <= i10+i1 <= b: ans_list.append(i) elif 100 <= i <= 999: i100 = i // 100 i10 = (i % 100) // 10 i1 = (i % 100) % 10 if a <= i100+i10+i1 <= b: ans_list.append(i) elif 1000 <= i <= 9999: i1000 = i // 1000 i100 = (i % 1000) // 100 i10 = ((i % 1000) % 1000) // 10 i1 = ((i % 1000) % 1000) % 10 if a <= i1000 +i100 +i10 +i1 <= b: ans_list.append(i) else: if a <= 1 <= b: ans_list.append(i)
s470501000
Accepted
36
9,392
670
n,a,b = map(int, input().split()) ans_list = [] for i in range(1, n+1): if i <= 9: if a <= i <= b: ans_list.append(i) elif 10 <= i <= 99: i10 = i // 10 i1 = i % 10 if a <= i10+i1 <= b: ans_list.append(i) elif 100 <= i <= 999: i100 = i // 100 i10 = (i % 100) // 10 i1 = (i % 100) % 10 if a <= i100+i10+i1 <= b: ans_list.append(i) elif 1000 <= i <= 9999: i1000 = i // 1000 i100 = (i % 1000) // 100 i10 = ((i % 1000) % 100) // 10 i1 = ((i % 1000) % 100) % 10 if a <= i1000 +i100 +i10 +i1 <= b: ans_list.append(i) else: if a <= 1 <= b: ans_list.append(i) print(sum(ans_list))
s037160588
p03555
u446711904
2,000
262,144
Wrong Answer
17
2,940
66
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a=list(input()) b=list(input()) print('NYOE S'[a==b.reverse()::2])
s304043698
Accepted
17
2,940
68
a=list(input()) b=list(input()) b.reverse() print('NYOE S'[a==b::2])
s203995674
p03049
u507613674
2,000
1,048,576
Wrong Answer
45
4,336
849
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
from collections import defaultdict from string import ascii_uppercase import sys, bisect, math stdin = sys.stdin read_int = lambda : list(map(int,stdin.readline().split())) read_str = lambda : stdin.readline().rstrip() N = read_int()[0] S = [read_str() for _ in range(N)] def solve(): _a = 0 b_ = 0 ba = 0 in_ab = 0 # search for i in range(N): if S[i][0] == 'B' and S[i][-1:] == 'A': ba += 1 elif S[i][0] == 'B': b_ += 1 elif S[i][-1:] == 'A': _a += 1 for j in range(len(S[i]) - 1): if S[i][j: j + 2] == 'AB': in_ab += 1 ans = 0 ans += in_ab + ba - 1 + max(0, min(_a - 1, b_ - 1)) print(in_ab, ba, ans) if _a > 0: ans += 1 if b_ > 0: ans += 1 return ans if __name__ == "__main__": print(solve())
s440723311
Accepted
45
4,336
928
from collections import defaultdict from string import ascii_uppercase import sys, bisect, math stdin = sys.stdin read_int = lambda : list(map(int,stdin.readline().split())) read_str = lambda : stdin.readline().rstrip() N = read_int()[0] S = [read_str() for _ in range(N)] def solve(): _a = 0 b_ = 0 ba = 0 in_ab = 0 # search for i in range(N): if S[i][0] == 'B' and S[i][-1:] == 'A': ba += 1 elif S[i][0] == 'B': b_ += 1 elif S[i][-1:] == 'A': _a += 1 for j in range(len(S[i]) - 1): if S[i][j: j + 2] == 'AB': in_ab += 1 ans = 0 if ba == 0: ans += in_ab + min(_a, b_) return ans ans += in_ab + max(ba - 1,0) + max(0, min(_a - 1, b_ - 1)) # print(in_ab, ba, ans) if _a > 0: ans += 1 if b_ > 0: ans += 1 return ans if __name__ == "__main__": print(solve())
s117891509
p03545
u391475811
2,000
262,144
Wrong Answer
18
3,192
760
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=list(input().strip()) if int(s[0])+int(s[1])+int(s[2])+int(s[3])==7: print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]) elif int(s[0])-int(s[1])-int(s[2])-int(s[3])==7: print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]) elif int(s[0])+int(s[1])-int(s[2])-int(s[3])==7: print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]) elif int(s[0])+int(s[1])+int(s[2])-int(s[3])==7: print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]) elif int(s[0])-int(s[1])+int(s[2])-int(s[3])==7: print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]) elif int(s[0])-int(s[1])+int(s[2])+int(s[3])==7: print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]) elif int(s[0])+int(s[1])-int(s[2])+int(s[3])==7: print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]) elif int(s[0])-int(s[1])-int(s[2])+int(s[3])==7: print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]) else: print(-1)
s649851197
Accepted
18
3,192
800
s=list(input().strip()) if int(s[0])+int(s[1])+int(s[2])+int(s[3])==7: print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7") elif int(s[0])-int(s[1])-int(s[2])-int(s[3])==7: print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7") elif int(s[0])+int(s[1])-int(s[2])-int(s[3])==7: print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7") elif int(s[0])+int(s[1])+int(s[2])-int(s[3])==7: print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3]+"=7") elif int(s[0])-int(s[1])+int(s[2])-int(s[3])==7: print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3]+"=7") elif int(s[0])-int(s[1])+int(s[2])+int(s[3])==7: print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3]+"=7") elif int(s[0])+int(s[1])-int(s[2])+int(s[3])==7: print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3]+"=7") elif int(s[0])-int(s[1])-int(s[2])+int(s[3])==7: print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3]+"=7") else: print(-1)
s478047325
p03351
u940102677
2,000
1,048,576
Wrong Answer
17
2,940
130
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(a-c) <= d or (abs(a-b) <= d and abs(a-c) <=d): print("Yes") else: print("No")
s324323639
Accepted
17
3,064
127
a, b, c, d = map(int, input().split()) if abs(a-c)<= d or (abs(a-b)<= d and abs(b-c)<=d): print("Yes") else: print("No")
s627204380
p02606
u654240084
2,000
1,048,576
Wrong Answer
27
9,020
47
How many multiples of d are there among the integers between L and R (inclusive)?
l,r,d = map(int,input().split()) print(r/d-l/d)
s021310478
Accepted
27
9,140
54
l,r,d = map(int,input().split()) print(r//d-(l-1)//d)
s775855604
p03470
u597017430
2,000
262,144
Wrong Answer
17
3,060
160
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()) d = [0]*n for i in range(n): d[i] = int(input()) d.sort count = 1 for i in range(n-1): if d[i]>d[i+1]: count += 1 print(count) print(d)
s725387305
Accepted
17
3,060
167
n = int(input()) d = [0]*n for i in range(n): d[i] = int(input()) d.sort(reverse = True) count = 1 for i in range(n-1): if d[i]>d[i+1]: count += 1 print(count)
s503984707
p02262
u637322311
6,000
131,072
Wrong Answer
20
5,612
709
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
def read_n_lows_input(n): Alist=[int(input()) for i in range(n)] return Alist def print_list(A): print(*A, sep=" ") def print_list_multi_low(A): for i in A: print(i) def insertion_sort(A, n, g, cnt): for i in range(g-1, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j+g] = A[j] j -= g cnt += 1 A[j+g] = v return A, cnt def shell_sort(A, n): cnt = 0 G = [8, 4, 2, 1] m = len(G) print(m) print_list(G) for i in range(m): A, cnt = insertion_sort(A, n, G[i], cnt) print(cnt) print_list_multi_low(A) n=int(input()) A = read_n_lows_input(n) shell_sort(A, n)
s402292914
Accepted
17,750
45,520
804
def read_n_lows_input(n): Alist=[int(input()) for i in range(n)] return Alist def print_list(A): print(*A, sep=" ") def print_list_multi_low(A): for i in A: print(i) def insertion_sort(A, n, g, cnt): for i in range(g-1, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j+g] = A[j] j -= g cnt += 1 A[j+g] = v return A, cnt def shell_sort(A, n): cnt = 0 G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1] G = [i for i in G0 if i <= n] m = len(G) print(m) print_list(G) for i in range(m): A, cnt = insertion_sort(A, n, G[i], cnt) print(cnt) print_list_multi_low(A) n=int(input()) A = read_n_lows_input(n) shell_sort(A, n)
s904262777
p03592
u418199806
2,000
262,144
Wrong Answer
1,050
10,036
435
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
N, M, K = map(int, input().split()) if K == 0 : print('Yes') exit() for j in range(1, M): print("----", j) cnt = 0 for i in range(N * j, N*M, M-j): if cnt == 0: print(i) if K == i: print('Yes') exit() else : print(i - j) if K == i - j: print('Yes') exit() cnt += 1 print('No')
s236155388
Accepted
298
2,940
189
X, Y, K = map(int, input().split()) for Xi in range(0, X+1): for Yi in range(0, Y+1): if Yi * (X-Xi) + Xi * (Y-Yi) == K: print("Yes") exit() print("No")
s696988121
p00067
u756426560
1,000
131,072
Wrong Answer
20
7,708
511
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。 ■■■■□□□□■■■■ ■■■□□□□□■■■■ ■■□□□□□□■■■■ ■□□□□□□□■■■■ □□□■□□□■□□□□ □□□□□□■■■□□□ □□□□□■■■■■□□ ■□□□■■■■■■■□ ■■□□□■■■■■□□ ■■■□□□■■■□□□ ■■■■□□□■□□□□ □□□□□□□□□□□□ マスのデータを読み込んで、島の数を出力するプログラムを作成してください。
def remove_linked(x, y, DATA): DATA[x][y]=0# clear move = [[1, 0], [0, 1], [-1, 0], [0, -1]]#left, right, down, up for i, j in move: nx,ny=x+i,y+j#next x and y if -1<nx<12 and -1<ny<12 and DATA[nx][ny]: DATA=remove_linked(nx, ny, DATA) return DATA DATA = [[int(x) for x in list(input())] for _ in range(12)] count = 0 for x in range(12): for y in range(12): if DATA[x][y]: count += 1 DATA = remove_linked(x, y, DATA) print (count)
s860695270
Accepted
30
7,732
590
def remove_linked(x, y, DATA): DATA[x][y]=0# clear move = [[1, 0], [0, 1], [-1, 0], [0, -1]]#left, right, down, up for i, j in move: nx,ny=x+i,y+j#next x and y if -1<nx<12 and -1<ny<12 and DATA[nx][ny]: DATA=remove_linked(nx, ny, DATA) return DATA while 1: DATA = [[int(x) for x in list(input())] for _ in range(12)] count = 0 for x in range(12): for y in range(12): if DATA[x][y]: count += 1 DATA = remove_linked(x, y, DATA) print (count) try:input() except:break
s943967693
p02409
u340503368
1,000
131,072
Wrong Answer
20
5,624
430
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.
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] n = int(input()) for l in range(n): a,b,c,d = map(int, input().split()) rooms[a-1][b-1][c-1] += d for i in range(4): for j in range(3): for k in range(10): print(rooms[i][j][k], end = "") if k != 9: print(" ", end="") print() print("####################")
s810258102
Accepted
20
5,620
371
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)] n = int(input()) for l in range(n): a,b,c,d = map(int, input().split()) rooms[a-1][b-1][c-1] += d for i in range(4): for j in range(3): for k in range(10): print(" " + str(rooms[i][j][k]), end = "") print() if i != 3: print("####################")
s139636470
p03485
u361826811
2,000
262,144
Wrong Answer
17
3,060
244
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 readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) n, a = map(int, readline().rstrip().split()) print((n+a+1)/2 if (n+a)%2==1 else (n+a)/2)
s095104364
Accepted
17
3,060
261
import sys import itertools # import numpy as np read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines A, B = map(int, readline().split()) print((A+B+1)//2)
s784883225
p03550
u242679311
2,000
262,144
Wrong Answer
18
3,188
156
We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i. Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they will alternately perform the following action: * Draw some number of cards from the top of the deck. Then, discard the card in his hand and keep the last drawn card instead. Here, at least one card must be drawn. The game ends when there is no more card in the deck. The score of the game is the absolute difference of the integers written on the cards in the two players' hand. X will play the game so that the score will be maximized, and Y will play the game so that the score will be minimized. What will be the score of the game?
n,z,w = map(int,input().split()) a = list(map(int,input().split())) if n == 1: print(abs(a[0]-w)) else: print(min(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))
s761610788
Accepted
19
3,188
156
n,z,w = map(int,input().split()) a = list(map(int,input().split())) if n == 1: print(abs(a[0]-w)) else: print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))
s988849377
p03370
u404556828
2,000
262,144
Wrong Answer
278
3,060
213
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 = [int(x) for x in input().split()] list01=[] for i in range(N): j = int(input()) list01.append(j) i = 0 mass = sum(list01) while mass < X: i += 1 mass = sum(list01) + min(list01) * i print(i -1)
s662476278
Accepted
17
3,060
320
N, X = [int(x) for x in input().split()] list01 = [] for i in range(N): i = int(input()) list01.append(i) min_01 = 0 for i in range(len(list01)): if min_01 == 0: min_01 = list01[i] elif list01[i] < min_01: min_01 = list01[i] for i in range(len(list01)): X -= list01[i] print(X // min_01 + N)
s835117058
p02397
u105694406
1,000
131,072
Wrong Answer
50
7,604
119
Write a program which reads two integers x and y, and prints them in ascending order.
while 1: a, b = map(int, input().split()) if b < a: print(b, a) else: print(a, b) if a == 0 and b == 0: break
s505671897
Accepted
50
7,580
124
while 1: a, b = map(int, input().split()) if a == 0 and b == 0: break if b < a: print(b, a) else: print(a, b)
s663243680
p03024
u223904637
2,000
1,048,576
Wrong Answer
17
2,940
138
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
s=list(input()) o=0 z=len(s) for i in range(len(s)): if s[i]=='o': o+=1 if o+(15-z)>=8: print('Yes') else: print('No')
s331132676
Accepted
17
2,940
139
s=list(input()) o=0 z=len(s) for i in range(len(s)): if s[i]=='o': o+=1 if o+(15-z)>=8: print('YES') else: print('NO')
s975617562
p03080
u728047357
2,000
1,048,576
Wrong Answer
17
2,940
254
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
def main(): n = int(input()) // 2 numR = 0 for c in input(): if c != 'B': continue numR += 1 if numR > n: print("Yes") return print("No") if __name__ == '__main__': main()
s076995579
Accepted
17
2,940
254
def main(): n = int(input()) // 2 numR = 0 for c in input(): if c == 'B': continue numR += 1 if numR > n: print("Yes") return print("No") if __name__ == '__main__': main()
s539203801
p03963
u089230684
2,000
262,144
Wrong Answer
19
2,940
97
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
try: n = int(input()) k = int(input()) print(k * (k - 1) ** (n - 1)) except: pass
s724576572
Accepted
17
2,940
76
import math k,m=list(map(int,input().split())) res=m*pow(m-1,k-1) print(res)
s589437628
p03457
u838559130
2,000
262,144
Wrong Answer
397
3,064
315
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.
n = int(input()) flg = True t, x, y = 0, 0, 0 for i in range(n): nt, nx, ny = map(int, input().split()) dist = abs(x - nx) + abs(y - ny) dt = nt - t if dist > dt or (dist - dt) % 2 == 1: print("NO") flg = False break t, x, y = nt, nx, ny if flg == True: print("YES")
s568182588
Accepted
374
3,064
315
n = int(input()) flg = True t, x, y = 0, 0, 0 for i in range(n): nt, nx, ny = map(int, input().split()) dist = abs(x - nx) + abs(y - ny) dt = nt - t if dist > dt or (dist - dt) % 2 == 1: print("No") flg = False break t, x, y = nt, nx, ny if flg == True: print("Yes")
s214548558
p02612
u953020348
2,000
1,048,576
Wrong Answer
29
9,140
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.
x=input() print(int(x[-3:]))
s354882095
Accepted
27
9,144
62
x=int(input()) x=x%1000 x=1000-x if x==1000: x=0 print(x)
s765593335
p02259
u581154076
1,000
131,072
Wrong Answer
20
5,596
411
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
def main(): n = int(input()) a = [] for _ in range(n): a.append(int(input())) count = 0 flag = True while flag: flag = False for j in range(n-1, 0, -1): if a[j] < a[j-1]: a[j], a[j-1] = a[j-1], a[j] flag = True count += 1 print(a) print(count) if __name__ == '__main__': main()
s516853714
Accepted
20
5,608
388
def main(): n = int(input()) a = [int(i) for i in input().split()] count = 0 flag = True while flag: flag = False for j in range(n-1, 0, -1): if a[j] < a[j-1]: a[j], a[j-1] = a[j-1], a[j] flag = True count += 1 print(*a) print(count) if __name__ == '__main__': main()
s660905395
p04029
u560301743
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(N * (N + 1) / 2)
s244993965
Accepted
17
2,940
44
N = int(input()) print(int(N * (N + 1) / 2))
s709762444
p03478
u077127204
2,000
262,144
Wrong Answer
27
3,296
104
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()) sum([n for n in range(1, N + 1) if A <= sum(map(int, str(n))) <= B])
s923109558
Accepted
29
3,296
111
N, A, B = map(int, input().split()) print(sum([n for n in range(1, N + 1) if A <= sum(map(int, str(n))) <= B]))
s039071249
p03476
u608088992
2,000
262,144
Time Limit Exceeded
2,104
4,504
516
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 math Primes = {2} Sim = [0 for i in range(100002)] for i in range(3, 100001): if i % 2 == 0: Sim[i] = Sim[i-1] else: for p in Primes: if i % p == 0: Sim[i] = Sim[i-1] break else: Primes |= {i} if (i+1)//2 in Primes: Sim[i] = Sim[i-1] + 1 else: Sim[i] = Sim[i-1] Q = int(input()) for i in range(Q): l, r = map(int, input().split()) print(Sim[r] - Sim[l-1])
s442117689
Accepted
254
5,432
669
import sys def solve(): input = sys.stdin.readline isPrime = [True] * (1 + 10**5) isPrime[0] = isPrime[1] = False Like = [0] * (1 + 10 ** 5) for i in range(2, 1 + 10 ** 5): if isPrime[i]: k = 2 * i while k <= 10 ** 5: isPrime[k] = False k += i if i % 2 == 1 and isPrime[(i + 1) // 2]: Like[i] = Like[i-1] + 1 else: Like[i] = Like[i-1] else: Like[i] = Like[i-1] Q = int(input()) for _ in range(Q): l, r = map(int, input().split()) print(Like[r] - Like[l-1]) return 0 if __name__ == "__main__": solve()
s236461176
p02647
u894521144
2,000
1,048,576
Wrong Answer
2,206
53,604
673
We have N bulbs arranged on a number line, numbered 1 to N from left to right. Bulb i is at coordinate i. Each bulb has a non-negative integer parameter called intensity. When there is a bulb of intensity d at coordinate x, the bulb illuminates the segment from coordinate x-d-0.5 to x+d+0.5. Initially, the intensity of Bulb i is A_i. We will now do the following operation K times in a row: * For each integer i between 1 and N (inclusive), let B_i be the number of bulbs illuminating coordinate i. Then, change the intensity of each bulb i to B_i. Find the intensity of each bulb after the K operations.
import numpy as np from math import log def main(N, K, A): A = np.array(A, dtype = int) if K > log(N): A = [N for _ in range(N)] else: for k in range(K): B = np.zeros(N, dtype = int) for x in range(N): if A[x] >= N - 1: B += 1 else: minimum = max(0, x - A[x]) maximum = min(N, x + A[x] + 1) B[minimum:maximum] += 1 A = B print(' '.join([str(i) for i in A])) if __name__ == '__main__': N, K = list(map(int, input().split())) A = list(map(int, input().split())) main(N, K, A)
s717349019
Accepted
910
137,332
1,008
import numpy as np from numba import njit def main(N, K, A): @njit(cache = True) def rep(N, A): B = np.zeros(N + 1, dtype=np.int64) for x in range(N): minimum = max(0, x - A[x]) maximum = min(N, x + A[x] + 1) B[minimum] += 1 B[maximum] -= 1 return np.cumsum(B)[:-1] A = np.array(A, dtype=np.int64) for k in range(K): B = rep(N, A) if np.array_equal(A, B): break else: A = B return A if __name__ == '__main__': N, K = list(map(int, input().split())) A = list(map(int, input().split())) print(' '.join([str(i) for i in main(N, K, A)]))
s347183714
p04029
u251017754
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)
s346251551
Accepted
17
2,940
34
N = int(input()) print(N*(N+1)//2)
s191454989
p03401
u858523893
2,000
262,144
Wrong Answer
209
14,172
549
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
N = int(input()) a = list(map(int, input().split())) # calc dif a_zero = [0,] + a + [0,] a_d = [] for i in range(1, N + 2) : a_d.append(abs(a_zero[i] - a_zero[i - 1])) a_d_sum = sum(a_d) for i in range(N) : if i == N - 1 : if a[i] >= a[i - 1] : print(a_d_sum) else : print(a_d_sum - a_d[i] * 2) else : if abs(a[i]) <= abs(a[i + 1]) and ((a[i] >= 0 and a[i + 1] >= 0) or (a[i] < 0 and a[i + 1] < 0)): print(a_d_sum) else : print(a_d_sum - a_d[i] * 2)
s465960374
Accepted
270
14,164
620
N = int(input()) a = [int(x) for x in input().split()] d = [] prev = 0 for i in range(N + 1) : if i == 0 : d.append(abs(a[i])) elif i == N : d.append(abs(a[i - 1])) else : d.append(abs(prev - a[i])) if i != N : prev = a[i] totsum = sum(d) for i in range(N) : # for first if i == 0 : x, y, z = 0, a[i], a[i + 1] elif i == N - 1 : x, y, z = a[i - 1], a[i], 0 else : x, y, z = a[i - 1], a[i], a[i + 1] if x <= y <= z or x >= y >= z : print(totsum) else : print(totsum - abs(d[i] + d[i + 1]) + abs(d[i] - d[i + 1]))
s245040026
p03555
u338225045
2,000
262,144
Wrong Answer
17
3,060
184
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
S1 = input() S2 = input() isMatch = True for i in range( len(S1) ): if S1[i] != S2[-i]: isMatch = False break if isMatch: print( 'YES' ) else: print( 'NO' )
s944140727
Accepted
20
2,940
186
S1 = input() S2 = input() isMatch = True for i in range( len(S1) ): if S1[i] != S2[-i-1]: isMatch = False break if isMatch: print( 'YES' ) else: print( 'NO' )
s489647861
p03377
u059684735
2,000
262,144
Wrong Answer
17
3,064
146
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 == x: print('Yes') elif a+b >= x: print('Yes') else: print('No')
s058480011
Accepted
17
2,940
95
a, b, x = map(int, input().split()) if a <= x <= a + b: print('YES') else: print('NO')
s771152288
p03861
u946386741
2,000
262,144
Wrong Answer
22
3,316
108
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()) result = 0 if a is 0: result = 1 result += (b-a)//x print(result)
s206497645
Accepted
18
2,940
131
a, b, x = map(int, input().split()) def f(n): if n >= 0: return n//x+1 else: return 0 print(f(b)-f(a-1))
s765718369
p03448
u663014688
2,000
262,144
Wrong Answer
47
3,060
231
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): for j in range(B): for k in range(C): if 500 * i + 100 * j + 50 * k == X: ans += 1 print(ans)
s536932283
Accepted
50
3,060
239
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 (500 * i + 100 * j + 50 * k) == X: ans += 1 print(ans)
s795410675
p03729
u124498235
2,000
262,144
Wrong Answer
17
2,940
33
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 = str(input()) print("ABC" + a)
s422619631
Accepted
17
2,940
105
a, b, c = map(str,input().split()) if a[-1] == b[0] and b[-1] == c[0]: print ("YES") else: print ("NO")
s424344227
p03139
u994988729
2,000
1,048,576
Wrong Answer
17
2,940
72
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()) and_=abs(a-b) or_=a+b-n print(and_, or_)
s575065876
Accepted
17
2,940
79
n,a,b=map(int,input().split()) and_=min(a,b) or_=max(0, a+b-n) print(and_, or_)
s662605662
p03545
u405660020
2,000
262,144
Wrong Answer
18
2,940
207
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 op1 in op: for op2 in op: for op3 in op: tmp=s[0]+op1+s[1]+op2+s[2]+op3+s[3] if eval(tmp)==7: print(tmp) break
s037066864
Accepted
18
2,940
197
s=input() op=['+', '-'] for op1 in op: for op2 in op: for op3 in op: tmp=s[0]+op1+s[1]+op2+s[2]+op3+s[3] if eval(tmp)==7: ans=tmp print(ans+'=7')
s381765983
p02605
u729133443
3,000
1,048,576
Wrong Answer
903
71,508
330
M-kun is a brilliant air traffic controller. On the display of his radar, there are N airplanes numbered 1, 2, ..., N, all flying at the same altitude. Each of the airplanes flies at a constant speed of 0.1 per second in a constant direction. The current coordinates of the airplane numbered i are (X_i, Y_i), and the direction of the airplane is as follows: * if U_i is `U`, it flies in the positive y direction; * if U_i is `R`, it flies in the positive x direction; * if U_i is `D`, it flies in the negative y direction; * if U_i is `L`, it flies in the negative x direction. To help M-kun in his work, determine whether there is a pair of airplanes that will collide with each other if they keep flying as they are now. If there is such a pair, find the number of seconds after which the first collision will happen. We assume that the airplanes are negligibly small so that two airplanes only collide when they reach the same coordinates simultaneously.
d=[[],[],[],[]] for t in[*open(0)][1:]:*z,u=t.split();d[ord(u)%5]+=[*map(int,z)], I=N=9e9 P,M='x+y,','x-y,' for*A,S in(3,0,'x,y,'),(1,2,'y,x,'),(0,2,P+M),(1,3,P+M),(1,0,M+P),(3,2,M+P): n=p=-I for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in d[P])'%S): if r:n,p=x,y elif x==n:N=min(N,y-p) print(N%I*5or'SAFE')
s845274450
Accepted
2,812
72,464
318
I,*U=N,*D=9**9, P,*L='x+y,', M,*R='x-y,', for t in[*open(0)][1:]:*z,u=t.split();exec(u+'+=[*map(int,z)],') for*A,S in(D,U,'x,y,'),(L,R,'y,x,'),(U,R,P+M),(L,D,P+M),(L,U,M+P),(D,R,M+P): for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in P)'%S): if r:S,p=x,y elif x==S:N=min(N,y-p) print(N%I*5or'SAFE')
s796978614
p03474
u981864683
2,000
262,144
Wrong Answer
30
9,008
197
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
A,B = map(int,input().split()) S = input() count = "No" if S[:A+1].isnumeric(): if S[A+1] == "-": if len(S[A+2:]) == B and S[A+2:].isnumeric(): count = "Yes" print(count)
s145046340
Accepted
27
9,104
193
A,B = map(int,input().split()) S = input() count = "No" if S[:A].isnumeric(): if S[A] == "-": if len(S[A+1:]) == B and S[A+1:].isnumeric(): count = "Yes" print(count)
s580583546
p03024
u688126754
2,000
1,048,576
Wrong Answer
17
2,940
139
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
S = input() lose = 0 for i in range(len(S)): if S[i] == "x": lose += 1 if lose >= 8: print("No") else: print("Yes")
s252601722
Accepted
17
2,940
139
S = input() lose = 0 for i in range(len(S)): if S[i] == "x": lose += 1 if lose >= 8: print("NO") else: print("YES")
s589362962
p03827
u821251381
2,000
262,144
Wrong Answer
17
2,940
105
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
S=input() max_v =0 v =0 for i in S: if i=="I": v+=0 if v>max_v: max_v=v else: v-=0
s399897773
Accepted
17
2,940
127
N=input() S=input() max_v =0 v =0 for i in S: if i=="I": v+=1 if v>max_v: max_v=v else: v-=1 print(max_v)
s298005393
p03369
u729133443
2,000
262,144
Wrong Answer
17
2,940
41
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(700+list(input()).count('○')*100)
s418003240
Accepted
27
8,932
33
print(700+input().count('o')*100)
s826563505
p02613
u807241701
2,000
1,048,576
Wrong Answer
177
16,188
368
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N = int(input()) X = [] for i in range(N): X.append(input()) AC = 0 WA = 0 TLE = 0 RE = 0 for s in X: print(s) if s == 'AC': AC += 1 elif s == 'WA': WA += 1 elif s == 'TLE': TLE += 1 elif s == 'RE': RE += 1 print('AC x ' + str(AC)) print('WA x ' + str(WA)) print('TLE x ' + str(TLE)) print('RE x ' + str(RE))
s682519161
Accepted
153
16,236
355
N = int(input()) X = [] for i in range(N): X.append(input()) AC = 0 WA = 0 TLE = 0 RE = 0 for s in X: if s == 'AC': AC += 1 elif s == 'WA': WA += 1 elif s == 'TLE': TLE += 1 elif s == 'RE': RE += 1 print('AC x ' + str(AC)) print('WA x ' + str(WA)) print('TLE x ' + str(TLE)) print('RE x ' + str(RE))
s299817668
p03469
u266171694
2,000
262,144
Wrong Answer
17
3,064
34
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('2017' + s[4::])
s365918576
Accepted
17
2,940
33
s = input() print('2018' + s[4:])
s615358116
p03478
u870297120
2,000
262,144
Wrong Answer
19
3,064
98
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()) x = sum(i for i in range(1, N) if A <= i//10+i%10 <= B) print(x)
s903033329
Accepted
32
2,940
117
N,A,B = map(int, input().split()) x = sum(i for i in range(1, N+1) if A <= sum(map(int, list(str(i)))) <= B) print(x)
s181532470
p03795
u853900545
2,000
262,144
Wrong Answer
17
2,940
38
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
n=int(input()) print(800*n-50*(n//15))
s293611861
Accepted
17
2,940
40
n=int(input()) print(800*n-200*(n//15))
s072942873
p03740
u931938233
2,000
262,144
Wrong Answer
27
9,064
72
Alice and Brown loves games. Today, they will play the following game. In this game, there are two piles initially consisting of X and Y stones, respectively. Alice and Bob alternately perform the following operation, starting from Alice: * Take 2i stones from one of the piles. Then, throw away i of them, and put the remaining i in the other pile. Here, the integer i (1≤i) can be freely chosen as long as there is a sufficient number of stones in the pile. The player who becomes unable to perform the operation, loses the game. Given X and Y, determine the winner of the game, assuming that both players play optimally.
X,Y=map(int,input().split()) print('Alice' if abs(X-Y) < 2 else 'Brown')
s424355613
Accepted
28
9,008
72
X,Y=map(int,input().split()) print('Alice' if abs(X-Y) > 1 else 'Brown')
s786700688
p03730
u637451088
2,000
262,144
Wrong Answer
17
2,940
168
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
import sys a, b, c = map(int, input().split()) flag = False for i in range(a, b*a+1, a): if i % b == c: flag = True print("Yes") if flag else print("No")
s978597977
Accepted
18
2,940
168
import sys a, b, c = map(int, input().split()) flag = False for i in range(a, b*a+1, a): if i % b == c: flag = True print("YES") if flag else print("NO")
s231862353
p03836
u060455496
2,000
262,144
Wrong Answer
17
3,064
521
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.
def main(): sx,sy,tx,ty = map(int,input().split()) path ='' ly,lx = abs(ty-sy),abs(tx-sx) path += 'U' * ly path += 'R' * lx path += 'D' * ly path += 'L' * lx path += 'L' + 'U' * (ly+1) path += 'R' * (lx+1) + 'D' path += 'R' +'U'*(ly+1) path += 'L'*(lx+1) +'U' print(path) if __name__ == '__main__': main()
s290354220
Accepted
18
3,064
521
def main(): sx,sy,tx,ty = map(int,input().split()) path ='' ly,lx = abs(ty-sy),abs(tx-sx) path += 'U' * ly path += 'R' * lx path += 'D' * ly path += 'L' * lx path += 'L' + 'U' * (ly+1) path += 'R' * (lx+1) + 'D' path += 'R' +'D'*(ly+1) path += 'L'*(lx+1) +'U' print(path) if __name__ == '__main__': main()
s815683714
p03494
u081714930
2,000
262,144
Time Limit Exceeded
2,205
9,040
172
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()) n_length=list(map(int,input().split())) counter=0 while all(i%2==0 for i in n_length): n_list=[i/2 for i in n_length] counter=+1 print(counter)
s196426985
Accepted
29
9,176
170
n = int(input()) a = list(map(int, input().split())) cnt = 0 while True: if [i for i in a if i % 2 == 1]: break a = [i/2 for i in a] cnt += 1 print(cnt)
s142818488
p03555
u751863169
2,000
262,144
Wrong Answer
17
3,060
324
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
#!/usr/bin/env python def main(): matrix = [] for _ in range(2): matrix.append(list(input())) if matrix[0][0] == matrix[1][2] \ and matrix[0][1] == matrix[1][1] \ and matrix[0][2] == matrix[1][0]: print("Yes") else: print("No") if __name__ == '__main__': main()
s496231228
Accepted
18
3,060
302
def main(): matrix = [] for _ in range(2): matrix.append(list(input())) if matrix[0][0] == matrix[1][2] \ and matrix[0][1] == matrix[1][1] \ and matrix[0][2] == matrix[1][0]: print("YES") else: print("NO") if __name__ == '__main__': main()
s383531925
p03598
u385244248
2,000
262,144
Wrong Answer
17
2,940
76
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
N,K,*x =map(int,open(0).read().split()) print(sum([min(i,K-i) for i in x]))
s828470417
Accepted
17
2,940
78
N,K,*x =map(int,open(0).read().split()) print(sum(2*[min(i,K-i) for i in x]))
s521323737
p03456
u452198080
2,000
262,144
Wrong Answer
17
2,940
103
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=input().split() d=int(a[0]+a[1]) x=int(math.sqrt(d)) x=x*x print("YES" if x==d else "No")
s343771493
Accepted
17
2,940
103
import math a=input().split() d=int(a[0]+a[1]) x=int(math.sqrt(d)) x=x*x print("Yes" if x==d else "No")
s416245615
p03997
u616188005
2,000
262,144
Wrong Answer
17
2,940
67
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h/2)
s986576134
Accepted
17
2,940
82
a = int(input()) b = int(input()) h = int(input()) ans = (a+b)*h/2 print(int(ans))
s901684161
p02833
u732870425
2,000
1,048,576
Time Limit Exceeded
2,104
2,940
134
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
N = int(input()) ans = 0 i = 0 while True: x = (2 * 5 * (5 ** i)) if x <= N: ans += N // x i += 1 print(ans)
s386567186
Accepted
17
2,940
182
N = int(input()) ans = 0 if N % 2 == 0: i = 0 while True: x = (2 * 5 * (5 ** i)) if x > N: break ans += N // x i += 1 print(ans)
s970579740
p03380
u177040005
2,000
262,144
Wrong Answer
82
14,052
700
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 bisect N = int(input()) A = sorted(list(map(int,input().split()))) if N == 2: print(A[-1],A[0]) exit() r_val = A[-1]//2 r_ind = bisect.bisect_left(A,r_val,0,N-1) # if abs(A[-1]/2 - float(A[r_ind])) < abs(A[-1]/2 - float(A[min(r_ind+1,N-2)])): # r_ind = r_ind + 1 #print(A[r_ind]) ans = [A[-1],A[r_ind]] # print(A) # for i,n in enumerate(A[:-1]): # print(i,n,n//2) # r_val = n // 2 # if abs(n/2 - A[r_ind]) > abs(n/2 - A[r_ind+1]): # r_ind = r_ind + 1 # print(r_val,'r_ind = ',r_ind,A[r_ind]) # r = A[r_ind] # print(n,r,comb(n,r)) # if max_comb < comb(n,r): # ans = [n,r] print(ans)
s670754201
Accepted
127
14,428
234
N = int(input()) A = sorted(list(map(int,input().split()))) n = A[-1] A = A[:-1] r_val = n//2 diff_min = float(n) for a in A: diff = abs(n/2 - float(a)) if diff_min > diff: diff_min = diff r = a print(n,r)
s681377390
p03478
u382303205
2,000
262,144
Wrong Answer
72
3,060
262
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()) count = 0 for i in range(1, n + 1): tmp = i x = 0 for j in range(5)[::-1]: x += tmp // (10**j) tmp = tmp - (tmp // (10**j))*(10**j) if a <= x <= b: count +=1 print(count)
s906756215
Accepted
69
3,060
257
n,a,b = map(int,input().split()) sum = 0 for i in range(1, n + 1): tmp = i x = 0 for j in range(5)[::-1]: x += tmp // (10**j) tmp = tmp - (tmp // (10**j))*(10**j) if a <= x <= b: sum += i print(sum)
s877451487
p02795
u760961723
2,000
1,048,576
Wrong Answer
17
2,940
64
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.
H,W,N = [int(input()) for i in range(3)] print(min(N//H,N//W))
s142846344
Accepted
18
2,940
98
import math H,W,N = [int(input()) for i in range(3)] print(min(math.ceil(N/H),math.ceil(N/W)))
s452022980
p03394
u052499405
2,000
262,144
Wrong Answer
27
5,488
822
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.
import math k = int(input()) if k == 3: print("3 6 9") elif k == 4: print("3 9 2 4") elif k == 6: print("3 9 2 4 8 10") elif k <= 15002: prints = set([3, 9]) k -= 2 for i in range(int(math.ceil(k / 3))): prints.add(i*6+2) prints.add(i*6+4) prints.add(i*6+6) if 3 - k % 3 == 1: prints.remove(6) if 3 - k % 3 == 2: prints.remove(6) prints.remove(12) print(" ".join([str(item) for item in prints])) else: prints = set() for i in range(5000): prints.add(i*6+2) prints.add(i*6+4) prints.add(i*6+6) k -= 15000 for i in range(int(math.ceil(k / 2))): prints.add(i*12+3) prints.add(i*12+9) if 3 - k % 3 == 1: prints.remove(6) print(" ".join([str(item) for item in prints]))
s879798496
Accepted
26
5,488
823
import math k = int(input()) if k == 3: print("2 5 63") elif k == 4: print("3 9 2 4") elif k == 6: print("3 9 2 4 8 10") elif k <= 15002: prints = set([3, 9]) k -= 2 for i in range(int(math.ceil(k / 3))): prints.add(i*6+2) prints.add(i*6+4) prints.add(i*6+6) if 3 - k % 3 == 1: prints.remove(6) if 3 - k % 3 == 2: prints.remove(6) prints.remove(12) print(" ".join([str(item) for item in prints])) else: prints = set() for i in range(5000): prints.add(i*6+2) prints.add(i*6+4) prints.add(i*6+6) k -= 15000 for i in range(int(math.ceil(k / 2))): prints.add(i*12+3) prints.add(i*12+9) if 2 - k % 2 == 1: prints.remove(6) print(" ".join([str(item) for item in prints]))
s159123908
p03130
u191635495
2,000
1,048,576
Wrong Answer
17
3,064
247
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads. Determine if we can visit all the towns by traversing each of the roads exactly once.
a1, b1 = map(int, input().split()) a2, b2 = map(int, input().split()) a3, b3 = map(int, input().split()) l = [a1, a2, a3, b1, b2, b3] res = [sum([1 for _ in l if _ == __]) for __ in [1,2,3,4]] if 3 in res: print("No") else: print("Yes")
s205602946
Accepted
17
3,060
248
a1, b1 = map(int, input().split()) a2, b2 = map(int, input().split()) a3, b3 = map(int, input().split()) l = [a1, a2, a3, b1, b2, b3] res = [sum([1 for _ in l if _ == __]) for __ in [1,2,3,4]] if 3 in res: print("NO") else: print("YES")
s662403884
p03611
u188138642
2,000
262,144
Wrong Answer
69
20,680
186
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
n = int(input()) p = list(map(int, input().split())) i=0 ans =0 while i<n: if p[i]==i+1: ans += 1 i+=1 if not (i==n-2 and p[i+1]==i+2): i += 1 print(ans)
s637659426
Accepted
114
31,696
195
from collections import Counter n = int(input()) a = list(map(int, input().split())) c = [] for i in a: c.append(i) c.append(i-1) c.append(i+1) c = Counter(c) print(max(c.values()))
s869699348
p03037
u094932051
2,000
1,048,576
Wrong Answer
373
27,332
301
We have N ID cards, and there are M gates. We can pass the i-th gate if we have one of the following ID cards: the L_i- th, (L_i+1)-th, ..., and R_i-th ID cards. How many of the ID cards allow us to pass all the gates alone?
while True: try: N, M = map(int, input().split()) gate = [list(map(int, input().split())) for i in range(M)] L, R = 0, 10**5+5 for l, r in gate: L = max(L, l) R = min(R, r) print(R-L+1) except: break
s541041364
Accepted
346
3,956
418
while True: try: N, M = map(int, input().split()) dp = [0]*(10**5+5) for i in range(M): L, R = map(int, input().split()) dp[L-1] += 1 dp[R] -= 1 cnt = 0 ans = 0 for i in range(N): cnt += dp[i] if cnt == M: ans += 1 print(ans) except: break
s795897639
p03854
u591287669
2,000
262,144
Wrong Answer
72
3,188
236
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 len(s)>0: if s[-5:]=='erase' or s[-5:]=='dream': s=s[:-5] elif s[-6:]=='eraser': s=s[:-6] elif s[-7:]=='dreamer': s=s[:-7] else: print('No') exit(0) print('Yes')
s047869423
Accepted
72
3,316
236
s = input() while len(s)>0: if s[-5:]=='erase' or s[-5:]=='dream': s=s[:-5] elif s[-6:]=='eraser': s=s[:-6] elif s[-7:]=='dreamer': s=s[:-7] else: print('NO') exit(0) print('YES')
s036461251
p03565
u465101448
2,000
262,144
Wrong Answer
17
3,064
766
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`.
S = list(input())[:-1] T = list(input())[:-1] ans_list=[] for i in range(len(S)-len(T)+1): S_temp=S.copy() serch_S=S_temp[i:i+len(T)] # print(serch_S) count=0 for t in range(len(T)): if serch_S[t] in [T[t],'?']: # print(serch_S[t]) count+=1 else: break if count==len(T): S_temp[i:i+len(T)]=T for s in range(len(S_temp)): if S_temp[s]=='?': S_temp[s]='a' S_temp_str='' for s_t in S_temp: S_temp_str+=s_t ans_list.append(S_temp_str) if len(ans_list)>0: ans_list.sort() ans=ans_list[0] else: ans='UNRESTORABLE' print(ans)
s923185424
Accepted
18
3,064
703
S = list(input()) T = list(input()) ans_list=[] for i in range(len(S)-len(T)+1): S_temp=S.copy() serch_S=S_temp[i:i+len(T)] count=0 for t in range(len(T)): if serch_S[t] in [T[t],'?']: count+=1 else: break if count==len(T): S_temp[i:i+len(T)]=T for s in range(len(S_temp)): if S_temp[s]=='?': S_temp[s]='a' S_temp_str='' for s_t in S_temp: S_temp_str+=s_t ans_list.append(S_temp_str) if len(ans_list)>0: ans_list.sort() ans=ans_list[0] else: ans='UNRESTORABLE' print(ans)
s463175084
p03352
u870518235
2,000
1,048,576
Wrong Answer
27
9,384
40
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X = int(input()) print(int(X**0.5-1)**2)
s616481319
Accepted
33
9,176
235
X = int(input()) lst = [] for i in range(1,101): for j in range(2,11): if i**j > 1000: break else: lst.append(i**j) for k in range(X): if X - k in lst: print(X-k) break
s798467450
p04043
u995062424
2,000
262,144
Wrong Answer
16
2,940
133
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() if a.count('5') == 2: if a.count('7') == 1: print('yes') else: print('no') else: print('no')
s052420118
Accepted
16
2,940
141
a = input().split() if a.count('5') == 2: if a.count('7') == 1: print('YES') else: print('NO') else: print('NO')
s075118071
p02618
u312078744
2,000
1,048,576
Wrong Answer
127
27,360
658
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows. * The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative. * Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}. * If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)). Please schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.
import sys import numpy as np from operator import mul read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines d = int(readline()) c = list(map(int, readline().split())) s = [] for _ in range(d): add = list(map(int, readline().split())) s.append(add) #t = [0] * d day = 0 satisfy = 0 sumC = sum(c) count = np.zeros(26) for i in range(d): #t = int(readline()) - 1 tarLis = s[day] tar = max(tarLis) t = tarLis.index(tar) up = s[day][t] count += 1 count[t] = 0 sub = map(mul, count, c) satisfy += (up - sum(sub)) # satisfy print(int(satisfy)) day += 1
s348286315
Accepted
132
27,240
686
import sys import numpy as np from operator import mul read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines d = int(readline()) c = list(map(int, readline().split())) s = [] for _ in range(d): add = list(map(int, readline().split())) s.append(add) #t = [0] * d day = 0 satisfy = 0 sumC = sum(c) count = np.zeros(26) for i in range(d): #t = int(readline()) - 1 tarLis = s[day] tar = max(tarLis) t = tarLis.index(tar) + 1 print(t) day += 1 ''' up = s[day][t] count += 1 count[t] = 0 sub = map(mul, count, c) satisfy += (up - sum(sub)) # satisfy print(satisfy) '''
s616208360
p02397
u092736322
1,000
131,072
Wrong Answer
20
5,596
226
Write a program which reads two integers x and y, and prints them in ascending order.
for i in range(3000): k=input().split() a=int(k[0]) b=int(k[0]) if a==0 and b==0: break else: if a<b: print(str(a)+" "+str(b)) else: print(str(b)+" "+str(a))
s110052992
Accepted
50
5,612
226
for i in range(3000): k=input().split() a=int(k[0]) b=int(k[1]) if a==0 and b==0: break else: if a<b: print(str(a)+" "+str(b)) else: print(str(b)+" "+str(a))
s682298333
p03569
u354915818
2,000
262,144
Wrong Answer
2,108
21,516
709
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required.
# coding: utf-8 # Here your code ! #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 9 22:12:40 2017 @author: kitagenbakurou """ import numpy as np import copy def insert(pos, s, x): return x.join([s[:pos], s[pos:] ]) s = input() N = len(s) i = 0 cnt = 0 flag = True while i < N - i - 1 : if s[i] != s[N - i - 1] : if s[i] == "x" : cnt += 1 s = insert(N - i , s , "x") i = -1 elif s[N - i - 1] == "x" : cnt += 1 s = insert(i , s , "x") i = -1 else : flag = False break N = len(s) i += 1 print(s) if flag : print(cnt) else : print(-1)
s387956002
Accepted
204
12,724
741
# coding: utf-8 # Here your code ! #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 9 22:12:40 2017 @author: kitagenbakurou """ import numpy as np import copy def insert(pos, s, x): return x.join([s[:pos], s[pos:] ]) s = input() N = len(s) i = 0 j = N - 1 cnt = 0 flag = True while i < j : if s[i] != s[j] : if s[i] == "x" : cnt += 1 i += 1 j += 0 elif s[j] == "x" : cnt += 1 i +=0 j -= 1 else : flag = False break else : i += 1 j -= 1 if flag : print(cnt) else : print(-1)
s985290545
p03494
u818542539
2,000
262,144
Wrong Answer
19
3,060
221
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()) As = [int(c) for c in input().split()] counter = 0 w = 0 while w == 0: for i in range(N): if As[i] % 2 != 0: w = 1 As[i] = int(As[i] / 2) counter += 1 print(counter)
s959623897
Accepted
18
3,060
254
N = int(input()) As = [int(c) for c in input().split()] counter = 0 while True: for i in range(N): if As[i] % 2 != 0: break As[i] = int(As[i] / 2) else: counter += 1 continue break print(counter)
s571430169
p03409
u064408584
2,000
262,144
Wrong Answer
19
3,064
434
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
n=int(input()) a=[] b=[] for i in range(n): a.append(list(map(int,input().split()))) for i in range(n): b.append(list(map(int,input().split()))) an=sorted(a,reverse=True) bn=sorted(b,reverse=True) print(an,bn) count=0 for i in range(len(bn)): for j in range(len(an)): # print(an[j],bn[i]) if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]: count+=1 an.pop(j) break print(count)
s578003937
Accepted
19
3,064
444
n=int(input()) a=[] b=[] for i in range(n): a.append(list(map(int,input().split()))) for i in range(n): b.append(list(map(int,input().split()))) an=sorted(a, key=lambda x:-x[1]) bn=sorted(b)#, key=lambda x:(x[0],x[1])) count=0 for i in range(len(bn)): for j in range(len(an)): # print(an[j],bn[i]) if bn[i][0]>an[j][0] and bn[i][1]>an[j][1]: count+=1 an.pop(j) break print(count)
s689664470
p03351
u682730715
2,000
1,048,576
Wrong Answer
17
2,940
91
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(a-c) <= d: print('Yes') else: print('No')
s743729473
Accepted
17
2,940
132
a, b, c, d = map(int, input().split()) if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d): print('Yes') else: print('No')
s871184672
p02612
u353548710
2,000
1,048,576
Wrong Answer
31
9,140
36
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.
pay = int(input()) print( pay%1000 )
s912028521
Accepted
27
9,144
72
pay = int(input())%1000 if pay == 0: print(0) else: print(1000- pay)
s681292541
p03067
u118867138
2,000
1,048,576
Wrong Answer
17
2,940
89
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 = map(int, input().split()) if C<A and B>A: print("Yes") else: print("No")
s302343587
Accepted
17
3,060
124
A,B,C = map(int, input().split()) if C<A and B<C: print("Yes") elif C>A and B>C: print("Yes") else: print("No")
s381906873
p02612
u631579948
2,000
1,048,576
Wrong Answer
33
9,076
56
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.
a=int(input()) while a>=1000: a-=1000 print(a)
s956696448
Accepted
34
9,144
53
a=int(input()) while a>1000: a-=1000 print(1000-a)
s744096848
p03455
u752552310
2,000
262,144
Wrong Answer
21
3,316
84
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a, b = map(int, input().split()) if a*b%2 == 0: print("Odd") else: print("Even")
s860633973
Accepted
17
2,940
86
a, b = map(int, input().split()) if (a*b)%2 != 0: print("Odd") else: print("Even")
s205871339
p00003
u316584871
1,000
131,072
Wrong Answer
40
5,596
191
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.
for i in range(int(input())): llist = list(map(int,input().split())) llist.sort() if(llist[2]**2 == llist[0]**2 + llist[1]**2): print('Yes') else: print('No')
s176331758
Accepted
40
5,600
191
for i in range(int(input())): llist = list(map(int,input().split())) llist.sort() if(llist[2]**2 == llist[0]**2 + llist[1]**2): print('YES') else: print('NO')
s010685490
p03997
u862757671
2,000
262,144
Wrong Answer
17
2,940
73
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)
s637964990
Accepted
17
2,940
78
a = int(input()) b = int(input()) h = int(input()) print(int((a + b) * h / 2))
s313198438
p03548
u960171798
2,000
262,144
Wrong Answer
17
2,940
68
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?
x,y,z = map(int, input().split()) ans = 1+(x-y-2*z)/(y+z) print(ans)
s003339515
Accepted
17
2,940
69
x,y,z = map(int, input().split()) ans = 1+(x-y-2*z)//(y+z) print(ans)
s507050134
p03493
u331464808
2,000
262,144
Wrong Answer
18
3,064
99
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.
A = list(map(int, input().split())) res = 0 for i in range(len(A)): res =res + A[i] print(res)
s136664200
Accepted
17
2,940
58
s = input() res = 0 for v in s: res += int(v) print(res)
s121805812
p03360
u226873514
2,000
262,144
Wrong Answer
17
2,940
94
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
a = list(map(int, input().split())) k = int(input()) a.sort() print(a[2] ** k + a[1] + a[0])
s267360033
Accepted
17
2,940
100
a = list(map(int, input().split())) k = int(input()) a.sort() print(a[2] * (2 ** k) + a[1] + a[0])