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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s336184230 | p03338 | u905582793 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 180 | You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when ... | n=int(input())
s=input()
ls = list("abcdefghijklmnopqrstuvwxyz")
ans = [0]*n
for i in range(1,n):
for j in ls:
if j in s[:i] and j in s[i+1:]:
ans[i]+=1
print(max(ans)) | s063274901 | Accepted | 18 | 3,060 | 178 | n=int(input())
s=input()
ls = list("abcdefghijklmnopqrstuvwxyz")
ans = [0]*n
for i in range(1,n):
for j in ls:
if j in s[:i] and j in s[i:]:
ans[i]+=1
print(max(ans)) |
s079702888 | p03151 | u328131364 | 2,000 | 1,048,576 | Wrong Answer | 118 | 19,188 | 666 | A university student, Takahashi, has to take N examinations and pass all of them. Currently, his _readiness_ for the i-th examination is A_{i}, and according to his investigation, it is known that he needs readiness of at least B_{i} in order to pass the i-th examination. Takahashi thinks that he may not be able to pa... | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff_m = 0
diff_p = []
mcount = 0
if sum(B) > sum(A):
print("-1")
else:
for i in range(N):
difftmp = A[i] - B[i]
if difftmp < 0:
diff_m += difftmp
mcount += 1
... | s042818120 | Accepted | 119 | 18,524 | 656 | N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
diff_m = 0
diff_p = []
mcount = 0
if sum(B) > sum(A):
print(-1)
else:
for i in range(N):
difftmp = A[i] - B[i]
if difftmp < 0:
diff_m += difftmp
mcount += 1
... |
s274419564 | p03860 | u781025961 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 140 | 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... | name1 = input()
name2 = name1.replace(" ","")
name3 = name2[7:]
name4 = name3[:7]
print(name4)
lst1 = list(name4)
print("A" + lst1[0] + "C") | s844060409 | Accepted | 17 | 2,940 | 128 | name1 = input()
name2 = name1.replace(" ","")
name3 = name2[7:]
name4 = name3[:7]
lst1 = list(name4)
print("A" + lst1[0] + "C")
|
s808609282 | p03564 | u943004959 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 50 | Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the m... | R = int(input())
G = int(input())
print(2 * G - R) | s143198091 | Accepted | 17 | 2,940 | 154 | def solve():
N = int(input())
K = int(input())
ans = 1
for i in range(N):
ans = min(2 * ans, ans + K)
print(ans)
solve() |
s267745963 | p03149 | u765556930 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,064 | 20 | 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". | x = input()
print(x) | s769178567 | Accepted | 17 | 2,940 | 150 | x = input().split()
test = ["1", "9", "7", "4"]
for _ in x:
if _ in test:
test.remove(_)
if len(test) == 0:
print("YES")
else:
print("NO") |
s853222802 | p03162 | u090068671 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 400 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain... | def resolve():
N = int(input())
ABC = [
map(int, input().split())
for _ in range(N)
]
Va, Vb, Vc = ABC.pop()
for _ in range(N-1):
a, b, c = ABC.pop()
Va, Vb, Vc = max(Vb, Vc) + a, max(Va, Vc) + b, max(Va, Vb) + c
print(max(Va, Vb, Vc)) | s770196301 | Accepted | 478 | 54,424 | 410 | def resolve():
N = int(input())
ABC = [
map(int, input().split())
for _ in range(N)
]
Va, Vb, Vc = ABC.pop()
for _ in range(N-1):
a, b, c = ABC.pop()
Va, Vb, Vc = max(Vb, Vc) + a, max(Va, Vc) + b, max(Va, Vb) + c
print(max(Va, Vb, Vc))
resolve() |
s125718947 | p03607 | u760961723 | 2,000 | 262,144 | Wrong Answer | 207 | 16,660 | 197 | 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... | N = int(input())
s = [int(input()) for i in range(N)]
import collections
c = collections.Counter(s)
print(list(c.values()))
ans_lis = [x for x in list(c.values()) if x %2 != 0]
print(len(ans_lis)) | s347308390 | Accepted | 196 | 16,660 | 174 | N = int(input())
s = [int(input()) for i in range(N)]
import collections
c = collections.Counter(s)
ans_lis = [x for x in list(c.values()) if x %2 != 0]
print(len(ans_lis)) |
s497478814 | p03693 | u630657312 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 106 | 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 i... | r, g, b = map(int, input().split())
if (100*r + 10*g + b) % 4 == 0:
print('Yes')
else:
print('No') | s475355798 | Accepted | 18 | 2,940 | 106 | r, g, b = map(int, input().split())
if (100*r + 10*g + b) % 4 == 0:
print('YES')
else:
print('NO') |
s395248356 | p02831 | u006883624 | 2,000 | 1,048,576 | Wrong Answer | 39 | 3,060 | 266 | 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 ... | A, B = [int(v) for v in input().split()]
minV = min(A, B)
maxV = max(A, B)
if maxV % minV == 0:
print(maxV)
if maxV == minV + 1:
print(maxV * minV)
v = maxV * 2
for i in range(2, minV + 1):
if v % minV != 0:
v += maxV
continue
print(v)
exit()
| s176160014 | Accepted | 39 | 3,064 | 284 | A, B = [int(v) for v in input().split()]
minV = min(A, B)
maxV = max(A, B)
if maxV % minV == 0:
print(maxV)
exit()
if maxV == minV + 1:
print(maxV * minV)
exit()
v = maxV * 2
for i in range(2, minV + 1):
if v % minV != 0:
v += maxV
continue
print(v)
exit()
|
s615495820 | p03847 | u560301743 | 2,000 | 262,144 | Wrong Answer | 27 | 9,168 | 469 | You are given a positive integer N. Find the number of the pairs of integers u and v (0≦u,v≦N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Here, xor denotes the bitwise exclusive OR. Since it can be extremely large, compute the answer modulo 10^9+7. | def solve(n: int) -> int:
mod = 1e9 + 7
n_bin = '0' + bin(n)[2:]
dp = [[0, 0, 0] for _ in range(len(n_bin))]
dp[-1][0] = 1
for i in range(len(n_bin) - 2, -1, -1):
for s in range(3):
for k in range(3):
s2 = min(2, 2 * s + int(n_bin[len(n_bin) - i - 1]) - k)
... | s099005878 | Accepted | 28 | 9,224 | 479 | def solve(n: int) -> int:
mod = 1e9 + 7
n_bin = '0' + bin(n)[2:]
dp = [[0, 0, 0] for _ in range(len(n_bin))]
dp[-1][0] = 1
for i in range(len(n_bin) - 2, -1, -1):
for s in range(3):
for k in range(3):
s2 = min(2, 2 * s + int(n_bin[len(n_bin) - i - 1]) - k)
... |
s434403533 | p02747 | u340585574 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 192 | A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. | n=input()
if(len(n)%2==1):
print("No")
exit()
for i in range(int(len(n)/2)):
if(n[i]=='h'and n[i+1]=='i'):
flag=1
else:
print("No")
exit()
print("Yes")
| s192885630 | Accepted | 17 | 2,940 | 86 | n=input()
n2=n.replace('hi','')
if(len(n2)==0):
print("Yes")
else:
print("No") |
s431814405 | p04043 | u260068288 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | 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 =input()
if a.count("5") == 2 and a.count("7") == 1:
print("Yes")
else:
print("No") | s012316878 | Accepted | 17 | 2,940 | 119 | abc =input()
five = abc.count("5")
seven = abc.count("7")
if five==2 and seven==1:
print("YES")
else:
print("NO") |
s993738658 | p02742 | u623953567 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 289 | 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 = map(int,input().split())
if(H == 1 or W == 1):
print(1)
else:
if(H%2 == 0):
i = H//2
if(H%2 != 0):
i = H//2+1
j = H-i
if(W%2 == 0):
sum = i*(W//2) + j*(W//2)
if(W%2 != 0):
sum = i*(W/2+1) + j*(W/2)
print(sum) | s675611825 | Accepted | 17 | 3,064 | 296 | H,W = map(int,input().split())
if(H == 1 or W == 1):
print(1)
else:
if(H%2 == 0):
i = H//2
if(H%2 != 0):
i = H//2 + 1
j = H-i
if(W%2 == 0):
sum = i*(W//2) + j*(W//2)
if(W%2 != 0):
sum = i*(W//2 + 1) + j*(W//2)
print(sum)
|
s314625695 | p03730 | u189397279 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 158 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | import sys
A, B, C = map(int, sys.stdin.readline().split())
for i in range(1, B + 1):
if (A * i) % B == C:
print("Yes")
exit()
print("No") | s902524214 | Accepted | 17 | 2,940 | 158 | import sys
A, B, C = map(int, sys.stdin.readline().split())
for i in range(1, B + 1):
if (A * i) % B == C:
print("YES")
exit()
print("NO") |
s286953324 | p02646 | u046826851 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,160 | 205 | 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())
dis0 = b - a
dis = v - w
if dis <= 0:
print('No')
exit()
d = dis*t
if d < dis:
print('No')
else:
print('Yes')
| s315917850 | Accepted | 28 | 9,036 | 205 | a,v = map(int, input().split( ))
b,w = map(int, input().split( ))
t = int(input())
dis0 = abs(b - a)
dis = v - w
if w>=v:
print("NO")
exit()
if abs(b-a)/(v-w)>t:
print("NO")
else:
print("YES")
|
s272282990 | p03997 | u507116804 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 62 | 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) | s666895461 | Accepted | 18 | 2,940 | 80 | a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s731204278 | p02407 | u316584871 | 1,000 | 131,072 | Wrong Answer | 20 | 5,584 | 112 | Write a program which reads a sequence and prints it in the reverse order. | n = int(input())
li = list(map(int, input().split()))
li.sort()
for i in li:
print('{}'.format(i), end=" ")
| s627744953 | Accepted | 20 | 5,612 | 215 | n = int(input())
l = list(map(int, input().split()))
x = []
for i in range(n):
x.append(l[n-1-i])
for s in x:
if(s == x[n-1]):
print('{}'.format(s))
else:
print('{}'.format(s), end=" ")
|
s996274250 | p03068 | u346395915 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 150 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | n = int(input())
s = list(input())
k = int(input())
mozi = s[k-1]
print(mozi)
for i in range(n):
if s[i] != mozi:
s[i] = "*"
print(*s)
| s273911432 | Accepted | 17 | 2,940 | 146 | n = int(input())
s = list(input())
k = int(input())
mozi = s[k-1]
for i in range(n):
if s[i] != mozi:
s[i] = "*"
print(*s, sep="")
|
s157023879 | p03303 | u119460590 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,188 | 101 | You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom. | s = input()
N = int(input())
while len(s):
print(s[0:min(len(s), N)])
s = s[min(len(s), N):]
| s821901665 | Accepted | 17 | 2,940 | 50 | s = input()
N = int(input())
print(s[0:len(s):N])
|
s425124330 | p03160 | u020091453 | 2,000 | 1,048,576 | Wrong Answer | 147 | 13,928 | 355 | 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()
for i in input().split(' '):
a.append(int(i))
cost = list()
for i in range(N):
if i == 0:
cost.append(0)
elif i == 1:
cost.append(abs(a[1] - a[0]))
else:
c1 = abs(a[i] - a[i-1]) + cost[i-1]
c2 = abs(a[i] - a[i-2]) + cost[i-2]
cost.appe... | s948352857 | Accepted | 143 | 13,980 | 372 | N = int(input())
a = list()
for i in input().split(' '):
a.append(int(i))
cost = list()
for i in range(N):
if i == 0:
cost.append(0)
elif i == 1:
cost.append(abs(a[1] - a[0]))
else:
c1 = abs(a[i] - a[i-1]) + cost[i-1]
c2 = abs(a[i] - a[i-2]) + cost[i-2]
cost.appe... |
s766770248 | p03385 | u046592970 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | s = sorted(input())
if s == ["a","b","c"]:
print("Yes")
else:
print("No")
print(s) | s834313718 | Accepted | 18 | 2,940 | 82 | s = sorted(input())
if s == ["a","b","c"]:
print("Yes")
else:
print("No")
|
s438935175 | p02257 | u935329231 | 1,000 | 131,072 | Wrong Answer | 20 | 7,748 | 506 | A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list. | # -*- coding: utf-8 -*-
import math
def is_prime(x):
# Primality Test
if x <= 1 or x % 2 == 0:
return False
if x == 2:
return True
i = 3
while i <= math.sqrt(x):
if x % i == 0:
return False
i += 2
return True
def to_int(v):
return int(v)
i... | s866499940 | Accepted | 820 | 8,020 | 506 | # -*- coding: utf-8 -*-
import math
def is_prime(x):
# Primality Test
if x == 2:
return True
if x <= 1 or x % 2 == 0:
return False
i = 3
while i <= math.sqrt(x):
if x % i == 0:
return False
i += 2
return True
def to_int(v):
return int(v)
i... |
s867194513 | p03679 | u846150137 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 114 | 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. Ot... | a,b,c=map(int,input().split())
if b-c>a:
print("dangerous")
elif b>c:
print("safe")
else:
print("delicious") | s974733101 | Accepted | 17 | 2,940 | 114 | a,b,c=map(int,input().split())
if c-b>a:
print("dangerous")
elif c>b:
print("safe")
else:
print("delicious") |
s953655950 | p03090 | u198440493 | 2,000 | 1,048,576 | Wrong Answer | 26 | 3,956 | 153 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | n=int(input())
a=[]
i=1
while(i<=n):
j=i+1
while(j<=n):
if j!=n-i:
a+=[(i,j)]
j+=1
i+=1
for x in a:
print(*x) | s766519490 | Accepted | 25 | 3,956 | 187 | n=int(input())
a=[]
m=n if n&1 else n+1
i=1
while(i<=n):
j=i+1
while(j<=n):
if j!=m-i:
a+=[(i,j)]
j+=1
i+=1
print(len(a))
for x in a:
print(*x) |
s849972611 | p03713 | u244416763 | 2,000 | 262,144 | Wrong Answer | 267 | 9,220 | 722 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying... | h,w = map(int,input().split())
ans = h*w
for i in range(1,h-1):
A = w*i
if w%2 == 0 or h-1%2 == 0:
B = (h-i)*w//2
C = (h-i)*w//2
else:
if h-1 < w:
B = (h-i)*((w//2)+1)
C = (h-i)*(w//2)
else:
B = ((h-i)//2 + 1) * w
C = (h-i)//2 *... | s405998746 | Accepted | 274 | 9,240 | 736 | h,w = map(int,input().split())
ans = h*w
for i in range(1,h):
A = w*i
if w%2 == 0 or (h-i)%2 == 0:
B = ((h-i)*w)//2
C = ((h-i)*w)//2
else:
if h-i <= w:
B = (h-i)*((w//2)+1)
C = (h-i)*(w//2)
else:
B = ((h-i)//2 + 1) * w
C = ((h-i... |
s248818332 | p03433 | u750275181 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 107 | 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 = list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[0::2])-sum(a[1::2])) | s702808182 | Accepted | 18 | 2,940 | 91 | n = int(input())
a = int(input())
if n % 500 <= a:
print("Yes")
else:
print("No")
|
s394535334 | p03433 | u442152792 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. | input = list(map(str,input().split()))
num = ''.join(input)
if(int(num) % 4 == 0):
print('YES')
else:
print('NO') | s157250322 | Accepted | 17 | 2,940 | 111 | pay = int(input())
coin = int(input())
mod = pay % 500
if mod <= coin:
print('Yes')
else:
print('No') |
s819789229 | p03371 | u437215432 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 172 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr... | # ABC095C
a, b, c, x, y = map(int, input().split())
if a > c or b > c:
t = min(x, y)
print("(1)", (x - t)*a + (y - t)*b + t*2*c)
else:
print("(2)", a*x + b*y)
| s862871461 | Accepted | 280 | 12,504 | 308 | import numpy as np
def f(a, b, c, x, y):
Min = np.inf
for use_c in range(max(x, y) * 2 + 1):
price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b
if price < Min:
Min = price
print(Min)
a, b, c, x, y = map(int, input().split())
f(a, b, c, x, y)
|
s737202436 | p03737 | u305732215 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 67 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | s1, s2, s3 = input().split()
ans = s1[0] + s2[0] + s3[0]
print(ans) | s296607187 | Accepted | 19 | 2,940 | 79 | s1, s2, s3 = input().split()
ans = str.upper(s1[0] + s2[0] + s3[0])
print(ans)
|
s927468118 | p03380 | u365364616 | 2,000 | 262,144 | Wrong Answer | 108 | 14,060 | 184 | 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()))
A.sort()
X = A[-1]
X2 = X // 2
dd = A[-1]
for i in range(N - 1):
d = abs(X2 - A[i])
if d < dd:
Y = A[i]
print(X, Y) | s540080464 | Accepted | 107 | 14,428 | 205 | N = int(input())
A = list(map(int, input().split()))
A.sort()
X = A[-1]
X2 = (X + 1) // 2
dd = A[-1]
for i in range(N - 1):
d = abs(X2 - A[i])
if d < dd:
dd = d
Y = A[i]
print(X, Y) |
s564329279 | p03448 | u048945791 | 2,000 | 262,144 | Wrong Answer | 48 | 3,060 | 256 | 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())
ans = 0
for num_a in range(1, a + 1):
for num_b in range(1, b + 1):
for num_c in range(1, c + 1):
if 500 * num_a + 100 * num_b + 50 * num_c == x:
ans += 1
print(ans) | s882400309 | Accepted | 50 | 3,060 | 256 | a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for num_a in range(0, a + 1):
for num_b in range(0, b + 1):
for num_c in range(0, c + 1):
if 500 * num_a + 100 * num_b + 50 * num_c == x:
ans += 1
print(ans) |
s294748723 | p03854 | u494058663 | 2,000 | 262,144 | Wrong Answer | 59 | 3,956 | 503 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | S = list(input())
tmp = ''
L = len(S)
S.append('0')
S.append('0')
ans = 0
for i in range(L):
tmp += str(S[i])
if tmp=='dream':
if tmp+str(S[i+1])+str(S[i+2])=='dreamer':
ans += len(tmp)+2
tmp = ''
i+=2
else:
ans += len(tmp)
tmp = ''
... | s393224230 | Accepted | 63 | 4,652 | 267 | S = list(input())
tmp = ''
L = len(S)
S = S[-1:-L-1:-1]
Kouho = ['maerd','remaerd','esare','resare']
ans = 0
for i in range(L):
tmp += str(S[i])
if tmp in Kouho:
ans += len(tmp)
tmp = ''
if ans == L:
print('YES')
else:
print('NO') |
s298378212 | p03149 | u201660334 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,040 | 104 | 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". | n1, n2, n3, n4 = input().split()
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
print("YES")
else:
print("NO") | s918163134 | Accepted | 29 | 9,160 | 114 | n1, n2, n3, n4 = map(int, input().split())
if {n1, n2, n3, n4} == {1, 9, 7, 4}:
print("YES")
else:
print("NO") |
s921771395 | p03997 | u779308281 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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())
result = (a + b) * h / 2
print(result)
| s489597570 | Accepted | 17 | 2,940 | 94 | a = int(input())
b = int(input())
h = int(input())
result = int((a + b) * h / 2)
print(result) |
s330673975 | p04043 | u980503157 | 2,000 | 262,144 | Wrong Answer | 22 | 8,920 | 102 | 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 ... | form = input()
form = form.split()
form.sort()
if form == [5,5,7]:
print("YES")
else:
print("NO") | s313275510 | Accepted | 23 | 9,092 | 93 | s = input()
s = s.split()
s.sort()
if s == ["5","5","7"]:
print("YES")
else:
print("NO") |
s016651903 | p02694 | u931118906 | 2,000 | 1,048,576 | Wrong Answer | 20 | 9,156 | 93 | 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())
a = 100
ans = 0
while x >= a:
ans += 1
a = int(a * 1.01)
print(ans)
| s487630944 | Accepted | 25 | 9,152 | 92 | x = int(input())
a = 100
ans = 0
while x > a:
ans += 1
a = int(a * 1.01)
print(ans)
|
s013205754 | p02678 | u614181788 | 2,000 | 1,048,576 | Wrong Answer | 1,062 | 48,720 | 987 | 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 th... | n,m = map(int,input().split())
C = [[0 for j in range(2)] for i in range(m)]
for i in range(m):
C[i] = list(map(int,input().split()))
if C[i][0] > C[i][1]:
C[i][0], C[i][1] = C[i][1],C[i][0]
sortF = lambda val : val[0]
C.sort(key=sortF)
a = [0]*n
b = [0]*n
for i in range(m):
if C[i][0] == 1:
... | s776279192 | Accepted | 715 | 35,596 | 555 | n,m = map(int,input().split())
V = [None] + [[] for _ in range(n)]
for i in range(m):
a, b= map(int,input().split())
V[a].append(b)
V[b].append(a)
from collections import deque
q = deque()
reach = [None] + [0] + [-1]*(n-1)
goal = [None] + [0]*n
for L in V[1]:
q.append(L)
reach[L] = reach[1] + 1
... |
s945420542 | p02795 | u711539583 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 75 | We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all t... | h = int(input())
w = int(input())
n = int(input())
print(int(n / max(h,w))) | s884935754 | Accepted | 18 | 3,316 | 116 | h = int(input())
w = int(input())
n = int(input())
m = max(h, w)
if n % m:
print(n // m + 1)
else:
print(n // m) |
s919309885 | p02255 | u599879983 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 290 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ... | N = int(input())
A = list(map(int,input().split()))
print(A)
def insertionSort(A,N):
for i in range(1,N):
v = A[i]
j = i -1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(A)
insertionSort(A,N)
| s030942077 | Accepted | 20 | 5,604 | 372 | N = int(input())
A = list(map(int,input().split()))
def insertionSort(A,N):
for i in range(1,N):
v = A[i]
j = i -1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
outputNum(A)
def outputNum(A):
tmp = map(str,A)
text = " ".join(tmp... |
s018813928 | p03493 | u582614471 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 42 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | n = map(int,input().split())
print(sum(n)) | s502909234 | Accepted | 17 | 2,940 | 40 | n = map(int,list(input()))
print(sum(n)) |
s527883879 | p04045 | u070423038 | 2,000 | 262,144 | Wrong Answer | 30 | 9,100 | 323 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ... | price, hate = input().split()
no_num = set([x for x in input().split()])
ok_num = sorted(list({'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'} - no_num))
print(ok_num)
result = []
for i in price:
print(i)
for j in ok_num:
if i <= j:
result.append(j)
break
print(''.join(result... | s907165552 | Accepted | 27 | 9,044 | 534 | kingaku, n = input().split()
no_num = input().split()
ok_num = [str(i) for i in range(10) if not str(i) in no_num]
result = []
for i in kingaku:
for j in ok_num:
if i == j:
result.append(j)
break
elif i < j:
result.append(j)
print("".join(result).lju... |
s799442973 | p03798 | u427344224 | 2,000 | 262,144 | Wrong Answer | 241 | 3,572 | 1,485 | Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered... | n = int(input())
s = input()
S1 = "SS"
S2 = "WW"
S3 = "SW"
S4 = "WW"
S_list = [S1, S2, S3, S4]
for S in S_list:
last = ""
for i in range(n):
if i == 0:
if S[0] == "S":
if s[i] == "o":
last = S[1]
else:
last = "S" if S[1... | s501403843 | Accepted | 257 | 3,572 | 1,486 | n = int(input())
s = input()
S1 = "SS"
S2 = "WW"
S3 = "SW"
S4 = "WS"
S_list = [S1, S2, S3, S4]
for S in S_list:
last = ""
for i in range(n):
if i == 0:
if S[0] == "S":
if s[i] == "o":
last = S[1]
else:
last = "S" if S[1... |
s773357384 | p03855 | u074220993 | 2,000 | 262,144 | Wrong Answer | 2,212 | 238,372 | 606 | There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the s... | N, K, L = map(int, input().split())
city = [{"path":{i},"train":{i}} for i in range(N)]
for i in range(K):
p, q = map(int, input().split())
city[p-1]["path"].add(q-1)
city[q-1]["path"].add(p-1)
for i in range(L):
r, s = map(int, input().split())
city[r-1]["train"].add(s-1)
city[s-1]["train"].add... | s423661919 | Accepted | 882 | 55,756 | 599 | N, K, L = map(int, input().split())
#Parent List(PL)
road = [i for i in range(N)]
rail = [i for i in range(N)]
def fp(x,P): #findParent
if x == P[x]:
return x
else:
P[x] = fp(P[x],P)
return P[x]
for i in range(K+L):
PL = (lambda x:road if x < K else rail)(i)
p, q = map(lambda x... |
s227408170 | p03067 | u187606204 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 79 | There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise. | A,B,C = map(int,input().split())
if A<C & C<B:
print("yes")
else:
print("No") | s827723524 | Accepted | 17 | 3,060 | 202 | A,B,C = map(int,input().split())
if A>C & C>B:
print("Yes")
if B>C & C>A:
print("Yes")
if C>A & A>B:
print("No")
if B>A & A>C:
print("No")
if A>B & B>C:
print("No")
if C>B & B>A:
print("No")
|
s617908044 | p03862 | u838644735 | 2,000 | 262,144 | Wrong Answer | 188 | 20,660 | 1,012 | There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con... | def main():
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
diff = A[0] - x
A[0] = x
ans += diff
if A[-1] > x:
diff = A[-1] - x
A[-1] = x
ans += diff
B = [a for a in A]
ans1 = 0
for i in range(N-1):... | s731691854 | Accepted | 116 | 20,940 | 982 | def main():
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
if A[0] > x:
diff = A[0] - x
A[0] = x
ans += diff
if A[-1] > x:
diff = A[-1] - x
A[-1] = x
ans += diff
B = [a for a in A]
ans1 = 0
for i in range(N-1):... |
s426246160 | p03487 | u209594105 | 2,000 | 262,144 | Wrong Answer | 87 | 21,532 | 304 | 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 = input()
str = input()
nums = str.split()
num_dict = {}
for num in nums:
if num in num_dict:
num_dict[num] += 1
else:
num_dict[num] = 1
result = 0
for k, v in num_dict.items():
if int(k) > v:
result += v
elif int(k) < v:
result += int(k)
print(result)
| s668081174 | Accepted | 96 | 21,528 | 310 | n = input()
str = input()
nums = str.split()
num_dict = {}
for num in nums:
if num in num_dict:
num_dict[num] += 1
else:
num_dict[num] = 1
result = 0
for k, v in num_dict.items():
if int(k) > v:
result += v
elif int(k) < v:
result += (v - int(k))
print(result)
|
s093050699 | p03494 | u361826811 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 487 | 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. |
import sys
# import itertools
# import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
def num(n):
cnt = 0
while n:
if n % 2 == 0:
cnt += 1
n /= 2
else:
b... | s043085930 | Accepted | 153 | 12,396 | 366 |
import sys
# import itertools
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
N = int(readline())
A = np.array(readline().split(), dtype=np.int64)
ans=0
while np.all(A%2==0):
A//=2
ans+=1
print(ans) |
s791564566 | p02256 | u741801763 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 132 | Write a program which finds the greatest common divisor of two natural numbers _a_ and _b_ | x,y = list(map(int,input().split()))
###??????x >= y
if y>x:x,y = y,x
while x % y !=0:
y = x%y
if y > x:x,y = y,x
print(y) | s948374321 | Accepted | 20 | 5,600 | 130 | x,y = list(map(int,input().split()))
###??????x >= y
if y>x:x,y = y,x
while x % y !=0:
x = x%y
if y>x:x,y = y,x
print(y) |
s801564060 | p02401 | u685534465 | 1,000 | 131,072 | Wrong Answer | 30 | 7,576 | 234 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | a = 1
b = 1
op = ''
i = 0
while op!='?':
a,op,b = [i for i in input().split()]
a = int(a)
b = int(b)
if op!='?':
if op=='+':
print(a+b)
elif op=='-':
print(a-b)
elif op=='*':
print(a*b)
elif op=='/':
print(a/b) | s027399995 | Accepted | 20 | 7,556 | 235 | a = 1
b = 1
op = ''
i = 0
while op!='?':
a,op,b = [i for i in input().split()]
a = int(a)
b = int(b)
if op!='?':
if op=='+':
print(a+b)
elif op=='-':
print(a-b)
elif op=='*':
print(a*b)
elif op=='/':
print(a//b) |
s050908742 | p03095 | u309141201 | 2,000 | 1,048,576 | Wrong Answer | 26 | 3,444 | 196 | You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a conca... | from collections import Counter
n = int(input())
s = input()
mod = 10**9 + 7
ans = 1
scnt = Counter(s)
# print(scnt)
for cnt in scnt.values():
print(cnt)
ans *= (cnt+1) % mod
print(ans-1) | s215528213 | Accepted | 25 | 3,444 | 170 | from collections import Counter
n = int(input())
s = input()
mod = 10**9 + 7
ans = 1
scnt = Counter(s)
for cnt in scnt.values():
ans = ans*(cnt+1) % mod
print(ans-1) |
s865176203 | p03456 | u043236471 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 132 | AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. | import math
a, b = [int(n) for n in input().split()]
res = math.sqrt(a * b)
if res % 1 == 0:
print('YES')
else:
print('NO') | s952838362 | Accepted | 17 | 2,940 | 145 | import math
a, b = [int(n) for n in input().split()]
res = math.sqrt(int(str(a)+str(b)))
if res % 1 == 0:
print('Yes')
else:
print('No') |
s845770738 | p03543 | u318427318 | 2,000 | 262,144 | Wrong Answer | 30 | 9,336 | 253 | 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**? | #-*-coding:utf-8-*-
import collections
def main():
s = input()
count=collections.Counter(s)
for i in count.values():
if i >=3:
print("Yes")
else:
print("No")
if __name__=="__main__":
main() | s950005289 | Accepted | 26 | 9,112 | 304 | #-*-coding:utf-8-*-
def main():
s = input()
string_list=list(str(s))
if string_list[0]==string_list[1]==string_list[2]:
print("Yes")
elif string_list[1]==string_list[2]==string_list[3]:
print("Yes")
else:
print("No")
if __name__=="__main__":
main() |
s205190140 | p03416 | u636822224 | 2,000 | 262,144 | Wrong Answer | 127 | 3,060 | 172 | Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. | a,b=map(int,input().split())
sum=0
print(b-a+1)
for i in range(b-a+1):
if int(str(a+i)[0])==int(str(a+i)[4]) and int(str(a+i)[1])==int(str(a+i)[3]):
sum+=1
print(sum) | s211970666 | Accepted | 122 | 3,060 | 159 | a,b=map(int,input().split())
sum=0
for i in range(b-a+1):
if int(str(a+i)[0])==int(str(a+i)[4]) and int(str(a+i)[1])==int(str(a+i)[3]):
sum+=1
print(sum) |
s303469547 | p02748 | u993310962 | 2,000 | 1,048,576 | Wrong Answer | 411 | 18,736 | 238 | You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tic... | a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
buf=min(A)+min(B)
for i in range(m):
x,y,c=map(int, input().split())
cp=A[x-1]+B[y-1]-c
if buf>=cp:
buf==cp
print(buf) | s044387575 | Accepted | 400 | 18,736 | 237 | a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
buf=min(A)+min(B)
for i in range(m):
x,y,c=map(int, input().split())
cp=A[x-1]+B[y-1]-c
if buf>=cp:
buf=cp
print(buf) |
s810855988 | p03997 | u423665486 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 104 | 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. | def resolve():
t = []
for _ in range(3):
t.append(int(input()))
a, b, h = t
print(int((a+b)/2*h))
| s106384549 | Accepted | 17 | 2,940 | 113 | def resolve():
t = []
for _ in range(3):
t.append(int(input()))
a, b, h = t
print(int((a+b)/2*h))
resolve() |
s915515039 | p03997 | u536177854 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 61 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2) | s162428226 | Accepted | 17 | 2,940 | 62 | a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2) |
s864634447 | p03079 | u195912432 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 115 | You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C. | # coding: utf-8
A, B, C = map(int, input().split())
if A == B and B == C:
print("YES")
else:
print("NO")
| s712820365 | Accepted | 18 | 2,940 | 115 | # coding: utf-8
A, B, C = map(int, input().split())
if A == B and B == C:
print("Yes")
else:
print("No")
|
s972132988 | p03699 | u811000506 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 240 | You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When... | N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
sum = sum(S)
if sum%10==0:
for i in range(N):
if (sum-S[i])%10!=0:
sum -= S[i]
print(sum)
break
print(0)
else:
print(sum) | s444579635 | Accepted | 17 | 3,060 | 241 | N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
sum = sum(S)
if sum%10==0:
for i in range(N):
if (sum-S[i])%10!=0:
sum -= S[i]
print(sum)
exit()
print(0)
else:
print(sum) |
s365516315 | p03997 | u680851063 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 77 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a=int(input())
b=int(input())
c=int(input())
#d=int(input())
print((a+b)*c/2) | s447085908 | Accepted | 17 | 2,940 | 82 | a=int(input())
b=int(input())
c=int(input())
#d=int(input())
print(int((a+b)*c/2)) |
s774879150 | p03845 | u513081876 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 214 | 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 d... | N = int(input())
T = list(map(int, input().split()))
M = int(input())
p = []
x = []
ans = []
for i in range(M):
p, x = map(int, input().split())
T[p-1] = x
ans.append(sum(T))
for _ in ans:
print(_) | s442693587 | Accepted | 17 | 3,060 | 212 | N = int(input())
T = [int(i) for i in input().split()]
M = int(input())
PX = [[int(i) for i in input().split()] for i in range(M)]
for i in range(M):
ans = sum(T) - T[PX[i][0] - 1] + PX[i][1]
print(ans)
|
s707744733 | p03386 | u842388336 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 153 | 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,x = map(int,input().split())
a_set = set(range(a,a+x))
b_set = set(range(b-x,b+1))
answer = a_set.intersection(b_set)
for ans in answer:
print(ans) | s809236582 | Accepted | 17 | 3,060 | 232 | a,b,x = map(int,input().split())
a_set = set(range(a,min(a+x,b)))
b_set = set(range(max(a,b-x+1),b+1))
#print(a_set)
#print(b_set)
a_set = a_set.union(b_set)
ans_list = list(a_set)
ans_list.sort()
for ans in ans_list:
print(ans) |
s182117902 | p03598 | u844005364 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 110 | There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th t... | n = int(input())
k = int(input())
arr = list(map(int, input().split()))
print(sum(min(x, k-x) for x in arr)) | s256503504 | Accepted | 19 | 2,940 | 83 | _,k=input(),int(input())
print(2*sum(min(x,k-x) for x in map(int,input().split()))) |
s748584472 | p03523 | u201660334 | 2,000 | 262,144 | Wrong Answer | 35 | 9,872 | 117 | 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`? | import re
s = input()
regex = re.compile(r"A?KIHA?BA?RA?")
if regex.match(s):
print("Yes")
else:
print("No") | s329060952 | Accepted | 35 | 9,820 | 121 | import re
s = input()
regex = re.compile(r"A?KIHA?BA?RA?")
if regex.fullmatch(s):
print("YES")
else:
print("NO") |
s368074065 | p03478 | u039623862 | 2,000 | 262,144 | Wrong Answer | 26 | 3,064 | 200 | 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 dsum(n):
res = 0
while n>0:
res *= 10
res += n%10
n //= 10
return res
cnt = 0
for i in range(1,n+1):
if a<=dsum(i)<=b:
cnt += 1
print(cnt) | s357937461 | Accepted | 25 | 3,060 | 188 | n,a,b=map(int, input().split())
def dsum(n):
res = 0
while n>0:
res += n%10
n //= 10
return res
cnt = 0
for i in range(1,n+1):
if a<=dsum(i)<=b:
cnt += i
print(cnt) |
s193068410 | p03457 | u156896646 | 2,000 | 262,144 | Wrong Answer | 382 | 3,064 | 403 | 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... | N = int(input())
t0, x0, y0 = 0, 0, 0
for _ in range(N):
t, x, y = map(int, input().split())
dt = t - t0
dx = x - x0
dy = y - y0
dxy = abs(dx) + abs(dy) #; print(dt, dx, dy, dxy)
isEvenOdd = (dt%2 == 0 and dxy%2 == 0) or (dt%2 != 0 and dxy%2 != 0)
if isEvenOdd and dxy <= dt :
t0, ... | s784406969 | Accepted | 378 | 3,064 | 334 | N = int(input())
t0, x0, y0 = 0, 0, 0
for _ in range(N):
t, x, y = map(int, input().split())
dt = t - t0
dx = x - x0
dy = y - y0
dxy = abs(dx) + abs(dy) #; print(dt, dx, dy, dxy)
if dt%2 == dxy%2 and dxy <= dt :
t0, x0, y0 = t, x, y
else:
print('No')
break
else:
... |
s137892677 | p03434 | u835283343 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 150 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c... | import math
input()
data = sorted(map(int, input().split(' ')))
s = 0
for i, n in enumerate(data):
s = s + int(math.pow((-1),(i%2)))*n
print(s) | s167309323 | Accepted | 17 | 2,940 | 164 | import math
input()
data = sorted(map(int, input().split(' ')), reverse=True)
s = 0
for i, n in enumerate(data):
s = s + int(math.pow((-1),(i%2)))*n
print(s) |
s157279537 | p04043 | u822179469 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 122 | 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 ... | d = list(map(int,input().split()))
print(d)
if d.count(5)==2 and d.count(7) == 1 :
print("YES")
else :
print("NO") | s409982184 | Accepted | 17 | 2,940 | 113 | d = list(map(int,input().split()))
if d.count(5)==2 and d.count(7) == 1 :
print("YES")
else :
print("NO") |
s734709341 | p03729 | u422272120 | 2,000 | 262,144 | Wrong Answer | 26 | 8,968 | 91 | You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `Y... | a,b,c = input().split()
print ("Yes") if a[-1] == b[0] and b[-1] == c[0] else print ("No")
| s443988519 | Accepted | 29 | 9,032 | 91 | a,b,c = input().split()
print ("YES") if a[-1] == b[0] and b[-1] == c[0] else print ("NO")
|
s561105106 | p03762 | u814986259 | 2,000 | 262,144 | Wrong Answer | 124 | 24,460 | 503 | On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis. Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i. Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i. For ever... | n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9 + 7
H = 0
W = 0
for i in range(n//2):
w = x[n-1-i] - x[i]
if i == n//2 - 1:
if n % 2 == 1:
w *= 2
else:
w *= n-2*i-1
W += w
W %= mod
for j in range(m // ... | s573102080 | Accepted | 123 | 24,356 | 840 | n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10**9 + 7
# H = x[-1] - x[0]
# W = y[-1] - y[0]
# S = H*W % mod
# S *= (n-1)*(m-1)
# if n >= 4:
# h = x[-2] - x[1]
# S -= h*W * 2
# if m >= 4:
# w = y[-2] - y[1]
# S -= H*w * 2
H = 0
W = 0
... |
s781038607 | p02853 | u597455618 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 270 | We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.... | x, y = list(map(int, input().split()))
ans = 0
if x == 1 and y == 1:
ans += 400000
elif x == 1:
ans += 300000
elif x == 2:
ans += 200000
elif x == 3:
ans += 100000
elif y == 1:
ans += 300000
elif y == 2:
ans += 200000
elif y == 3:
ans += 100000
print(ans) | s363862315 | Accepted | 17 | 3,064 | 266 | x, y = list(map(int, input().split()))
ans = 0
if x == 1 and y == 1:
ans += 400000
if x == 1:
ans += 300000
elif x == 2:
ans += 200000
elif x == 3:
ans += 100000
if y == 1:
ans += 300000
elif y == 2:
ans += 200000
elif y == 3:
ans += 100000
print(ans) |
s476891508 | p03044 | u047668580 | 2,000 | 1,048,576 | Wrong Answer | 1,556 | 63,068 | 676 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | from collections import defaultdict
import queue
N = int(input())
d = defaultdict(lambda: defaultdict(int))
for i in range(N-1):
u, v, w = list(map(int, input().split()))
d[u-1][v-1] = w
d[v-1][u-1] = w
for i in range(N):
if len(d[i]) == 1:
start = i
break
visited = [False for _ in ran... | s703266254 | Accepted | 1,657 | 59,876 | 658 | from collections import defaultdict
import queue
N = int(input())
d = defaultdict(lambda: defaultdict(int))
for i in range(N-1):
u, v, w = list(map(int, input().split()))
d[u-1][v-1] = w
d[v-1][u-1] = w
for i in range(N):
if len(d[i]) == 1:
start = i
break
visited = [False for _ in ran... |
s710121181 | p03351 | u639592190 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 103 | 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 ... | a,b,c,d=map(int,input().split())
print("YES" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else "NO") | s288701799 | Accepted | 17 | 2,940 | 103 | a,b,c,d=map(int,input().split())
print("Yes" if abs(a-c)<=d or (abs(a-b)<=d and abs(b-c)<=d) else "No") |
s073792598 | p03352 | u814986259 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 64 | 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. | import math
X=int(input())
ans=(math.ceil(X**0.5)**2)
print(ans) | s583558095 | Accepted | 18 | 3,060 | 208 | X = int(input())
ans = 1
for j in range(10, 1, -1):
if int(pow(X, (1/j)) + 1)**j <= X:
ans = max(int(pow(X, (1/j))+1)**j, ans)
else:
ans = max(int(pow(X, (1/j)))**j, ans)
print(ans)
|
s525190511 | p04029 | u690037900 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 31 | 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) | s092665911 | Accepted | 17 | 2,940 | 36 | N=int(input())
print(int(N*(N+1)/2)) |
s344234770 | p03400 | u023229441 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 114 | Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ... | n=int(input())
d,x=map(int,input().split())
ans=x
for i in range(n):
k=int(input())
ans+=(n-1)//k+1
print(ans) | s407063783 | Accepted | 18 | 2,940 | 118 | n=int(input())
d,x=map(int,input().split())
ans=x
for i in range(n):
k=int(input())
ans+=(d-1)//k+1
print(ans)
|
s114284469 | p03385 | u067267880 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | S = input()
if "a" in S and "b" in S and "c" in S:
print("YES")
else:
print("NO") | s518342080 | Accepted | 17 | 2,940 | 90 | S = input()
if "a" in S and "b" in S and "c" in S:
print("Yes")
else:
print("No") |
s389072056 | p02614 | u306060982 | 1,000 | 1,048,576 | Wrong Answer | 46 | 9,216 | 618 | We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation... | h,w,k = map(int,input().split())
c = []
for _ in range(h):
cc = input()
c.append(cc)
d = 0
kk = 0
g= []
for i in range(2 ** h):
gg=[]
for j in range(h):
if ((i>>j) &1):
gg.append(j)
g.append(gg)
import copy
gb = copy.deepcopy(g)
for lis in g:
ii = lis
for lisj in gb:
... | s712693308 | Accepted | 45 | 9,056 | 715 | h,w,k = map(int,input().split())
c = []
for _ in range(h):
cc = input()
c.append(cc)
d = 0
kk = 0
g= []
gb=[]
for i in range(2 ** h):
gg=[]
for j in range(h):
if ((i>>j) &1):
gg.append(j)
g.append(gg)
for i in range(2 ** w):
gg=[]
for j in range(w):
if ((i>>j) &1... |
s291995813 | p03415 | u181215519 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 93 | We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}. Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bot... | s1 = str( input() )
s2 = str( input() )
s3 = str( input() )
print( s1[0] + s1[1] + s1[2] ) | s898570511 | Accepted | 17 | 2,940 | 93 | s1 = str( input() )
s2 = str( input() )
s3 = str( input() )
print( s1[0] + s2[1] + s3[2] ) |
s597924222 | p02608 | u595375942 | 2,000 | 1,048,576 | Wrong Answer | 56 | 10,576 | 384 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | from collections import Counter
from itertools import combinations_with_replacement
N = int(input())
L = [i for i in range(1, 50)]
ans = []
for c in combinations_with_replacement(L, 3):
x = c[0]
y = c[1]
z = c[2]
tmp = x**2+y**2+z**2+x*y+y*z+z*x
ans.append(tmp)
C = Counter(ans)
for i in range(1, N+1... | s615225467 | Accepted | 225 | 10,016 | 510 | from collections import Counter
from itertools import combinations_with_replacement
N = int(input())
L = [i for i in range(1, 100)]
C = Counter()
for i in range(1, N+1):
C[i] = 0
for c in combinations_with_replacement(L, 3):
x = c[0]
y = c[1]
z = c[2]
tmp = x**2+y**2+z**2+x*y+y*z+z*x
if tmp <= ... |
s574759798 | p02865 | u189487046 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 26 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | n=int(input())
print(n//2) | s552336271 | Accepted | 17 | 2,940 | 33 | n = int(input())
print((n-1)//2)
|
s532832424 | p01540 | u509278866 | 5,000 | 199,680 | Wrong Answer | 50 | 9,052 | 2,095 | 太郎君はある広場にお宝を探しにやってきました。この広場にはたくさんのお宝が埋められていますが、太郎君は最新の機械を持っているので、どこにお宝が埋まっているかをすべて知っています。広場はとても広いので太郎君は領域を決めてお宝を探すことにしましたが、お宝はたくさんあるためどのお宝がその領域の中にあるかすぐにわかりません。そこで太郎君はその領域の中にあるお宝の数を数えることにしました。 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... | s512326261 | Accepted | 13,370 | 959,732 | 2,102 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... |
s102166329 | p03659 | u584459098 | 2,000 | 262,144 | Wrong Answer | 2,104 | 24,832 | 189 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | N = int(input())
a = list(map(int, input().split()))
diff = []
for i in range(N-1):
print(sum(a[:i+1]), sum(a[i+1:]))
diff.append(abs(sum(a[:i+1]) - sum(a[i+1:])))
print(min(diff))
| s380237809 | Accepted | 197 | 29,440 | 282 | N = int(input())
a = list(map(int, input().split()))
sunuke = []
diff = []
total = sum(a)
for i, x in enumerate(a[0:-1]):
if(i==0):
sunuke.append(x)
else:
sunuke.append(x + sunuke[i-1])
for i in sunuke:
diff.append(abs((i * 2) - total))
print(min(diff))
|
s992575710 | p03434 | u366886346 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 182 | We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the c... | n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
alice=0
bob=0
for i in range(n):
if n%2==0:
alice+=a[i]
else:
bob+=a[i]
print(alice-bob)
| s718425384 | Accepted | 17 | 3,060 | 182 | n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
alice=0
bob=0
for i in range(n):
if i%2==0:
alice+=a[i]
else:
bob+=a[i]
print(alice-bob)
|
s754962804 | p03545 | u522205105 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 484 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in... |
n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]
for i,val in enumerate(n):
if i == 0:
d[0].append(n[0])
op[0].append("")
else:
for j in d[i-1]:
d[i].append(j+val)
d[i].append(j-val)
for j in op[i-1]:
op[i].append(j + "+")
op[i].append... | s089908089 | Accepted | 18 | 3,064 | 502 | n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]
for i,val in enumerate(n):
if i == 0:
d[0].append(n[0])
op[0].append("")
else:
for j in d[i-1]:
d[i].append(j+val)
d[i].append(j-val)
for j in op[i-1]:
op[i].append(j + "+")
op[i].append(... |
s527497726 | p03024 | u143051858 | 2,000 | 1,048,576 | Wrong Answer | 27 | 8,916 | 90 | 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()
n = len(s)
if 8 <= 15-n+s.count('o'):
print('Yes')
else:
print('No') | s765199922 | Accepted | 30 | 8,996 | 90 | s = input()
n = len(s)
if 8 <= 15-n+s.count('o'):
print('YES')
else:
print('NO') |
s098770651 | p03943 | u863723142 | 2,000 | 262,144 | Wrong Answer | 27 | 9,164 | 170 | Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Not... | str_line = input().split(" ")
num_line = [int(n) for n in str_line]
num_line.sort()
if (num_line[0] == num_line[1] + num_line[2]):
print("Yes")
else:
print("No") | s759699600 | Accepted | 25 | 9,164 | 187 | str_line = input().split(" ")
num_line = [int(n) for n in str_line]
num_line.sort()
#print(num_line)
if (num_line[2] == num_line[1] + num_line[0]):
print("Yes")
else:
print("No") |
s437532075 | p03778 | u945418216 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 108 | AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the min... | w,a,b = map(int, input().split())
if a+w<b:
print(a+w-b)
elif b+w<a:
print(a-b-w)
else:
print(0) | s155090396 | Accepted | 17 | 2,940 | 118 | w,a,b = map(int, input().split())
if a+w<b:
print(abs(a+w-b))
elif b+w<a:
print(abs(a-b-w))
else:
print(0) |
s480001739 | p04045 | u941438707 | 2,000 | 262,144 | Wrong Answer | 27 | 9,160 | 126 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ... | n,k,*a=map(int,open(0).read().split())
for i in range(n,10**6):
if not set(str(i))&set(a):
print(i)
exit() | s348164474 | Accepted | 107 | 9,052 | 140 | n,k,*a=map(int,open(0).read().split())
for i in range(n,10**6):
if all(str(j) not in str(i) for j in a):
print(i)
exit() |
s707789025 | p03377 | u089032001 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 96 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A, B, X = map(int, input().split())
if(A <= X and A+B >= X):
print("Yes")
else:
print("No") | s228363150 | Accepted | 20 | 2,940 | 97 | A, B, X = map(int, input().split())
if(A <= X and A+B >= X):
print("YES")
else:
print("NO") |
s628080828 | p02845 | u814781830 | 2,000 | 1,048,576 | Wrong Answer | 162 | 28,252 | 317 | N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of p... | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
print(Counter(A))
MOD = 10 ** 9 + 7
#A.reverse()
ans = 1
cnt = [0] * N
for i, a in enumerate(A):
cnt[a] += 1
if a == 0:
ans *= 4 - cnt[a]
else:
ans *= max(0, cnt[a-1]-cnt[a]+1)
ans %= MOD
print(ans)
| s829544378 | Accepted | 118 | 14,780 | 286 | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 1
cnt = [0] * N
for i, a in enumerate(A):
cnt[a] += 1
if a == 0:
ans *= 4 - cnt[a]
else:
ans *= max(0, cnt[a-1]-cnt[a]+1)
ans %= MOD
print(ans)
|
s941126310 | p02613 | u441246928 | 2,000 | 1,048,576 | Wrong Answer | 163 | 16,320 | 375 | 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())
S = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N) :
if S[i] == 'AC' :
AC += 1
elif S[i] == 'WA' :
WA += 1
elif S[i] == 'TLE' :
TLE += 1
elif S[i] == 'RE' :
RE += 1
print('AC' + 'x' + str(AC) )
print('WA' + 'x' + str(WA) )
prin... | s344621500 | Accepted | 160 | 16,320 | 359 | N = int(input())
S = [input() for i in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N) :
if S[i] == 'AC' :
AC += 1
elif S[i] == 'WA' :
WA += 1
elif S[i] == 'TLE' :
TLE += 1
elif S[i] == 'RE' :
RE += 1
print('AC','x',str(AC) )
print('WA','x',str(WA) )
print('TLE',... |
s078038294 | p03828 | u075595666 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 605 | You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. | def is_prime(q):
if q < 2 or q&1 == 0: return False
return pow(5, q-1, q)*pow(7, q-1, q) == 1
def main():
mod = 10**9+7
n = int(input())
ans = 1
if n == 1:
print(1)
exit()
b = [2]
for i in range(2,min(n,998)):
if i == 5 or i == 7:
b.append(i)
if i == 561:
continue
... | s353106130 | Accepted | 19 | 3,064 | 611 | def is_prime(q):
if q < 2 or q&1 == 0: return False
return pow(5, q-1, q)*pow(7, q-1, q) == 1
def main():
mod = 10**9+7
n = int(input())
ans = 1
if n == 1:
print(1)
exit()
b = [2]
for i in range(2,min(n+1,998)):
if i == 5 or i == 7:
b.append(i)
if i == 561:
continue... |
s743108798 | p03549 | u521271655 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of th... | n,m = map(int,input().split())
x = 1900*m + 100*(n-m)
p = 1/2**m
print(x//p)
| s123018365 | Accepted | 18 | 2,940 | 82 | n,m = map(int,input().split())
x = 1900*m + 100*(n-m)
p = 1/2**m
print(int(x//p))
|
s054483549 | p03563 | u565204025 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 640 | 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... | # -*- coding: utf-8 -*-
s = list(input())
t = list(input())
slen = len(s)
tlen = len(t)
cand = []
for i in range(slen - tlen + 1):
match = True
for j in range(tlen):
if s[i + j] == "?" or s[i + j] == t[j]:
pass
else:
match = False
if match:
cand.append(i)
... | s549127055 | Accepted | 18 | 2,940 | 77 | # -*- coding: utf-8 -*-
r = int(input())
g = int(input())
print(2 * g - r)
|
s551766203 | p04045 | u396211450 | 2,000 | 262,144 | Wrong Answer | 28 | 9,004 | 262 | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very ... | import math
n,k=map(int,input().split())
l=set(map(int,input().split()))
s=n
p=set()
for i in range(10):
if i not in l:
p.add(i)
if k==1 and 0 in l:
print(n)
else:
d=math.floor(math.log(n, 10)+1)
for i in p:
n=n+i*(10**d)
d=d+1
print(n)
| s691850913 | Accepted | 51 | 9,068 | 327 | def check(n,s):
v=str(n)
for i in v:
if i in s:
return False
return True
def solve():
n,k=map(int,input().split())
s=input().split()
s=set(s)
while True:
if check(n,s):
print(n)
break
else:
n+=1
for _ in range(1):
... |
s980541709 | p03712 | u234631479 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 138 | You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1. | h, w = map(int, input().split())
S = [input() for i in range(h)]
print(S)
print("#"*(w+2))
for s in S:
print("#"+s+"#")
print("#"*(w+2)) | s865859693 | Accepted | 17 | 3,060 | 129 | h, w = map(int, input().split())
S = [input() for i in range(h)]
print("#"*(w+2))
for s in S:
print("#"+s+"#")
print("#"*(w+2)) |
s622437641 | p03160 | u163501259 | 2,000 | 1,048,576 | Wrong Answer | 162 | 13,980 | 275 | 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 = list(map(int, input().split()))
dp = [0]*N
dp[0] = 0
for i in range(2,N):
dp[i] = dp[i-1] + abs(h[i]-h[i-1])
if i > 1:
dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]),dp[i-1] + abs(h[i]-h[i-1]))
print(dp[N-1]) | s036914336 | Accepted | 174 | 13,980 | 275 | N = int(input())
h = list(map(int, input().split()))
dp = [0]*N
dp[0] = 0
for i in range(1,N):
dp[i] = dp[i-1] + abs(h[i]-h[i-1])
if i > 1:
dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]),dp[i-1] + abs(h[i]-h[i-1]))
print(dp[N-1]) |
s916618605 | p03400 | u806403461 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 144 | Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X ... | n = int(input())
d, x = map(int, input().split())
ans = x
for a in range(n):
A = int(input())
ans += int((d - 1)/A + 1)
print(ans+x)
| s990545335 | Accepted | 18 | 2,940 | 145 | n = int(input())
d, x = map(int, input().split())
ans = x
for a in range(0, n):
A = int(input())
ans += int((d - 1)/A) + 1
print(ans)
|
s626365161 | p04031 | u794521826 | 2,000 | 262,144 | Wrong Answer | 40 | 10,756 | 248 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (... | import math
from statistics import mean
n = int(input())
a = list(map(int, input().split()))
m = mean(a)
if m - math.floor(m) < 0.5:
m = math.floor(m)
else:
m = math.floor(m) + 1
diff = 0
for v in a:
diff = (m - v) ** 2
print(diff)
| s805587829 | Accepted | 40 | 10,740 | 249 | import math
from statistics import mean
n = int(input())
a = list(map(int, input().split()))
m = mean(a)
if m - math.floor(m) < 0.5:
m = math.floor(m)
else:
m = math.floor(m) + 1
diff = 0
for v in a:
diff += (m - v) ** 2
print(diff)
|
s518200550 | p02270 | u024715419 | 1,000 | 131,072 | Wrong Answer | 20 | 7,700 | 402 | In the first line, two integers $n$ and $k$ are given separated by a space character. In the following $n$ lines, $w_i$ are given respectively. | n,k = map(int,input().split())
w = [int(input()) for i in range(n)]
p_min = max(w)-1
p_max = sum(w)+1
while p_max - p_min > 1:
p_mid = int(p_min + (p_max - p_min)/2)
k_tmp = 1
w_tmp = 0
for w_i in w:
w_tmp += w_i
if w_tmp > p_mid:
w_tmp = w_i
k_tmp += 1
... | s849966770 | Accepted | 400 | 11,588 | 548 | n,k = map(int,input().split())
w = [int(input()) for i in range(n)]
def binarySearch(left,right):
mid = 0
while right > left:
mid = int(left + (right - left)//2)
if check(mid,w,k):
right = mid
else:
left = mid + 1
return left
def check(p,w,k):
k_tmp = 1
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.