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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s176887730
|
p03544
|
u743164083
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 143
|
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())
def luc(a, b, n):
if n > 0:
print(a,b)
return luc(b,a+b,n-1)
else:
return a
print(luc(2,1,n))
|
s114159871
|
Accepted
| 17
| 3,060
| 124
|
n = int(input())
def luc(a, b, n):
if n > 0:
return luc(b,a+b,n-1)
else:
return a
print(luc(2,1,n))
|
s911284294
|
p03110
|
u244459371
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 172
|
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())
ans = 0
for i in range(n):
a, b = input().split()
a = float(a)
if (b == 'JPY'):
ans += a;
else:
ans += a * 38000
print(ans)
|
s567646031
|
Accepted
| 17
| 2,940
| 177
|
n = int(input())
ans = 0
for i in range(n):
a, b = input().split()
a = float(a)
if (b == 'JPY'):
ans += a;
else:
ans += a * 38000 * 10
print(ans)
|
s391955661
|
p00001
|
u032780311
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,328
| 147
|
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.
|
# your code goes here
import sys
a=[]
for line in sys.stdin:
tmp=line.split(" ")
a.append(tmp[-1])
a.sort(reverse=True)
for i in a:
print(i)
|
s358448697
|
Accepted
| 50
| 7,612
| 234
|
# your code goes here
import sys
a=[]
for line in sys.stdin:
line.rstrip('rn')
tmp=line.split(" ")
a.append(int(tmp[-1]))
a.sort(reverse=True)
y=0
for i in a:
if y==3:
break
if i>=0 and i<=10000:
print(i)
y=y+1
|
s057610106
|
p03623
|
u224050758
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
X, A, B = [int(s) for s in input().split()]
print('A' if abs(X - A) > abs(X - B) else 'B')
|
s237544870
|
Accepted
| 17
| 2,940
| 90
|
X, A, B = [int(s) for s in input().split()]
print('A' if abs(X - A) < abs(X - B) else 'B')
|
s008832679
|
p02612
|
u368185034
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,016
| 54
|
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.
|
price = int(input())
amari = price % 1000
print(amari)
|
s129417270
|
Accepted
| 29
| 9,152
| 95
|
price = int(input())
amari = price % 1000
if amari == 0:
print(0)
else:
print(1000 - amari)
|
s982849385
|
p03729
|
u952130512
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 90
|
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a,b,c=input().split()
if a[1:]==b[:1] and b[1:]==c[:1]:
print("YES")
else:
print("NO")
|
s301853257
|
Accepted
| 17
| 2,940
| 92
|
a,b,c=input().split()
if a[-1:]==b[:1] and b[-1:]==c[:1]:
print("YES")
else:
print("NO")
|
s690565174
|
p02694
|
u152402277
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,092
| 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?
|
import math
K = input()
K = float(K)
X = 100.0
i = 0
while K >= X:
X = X *1.01
X = math.floor(X)
i = i + 1
print(i)
|
s379320742
|
Accepted
| 23
| 9,028
| 124
|
import math
K = input()
K = float(K)
X = 100.0
i = 0
while K > X:
X = X *1.01
X = math.floor(X)
i = i + 1
print(i)
|
s943312989
|
p02612
|
u941438707
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,080
| 24
|
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.
|
print(1000-int(input()))
|
s687878315
|
Accepted
| 28
| 9,028
| 32
|
print((10000-int(input()))%1000)
|
s518257070
|
p03795
|
u226912938
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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())
x = 800 * n
y = int(n // 15)
ans = x-y
print(ans)
|
s375452112
|
Accepted
| 35
| 3,316
| 72
|
n = int(input())
x = 800 * n
y = int(n // 15) * 200
ans = x-y
print(ans)
|
s739169400
|
p03416
|
u434765278
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 127
|
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())
if A == 1 and B == 1:
print(1)
elif A == 1 and B!= 1:
print(B-2)
else:
print((A-2)*(B-2))
|
s111568915
|
Accepted
| 84
| 2,940
| 145
|
A,B = map(int,input().split())
ans = 0
for i in range(A,B+1):
k = str(i)
if str(k[0]+k[1]) == str(k[4]+k[3]):
ans += 1
print(ans)
|
s994590199
|
p03997
|
u280096880
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
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)
|
s883805077
|
Accepted
| 17
| 2,940
| 72
|
A = int(input())
B = int(input())
H = int(input())
print(int((A+B)*H/2))
|
s622852317
|
p03827
|
u419963262
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 155
|
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
N=int(input())
S=input()
ans=0
max_ans=0
for i in range(N):
if i=='I':
ans+=1
if max_ans<ans:
max_ans=ans
else:
ans-=1
print(max_ans)
|
s183722189
|
Accepted
| 17
| 2,940
| 148
|
N=int(input())
S=input()
ans=0
max_ans=0
for i in S:
if i=='I':
ans+=1
if max_ans<ans:
max_ans=ans
else:
ans-=1
print(max_ans)
|
s590295308
|
p03478
|
u327248573
| 2,000
| 262,144
|
Wrong Answer
| 62
| 3,424
| 295
|
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
# -- coding: utf-8 --
args = input().split(' ')
limit = int(args[0])
lower = int(args[1])
upper = int(args[2])
sums = 0
for n in range(1, limit + 1):
print(list(str(n)))
order = sum(map(int, list(str(n))))
print(order)
if lower <= order <= upper:
sums += n
print(sums)
|
s191345483
|
Accepted
| 34
| 2,940
| 216
|
# -- coding: utf-8 --
limit, lower, upper = map(int, input().split(' '))
sums = 0
for n in range(1, limit + 1):
order = sum(map(int, list(str(n))))
if lower <= order <= upper:
sums += n
print(sums)
|
s559549648
|
p02692
|
u366886346
| 2,000
| 1,048,576
|
Wrong Answer
| 135
| 9,188
| 519
|
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
|
n,a,b,c=map(int,input().split())
ab=0
ac=0
bc=0
for i in range(n):
s=input()
if s=="AB":
ab+=1
elif s=="AC":
ac+=1
else:
bc+=1
ab2=ab%2
ac2=ac%2
bc2=bc%2
if ab2==1 and a+b==0:
print("No")
elif ac2==1 and a+c==0:
print("No")
elif bc2==1 and b+c==0:
print("No")
elif ab2+ac2==2 and a+b+c<2:
print("No")
elif ab2+bc2==2 and a+b+c<2:
print("No")
elif bc2+ac2==2 and a+b+c<2:
print("No")
elif ab2+ac2+bc2==3 and a+b+c<3:
print("No")
else:
print("Yes")
|
s956626216
|
Accepted
| 229
| 17,036
| 2,002
|
n,a,b,c=map(int,input().split())
ans=[]
slist=[]
for i in range(n):
s=input()
slist.append(s)
for i in range(n):
s=slist[i]
if s=="AB":
if a==0:
a+=1
b-=1
ans.append("A")
elif b==0:
a-=1
b+=1
ans.append("B")
elif slist[(i+1)%n]=="AB":
if a>b:
a-=1
b+=1
ans.append("B")
else:
a+=1
b-=1
ans.append("A")
elif slist[(i+1)%n]=="AC":
a+=1
b-=1
ans.append("A")
else:
a-=1
b+=1
ans.append("B")
elif s=="AC":
if a==0:
a+=1
c-=1
ans.append("A")
elif c==0:
a-=1
c+=1
ans.append("C")
elif slist[(i+1)%n]=="AC":
if a>c:
a-=1
c+=1
ans.append("C")
else:
a+=1
c-=1
ans.append("A")
elif slist[(i+1)%n]=="AB":
a+=1
c-=1
ans.append("A")
else:
a-=1
c+=1
ans.append("C")
else:
if b==0:
b+=1
c-=1
ans.append("B")
elif c==0:
b-=1
c+=1
ans.append("C")
elif slist[(i+1)%n]=="BC":
if b>c:
b-=1
c+=1
ans.append("C")
else:
b+=1
c-=1
ans.append("B")
elif slist[(i+1)%n]=="AC":
c+=1
b-=1
ans.append("C")
else:
c-=1
b+=1
ans.append("B")
if a<0 or b<0 or c<0:
ans.clear()
break
if len(ans)==0:
print("No")
else:
print("Yes")
for i in range(n):
print(ans[i])
|
s710389393
|
p03737
|
u859897687
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 44
|
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=input().split()
print(a[0]+b[0]+c[0])
|
s651026070
|
Accepted
| 17
| 2,940
| 52
|
a,b,c=input().upper().split()
print(a[0]+b[0]+c[0])
|
s927327262
|
p04044
|
u980753441
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,052
| 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 i in range(n)]
s.sort()
"".join(s)
|
s218872947
|
Accepted
| 28
| 9,104
| 91
|
n, l = map(int, input().split())
s = [input() for i in range(n)]
s.sort()
print("".join(s))
|
s911897116
|
p03549
|
u571867512
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
|
N,M = map(int,input().split())
p = 1-(1/2)**M
print((1900 * M + 100 * (N - M)) / (1 - p))
|
s848942647
|
Accepted
| 17
| 2,940
| 116
|
N,M = map(int,input().split())
p = 1-(1/2)**M
time = 1900 * M + 100 * (N - M)
ans = time / (1 - p)
print(int(ans))
|
s602193955
|
p02255
|
u995990363
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 365
|
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
print(' '.join([str(a) for a in A]))
def run():
N = int(input())
A = [int(i) for i in input().split()]
insertionSort(A,N)
if __name__ == '__main__':
run()
|
s762486486
|
Accepted
| 20
| 5,608
| 406
|
def insertionSort(A,N):
print(' '.join([str(a) for a in A]))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join([str(a) for a in A]))
def run():
N = int(input())
A = [int(i) for i in input().split()]
insertionSort(A,N)
if __name__ == '__main__':
run()
|
s195838524
|
p03672
|
u713627549
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 193
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
#s = list(input())
s = input()
n = len(s)
count = 0
if n % 2 == 1:
count += 1
while s[0 : int((n-count)/2)] != s[int((n-count)/2) : n-count]:
count += 2
print(count)
|
s100634577
|
Accepted
| 17
| 2,940
| 205
|
#s = list(input())
s = input()
n = len(s)
count = 1
if n % 2 == 1 - count:
count += 1
while s[0 : int((n-count)/2)] != s[int((n-count)/2) : n-count]:
count += 2
print(n-count)
|
s097048439
|
p03044
|
u892251744
| 2,000
| 1,048,576
|
Wrong Answer
| 919
| 60,440
| 714
|
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.
|
from collections import deque
N = int(input())
branch = [list(map(int, input().split())) for _ in range(N-1)]
adj = [[] for _ in range(N+1)]
for b in branch:
adj[b[0]].append([b[1],b[2]])
adj[b[1]].append([b[0],b[2]])
ans = [-1] * (N+1)
deq = deque()
deq.appendleft(1)
while len(deq) > 0:
v = deq.pop()
for u, w in adj[v]:
if ans[u] == -1:
deq.appendleft(u)
if ans[v] == -1 and ans[u] == -1:
if w % 2 == 0:
ans[v] = 0
ans[u] = 0
else:
ans[v] = 0
ans[u] = 1
elif ans[v] == 0:
if w % 2 == 0:
ans[u] = 0
else:
ans[u] = 1
else:
if w % 2 == 0:
ans[u] = 1
else:
ans[u] = 0
print(ans[1:])
|
s266572390
|
Accepted
| 1,022
| 59,668
| 770
|
from collections import deque
N = int(input())
branch = [list(map(int, input().split())) for _ in range(N-1)]
adj = [[] for _ in range(N+1)]
for b in branch:
adj[b[0]].append([b[1],b[2]])
adj[b[1]].append([b[0],b[2]])
ans = [-1] * (N+1)
deq = deque()
deq.appendleft(1)
while len(deq) > 0:
v = deq.pop()
for u, w in adj[v]:
if ans[u] == -1:
deq.appendleft(u)
if ans[v] == -1 and ans[u] == -1:
if w % 2 == 0:
ans[v] = 0
ans[u] = 0
else:
ans[v] = 0
ans[u] = 1
elif ans[v] == 0:
if w % 2 == 0:
ans[u] = 0
else:
ans[u] = 1
else:
if w % 2 == 0:
ans[u] = 1
else:
ans[u] = 0
if N == 1:
print(0)
else:
for i in range(1,N+1):
print(ans[i])
|
s356566886
|
p02612
|
u472618289
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,152
| 48
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
import math
n=int(input())
print(math.ceil(n)-n)
|
s162589011
|
Accepted
| 33
| 8,952
| 64
|
import math
n=int(input())
k=(math.ceil(n/1000)*1000-n)
print(k)
|
s508906587
|
p03023
|
u316322317
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 34
|
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)*180//2)
|
s786014232
|
Accepted
| 17
| 2,940
| 32
|
n=int(input())
print((n-2)*180)
|
s659351686
|
p03493
|
u256464928
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 52
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s = list(map(int,input().split()))
print(s.count(1))
|
s515711738
|
Accepted
| 17
| 2,940
| 31
|
s = input()
print(s.count("1"))
|
s417329996
|
p02390
|
u429841998
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 133
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
second = int(input())
h = second // 360
m = (second % 360) // 60
s = (second % 360) % 60
print(str(h) + ':' + str(m) + ':' + str(s))
|
s568228784
|
Accepted
| 20
| 5,588
| 136
|
second = int(input())
h = second // 3600
m = (second % 3600) // 60
s = (second % 3600) % 60
print(str(h) + ':' + str(m) + ':' + str(s))
|
s921607599
|
p02409
|
u921541953
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,656
| 759
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
n = int(input())
public_hall = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
input_info = []
for b in range(4):
for f in range(3):
for r in range(10):
public_hall[b][f].append(0)
for i in range(n):
input_info.append(input().split())
input_info[i] = list(map(int, input_info[i]))
for j in range(n):
public_hall[input_info[j][0] - 1][input_info[j][1] - 1][input_info[j][2] - 1] += input_info[j][3]
# ??????
for k in range(4):
for l in range(3):
for m in range(10):
print('', public_hall[k][l][m],end='')
print()
for n in range(20):
print('#',end='')
print()
|
s985360839
|
Accepted
| 20
| 7,688
| 611
|
n = int(input())
public_hall = [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]]
input_info = []
for b in range(4):
for f in range(3):
for r in range(10):
public_hall[b][f].append(0)
for i in range(n):
input_info.append(input().split())
input_info[i] = list(map(int, input_info[i]))
for j in range(n):
public_hall[input_info[j][0] - 1][input_info[j][1] - 1][input_info[j][2] - 1] += input_info[j][3]
for k in range(4):
for l in range(3):
for m in range(10):
print('', public_hall[k][l][m],end='')
print()
if k != 3:
print('#' * 20)
|
s776418989
|
p03095
|
u509368316
| 2,000
| 1,048,576
|
Wrong Answer
| 38
| 3,188
| 187
|
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
n=int(input())
s=input()
c=[0]*26
x=10**9+7
ans=0
for chr in range(n):
c[ord(s[chr])-97]+=1
for i in range(26):
ans=((ans%x)*((c[i]+1)%x))%x
ans+=c[i]
ans%=x
print(ans,c)
|
s147565839
|
Accepted
| 38
| 3,188
| 185
|
n=int(input())
s=input()
c=[0]*26
x=10**9+7
ans=0
for chr in range(n):
c[ord(s[chr])-97]+=1
for i in range(26):
ans=((ans%x)*((c[i]+1)%x))%x
ans+=c[i]
ans%=x
print(ans)
|
s839777151
|
p03644
|
u714300041
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 64
|
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
num = 1
while num < N:
num *= 2
print(num)
|
s271505361
|
Accepted
| 151
| 12,100
| 432
|
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import bisect
import numpy as np
N = int(input())
maxi_num = 0
ans = 1
def div_count(x):
num = 0
while True:
if x % 2 == 0:
x /= 2
num += 1
else:
break
return num
for i in range(1, N+1):
count = div_count(i)
if maxi_num < count:
maxi_num = count
ans = i
print(ans)
|
s392214395
|
p03556
|
u350179603
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,188
| 103
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n = int(input())
ans = 1
for i in range(1,n+1):
if i**(1/2) == int(i**(1/2)):
ans = 1
print(i)
|
s485689636
|
Accepted
| 17
| 2,940
| 40
|
n = int(input())
print(int(n**(0.5))**2)
|
s805653889
|
p03962
|
u102126195
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 137
|
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
a, b, c = map(int, input().split())
count = 1
if a != b:
count += 1
if b != c:
count += 1
if c != a:
count += 1
print(count)
|
s889987939
|
Accepted
| 17
| 2,940
| 122
|
a, b, c = map(int, input().split())
count = 1
if a != b:
count += 1
if b != c and c != a:
count += 1
print(count)
|
s802484507
|
p03486
|
u069129582
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 79
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s=sorted(input())
t=sorted(input(), reverse=True)
print('YES' if s<t else 'NO')
|
s229827557
|
Accepted
| 17
| 2,940
| 80
|
s=sorted(input())
t=sorted(input(), reverse=True)
print('Yes' if s<t else 'No')
|
s118852575
|
p03473
|
u366959492
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 36
|
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
m=int(input())
x=24+(24-m)
print(m)
|
s694786817
|
Accepted
| 17
| 2,940
| 36
|
m=int(input())
x=24+(24-m)
print(x)
|
s402082216
|
p03352
|
u408375121
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,105
| 27,544
| 141
|
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.
|
X = int(input())
l = []
for i in range(int(X ** 0.5) + 1):
j = 2
while i ** j <= X:
l.append(i ** j)
j += 1
l.sort()
print(l[-1])
|
s066011226
|
Accepted
| 17
| 3,060
| 186
|
X = int(input())
l = []
if X < 4:
print(1)
else:
for i in range(2, int(X ** 0.5) + 1):
j = 2
while i ** j <= X:
l.append(i ** j)
j += 1
l.sort()
print(l[-1])
|
s042057506
|
p02393
|
u838759969
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,560
| 115
|
Write a program which reads three integers, and prints them in ascending order.
|
inputStr = input()
numList = inputStr.split(' ')
numList = [int(x) for x in numList]
numList.sort()
print(numList)
|
s714904703
|
Accepted
| 20
| 7,668
| 260
|
inputStr = input()
numList = inputStr.split(' ')
numList = [int(x) for x in numList]
numList.sort()
outputStr = ''
count = len(numList)
for z in numList:
outputStr = outputStr + str(z)
count-=1
if count>0 :
outputStr+=' '
print(outputStr)
|
s386448725
|
p03371
|
u845333844
| 2,000
| 262,144
|
Wrong Answer
| 107
| 3,064
| 193
|
"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())
p1=a*x+b*y
min=10**9
for i in range(10**5+1):
p2=2*i*c+max(0,x-i)*a+max(0,y-i)*b
if p2<min:
min=p2
if p2<p1:
print(p2)
else:
print(p1)
|
s399976232
|
Accepted
| 112
| 3,060
| 195
|
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
min=10**9
for i in range(10**5+1):
p2=2*i*c+max(0,x-i)*a+max(0,y-i)*b
if p2<min:
min=p2
if min<p1:
print(min)
else:
print(p1)
|
s842148904
|
p03852
|
u123273712
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 107
|
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`.
|
a = str(input())
boin = ["a","e","i","o","u"]
if a in boin:
print("voewl")
else:
print("consonant")
|
s396951433
|
Accepted
| 19
| 2,940
| 107
|
a = str(input())
boin = ["a","e","i","o","u"]
if a in boin:
print("vowel")
else:
print("consonant")
|
s703172156
|
p03999
|
u595716769
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,064
| 499
|
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.
|
import itertools
num = str(input())
olist = [int(i+1) for i in range(len(num)-1)]
comblist = []
for i, _ in enumerate(olist, 1):
for j in itertools.combinations(olist, r=i):
comblist.append(j)
L = []
for i in range(len(comblist)):
t = num
for j in range(len(comblist[i])):
t = t[0:comblist[i][j]+j] + "," + t[comblist[i][j]+j:]
L.append(t)
print(L)
out = 0
for i in range(len(L)):
t = L[i].split(",")
for j in range(len(t)):
out += int(t[j])
print(out+int(num))
|
s535467533
|
Accepted
| 21
| 3,064
| 490
|
import itertools
num = str(input())
olist = [int(i+1) for i in range(len(num)-1)]
comblist = []
for i, _ in enumerate(olist, 1):
for j in itertools.combinations(olist, r=i):
comblist.append(j)
L = []
for i in range(len(comblist)):
t = num
for j in range(len(comblist[i])):
t = t[0:comblist[i][j]+j] + "," + t[comblist[i][j]+j:]
L.append(t)
out = 0
for i in range(len(L)):
t = L[i].split(",")
for j in range(len(t)):
out += int(t[j])
print(out+int(num))
|
s619969996
|
p03457
|
u668785999
| 2,000
| 262,144
|
Wrong Answer
| 323
| 34,460
| 346
|
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.
|
def boolean(a,b):
if(abs(a[0] - b[0]) == abs(a[1] - b[1]) + abs(a[2] - b[2])):
return 0
else:
return 1
N = int(input())
txy = [input() for i in range(N)]
txy = [list(map(int, txy[i].split())) for i in range(N)]
ans = "Yes"
for i in range(1,N):
if(boolean(txy[i-1],txy[i])):
ans = "No"
break
print(ans)
|
s513838874
|
Accepted
| 437
| 27,316
| 400
|
def boolean(a,b):
D = abs(a[0] - b[0]) -abs(a[1] - b[1]) - abs(a[2] - b[2])
if(D >= 0 and D %2 == 0):
return 0
else:
return 1
N = int(input())
txy=[0 for i in range(N+1)]
txy[0]=[0,0,0]
for i in range(N):
a=list(map(int,input().split()))
txy[i+1]=a
ans = "Yes"
for i in range(1,N + 1):
if(boolean(txy[i-1],txy[i])):
ans = "No"
break
print(ans)
|
s890891472
|
p02612
|
u227929139
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,040
| 42
|
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.
|
#ABC173-A
N = int(input())
print(N % 1000)
|
s520415410
|
Accepted
| 27
| 9,148
| 43
|
#ABC173-A
N = int(input())
print(-N % 1000)
|
s015737132
|
p03712
|
u064963667
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 416
|
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())
a_list = [[s for s in input()] for _ in range(h)]
print(a_list)
return_list = []
for i,row in enumerate(a_list):
if i == 0:
return_list.append(['#' for _ in range(w+2)])
row.insert(0,'#')
row.append('#')
return_list.append(row)
if i == len(a_list)-1:
return_list.append(['#' for _ in range(w+2)])
for elem in return_list:
print(''.join(elem))
|
s056557634
|
Accepted
| 18
| 3,064
| 402
|
h,w = map(int,input().split())
a_list = [[s for s in input()] for _ in range(h)]
return_list = []
for i,row in enumerate(a_list):
if i == 0:
return_list.append(['#' for _ in range(w+2)])
row.insert(0,'#')
row.append('#')
return_list.append(row)
if i == len(a_list)-1:
return_list.append(['#' for _ in range(w+2)])
for elem in return_list:
print(''.join(elem))
|
s760577839
|
p03433
|
u207036582
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
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 % 500:
print('Yes')
else:
print('No')
|
s469848069
|
Accepted
| 17
| 2,940
| 87
|
n = int(input())
a = int(input())
if (n % 500 <= a):
print('Yes')
else:
print('No')
|
s664878851
|
p02865
|
u696684809
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,156
| 80
|
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n = int(input())
if n%2==0:
n = int(n/2)-1
if n%2==1:
n = int(n/2)
print(n)
|
s803867408
|
Accepted
| 28
| 9,156
| 74
|
N = int(input())
if(N%2==0):
print(int((N/2)-1))
else:
print(int(N/2))
|
s581741023
|
p03814
|
u016622494
| 2,000
| 262,144
|
Wrong Answer
| 43
| 4,840
| 197
|
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 = list(input())
num = 0
num2 = 0
for i in range(len(S)):
if S[i] == "A":
num = i
break
for i in range(len(S)):
if S[i] == "Z":
num2 = i
print(num2 - num)
|
s046857190
|
Accepted
| 46
| 4,840
| 193
|
S = list(input())
num = 0
num2 = 0
for i in range(len(S)):
if S[i] == "A":
num = i
break
for i in range(len(S)):
if S[i] == "Z":
num2 = i
print(num2 - num + 1)
|
s538051305
|
p03854
|
u316603606
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,484
| 218
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input ()
Z = ''.join(list(reversed(S)))
Z = Z.replace('resare', '')
Z = Z.replace('esare', '')
Z = Z.replace('remaerd', '')
Z = Z.replace('maerd', '')
z = len (Z)
if z == 0:
print ('Yes')
else:
print ('No')
|
s309403272
|
Accepted
| 32
| 9,664
| 218
|
S = input ()
Z = ''.join(list(reversed(S)))
Z = Z.replace('resare', '')
Z = Z.replace('esare', '')
Z = Z.replace('remaerd', '')
Z = Z.replace('maerd', '')
z = len (Z)
if z == 0:
print ('YES')
else:
print ('NO')
|
s801700622
|
p03448
|
u641722141
| 2,000
| 262,144
|
Wrong Answer
| 50
| 3,060
| 220
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt = 0
for i in range(a):
for j in range(b):
for k in range(c):
if x == i * 500 + j * 100 + k * 50:
cnt += 1
print(cnt)
|
s081402880
|
Accepted
| 52
| 3,060
| 232
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
cnt = 0
for i in range(a + 1):
for j in range(b + 1):
for k in range(c + 1):
if x == i * 500 + j * 100 + k * 50:
cnt += 1
print(cnt)
|
s001218938
|
p03150
|
u579699847
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 3,188
| 297
|
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
pattern_keyence.append(repr(str[:i]+'.*'+str[i:]))
for p in pattern_keyence:
if re.fullmatch(p,S):
print('YES')
break
else:
print('NO')
|
s860856595
|
Accepted
| 19
| 3,188
| 305
|
import re,sys
def S(): return sys.stdin.readline().rstrip()
S = S()
str = 'keyence'
pattern_keyence = []
for i in range(len(str)+1):
pattern_keyence.append(r'{}'.format(str[:i]+'.*'+str[i:]))
for p in pattern_keyence:
if re.fullmatch(p,S):
print('YES')
break
else:
print('NO')
|
s702867848
|
p03796
|
u763881112
| 2,000
| 262,144
|
Wrong Answer
| 160
| 12,500
| 118
|
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.
|
import numpy as np
import math
MOD=10**9+7
n=int(input())
ans=1
for i in range(n+1):
ans=(ans*i)%MOD
print(ans)
|
s911242531
|
Accepted
| 164
| 12,500
| 120
|
import numpy as np
import math
MOD=10**9+7
n=int(input())
ans=1
for i in range(1,n+1):
ans=(ans*i)%MOD
print(ans)
|
s629437851
|
p03434
|
u401077816
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
if N%2 == 0:
print(N/2)
else:
print(N/2 + 1)
|
s135391521
|
Accepted
| 17
| 2,940
| 108
|
N = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
print(sum(l[0::2]) - sum(l[1::2]))
|
s110781121
|
p03643
|
u958506960
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 37
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
n = input()
print('abc' + n.zfill(3))
|
s329941542
|
Accepted
| 17
| 2,940
| 37
|
n = input()
print('ABC' + n.zfill(3))
|
s795708669
|
p02669
|
u857759499
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,206
| 9,240
| 726
|
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
|
t = int(input())
def solve(n,a,b,c,d):
sol = [n*d]
if n>=2:
if n%2 == 0:
sol.append(a+solve(n//2,a,b,c,d))
else:
sol.append(a+d+solve((n+1)//2,a,b,c,d))
sol.append(a+d+solve((n-1)//2,a,b,c,d))
if n>=3:
if n%3 == 0:
sol.append(b+solve(n//3,a,b,c,d))
else:
bd = n%3
sol.append(b+bd*d+solve((n-bd)//3,a,b,c,d))
sol.append(b+(3-bd)*d+solve((n-bd+3)//3,a,b,c,d))
if n>=5:
if n%5 == 0:
sol.append(c+solve(n//5,a,b,c,d))
else:
cd = n%5
sol.append(c+cd*d+solve((n-cd)//5,a,b,c,d))
sol.append(c+(5-cd)*d+solve((n-cd+5)//5,a,b,c,d))
return min(sol)
for _ in range(t):
n,a,b,c,d = map(int,input().split())
print(solve(n,a,b,c,d))
|
s875324951
|
Accepted
| 190
| 20,024
| 767
|
t = int(input())
def solve(n,a,b,c,d):
mem = {0:0,1:d}
def f(n):
if n in mem:
return mem[n]
ret = n*d
if n%2 == 0:
ret = min(ret,a+f(n//2))
else:
ret = min(ret,a+d+f(n//2+1),a+d+f(n//2))
if n%3 == 0:
ret = min(ret,b+f(n//3))
elif n%3 == 1:
ret = min(ret,b+d+f(n//3))
else:
ret = min(ret,b+d+f(n//3+1))
if n%5 == 0:
ret = min(ret,c+f(n//5))
elif n%5 == 1:
ret = min(ret,c+d+f(n//5))
elif n%5 == 2:
ret = min(ret,c+d+d+f(n//5))
elif n%5 == 3:
ret = min(ret,c+d+d+f(n//5+1))
else:
ret = min(ret,c+d+f(n//5+1))
mem[n] = ret
return ret
return f(n)
for _ in range(t):
n,a,b,c,d = map(int,input().split())
print(solve(n,a,b,c,d))
|
s888060760
|
p03471
|
u240055120
| 2,000
| 262,144
|
Wrong Answer
| 1,977
| 3,060
| 342
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n, y = map(int, input().split())
answer_a = -1
answer_b = -1
answer_c = -1
for a in range(1, n+1):
for b in range(1, n+1):
c = n-a-b
if a+b+c == n and 10000*a+5000*b+1000*c == y:
answer_a = a
answer_b = b
answer_c = c
print("{} {} {}".format(answer_a,answer_b,answer_c))
|
s990350560
|
Accepted
| 845
| 3,188
| 338
|
n, y = map(int, input().split())
answer_a = -1
answer_b = -1
answer_c = -1
for a in range(0, n+1):
for b in range(0, n-a+1):
c = n-a-b
if 10000*a+5000*b+1000*c == y and c>=0:
answer_a = a
answer_b = b
answer_c = c
print("{} {} {}".format(answer_a,answer_b,answer_c))
|
s387847627
|
p03360
|
u612721349
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 49
|
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?
|
print(max(map(int,input().split()))*int(input()))
|
s974901373
|
Accepted
| 17
| 2,940
| 77
|
p=input;a=[int(i)for i in p().split()];m=max(a);print(sum(a)-m+m*2**int(p()))
|
s093213866
|
p02678
|
u326552320
| 2,000
| 1,048,576
|
Wrong Answer
| 604
| 34,560
| 876
|
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.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: D
# CreatedDate: 2020-05-17 22:04:10 +0900
# LastModified: 2020-05-17 22:22:23 +0900
#
from collections import deque
def bfs(path_list,guide,n):
color = [0]*(n+1)
color[1] = 1
Q = deque()
Q.append(1)
while Q:
u = Q.popleft()
for v in path_list[u]:
if color[v] == 0:
color[v]=1
Q.append(v)
guide[v]=u
def main():
n,m = map(int,input().split())
path_list = [[] for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
# print(a,b)
path_list[a].append(b)
path_list[b].append(a)
# print(path_list)
guide = [0]*(n+1)
bfs(path_list,guide,n)
print("Yes")
for i in range(2,n):
print(guide[i])
if __name__ == "__main__":
main()
|
s022851930
|
Accepted
| 636
| 34,552
| 878
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: D
# CreatedDate: 2020-05-17 22:04:10 +0900
# LastModified: 2020-05-17 22:24:55 +0900
#
from collections import deque
def bfs(path_list,guide,n):
color = [0]*(n+1)
color[1] = 1
Q = deque()
Q.append(1)
while Q:
u = Q.popleft()
for v in path_list[u]:
if color[v] == 0:
color[v]=1
Q.append(v)
guide[v]=u
def main():
n,m = map(int,input().split())
path_list = [[] for _ in range(n+1)]
for _ in range(m):
a,b = map(int,input().split())
# print(a,b)
path_list[a].append(b)
path_list[b].append(a)
# print(path_list)
guide = [0]*(n+1)
bfs(path_list,guide,n)
print("Yes")
for i in range(2,n+1):
print(guide[i])
if __name__ == "__main__":
main()
|
s716384842
|
p03545
|
u585704797
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,188
| 683
|
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.
|
x=int(input())
dig=[]
for i in range(1,4):
dig.append(x%(10))
x=x//10
dig.append(x)
d,c,b,a=dig
if (a+b+c+d)==7:
print(str(a),"+",str(b),"+",str(c),"+",str(d),"=7")
elif (a+b+c-d)==7:
print(str(a),"+",str(b),"+",str(c),"-",str(d),"=7")
elif (a+b-c+d)==7:
print(str(a),"+",str(b),"-",str(c),"+",str(d),"=7")
elif (a+b-c-d)==7:
print(str(a),"+",str(b),"-",str(c),"-",str(d),"=7")
elif (a-b+c+d)==7:
print(str(a),"-",str(b),"+",str(c),"+",str(d),"=7")
elif (a-b-c+d)==7:
print(str(a),"-",str(b),"-",str(c),"+",str(d),"=7")
elif (a-b+c-d)==7:
print(str(a),"-",str(b),"+",str(c),"-",str(d),"=7")
elif (a-b-c-d)==7:
print(str(a),"-",str(b),"-",str(c),"-",str(d),"=7")
|
s728325752
|
Accepted
| 17
| 3,064
| 683
|
x=int(input())
dig=[]
for i in range(1,4):
dig.append(x%(10))
x=x//10
dig.append(x)
d,c,b,a=dig
if (a+b+c+d)==7:
print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a+b+c-d)==7:
print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a+b-c+d)==7:
print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a+b-c-d)==7:
print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
elif (a-b+c+d)==7:
print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
elif (a-b-c+d)==7:
print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
elif (a-b+c-d)==7:
print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
elif (a-b-c-d)==7:
print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
|
s676163158
|
p03997
|
u099300051
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 60
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a,b,h = [int(input()) for i in range(3)]
print((a+b)*h/2)
|
s491628834
|
Accepted
| 17
| 2,940
| 64
|
a,b,h = [int(input()) for i in range(3)]
print(int((a+b)*h/2))
|
s212753873
|
p03673
|
u066855390
| 2,000
| 262,144
|
Wrong Answer
| 133
| 25,792
| 279
|
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
n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
if left:
bb.append(a)
else:
bb.appendleft(a)
left = not left
if left:
print(list(bb))
else:
print(list(bb).reverse())
|
s649969224
|
Accepted
| 199
| 25,412
| 261
|
from collections import deque
n = int(input())
aa = list(map(int, input().split()))
bb = deque()
left = True
for a in aa:
if left:
bb.append(a)
else:
bb.appendleft(a)
left = not left
if not left:
bb.reverse()
print(*list(bb))
|
s488434041
|
p03251
|
u598009172
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 200
|
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=(int(i) for i in input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
x.sort()
y.sort()
if x[-1] < (y[0]-1):
print("No War")
else:
print("War")
|
s112235540
|
Accepted
| 17
| 3,064
| 263
|
N,M,X,Y=(int(i) for i in input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
x.sort()
y.sort()
c=0
for i in range(X+1,Y+1):
if x[-1] < i and i <= y[0]:
c=2
if c == 0 :
print("War")
else:
print("No War")
|
s904857302
|
p03729
|
u933214067
| 2,000
| 262,144
|
Wrong Answer
| 35
| 5,148
| 267
|
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
from statistics import mean, median,variance,stdev
import sys
import math
x = input().split()
#y = input().split()
a= []
# a.append(int(x[i]))
if x[0][len(x[0])-1] == x[1][0] and x[1][len(x[1])-1] == x[2][0]:print("Yes")
else:print("No")
|
s464267085
|
Accepted
| 36
| 5,148
| 267
|
from statistics import mean, median,variance,stdev
import sys
import math
x = input().split()
#y = input().split()
a= []
# a.append(int(x[i]))
if x[0][len(x[0])-1] == x[1][0] and x[1][len(x[1])-1] == x[2][0]:print("YES")
else:print("NO")
|
s367660223
|
p03377
|
u825528847
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 115
|
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+B < X:
print("NO")
elif A < X:
print("NO")
else:
print("YES")
|
s194229399
|
Accepted
| 17
| 2,940
| 115
|
A, B, X = map(int, input().split())
if A+B < X:
print("NO")
elif A > X:
print("NO")
else:
print("YES")
|
s938865804
|
p03674
|
u309977459
| 2,000
| 262,144
|
Wrong Answer
| 424
| 25,828
| 724
|
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.
|
n = int(input())
a = list(map(int, input().split()))
M = 10**9+7
res = [-1] * (n+1)
for i in range(n+1):
if res[a[i]] == -1:
res[a[i]] = i
else:
d = a[i]
l, r = res[d], n-i
def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1] 計算用テーブル
for i in range(2, n + 2):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod//i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
for i in range(1, n+2):
print(cmb(n+1, i, mod)-cmb(l+r, i-1, mod))
|
s739349973
|
Accepted
| 433
| 25,700
| 617
|
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
res = [-1] * (n+1)
for i in range(n+1):
if res[a[i]] == -1:
res[a[i]] = i
else:
d = a[i]
l, r = res[d], n-i
def cmb(n, r, mod):
if (r < 0 or r > n):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, n + 2):
g1.append((g1[-1] * i) % mod)
inverse.append((-inverse[mod % i] * (mod//i)) % mod)
g2.append((g2[-1] * inverse[-1]) % mod)
for i in range(1, n+2):
print((cmb(n+1, i, mod)-cmb(l+r, i-1, mod)) % mod)
|
s615986034
|
p03854
|
u914330401
| 2,000
| 262,144
|
Wrong Answer
| 166
| 3,188
| 346
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
S = S[::-1]
divide = ["dream", "dreamer", "erase", "eraser"]
for k in range(len(divide)):
divide[k] = divide[k][::-1]
is_divide = False
for i in range(len(S)):
for j in range(len(divide)):
if S[i:len(divide[j])+1] == divide[j]:
is_divide = True
i += len(divide[j])
if is_divide:
print("YES")
else:
print("NO")
|
s605955413
|
Accepted
| 19
| 3,188
| 264
|
S = input()
while "eraser" in S:
S = S.replace("eraser", "")
while "erase" in S:
S = S.replace("erase", "")
while "dreamer" in S:
S = S.replace("dreamer", "")
while "dream" in S:
S = S.replace("dream", "")
if S == "":
print("YES")
else:
print("NO")
|
s256987500
|
p03478
|
u807889603
| 2,000
| 262,144
|
Wrong Answer
| 33
| 2,940
| 218
|
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())
#4569=n
t = 0
for i in range(1, n+1):
ans = 0
while i!=0:
amari = i%10
i = int(i/10)
ans += amari
if a <= ans <= b:
t += 1
print('t=', t)
|
s497260454
|
Accepted
| 34
| 3,060
| 154
|
n, a, b = map(int,input().split())
ans = 0
for i in range(1,n+1):
s = sum(map(int,list(str(i))))
if a <= s and s <= b:
ans += i
print(ans)
|
s793284298
|
p03623
|
u485349322
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,084
| 83
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
print(a)
else:
print(b)
|
s424841824
|
Accepted
| 24
| 8,904
| 84
|
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
print("A")
else:
print("B")
|
s757198284
|
p03679
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 122
|
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.
|
x,a,b = map(int,input().split())
if a >= b:
print("delicious")
elif b-a >= x:
print("safe")
else:
print("dangerous")
|
s447901334
|
Accepted
| 18
| 2,940
| 122
|
x,a,b = map(int,input().split())
if a >= b:
print("delicious")
elif b-a <= x:
print("safe")
else:
print("dangerous")
|
s752339087
|
p03730
|
u824734140
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,092
| 107
|
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`.
|
import math
a, b, c = map(int, input().split())
d = math.gcd(a, b)
print("Yes" if c % d == 0 else "No")
|
s200389888
|
Accepted
| 32
| 9,148
| 107
|
import math
a, b, c = map(int, input().split())
d = math.gcd(a, b)
print("YES" if c % d == 0 else "NO")
|
s178409383
|
p03251
|
u518042385
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 273
|
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())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=True
for z in range(x+1,y+1):
if all([l<z for l in a]) and all([l>=z for l in b]):
pass
else:
c=False
if c==True:
print("No War")
else:
print("War")
|
s427935767
|
Accepted
| 19
| 3,060
| 267
|
n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=False
for z in range(x+1,y+1):
if all([l<z for l in a]) and all([l>=z for l in b]):
c=True
break
if c==True:
print("No War")
else:
print("War")
|
s389103648
|
p03597
|
u187883751
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 42
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
n=int(input())
a=int(input())
print(n**-a)
|
s644631709
|
Accepted
| 17
| 2,940
| 43
|
n=int(input())
a=int(input())
print(n**2-a)
|
s268258725
|
p02394
|
u169794024
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,596
| 90
|
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
W,H,x,y,r=map(int,input().split())
if W<(x+r):
print(No)
elif H<(y+r):
print(Yes)
|
s161432572
|
Accepted
| 20
| 7,620
| 135
|
W,H,x,y,r=map(int,input().split())
if W>=(x+r) and r<=x:
if H>=(y+r) and r<=y:
print('Yes')
else:
print('No')
else:
print('No')
|
s366949220
|
p02613
|
u094425865
| 2,000
| 1,048,576
|
Wrong Answer
| 149
| 16,192
| 186
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
a= [input() for i in range(n)]
ca=a.count('AC')
cw=a.count('WA')
ct=a.count('TLE')
cr=a.count('RE')
print('AC X',ca)
print('WA X',cw)
print('TEL X',ct)
print('RE X',cr)
|
s197767789
|
Accepted
| 142
| 16,296
| 186
|
n = int(input())
a= [input() for i in range(n)]
ca=a.count('AC')
cw=a.count('WA')
ct=a.count('TLE')
cr=a.count('RE')
print('AC x',ca)
print('WA x',cw)
print('TLE x',ct)
print('RE x',cr)
|
s543883161
|
p03227
|
u088488125
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,076
| 46
|
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
|
s=input()
if len(s)==3:
s=sorted(s)
print(s)
|
s251889990
|
Accepted
| 30
| 9,088
| 51
|
s=input()
if len(s)==3:
s=s[2]+s[1]+s[0]
print(s)
|
s031365592
|
p04045
|
u630211216
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,120
| 187
|
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.
|
N,K=map(int,input().split())
D=list(map(int,input().split()))
while True:
S=str(N)
flag=True
for x in S:
if x in D:
flag=False
if flag==True:
break;
N+=1
print(N)
|
s841925737
|
Accepted
| 151
| 9,060
| 192
|
N,K=map(int,input().split())
D=list(map(int,input().split()))
while True:
S=str(N)
flag=True
for x in S:
if int(x) in D:
flag=False
if flag==True:
break;
N+=1
print(N)
|
s014403967
|
p03759
|
u558764629
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 61
|
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())
print('YNeos'[b-a!=c-b::2])
|
s556639276
|
Accepted
| 17
| 2,940
| 61
|
a,b,c = map(int,input().split())
print('YNEOS'[b-a!=c-b::2])
|
s085408603
|
p04029
|
u239375815
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 37
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n = int(input())
print(((n)*(n+1))/2)
|
s083834645
|
Accepted
| 17
| 2,940
| 38
|
n = int(input())
print(((n)*(n+1))//2)
|
s270971895
|
p03485
|
u226912938
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 58
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a, b = map(int, input().split())
x = -(-(a+b)//1)
print(x)
|
s204828244
|
Accepted
| 17
| 2,940
| 67
|
a, b = map(int, input().split())
x = -(-((a+b)/2)//1)
print(int(x))
|
s979885714
|
p03456
|
u103902792
| 2,000
| 262,144
|
Wrong Answer
| 57
| 2,940
| 143
|
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.
|
a,b = input().split()
n = int(a+b)
for i in range(n):
b = i**2
if i ==n:
print('Yes')
break
elif i > n:
print('No')
break
|
s846277482
|
Accepted
| 17
| 2,940
| 146
|
a,b = input().split()
n = int(a+b)
for i in range(n):
b = i**2
if b ==n:
print('Yes')
break
elif b > n:
print('No')
break
|
s314724764
|
p03456
|
u538956308
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 136
|
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.
|
a,b = map(int,input().split())
n = b//10
jud = a*10**(n+1)+b
m = int(jud**.5)
if abs(m*m-jud)< 1e-6:
print('Yes')
else:
print('No')
|
s635569392
|
Accepted
| 17
| 3,060
| 115
|
a = int(input().replace(" ", ""))
b = a**0.5
c = b - int(b)
if c == 0.0:
print("Yes")
else:
print("No")
|
s826437868
|
p03997
|
u570545890
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 61
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)
|
s789768686
|
Accepted
| 17
| 2,940
| 68
|
a=int(input())
b=int(input())
h=int(input())
print((a+b)*(int(h/2)))
|
s253111756
|
p02972
|
u127499732
| 2,000
| 1,048,576
|
Wrong Answer
| 150
| 6,756
| 372
|
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.
|
def main():
n, *a = map(int, open(0).read().split())
res = []
for i in range(1, n):
x = sum(a[i - 1::i])
b = x % 2
if x > 0 and b == 0:
print(-1)
exit()
if a[i - 1]:
res.append(i - 1)
ans = ' '.join(map(str, res))
print(sum(a))
print(ans)
if __name__ == '__main__':
main()
|
s450225778
|
Accepted
| 145
| 18,424
| 320
|
def solve():
N, *a_l = map(int, open(0).read().split())
a_l = [0] + a_l
for i in range(N//2, 0, -1):
a_l[i] = sum(a_l[i::i]) % 2
b_l = [i for i, x in enumerate(a_l) if x]
print(len(b_l))
if len(b_l) != 0:
print(' '.join(map(str, b_l)))
if __name__ == '__main__':
solve()
|
s690355406
|
p02393
|
u037441960
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 180
|
Write a program which reads three integers, and prints them in ascending order.
|
a, b, c = map(int, input().split())
if(a > b) :
a, b = b, a
if(b > c) :
b, c = c, b
else :
pass
else :
if(b > c) :
b, c = c, b
else :
pass
print(a, b, c)
|
s473612477
|
Accepted
| 20
| 5,592
| 286
|
a, b, c = map(int, input().split())
if a < b :
if b < c :
print(a, b, c)
elif a < c :
print(a, c, b)
else :
print(c, a, b)
elif b < a :
if a < c :
print(b, a, c)
elif b < c :
print(b, c, a)
else :
print(c, b, a)
|
s014775772
|
p03719
|
u759412327
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a = list(map(int,input().split()))
if a[0] <= a[2] <= a[1]:
print("YES")
else:
print("NO")
|
s751249023
|
Accepted
| 32
| 9,156
| 80
|
A,B,C = map(int,input().split())
if A<=C<=B:
print("Yes")
else:
print("No")
|
s431155562
|
p02854
|
u500297289
| 2,000
| 1,048,576
|
Wrong Answer
| 187
| 26,060
| 177
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
N = int(input())
A = list(map(int, input().split()))
left = 0
right = sum(A)
ans = 0
for a in A:
left += a
right -= a
ans = min(ans, abs(left - right))
print(ans)
|
s207320188
|
Accepted
| 190
| 26,764
| 188
|
N = int(input())
A = list(map(int, input().split()))
left = 0
right = sum(A)
ans = float('inf')
for a in A:
left += a
right -= a
ans = min(ans, abs(left - right))
print(ans)
|
s997749937
|
p03556
|
u301302814
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 74
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
# coding: utf-8
from math import sqrt
N = int(input())
print(int(sqrt(N)))
|
s850075261
|
Accepted
| 18
| 2,940
| 78
|
# coding: utf-8
from math import sqrt
N = int(input())
print(int(sqrt(N))**2)
|
s559598571
|
p03567
|
u923270446
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 188
|
Snuke built an online judge to hold a programming contest. When a program is submitted to the judge, the judge returns a verdict, which is a two-character string that appears in the string S as a contiguous substring. (The judge can return any two-character substring of S.) Determine whether the judge can return the string `AC` as the verdict to a program.
|
s = list(input())
for i in range(len(s)):
if s[i] == "A":
for j in range(i, len(s)):
if s[j] == "C":
print("YES")
exit()
print("NO")
|
s094179091
|
Accepted
| 17
| 2,940
| 145
|
s = list(input())
for i in range(len(s)):
if s[i] == "A":
if s[i + 1] == "C":
print("Yes")
exit()
print("No")
|
s667024423
|
p02614
|
u189806337
| 1,000
| 1,048,576
|
Wrong Answer
| 57
| 9,284
| 1,034
|
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
import itertools
h,w,k = map(int,input().split())
c = [[0]*w]*h
for i in range(h):
c[i] = input()
c[i] = list(c[i])
counter = 0
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
if c[i][j] == '#':
b += 1
if b == k:
ans += 1
for hl in range(1,h+1):
for wl in range(1,w+1):
for hi in itertools.combinations(range(h),hl):
for wj in itertools.combinations(range(w),wl):
for i in hi:
for j in range(w):
if c[i][j] == '#':
counter += 1
for j in wj:
for i in range(h):
if c[i][j] == '#':
counter += 1
if b - counter == k:
ans += 1
counter = 0
for hl in range(h+1):
for hi in itertools.combinations(range(h),hl):
for i in hi:
for j in range(w):
if c[i][j] == '#':
counter += 1
if b - counter == k:
ans += 1
counter = 0
for wl in range(w+1):
for wj in itertools.combinations(range(w),wl):
for j in wj:
for i in range(h):
if c[i][j] == '#':
counter += 1
if b - counter == k:
ans += 1
counter = 0
print(ans)
|
s971220347
|
Accepted
| 133
| 9,280
| 667
|
import copy
import itertools
h,w,k = map(int,input().split())
c = [[0]*w]*h
for i in range(h):
c[i] = input()
c[i] = list(c[i])
counter = 0
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
if c[i][j] == '#':
b += 1
for hl in range(h+1):
for wl in range(w+1):
for hi in itertools.combinations(range(h),hl):
for wj in itertools.combinations(range(w),wl):
C = copy.deepcopy(c)
for i in hi:
for j in range(w):
if C[i][j] == '#':
counter += 1
C[i][j] = '.'
for j in wj:
for i in range(h):
if C[i][j] == '#':
counter += 1
if b - counter == k:
ans += 1
counter = 0
print(ans)
|
s172403419
|
p03435
|
u883792993
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 534
|
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.
|
gridNumber = []
numbers = []
for i in range(3):
gridNumber.append(list(map(int, input().split())))
a1=0
b1=gridNumber[0][0] - a1
b2=gridNumber[0][1] - a1
b3=gridNumber[0][2] - a1
a2=gridNumber[0][1] - b1
a3=gridNumber[0][2] - b1
numbers.append([a1+b1, a1+b2, a1+b3])
numbers.append([a2+b1, a2+b2, a2+b3])
numbers.append([a3+b1, a3+b2, a3+b3])
for i in range(3):
for j in range(3):
if not(numbers[i][j] == gridNumber[i][j]):
print("No")
quit()
else:
pass
print("Yes")
|
s590365684
|
Accepted
| 17
| 3,064
| 531
|
gridNumber = []
numbers = []
for i in range(3):
gridNumber.append(list(map(int, input().split())))
a1=0
b1=gridNumber[0][0] - a1
b2=gridNumber[0][1] - a1
b3=gridNumber[0][2] - a1
a2=gridNumber[1][0] - b1
a3=gridNumber[2][0] - b1
numbers.append([a1+b1, a1+b2, a1+b3])
numbers.append([a2+b1, a2+b2, a2+b3])
numbers.append([a3+b1, a3+b2, a3+b3])
for i in range(3):
for j in range(3):
if not(numbers[i][j] == gridNumber[i][j]):
print("No")
quit()
else:
pass
print("Yes")
|
s152728459
|
p03457
|
u336624604
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 157
|
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())
ans=0
for i in range(N):
t,x,y = map(int,input().split())
if x+y<=t and t%2==(x+y)%2:
print('No')
exit()
print('Yes')
|
s635558380
|
Accepted
| 321
| 3,060
| 158
|
n=int(input())
for _ in range(n):
t, x, y = map(int, input().split())
if x + y > t or (t -x -y) % 2:
print("No")
exit()
print("Yes")
|
s388144703
|
p02854
|
u131881594
| 2,000
| 1,048,576
|
Wrong Answer
| 95
| 31,632
| 146
|
Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be possible as is, so he will do the following operations some number of times **before** he does the cut: * Choose one section and expand it, increasing its length by 1 millimeter. Doing this operation once costs 1 yen (the currency of Japan). * Choose one section of length at least 2 millimeters and shrink it, decreasing its length by 1 millimeter. Doing this operation once costs 1 yen. Find the minimum amount of money needed before cutting the bar into two parts with the same length.
|
n=int(input())
a=list(map(int,input().split()))
harf=sum(a)//2
l,r,i=0,a[0],0
while r<harf:
i+=1
l=r
r+=a[i]
print(min(harf-l,r-harf))
|
s881129922
|
Accepted
| 96
| 31,448
| 152
|
n=int(input())
a=list(map(int,input().split()))
harf=sum(a)/2
l,r,i=0,a[0],0
while r<harf:
i+=1
l=r
r+=a[i]
print(int(min(harf-l,r-harf)*2))
|
s238239496
|
p04039
|
u925051897
| 2,000
| 262,144
|
Wrong Answer
| 38
| 3,188
| 328
|
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 re
#input_1st="1000 8"
#input_2nd="1 3 4 5 6 7 8 9"
input_1st=input()
input_2nd=input()
N, K = input_1st.split(" ")
D = input_2nd.split(" ")
pattern = re.compile("|".join(D))
print(pattern)
for ans in range(int(N), 10000):
result = re.findall(pattern, str(ans))
if not result:
print(ans)
break
|
s910679923
|
Accepted
| 100
| 2,940
| 288
|
input_1st=input()
input_2nd=input()
N, K = input_1st.split(" ")
D = input_2nd.split(" ")
for ans in range(int(N), 100000):
flg = True
for i in range(len(str(ans))):
if str(ans)[i] in D:
flg = False
break
if flg:
print(ans)
break
|
s140797301
|
p03795
|
u023077142
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 62
|
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())
x = 800 * N
y = (N % 15) * 200
print(x - y)
|
s457347761
|
Accepted
| 17
| 2,940
| 63
|
N = int(input())
x = 800 * N
y = (N // 15) * 200
print(x - y)
|
s939353138
|
p03162
|
u857293613
| 2,000
| 1,048,576
|
Wrong Answer
| 2,106
| 92,248
| 430
|
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]
for k in range(3):
dp[1][k] = lis[0][k]
print(dp)
for i in range(2, N+1):
dp[i][0] = max(dp[i-1][1] + lis[i-1][1], dp[i-1][2] + lis[i-1][2])
dp[i][1] = max(dp[i-1][0] + lis[i-1][0], dp[i-1][2] + lis[i-1][2])
dp[i][2] = max(dp[i-1][0] + lis[i-1][0], dp[i-1][1] + lis[i-1][1])
print(dp)
print(max(dp[N]))
|
s103747733
|
Accepted
| 609
| 47,408
| 364
|
N = int(input())
lis = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*3 for _ in range(N+1)]
for k in range(3):
dp[1][k] = lis[0][k]
for i in range(2, N+1):
dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + lis[i-1][0]
dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + lis[i-1][1]
dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + lis[i-1][2]
print(max(dp[N]))
|
s896582805
|
p03486
|
u682997551
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 102
|
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 = input()
t = input()
s = sorted(s)
t = sorted(t)
if s < t:
print('Yes')
else:
print('No')
|
s366737650
|
Accepted
| 17
| 2,940
| 116
|
s = input()
t = input()
s = sorted(s)
t = sorted(t, reverse=True)
if s < t:
print('Yes')
else:
print('No')
|
s520468182
|
p02401
|
u814278309
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 161
|
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
a,op,b=input().split()
a=int(a)
b=int(b)
if op=='+':
print(a+b)
elif op=='-':
print(a-b)
elif op=='*':
print(a*b)
elif op=='/':
print(a//b)
else:
pass
|
s033024136
|
Accepted
| 20
| 5,596
| 320
|
while 1:
a,op,b = input().split()
a = int(a)
b = int(b)
if op == "?":
break
else:
if op == "+":
x = a + b
print(x)
elif op == "-":
x = a - b
print(x)
elif op == "*":
x = a * b
print(x)
elif op == "/":
x = a // b
print(x)
else:
pass
|
s924585899
|
p03380
|
u729133443
| 2,000
| 262,144
|
Wrong Answer
| 73
| 14,432
| 122
|
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.
|
n=int(input())
a=list(map(int,input().split()))
b=max(a)
c=b
d=0
for i in a:
if c<abs(b/2-i):c=abs(b/2-i);d=i
print(b,d)
|
s501652366
|
Accepted
| 65
| 14,052
| 123
|
n=int(input())
a=list(map(int,input().split()))
b=max(a)
c=b
d=0
for i in a:
if c>=abs(b/2-i):c=abs(b/2-i);d=i
print(b,d)
|
s538215506
|
p03729
|
u086503932
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 68
|
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a,b,c = input().split()
print('YNeos'[a[-1]!=b[0]or b[-1]!=c[0]::2])
|
s032972555
|
Accepted
| 17
| 2,940
| 70
|
a,b,c = input().split()
print('YNEOS'[a[-1]!=b[0] or b[-1]!=c[0]::2])
|
s513586511
|
p03433
|
u015845133
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 152
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
def calc():
amari = N % 500
if amari >= A:
return"Yes"
else:
return"No"
N = int(input())
A = int(input())
print(calc())
|
s372087241
|
Accepted
| 18
| 2,940
| 152
|
def calc():
amari = N % 500
if amari <= A:
return"Yes"
else:
return"No"
N = int(input())
A = int(input())
print(calc())
|
s340460800
|
p01085
|
u284260266
| 8,000
| 262,144
|
Wrong Answer
| 160
| 5,608
| 426
|
The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is higher than that of any unsuccessful applicant. * The number of successful applicants _n_ must be between _n_ min and _n_ max, inclusive. We choose _n_ within the specified range that maximizes the _gap._ Here, the _gap_ means the difference between the lowest score of successful applicants and the highest score of unsuccessful applicants. * When two or more candidates for _n_ make exactly the same _gap,_ use the greatest _n_ among them. Let's see the first couple of examples given in Sample Input below. In the first example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65. For _n_ of two, three and four, the gaps will be 8, 12, and 5, respectively. We must choose three as _n_ , because it maximizes the gap. In the second example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65. For _n_ of two, three and four, the gap will be 10, 5, and 10, respectively. Both two and four maximize the gap, and we must choose the greatest number, four. You are requested to write a program that computes the number of successful applicants that satisfies the conditions.
|
while True:
P = list()
ans = list()
tans = list()
m, Mn, Mx = map(int, input().split())
if m == 0 and Mn == 0 and Mx == 0:
break
for i in range(0, m):
P.append(int(input()))
for j in range(Mn-1, Mx, 1):
ans.append(P[j]-P[j+1])
print(ans)
for k in range(0,len(ans)):
if ans[k] == max(ans):
tans.append(k)
print(tans)
print(max(tans)+Mn)
|
s229897279
|
Accepted
| 160
| 5,612
| 428
|
while True:
P = list()
ans = list()
tans = list()
m, Mn, Mx = map(int, input().split())
if m == 0 and Mn == 0 and Mx == 0:
break
for i in range(0, m):
P.append(int(input()))
for j in range(Mn-1, Mx, 1):
ans.append(P[j]-P[j+1])
#print(ans)
for k in range(0,len(ans)):
if ans[k] == max(ans):
tans.append(k)
#print(tans)
print(max(tans)+Mn)
|
s229194257
|
p04011
|
u381712637
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
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())
if n<=k:
print (n*x)
else:
print (n*k+y*(n-k))
|
s769218354
|
Accepted
| 17
| 2,940
| 110
|
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<=k:
print (n*x)
else:
print (x*k+y*(n-k))
|
s187041856
|
p03795
|
u331464808
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 48
|
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())
x =n*800
y =n*200/15
print(x-y)
|
s189067832
|
Accepted
| 17
| 2,940
| 51
|
n = int(input())
x =n*800
y =200*(n//15)
print(x-y)
|
s925927431
|
p03738
|
u853586331
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 106
|
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
A=int(input())
B=int(input())
if A>B:
print ('greater')
elif A<B:
print ('less')
else:
print ('equal')
|
s392100935
|
Accepted
| 17
| 2,940
| 106
|
A=int(input())
B=int(input())
if A>B:
print ('GREATER')
elif A<B:
print ('LESS')
else:
print ('EQUAL')
|
s156275350
|
p02258
|
u800815741
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 315
|
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 28 21:09:30 2016
@author: you
"""
n = int(input())
maxv = 0
minv = 10000000
price = 0
for i in range(n):
x = int(input())
if x < minv:
minv = x
if x > maxv:
maxv = x
if price < maxv - minv:
price = maxv - minv
print(price)
|
s685584136
|
Accepted
| 580
| 5,628
| 413
|
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 28 21:09:30 2016
@author: you
"""
n = int(input())
b = int(input())
maxv = b
minv = b
price = -1000000000
for i in range(n-1):
x = int(input())
flag = (x-b > 0)
if flag:
price = max(price, x-minv)
else:
if x < minv:
minv = x
maxv = x
if price < x-b:
price = x-b
b = x
print(price)
|
s272841587
|
p03861
|
u149991748
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 3,060
| 139
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
ans = 0
p = a
while p <= b:
if p%x == 0:
break
p += 1
ans = ((b-p)/x) + 1
print(ans)
|
s851773801
|
Accepted
| 43
| 3,064
| 308
|
a, b, x = map(int, input().split())
p = 0
y = int(b//x) + 1
i = 1
while x*i <= b:
if a <= x*i:
p = x*i
break
i += 1
if p != 0:
t = b-p
s = t//x
ans = s + 1
if a == 0:
ans += 1
print(ans)
elif a == 0:
print(1)
else:
print(0)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.