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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s692689161
|
p03385
|
u219369949
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
s = input()
set1 = set(s)
print(set1)
if set1 == {'c', 'b', 'a'}:
print("Yes")
else:
print("No")
|
s331820715
|
Accepted
| 17 | 2,940 | 93 |
s = input()
set1 = set(s)
if set1 == {'c', 'b', 'a'}:
print("Yes")
else:
print("No")
|
s162239178
|
p03494
|
u278670845
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,104 | 2,940 | 178 |
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
n = int(input())
a = list(map(int, input().split()))
i = 0
while(True):
for x in a:
if x%2!=0:
print(i)
sys.exit()
else:
x = x//2
i += 1
|
s155023203
|
Accepted
| 18 | 3,060 | 288 |
import sys
def main():
n = int(input())
a = list(map(int, input().split()))
i = 0
while(True):
for x in a:
if x%2!=0:
print(i)
sys.exit()
a = [x//2 for x in a]
i += 1
if __name__=="__main__":
main()
|
s839016226
|
p03610
|
u773686010
| 2,000 | 262,144 |
Wrong Answer
| 28 | 8,980 | 25 |
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.
|
print(str(input())[1::2])
|
s839059163
|
Accepted
| 23 | 9,056 | 24 |
print(str(input())[::2])
|
s746775019
|
p03545
|
u917558625
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,116 | 282 |
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.
|
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
c=''
c+=A[0]
bns=int(A[0])
for j in range(3):
if i[j]==0:
bns+=int(A[j+1])
c+='+'+A[j+1]
else:
bns-=int(A[j+1])
c+='-'+A[j+1]
if bns==7:
print(c)
exit()
|
s483975321
|
Accepted
| 29 | 9,084 | 287 |
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
c=''
c+=A[0]
bns=int(A[0])
for j in range(3):
if i[j]==0:
bns+=int(A[j+1])
c+='+'+A[j+1]
else:
bns-=int(A[j+1])
c+='-'+A[j+1]
if bns==7:
print(c+'=7')
exit()
|
s888305182
|
p03360
|
u202826462
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 155 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
a, b, c = map(int, input().split())
k = int(input())
ans = 0
sub = a + b + c
ans = max(a * (2 * k) + sub, b * (2 * k) + sub, c * (2 * k) + sub)
print(ans)
|
s768269780
|
Accepted
| 17 | 2,940 | 100 |
a, b, c = map(int, input().split())
k = int(input())
print(a + b + c + max(a, b, c) * (2 ** k - 1))
|
s105247685
|
p03729
|
u854627522
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 121 |
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`.
|
nums = input().split()
if nums[0][-1] == nums[1][0] and nums[1][-1] == nums[2][0]:
print('Yes')
else:
print('No')
|
s365440272
|
Accepted
| 18 | 2,940 | 121 |
nums = input().split()
if nums[0][-1] == nums[1][0] and nums[1][-1] == nums[2][0]:
print('YES')
else:
print('NO')
|
s655762256
|
p03644
|
u419963262
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,132 | 170 |
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())
ANS = 0
for i in range(1,n+1):
check = i
ans = 0
while check % 2 == 0:
check = check // 2
ans += 1
if ANS < ans:
ANS = ans
print(ANS)
|
s275045039
|
Accepted
| 26 | 9,140 | 194 |
n = int(input())
ANS = 1
keep = 0
for i in range(1,n+1):
check = i
ans = 0
while check % 2 == 0:
check = check // 2
ans += 1
if keep < ans:
keep = ans
ANS = i
print(ANS)
|
s421599625
|
p03796
|
u858670323
| 2,000 | 262,144 |
Wrong Answer
| 51 | 2,940 | 76 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
N=int(input())
a=1
mod=1e9+7
for i in range(1,N+1):
a*=i
a%=mod
print(a)
|
s622081570
|
Accepted
| 56 | 2,940 | 91 |
N=int(input().rstrip())
a=1
mod=1e9+7
for i in range(1,N+1):
a*=i
a%=mod
print(int(a))
|
s635893573
|
p03359
|
u129978636
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 144 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a, b = map( int, input().split())
count = 0
for i in range(1, a + 1):
if( i < b):
count += 1
else:
continue
print(count)
|
s209349238
|
Accepted
| 17 | 2,940 | 104 |
a, b = map( int, input().split())
if( b < a):
count = a - 1
else:
count = a
print(count)
|
s827556022
|
p03836
|
u667472448
| 2,000 | 262,144 |
Wrong Answer
| 33 | 4,468 | 606 |
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())
distance_x, distance_y = tx-sx, ty-sy
x_now, y_now = sx, sy
#path1
for i in range(distance_y):
print("U",end="")
for i in range(distance_x):
print("R",end="")
#path2
for i in range(distance_y):
print("D",end="")
for i in range(distance_x):
print("L",end="")
#path3
print("L",end="")
for i in range(distance_y+1):
print("U",end="")
for i in range(distance_x+1):
print("R",end="")
print("D",end="")
#path4
print("R",end="")
for i in range(distance_y+1):
print("D",end="")
for i in range(distance_x):
print("L",end="")
print("U")
|
s047670893
|
Accepted
| 17 | 3,064 | 405 |
sx, sy, tx, ty = map(int, input().split())
distance_x, distance_y = tx-sx, ty-sy
x_now, y_now = sx, sy
up, down, right, left = 'U', 'D', 'R', 'L'
#path1
print(up*distance_y+""+right*distance_x,end="")
#path2
print(down*distance_y+""+left*distance_x,end="")
#path3
print("L"+""+up*(distance_y+1)+""+right*(distance_x+1)+""+"D",end="")
#path4
print("R"+""+down*(distance_y+1)+""+left*(distance_x+1)+""+"U")
|
s754021977
|
p02975
|
u754022296
| 2,000 | 1,048,576 |
Wrong Answer
| 56 | 14,708 | 237 |
Snuke has N hats. The i-th hat has an integer a_i written on it. There are N camels standing in a circle. Snuke will put one of his hats on each of these camels. If there exists a way to distribute the hats to the camels such that the following condition is satisfied for every camel, print `Yes`; otherwise, print `No`. * The bitwise XOR of the numbers written on the hats on both adjacent camels is equal to the number on the hat on itself. What is XOR? The bitwise XOR x_1 \oplus x_2 \oplus \ldots \oplus x_n of n non- negative integers x_1, x_2, \ldots, x_n is defined as follows: - When x_1 \oplus x_2 \oplus \ldots \oplus x_n is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 \oplus 5 = 6.
|
from functools import reduce
n = int(input())
l = list(map(int, input().split()))
if n%3:
if max(l) == 0:
print("YES")
else:
print("NO")
else:
if reduce((lambda x, y:x ^ y), l) == 0:
print("YES")
else:
print("NO")
|
s721916317
|
Accepted
| 55 | 11,508 | 105 |
from functools import reduce as f;input();print("YNeos"[f(lambda x,y:x^y,map(int,input().split()))>0::2])
|
s356812139
|
p03485
|
u623687794
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 46 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
print((a+b)//2+1)
|
s190652104
|
Accepted
| 17 | 2,940 | 90 |
a,b=map(int,input().split())
if (a+b) % 2==1:
print((a+b+1)//2)
else:
print((a+b)//2)
|
s272939477
|
p03672
|
u445511055
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 291 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
# -*- coding: utf-8 -*-
def main():
"""Function."""
s = str(input())
max_len = 0
for i in range((len(s)-1)//2):
if s[:i+1] * 2 == s[:(i+1)*2]:
print(s[:i+1])
max_len = (i + 1) * 2
print(max_len)
if __name__ == "__main__":
main()
|
s849266252
|
Accepted
| 18 | 2,940 | 264 |
# -*- coding: utf-8 -*-
def main():
"""Function."""
s = str(input())
max_len = 0
for i in range((len(s)-1)//2):
if s[:i+1] * 2 == s[:(i+1)*2]:
max_len = (i + 1) * 2
print(max_len)
if __name__ == "__main__":
main()
|
s625283958
|
p02747
|
u821237744
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 244 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
S = list(input())
flug = True
for i in range(0,len(S),2):
if i+1 < len(S):
st = S[i] + S[i + 1]
if st != "hi":
flug = False
else:
flug = False
if flug == True:
print("YES")
else:
print("NO")
|
s562702939
|
Accepted
| 17 | 3,060 | 244 |
S = list(input())
flug = True
for i in range(0,len(S),2):
if i+1 < len(S):
st = S[i] + S[i + 1]
if st != "hi":
flug = False
else:
flug = False
if flug == True:
print("Yes")
else:
print("No")
|
s979926608
|
p03636
|
u305732215
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 57 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
aida = str(len(s))
print(s[0] + aida + s[-1])
|
s779714879
|
Accepted
| 17 | 2,940 | 60 |
s = input()
aida = str(len(s)-2)
print(s[0] + aida + s[-1])
|
s583202266
|
p03007
|
u162612857
| 2,000 | 1,048,576 |
Wrong Answer
| 232 | 14,260 | 950 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
n = int(input())
nums = list(map(int, input().split() ))
nums.sort()
print(nums)
if nums[0] >= 0:
print(sum(list(map(abs, nums))) - 2 * nums[0])
hikareru = nums[0]
for idx in range(2,n):
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
print("{} {}".format(nums[1], hikareru) )
elif nums[-1] <= 0:
print(sum(list(map(abs, nums))) - 2 * (-1)*nums[-1] )
hikareru = nums[-1]
for idx in range(n-1):
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
else:
print(sum(list(map(abs, nums))) )
hikareru = nums[0]
idx = n-2
while True:
if nums[idx] < 0:
break
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
idx -= 1
hiku = hikareru
print("{} {}".format(nums[n-1], hiku) )
hikareru = nums[n-1] - hiku
idx = 1
while True:
if nums[idx] >= 0:
break
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
idx += 1
|
s051288345
|
Accepted
| 230 | 14,088 | 936 |
n = int(input())
nums = list(map(int, input().split() ))
nums.sort()
if nums[0] >= 0:
print(sum(list(map(abs, nums))) - 2 * nums[0])
hikareru = nums[0]
for idx in range(2,n):
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
print("{} {}".format(nums[1], hikareru) )
elif nums[-1] <= 0:
print(sum(list(map(abs, nums))) - 2 * (-1)*nums[-1] )
hikareru = nums[-1]
for idx in range(n-1):
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
else:
print(sum(list(map(abs, nums))) )
hikareru = nums[0]
idx = n-2
while True:
if nums[idx] < 0:
break
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
idx -= 1
hiku = hikareru
print("{} {}".format(nums[n-1], hiku) )
hikareru = nums[n-1] - hiku
idx = 1
while True:
if nums[idx] >= 0:
break
print("{} {}".format(hikareru, nums[idx]) )
hikareru -= nums[idx]
idx += 1
|
s233290249
|
p02612
|
u284679563
| 2,000 | 1,048,576 |
Wrong Answer
| 35 | 9,132 | 151 |
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.
|
import sys
#DEBUG = True
DEBUG = False
if DEBUG:
f=open("202007_1st/A_input.txt")
else:
f=sys.stdin
N=int(f.readline())
print(N%1000)
f.close()
|
s672723920
|
Accepted
| 33 | 9,172 | 207 |
import sys
#DEBUG = True
DEBUG = False
if DEBUG:
f=open("202007_1st/A_input.txt")
else:
f=sys.stdin
N=int(f.readline().strip())
R=N%1000
if R==0:
print(R)
else:
print(1000-(N%1000))
f.close()
|
s292072645
|
p00001
|
u247705495
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 143 |
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.
|
mountains = []
for i in range(10):
m = int(input())
mountains.append(m)
mountains.sort()
for i in range(3):
print(mountains[i])
|
s091036030
|
Accepted
| 20 | 5,596 | 155 |
mountains = []
for i in range(10):
m = int(input())
mountains.append(m)
mountains.sort(reverse=True)
for i in range(3):
print(mountains[i])
|
s167034018
|
p03779
|
u280552586
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 85 |
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.
|
x = int(input())
cnt = 0
i = 1
while cnt >= x:
cnt += i
i += 1
print(i-1)
|
s540031649
|
Accepted
| 26 | 2,940 | 84 |
x = int(input())
cnt = 0
i = 1
while cnt < x:
cnt += i
i += 1
print(i-1)
|
s420007768
|
p03693
|
u056599756
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 137 |
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())
n=r*100000000+r*10000000+r*1000000+g*100000+g*10000+g*1000+b*100+b*10+b
print("Yes" if n%4==0 else "No")
|
s429341611
|
Accepted
| 17 | 2,940 | 80 |
r,g,b=map(int,input().split())
n=r*100+g*10+b
print("YES" if n%4==0 else "NO")
|
s030943225
|
p02842
|
u755545520
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 107 |
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())
for i in range(50000):
if int(i*1.08)== n:
print(i)
break
else:
print(':(')
break
|
s070754615
|
Accepted
| 31 | 2,940 | 94 |
n=int(input())
for i in range(50000):
if int(i*1.08)== n:
print(i)
exit()
print(':(')
|
s802685499
|
p03853
|
u167681750
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 92 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h, w = map(int, input().split())
c = [input() for i in range(h)]
for i in c*2:
print(i)
|
s822888614
|
Accepted
| 18 | 3,060 | 92 |
h, w = map(int, input().split())
for i in range(h):
c = input()
print(c + "\n" + c)
|
s938159702
|
p03547
|
u620945921
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 49 |
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
x,y=input().split()
print('>' if x < y else '=')
|
s006421064
|
Accepted
| 17 | 2,940 | 87 |
x,y=input().split()
if x < y:
print('<')
elif x > y:
print('>')
else:
print('=')
|
s750997352
|
p03643
|
u104888971
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 27 |
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
N = input()
print('ABC',N)
|
s057229579
|
Accepted
| 17 | 2,940 | 27 |
N = input()
print("ABC"+N)
|
s438504928
|
p04046
|
u474423089
| 2,000 | 262,144 |
Wrong Answer
| 138 | 14,836 | 499 |
We have a large square grid with H rows and W columns. Iroha is now standing in the top-left cell. She will repeat going right or down to the adjacent cell, until she reaches the bottom-right cell. However, she cannot enter the cells in the intersection of the bottom A rows and the leftmost B columns. (That is, there are A×B forbidden cells.) There is no restriction on entering the other cells. Find the number of ways she can travel to the bottom-right cell. Since this number can be extremely large, print the number modulo 10^9+7.
|
def main():
h,w,a,b=map(int,input().split(' '))
mod = 10**9+7
mx=max(h,w)
fac=[1]*(h+w+1)
for i in range(1,h+w+1):
fac[i]=fac[i-1]*i%mod
rev=[1]*(mx+1)
rev[-1]=pow(fac[mx],mod-2,mod)
for i in range(mx-1,-1,-1):
rev[i+1]=rev[i+1]*(i+1)%mod
const=rev[h-a-1]*rev[a-1]%mod
ans = sum(fac[h - a + i - 1] * rev[i] * fac[a + w - 2 - i] * rev[w - i - 1] % mod for i in range(b, w))
print(ans * const % mod)
if __name__ == '__main__':
main()
|
s646453543
|
Accepted
| 138 | 14,836 | 497 |
def main():
h,w,a,b=map(int,input().split(' '))
mod = 10**9+7
mx=max(h,w)
fac=[1]*(h+w+1)
for i in range(1,h+w+1):
fac[i]=fac[i-1]*i%mod
rev=[1]*(mx+1)
rev[-1]=pow(fac[mx],mod-2,mod)
for i in range(mx-1,-1,-1):
rev[i]=rev[i+1]*(i+1)%mod
const=rev[h-a-1]*rev[a-1]%mod
ans = sum(fac[h - a + i - 1] * rev[i] * fac[a + w - 2 - i] * rev[w - i - 1] % mod for i in range(b, w))
print(ans * const % mod)
if __name__ == '__main__':
main()
|
s312784576
|
p02255
|
u972731768
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 355 |
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 insertionSort(A,N):
for i in range(1,len(A)):
v = A[i]
j=i-1
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j-=1
A[j+1]=v
print(*A)
def main():
print("??°????????\???")
A = list(map(int,input().split()))
N = len(A)
insertionSort(A,N)
if __name__ == '__main__':
main()
|
s502708898
|
Accepted
| 20 | 5,976 | 216 |
N = int(input())
A = list(map(int,input().split()))
print( *A )
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A [j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print( *A )
|
s690734465
|
p02833
|
u620464724
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 203 |
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
n=int(input())
ans=0
if n % 2==1:
for i in range(1,19):
waru = 2*5**i
if n < waru:
break
else:
tmp = n/waru
ans += int(tmp)
print(str(ans))
|
s640641741
|
Accepted
| 17 | 2,940 | 202 |
n=int(input())
ans=0
if n % 2==0:
for i in range(1,10000):
waru = 2*5**i
if n < waru:
break
else:
tmp = n//waru
ans += tmp
print(str(ans))
|
s048539591
|
p03795
|
u706414019
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,148 | 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-200*N//15)
|
s863599048
|
Accepted
| 23 | 9,116 | 42 |
N = int(input())
print(N*800-200*(N//15))
|
s824968641
|
p03759
|
u912862653
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 88 |
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 = list(map(int, input().split()))
if a-b==c-b:
print('YES')
else:
print('NO')
|
s994993029
|
Accepted
| 18 | 2,940 | 88 |
a, b, c = list(map(int, input().split()))
if b-a==c-b:
print('YES')
else:
print('NO')
|
s895009774
|
p03048
|
u463655976
| 2,000 | 1,048,576 |
Wrong Answer
| 1,006 | 2,940 | 178 |
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
R, G, B, N = map(int, input().split())
ans = 0
for i in range(R):
cntR = N - i
for j in range(min(cntR, G)):
cntG = cntR - j
if cntG <= B:
ans += 1
print(ans)
|
s828024798
|
Accepted
| 1,353 | 2,940 | 192 |
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
cntR = N - i * R
for j in range(cntR//G+1):
cntG = cntR - j * G
if cntG % B == 0:
ans += 1
print(ans)
|
s897210552
|
p02418
|
u742505495
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,540 | 102 |
Write a program which finds a pattern $p$ in a ring shaped text $s$.
|
s = str(input())
p = str(input())
case = s + s
if p in case == True:
print('yes')
else:
print('no')
|
s183465759
|
Accepted
| 20 | 5,552 | 94 |
s = str(input())
p = str(input())
case = s + s
if p in case:
print('Yes')
else:
print('No')
|
s157853127
|
p03853
|
u045953894
| 2,000 | 262,144 |
Wrong Answer
| 33 | 9,108 | 138 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h,w = map(int,input().split())
c = []
for _ in range(h):
c.append(list(input()))
for i in range(h):
print(*c[i])
print(*c[i])
|
s671222391
|
Accepted
| 38 | 9,112 | 154 |
h,w = map(int,input().split())
c = []
for _ in range(h):
c.append(list(input()))
for i in range(h):
print("".join(c[i]))
print("".join(c[i]))
|
s691088876
|
p03495
|
u559367141
| 2,000 | 262,144 |
Wrong Answer
| 2,206 | 32,208 | 296 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
counter_list = []
for i in range(N):
if a_list.count(i) > 0:
counter_list.append(a_list.count(i))
counter_list.sort()
count = 0
for i in range(len(counter_list) - K):
count += i
print(count)
|
s056749895
|
Accepted
| 99 | 32,320 | 219 |
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = [0]*N
for i in a_list:
counter_list[i-1] += 1
counter_list.sort(reverse=True)
ans = N - sum(counter_list[:K])
print(ans)
|
s392621044
|
p02612
|
u696684809
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,092 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s473936198
|
Accepted
| 30 | 9,156 | 70 |
N = int(input())
a = N%1000
if(a==0):
print(a)
else:
print(1000-a)
|
s391590161
|
p03494
|
u309120194
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,248 | 226 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = False
while True:
for n in range(N):
if A[n] % 2 == 0:
A[n] = A[n] / 2
else:
flag = True
break
count += 1
if flag: break
|
s989626766
|
Accepted
| 25 | 9,176 | 245 |
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = False
while True:
for n in range(N):
if A[n] % 2 != 0:
flag = True
break
if flag: break
for n in range(N):
A[n] //= 2
count += 1
print(count)
|
s435029038
|
p03637
|
u075303794
| 2,000 | 262,144 |
Wrong Answer
| 143 | 38,160 | 323 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
odd=np.count_nonzero(A%2!=0)
four=np.count_nonzero(A%4==0)
if odd+four==N:
if odd-1<=four:
print('Yes')
else:
print('No')
else:
if odd==2 and four==2:
print('Yes')
elif odd+1<=four:
print('Yes')
else:
print('No')
|
s329984182
|
Accepted
| 140 | 38,044 | 318 |
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
odd=np.count_nonzero(A%2!=0)
four=np.count_nonzero(A%4==0)
ans='No'
if odd==1 and four>=1:
ans='Yes'
elif odd==2 and four>=2:
ans='Yes'
else:
if odd+four==N and odd-1<=four:
ans='Yes'
elif odd<=four:
ans='Yes'
print(ans)
|
s817453832
|
p03779
|
u547167033
| 2,000 | 262,144 |
Wrong Answer
| 27 | 2,940 | 86 |
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.
|
x=int(input())
for t in range(1,10**5+1):
if t*(t-1)//2>x:
print(t-1)
exit()
|
s100250690
|
Accepted
| 26 | 2,940 | 88 |
x=int(input())
for t in range(1,10**5+1):
if t*(t-1)//2>=x:
print(t-1)
exit()
|
s114350233
|
p03543
|
u626468554
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 351 |
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 = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
a = list(input())
print(a)
if a[0] == a[1] and a[1] == a[2]:
print("Yes")
elif a[0] == a[1] and a[1] == a[3]:
print("Yes")
elif a[0] == a[2] and a[2] == a[3]:
print("Yes")
elif a[2] == a[1] and a[1] == a[3]:
print("Yes")
else:
print("No")
|
s466765118
|
Accepted
| 17 | 3,060 | 243 |
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
a = list(input())
if (a[0] == a[1]) and (a[1] == a[2]):
print("Yes")
elif (a[2] == a[1]) and (a[1] == a[3]):
print("Yes")
else:
print("No")
|
s764885863
|
p02409
|
u498462680
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,640 | 1,057 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())
#building = [[0]*sharpNum] * height
building = [[0] * sharpNum for i in range(height)]
actRoom = 0
for data in range(dataNum):
b,f,r,v = map(int, input().split())
for floor in range(height):
if floor%4 == 3:
for room in range(sharpNum):
#print("#floor: %d" %floor)
#print("#room: %d" %room)
building[floor][room] = "#"
#print("buiding: &s" %building[floor][room])
else:
for room in range(sharpNum):
if room%2 == 0:
building[floor][room] = " "
else:
actRoom = actRoom + 1
#print("#room: %d" %room)
#print("#actRoom: %d" %actRoom)
if floor == f-1 and actRoom == r:
building[floor][room] = building[floor][room] + v
for floor in range(height):
for i in range(len(building[0])):
print(building[floor][i],end="")
|
s907332415
|
Accepted
| 40 | 5,648 | 1,026 |
sharpNum = 20
roomNum = 10
height = 15
dataNum = int(input())
#building = [[0]*sharpNum] * height
building = [[0] * sharpNum for i in range(height)]
for data in range(dataNum):
actBuilding = 1
actRoom = 0
actFloor = 0
b,f,r,v = map(int, input().split())
for floor in range(height):
actRoom = 0
if floor%4 == 3:
actFloor = 0
actBuilding = actBuilding + 1
for room in range(sharpNum):
building[floor][room] = "#"
else:
actFloor = actFloor + 1
for room in range(sharpNum):
if room%2 == 0:
building[floor][room] = " "
else:
actRoom = actRoom + 1
if actBuilding == b and actFloor== f and actRoom == r:
building[floor][room] = building[floor][room] + v
for floor in range(height):
for i in range(len(building[0])):
print(building[floor][i],end="")
print("")
|
s620324329
|
p03574
|
u749491107
| 2,000 | 262,144 |
Wrong Answer
| 40 | 9,100 | 566 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
for j in range(w):
if s[i][j] == ".":
c = 0
for x in range(-1, 2):
for y in range(-1, 2):
if x == 0 and y == 0:
break
else:
if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:
if s[i+y][j+x] == "#":
c += 1
s[i][j] = str(c)
for a in range(h):
print("".join(s[a]))
|
s712215528
|
Accepted
| 36 | 9,228 | 569 |
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
for j in range(w):
if s[i][j] == ".":
c = 0
for x in range(-1, 2):
for y in range(-1, 2):
if x == 0 and y == 0:
continue
else:
if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:
if s[i+y][j+x] == "#":
c += 1
s[i][j] = str(c)
for a in range(h):
print("".join(s[a]))
|
s852008887
|
p02390
|
u231369830
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,584 | 139 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
s = int(input())
m = 0
h = 0
if s >= 60:
m = int(s / 60)
s = s % 60
if m >= 60:
h = int(m / 60)
m = m % 60
print(h,m,s)
|
s312152449
|
Accepted
| 20 | 5,592 | 173 |
s = int(input())
m = 0
h = 0
if s >= 60:
m = int(s / 60)
s = s % 60
if m >= 60:
h = int(m / 60)
m = m % 60
print(h,end = ":")
print(m,end = ":")
print(s)
|
s023190347
|
p03852
|
u036190609
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 94 |
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
komoji = input()
if komoji in "aeiou" == True:
print("vowel")
else:
print("consonant")
|
s115701842
|
Accepted
| 17 | 2,940 | 76 |
s = input()
if s in "aeiou":
print("vowel")
else:
print("consonant")
|
s704436802
|
p03054
|
u667084803
| 2,000 | 1,048,576 |
Wrong Answer
| 1,176 | 14,640 | 665 |
We have a rectangular grid of squares with H horizontal rows and W vertical columns. Let (i,j) denote the square at the i-th row from the top and the j-th column from the left. On this grid, there is a piece, which is initially placed at square (s_r,s_c). Takahashi and Aoki will play a game, where each player has a string of length N. Takahashi's string is S, and Aoki's string is T. S and T both consist of four kinds of letters: `L`, `R`, `U` and `D`. The game consists of N steps. The i-th step proceeds as follows: * First, Takahashi performs a move. He either moves the piece in the direction of S_i, or does not move the piece. * Second, Aoki performs a move. He either moves the piece in the direction of T_i, or does not move the piece. Here, to move the piece in the direction of `L`, `R`, `U` and `D`, is to move the piece from square (r,c) to square (r,c-1), (r,c+1), (r-1,c) and (r+1,c), respectively. If the destination square does not exist, the piece is removed from the grid, and the game ends, even if less than N steps are done. Takahashi wants to remove the piece from the grid in one of the N steps. Aoki, on the other hand, wants to finish the N steps with the piece remaining on the grid. Determine if the piece will remain on the grid at the end of the game when both players play optimally.
|
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
print(hidari,migi,ue,shita)
if S[i] == 'L':
hidari -= 1
if S[i] == 'R':
migi += 1
if S[i] == 'U':
ue -= 1
if S[i] == 'D':
shita += 1
if hidari == 0 or migi == W+1 or ue == H+1 or shita == 0:
flag = 1
print(hidari,migi,ue,shita)
if T[i] == 'R' and hidari != W:
hidari += 1
if T[i] == 'L' and migi != 0:
migi -= 1
if T[i] == 'D' and ue != 0:
ue += 1
if T[i] == 'U' and shita != H:
shita -= 1
if flag :
print("NO")
else :
print("YES")
|
s745695693
|
Accepted
| 230 | 3,788 | 606 |
H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
flag = 0
hidari = sc
migi = sc
ue = sr
shita = sr
for i in range(N):
if S[i] == 'L':
hidari -= 1
if S[i] == 'R':
migi += 1
if S[i] == 'U':
ue -= 1
if S[i] == 'D':
shita += 1
if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :
flag = 1
if T[i] == 'R' and hidari != W:
hidari += 1
if T[i] == 'L' and migi != 1:
migi -= 1
if T[i] == 'D' and ue != H:
ue += 1
if T[i] == 'U' and shita != 1:
shita -= 1
if flag :
print("NO")
else :
print("YES")
|
s865854254
|
p04029
|
u393581926
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 32 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n=int(input())
print(n*(n+1)/2)
|
s620376083
|
Accepted
| 18 | 2,940 | 33 |
n=int(input())
print(n*(n+1)//2)
|
s299126715
|
p03415
|
u470286613
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 47 |
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
|
for i in range(3):
print(input()[i],sep='')
|
s307571915
|
Accepted
| 17 | 2,940 | 50 |
s=''
for i in range(3):
s+=input()[i]
print(s)
|
s639062368
|
p03129
|
u591779169
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 150 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
n, k = map(int, input().split())
sum = 0
for i in range (1, n-1):
sum = sum + i
print(sum)
if k >= sum:
print("YES")
else:
print("NO")
|
s153244565
|
Accepted
| 17 | 2,940 | 100 |
n, k = map(int, input().split())
num = n/2+ 0.5
if num >= k:
print("YES")
else:
print("NO")
|
s547808074
|
p04043
|
u193657135
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
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.
|
ABC = list(map(int, input().split()))
if sorted(ABC) == [5,5,7]:
print("Yes")
else:
print("No")
|
s748779358
|
Accepted
| 17 | 2,940 | 134 |
A,B,C = map(int, input().split())
ABC = [A,B,C]
if sorted(ABC) == [5,5,7]:
print("YES")
else:
print("NO")
|
s807965056
|
p03473
|
u010437136
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 47 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
def time(x):
return 48-int(x)
time(input())
|
s573605479
|
Accepted
| 17 | 2,940 | 34 |
a = input()
x = int(a)
print(48-x)
|
s296282477
|
p03563
|
u178432859
| 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.
|
a = int(input())
b = int(input())
print(b-a)
|
s286090601
|
Accepted
| 21 | 3,316 | 46 |
a = int(input())
b = int(input())
print(2*b-a)
|
s100178467
|
p02388
|
u517275798
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 52 |
Write a program which calculates the cube of a given integer x.
|
s = input()
n = int(s)**3
print('x =', s,'x^3=', n)
|
s816353805
|
Accepted
| 20 | 5,572 | 30 |
x = int(input())
print(x*x*x)
|
s783237445
|
p03657
|
u969848070
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,092 | 192 |
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
a, b = map(int, input().split())
if a + b % 3 == 0:
print('Possible')
exit()
elif a % 3 == 0:
print('Possible')
exit()
elif b % 3 == 0:
print('Possible')
exit()
print('Impossible')
|
s140262302
|
Accepted
| 28 | 9,172 | 194 |
a, b = map(int, input().split())
if (a + b) % 3 == 0:
print('Possible')
exit()
elif a % 3 == 0:
print('Possible')
exit()
elif b % 3 == 0:
print('Possible')
exit()
print('Impossible')
|
s833359792
|
p03575
|
u131634965
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,064 | 1,234 |
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.
|
def dfs(x):
if visited[x]:
return
visited[x] = True
for i in range(N):
if graph[x][i]:
dfs(i)
N, M = map(int, input().split())
edge = []
graph = [[False]*N for _ in range(N)]
visited = [False]*N
for i in range(M):
a, b = map(int, input().split())
edge.append((a, b))
graph[a-1][b-1] = True
graph[b-1][a-1] = True
ans = 0
for i, e in enumerate(edge):
graph[e[0]-1][e[1]-1] = False
graph[e[1]-1][e[0]-1] = False
for j in range(N):
visited[j] = False
dfs(0)
bridge = True
for j in range(N):
if visited[j]:
bridge=False
break
# for j in range(N):
# if not visited[j]:
# bridge = True
if bridge:
ans += 1
graph[e[0]-1][e[1]-1] = True
graph[e[1]-1][e[0]-1] = True
print(ans)
|
s588784059
|
Accepted
| 26 | 3,188 | 1,170 |
def dfs(x):
if visited[x]:
return
visited[x] = True
for i in range(N):
if graph[x][i]:
dfs(i)
N, M = map(int, input().split())
edge = []
graph = [[False]*N for _ in range(N)]
visited = [False]*N
for i in range(M):
a, b = map(int, input().split())
edge.append((a, b))
graph[a-1][b-1] = True
graph[b-1][a-1] = True
ans = 0
for i, e in enumerate(edge):
graph[e[0]-1][e[1]-1] = False
graph[e[1]-1][e[0]-1] = False
for j in range(N):
visited[j] = False
dfs(0)
bridge = False
for j in range(N):
#if not visited[j]:
if not all(visited):
bridge = True
if bridge:
ans += 1
graph[e[0]-1][e[1]-1] = True
graph[e[1]-1][e[0]-1] = True
print(ans)
|
s644503535
|
p03737
|
u312078744
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
a, b, c = map(str, input().split())
A = a[0]
B = b[0]
C = c[0]
ans = A.upper() + B.upper() + C.upper()
|
s107832873
|
Accepted
| 17 | 2,940 | 114 |
a, b, c = map(str, input().split())
A = a[0]
B = b[0]
C = c[0]
ans = A.upper() + B.upper() + C.upper()
print(ans)
|
s431690296
|
p03693
|
u840310460
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 95 |
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?
|
x = input().split()
xx = int("".join(x))
if xx % 4 == 0:
print("Yes")
else:
print("No")
|
s490072446
|
Accepted
| 18 | 2,940 | 95 |
x = input().split()
xx = int("".join(x))
if xx % 4 == 0:
print("YES")
else:
print("NO")
|
s090239443
|
p00026
|
u964040941
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,680 | 711 |
As shown in the following figure, there is a paper consisting of a grid structure where each cell is indicated by (x, y) coordinate system. We are going to put drops of ink on the paper. A drop comes in three different sizes: Large, Medium, and Small. From the point of fall, the ink sinks into surrounding cells as shown in the figure depending on its size. In the figure, a star denotes the point of fall and a circle denotes the surrounding cells. Originally, the paper is white that means for each cell the value of density is 0. The value of density is increased by 1 when the ink sinks into the corresponding cells. For example, if we put a drop of Small ink at (1, 2) and a drop of Medium ink at (3, 2), the ink will sink as shown in the following figure (left side): In the figure, density values of empty cells are 0. The ink sinking into out of the paper should be ignored as shown in the figure (top side). We can put several drops of ink at the same point. Your task is to write a program which reads a sequence of points of fall (x, y) with its size (Small = 1, Medium = 2, Large = 3), and prints the number of cells whose density value is 0. The program must also print the maximum value of density. You may assume that the paper always consists of 10 × 10, and 0 ≤ x < 10, 0 ≤ y < 10\.
|
import sys
paper = [[0] * 10 for i in range(10)]
for line in sys.stdin:
x,y,s = map(int,line.split(','))
for i in range(10):
for j in range(10):
if s == 1:
if abs(i - y) + abs(j - x) <= 1:
paper [i] [j] += 1
if s == 2:
if abs(i - y) <= 1 and abs(j - x) <= 1:
paper [i] [j] += 1
if s == 3:
if abs(i - y) + abs(j - x) <= 2:
paper [i] [j] += 1
ans = [0,0]
for i in range(10):
for j in range(10):
if paper [i] [j] == 0:
ans [0] += 1
if paper [i] [j] > ans [1]:
ans [1] = paper [i] [j]
print(ans [0],ans [1])
|
s426531926
|
Accepted
| 30 | 7,728 | 676 |
paper = [[0] * 10 for i in range(10)]
while True:
try:
x,y,s = map(int,input().split(','))
except:
break
if s == 1:
for i in range(10):
for j in range(10):
if abs(x - i) + abs(y - j) <= 1:
paper [i] [j] += 1
elif s == 2:
for i in range(10):
for j in range(10):
if abs(x - i) <= 1 and abs(y - j) <= 1:
paper [i] [j] += 1
else:
for i in range(10):
for j in range(10):
if abs(x - i) + abs(y - j) <= 2:
paper [i] [j] += 1
ls = sum(paper,[])
print(ls.count(0))
print(max(ls))
|
s373366789
|
p02601
|
u008464939
| 2,000 | 1,048,576 |
Wrong Answer
| 127 | 27,168 | 328 |
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.
|
import numpy as np
A = [int(x) for x in input().split()]
src = np.array(A)
K = int(input())
flag = 0
for i in range(K):
if(src[0] < src[1]):
if(src[1] < src[2]):
flag = 1
break
else:
src[2] *= 2
else:
src[1] *= 2
if(src[0] < src[1]):
if(src[1] < src[2]):
print("yes")
else:
print("no")
|
s423341661
|
Accepted
| 121 | 27,116 | 355 |
import numpy as np
A = [int(x) for x in input().split()]
src = np.array(A)
K = int(input())
flag = 0
for i in range(K):
if(src[0] < src[1]):
if(src[1] < src[2]):
flag = 1
break
else:
src[2] *= 2
else:
src[1] *= 2
if(src[0] < src[1]):
if(src[1] < src[2]):
print("Yes")
else:
print("No")
else:
print("No")
|
s825981362
|
p02399
|
u896025703
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,632 | 78 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, f)
|
s550115892
|
Accepted
| 30 | 7,640 | 95 |
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, "{:.5f}".format(f))
|
s919059324
|
p03997
|
u483151310
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 68 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s117895471
|
Accepted
| 19 | 2,940 | 86 |
a = int(input())
b = int(input())
h = int(input())
calc = int((a+b)*h/2)
print(calc)
|
s805658028
|
p03131
|
u668503853
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 87 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
K,A,B=map(int,input().split())
if B-A<=2:
print(K+1)
else:
print(max(0,K-(A-1)//2))
|
s666642946
|
Accepted
| 17 | 2,940 | 113 |
K,A,B=map(int,input().split())
if K+1>=A and A+2<=B:
print(((K+1)-A)//2*(B-A)+A+((K+1)-A)%2)
else:
print(K+1)
|
s358460458
|
p03574
|
u146346223
| 2,000 | 262,144 |
Wrong Answer
| 31 | 3,188 | 577 |
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if s[i][j] == '.':
count = 0
for dx, dy in (
(-1,1), (0,1), (1,0),
(-1,0), (0,0), (0,1),
(-1,-1),(0,-1),(1,-1)
):
now_x, now_y = i+dx, j+dy
if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
count += 1
s[i][j] = str(count)
for i in range(H):
print(''.join(s[i]))
|
s910480131
|
Accepted
| 29 | 3,188 | 577 |
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if s[i][j] == '.':
count = 0
for dx, dy in (
(-1,1), (0,1), (1,1),
(-1,0), (0,0), (1,0),
(-1,-1),(0,-1),(1,-1)
):
now_x, now_y = i+dx, j+dy
if 0 <= now_x and 0 <= now_y and now_x <= H-1 and now_y <= W-1 and s[now_x][now_y] == "#":
count += 1
s[i][j] = str(count)
for i in range(H):
print(''.join(s[i]))
|
s201573834
|
p03545
|
u483304397
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 593 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
sS = sumS
ba = bin(a)
for ia,aa in enumerate(ba[::-1]):
if aa == 'b':
break
elif aa == '1':
sS -= 2 * int(S[ia+1:ia+2])
if sS == 7:
print(ba)
T = ['+', '+', '+', '=7']
for ia,aa in enumerate(ba[::-1]):
if aa == '1':
T[ia] = '-'
result = ''
for i in range(len(S)):
result += S[i] + T[i]
return result
else:
return minus(a+1,sumS)
print(minus(0,sumS))
|
s321528548
|
Accepted
| 17 | 3,064 | 575 |
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
sS = sumS
ba = bin(a)
for ia,aa in enumerate(ba[::-1]):
if aa == 'b':
break
elif aa == '1':
sS -= 2 * int(S[ia+1:ia+2])
if sS == 7:
T = ['+', '+', '+', '=7']
for ia,aa in enumerate(ba[::-1]):
if aa == '1':
T[ia] = '-'
result = ''
for i in range(len(S)):
result += S[i] + T[i]
return result
else:
return minus(a+1,sumS)
print(minus(0,sumS))
|
s192514155
|
p02612
|
u306412379
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,108 | 40 |
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 - N//1000*1000)
|
s520774799
|
Accepted
| 27 | 9,136 | 56 |
N = int(input())
a = (N + 1000 -1)//1000
print(a*1000-N)
|
s471563716
|
p02613
|
u131453093
| 2,000 | 1,048,576 |
Wrong Answer
| 142 | 9,140 | 177 |
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())
test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(N):
s = input()
test[s] += 1
for i, j in test.items():
print("{} × {}".format(i, j))
|
s002808377
|
Accepted
| 145 | 9,180 | 178 |
N = int(input())
test = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(N):
s = input()
test[s] += 1
for i, j in test.items():
print("{} x {}".format(i, j))
|
s017353267
|
p03997
|
u239342230
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 61 |
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
c=int(input())
print((a+b)*c/2)
|
s126663784
|
Accepted
| 19 | 2,940 | 66 |
a=int(input())
b=int(input())
c=int(input())
print(int((a+b)*c/2))
|
s357967658
|
p03089
|
u918845030
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 3,440 | 493 |
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.
|
def find(n):
tn = int(n/2)
s = 2 * tn + 1
count = 0
line_list = []
for i in range(1, n+1):
for j in range(i+1, n+1):
if i + j != s:
line_list.append(str(i) + " " + str(j))
count +=1
return count, line_list
if __name__ == '__main__':
n = input()
count, line_list = find(int(n))
print(count)
print("\n".join(line_list))
|
s090357211
|
Accepted
| 17 | 3,064 | 488 |
def find(sequence):
result_list = []
for i in range(len(sequence)):
for j in reversed(list(range(len(sequence)))):
if sequence[j] == j + 1:
result_list.append(sequence.pop(j))
break
if len(sequence) != 0:
return [-1]
return result_list
if __name__ == "__main__":
n = input()
sequence = input()
data = [int(item) for item in sequence.split(" ")]
print("\n".join(map(str, reversed(find(data)))))
|
s222847649
|
p03359
|
u776871252
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 78 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a, b = map(int, input().split())
ans = a
if b <= a:
ans -= 1
print(ans)
|
s289914422
|
Accepted
| 17 | 2,940 | 77 |
a, b = map(int, input().split())
ans = a
if b < a:
ans -= 1
print(ans)
|
s772294498
|
p03545
|
u941884460
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 767 |
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.
|
import sys
x = input()
A = int(x[0])
B = int(x[1])
C = int(x[2])
D = int(x[3])
work = A
op1,op2,op3 = "","",""
for i in range(2):
for j in range(2):
for k in range(2):
if i == 1:
op1 = "+"
work += B
else:
op1 = "-"
work -= B
if j == 1:
op2 = "+"
work += C
else:
op2 = "-"
work -= C
if k == 1:
op3 = "+"
work += D
else:
op3 = "-"
work -= D
if work ==7:
print(x[0]+op1+x[1]+op2+x[2]+op3+x[3])
sys.exit()
else:
work = A
|
s023417498
|
Accepted
| 17 | 3,064 | 772 |
import sys
x = input()
A = int(x[0])
B = int(x[1])
C = int(x[2])
D = int(x[3])
work = A
op1,op2,op3 = "","",""
for i in range(2):
for j in range(2):
for k in range(2):
if i == 1:
op1 = "+"
work += B
else:
op1 = "-"
work -= B
if j == 1:
op2 = "+"
work += C
else:
op2 = "-"
work -= C
if k == 1:
op3 = "+"
work += D
else:
op3 = "-"
work -= D
if work ==7:
print(x[0]+op1+x[1]+op2+x[2]+op3+x[3]+"=7")
sys.exit()
else:
work = A
|
s741511927
|
p03067
|
u297756089
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 118 |
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 a<=b and b<=c:
print("Yes")
elif a>=b and b>=c:
print("Yes")
else:
print("No")
|
s495994573
|
Accepted
| 17 | 2,940 | 119 |
a,b,c=map(int,input().split())
if a<=c and c<=b:
print("Yes")
elif a>=c and c>=b:
print("Yes")
else:
print("No")
|
s502626931
|
p02396
|
u499005012
| 1,000 | 131,072 |
Wrong Answer
| 110 | 6,720 | 109 |
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.
|
i = 0
while True:
v = input()
if v == '0':
break
print('Case %d: %s' % (i, v))
i += 1
|
s436764588
|
Accepted
| 120 | 6,724 | 109 |
i = 0
while True:
i += 1
v = input()
if v == '0':
break
print('Case %d: %s' % (i, v))
|
s083870222
|
p02393
|
u389610071
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,724 | 277 |
Write a program which reads three integers, and prints them in ascending order.
|
nums = input().split()
a = int(nums[0])
b = int(nums[0])
c = int(nums[0])
if a < b < c:
print(a, b, c)
elif a < c < b:
print(a, c, b)
elif b < a < c:
print(b, a, c)
elif b < c < a:
print(b, c, a)
elif c < a < b:
print(c, a, b)
else:
print(c, b, a)
|
s823707254
|
Accepted
| 30 | 6,724 | 287 |
nums = input().split()
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
if a <= b <= c:
print(a, b, c)
elif a <= c <= b:
print(a, c, b)
elif b <= a <= c:
print(b, a, c)
elif b <= c <= a:
print(b, c, a)
elif c <= a <= b:
print(c, a, b)
else:
print(c, b, a)
|
s741294507
|
p02742
|
u190873802
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 113 |
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:
|
import math
a,b=map(int,input().split())
c=a*b
if c%2==0:
d = c/2
else:
d = math.floor(c/2) + 1
print(d)
|
s350088122
|
Accepted
| 18 | 2,940 | 106 |
import math
H,W=map(int, input().split())
if H==1 or W==1:
print(1)
else:
print(math.ceil(H*W/2))
|
s333804587
|
p03251
|
u570121126
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 229 |
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.
|
f=input().split()
(n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3]))
ax=[int(i) for i in input().split()]
ay=[int(i) for i in input().split()]
ax.sort()
ay.sort()
b=ay[0]-ax[-1]
if b>1:
print("No War")
else:
print("War")
|
s223962491
|
Accepted
| 17 | 3,064 | 370 |
f=input().split()
(n,m,x,y)=(int(f[0]),int(f[1]),int(f[2]),int(f[3]))
ax=[int(i) for i in input().split()]
ay=[int(i) for i in input().split()]
ax.sort()
ay.sort()
b=ay[0]-ax[-1]
c=0
if x<ax[-1] and y>ax[-1]:
c=1
elif x>ax[-1] and x<ay[0] and y<ay[0]:
c=1
elif x>ax[-1] and y>ay[0] and x<ay[0]:
c=1
if b>0 and c==1:
print("No War")
else:
print("War")
|
s868447625
|
p02869
|
u923270446
| 2,000 | 1,048,576 |
Wrong Answer
| 136 | 9,264 | 571 |
Given are positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be partitioned into N triples (a_1,b_1,c_1), ..., (a_N,b_N,c_N) so that the condition below is satisfied. Any of the integers K, K+1, ..., K+3N-1 must appear in exactly one of those triples. * For every integer i from 1 to N, a_i + b_i \leq c_i holds. If the answer is yes, construct one such partition.
|
n, k = map(int, input().split())
if 2 * k > n + 1:
exit(print(-1))
else:
if n % 2 == 0:
for i in range(n):
if i % 2 == 0:
print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=" ")
else:
print(i // 2 + n // 2 + k, i // 2 + n + k, i + n * 2 + k, end=" ")
else:
for i in range(n):
if i % 2 == 0:
print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=" ")
else:
print(i // 2 + n // 2 + k + 1, i // 2 + n + k, i + n * 2 + k, end=" ")
|
s826606168
|
Accepted
| 138 | 9,204 | 543 |
n, k = map(int, input().split())
if 2 * k > n + 1:
exit(print(-1))
else:
if n % 2 == 0:
for i in range(n):
if i % 2 == 0:
print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)
else:
print(k + i // 2 + n // 2, k + i // 2 + n, k + i + n * 2)
else:
for i in range(n):
if i % 2 == 0:
print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)
else:
print(k + i // 2 + n // 2 + 1, k + i // 2 + n, k + i + n * 2)
|
s398323374
|
p02613
|
u137962336
| 2,000 | 1,048,576 |
Wrong Answer
| 143 | 16,152 | 206 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N = int(input())
S = [input() for i in range(N)]
print('AC' + 'x' + str(S.count('AC')))
print('WA' + 'x' + str(S.count('WA')))
print('TLE' + 'x' + str(S.count('TLE')))
print('RE' + 'x' + str(S.count('RE')))
|
s401964963
|
Accepted
| 138 | 16,276 | 217 |
N = int(input())
S = [input() for i in range(N)]
print('AC' + ' x ' + str(S.count('AC')))
print('WA' + ' x ' + str(S.count('WA')))
print('TLE' + ' x ' + str(S.count('TLE')))
print('RE' + ' x ' + str(S.count('RE')))
|
s393104129
|
p02646
|
u112629957
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,164 | 129 |
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())
T=int(input())
if (V-W)*T>=abs(A-B):
print("Yes")
else:
print("No")
|
s697056211
|
Accepted
| 22 | 9,164 | 130 |
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if (V-W)*T>=abs(A-B):
print("YES")
else:
print("NO")
|
s346624719
|
p03385
|
u560135121
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 59 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
abc=sorted(input())
print(["NO","YES"][abc==["a","b","c"]])
|
s283124628
|
Accepted
| 17 | 2,940 | 59 |
abc=sorted(input())
print(["No","Yes"][abc==["a","b","c"]])
|
s776748282
|
p03599
|
u658993896
| 3,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 521 |
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 = list(map(int,input().split()))
water = {}
for i in range(A[5]//(100*A[0])+1):
for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)
print(water)
ans = [0, 0]
max_ = 0
for w in water.keys():
for c in range((w//100*A[4])//A[2]+1):
d = ((w//100*A[4])-c*A[2])//A[3]
tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
if max_ < tmp and (w+A[2]*c+A[3]*d) < A[5]:
ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
max_=tmp
print(ans[0], ans[1])
|
s685733750
|
Accepted
| 20 | 3,064 | 568 |
A = list(map(int,input().split()))
water = {}
for i in range(A[5]//(100*A[0])+1):
for j in range((A[5]-i*A[0]*100)//(100*A[1])+1):
water[100*(A[0]*i+A[1]*j)]=1
water.pop(0)
ans = [100*A[0], 0]
max_ = -1
for w in water.keys():
for c in range(min((w//100*A[4])//A[2]+1,(A[5]-w)//A[2]+1)):
d = min(((w//100*A[4])-c*A[2])//A[3], (A[5]-w-c*A[2])//A[3])
tmp = (A[2]*c+A[3]*d)/(w+A[2]*c+A[3]*d)
if max_ < tmp and (w+A[2]*c+A[3]*d) <= A[5]:
ans=[w+A[2]*c+A[3]*d, A[2]*c+A[3]*d]
max_=tmp
print(ans[0], ans[1])
|
s596417597
|
p04029
|
u185331085
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
S = N*N/2+N/2
print(S)
|
s788943423
|
Accepted
| 20 | 2,940 | 44 |
N = int(input())
S = int(N*N/2+N/2)
print(S)
|
s509574093
|
p03555
|
u556371693
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
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,b,c=input()
d,e,f=input()
if a==f and b==e and c==d:
print("Yes")
else:
print("No")
|
s248267703
|
Accepted
| 17 | 2,940 | 93 |
a,b,c=input()
d,e,f=input()
if a==f and b==e and c==d:
print("YES")
else:
print("NO")
|
s592491152
|
p02663
|
u518085378
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,148 | 71 |
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?
|
h, m, h2, m2, k = map(int, input().split())
print(12*h2+m2-(12*h+m+k))
|
s555995525
|
Accepted
| 24 | 9,148 | 71 |
h, m, h2, m2, k = map(int, input().split())
print(60*h2+m2-(60*h+m+k))
|
s677080672
|
p02612
|
u690833702
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 8,988 | 80 |
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.
|
import math
def main():
N = int(input())
print(N % 1000)
main()
|
s270329816
|
Accepted
| 28 | 9,136 | 136 |
import math
def main():
N = int(input())
if N % 1000 == 0:
print(0)
return
print(1000 - (N % 1000))
main()
|
s276280630
|
p03485
|
u266171694
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
print(-(-a // b))
|
s423839535
|
Accepted
| 17 | 2,940 | 56 |
a, b = map(int, input().split())
print((a + b + 1) // 2)
|
s254728698
|
p03563
|
u695079172
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 58 |
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 = int(input())
print((r + (g - r))//2)
|
s312927786
|
Accepted
| 17 | 2,940 | 60 |
r = int(input())
g = int(input())
sa = g - r
print(g + sa)
|
s820174018
|
p03854
|
u767797498
| 2,000 | 262,144 |
Wrong Answer
| 34 | 9,116 | 127 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s=input()
lst=["eraser","erase","dreamer","dream",]
for e in lst:
s=s.replace(e,"")
print(s)
print("YES" if s=="" else "NO")
|
s785495804
|
Accepted
| 29 | 9,104 | 119 |
s=input()
lst=["eraser","erase","dreamer","dream",]
for e in lst:
s=s.replace(e,"")
print("YES" if s=="" else "NO")
|
s625370013
|
p03193
|
u023229441
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,060 | 120 |
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
|
n,H,W=map(int,input().split())
p=0
for i in range(n):
a,b=map(int,input().split())
if a>=H & b>=W:
p+=1
print(p)
|
s592909625
|
Accepted
| 20 | 3,060 | 123 |
n,H,W=map(int,input().split())
p=0
for i in range(n):
a,b=map(int,input().split())
if a>=H and b>=W:
p+=1
print(p)
|
s820857877
|
p03485
|
u753682919
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
x=(a+b)/2
print(int(x)+1)
|
s858075500
|
Accepted
| 17 | 2,940 | 87 |
a,b=map(int,input().split())
x=(a+b)/2
if (a+b)%2==0:
n=0
else:
n=1
print(int(x)+n)
|
s947195741
|
p03557
|
u924406834
| 2,000 | 262,144 |
Wrong Answer
| 510 | 23,360 | 324 |
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
c.sort()
ans = 0
for i in range(n):
a_num = bisect.bisect_left(a,b[i])
c_num = n - bisect.bisect_right(c,b[i])
print(a_num,c_num)
ans += c_num * a_num
print(ans)
|
s954428854
|
Accepted
| 383 | 23,360 | 301 |
import bisect
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
a.sort()
c.sort()
ans = 0
for i in range(n):
a_num = bisect.bisect_left(a,b[i])
c_num = n - bisect.bisect_right(c,b[i])
ans += c_num * a_num
print(ans)
|
s093350155
|
p02601
|
u130074358
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,196 | 307 |
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.
|
X = list(map(int,input().split()))
A = X[0]
B = X[1]
C = X[2]
K = int(input())
cnt = 0
if A > B:
for i in range(K):
B = B*2
cnt = cnt + 1
if A < B:
break
if B > C:
for j in range(K):
C = C*2
cnt = cnt + 1
if B < C:
break
if cnt <= K:
print('YES')
else:
print('NO')
|
s868759364
|
Accepted
| 32 | 9,192 | 301 |
X = list(map(int,input().split()))
A = X[0]
B = X[1]
C = X[2]
K = int(input())
cnt = 0
if A >= B:
for i in range(7):
B = B*2
cnt = cnt + 1
if A < B:
break
if B >= C:
for j in range(7):
C = C*2
cnt = cnt + 1
if B < C:
break
if cnt <= K:
print('Yes')
else:
print('No')
|
s883580902
|
p03693
|
u772649753
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
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?
|
l = list(input().split())
x = int(l[1]+l[2])
if x//4 == 0:
print("YES")
else:
print("NO")
|
s372613929
|
Accepted
| 17 | 2,940 | 92 |
l = list(input().split())
x = int(l[1]+l[2])
if x%4 == 0:
print("YES")
else:
print("NO")
|
s217230828
|
p03814
|
u197300260
| 2,000 | 262,144 |
Wrong Answer
| 30 | 3,816 | 603 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
# _*_ coding:utf-8 _*_
def atozString(dataStr) :
rangeFirstToEnd = range(0,len(dataStr),1)
rangeEndToFirst = range(len(dataStr)-1,-1,-1)
firstA = 0
lastZ = len(dataStr)
for i in rangeFirstToEnd:
if dataStr[i] == 'A':
firstA = i
break
for i in rangeEndToFirst:
if dataStr[i] == 'Z':
lastZ = i
break
print(dataStr[firstA:lastZ+1])
answerInt = lastZ-firstA+1
return answerInt
if __name__ == '__main__':
inputLine = input()
inputStr = inputLine
ans=atozString(inputStr)
print(ans)
|
s575293171
|
Accepted
| 23 | 4,012 | 459 |
# Python 3rd Try
import copy
def solver(givenstring):
result = 0
usestrA = copy.copy(givenstring)
usestrZ = copy.copy(givenstring)
# a position
apos = usestrA.index('A')+1
usestrrevZ = usestrZ[::-1]
zpos = len(givenstring) - usestrrevZ.index('Z')
result = zpos - apos + 1
return result
if __name__ == "__main__":
s = input()
print("{}".format(solver(s)))
|
s263485260
|
p02283
|
u935184340
| 2,000 | 131,072 |
Wrong Answer
| 30 | 7,492 | 1,361 |
Search trees are data structures that support dynamic set operations including insert, search, delete and so on. Thus a search tree can be used both as a dictionary and as a priority queue. Binary search tree is one of fundamental search trees. The keys in a binary search tree are always stored in such a way as to satisfy the following binary search tree property: * Let $x$ be a node in a binary search tree. If $y$ is a node in the left subtree of $x$, then $y.key \leq x.key$. If $y$ is a node in the right subtree of $x$, then $x.key \leq y.key$. The following figure shows an example of the binary search tree. For example, keys of nodes which belong to the left sub-tree of the node containing 80 are less than or equal to 80, and keys of nodes which belong to the right sub-tree are more than or equal to 80. The binary search tree property allows us to print out all the keys in the tree in sorted order by an inorder tree walk. A binary search tree should be implemented in such a way that the binary search tree property continues to hold after modifications by insertions and deletions. A binary search tree can be represented by a linked data structure in which each node is an object. In addition to a key field and satellite data, each node contains fields _left_ , _right_ , and _p_ that point to the nodes corresponding to its left child, its right child, and its parent, respectively. To insert a new value $v$ into a binary search tree $T$, we can use the procedure insert as shown in the following pseudo code. The insert procedure is passed a node $z$ for which $z.key = v$, $z.left = NIL$, and $z.right = NIL$. The procedure modifies $T$ and some of the fields of $z$ in such a way that $z$ is inserted into an appropriate position in the tree. 1 insert(T, z) 2 y = NIL // parent of x 3 x = 'the root of T' 4 while x ≠ NIL 5 y = x // set the parent 6 if z.key < x.key 7 x = x.left // move to the left child 8 else 9 x = x.right // move to the right child 10 z.p = y 11 12 if y == NIL // T is empty 13 'the root of T' = z 14 else if z.key < y.key 15 y.left = z // z is the left child of y 16 else 17 y.right = z // z is the right child of y Write a program which performs the following operations to a binary search tree $T$. * insert $k$: Insert a node containing $k$ as key into $T$. * print: Print the keys of the binary search tree by inorder tree walk and preorder tree walk respectively. You should use the above pseudo code to implement the insert operation. $T$ is empty at the initial state.
|
import sys
class Node():
def __init__(self,key):
self.key = key
self.left = None
self.right = None
def insert(t, z):
y = None
x = t
while x is not None:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
if y is None:
return z
else:
if z.key < y.key:
y.left = z
else:
y.right = z
return t
def in_order(t):
s = ""
l = []
curr = t
while True:
while curr is not None:
l.append(curr)
curr = curr.left
if curr is None and len(l) == 0:
break
else:
curr = l.pop()
s += " " + str(curr.key)
curr = curr.right
return s
def pre_order(t):
s = ""
l = []
curr = t
while True:
while curr is not None:
s += " " + str(curr.key)
l.append(curr)
curr = curr.left
if curr is None and len(l) == 0:
break
else:
curr = l.pop()
curr = curr.right
return s
t = None
n = sys.stdin.readline()
lines = sys.stdin.readlines()
for line in lines:
com = line.split()
if line[0] == "insert":
t = insert(t, Node(int(com[1])))
else:
print(in_order(t))
print(pre_order(t))
|
s158143021
|
Accepted
| 6,830 | 152,012 | 1,368 |
import sys
class Node():
def __init__(self,key):
self.key = key
self.left = None
self.right = None
def insert(t, z):
y = None
x = t
while x is not None:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
if y is None:
return z
else:
if z.key < y.key:
y.left = z
else:
y.right = z
return t
def inorder(t):
s = ""
l = []
curr = t
while True:
while curr is not None:
l.append(curr)
curr = curr.left
if curr is None and len(l) == 0:
break
else:
curr = l.pop()
s += " " + str(curr.key)
curr = curr.right
return s
def preorder(t):
s = ""
l = []
curr = t
while True:
while curr is not None:
s += " " + str(curr.key)
l.append(curr)
curr = curr.left
if curr is None and len(l) == 0:
break
else:
curr = l.pop()
curr = curr.right
return s
t = None
n = sys.stdin.readline()
lines = sys.stdin.readlines()
for line in lines:
com = line.split()
if com[0] == "insert":
t = insert(t, Node(int(com[1])))
else:
print(inorder(t))
print(preorder(t))
|
s686687256
|
p03149
|
u457460736
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,084 | 140 |
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
N=list(map(int,input().split()))
if(N.count(1)==1 and N.count(9)==1 and N.count(7)==1 and N.count(4)==1):
print("Yes")
else:
print("No")
|
s627355475
|
Accepted
| 29 | 9,064 | 141 |
N=list(map(int,input().split()))
if(N.count(1)==1 and N.count(9)==1 and N.count(7)==1 and N.count(4)==1):
print("YES")
else:
print("NO")
|
s624663529
|
p03644
|
u994767958
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 216 |
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.
|
import sys
sys.setrecursionlimit(10**6)
def f(n):
if n == 1:
return True
elif n%2 == 0:
return f(n/2)
else:
return False
n = int(input())
for i in range(n,0,-1):
if f(n):
print(i)
break
|
s300015948
|
Accepted
| 18 | 2,940 | 216 |
import sys
sys.setrecursionlimit(10**6)
def f(n):
if n == 1:
return True
elif n%2 == 0:
return f(n/2)
else:
return False
n = int(input())
for i in range(n,0,-1):
if f(i):
print(i)
break
|
s110673068
|
p03796
|
u409064224
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 45 |
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
|
n = int(input())
n *= 6
print(n%1000000007)
|
s716385014
|
Accepted
| 43 | 3,064 | 103 |
n = int(input())
res = 1
for i in range(1,n+1):
res *= i
res %= (10**9+7)
else:
print(res)
|
s577145814
|
p03721
|
u698771758
| 2,000 | 262,144 |
Wrong Answer
| 373 | 15,072 | 249 |
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.
|
N,K=map(int,input().split())
ans={}
for i in range(N):
a,b=map(int,input().split())
if a in ans:ans[a]+=b
else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
print(ans)
for key,value in ans:
K-=value
if K<=0:break
print(key)
|
s988489995
|
Accepted
| 344 | 15,076 | 238 |
N,K=map(int,input().split())
ans={}
for i in range(N):
a,b=map(int,input().split())
if a in ans:ans[a]+=b
else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
for key,value in ans:
K-=value
if K<=0:break
print(key)
|
s598113521
|
p02927
|
u227085629
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 2,940 | 145 |
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
|
m,d = map(int,input().split())
ans = 0
for i in range(1,d+1):
a = i%10
b = i//10
if a >= 2 and b >= 2 and a*b == m:
ans += 1
print(ans)
|
s454438149
|
Accepted
| 17 | 2,940 | 145 |
m,d = map(int,input().split())
ans = 0
for i in range(1,d+1):
a = i%10
b = i//10
if a >= 2 and b >= 2 and a*b <= m:
ans += 1
print(ans)
|
s053267742
|
p02833
|
u771524928
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 228 |
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).
|
#import numpy as np
def cin():
return map(int, input().split())
n = int(input())
print(n)
cnt = 0
if n % 2 == 1:
print(0)
exit(0)
div = 1
n //= 2
for i in range(33):
div *= 5
cnt += n // div
print(cnt)
|
s807345211
|
Accepted
| 18 | 2,940 | 219 |
#import numpy as np
def cin():
return map(int, input().split())
n = int(input())
cnt = 0
if n % 2 == 1:
print(0)
exit(0)
div = 1
n //= 2
for i in range(33):
div *= 5
cnt += n // div
print(cnt)
|
s389226772
|
p03992
|
u461636820
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 45 |
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.
|
s = 'codefextival'
print(s[:4] + ' ' + s[4:])
|
s879406721
|
Accepted
| 17 | 2,940 | 39 |
s = input()
print(s[0:4] + ' ' + s[4:])
|
s593942559
|
p03860
|
u045408189
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 29 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s=input()
print('A'+s[7]+'C')
|
s623734199
|
Accepted
| 17 | 2,940 | 30 |
s=input()
print('A'+s[8]+'C')
|
s177573272
|
p03637
|
u787449825
| 2,000 | 262,144 |
Wrong Answer
| 80 | 14,636 | 461 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
from collections import deque
def f(x):
return num.count(x)
n = int(input())
a = list(map(int, input().split()))
num = deque([])
for i in a:
if i%4==0:
num.append(4)
elif i%2==0:
num.append(2)
else:
num.append(0)
print(num)
if len(a)%2==1:
if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:
print('Yes')
exit(0)
if len(a)%2==0:
if f(2)>=2*(n//2-f(4)):
print('Yes')
exit(0)
print('No')
|
s731471912
|
Accepted
| 71 | 14,636 | 451 |
from collections import deque
def f(x):
return num.count(x)
n = int(input())
a = list(map(int, input().split()))
num = deque([])
for i in a:
if i%4==0:
num.append(4)
elif i%2==0:
num.append(2)
else:
num.append(0)
if len(a)%2==1:
if f(4)>=len(a)//2 or f(2)>=2*(n//2-f(4))+1:
print('Yes')
exit(0)
if len(a)%2==0:
if f(2)>=2*(n//2-f(4)):
print('Yes')
exit(0)
print('No')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.