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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s035037340 | p03457 | u088063513 | 2,000 | 262,144 | Wrong Answer | 416 | 21,180 | 1,064 | 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... | ## coding: UTF-8
N = int(input())
a = []
a.append([0,0,0])
for i in range(N):
a.append([int(x) for x in input().split()])
#print(a)
def hantei(l1, l2):
if( (abs(l2[1] - l1[1]) + abs(l2[2] - l1[2])) <= (l2[0] - l1[0]) ):
#print(l1)
#print(l2)
return 'OK'
else:
return '... | s346494125 | Accepted | 416 | 21,180 | 1,064 | ## coding: UTF-8
N = int(input())
a = []
a.append([0,0,0])
for i in range(N):
a.append([int(x) for x in input().split()])
#print(a)
def hantei(l1, l2):
if( (abs(l2[1] - l1[1]) + abs(l2[2] - l1[2])) <= (l2[0] - l1[0]) ):
#print(l1)
#print(l2)
return 'OK'
else:
return '... |
s716640718 | p03478 | u374082254 | 2,000 | 262,144 | Wrong Answer | 34 | 3,060 | 227 | 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())
def digitSum(n):
s = str(n)
array = list(map(int, s))
return sum(array)
result = 0
for i in range(N):
s = digitSum(i)
if A <= s and s <= B:
result += s
print(s) | s185313050 | Accepted | 35 | 3,060 | 237 | N, A, B = map(int, input().split())
def digitSum(n):
s = str(n)
array = list(map(int, s))
return sum(array)
result = 0
for i in range(N+1):
s = digitSum(i)
if A <= s and s <= B:
result += i
print(result)
|
s376692892 | p02744 | u207097826 | 2,000 | 1,048,576 | Wrong Answer | 29 | 3,700 | 970 | In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F... | # -*- coding: utf-8 -*-
"""
Created on Sat Mar 14 22:00:05 2020
@author: naoki
"""
import sys
import itertools
N = int(input())
all_list = []
for i in range(0,N+1):
if i != 1:
all_list.extend(list(itertools.combinations(range(N),i)))
answer = [["x"] * N for _ in range(len(all_list))]
for i in range(len(... | s155180653 | Accepted | 1,065 | 29,072 | 363 | N = int(input())
All = []
def enumeration(a="0", b = 1):
if len(a) == N:
All.append(a)
else:
for i in range(len(set(a)) + 1):
enumeration(a + str(i), b+1)
enumeration()
for i in range(len(All)):
All[i] = list(All[i])
for p in range(len(All[i])):
All[i][p] = chr(97 +... |
s324713576 | p03131 | u404561212 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,060 | 408 | Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ... | def calc_max_biscuit(K,A,B):
hit_only = 1+K
sell_and_buy = 0
if B-A<1:
print(hit_only)
else:
K -= A-1
sell_and_buy = int(K/2)*(B-A)
print(max(sell_and_buy, hit_only))
K, A, B = list(map(int, input().split()))
calc_max_biscuit(K,A,B) | s595061948 | Accepted | 18 | 3,064 | 499 | def calc_max_biscuit(K,A,B):
hit_only = 1+K
sell_and_buy = 0
if B-A<1:
print(hit_only)
else:
K -= (A-1)
if K%2==0:
sell_and_buy = A + int(K/2)*(B-A)
else:
sell_and_buy = A + int(K/2)*(B-A)+1
print(max(sell_and_buy, hit_only))
... |
s483441201 | p03731 | u075303794 | 2,000 | 262,144 | Wrong Answer | 129 | 30,924 | 263 | In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will pus... | N,T=map(int,input().split())
t=list(map(int,input().split()))
t.append(10**10)
ans=0
flg=0
for i in range(N):
if t[i]+T > t[i+1]:
if flg==0:
flg=t[i]
continue
else:
if flg==0:
ans+=T
else:
ans+=t[i]-flg+T
flg=0
print(ans) | s049962958 | Accepted | 115 | 30,896 | 285 | N,T=map(int,input().split())
t=list(map(int,input().split()))
t.append(10**10)
ans=0
flg=0
temp=0
for i in range(N):
if t[i]+T > t[i+1]:
if flg==0:
temp=t[i]
flg=1
continue
else:
if flg==0:
ans+=T
else:
ans+=t[i]-temp+T
flg=0
print(ans) |
s267640643 | p03386 | u343977188 | 2,000 | 262,144 | Wrong Answer | 29 | 9,124 | 177 | 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())
ans=[]
for i in range(a,min(k,b)+1):
ans.append(i)
for i in range(max(b-k,a),b+1):
ans.append(i)
ans = list(set(ans))
for i in ans:
print(i) | s107259487 | Accepted | 28 | 9,188 | 189 | a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1)):
ans.append(i)
for i in range(max(b-k+1,a),b+1):
ans.append(i)
ans = sorted(list(set(ans)))
for i in ans:
print(i) |
s152574009 | p02865 | u658993896 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 25 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | N=int(input())
print(N-1) | s574788808 | Accepted | 17 | 2,940 | 62 | N=int(input())
if(N%2==1):
print(N//2)
else:
print(N//2-1) |
s501832986 | p03761 | u703890795 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 406 | 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 headlin... | n = int(input())
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']
G = [99 for i in range(26)]
for i in range(n):
A = [0 for i in range(26)]
S = list(input())
for s in S:
A[abc.index(s)] += 1
for j... | s782629458 | Accepted | 19 | 3,064 | 447 | n = int(input())
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']
G = [99 for i in range(26)]
for i in range(n):
A = [0 for i in range(26)]
S = list(input())
for s in S:
A[abc.index(s)] += 1
for j... |
s812014516 | p02613 | u969133463 | 2,000 | 1,048,576 | Wrong Answer | 175 | 17,496 | 689 | 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`,... | class kazoe:
def __init__(self,b):
b.sort()
self.b = b
print(self.b)
def sum(self):
c = [0] *4
for i in range(len(self.b)):
if(self.b[i] == "AC"):
c[0] += 1
else:
if(self.b[i] == "TLE"):
c[1] +=... | s202352383 | Accepted | 167 | 16,420 | 663 | class kazoe:
def __init__(self,b):
b.sort()
self.b = b
def sum(self):
c = [0] *4
for i in range(len(self.b)):
if(self.b[i] == "AC"):
c[0] += 1
else:
if(self.b[i] == "TLE"):
c[1] += 1
els... |
s971197531 | p02242 | u798803522 | 1,000 | 131,072 | Wrong Answer | 20 | 7,700 | 650 | For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. | trial = int(input())
graph = []
for t in range(trial):
graph.append([int(n) for n in input().split(" ")])
root = []
ans = []
stack = [[0,0]]
cnt = 0
while len(stack) > 0:
index,out = stack[0][0],stack[0][1]
print(index,out,stack,graph)
for get in range(graph[index][1]):
if graph[index][get*2 + 2... | s444266770 | Accepted | 1,710 | 8,356 | 662 | trial = int(input())
graph = []
for t in range(trial):
graph.append([int(n) for n in input().split(" ")])
root = []
ans = []
stack = [[0,0]]
cnt = 0
while len(stack) > 0:
index,out = stack[0][0],stack[0][1]
for get in range(graph[index][1]):
if graph[index][get*2 + 2] not in root:
stack.... |
s388256246 | p03024 | u480847874 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 72 | 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 cons... | S = input()
if S.count("x") > 7:
print('NO')
else:
print('Yes') | s134353441 | Accepted | 17 | 2,940 | 72 | S = input()
if S.count("x") > 7:
print('NO')
else:
print('YES') |
s213585804 | p03047 | u163874353 | 2,000 | 1,048,576 | Wrong Answer | 2,229 | 1,706,128 | 111 | Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? | from itertools import combinations
n, k = map(int, input().split())
print(len(list(combinations(range(n), k)))) | s632865386 | Accepted | 17 | 2,940 | 49 | n, k = map(int, input().split())
print(n - k + 1) |
s061079089 | p02389 | u312033355 | 1,000 | 131,072 | Wrong Answer | 20 | 5,576 | 79 | Write a program which calculates the area and perimeter of a given rectangle. | a,b=map(int, input().split())
length=2*a+2*b
menseki=a*b
print(length,menseki)
| s851090082 | Accepted | 20 | 5,584 | 79 | a,b=map(int, input().split())
length=2*a+2*b
menseki=a*b
print(menseki,length)
|
s264675474 | p02694 | u165394332 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,092 | 87 | 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 abo... | X = int(input())
n = 100
i = 0
while n <= X:
i += 1
n = int(n * 1.01)
print(i)
| s473305478 | Accepted | 22 | 9,156 | 86 | X = int(input())
n = 100
i = 0
while n < X:
i += 1
n = int(n * 1.01)
print(i)
|
s775176957 | p03719 | u214380782 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 158 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | numsstr = input().split()
nums = []
for i in numsstr:
nums.append(int(i))
if nums[2]>=nums[0] and nums[2]<=nums[1]:
print('YES')
else:
print('NO') | s018500960 | Accepted | 17 | 2,940 | 150 | ABCstr = input().split()
ABC = []
for n in ABCstr:
ABC.append(int(n))
if ABC[0]<=ABC[2] and ABC[1]>=ABC[2]:
print('Yes')
else:
print('No') |
s866523141 | p02612 | u273326224 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,128 | 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(int(input())%1000) | s934041640 | Accepted | 32 | 9,096 | 29 | print(int(input())*(-1)%1000) |
s031469796 | p03813 | u865413330 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 55 | Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise. | s = input()
print(len(s[s.find("A"):s.rfind("Z") + 1])) | s244442543 | Accepted | 17 | 2,940 | 59 | x = int(input())
print("ABC") if x < 1200 else print("ARC") |
s986973259 | p04011 | u840570107 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 118 | 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(x*n)
else:
print(x*n+y*(n-k)) | s684751190 | Accepted | 17 | 2,940 | 118 | n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n < k:
print(x*n)
else:
print(x*k+y*(n-k)) |
s169122410 | p03565 | u223646582 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 317 | 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 mo... | Sd=input()
T=input()
if T in Sd:
print(Sd.replace('?','a'))
else:
for i in range(len(Sd)-len(T)+1):
for j in range(len(T)):
if Sd[len(Sd)-i-j-1] not in (T[len(T)-j-1],'?'):
break
else:
print(Sd.replace('?','a'))
exit()
print('UNRESTORABLE') | s222927747 | Accepted | 17 | 3,060 | 272 | S_ = input()
T = input()
for i in range(len(S_)-len(T), -1, -1):
for j in range(len(T)):
if S_[i+j] not in (T[j], '?'):
break
else:
print(S_[:i].replace('?', 'a')+T+S_[i+len(T):].replace('?', 'a'))
exit()
print('UNRESTORABLE')
|
s807484772 | p02401 | u082526811 | 1,000 | 131,072 | Wrong Answer | 20 | 7,604 | 294 | 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. | if __name__ == "__main__":
co = []
while True:
a, op, b = input().split()
if op == '?':
break
co.append([int(a),op,int(b)])
for i in co:
if i[1] == '+':
print(i[0]+i[2])
elif i[2] == '-':
print(i[0]-i[2])
elif i[2] == '/':
print(i[0]/i[2])
else:
print(i[0]*i[2]) | s354704363 | Accepted | 20 | 7,428 | 104 | while True:
data = input()
if '?' in data:
break
print(eval(data.replace('/','//'))) |
s048240722 | p02749 | u516589098 | 2,000 | 1,048,576 | Wrong Answer | 2,156 | 861,232 | 630 | We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i. Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots , p_N of integers from 1 to N satisfying the following condition: * For every pair of vertices (i, j), if the distance be... | N = int(input())
tree = [[] for i in range(N)]
ans = [i for i in range(1,N+1)]
for i in range(N-1):
pair = [int(i) for i in input().split()]
tree[pair[0]-1].append(pair[1]-1)
tree[pair[1]-1].append(pair[0]-1)
b = []
for i in range(N):
a = []
for idx_1 in tree[i]:
tmp = [j for j in tree[id... | s784981761 | Accepted | 1,176 | 65,272 | 1,713 | N = int(input())
node = [[] for _ in range(N)]
for _ in range(N-1):
a, b = map(int, input().split())
node[a-1].append(b-1)
node[b-1].append(a-1)
group = [False] * N
parents = list(range(N))
stack = [0]
while stack:
p = stack.pop()
for c in node[p]:
if c != parents[p]:
... |
s808041905 | p03861 | u396961814 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 94 | 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 = [int(x) for x in input().split()]
cnt_a = a // x
cnt_b = b // x
print(cnt_b-cnt_a) | s090672909 | Accepted | 17 | 2,940 | 98 | a, b, x = [int(x) for x in input().split()]
cnt_a = (a-1) // x
cnt_b = b // x
print(cnt_b-cnt_a) |
s645608984 | p03795 | u333768710 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 177 | 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 ... | mod = 1000000007
n = int(input())
factorial_previous = 1
for i in range(1,n+1):
factorial = (i*factorial_previous)%mod
factorial_previous = factorial
print(factorial)
| s455914630 | Accepted | 17 | 2,940 | 113 | if __name__ == '__main__':
n = int(input())
pay = 800 * n
ret = 200 * (n // 15)
print(pay - ret)
|
s907572418 | p03814 | u580362735 | 2,000 | 262,144 | Wrong Answer | 61 | 5,872 | 73 | 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 w... | s = input()
print(sorted(s,reverse = True).index('Z') - s.index('A') + 1) | s744280363 | Accepted | 18 | 3,500 | 60 | s = input()
print(len(s)- s[::-1].index('Z') - s.index('A')) |
s486412722 | p02842 | u909224749 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,096 | 78 | Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).... | N = int(input())
x = N // 1.08
if x*1.08 < N:
print(":(")
else:
print(x) | s934778624 | Accepted | 36 | 9,096 | 116 | N = int(input())
ans = ":("
for X in range(N+1):
if int(X * 1.08) == N:
ans = X
break
print(ans)
|
s819659428 | p02288 | u672443148 | 2,000 | 131,072 | Wrong Answer | 20 | 5,600 | 537 | A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tr... | def maxHeapify(A,i,H):
l=2*i
r=2*i+1
#select the node which has the maximum value
if l<=H and A[l-1]>A[i-1]:
largest=l
else:
largest=i
if r<=H and A[r-1]>A[l-1]:
largest=r
#value of children is larger than that of i
if largest!=i:
A[i-1],A[largest-1]=... | s579399634 | Accepted | 790 | 63,700 | 435 | def maxHeapify(A,i,H):
l=2*i
r=2*i+1
if l<=H and A[l-1]>A[i-1]:
largest=l
else:
largest=i
if r<=H and A[r-1]>A[largest-1]:
largest=r
if largest!=i:
A[i-1],A[largest-1]=A[largest-1],A[i-1]
maxHeapify(A,largest,H)
H=int(input())
A=list(map(int... |
s628087708 | p04044 | u076564993 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 65 | 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 sm... | l=input().split()
l.sort()
ans=''
for i in l:
ans+=i
print(ans) | s424148601 | Accepted | 17 | 3,060 | 123 | n,L=map(int,input().split())
l=[]
for i in range(n):
l.append(input())
l.sort()
ans=''
for i in l:
ans+=i
print(ans)
|
s179186984 | p03860 | u923270446 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe... | s = input()
list1 = [str(x) for x in s]
print("A" + list1[0] + "C") | s602371702 | Accepted | 17 | 3,060 | 188 | input1 = input().split()
A = input1[0]
s = input1[1]
C = input1[2]
listA = [str(x) for x in A]
listS = [str(y) for y in s]
listC = [str(z) for z in C]
print(listA[0] + listS[0] + listC[0]) |
s666278318 | p03964 | u631277801 | 2,000 | 262,144 | Wrong Answer | 23 | 3,316 | 674 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he c... | N = int(input())
TA = []
for i in range(N):
TA.append(list(map(int, input().split())))
t_real = [TA[0][0]]
a_real = [TA[0][1]]
for i in range(1,N):
t_cand = (t_real[i-1]//TA[i][0] + bool(t_real[i-1]%TA[i][0])) * TA[i][0]
a_cand = (a_real[i-1]//TA[i][1] + bool(a_real[i-1]%TA[i][1])) * TA[i][1]
if ... | s143931181 | Accepted | 21 | 3,188 | 968 | import sys
sdin = sys.stdin.readline
INF = float("inf")
n = int(sdin())
ta = []
for _ in range(n):
ta.append(tuple(map(int, sdin().split())))
t_real = [ta[0][0]]
a_real = [ta[0][1]]
for i in range(1,n):
t_k = t_real[i-1]//ta[i][0] + bool(t_real[i-1]%ta[i][0])
a_k = a_real[i-1]//ta[i][1] + bool(a... |
s319266487 | p03408 | u520697798 | 2,000 | 262,144 | Wrong Answer | 31 | 9,384 | 230 | Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea... | from collections import Counter
for i in range(int(input())):
s = input()
for j in range(int(input())):
t = input()
c = Counter(s)
for i in t:
if i in c:
c[i] -=1
print(max(0,c.most_common()[0][1])) | s373614186 | Accepted | 28 | 9,112 | 156 | s=[input() for _ in range(int(input()))]
t=[input() for _ in range(int(input()))]
res=0
for i in set(s):
res=max(s.count(i)-t.count(i),res)
print(res) |
s672242246 | p03359 | u264265458 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 53 | 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 ... | a,b=map(int,input().split())
print(a if b>a else a-1) | s220008162 | Accepted | 17 | 2,940 | 53 | a,b=map(int,input().split())
print(a-1 if b<a else a) |
s137023239 | p03623 | u474423089 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | 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... | x,a,b=map(int,input().split(' '))
if abs(x-a) > abs(x-b):
print('A')
else:
print('B') | s631428527 | Accepted | 17 | 2,940 | 93 | x,a,b=map(int,input().split(' '))
if abs(x-a) < abs(x-b):
print('A')
else:
print('B') |
s793198082 | p03160 | u562015767 | 2,000 | 1,048,576 | Wrong Answer | 135 | 14,672 | 197 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | N = int(input())
A = list(map(int,input().split()))
dp = [0] * N
dp[1] = abs(A[1] - A[0])
for i in range(2,N):
dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
print(dp) | s742531703 | Accepted | 126 | 13,980 | 202 | N = int(input())
A = list(map(int,input().split()))
dp = [0] * N
dp[1] = abs(A[1] - A[0])
for i in range(2,N):
dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]),dp[i-2] + abs(A[i] - A[i-2]))
print(dp[N-1]) |
s121146463 | p03163 | u237493274 | 2,000 | 1,048,576 | Wrong Answer | 255 | 15,496 | 185 | 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 ... | from numpy import*
N,W=map(int, input().split())
dp=zeros(W+1)
for i in range(N):
w,v=map(int, input().split())
dp[w:]=maximum(dp[w:], dp[:-w]+v)
print(dp)
print(int(dp[W])) | s523086293 | Accepted | 332 | 19,356 | 171 | from numpy import*
N,W=map(int, input().split())
dp=zeros(W+1)
for i in range(N):
w,v=map(int, input().split())
dp[w:]=maximum(dp[w:], dp[:-w]+v)
print(int(dp[W])) |
s669732183 | p03448 | u923712635 | 2,000 | 262,144 | Wrong Answer | 53 | 3,064 | 197 | 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 co... | 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(500*i+100*j+50*k == X):
cnt+=1
print(cnt) | s649132871 | Accepted | 51 | 3,060 | 204 | 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(500*i+100*j+50*k == X):
cnt+=1
print(cnt)
|
s043548224 | p03523 | u566264434 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,060 | 252 | You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`? | s=input()
for bit in range(2**(len(s)+1)):
T = ""
for j in range(len(s)+1):
if ((bit >> j) & 1):
T += "A"
if j<(len(s)):
T += s[j]
if T=='AKIHABARA':
print('YES')
exit
print('NO') | s987024072 | Accepted | 29 | 3,064 | 296 | s=input()
if len(s)>10:
print('NO')
exit()
for bit in range(2**(len(s)+1)):
T = ""
for j in range(len(s)+1):
if ((bit >> j) & 1):
T += "A"
if j<(len(s)):
T += s[j]
if T=='AKIHABARA':
print('YES')
exit()
print('NO') |
s475174323 | p03698 | u243572357 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 49 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | print('yes' if len(set(input())) == 26 else 'no') | s355752294 | Accepted | 17 | 2,940 | 65 | s = list(input())
print('yes' if len(s) == len(set(s)) else 'no') |
s027708610 | p03160 | u506858457 | 2,000 | 1,048,576 | Wrong Answer | 124 | 13,928 | 207 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | N=int(input())
H=[int(i) for i in input().split()]
dp=[0]*(N+5)
dp[0]=0
dp[1]=abs(H[1]-H[0])
for i in range(1,N):
dp[i]=min(dp[i-2]+abs(H[i-2]-H[i]),dp[i-1]+abs(H[i-1]-H[i]))
print(dp[N-1])
| s197686372 | Accepted | 134 | 14,872 | 242 | dp=[0]*110000
n=int(input())
h=list(map(int,input().split()))
dp[0]=0
for i in range(1,n):
if i==1:
dp[i]=dp[i-1]+abs(h[i]-h[i-1])
else:
dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),
dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1]) |
s856872001 | p02646 | u868606077 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,180 | 170 | 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 ... | A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
ret1 = A + V * T
ret2 = B + W * T
if ret1 >= ret2:
print('Yes')
else:
print('No') | s886650785 | Accepted | 25 | 9,180 | 177 | A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
ret1 = V * T
ret2 = abs(A-B) + W * T
if ret1 >= ret2 > 0:
print('YES')
else:
print('NO') |
s441256770 | p03827 | u143536664 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 160 | 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 duri... | N = int(input())
S = list(input())
count = 0
for i in range(N):
if i == "I":
count += 1
if i == "D":
count -= 1
else:
print(count)
| s860873415 | Accepted | 17 | 2,940 | 222 | N = int(input())
S = list(input())
count = 0
max_count = 0
for i in S:
if i == "I":
count += 1
if i == "D":
count -= 1
if max_count < count:
max_count = count
else:
print(max_count)
|
s451237545 | p00120 | u319725914 | 1,000 | 131,072 | Wrong Answer | 30 | 6,052 | 804 | ケーキ屋さんが、まちまちな大きさのロールケーキをたくさん作りました。あなたは、このケーキを箱に並べる仕事を任されました。 ロールケーキはとてもやわらかいので、他のロールケーキが上に乗るとつぶれてしまいます。ですから、図(a) のように全てのロールケーキは必ず箱の底面に接しているように並べなければなりません。並べ替えると必要な幅も変わります。 --- 図(a) 図(b) n 個のロールケーキの半径 r1, r2, ..., rn と箱の長さを読み込み、それぞれについて、箱の中にうまく収まるかどうか判定し、並べる順番を工夫すると箱に入る場合は "OK"、どう並べても入らない場合には "NA"を出力するプ... | from collections import deque
def calcwidth(cks):
if len(cks) == 1: return cks[0]*2
width = cks[0] + cks[-1]
for ck1,ck2 in zip(cks[:-1],cks[1:]):
width += ((ck1+ck2)**2-(ck1-ck2)**2)**0.5
return width
while True:
try: W, *rs = list(map(float,input().split()))
except: break
rs = de... | s454324625 | Accepted | 20 | 6,052 | 805 | from collections import deque
def calcwidth(cks):
if len(cks) == 1: return cks[0]*2
width = cks[0] + cks[-1]
for ck1,ck2 in zip(cks[:-1],cks[1:]):
width += ((ck1+ck2)**2-(ck1-ck2)**2)**0.5
return width
while True:
try: W, *rs = list(map(float,input().split()))
except: break
rs = de... |
s855844187 | p03601 | u252828980 | 3,000 | 262,144 | Wrong Answer | 3,171 | 249,928 | 495 | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the bea... | a,b,c,d,e,f = map(int,input().split())
L = []
for p in range(31):
for q in range(31):
h = 100*(a*p+b*q)
for r in range((f-h)//(c)):
for s in range((f-h)//(d)):
g = c*r+d*s
if g+h !=0:
bool1 = (g/(g+h) <= 100*e/(100+e))
... | s339269078 | Accepted | 1,867 | 109,664 | 509 | a,b,c,d,e,f = map(int,input().split())
L = []
for p in range(f//a+1):
for q in range((f-a*p)//b+1):
h = 100*(a*p+b*q)
for r in range((f-h)//c+1):
for s in range((f-h-c*r)//d+1):
g = c*r+d*s
if g+h !=0:
bool1 = (g/(g+h) <= e/(100+e))
... |
s733947530 | p03110 | u722189950 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 170 | 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`... | #ABC119 B
N = int(input())
ans = 0
for i in range(N):
x, v = input().split()
x = float(x)
if v == "BTC":
x *= 38000.0
ans += x
print(ans) | s743681298 | Accepted | 17 | 2,940 | 169 | #ABC119 B
N = int(input())
ans = 0
for i in range(N):
x, v = input().split()
x = float(x)
if v == "BTC":
x *= 380000
ans += x
print(ans) |
s150829007 | p03698 | u239342230 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 55 | You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. | S=input();print("YES" if len(S)==len(set(S)) else "NO") | s658466747 | Accepted | 17 | 2,940 | 50 | S=input();print(["no","yes"][len(S)==len(set(S))]) |
s490094515 | p03494 | u919633157 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,060 | 258 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | n=int(input())
a=list(map(int,input().split()))
s=0
cnt=0
while True:
tmp=a.copy()
for j in range(n):
s+=tmp.pop()
if s%n==0:
a=[int(int(j)/2) for j in a]
cnt+=1
tmp=a.copy()
s=0
else : break
print(cnt) | s889419306 | Accepted | 18 | 2,940 | 191 | n=int(input())
a=list(map(int,input().split()))
ans=[]
for i in range(len(a)):
cnt=0
m=a[i]
while m%2==0:
cnt+=1
m//=2
ans.append(cnt)
print(min(ans))
|
s465102211 | p03469 | u076996519 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date col... | s = input()
print("2017" + s[:4]) | s915067231 | Accepted | 20 | 2,940 | 33 | s = input()
print("2018" + s[4:]) |
s892332753 | p02833 | u879266613 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 174 | For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N). | num = int(input())
result = 0
if num % 2 != 0:
result = 0
else:
num = num / 2
while(num > 0):
result += num // 5
num = num // 5
print(result)
| s855275801 | Accepted | 17 | 2,940 | 175 | num = int(input())
result = 0
if num % 2 != 0:
result = 0
else:
num = num // 2
while(num > 0):
result += num // 5
num = num // 5
print(result)
|
s952636463 | p03543 | u960570220 | 2,000 | 262,144 | Wrong Answer | 25 | 8,944 | 107 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | N = str(input())
if N[0] == N[1] and N[1] == N[2] and N[2] == N[3]:
print('Yes')
else:
print('No') | s183394984 | Accepted | 24 | 9,092 | 125 | N = str(input())
if N[0] == N[1] == N[2]:
print('Yes')
elif N[1] == N[2] == N[3]:
print('Yes')
else:
print('No') |
s485899396 | p03377 | u634079249 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 285 | 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. | import sys
import os
OK = 'APPROVED'
NG = 'DENIED'
def main():
if os.getenv("LOCAL"):
sys.stdin = open("input.txt", "r")
A, B, X = list(map(int, sys.stdin.buffer.readline().split()))
print('YES' if X - A >= B else 'NO')
if __name__ == '__main__':
main()
| s449334322 | Accepted | 17 | 3,064 | 558 | import sys
import os
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readl... |
s265544848 | p02288 | u460172144 | 2,000 | 131,072 | Wrong Answer | 30 | 7,572 | 490 | A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tr... |
def maxHeapify(i):
l =2*i
r = 2*i+1
print(A[i])
largest =0
if l <=H and A[l]> A[i]:
largest = l
else:
largest = i
if r <= H and A[r] > A[largest]:
largest = r
if largest != i :
A[i],A[largest] = A[largest],A[i]
maxHeapify(largest)
print(A)... | s429941624 | Accepted | 790 | 72,888 | 513 |
def maxHeapify(i):
l =2*i
r = 2*i+1
# print(A[i])
largest =0
if l <=H and A[l]> A[i]:
largest = l
else:
largest = i
if r <= H and A[r] > A[largest]:
largest = r
if largest != i :
A[i],A[largest] = A[largest],A[i]
maxHeapify(largest)
# prin... |
s657687452 | p03657 | u484856305 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca... | a,b=map(int,input().split())
if a+b%3==0:
print("Possible")
else:
print("Impossible") | s467492248 | Accepted | 17 | 2,940 | 111 | a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
print("Possible")
else:
print("Impossible") |
s137395882 | p02417 | u659302741 | 1,000 | 131,072 | Wrong Answer | 40 | 7,852 | 322 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | import string
text = input()
character_count_map = {}
for c in text:
if c not in character_count_map:
character_count_map[c] = 0
character_count_map[c] += 1
for c in string.ascii_lowercase:
if c in character_count_map:
print(c, ":", character_count_map[c])
else:
print(c, ":", ... | s998551174 | Accepted | 50 | 7,896 | 377 | import sys
import string
text = ""
for line in sys.stdin:
text += line
character_count_map = {}
for c in text.lower():
if c not in character_count_map:
character_count_map[c] = 0
character_count_map[c] += 1
for c in string.ascii_lowercase:
if c in character_count_map:
print(c, ":", c... |
s827893876 | p02844 | u735008991 | 2,000 | 1,048,576 | Wrong Answer | 25 | 3,060 | 299 | 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? ... | def ok(target, S):
pos = 0
for t in target:
if t in S[pos:]:
pos = S[pos:].index(t)
else:
return False
return True
N = int(input())
S = input()
ans = 0
for i in range(0, 999+1):
target = str(i).zfill(3)
ans += ok(target, S)
print(ans)
| s586377889 | Accepted | 27 | 3,060 | 241 | N = int(input())
S = input()
ans = 0
for s in range(0, 1000):
s = str(s).zfill(3)
i = 0
for d in s:
if d in S[i:]:
i += S[i:].index(d) + 1
else:
break
else:
ans += 1
print(ans)
|
s343422457 | p02612 | u235210692 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,156 | 28 | 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) | s538921220 | Accepted | 25 | 9,100 | 48 | n=int(input())
oturi=10000-n
print(oturi%1000) |
s187316564 | p03563 | u505422196 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 126 | Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the cont... | n = int(input())
k = int(input())
a = 1
for i in range(n):
if 2*a>=a+k:
a = a+k
else:
a = 2*a
print(a) | s207812092 | Accepted | 17 | 2,940 | 60 | r = int(input())
g = int(input())
goal = 2*g - r
print(goal) |
s429510199 | p03494 | u462214100 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 171 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = int(input())
A = list(map(int, input().split()))
ans = 0
for a in A:
i = 0
while a % 2 == 0:
a = a // 2
i += 1
ans = min(ans,i)
print(ans) | s137521114 | Accepted | 18 | 2,940 | 161 | ans=10**9
n=int(input())
s=list(map(int,input().split()))
for i in s:
p=0
while i%2==0:
i//=2
p+=1
if p<ans:
ans=p
print(ans) |
s751717846 | p04029 | u000123984 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 33 | 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) | s424974421 | Accepted | 17 | 2,940 | 38 | n = int(input())
print(int(n*(n+1)/2)) |
s391305126 | p00003 | u831725332 | 1,000 | 131,072 | Wrong Answer | 40 | 5,592 | 166 | Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so. | N = int(input())
for i in range(N):
sides = list(map(int, input().split()))
if max(sides) == min(sides):
print('YES')
else:
print('NO')
| s810221166 | Accepted | 40 | 5,596 | 245 | N = int(input())
for i in range(N):
adjacent_side_1, adjacent_side_2, hypotenuse = sorted(list(map(int, input().split())))
if adjacent_side_1**2 + adjacent_side_2**2 == hypotenuse**2:
print('YES')
else:
print('NO')
|
s048235270 | p03720 | u636822224 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? | n,m=map(int,input().split())
a=[input() for i in range(m)]
print(a) | s075531696 | Accepted | 18 | 2,940 | 167 | n,m=map(int,input().split())
items=[input().split() for i in range(m)]
for i in range(1,n+1):
cnt=0
for j in range(m):
cnt+=items[j].count(str(i))
print(cnt) |
s019439889 | p02612 | u637918426 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,164 | 33 | 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)
| s170019253 | Accepted | 28 | 9,148 | 68 | N = int(input())
print(1000 - (N % 1000) if (N % 1000) != 0 else 0) |
s007064235 | p02259 | u510829608 | 1,000 | 131,072 | Wrong Answer | 20 | 7,672 | 382 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in... | N = int(input())
A = list(map(int, input().split()))
def bubblesort(A, N):
flag = True
i = 0
cnt = 0
while flag:
flag = False
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = True
cnt += 1
... | s867773214 | Accepted | 20 | 7,688 | 379 | N = int(input())
A = list(map(int, input().split()))
def bubblesort(A, N):
flag = True
i = 0
cnt = 0
while flag:
flag = False
for j in range(N-1, i, -1):
if A[j] < A[j-1]:
A[j], A[j-1] = A[j-1], A[j]
flag = True
cnt += 1
... |
s742100473 | p02646 | u299599133 | 2,000 | 1,048,576 | Wrong Answer | 2,205 | 9,192 | 276 | 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 ... | A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
x = A - B
v = abs(V - W)
if v <= 0:
print('NO')
else:
for t in range(1,T+1):
x -= v
if x == 0:
print('YES')
break
else:
print('NO') | s152844766 | Accepted | 23 | 9,192 | 276 | A,V = map(int, input().split())
B,W = map(int, input().split())
T = int(input())
x = abs(A - B)
v = V - W
if v <= 0:
print('NO')
else:
if T < x // v:
print('NO')
elif T == x // v and x % v > 0:
print('NO')
else:
print('YES') |
s261189612 | p03448 | u130900604 | 2,000 | 262,144 | Wrong Answer | 50 | 2,940 | 192 | 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 co... | a,b,c,x=map(int,open(0).read().split())
cnt=0
#O(n**3)=O(50**3)=O(125000)
for i in range(a):
for j in range(b):
for k in range(c):
if 500*i+100*j+50*k==x:
cnt+=1
print(cnt) | s284249116 | Accepted | 53 | 3,060 | 198 | a,b,c,x=map(int,open(0).read().split())
cnt=0
#O(n**3)=O(50**3)=O(125000)
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if 500*i+100*j+50*k==x:
cnt+=1
print(cnt) |
s201473827 | p02259 | u002280517 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 268 | Write a program of the Bubble Sort algorithm which sorts a sequence _A_ in ascending order. The algorithm should be based on the following pseudocode: BubbleSort(A) 1 for i = 0 to A.length-1 2 for j = A.length-1 downto i+1 3 if A[j] < A[j-1] 4 swap A[j] and A[j-1] Note that, in... | n = int(input())
a = list(map(int,input().split()))
flag = True
judge = True
while flag:
for i in range(n-1,0,-1):
if a[i] < a[i - 1]:
a[i],a[i - 1] = a[i - 1], a[i] #swap
print(' '.join(map(str,a)))
if sorted(a) == a: flag = False
| s118169617 | Accepted | 20 | 5,600 | 306 | n = int(input())
a = list(map(int,input().split()))
flag = True
judge = True
count=0
while flag:
for i in range(n-1,0,-1):
if a[i] < a[i - 1]:
a[i],a[i - 1] = a[i - 1], a[i] #swap
count+=1
if sorted(a) == a: flag = False
print(' '.join(map(str,a)))
print(count)
|
s834881000 | p04043 | u488178971 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 189 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ... |
a ,b, c = map(int,input().split())
all_num =[]
all_num.append(a)
all_num.append(b)
all_num.append(c)
if all_num.count(5)==2 and all_num.count(7)==1:
print("Yes")
else:
print("No")
| s591469407 | Accepted | 17 | 2,940 | 119 | #042 A
S = [int(j) for j in input().split()]
if S.count(5)==2 and S.count(7)==1:
print('YES')
else:
print('NO') |
s856179387 | p02842 | u297651868 | 2,000 | 1,048,576 | Wrong Answer | 38 | 2,940 | 115 | Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer).... | n = int(input())
for i in range(n):
tmp=i*1.08//1
if tmp==n:
print(tmp)
exit(0)
print(":(") | s031879371 | Accepted | 47 | 3,060 | 117 | n = int(input())
for i in range(50000):
tmp=i*1.08//1
if tmp==n:
print(i)
exit(0)
print(":(") |
s389155901 | p02401 | u482227082 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 192 | 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. | line = input().split()
a = int(line[0])
op = line[1]
b = int(line[2])
if op == "+":
print(a + b)
elif op =="-":
print(a - b)
elif op =="*":
print(a * b)
else:
print(a // b)
| s190448336 | Accepted | 20 | 5,600 | 412 | #
# 4c
#
def main():
while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == "?":
break
elif op == "+":
print(a+b)
elif op == "-":
print(a-b)
elif op == "*":
print(a*b)
elif op == "/":
... |
s304260337 | p03379 | u638282348 | 2,000 | 262,144 | Wrong Answer | 1,331 | 35,704 | 267 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | import numpy as np
N = int(input())
X = np.array(input().split(), dtype=np.int64)
argsort = X.argsort().argsort()
X_sorted = X[argsort]
m1, m2 = N // 2 - 1, N // 2
for idx in argsort:
if idx > m1:
print(X_sorted[m1])
else:
print(X_sorted[m2])
| s732805157 | Accepted | 1,131 | 35,712 | 289 | import numpy as np
N = int(input())
X = np.array(input().split(), dtype=np.int64)
argsort = X.argsort()
argsort_argsort = argsort.argsort()
X_sorted = X[argsort]
m1, m2 = N // 2 - 1, N // 2
print("\n".join(str(X_sorted[m2]) if idx <= m1 else str(X_sorted[m1]) for idx in argsort_argsort))
|
s195511382 | p03448 | u123745130 | 2,000 | 262,144 | Wrong Answer | 51 | 3,060 | 243 | 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 co... | a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a):
for j in range(b):
for k in range(c):
if x == 500 * i + 100 * j + 50 * k:
count += 1
print(count) | s549826084 | Accepted | 53 | 3,060 | 250 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if x == 500 * i + 100 * j + 50 * k:
count += 1
print(count) |
s725929815 | p02398 | u606989659 | 1,000 | 131,072 | Wrong Answer | 30 | 7,628 | 123 | Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b. | a,b,c = map(int,input().split())
l = []
for i in range(a,b + 1):
if c % i == 0:
l.append(i)
print(len(l))
| s278575068 | Accepted | 20 | 7,572 | 89 | a,b,c = map(int,input().split())
l = [i for i in range(a,b+1) if c%i == 0]
print(len(l)) |
s246190641 | p02397 | u344890307 | 1,000 | 131,072 | Wrong Answer | 50 | 5,608 | 127 | Write a program which reads two integers x and y, and prints them in ascending order. | i=1
while True:
x,y= map(int,input().split())
if x==y==0:
break
else:
print('{0} {1}'.format(x,y))
| s877298160 | Accepted | 60 | 5,620 | 183 | i=1
while True:
xy= [int(xy) for xy in input().split()]
if xy[0]==xy[1]==0:
break
else:
print('{0} {1}'.format(sorted(xy)[0],sorted(xy)[1]))
i +=1
|
s027006808 | p03796 | u768152935 | 2,000 | 262,144 | Wrong Answer | 58 | 2,940 | 103 | 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. |
INF=1e18
MOD=1e9+7
N=int(input())
ans=1
for i in range(1, N+1):
ans*=i
ans%=MOD
print(ans) | s495338512 | Accepted | 52 | 2,940 | 108 |
INF=1e18
MOD=1e9+7
N=int(input())
ans=1
for i in range(1, N+1):
ans*=i
ans%=MOD
print(int(ans)) |
s305868111 | p02936 | u847758719 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,141 | 614,684 | 444 | Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operati... | import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
n,q=[int(_) for _ in input().split()]
ki=[[] for _ in range(n)]
ans=[0]*n
def dfs(numQ):
for child in ki[numQ]:
ans[child]+=ans[numQ]
dfs(child)
for i in range(n-1):
a,b=[int(_) for _ in input().split()]
ki[a-1].append(b-1)... | s298464547 | Accepted | 1,838 | 254,356 | 584 | import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
N, Q = map(int, input().split())
ki = [[[],0] for i in range(N)]
result = [0]*N
def dfs(i, num, parent):
num_tmp = num+ki[i][1]
result[i] = num_tmp
if not ki[i][0]:
return
for j in ki[i][0]:
if j == parent:
co... |
s809801436 | p02606 | u581403769 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,128 | 122 | How many multiples of d are there among the integers between L and R (inclusive)? | L, R, d = map(int, input().split())
count = 0
for i in range(L + 1, R):
if i % d == 0:
count += 1
print(count) | s288131215 | Accepted | 28 | 9,156 | 122 | L, R, d = map(int, input().split())
count = 0
for i in range(L, R + 1):
if i % d == 0:
count += 1
print(count) |
s564093524 | p02749 | u203843959 | 2,000 | 1,048,576 | Wrong Answer | 960 | 179,884 | 1,503 | We have a tree with N vertices. The vertices are numbered 1 to N, and the i-th edge connects Vertex a_i and Vertex b_i. Takahashi loves the number 3. He is seeking a permutation p_1, p_2, \ldots , p_N of integers from 1 to N satisfying the following condition: * For every pair of vertices (i, j), if the distance be... | import sys
sys.setrecursionlimit(10**9)
N=int(input())
tree=[[] for _ in range(N+1)]
occur_list=[0]*(N+1)
for _ in range(N-1):
a,b=map(int,input().split())
tree[a].append(b)
tree[b].append(a)
occur_list[a]+=1
occur_list[b]+=1
#print(tree)
#print(occur_list)
leaf=0
for i in range(1,N+1):
if occur_list[i]==... | s952942186 | Accepted | 880 | 180,356 | 1,560 | import sys
sys.setrecursionlimit(10**9)
N=int(input())
tree=[[] for _ in range(N+1)]
for _ in range(N-1):
a,b=map(int,input().split())
tree[a].append(b)
tree[b].append(a)
#print(tree)
def dfs(u,par,depth):
dist_list[u]=depth
for v in tree[u]:
if v!=par:
dfs(v,u,depth+1)
dist_list=[-1]*(N+1)
dfs... |
s406547246 | p02613 | u678505520 | 2,000 | 1,048,576 | Wrong Answer | 149 | 9,204 | 271 | 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`,... | n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
s=input()
if s=='AC':
ac+=1
elif s=='WA':
wa+=1
elif s=='TLE':
tle+=1
elif s=='RE':
re+=1
print('AC ×',ac)
print('WA ×',wa)
print('TLE ×',tle)
print('RE ×',re) | s653804183 | Accepted | 141 | 9,204 | 267 | n=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(n):
s=input()
if s=='AC':
ac+=1
elif s=='WA':
wa+=1
elif s=='TLE':
tle+=1
elif s=='RE':
re+=1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re) |
s362247444 | p03485 | u745554846 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | 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 = [int(i) for i in input().split()]
print(-(-(a+b) / 2)) | s515711425 | Accepted | 17 | 2,940 | 63 | a, b = [int(i) for i in input().split()]
print(-(-(a+b) // 2)) |
s572339208 | p03407 | u244836567 | 2,000 | 262,144 | Wrong Answer | 26 | 9,084 | 94 | An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan. | a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b<=c:
print("Yes")
else:
print("No") | s527097563 | Accepted | 29 | 9,104 | 94 | a,b,c=input().split()
a=int(a)
b=int(b)
c=int(c)
if a+b>=c:
print("Yes")
else:
print("No") |
s935529807 | p00100 | u179694829 | 1,000 | 131,072 | Wrong Answer | 30 | 7,592 | 192 | There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales pr... | l = int(input())
while l != 0:
k = 0
for l in range(0,l):
li = input().split()
if int(li[1]) * int(li[2]) >= 10**6:
print(li[0])
k = 1
if k == 0:
print("NA")
l = int(input()) | s529099194 | Accepted | 50 | 7,828 | 320 | while True:
N= int(input())
if N == 0:
break
D = {}
di = []
for n in range(N):
e,p,q = input().split()
p = int(p)
q = int(q)
if e not in di:
di.append(e)
D[e] = p * q
else:
D[e] = D[e] + p * q
flag = 0
for dj in di:
if D[dj] >= 10**6:
print(dj)
flag = 1
if flag == 0:
print("NA")
|
s919394629 | p03455 | u533232830 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 101 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = (int(x) for x in input().split())
if a%2==1 & b%2==1:
print("odd")
else:
print("even") | s364470574 | Accepted | 17 | 2,940 | 101 | a, b = (int(x) for x in input().split())
if a%2==1 & b%2==1:
print("Odd")
else:
print("Even") |
s862372492 | p03068 | u965581346 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 182 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | # -*- coding: utf-8 -*-
N = int(input())
S = input()
K = int(input())
result = ''
sk = S[K-1]
print(sk)
for s in S:
if sk == s:
result += s
else:
result += '*'
print(result) | s663464684 | Accepted | 17 | 3,060 | 176 | # -*- coding: utf-8 -*-
N = int(input())
S = input()
K = int(input())
result = ''
sk = S[K-1]
for s in S:
if sk == s:
result += s
else:
result += '*'
print(result) |
s567698169 | p03555 | u074220993 | 2,000 | 262,144 | Wrong Answer | 29 | 8,936 | 110 | 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. | up = list(input())
down = list(input())
up.reverse()
if up == down:
print('Yes')
else:
print('No')
| s991605722 | Accepted | 31 | 8,916 | 91 | with open(0) as f:
C = ''.join(f.read().split())
print('YES' if C == C[::-1] else 'NO') |
s358064394 | p02742 | u075595666 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 94 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to... | h,w = [int(i) for i in input().split()]
if h*w%2 == 0:
print(h*w/2)
else:
print((h*w+1)/2) | s552450060 | Accepted | 18 | 2,940 | 150 | h,w = [int(i) for i in input().split()]
if (h-1)*(w-1) != 0:
if h*w%2 == 0:
print(int(h*w/2))
else:
print(int((h*w+1)/2))
else:
print(1) |
s674727819 | p02396 | u508732591 | 1,000 | 131,072 | Wrong Answer | 70 | 7,732 | 109 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are give... | import sys
i=1
for n in sys.stdin:
if int(n) == 0:
break
print("Case "+str(i)+": "+n,end="") | s275272476 | Accepted | 70 | 7,960 | 113 | import sys
i=1
for s in sys.stdin:
n = int(s)
if n == 0:
break
print("Case ",i,": ",n,sep="")
i += 1 |
s259927041 | p03399 | u228223940 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 124 | You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimu... | a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a > b:
b = a
if c > d:
d = c
print(b+d) | s904520039 | Accepted | 17 | 3,060 | 124 | a = int(input())
b = int(input())
c = int(input())
d = int(input())
if a < b:
b = a
if c < d:
d = c
print(b+d) |
s180190331 | p03534 | u075012704 | 2,000 | 262,144 | Wrong Answer | 26 | 3,444 | 162 | 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. | from collections import Counter
S = input()
C = Counter(S)
for n in C.values():
if n > len(S) // 2:
print("No")
break
else:
print("Yes")
| s400352894 | Accepted | 19 | 3,188 | 140 | S = input()
A, B, C = S.count('a'), S.count('b'), S.count('c')
if max(A, B, C) - min(A, B, C) <= 1:
print('YES')
else:
print('NO')
|
s192946230 | p02412 | u067975558 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 367 | Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9 | while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0:
break
count = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
for k in range(j + 1, n + 1):
if x - i + j + k == 0:
count += 1
if x - i + j + k ... | s519759368 | Accepted | 250 | 6,724 | 352 | while True:
(n, x) = [int(i) for i in input().split()]
if n == x == 0: break
count = 0
for i in range(1,n - 1):
for j in range(i + 1 ,n):
if i + j + j + 1 > x: break
for k in range(j + 1 ,n + 1):
if i + j + k == x:
count += 1
... |
s874170566 | p03635 | u472333691 | 2,000 | 262,144 | Wrong Answer | 28 | 8,940 | 45 | In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city? | s=input()
print(s[0] + str(len(s)-2) + s[-1]) | s799371379 | Accepted | 25 | 9,140 | 51 | n, m = map(int, input().split())
print((n-1)*(m-1)) |
s399279140 | p03377 | u341543478 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 98 | 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 = list(map(int, input().split()))
print('Yes') if (a <= x) & (x - a < b) else print('No')
| s303044413 | Accepted | 17 | 2,940 | 101 | a, b, x = list(map(int, input().split()))
if a <= x <= a + b:
print('YES')
else:
print('NO')
|
s571419669 | p03644 | u281303342 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 41 | 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... | N = int(input())
print(len(bin(N)[2:])-1) | s052287485 | Accepted | 18 | 2,940 | 46 | N = int(input())
print(2**(len(bin(N)[2:])-1)) |
s088359828 | p02928 | u867604473 | 2,000 | 1,048,576 | Wrong Answer | 705 | 3,188 | 484 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of o... | N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * len(A)
C = [0] * len(A)
mod = 1000000007
counter = 0
for i in range(N):
B[i] = sum([A[i] > A[j] for j in range(0,N)])
C[i] = sum([A[i] > A[j] for j in range(i, N )])
B[i] = int(B[i]) if B[i] >0 else 0
for i in range(N-1):
... | s609133788 | Accepted | 746 | 3,188 | 471 | N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * len(A)
C = [0] * len(A)
mod = 10 ** 9 + 7
counter = 0
for i in range(N):
B[i] = sum([A[i] > A[j] for j in range(0, N)])
C[i] = sum([A[i] > A[j] for j in range(i, N)])
for i in range(N):
c = (C[i] * K)%mod + ((K - 1) * K * B[... |
s204189157 | p03487 | u845620905 | 2,000 | 262,144 | Wrong Answer | 137 | 15,260 | 264 | You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly ... | n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
now = 0
cnt = 1
for i in range(1, n):
if(a[i-1] != a[i]):
ans += min(abs(a[i-1] - cnt), cnt)
cnt = 1
else:
cnt += 1
ans += min(cnt, a[-1] - cnt)
print(ans)
| s036867151 | Accepted | 115 | 14,692 | 350 | n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ans = 0
now = 0
cnt = 1
for i in range(1, n):
if(a[i-1] != a[i]):
if(cnt >= a[i-1]):
ans += cnt - a[i-1]
else:
ans += cnt
cnt = 1
else:
cnt += 1
if(cnt >= a[-1]):
ans += cnt - a[-1]
els... |
s493571257 | p03997 | u011872685 | 2,000 | 262,144 | Wrong Answer | 26 | 9,028 | 80 | 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. | #45
a=int(input())
b=int(input())
h=int(input())
if h%2==0:
print((a+b)*h/2) | s354636735 | Accepted | 25 | 8,976 | 85 | #45
a=int(input())
b=int(input())
h=int(input())
if h%2==0:
print(int((a+b)*h/2)) |
s454191412 | p03161 | u556594202 | 2,000 | 1,048,576 | Wrong Answer | 1,899 | 20,640 | 212 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to one of the following: Stone i + 1, i + 2, \... | N,K = map(int,input().split())
h = list(map(int,input().split()))
cost = [0]
for i in range(2,N+1):
print(i)
cost.append( min([cost[j] + abs(h[i-1]-h[j]) for j in range(max(0,i-K-1), i-1)]) )
print(cost) | s815149023 | Accepted | 1,864 | 20,680 | 204 | N,K = map(int,input().split())
h = list(map(int,input().split()))
cost = [0]
for i in range(2,N+1):
cost.append( min([cost[j] + abs(h[i-1]-h[j]) for j in range(max(0,i-K-1), i-1)]) )
print(cost[-1])
|
s343236738 | p03605 | u796877631 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 44 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | n=input()
print("YES" if "9" in n else "NO") | s291408547 | Accepted | 17 | 2,940 | 44 | n=input()
print("Yes" if "9" in n else "No") |
s324909616 | p03644 | u908763441 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | 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... | N = int(input())
ans = 1
while N > ans:
ans = ans *2
print(ans/2) | s737799707 | Accepted | 17 | 2,940 | 99 | N = int(input())
ans = 1
while N > ans:
ans = ans * 2
ans = N if ans == N else ans//2
print(ans)
|
s485472351 | p04043 | u289162337 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 143 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each ... | a, b, c = map(int, input().split())
if a+b+c == 17:
if set([a, b, c]) == (5, 7):
print("YES")
else:
print("NO")
else:
print("NO") | s333348491 | Accepted | 17 | 2,940 | 143 | a, b, c = map(int, input().split())
if a+b+c == 17:
if set([a, b, c]) == {5, 7}:
print("YES")
else:
print("NO")
else:
print("NO") |
s731437540 | p02390 | u721446434 | 1,000 | 131,072 | Wrong Answer | 30 | 7,652 | 67 | 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. | num = int(input())
print(int(num/3600), int((num%3600)/60), num%60) | s267092190 | Accepted | 30 | 7,660 | 76 | num = int(input())
print(int(num/3600), int((num%3600)/60), num%60, sep=":") |
s471603215 | p02690 | u225053756 | 2,000 | 1,048,576 | Wrong Answer | 234 | 37,624 | 190 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | import numpy as np
X = int(input())
t = np.arange(-100000, 100000, 1)
t = t**2
S = set(t)
for B in range(-100000, 100001, 1):
if X+B**5 in S:
print("%d %d"%((X+B**5)**0.2, B))
| s589174402 | Accepted | 1,065 | 195,672 | 268 | import numpy as np
X = int(input())
t = np.arange(0, 2000001, 1)
t = t**5
S = set(t)
for B in range(0,200001,1):
if X+B**5 in S:
print("%d %d"%((X+B**5)**0.2, B))
break
if X-B**5 in S:
print("%d %d"%((X-B**5)**0.2, -B))
break
|
s948360926 | p02383 | u027874809 | 1,000 | 131,072 | Wrong Answer | 20 | 5,612 | 684 | Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, ... | all_list = list(map(int, input().split()))
shiji = list(input())
for x in range(len(shiji)):
print(all_list)
if shiji[x] == 'S':
all_list[0], all_list[1], all_list[5], all_list[4] = all_list[1], all_list[5], all_list[4], all_list[0]
elif shiji[x] == 'N':
all_list[1], all_list[5], all_list[4]... | s664130168 | Accepted | 20 | 5,568 | 151 | r={'N':(1,5,2,3,0,4),'S':(4,0,2,3,5,1),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3)}
d=input().split()
for x in input():
d=[d[y]for y in r[x]]
print(d[0])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.