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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s608098669
|
p03997
|
u098994567
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,032
| 493
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
input_a = int(input())
input_b = int(input())
input_h = int(input())
result = (input_a + input_b) * input_h / 2
print(result)
|
s907130562
|
Accepted
| 24
| 9,048
| 498
|
input_a = int(input())
input_b = int(input())
input_h = int(input())
result = int((input_a + input_b) * input_h / 2)
print(result)
|
s953691088
|
p00022
|
u618637847
| 1,000
| 131,072
|
Wrong Answer
| 40
| 7,636
| 249
|
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a _contiquous_ subsequence.
|
while True:
num = int(input())
if num == 0:
break
list = []
for i in range(num):
list.append(int(input()))
for i in range(1, num):
list[i] = max(list[i - 1] + list[i], list[i])
print((list))
|
s692414721
|
Accepted
| 50
| 7,576
| 252
|
while True:
num = int(input())
if num == 0:
break
list = []
for i in range(num):
list.append(int(input()))
for i in range(1, num):
list[i] = max(list[i - 1] + list[i], list[i])
print(max(list))
|
s102208492
|
p00002
|
u372789658
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,528
| 52
|
Write a program which computes the digit number of sum of two integers a and b.
|
print(len(str(sum(list(map(int,input().split()))))))
|
s174588357
|
Accepted
| 30
| 7,448
| 101
|
while True:
try:
print(len(str(sum(list(map(int,input().split()))))))
except:
break
|
s318868882
|
p03377
|
u129315407
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 99
|
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 or A + B < X:
print("No")
else:
print("Yes")
|
s004309893
|
Accepted
| 17
| 2,940
| 98
|
A, B, X = map(int, input().split())
if A + B < X or A > X:
print("NO")
else:
print("YES")
|
s145303297
|
p02601
|
u047102107
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,144
| 384
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
red, green, blue = map(int, input().split())
K = int(input())
while K >= 0 and red > green:
green *= 2
K -= 1
if red < green:
print("No")
exit()
if green > red and blue > green:
print("Yes")
exit()
if K == 0:
print("No")
else:
while K >= 0 and green > blue:
blue *= 2
K -= 1
if green > red and blue > green:
print("Yes")
else:
print("No")
|
s888441017
|
Accepted
| 28
| 9,140
| 201
|
a, b, c = map(int,input().split())
k = int(input())
for i in range(k):
if b <= a:
b *= 2
elif c <= b:
c *= 2
else:
break
if a >= b or b >= c:
print('No')
else:
print('Yes')
|
s763053469
|
p03377
|
u857673087
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 69
|
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())
print('YES' if X-A >= B else 'NO')
|
s254341343
|
Accepted
| 17
| 2,940
| 81
|
A,B,X = map(int, input().split())
print('YES' if A <= X and A+B >= X else 'NO')
|
s932495790
|
p03545
|
u035424059
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 253
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
import sys
s=input()
opt = ["+","-"]
for opt1 in opt:
for opt2 in opt:
for opt3 in opt:
equation = s[0]+opt1+s[1]+opt2+s[2]+opt3+s[3]
if eval(equation) == 7:
print(equation)
sys.exit()
|
s312934909
|
Accepted
| 17
| 2,940
| 275
|
import sys
s=input()
opt = ["+","-"]
for opt1 in opt:
for opt2 in opt:
for opt3 in opt:
equation = s[0]+opt1+s[1]+opt2+s[2]+opt3+s[3]
if eval(equation) == 7:
print(equation+"=7")
sys.exit()
|
s996178900
|
p03359
|
u379535139
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a, b = [int(num) for num in input().split()]
sum = 0
if a < b or a == b:
sum = 1
else:
sum = a - 1
print(sum)
|
s220025554
|
Accepted
| 17
| 2,940
| 114
|
a, b = [int(num) for num in input().split()]
sum = 0
if a < b or a == b:
sum = a
else:
sum = a - 1
print(sum)
|
s227457874
|
p02407
|
u777299405
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,720
| 53
|
Write a program which reads a sequence and prints it in the reverse order.
|
n = input()
print(*sorted(map(int, input().split())))
|
s044738219
|
Accepted
| 40
| 6,724
| 69
|
n = input()
data = list(map(str, input().split()))
print(*data[::-1])
|
s644080545
|
p02694
|
u267482423
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,108
| 138
|
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?
|
result = int(input())
count = 0
kinngaku = 100
while kinngaku <= result:
count += 1
kinngaku += int(kinngaku * 0.01)
print(count)
|
s075732129
|
Accepted
| 23
| 9,156
| 144
|
result = int(input())
count = 0
kinngaku = 100
while kinngaku < result:
count += 1
kinngaku += int(kinngaku * 0.01)
print(count)
|
s582641263
|
p03377
|
u083960235
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 129
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
if x-a>=0:
if x-a<=b:
print("Yes")
else:
print("No")
else:
print("No")
|
s156123760
|
Accepted
| 18
| 3,064
| 129
|
a,b,x=map(int,input().split())
if x-a>=0:
if x-a<=b:
print("YES")
else:
print("NO")
else:
print("NO")
|
s821073070
|
p03852
|
u801247169
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,020
| 132
|
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 = str(input())
vowels = ['a','e','i','o','u']
if c in vowels:
answer = "vowei"
else:
answer = "consonant"
print(answer)
|
s564433346
|
Accepted
| 26
| 9,068
| 133
|
c = str(input())
vowels = ['a','e','i','o','u']
if c in vowels:
answer = "vowel"
else:
answer = "consonant"
print(answer)
|
s317610723
|
p03555
|
u268314634
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,008
| 105
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
c1=input()
c2=input()
if c1[0]+c1[1]+c1[2] == c2[2]+c2[1]+c2[0]:
print("Yes")
else:
print("No")
|
s627988389
|
Accepted
| 30
| 9,092
| 105
|
c1=input()
c2=input()
if c1[0]+c1[1]+c1[2] == c2[2]+c2[1]+c2[0]:
print("YES")
else:
print("NO")
|
s121213534
|
p03524
|
u060793972
| 2,000
| 262,144
|
Wrong Answer
| 43
| 3,188
| 237
|
Snuke has a string S consisting of three kinds of letters: `a`, `b` and `c`. He has a phobia for palindromes, and wants to permute the characters in S so that S will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.
|
def mycounter(d,i):
if i in d:
d[i]+=1
else:
d[i]=1
return d
s=input()
d=dict()
for i in s:
d=mycounter(d,i)
l=-(-len(s)//3)
for i in d.values():
if l<i:
print('No')
exit()
print('Yes')
|
s638160498
|
Accepted
| 43
| 3,188
| 237
|
def mycounter(d,i):
if i in d:
d[i]+=1
else:
d[i]=1
return d
s=input()
d=dict()
for i in s:
d=mycounter(d,i)
l=-(-len(s)//3)
for i in d.values():
if l<i:
print('NO')
exit()
print('YES')
|
s690168339
|
p03565
|
u599547273
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 799
|
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`.
|
def reverse_enumerate(l):
for i, l_i in zip(range(len(l)-1, -1, -1), l):
yield i, l_i
def n_gram(s, n):
return [s[i:i+n] for i in range(len(s)-n+1)]
def is_equal_match(s1, s2, all_match=[]):
for i in range(len(s1)):
if not (s1[i] == s2[i] or s1[i] in all_match):
return False
return True
def fill_in_str(text, s, n):
return text[:n] + s + text[n+len(s):]
s_ = input()
t = input()
for i, s_i in reverse_enumerate(n_gram(s_, len(t))):
if is_equal_match(s_i, t, all_match="?"):
print(fill_in_str(s_, t, i))
exit()
print("UNRESTORABLE")
|
s804742082
|
Accepted
| 17
| 3,060
| 242
|
s, t = [input() for _ in range(2)]
n, m = map(len, [s, t])
for i in range(n-m, -1, -1):
if not all(s_j in ["?", t_j] for s_j, t_j in zip(s[i:i+m], t)):
continue
print((s[:i] + t + s[i+m:]).replace("?", "a"))
exit()
print("UNRESTORABLE")
|
s477086714
|
p03457
|
u220612891
| 2,000
| 262,144
|
Wrong Answer
| 950
| 3,700
| 223
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N = int(input())
a = 0
for i in range(N):
a = list(map(int, input().split()))
print(a[0])
if a[0] < sum(a) - a[0]:
print("No")
exit()
if (sum(a) - a[0] - a[0])%2 != 0:
print("No")
exit()
print("Yes")
|
s239245241
|
Accepted
| 402
| 3,064
| 209
|
N = int(input())
a = 0
for i in range(N):
a = list(map(int, input().split()))
if a[0] < sum(a) - a[0]:
print("No")
exit()
if (sum(a) - a[0] - a[0])%2 != 0:
print("No")
exit()
print("Yes")
|
s252337011
|
p03149
|
u188927483
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,112
| 98,968
| 251
|
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
l1 = input().split()
ar = []
for i in l1:
l1.append(int(i))
d = {1:0,9:0,7:0,4:0}
for i in ar:
for j in d:
if i == j:
d[j] = 1
con = True
for i in d:
if d[i] == 0:
con = False
print("NO")
break
if con:
print("YES")
|
s959408262
|
Accepted
| 18
| 3,064
| 254
|
l1 = input().split(" ")
ar = []
for i in l1:
ar.append(int(i))
d = {1:0,9:0,7:0,4:0}
for i in ar:
for j in d:
if i == j:
d[j] = 1
con = True
for i in d:
if d[i] == 0:
con = False
print("NO")
break
if con:
print("YES")
|
s381291269
|
p03023
|
u657208344
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 27
|
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*180)
|
s223910392
|
Accepted
| 19
| 2,940
| 31
|
n=int(input())
print(180*(n-2))
|
s811008421
|
p02865
|
u721316601
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 3,316
| 59
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
N = int(input())
if N % 2: print(N//2-1)
else: ((N-1)//2)
|
s471244149
|
Accepted
| 18
| 2,940
| 67
|
N = int(input())
if not N % 2: print(N//2-1)
else: print((N-1)//2)
|
s055194220
|
p03387
|
u857330600
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 216
|
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
l=list(map(int,input().split()))
l.sort()
a,b,c=l[0],l[1],l[2]
if (b-a)%2==1 and (c-a)%2==1:
print(1+(c+1-a)//2+(c-b)//2)
elif (b-a)%2==0 and (c-a)%2==0:
print((c-a)//2+(c-b)//2)
else:
print(1+(2*c+2-a-b+1)//2)
|
s752484090
|
Accepted
| 18
| 3,064
| 204
|
l=list(map(int,input().split()))
l.sort()
a,b,c=l[0],l[1],l[2]
if (c-a)%2==1 and (c-b)%2==1:
print(1+(2*c-2-a-b)//2)
elif (c-a)%2==0 and (c-b)%2==0:
print((2*c-a-b)//2)
else:
print(1+(2*c+1-a-b)//2)
|
s634118846
|
p02865
|
u130900604
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 26
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n=int(input())
print(n//2)
|
s607614742
|
Accepted
| 17
| 2,940
| 26
|
print((int(input())-1)//2)
|
s655205455
|
p02255
|
u564105430
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 286
|
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
n=int(input())
A=input().split()
A=[int(i)for i in A]
insertionSort(A,n)
for i in range(n):
print(A[i],end=" ")
|
s018391859
|
Accepted
| 30
| 5,984
| 392
|
def pr(A,n):
for i in range(n):
if i!=n-1:
print(A[i],end=" ")
else:
print(A[i])
def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
pr(A,n)
n=int(input())
A=input().split()
A=[int(i)for i in A]
pr(A,n)
insertionSort(A,n)
|
s185874266
|
p03970
|
u363836311
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 108
|
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
|
S=list(str(input().split()))
G='CODEFESTIVAL2016'
t=0
for i in range(16):
if S[i]!=G[i]:
t+=1
print(t)
|
s234616880
|
Accepted
| 17
| 2,940
| 101
|
S=list(str(input()))
G='CODEFESTIVAL2016'
t=0
for i in range(16):
if S[i]!=G[i]:
t+=1
print(t)
|
s860908022
|
p02612
|
u771383254
| 2,000
| 1,048,576
|
Wrong Answer
| 32
| 9,136
| 31
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s000885501
|
Accepted
| 28
| 9,144
| 66
|
n = int(input())
if n%1000 == 0: print(0)
else: print(1000-n%1000)
|
s667384579
|
p03456
|
u209616713
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 124
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
import math
a,b = input().split()
c = a+b
d = int(c)
e = int(math.sqrt(d))
if e^2 == d:
pint('Yes')
else:
print('No')
|
s215838047
|
Accepted
| 17
| 2,940
| 125
|
import math
a,b = input().split()
c = a+b
d = int(c)
e = int(math.sqrt(d))
if e*e == d:
print('Yes')
else:
print('No')
|
s569627732
|
p00001
|
u651428295
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,700
| 102
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
j = []
for i in range(10) :
j.append(int(input()))
j.reverse()
for k in range(3) :
print(j[k])
|
s340624823
|
Accepted
| 20
| 7,688
| 113
|
j = []
for i in range(10) :
j.append(int(input()))
j.sort(reverse = True)
for k in range(3) :
print(j[k])
|
s328580724
|
p03044
|
u583507988
| 2,000
| 1,048,576
|
Wrong Answer
| 280
| 31,356
| 231
|
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
n = int(input())
data = [list(map(int, input().split())) for i in range(n-1)]
d = [0]*n
for i in range(n-1):
if data[i][2]%2==0:
continue
else:
d[data[i][0]-1] += 1
d[data[i][1]-1] += 1
for i in d:
print(i)
|
s412259822
|
Accepted
| 752
| 55,360
| 411
|
n = int(input())
d = [[] for i in range(n)]
for i in range(n-1):
u, v, w = map(int, input().split())
d[u-1].append([v-1, w])
d[v-1].append([u-1, w])
ans = [[] for i in range(n)]
ans[0].append(0)
q = [0]
while q:
x = q.pop()
for u, w in d[x]:
if not ans[u]:
buf = ans[x][0]
if w%2==1:
buf = (buf+1)%2
ans[u].append(buf)
q.append(u)
for i in ans:
print(*i)
|
s607927924
|
p00082
|
u193025715
| 1,000
| 131,072
|
Wrong Answer
| 40
| 6,740
| 661
|
遊園地にあるメリーゴーランドはご存じでしょう。大きな円盤の上に馬や馬車などの乗り物が固定されていて、円盤が回転すると同時に乗り物が上下に揺れる、定番の遊具です。ある遊園地のメリーゴーランドは、4人乗りの馬車が2台、2人乗りの車2台、1人乗りの馬が4台、計8台の乗り物が図1のような順序で備えられています。そして、遊園地においでのお客様は、図1に示す乗り場0〜7のどこかで待つようになっています。 この遊園地のメリーゴーランドは、かならず乗り物が乗り場にぴったりと合う位置に停止します。そして、0〜7のそれぞれで待っているお客さまは、目の前にとまった乗り物に乗ることになっています。急いで他の乗り場へ移動してそこから乗るということはできません。効率よく、お客さまにたのしんでいただくためには、メリーゴーランドの停止する位置をうまく調整して、乗れないお客さまをできるだけ少なくするようにしなければなりません。 乗り場0〜7で待っているお客さまの人数を読み込んで、どの位置にどの乗り物が来るように止めれば乗れないお客さまが最も少なくなるかを出力するプログラムを作成してください。
|
mgr = [4, 1, 4, 1, 2, 1, 2, 1]
while True:
try:
p = list(map(int, input().split(' ')))
v = []
for i in range(8):
q = mgr[i:] + mgr[:i]
sum_v = sum(p) - sum(p[j]-q[j] if p[j]-q[j] >= 0 else 0 for j in range(8))
v.append(sum_v)
if v.count(max(v)) > 1:
mv = max(v)
ans = []
for i in range(8):
if v[i] == mv:
ans.append(int("".join(map(str, mgr[i:] + mgr[:i]))))
print(" ".join(list(str(min(ans)))))
else:
i = v.index(max(v))
print(mgr[i:] + mgr[:i])
except:
break
|
s693046726
|
Accepted
| 30
| 6,744
| 681
|
mgr = [4, 1, 4, 1, 2, 1, 2, 1]
while True:
try:
p = list(map(int, input().split(' ')))
v = []
for i in range(8):
q = mgr[i:] + mgr[:i]
sum_v = sum(p) - sum(p[j]-q[j] if p[j]-q[j] >= 0 else 0 for j in range(8))
v.append(sum_v)
if v.count(max(v)) > 1:
mv = max(v)
ans = []
for i in range(8):
if v[i] == mv:
ans.append(int("".join(map(str, mgr[i:] + mgr[:i]))))
print(" ".join(list(str(min(ans)))))
else:
i = v.index(max(v))
print(" ".join(map(str, mgr[i:] + mgr[:i])))
except:
break
|
s009192893
|
p03163
|
u017415492
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 7,668
| 341
|
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
|
n,m=map(int,input().split())
d=[ list(map(int,input().split())) for i in range(n)]
dp=[0]*(m+1)
for i in range(n):
for j in range(d[i][0],m):
dp[j]=max(dp[j-d[i][0]]+d[i][1],dp[j]) #d[i][0]=w d[i][1]=v
print(max(dp))
|
s197892946
|
Accepted
| 1,469
| 7,668
| 301
|
def DP():
n,W = map(int, input().split(' '))
WV = (map(int, input().split(' ')) for _ in range(n))
dp = [0] * (W+1)
for w, v in WV:
for j in range(W, w-1, -1):
DP = dp[j-w] + v
if dp[j] < DP:
dp[j] = DP
return max(dp)
print(DP())
|
s373308582
|
p03693
|
u823044869
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 204
|
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?
|
import sys
r,g,b = input().split()
if 1 > int(r) or 1 > int(g) or 1 > int(b) or 9 < int(r) or 9 < int(g) or 9 < int(b):
sys.exit()
if int(r + g + b)%4 == 0:
print('Yes')
else:
print('No')
|
s749478827
|
Accepted
| 17
| 2,940
| 97
|
r,g,b = map(int,input().split())
if not((100*r+10*g+b)%4) :
print("YES")
else:
print("NO")
|
s792676965
|
p03006
|
u474423089
| 2,000
| 1,048,576
|
Wrong Answer
| 539
| 3,188
| 1,127
|
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
|
def main():
n=int(input())
if n ==1:
print(1)
else:
x_y_list=[]
for i in range(n):
x,y = map(int,input().split(' '))
x_y_list.append((x,y))
sorted_x_y = sorted(x_y_list)
p_q_list=[]
for i in range(n-1):
for j in range(i,n):
dif_x = sorted_x_y[i][0]-sorted_x_y[j][0]
dif_y = sorted_x_y[i][1]-sorted_x_y[j][1]
if dif_x != 0 and dif_y != 0:
p_q_list.append((dif_x,dif_y))
p_q_list = list(set(p_q_list))
p_q_max = 0
for p,q in p_q_list:
for i in range(n):
tmp = 0
x_i = sorted_x_y[i][0]
y_i = sorted_x_y[i][1]
for j in range(n):
if i ==j:
continue
x_j = sorted_x_y[j][0]
y_j = sorted_x_y[j][1]
if x_j%p == x_i and y_j%q == y_j:
tmp += 1
if tmp > p_q_max:
p_q_max = tmp
print(n-p_q_max+1)
main()
|
s037955332
|
Accepted
| 20
| 3,444
| 734
|
def main():
n = int(input())
if n ==1:
print(1)
exit()
x_y_list = []
p_q_dic = {}
for i in range(n):
x,y = map(int,input().split(' '))
x_y_list.append((x,y))
for i in range(n):
x_i = x_y_list[i][0]
y_i = x_y_list[i][1]
for j in range(n):
if i == j:
continue
x_j = x_y_list[j][0]
y_j = x_y_list[j][1]
p = x_j - x_i
q = y_j - y_i
if (p !=0 or q !=0) and (p,q) in p_q_dic:
p_q_dic[(p,q)] += 1
elif p != 0 or q != 0:
p_q_dic[(p,q)] = 1
p_q_sorted = sorted(p_q_dic.values(),reverse=True)
print(n-p_q_sorted[0])
main()
|
s327925147
|
p03361
|
u129325056
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 609
|
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]
H, W = map(int, input().split())
field = []
for i in range(H):
field.append(list(input()))
for y in range(H):
for x in range(W):
if field[y][x] == ".":
continue
for k in range(4):
cnt = 0
ny = y + dy[k]
nx = x + dx[k]
if ny < 0 or H <= ny\
or nx < 0 or W <= nx:
continue
elif field[ny][nx] == "#":
continue
if cnt == 0:
print("No")
exit()
print("Yes")
|
s451991358
|
Accepted
| 24
| 3,064
| 609
|
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]
H, W = map(int, input().split())
field = []
for i in range(H):
field.append(list(input()))
for y in range(H):
for x in range(W):
if field[y][x] == "#":
cnt = 0
for k in range(4):
ny = y + dy[k]
nx = x + dx[k]
if ny < 0 or H <= ny or nx < 0 or W <= nx:
continue
if field[ny][nx] == "#":
cnt += 1
if cnt == 0:
print("No")
exit()
print("Yes")
|
s138773711
|
p03457
|
u685263709
| 2,000
| 262,144
|
Wrong Answer
| 318
| 3,060
| 160
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if x + y < t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
|
s566989020
|
Accepted
| 415
| 18,092
| 459
|
n = int(input())
travel_plan = [tuple(map(int, input().split())) for i in range(n)]
travel_plan = [(0, 0, 0)] + travel_plan
for i in range(n):
t1 = travel_plan[i][0]
x1 = travel_plan[i][1]
y1 = travel_plan[i][2]
t2 = travel_plan[i+1][0]
x2 = travel_plan[i+1][1]
y2 = travel_plan[i+1][2]
x = abs(x1 - x2)
y = abs(y1 - y2)
t = t2 - t1
if x + y > t or (x + y) % 2 != t % 2:
print("No")
exit()
print("Yes")
|
s043130125
|
p02578
|
u901144784
| 2,000
| 1,048,576
|
Wrong Answer
| 195
| 32,312
| 149
|
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n=int(input())
l=[int(i) for i in input().split()]
m=l[0]
c=0
for i in range(1,n):
if(l[i]<m):
c=max(c,m-l[i])
m=max(l[i],m)
print(c)
|
s686381065
|
Accepted
| 216
| 32,116
| 139
|
n=int(input())
l=[int(i) for i in input().split()]
c=0
for i in range(1,n):
c+=max(l[i-1]-l[i],0)
l[i]+=max(l[i-1]-l[i],0)
print(c)
|
s889359175
|
p03636
|
u792547805
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 48
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
S = input()
print(S[0] + str(len(S)-1) + S[-1])
|
s640333690
|
Accepted
| 17
| 2,940
| 47
|
S = input()
print(S[0] + str(len(S)-2) + S[-1])
|
s121077846
|
p03680
|
u399721252
| 2,000
| 262,144
|
Wrong Answer
| 215
| 9,764
| 286
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
n = int(input())
switch_list = [ int(input())-1 for i in range(n)]
move_list = [0] + [None for i in range(n-1)]
for i in range(n-1):
move_list[i+1] = switch_list[move_list[i]]
print(move_list)
if move_list.count(1) == 0:
ans = -1
else:
ans = move_list.index(1)
print(ans)
|
s094425390
|
Accepted
| 207
| 8,620
| 269
|
n = int(input())
switch_list = [ int(input())-1 for i in range(n)]
move_list = [0] + [None for i in range(n-1)]
for i in range(n-1):
move_list[i+1] = switch_list[move_list[i]]
if move_list.count(1) == 0:
ans = -1
else:
ans = move_list.index(1)
print(ans)
|
s196931993
|
p03545
|
u144072139
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 203
|
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.
|
#ABC 079 C
a,b,c,d=list(input())
s="+-"
for i in range(2):
for j in range(2):
for k in range(2):
if a+s[i]+b+s[j]+c+s[k]+d==7:
print(eval(a+s[i]+b+s[j]+c+s[k]+d))
|
s348703086
|
Accepted
| 18
| 3,060
| 236
|
#ABC 079 C
a,b,c,d=list(input())
s="+-"
for i in range(2):
for j in range(2):
for k in range(2):
if eval(a+s[i]+b+s[j]+c+s[k]+d)==7:
print(str(a+s[i]+b+s[j]+c+s[k]+d)+"=7")
exit()
|
s440135351
|
p03090
|
u475503988
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 3,992
| 240
|
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
|
n = int(input())
ans = []
if n % 2 == 0:
temp = n + 1
else:
temp = n
for i in range(1, n):
for j in range(i+1, n+1):
if i + 1 != temp:
ans.append((i, j))
print(len(ans))
for a in ans:
print(a[0], a[1])
|
s842994103
|
Accepted
| 26
| 3,956
| 276
|
n = int(input())
ans = []
if n % 2 == 0:
temp = n + 1
else:
temp = n
for i in range(1, n):
for j in range(i+1, n+1):
if i + j == temp:
continue
else:
ans.append((i, j))
print(len(ans))
for a in ans:
print(a[0], a[1])
|
s450490951
|
p02613
|
u382169090
| 2,000
| 1,048,576
|
Wrong Answer
| 145
| 16,620
| 154
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
for i in c.items():
print(str(i[0]) + ' x ' + str(i[1]))
|
s101930704
|
Accepted
| 148
| 16,612
| 217
|
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)
print('AC x ' + str(c['AC']))
print('WA x ' + str(c['WA']))
print('TLE x ' + str(c['TLE']))
print('RE x ' + str(c['RE']))
|
s367706538
|
p02613
|
u184661160
| 2,000
| 1,048,576
|
Wrong Answer
| 151
| 9,168
| 254
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
ls=["AC","TLE","RE","WA"]
n=int(input())
a=b=c=d=0
for i in range(n):
s=input()
if s==ls[0]:
a+=1
elif s==ls[1]:
b+=1
elif s==ls[2]:
c+=1
else:
d+=1
print(ls[0]+" *",a)
print(ls[1]+" *",b)
print(ls[2]+" *",c)
print(ls[3]+" *",d)
|
s951474474
|
Accepted
| 151
| 9,160
| 254
|
ls=["AC","TLE","RE","WA"]
n=int(input())
a=b=c=d=0
for i in range(n):
s=input()
if s==ls[0]:
a+=1
elif s==ls[1]:
b+=1
elif s==ls[2]:
c+=1
else:
d+=1
print(ls[0]+" x",a)
print(ls[3]+" x",d)
print(ls[1]+" x",b)
print(ls[2]+" x",c)
|
s721981258
|
p03759
|
u459215900
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = map(int, input().split())
if (b-a) == (c-b):
print('Yes')
else:
print('No')
|
s320500851
|
Accepted
| 18
| 2,940
| 95
|
a, b, c = map(int, input().split())
if (b-a) == (c-b):
print('YES')
else:
print('NO')
|
s235179733
|
p02389
|
u632803184
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,624
| 53
|
Write a program which calculates the area and perimeter of a given rectangle.
|
l = list(map(int,input().split()))
print(l[0] * l[1])
|
s619066105
|
Accepted
| 20
| 7,572
| 69
|
l = list(map(int,input().split()))
print(l[0] * l[1],2*(l[0] + l[1]))
|
s650281242
|
p03605
|
u120564432
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 120
|
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?
|
s=input()
ans=False
for i in range(len(s)):
if s[i]=='9':
ans=False
if ans:
print('Yes')
else :
print('No')
|
s870214092
|
Accepted
| 17
| 2,940
| 105
|
s=input()
ans=False
for i in s:
if i=='9':
ans=True
if ans:
print('Yes')
else :
print('No')
|
s313787442
|
p03478
|
u984924962
| 2,000
| 262,144
|
Wrong Answer
| 46
| 3,412
| 212
|
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())
sum = 0
count = 0
for i in range(1,n+1) :
s = str(i)
l = len(s)
sum = 0
for j in range(l):
sum += int(s[j])
if sum >= a and sum <= b:
print(i)
count += i
print(count)
|
s515531029
|
Accepted
| 39
| 3,060
| 198
|
n,a,b = map(int,input().split())
count = 0
for i in range(1,n+1) :
s = str(i)
l = len(s)
x = 0
for j in range(l):
x += int(s[j])
if x >= a and x <= b:
# print(i)
count += i
print(count)
|
s940393435
|
p03371
|
u010870870
| 2,000
| 262,144
|
Wrong Answer
| 101
| 2,940
| 192
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
sum = 0
A,B,C,X,Y = map(int,input().split())
AB = C*2
ans = float("inf")
for i in range(10**5+1):
sum = AB*i + A*min(0,X-i) + B*min(0,Y-i)
if sum < ans:
ans = sum
print(ans)
|
s196501100
|
Accepted
| 94
| 2,940
| 192
|
sum = 0
A,B,C,X,Y = map(int,input().split())
AB = C*2
ans = float("inf")
for i in range(10**5+1):
sum = AB*i + A*max(0,X-i) + B*max(0,Y-i)
if sum < ans:
ans = sum
print(ans)
|
s893198886
|
p03494
|
u305018585
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,107
| 2,940
| 185
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
n = input()
nums = list(map(int, input().split()))
s = 0
while True :
f = [ i%2 == 0 for i in nums]
if all(f) :
s+=1
nums = [ i%2 for i in nums]
else :
break
print(s)
|
s637786945
|
Accepted
| 18
| 3,064
| 160
|
n = input()
A= set(map(int, input().split()))
result = []
for i in A:
r = 0
while i %2 == 0 :
i = i/2
r += 1
result.append(r)
print(min(result))
|
s807975170
|
p03044
|
u985929170
| 2,000
| 1,048,576
|
Wrong Answer
| 467
| 43,128
| 395
|
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
u,v,w = map(int,input().split())
g[u-1].append((v-1,w))
g[v-1].append((u-1,w))
from collections import deque
que = deque()
seen = [0] + [-1]*(n-1)
que.append(0)
while que:
s = que.popleft()
for v,w in g[s]:
if seen[v] != -1:continue
seen[v] = seen[s]^(w%2)
que.append(v)
print(seen)
|
s930312024
|
Accepted
| 461
| 43,272
| 411
|
n = int(input())
g = [[] for _ in range(n)]
for _ in range(n-1):
u,v,w = map(int,input().split())
g[u-1].append((v-1,w))
g[v-1].append((u-1,w))
from collections import deque
que = deque()
seen = [0] + [-1]*(n-1)
que.append(0)
while que:
s = que.popleft()
for v,w in g[s]:
if seen[v] != -1:continue
seen[v] = seen[s]^(w%2)
que.append(v)
for i in seen:
print(i)
|
s285545892
|
p02402
|
u597483031
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 73
|
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
n=list(map(int,input().split()))
a=min(n)
b=max(n)
c=sum(n)
print(a,b,c)
|
s245707980
|
Accepted
| 20
| 6,540
| 84
|
k=input()
n=list(map(int,input().split()))
a=min(n)
b=max(n)
c=sum(n)
print(a,b,c)
|
s893486446
|
p03351
|
u374146618
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 106
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d = [int(x) for x in input().split()]
if (b-a)<d and (c-b)<d:
print("Yes")
else:
print("No")
|
s472024331
|
Accepted
| 17
| 2,940
| 149
|
a,b,c,d = [int(x) for x in input().split()]
if abs(b-a)<=d and abs(c-b)<=d:
print("Yes")
elif abs(c-a)<=d:
print("Yes")
else:
print("No")
|
s946306066
|
p02616
|
u570155187
| 2,000
| 1,048,576
|
Wrong Answer
| 2,248
| 1,835,024
| 248
|
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).
|
from itertools import combinations
import numpy as np
n,k = map(int,input().split())
a = list(map(int,input().split()))
c = list(combinations(a,k))
max = -10**9
for i in c:
p = np.prod(i)
if max < p:
max = p
r = max % 10**9 + 7
print(r)
|
s257309435
|
Accepted
| 166
| 31,660
| 479
|
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = sorted(a,reverse=True)
mod = 10**9 + 7
ans = 1
if k % 2 == 1 and s[0] < 0:
for i in range(k):
ans = ans * s[i] % mod
print(ans)
exit()
l = 0
r = n - 1
if k % 2 == 1:
ans = ans * s[l]
l += 1
for _ in range(k // 2):
ml = s[l] * s[l + 1]
mr = s[r] * s[r - 1]
if ml > mr:
ans = ans * ml % mod
l += 2
else:
ans = ans * mr % mod
r -= 2
print(ans)
|
s272955551
|
p03448
|
u699699071
| 2,000
| 262,144
|
Wrong Answer
| 84
| 3,188
| 572
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
def hantei(n, m, l, d ):
if (n*500+m*100+l*50)==d:
print("n,m,l",n,m,l)
return True
return False
a = int(input()) #five
b = int(input()) #hund
c = int(input()) #fift
d = int(input()) #
n=m=l=0
result=0
while(n <= a):
m=l=0
while(m <= b):
l=0
while(l <= c):
# print("n,m,l",n,m,l)
if hantei(n,m,l,d)==True:
result += 1
l+=1
if hantei(n,m,l,d)==True:
result += 1
m+=1
if hantei(n,m,l,d)==True:
result += 1
n+=1
print(result)
|
s912873899
|
Accepted
| 85
| 3,064
| 584
|
def hantei(n, m, l, d ):
if (n*500+m*100+l*50)==d:
# print("GO n,m,l",n,m,l)
return True
return False
a = int(input()) #five
b = int(input()) #hund
c = int(input()) #fift
d = int(input()) #
n=m=l=0
result=0
while(n <= a):
while(m <= b):
while(l <= c):
# print("n,m,l",n,m,l)
if hantei(n,m,l,d)==True:
result += 1
l+=1
l=0
# result += 1
m+=1
# result += 1
m=l=0
n+=1
print(result)
|
s959821619
|
p02694
|
u542774596
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,144
| 125
|
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())
deposit = 100
for i in range(x):
deposit = int(deposit * 1.01)
if x < deposit:
print(i+1)
break
|
s448119839
|
Accepted
| 23
| 9,168
| 110
|
x = int(input())
deposit = 100
n = 0
while(x > deposit):
deposit = int(deposit * 1.01)
n += 1
print(n)
|
s499618873
|
p03779
|
u674588203
| 2,000
| 262,144
|
Wrong Answer
| 2,205
| 9,020
| 114
|
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
X=int(input())
ans=[0]
for i in range(1,10**9):
temp=ans[-1]+i
if temp>=X:
print(i)
break
|
s935585310
|
Accepted
| 41
| 10,664
| 135
|
X=int(input())
ans=[0]
for i in range(1,10**9):
temp=ans[-1]+i
ans.append(temp)
if temp>=X:
print(i)
exit()
|
s498904232
|
p03044
|
u391731808
| 2,000
| 1,048,576
|
Wrong Answer
| 521
| 71,424
| 462
|
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
#DFS
N = int(input())
UVW = [list(map(int,input().split())) for _ in [0]*(N-1)]
E = [{} for _ in [0]*N]
for u,v,c in UVW:
E[u-1][v-1] = c
E[v-1][u-1] = c
def dist_dfs_tree(N,E,root):
d = [0]*N
q = [root]
while q:
i = q.pop()
ci = d[i]
for j,cj in E[i].items():
if d[j] !=-1:continue
d[j] = ci+cj
q.append(j)
return d
d = dist_dfs_tree(N,E,0)
print(*[l%2 for l in d],sep="\n")
|
s252996398
|
Accepted
| 631
| 75,392
| 482
|
#DFS
N = int(input())
UVW = [list(map(int,input().split())) for _ in [0]*(N-1)]
E = [{} for _ in [0]*N]
for u,v,c in UVW:
E[u-1][v-1] = c
E[v-1][u-1] = c
def dist_dfs_tree(N,E,start):
d = [-1]*N
d[start] = 0
q = [start]
while q:
i = q.pop()
ci = d[i]
for j,cj in E[i].items():
if d[j] !=-1:continue
d[j] = ci+cj
q.append(j)
return d
d = dist_dfs_tree(N,E,0)
print(*[l%2 for l in d],sep="\n")
|
s822538976
|
p02678
|
u981767024
| 2,000
| 1,048,576
|
Wrong Answer
| 1,385
| 34,444
| 710
|
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.
|
# 2020/05/17
# Input
n, m = map(int, input().split())
plist = [[] for k in range(n+1)]
print(len(plist))
for i in range(m):
a, b = map(int, input().split())
plist[a].append(b)
plist[b].append(a)
visited = [0] * (n+1)
visited[0] = 10 ** 9
beforeidx = [0] * (n+1)
# BFS
q = list()
q.append(1)
while(len(q) > 0):
stidx = q.pop(0)
for j in range(len(plist[stidx])):
nextidx = plist[stidx][j]
if visited[nextidx] == 0:
q.append(nextidx)
beforeidx[nextidx] = stidx
visited[nextidx] = 1
if min(visited) > 0:
print('Yes')
for i in range(2, n+1):
print(beforeidx[i])
else:
print('No')
|
s768241994
|
Accepted
| 1,426
| 34,748
| 692
|
# 2020/05/17
# Input
n, m = map(int, input().split())
plist = [[] for k in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
plist[a].append(b)
plist[b].append(a)
visited = [0] * (n+1)
visited[0] = 10 ** 9
beforeidx = [0] * (n+1)
# BFS
q = list()
q.append(1)
while(len(q) > 0):
stidx = q.pop(0)
for j in range(len(plist[stidx])):
nextidx = plist[stidx][j]
if visited[nextidx] == 0:
q.append(nextidx)
beforeidx[nextidx] = stidx
visited[nextidx] = 1
if min(visited) > 0:
print('Yes')
for i in range(2, n+1):
print(beforeidx[i])
else:
print('No')
|
s537102298
|
p00015
|
u379956761
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,784
| 162
|
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".
|
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
n = int(input())
for _ in range(n):
x = int(input())
y = int(input())
print(x+y)
|
s027972645
|
Accepted
| 30
| 6,784
| 301
|
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys
import math
n = int(input())
result = 0
for i in range(n):
result = 0
x = int(input())
y = int(input())
result = x + y
length = len(str(result))
if length > 80:
print("overflow")
else:
print(result)
|
s165654459
|
p02694
|
u815878613
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 9,160
| 96
|
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())
A = 100
cnt = 0
while A <= X:
A = int(A * 1.01)
cnt += 1
print(cnt)
|
s433225200
|
Accepted
| 22
| 9,156
| 95
|
X = int(input())
A = 100
cnt = 0
while A < X:
A = int(A * 1.01)
cnt += 1
print(cnt)
|
s486220651
|
p02388
|
u965112171
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,504
| 29
|
Write a program which calculates the cube of a given integer x.
|
def cube(x):
return(x^3)
|
s010368324
|
Accepted
| 20
| 5,572
| 30
|
s = input()
print(int(s) **3)
|
s935695690
|
p03352
|
u981332890
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 2,940
| 45
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
num = input()
num = int(num)
print(num * num)
|
s465104756
|
Accepted
| 18
| 3,060
| 356
|
num = input()
num = int(num)
max = 1
for i in range(2,num):
beki = 2
cou = i**beki
while i**beki <= num:
beki += 1
if max < i ** (beki-1):
if beki > 2:
max = i ** (beki-1)
print(max)
|
s833622210
|
p03795
|
u668503853
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 72
|
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())
if n%15 == 0:print(800*n + 200 * n//15)
else:print(800*n)
|
s827606051
|
Accepted
| 17
| 2,940
| 52
|
n=int(input())
x = 800*n
y = 200 *(n//15)
print(x-y)
|
s648292061
|
p03997
|
u801864018
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,156
| 77
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print(((a + b) / 2 ) * h)
|
s343709556
|
Accepted
| 28
| 9,044
| 92
|
a = int(input())
b = int(input())
h = int(input())
area = int((a + b) * h / 2)
print(area)
|
s583784367
|
p03435
|
u540290227
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,208
| 254
|
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
result = 'No'
if sum(c1[:2]) == c1[2]:
if sum(c2[:2]) == c2[2]:
if sum(c2[:2]) == c3[2]:
result = 'Yes'
print(result)
|
s844327344
|
Accepted
| 29
| 9,060
| 229
|
c = []
for i in range(3):
c.append(list(map(int, input().split())))
for i in range(2):
for j in range(2):
if c[j][i+1] - c[j][i] != c[j+1][i+1] - c[j+1][i]:
print('No')
exit()
print('Yes')
|
s631212197
|
p03861
|
u129325056
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
ans = (b // x) - (a // x)
if a == 0:
ans += 1
print(ans)
|
s392655637
|
Accepted
| 18
| 2,940
| 103
|
a, b, x = map(int, input().split())
ans = (b // x) - (a // x)
if a % x == 0:
ans += 1
print(ans)
|
s876491692
|
p02381
|
u213265973
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,684
| 202
|
You have final scores of an examination for n students. Calculate standard deviation of the scores s1, s2 ... sn. The variance α2 is defined by α2 = (∑n _i_ =1(s _i_ \- m)2)/n where m is an average of si. The standard deviation of the scores is the square root of their variance.
|
import math
n = int(input())
score = [ int(i) for i in input().split(" ") ]
average = sum(score) / n
a2 = 0
for s in score:
a2 += (s - average) ** 2
print("{:.8f}".format( math.sqrt( a2 ) / 2 ) )
|
s623472575
|
Accepted
| 30
| 7,680
| 209
|
import math
while True:
n = int(input())
if n == 0:
break
s = [int(i) for i in input().split(" ")]
m = sum(s) / n
print("{:.8f}".format(math.sqrt(sum([(x-m) ** 2 for x in s]) / n)))
|
s706496276
|
p02843
|
u811436126
| 2,000
| 1,048,576
|
Wrong Answer
| 44
| 3,064
| 920
|
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
x = int(input())
n = x // 105 + 1
print(n)
flag = False
for a in range(n):
for b in range(n - a):
if b >= 0:
for c in range(n - b):
if c >= 0:
for d in range(n - c):
if d >= 0:
for e in range(n - d):
if e >= 0:
val = x - a * 100 - b * 101 - c * 102 - d * 103 - e * 104 - (
n - a - b - c - d - e) * 105
if val == 0:
flag = True
break
if flag:
break
if flag:
break
if flag:
break
if flag:
break
print(0) if flag == False else print(1)
|
s627408077
|
Accepted
| 42
| 3,956
| 295
|
x = int(input())
dp = [0] * 100001
dp[100] = dp[101] = dp[102] = dp[103] = dp[104] = dp[105] = 1
for i in range(106, 100001):
if dp[i - 100] == 1 or dp[i - 101] == 1 or dp[i - 102] == 1 or dp[i - 103] == 1 or dp[i - 104] == 1 or dp[
i - 105] == 1:
dp[i] = 1
print(dp[x])
|
s202449182
|
p03943
|
u371409687
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 112
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=map(int, input().split())
List=sorted([a,b,c], reverse=True)
if a+b==c:
print("Yes")
else: print("No")
|
s291372482
|
Accepted
| 17
| 2,940
| 115
|
a,b,c=map(int, input().split())
[x,y,z]=sorted([a,b,c], reverse=True)
if y+z==x:
print("Yes")
else: print("No")
|
s878133646
|
p03456
|
u034734062
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 40
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
x = ''.join(input().split())
print(x)
|
s110207254
|
Accepted
| 17
| 2,940
| 102
|
x = int(''.join(input().split()))
n = int(x ** .5)
if n ** 2 == x:
print('Yes')
else:
print('No')
|
s106056466
|
p03359
|
u007550226
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 56
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
A,B = map(int,input().split())
print(A+1 if A<=B else A)
|
s056658640
|
Accepted
| 18
| 2,940
| 56
|
A,B = map(int,input().split())
print(A if A<=B else A-1)
|
s350820433
|
p03352
|
u983967747
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 2,940
| 225
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
A=input()
a=int(A)
n1=0
n2=1
for i in range(a):
for x in range(a):
if n2 <= a:
n1=(i+2)**(x+2)
if n2 <= n1 and n1 <= a:
n2 = n1
#print(n2)
n1
|
s983100777
|
Accepted
| 617
| 3,060
| 247
|
A=input()
a=int(A)
b=round(a*(1/2))
n2=1
for i in range(2,b):
for x in range(2,b):
if n2 <= a:
n1=(i)**(x)
if n2 <= n1 and n1 <= a:
n2 = n1
#print(n2)
n1
print(n2)
|
s479565829
|
p03970
|
u936985471
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 99
|
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
|
a="C0DEFESTIVAL2O16"
s=input()
ans=0
for i in range(len(a)):
if a[i]!=s[i]:
ans+=1
print(ans)
|
s461405984
|
Accepted
| 17
| 2,940
| 100
|
a="CODEFESTIVAL2016"
s=input()
ans=0
for i in range(len(a)):
if a[i]!=s[i]:
ans+=1
print(ans)
|
s055177578
|
p02646
|
u357698450
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,476
| 332
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
import math
import sys
a,v=(int(x) for x in input().split())
b,w=(int(x) for x in input().split())
t = int(input())
e1=pow(10, -9)
e2=pow(10, 9)
if (a<e1)or(e2<a)or(b<e1)or(e2<b)or(v<1)or(e2<v)or(w<1)or(e2<w)or(t<1)or(e2<t)or(a==b):
sys.exit(0)
aa = a + v+t
bb = b + w+t
if (aa>=bb):
print("YES")
else :
print("NO")
|
s265970525
|
Accepted
| 21
| 9,160
| 323
|
import math
import sys
a,v=(int(x) for x in input().split())
b,w=(int(x) for x in input().split())
t = int(input())
e1=pow(-10, 9)
e2=pow(10, 9)
if (a<e1)or(e2<a)or(b<e1)or(e2<b)or(v<1)or(e2<v)or(w<1)or(e2<w)or(t<1)or(e2<t)or(a==b):
sys.exit(0)
ab = abs(b-a)/t+w-v
if ab<=0:
print("YES")
else :
print("NO")
|
s830883024
|
p02418
|
u519227872
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,400
| 144
|
Write a program which finds a pattern $p$ in a ring shaped text $s$.
|
import sys
lines = [line for line in sys.stdin]
s = lines[0] + lines[0]
p = lines[1]
if s.find(p) != -1:
print('Yes')
else:
print('No')
|
s370157418
|
Accepted
| 30
| 7,552
| 161
|
import sys
lines = [line.strip() for line in sys.stdin]
s = lines[0] + lines[0]
p = lines[1].strip()
if s.find(p) != -1:
print('Yes')
else:
print('No')
|
s496881518
|
p02612
|
u461454424
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,044
| 345
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
#atcoder template
def main():
import sys
imput = sys.stdin.readline
#input
n = int(input())
#output
while n >= 0:
n -= 1000
print(n + 1000)
if __name__ == "__main__":
main()
|
s127294128
|
Accepted
| 29
| 9,160
| 338
|
#atcoder template
def main():
import sys
imput = sys.stdin.readline
#input
n = int(input())
#output
while n > 0:
n -= 1000
print(-n)
if __name__ == "__main__":
main()
|
s121589156
|
p03545
|
u698176039
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 512
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
S = input()
N = len(S)-1
for i in range(2**N):
binary = bin(i)
binary = binary[2:].zfill(N)
sumsum = int(S[0])
for j in range(N):
if binary[j] == '0':
sumsum -= int(S[j+1])
else:
sumsum += int(S[j+1])
if sumsum == 7:
ans = S[0]
for j in range(N):
if binary[j] == '0':
ans += '-'
else:
ans += '+'
ans += S[j+1]
break
print(ans)
|
s918534509
|
Accepted
| 17
| 3,064
| 541
|
S = input()
N = len(S)-1
for i in range(2**N):
binary = bin(i)
binary = binary[2:].zfill(N)
sumsum = int(S[0])
for j in range(N):
if binary[j] == '0':
sumsum -= int(S[j+1])
else:
sumsum += int(S[j+1])
if sumsum == 7:
ans = S[0]
for j in range(N):
if binary[j] == '0':
ans += '-'
else:
ans += '+'
ans += S[j+1]
ans += '=7'
break
print(ans)
|
s445035960
|
p03351
|
u864453204
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 120
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
l = list(map(int, input().split()))
k = l[-1]
l.pop()
if max(l) - min(l) <= k:
print('Yes')
else:
print('No')
|
s246504772
|
Accepted
| 17
| 3,060
| 212
|
l = list(map(int, input().split()))
k = l[-1]
l.pop()
if abs(l[0] - l[2]) <= k:
print('Yes')
else:
if abs(l[0] - l[1]) <= k and abs(l[1] - l[2]) <= k:
print('Yes')
else:
print('No')
|
s136877595
|
p04044
|
u071002307
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 140
|
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 = []
for x in range(N):
S.append(input())
S = sorted(S)
for x in range(N):
print(S[x], end=" ")
|
s686053780
|
Accepted
| 17
| 3,060
| 113
|
N, L = map(int, input().split())
S = []
for x in range(N):
S.append(input())
S = sorted(S)
print("".join(S))
|
s612025958
|
p03999
|
u405483159
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 207
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
s = input()
def dfs( i, f ):
if i == len( s ) - 1:
return sum( list( map( int, f.split( "+" ))))
return dfs( i + 1, f + s[ i + 1 ] ) + dfs( i + 1, f + "+" + s[ i + 1 ])
dfs( 0, s[ 0 ])
|
s567313823
|
Accepted
| 18
| 3,060
| 219
|
s = input()
def dfs( i, f ):
if i == len( s ) - 1:
return sum( list( map( int, f.split( "+" ))))
return dfs( i + 1, f + s[ i + 1 ] ) + dfs( i + 1, f + "+" + s[ i + 1 ])
print( dfs( 0, s[ 0 ]) )
|
s182055520
|
p02393
|
u711765449
| 1,000
| 131,072
|
Wrong Answer
| 40
| 7,656
| 159
|
Write a program which reads three integers, and prints them in ascending order.
|
# -*- coding:utf-8 -*-
string = input()
array = string.split()
x = [int(array[0]),int(array[1]),int(array[2])]
y = sorted(x)
for value in y:
print(value)
|
s430780825
|
Accepted
| 20
| 7,648
| 135
|
in_str = input().split(" ")
in_int = sorted(list(map(int, in_str)))
in_sstr = list(map(str, in_int))
tes = " ".join(in_sstr)
print(tes)
|
s982368348
|
p02743
|
u781758937
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 178
|
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
import math
a,b,c = map(int,input().split())
sqa = math.sqrt(a)
sqb = math.sqrt(b)
sqc = math.sqrt(c)
print(sqa,sqb,sqc)
if sqa + sqb < sqc:
print("Yes")
else:
print("No")
|
s026699198
|
Accepted
| 17
| 3,060
| 175
|
import math
a,b,c = map(int,input().split())
left = 4*a*b
right = (c-a-b)**2
if a+b-c > 2*math.sqrt(a*b):
print("No")
elif left < right:
print("Yes")
else:
print("No")
|
s128421163
|
p02844
|
u839188633
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,104
| 3,316
| 234
|
AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? Both the lucky number and the PIN code may begin with a 0.
|
N = int(input())
S = input()
S = "1234" * 3000
from itertools import product
from re import search
ans = 0
for i in product(map(str, range(10)), repeat=3):
res = search(".*?".join(i), S)
if res:
ans += 1
print(ans)
|
s060101006
|
Accepted
| 751
| 3,188
| 232
|
from itertools import product
N = int(input())
S = input()
one = set()
two = set()
three = set()
for s in S:
for tw in two:
three.add(tw + s)
for on in one:
two.add(on + s)
one.add(s)
print(len(three))
|
s087380559
|
p03673
|
u514894322
| 2,000
| 262,144
|
Wrong Answer
| 124
| 25,536
| 209
|
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
from collections import deque
ans = deque()
n=int(input())
*l, = map(int,input().split())
r=True
for i in l:
if r:
r=False
ans.append(i)
else:
r=True
ans.appendleft(i)
print(list(ans))
|
s889154326
|
Accepted
| 159
| 32,964
| 269
|
from collections import deque
ans = deque()
n=int(input())
*l, = map(int,input().split())
r=True
for i in l:
if r:
r=False
ans.append(i)
else:
r=True
ans.appendleft(i)
s = [str(i) for i in ans]
if len(l)%2 == 1:
s.reverse()
print(' '.join(s))
|
s574587553
|
p03455
|
u836690557
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int,input().split())
if a * b % 2 == 0:
print("even")
else:
print("odd")
|
s030063099
|
Accepted
| 19
| 2,940
| 91
|
a, b = map(int,input().split())
if a * b % 2 == 0:
print("Even")
else:
print("Odd")
|
s145826214
|
p03457
|
u178389763
| 2,000
| 262,144
|
Wrong Answer
| 323
| 3,060
| 160
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if x + y < t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
|
s945411990
|
Accepted
| 383
| 3,060
| 293
|
n = int(input())
pre_t,pre_x,pre_y=0, 0, 0
for i in range(n):
t, x, y = map(int, input().split())
d_t = t-pre_t
d_x = abs(x-pre_x)
d_y = abs(y-pre_y)
if d_x + d_y > d_t or (d_x + d_y + d_t) % 2:
print("No")
quit()
pre_t,pre_x,pre_y=t, x, y
print("Yes")
|
s898007559
|
p03338
|
u599547273
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 3,060
| 255
|
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.
|
def same_count(str_list):
standard_str = min(str_list, key=lambda x: len(x))
return [all([c in str_ for str_ in str_list]) for c in standard_str].count(True)
n = int(input())
s = input()
print(max([same_count([s[:i], s[i:]]) for i in range(n)]))
|
s570928244
|
Accepted
| 17
| 3,060
| 199
|
n = int(input())
s = input()
max_same_count = 0
for i in range(1, n):
same_count = len(set(s[:i]) & set(s[i:]))
if max_same_count < same_count:
max_same_count = same_count
print(max_same_count)
|
s511874497
|
p03863
|
u969190727
| 2,000
| 262,144
|
Wrong Answer
| 48
| 3,316
| 259
|
There is a string s of length 3 or greater. No two neighboring characters in s are equal. Takahashi and Aoki will play a game against each other. The two players alternately performs the following operation, Takahashi going first: * Remove one of the characters in s, excluding both ends. However, a character cannot be removed if removal of the character would result in two neighboring equal characters in s. The player who becomes unable to perform the operation, loses the game. Determine which player will win when the two play optimally.
|
s=input()
a,b=s[0],s[-1]
ct=0
n=len(s)
cur=a
for i in range(1,n-1):
if cur==a:
if s[i]==b:
cur=b
continue
else:
ct+=1
else:
if s[i]==a:
cur=a
continue
else:
ct+=1
print("First" if ct%2==1 else "Second")
|
s361471142
|
Accepted
| 17
| 3,316
| 132
|
s=input()
a,b=s[0],s[-1]
n=len(s)
if a==b:
print("First" if n%2==0 else "Second")
else:
print("First" if n%2==1 else "Second")
|
s870981471
|
p03997
|
u943624079
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,064
| 61
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s466270579
|
Accepted
| 22
| 3,064
| 66
|
a=int(input())
b=int(input())
h=int(input())
print(int((a+b)*h/2))
|
s105210902
|
p03386
|
u442877951
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 104
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
A,B,K = map(int,input().split())
for i in range(1,K+1):
print(A+i)
for i in range(1,K+1):
print(B-1)
|
s942683526
|
Accepted
| 17
| 3,060
| 247
|
A,B,K = map(int,input().split())
n = 0
ans = []
for i in range(K):
n = i
if A+i <= B:
ans.append(A+i)
else:
break
for j in range(K-1,-1,-1):
if B-j > A+n:
ans.append(B-j)
ans.sort()
for k in range(len(ans)):
print(ans[k])
|
s173955898
|
p03416
|
u191635495
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,188
| 284
|
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
|
A, B = map(int, input().split())
res = 0
for i in range(10):
for j in range(10):
for k in range(10):
cand = int(''.join([str(i), str(j), str(k), str(j), str(i)]))
if A <= cand <= B:
print(cand)
res += 1
print(res)
|
s260886338
|
Accepted
| 19
| 3,060
| 256
|
A, B = map(int, input().split())
res = 0
for i in range(10):
for j in range(10):
for k in range(10):
cand = int(''.join([str(i), str(j), str(k), str(j), str(i)]))
if A <= cand <= B:
res += 1
print(res)
|
s794646149
|
p03360
|
u879870653
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 102
|
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
L = sorted(list(map(int,input().split())))
k = int(input())
L[-1] = 2**k*L[-1]
print(sum(L))
print(L)
|
s195023258
|
Accepted
| 17
| 2,940
| 93
|
L = sorted(list(map(int,input().split())))
k = int(input())
L[-1] = 2**k*L[-1]
print(sum(L))
|
s275467027
|
p03494
|
u364429138
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 291
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
for_num = int(input())
nums = input()
nums = nums.split()
count = 0
Tf = True
while Tf:
count += 1
for i in range(0,for_num):
num = int(nums[i])
if num%2 == 0:
nums[i] = int(num/2)
Tf = True
else:
Tf = False
print(count-1)
|
s536643294
|
Accepted
| 20
| 3,064
| 309
|
for_num = int(input())
nums = input()
nums = nums.split()
count = 0
Tf = True
while Tf:
count += 1
for i in range(0,for_num):
num = int(nums[i])
if num%2 == 0:
nums[i] = int(num/2)
Tf = True
else:
Tf = False
break
print(count-1)
|
s539622007
|
p03371
|
u768896740
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 554
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a, b, c, x, y = map(int, input().split())
if 2 * c < min(a, b):
ans = 2 * c * max(x, y)
elif 2 * c >= max(a, b):
ans = a * x + b * y
else:
ans_1 = 2 * c * min(x, y)
if a <= 2 * c < b and x < y:
ans_2 = 2 * c * (y - min(x, y))
ans = ans_1 + ans_2
elif b <= 2 * c < a and x > y:
ans_2 = 2 * c * (x - min(x, y))
ans = ans_1 + ans_2
elif x > y:
ans_2 = (x - min(x, y)) * a
ans = ans_1 + ans_2
elif y > x:
ans_2 = (y - min(x, y)) * b
ans = ans_2 + ans_1
print(ans)
|
s297842820
|
Accepted
| 20
| 3,188
| 169
|
a,b,c,x,y = map(int, input().split())
sum1 = a*x + b*y
num = min(x, y)
sum2 = num * 2 * c + a*(x-num) + b*(y-num)
sum3 = max(x,y) * 2 * c
print(min(sum1, sum2, sum3))
|
s241064902
|
p03044
|
u171366497
| 2,000
| 1,048,576
|
Wrong Answer
| 2,106
| 61,052
| 540
|
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
N=int(input())
color=[-1]*N
from collections import defaultdict
branch=defaultdict(dict)
check=[]
for i in range(N-1):
u,v,w=map(int,input().split())
branch[u-1][v-1]=w
branch[v-1][u-1]=w
if w%2==1:
check+=[u-1,v-1]
if len(check)>0:
color[check[-1]]=0
while len(check)>0:
now=check.pop()
for nex,w in branch[now].items():
if w%2==1 and color[nex]==-1:
color[nex]=(color[now]+1)%2
check+=[nex]
color=[i if i!=-1 else 0 for i in color]
for i in range(N):
print(color[i])
|
s678640304
|
Accepted
| 752
| 54,588
| 440
|
N=int(input())
from collections import defaultdict
branch=defaultdict(dict)
for i in range(N-1):
u,v,w=map(int,input().split())
u-=1
v-=1
branch[u][v]=w
branch[v][u]=w
dist=[float('inf')]*N
dist[0]=0
check={0}
while len(check)>0:
now=check.pop()
for nex,d in branch[now].items():
if dist[nex]>dist[now]+d:
dist[nex]=dist[now]+d
check|={nex}
for i in range(N):
print(dist[i]%2)
|
s055093321
|
p03024
|
u666198201
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 146
|
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.
|
str=input()
n=len(str)
count=0
for a in range(n):
if str[a]== "o":
count +=1
if count+15-n>=8:
print("yes")
else:
print("no")
|
s432637203
|
Accepted
| 17
| 2,940
| 146
|
str=input()
n=len(str)
count=0
for a in range(n):
if str[a]== "o":
count +=1
if count+15-n>=8:
print("YES")
else:
print("NO")
|
s156780458
|
p04045
|
u609061751
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 278
|
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.
|
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
D = [str(x) for x in input().rstrip()]
D = set(D)
for i in range(N, N + 10 ** 4):
i_list = list(str(i))
for j in i_list:
if j in D:
break
print(i)
sys.exit()
|
s119162255
|
Accepted
| 82
| 3,060
| 341
|
import sys
input = sys.stdin.readline
N, K = [int(x) for x in input().split()]
D = [str(x) for x in input().rstrip().split()]
D = set(D)
for i in range(N, N + 10 ** 6):
i_list = list(str(i))
flag = 1
for j in i_list:
if j in D:
flag = 0
break
if flag:
print(i)
sys.exit()
|
s373193347
|
p04030
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s=input()
ls=[]
for i in range(len(s)):
if i!="B":
ls.append(i)
elif ls!=[]:
del ls[-1]
print(*ls,sep="")
|
s394657904
|
Accepted
| 17
| 2,940
| 123
|
s=input()
ls=[]
for i in range(len(s)):
if s[i]!="B":
ls.append(s[i])
elif ls!=[]:
del ls[-1]
print(*ls,sep="")
|
s739267046
|
p03761
|
u863370423
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 466
|
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
n = int(input())
alp = [chr(i) for i in range(97, 97+26)]
ans = []
de = []
for i in range(n):
a = list(input())
a.sort()
if i == 0:
ans = a
else:
k = 0
while k < len(a):
if k >= len(ans):
break
if a[k] < ans[k]:
del a[k]
elif a[k] == ans[k]:
k += 1
elif a[k] > ans[k]:
del ans[k]
for i in ans:
print(i, end="")
|
s562479517
|
Accepted
| 20
| 3,188
| 433
|
N = int(input())
s_list = []
s_set = []
for i in range(N):
s_list.append(list(x for x in input()))
for i in s_list:
s_set.append(set(i))
result_char = {x for x in 'qwertyuiopasdfghjklzxcvbnm'}
for i in range(N-1):
result_char = (s_set[i] & s_set[i+1] & result_char)
result_char = list(result_char)
result_char.sort()
result = ''
for i in result_char:
count = min(x.count(i) for x in s_list)
result += i*count
print(result)
|
s865339412
|
p00001
|
u982618289
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,388
| 152
|
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
mt = []
for i in range(10):
mt.append(input())
print(mt.pop(mt.index(max(mt))))
print(mt.pop(mt.index(max(mt))))
print(mt.pop(mt.index(max(mt))))
|
s022989280
|
Accepted
| 20
| 7,644
| 116
|
mt = []
for i in range(10):
mt.append(int(input()))
mt.sort()
print( mt[9] )
print( mt[8] )
print( mt[7] )
|
s776966206
|
p03861
|
u019584841
| 2,000
| 262,144
|
Wrong Answer
| 2,108
| 3,316
| 100
|
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())
count=0
for i in range(a,b+1):
if i%x==0:
count=+1
print(count)
|
s303025728
|
Accepted
| 18
| 3,060
| 73
|
a, b, x = [int(x) for x in input().split()]
print(b // x - (a - 1) // x)
|
s286598202
|
p03814
|
u284102701
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,720
| 53
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s=input()
a=s.find("A")
b=s.rfind("Z")
print(s[a:b])
|
s840935992
|
Accepted
| 18
| 3,512
| 53
|
s=input()
a=s.find("A")
b=s.rfind("Z")
print(b-a+1)
|
s508750399
|
p03544
|
u006187236
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 138
|
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())
array=[0 for i in range(87)]
array[0]=2
array[1]=1
for i in range(2, N):
array[i]=array[i-1]+array[i-2]
print(array[N-1])
|
s845779736
|
Accepted
| 18
| 3,060
| 138
|
N=int(input())
array=[0 for i in range(87)]
array[0]=2
array[1]=1
for i in range(2, N+1):
array[i]=array[i-1]+array[i-2]
print(array[N])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.