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
s918917106
p03555
u189479417
2,000
262,144
Wrong Answer
17
2,940
79
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
A = input() B = input() if A == B[::-1]: print('Yes') else: print('No')
s605811963
Accepted
17
2,940
79
A = input() B = input() if A == B[::-1]: print('YES') else: print('NO')
s605154916
p03494
u439392790
2,000
262,144
Wrong Answer
19
2,940
221
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
n=int(input()) a=list(map(int,input().split())) loop=True cnt=0 while loop: for i in range(n): if a[i]%2==0: a[i]=a[i]/2 else: loop=False break cnt=cnt+1 print(cnt)
s891646272
Accepted
19
2,940
223
n=int(input()) a=list(map(int,input().split())) loop=True cnt=0 while loop: for i in range(n): if a[i]%2==0: a[i]=a[i]/2 else: loop=False break cnt=cnt+1 print(cnt-1)
s021594971
p03448
u267577436
2,000
262,144
Wrong Answer
48
3,060
257
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()) rCnt = 0 ttla = 0 ttlb = 0 for ia in range(a): ttla = 500 * ia for ib in range(b): ttlb = 100 * ib for ic in range(c): if ttla + ttlb + 50 * ic: rCnt = rCnt + 1
s406719977
Accepted
49
3,064
344
a = int(input()) b = int(input()) c = int(input()) x = int(input()) rCnt = 0 ttla = 0 ttlb = 0 ia = 0 while ia <= a: ib = 0 ic = 0 ttla = 500 * ia ia = ia + 1 while ib <= b: ic = 0 ttlb = 100 * ib ib = ib + 1 while ic <= c: if x == ttla + ttlb + 50 * ic: rCnt = rCnt + 1 ic = ic + 1 print(rCnt)
s807332472
p02401
u142359205
1,000
131,072
Wrong Answer
20
5,592
203
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.
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))
s193363035
Accepted
30
5,592
275
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
s725941574
p03494
u695261159
2,000
262,144
Wrong Answer
17
3,064
281
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.
import sys Row=int(input()) List = [int(j) for j in input().split()] for i in range(len(List)): ans = List[i] % 2 if ans == 1: print(0) sys.exit() minVal = min(List) count = 0 while minVal%2 == 0: count = count + 1 minVal = minVal/2 print(count)
s738607031
Accepted
19
3,064
359
import sys Row = input() List = [int(j) for j in input().split()] for i in range(len(List)): ans = List[i] % 2 if ans == 1: print(0) sys.exit() count = 0 flg = 0 while flg == 0: count = count + 1 for j in range(len(List)): List[j] = List[j] / 2 if List[j]%2: flg = 1 break print(count)
s112135728
p03474
u222841610
2,000
262,144
Wrong Answer
19
2,940
208
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
a,b = map(int,input().split()) s = list(input()) ans = True for i in range(a+b+1): if i == a and s[i] != '-': ans = 'No' if s[i] == '-' and i != a: ans ='No' break print (ans)
s290768362
Accepted
17
2,940
301
a,b = map(int,input().split()) s = list(input()) ans = 'Yes' if len(s) != a+b+1: ans = 'No' else: for i in range(a+b+1): if i == a and s[i] != '-': ans = 'No' break if (not s[i].isdigit()) and i != a: ans ='No' break print (ans)
s485446600
p02841
u583276018
2,000
1,048,576
Wrong Answer
17
2,940
105
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
a, b = map(int, input().split()) c, d = map(int, input().split()) if(a != b): print(1) else: print(0)
s137057568
Accepted
17
2,940
106
a, b = map(int, input().split()) c, d = map(int, input().split()) if(a != c): print(1) else: print(0)
s483054246
p03449
u976469393
2,000
262,144
Wrong Answer
358
21,280
350
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
# -*- coding: utf-8 -*- import numpy as np N=int(input()) A=np.zeros((2,N)) X=np.zeros(N) A[0]=list(map(int,input().split())) A[1]=list(map(int,input().split())) print(A) for k in range(N): j=0 drop=0 for i in range(N): drop+=A[j,i] if i==k: j+=1 drop+=A[j,i] X[k]=drop print(max(X))
s480984899
Accepted
300
20,764
346
# -*- coding: utf-8 -*- import numpy as np N=int(input()) A=np.zeros((2,N)) X=np.zeros(N) A[0]=list(map(int,input().split())) A[1]=list(map(int,input().split())) for k in range(N): j=0 drop=0 for i in range(N): drop+=A[j,i] if i==k: j+=1 drop+=A[j,i] X[k]=drop print(int(max(X)))
s913768054
p03815
u166696759
2,000
262,144
Wrong Answer
17
2,940
103
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
n = int(input()) count = 0 count += n // 11 count *= 2 n = n % 11 if n: count += 1 print(count)
s980204794
Accepted
17
2,940
127
n = int(input()) count = 0 count += n // 11 count *= 2 n = n % 11 if n>6: count += 2 elif n: count +=1 print(count)
s143247409
p03399
u925353288
2,000
262,144
Wrong Answer
27
8,932
70
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
A = input() B = input() C = input() D = input() print(min(A,B,C,D))
s001997489
Accepted
26
9,004
98
A = int(input()) B = int(input()) C = int(input()) D = int(input()) print(min(A+C,A+D,B+C,B+D))
s317637801
p03945
u781262926
2,000
262,144
Wrong Answer
205
7,924
73
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
from itertools import groupby for g, n in groupby(input()): print(g, n)
s990553246
Accepted
55
15,860
66
from itertools import groupby print(len(list(groupby(input())))-1)
s506070556
p03487
u188827677
2,000
262,144
Wrong Answer
131
23,072
113
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.
s = "".join(sorted(input())) t = "".join(sorted(input(), reverse=True)) if s < t: print("Yes") else: print("No")
s437831496
Accepted
72
22,304
195
from collections import Counter n = int(input()) a = list(map(int, input().split())) count = Counter(a) ans = 0 for k,v in count.items(): if k < v: ans += v-k elif v < k: ans += v print(ans)
s525179450
p03737
u543954314
2,000
262,144
Wrong Answer
18
2,940
87
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.
s = input().split() ans = "" for i in range(3): ans += s[i][0] ans.upper() print(ans)
s885481149
Accepted
18
2,940
83
s = input().split() ans = "" for i in range(3): ans += s[i][0] print(ans.upper())
s807809097
p03957
u300538442
1,000
262,144
Wrong Answer
24
3,316
109
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
import re S1 = input() p = r'C*F' result = re.match(p, S1) if result: print('yes') else: print('No')
s180616303
Accepted
30
3,316
114
import re S1 = input() p = r'C.+F|CF' result = re.search(p, S1) if result: print('Yes') else: print('No')
s052310994
p00002
u002010345
1,000
131,072
Wrong Answer
20
5,536
170
Write a program which computes the digit number of sum of two integers a and b.
def main(): while True: try: a, b = (int(x) for x in input().split()) print(len(str(a+b))) except EOFError: break
s615163678
Accepted
20
5,600
177
def main(): while True: try: a, b = (int(x) for x in input().split()) print(len(str(a+b))) except EOFError: break main()
s335832244
p03455
u952396514
2,000
262,144
Wrong Answer
18
2,940
128
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
import math num = int(input().replace(" ", "")) squreRoot = math.sqrt(num) print('Yes' if squreRoot == int(squreRoot) else 'No')
s951725124
Accepted
18
2,940
77
a, b = map(int, input().split()) print('Odd' if (a * b) % 2 == 1 else 'Even')
s345879025
p02601
u923662841
2,000
1,048,576
Wrong Answer
30
9,200
379
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
A,B,C = map(int, input().split()) K = int(input()) d = 0 for i in range(K): for j in range(K - i): for k in range(K - i - j+1): a = A*2**i b = B*2**j c = C*2**k print("a:",a, ",b:",b, ",c:",c) if a<b and b<c: d = 1 break if d ==0: print("No")
s168430136
Accepted
28
9,200
452
A,B,C = map(int, input().split()) K = int(input()) def F(d): for i in range(K): for j in range(K - i): for k in range(K - i - j+1): a = A*2**i b = B*2**j c = C*2**k #print("a:",a, ",b:",b, ",c:",c) if a<b and b<c: d = 1 return "Yes" if d ==0: return "No" print(F(0))
s259624726
p04043
u799691369
2,000
262,144
Wrong Answer
16
2,940
228
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
import sys args = sys.argv count_5 = 0 count_7 = 0 for i in args: print(i) if i == '5': count_5+=1 if i == '7': count_7+=1 if count_5 == 2 and count_7 == 1: print('YES') else: print('NO')
s550922753
Accepted
50
3,060
288
A, B, C = map(int, input().split()) l = [5, 5, 7] def main(A=A, B=B, C=C): if A in l: l.remove(A) if B in l: l.remove(B) if C in l: return 'YES' return 'NO' if __name__ == '__main__': result = main() print(result)
s563646702
p02842
u148423304
2,000
1,048,576
Wrong Answer
17
2,940
95
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 = int(n / 1.08) n2 = x * 1.08 if x == n2: print(x) else: print(":(")
s787322566
Accepted
17
3,060
174
n = int(input()) x1 = int(n / 1.08) x2 = int(n / 1.08) + 1 n1 = int(x1 * 1.08) n2 = int(x2 * 1.08) if n == n1: print(x1) elif n == n2: print(x2) else: print(":(")
s028713750
p03455
u311919427
2,000
262,144
Wrong Answer
17
2,940
103
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()) ans = a * b if ans % 2 == 0: print("Odd") else: print("Even")
s811985026
Accepted
18
2,940
103
a, b = map(int, input().split()) ans = a * b if ans % 2 == 0: print("Even") else: print("Odd")
s400529849
p03860
u365254117
2,000
262,144
Wrong Answer
17
2,940
81
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
a, s, c=input().split() s.lower() s[0].upper() print("{} {} {}".format(a, s, c))
s054618873
Accepted
17
2,940
54
a, s, c=input().split() print(a[0]+s[0].upper()+c[0])
s527980604
p02607
u036340997
2,000
1,048,576
Wrong Answer
25
9,120
127
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(0,n,2): if a[i] % 2 == 0: ans += 1 print(ans)
s904551458
Accepted
24
9,096
128
n = int(input()) a = list(map(int, input().split())) ans = 0 for i in range(0,n,2): if a[i] % 2 == 1: ans += 1 print(ans)
s464190058
p03388
u319818856
2,000
262,144
Wrong Answer
19
3,064
1,251
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.
def upper_square(A: int, B: int) -> int: l, r = min(A, B), max(A, B) while r - l > 1: m = (l + r) // 2 if m * m < A * B: l = m else: r = m return l def query(A: int, B: int) -> int: A, B = min(A, B), max(A, B) if A == B: # (1, 2A-1), ..., (A-1, A+1), (A+1, A-1), ..., (2A-1, 1) return 2 * A - 2 if B == A + 1: # (1, 2A), ..., (A-1, A+2), (A+2, A-1), ..., (2A, 1) return 2 * A - 2 # C = A # while (C + 1) ** 2 < A * B: # C += 1 C = upper_square(A, B) if A * B <= C * (C + 1): return 2 * C - 2 return 2*C - 1 def worst_case(Q: int, queries: list) -> list: return [query(A, B) for A, B in queries] if __name__ == "__main__": Q = int(input()) queries = [tuple(map(int, input().split())) for _ in range(Q)] ans = worst_case(Q, queries) print(ans)
s464631561
Accepted
18
3,064
1,271
def upper_square(A: int, B: int) -> int: l, r = min(A, B), max(A, B) while r - l > 1: m = (l + r) // 2 if m * m < A * B: l = m else: r = m return l def query(A: int, B: int) -> int: A, B = min(A, B), max(A, B) if A == B: # (1, 2A-1), ..., (A-1, A+1), (A+1, A-1), ..., (2A-1, 1) return 2 * A - 2 if B == A + 1: # (1, 2A), ..., (A-1, A+2), (A+2, A-1), ..., (2A, 1) return 2 * A - 2 # C = A # while (C + 1) ** 2 < A * B: # C += 1 C = upper_square(A, B) if A * B <= C * (C + 1): return 2 * C - 2 return 2*C - 1 def worst_case(Q: int, queries: list) -> list: return [query(A, B) for A, B in queries] if __name__ == "__main__": Q = int(input()) queries = [tuple(map(int, input().split())) for _ in range(Q)] ans = worst_case(Q, queries) for a in ans: print(a)
s222568233
p03644
u327248573
2,000
262,144
Wrong Answer
17
2,940
89
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()) power = [2,4,8,16,32,64] print(max([i if i <= N else N for i in power]))
s600221674
Accepted
17
3,060
107
N = int(input()) power = [2,4,8,16,32,64] if N < 2: print(N) else: print(max([i for i in power if i <= N]))
s706600116
p03795
u642012866
2,000
262,144
Wrong Answer
26
8,980
39
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
N = int(input()) print(N*800-15//N*400)
s971480112
Accepted
31
9,064
39
N = int(input()) print(N*800-N//15*200)
s543946122
p03478
u505420467
2,000
262,144
Wrong Answer
38
2,940
146
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b=map(int,input().split()) ans=0 for i in range(n): tmp=sum([int(j) for j in list(str(i+1))]) if a<=tmp<=b: ans+=1 print(ans)
s485071691
Accepted
38
2,940
148
n,a,b=map(int,input().split()) ans=0 for i in range(n): tmp=sum([int(j) for j in list(str(i+1))]) if a<=tmp<=b: ans+=i+1 print(ans)
s039650162
p03433
u835353642
2,000
262,144
Wrong Answer
17
2,940
92
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
N = int(input()) A = int(input()) if (N%500) <= A: print ("YES") else: print ("NO")
s556073210
Accepted
17
2,940
92
N = int(input()) A = int(input()) if (N%500) <= A: print ("Yes") else: print ("No")
s080698528
p02399
u566311709
1,000
131,072
Wrong Answer
20
5,596
77
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a, b = map(int, input().split()) print(a // b, a % b, "{:.5}".format(a / b))
s702652533
Accepted
20
5,600
79
a, b = map(int, input().split()) print(a // b, a % b, "{0:.5f}".format(a / b))
s346627555
p03023
u095756391
2,000
1,048,576
Wrong Answer
17
2,940
155
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() win = 0 for i in s: if i == 'o': win += 1 if (15 - len(s)) + win >= 8: print('YES') else: print('NO')
s012967169
Accepted
17
2,940
35
n = int(input()) print(180*(n-2))
s993715459
p02795
u341267151
2,000
1,048,576
Wrong Answer
29
9,204
329
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.
n=int(input()) a=list(map(int,input().split())) t=sum(a) m=10**9 flag=0 for i in range(len(a)-1): t-=2*a[i] if t<=0 : if i==0: print(abs(t)) flag = 1 break else: print(min(abs(t+2*a[i]),abs(t))) flag=1 break if flag==0: print(t)
s312236759
Accepted
27
9,032
87
import math h=int(input()) w=int(input()) n=int(input()) print(math.ceil(n/max(h,w)))
s048459499
p02401
u825994660
1,000
131,072
Wrong Answer
20
7,392
354
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.
import sys while True: x = sys.stdin.readline().strip() if "?" in x: break else: a = list(x.split()) if a[1] == "+": print(a[0] + a[2]) elif a[1] == "-": print(a[0] - a[2]) elif a[1] == "*": print(a[0] * a[2]) elif a[1] == "/": print(a[0] / a[2])
s776942566
Accepted
30
7,768
397
import sys import math while True: x = sys.stdin.readline().strip() a = list(x.split()) if a[1] == "?": break else: x = int(a[0]) y = int(a[2]) if a[1] == "+": print(x + y) elif a[1] == "-": print(x - y) elif a[1] == "*": print(x * y) elif a[1] == "/": print(math.floor(x / y))
s298491484
p03486
u233720439
2,000
262,144
Wrong Answer
18
3,060
156
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
S = str(input()) T = str(input()) sl = [c for c in S] tl = [c for c in T] sl.sort() tl.sort() print("YES" if sl[0] < [c for c in reversed(tl)][0] else "NO")
s550685905
Accepted
17
2,940
84
S = sorted(input()) N = sorted(input()) N.reverse() print("Yes" if S < N else "No")
s908421847
p02259
u918276501
1,000
131,072
Wrong Answer
20
7,640
228
Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 4 of the pseudocode.
cnt = 0 n = int(input()) lst = list(map(int, input().split())) for i in range(n): for j in range(n-1,i,-1): if lst[j] < lst[j-1]: lst[j-1:j+1] = lst[j], lst[j-1] cnt += 1 print(lst) print(cnt)
s238941092
Accepted
30
7,696
229
cnt = 0 n = int(input()) lst = list(map(int, input().split())) for i in range(n): for j in range(n-1,i,-1): if lst[j] < lst[j-1]: lst[j-1:j+1] = lst[j], lst[j-1] cnt += 1 print(*lst) print(cnt)
s131705125
p03731
u906017074
2,000
262,144
Wrong Answer
164
25,200
249
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
n, T = [int(i) for i in input().split()] t = [int(i) for i in input().split()] print(n, T, t) sum = 0 for i in range(1,n): interval = t[i] - t[i-1] if interval < T: sum += interval else: sum += T sum += T print(sum)
s822666149
Accepted
139
25,200
251
n, T = [int(i) for i in input().split()] t = [int(i) for i in input().split()] # print(n, T, t) sum = 0 for i in range(1,n): interval = t[i] - t[i-1] if interval < T: sum += interval else: sum += T sum += T print(sum)
s156963827
p02396
u260980560
1,000
131,072
Wrong Answer
30
6,776
126
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
ans = [] for i, x in enumerate(open(0).readlines()): ans.append("Case %d: %s" % (i, x)) open(1,'w').writelines(ans[:-1])
s439941146
Accepted
30
6,768
128
ans = [] for i, x in enumerate(open(0).readlines()): ans.append("Case %d: %s" % (i+1, x)) open(1,'w').writelines(ans[:-1])
s868194663
p04029
u339503988
2,000
262,144
Wrong Answer
17
2,940
26
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
sum(range(int(input())+1))
s627713823
Accepted
17
2,940
33
print(sum(range(int(input())+1)))
s468196192
p02613
u507456172
2,000
1,048,576
Wrong Answer
146
9,212
337
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()) result=[0,0,0,0] for i in range(N): S=input() if S == "AC": result[0] += 1 elif S == "WA": result[1] += 1 elif S == "TLE": result[2] += 1 else: result[3] += 1 print("AC × " + str(result[0])) print("WA × " + str(result[1])) print("TLE × " + str(result[2])) print("RE × " + str(result[3]))
s270317249
Accepted
149
9,156
333
N = int(input()) result=[0,0,0,0] for i in range(N): S=input() if S == "AC": result[0] += 1 elif S == "WA": result[1] += 1 elif S == "TLE": result[2] += 1 else: result[3] += 1 print("AC x " + str(result[0])) print("WA x " + str(result[1])) print("TLE x " + str(result[2])) print("RE x " + str(result[3]))
s335534277
p02646
u485172913
2,000
1,048,576
Wrong Answer
22
9,108
132
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a,v=map(int,input().split()) b,w=map(int,input().split()) s=int(input()) if(((b*w)-(a*v))>(a*v)): print("Yes") else: print("No")
s554082070
Accepted
21
9,108
129
a,v=map(int,input().split()) b,w=map(int,input().split()) s=int(input()) if(abs(a-b)>(v-w)*s): print("NO") else: print("YES")
s637809448
p02972
u747602774
2,000
1,048,576
Wrong Answer
296
8,784
269
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
N = int(input()) a = list(map(int,input().split())) b = [0 for i in range(N//2)]+a[N//2:] for i in range(N//2-1,-1,-1): if sum(b[i::i+1])%2 == 0: b[i] = a[i] else: b[i] = 1-a[i] for i in range(N): if b[i] == 1: print(i+1,end=' ')
s461821223
Accepted
189
20,276
322
N = int(input()) a = list(map(int,input().split())) b = [0 for i in range(N//2)]+a[N//2:] for i in range(N//2-1,-1,-1): if sum(b[i::i+1])%2 == 0: b[i] = a[i] else: b[i] = 1-a[i] ans = [] for i in range(N): if b[i] == 1: ans.append(i+1) print(len(ans)) print(' '.join(map(str,ans)))
s735439401
p03943
u218984487
2,000
262,144
Wrong Answer
17
2,940
118
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
a, b, c = map(int, input().split()) if a + b == c or a == c + b or b == a + c: print("YES") else: print("NO")
s613480505
Accepted
18
2,940
118
a, b, c = map(int, input().split()) if a + b == c or a == c + b or b == a + c: print("Yes") else: print("No")
s610605224
p00008
u362104929
1,000
131,072
Wrong Answer
190
7,644
569
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
for _ in range(50): try: n = int(input()) # 1 <= n <= 50 ans =set() for a in range(10): if (n - a) >= 1: for b in range(10): if(n - a -b) >= 1: for c in range(10): if(n - a - b - c) >= 1: for d in range(10): if(n - a - b - c - d) == 0: ans.add("{},{},{},{}".format(a,b,c,d)) print(len(ans)) except EOFError: break
s768894653
Accepted
220
7,656
806
for _ in range(50): try: n = int(input()) # 1 <= n <= 50 ans =set() for a in range(10): if (n - a) >= 1: for b in range(10): if(n - a -b) >= 1: for c in range(10): if(n - a - b - c) >= 1: for d in range(10): if(n - a - b - c - d) == 0: ans.add("{},{},{},{}".format(a,b,c,d)) ans.add("{},{},{},{}".format(b,c,d,a)) ans.add("{},{},{},{}".format(c,d,a,b)) ans.add("{},{},{},{}".format(d,a,b,c)) print(len(ans)) except EOFError: break
s496215524
p03543
u484856305
2,000
262,144
Wrong Answer
18
2,940
111
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
a=input() if a[0]==a[1]==a[3] or a[1]==a[2]==a[3] or a[0]==a[1]==a[2]==a[3]: print("Yes") else: print("No")
s694013485
Accepted
17
2,940
73
a,b,c,d=input() if a==b==c or b==c==d: print("Yes") else: print("No")
s310119032
p03992
u751047721
2,000
262,144
Wrong Answer
22
3,068
11
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
print("No")
s601001725
Accepted
22
3,192
32
i=input() print(i[:4]+" "+i[4:])
s191856725
p02402
u767850279
1,000
131,072
Wrong Answer
20
7,620
160
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
# coding : utf-8 a = int(input()) n1 = input().split() n1 = [float(i) for i in n1] print(min(n1), max(n1), sum(n1))
s467819058
Accepted
20
8,600
158
# coding : utf-8 a = int(input()) n1 = input().split() n1 = [int(i) for i in n1] print(min(n1), max(n1), sum(n1))
s141949647
p02261
u301461168
1,000
131,072
Wrong Answer
30
7,800
1,358
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
def is_stable(output_str, same_num_str): if len(same_num_str)>0: for i in range(len(same_num_str)): if output_str.find(same_num_str[i]) == -1: return "Not Stable" return "Stable" data_num = int(input()) cards = input().split(" ") cards2 = cards[:] cnt = 0 num_1 = 0 num_2 = 0 same_num_str = [] output_str = "" judge_stbl = "" for i in range(data_num): for j in range(data_num-1, i,-1): if int(cards[j][1:]) < int(cards[j-1][1:]): cards[j], cards[j-1] = cards[j-1], cards[j] elif int(cards[j][1:]) == int(cards[j-1][1:]): same_num_str.append(cards[j-1]+" "+cards[j]) output_str = " ".join(cards) judge_stbl = is_stable(output_str, same_num_str) print(output_str + "\n" + judge_stbl) same_num_str = [] output_str = "" judge_stbl = "" for i in range(data_num): min_idx = i for j in range(i, data_num): if int(cards2[j][1:]) < int(cards2[min_idx][1:]): min_idx = j elif int(cards2[j][1:]) == int(cards2[min_idx][1:]) and j != min_idx: same_num_str.append(cards2[min_idx]+" "+cards2[j]) if i != min_idx: cards2[i], cards2[min_idx] = cards2[min_idx], cards2[i] output_str = " ".join(cards2) judge_stbl = is_stable(output_str, same_num_str) print(output_str + "\n" + judge_stbl)
s440762062
Accepted
20
7,764
1,358
def is_stable(output_str, same_num_str): if len(same_num_str)>0: for i in range(len(same_num_str)): if output_str.find(same_num_str[i]) == -1: return "Not stable" return "Stable" data_num = int(input()) cards = input().split(" ") cards2 = cards[:] cnt = 0 num_1 = 0 num_2 = 0 same_num_str = [] output_str = "" judge_stbl = "" for i in range(data_num): for j in range(data_num-1, i,-1): if int(cards[j][1:]) < int(cards[j-1][1:]): cards[j], cards[j-1] = cards[j-1], cards[j] elif int(cards[j][1:]) == int(cards[j-1][1:]): same_num_str.append(cards[j-1]+" "+cards[j]) output_str = " ".join(cards) judge_stbl = is_stable(output_str, same_num_str) print(output_str + "\n" + judge_stbl) same_num_str = [] output_str = "" judge_stbl = "" for i in range(data_num): min_idx = i for j in range(i, data_num): if int(cards2[j][1:]) < int(cards2[min_idx][1:]): min_idx = j elif int(cards2[j][1:]) == int(cards2[min_idx][1:]) and j != min_idx: same_num_str.append(cards2[min_idx]+" "+cards2[j]) if i != min_idx: cards2[i], cards2[min_idx] = cards2[min_idx], cards2[i] output_str = " ".join(cards2) judge_stbl = is_stable(output_str, same_num_str) print(output_str + "\n" + judge_stbl)
s733795553
p03645
u970267139
2,000
262,144
Wrong Answer
575
67,668
629
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
from collections import deque n, m = map(int, input().split()) p = [tuple(map(int, input().split())) for _ in range(m)] d = dict() for a, b in p: if a not in d.keys(): d[a] = [b] else: d[a].append(b) if b not in d.keys(): d[b] = [] node = deque() node.append((1, 0)) visit = set() while node: (s, count) = node.popleft() if s in visit: continue if s == n: print(count) if count == 2: print('POSSIBLE') exit() else: break for i in d[s]: node.append((i, count+1)) visit.add(s) print('IMPOSSIBLE')
s880523670
Accepted
607
67,784
608
from collections import deque n, m = map(int, input().split()) p = [tuple(map(int, input().split())) for _ in range(m)] d = dict() for a, b in p: if a not in d.keys(): d[a] = [b] else: d[a].append(b) if b not in d.keys(): d[b] = [] node = deque() node.append((1, 0)) visit = set() while node: (s, count) = node.popleft() if s in visit: continue if s == n: if count == 2: print('POSSIBLE') exit() else: break for i in d[s]: node.append((i, count+1)) visit.add(s) print('IMPOSSIBLE')
s562678585
p03044
u711539583
2,000
1,048,576
Wrong Answer
768
42,668
456
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()) d = {} for i in range(n - 1): u, v, w = map(int, input().split()) if u in d: d[u].append([v, w]) else: d[u] = [[v, w]] if v in d: d[v] = [[u, w]] else: d[v] = [[u, w]] start = list(d.keys())[0] ans = [0 for _ in range(n)] def walk(poj): ans[poj - 1] = 1 for i, way in enumerate(d[poj]): if way[1] % 2 == 0: d[poj][i][1] = 1 walk(way[0]) walk(start) for res in ans: print(res)
s372592465
Accepted
915
99,740
562
import sys sys.setrecursionlimit(10**9) input = sys.stdin.readline n = int(input()) d = {} for i in range(n - 1): u, v, w = map(int, input().split()) u -= 1 v -= 1 if u in d: d[u].append([v, w]) else: d[u] = [[v, w]] if v in d: d[v].append([u, w]) else: d[v] = [[u, w]] rem = {} for i in range(n): rem[i] = 1 ans = [0 for _ in range(n)] def check(p, tmp): rem.pop(p) for n, w in d[p]: if n in rem: ntmp = (tmp + w) % 2 ans[n] = ntmp check(n, ntmp) check(0, 0) for res in ans: print(res)
s538297769
p03229
u607865971
2,000
1,048,576
Wrong Answer
517
9,492
589
You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like.
import collections N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) A = sorted(A) if N % 2 == 1: d1 = A[0:N // 2 + 1] u1 = A[N // 2 + 1:N + 1] else: d1 = A[0:N // 2] u1 = A[N // 2:N + 1] d1 = collections.deque(d1) u1 = collections.deque(u1) d1.rotate(1) u1.rotate(1) sum1 = 0 i = 0 while (True): print("{},{},{}".format(i, len(d1), len(u1))) if i >= len(d1) or i >= len(u1): break sum1 += abs(u1[i] - d1[i]) if i+1 >= len(d1) or i >= len(u1): break sum1 += abs(u1[i] - d1[i + 1]) i += 1 print(sum1)
s767441878
Accepted
1,056
10,516
1,575
import collections N = int(input()) A = [0] * N for i in range(N): A[i] = int(input()) A = sorted(A) if N % 2 == 1: d1 = A[0:N // 2 + 1] u1 = A[N // 2 + 1:N + 1] else: d1 = A[0:N // 2] u1 = A[N // 2:N + 1] d1 = collections.deque(d1) u1 = collections.deque(u1) d1.rotate(1) u1.rotate(-1) sum1 = 0 i = 0 while (True): if i >= len(d1) or i >= len(u1): break sum1 += abs(u1[i] - d1[i]) if i+1 >= len(d1) or i >= len(u1): break sum1 += abs(u1[i] - d1[i + 1]) i += 1 sum2 = 0 i = 0 while (True): if i >= len(d1) or i >= len(u1): break sum2 += abs(u1[i] - d1[i]) if i >= len(d1) or i+1 >= len(u1): break sum2 += abs(u1[i+1] - d1[i]) i += 1 ########################### if N % 2 == 1: d1 = A[0:N // 2] u1 = A[N // 2:N + 1] d1 = collections.deque(d1) u1 = collections.deque(u1) d1.rotate(1) u1.rotate(-1) sum3 = 0 i = 0 while (True): if i >= len(d1) or i >= len(u1): break sum3 += abs(u1[i] - d1[i]) if i+1 >= len(d1) or i >= len(u1): break sum3 += abs(u1[i] - d1[i + 1]) i += 1 sum4 = 0 i = 0 while (True): if i >= len(d1) or i >= len(u1): break sum4 += abs(u1[i] - d1[i]) if i >= len(d1) or i+1 >= len(u1): break sum4 += abs(u1[i+1] - d1[i]) i += 1 print(max(sum1, sum2, sum3, sum4))
s739635435
p02388
u885889402
1,000
131,072
Wrong Answer
30
7,340
28
Write a program which calculates the cube of a given integer x.
s=input() print(float(s)**3)
s946007192
Accepted
20
7,684
26
s=input() print(int(s)**3)
s257680098
p03711
u472721500
2,000
262,144
Wrong Answer
17
3,060
190
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
a, b = map(int, input().split()) group1 = [1,3,5,7,8,10,12] group2 = [4,6,9,11] if a in group1 and b in group1: print("YES") elif a in group2 and b in group2: print("YES") else: print("NO")
s497283900
Accepted
18
3,060
172
a, b = map(int, input().split()) x = [1,3,5,7,8,10,12] y = [4,6,9,11] if a in x and b in x: print("Yes") elif a in y and b in y: print("Yes") else: print("No")
s837544131
p03150
u328131364
2,000
1,048,576
Wrong Answer
98
3,700
347
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
import copy S = input() ja = 0 sremove = "" S_tmp = "" for i in range(len(S)): for j in range(len(S)- i): S_tmp = S sremove = S_tmp[i:] sremove = sremove[j:] S_tmp.replace(sremove, "") if S_tmp == "keyence": ja = 1 break if ja == 0: print("NO") else: print("YES")
s580905779
Accepted
319
3,444
307
import copy S = list(input()) ja = 0 sremove = "" S_tmp = [] for i in range(len(S)): for j in range(i,len(S)+1): S_tmp = copy.deepcopy(S) del S_tmp[i:j] if "".join(S_tmp) == "keyence": ja = 1 break if ja == 1: print("YES") else: print("NO")
s000732947
p03693
u379424722
2,000
262,144
Wrong Answer
17
2,940
115
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
n = input().split(" ") n = int(n[0] + n[1] + n[2]) print(n) if n % 4 == 0: print("YES") else: print("NO")
s042497699
Accepted
17
3,064
106
n = input().split(" ") n = int(n[0] + n[1] + n[2]) if n % 4 == 0: print("YES") else: print("NO")
s428298580
p03658
u740284863
2,000
262,144
Wrong Answer
17
2,940
92
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
n,k = map(int,input().split()) x = sorted(list(map(int,input().split()))) print(sum(x[k:]))
s763298246
Accepted
18
2,940
106
n,k = map(int,input().split()) x = sorted(list(map(int,input().split())),reverse=True) print(sum(x[:k]))
s707991421
p02406
u316584871
1,000
131,072
Wrong Answer
20
5,588
142
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; }
i = int(input()) for n in range(1,i+1): if (n%3==0): print(' {}'.format(n)) elif(n%10 == 3): print(' {}'.format(n))
s344236924
Accepted
20
5,876
319
i = int(input()) for n in range(1,i+1): if (n%3==0): print(' {}'.format(n),end="") else: x = n while(x>0): if (x%10 == 3): print(' {}'.format(n),end="") break else: x = x//10 print()
s603253166
p02612
u275242455
2,000
1,048,576
Wrong Answer
32
9,140
43
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()) ans = N % 1000 print(ans)
s485474301
Accepted
32
9,184
76
N = int(input()) ans = N % 1000 if ans != 0: ans = 1000 - ans print(ans)
s571534474
p03720
u445380615
2,000
262,144
Wrong Answer
20
2,940
259
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
wlist = [] city, road = map(int, input().split()) for i in range(road): wlist.append(input()) dst = [] for i in range(city): count = 0 for k in wlist: if str(i) in k: count += 1 dst.append(count) for d in dst: print(d)
s991629809
Accepted
18
2,940
280
wlist = [] city, road = map(int, input().split()) for i in range(road): wlist.append(list(map(int, input().split()))) dst = [] for i in range(city): count = 0 for k in wlist: if i+1 in k: count += 1 dst.append(count) for d in dst: print(d)
s447955831
p03494
u925836726
2,000
262,144
Time Limit Exceeded
2,104
3,064
385
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.
def main(): n = int(input()) a = list(map(int, input().split())) flag = True count = 0 for i in a: if(i%2 == 1): flag = False while flag == True: count += 1 a = list(map( lambda x: int(x/2), a)) for i in a: if(i%2 != 0): False print(count) if __name__ == '__main__': main()
s871645077
Accepted
19
3,064
392
def main(): n = int(input()) a = list(map(int, input().split())) flag = True count = 0 for i in a: if(i%2 == 1): flag = False while flag == True: count += 1 a = list(map( lambda x: int(x/2), a)) for i in a: if(i%2 != 0): flag = False print(count) if __name__ == '__main__': main()
s950891436
p02389
u721446434
1,000
131,072
Wrong Answer
30
7,608
63
Write a program which calculates the area and perimeter of a given rectangle.
nums = list(map(int, input().split())) print(nums[0] * nums[1])
s603613641
Accepted
20
7,572
88
nums = list(map(int, input().split())) print(nums[0] * nums[1], (nums[0] + nums[1]) * 2)
s732001192
p03673
u811528179
2,000
262,144
Wrong Answer
2,104
26,176
125
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n=int(input()) a=list(map(int,input().split())) ans=[] for i in range(1,n+1): ans.append(i) ans=ans[::-1] print(ans)
s349152621
Accepted
181
29,252
232
from collections import deque n=int(input()) a=list(map(int,input().split())) ans=deque([a[0]]) for i in range(1,n): if (n-1)%2==i%2: ans.appendleft(a[i]) else: ans.append(a[i]) print(" ".join(map(str,ans)))
s333700754
p02927
u167908302
2,000
1,048,576
Wrong Answer
17
2,940
181
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?
#coding:utf-8 m, d = map(int, input().split()) ans = 0 for i in range(10, d+1): d1 = d % 10 d10 = d // 10 if d1 >= 2 and d10 >= 2 and d1*d10 == m: ans += 1 print(ans)
s812112819
Accepted
17
2,940
180
#coding:utf-8 m, d = map(int, input().split()) ans = 0 for i in range(10, d+1): i1 = i % 10 i10 = i // 10 if i1 >= 2 and i10 >= 2 and i1*i10 <= m: ans += 1 print(ans)
s451770194
p03024
u026788530
2,000
1,048,576
Wrong Answer
17
2,940
78
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
s=[x for x in input()] if(s.count('x')>7): print("No") else: print("Yes")
s287674206
Accepted
17
2,940
78
s=[x for x in input()] if(s.count('x')>7): print("NO") else: print("YES")
s135335613
p02833
u871841829
2,000
1,048,576
Wrong Answer
18
3,060
137
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
N = int(input()) import sys if N & 1: print(0) sys.exit() ans = 0 N /= 2 while N != 0: ans += N // 5 N /= 5 print(ans)
s010572982
Accepted
17
2,940
139
N = int(input()) import sys if N & 1: print(0) sys.exit() ans = 0 N //= 2 while N != 0: ans += N // 5 N //= 5 print(ans)
s142453794
p03624
u789290859
2,000
262,144
Wrong Answer
51
9,760
313
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.
str1 = input() li = list(str1) anli = [] for i in range(26): anli.append(0) for i in range(len(li)): anli[ord(li[i]) - 97] += 1 flag = True mi = 27 print(anli) for i in range(len(anli)): if anli[i] == 0: flag = False mi = min(i,mi) if flag: print('None') else: print(chr(mi+97))
s810018667
Accepted
50
9,700
301
str1 = input() li = list(str1) anli = [] for i in range(26): anli.append(0) for i in range(len(li)): anli[ord(li[i]) - 97] += 1 flag = True mi = 27 for i in range(len(anli)): if anli[i] == 0: flag = False mi = min(i,mi) if flag: print('None') else: print(chr(mi+97))
s332652602
p02393
u548155360
1,000
131,072
Wrong Answer
20
7,528
255
Write a program which reads three integers, and prints them in ascending order.
nums=list(map(int,input().split())) if nums[2] >= nums[1]: a=nums[1] b=nums[2] else: b=nums[1] a=nums[2] if nums[0] <= a: min=nums[0] mid=a max=b elif nums[0] < b: min=a mid=nums[0] max=b else: min=a mid=b max=nums[0] print("min,mid,max")
s569806674
Accepted
20
7,624
254
nums=list(map(int,input().split())) if nums[2] >= nums[1]: a=nums[1] b=nums[2] else: b=nums[1] a=nums[2] if nums[0] <= a: min=nums[0] mid=a max=b elif nums[0] <= b: min=a mid=nums[0] max=b else: min=a mid=b max=nums[0] print(min,mid,max)
s977039250
p03377
u914797917
2,000
262,144
Wrong Answer
17
2,940
89
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
A,B,X = map(int,input().split()) if X>A+B or A>X: print('No') else: print('Yes')
s006046528
Accepted
17
2,940
89
A,B,X = map(int,input().split()) if X>A+B or A>X: print('NO') else: print('YES')
s286820692
p03097
u675317308
2,000
1,048,576
Wrong Answer
1,094
22,836
865
You are given integers N,\ A and B. Determine if there exists a permutation (P_0,\ P_1,\ ...\ P_{2^N-1}) of (0,\ 1,\ ...\ 2^N-1) that satisfies all of the following conditions, and create one such permutation if it exists. * P_0=A * P_{2^N-1}=B * For all 0 \leq i < 2^N-1, the binary representations of P_i and P_{i+1} differ by exactly one bit.
def Double(vec): m=len(vec) res=[] for i in range(0,m,2): res.extend([vec[i],vec[i]^m,vec[i+1]^m,vec[i+1]]) return res def Greedy(n): m=1<<n res=[0]*m vis=[False]*m vis[0]=True for i in range(1,m): x=res[i-1] for j in range(n): if not vis[x^(1<<j)]: x^=1<<j break vis[x]=True res[i]=x return res def Perfect(n): if n==1: return [0,1] m=1<<n A=Greedy(n-1) B=Double(Perfect(n-2)) B.reverse() for i in range(m>>1): B[i]^=m-1 A.extend(B) return A n,a,b=map(int,input().split()) m=1<<n c=bin(a^b).count('1') if not c&1: print('NO') exit() tmp=Perfect(c) for i in range(c,n): tmp=Double(tmp) p=0 q=c ans=[0]*m for i in range(n): if (a^b)>>i&1: for j in range(m): ans[j]^=(((tmp[j]>>p)^(a>>i))&1)<<i p+=1 else: for j in range(m): ans[j]^=(((tmp[j]>>q)^(a>>i))&1)<<i q+=1 print(' '.join(str(i) for i in ans))
s431711792
Accepted
1,146
22,840
880
def Double(vec): m=len(vec) res=[] for i in range(0,m,2): res.extend([vec[i],vec[i]^m,vec[i+1]^m,vec[i+1]]) return res def Greedy(n): m=1<<n res=[0]*m vis=[False]*m vis[0]=True for i in range(1,m): x=res[i-1] for j in range(n): if not vis[x^(1<<j)]: x^=1<<j break vis[x]=True res[i]=x return res def Perfect(n): if n==1: return [0,1] m=1<<n A=Greedy(n-1) B=Double(Perfect(n-2)) B.reverse() for i in range(m>>1): B[i]^=m-1 A.extend(B) return A n,a,b=map(int,input().split()) m=1<<n c=bin(a^b).count('1') if not c&1: print('NO') exit() tmp=Perfect(c) for i in range(c,n): tmp=Double(tmp) p=0 q=c ans=[0]*m for i in range(n): if (a^b)>>i&1: for j in range(m): ans[j]^=(((tmp[j]>>p)^(a>>i))&1)<<i p+=1 else: for j in range(m): ans[j]^=(((tmp[j]>>q)^(a>>i))&1)<<i q+=1 print('YES\n',' '.join(str(i) for i in ans),sep='')
s600017869
p03693
u736479342
2,000
262,144
Wrong Answer
24
9,092
99
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r, g, b = map(int, input().split()) if (100*r + 10*b + b)%4==0: print('YES') else: print('NO')
s237994542
Accepted
30
9,040
99
r, g, b = map(int, input().split()) if (100*r + 10*g + b)%4==0: print('YES') else: print('NO')
s441908199
p02843
u580049189
2,000
1,048,576
Wrong Answer
17
2,940
7
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
input()
s940028604
Accepted
18
2,940
146
def solve(target): n = int(target / 100) if n * 100 <= target <= n * 105: print(1) else: print(0) solve(int(input()))
s202502377
p04044
u628018347
2,000
262,144
Wrong Answer
37
3,060
492
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
num_list = list(map(int, input().split())) N = num_list[0] L = num_list[1] S = [input(i) for i in range(N)] for i in range(N): for j in range(N): if i < j: for k in range(L): if S[i][k] > S[j][k]: S[i], S[j] = S[j], S[i] break else: continue print(''.join(S))
s853887270
Accepted
17
3,060
118
num_list = list(map(int, input().split())) S = [input() for i in range(num_list[0])] S2 = sorted(S) print(*S2, sep='')
s859561541
p03474
u667949809
2,000
262,144
Wrong Answer
19
3,060
126
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
A, B = map(int,input().split()) S = list(input()) if S.count("-") == 1 and S[A] == "-": print("yes") else: print("No")
s800272568
Accepted
18
3,064
113
a,b = map(int,input().split()) s=input() if s[a]=="-" and s.count("-")==1: print("Yes") else: print("No")
s698509731
p03024
u657208344
2,000
1,048,576
Wrong Answer
32
9,024
68
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.
n = input() if n.count('o') >= 8: print("YES") else: print("NO")
s142410121
Accepted
26
9,064
81
n = input() if 15-len(n) + n.count('o') >= 8: print("YES") else: print("NO")
s732697821
p02401
u391228754
1,000
131,072
Wrong Answer
20
7,624
263
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, b, c = input().split() a = int(a) c = int(c) if b == "?": break elif b == "-": d = a - c elif b == "+": d = a + c elif b == "*": d = a * c elif b == "/": d = a / c print(d)
s912753781
Accepted
30
7,656
264
while True: a, b, c = input().split() a = int(a) c = int(c) if b == "?": break elif b == "-": d = a - c elif b == "+": d = a + c elif b == "*": d = a * c elif b == "/": d = a // c print(d)
s484251380
p03578
u075304271
2,000
262,144
Wrong Answer
2,207
45,216
385
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
import math import collections import fractions import itertools def solve(): n = int(input()) d = list(map(int, input().split())) m = int(input()) t = list(map(int, input().split())) t = collections.Counter(t) for i in t: if t[i] > d.count(i): print("YES") else: print("NO") return 0 if __name__ == "__main__": solve()
s166405264
Accepted
250
56,608
428
import math import collections import fractions import itertools def solve(): n = int(input()) d = list(map(int, input().split())) m = int(input()) t = list(map(int, input().split())) t = collections.Counter(t) d = collections.Counter(d) for i in t: if t[i] > d[i]: print("NO") break else: print("YES") return 0 if __name__ == "__main__": solve()
s786690014
p02865
u967789504
2,000
1,048,576
Wrong Answer
20
2,940
70
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n % 2: print(n // 2) else: print((n / 2) - 1)
s623989345
Accepted
17
3,064
30
n=int(input()) print((n-1)//2)
s845737433
p03719
u765590009
2,000
262,144
Wrong Answer
17
2,940
180
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
a, b, c = map(int, input().split()) if (c >= a) and (c <= b) : print("YES") else : print("NO")
s506191230
Accepted
17
2,940
180
a, b, c = map(int, input().split()) if (c >= a) and (c <= b) : print("Yes") else : print("No")
s376499357
p03729
u785205215
2,000
262,144
Wrong Answer
18
3,064
165
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`.
def read_str_list(): return list(str(_) for _ in input().split()) a,b,c = read_str_list() if a[-1]==b[0] and b[-1]==c[0]: print("Yes") else: print("No")
s666598442
Accepted
17
2,940
165
def read_str_list(): return list(str(s) for s in input().split()) a,b,c = read_str_list() if a[-1]==b[0] and b[-1]==c[0]: print("YES") else: print("NO")
s443906523
p03845
u084320347
2,000
262,144
Wrong Answer
32
3,572
217
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
import copy n = int(input()) t = list(map(int,input().split())) m = int(input()) for i in range(m): c_t = copy.deepcopy(t) p,x = list(map(int,input().split())) c_t[p-1]=x print(c_t) print(sum(c_t))
s953165616
Accepted
31
3,444
202
import copy n = int(input()) t = list(map(int,input().split())) m = int(input()) for i in range(m): c_t = copy.deepcopy(t) p,x = list(map(int,input().split())) c_t[p-1]=x print(sum(c_t))
s155999915
p02263
u650790815
1,000
131,072
Wrong Answer
20
7,620
239
An expression is given in a line. Two consequtive symbols (operand or operator) are separated by a space character. You can assume that +, - and * are given as the operator and an operand is a positive integer less than 106
q = [] for e in input().strip().split(): if e == '+': q.append(q.pop() + q.pop()) elif e == '-': q.append(-q.pop() + q.pop()) elif e == '*': q.append(q.pop() * q.pop()) else: q.append(int(e))
s239903523
Accepted
20
7,636
258
f = input().strip().split() q = [] for e in f: if e == '+': q.append(q.pop() + q.pop()) elif e == '-': q.append(-q.pop() + q.pop()) elif e == '*': q.append(q.pop() * q.pop()) else: q.append(int(e)) print(q[0])
s066884029
p02274
u918276501
1,000
131,072
Wrong Answer
20
7,704
684
For a given sequence $A = \\{a_0, a_1, ... a_{n-1}\\}$, the number of pairs $(i, j)$ where $a_i > a_j$ and $i < j$, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program: bubbleSort(A) cnt = 0 // the number of inversions for i = 0 to A.length-1 for j = A.length-1 downto i+1 if A[j] < A[j-1] swap(A[j], A[j-1]) cnt++ return cnt For the given sequence $A$, print the number of inversions of $A$. Note that you should not use the above program, which brings Time Limit Exceeded.
def merge(A, left, mid, right): global count # count += (right - left) L = A[left:mid] + [int(1e9)] R = A[mid:right] + [int(1e9)] i,j = 0,0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 count += 1 def merge_sort(A, left, right): if left+1 < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid, right) merge(A, left, mid, right) if __name__ == "__main__": n = int(input()) A = list(map(int, input().strip().split())) count = 0 merge_sort(A, 0, n) print(count)
s403222715
Accepted
1,600
30,444
695
def merge(A, left, mid, right): global count # count += (right - left) L = A[left:mid] + [int(1e9)] R = A[mid:right] + [int(1e9)] i = j = 0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 count += (mid-left-i) def merge_sort(A, left, right): if left+1 < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid, right) merge(A, left, mid, right) if __name__ == "__main__": n = int(input()) A = list(map(int, input().strip().split())) count = 0 merge_sort(A, 0, n) print(count)
s548856929
p03555
u021548497
2,000
262,144
Wrong Answer
17
2,940
109
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
s = input() t = input() if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]: print("Yes") else: print("No")
s619521226
Accepted
17
2,940
109
s = input() t = input() if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]: print("YES") else: print("NO")
s405715401
p03486
u392361133
2,000
262,144
Wrong Answer
17
2,940
72
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s = sorted(input()) t = sorted(input()) print("Yes" if s < t else "No")
s712584688
Accepted
17
2,940
78
s = sorted(input()) t = sorted(input())[::-1] print("Yes" if s < t else "No")
s503589893
p02422
u613534067
1,000
131,072
Wrong Answer
20
5,596
396
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
t = input() for i in range(int(input())): cmd = list(input().split()) cmd[1] = int(cmd[1]) cmd[2] = int(cmd[2]) if cmd[0] == "print": print(t[cmd[1]-1 : cmd[2]]) elif cmd[0] == "reverse": tmp = t[cmd[1]-1 : cmd[2]] tmp = tmp[::-1] t = t[:cmd[1]-1] + tmp + t[cmd[2]:] elif cmd[0] == "replace": t = t[:cmd[1]-1] + cmd[3] + t[cmd[2]:]
s285011673
Accepted
20
5,620
482
t = input() for i in range(int(input())): cmd = list(input().split()) cmd[1] = int(cmd[1]) cmd[2] = int(cmd[2]) if cmd[0] == "print": print(t[cmd[1] : cmd[2]] + t[cmd[2]]) elif cmd[0] == "reverse": tmp = t[cmd[1] : cmd[2]] + t[cmd[2]] tmp = tmp[::-1] t = t[:cmd[1]] + tmp + t[cmd[2]+1:] elif cmd[0] == "replace": t = t[:cmd[1]] + cmd[3] + t[cmd[2]+1:]
s764087811
p03555
u346474533
2,000
262,144
Wrong Answer
17
2,940
96
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a = input() b = input() if a == b[::-1] and b == a[::-1]: print('Yes') else: print('No')
s338664623
Accepted
17
2,940
79
a = input() b = input() if a == b[::-1]: print('YES') else: print('NO')
s092726660
p03610
u197300260
2,000
262,144
Wrong Answer
18
3,188
543
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.
# Python 2nd Try class Problem: def __init__(self, problemstring): self.problemstring = problemstring self.length = len(self.problemstring) def solve(self): result = '' resultlist = [] for j in range(0, self.length): if j % 2 == 0: resultlist.append(self.problemstring[j]) result = ''.join(resultlist) return result if __name__ == "__main__": S = input() print(Problem(S).solve)
s416647096
Accepted
22
3,700
475
# Python 3rd Try import copy class Problem: def __init__(self, inputstring): self.inputstring = inputstring def __str__(self): return self.inputstring def solver(self): result = '' string = copy.copy(self.inputstring) result = string[0:len(string):2] return result if __name__ == "__main__": s = input() x = Problem(s) print(x.solver())
s720256613
p04043
u919978322
2,000
262,144
Wrong Answer
17
2,940
201
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
ip = input().split() A = int(ip[0]) B = int(ip[1]) C = int(ip[2]) boolean = False if A+B+C==19: if A==5 or B==5 or C==5: boolean = True if boolean: print("YES") else: print("NO")
s302140215
Accepted
17
2,940
201
ip = input().split() A = int(ip[0]) B = int(ip[1]) C = int(ip[2]) boolean = False if A+B+C==17: if A==5 or B==5 or C==5: boolean = True if boolean: print("YES") else: print("NO")
s441871880
p02694
u242580186
2,000
1,048,576
Wrong Answer
31
9,200
472
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
import sys read = sys.stdin.readline import time import math import itertools as it def inp(): return int(input()) def inpl(): return list(map(int, input().split())) start_time = time.perf_counter() # ------------------------------ X = inp() yen = 100 for i in range(10**4): yen += (yen // 100) if yen >= X: print(i) break # ----------------------------- end_time = time.perf_counter() print('time:', end_time-start_time, file=sys.stderr)
s029894427
Accepted
30
9,188
474
import sys read = sys.stdin.readline import time import math import itertools as it def inp(): return int(input()) def inpl(): return list(map(int, input().split())) start_time = time.perf_counter() # ------------------------------ X = inp() yen = 100 for i in range(10**4): yen += (yen // 100) if yen >= X: print(i+1) break # ----------------------------- end_time = time.perf_counter() print('time:', end_time-start_time, file=sys.stderr)
s946080084
p03635
u001495709
2,000
262,144
Wrong Answer
18
2,940
52
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
n, m = map(int, input().split()) print = (n-1)*(m-1)
s584504113
Accepted
18
2,940
52
n, m = map(int, input().split()) print((n-1)*(m-1))
s244543428
p03457
u316603606
2,000
262,144
Wrong Answer
261
9,156
384
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
N = int (input ()) t2 = 0 x2 = 0 y2 = 0 for i in range (N): t,x,y = map(int, input().split()) if abs (t-t2) >= abs ((x-x2)+(y-y2)): if (round (((t-t2)-((x-x2)+(y-y2)))/2))*2 ==((t-t2)-((x-x2)+(y-y2))): ans = 'YES' else: ans = 'NO' break else: ans = 'NO' break t2 = t x2 = x y2 = y print (ans)
s164804494
Accepted
240
9,160
316
N = int (input ()) t2 = 0 x2 = 0 y2 = 0 ans = 'Yes' for i in range (N): t,x,y = map(int, input().split()) if abs(x+y-x2-y2) <= t-t2: if ((abs(x2+y2-x-y))-(t-t2)) % 2 == 1: ans = 'No' break else: ans = 'No' break t2 = t x2 = x y2 = y print (ans)
s839915871
p03351
u869728296
2,000
1,048,576
Wrong Answer
18
2,940
171
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=input().strip().split(" ") b=[int(i) for i in a] if(((abs(b[0]-b[1])<b[3]) and (abs(b[2]-b[1])<b[3])) or abs(b[0]-b[2])<b[3] ): print("Yes") else: print("No")
s327271501
Accepted
18
2,940
174
a=input().strip().split(" ") b=[int(i) for i in a] if(((abs(b[0]-b[1])<=b[3]) and (abs(b[2]-b[1])<=b[3])) or abs(b[0]-b[2])<=b[3] ): print("Yes") else: print("No")
s990377150
p02255
u342125850
1,000
131,072
Wrong Answer
20
5,596
271
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.
num = int(input()) cards = [int(i) for i in input().split()] def insertion_sort(num, cards): for i in range(num): v = cards[i] j = i - 1 while j >= 0 and cards[j] > v: cards[j+1] = cards[j] j -= 1 cards[j+1] = v print(cards) insertion_sort(num, cards)
s733344277
Accepted
20
5,608
353
num = int(input()) cards = [int(i) for i in input().split()] def insertion_sort(num, cards): for i in range(num): v = cards[i] j = i - 1 while j >= 0 and cards[j] > v: cards[j+1] = cards[j] j -= 1 cards[j+1] = v output(cards) def output(cards): sorting = [str(i) for i in cards] print(" ".join(sorting)) insertion_sort(num, cards)
s193644064
p02578
u198065632
2,000
1,048,576
Wrong Answer
123
32,264
170
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
n = int(input()) a = list(map(int, input().split())) s = 0 for i in range(0, n - 1): h = a[i] - a[i+1] if h > 0: s += h a[i] += h print(str(s))
s105169478
Accepted
141
32,172
196
n = int(input()) a = list(map(int, input().split())) s = 0 for i in range(0, n - 1): h = a[i] - a[i+1] if h > 0: s += h a[i+1] += h # a[i+1] = a[i] print(str(s))
s958597704
p02612
u729805651
2,000
1,048,576
Wrong Answer
25
8,948
32
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()) a=N%1000 print(a)
s562442416
Accepted
27
9,108
69
N=int(input()) a=N%1000 if a==0: print(a) else: print(1000-a)
s503430462
p03609
u965436898
2,000
262,144
Wrong Answer
17
2,940
65
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
n = list(input()) if "9" in n: print("Yes") else: print("No")
s045039962
Accepted
17
2,940
77
x,t = map(int,input().split()) if x - t >= 0: print(x - t) else: print(0)
s266233559
p02771
u528594564
2,000
1,048,576
Wrong Answer
17
2,940
205
A triple of numbers is said to be _poor_ when two of those numbers are equal but the other number is different from those two numbers. You will be given three integers A, B, and C. If this triple is poor, print `Yes`; otherwise, print `No`.
from sys import stdin,stdout def main(): for x in stdin: A = list(map(int,x.split())) A.sort() if A[0]==A[1] and A[1]!=A[2]:print('Yes') else:print('No') if __name__ == "__main__": main()
s814908133
Accepted
17
3,064
328
from sys import stdin,stdout def f(i,j,n,mat): ans = -1 for k in range(n): ans += mat[i][k]+mat[k][j] return ans def main(): for x in stdin: A = list(map(int,x.split())) A.sort() if (A[0]==A[1] and A[1]!=A[2]) or (A[0]!=A[1] and A[1]==A[2]):print('Yes') else:print('No') if __name__ == "__main__": main()
s012017733
p03487
u875291233
2,000
262,144
Time Limit Exceeded
2,132
532,388
335
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.
N=int(input()) a=[int(i) for i in input().split()] #print(a) counter = [0 for i in range(10**9+3)] #print(counter[a[N-1]]) #print(counter[6]) for i in range(N): counter[a[i]] += 1 ans = 0 for i in range(N): if counter[i] < i: ans += counter[i] else: ans += counter[i] - i print(ans)
s853671785
Accepted
90
14,024
470
N=int(input()) a=[int(i) for i in input().split()] counter = [0]*(10**5+10) ans = 0 for i in range(N): # print('a[i]=') # print(a[i]) if a[i] < 10**5 + 3: counter[a[i]] += 1 # print('hoge') else: ans += 1 # print(ans) for i in range(10**5+3): if counter[i] < i: ans += counter[i] # print(counter[i]) else: ans += counter[i] - i # print(counter[i]-i) # print(ans) print(ans)
s914720847
p03555
u197300773
2,000
262,144
Wrong Answer
17
2,940
49
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
print("Yes" if input()==input()[::-1] else "No" )
s438739998
Accepted
17
2,940
49
print("YES" if input()==input()[::-1] else "NO" )
s086993124
p03658
u729133443
2,000
262,144
Wrong Answer
17
2,940
58
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
t,l=open(0);print(sorted(map(int,l.split()))[-int(t[2:])])
s543193519
Accepted
17
2,940
64
t,l=open(0);print(sum(sorted(map(int,l.split()))[-int(t[2:]):]))
s223886275
p03694
u735008991
2,000
262,144
Wrong Answer
17
2,940
80
It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
N = input() A = sorted(list(map(int, input().split()))) print(A[-1] - A[0] + 1)
s108299202
Accepted
17
2,940
76
N = input() A = sorted(list(map(int, input().split()))) print(A[-1] - A[0])
s925685968
p03545
u094778153
2,000
262,144
Wrong Answer
17
3,064
599
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
if __name__ == '__main__': num = input() num_list = [int(i) for i in str(num)] A = num_list[0] B = num_list[1] C = num_list[2] D = num_list[3] if A + B + C + D == 7: print("A+B+C+D") elif A + B + C - D == 7: print("A+B+C-D") elif A + B - C + D == 7: print("A+B-C+D") elif A + B - C - D == 7: print("A+B-C-D") elif A - B + C + D == 7: print("A-B+C+D") elif A - B + C - D == 7: print("A-B+C-D") elif A - B - C + D == 7: print("A-B-C+D") elif A - B - C - D == 7: print("A-B-C-D")
s047900819
Accepted
17
3,064
831
if __name__ == '__main__': num = input() num_list = [int(i) for i in str(num)] A = num_list[0] B = num_list[1] C = num_list[2] D = num_list[3] if A + B + C + D == 7: print("{0}+{1}+{2}+{3}=7".format(A, B, C, D)) elif A + B + C - D == 7: print("{0}+{1}+{2}-{3}=7".format(A, B, C, D)) elif A + B - C + D == 7: print("{0}+{1}-{2}+{3}=7".format(A, B, C, D)) elif A + B - C - D == 7: print("{0}+{1}-{2}-{3}=7".format(A, B, C, D)) elif A - B + C + D == 7: print("{0}-{1}+{2}+{3}=7".format(A, B, C, D)) elif A - B + C - D == 7: print("{0}-{1}+{2}-{3}=7".format(A, B, C, D)) elif A - B - C + D == 7: print("{0}-{1}-{2}+{3}=7".format(A, B, C, D)) elif A - B - C - D == 7: print("{0}-{1}-{2}-{3}=7".format(A, B, C, D))
s735525818
p03963
u816631826
2,000
262,144
Wrong Answer
17
2,940
99
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.
a=list(map(int,input().split())) if a[0]==1: print(a[1]) exit(0) print(a[1]*(a[1]**(a[0]-1)))
s993391819
Accepted
17
2,940
72
# your code goes here n,k=map(int,input().split()) print(k*pow(k-1,n-1))