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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s821714036
|
p00008
|
u737311644
| 1,000
| 131,072
|
Wrong Answer
| 30
| 5,592
| 306
|
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
|
n=int(input())
a,b,c,d=0,0,0,0
ans=0
for i in range(10):
c=0
for j in range(10):
b=0
for f in range(10):
a=0
for e in range(10):
if a+b+c+d==n:
ans+=1
a+=1
b+=1
c+=1
d+=1
print(ans)
|
s825608271
|
Accepted
| 170
| 5,592
| 263
|
while True:
try:n=int(input())
except:break
ans=0
for i in range(10):
for j in range(10):
for f in range(10):
for e in range(10):
if i+j+f+e==n:
ans+=1
print(ans)
|
s627401920
|
p04039
|
u021759654
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 209
|
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
#1000 8
#1 3 4 5 6 7 8 9
n, k = map(int, input().split())
Ds = list(map(int, input().split()))
for i in range(n, n*10+2):
for d in Ds:
if d in list(str(i)):
break
else:
print(i)
exit(0)
|
s558786114
|
Accepted
| 346
| 3,060
| 197
|
n, k = map(int, input().split())
Ds = list(map(int, input().split()))
for i in range(n, n*11):
for d in Ds:
if d in list(map(int, list(str(i)))):
break
else:
print(i)
exit(0)
|
s712465002
|
p03377
|
u987164499
| 2,000
| 262,144
|
Wrong Answer
| 149
| 12,400
| 152
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
from sys import stdin
import numpy as np
a,b,c= [int(x) for x in stdin.readline().rstrip().split()]
if c-a >= b:
print("YES")
else:
print("NO")
|
s279609437
|
Accepted
| 161
| 13,232
| 164
|
from sys import stdin
import numpy as np
a,b,c= [int(x) for x in stdin.readline().rstrip().split()]
if c-a <= b and a <= c:
print("YES")
else:
print("NO")
|
s909930939
|
p03493
|
u929138803
| 2,000
| 262,144
|
Wrong Answer
| 2,103
| 3,060
| 208
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
count = 0
flg = 0
a = list(map(int,input().split()))
while True:
for i in a:
if i%2 != 0:
flg = 1
if flg == 0:
a = list(map(lambda x: int(x/2), a))
count += 1
else:
break
print(count)
|
s081388009
|
Accepted
| 18
| 2,940
| 76
|
count = 0
a = input()
for i in a:
if i == '1':
count += 1
print(count)
|
s407945629
|
p03993
|
u982653403
| 2,000
| 262,144
|
Wrong Answer
| 90
| 14,008
| 157
|
There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculate the number of the friendly pairs.
|
n = int(input())
a = list(map(int, input().split()))
print(a)
total = 0
for i in range(n):
if a[a[i] - 1] == i + 1:
total += 1
print(total // 2)
|
s272042462
|
Accepted
| 81
| 14,008
| 148
|
n = int(input())
a = list(map(int, input().split()))
total = 0
for i in range(n):
if a[a[i] - 1] == i + 1:
total += 1
print(total // 2)
|
s742631933
|
p04035
|
u064408584
| 2,000
| 262,144
|
Wrong Answer
| 131
| 14,060
| 248
|
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
n,l=map(int, input().split())
a=list(map(int, input().split()))
ans=-1
for i in range(n-1):
if a[i]+a[i+1]>=l:
ans=i+1
break
if ans==-1:print('Impossible')
else:
for i in range(1,n):
if i!=ans:print(i)
print(ans)
|
s914486895
|
Accepted
| 126
| 14,060
| 276
|
n,l=map(int, input().split())
a=list(map(int, input().split()))
ans=-1
for i in range(n-1):
if a[i]+a[i+1]>=l:
ans=i+1
break
if ans==-1:print('Impossible')
else:
print('Possible')
for i in range(1,ans):print(i)
for i in range(n-1,i,-1):print(i)
|
s699777088
|
p03151
|
u243453868
| 2,000
| 1,048,576
|
Wrong Answer
| 343
| 27,564
| 679
|
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
import numpy
import scipy
from collections import defaultdict
from pprint import pprint
N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]
diff = [0 for x in range(N)]
for i in range(N):
diff[i] = A[i] - B[i]
if (sum(diff) < 0):
print (-1)
else:
shakkin = 0
ans = 0
for d in diff:
if d < 0:
shakkin += d
ans += 1
for d in sorted(diff, reverse=True):
if shakkin >= 0:
break
print("diff: %s", d)
ans += 1
shakkin += d
if shakkin >= 0:
break
print(ans)
|
s509103718
|
Accepted
| 284
| 29,628
| 599
|
import numpy
import scipy
from collections import defaultdict
from pprint import pprint
N = int(input())
A = [int(x) for x in input().split(" ")]
B = [int(x) for x in input().split(" ")]
diff = [0 for x in range(N)]
for i in range(N):
diff[i] = A[i] - B[i]
if (sum(diff) < 0):
print (-1)
else:
point = 0
ans = 0
for d in diff:
if d < 0:
point += d
ans += 1
for d in sorted(diff, reverse=True):
if point >= 0:
break
ans += 1
point += d
print(ans)
|
s252380707
|
p03861
|
u312025627
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
def main():
a, b, x = map(int,input().split())
print((b//x+1) - (a//x+1))
main()
|
s274530591
|
Accepted
| 18
| 2,940
| 180
|
def main():
a, b, x = map(int,input().split())
re_b = (b//x)+1
if a-1 != -1:
re_a = ((a-1)//x)+1
print(re_b - re_a)
else:
print(re_b)
main()
|
s936237419
|
p03860
|
u604231488
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 24
|
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(s[8])
|
s644083639
|
Accepted
| 17
| 2,940
| 32
|
s = input()
print('A'+s[8]+'C')
|
s444813651
|
p03251
|
u121161758
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 493
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N, M , X ,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
max_y = max(y)
#print(max_x)
#print(max_y)
#print(Y-X)
XY_list = []
xy_list = []
for i in range(X+1, Y+1):
XY_list.append(i)
if max_x + 1 >= max_y:
print("War")
exit()
for i in range(max_x, max_y+1):
xy_list.append(i)
#print(XY_list)
#print(xy_list)
set_XY = set(XY_list)
set_xy = set(xy_list)
print("No War" if set_XY in set_xy else "War")
|
s591601086
|
Accepted
| 17
| 3,064
| 507
|
N, M , X ,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
max_y = max(y)
min_y = min(y)
#print(max_x)
#print(max_y)
#print(Y-X)
XY_list = []
xy_list = []
for i in range(X+1, Y+1):
XY_list.append(i)
if max_x >= min_y:
print("War")
exit()
for i in range(max_x +1, min_y+1):
xy_list.append(i)
#print(XY_list)
#print(xy_list)
set_XY = set(XY_list)
set_xy = set(xy_list)
print("No War" if set_XY & set_xy else "War")
|
s426817798
|
p03385
|
u823044869
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 85
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
sSorted = sorted(input())
if sSorted =="abc":
print("Yes")
else:
print("No")
|
s614395794
|
Accepted
| 17
| 3,064
| 90
|
sSorted = sorted(input())
if ''.join(sSorted) =="abc":
print("Yes")
else:
print("No")
|
s677467697
|
p03407
|
u921830178
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
#96
A,B,C = map(int,input().split())
ans= ((A+B)>=C)
if ans:
print("YES")
else:
print("NO")
|
s415794440
|
Accepted
| 17
| 2,940
| 99
|
#96
A,B,C = map(int,input().split())
ans= ((A+B)>=C)
if ans:
print("Yes")
else:
print("No")
|
s207873112
|
p03151
|
u843135954
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 319
|
A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
i = input()
n = int(i)
a = list(map(int, i.split()))
b = list(map(int, i.split()))
if sum(a) < sum(b):
print(-1)
exit()
c = [x-y for x,y in zip(a,b)]
p = [i for i in c if i > 0]
m = [i for i in c if i < 0]
f = sum(m)
l = len(m)
for k in sorted(p, reverse=True):
if f >= 0:
break
f += k
l += 1
print(l)
|
s106760084
|
Accepted
| 108
| 18,356
| 325
|
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
print(-1)
exit()
c = [x-y for x,y in zip(a,b)]
p = [z for z in c if z > 0]
m = [z for z in c if z < 0]
f = sum(m)
l = len(m)
for k in sorted(p, reverse=True):
if f >= 0:
break
f += k
l += 1
print(l)
|
s779000607
|
p03474
|
u868418093
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 292
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a,b = list(map(int,input().split(" ")))
s = input()
postal_code_len = a+b+1
num_list = list(map(str, range(0,10)))
flag = True
print([c in num_list for c in list(s[:a]+s[a+1:]) ])
if s[a] == "-" and all([ c in num_list for c in list(s[:a]+s[a+1:]) ]):
print("Yes")
else:
print("No")
|
s053699154
|
Accepted
| 17
| 3,064
| 293
|
a,b = list(map(int,input().split(" ")))
s = input()
postal_code_len = a+b+1
num_list = list(map(str, range(0,10)))
flag = True
#print([c in num_list for c in list(s[:a]+s[a+1:]) ])
if s[a] == "-" and all([ c in num_list for c in list(s[:a]+s[a+1:]) ]):
print("Yes")
else:
print("No")
|
s430934378
|
p03737
|
u503901534
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 129
|
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())
aa = list(a)
bb = list(b)
cc = list(c)
abc = aa[0] + bb[0] + cc[0]
abc.capitalize()
print(abc)
|
s388812261
|
Accepted
| 17
| 2,940
| 135
|
a,b,c = map(str,input().split())
aa = list(a)
bb = list(b)
cc = list(c)
abc = aa[0] + bb[0] + cc[0]
abc.upper()
print(abc.upper())
|
s170682752
|
p03377
|
u354638986
| 2,000
| 262,144
|
Wrong Answer
| 96
| 2,940
| 116
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, x = map(int, input().split())
if a > x:
print("No")
elif b < x-a:
print("No")
else:
print("Yes")
|
s336841641
|
Accepted
| 17
| 2,940
| 116
|
a, b, x = map(int, input().split())
if a > x:
print("NO")
elif b < x-a:
print("NO")
else:
print("YES")
|
s205044846
|
p03129
|
u281610856
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 110
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
import math
n, k = map(int, input().split())
if math.ceil(n / 2) >= k:
print('Yes')
else:
print('No')
|
s509738024
|
Accepted
| 17
| 2,940
| 110
|
import math
n, k = map(int, input().split())
if math.ceil(n / 2) >= k:
print('YES')
else:
print('NO')
|
s777836282
|
p03502
|
u293579463
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 147
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
def f(X):
total = 0
while X > 0:
total += X % 10
X /= 10
return total
N = int(input())
if N / f(N) == 0:
print("Yes")
else:
print("No")
|
s487676447
|
Accepted
| 20
| 3,316
| 151
|
def f(X):
total = 0
while X > 0:
total += X % 10
X = X // 10
return total
N = int(input())
if N % f(N) == 0:
print("Yes")
else:
print("No")
|
s048260653
|
p03068
|
u483005329
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 138
|
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
n=int(input())
s=list(input())
k=int(input())
t=s[k-1]
print(t)
for i in range(len(s)):
if s[i]!=t:
s[i]="*"
print("".join(s))
|
s912542610
|
Accepted
| 17
| 2,940
| 118
|
n=int(input())
s=list(input())
k=int(input())
l=s[k-1]
for i in range(n):
if s[i]!=l:
s[i]="*"
print("".join(s))
|
s368743094
|
p02399
|
u510829608
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,636
| 59
|
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b = map(int, input().split())
print(a // b, a % b, a /b)
|
s759144260
|
Accepted
| 30
| 7,636
| 85
|
a,b = map(int, input().split())
print('{0} {1} {2:.5f}'.format(a // b, a % b, a / b))
|
s826021665
|
p03474
|
u388904130
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,444
| 234
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
import copy
a,b = map(int, input().split())
s = list(input())
tmp = copy.copy(s)
tmp.pop(a)
if 1 <= a and b <= 5 and a + b + 1 == len(s) and s[a] == '-' and 'tmp'.join(tmp).isnumeric():
print('yes')
else:
print('No')
|
s872145629
|
Accepted
| 17
| 2,940
| 116
|
a,b = map(int, input().split())
s = input()
print('Yes' if s[a] == '-' and (s[:a] + s[a + 1:]).isdigit() else 'No')
|
s254346135
|
p02419
|
u130834228
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,364
| 221
|
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
|
W = input()
print(W)
t=0
while(1):
char_list = list(x for x in input().split())
print(char_list)
if char_list[0] == 'END_OF_TEXT':
break
for i in range(len(char_list)):
if W == char_list[i]:
t += 1
print(t)
|
s682674254
|
Accepted
| 30
| 7,384
| 239
|
W = input().lower()
#print(W)
t=0
while(1):
char_list = list(x for x in input().split())
#print(char_list)
if char_list[0] == 'END_OF_TEXT':
break
for i in range(len(char_list)):
if W == char_list[i].lower():
t += 1
print(t)
|
s360946229
|
p03338
|
u781262926
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 98
|
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
n = int(input())
S = input().strip()
print(max(len(set(S[i+1:]) & set(S[:i])) for i in range(n)))
|
s845301409
|
Accepted
| 18
| 2,940
| 101
|
n = int(input())
S = input().strip()
print(max(len(set(S[:i+1]) & set(S[i+1:])) for i in range(n-1)))
|
s884013294
|
p03737
|
u614181788
| 2,000
| 262,144
|
Wrong Answer
| 27
| 8,996
| 65
|
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
s = list(map(str,input().split()))
print(s[0][0]+s[1][0]+s[2][0])
|
s916205773
|
Accepted
| 28
| 9,088
| 75
|
s = list(map(str,input().split()))
print((s[0][0]+s[1][0]+s[2][0]).upper())
|
s004636063
|
p03417
|
u591295155
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 188
|
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
|
N, M = map(int, input().split())
if N == 1 and M == 1:
print(1)
elif N == 1 and M > 1:
print(M-2)
elif M == 1 and N > 1:
print(N-2)
elif N > 1 and M > 2:
print((N-2)*(M-2))
|
s047731773
|
Accepted
| 17
| 2,940
| 53
|
N,M= map(int,input().split())
print(abs((N-2)*(M-2)))
|
s538097432
|
p03573
|
u347600233
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
abc = [int(i) for i in input().split()]
if abc[0] == abc[1]:
print(abc[0])
else:
print((set(abc[:2]) & set([abc[2]])).pop())
|
s162868773
|
Accepted
| 18
| 3,188
| 149
|
abc = [int(i) for i in input().split()]
if abc[0] == abc[1]:
print(abc[2])
else:
print((set(abc[:2]) - (set(abc[:2]) & set([abc[2]]))).pop())
|
s733428506
|
p03852
|
u339922532
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 78
|
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`.
|
c = input()
print("voewl" if c in ["a", "b", "c", "d", "e"] else "consonant")
|
s992120563
|
Accepted
| 17
| 2,940
| 78
|
c = input()
print("vowel" if c in ["a", "i", "u", "e", "o"] else "consonant")
|
s617094843
|
p03486
|
u732870425
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 134
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = list(input())
t = list(input())
ss = "".join(sorted(s))
tt = "".join(sorted(t))
if ss<tt:
print("Yes")
else:
print("No")
|
s467506014
|
Accepted
| 19
| 3,060
| 148
|
s = list(input())
t = list(input())
ss = "".join(sorted(s))
tt = "".join(sorted(t, reverse=True))
if ss<tt:
print("Yes")
else:
print("No")
|
s567322278
|
p03679
|
u604412462
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 159
|
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
xab = list(map(int, input().split()))
if xab[2] <= xab[1]:
print('delicious')
elif xab[1] < xab[2] <= xab[0]:
print('safe')
else:
print('dangerou')
|
s277576080
|
Accepted
| 18
| 3,060
| 167
|
xab = list(map(int, input().split()))
if xab[2] <= xab[1]:
print('delicious')
elif xab[1] < xab[2] <= xab[0]+xab[1]:
print('safe')
else:
print('dangerous')
|
s363839785
|
p04011
|
u102960641
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 100
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(n,k)*x + min(n-k,0)*y)
|
s059568409
|
Accepted
| 17
| 2,940
| 101
|
n = int(input())
k = int(input())
x = int(input())
y = int(input())
print(min(n,k)*x + max(n-k,0)*y)
|
s415075613
|
p03861
|
u339199690
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
if x == a:
print((b - a + 1) // x + 1)
else:
print((b - a + 1) // x)
|
s797635470
|
Accepted
| 17
| 2,940
| 61
|
a, b, x = map(int, input().split())
print(b//x - (a - 1)//x)
|
s360591564
|
p03417
|
u619458041
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 169
|
There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following operation once for each square contains a card: * For each of the following nine squares, flip the card in it if it exists: the target square itself and the eight squares that shares a corner or a side with the target square. It can be proved that, whether each card faces up or down after all the operations does not depend on the order the operations are performed. Find the number of cards that face down after all the operations.
|
import sys
def main():
input = sys.stdin.readline
N, M = map(int, input().split())
print(max(1, N-2) * max(1, M-2))
if __name__ == '__main__':
main()
|
s867422970
|
Accepted
| 17
| 2,940
| 225
|
import sys
def main():
input = sys.stdin.readline
N, M = map(int, input().split())
if N == 2 or M == 2:
print(0)
else:
print(max(1, N-2) * max(1, M-2))
if __name__ == '__main__':
main()
|
s198711302
|
p03110
|
u820052258
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 197
|
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n = int(input())
s=0
for i in range(n):
x,u=map(str,input().split())
if u == "JPY":
s+=int(x)
elif u == "BTC":
s+=380000*float(x)
else:
s+=0
print(int(s))
|
s369810547
|
Accepted
| 17
| 2,940
| 192
|
n = int(input())
s=0
for i in range(n):
x,u=map(str,input().split())
if u == "JPY":
s+=int(x)
elif u == "BTC":
s+=380000*float(x)
else:
s+=0
print(s)
|
s488128775
|
p03719
|
u325206354
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 116
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
# -*- coding: utf-8 -*-
a,b,c = list(map(int,input().split()))
if a < b < c:
print("Yes")
else:
print("No")
|
s334460776
|
Accepted
| 17
| 2,940
| 92
|
a,b,c=map(int,input().split())
if a<=c and b>=c:
print("Yes")
else:
print("No")
|
s338424070
|
p03433
|
u051751608
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n, a = [int(input(i)) for i in range(2)]
if n % 500 <= a:
print('Yes')
else:
print('No')
|
s304420453
|
Accepted
| 17
| 2,940
| 90
|
n = int(input())
a = int(input())
if n % 500 <= a:
print('Yes')
else:
print('No')
|
s204251085
|
p02615
|
u655663334
| 2,000
| 1,048,576
|
Wrong Answer
| 196
| 32,516
| 306
|
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
import collections
N = int(input())
As = list(map(int, input().split()))
As.sort(reverse = True)
print(As)
circle_que = collections.deque()
circle_que.append(As[0])
ans = 0
for A in As[1:]:
circle_que.append(A)
circle_que.append(A)
ans += circle_que.popleft()
#print(ans)
print(ans)
|
s447051206
|
Accepted
| 171
| 32,352
| 307
|
import collections
N = int(input())
As = list(map(int, input().split()))
As.sort(reverse = True)
#print(As)
circle_que = collections.deque()
circle_que.append(As[0])
ans = 0
for A in As[1:]:
circle_que.append(A)
circle_que.append(A)
ans += circle_que.popleft()
#print(ans)
print(ans)
|
s902191655
|
p02602
|
u771089154
| 2,000
| 1,048,576
|
Wrong Answer
| 273
| 31,824
| 340
|
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n,k= map(int, input().split())
lst = []
lst2 = []
sum=0
j=0
lst = [int(item) for item in input().split()]
for i in range(n):
if i==0:
while i<k-1:
sum=sum+lst[i]
i=i+1
else:
sum=sum-lst[j]
sum=sum+lst[i]
j=j+1
lst2.append(sum)
x=len(lst2)
for i in range(1,x):
if lst2[i]>lst2[i-1]:
print("Yes")
else:
print("No")
|
s992892367
|
Accepted
| 240
| 31,568
| 343
|
n,k= map(int, input().split())
lst = []
lst2 = []
sum=0
j=0
lst = [int(item) for item in input().split()]
i=0
while i<n:
if i==0:
while i<k-1:
sum=sum+lst[i]
i=i+1
else:
sum=sum-lst[j]
sum=sum+lst[i]
j=j+1
lst2.append(sum)
i=i+1
x=len(lst2)
for i in range(1,x):
if lst2[i]>lst2[i-1]:
print("Yes")
else:
print("No")
|
s452166696
|
p03565
|
u858523893
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 517
|
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
S = input()
T = input()
search_str = ["?" for x in range(len(T))]
last_occ = -1
for i in range(len(S)) :
if i < len(S) - len(T) + 1:
ok_cnt = 0
for j in range(len(T)) :
if S[i + j] == T[j] or S[i + j] == "?" :
ok_cnt += 1
if ok_cnt == len(T) :
print("HOGE")
last_occ = i
if last_occ != -1 :
str_tmp = S[0:last_occ] + T + S[last_occ + len(T):]
print(str_tmp.replace("?", "a"))
else :
print("UNRESTORABLE")
|
s674614508
|
Accepted
| 17
| 3,064
| 491
|
S = input()
T = input()
search_str = ["?" for x in range(len(T))]
last_occ = -1
for i in range(len(S)) :
if i < len(S) - len(T) + 1:
ok_cnt = 0
for j in range(len(T)) :
if S[i + j] == T[j] or S[i + j] == "?" :
ok_cnt += 1
if ok_cnt == len(T) :
last_occ = i
if last_occ != -1 :
str_tmp = S[0:last_occ] + T + S[last_occ + len(T):]
print(str_tmp.replace("?", "a"))
else :
print("UNRESTORABLE")
|
s141397060
|
p03502
|
u061732150
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 193
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
def main():
N = int(input())
f = 0
for n in str(N):
f += int(n)
if f%N == 0:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
s469756288
|
Accepted
| 17
| 2,940
| 193
|
def main():
N = int(input())
f = 0
for n in str(N):
f += int(n)
if N%f == 0:
print("Yes")
else:
print("No")
if __name__ == '__main__':
main()
|
s391462517
|
p03415
|
u865191802
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 116
|
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.
|
data = [[i for i in input().split()] for i in range(3)]
num = 0
for i in data:
for j in i:
print(j[num])
num+=1
|
s766368101
|
Accepted
| 18
| 2,940
| 144
|
data = [[i for i in input().split()] for i in range(3)]
num = 0
answer = ""
for i in data:
for j in i:
answer+=j[num]
num+=1
print(answer)
|
s392928565
|
p00015
|
u364509382
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,648
| 79
|
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
|
n = int(input())
for i in range(n):
a=int(input())
b=int(input())
print(a+b)
|
s567307563
|
Accepted
| 20
| 7,636
| 124
|
n = int(input())
for i in range(n):
s = int(input())+int(input())
if len(str(s))>80:
print("overflow")
else:
print(s)
|
s682777517
|
p03023
|
u336721073
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 31
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
N=int(input())
print((N-2)*360)
|
s748089493
|
Accepted
| 17
| 2,940
| 31
|
N=int(input())
print((N-2)*180)
|
s669224910
|
p04011
|
u243572357
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 70
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n, k, x, y = [int(input()) for i in range(4)]
if n < k:
print(n * x)
|
s659350763
|
Accepted
| 17
| 2,940
| 102
|
n, k, x, y = [int(input()) for i in range(4)]
if n >= k:
print(k*x + (n-k) * y)
else:
print(n * x)
|
s963223087
|
p03433
|
u062189367
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 100
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
if N % 500 < A:
print('YES')
else:
print('NO')
|
s694634914
|
Accepted
| 17
| 2,940
| 93
|
N = int(input())
A = int(input())
if N % 500 <= A:
print('Yes')
else:
print('No')
|
s236484855
|
p03730
|
u136395536
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 126
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
A,B,C = (int(i) for i in input().split())
test = (B*C)/A
if test == int(test):
print("YES")
else:
print("NO")
|
s762952999
|
Accepted
| 17
| 2,940
| 183
|
A,B,C = (int(i) for i in input().split())
dividable = False
for i in range(B):
if A*(i+1) % B == C:
dividable = True
if dividable:
print("YES")
else:
print("NO")
|
s593180184
|
p03068
|
u825115925
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 149
|
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
N=int(input())
A=input()
x=int(input())
for i in range(N):
if A[i]!=A[x-1]:
print(A[i])
A=A.replace(A[i],"*")
print(A)
|
s821176548
|
Accepted
| 17
| 2,940
| 129
|
N=int(input())
A=input()
x=int(input())
for i in range(N):
if A[i]!=A[x-1]:
A=A.replace(A[i],"*")
print(A)
|
s321193406
|
p02392
|
u810591206
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,488
| 89
|
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
a, b, c = map(int, input().split())
if a < b < c:
print('YES')
else:
print('NO')
|
s322034671
|
Accepted
| 20
| 7,496
| 89
|
a, b, c = map(int, input().split())
if a < b < c:
print('Yes')
else:
print('No')
|
s332809862
|
p02616
|
u580273604
| 2,000
| 1,048,576
|
Wrong Answer
| 2,211
| 33,248
| 402
|
Given are N integers A_1,\ldots,A_N. We will choose exactly K of these elements. Find the maximum possible product of the chosen elements. Then, print the maximum product modulo (10^9+7), using an integer between 0 and 10^9+6 (inclusive).
|
N,K=map(int, input().split())
A=list(map(int,input().split()))
A=sorted(A)
print('A:',A)
B=sorted(A, key=lambda x: abs(x), reverse=True)
print('B:',B)
ABSmax=1
ABSmin=1
for i in range(K):
ABSmax=ABSmax*B[i]
ABSmin=ABSmin*B[-1-i]
print(ABSmax,ABSmin)
C=1
for i in range(K-1):
C=C*B[0]
del B[0]
BB=sorted(B)
if C<0:C=C*BB[0]
else:C=C*BB[-1]
print(BB)
print(max(ABSmax,ABSmin,C)%(10**9+7))
|
s956692729
|
Accepted
| 795
| 65,864
| 1,163
|
import numpy as np
N,K=map(int, input().split())
A =list(map(int,input().split()))
MOD = 10 ** 9 + 7
if N==K:
ans0 = 1
for a in A:
ans0 = ans0*a%MOD
print(ans0)
exit()
A=sorted(A)
if (K%2==1 and A[-1]<0):
ans1 = 1
for a in A[N-K:N]:
ans1 = ans1*a%MOD
print(ans1)
exit()
A=sorted(A, key=lambda x:abs(x), reverse=True)
AA=[np.sign(i) for i in A]
ansA = 1
for a in A[0:K]:
ansA = ansA*a%MOD
ansAA = AA[0:K].count(-1)%2
if ansA==0 or ansAA==0:
print(ansA)
exit()
B1=A[0:K]
C1=A[0:K]
B2=sorted(A[K:N])
Bp=[i for i in A[0:K] if i>0]
Bm=[i for i in A[0:K] if i<0]
if B2[0]>0:B2.insert(0,0)
if B2[-1]<0:B2.insert(-1,0)
if not Bp:Bp.insert(0,B1[-1])
if not Bm:Bm.insert(0,B1[0])
B1.remove(Bp[-1])
B1.append(min(B2[0],0))
ansB = 1
for a in B1[0:K]:
ansB = ansB*a%MOD
C1.remove(Bm[-1])
C1.append(max(B2[-1],0))
ansC = 1
for a in C1[0:K]:
ansC = ansC*a%MOD
BB1=[np.sign(i) for i in B1]
ansBB1 = BB1[0:K].count(-1)%2
BB2=[np.sign(i) for i in C1]
ansBB2 = BB2[0:K].count(-1)%2
if ansBB1==1:
print(ansC)
exit()
if ansBB2==1:
print(ansB)
exit()
if abs(Bp[-1]*B2[-1])-abs(Bm[-1]*B2[0])>=0:
print(ansC)
else: print(ansB)
|
s360610654
|
p03795
|
u288948615
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 43
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
N = int(input())
print(800*N - 200* 15//N)
|
s969122078
|
Accepted
| 17
| 2,940
| 45
|
N = int(input())
print(800*N - 200* (N//15))
|
s197461680
|
p03548
|
u294385082
| 2,000
| 262,144
|
Wrong Answer
| 32
| 2,940
| 151
|
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
|
x,y,z = map(int,input().split())
count = 0
t = 0
for i in range(10**6):
t += y
if t<=x:
count += 1
else:
exit()
t += z
print(count)
|
s584891821
|
Accepted
| 39
| 3,064
| 161
|
x,y,z = map(int,input().split())
s = z
count = 0
for i in range(10**99):
s += y
if s <= x-z:
count += 1
elif s> x-z:
break
s+= z
print(count)
|
s774976681
|
p03545
|
u190406011
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 768
|
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.
|
abcd = input()
def train_ticket(flg,sum,op):
if flg == 0:
if train_ticket(flg + 1, sum, op + "+"):
return True
elif train_ticket(flg + 1, sum, op + "-"):
return True
if flg >= len(abcd):
if operation(sum, op[-1], flg) == 7:
print("".join([abcd[i] + op[i+1] for i in range(len(op) - 1)]) + abcd[-1])
return True
else:
return False
if train_ticket(flg + 1, operation(sum, op[-1], flg), op+"+"):
return True
elif train_ticket(flg + 1, operation(sum, op[-1], flg), op+"-"):
return True
def operation(sum, op, flg):
if op == "+":
return sum + int(abcd[flg - 1])
else:
return sum - int(abcd[flg - 1])
train_ticket(0, 0, "")
|
s167110086
|
Accepted
| 17
| 3,064
| 775
|
abcd = input()
def train_ticket(flg,sum,op):
if flg == 0:
if train_ticket(flg + 1, sum, op + "+"):
return True
elif train_ticket(flg + 1, sum, op + "-"):
return True
if flg >= len(abcd):
if operation(sum, op[-1], flg) == 7:
print("".join([abcd[i] + op[i+1] for i in range(len(op) - 1)]) + abcd[-1] + "=7")
return True
else:
return False
if train_ticket(flg + 1, operation(sum, op[-1], flg), op+"+"):
return True
elif train_ticket(flg + 1, operation(sum, op[-1], flg), op+"-"):
return True
def operation(sum, op, flg):
if op == "+":
return sum + int(abcd[flg - 1])
else:
return sum - int(abcd[flg - 1])
train_ticket(0, 0, "")
|
s282388728
|
p03544
|
u934868410
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 83
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n = int(input())
x = 2
ans = 1
for i in range(n-1):
ans += x
x = ans
print(ans)
|
s750848415
|
Accepted
| 17
| 2,940
| 95
|
n = int(input())
x = 2
ans = 1
for i in range(n-1):
tmp = ans
ans += x
x = tmp
print(ans)
|
s915445819
|
p03944
|
u039623862
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 301
|
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
w,h,n = map(int, input().split())
x_min = 0
x_max = w
y_min = 0
y_max = h
for i in range(n):
x,y,a = map(int, input().split())
if a == 1:
x_max = x
elif a == 2:
x_min = x
elif a == 3:
y_max = y
else:
y_min = y
print((y_max-y_min) * (x_max-x_min))
|
s192423851
|
Accepted
| 17
| 3,064
| 369
|
w, h, n = map(int, input().split())
x_min = 0
x_max = w
y_min = 0
y_max = h
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
x_min = max(x, x_min)
elif a == 2:
x_max = min(x, x_max)
elif a == 3:
y_min = max(y, y_min)
else:
y_max = min(y, y_max)
print(max(y_max - y_min, 0) * max(x_max - x_min, 0))
|
s230176163
|
p03485
|
u791527495
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 88
|
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.
|
li = list(map(int,input().split()))
heikin = (li[0] + li[1] ) / 2
print(int(heikin + 1))
|
s009000648
|
Accepted
| 17
| 2,940
| 55
|
a,b = map(int,input().split())
print((a + b + 1) // 2 )
|
s490193737
|
p04044
|
u746849814
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 84
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n, l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
''.join(s)
|
s593252058
|
Accepted
| 17
| 3,060
| 91
|
n, l = map(int, input().split())
s = [input() for _ in range(n)]
s.sort()
print(''.join(s))
|
s088328286
|
p02380
|
u350064373
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,612
| 288
|
For given two sides of a triangle _a_ and _b_ and the angle _C_ between them, calculate the following properties: * S: Area of the triangle * L: The length of the circumference of the triangle * h: The height of the triangle with side a as a bottom edge
|
import math
a, b, C = map(int, input().split())
sin = math.sin(C)
cos = math.cos(C)
S =(a*b*sin) / 2
L = math.sqrt((a**2) + (b**2) - (2*a*b*cos))
#L**2 = (a**2) + (b**2) - (2*a*b*cos)
h = (a*b*sin/2)/(a/2)
print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))
|
s293640232
|
Accepted
| 30
| 7,836
| 310
|
import math
a, b, C = map(int, input().split())
C2 = math.radians(C)
sin = math.sin(C2)
cos = math.cos(C2)
c = math.sqrt(a**2 + b**2 - 2*a*b*cos)
S =(a*b*sin) / 2
L = a+b+c
#L**2 = a**2 + b**2 - 2*a*b*cos
h = (a*b*sin/2)/(a/2)
print("{0:.8f}".format(S))
print("{0:.8f}".format(L))
print("{0:.8f}".format(h))
|
s120830162
|
p03370
|
u994988729
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
|
n,x=map(int,input().split())
m=[]
for _ in range(n):
m.append(int(input()))
m.sort()
ans=n+(x-sum(m))//x
print(ans)
|
s114861544
|
Accepted
| 17
| 2,940
| 120
|
n,x=map(int,input().split())
m=[]
for _ in range(n):
m.append(int(input()))
m.sort()
ans=n+(x-sum(m))//m[0]
print(ans)
|
s804306788
|
p03131
|
u600402037
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 338
|
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())
answer = 1
if B - A <= 2:
answer += K
else:
time = A - 1
if time + 2 > K or B - A < 2:
answer += K
else:
answer += time
q, mod = divmod(K-time, 2)
answer += q
answer += mod
print(answer)
|
s020037227
|
Accepted
| 17
| 3,060
| 346
|
K, A, B = map(int, input().split())
answer = 1
if B - A <= 2:
answer += K
else:
time = A - 1
if time + 2 > K or B - A < 2:
answer += K
else:
answer += time
q, mod = divmod(K-time, 2)
answer += q * (B-A)
answer += mod
print(answer)
|
s191648689
|
p00048
|
u567380442
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,748
| 616
|
ボクシングは体重によって階級が分けられています。体重を読み込んで、その階級を出力するプログラムを作成してください。階級と体重の関係は以下の表のとおりとします。 階級| 体重(kg) ---|--- light fly| 48.00kg 以下 fly| 48.00kg 超 51.00kg 以下 bantam| 51.00kg 超 54.00kg 以下 feather| 54.00kg 超 57.00kg 以下 light| 57.00kg 超 60.00kg 以下 light welter| 60.00kg 超 64.00kg 以下 welter| 64.00kg 超 69.00 kg 以下 light middle| 69.00kg 超 75.00 kg 以下 middle| 75.00kg 超 81.00 kg 以下 light heavy| 81.00kg 超 91.00 kg 以下 heavy| 91.00kg 超
|
import sys
f = sys.stdin
classes = {'light fly':(00.00, 48.00),
'fly':(48.00, 51.00),
'bantam':(51.00, 54.00),
'feather':(54.00,57.00),
'light':(57.00,60.00),
'light welter':(60.00,64.00),
'welter':(64.00,69.00),
'light middle':(69.00,75.00),
'middle':(75.00,81.00),
'light heavy':(81.00,91.00),
'heavy':(91.00,1000.00)}
for line in f:
weight = float(line)
for class_name, weights in classes.items():
if weights[0] <= weight < weights[1]:
print(class_name)
break
|
s686116137
|
Accepted
| 30
| 6,748
| 615
|
import sys
f = sys.stdin
classes = {'light fly':(00.00, 48.00),
'fly':(48.00, 51.00),
'bantam':(51.00, 54.00),
'feather':(54.00,57.00),
'light':(57.00,60.00),
'light welter':(60.00,64.00),
'welter':(64.00,69.00),
'light middle':(69.00,75.00),
'middle':(75.00,81.00),
'light heavy':(81.00,91.00),
'heavy':(91.00,1000.00)}
for line in f:
weight = float(line)
for class_name, weights in classes.items():
if weights[0] < weight <= weights[1]:
print(class_name)
break
|
s779584327
|
p00773
|
u089116225
| 8,000
| 131,072
|
Wrong Answer
| 210
| 5,612
| 741
|
VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price. Our store uses the following rules to calculate the after-tax prices. * When the VAT rate is _x_ %, for an item with the before-tax price of _p_ yen, its after-tax price of the item is _p_ (100+ _x_ ) / 100 yen, fractions rounded off. * The total after-tax price of multiple items paid at once is the sum of after-tax prices of the items. The VAT rate is changed quite often. Our accountant has become aware that "different pairs of items that had the same total after-tax price may have different total after-tax prices after VAT rate changes." For example, when the VAT rate rises from 5% to 8%, a pair of items that had the total after-tax prices of 105 yen before can now have after-tax prices either of 107, 108, or 109 yen, as shown in the table below. Before-tax prices of two items| After-tax price with 5% VAT| After-tax price with 8% VAT ---|---|--- 20, 80| 21 + 84 = 105| 21 + 86 = 107 2, 99| 2 + 103 = 105| 2 + 106 = 108 13, 88| 13 + 92 = 105| 14 + 95 = 109 Our accountant is examining effects of VAT-rate changes on after-tax prices. You are asked to write a program that calculates the possible maximum total after-tax price of two items with the new VAT rate, knowing their total after- tax price before the VAT rate change.
|
def change(before_tax,after_tax,previous_price):
#change z from taxrate x to taxrate y
tmp_original_price = previous_price * 100 / (100 + before_tax)
if tmp_original_price % 1 == 0:
original_price = tmp_original_price
else:
original_price = tmp_original_price // 1 + 1
return int(original_price * (100 + after_tax) // 100)
while True:
x,y,s = [int(x) for x in input().split()]
if x == 0:
break
else:
ans = 0
for i in range(1,int(s//2)+2):
price1, price2 = i, s - i
afterprice = change(x,y,price1) + change(x,y,price2)
if afterprice > ans:
ans = afterprice
else:
pass
print(ans)
|
s672821513
|
Accepted
| 6,970
| 5,640
| 738
|
def change(before_tax,after_tax,previous_price):
original_price = 0
for i in range(1, previous_price+1):
if i * (100 + before_tax) // 100 == previous_price:
original_price = i
break
else:
pass
return original_price * (100 + after_tax) // 100
ans_list = []
while True:
x,y,s = [int(x) for x in input().split()]
if x == 0:
break
else:
ans = 0
for i in range(1,s):
price1, price2 = i, s - i
afterprice = change(x,y,price1) + change(x,y,price2)
if afterprice > ans:
ans = afterprice
else:
continue
ans_list.append(ans)
for x in ans_list:
print(x)
|
s610518239
|
p03796
|
u946386741
| 2,000
| 262,144
|
Wrong Answer
| 41
| 2,940
| 107
|
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())
result = 1
for i in range(1,n):
result *= i
result %= (10**9 + 7)
print(result)
|
s691208706
|
Accepted
| 34
| 2,940
| 110
|
n = int(input())
result = 1
for i in range(1, n+1):
result = (i * result) % (10 ** 9 + 7)
print(result)
|
s427155805
|
p03836
|
u745514010
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,180
| 1,009
|
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())
dx = tx - sx
dy = ty - sy
if dx == 0:
if dy > 0:
d1 = "U"
d2 = "D"
else:
d1 = "D"
d2 = "U"
dy = abs(dy)
ans = d1 * dy
ans += "R" + d2 * dy + "L"
ans += "L" + d1 * dy + "R"
ans += d1 + "RR" + d2 * (dy + 2) + "LL" + d1
print(ans)
elif dy == 0:
if dx > 0:
d1 = "R"
d2 = "L"
else:
d1 = "L"
d2 = "R"
dx = abs(dx)
ans = d1 * dx
ans += "U" + d2 * dx + "D"
ans += "D" + d1 * dx + "U"
ans += d1 + "UU" + d2 * (dx + 2) + "DD" + d1
print(ans)
else:
if dy > 0:
d1 = "U"
d2 = "D"
else:
d1 = "D"
d2 = "U"
if dx > 0:
d3 = "R"
d4 = "L"
else:
d3 = "L"
d4 = "R"
dx = abs(dx)
dy = abs(dy)
ans = d1 * dy + d3 * dx
ans += d4 * dx + d2 * dy
ans += d4 + d1 * (dy + 1) + d3 * (dx + 1) + d2
ans += d1 + d4 * (dx + 1) + d2 * (dy + 1) + d3
print(ans)
|
s691003581
|
Accepted
| 25
| 9,204
| 1,009
|
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
if dx == 0:
if dy > 0:
d1 = "U"
d2 = "D"
else:
d1 = "D"
d2 = "U"
dy = abs(dy)
ans = d1 * dy
ans += "R" + d2 * dy + "L"
ans += "L" + d1 * dy + "R"
ans += d1 + "RR" + d2 * (dy + 2) + "LL" + d1
print(ans)
elif dy == 0:
if dx > 0:
d1 = "R"
d2 = "L"
else:
d1 = "L"
d2 = "R"
dx = abs(dx)
ans = d1 * dx
ans += "U" + d2 * dx + "D"
ans += "D" + d1 * dx + "U"
ans += d1 + "UU" + d2 * (dx + 2) + "DD" + d1
print(ans)
else:
if dy > 0:
d1 = "U"
d2 = "D"
else:
d1 = "D"
d2 = "U"
if dx > 0:
d3 = "R"
d4 = "L"
else:
d3 = "L"
d4 = "R"
dx = abs(dx)
dy = abs(dy)
ans = d1 * dy + d3 * dx
ans += d2 * dy + d4 * dx
ans += d4 + d1 * (dy + 1) + d3 * (dx + 1) + d2
ans += d3 + d2 * (dy + 1) + d4 * (dx + 1) + d1
print(ans)
|
s718331598
|
p03478
|
u324975917
| 2,000
| 262,144
|
Wrong Answer
| 35
| 3,060
| 196
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n, a, b = map(int, input().split())
for i in range(1,n):
n1 = 0
s = str(n)
array = list(map(int, s))
s1 = sum(array)
if a <= n1 <= b:
n1 = n1+s1
print(n1)
|
s880737272
|
Accepted
| 35
| 3,060
| 197
|
n, a, b = map(int, input().split())
n1 = 0
for i in range(1,n+1):
s = str(i)
array = list(map(int, s))
s1 = sum(array)
if a <= s1 <= b:
n1 = n1+i
print(n1)
|
s861427410
|
p03712
|
u408791346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 203
|
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
h,w = map(int, input().split())
n = list(input() for _ in range(h))
tb = '#'*(w+2)
for i in range(h):
n[i] = '#'+n[i]+'#'
else:
n.insert(0, tb)
n.append(tb)
print(n[g] for g in range(h+2))
|
s940686521
|
Accepted
| 17
| 3,060
| 208
|
h,w = map(int, input().split())
n = list(input() for _ in range(h))
tb = '#'*(w+2)
for i in range(h):
n[i] = '#'+n[i]+'#'
else:
n.insert(0, tb)
n.append(tb)
for g in range(h+2):
print(n[g])
|
s855048271
|
p03737
|
u480138356
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 76
|
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 = input().split()
for s in a:
print(chr(ord(s[0]) + ord("A") -ord("a")))
|
s378019215
|
Accepted
| 17
| 2,940
| 92
|
a = input().split()
for s in a:
print(chr(ord(s[0]) + ord("A") -ord("a")), end="")
print()
|
s035486429
|
p03609
|
u988402778
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 19
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
print(input()[::2])
|
s882877074
|
Accepted
| 21
| 3,192
| 53
|
a,b=map(int,input().split())
x = max(a-b,0)
print (x)
|
s427734876
|
p03544
|
u201660334
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 147
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n = int(input())
l = [2, 1]
if n == 1:
print(2)
elif n == 2:
print(1)
else:
for i in range(n - 2):
l.append(l[-1] + l[-2])
print(l[-1])
|
s945371799
|
Accepted
| 17
| 2,940
| 124
|
n = int(input())
l = [2, 1]
if n == 1:
print(1)
else:
for i in range(n - 1):
l.append(l[-1] + l[-2])
print(l[-1])
|
s334847912
|
p03049
|
u172035535
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 3,700
| 371
|
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
|
import sys
input = sys.stdin.readline
S = [input() for _ in range(int(input()))]
AB = 0
end_A = 0
start_B = 0
sB_eA = 0
for s in S:
AB += s.count('AB')
if s[0] == 'B' and s[-1] == 'A':
sB_eA += 1
elif s[0] == 'B':
start_B += 1
elif s[-1] == 'A':
end_A += 1
amari = abs(start_B-end_A)
print(AB+min(start_B,end_A)+min(amari,sB_eA))
|
s690556046
|
Accepted
| 34
| 3,700
| 382
|
S = [input() for _ in range(int(input()))]
end_A = 0
start_B = 0
sB_eA = 0
ans = 0
for s in S:
ans += s.count('AB')
if s[0] == 'B' and s[-1] == 'A':
sB_eA += 1
elif s[0] == 'B':
start_B += 1
elif s[-1] == 'A':
end_A += 1
ans += min(start_B,end_A)
if start_B == 0 and end_A == 0:
ans += max(0,sB_eA-1)
else:
ans += sB_eA
print(ans)
|
s832933457
|
p04044
|
u867848444
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 95
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,l=map(int,input().split())
s=sorted([input() for i in range(n)])
s_1=''.join(s)
print('s_1')
|
s337854840
|
Accepted
| 17
| 3,060
| 88
|
n,l=map(int,input().split())
s=[input() for i in range(n)]
s=sorted(s)
print(*s,sep='')
|
s951020244
|
p03447
|
u014322942
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 304
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x = int(input("いくら持ってる?"))
a = int(input("ケーキは1個いくら?"))
b = int(input("ドーナッツは1個いくら?"))
#print(x,a,b)
x -= a
x = x%b
print(x)
|
s534206537
|
Accepted
| 17
| 2,940
| 212
|
x = int(input())
a = int(input())
b = int(input())
#print(x,a,b)
x -= a
x = x%b
print(x)
|
s373555860
|
p02237
|
u912143677
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 263
|
There are two standard ways to represent a graph $G = (V, E)$, where $V$ is a set of vertices and $E$ is a set of edges; Adjacency list representation and Adjacency matrix representation. An adjacency-list representation consists of an array $Adj[|V|]$ of $|V|$ lists, one for each vertex in $V$. For each $u \in V$, the adjacency list $Adj[u]$ contains all vertices $v$ such that there is an edge $(u, v) \in E$. That is, $Adj[u]$ consists of all vertices adjacent to $u$ in $G$. An adjacency-matrix representation consists of $|V| \times |V|$ matrix $A = a_{ij}$ such that $a_{ij} = 1$ if $(i, j) \in E$, $a_{ij} = 0$ otherwise. Write a program which reads a directed graph $G$ represented by the adjacency list, and prints its adjacency-matrix representation. $G$ consists of $n\; (=|V|)$ vertices identified by their IDs $1, 2,.., n$ respectively.
|
n = int(input())
g = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
a = list(map(int, input().split()))
for j in range(a[1]):
g[a[0] - 1][a[j + 2] - 1] = 1
g[a[j + 2] - 1][a[0] - 1] = 1
for i in range(n):
print(*g[i])
|
s666219413
|
Accepted
| 20
| 6,392
| 225
|
n = int(input())
g = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
a = list(map(int, input().split()))
for j in range(a[1]):
g[a[0] - 1][a[j + 2] - 1] = 1
for i in range(n):
print(*g[i])
|
s477291101
|
p02972
|
u392319141
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 6,488
| 213
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
N = int(input())
A = list(map(int, input().split()))
ball = [0] * N
ball[-1] = A[-1]
for i in range(N-2, -1, -1) :
bit = A[i]
for j in range(i, N) :
bit ^= ball[i]
ball[i] = bit
print(*ball)
|
s883274228
|
Accepted
| 577
| 13,112
| 314
|
N = int(input())
A = list(map(int, input().split()))
ans = [0] * N
for i in range(N)[:: -1]:
a = A[i]
cnt = 0
for j in range(i, N, (i + 1)):
cnt += ans[j]
if cnt % 2 != a % 2:
ans[i] = 1
M = sum(ans)
print(M)
if M > 0:
print(*[i for i, a in enumerate(ans, start=1) if a > 0])
|
s725908666
|
p02663
|
u773081031
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,168
| 127
|
In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?
|
h1, m1, h2, m2, k = map(int, input().split())
h = h2 - h1
if m1>m2:
h-=1
m = m2 - m1 + 60
else:
m = m2 - m1
l = h*60 + m - k
|
s681513019
|
Accepted
| 29
| 9,164
| 136
|
h1, m1, h2, m2, k = map(int, input().split())
h = h2 - h1
if m1>m2:
h-=1
m = m2 - m1 + 60
else:
m = m2 - m1
l = h*60 + m - k
print(l)
|
s926563035
|
p03543
|
u374974389
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 560
|
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**?
|
num = list(input())
ans = 7
for i in range(2 ** len(num)):
total = 0
ans_num = []
ans_op = []
for j in range(len(num)):
if((i >> j) & 1):
ans_num.append(num[j])
if(j >= 1):
ans_op.append('+')
total += int(num[j])
else:
ans_num.append(num[j])
if (j >= 1):
ans_op.append('-')
total -= int(num[j])
if(total == ans):
print(ans_num[0]+ans_op[0]+ans_num[1]+ans_op[1]+ans_num[2]+ans_op[2]+ans_num[3]+'=7')
break
|
s996911603
|
Accepted
| 17
| 3,060
| 137
|
n = input()
if n[0] == n[1] and n[1] == n[2]:
print('Yes')
elif n[1] == n[2] and n[2] == n[3]:
print('Yes')
else:
print('No')
|
s928857364
|
p03177
|
u193264896
| 2,000
| 1,048,576
|
Wrong Answer
| 190
| 17,336
| 1,229
|
There is a simple directed graph G with N vertices, numbered 1, 2, \ldots, N. For each i and j (1 \leq i, j \leq N), you are given an integer a_{i, j} that represents whether there is a directed edge from Vertex i to j. If a_{i, j} = 1, there is a directed edge from Vertex i to j; if a_{i, j} = 0, there is not. Find the number of different directed paths of length K in G, modulo 10^9 + 7. We will also count a path that traverses the same edge multiple times.
|
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
INF = float('inf')
MOD = 10**9 +7
def main():
N, K = map(int, readline().split())
A = np.array(read().split(), np.int64).reshape(N,N)
def pow_array(a,k):
ans = np.eye(N)
while k:
if k%2:
ans = np.dot(ans%MOD, a%MOD)
a = np.dot(a%MOD, a%MOD)
k>>=1
return ans%MOD
anser = pow_array(A,K).astype('int64').sum()
print(anser)
if __name__ == '__main__':
main()
|
s951130326
|
Accepted
| 522
| 12,520
| 730
|
import sys
readline = sys.stdin.buffer.readline
import numpy as np
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
def main():
N, K = map(int, readline().split())
A = list(list(map(int, readline().split())) for _ in range(N))
A = np.array(A)
def dot(A, B):
C = np.zeros((N, N), np.int64)
for n in range(N):
C[n] = (A[n, :][:, None] * B % MOD).sum(axis=0) % MOD
return C
def matrix_power(A, n):
if n == 0:
return np.eye(N, dtype=np.int64)
X = matrix_power(A, n // 2)
X = dot(X, X)
return dot(A, X) if n & 1 else X
ans = matrix_power(A,K)
print(ans.sum() %MOD)
if __name__ == '__main__':
main()
|
s078807952
|
p02744
|
u210827208
| 2,000
| 1,048,576
|
Wrong Answer
| 133
| 4,412
| 262
|
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
n=int(input())
A='abcdefghijklmnopqrstuvwxyz'
def dfs(s,mx):
if len(s)==n:
print(s)
else:
for c in range(mx):
if c==mx-1:
dfs(s+A[c],mx+1)
else:
dfs(s+A[c],mx)
print(dfs('',1))
|
s448464003
|
Accepted
| 177
| 14,532
| 415
|
n=int(input())
A='abcdefghijklmnopqrstuvwxyz'
P=['a']
X=[[] for _ in range(n)]
X[0].append('a')
for i in range(n-1):
P.append(A[i+1])
for j in range(len(X[i])):
flag=False
for k in range(len(P)):
X[i+1].append(X[i][j]+P[k])
if not P[k] in X[i][j]:
flag=True
if flag:
break
Y=X[n-1]
for i in range(len(Y)):
print(Y[i])
|
s800781539
|
p03605
|
u951601135
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 38
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
N=list(map(int,input()))
print(9 in N)
|
s197070858
|
Accepted
| 18
| 2,940
| 34
|
print(["No","Yes"]["9"in input()])
|
s143189374
|
p03645
|
u923279197
| 2,000
| 262,144
|
Wrong Answer
| 2,106
| 38,320
| 320
|
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
n,m = map(int,input().split())
matrix = [[] for i in range(n)]
for i in range(m):
a,b = map(int,input().split())
a -= 1
b -= 1
matrix[a].append(b)
matrix[b].append(a)
for i in matrix[0]:
for j in matrix[n-1]:
if i == j:
print('possible')
exit()
print('impossible')
|
s223215351
|
Accepted
| 606
| 6,132
| 407
|
n,m = map(int,input().split())
Check1 = [False]*n
Check2 = [False]*n
for i in range(m):
a,b = map(int,input().split())
if a ==1:
Check1[b-1] = True
elif a == n:
Check2[b-1] = True
elif b == 1:
Check1[a-1] = True
elif b == n:
Check2[a-1] = True
for i in range(n):
if Check1[i] and Check2[i]:
print('POSSIBLE')
exit()
print('IMPOSSIBLE')
|
s817375973
|
p04044
|
u133936772
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 77
|
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,_ = map(int,input().split())
l = sorted(input() for _ in range(n))
print(l)
|
s322567715
|
Accepted
| 17
| 3,060
| 80
|
n,_ = map(int,input().split())
print(''.join(sorted(input() for _ in range(n))))
|
s072902271
|
p04011
|
u040033078
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(b * d + (a-b)*c)
|
s498318603
|
Accepted
| 17
| 2,940
| 126
|
a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a < b:
print(a * c)
else:
print((a-b) * d + b * c)
|
s508725681
|
p03607
|
u100641536
| 2,000
| 262,144
|
Wrong Answer
| 2,206
| 16,516
| 219
|
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
|
n=int(input())
a = [input() for _ in range(n)]
a.sort()
count = 0
i=0
while i<n-1:
j=i+1
ex=1
while j<n:
if a[j]==a[i]:
ex=1-ex
j+=1
else:
i=j+1
count+=ex
break
print(count+1)
|
s679379254
|
Accepted
| 166
| 24,092
| 154
|
from collections import Counter
n=int(input())
a = [input() for _ in range(n)]
c = Counter(a)
count = 0
for i in c.keys():
count += c[i]%2
print(count)
|
s830435668
|
p03024
|
u087731474
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 177
|
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
s = input()
c=0
n = list(map(str, s))
print(n)
for i in n :
if i == 'o' :
c +=1
if c >= 8 or (8-c) == 15 - len(n) :
print('YES')
else :
print('NO')
|
s768296035
|
Accepted
| 17
| 3,060
| 168
|
s = input()
c=0
n = list(map(str, s))
for i in n :
if i == 'o' :
c +=1
if c >= 8 or (8-c) <= 15 - len(n) :
print('YES')
else :
print('NO')
|
s045325898
|
p03131
|
u247830763
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,172
| 184
|
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 <= 1 or a >= k:
print(k+1)
else:
k -= a - 1
ans = a
ans += (b - a)*(k//2)
if k/2 % 2 == 0:
ans += 1
print(ans)
|
s616837833
|
Accepted
| 28
| 9,068
| 182
|
k,a,b = map(int,input().split())
if b - a <= 1 or a >= k:
print(k+1)
else:
k -= a - 1
ans = a
ans += (b - a)*(k//2)
if k % 2 != 0:
ans += 1
print(ans)
|
s670046370
|
p03943
|
u694370915
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 286
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
def main():
a, b, c = map(int, input().split())
if a + b == c:
print('YES')
return
if a + c == b:
print('YES')
return
if a == b + c:
print('YES')
return
print('NO')
return
if __name__ == '__main__':
main()
|
s060992159
|
Accepted
| 18
| 2,940
| 288
|
def main():
a, b, c = map(int, input().split())
if a + b == c:
print('Yes')
return
if a + c == b:
print('Yes')
return
if a == b + c:
print('Yes')
return
print('No')
return
if __name__ == '__main__':
main()
|
s809765852
|
p03214
|
u556589653
| 2,525
| 1,048,576
|
Wrong Answer
| 20
| 3,064
| 538
|
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
N = int(input())
P = list(map(int,input().split()))
sum = 0
ave = 0
ave_first = 99999
k = []
for i in range(N):
sum += P[i]
print(sum)
ave = sum/N
print(ave)
for i in range(0,N-1):
if abs(P[i]-ave)< ave_first:
ave_first = abs(P[i]-ave)
k.clear()
k.append(i)
elif abs(P[i]-ave) == ave_first:
k.append(i)
print(min(k))
|
s067811599
|
Accepted
| 17
| 3,064
| 512
|
N = int(input())
P = list(map(int,input().split()))
sum = 0
ave = 0
ave_first = 99999
k = []
for i in range(N):
sum += P[i]
ave = sum/N
for i in range(0,N-1):
if abs(P[i]-ave)< ave_first:
ave_first = abs(P[i]-ave)
k.clear()
k.append(i)
elif abs(P[i]-ave) == ave_first:
k.append(i)
print(min(k))
|
s509460982
|
p03730
|
u215753631
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 283
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
_input = list(map(int, input().split(" ")))
a = _input[0]
b = _input[1]
c = _input[2]
check_limit = a * b
ratio = 1
remain_list = []
while (True):
remain_list.append(a * ratio % b)
ratio += 1
if ratio > b:
break
if c in remain_list:
print("Yes")
else:
print("No")
|
s073908070
|
Accepted
| 17
| 3,060
| 283
|
_input = list(map(int, input().split(" ")))
a = _input[0]
b = _input[1]
c = _input[2]
check_limit = a * b
ratio = 1
remain_list = []
while (True):
remain_list.append(a * ratio % b)
ratio += 1
if ratio > b:
break
if c in remain_list:
print("YES")
else:
print("NO")
|
s767156821
|
p02795
|
u836737505
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 69
|
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
a = int(input())
b = int(input())
c = int(input())
print(c//max(a,b))
|
s023311253
|
Accepted
| 17
| 2,940
| 91
|
import math
a = int(input())
b = int(input())
c = int(input())
print(math.ceil(c/max(a,b)))
|
s455822411
|
p03693
|
u367373844
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,316
| 123
|
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())
number = r * 100 + g * 10 + b
if number % 4 == 0:
print("Yes")
else:
print("No")
|
s759465256
|
Accepted
| 17
| 2,940
| 123
|
r,g,b = map(int,input().split())
number = r * 100 + g * 10 + b
if number % 4 == 0:
print("YES")
else:
print("NO")
|
s178953394
|
p02694
|
u549474450
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,164
| 72
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
x=int(input())
i=100
c=0
while i<=x:
i=i+(i//100)
c=c+1
print(c)
|
s637606925
|
Accepted
| 22
| 9,164
| 71
|
x=int(input())
i=100
c=0
while i<x:
i=i+(i//100)
c=c+1
print(c)
|
s323968472
|
p03385
|
u612721349
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 44
|
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
print(["No","Yes"]["".join(input())=="abc"])
|
s889757943
|
Accepted
| 17
| 2,940
| 52
|
print(["No","Yes"]["".join(sorted(input()))=="abc"])
|
s424770132
|
p03563
|
u894694822
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
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((g-r)*2+g)
|
s438273713
|
Accepted
| 17
| 2,940
| 46
|
r=int(input())
g=int(input())
print((g-r)*2+r)
|
s113871164
|
p03129
|
u448743361
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 79
|
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())
if k-n>=1:
print('YES')
else:
print('NO')
|
s138413439
|
Accepted
| 17
| 3,064
| 286
|
import sys
n,k=map(int,input().split())
tmp=1
count=1
if n==1 and k==1:
print('YES')
sys.exit(0)
if k==0:
print('YES')
sys.exit(0)
for i in range(2,n+1):
if i-tmp>1:
tmp=i
count+=1
if count==k:
print('YES')
sys.exit(0)
print('NO')
|
s291748410
|
p02742
|
u829416877
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,104
| 88
|
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:
|
H,W = map(int, input().split())
if H*W%2 == 0:
print(H*W/2)
else:
print(H*W//2+1)
|
s279498073
|
Accepted
| 29
| 9,044
| 120
|
H,W = map(int, input().split())
if W == 1 or H == 1:
print(1)
elif H*W%2 == 0:
print(H*W//2)
else:
print(H*W//2+1)
|
s270639562
|
p02806
|
u816637025
| 2,525
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 197
|
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep.
|
n = int(input())
s = ['']*n
t = ['']*n
for i in range(n):
s[i], t[i] = input().split()
x = input()
p = s.index(x)
total = 0
for i in range(p, n):
total += int(t[i])
print(total)
|
s625289888
|
Accepted
| 17
| 3,064
| 199
|
n = int(input())
s = ['']*n
t = ['']*n
for i in range(n):
s[i], t[i] = input().split()
x = input()
p = s.index(x)
total = 0
for i in range(p+1, n):
total += int(t[i])
print(total)
|
s067950339
|
p03478
|
u336624604
| 2,000
| 262,144
|
Wrong Answer
| 55
| 3,636
| 177
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
if a <= sum(map(int, str(i))) <= b:
ans += i
print(sum(list(map(int,str(i)))))
print(ans)
|
s485572034
|
Accepted
| 30
| 3,060
| 135
|
n, a, b = map(int, input().split())
ans = 0
for i in range(1, n+1):
if a <= sum(map(int, str(i))) <= b:
ans += i
print(ans)
|
s392106025
|
p02842
|
u597455618
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 2,940
| 87
|
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())
if int(-(-n//1.08)*1.08) == n:
print(n//1.08)
else:
print(":(")
|
s845087211
|
Accepted
| 17
| 2,940
| 96
|
n= int(input())
if int(-(-n//1.08)*1.08) == n:
print(int(-(-n//1.08)))
else:
print(":(")
|
s308127276
|
p03438
|
u608088992
| 2,000
| 262,144
|
Wrong Answer
| 30
| 4,852
| 534
|
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
|
import sys
def solve():
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
A.sort()
B.sort()
C = []
for i in range(N): C.append(A[i] - B[i])
print(C)
sumA = sum(A)
sumB = sum(B)
if sumA >= sumB: print("No")
else:
for i, c in enumerate(C):
if c > 0:
print("No")
break
else:
print("Yes")
return 0
if __name__ == "__main__":
solve()
|
s840014947
|
Accepted
| 27
| 4,596
| 494
|
import sys
def solve():
input = sys.stdin.readline
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [A[i] - B[i] for i in range(N)]
sumA = sum(A)
sumB = sum(B)
addA, addB = 0, 0
for i, c in enumerate(C):
if c > 0: addB += c
else: addA += (-1 * c + 1) // 2
if addA > sumB - sumA or addB > sumB - sumA: print("No")
else: print("Yes")
return 0
if __name__ == "__main__":
solve()
|
s841002052
|
p02283
|
u159356473
| 2,000
| 131,072
|
Wrong Answer
| 20
| 7,732
| 1,110
|
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.
|
#coding:UTF-8
class Node:
def __init__(self,point):
self.n=point
self.left=None
self.right=None
def insert(t,z):
y=None
x=t
while x!=None:
y=x
if z.n<x.n:
x=x.left
else:
x=x.right
if y==None:
return z
else:
if z.n<y.n:
y.left=z
else:
y.right=z
return t
def Pre(t,l):
l.append(t.n)
if t.left!=None:
Pre(t.left,l)
if t.right!=None:
Pre(t.right,l)
def In(t,l):
if t.left!=None:
In(t.left,l)
l.append(t.n)
if t.right!=None:
In(t.right,l)
def BST1(A,n):
tree=None
for i in range(n):
if A[i]=="print":
PreAns=[]
InAns=[]
Pre(tree,PreAns)
In(tree,InAns)
print(" ",*PreAns)
print(" ",*InAns)
else:
z=Node(int(A[i].split(" ")[1]))
tree=insert(tree,z)
if __name__=="__main__":
n=int(input())
A=[]
for i in range(n):
A.append(input())
BST1(A,n)
|
s856009950
|
Accepted
| 7,360
| 215,576
| 1,138
|
#coding:UTF-8
class Node:
def __init__(self,point):
self.n=point
self.left=None
self.right=None
def insert(t,z):
y=None
x=t
while x!=None:
y=x
if z.n<x.n:
x=x.left
else:
x=x.right
if y==None:
return z
else:
if z.n<y.n:
y.left=z
else:
y.right=z
return t
def Pre(t,l):
l.append(str(t.n))
if t.left!=None:
Pre(t.left,l)
if t.right!=None:
Pre(t.right,l)
def In(t,l):
if t.left!=None:
In(t.left,l)
l.append(str(t.n))
if t.right!=None:
In(t.right,l)
def BST1(A,n):
tree=None
for i in range(n):
if A[i]=="print":
PreAns=[]
InAns=[]
Pre(tree,PreAns)
In(tree,InAns)
print(" "+" ".join(InAns))
print(" "+" ".join(PreAns))
else:
z=Node(int(A[i].split(" ")[1]))
tree=insert(tree,z)
if __name__=="__main__":
n=int(input())
A=[]
for i in range(n):
A.append(input())
BST1(A,n)
|
s249771865
|
p03861
|
u651803486
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 74
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
c = (a-1) / x
d = b / x
print(d-c)
|
s706826851
|
Accepted
| 17
| 2,940
| 75
|
a, b, x = map(int, input().split())
c = (a-1) // x
d = b // x
print(d-c)
|
s683674206
|
p02678
|
u790012205
| 2,000
| 1,048,576
|
Wrong Answer
| 2,257
| 46,660
| 625
|
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]
R = [0] * N
P = 0
S = [1]
Stmp = []
while True:
for i in range(M):
for s in S:
if AB[i][0] == s:
R[AB[i][1] - 1] = s
Stmp.append(AB[i][1])
AB[i] = [0, 0]
P += 1
elif AB[i][1] == s:
R[AB[i][0] - 1] = s
Stmp.append(AB[i][0])
AB[i] = [0, 0]
P += 1
S = Stmp
Stmp = []
print(R, P)
if P > N - 1:
break
print('Yes')
for i in range(1, N):
print(R[i])
|
s753937512
|
Accepted
| 625
| 34,940
| 398
|
from collections import deque
N, M = map(int, input().split())
R = [[] for i in range(N + 1)]
for i in range(M):
A, B = map(int, input().split())
R[A].append(B)
R[B].append(A)
P = [-1] * (N + 1)
P[1] = 0
Q = deque()
Q.append(1)
while Q:
v = Q.popleft()
for r in R[v]:
if P[r] == -1:
P[r] = v
Q.append(r)
print('Yes')
for p in P[2:]:
print(p)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.