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
s313515942
p03836
u611871297
2,000
262,144
Wrong Answer
17
3,064
279
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx, sy, tx, ty = map(int, input().split()) h = tx - sx w = ty - sy s = '' s += 'U' s += 'U' * (h - 1) s += 'R' * w s += 'D' s += 'D' * (h - 1) s += 'L' * w s += 'L' s += 'U' * (h + 1) s += 'R' * (w + 1) s += 'D' s += 'R' s += 'D' * (h + 1) s += 'L' * (w + 1) s += 'U' print(s)
s079349316
Accepted
17
3,064
279
sx, sy, tx, ty = map(int, input().split()) w = tx - sx h = ty - sy s = '' s += 'U' s += 'U' * (h - 1) s += 'R' * w s += 'D' s += 'D' * (h - 1) s += 'L' * w s += 'L' s += 'U' * (h + 1) s += 'R' * (w + 1) s += 'D' s += 'R' s += 'D' * (h + 1) s += 'L' * (w + 1) s += 'U' print(s)
s175614447
p02408
u641357568
1,000
131,072
Wrong Answer
20
5,608
305
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
import sys cards_num = int(sys.stdin.readline()) cards =[ card[:-1] for card in sys.stdin.readlines() ] print(cards_num) print(cards) all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ] missing_cards = [i for i in all_cards if not(i in cards) ] for s in missing_cards: print(s)
s587747498
Accepted
30
5,604
274
import sys cards_num = int(sys.stdin.readline()) cards =[ card[:-1] for card in sys.stdin.readlines() ] all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ] missing_cards = [i for i in all_cards if not(i in cards) ] for s in missing_cards: print(s)
s611236265
p03737
u478266845
2,000
262,144
Wrong Answer
17
2,940
123
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.
s1,s2,s3 = [str(i) for i in input().split()] s1.upper() s2.upper() s3.upper() ans = s1[0] +s2[0] +s3[0] print(str(ans))
s501738683
Accepted
17
2,940
138
s1,s2,s3 = [str(i) for i in input().split()] S1 = s1.upper() S2 = s2.upper() S3 = s3.upper() ans = S1[0] +S2[0] +S3[0] print(str(ans))
s590458485
p03455
u546235346
2,000
262,144
Wrong Answer
17
2,940
114
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
l = input().split() print(l) a = int(l[0]) b = int(l[1]) if ((a*b)%2 == 0): print ("Even") else: print ("Odd")
s124065445
Accepted
17
2,940
115
l = input().split() # print(l) a = int(l[0]) b = int(l[1]) if ((a*b)%2 == 0): print ("Even") else: print ("Odd")
s387538551
p02613
u938785734
2,000
1,048,576
Wrong Answer
158
16,240
344
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()) li=[] for i in range(n): s=input() li.append(s) ac=0 wa=0 tle=0 re=0 for i in li: if i=="AC": ac+=1 elif i =="TLE": tle+=1 elif i=="wa": wa+=1 else: re+=1 print("AC × {}".format(ac)) print("WA × {}".format(wa)) print("TLE × {}".format(tle)) print("RE × {}".format(re))
s424758726
Accepted
160
16,324
340
n=int(input()) li=[] for i in range(n): s=input() li.append(s) ac=0 wa=0 tle=0 re=0 for i in li: if i=="AC": ac+=1 elif i =="TLE": tle+=1 elif i=="WA": wa+=1 else: re+=1 print("AC x {}".format(ac)) print("WA x {}".format(wa)) print("TLE x {}".format(tle)) print("RE x {}".format(re))
s914343272
p03377
u570612423
2,000
262,144
Wrong Answer
18
3,060
195
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.
# -*- coding: utf-8 -*- A,B,X = map(int, input().split()) if X==A: print("Yes") elif A < X and X < (A+B): print("Yes") elif A < X and X == (A+B): print("Yes") else: print("No")
s686856314
Accepted
17
3,060
195
# -*- coding: utf-8 -*- A,B,X = map(int, input().split()) if X==A: print("YES") elif A < X and X < (A+B): print("YES") elif A < X and X == (A+B): print("YES") else: print("NO")
s792511531
p02233
u007270338
1,000
131,072
Wrong Answer
20
5,600
236
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula: \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}
#coding:utf-8 n = int(input()) F = [False for i in range(n+1)] def fib(n): if n == 1 or n == 2: F[n] = 1 return 1 if F[n]: return F[n] F[n] = fib(n-2) + fib(n-1) return F[n] a = fib(n) print(a)
s860644117
Accepted
30
5,608
236
#coding:utf-8 n = int(input()) F = [False for i in range(n+1)] def fib(n): if n == 0 or n == 1: F[n] = 1 return 1 if F[n]: return F[n] F[n] = fib(n-2) + fib(n-1) return F[n] a = fib(n) print(a)
s602915466
p03067
u085186789
2,000
1,048,576
Wrong Answer
27
9,080
105
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 > min(A, B) and C < max(A, B): print("YES") else: print("NO")
s431976017
Accepted
23
9,100
106
A, B, C = map(int,input().split()) if C > min(A, B) and C < max(A, B): print("Yes") else: print("No")
s668471251
p03351
u496687522
2,000
1,048,576
Wrong Answer
17
2,940
113
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()) print('Yes' if abs(a-c) <= d or abs(a-b) <= d and abs(a-c) <= d else 'No')
s051782070
Accepted
17
2,940
113
a, b, c, d = map(int, input().split()) print('Yes' if abs(a-c) <= d or abs(a-b) <= d and abs(b-c) <= d else 'No')
s242661380
p03730
u768896740
2,000
262,144
Wrong Answer
19
2,940
141
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`.
a, b, c = map(int, input().split()) for i in range(10000): t = a * i if t % b == c: print('Yes') exit() print('No')
s005934310
Accepted
19
2,940
141
a, b, c = map(int, input().split()) for i in range(10000): t = a * i if t % b == c: print('YES') exit() print('NO')
s715587746
p03399
u888933875
2,000
262,144
Wrong Answer
24
9,024
142
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
l= sorted([int(input()) for _ in range(2)]) m=sorted([int(input()) for _ in range(2)]) print(l,m) ans= min(x+y for x,y in zip(l,m)) print(ans)
s394903799
Accepted
29
9,024
149
from itertools import product l= [int(input()) for _ in range(2)] m=[int(input()) for _ in range(2)] ans= min(x+y for x,y in product(l,m)) print(ans)
s110071700
p01086
u284260266
8,000
262,144
Wrong Answer
30
5,608
1,392
A _Short Phrase_ (aka. Tanku) is a fixed verse, inspired by Japanese poetry Tanka and Haiku. It is a sequence of words, each consisting of lowercase letters 'a' to 'z', and must satisfy the following condition: > (The Condition for a Short Phrase) > The sequence of words can be divided into five sections such that the total > number of the letters in the word(s) of the first section is five, that of > the second is seven, and those of the rest are five, seven, and seven, > respectively. The following is an example of a Short Phrase. > > do the best and enjoy today at acm icpc In this example, the sequence of the nine words can be divided into five sections (1) "do" and "the", (2) "best" and "and", (3) "enjoy", (4) "today" and "at", and (5) "acm" and "icpc" such that they have 5, 7, 5, 7, and 7 letters in this order, respectively. This surely satisfies the condition of a Short Phrase. Now, _Short Phrase Parnassus_ published by your company has received a lot of contributions. By an unfortunate accident, however, some irrelevant texts seem to be added at beginnings and ends of contributed Short Phrases. Your mission is to write a program that finds the Short Phrase from a sequence of words that may have an irrelevant prefix and/or a suffix.
while True: n = int(input()) if n == 0: break w = list() for i in range(0, n): w.append(input()) for j in range(1, n+1): ck = 0 co = 0 p = 0 t = "" for k in range(j-1,50): #print(k) if co == 0 or co == 2: if ck < 5: #print("<") ck = ck + len(w[k+p]) elif ck == 5: #print("==") co = co + 1 ck = 0 p = p-1 else: #print(">") break else: if ck < 7: #print("<7") ck = ck+len(w[k+p]) #print(" " ,ck) elif ck == 7: #print("==7") co = co+1 ck = 0 p = p-1 if co == 5: t = "fin" break else: #print(">7") break print(j) if t == "fin": break #print("over")
s732966864
Accepted
30
5,608
1,396
while True: n = int(input()) if n == 0: break w = list() for i in range(0, n): w.append(input()) for j in range(1, n+1): ck = 0 co = 0 p = 0 t = "" for k in range(j-1,50): #print(k) if co == 0 or co == 2: if ck < 5: #print("<") ck = ck + len(w[k+p]) elif ck == 5: #print("==") co = co + 1 ck = 0 p = p-1 else: #print(">") break else: if ck < 7: #print("<7") ck = ck+len(w[k+p]) #print(" " ,ck) elif ck == 7: #print("==7") co = co+1 ck = 0 p = p-1 if co == 5: t = "fin" break else: #print(">7") break if t == "fin": print(j) break #print("over")
s696220175
p03455
u780675733
2,000
262,144
Wrong Answer
17
2,940
108
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 % 2 == 0) and (b % 2 == 0): print("Even") else: print("Odd")
s896248752
Accepted
17
2,940
91
a, b = map(int, input().split()) if a*b % 2 == 0: print("Even") else: print("Odd")
s655578451
p02275
u949517845
1,000
131,072
Wrong Answer
50
7,684
546
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort.
# -*- coding:utf-8 -*- def countingSort(A, B, k, n): C = [0] * (k+1) for i in range(1, n + 1): C[A[i]] += 1 for j in range(1, k + 1): C[j] = C[j] + C[j - 1] print(C) for j in range(n, 0, -1): B[C[A[j]]] = A[j] C[A[j]] -= 1 if __name__ == "__main__": n = int(input()) lst = [int(val) for val in input().split()] lst.insert(0, 0) result = [0] * (n + 1) k = max(lst) countingSort(lst, result, k, n) result.pop(0) print(" ".join([str(val) for val in result]))
s224292442
Accepted
1,620
242,152
465
# -*- coding:utf-8 -*- def countingSort(lst, n): cnt_lst = [0] * (max(lst)+1) for i in range(0, n): cnt_lst[lst[i]] += 1 i = 0 result = [] for j, cnt in enumerate(cnt_lst): for _ in range(0, cnt): result.append(j) return result if __name__ == "__main__": n = int(input()) lst = [int(val) for val in input().split()] result = countingSort(lst, n) print(" ".join([str(val) for val in result]))
s485183102
p02842
u478417863
2,000
1,048,576
Wrong Answer
26
9,232
380
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
n=int(input()) a=n//108 B=n%108 if B<13: b=B elif 14<=B<24: b=B-1 print(100*a+b) elif 27<=B<38: b=B-2 print(100*a+b) elif 41<=B<50: b=B-3 print(100*a+b) elif 54<=B<63: b=B-4 print(100*a+b) elif 68<=B<75: b=B-5 print(100*a+b) elif 81<=B<88: b=B-6 print(100*a+b) elif 95<=B<100: b=B-7 print(100*a+b) else : print(":(")
s905671305
Accepted
36
9,176
133
N = int(input()) ans = -1 for i in range(1, N + 1): if int(i * 1.08) == N: ans = i if ans != -1: print(ans) else: print(":(")
s024856896
p03455
u806855121
2,000
262,144
Wrong Answer
17
2,940
137
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(str, input().split()) n = int(a+b) for i in range(1, 318): if i**2 == n: print('Yes') quit() print('No')
s838529767
Accepted
17
2,940
89
a, b = map(int, input().split()) if a*b%2 == 0: print('Even') else: print('Odd')
s960738442
p02866
u587589241
2,000
1,048,576
Wrong Answer
85
24,248
257
Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i.
from collections import Counter N = int(input()) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in D[1:]: ans *= c[i-1] ans %= mod else: print(0)
s309122428
Accepted
91
24,316
272
from collections import Counter N = int(input()) D = list(map(int, input().split())) mod = 998244353 c = Counter(D) m = max(c.keys()) if D[0] == 0 and c[0] == 1: ans = 1 for i in D[1:]: ans *= c[i-1] ans %= mod print(ans) else: print(0)
s787814002
p03543
u205700197
2,000
262,144
Wrong Answer
18
2,940
160
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() count = 0 for i in range(0,2): if n[i] == n[i+1]: count = count + 1 print(count) if count >= 2: print("Yes") else:print("No")
s266538957
Accepted
17
2,940
149
n=input() count = 0 for i in range(0,2): if n[i] == n[i+1] == n[i+2]: count = count + 1 if count >= 1: print("Yes") else:print("No")
s193541832
p02389
u684306364
1,000
131,072
Wrong Answer
30
7,520
51
Write a program which calculates the area and perimeter of a given rectangle.
ab = input().split() print(int(ab[0]) * int(ab[1]))
s597013772
Accepted
30
7,480
96
ab = input().split() a = int(ab[0]) b = int(ab[1]) print("{0} {1}".format(a * b, a * 2 + b * 2))
s289021440
p02415
u075836834
1,000
131,072
Wrong Answer
20
7,328
112
Write a program which converts uppercase/lowercase letters to lowercase/uppercase for a given string.
import sys A=input().split() print(A) for i in A: sys.stdout.write(i.swapcase()) sys.stdout.write(" ") print()
s472899264
Accepted
30
7,428
118
import sys A=input().split() for i in A: sys.stdout.write(i.swapcase()) if i!=A[-1]: sys.stdout.write(" ") print()
s739209255
p03997
u209619667
2,000
262,144
Wrong Answer
17
2,940
71
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()) c = int(input()) s = (a+b)/2 print(s)
s556569726
Accepted
17
2,940
84
a = int(input()) b = int(input()) h = int(input()) s = (a+b)*h s = s/2 print(int(s))
s048068179
p04031
u703214333
2,000
262,144
Wrong Answer
21
2,940
160
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
n=int(input()) a=list(map(int,input().split())) ans=10**9 for i in a: tmp=0 for j in range(n): tmp+=(i-a[j])**2 ans=min(tmp,ans) print(ans)
s131304641
Accepted
26
3,060
173
n=int(input()) a=list(map(int,input().split())) ans=10**9 for i in range(-100,101): tmp=0 for j in range(n): tmp+=(i-a[j])**2 ans=min(tmp,ans) print(ans)
s314435554
p03160
u858033561
2,000
1,048,576
Wrong Answer
204
13,924
330
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
import sys n = int(sys.stdin.readline().strip()) hs = list(map(int, sys.stdin.readline().strip().split(' '))) print(n,hs) dp = [0]*n for i in range(1, n): x = 10**10 if i-1 >= 0: x = min(x, dp[i-1]+abs(hs[i]-hs[i-1])) if i-2 >= 0: x = min(x, dp[i-2]+abs(hs[i]-hs[i-2])) dp[i] = x print(dp[n-1])
s133684043
Accepted
173
13,976
319
import sys n = int(sys.stdin.readline().strip()) hs = list(map(int, sys.stdin.readline().strip().split(' '))) dp = [0]*n for i in range(1, n): x = 10**10 if i-1 >= 0: x = min(x, dp[i-1]+abs(hs[i]-hs[i-1])) if i-2 >= 0: x = min(x, dp[i-2]+abs(hs[i]-hs[i-2])) dp[i] = x print(dp[n-1])
s160760490
p03997
u316603606
2,000
262,144
Wrong Answer
31
8,976
83
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int (input ()) b = int (input ()) h = int (input ()) S = ((a+b)*h)/2 print (S)
s382787308
Accepted
25
9,048
84
a = int (input ()) b = int (input ()) h = int (input ()) print ((a+b)*(round(h/2)))
s167945352
p03407
u811202694
2,000
262,144
Wrong Answer
17
2,940
108
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()) total = 2 * (a + b) if total >= c: print("YES") else: print("NO")
s764955364
Accepted
21
2,940
104
a,b,c = map(int,input().split()) total = (a + b) if total >= c: print("Yes") else: print("No")
s409719624
p03251
u307585631
2,000
1,048,576
Wrong Answer
17
3,064
327
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
N, M, X, Y = map(int, input().split()) list_x = list(map(int,input().split(' '))) list_y = list(map(int,input().split(' '))) min_range = max(list_x) max_range = min(list_y) ans = 0 for i in range(X+1, Y): if(i > min_range and i <= max_range): ans = 1 if (ans == 1): print("No war") elif (ans == 0): print("War")
s085892465
Accepted
17
3,064
333
N, M, X, Y = map(int, input().split()) list_x = list(map(int,input().split(' '))) list_y = list(map(int,input().split(' '))) min_range = max(list_x) max_range = min(list_y) ans = 0 for i in range(X+1, Y+1): if(i > min_range and i <= max_range): ans = 1 if (ans == 1): print("No War") elif (ans == 0): print("War")
s776882013
p03024
u366541443
2,000
1,048,576
Wrong Answer
17
3,060
129
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.
import math n = list(map(str, input().split())) n=n[0] yes=0 no=0 print(yes,no) if(no>=8): print("NO") else: print("YES")
s851775081
Accepted
18
3,060
170
import math n = list(map(str, input().split())) n=n[0] yes=0 no=0 for i in range(len(n)): if(n[i]=='x'): no+=1 if(no>=8): print("NO") else: print("YES")
s030482843
p03563
u317440328
2,000
262,144
Wrong Answer
17
2,940
44
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
R=int(input()) G=float(input()) print(2*G-R)
s904084452
Accepted
17
2,940
42
R=int(input()) G=int(input()) print(2*G-R)
s496508877
p03379
u026155812
2,000
262,144
Wrong Answer
311
25,220
156
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
N = int(input()) X = [int(i) for i in input().split()] for i in range(N): if i < N/2: print(X[int(N/2)]) else: print(X[int(N/2)-1])
s260571720
Accepted
326
25,344
266
N = int(input()) X = [int(i) for i in input().split()] a = X[:] a.sort() l = a[N//2-1] r = a[N//2] if l == r: for i in range(N): print(l) else: for i in range(N): if X[i] <= l: print(r) elif X[i] >= r: print(l)
s802619017
p02846
u968846084
2,000
1,048,576
Wrong Answer
17
3,192
673
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
t=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) if t[0]*a[0]+t[1]*a[1]==t[0]*b[0]+t[1]*b[1]: print("infinity") else: if t[0]*a[0]>t[0]*b[0]: if t[0]*a[0]+t[1]*a[1]>t[0]*b[0]+t[1]*b[1]: print(0) else: d=(t[0]*b[0]+t[1]*b[1])-(t[0]*a[0]+t[1]*a[1]) c=t[0]*a[0]-t[0]*b[0] if c//d==0: print(c//d*2) else: print(c//d*2+1) else: if t[0]*a[0]+t[1]*a[1]<t[0]*b[0]+t[1]*b[1]: print(0) else: d=(t[0]*a[0]+t[1]*a[1])-(t[0]*b[0]+t[1]*b[1]) c=t[0]*b[0]-t[0]*a[0] if c//d==0: print(c//d*2) else: print(c//d*2+1)
s171888966
Accepted
17
3,064
671
t=list(map(int,input().split())) a=list(map(int,input().split())) b=list(map(int,input().split())) if t[0]*a[0]+t[1]*a[1]==t[0]*b[0]+t[1]*b[1]: print("infinity") else: if t[0]*a[0]>t[0]*b[0]: if t[0]*a[0]+t[1]*a[1]>t[0]*b[0]+t[1]*b[1]: print(0) else: d=(t[0]*b[0]+t[1]*b[1])-(t[0]*a[0]+t[1]*a[1]) c=t[0]*a[0]-t[0]*b[0] if c%d==0: print(c//d*2) else: print(c//d*2+1) else: if t[0]*a[0]+t[1]*a[1]<t[0]*b[0]+t[1]*b[1]: print(0) else: d=(t[0]*a[0]+t[1]*a[1])-(t[0]*b[0]+t[1]*b[1]) c=t[0]*b[0]-t[0]*a[0] if c%d==0: print(c//d*2) else: print(c//d*2+1)
s416502772
p02612
u604055101
2,000
1,048,576
Wrong Answer
26
9,132
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)
s034735478
Accepted
30
9,140
76
n = int(input()) if n%1000 == 0: print(0) else: print(1000-n%1000)
s484836017
p02392
u885889402
1,000
131,072
Wrong Answer
20
7,540
84
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
s=input() a,b,c=map(int,s.split()) if(a<b<c): print("yes") else: print("No")
s177839143
Accepted
20
7,680
90
s=input() a,b,c=map(int,s.split()) if(a<b and b<c): print("Yes") else: print("No")
s640815225
p03777
u234631479
2,000
262,144
Wrong Answer
17
2,940
103
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or Dishonest_. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either `H` or `D`, and carries the following information: If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`, AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest.
a,b = input().split() print(a,b) if a == "H": print(b) elif b == "H": print("D") else: print("H")
s531674962
Accepted
17
2,940
92
a,b = input().split() if a == "H": print(b) elif b == "H": print("D") else: print("H")
s154960453
p03779
u870518235
2,000
262,144
Wrong Answer
34
9,140
117
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
# ABC056_C X = int(input()) sum = 0 for i in range(1,X+1): sum = sum + i if sum > X: break print(i)
s039298929
Accepted
35
9,140
118
# ABC056_C X = int(input()) sum = 0 for i in range(1,X+1): sum = sum + i if sum >= X: break print(i)
s234530260
p03457
u112523623
2,000
262,144
Wrong Answer
1,020
5,876
730
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.
if __name__ == "__main__": n = int(input()) cur_x = 0 cur_y = 0 cur_t = 0 can_travel = True for _ in range(n): next_t, next_x, next_y = list(map(int, input().split(" "))) time_diff = abs(next_t - cur_t) x_diff = abs(next_x - cur_x) y_diff = abs(next_y - cur_y) print("time_diff:{}, shortest_diff:{}".format(time_diff, (x_diff + y_diff))) if time_diff < (x_diff + y_diff): can_travel = False elif time_diff > (x_diff + y_diff): can_travel = ((time_diff - (x_diff + y_diff)) % 2 == 0) cur_t, cur_x, cur_y = next_t, next_x, next_y if not can_travel: break print("Yes" if can_travel else "No")
s481123756
Accepted
415
3,064
601
if __name__ == "__main__": n = int(input()) cur_x = 0 cur_y = 0 cur_t = 0 can_travel = True for _ in range(n): next_t, next_x, next_y = list(map(int, input().split(" "))) time_diff = abs(next_t - cur_t) xy_diff = abs(next_x - cur_x) + abs(next_y - cur_y) if time_diff < xy_diff: can_travel = False elif time_diff > xy_diff: can_travel = ((time_diff - xy_diff) % 2 == 0) if not can_travel: break cur_t, cur_x, cur_y = next_t, next_x, next_y print("Yes" if can_travel else "No")
s969163404
p00003
u150984829
1,000
131,072
Wrong Answer
30
5,612
101
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 _ in[0]*int(input()): a,b,c=map(int,sorted(input().split())) print(['No','Yes'][a*a+b*b==c*c])
s228967488
Accepted
30
5,640
119
import sys input() for a,b,c in map(lambda x:sorted(map(int,x.split())),sys.stdin): print(['NO','YES'][a*a+b*b==c*c])
s624466578
p03860
u867848444
2,000
262,144
Wrong Answer
17
2,940
25
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
print('A'+input()[8]+'c')
s929781007
Accepted
17
2,940
49
a,b,c=input().split() print('A',b[0],'C',sep='')
s349187951
p03386
u200239931
2,000
262,144
Wrong Answer
18
3,064
917
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.
import math import sys def getinputdata(): array_result = [] data = input() array_result.append(data.split(" ")) flg = True try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" ")) flg = True else: flg = False finally: return array_result arr_data = getinputdata() a = int(arr_data[0][0]) b = int(arr_data[0][1]) k = int(arr_data[0][2]) #print(a,b,k) s1=set() cnt=0 for i in range(a,b+1): # print(i) if cnt<k: s1.add(i) cnt+=1 else: break cnt=0 for i in range(b,a-1,-1): if cnt<k: s1.add(i) cnt+=1 else: break print("\n".join(list(map(str, list(s1)))))
s613082086
Accepted
18
3,064
1,009
import math import sys def getinputdata(): array_result = [] data = input() array_result.append(data.split(" ")) flg = True try: while flg: data = input() array_temp = [] if(data != ""): array_result.append(data.split(" ")) flg = True else: flg = False finally: return array_result arr_data = getinputdata() a = int(arr_data[0][0]) b = int(arr_data[0][1]) k = int(arr_data[0][2]) #print(a,b,k) s1=set() cnt=0 for i in range(a,b+1): # print(i) if cnt<k: s1.add(i) cnt+=1 else: break cnt=0 for i in range(b,a-1,-1): if cnt<k: s1.add(i) cnt+=1 else: break #print(s1) list01=sorted(list(s1),reverse=False) #print(list01) #print(list(map(str, list01))) print("\n".join(list(map(str, list01))))
s504467394
p03599
u101490607
3,000
262,144
Wrong Answer
148
12,456
828
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
a,b,c,d,e,f = map(int, input().split()) x = [] y = [] k=0 i = 0 j = 0 #print(a,b,c,d,e,f) while( 100*a*i + 100*b*j < f ): while( 100*a*i + 100*b*j < f): x.append(100*a*i + 100*b*j) j +=1 j = 0 i +=1 i = 0 j = 0 while( c*i + d*j < f ): while( c*i + d*j < f): y.append(c*i + d*j) j +=1 j = 0 i +=1 x = list(set(x)) y = list(set(y)) x.remove(0) y.remove(0) #print( x ) noudo = 0 reg_i = 0 reg_j = 0 for i in range(len(x)): if x[i] > f: break for j in range(len(y)): if x[i]+y[j] > f: break tmp_noudo = 100 * y[j] / (x[i] + y[j]) if tmp_noudo <= 100 * e / (100 + e): if noudo < tmp_noudo: noudo = tmp_noudo reg_i = i reg_j = j print( x[reg_i]+y[reg_j] , y[reg_j] ) #print( eki, satou)
s164041129
Accepted
135
12,476
758
a,b,c,d,e,f = map(int, input().split()) x = [] y = [] k=0 i = 0 j = 0 #print(a,b,c,d,e,f) while( 100*a*i + 100*b*j <= f ): while( 100*a*i + 100*b*j <= f): x.append(100*a*i + 100*b*j) j +=1 j = 0 i +=1 i = 0 j = 0 while( c*i + d*j <= f ): while( c*i + d*j <= f): y.append(c*i + d*j) j +=1 j = 0 i +=1 x = list(set(x)) y = list(set(y)) x.remove(0) #y.remove(0) #print( x ) noudo = 0 reg_i = 0 reg_j = 0 for i in range(len(x)): for j in range(len(y)): tmp_noudo = 100 * y[j] / (x[i] + y[j]) if tmp_noudo <= 100 * e / (100 + e) and (x[i] + y[j]) <= f: if noudo < tmp_noudo: noudo = tmp_noudo reg_i = i reg_j = j print( x[reg_i]+y[reg_j] , y[reg_j] )
s739622853
p02379
u216425054
1,000
131,072
Wrong Answer
20
7,444
112
Write a program which calculates the distance between two points P1(x1, y1) and P2(x2, y2).
import math x1, x2, y1, y2 = map(float,input().split()) print("{0:8f}".format(math.sqrt((x1-x2)**2+(y1-y1)**2)))
s782047438
Accepted
20
7,524
110
import math x1,y1,x2,y2 = map(float,input().split()) print("{0:.8f}".format(math.sqrt((x1-x2)**2+(y1-y2)**2)))
s283703959
p03407
u695429668
2,000
262,144
Wrong Answer
17
2,940
122
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.
# coding: utf-8 A, B, C = list(map(int, input().split())) ans = A+B if ans <= C: print("Yes") else: print("No")
s052495553
Accepted
17
2,940
122
# coding: utf-8 A, B, C = list(map(int, input().split())) ans = A+B if ans >= C: print("Yes") else: print("No")
s551192497
p03605
u077291787
2,000
262,144
Wrong Answer
18
2,940
153
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
# ABC073A - September 9 def main(): N = input().rstrip() flg = "g" in N print("Yes" if flg else "No") if __name__ == "__main__": main()
s327167228
Accepted
18
2,940
153
# ABC073A - September 9 def main(): N = input().rstrip() flg = "9" in N print("Yes" if flg else "No") if __name__ == "__main__": main()
s826748773
p00067
u093607836
1,000
131,072
Wrong Answer
40
6,760
965
地勢を示す縦 12, 横 12 のマスからなる平面図があります。おのおののマスは白か黒に塗られています。白は海を、黒は陸地を表します。二つの黒いマスが上下、あるいは左右に接しているとき、これらは地続きであるといいます。この平面図では、黒いマス一つのみ、あるいは地続きの黒いマスが作る領域を「島」といいます。例えば下図には、5 つの島があります。 ■■■■□□□□■■■■ ■■■□□□□□■■■■ ■■□□□□□□■■■■ ■□□□□□□□■■■■ □□□■□□□■□□□□ □□□□□□■■■□□□ □□□□□■■■■■□□ ■□□□■■■■■■■□ ■■□□□■■■■■□□ ■■■□□□■■■□□□ ■■■■□□□■□□□□ □□□□□□□□□□□□ マスのデータを読み込んで、島の数を出力するプログラムを作成してください。
import itertools def getPoint(m,x,y): if not (0 <= x < 12) or not (0 <= y < 12): return 0 return m[y][x] def setPoint(m,x,y,v): m[y][x] = v while 1: try: m = [list(map(int,input().strip())) for _ in range(12)] count = 0 empty = False while not empty: empty = True for x,y in itertools.product(range(12),repeat=2): if(getPoint(m,x,y)): print(x,y) count += 1 empty = False q = [] q.append((x,y)) while q != []: p = q.pop() if(getPoint(m,p[0],p[1])): setPoint(m,p[0],p[1],0) for o in [(1,0),(-1,0),(0,1),(0,-1)]: q.append((p[0] + o[0], p[1] + o[1])) print(count) input() except: exit()
s397588046
Accepted
40
6,756
934
import itertools def getPoint(m,x,y): if not (0 <= x < 12) or not (0 <= y < 12): return 0 return m[y][x] def setPoint(m,x,y,v): m[y][x] = v while 1: try: m = [list(map(int,input().strip())) for _ in range(12)] count = 0 empty = False while not empty: empty = True for x,y in itertools.product(range(12),repeat=2): if(getPoint(m,x,y)): count += 1 empty = False q = [] q.append((x,y)) while q != []: p = q.pop() if(getPoint(m,p[0],p[1])): setPoint(m,p[0],p[1],0) for o in [(1,0),(-1,0),(0,1),(0,-1)]: q.append((p[0] + o[0], p[1] + o[1])) print(count) input() except: exit()
s771613992
p03476
u785989355
2,000
262,144
Wrong Answer
1,029
8,704
524
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.
def sieve_of_eratosthenes(n): pl = [i for i in range(2, n + 1)] i=0 p = pl[0] while p**2<=n: pl = [pl[j] for j in range(len(pl)) if pl[j]%p!=0 or j<=i] i+=1 p=pl[i] return pl pl=sieve_of_eratosthenes(100000) p_list = [0 for i in range(100001)] for p in pl: p_list[p]+=1 ps_list = [0] ps = 0 for i in range(1,100001): ps+=p_list[i] ps_list.append(ps) Q = int(input()) for i in range(Q): l,r = list(map(int,input().split())) print(ps_list[r]-ps_list[l-1])
s927994071
Accepted
1,038
8,320
591
def sieve_of_eratosthenes(n): pl = [i for i in range(2, n + 1)] i=0 p = pl[0] while p**2<=n: pl = [pl[j] for j in range(len(pl)) if pl[j]%p!=0 or j<=i] i+=1 p=pl[i] return pl pl=sieve_of_eratosthenes(100000) p_list = [0 for i in range(100001)] for p in pl: if 2*p-1<=100000: p_list[2*p-1]+=1 p_list[p]+=1 ps_list = [0] ps = 0 for i in range(1,100001): if p_list[i]>=2: ps+=1 ps_list.append(ps) Q = int(input()) for i in range(Q): l,r = list(map(int,input().split())) print(ps_list[r]-ps_list[l-1])
s552780697
p02406
u643542669
1,000
131,072
Wrong Answer
20
5,580
92
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 is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
import sys n = int(input()) for i in range(3, n + 1, 3): sys.stdout.write("%d " % (i))
s335551620
Accepted
20
5,640
127
n = input() out = "" for i in range(1, int(n) + 1): if i % 3 == 0 or "3" in str(i): out += " " + str(i) print(out)
s675340428
p03476
u993435350
2,000
262,144
Wrong Answer
2,104
4,636
491
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.
def isprime(n): m = (n + 1) // 2 i = 2 if m in primedic and n in primedic: return True while i * i <= m: if m % i == 0: return False i += 1 i -= 1 while i * i <= n: if n % i == 0: return False i += 1 return True primedic = {} Q = int(input()) for i in range(Q): l,r = map(int,input().split()) ans = 0 for i in range(l,r + 1): if isprime(i): primedic[i] = True primedic[(i + 1) // 2] = True ans += 1 print(ans)
s401195801
Accepted
533
5,432
432
import sys input = sys.stdin.readline def isprime(x): if x <= 1: return False for i in range(2, int(x**0.5) + 1): if x % i == 0: return False return True A = [0] * 10 ** 5 B = [0] * 10 ** 5 con = 0 for i in range(10 ** 5): if isprime(i): A[i] = 1 if A[i] and A[(i + 1) // 2]: con += 1 B[i] = con Q = int(input()) for _ in range(Q): l, r = map(int, input().split()) print(B[r] - B[l - 1])
s221285737
p02833
u437860615
2,000
1,048,576
Wrong Answer
17
2,940
66
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).
def func(n): if n < 2: return 1 return n * f(n-2) func(1)
s458959888
Accepted
17
2,940
122
n = int(input()) a = 0 i = 1 if n % 2 == 0: while 2 * (5 ** i) <= n: a += n // (2 * (5 ** i)) i += 1 print(a)
s404226288
p03556
u840958781
2,000
262,144
Wrong Answer
18
2,940
37
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
n = int(input()) print(n ** 0.5 ** 2)
s108127660
Accepted
17
2,940
42
n = int(input()) print(int(n ** 0.5) ** 2)
s585889538
p03477
u693953100
2,000
262,144
Wrong Answer
18
2,940
126
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d = map(int,input().split()) if a+b<c+d: print('Left') elif a+b==c+d: print('Balanced') else: print('Right')
s200922843
Accepted
17
2,940
126
a,b,c,d = map(int,input().split()) if a+b>c+d: print('Left') elif a+b==c+d: print('Balanced') else: print('Right')
s214476912
p03050
u522726434
2,000
1,048,576
Wrong Answer
188
3,060
167
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
import math N = int(input()) max_m = math.floor(math.sqrt(N) - 1) count = 0 for i in range(1, max_m+1): if (N - i) % i == 0: count += (N - i) // i print(count)
s429604881
Accepted
525
3,064
182
import math N = int(input()) count = 0 m = 1 while m**2 < N: if (N - m) % m == 0: fav_num = (N - m) // m if fav_num > m: count += fav_num m += 1 print(count)
s098567241
p03612
u530844517
2,000
262,144
Wrong Answer
124
13,880
305
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
n = int(input()) p = list(map(int, input().split())) swap = 0 flag = 0 while True: flag = 0 for i in range(n-1): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] flag = 1 swap += 1 print(swap) if flag == 0: print(swap) break
s331747545
Accepted
88
13,880
388
n = int(input()) p = list(map(int, input().split())) swap = 0 flag = 0 while True: flag = 0 for i in range(n-1): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] flag = 1 swap += 1 if p[n-1] == n: p[n-1], p[n-2] = p[n-2], p[n-1] flag = 1 swap += 1 if flag == 0: print(swap) break
s506176031
p03434
u652150585
2,000
262,144
Wrong Answer
17
3,060
119
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
num=int(input()) n=list(map(int,input().split())) n.sort(reverse=True) print(n) a=sum(n[::2]) b=sum(n[1::2]) print(a-b)
s604773880
Accepted
17
2,940
120
num=int(input()) n=list(map(int,input().split())) n.sort(reverse=True) #print(n) a=sum(n[::2]) b=sum(n[1::2]) print(a-b)
s358518791
p03079
u927764913
2,000
1,048,576
Wrong Answer
17
2,940
66
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
a,b,c = map(int,input().split()) if a == b == c: print("yes")
s756226492
Accepted
17
2,940
85
a,b,c = map(int,input().split()) if a == b == c: print("Yes") else : print("No")
s037421120
p03469
u158225062
2,000
262,144
Wrong Answer
18
2,940
75
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.
# coding: utf-8 N = input() N_list = list(N) N_list[3] = 8 print(N_list)
s758511323
Accepted
681
15,416
124
# coding: utf-8 import numpy N = input() N_list = list(N) map(str,N_list) N_list[3] = "8" ans = ''.join(N_list) print(ans)
s435431731
p03386
u550014122
2,000
262,144
Wrong Answer
29
9,116
154
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 = map(int, input().split()) s = set() for i in range(a,min(a+k,b+1)): s.add(i) for i in range(max(a,b-k+1),b+1): s.add(i) for i in s: print(i)
s920701262
Accepted
25
9,168
119
a,b,k=map(int,input().split()) b+=1 for i in range(a,min(a+k,b)): print(i) for i in range(max(b-k,a+k),b): print(i)
s502455768
p02927
u629540524
2,000
1,048,576
Wrong Answer
30
9,056
104
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
m,d = map(int,input().split()) c = 0 for i in range(22,d+1): if i//10*i%10<=m: c+=1 print(c)
s936067555
Accepted
26
9,096
118
m,d = map(int,input().split()) c = 0 for i in range(22,d+1): if i//10*(i%10)<=m and i%10>=2: c+=1 print(c)
s478157315
p03478
u849622363
2,000
262,144
Wrong Answer
27
3,064
324
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()) counter = 0 for i in range(1,n+1): thou = i // 1000 hund = (i - thou * 1000) // 100 ten = (i - thou * 1000 - hund * 100) // 10 one = i - thou * 1000 - hund * 100 - ten * 10 sum_all = thou + hund + ten + one if sum_all >= a and sum_all <= b: counter += 1 print(counter)
s695052194
Accepted
39
3,060
413
n,a,b = map(int, input().split()) counter = 0 for i in range(1,n+1): tent = i //10000 thou = (i - tent * 10000) // 1000 hund = (i - thou * 1000 - tent * 10000) // 100 ten = (i - thou * 1000 - hund * 100 - tent * 10000) // 10 one = i - thou * 1000 - hund * 100 - ten * 10 - tent * 10000 sum_all = tent + thou + hund + ten + one if sum_all >= a and sum_all <= b: counter += i print(counter)
s299353971
p03730
u488884575
2,000
262,144
Wrong Answer
18
2,940
154
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`.
a,b,c = map(int, input().split()) ans = 0 for i in range(1, 200): if i*a%b == c: ans = 1 if ans == 1: print('Yes') else: print('No')
s363023875
Accepted
17
3,060
154
a,b,c = map(int, input().split()) ans = 0 for i in range(1, 200): if i*a%b == c: ans = 1 if ans == 1: print('YES') else: print('NO')
s640298132
p03388
u383196771
2,000
262,144
Wrong Answer
18
3,064
424
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
import math def worst_case(A, B): c = min(A, B) d = max(A, B) if c == d or c + 1 == d: return 2 * (c - 1) root = int(math.sqrt(A * B)) return 2 * (root - 1) + 1 if root * (root + 1) < A * B else 2 * (root - 1) Q = int(input()) A = [] B = [] for i in range(Q): line = input().split() A.append(int(line[0])) B.append(int(line[1])) for i in range(Q): print(worst_case(A[i], B[i]))
s955271113
Accepted
18
3,064
469
import math def worst_case(A, B): c = min(A, B) d = max(A, B) if c == d or c + 1 == d: return 2 * (c - 1) root = int(math.sqrt(A * B)) if root ** 2 == A * B: root -= 1 return 2 * (root - 1) + 1 if root * (root + 1) < A * B else 2 * (root - 1) Q = int(input()) A = [] B = [] for i in range(Q): line = input().split() A.append(int(line[0])) B.append(int(line[1])) for i in range(Q): print(worst_case(A[i], B[i]))
s593158690
p02406
u908651435
1,000
131,072
Wrong Answer
20
5,588
135
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 is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
n=int(input()) for i in range(n+1): if i%3==0: print(' '+str(i),end='') elif i%10==3: print(' '+str(i),end='')
s264079542
Accepted
20
5,624
244
n = int(input()) ans = "" for i in range(1, n + 1): if(i % 3 == 0): ans += " " + str(i) continue x = i while(x): if(x % 10 == 3): ans += " " + str(i) break x //= 10 print(ans)
s385470811
p03407
u514118270
2,000
262,144
Wrong Answer
39
9,976
534
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.
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) INF = 10**9 mod = 10**9+7 A,B,C = I() if C == A+B or C == A or C == B: print('Yes') else: print('No')
s083772421
Accepted
34
9,952
514
import sys import math import itertools import bisect from copy import copy from collections import deque,Counter from decimal import Decimal def s(): return input() def i(): return int(input()) def S(): return input().split() def I(): return map(int,input().split()) def L(): return list(input().split()) def l(): return list(map(int,input().split())) def lcm(a,b): return a*b//math.gcd(a,b) sys.setrecursionlimit(10 ** 9) INF = 10**9 mod = 10**9+7 A,B,C = I() if C <= A+B: print('Yes') else: print('No')
s001820328
p02255
u630566146
1,000
131,072
Wrong Answer
20
5,604
359
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def insertion_sort(l): for i in range(1, len(l)): tmp = l[i] j = i - 1 while j >= 0 and l[j] > tmp: l[j+1] = l[j] j -= 1 l[j+1] = tmp print(' '.join(map(str, l))) return l if __name__ == '__main__': N = int(input()) l = list(map(int, input().split())) insertion_sort(l)
s747664855
Accepted
20
5,604
392
def insertion_sort(l): for i in range(1, len(l)): tmp = l[i] j = i - 1 while j >= 0 and l[j] > tmp: l[j+1] = l[j] j -= 1 l[j+1] = tmp print(' '.join(map(str, l))) return l if __name__ == '__main__': N = int(input()) l = list(map(int, input().split())) print(' '.join(map(str, l))) insertion_sort(l)
s688641368
p03493
u105210954
2,000
262,144
Wrong Answer
17
2,940
67
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
s = input() n= 0 for c in s: if s == '1': c += 1 print(c)
s153547741
Accepted
17
2,940
67
s = input() n= 0 for c in s: if c == '1': n += 1 print(n)
s147990820
p03023
u735975757
2,000
1,048,576
Wrong Answer
17
2,940
97
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.
S = input() num = S.count("○") print(num) if num >= 8 : print("YES") else : print("NO")
s484151791
Accepted
18
2,940
39
N = int(input()) r = (N-2)*180 print(r)
s278141187
p03448
u528124741
2,000
262,144
Wrong Answer
50
3,060
210
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()) ret = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if (i*500 + i*100 + k*50) == x: ret += 1 print(ret)
s499655117
Accepted
47
3,060
210
a = int(input()) b = int(input()) c = int(input()) x = int(input()) ret = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if (i*500 + j*100 + k*50) == x: ret += 1 print(ret)
s355570440
p03305
u281610856
2,000
1,048,576
Wrong Answer
1,163
58,912
1,347
Kenkoooo is planning a trip in Republic of Snuke. In this country, there are n cities and m trains running. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Any city can be reached from any city by changing trains. Two currencies are used in the country: yen and snuuk. Any train fare can be paid by both yen and snuuk. The fare of the i-th train is a_i yen if paid in yen, and b_i snuuk if paid in snuuk. In a city with a money exchange office, you can change 1 yen into 1 snuuk. However, when you do a money exchange, you have to change all your yen into snuuk. That is, if Kenkoooo does a money exchange when he has X yen, he will then have X snuuk. Currently, there is a money exchange office in every city, but the office in City i will shut down in i years and can never be used in and after that year. Kenkoooo is planning to depart City s with 10^{15} yen in his pocket and head for City t, and change his yen into snuuk in some city while traveling. It is acceptable to do the exchange in City s or City t. Kenkoooo would like to have as much snuuk as possible when he reaches City t by making the optimal choices for the route to travel and the city to do the exchange. For each i=0,...,n-1, find the maximum amount of snuuk that Kenkoooo has when he reaches City t if he goes on a trip from City s to City t after i years. You can assume that the trip finishes within the year.
from heapq import heappush, heappop INF = float("inf") def Dijkstra(n, s, g, mode): dist = [INF] * n dist[s] = 0 hq = [(0, s)] while hq: d, v = heappop(hq) if dist[v] < d: continue for w, *a in g[v]: nd = d + a[mode] if dist[w] > nd: dist[w] = nd heappush(hq, (nd, w)) return dist def main(): n, m, s, t = map(int, input().split()) s -= 1 t -= 1 g = [[] for _ in range(n)] for _ in range(m): u, v, a, b = map(int, input().split()) u -= 1 v -= 1 g[u].append((v, a, b)) g[v].append((u, a, b)) d_yen = Dijkstra(n, s, g, 0) d_sunnk = Dijkstra(n, t, g, 1) ans = [0] * n cost = float("inf") for i in range(n-1, -1, -1): cost = min(cost, d_yen[i] + d_sunnk[i]) ans[i-1] = 10 ** 15 - cost print(*ans, sep='\n') if __name__ == "__main__": main()
s868674758
Accepted
1,152
58,936
1,345
from heapq import heappush, heappop INF = float("inf") def Dijkstra(n, s, g, mode): dist = [INF] * n dist[s] = 0 hq = [(0, s)] while hq: d, v = heappop(hq) if dist[v] < d: continue for w, *a in g[v]: nd = d + a[mode] if dist[w] > nd: dist[w] = nd heappush(hq, (nd, w)) return dist def main(): n, m, s, t = map(int, input().split()) s -= 1 t -= 1 g = [[] for _ in range(n)] for _ in range(m): u, v, a, b = map(int, input().split()) u -= 1 v -= 1 g[u].append((v, a, b)) g[v].append((u, a, b)) d_yen = Dijkstra(n, s, g, 0) d_sunnk = Dijkstra(n, t, g, 1) ans = [0] * n cost = float("inf") for i in range(n-1, -1, -1): cost = min(cost, d_yen[i] + d_sunnk[i]) ans[i] = 10 ** 15 - cost print(*ans, sep='\n') if __name__ == "__main__": main()
s729597653
p03494
u256106029
2,000
262,144
Wrong Answer
17
2,940
265
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n = int(input()) a = list(map(int, input().strip().split())) count = 0 for i in range(n): if i + 1 != n: if a[i] % 2 == 0: continue else: break else: if a[i] % 2 == 0: count += 1 print(count)
s533514900
Accepted
19
3,064
512
n = int(input()) a = list(map(int, input().strip().split())) c = 0 def func(num: int, array: [int], count) -> int: for i in range(num): if i + 1 != num: if array[i] % 2 == 0: array[i] = array[i] / 2 continue else: break else: if array[i] % 2 == 0: count += 1 array[i] = array[i] / 2 count = func(num, array, count) return count print(func(n, a, c))
s547214093
p03963
u901598613
2,000
262,144
Wrong Answer
17
2,940
51
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.
n,m=1,10 for i in range(n-1): m*=(m-1) print(m)
s690187385
Accepted
18
2,940
56
n,m=map(int,input().split()) k=m*((m-1)**(n-1)) print(k)
s426179236
p03089
u952467214
2,000
1,048,576
Wrong Answer
18
2,940
231
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
n = int(input()) b = list( map(int, input().split())) ans = [] while b: for i in reversed(range(len(b))): if b[i] == i+1: ans.append(b.pop(i)) break else: print(-1) exit()
s945905663
Accepted
19
3,060
333
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline n = int(input()) b = list( map(int, input().split())) ans = [] while b: for i in reversed(range(len(b))): if b[i] == i+1: ans.append(b.pop(i)) break else: print(-1) exit() print(*reversed(ans),sep='\n')
s871185829
p03448
u096983897
2,000
262,144
Wrong Answer
53
3,064
220
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()) cnt = 0 for i in range(a): for j in range(b): for k in range(c): sum = i*500 + j*100 + k*50 if sum == x: cnt += 1 print(cnt)
s207516444
Accepted
55
3,064
226
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): sum = i*500 + j*100 + k*50 if sum == x: cnt += 1 print(cnt)
s167724875
p02284
u569960318
2,000
131,072
Wrong Answer
30
7,740
1,740
Write a program which performs the following operations to a binary search tree $T$ by adding the find operation to A: Binary Search Tree I. * insert $k$: Insert a node containing $k$ as key into $T$. * find $k$: Report whether $T$ has a node containing $k$. * print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively.
class BinarySearchTree: def __init__(self): self.root = None def insert(self, z): p = None x = self.root while x != None: p = x if z.key < x.key : x = x.left else : x = x.right z.p = p if p == None : self.root = z elif z.key < p.key: p.left = z else : p.right = z def get_inorder_list(self): def _get_inorder_list(root): l = root.left r = root.right if l: yield from _get_inorder_list(l) yield root.key if r: yield from _get_inorder_list(r) yield from _get_inorder_list(self.root) def get_preorder_list(self): def _get_preorder_list(root): l = root.left r = root.right yield root.key if l: yield from _get_preorder_list(l) if r: yield from _get_preorder_list(r) yield from _get_preorder_list(self.root) def find(self, k): def _find(k, x): if x == None : return False if x.key == k: return True return _find(k, x.left) or _find(k, x.right) return _find(k, self.root) class Node: def __init__(self, k): self.key = k self.p = None self.left = None self.right = None if __name__=='__main__': m = int(input()) T = BinarySearchTree() for _ in range(m): op = input().split() if op[0] == 'insert': T.insert( Node(int(op[1])) ) elif op[0] == 'find': print("Yes" if T.find(int(op[1])) else "No") else: print("",*T.get_inorder_list()) print("",*T.get_preorder_list())
s938981115
Accepted
8,780
130,768
1,729
class BinarySearchTree: def __init__(self): self.root = None def insert(self, z): p = None x = self.root while x != None: p = x if z.key < x.key : x = x.left else : x = x.right z.p = p if p == None : self.root = z elif z.key < p.key: p.left = z else : p.right = z def get_inorder_list(self): def _get_inorder_list(root): l = root.left r = root.right if l: yield from _get_inorder_list(l) yield root.key if r: yield from _get_inorder_list(r) yield from _get_inorder_list(self.root) def get_preorder_list(self): def _get_preorder_list(root): l = root.left r = root.right yield root.key if l: yield from _get_preorder_list(l) if r: yield from _get_preorder_list(r) yield from _get_preorder_list(self.root) def find(self, k): x = self.root while x: if k == x.key: return True if k < x.key: x = x.left else : x = x.right return False class Node: def __init__(self, k): self.key = k self.p = None self.left = None self.right = None if __name__=='__main__': m = int(input()) T = BinarySearchTree() for _ in range(m): op = input().split() if op[0] == 'insert': T.insert( Node(int(op[1])) ) elif op[0] == 'find': print("yes" if T.find(int(op[1])) else "no") else: print("",*T.get_inorder_list()) print("",*T.get_preorder_list())
s211970337
p02833
u798768533
2,000
1,048,576
Wrong Answer
17
2,940
8
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).
print(0)
s074790374
Accepted
17
2,940
140
N = int(input()) if N % 2 == 1: print(0) exit(0) count = 0 base = 10 while base <= N: count += N // base base *= 5 print(count)
s535119678
p03644
u600215903
2,000
262,144
Wrong Answer
17
3,064
136
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
n = int(input()) result = 1 for i in range(n): if result <= 2: result = result * 2 result = result / 2 print(int(result))
s838071958
Accepted
17
2,940
83
n = int(input()) result = 1 while result <= n: result *= 2 print(result // 2)
s197329945
p02663
u859059120
2,000
1,048,576
Wrong Answer
22
9,156
65
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
h1,m1,h2,m2,k=map(int,input().split()) print(h1*60+m1-k-m2-60*h2)
s047911432
Accepted
24
9,148
66
h1,m1,h2,m2,k=map(int,input().split()) print(h2*60+m2-k-m1-60*h1)
s041494663
p00001
u756242733
1,000
131,072
Wrong Answer
20
5,596
122
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
hills = [input() for _ in range(10)] hills = list(map(int, hills)) hills.sort for i in range(3): print(hills.pop())
s081257433
Accepted
20
5,604
124
hills = [input() for _ in range(10)] hills = list(map(int, hills)) hills.sort() for i in range(3): print(hills.pop())
s835949358
p00045
u964040941
1,000
131,072
Wrong Answer
20
7,608
237
販売単価と販売数量を読み込んで、販売金額の総合計と販売数量の平均を出力するプログラムを作成してください。
A = [] B = [] while True: try: x,y = map(int,input().split(',')) A.append(x) B.append(y) except EOFError: break N = len(A) print(sum(A [i] * B [i] for i in range(N)),sum(B) * 2 // N - sum(B) // N)
s667745305
Accepted
30
7,572
244
A = [] B = [] while True: try: x,y = map(int,input().split(',')) A.append(x) B.append(y) except EOFError: break N = len(A) print(sum(A [i] * B [i] for i in range(N))) print(sum(B) * 2 // N - sum(B) // N)
s418922280
p02401
u884012707
1,000
131,072
Wrong Answer
20
7,616
254
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: a, op, b = input().split() if op=="+": print(int(a) + int(b)) elif op=="-": print(int(a)-int(b)) elif op=="*": print(int(a)*int(b)) elif op=="/": print(int(a)/int(b)) else: break
s938312099
Accepted
30
7,644
255
while True: a, op, b = input().split() if op=="+": print(int(a) + int(b)) elif op=="-": print(int(a)-int(b)) elif op=="*": print(int(a)*int(b)) elif op=="/": print(int(a)//int(b)) else: break
s425864930
p03712
u367393577
2,000
262,144
Wrong Answer
22
3,316
603
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
def twoDimArraywithwall(row,column,n,wallchar): return [[n if j!=0 and j!=(column+1) else wallchar for j in range(column+2)] if i!=0 and i!=(row+1) else [wallchar]*(column+2) for i in range(row+2)] def maketwodimarraywithwall(matrix,wallchar): rownum=len(matrix) colnum=len(matrix[0]) ret=twoDimArraywithwall(rownum,colnum,None,wallchar) for i in range(rownum): for j in range(colnum): ret[i+1][j+1]=matrix[i][j] return ret H, W = map(int, input().split()) table = [] for h in range(H): table.append(list(input())) print(maketwodimarraywithwall(table,"#"))
s692127071
Accepted
21
3,188
640
def twoDimArraywithwall(row,column,n,wallchar): return [[n if j!=0 and j!=(column+1) else wallchar for j in range(column+2)] if i!=0 and i!=(row+1) else [wallchar]*(column+2) for i in range(row+2)] def maketwodimarraywithwall(matrix,wallchar): rownum=len(matrix) colnum=len(matrix[0]) ret=twoDimArraywithwall(rownum,colnum,None,wallchar) for i in range(rownum): for j in range(colnum): ret[i+1][j+1]=matrix[i][j] return ret H, W = map(int, input().split()) table = [] for h in range(H): table.append(list(input())) table=maketwodimarraywithwall(table,"#") for i in table: print("".join(i))
s122488592
p03759
u582084082
2,000
262,144
Wrong Answer
17
2,940
94
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')
s745633569
Accepted
18
2,940
94
a, b, c = map(int, input().split()) if b - a == c - b: print('YES') else: print('NO')
s011494895
p03697
u956547804
2,000
262,144
Wrong Answer
18
2,940
111
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
s=input() result=[] ans='yes' for i in s: if i in result: ans='no' result.append(i) print(ans)
s159868860
Accepted
17
2,940
80
a,b=map(int,input().split()) if a+b>=10: print('error') else: print(a+b)
s342494231
p03997
u904945034
2,000
262,144
Wrong Answer
28
8,976
61
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a,b,h = [int(input()) for _ in range(3)] print(((a + b)*h)/2)
s689523350
Accepted
26
9,028
68
a,b,h = [int(input()) for _ in range(3)] print(round(((a + b)*h)/2))
s947251059
p03624
u170183831
2,000
262,144
Wrong Answer
20
3,188
115
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
diff = set(input()) - set('abcdefghijklmnopqrstuvwxyz') if diff: print(sorted(diff)[0]) else: print('None')
s541191979
Accepted
19
3,188
116
diff = set('abcdefghijklmnopqrstuvwxyz') - set(input()) if diff: print(sorted(diff)[0]) else: print('None')
s701987104
p03575
u316386814
2,000
262,144
Wrong Answer
103
3,436
916
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
from collections import deque n, m = list(map(int, input().split())) li = [] for _ in range(m): li.append(list(map(int, input().split()))) # construct indirectional graphs edges = [[] for _ in range(n)] for i, j in li: i -= 1 j -= 1 edges[i].append(j) edges[j].append(i) import copy edges2 = copy.deepcopy(edges) S = deque() S.append([0]) while len(S) > 0: path = S.pop() # if full path, if len(path) == n: # used path list used = [[] for _ in range(n)] for i, j in zip(path[:-1], path[1:]): used[i].append(j) for i in range(len(edges2)): for j in edges2[i][::-1]: if j not in used[i]: edges2[i].remove(j) continue for v in edges[path[-1]]: if v not in path: S.append(path + [v]) ans = sum(len(e) for e in edges2) print(ans)
s565022261
Accepted
24
3,316
663
from collections import deque n, m = list(map(int, input().split())) li = [] for _ in range(m): li.append(list(map(int, input().split()))) ans = 0 for k in range(len(li)): li0 = li[:k] + li[k + 1:] # construct indirectional graphs edges = [[] for _ in range(n)] for i, j in li0: i -= 1 j -= 1 edges[i].append(j) edges[j].append(i) S = deque() S.append(0) visited = set() while len(S) > 0: u = S.pop() visited.add(u) for v in edges[u]: if v not in visited: S.append(v) if len(visited) < n: ans += 1 print(ans)
s690132614
p03556
u140251125
2,000
262,144
Wrong Answer
28
2,940
77
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
# input N = int(input()) i = 1 while i ** 2 <= N: i += 1 print(i ** 2)
s280822688
Accepted
29
2,940
83
# input N = int(input()) i = 1 while i ** 2 <= N: i += 1 print((i - 1) ** 2)
s864157252
p02842
u805011545
2,000
1,048,576
Wrong Answer
26
9,164
98
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
N = int(input()) X = -(-N//1.08) n = X*108//100 if(int(N)==int(n)): print(X) else: print(':(')
s910036954
Accepted
31
9,144
103
N = int(input()) X = -(-N//1.08) n = X*108//100 if(int(N)==int(n)): print(int(X)) else: print(':(')
s694998735
p03836
u280978334
2,000
262,144
Wrong Answer
19
3,064
408
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
sx,sy,tx,ty = map(int,input().split()) ans = "" X = tx - sx Y = ty - sy for i in range(Y): ans += "U" for i in range(X): ans += "R" for i in range(Y): ans += "D" for i in range(X): ans += "L" ans += "L" for i in range(Y): ans += "U" for i in range(X+1): ans += "R" ans += "D" ans += "R" for i in range(Y+1): ans += "D" for i in range(X+1): ans += "L" ans += "U" print(ans)
s524881029
Accepted
20
3,064
411
sx,sy,tx,ty = map(int,input().split()) ans = "" X = tx - sx Y = ty - sy for i in range(Y): ans += "U" for i in range(X): ans += "R" for i in range(Y): ans += "D" for i in range(X): ans += "L" ans += "L" for i in range(Y+1): ans += "U" for i in range(X+1): ans += "R" ans += "D" ans += "R" for i in range(Y+1): ans += "D" for i in range(X+1): ans += "L" ans += "U" print(ans)
s600395710
p03610
u636822224
2,000
262,144
Wrong Answer
34
3,188
74
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() t=s[0] for i in range(int(len(s)/2)-1): t+=s[2*(i+1)] print(t)
s665834310
Accepted
30
3,188
124
s=input() t=s[0] if len(s)/2==0: n=int(len(s)/2)-1 else: n=int((len(s)-1)/2) for i in range(n): t+=s[2*(i+1)] print(t)
s031041980
p03044
u797016134
2,000
1,048,576
Wrong Answer
378
4,720
179
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
n = int(input()) ans = [0]*n for i in range(n-1): u, v, w = map(int, input().split()) if w % 2 == 0: ans[u-1] = 1 ans[v-1] = 1 for i in ans: print(i)
s661516394
Accepted
702
79,408
500
import sys sys.setrecursionlimit(10**7) n = int(input()) link = [[] for i in range(n)] for i in range(n-1): u, v, w = map(int, input().split()) u -= 1 v -= 1 link[u].append((v,w)) link[v].append((u,w)) ans = [-1]*n def dfs(v, now): ans[v] = now for next_v ,w in link[v]: if ans[next_v] != -1: continue if w % 2: dfs(next_v, 1-now) else: dfs(next_v, now) dfs(0,0) for i in ans: print(i)
s535344378
p03487
u171065106
2,000
262,144
Wrong Answer
163
22,436
241
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
from collections import Counter n = int(input()) a = list(map(int, input().split())) count = 0 for i, j in Counter(a).items(): print(i, j, j-i, j) if j-i < 0: count += j else: count += min(j-i, j) print(count)
s736193821
Accepted
75
22,236
217
from collections import Counter n = int(input()) a = list(map(int, input().split())) count = 0 for i, j in Counter(a).items(): if j-i < 0: count += j else: count += min(j-i, j) print(count)
s636772674
p02412
u535719732
1,000
131,072
Wrong Answer
20
5,592
277
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: num = list(map(int,input().split())) if(num[0] == 0 and num[1] == 0): break c = 0 for i in range(1,num[0] - 2): for j in range(i+1,num[0] - 1): for k in range(j+1,num[0]): if(i+j+k == num[1]): c print(c)
s307325820
Accepted
60
5,596
326
while True: num = list(map(int,input().split())) if(num[0] == 0 and num[1] == 0): break c = 0 for i in range(1,num[0]+1): for j in range(i+1,num[0]+1): if j <= i: continue k = num[1]-(i+j) if k > j and k <= num[0]: c+= 1 print(c)
s896537547
p03696
u698176039
2,000
262,144
Wrong Answer
17
3,064
384
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
N = int(input()) S = list(input()) ans = (S) cnt = 0 idx = 0 for s in S: if s == ')': cnt += 1 if cnt > 0: ans = ans[:idx] + ['('] + ans[idx:] idx += 1 cnt = 0 else : cnt -= 1 idx += 1 if cnt<0: for i in range(-cnt): ans = ans[:idx] + [')'] + ans[idx:] idx += 1 print(''.join(ans))
s415174267
Accepted
17
3,064
302
N = int(input()) S = list(input()) ans = (S) cnt = 0 for i,s in enumerate(S): if cnt < 0: ans = ['('] + ans cnt = 0 if s == '(': cnt += 1 else: cnt -= 1 if cnt> 0: ans = ans + [')'] * cnt elif cnt < 0: ans = ['('] * (-cnt) + ans print(''.join(ans))
s137525658
p03729
u623349537
2,000
262,144
Wrong Answer
18
2,940
100
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
A, B, C = input().split() if A[-1] == B[0] and B[-1] == C[0]: print("Yes") else: print("No")
s987975783
Accepted
17
2,940
100
A, B, C = input().split() if A[-1] == B[0] and B[-1] == C[0]: print("YES") else: print("NO")
s464957382
p03861
u583507988
2,000
262,144
Wrong Answer
2,104
3,060
165
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()) ans = 0 for i in range(b): if i % x == 0: ans += 1 for j in range(a): if j % x == 0: ans -= 1 print(ans)
s824610016
Accepted
31
9,092
91
a, b, x = map(int, input().split()) c=b//x if a%x==0: d=a//x-1 else: d=a//x print(c-d)
s215524212
p03377
u044964932
2,000
262,144
Wrong Answer
17
2,940
235
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 main(): a, b, x = map(int, input().split()) if x < a: ans = "No" else: if (x - a) > b: ans = "No" else: ans = "Yes" print(ans) if __name__ == "__main__": main()
s427371502
Accepted
17
3,064
235
def main(): a, b, x = map(int, input().split()) if x < a: ans = "NO" else: if (x - a) > b: ans = "NO" else: ans = "YES" print(ans) if __name__ == "__main__": main()
s306517685
p03369
u782516204
2,000
262,144
Wrong Answer
17
2,940
73
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.
l = input() ans = 0 for i in l: if i=="o": ans+=1 print(ans)
s179436008
Accepted
17
2,940
85
l = input() ans = 0 for i in l: if i=="o": ans+=1 print(ans * 100 + 700)
s731892519
p03505
u344627992
2,000
262,144
Wrong Answer
18
2,940
172
_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 called _Kaiden_ ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
K, A, B = map(int, input().split()) if A <= B : print ('-1') elif K < B: print ('1') else : delta = A - B ans = (K - A) // delta * 2 + 1 print ('%ld' % ans)
s990639677
Accepted
19
3,060
186
K, A, B = map(int, input().split()) if K <= A : print ('1') elif A <= B : print ('-1') else : delta = A - B ans = (K - A + delta - 1) // delta * 2 + 1 print ('%ld' % ans)
s244864625
p00462
u901080241
1,000
131,072
Wrong Answer
20
7,552
307
JOI ピザでは,市の中心部を通る全長 _d_ メートルの環状線の沿線上でピザの宅配販 売を行っている. JOI ピザは,環状線上に _n_ 個の店舗 _S_ 1, ... , _S n_ を持つ.本店は _S_ 1 である. _S_ 1 から _S i_ まで,時計回りに環状線を移動したときの道のりを _d i_ メートルとおく. _d_ 2, ... , _d n_ は 1 以上 _d_ \- 1 以下の整数である. _d_ 2 , ... , _d n_ は全て異なる. ピザの注文を受けると, ピザが冷めないように, 宅配先までの移動距離がもっとも短い店舗でピザを焼き宅配する. 宅配先の位置は 0 以上 _d_ \- 1 以下の整数 _k_ で表される.これは, 本店 _S_ 1 から宅配先までに時計回りで環状線を移動したときの道のりが _k_ メートルであることを意味する. ピザの宅配は環状線に沿って行われ, それ以外の道を通ることは許されない. ただし, 環状線上は時計回りに移動しても反時計回りに移動してもよい. 例えば,店舗の位置と宅配先の位置が下図のようになっている場合 (この例は「入出力の例」の例 1 と対応している), 宅配先 1 にもっとも近い店舗は _S_ 2 なので, 店舗 _S_ 2 から宅配する.このとき, 店舗からの移動距離は 1 である.また, 宅配先 2 にもっとも近い店舗は _S_ 1 (本店) なので, 店舗 _S_ 1 (本店) から宅配する.このとき,店舗からの移動距離は 2 である. 環状線の全長 _d_ , JOI ピザの店舗の個数 _n_ , 注文の個数 _m_ , 本店以外の位置を表す _n_ \- 1 個の整数 _d_ 2, ... , _d n_ , 宅配先の場所を表す整数 _k_ 1, ... , _k m_ が与えられたとき, 各注文に対する宅配時の移動距離 (すなわち,最寄店舗から宅配先までの道のり) の全注文にわたる総和を求めるプログラムを作成せよ.
import bisect d = int(input()) n = int(input()) m = int(input()) shops = [0]*n for i in range(1,n): shops[i] = int(input()) shops.sort() shops.append(d) d = 0 for i in range(m): cus = int(input()) req = bisect.bisect(shops,cus) d += min(abs(cus-shops[req-1]), abs(cus-shops[req])) print(d)
s004591373
Accepted
390
11,840
394
import bisect while True: d = int(input()) if d==0: break n = int(input()) m = int(input()) shops = [0]*n for i in range(1,n): shops[i] = int(input()) shops.sort() shops.append(d) d = 0 for i in range(m): cus = int(input()) req = bisect.bisect(shops,cus) d += min(abs(cus-shops[req-1]), abs(cus-shops[req])) print(d)
s053286348
p02795
u899782392
2,000
1,048,576
Wrong Answer
17
2,940
132
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.
import sys H = int(sys.stdin.readline()) W = int(sys.stdin.readline()) N = int(sys.stdin.readline()) print((N - 1) / max(H, W) + 1)
s293662347
Accepted
17
2,940
134
import sys H = int(sys.stdin.readline()) W = int(sys.stdin.readline()) N = int(sys.stdin.readline()) print((N - 1) // max(H, W) + 1)
s107888733
p03478
u635391905
2,000
262,144
Wrong Answer
36
3,064
691
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).
# -*- coding: utf-8 -*- import sys from math import * if __name__ =="__main__": str_in = input('input with blocks:') num = [int(n) for n in str_in.split()] N,A,B=num SUM=0 if N<0 or N>(10**4) or A<0 or B<0 or A>36 or B>36 or A>B: print("error input!") else: for i in range(1,(N+1)): #print(i) ii0 = int((i / 1) % 10 ) ii1 = int((i / 10) % 10) ii2 = int((i / 100) % 10) ii3 = int((i / 1000) % 10) ii4 = int((i / 10000) % 10) #print(ii4,ii3,ii2,ii1,ii0) SUMi=ii4+ii3+ii2+ii1+ii0 if(SUMi>=A and SUMi<=B): SUM+=i print(SUM)
s371401615
Accepted
36
3,064
674
#2 # -*- coding: utf-8 -*- import sys from math import * if __name__ =="__main__": str_in = input() num = [int(n) for n in str_in.split()] N,A,B=num SUM=0 if N<0 or N>(10**4) or A<0 or B<0 or A>36 or B>36 or A>B: print("error input!") else: for i in range(1,(N+1)): #print(i) ii0 = int((i / 1) % 10 ) ii1 = int((i / 10) % 10) ii2 = int((i / 100) % 10) ii3 = int((i / 1000) % 10) ii4 = int((i / 10000) % 10) #print(ii4,ii3,ii2,ii1,ii0) SUMi=ii4+ii3+ii2+ii1+ii0 if(SUMi>=A and SUMi<=B): SUM+=i print(SUM)
s086710086
p02742
u619084943
2,000
1,048,576
Wrong Answer
18
2,940
291
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
def main(): h,w = map(int,input().split()) if w==1 or h==1: print(1) return if w%2==0: print(h*w/2) else: if h%2==0: print((w//2+1)*(h/2) + (w//2)*(h/2)) else: print((w//2+1)*(h//2+1) + (w//2)*(h//2)) main()
s637479254
Accepted
17
3,060
306
def main(): h,w = map(int,input().split()) if w==1 or h==1: print(1) return if w%2==0: print(int(h*w/2)) else: if h%2==0: print(int((w//2+1)*(h/2) + (w//2)*(h/2))) else: print(int((w//2+1)*(h//2+1) + (w//2)*(h//2))) main()