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
s157893759
p03992
u331464808
2,000
262,144
Wrong Answer
17
2,940
34
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the fi...
s = input() print(s[:3]+' '+s[4:])
s614170133
Accepted
18
2,940
34
s = input() print(s[:4]+' '+s[4:])
s607417254
p03555
u152638361
2,000
262,144
Wrong Answer
17
2,940
100
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() if a[0]==b[2] and a[1]==b[2] and a[2]==b[0]: print("YES") else: print("NO")
s490582163
Accepted
17
2,940
100
a = input() b = input() if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print("YES") else: print("NO")
s721374980
p02697
u511268447
2,000
1,048,576
Wrong Answer
106
9,292
784
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fi...
if __name__ == '__main__': from sys import stdin # from collections import defaultdict import math input = stdin.readline # import random n, m = map(int, input().split()) """ a = random.randint(1, 10**6) b = random.randint(1, 10**6) n = random.randint(1, 10**12) """ # ...
s890378706
Accepted
95
9,280
499
if __name__ == '__main__': from sys import stdin # from collections import defaultdict import math input = stdin.readline # import random n, m = map(int, input().split()) """ a = random.randint(1, 10**6) b = random.randint(1, 10**6) n = random.randint(1, 10**12) """ # ...
s869923092
p03377
u207799478
2,000
262,144
Wrong Answer
17
2,940
186
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.
def readints(): return list(map(int, input().split())) A, B, X = map(int, input().split()) if A+B < X: print("No") exit() if A > X: print("No") exit() print("Yes")
s509628722
Accepted
17
2,940
186
def readints(): return list(map(int, input().split())) A, B, X = map(int, input().split()) if A+B < X: print("NO") exit() if A > X: print("NO") exit() print("YES")
s969917800
p03827
u408958033
2,000
262,144
Wrong Answer
17
2,940
124
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 duri...
n = int(input()) s = input() x = 0 i = 0 for i in range(len(s)): i = i + (s[i]=='I') - (s[i]=='D') x = max(x,i) print(x)
s965367450
Accepted
17
2,940
125
n = int(input()) s = input() x = 0 j = 0 for i in range(len(s)): j = j + (s[i]=='I') - (s[i]=='D') x = max(x,j) print(x)
s949223792
p02262
u320121447
6,000
131,072
Wrong Answer
30
5,604
682
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+...
def swap(A, i, j): tmp = A[i] A[i] = A[j] A[j] = tmp def insertionSort(A, n, g): global cnt for i in range(g, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j+g] = A[j] j = j - g cnt += 1 A[j+g] = v def shellSort(A, n): ...
s633587482
Accepted
19,090
45,516
652
from sys import stdin def insertionSort(A, n, g): global cnt for i in range(g, n): v = A[i] j = i - g while j >= 0 and A[j] > v: A[j+g] = A[j] j = j - g cnt += 1 A[j+g] = v def shellSort(A, n): global cnt cnt = 0 g = 1 G = [...
s835158093
p02821
u106298129
2,000
1,048,576
Wrong Answer
2,136
535,116
288
Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i. Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows: * Takahashi c...
N, M = map(int, input().split()) tmp = input().split() A = [int(tmp[i]) for i in range(N)] score = [0 for i in range(N*N)] print(A) for i in range(N): for j in range(N): score[i*N+j] = A[i] + A[j] score.sort() sum = 0 for i in range(M): sum += score[N*N-1-i] print(sum)
s020943345
Accepted
1,343
20,584
997
N, M = map(int, input().split()) tmp = input().split() A = [int(tmp[i]) for i in range(N)] A.sort() cum_A = [None]*N cum_A[N-1] = A[N-1] for i in range(1,N): cum_A[N-1-i] = cum_A[N-i] + A[N-1-i] cum_A.append(0) def geq(A, cum_A, X, N): sum = 0 val = 0 index = 0 for i in range(N): while...
s480029031
p03339
u853900545
2,000
1,048,576
Wrong Answer
2,104
8,100
110
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of the...
n=int(input()) s=input() c=[0]*n for i in range(n): c[i]=c[i+1:].count('E')+c[:i].count('W') print(min(c))
s297630050
Accepted
175
3,672
157
n=int(input()) s=input() c=s[1:].count('E') a=c for i in range(1,n): if s[i-1]=='W': c+=1 if s[i]=='E': c-=1 a=min(a,c) print(a)
s894017268
p03730
u540762794
2,000
262,144
Wrong Answer
28
9,172
266
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 objecti...
# -*- coding: utf-8 -*- A,B,C = map(int, input().split()) mod = [] for i in range(max(B,C)): res = A * i % B if res == C: ans = "Yes" print(i) break if res in mod: ans = "No" break mod.append(res) print(ans)
s264067606
Accepted
28
9,136
174
# -*- coding: utf-8 -*- A,B,C = map(int, input().split()) ans = "NO" for i in range(B+1): res = A * i % B if res == C: ans = "YES" break print(ans)
s373104059
p03407
u860546679
2,000
262,144
Wrong Answer
17
2,940
70
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
a,b,c=map(int,input().split()) print("Yes") if a+b<=c else print("No")
s094074745
Accepted
17
2,940
69
a,b,c=map(int,input().split()) print("No") if a+b<c else print("Yes")
s451158823
p03370
u107091170
2,000
262,144
Wrong Answer
17
2,940
133
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 o...
N,X=map(int, input().split()) mmin = 10000000 for i in range(N): m = int(input()) X -= m mmin = min(m, mmin) ans = N + X//mmin
s959248909
Accepted
17
2,940
143
N,X=map(int, input().split()) mmin = 10000000 for i in range(N): m = int(input()) X -= m mmin = min(m, mmin) ans = N + X//mmin print(ans)
s484226576
p03471
u635958201
2,000
262,144
Wrong Answer
801
3,060
191
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situat...
N,Y=map(int,input().split()) Y=Y/1000 ans=[-1,-1,-1] for i in range(N): for j in range(N-i): if 10*i+5*j+N-i-j==Y: ans=[i,j,N-i-j] break print(ans)
s982010464
Accepted
660
3,060
213
N,Y=map(int,input().split()) Y=Y//1000 ans=[-1,-1,-1] for i in range(N+1): for j in range(N-i+1): if 10*i+5*j+N-i-j==Y: ans=[i,j,N-i-j] break print(ans[0],ans[1],ans[2])
s026614250
p04043
u779308281
2,000
262,144
Wrong Answer
18
3,064
374
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 ...
b = input().split() c = [int(s) for s in b] print(c) num5 = 0 num7 = 0 for i in range(len(c)): if c[i] == 5: num5 += 1 continue if c[i] == 7: num7 +=1 continue if num5 == 2 and num7 == 1: print("YES") else: print("NO")
s673564733
Accepted
17
3,060
365
b = input().split() c = [int(s) for s in b] num5 = 0 num7 = 0 for i in range(len(c)): if c[i] == 5: num5 += 1 continue if c[i] == 7: num7 +=1 continue if num5 == 2 and num7 == 1: print("YES") else: print("NO")
s104870033
p02406
u494314211
1,000
131,072
Wrong Answer
20
7,576
110
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ...
n=input() n=int(n) s="" for i in range(n): if i%3==0: s+=" "+str(i) elif i%10==3: s+=" "+str(i) print(s)
s341260415
Accepted
20
7,532
126
n=input() n=int(n) s="" for i in range(1,n+1): if i%3==0: s+=" "+str(i) elif "3" in list(str(i)): s+=" "+str(i) print(s)
s789624802
p02612
u618953765
2,000
1,048,576
Wrong Answer
29
9,044
30
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n = int(input()) print(n%1000)
s590287350
Accepted
27
8,912
37
n = int(input()) print((1000-n)%1000)
s272722881
p03645
u026788530
2,000
262,144
Wrong Answer
667
4,596
407
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
N,M =[int(i) for i in input().split(' ')] table = [0]*N for i in range(M): a,b = [int(i) for i in input().split(' ')] if a==1: table[b-1] +=1 if b==M: table[b-1] +=1 if b==N: table[a-1]+=1 # print(table) flag = True for i in table: if i==2: print("POSSIBLE...
s799382712
Accepted
665
4,596
407
N,M =[int(i) for i in input().split(' ')] table = [0]*N for i in range(M): a,b = [int(i) for i in input().split(' ')] if a==1: table[b-1] +=1 if b==N: table[b-1] +=1 if b==N: table[a-1]+=1 # print(table) flag = True for i in table: if i==2: print("POSSIBLE...
s791497843
p02419
u213265973
1,000
131,072
Wrong Answer
20
7,368
152
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
W = input() count = 0 while True: T = input() if T == "END_OF_TEXT": break if W in T: count += 1 print(count)
s657180258
Accepted
30
7,376
165
W = input().lower() count = 0 while True: T = input() if T == "END_OF_TEXT": break count += T.lower().split(" ").count(W) print(count)
s326552439
p03090
u977389981
2,000
1,048,576
Wrong Answer
23
3,612
365
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved...
N = int(input()) G = [[] for i in range(N + 1)] for i in range(1, N + 1): for j in range(i, N + 1): if N % 2 == 1: if i + j != N and i != j: G[i].append(j) else: if i + j != N + 1 and i != j: G[i].append(j) for i in range(1, N...
s580150254
Accepted
24
3,612
419
N = int(input()) cnt = 0 G = [[] for i in range(N + 1)] for i in range(1, N + 1): for j in range(i, N + 1): if N % 2 == 1: if i + j != N and i != j: G[i].append(j) cnt += 1 else: if i + j != N + 1 and i != j: G[i].append(j) ...
s160362011
p03719
u493440568
2,000
262,144
Wrong Answer
26
8,856
79
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
A, B, C = map(int, input().split()) print("YES" if C >= A and C <= B else "No")
s832961656
Accepted
30
9,092
79
A, B, C = map(int, input().split()) print("Yes" if C >= A and C <= B else "No")
s327177585
p03416
u074338678
2,000
262,144
Wrong Answer
17
2,940
107
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
n, m = map(int, input().split()) if n==1: print(m-2) elif m==1: print(n-2) else: print((n-2)*(m-2))
s056276349
Accepted
72
2,940
136
a, b = map(int, input().split()) count = 0 for i in range(a, b+1): if str(i)[0:2] == str(i)[:-3:-1]: count += 1 print(count)
s076997390
p03369
u642418876
2,000
262,144
Wrong Answer
17
2,940
54
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 ...
S=str(input()) X=S.count("○") print(700+100*int(X))
s544023282
Accepted
17
2,940
47
s=str(input()) x=s.count('o') print(700+100*x)
s291883176
p02418
u908651435
1,000
131,072
Wrong Answer
20
5,540
72
Write a program which finds a pattern $p$ in a ring shaped text $s$.
s=input()*2 p=input() if s in p: print('Yes') else: print('No')
s700940718
Accepted
20
5,548
73
s=input()*2 p=input() if p in s: print('Yes') else: print('No')
s913635994
p03795
u446711904
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 ...
n=int(input());print(800*n-60//15*200)
s686504303
Accepted
17
2,940
37
n=int(input());print(800*n-n//15*200)
s175630687
p02418
u498511622
1,000
131,072
Wrong Answer
20
7,296
41
Write a program which finds a pattern $p$ in a ring shaped text $s$.
s=input() p=input() print(s.find(p) != p)
s106693984
Accepted
30
7,460
76
s=input()*2 p=input() if s.find(p) != -1: print('Yes') else: print('No')
s118842464
p03080
u619785253
2,000
1,048,576
Wrong Answer
17
2,940
146
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.
i = int(input()) hat = list(input()) B_count = hat.count('B') R_count = hat.count('R') if B_count < R_count: print("YES") else: print('NO')
s284906672
Accepted
18
2,940
145
i = int(input()) hat = list(input()) B_count = hat.count('B') R_count = hat.count('R') if B_count < R_count: print("Yes") else: print('No')
s716906014
p03853
u694665829
2,000
262,144
Wrong Answer
33
9,252
224
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, p...
h,w=map(int,input().split()) C=[list(input()) for i in range(h)] A=[[None for i in range(w)] for i in range(2*h)] for i in range(2*h): for j in range(w): A[i][j]=C[(i+1)//2-1][j] for a in A: print(''.join(a))
s083063736
Accepted
25
9,144
120
h,w=map(int,input().split()) C=[list(input()) for i in range(h)] for c in C: print(''.join(c)) print(''.join(c))
s602616480
p03386
u918601425
2,000
262,144
Wrong Answer
2,104
26,448
182
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
A,B,K=[int(s) for s in input().split()] if (B-A+1)>=2*K: for i in range(A,B+1): print(i) else: for i in range(K): print(A+i) for i in range(K): print(B+i-K+1)
s421172330
Accepted
17
3,060
183
A,B,K=[int(s) for s in input().split()] if (B-A+1)<=2*K: for i in range(A,B+1): print(i) else: for i in range(K): print(A+i) for i in range(K): print(B+i-K+1)
s249183332
p03457
u600608564
2,000
262,144
Wrong Answer
388
11,636
382
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...
N = int(input()) t = [0] * (N + 1) x = [0] * (N + 1) y = [0] * (N + 1) for i in range(N): t[i + 1], x[i + 1], y[i + 1] = map(int, input().split()) for i in range(N): dt = t[i + 1] - t[i] dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if dt < dist: print("NO") exit(0) if dist % ...
s869802340
Accepted
388
11,636
382
N = int(input()) t = [0] * (N + 1) x = [0] * (N + 1) y = [0] * (N + 1) for i in range(N): t[i + 1], x[i + 1], y[i + 1] = map(int, input().split()) for i in range(N): dt = t[i + 1] - t[i] dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) if dt < dist: print("No") exit(0) if dist % ...
s464109887
p02697
u886747123
2,000
1,048,576
Wrong Answer
72
9,284
101
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing fi...
N, M = map(int, input().split()) a = 1 b = N for i in range(M): print(a,b) a += 1 b -= 1
s864062915
Accepted
76
9,284
458
N, M = map(int, input().split()) if M%2 == 1: a = 1 b = M for _ in range(M//2): print(a,b) a += 1 b -= 1 a = M+1 b = 2*M + 1 for _ in range(M - M//2): print(a,b) a += 1 b -= 1 else: a = 1 b = M+1 for _ in range(M//2): print(a,b...
s942615966
p02409
u692415695
1,000
131,072
Wrong Answer
30
7,656
367
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 fl...
# (c) midandfeed q = [] for i in range(4): b = [] for j in range(3): a = [0 for x in range(10)] b.append(a) q.append(b) for _ in range(int(input())): b, f, r, v = [int(x) for x in input().split()] q[b-1][f-1][r-1] += v for x in q: for y in x: for z in range(len(y)): print(" {}".format(y[z]), end='') ...
s008593771
Accepted
50
7,744
401
# (c) midandfeed q = [] for i in range(4): b = [] for j in range(3): a = [0 for x in range(10)] b.append(a) q.append(b) t = int(input()) for _ in range(t): b, f, r, v = [int(x) for x in input().split()] q[b-1][f-1][r-1] += v a = 0 for x in q: a += 1 for y in x: for z in range(len(y)): print(" {}".form...
s761320292
p03485
u220904910
2,000
262,144
Wrong Answer
152
12,396
109
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 numpy as np if __name__ == '__main__': a,b=map(int, input().split()) print(np.ceil((a+b)/2))
s247097699
Accepted
151
12,392
114
import numpy as np if __name__ == '__main__': a,b=map(int, input().split()) print(int(np.ceil((a+b)/2)))
s403764400
p03543
u395237353
2,000
262,144
Wrong Answer
17
3,060
172
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
N = input() num = "0" count = 1 for i in N: if (num == i): count += 1 elif count > 2: break else: count = 1 num = i print(num, count) if count > 2: print("yes")
s608429728
Accepted
17
3,060
173
N = input() num = "0" count = 1 for i in N: if (num == i): count += 1 elif count > 2: break else: count = 1 num = i if count > 2: print("Yes") else: print("No")
s299164986
p03505
u126823513
2,000
262,144
Wrong Answer
17
2,940
216
_ButCoder Inc._ runs a programming competition site called _ButCoder_. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is calle...
k, a, b = map(int, input().split()) if a <= b: if a < k: print(-1) else: print(1) else: if a > k: print(1) else: diff = a - b print(2 * ((k - a) // diff) + 1)
s554631530
Accepted
17
2,940
226
k, a, b = map(int, input().split()) if a <= b: if a < k: print(-1) else: print(1) else: if a > k: print(1) else: answer = ((k - b - 1) // (a - b) * 2) + 1 print(answer)
s169073709
p03370
u673281957
2,000
262,144
Wrong Answer
17
3,064
192
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 o...
m,n = map(int,input().split()) dlis = [] zan = n cnt = int(0) for i in range(m): dlis.append(int(input())) zan = zan - dlis[i] cnt += 1 print(zan) x = zan//int(min(dlis)) print(cnt+x)
s595850679
Accepted
17
3,060
179
m,n = map(int,input().split()) dlis = [] zan = n cnt = int(0) for i in range(m): dlis.append(int(input())) zan = zan - dlis[i] cnt += 1 x = zan//int(min(dlis)) print(cnt+x)
s520495504
p03110
u489315616
2,000
1,048,576
Wrong Answer
17
2,940
185
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000`...
sum = 0.0 n = int(input()) for i in range(n): x, u = map(str, input().split()) if u == 'JPY': sum += int(x) else: sum += 380000.0 * float(x) print(int(sum))
s546296609
Accepted
17
2,940
191
sum = 0.0 n = int(input()) for i in range(n): x, u = map(str, input().split()) if u == 'JPY': sum += int(x) elif u == 'BTC': sum += 380000.0 * float(x) print(sum)
s923255644
p02694
u282676559
2,000
1,048,576
Wrong Answer
20
9,140
114
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 abo...
X = int(input()) money = 100 count = 0 while money <= X: count += 1 money = int(money * 1.01) print(count)
s839921962
Accepted
24
9,068
113
X = int(input()) money = 100 count = 0 while money < X: count += 1 money = int(money * 1.01) print(count)
s099665355
p03448
u205580583
2,000
262,144
Wrong Answer
58
3,064
320
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 co...
a = int(input()) #500 b = int(input()) #100 c = int(input()) #50 x = int(input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): total = 500 * i + 100 * j + 50 * k if total == x: print("cnt!") cnt += 1 print(cnt)
s629232040
Accepted
53
3,060
290
a = int(input()) #500 b = int(input()) #100 c = int(input()) #50 x = int(input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): total = 500 * i + 100 * j + 50 * k if total == x: cnt += 1 print(cnt)
s272156364
p03149
u419686324
2,000
1,048,576
Wrong Answer
18
2,940
57
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
print("YES" if sorted(input()) == list("1479") else "NO")
s650091934
Accepted
18
2,940
65
print("YES" if sorted(input().split()) == list("1479") else "NO")
s975899642
p03472
u017415492
2,000
262,144
Wrong Answer
412
28,564
409
You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of d...
n,h=map(int,input().split()) ab=[list(map(int,input().split())) for i in range(n)] a_max=0 b=[] ans=0 kaisuu=0 for i in range(n): if a_max<ab[i][0]: a_max=ab[i][0] for i in range(n): b.append(ab[i][1]) b.sort(reverse=True) for i in range(n): if a_max<b[i]: h-=b[i] kaisuu+=1 else: if h%a_max==0: ...
s791770340
Accepted
235
16,836
357
n,h=map(int,input().split()) A=[] B=[] for i in range(n): a,b=map(int,input().split()) A.append(a) B.append(b) A=max(A) B.sort(reverse=True) count=0 for i in B: if A>i: break else: if h>0: h-=i count+=1 else: break if h%A==0 and h>0: print(count+h//A) elif h%A!=0 and h>0: pri...
s528937576
p02399
u344890307
1,000
131,072
Wrong Answer
20
5,596
84
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a,b=map(int,input().split()) print('{0} {1} {2}'.format(int(a/b),a % b,float(a/b)))
s884869959
Accepted
20
5,604
89
a,b=map(int,input().split()) print('{:d} {:d} {:.5f}'.format(int(a/b),a % b,a/float(b)))
s131759958
p03448
u582614471
2,000
262,144
Wrong Answer
50
2,940
197
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 co...
a,b,c,x =[int(input(i)) for i in range(4)] 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)
s357711508
Accepted
50
2,940
197
a,b,c,x =[int(input()) for i in range(4)] 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)
s009714235
p03193
u652656291
2,000
1,048,576
Wrong Answer
20
3,060
140
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by cho...
n,h,w = map(int,input().split()) ans = 0 for i in range(n): a,b = map(int,input().split()) if a <= h and b <= w: ans += 1 print(ans)
s268258090
Accepted
20
3,060
140
n,h,w = map(int,input().split()) ans = 0 for i in range(n): a,b = map(int,input().split()) if a >= h and b >= w: ans += 1 print(ans)
s553059780
p03997
u922952729
2,000
262,144
Wrong Answer
23
3,064
64
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)
s782720555
Accepted
23
3,064
68
a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
s875398245
p03673
u300579805
2,000
262,144
Wrong Answer
161
25,156
388
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
import math n = int(input()) A=list(map(int, input().split())) ans = [0] * n if (n % 2 == 0): for i in range(n): if (i%2 == 0): ans[n//2+i//2] = A[i] else: ans[n//2-(i+2)//2] = A[i] if (n % 2 != 0): for i in range(n): if (i%2 == 0): ans[n//2-i//2] = ...
s001780902
Accepted
233
25,156
389
import math n = int(input()) A=list(map(int, input().split())) ans = [0] * n if (n % 2 == 0): for i in range(n): if (i%2 == 0): ans[n//2+i//2] = A[i] else: ans[n//2-(i+2)//2] = A[i] if (n % 2 != 0): for i in range(n): if (i%2 == 0): ans[n//2-i//2] = ...
s164140214
p03438
u729707098
2,000
262,144
Wrong Answer
28
4,660
205
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two ac...
n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] num,A,B = 0,sum(a),sum(b) for i in range(n): num = max(num,b[i]-a[i]) if num>B-A: print("No") else: print("Yes")
s404295249
Accepted
30
4,596
223
n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] num,A,B = 0,sum(a),sum(b) for i in range(n): num+=max(0,((b[i]-a[i])+(b[i]-a[i])%2)//2) if num>B-A: print("No") else: print("Yes")
s172334555
p03964
u911575040
2,000
262,144
Wrong Answer
20
2,940
128
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 c...
N=int(input()) t=a=1 for i in range(N): T,A=map(int,input().split()) num=max(-t//T,a//A) t,a=num*T,num*A print(t+a)
s958405679
Accepted
21
2,940
135
N=int(input()) t=a=1 for i in range(N): T,A=map(int,input().split()) num=max(-(-t//T),-(-a//A)) t,a=num*T,num*A print(t+a)
s683219225
p03610
u068538925
2,000
262,144
Wrong Answer
41
10,944
138
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s = input() #print(s[1]) #print(s[2]) i = list(range(0,len(s),2)) temp ="" for t in range(len(s)//2): temp = temp+s[i[t]] print(temp)
s422647742
Accepted
42
10,864
145
s = input() #print(s[1]) #print(s[2]) i = list(range(0,len(s)+1,2)) temp ="" for t in range((len(s)+1)//2): temp = temp+s[i[t]] print(temp)
s052559549
p02936
u905329882
2,000
1,048,576
Wrong Answer
2,117
227,016
466
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati...
import sys sys.setrecursionlimit(1000000) n,q=map(int,input().split()) g=[[]for i in range(n)] for i in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) lis = [0 for i in range(n)] for i in range(q): p,x=map(int,input().split()) lis[p-1]+=x def dfs(i,j,k): nex=g[i...
s263105672
Accepted
1,730
230,920
495
import sys def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) n,q=map(int,input().split()) g=[[]for i in range(n)] for i in range(n-1): a,b=map(int,input().split()) g[a-1].append(b-1) g[b-1].append(a-1) lis = [0 for i in range(n)] for i in range(q): p,x=map(int,input().spl...
s614164857
p02678
u309141201
2,000
1,048,576
Wrong Answer
23
9,144
11
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in th...
print('No')
s345113285
Accepted
753
34,976
576
from collections import deque n, m = map(int, input().split()) g = [[] for _ in range(n)] for _ in range(m): a, b = map(int, input().split()) a -= 1 b -= 1 g[a].append(b) g[b].append(a) ans = [-1]*n used = [0]*n used[0] = 1 que = deque() que.appendleft(0) while que: v = que.pop() # print(v)...
s660236026
p03502
u584529823
2,000
262,144
Time Limit Exceeded
2,104
2,940
130
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
N = int(input()) sum = 0 tmp = N while tmp > 0: sum += tmp % 10 tmp // 10 if N % sum == 0: print("Yes") else: print("No")
s198225856
Accepted
17
2,940
132
N = int(input()) sum = 0 tmp = N while tmp > 0: sum += tmp % 10 tmp //= 10 if N % sum == 0: print("Yes") else: print("No")
s463660836
p03997
u646336933
2,000
262,144
Wrong Answer
17
2,940
69
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)
s240184489
Accepted
17
2,940
70
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h//2)
s416201144
p02902
u875291233
2,000
1,048,576
Wrong Answer
21
3,316
2,259
Given is a directed graph G with N vertices and M edges. The vertices are numbered 1 to N, and the i-th edge is directed from Vertex A_i to Vertex B_i. It is guaranteed that the graph contains no self-loops or multiple edges. Determine whether there exists an induced subgraph (see Notes) of G such that the in-degr...
# find a cycle def find_cycle(g): n = len(g) used = [0]*n #0:not yet 1: visiting 2: visited for v in range(n): if used[v] == 2: continue stack = [v] hist =[] while stack: v = stack[-1] if used[v] == 1: used[v] = 2 ...
s396475898
Accepted
21
3,316
2,242
# find a cycle def find_cycle(g): n = len(g) used = [0]*n #0:not yet 1: visiting 2: visited for v in range(n): if used[v] == 2: continue stack = [v] hist =[] while stack: v = stack[-1] if used[v] == 1: used[v] = 2 ...
s756402826
p03759
u749770850
2,000
262,144
Wrong Answer
17
2,940
89
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
a, b, c = map(int, input().split()) if b - a == c - b : print("Yes") else: print("No")
s330332852
Accepted
17
2,940
89
a, b, c = map(int, input().split()) if b - a == c - b : print("YES") else: print("NO")
s371207244
p03574
u001024152
2,000
262,144
Wrong Answer
26
3,064
869
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con...
H, W = map(int, input().split()) S = [] for h in range(H): S.append(list(input())) for h in range(H): for w in range(W): cnt = 0 if S[h][w]==".": if w > 0: cnt += int(S[h][w-1] == "#") if w < W-1: cnt += int(S[h][w+1] == "#") ...
s458502790
Accepted
25
3,188
899
H, W = map(int, input().split()) S = [] for h in range(H): S.append(list(input())) for h in range(H): for w in range(W): cnt = 0 if S[h][w]==".": if w > 0: cnt += int(S[h][w-1] == "#") if w < W-1: cnt += int(S[h][w+1] == "#") ...
s157676183
p03760
u140251125
2,000
262,144
Wrong Answer
17
3,060
238
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the...
# input O = input() E = input() password = [0 for _ in range(len(O) + len(E))] for i in range(len(O)): password[2 * i] = O[i] for i in range(len(E)): password[2 * i + 1] = E[i] password_str = str(password) print(password_str)
s204494818
Accepted
17
3,060
241
# input O = input() E = input() password = [0 for _ in range(len(O) + len(E))] for i in range(len(O)): password[2 * i] = O[i] for i in range(len(E)): password[2 * i + 1] = E[i] password_str = ''.join(password) print(password_str)
s070310422
p02742
u998082063
2,000
1,048,576
Wrong Answer
17
2,940
170
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to...
h, w = map(int,input().split()) wid = 0 if w % 2 == 0: wid = w // 2 else: wid = w // 2 + 1 if h % 2 == 0: print(h*wid) else: print(h*wid - h//2*(wid-1))
s525686676
Accepted
17
2,940
111
h, w = map(int,input().split()) if h == 1 or w == 1: print(1) exit() else: print((h * w + 1) // 2)
s996684638
p04029
u895536055
2,000
262,144
Wrong Answer
17
2,940
41
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)
s953945992
Accepted
20
3,060
43
N = int(input()) print((N * (N + 1)) // 2)
s504687470
p03644
u511457539
2,000
262,144
Wrong Answer
17
3,064
402
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can...
N = int(input()) count = 0 if N == 1: print(1) elif N == 2 or N == 3: print(2) else: even = [i for i in range(2, N+1, 2)] while len(even) >1: i = 0 count +=1 while i < len(even): if even[i]%2 == 0: even[i] = even[i]/2 i +=1 ...
s456164380
Accepted
17
2,940
209
N = int(input()) if N == 1: print(1) elif N == 2 or N == 3: print(2) elif N < 8: print(4) elif N < 16: print(8) elif N < 32: print(16) elif N < 64: print(32) else: print(64)
s594595514
p03696
u027929618
2,000
262,144
Wrong Answer
17
3,060
166
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of...
N = int(input()) S = input() cnt = [0, 0] ans = "" for i in range(N): if S[i] == ")": cnt[0] += 1 else: cnt[1] += 1 print("(" * cnt[0] + S + ")" * cnt[1])
s351920500
Accepted
17
3,060
143
N = int(input()) S = input() s = S[:] while "()" in s: s = s.replace("()", "") r = s.count("(") l = s.count(")") print("(" * l + S + ")" * r)
s769825463
p03637
u652057333
2,000
262,144
Wrong Answer
71
14,252
333
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
n = int(input()) a = list(map(int, input().split())) count = [0] * 3 for i in range(n): if a[i] % 4 == 0: count[2] += 1 elif a[i] % 2 == 0: count[1] += 1 else: count[0] += 1 ans = False if count[0] + (count[1] % 2) <= count[2] + 1: ans = True if ans: print("YES") else: ...
s825803751
Accepted
71
14,252
333
n = int(input()) a = list(map(int, input().split())) count = [0] * 3 for i in range(n): if a[i] % 4 == 0: count[2] += 1 elif a[i] % 2 == 0: count[1] += 1 else: count[0] += 1 ans = False if count[0] + (count[1] % 2) <= count[2] + 1: ans = True if ans: print("Yes") else: ...
s453280768
p03455
u421499233
2,000
262,144
Wrong Answer
17
3,060
93
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()) p = a*b % 2 if p == 1 : print("Even") else: print("Odd")
s891804870
Accepted
17
2,940
98
a,b = map(int,input().split()) ans = a*b if ans % 2 == 0: print("Even") else: print("Odd")
s422339992
p02612
u633203155
2,000
1,048,576
Wrong Answer
31
9,076
31
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) print(N%1000)
s063468113
Accepted
32
9,132
89
N = int(input()) amari = N%1000 if amari == 0: print(0) else: print(1000-amari)
s333033951
p03693
u246820565
2,000
262,144
Wrong Answer
20
3,060
89
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i...
rgb = list(map(str,input().split())) print('Yes' if int(''.join(rgb)) % 4 == 0 else 'NO')
s659128524
Accepted
17
2,940
89
rgb = list(map(str,input().split())) print('YES' if int(''.join(rgb)) % 4 == 0 else 'NO')
s151044502
p02399
u477464845
1,000
131,072
Wrong Answer
20
5,600
84
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 = a / b print(d,r,f,sep=' ')
s316801812
Accepted
20
5,608
95
a,b = map(int,input().split(" ")) d = a // b r = a % b f = a / b print(d,r,"{:.5f}".format(f))
s205960808
p02261
u777299405
1,000
131,072
Wrong Answer
40
6,724
423
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubbl...
n = int(input()) c = input().split() d = c[:] for i in range(n): for j in range(n - 1, i, -1): if d[j] < d[j - 1]: d[j], d[j - 1] = d[j - 1], d[j] print(*d) print("Stable") # selectionsort for i in range(n): minj = i for j in range(i, n): if c[j] < c[minj]: minj =...
s536912191
Accepted
30
6,724
434
n = int(input()) c = input().split() d = c[:] for i in range(n): for j in range(n - 1, i, -1): if d[j][1] < d[j - 1][1]: d[j], d[j - 1] = d[j - 1], d[j] print(*d) print("Stable") # selectionsort for i in range(n): minj = i for j in range(i, n): if c[j][1] < c[minj][1]: ...
s522409342
p03855
u112317104
2,000
262,144
Wrong Answer
860
32,296
921
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s...
def find(x, parent): if parent[x] == x: return x else: parent[x] = find(parent[x], parent) return parent[x] def unite(x, y, parent): x = find(x, parent) y = find(y, parent) if x == y: return parent[y] = x def solve(): N, K, L = map(int, input().split()) ...
s740798732
Accepted
1,255
55,924
1,010
from collections import defaultdict def find(x, parent): if parent[x] == x: return x else: parent[x] = find(parent[x], parent) return parent[x] def unite(x, y, parent): x = find(x, parent) y = find(y, parent) if x == y: return parent[y] = x def solve(): ...
s281911261
p03456
u077898957
2,000
262,144
Wrong Answer
18
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,b = input().split() print('YES' if (int(a+b))**.5 == int(math.sqrt(int(a+b))) else 'No')
s184206213
Accepted
17
3,064
103
import math a,b=map(str,input().split()) c=int(a+b) print('Yes' if (math.sqrt(c)//1)**2==c else 'No')
s310817254
p03555
u923794601
2,000
262,144
Wrong Answer
17
2,940
172
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_Rotation def rotation(c1, c2): if str(c1) == str(c2)[:-1]: print("YES") else: print("NO") if __name__ == "__main__": c1 = input() c2 = input() rotation(c1, c2)
s965212598
Accepted
17
2,940
173
#A_Rotation def rotation(c1, c2): if str(c1) == str(c2)[::-1]: print("YES") else: print("NO") if __name__ == "__main__": c1 = input() c2 = input() rotation(c1, c2)
s237317154
p00311
u546285759
1,000
262,144
Wrong Answer
20
7,584
344
浩と健次郎の兄弟は猪苗代湖に魚釣りをしに来ました。二人は以下のように点数を決め、釣り上げた魚の合計得点で勝負することにしました。 * イワナは1匹 a 点 * ヤマメは1匹 b 点 * イワナ10匹ごとに c 点追加 * ヤマメ20匹ごとに d点追加 浩と健次郎が釣り上げた魚の数をもとに、どちらが勝ちか、あるいは引き分けか判定するプログラムを作成せよ。
h1, h2 = map(int, input().split()) k1, k2 = map(int, input().split()) a, b, c, d = map(int, input().split()) hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d) kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d) print("even" if hiroshi else ["hiroshi", "kenji...
s673827449
Accepted
50
7,736
355
h1, h2 = map(int, input().split()) k1, k2 = map(int, input().split()) a, b, c, d = map(int, input().split()) hiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d) kenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d) print("even" if hiroshi == kenjiro else ["hiros...
s157505184
p02694
u749742659
2,000
1,048,576
Wrong Answer
24
9,240
158
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 abo...
x = int(input()) year = 0 money = 100 while(True): money *= 1.01 money = money // 1 year += 1 if(money > x): break print(str(year))
s133055438
Accepted
24
9,088
159
x = int(input()) year = 0 money = 100 while(True): money *= 1.01 money = money // 1 year += 1 if(money >= x): break print(str(year))
s489479849
p02392
u092736322
1,000
131,072
Wrong Answer
20
5,588
119
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
ins=input().split() a=int(ins[0]) b=int(ins[1]) c=int(ins[2]) if a<b and b<c: print("Yse") else: print("No")
s284654008
Accepted
20
5,592
119
ins=input().split() a=int(ins[0]) b=int(ins[1]) c=int(ins[2]) if a<b and b<c: print("Yes") else: print("No")
s524613325
p03962
u516242950
2,000
262,144
Wrong Answer
17
2,940
136
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he migh...
iro = list(map(int, input().split())) shu = 1 iro.sort() for i in range(1, len(iro)): if iro[i - 1] != iro[i]: shu += 1 print(iro)
s652538825
Accepted
17
2,940
136
iro = list(map(int, input().split())) shu = 1 iro.sort() for i in range(1, len(iro)): if iro[i - 1] != iro[i]: shu += 1 print(shu)
s918841966
p03730
u703823201
2,000
262,144
Wrong Answer
26
8,980
157
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 objecti...
A, B, C = map(int, input().split()) ans = "No" for i in range(1, 1000): a = A*i if a % B == C: ans = "Yes" break print(ans)
s222402207
Accepted
27
9,100
157
A, B, C = map(int, input().split()) ans = "NO" for i in range(1, 1000): a = A*i if a % B == C: ans = "YES" break print(ans)
s568010850
p03565
u210827208
2,000
262,144
Wrong Answer
19
3,192
616
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 mo...
s=input() t=input() ans=1 table=str.maketrans({'?':'a'}) for i in range(len(s),len(t),-1): x=list(s[i-len(t):i]) if set(x)=={'?'}: s=s.translate(table) ans=2 break else: cnt=0 for j in range(len(t)): if x[j]=='?' or x[j]==t[j]: cnt+=1 ...
s182165369
Accepted
21
3,188
223
import re s=input().replace('?','.') t=input() ans='UNRESTORABLE' for i in range(len(s)-len(t),-1,-1): if re.match(s[i:i+len(t)],t): s=s.replace('.','a') ans=s[:i]+t+s[i+len(t):] break print(ans)
s589279864
p03544
u594956556
2,000
262,144
Wrong Answer
17
2,940
126
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
N = int(input()) if N == 1: print(1) exit() L = [0]*(N+1) for i in range(2, N+1): L[i] = L[i-1] + L[i-2] print(L[N])
s653417208
Accepted
18
3,060
144
N = int(input()) if N == 1: print(1) exit() L = [0]*(N+1) L[0] = 2 L[1] = 1 for i in range(2, N+1): L[i] = L[i-1] + L[i-2] print(L[N])
s845266200
p02389
u477717106
1,000
131,072
Wrong Answer
20
5,584
81
Write a program which calculates the area and perimeter of a given rectangle.
line=input().split() a=int(line[0]) b=int(line[1]) print(a*b) print((2*a)+(2*b))
s133791819
Accepted
20
5,588
71
line=input().split() a=int(line[0]) b=int(line[1]) print(a*b,2*(a+b))
s769408416
p03360
u411858517
2,000
262,144
Wrong Answer
17
3,060
130
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...
l = list(map(int, input().split())) K = int(input()) l.sort() for i in range(K): l[0] = 2*l[0] print(l[0] + l[1] + l[2])
s788050537
Accepted
17
2,940
130
l = list(map(int, input().split())) K = int(input()) l.sort() for i in range(K): l[2] = 2*l[2] print(l[0] + l[1] + l[2])
s065528876
p03910
u276204978
2,000
262,144
Wrong Answer
1,801
399,640
199
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highe...
def solve(): N = int(input()) s = sum([i for i in range(1, N+1)]) for i in reversed(range(1, N+1)): if s - i <= N: return i s -= i print(solve())
s261457645
Accepted
19
3,444
261
def solve(): N = int(input()) score = 0 for i in range(1, N+1): score += i if score >= N: break x = score - N res = list(range(1, x)) + list(range(x+1, i+1)) return '\n'.join(map(str, res)) print(solve())
s550041217
p03711
u360515075
2,000
262,144
Wrong Answer
17
2,940
192
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
x, y = map(int, input().split()) g1 = [1, 3, 5, 7, 8, 10, 12] g2 = [4, 6, 9, 11] g3 = [2] print ("YES" if x in g1 and y in g1 or x in g2 and y in g2 or x in g3 and y in g3 else "NO")
s229423726
Accepted
17
3,060
192
x, y = map(int, input().split()) g1 = [1, 3, 5, 7, 8, 10, 12] g2 = [4, 6, 9, 11] g3 = [2] print ("Yes" if x in g1 and y in g1 or x in g2 and y in g2 or x in g3 and y in g3 else "No")
s664276425
p03377
u977855674
2,000
262,144
Wrong Answer
18
2,940
85
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, str(input()).split(" ")) print("Yes" if A <= X <= A + B else "No")
s037909762
Accepted
18
2,940
85
A, B, X = map(int, str(input()).split(" ")) print("YES" if A <= X <= A + B else "NO")
s807966405
p03407
u274045692
2,000
262,144
Wrong Answer
17
2,940
89
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
A, B, C = map(int, input().split()) if A + B == C: print("Yes") else: print("No")
s697617397
Accepted
19
3,060
90
A, B, C = map(int, input().split()) if A + B >= C: print("Yes") else: print("No")
s803738236
p03557
u190079347
2,000
262,144
Wrong Answer
2,105
22,720
297
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper ...
import bisect n = int(input()) a = sorted(list(map(int,input().split()))) b = sorted(list(map(int,input().split()))) c = sorted(list(map(int,input().split()))) count = 0 for i in range(n): for s in range(bisect.bisect_right(b, a[i]),n): count += n-bisect.bisect_right(c, a[s])-1 print(count)
s819424354
Accepted
339
23,328
271
n=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort() b.sort() c.sort() import bisect ans=0 for i in b: q=bisect.bisect_left(a,i) s=bisect.bisect_right(c,i) ans=ans+q*(n-s) print(ans)
s237055825
p03573
u967835038
2,000
262,144
Wrong Answer
17
2,940
101
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
a,b,c=map(int,input().split()) if a==b: print('c') elif b==c: print('a') else: print('b')
s453156063
Accepted
17
2,940
95
a,b,c=map(int,input().split()) if a==b: print(c) elif b==c: print(a) else: print(b)
s581291939
p02578
u736479342
2,000
1,048,576
Wrong Answer
167
32,328
194
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a ...
n = int(input()) a = [int(i) for i in input().split()] print(a) ans=0 for i in range(n-1): d = a[i-1] - a[i] if d<0: ans+= d+1 a[i]=a[i]+d+1 else: continue print(abs(ans))
s106957668
Accepted
155
32,092
181
n = int(input()) a = [int(i) for i in input().split()] ans=0 for i in range(1,n): d = a[i-1] - a[i] if d>0: ans+= d a[i]=a[i]+d else: continue print(abs(ans))
s561302154
p03149
u405256066
2,000
1,048,576
Wrong Answer
20
3,188
253
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
import re from sys import stdin N=(stdin.readline().rstrip()) cnt=0 for i in range(7): mae="keyence"[0:i+1] ato="keyence"[i+1:8] if re.match("%s.*%s"%(mae, ato),N): print("YES") cnt+=1 break if cnt==0: print("NO")
s627209062
Accepted
17
2,940
167
from sys import stdin N=(stdin.readline().rstrip()) if N.count("1")>0 and N.count("9")>0 and N.count("7")>0 and N.count("4") >0: print("YES") else: print("NO")
s346916651
p03943
u514894322
2,000
262,144
Wrong Answer
17
2,940
103
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not...
candy = set(map(int,input().split())) if max(candy)*2 == sum(candy): print('YES') else: print('NO')
s645423333
Accepted
17
2,940
104
candy = list(map(int,input().split())) if max(candy)*2 == sum(candy): print('Yes') else: print('No')
s776856357
p02694
u553600587
2,000
1,048,576
Wrong Answer
23
9,180
115
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 abo...
import math X = int(input().strip()) v = 100 y = 0 while v <= X: y += 1 v = math.floor(v * 1.01) print(y)
s945888361
Accepted
22
9,156
142
import math X = int(input().strip()) v = 100 y = 0 while True: y += 1 v = math.floor(v * 1.01) if v >= X: break print(y)
s375842640
p03699
u371686382
2,000
262,144
Wrong Answer
17
2,940
318
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When...
N = int(input()) S = sorted([int(input()) for _ in range(N)]) ans = sum(S) if ans % 10 == 0: # find numbers that are not multiples of 10 in order of decreasing. for s in S: if s % 10 != 0: ans -= s break # if all the numbers in the list are multiples of 10, the ans is 0. ans = 0 print(ans)
s108705168
Accepted
17
2,940
340
N = int(input()) S = sorted([int(input()) for _ in range(N)]) ans = sum(S) if ans % 10 == 0: # find numbers that are not multiples of 10 in order of decreasing. for s in S: if s % 10 != 0: ans -= s break # if all the numbers in the list are multiples of 10, the ans is 0. if ans == sum(S): ...
s657469908
p02608
u929996201
2,000
1,048,576
Wrong Answer
2,206
9,208
302
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
import itertools import math a = int(input()) def calc(x,y,z,n): if(n==x*x+y*y+z*z+x*y+y*z+z*x): return True for i in range(1,a+1): l = list(range(int(math.sqrt(a+1)))) cnt = 0; for x,y,z in itertools.combinations_with_replacement(l, 3): if(calc(x,y,z,i)): cnt+=1; print(cnt)
s496383097
Accepted
480
9,836
229
import itertools import math a = int(input()) cnt = 0 ans = [0]*100000 l = list(range(1,int(math.sqrt(a)))) for x,y,z in itertools.product(l, repeat=3): ans[x*x+y*y+z*z+x*y+y*z+z*x]+=1 for i in range(1,a+1): print(ans[i])
s835586464
p03023
u474514603
2,000
1,048,576
Wrong Answer
22
3,688
1,143
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
#-*- coding: utf-8 # -*- """ oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d oj test -d test-d -c "python abc116d.py" oj test -d test-d -c "python abc116d.py" test-d/sample-3.in """ from collections import defaultdict import sys import math from datetime import datetime def sol(n): # 3 -> 3 * 60...
s656280816
Accepted
23
3,688
1,148
#-*- coding: utf-8 # -*- """ oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d oj test -d test-d -c "python abc116d.py" oj test -d test-d -c "python abc116d.py" test-d/sample-3.in """ from collections import defaultdict import sys import math from datetime import datetime def sol(n): # 3 -> 3 * 60...
s823359512
p03737
u319612498
2,000
262,144
Wrong Answer
17
3,064
54
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
a,b,c=map(str,input().split()) print("a[0]+b[0]+c[0]")
s160723307
Accepted
17
2,940
76
a,b,c=map(str,input().split()) print(a[0].upper()+b[0].upper()+c[0].upper())
s327491459
p02361
u279546122
3,000
131,072
Wrong Answer
30
8,024
793
For a given weighted graph G(V, E) and a source r, find the source shortest path to each vertex from the source (SSSP: Single Source Shortest Path).
#!usr/bin/env python3 from collections import defaultdict import time def main(): #Read stdin start = time.clock() fl = input().split(" ") V = int(fl[0]) E = int(fl[1]) R = int(fl[2]) #Adjacency list G = defaultdict(list) for i in range(int(E)): s, t, w = [int(x) for x in i...
s706372755
Accepted
2,430
104,916
722
from collections import defaultdict from collections import deque from sys import stdin #time 2.49 def sp(G,R,V): d = {} INF = float('inf') for i in range(V): d[i] = INF d[R] = 0 q = deque([(0, R)]) while q: (cost, v) = q.popleft() for (u, c) in G[v].items(): ...
s951636818
p03251
u252828980
2,000
1,048,576
Wrong Answer
19
3,064
393
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
n,m,x,y = map(int,input().split()) li1 = list(map(int,input().split())) li2 = list(map(int,input().split())) for z in range(x,y+1): if all([i < z for i in li1]): flag = True else: flag = False if all([i >= z for i in li2]): flag = True else: flag = False if flag...
s930980130
Accepted
18
3,060
255
n,m,x,y = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) for i in range(x,y+1): if all([p < i for p in a]) and all([q >=i for q in b]) and x < i <= y: print("No War") exit() print("War")
s105154148
p03251
u730318873
2,000
1,048,576
Wrong Answer
17
3,064
289
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes incli...
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) ans = 0 for z in range(X+1,Y+1): if max(x) < z and min(y) >= z: ans = 1 if ans == 1: j = z break if ans == 0: print('War') else: print('No war')
s604390586
Accepted
18
3,060
289
N,M,X,Y = map(int,input().split()) x = list(map(int,input().split())) y = list(map(int,input().split())) ans = 0 for z in range(X+1,Y+1): if max(x) < z and min(y) >= z: ans = 1 if ans == 1: j = z break if ans == 0: print('War') else: print('No War')
s463065120
p02743
u117541450
2,000
1,048,576
Wrong Answer
17
3,064
185
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
l=[int(e) for e in input().split(' ')] a=l.pop(0) b=l.pop(0) c=l.pop(0) lt=4*a*b rt=c**2 - 2*(a+b)*c + (a+b)**2 print(lt) print(rt) if lt < rt: print('Yes') else: print('No')
s698920211
Accepted
18
3,064
207
l=[int(e) for e in input().split(' ')] a=l.pop(0) b=l.pop(0) c=l.pop(0) if c < (a+b): print('No') exit() lt=4*a*b + 2*(a+b)*c rt=c**2 + (a+b)**2 if lt < rt: print('Yes') else: print('No')
s503498602
p03693
u086503932
2,000
262,144
Wrong Answer
17
2,940
79
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i...
a,b,c=map(int,input().split()) print('YES') if b*10+c % 4 == 0 else print('NO')
s578520072
Accepted
17
2,940
82
a,b,c=map(int,input().split()) print('YES') if (b*10+c) % 4 == 0 else print('NO')
s030697821
p03623
u881472317
2,000
262,144
Wrong Answer
17
2,940
116
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and...
x, a, b = map(int, input().split()) xa = abs(x - a) xb = abs(x - b) if xa > xb: print("A") else: print("B")
s305561451
Accepted
17
2,940
116
x, a, b = map(int, input().split()) xa = abs(x - a) xb = abs(x - b) if xa > xb: print("B") else: print("A")
s493603194
p04029
u132974957
2,000
262,144
Wrong Answer
17
2,940
130
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?
x = int(input("あめ")) def main(x): y = 0 for i in range(x+1): y = y + i return y print(main(x))
s850772320
Accepted
17
2,940
68
x = int(input()) y = 0 for i in range(x+1): y += i print(y)
s168041240
p03401
u036340997
2,000
262,144
Wrong Answer
221
14,048
310
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...
n = int(input()) a = [0] a += list(map(int, input().split())) a.append(0) a_sum = 0 for i in range(n + 1): a_sum += abs(a[i] - a[i+1]) for i in range(1, n+1): if (a[i-1] <= a[i] and a[i] <= a[i+1]) or (a[i-1] >= a[i] and a[i] >= a[i+1]): print(a_sum) else: print(a_sum - 2 * abs(a[i] - a[i+1]))
s167659619
Accepted
250
14,048
336
n = int(input()) a = [0] a += list(map(int, input().split())) a.append(0) a_sum = 0 for i in range(n + 1): a_sum += abs(a[i] - a[i+1]) for i in range(1, n+1): if (a[i-1] <= a[i] and a[i] <= a[i+1]) or (a[i-1] >= a[i] and a[i] >= a[i+1]): print(a_sum) else: print(a_sum - 2 * min(abs(a[i] - a[i+1]), abs(a...
s325103765
p03386
u859897687
2,000
262,144
Wrong Answer
18
3,060
98
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a,b,c=map(int,input().split()) for i in range(a,a+c): print(i) for i in range(b-c,b): print(i)
s240835608
Accepted
18
3,060
168
a,b,c=map(int,input().split()) if b-a+1>c*2: for i in range(a,a+c): print(i) for i in range(b-c+1,b+1): print(i) else: for i in range(a,b+1): print(i)