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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s731239909 | p03711 | u766566560 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 183 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group. | list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
list3 = [2]
num = map(int, input().split())
if num in list1 or num in list2 or num in list3:
print('Yes')
else:
print('No') | s297823564 | Accepted | 17 | 3,060 | 229 | list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
list3 = [2]
x, y = map(int, input().split())
if (x in list1 and y in list1) or (x in list2 and y in list2) or (x in list3 and y in list3):
print('Yes')
else:
print('No') |
s409633207 | p03139 | u102126195 | 2,000 | 1,048,576 | Wrong Answer | 23 | 3,316 | 84 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question. | def A():
n, a, b = map(int, input().split())
print(min(a, b), a + b - n)
A() | s073182794 | Accepted | 17 | 2,940 | 93 | def A():
n, a, b = map(int, input().split())
print(min(a, b), max(a + b - n, 0))
A()
|
s176212314 | p03448 | u943057856 | 2,000 | 262,144 | Wrong Answer | 55 | 3,060 | 218 | 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())
ans = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
price = 500*a + 100*b + 50*c
if price == X:
ans += 1 | s910662142 | Accepted | 51 | 2,940 | 193 | a,b,c,x=[int(input()) for _ in range(4)]
ans=0
for A in range(a+1):
for B in range(b+1):
for C in range(c+1):
if 500*A+100*B+50*C == x:
ans+=1
print(ans) |
s252235624 | p02927 | u541610817 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,176 | 167 | Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have? | M, D = [int(_) for _ in input().split()]
ans = 0
for m in range(1, M+1):
for d in range(1, D+1):
dd = (d%10) * (d - d%10)//10
if dd == m: ans += 1
print(ans) | s709339917 | Accepted | 31 | 8,984 | 204 | M, D = [int(_) for _ in input().split()]
ans = 0
for m in range(1, M+1):
for d in range(1, D+1):
d0 = d%10
d10 = (d - d%10)//10
if d0 > 1 and d10 > 1 and d0 * d10 == m: ans += 1
print(ans)
|
s676885763 | p03007 | u392319141 | 2,000 | 1,048,576 | Wrong Answer | 245 | 14,608 | 314 | There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer. | from collections import deque
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans = sum(A[N//2:]) - sum(A[:N//2])
print(ans)
A = deque(A)
ans = 0
for i in range(N - 1):
x, y = A.popleft(), A.pop()
print(y, x)
if x - y > 0:
A.append(x - y)
else:
A.appendleft(x - y)
| s101346731 | Accepted | 224 | 14,324 | 678 | N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] < 0 and A[-1] > 0:
ans = 0
for a in A:
ans += abs(a)
print(ans)
now = A[0]
for a in A[1:N - 1]:
if a >= 0:
print(now, a)
now -= a
print(A[-1], now)
now = A[-1] - now
for a in A[1: -1]:
if a < 0:
print(now, a)
now -= a
elif A[0] >= 0:
ans = sum(A) - A[0] * 2
print(ans)
now = A[0]
for a in A[1: -1]:
print(now, a)
now -= a
print(A[-1], now)
else:
ans = -sum(A) + A[-1] * 2
print(ans)
now = A[-1]
for a in A[: -1]:
print(now, a)
now -= a |
s387736541 | p03478 | u368796742 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 2,940 | 196 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | n,a,b = map(int,input().split())
count = 0
for i in range(1,n):
c = 0
while True:
if i == 0:
break
else:
c += i%10
i//10
if a <= c <= b:
count += 1
print(count) | s048372261 | Accepted | 28 | 2,940 | 172 | n,a,b = map(int,input().split())
count = 0
for i in range(1,n+1):
c = 0
d = i
while i != 0:
c += i%10
i //=10
if a <= c <= b:
count += d
print(count)
|
s828718885 | p04029 | u724012411 | 2,000 | 262,144 | Wrong Answer | 27 | 9,140 | 40 | 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? | a=int(input())
ans=a*(a+1)/2
print(ans)
| s046158158 | Accepted | 27 | 8,740 | 41 | a=int(input())
ans=a*(a+1)//2
print(ans)
|
s273828533 | p03418 | u347640436 | 2,000 | 262,144 | Wrong Answer | 77 | 2,940 | 142 | Takahashi had a pair of two positive integers not exceeding N, (a,b), which he has forgotten. He remembers that the remainder of a divided by b was greater than or equal to K. Find the number of possible pairs that he may have had. | N, K = map(int, input().split())
result = 0
for b in range(K + 1, N + 1):
result += (N // b) * (b - K) + max(N % b - K, 0)
print(result)
| s116380368 | Accepted | 98 | 2,940 | 153 | N, K = map(int, input().split())
result = 0
for b in range(K + 1, N + 1):
result += (N // b) * (b - K) + max(N % b - max(K - 1, 0), 0)
print(result) |
s957493619 | p03494 | u626337957 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 2,940 | 240 | 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())
nums = list(map(int, input().split()))
ans = 10**9
for num in nums:
div_num = num
cnt = 0
while True:
if num%2 == 0:
div_num = num//2
cnt += 1
else:
ans = min(ans, cnt)
break
print(ans) | s809720956 | Accepted | 18 | 2,940 | 206 | N = int(input())
nums = list(map(int, input().split()))
ans = 0
while True:
for idx, num in enumerate(nums):
if num%2 != 0:
print(ans)
exit()
else:
nums[idx] = num//2
ans += 1
|
s400096700 | p02743 | u977855674 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 156 | Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? | a, b, c = map(int, input().split())
i = a ** 2 + b ** 2 + c ** 2
j = 2 * (a * b + b * c + c * a)
k = i - j
if k < 0:
print("Yes")
else:
print("No")
| s761809591 | Accepted | 18 | 2,940 | 175 | a, b, c = map(int, input().split())
i = a ** 2 + b ** 2 + c ** 2
j = 2 * (a * b + b * c + c * a)
k = i - j
if k > 0 and c - a - b >= 0:
print("Yes")
else:
print("No")
|
s580081854 | p03992 | u328755070 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 50 | This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s. | s = input()
ans = s[:5] + ' ' + s[5:]
print(ans) | s296330512 | Accepted | 17 | 2,940 | 50 | s = input()
ans = s[:4] + ' ' + s[4:]
print(ans) |
s506097349 | p03693 | u341543478 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | s = int(''.join(input().split()))
print('No') if s % 4 else print('Yes') | s551430873 | Accepted | 17 | 2,940 | 66 | print(['NO', 'YES'][int(int(''.join(input().split())) % 4 == 0)])
|
s645759514 | p02388 | u104171359 | 1,000 | 131,072 | Wrong Answer | 20 | 7,592 | 177 | Write a program which calculates the cube of a given integer x. | #!usr/bin/env python3
def cubic(x):
return x ** 3
def main():
x = int(input('Enter a number to be cubed: '))
print(cubic(x))
if __name__ == '__main__':
main() | s985366127 | Accepted | 30 | 7,728 | 149 | #!usr/bin/env python3
def cubic(x):
return x ** 3
def main():
x = int(input())
print(cubic(x))
if __name__ == '__main__':
main() |
s563879397 | p02613 | u799428010 | 2,000 | 1,048,576 | Wrong Answer | 149 | 16,200 | 204 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. | N=int(input())
S = []
for _ in range(N):
S.append(input())
print('AC x '+ str(S.count('AC')))
print('WA x '+ str(S.count('AC')))
print('TLE x '+ str(S.count('TLE')))
print('RE x '+ str(S.count('RE'))) | s410507912 | Accepted | 148 | 16,296 | 220 | N=int(input())
S = []
for _ in range(N):
S.append(input())
A=S.count('AC')
W=S.count('WA')
T=S.count('TLE')
R=S.count('RE')
print('AC x '+ str(A))
print('WA x '+ str(W))
print('TLE x '+ str(T))
print('RE x '+ str(R)) |
s724838993 | p03456 | u912294434 | 2,000 | 262,144 | Wrong Answer | 25 | 3,572 | 124 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | n,m = input().split()
t = n + m
t = int(t)
for i in range(1,10001):
if i*i == t:
print ("Yes")
else:
print("No") | s779506994 | Accepted | 18 | 2,940 | 128 | n,m = input().split()
t = n + m
t = int(t)
for i in range(1,10001):
if i*i == t:
print ("Yes")
exit()
print("No") |
s735640621 | p04029 | u244836567 | 2,000 | 262,144 | Wrong Answer | 30 | 8,996 | 29 | 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) | s861305480 | Accepted | 29 | 9,024 | 36 | N=int(input())
print(int(N*(N+1)/2)) |
s549717020 | p03495 | u831752983 | 2,000 | 262,144 | Wrong Answer | 123 | 25,644 | 190 | Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. | n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
count[a[i]-1] += 1
count.sort()
sum=0
for i in range(k):
sum += count[i]
print(max(0,n-sum)); | s787163446 | Accepted | 140 | 24,748 | 194 | n,k=map(int,input().split())
a=list(map(int,input().split()))
count=[0]*n
for i in range(n):
count[a[i]-1] += 1
count.sort()
sum=0
for i in range(k):
sum += count[n-1-i]
print(max(0,n-sum)); |
s834235433 | p02831 | u994034374 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 166 | Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests. |
a,b = list(map(int, input().split()))
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
lcm(a,b) | s134476529 | Accepted | 17 | 2,940 | 173 |
a,b = list(map(int, input().split()))
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
def lcm(a,b):
return a*b//gcd(a,b)
print(lcm(a,b)) |
s690093021 | p04029 | u608854150 | 2,000 | 262,144 | Wrong Answer | 40 | 3,064 | 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) | s981073779 | Accepted | 40 | 3,064 | 38 | N = int(input())
print(int(N*(N+1)/2)) |
s275067144 | p03068 | u353664889 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 318 | 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 `*`. | import sys
a = []
for l in sys.stdin:
a.append(l)
word_num = int(a[0])
word = a[1]
char_num = int(a[2])
target_char = word[char_num]
result = []
for each_char in word:
if each_char == target_char:
result.append('*')
else:
result.append(each_char)
result = ''.join(result)
print(result)
| s572732260 | Accepted | 20 | 3,060 | 333 | import sys
a = []
for l in sys.stdin:
a.append(l)
word_num = int(a[0])
word = a[1].split()[0]
char_num = int(a[2])
target_char = word[char_num - 1]
result = []
for each_char in word:
if each_char != target_char:
result.append('*')
else:
result.append(each_char)
result = ''.join(result)
print(result)
|
s790057561 | p03860 | u175743386 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 63 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | text = input().split(' ')
print(' '.join([t[0] for t in text])) | s067152919 | Accepted | 20 | 2,940 | 62 | text = input().split(' ')
print(''.join([t[0] for t in text])) |
s612533302 | p03050 | u581337384 | 2,000 | 1,048,576 | Wrong Answer | 172 | 3,060 | 138 | Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those. | N = int(input())
ans = int()
for i in range(1, int((N + 1) ** 0.5) - 1):
if N % i == 0:
ans += int(N / i) - 1
print(ans)
| s819422992 | Accepted | 188 | 3,060 | 155 | N = int(input())
ans = int()
for i in range(1, int(N ** 0.5) + 1):
if N % i == 0 and i < int(N / i - 1):
ans += int(N / i) - 1
print(ans)
|
s863361128 | p04043 | u991604406 | 2,000 | 262,144 | Wrong Answer | 25 | 9,084 | 179 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | a = input().split()
countF = 0
countS = 0
for i in range(3):
countF += a[i] == 5
countS += a[i] == 7
if countF == 2 and countS == 1:
print('YES')
else:
print('NO') | s672296197 | Accepted | 21 | 8,872 | 197 | a = [int(x) for x in input().split()]
countF = 0
countS = 0
for i in range(3):
countF += a[i] == 5
countS += a[i] == 7
if countF == 2 and countS == 1:
print('YES')
else:
print('NO') |
s341131948 | p03544 | u665038048 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 134 | 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())
l1 = 2
l2 = 1
ans = 0
if n == 1:
print(l2)
exit()
for i in range(1, n):
ans, l2 = l1 + l2, ans
print(ans) | s036583122 | Accepted | 17 | 2,940 | 76 | n = int(input())
a, b = 2, 1
for i in range(n):
a, b = b, a + b
print(a) |
s905184676 | p04029 | u056599756 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 32 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n=int(input())
print(n*(n+1)/2) | s465631598 | Accepted | 17 | 2,940 | 60 | n=int(input())
ans=sum([i for i in range(n+1)])
print(ans) |
s440271537 | p02409 | u492556875 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 482 | 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. | import sys
official_house = {}
for b in range(1, 5):
for f in range(1, 4):
for r in range(1, 11):
official_house[(b, f, r)] = 0
n = int(sys.stdin.readline())
for line in sys.stdin:
(b, f, r, v) = [int(i) for i in line.split()]
official_house[(b, f, r)] += v
for b in range(1, 5):
for f in range(1, 4):
for r in range(1, 11):
print(" %d" % official_house[(b, f, r)], end="")
print()
print("####################") | s375215076 | Accepted | 30 | 6,724 | 501 | import sys
official_house = {}
for b in range(1, 5):
for f in range(1, 4):
for r in range(1, 11):
official_house[(b, f, r)] = 0
n = int(sys.stdin.readline())
for line in sys.stdin:
(b, f, r, v) = [int(i) for i in line.split()]
official_house[(b, f, r)] += v
for b in range(1, 5):
if b != 1:
print("####################")
for f in range(1, 4):
for r in range(1, 11):
print(" %d" % official_house[(b, f, r)], end="")
print() |
s871635980 | p03478 | u412481017 | 2,000 | 262,144 | Wrong Answer | 40 | 3,060 | 205 | 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())
i=0
souwa=0
while i<N:
j=i
sum =0
while j>0:
sum=sum+j%10
j=round(j/10)
#print(i,sum)
if sum>a and sum<b:
souwa=souwa+sum
i=i+1
print(souwa) | s036428131 | Accepted | 33 | 3,060 | 222 | N,a,b = map(int, input().split())
i=0
souwa=0
while i<=N:
j=i
sum =0
while j>0:
sum=sum+j%10
j=int(j/10)
#print(i,sum)
if sum>=a and sum<=b:
#print(sum,i)
souwa=souwa+i
i=i+1
print(souwa) |
s901137333 | p03795 | u339503988 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | n=int(input());print(800*n-200*n//15) | s963066034 | Accepted | 17 | 2,940 | 37 | n=int(input());print(800*n-n//15*200) |
s583534420 | p02612 | u299791633 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,080 | 30 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | a = int(input())
print(a%1000) | s082579042 | Accepted | 32 | 9,152 | 76 | a = int(input())
if a%1000 == 0:
print(0)
else:
print(1000 - a%1000) |
s708855537 | p02401 | u899891332 | 1,000 | 131,072 | Wrong Answer | 30 | 7,448 | 75 | 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. | while True:
try:
print(eval(input()))
except SyntaxError:
break | s568147002 | Accepted | 30 | 7,508 | 80 | while True:
try:
print(int(eval(input())))
except SyntaxError:
break |
s304269008 | p03502 | u815797488 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 161 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. | N = int(input())
def sum_10(n):
ans = 0
while n != 0:
ans += n % 10
n //= 10
return ans
if N / sum_10(N) == 0:
print('Yes')
else:
print('No') | s108013772 | Accepted | 17 | 2,940 | 161 | N = int(input())
def sum_10(n):
ans = 0
while n != 0:
ans += n % 10
n //= 10
return ans
if N % sum_10(N) == 0:
print('Yes')
else:
print('No') |
s485848604 | p03351 | u672882146 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 129 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate. | a,b,c,d=map(int, input().split())
if d**2 >(c-a)**2 or (d**2>(c-b)**2 and d**2>(b-a)**2):
print("Yes")
else:
print("No") | s607551906 | Accepted | 18 | 3,060 | 152 | a,b,c,d=map(int, input().split())
if d**2 >=(c-a)**2:
print("Yes")
elif (d**2>=(c-b)**2 and d**2>=(b-a)**2):
print("Yes")
else:
print("No") |
s203524686 | p03860 | u597436499 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 36 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | n = input()[0]
print("A" + n + "C")
| s055400523 | Accepted | 17 | 2,940 | 105 | n = input().split()
b = []
for i in n:
b.append(i[0])
b = ','.join(b)
b = b.replace(',','')
print(b)
|
s415102115 | p03407 | u483945851 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | 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=map(int,input().split())
if(A+B)<=C:
print("YeS")
else:
print("NO") | s828368790 | Accepted | 17 | 2,940 | 79 | A,B,C=map(int,input().split())
if (A+B)>= C:
print("Yes")
else:
print("No") |
s632832812 | p03997 | u942871960 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 76 | 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)
| s699088774 | Accepted | 17 | 2,940 | 77 | a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)
|
s934445903 | p03844 | u073549161 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 24 | Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her. | import math
math.log2(2) | s030304658 | Accepted | 17 | 2,940 | 94 | a,o,b = input().split()
a = int(a)
b = int(b)
if o == "+":
print(a+b)
else:
print(a-b) |
s223781367 | p00025 | u306037418 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 266 | Let's play Hit and Blow game. _A_ imagines four numbers and _B_ guesses the numbers. After _B_ picks out four numbers, _A_ answers: * The number of numbers which have the same place with numbers _A_ imagined (Hit) * The number of numbers included (but different place) in the numbers _A_ imagined (Blow) For example, if _A_ imagined numbers: 9 1 8 2 and _B_ chose: 4 1 5 9 _A_ should say 1 Hit and 1 Blow. Write a program which reads four numbers _A_ imagined and four numbers _B_ chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9. | import sys
for line in sys.stdin:
a = list(map(int, line.split()))
b = list(map(int, line.split()))
hit, brow = 0, 0
for i in range(4):
if a[i] == b[i]:
hit += 1
elif a[i] in b:
brow += 1
print(hit, brow)
| s165153238 | Accepted | 30 | 5,596 | 360 | import sys
count = 0
for line in sys.stdin:
if count % 2 == 0:
a = list(map(int, line.split()))
else:
b = list(map(int, line.split()))
hit, brow = 0, 0
for i in range(4):
if a[i] == b[i]:
hit += 1
elif a[i] in b:
brow += 1
print(hit, brow)
count += 1
|
s947163813 | p02393 | u928633434 | 1,000 | 131,072 | Wrong Answer | 20 | 5,536 | 30 | Write a program which reads three integers, and prints them in ascending order. | x = input().split()
print (x)
| s314097673 | Accepted | 30 | 5,592 | 230 | a,b,c = input().split()
a = int(a)
b = int(b)
c = int(c)
tmp = 0
if c < b:
tmp = b
b = c
c = tmp
if b < a:
tmp = a
a = b
b = tmp
if c < b:
tmp = b
b = c
c = tmp
print (str(a) + " " + str(b) + " " + str(c))
|
s097914323 | p03845 | u430771494 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 239 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. | N=int(input())
T= list(map(int, input().split()))
F=T
M=int(input())
Ml=[]
for i in range(0,M):
P=list(map(int, input().split()))
Ml.append(P)
for i in range(0,M):
s=Ml[i][0]-1
F[s]=Ml[i][1]
print(sum(F))
F[s]=T[s] | s364558099 | Accepted | 17 | 3,064 | 247 | N=int(input())
T= list(map(int, input().split()))
X=T
M=int(input())
Ml=[]
for i in range(0,M):
P=list(map(int, input().split()))
Ml.append(P)
for i in range(0,M):
s=Ml[i][0]-1
f=X[s]
X[s]=Ml[i][1]
print(sum(X))
X[s]=f |
s614639067 | p03352 | u541610817 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 115 | 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())
res = 0
for b in range(1, 33):
for p in range(2, 10):
res = max(res, b ** p)
print(res)
| s973526524 | Accepted | 17 | 2,940 | 138 | X = int(input())
res = 0
for b in range(1, 33):
for p in range(2, 10):
if b ** p <= X:
res = max(res, b ** p)
print(res)
|
s034693738 | p03578 | u102126195 | 2,000 | 262,144 | Wrong Answer | 414 | 35,420 | 479 | Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems. | N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
i = 0
j = 0
while True:
if i >= len(T) or j >= len(D):
break
ans = 0
while True:
if j >= len(D):
break
if T[i] == D[j]:
ans = 1
j += 1
break
j += 1
if ans == 0:
break
i += 1
if ans == 1:
print("Yes")
elif ans == 0:
print("No") | s276118459 | Accepted | 428 | 35,420 | 479 | N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
i = 0
j = 0
while True:
if i >= len(T) or j >= len(D):
break
ans = 0
while True:
if j >= len(D):
break
if T[i] == D[j]:
ans = 1
j += 1
break
j += 1
if ans == 0:
break
i += 1
if ans == 1:
print("YES")
elif ans == 0:
print("NO") |
s748402819 | p03485 | u524765246 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | 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())
c = (a+b)/2
if (c-int(c))*10 >=5:
print(c+1)
else:
print(c) | s100518308 | Accepted | 18 | 2,940 | 105 | a,b = map(int,input().split())
c = (a+b)/2
if (c-int(c))*10 >=5:
print(int(c)+1)
else:
print(int(c)) |
s369788876 | p03433 | u791527495 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 131 | 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 <= A:
print('YES')
else:
if (N - A) % 500 == 0:
print('YES')
else:
print('NO') | s803356975 | Accepted | 17 | 2,940 | 86 | N = int(input())
A = int(input())
amari = N % 500
print("Yes" if A >= amari else "No") |
s513990303 | p03494 | u291373585 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 250 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = input()
num_list = list(map(int, input().split()))
mod = list(map(lambda x: x % 2, num_list))
count = 0
while sum(mod) ==0 :
mod = list(map(lambda x: x % 2, num_list))
num_list = [x / 2 for x in num_list]
print(mod)
count +=1
print(count) | s713832352 | Accepted | 21 | 3,064 | 280 | N = int(input())
l = list(map(int,input().split()))
num = 0
while(True):
odd_flag = False
for i in l:
if (i % 2 !=0):
odd_flag = True
if(odd_flag):
break
for i in range(len(l)):
l[i] = l[i] // 2
num +=1
print(num)
|
s132391751 | p03997 | u697615293 | 2,000 | 262,144 | Wrong Answer | 29 | 8,988 | 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. | a = int(input())
b = int(input())
c = int(input())
ans = (a+b) *c /2
print(ans) | s098600880 | Accepted | 26 | 8,984 | 85 | a = int(input())
b = int(input())
c = int(input())
ans = (a+b) *c /2
print(int(ans)) |
s815599609 | p03448 | u894348341 | 2,000 | 262,144 | Wrong Answer | 50 | 3,060 | 214 | 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())
res = 0
for i in range(A + 1):
for j in range(B + 1):
for k in range(C + 1):
if 500*i + 100*i + 50*k == X:
res += 1
print(res) | s984647002 | Accepted | 50 | 3,060 | 210 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 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:
ans += 1
print(ans) |
s624896292 | p02854 | u239904571 | 2,000 | 1,048,576 | Wrong Answer | 138 | 26,220 | 252 | 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(int(x) for x in input().split(" "))
center = sum(a) / 2
print(center)
sum = 0
diff = float('inf')
for x in a:
if abs(sum + x - center) > diff:
break
sum += x
diff = abs(sum - center)
print(int(diff * 2))
| s228283080 | Accepted | 133 | 26,220 | 238 | n = int(input())
a = list(int(x) for x in input().split(" "))
center = sum(a) / 2
sum = 0
diff = float('inf')
for x in a:
if abs(sum + x - center) > diff:
break
sum += x
diff = abs(sum - center)
print(int(diff * 2))
|
s670106790 | p02261 | u058433718 | 1,000 | 131,072 | Wrong Answer | 20 | 7,736 | 1,385 | Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance). | import sys
def is_stable(in_data, out_data):
len_data = len(in_data)
for i in range(len_data):
for j in range(i+1, len_data):
for a in range(len_data):
for b in range(a+1, len_data):
if in_data[i][1] == in_data[j][1] and\
in_data[i] == out_data[b] and\
in_data[j] == out_data[a]:
return False
return True
def bubble_sort(data, n):
for i in range(n):
for j in range(n-1, i, -1):
if data[j][1] < data[j-1][1]:
data[j], data[j-1] = data[j-1], data[j]
def selection_sort(data, n):
for i in range(n):
minj = i
for j in range(i, n):
if data[j][1] < data[minj][1]:
minj = j
data[i], data[minj] = data[minj], data[i]
def main():
n = int(sys.stdin.readline().strip())
card1 = sys.stdin.readline().strip().split(' ')
card2 = card1[::]
bubble_sort(card2, n)
print(card2)
if is_stable(card1, card2):
print('Stable')
else:
print('Not stable')
card2 = card1[::]
selection_sort(card2, n)
print(card2)
if is_stable(card1, card2):
print('Stable')
else:
print('Not stable')
if __name__ == '__main__':
main()
| s926702982 | Accepted | 20 | 7,820 | 1,193 | import sys
def is_stable(bs_data, ss_data):
# in_data : ??????????????????????????????????????????
# ss_data : ???????????????????????????????????????
len_data = len(bs_data)
for i in range(len_data):
if bs_data[i] != ss_data[i]:
return False
return True
def bubble_sort(data, n):
for i in range(n):
for j in range(n-1, i, -1):
if data[j][1] < data[j-1][1]:
data[j], data[j-1] = data[j-1], data[j]
def selection_sort(data, n):
for i in range(n):
minj = i
for j in range(i, n):
if data[j][1] < data[minj][1]:
minj = j
data[i], data[minj] = data[minj], data[i]
def main():
n = int(sys.stdin.readline().strip())
card1 = sys.stdin.readline().strip().split(' ')
card2 = card1[::]
bubble_sort(card2, n)
print(' '.join(card2))
print('Stable')
card3 = card1[::]
selection_sort(card3, n)
print(' '.join(card3))
if is_stable(card2, card3):
print('Stable')
else:
print('Not stable')
if __name__ == '__main__':
main()
|
s976328504 | p01102 | u848218390 | 8,000 | 262,144 | Wrong Answer | 30 | 5,580 | 766 | The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program. Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such _close_ submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions. | while 1:
s1 = input()
if s1 == '.': break
s2 = input()
S1 = s1.partition('\"')
S2 = s2.partition('\"')
jdg = 1
cnt_d = 0
if len(S1) != len(S2):
if '\"' in s1 or '\"' in s2:
jdg = 1
print("CLOSE")
else:
jdg = 0
print("DIFFERENT")
else:
l = len(S1)
i = 0
while i < l:
if S1[i] != S2[i]:
cnt_d += 1
if '\"' in S1[i] and '\"' in S2[i]:
jdg = 1
else:
jdg = 0
break
i += 1
if jdg == 1 and cnt_d == 1: print("CLOSE")
elif jdg == 0 or cnt_d > 1: print("DIFFERENT")
else: print("IDENTICAL")
| s315400615 | Accepted | 30 | 5,584 | 600 | while 1:
s1 = input().split('\"')
if s1[0] == '.': break
s2 = input().split('\"')
jdg = 1
cnt_d = 0
if len(s1) != len(s2): print("DIFFERENT")
else:
l = len(s1)
i = 0
while i < l:
if s1[i] != s2[i]:
cnt_d += 1
if cnt_d == 1 and i % 2 == 1:
jdg = 1
else:
jdg = 0
break
i += 1
if jdg == 1 and cnt_d == 1: print("CLOSE")
elif jdg == 0 or cnt_d > 1: print("DIFFERENT")
else: print("IDENTICAL")
|
s486830193 | p03408 | u115682115 | 2,000 | 262,144 | Wrong Answer | 21 | 3,316 | 262 | 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 earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards. | import collections
N = int(input())
blue = [list(input().split()) for i in range(N)]
M = int(input())
red = [list(input().split()) for i in range(M)]
sum =0
for i in blue:
score = blue.count(i) - red.count(i)
if score>sum:
result = sum
print(sum) | s122713432 | Accepted | 21 | 3,316 | 261 | import collections
N = int(input())
blue = [list(input().split()) for i in range(N)]
M = int(input())
red = [list(input().split()) for i in range(M)]
sum =0
for i in blue:
score = blue.count(i) - red.count(i)
if score>sum:
sum = score
print(sum) |
s379261652 | p03380 | u758411830 | 2,000 | 262,144 | Wrong Answer | 2,206 | 27,048 | 518 | 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()))
def calc_comb(n, r):
x = 1
y = 1
lc = r
for _ in range(lc):
x *= n
y *= r
n -= 1
r -= 1
return x//y
max_a = max(a)
res = [calc_comb(max_a, x) if x != max_a else -1 for x in a]
import numpy as np
idx = np.argmax(res) % len(a)
print(res)
print('{:d} {:d}'.format(max_a, a[idx]))
| s419011382 | Accepted | 150 | 30,688 | 358 | n = int(input())
a = list(map(int, input().split()))
a.sort()
import bisect
import numpy as np
amax = a[-1]
cent = amax // 2
idx = bisect.bisect_left(a, cent)
if idx == len(a)-1:
print(amax, a[-2])
else:
max_idx = np.argmin([abs(a[idx]-cent), abs(a[idx-1]-cent)])
if max_idx:
print(amax, a[idx-1])
else:
print(amax, a[idx])
|
s495455940 | p03696 | u652737716 | 2,000 | 262,144 | Wrong Answer | 20 | 3,188 | 229 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one. | import re
S = input()
while True:
pre = S
S = re.sub(r'\(((L|R)*?)\)', r'L\1R', S)
if pre == S:
break
S = '(' * S.count(')') + S + ')' * S.count('(')
S = S.replace('L', '(')
S = S.replace('R', ')')
print(S) | s320424173 | Accepted | 22 | 3,316 | 246 | import re
N = int(input())
S = input()
while True:
pre = S
S = re.sub(r'\(((L|R)*?)\)', r'L\1R', S)
if pre == S:
break
S = '(' * S.count(')') + S + ')' * S.count('(')
S = S.replace('L', '(')
S = S.replace('R', ')')
print(S) |
s534870363 | p03607 | u201234972 | 2,000 | 262,144 | Time Limit Exceeded | 2,127 | 499,096 | 123 | You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game? | N = int(input())
X = [ 0 for _ in range(10**9)]
for i in range(N):
a = int(input())
X[a] = (X[a]+1)%2
print(sum(X)) | s627693718 | Accepted | 251 | 8,280 | 275 | N = int(input())
A = []
for i in range(N):
A.append(int(input()))
A = sorted(A)
ans = 0
K = A[0]
cnt = 0
for i in range(N):
if A[i] == K:
cnt = (cnt + 1)%2
else:
K = A[i]
ans += cnt
cnt = 1
if A[N-1] == K:
ans += cnt
print(ans) |
s076252744 | p02615 | u638456847 | 2,000 | 1,048,576 | Wrong Answer | 208 | 31,296 | 405 | Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into? | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
A.sort(reverse=True)
ans = A[0]
n = 1
cnt = 0
while cnt <= N-2:
for j in range(2):
ans += A[n]
n += 1
cnt += 1
print(ans)
if __name__ == "__main__":
main()
| s080434082 | Accepted | 130 | 31,448 | 326 | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
def main():
N = int(readline())
A = [int(i) for i in readline().split()]
A.sort(reverse=True)
ans = 0
for i in range(1, N):
ans += A[i // 2]
print(ans)
if __name__ == "__main__":
main()
|
s613916140 | p02406 | u104171359 | 1,000 | 131,072 | Wrong Answer | 40 | 7,612 | 358 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; } | #!usr/bin/env python3
import sys
def int_fetcher():
num = int(sys.stdin.readline())
return num
def generate_factors_of_three():
res = ''
for i in range(1, int_fetcher()+1):
if (i % 3 == 0):
res += ' ' + str(i)
return res
def main():
print(generate_factors_of_three())
if __name__ == '__main__':
main() | s178386623 | Accepted | 30 | 7,756 | 494 | #!usr/bin/env python3
import sys
def int_fetcher():
num = int(sys.stdin.readline())
return num
def call(num):
res = ''
for i in range(1, num+1):
x = i
if x % 3 == 0 or x % 10 == 3:
res += ' ' + str(i)
continue
while x:
if x % 10 == 3:
res += ' ' + str(i)
break
x //= 10
return res
def main():
print(call(int_fetcher()))
if __name__ == '__main__':
main() |
s528545348 | p03377 | u916637712 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 94 | 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,c=map(int, input().split(" "))
if a<=c and a+b>=c:
print("Yes")
else:
print("No")
| s076096212 | Accepted | 17 | 2,940 | 94 | a,b,c=map(int, input().split(" "))
if a<=c and a+b>=c:
print("YES")
else:
print("NO")
|
s003119127 | p04043 | u209619667 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 295 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | N = list(input().split())
flag = False
count_5 = 0
count_7 = 0
for n in N:
a = int(n)
if a == 5:
count_5 = count_5 + 1
elif a == 7:
count_7 = count_7 + 1
else:
flag = True
break
if flag:
break
if (count_5 == 2) and (count_7 == 1):
print('Yes')
else:
print('No') | s785838436 | Accepted | 17 | 3,060 | 295 | N = list(input().split())
flag = False
count_5 = 0
count_7 = 0
for n in N:
a = int(n)
if a == 5:
count_5 = count_5 + 1
elif a == 7:
count_7 = count_7 + 1
else:
flag = True
break
if flag:
break
if (count_5 == 2) and (count_7 == 1):
print('YES')
else:
print('NO') |
s494145653 | p03609 | u072717685 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 82 | We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? | X, t = map(int , input().split())
if t < X:
r = 0
else:
r = X-t
print(int(r)) | s182322817 | Accepted | 17 | 2,940 | 83 | X, t = map(int , input().split())
if t > X:
r = 0
else:
r = X-t
print(int(r)) |
s020409473 | p03557 | u106778233 | 2,000 | 262,144 | Wrong Answer | 312 | 22,720 | 428 | The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different. | from bisect import bisect_right
from bisect import bisect_left
def main():
n=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
sum=0
for i in range(n):
cnt=1
cnt*= bisect_left(A,B[i])
cnt*= n-bisect_right(A,B[i])
sum+=cnt
print(sum)
if __name__ == '__main__':
main() | s647241944 | Accepted | 377 | 22,720 | 428 | from bisect import bisect_right
from bisect import bisect_left
def main():
n=int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
sum=0
for i in range(n):
cnt=1
cnt*= bisect_left(A,B[i])
cnt*= n-bisect_right(C,B[i])
sum+=cnt
print(sum)
if __name__ == '__main__':
main() |
s446217293 | p03543 | u246572032 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 75 | 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 = input()
print('YES' if n[0]==n[1]==n[2] and n[1]==n[2]==n[3] else 'NO') | s450627794 | Accepted | 17 | 2,940 | 74 | N = input()
print('Yes' if N[0]==N[1]==N[2] or N[1]==N[2]==N[3] else 'No') |
s743586651 | p02393 | u064313887 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 267 | Write a program which reads three integers, and prints them in ascending order. | a,b,c = map(int,input().split())
if a < b and b < c:
print(a,b,c)
elif a < b and b > c:
print(a,c,b)
elif a > b and a < c:
print(b,a,c)
elif a > b and a > c:
print(b,c,a)
elif c < a and a < b:
print(c,a,b)
elif c < a and a > b:
print(c,b,a)
| s377600617 | Accepted | 20 | 5,596 | 326 | a,b,c = map(int,input().split())
if a <= b and b <= c:
print(a,b,c,sep=' ')
elif a <= c and c <= b:
print(a,c,b,sep=' ')
elif b <= a and a <= c:
print(b,a,c,sep=' ')
elif b <= c and c <= a:
print(b,c,a,sep=' ')
elif c <= a and a <= b:
print(c,a,b,sep=' ')
elif c <= b and b <= a:
print(c,b,a,sep=' ')
|
s170925254 | p03379 | u773981351 | 2,000 | 262,144 | Wrong Answer | 295 | 25,472 | 375 | 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, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. | def medians(nums, n):
median_left = nums[(n + 1)//2]
median_right = nums[(n + 1)//2 - 1]
return median_left, median_right
if __name__ == '__main__':
n = int(input())
nums = list(map(int, input().split()))
median_left, median_right = medians(sorted(nums), n)
for i in nums:
print(median_left) if i <= median_left else print(median_right)
| s114618764 | Accepted | 288 | 26,180 | 373 | def medians(nums, n):
median_left = nums[(n + 1)//2]
median_right = nums[(n + 1)//2 - 1]
return median_left, median_right
if __name__ == '__main__':
n = int(input())
nums = list(map(int, input().split()))
median_left, median_right = medians(sorted(nums), n)
for i in nums:
print(median_left) if i < median_left else print(median_right) |
s118070205 | p03681 | u223904637 | 2,000 | 262,144 | Wrong Answer | 48 | 3,060 | 199 | Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished. | mod=1000000007
def kai(n):
a=1
for i in range(1,n+1):
a*=i
a%=mod
return a%mod
n,m=map(int,input().split())
if abs(n-m)<=1:
print(kai(n)*kai(m)%mod)
else:
print(0) | s249675088 | Accepted | 48 | 3,064 | 248 | mod=1000000007
def kai(n):
a=1
for i in range(1,n+1):
a*=i
a%=mod
return a%mod
n,m=map(int,input().split())
if abs(n-m)==1:
print(kai(n)*kai(m)%mod)
elif abs(n-m)==0:
print(2*kai(n)*kai(m)%mod)
else:
print(0) |
s939647131 | p03958 | u635974378 | 1,000 | 262,144 | Wrong Answer | 26 | 3,068 | 284 | There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all. There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i. Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before. Compute the minimum number of days on which the same type of cake as the previous day will be eaten. | K, T = list(map(int, input().split()))
a = list(map(int, input().split()))
# m = max(seq)
# for idx,i in enumerate(seq):
# if m==i:
# return (idx, m)
#
# cnt = 0
# for _k in range(K):
# remax
#
print(max(a)*2-sum(a)-1)
| s797097999 | Accepted | 22 | 3,064 | 291 | K, T = list(map(int, input().split()))
a = list(map(int, input().split()))
# m = max(seq)
# for idx,i in enumerate(seq):
# if m==i:
# return (idx, m)
#
# cnt = 0
# for _k in range(K):
# remax
#
print(max(0,max(a)*2-sum(a)-1))
|
s567398371 | p03477 | u347397127 | 2,000 | 262,144 | Wrong Answer | 25 | 8,952 | 123 | A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right. | a,b,c,d = map(int,input().split())
if a+b<c+d:
print("Left")
elif a+b==c+d:
print("Balanced")
else:
print("Right")
| s103290263 | Accepted | 23 | 9,160 | 123 | a,b,c,d = map(int,input().split())
if a+b>c+d:
print("Left")
elif a+b==c+d:
print("Balanced")
else:
print("Right")
|
s140608946 | p03457 | u557282438 | 2,000 | 262,144 | Wrong Answer | 456 | 27,380 | 352 | 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())
s = [[0,0,0]]
for i in range(N):
s.append(list(map(int,list(input().split()))))
err = 0
for i in range(N):
dt = s[i+1][0] - s[i][0]
dist = abs(s[i+1][1] - s[i][1]) + abs(s[i+1][2] - s[i][2])
if(dt < dist):
err = 1
if(dist % 2 != dt % 2):
err = 1
if(err == 0):
print("YES")
else:
print("NO") | s052542076 | Accepted | 478 | 27,380 | 352 | N = int(input())
s = [[0,0,0]]
for i in range(N):
s.append(list(map(int,list(input().split()))))
err = 0
for i in range(N):
dt = s[i+1][0] - s[i][0]
dist = abs(s[i+1][1] - s[i][1]) + abs(s[i+1][2] - s[i][2])
if(dt < dist):
err = 1
if(dist % 2 != dt % 2):
err = 1
if(err == 0):
print("Yes")
else:
print("No") |
s936597343 | p03555 | u992759582 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 129 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | c1 = input()
c2 = input()
for i in range(0,len(c1)):
if c1[i] != c2[-(i+1)]:
print('NO')
exit()
print('Yes') | s201997933 | Accepted | 17 | 2,940 | 60 | a = input()
b = input()
print('YES' if a==b[::-1] else 'NO') |
s156077151 | p02603 | u278057806 | 2,000 | 1,048,576 | Wrong Answer | 33 | 9,188 | 419 | To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally? | from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(int, input().split()))
start = 0
money = 1000
for i in range(N - 1):
if A[i + 1] > A[i]:
tmp = 10 ** 3
for k in range(i, start - 1, -1):
tmp = min(A[k], tmp)
print(A[i + 1], tmp)
buy = money // tmp
money -= tmp * buy
money += buy * A[i + 1]
start = i + 1
print(money)
| s777934748 | Accepted | 25 | 9,140 | 273 | from sys import stdin
input = stdin.readline
N = int(input())
A = list(map(int, input().split()))
start = 0
money = 1000
for i in range(N - 1):
if A[i + 1] > A[i]:
buy = money // A[i]
money -= A[i] * buy
money += buy * A[i + 1]
print(money)
|
s738328782 | p03573 | u866949333 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 186 | You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. | a = [int(i) for i in input().split()]
for num1 in range(len(a)):
c = 0
for num2 in range(len(a)):
if num1 == num2:
c += 1
if c == 1:
print(num1)
| s721337266 | Accepted | 18 | 2,940 | 162 | a = [int(i) for i in input().split()]
for num1 in a:
c = 0
for num2 in a:
if num1 == num2:
c += 1
if c == 1:
print(num1)
|
s814292761 | p03997 | u350836088 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | 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())
h = int(input())
b = int(input())
print((a+b)*h*0.5) | s848769191 | Accepted | 17 | 2,940 | 75 | a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h*0.5))
|
s366032304 | p03339 | u623677535 | 2,000 | 1,048,576 | Wrong Answer | 63 | 3,676 | 150 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | N = int(input())
S = input()
c_e = 0
c_w = 0
for s in S:
if s == "E":
c_e += 1
elif s == "W":
c_w += 1
print(min(c_e, c_w)) | s618060889 | Accepted | 283 | 29,708 | 376 | N = int(input())
S = input()
sum_W = [0] * (N+1)
sum_E = [0] * (N+1)
for i in range(N):
if S[i] == "W":
sum_W[i+1] = sum_W[i] + 1
sum_E[i+1] = sum_E[i]
else:
sum_W[i+1] = sum_W[i]
sum_E[i+1] = sum_E[i] + 1
answers = []
for i in range(N):
answer = sum_W[i] + (sum_E[N] - sum_E[i+1])
answers.append(answer)
print(min(answers)) |
s548145268 | p02821 | u130860911 | 2,000 | 1,048,576 | Wrong Answer | 2,121 | 23,360 | 640 | Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i. Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows: * Takahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same). * Then, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y. However, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold: * Assume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \leq p < q \leq M) such that (x_p,y_p)=(x_q,y_q). What is the maximum possible happiness after M handshakes? | import numpy as np
N,M = map(int,input().split())
A = np.sort(list(map(int,input().split())))
ans = 0
xOK = A[0]*2
xNG = A[-1]*2 + 1
nx = 0
while xOK+1 < xNG:
x = (xOK + xNG)//2
nx = 0
for a in A:
print("np.searchsorted(A,x-a)=",np.searchsorted(A,x-a))
nx += N-(np.searchsorted(A,x-a))
if nx >= M:
xOK = x
break
else:
xNG = x
from itertools import accumulate
S=[0]+list(accumulate(A))
ans = 0
nnx = 0
for a in A:
nx = np.searchsorted(A,xOK-a,side='right')
ans += a*(N-nx) + (S[N]-S[nx])
nnx += (N-nx)
ans += xOK*(M-nnx)
print(ans) | s906664942 | Accepted | 1,422 | 14,368 | 565 | import bisect
from itertools import accumulate
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
ans = 0
xOK = A[0]*2
xNG = A[-1]*2 + 1
nx = 0
while xOK+1 < xNG:
x = (xOK + xNG)//2
nx = 0
for a in A:
nx += N-(bisect.bisect_left(A,x-a))
if nx >= M:
xOK = x
break
else:
xNG = x
S=[0]+list(accumulate(A))
ans = 0
nnx = 0
for a in A:
nx = bisect.bisect_right(A,xOK-a)
ans += a*(N-nx) + (S[N]-S[nx])
nnx += (N-nx)
ans += xOK*(M-nnx)
print(ans) |
s726008945 | p03671 | u533039576 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 69 | Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells. | a, b, c = map(int, input().split())
print(a + b + c - min(a, b, c))
| s980528773 | Accepted | 17 | 2,940 | 69 | a, b, c = map(int, input().split())
print(a + b + c - max(a, b, c))
|
s607772886 | p03597 | u375500286 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 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) | s887949185 | Accepted | 17 | 2,940 | 43 | n=int(input())
a=int(input())
print(n**2-a) |
s627908499 | p03607 | u043844098 | 2,000 | 262,144 | Wrong Answer | 169 | 22,712 | 234 | You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game? | def c(s):
n = input()
if n in s:
s.remove(n)
else:
s.add(n)
def main():
n = int(input())
s = set()
for i in range(n):
c(s)
return print(s)
if __name__ == '__main__':
main()
| s425933926 | Accepted | 156 | 23,096 | 368 | from typing import List
def main():
n = int(input())
nums = [input() for _ in range(n)]
print(wae(n, nums))
def wae(n: int, nums: List[str]) -> int:
s = set()
for i in range(n):
num = nums[i]
if num in s:
s.remove(num)
else:
s.add(num)
return len(s)
if __name__ == '__main__':
main()
|
s551333535 | p03353 | u905203728 | 2,000 | 1,048,576 | Wrong Answer | 27 | 15,604 | 190 | You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}. | s=input()
k=int(input())
word=[]
for i in range(len(s)):word.append(s[i:])
word=sorted(word)
for i in word:
if len(i)>=k:
print(i[:k])
exit()
else:
k -=len(i) | s328281424 | Accepted | 370 | 25,204 | 295 | s=input()
k=int(input())
words=[]
for i in range(len(s)):words.append(s[i:])
words.sort()
record=[]
for i in words:
for j in range(len(i)):
word="".join(i[:j+1])
if word not in record:
record.append(word)
if len(record)>=k:
print(record[k-1]);exit() |
s649063906 | p04029 | u374802266 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 34 | 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(int(n*n+1/2)) | s219733035 | Accepted | 17 | 2,940 | 37 | n=int(input())
print(int((n**2+n)/2)) |
s593605131 | p03385 | u187857228 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 162 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | def test():
s = input()
if "a" in s and "b" in s and "c" in s:
print("YES")
else:
print("NO")
if __name__ == "__main__":
test()
| s994375837 | Accepted | 17 | 2,940 | 144 | def test():
s = set(input())
if len(s) == 3:
print("Yes")
else:
print("No")
if __name__ == "__main__":
test()
|
s493493385 | p02409 | u037441960 | 1,000 | 131,072 | Wrong Answer | 20 | 5,640 | 442 | 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())
home = [[0 for i in range(20)] for j in range(15)]
for i in range(n) :
b, f, r, v = map(int, input().split())
h = (b - 1) * 4 + f - 1
w = r * 2 - 1
s = v
home[h][w] += s
for y in range(15) :
for x in range(20) :
if(y % 4 == 3) :
home[y][x] = "#"
elif(x % 2 == 0) :
home[y][x] == " "
print(home[y][x], end = "")
print()
| s106093802 | Accepted | 20 | 5,640 | 431 | n = int(input())
home = [[0 for i in range(20)] for j in range(15)]
for i in range(n) :
b, f, r, v = map(int, input().split())
h = (b - 1) * 4 + f - 1
w = r * 2 - 1
s = v
home[h][w] += s
for y in range(15) :
for x in range(20) :
if(y % 4 == 3) :
home[y][x] = "#"
elif(x % 2 == 0) :
home[y][x] = " "
print(home[y][x], end = "")
print()
|
s181784820 | p01101 | u217703215 | 8,000 | 262,144 | Wrong Answer | 20 | 5,604 | 354 | Mammy decided to give Taro his first shopping experience. Mammy tells him to choose any two items he wants from those listed in the shopping catalogue, but Taro cannot decide which two, as all the items look attractive. Thus he plans to buy the pair of two items with the highest price sum, not exceeding the amount Mammy allows. As getting two of the same item is boring, he wants two different items. You are asked to help Taro select the two items. The price list for all of the items is given. Among pairs of two items in the list, find the pair with the highest price sum not exceeding the allowed amount, and report the sum. Taro is buying two items, not one, nor three, nor more. Note that, two or more items in the list may be priced equally. | n,m=map(int,input().split())
a=[0]*n
a=list(input().split())
for i in range(n):
a[i]=int(a[i])
max=0
for i in range(n):
for j in range(n):
if i<j:
tmp=a[i]+a[j]
if tmp>max and tmp<=m:
max=tmp
else: pass
else: pass
if max==0:
print("NONE")
else:
print(max)
| s481226663 | Accepted | 2,170 | 5,712 | 526 | ans=[]
n,m=map(int,input().split())
while n!=0 and m!=0:
a=[0]*n
a=list(input().split())
for i in range(n):
a[i]=int(a[i])
max=0
for i in range(n):
for j in range(n):
if i<j:
tmp=a[i]+a[j]
if tmp>max and tmp<=m:
max=tmp
else: pass
else: pass
ans.append(max)
n,m=map(int,input().split())
for i in range(len(ans)):
if ans[i]==0:
print("NONE")
else:
print(ans[i])
|
s181975058 | p03693 | u661983922 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 94 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4? | r,g,b = map(int,input().split())
if (100*r+10*g+b)%4 == 0:
print("Yes")
else:
print("NO") | s218270447 | Accepted | 17 | 2,940 | 94 | r,g,b = map(int,input().split())
if (100*r+10*g+b)%4 == 0:
print("YES")
else:
print("NO") |
s341911119 | p03380 | u067983636 | 2,000 | 262,144 | Wrong Answer | 68 | 14,428 | 372 | 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()))
def f(N, A):
if len(A) == 2:
A.sort()
print(A[1], A[0])
return
maxA = max(A)
res = 0
for a in A:
if a == maxA:
continue
b = min(a, maxA - a)
if res < b:
res = b
return print(maxA, res)
f(N, A) | s937617301 | Accepted | 70 | 14,060 | 405 | N = int(input())
A = list(map(int, input().split()))
def f(N, A):
if len(A) == 2:
A.sort()
print(A[1], A[0])
return
res = 0
temp = 0
maxA = max(A)
for a in A:
if a == maxA:
continue
b = min(a, maxA - a)
if temp < b:
temp = b
res = a
return print(maxA, res)
f(N, A)
|
s898307832 | p03110 | u629540524 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,040 | 154 | 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())
x = 0
for i in range(n):
a,b = input().split()
if b == 'BTC':
x += float(x)*380000
else:
x += int(a)
print(x) | s175904226 | Accepted | 29 | 9,116 | 154 | n = int(input())
x = 0
for i in range(n):
a,b = input().split()
if b == 'BTC':
x += float(a)*380000
else:
x += int(a)
print(x) |
s304901402 | p02678 | u785573018 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 24,704 | 598 | There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists. | n, m = map(int, input().split())
A = []
B = []
c = [0]*(n-1)
for i in range(m):
a, b = map(int, input().split())
if a > b:
a, b = b, a
if a == 1:
c[b-2] = 1
else:
A.append(a)
B.append(b)
i = 0
while len(A) > 0:
if c[A[i]-2] != 0:
if c[B[i]-2] != 0:
del A[i]
del B[i]
else:
c[B[i]-2] = A.pop(i)
del B[i]
elif c[B[i]-2] != 0:
c[A[i]-2] = B.pop(i)
del A[i]
else:
i += 1
if i >= len(A):
i = 0
print("Yes")
for i in range(n-1):
print(c[i]) | s500615970 | Accepted | 1,329 | 33,644 | 347 | n, m = map(int, input().split())
c = [[] for i in range(n)]
d = [0]
e = [-1]*n
for i in range(m):
a, b = map(int, input().split())
c[a-1].append(b-1)
c[b-1].append(a-1)
while d:
f = d.pop(0)
for i in c[f]:
if e[i] == -1:
d.append(i)
e[i] = f
print("Yes")
for i in range(n-1):
print(e[i+1]+1) |
s691155569 | p02697 | u919730120 | 2,000 | 1,048,576 | Wrong Answer | 68 | 9,268 | 68 | You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given. | n,m=map(int,input().split())
for i in range(m):
print(i+1,n-i-1) | s137695613 | Accepted | 88 | 9,264 | 152 | N, M = map(int, input().split())
for i in range(M):
j = i // 2
if i % 2 == 1:
print(j+1, M-j)
else:
print(M+j+1, 2*M+1-j)
|
s247802026 | p03624 | u855057563 | 2,000 | 262,144 | Wrong Answer | 25 | 9,192 | 120 | You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead. | s=input()
for i in "abcdefghijklmnopqrstuvwswz":
if i not in s:
print(i)
break
else:
print("None")
| s846459414 | Accepted | 28 | 9,056 | 111 | s=input()
for i in "abcdefghijklmnopqrstuvwxyz":
if i not in s:
print(i)
break
else:
print("None") |
s875856969 | p03853 | u609738635 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 299 | There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down). | # -*- coding: utf-8 -*-
def solve(H, W, C):
X = []
for i in range(H):
X.append(C[i])
X.append(C[i])
for i in range(2*H):
print(X[i])
if __name__ == '__main__':
H, W = map(int, input().split())
C = [[input()] for i in range(H)]
solve(H, W, C) | s058846968 | Accepted | 17 | 3,060 | 271 | # -*- coding: utf-8 -*-
def solve(H, W, C):
for i in range(H):
for j in list(C[i]):
print(j)
print(j)
if __name__ == '__main__':
H, W = map(int, input().split())
C = [[input()] for i in range(H)]
solve(H, W, C) |
s305633891 | p02412 | u839008951 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 323 | 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 = map(int, input().split())
if(n == 0 and x == 0):
break
ot = 0
for i in range(1, n + 1):
for j in range(i + 1, n + 1):
for k in range(j + 1, n + 1):
print(i, j, k)
if i + j + k == x:
ot += 1
print(ot)
| s776785868 | Accepted | 490 | 5,596 | 292 | while True:
n, x = map(int, input().split())
if(n == 0 and x == 0):
break
ot = 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 i + j + k == x:
ot += 1
print(ot)
|
s753632215 | p03679 | u039623862 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 135 | 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())
y = b-a
if y <= 0:
print('delicious')
elif y >= x:
print('safe')
else:
print('dangerous') | s161167034 | Accepted | 17 | 2,940 | 135 | x,a,b = map(int, input().split())
y = b-a
if y <= 0:
print('delicious')
elif y <= x:
print('safe')
else:
print('dangerous') |
s633417959 | p02389 | u067299340 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 54 | Write a program which calculates the area and perimeter of a given rectangle. | x, y = [int(i) for i in input().split()]
print(x * y)
| s294194582 | Accepted | 20 | 5,592 | 67 | x, y = [int(i) for i in input().split()]
print(x * y, (x + y) * 2)
|
s960777144 | p03455 | u442948527 | 2,000 | 262,144 | Wrong Answer | 26 | 8,864 | 58 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | print(["odd","even"][eval(input().replace(" ","*"))%2==0]) | s267746961 | Accepted | 26 | 8,776 | 53 | print("EOvdedn"[eval(input().replace(" ","*"))%2::2]) |
s257958099 | p03110 | u034128150 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 191 | 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? | data = input().split()[1:]
sum = 0.0
for i in range(0, len(data), 2):
if data[i+1] == "JPY":
sum += int(data[i])
elif data[i+1] == "BTC":
sum += float(data[i]) * 380000.0
print(sum) | s108024712 | Accepted | 19 | 3,060 | 187 | n = int(input())
sum = 0.0
for _ in range(n):
data = input().split()
if data[1] == "JPY":
sum += int(data[0])
elif data[1] == "BTC":
sum += float(data[0]) * 380000.0
print(sum) |
s019279677 | p03023 | u850266651 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 33 | 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(180*(N-1)) | s257573683 | Accepted | 17 | 3,064 | 34 | N = int(input())
print(180*(N-2))
|
s537934537 | p04043 | u297756089 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 162 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | a,b,c=map(int,input().split())
if a==b==7 and c==5:
print("YES")
elif b==c==7 and a==5:
print("YES")
elif a==c==7 and b==5:
print("YES")
else:
print("NO") | s440603468 | Accepted | 17 | 3,060 | 162 | a,b,c=map(int,input().split())
if a==b==5 and c==7:
print("YES")
elif b==c==5 and a==7:
print("YES")
elif a==c==5 and b==7:
print("YES")
else:
print("NO") |
s298156270 | p03860 | u531214632 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 60 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. | S = input().split()
"{}{}{}".format(S[0][0],S[1][0],S[2][0]) | s244645975 | Accepted | 17 | 2,940 | 67 | S = input().split()
print("{}{}{}".format(S[0][0],S[1][0],S[2][0])) |
s139127877 | p03719 | u133356863 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 125 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | A,B,C=map(int,input().split())
def J(A,B,C):
if C>=A and C<=B:
return 'YES'
return 'NO'
print(J(A,B,C)) | s621764126 | Accepted | 17 | 2,940 | 139 | A,B,C=map(int,input().split())
def J(A,B,C):
if C>=A and C<=B:
return 'Yes'
else:
return 'No'
print(J(A,B,C)) |
s089856201 | p02600 | u836695640 | 2,000 | 1,048,576 | Wrong Answer | 32 | 9,180 | 358 | M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * From 1000 through 1199: 5-kyu * From 1200 through 1399: 4-kyu * From 1400 through 1599: 3-kyu * From 1600 through 1799: 2-kyu * From 1800 through 1999: 1-kyu What kyu does M-kun have? | x = int(input())
def score(x):
if 400 <= x :
print("8")
elif 600 <= x :
print("7")
elif 899 <= x :
print("6")
elif 1000 <= x :
print("5")
elif 1200 <= x :
print("4")
elif 1400 <= x :
print("3")
elif 1600 <= x :
print("2")
elif 1800 <= x <= 1999:
print("1")
print(score(x))
| s384543889 | Accepted | 31 | 9,192 | 386 | x = int(input())
def score(x):
if 400 <= x <= 599:
print("8")
elif 600 <= x <= 799:
print("7")
elif 800 <= x <= 999:
print("6")
elif 1000 <= x <= 1199:
print("5")
elif 1200 <= x <= 1399:
print("4")
elif 1400 <= x <= 1599:
print("3")
elif 1600 <= x <= 1799:
print("2")
elif 1800 <= x <= 1999:
print("1")
score(x) |
s504896544 | p03502 | u375870553 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 178 | An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. | def main():
n=input()
s=sum([int(i) for i in n])
print(s)
if int(n)%s==0:
print("Yes")
else:
print("No")
if __name__=='__main__':
main()
| s748504815 | Accepted | 17 | 2,940 | 165 | def main():
n=input()
s=sum([int(i) for i in n])
if int(n)%s==0:
print("Yes")
else:
print("No")
if __name__=='__main__':
main()
|
s536157559 | p03149 | u047535298 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 98 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | N = input().split()
N = "".join(sorted(N))
if N == "1479":
print("Yes")
else:
print("No") | s458565397 | Accepted | 17 | 2,940 | 98 | N = input().split()
N = "".join(sorted(N))
if N == "1479":
print("YES")
else:
print("NO") |
s459980952 | p02396 | u714141025 | 1,000 | 131,072 | Wrong Answer | 50 | 7,432 | 82 | In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem. | import sys
i=1
for x in sys.stdin:
print ('Case {}: {}'.format(i,x))
i+=1 | s674113046 | Accepted | 60 | 7,720 | 127 | import sys
for i, x in enumerate(map(int, sys.stdin)):
if not x:
break
print("Case {0}: {1}".format(i + 1, x)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.