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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s406912113
|
p02613
|
u821588465
| 2,000 | 1,048,576 |
Wrong Answer
| 159 | 17,548 | 365 |
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 = list(str(input()) for _ in range(N))
print(S)
AC = 0
WA = 0
TLE = 0
RE = 0
for s in S:
if s =='AX':
AC +=1
elif s == 'WA':
WA +=1
elif s == 'TLE':
TLE += 1
elif s == 'RE':
RE +=1
print('AC x {}'.format(AC))
print('WA x {}'.format(WA))
print('TLE x {}'.format(TLE))
print('RE x {}'.format(RE))
|
s082712161
|
Accepted
| 145 | 15,936 | 215 |
from collections import Counter
n = int(input())
a = list(input() for _ in range(n))
c = Counter(a)
print('AC x '+str(c['AC']))
print('WA x '+str(c['WA']))
print('TLE x '+str(c['TLE']))
print('RE x '+str(c['RE']))
|
s874424948
|
p03377
|
u901582103
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 66 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x=map(int,input().split())
print('Yes' if a<=x<=a+b else 'no')
|
s862600200
|
Accepted
| 17 | 2,940 | 66 |
a,b,x=map(int,input().split())
print('YES' if a<=x<=a+b else 'NO')
|
s777824691
|
p03719
|
u922487073
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 65 |
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())
print("Yes" if a<=b<=c else "No")
|
s869340328
|
Accepted
| 17 | 2,940 | 65 |
a,b,c=map(int, input().split())
print("Yes" if a<=c<=b else "No")
|
s004726376
|
p03971
|
u597455618
| 2,000 | 262,144 |
Wrong Answer
| 96 | 4,016 | 230 |
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
n, a, b = map(int, input().split())
s = input()
for i in range(n):
if s[i] == "a" and 0 < a:
print("Yes")
a -= 1
elif s[i] == "b" and 0 < b:
print("Yes")
b -= 1
else:
print("No")
|
s507381515
|
Accepted
| 104 | 4,016 | 278 |
n, a, b = map(int, input().split())
s = input()
plus = a+b
for i in range(n):
if s[i] == "a" and 0 < plus:
print("Yes")
plus -= 1
elif s[i] == "b" and 0 < b and 0 < plus:
print("Yes")
b -= 1
plus -= 1
else:
print("No")
|
s125428227
|
p03469
|
u744034042
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 36 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
print("input().replace(2017, 2018)")
|
s268483042
|
Accepted
| 17 | 2,940 | 44 |
print(input().replace(str(2017), str(2018)))
|
s014490095
|
p03637
|
u308684517
| 2,000 | 262,144 |
Wrong Answer
| 64 | 15,020 | 269 |
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
n = int(input())
A = list(map(int, input().split()))
c = 0
d = 0
for i in A:
if i % 4 == 0:
c += 1
elif i % 2 == 0:
d += 1
if d > 0:
if c > n-c-d : print("Yes")
else: print("No")
else:
if c >= n//2: print("Yes")
else: print("No")
|
s363892302
|
Accepted
| 65 | 15,020 | 270 |
n = int(input())
A = list(map(int, input().split()))
c = 0
d = 0
for i in A:
if i % 4 == 0:
c += 1
elif i % 2 == 0:
d += 1
if d > 0:
if c >= n-c-d : print("Yes")
else: print("No")
else:
if c >= n//2: print("Yes")
else: print("No")
|
s412274770
|
p03761
|
u396266329
| 2,000 | 262,144 |
Wrong Answer
| 22 | 3,316 | 519 |
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
import collections
N = int(input())
s = list()
mojiNum = list()
minLen = 50
minNum = 0
for n in range(N):
temp = input()
if minLen > len(temp):
minLen = len(temp)
minNum = n
mojiNum.append(collections.Counter(temp))
s.append(temp)
minMojiNum = mojiNum[minNum]
for moji in minMojiNum.keys():
for n in range(N):
minMojiNum[moji] = min(minMojiNum[moji],mojiNum[n][moji])
ans = ""
for m in minMojiNum.keys():
for n in range(minMojiNum[m]):
ans += m
if ans == "":
print(" ")
else:
print(ans)
|
s216650509
|
Accepted
| 22 | 3,316 | 378 |
import collections
N = int(input())
mojiNum = list()
for n in range(26):
mojiNum.append(50);
for n in range(N):
temp = input()
mojikind = collections.Counter(temp)
for i in range(26):
mojiNum[i] = min(mojiNum[i], mojikind[chr(i + 97)])
ans = ""
for n in range(26):
for i in range(mojiNum[n]):
ans += chr(97 + n)
if ans == "":
print(" ")
else:
print(ans)
|
s703929177
|
p02272
|
u196653484
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 752 |
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
|
def merge(A, left, mid, right):
n1=mid - left
n2=right - mid
L=[i for i in range(n1+1)]
R=[i for i in range(n2+1)]
for i in range(n1):
L[i] = A[left+i]
for i in range(n2):
R[i] = A[mid+i]
L[n1] = 1000000
R[n2] = 1000000
i=0
j=0
for k in range(left,right):
if L[i] <= R[j]:
A[k] = L[i]
i = i + 1
else:
A[k] = R[j]
j = j + 1
def merge_sort(A, left, right):
if left+1 < right:
mid=(left+right)//2
merge_sort(A, left, mid)
merge_sort(A, mid, right)
merge(A, left, mid, right)
if __name__ == "__main__":
n=int(input())
A=list(map(int,input().split()))
merge_sort(A,0,n)
print(A)
|
s605887228
|
Accepted
| 3,890 | 61,648 | 623 |
count=0
def merge(A, left, mid, right):
global count
L=A[left:mid]+[2**32]
R=A[mid:right]+[2**32]
i=0
j=0
for k in range(left,right):
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
count+=1
def merge_sort(A, left, right):
if left+1 < right:
mid=(left+right)//2
merge_sort(A, left, mid)
merge_sort(A, mid, right)
merge(A, left, mid, right)
if __name__ == "__main__":
n=int(input())
A=list(map(int,input().split()))
merge_sort(A,0,n)
print(*A)
print(count)
|
s154672128
|
p03110
|
u845937249
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 340 |
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?
|
import sys
if sys.platform =='ios':
sys.stdin=open('input_file.txt')
n = int(input())
lists = [input().split() for i in range(n)]
print(lists)
ans = 0
for i in range(n):
if lists[i][1] == 'JPY':
ans = ans + float(lists[i][0])
else:
ans = ans + float(lists[i][0])*380000
print(ans)
|
s195916580
|
Accepted
| 17 | 3,060 | 341 |
import sys
if sys.platform =='ios':
sys.stdin=open('input_file.txt')
n = int(input())
lists = [input().split() for i in range(n)]
#print(lists)
ans = 0
for i in range(n):
if lists[i][1] == 'JPY':
ans = ans + float(lists[i][0])
else:
ans = ans + float(lists[i][0])*380000
print(ans)
|
s534985775
|
p03659
|
u503901534
| 2,000 | 262,144 |
Wrong Answer
| 166 | 24,832 | 240 |
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 the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
|
n = int(input())
a = list(map(int,input().split()))
sss = 0
for i in range(n):
sss=sss + a[i]
ppp = 0
qqq = abs(sss - a[0])
for i in range(n):
ppp=ppp + a[i]
qo = abs(sss-ppp)
if qqq > qo:
qqq=qo
print(qqq)
|
s127283719
|
Accepted
| 188 | 24,832 | 248 |
n = int(input())
a = list(map(int,input().split()))
sss = 0
for i in range(n):
sss=sss + a[i]
ppp = 0
qqq = abs(sss - 2 * a[0])
for i in range(n-1):
ppp=ppp + a[i]
qo = abs(sss-2*ppp)
if qqq > qo:
qqq=qo
print(qqq)
|
s143836870
|
p03351
|
u127856129
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 107 |
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())
e=abs(a-b)
f=abs(b-c)
if e>=d and f>=d:
print("Yes")
else:
print("No")
|
s213016217
|
Accepted
| 17 | 2,940 | 125 |
a,b,c,d=map(int,input().split())
e=abs(a-b)
f=abs(b-c)
g=abs(a-c)
if g>d and (e>d or f>d):
print("No")
else:
print("Yes")
|
s582124999
|
p03399
|
u477651929
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,188 | 226 |
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
b = 0
bud = 0
for j, ai in enumerate(a):
if i != j:
bud += abs(ai - b)
b = ai
bud += abs(b)
print(bud)
|
s856146506
|
Accepted
| 17 | 2,940 | 84 |
a, b, c, d = map(int, [input() for i in range(4)])
print(min([a, b]) + min([c, d]))
|
s769041505
|
p03861
|
u191635495
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 236 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
if a != b:
first = a + ((x - a % x) if a % x != 0 else 0)
end = b - (b % x if b % x != 0 else 0)
print(first, end)
res = (end // x) - (first // x) + 1
print(res)
else:
print(0)
|
s026548090
|
Accepted
| 18 | 2,940 | 157 |
import math
a, b, x = map(int, input().split())
def f(n, x = x):
if n == -1:
return 0
else:
return n // x + 1
print(f(b) - f(a-1))
|
s525904803
|
p03693
|
u569742427
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 141 |
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?
|
if __name__ == '__main__':
r,g,b,=[i for i in input().split()]
if int(r+g+b)%4==0:
print('Yes')
else:
print('No')
|
s119969750
|
Accepted
| 18 | 2,940 | 143 |
if __name__ == '__main__':
r,g,b,=[i for i in input().split()]
if int(r+g+b)%4==0:
print('YES')
else:
print('NO')
|
s215288784
|
p02972
|
u700805562
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 9 |
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
print(-1)
|
s594038961
|
Accepted
| 230 | 14,004 | 206 |
n = int(input())
a = list(map(int, input().split()))
res = [0]*n
ans = []
for i in range(n-1, -1, -1):
if sum(res[i::i+1])%2!=a[i]:
res[i] = 1
ans.append(i+1)
print(len(ans))
print(*ans)
|
s803807249
|
p02409
|
u075836834
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,620 | 711 |
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())
A=[[['0' for _ in range(10)] for _ in range(3)] for _ in range(4)]
#[[[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]]]
#??? Room = r
for i in range(n):
b,f,r,num = input().strip().split()
A[int(b)-1][int(f)-1][int(r)-1]=num
for i in range(4):
for j in range(3):
print(' '.join(A[i][j]))
print('####################')
|
s594893286
|
Accepted
| 30 | 7,760 | 709 |
n = int(input())
A=[[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
#[[[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]],
# [[0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0],
# [0 0 0 0 0 0 0 0 0 0]]]
#??? Room = r
for i in range(n):
b,f,r,num = input().strip().split()
A[int(b)-1][int(f)-1][int(r)-1]+=int(num)
for i in range(4):
for j in range(3):
print('',' '.join(map(str,A[i][j])))
if i!=3:
print('#'*20)
|
s684658224
|
p03129
|
u259334183
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 65 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
n,k=map(int,input().split())
print('Yes' if n/2+0.5>=k else 'No')
|
s222149357
|
Accepted
| 17 | 3,064 | 65 |
n,k=map(int,input().split())
print('YES' if n/2+0.5>=k else 'NO')
|
s987381843
|
p03371
|
u619379081
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 176 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a, b, c, x, y = list(map(int, input().split()))
n = [0, 0, 0]
n[0] = a*x+b*y
if x<=y:
n[1] = 2*c*x+b*(y-x)
else:
n[1] = 2*c*x+a*(x-y)
n[2] = 2*c*max(x, y)
print(min(n))
|
s852974041
|
Accepted
| 19 | 3,064 | 176 |
a, b, c, x, y = list(map(int, input().split()))
n = [0, 0, 0]
n[0] = a*x+b*y
if x<=y:
n[1] = 2*c*x+b*(y-x)
else:
n[1] = 2*c*y+a*(x-y)
n[2] = 2*c*max(x, y)
print(min(n))
|
s389671799
|
p03369
|
u092244748
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s = str(input())
ans = 700
count = s.count('o')
print(count)
print(ans + 100 * count)
|
s223582579
|
Accepted
| 17 | 2,940 | 90 |
s = str(input())
ans = 700
count = s.count('o')
print(ans + 100 * count)
|
s007917409
|
p03433
|
u837286475
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
a = int(input())
b = int(input())
print( 'Yes' if a%500 >= b else 'No')
|
s643816186
|
Accepted
| 17 | 2,940 | 73 |
a = int(input())
b = int(input())
print( 'Yes' if a%500 <= b else 'No')
|
s688096797
|
p03149
|
u730318873
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 181 |
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 = map(int,input().rstrip().split())
x = 0
if 1 in N:
x = x + 1
if 9 in N:
x = x + 1
if 7 in N:
x = x + 1
if 4 in N:
x = x + 1
if x == 4:
print('YES')
else:
print('NO')
|
s438218738
|
Accepted
| 17 | 3,060 | 188 |
N = list(map(int,input().rstrip().split()))
x = 0
if 1 in N:
x = x + 1
if 9 in N:
x = x + 1
if 7 in N:
x = x + 1
if 4 in N:
x = x + 1
if x == 4:
print('YES')
else:
print('NO')
|
s579646589
|
p02275
|
u777299405
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,720 | 365 |
Counting sort can be used for sorting elements in an array which each of the n input elements is an integer in the range 0 to k. The idea of counting sort is to determine, for each input element x, the number of elements less than x as C[x]. This information can be used to place element x directly into its position in the output array B. This scheme must be modified to handle the situation in which several elements have the same value. Please see the following pseudocode for the detail: Counting-Sort(A, B, k) 1 for i = 0 to k 2 do C[i] = 0 3 for j = 1 to length[A] 4 do C[A[j]] = C[A[j]]+1 5 /* C[i] now contains the number of elements equal to i */ 6 for i = 1 to k 7 do C[i] = C[i] + C[i-1] 8 /* C[i] now contains the number of elements less than or equal to i */ 9 for j = length[A] downto 1 10 do B[C[A[j]]] = A[j] 11 C[A[j]] = C[A[j]]-1 Write a program which sorts elements of given array ascending order based on the counting sort.
|
def countingsort(a, b, k):
c = [0 for i in range(k + 1)]
for i in range(len(a)):
c[a[i]] += 1
for i in range(1, len(c)):
c[i] += c[i - 1]
for i in range(len(a) - 1, -1, -1):
b[c[a[i]] - 1] = a[i]
c[a[i]] -= 1
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
countingsort(a, b, max(a))
print(*b)
|
s076426917
|
Accepted
| 4,270 | 261,872 | 359 |
def countingsort(a, b, k):
c = [0 for i in range(k + 1)]
for i in range(len(a)):
c[a[i]] += 1
for i in range(1, len(c)):
c[i] += c[i - 1]
for i in range(len(a) - 1, -1, -1):
b[c[a[i]] - 1] = a[i]
c[a[i]] -= 1
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
countingsort(a, b, max(a))
print(*b)
|
s112909257
|
p01085
|
u209989098
| 8,000 | 262,144 |
Wrong Answer
| 150 | 5,612 | 357 |
The International Competitive Programming College (ICPC) is famous for its research on competitive programming. Applicants to the college are required to take its entrance examination. The successful applicants of the examination are chosen as follows. * The score of any successful applicant is higher than that of any unsuccessful applicant. * The number of successful applicants _n_ must be between _n_ min and _n_ max, inclusive. We choose _n_ within the specified range that maximizes the _gap._ Here, the _gap_ means the difference between the lowest score of successful applicants and the highest score of unsuccessful applicants. * When two or more candidates for _n_ make exactly the same _gap,_ use the greatest _n_ among them. Let's see the first couple of examples given in Sample Input below. In the first example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 82, 70, and 65. For _n_ of two, three and four, the gaps will be 8, 12, and 5, respectively. We must choose three as _n_ , because it maximizes the gap. In the second example, _n_ min and _n_ max are two and four, respectively, and there are five applicants whose scores are 100, 90, 80, 75, and 65. For _n_ of two, three and four, the gap will be 10, 5, and 10, respectively. Both two and four maximize the gap, and we must choose the greatest number, four. You are requested to write a program that computes the number of successful applicants that satisfies the conditions.
|
da = list(map(int,input().split()))
k = []
while sum(da) != 0:
for i in range(da[0]):
k.append(int(input()))
for i in range(da[0]):
k[da[0] - 1 -i] = k[da[0] - 1 -i] - k[da[0]-2 -i]
pp = k[da[1]:da[2]+1]
print(pp)
qq = min(pp)
for i in range(len(pp)):
if pp[i] == qq:
jj = i
print(da[1]+jj)
da = list(map(int,input().split()))
k = []
|
s951647030
|
Accepted
| 140 | 5,612 | 346 |
da = list(map(int,input().split()))
k = []
while sum(da) != 0:
for i in range(da[0]):
k.append(int(input()))
for i in range(da[0]):
k[da[0] - 1 -i] = k[da[0] - 1 -i] - k[da[0]-2 -i]
pp = k[da[1]:da[2]+1]
qq = min(pp)
for i in range(len(pp)):
if pp[i] == qq:
jj = i
print(da[1]+jj)
da = list(map(int,input().split()))
k = []
|
s490777203
|
p02748
|
u000540018
| 2,000 | 1,048,576 |
Wrong Answer
| 2,106 | 40,316 | 1,123 |
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 tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
import sys
lines = sys.stdin.readlines()
num_a ,num_b, num_m = [int(v) for v in lines[0].split()]
# ----
a_list = [int(v) for v in lines[1].split()[:num_a+1]]
b_list = [int(v) for v in lines[2].split()[:num_b+1]]
# print(a_list)
# print(b_list)
result = max(a_list) + max(b_list)
ignores = set()
for c in lines[3:num_m+3]:
a_i, b_i, discount = map(int, c.split())
try:
ignores.add((int(a_i), int(b_i)))
price = a_list[a_i-1] + b_list[b_i-1] - discount
if price < result:
result = price
except IndexError:
print('------')
print(c)
pass
# ---
# result = max(a_list) + max(b_list)
for i, a in enumerate(a_list):
for j, b in enumerate(b_list):
if (i+1, j+1) not in ignores:
price = a + b
result = price if price < result else result
result
# c_list = {
# (int()):int(l[4]) for l in lines[2:num_m+3]
# }
# a_list
# print(max(c_list.values()))
# print(a_list)
# print(b_list)
# print(c_list)
# list(itertools.product(a_list, b_list))
# for c in c_list:
|
s511375519
|
Accepted
| 400 | 72,128 | 456 |
import sys
lines = sys.stdin.readlines()
num_a ,num_b, num_m = [int(v) for v in lines[0].split()]
# ----
a_list = [int(v) for v in lines[1].split()[:num_a+1]]
b_list = [int(v) for v in lines[2].split()[:num_b+1]]
res1 = [
a_list[a_i-1]+b_list[b_i-1]-discount for a_i, b_i, discount in [
map(int, l.split()) for l in lines[3:num_m+3]
]
]
res2 = min(a_list) + min (b_list)
print(min(min(res1), res2))
|
s544141026
|
p03353
|
u611368136
| 2,000 | 1,048,576 |
Wrong Answer
| 37 | 4,400 | 404 |
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())
l = list(s)
alphabet = sorted(list(set(l)))
num = 0
for a in alphabet:
cand = []
n = s.count(a)
for i in range(n):
ind = l.index(a)
for j in range(k):
cand.append(s[ind+i: ind+j+1+i])
l.remove(a)
cand = list(set(cand))
if len(cand) >= k:
break
else:
num += len(cand)
print(sorted(cand)[k-num-1])
|
s770363225
|
Accepted
| 37 | 4,432 | 420 |
s = input()
k = int(input())
l = list(s)
alphabet = sorted(list(set(l)))
num = 0
for a in alphabet:
cand = []
n = s.count(a)
l = list(s)
for i in range(n):
ind = l.index(a)
for j in range(k):
cand.append(s[ind+i: ind+j+1+i])
l.remove(a)
cand = list(set(cand))
if len(cand) >= k:
break
else:
num += len(cand)
print(sorted(cand)[k-num-1])
|
s379190802
|
p02390
|
u386861275
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,600 | 101 |
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S=int(input())
x=int(S/360)
print(x,end=":")
S=S-x*360
x=int(S/60)
print(x,end=":")
S=S-x*60
print(S)
|
s526198489
|
Accepted
| 20 | 7,668 | 103 |
S=int(input())
x=int(S/3600)
print(x,end=":")
S=S-x*3600
x=int(S/60)
print(x,end=":")
S=S-x*60
print(S)
|
s258344499
|
p04044
|
u476562059
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 66 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
a = sorted(list(map(str,input().split())))
b = ''.join(a)
print(b)
|
s531342910
|
Accepted
| 17 | 3,060 | 109 |
n, l = map(int, input().split())
a = []
for x in range(n):
a.append(input())
a.sort()
print("".join(a))
|
s014164336
|
p03155
|
u667024514
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 73 |
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
|
h = int(input())
w = int(input())
n = int(input())
print((h-n+1)*(w-n+1))
|
s061234762
|
Accepted
| 17 | 2,940 | 73 |
n = int(input())
h = int(input())
w = int(input())
print((n-h+1)*(n-w+1))
|
s038647045
|
p02388
|
u598393390
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 29 |
Write a program which calculates the cube of a given integer x.
|
x = int(input())
print(x**2)
|
s925772198
|
Accepted
| 20 | 5,576 | 29 |
x = int(input())
print(x**3)
|
s294536932
|
p03474
|
u377989038
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 247 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a, b = map(int, input().split())
s = input()
l = list(range(10))
for i in range(len(s)):
if i == 3 and s[i] != "-":
print("No")
exit()
else:
if s[i] not in l:
print("No")
exit()
print("Yes")
|
s009508717
|
Accepted
| 17 | 2,940 | 253 |
a, b = map(int, input().split())
s = input()
for i in range(len(s)):
if i == a:
if s[a] != "-":
print("No")
exit()
else:
if not "0" <= s[i] <= "9":
print("No")
exit()
print("Yes")
|
s042380778
|
p03479
|
u492532572
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 2,940 | 134 |
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
|
X, Y = map(int, input().split())
i = 1
while True:
if pow(X, 2 * i) <= Y:
i += 1
else:
print(i)
break
|
s325250604
|
Accepted
| 17 | 3,064 | 134 |
X, Y = map(int, input().split())
i = 1
while True:
if X * pow(2, i) <= Y:
i += 1
else:
print(i)
break
|
s046967964
|
p03457
|
u343128979
| 2,000 | 262,144 |
Wrong Answer
| 360 | 21,156 | 428 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
def main():
N = int(input())
l = [[int(s) for s in input().split()] for n in range(N)]
can = True
now = [0, 0, 0]
for i in range(N):
pos = l[i]
d = abs(pos[1] - now[1]) + abs(pos[2] - now[2])
t = pos[0] - now[0]
if d % 2 != t % 2:
can = False
now = pos
if can:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()
|
s824172325
|
Accepted
| 343 | 21,156 | 437 |
def main():
N = int(input())
l = [[int(s) for s in input().split()] for n in range(N)]
can = True
now = [0, 0, 0]
for i in range(N):
pos = l[i]
d = abs(pos[1] - now[1]) + abs(pos[2] - now[2])
t = pos[0] - now[0]
if d % 2 != t % 2 or d > t:
can = False
now = pos
if can:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s134139643
|
p03024
|
u059436995
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 87 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
s = input()
rest = 15- len(s)
print('Yes') if s.count('o') + rest >=8 else print('NO')
|
s500653934
|
Accepted
| 17 | 2,940 | 87 |
s = input()
rest = 15- len(s)
print('YES') if s.count('o') + rest >=8 else print('NO')
|
s395278242
|
p03597
|
u470735879
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
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**2 - 1)
|
s184375011
|
Accepted
| 20 | 2,940 | 51 |
n = int(input())
a = int(input())
print(n**2 - a)
|
s179468185
|
p03471
|
u247211039
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 293 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
N, Y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(N):
for j in range(N):
for k in range(N):
if 10000*i + 5000*j + 1000*k == Y and i+j+k<=N:
a = i
b = j
c = k
if a == 0 and b == 0 and c == 0:
print(-1,'',-1,"",-1)
else:
print(a,'',b,"",c)
|
s816774265
|
Accepted
| 1,461 | 3,064 | 292 |
N, Y = map(int, input().split())
a = 0
b = 0
c = 0
for i in range(N+1):
for j in range(N+1):
if 10000*i + 5000*j + 1000*(N-i-j) == Y and N-i-j>=0:
a = i
b = j
c = N-i-j
if a == 0 and b == 0 and c == 0:
print(-1,-1,-1)
else:
print(a,b,c)
|
s775397655
|
p02408
|
u525685480
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,800 | 1,197 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
# -*- coding:utf-8 -*-
class Cards:
trump = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,]
def HaveCards(self,num):
self.trump[num] = True
def TransCards(self,s,num):
if(s == 'H'):
num += 12
elif(s == 'C'):
num +=25
elif(s == 'D'):
num += 38
return num
def CheckCards(self,num):
if(num <= 12):
return 'S' ,num+1
elif(num >= 13 and num <= 25):
return 'H' ,num-12
elif(num >= 26 and num <= 38):
return 'C',num-25
elif(num >= 39 and num <=51):
return 'D',num-38
n = int(input())
ob = Cards()
for i in range(n):
s,str_num = input().split()
number = int(str_num)
Num=ob.TransCards(s,number-1)
ob.HaveCards(Num)
for i in range(len(Cards.trump)):
if Cards.trump[i] == False:
Str,Num=ob.CheckCards(i)
print(Str,Num)
|
s008924482
|
Accepted
| 20 | 7,808 | 1,197 |
# -*- coding:utf-8 -*-
class Cards:
trump = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,]
def HaveCards(self,num):
self.trump[num] = True
def TransCards(self,s,num):
if(s == 'H'):
num += 13
elif(s == 'C'):
num +=26
elif(s == 'D'):
num += 39
return num
def CheckCards(self,num):
if(num <= 12):
return 'S' ,num+1
elif(num >= 13 and num <= 25):
return 'H' ,num-12
elif(num >= 26 and num <= 38):
return 'C',num-25
elif(num >= 39 and num <=51):
return 'D',num-38
n = int(input())
ob = Cards()
for i in range(n):
s,str_num = input().split()
number = int(str_num)
Num=ob.TransCards(s,number-1)
ob.HaveCards(Num)
for i in range(len(Cards.trump)):
if Cards.trump[i] == False:
Str,Num=ob.CheckCards(i)
print(Str,Num)
|
s805443791
|
p03644
|
u586478468
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
a = int(input())
for i in range(a):
if(2**i>=a):
print(2**(i))
break
|
s793299225
|
Accepted
| 18 | 3,316 | 136 |
a = int(input())
for i in range(a):
if(a==1):
print(1)
break
if(2**i>a):
print(2**(i-1))
break
|
s252336261
|
p03778
|
u143278390
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 202 |
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 minimum distance it needs to be moved.
|
w,a,b =[int(i) for i in input().split()]
if(b+w>=a):
if(b>a):
if(a+w>=b):
print(0)
else:
print((a+w)-b)
else:#
print(0)
else:#3
print(a-(b+w))
|
s161952859
|
Accepted
| 17 | 2,940 | 207 |
w,a,b =[int(i) for i in input().split()]
if(b+w>=a):
if(b>a):
if(a+w>=b):#2
print(0)
else:#1
print(b-(a+w))
else:#4
print(0)
else:#3
print(a-(b+w))
|
s659298911
|
p02645
|
u629276590
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 8,960 | 27 |
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
|
s=str(input())
print(s[:2])
|
s752495117
|
Accepted
| 22 | 9,028 | 27 |
s=str(input())
print(s[:3])
|
s081759135
|
p02399
|
u521569208
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,608 | 58 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b=(int(x) for x in input().split())
print(a//b,a%b,a/b)
|
s045272829
|
Accepted
| 20 | 5,608 | 76 |
a,b=(int(x) for x in input().split())
print(a//b,a%b,"{0:.5f}".format(a/b))
|
s620109649
|
p02612
|
u334242570
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,016 | 40 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(abs(n%1000 - n))
|
s218471588
|
Accepted
| 32 | 9,160 | 81 |
n = int(input())
if(n%1000 !=0):
print(abs(n%1000 - 1000))
else:print(0)
|
s122012870
|
p02600
|
u727051308
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,148 | 31 |
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())
print(10-X%200)
|
s392045291
|
Accepted
| 30 | 9,140 | 34 |
X = int (input())
print(10-X//200)
|
s565384464
|
p03371
|
u681340020
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 332 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
line = input()
a, b, c, x, y = map(int, line.split(' '))
print(a, b, c, x, y)
if x < y:
pizza = [(x, a), (y, b)]
else:
pizza = [(y, b), (x, a)]
values = list()
values.append(c * 2 * pizza[0][0] + pizza[1][1] * pizza[1][0] - pizza[0][0])
values.append(c * 2 * pizza[1][0])
values.append(a * x + b * y)
print(min(values))
|
s824952122
|
Accepted
| 17 | 3,064 | 312 |
line = input()
a, b, c, x, y = map(int, line.split(' '))
if x < y:
pizza = [(x, a), (y, b)]
else:
pizza = [(y, b), (x, a)]
values = list()
values.append(c * 2 * pizza[0][0] + pizza[1][1] * (pizza[1][0] - pizza[0][0]))
values.append(c * 2 * pizza[1][0])
values.append(a * x + b * y)
print(min(values))
|
s818366272
|
p03457
|
u080108339
| 2,000 | 262,144 |
Wrong Answer
| 398 | 27,324 | 247 |
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
N= int(input())
A = [list(map(int, input().split(" "))) for i in range(N)]
count = 0
for i in range(0,N-1):
if (A[i+1][0] - A[i][0] + A[i+1][1] - A[i][1] + A[i+1][2] - A[i][2])%2==0:
count += 1
if count == N:
print('Yes')
else:
print('No')
|
s584906888
|
Accepted
| 430 | 27,324 | 311 |
N= int(input())
A = [list(map(int, input().split(" "))) for i in range(N)]
A.insert(0, [0, 0, 0])
count = 0
for i in range(0,N):
x = A[i+1][0] - A[i][0] + A[i+1][1] - A[i][1] + A[i+1][2] - A[i][2]
y = A[i+1][0] - A[i][0]
if x%2==0 and x <= 2*y:
count += 1
if count == N:
print('Yes')
else:
print('No')
|
s380373896
|
p03854
|
u083960235
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 297 |
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`.
|
import itertools
s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]
for i,_ in enumerate(add,1):
for j in itertools.permutations(add,r=i):
t.append("".join(j))
temp=False
for i in range(len(t)):
if(s==t[i]):
temp=True
break
if temp==True:
print("Yes")
else:
print("No")
|
s705033826
|
Accepted
| 20 | 3,188 | 463 |
s = input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
print("NO")
else:
print("YES")
"""
#failed
import itertools
s=str(input())
add=["dream","dreamer","erase","eraser"]
t=[]
for i,_ in enumerate(add,1):
for j in itertools.permutations(add,r=i):
t.append("".join(j))
print(t)
temp=False
for i in range(len(t)):
if(s==t[i]):
temp=True
break
if temp==True:
print("Yes")
else:
print("No")
"""
|
s275643686
|
p03997
|
u259738923
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 102 |
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())
area=(a+b)*int(h/2)
print(str(a)+str(b)+str(h)+str(area))
|
s333208026
|
Accepted
| 17 | 2,940 | 82 |
a = int(input())
b = int(input())
h = int(input())
face = (a+b)*h//2
print(face)
|
s957082689
|
p03251
|
u951601135
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 202 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
#print(N,M,X,Y,x,y)
x.append(X)
y.append(Y)
if(max(x)>min(y)):
print('War')
else:
print('Np War')
|
s339744043
|
Accepted
| 18 | 2,940 | 217 |
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
#print(N,M,X,Y,x,y)
x.append(X)
y.append(Y)
if((max(x)+1)>min(y) or (X+1)>Y):
print('War')
else:
print('No War')
|
s079776100
|
p03351
|
u474423089
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 121 |
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(' '))
A,B,C=sorted([A,B,C])
if B-A <=D and C-B <= D:
print('YES')
else:
print('NO')
|
s225310797
|
Accepted
| 17 | 2,940 | 129 |
A,B,C,D=map(int,input().split(' '))
if abs(A-C) <= D or ((abs(B-A)) <= D and abs(B-C)<=D):
print('Yes')
else:
print('No')
|
s502944391
|
p03470
|
u581603131
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
#bA
N = int(input())
d = [int(input()) for i in range(N)]
print(set(d))
|
s804168174
|
Accepted
| 17 | 2,940 | 129 |
#bA
N = int(input())
d = [int(input()) for i in range(N)]
print(len(set(d)))
|
s641832817
|
p04029
|
u124662294
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,044 | 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)
|
s422107556
|
Accepted
| 27 | 8,924 | 34 |
N = int(input())
print(N*(N+1)//2)
|
s298516718
|
p04030
|
u667472448
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 237 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = ''
while True:
try:
x = input()
if x == 'B' and len(s)!=0:
s.rstrip()
elif x == 'B' and len(s)==0:
pass
else:
s = s+x
except EOFError:
break
print(s)
|
s160008203
|
Accepted
| 17 | 2,940 | 146 |
s=''
x=input()
for i in range(len(x)):
if x[i]=='B' and len(s)!=0:s = s[:-1]
elif x[i]=='B' and len(s)==0:pass
else:s += x[i]
print(s)
|
s997141726
|
p03448
|
u224119985
| 2,000 | 262,144 |
Wrong Answer
| 48 | 3,064 | 264 |
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=[]
for _ in range(3):
A.append(int(input()))
a=A[0]
b=A[1]
c=A[2]
x=int(input())
count=0
for p in range(a):
for q in range(b):
for r in range(c):
if 500*p+100*q+50*r==x:
count=count+1
else:
count=count
print(count)
|
s997724286
|
Accepted
| 55 | 3,064 | 292 |
A=[]
for _ in range(3):
A.append(int(input()))
a=A[0]
b=A[1]
c=A[2]
x=int(input())
count=0
for p in range(a+1):
for q in range(b+1):
for r in range(c+1):
if 500*p+100*q+50*r==x:
count=count+1
else:
count=count
print(count)
|
s368821669
|
p03408
|
u642823003
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 367 |
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.
|
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
output = 0
s_count, t_count = Counter(s), Counter(t)
for i in s_count:
tmp_s = s_count[i]
tmp_t = 0
if i in t_count:
tmp_t = t_count[i]
if output > tmp_s - tmp_t:
output = tmp_s - tmp_t
print(output)
|
s361962528
|
Accepted
| 21 | 3,316 | 367 |
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
output = 0
s_count, t_count = Counter(s), Counter(t)
for i in s_count:
tmp_s = s_count[i]
tmp_t = 0
if i in t_count:
tmp_t = t_count[i]
if output < tmp_s - tmp_t:
output = tmp_s - tmp_t
print(output)
|
s063601522
|
p03435
|
u755180064
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,152 | 569 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
def main():
grid = [list(map(int, input().split())) for i in range(3)]
all = sum(sum(grid, []))
a = [0] * 3
b = [0] * 3
for i1 in range(0, grid[0][0] + 1):
a[0] = i1
b[0] = grid[0][0] - i1
for j2 in range(0, grid[1][1] + 1):
a[1] = j2
b[1] = grid[1][1] - j2
for k3 in range(0, grid[2][2] + 1):
a[2] = k3
b[2] = grid[2][2] - k3
if (sum(a) * 3) + (sum(b) * 3) == all:
print("Yes")
exit()
print('No')
|
s354027605
|
Accepted
| 409 | 9,192 | 489 |
import itertools
def main():
grid = [list(map(int, input().split())) for i in range(3)]
all = sum(sum(grid, []))
a = [0] * 3
b = [0] * 3
for i, j, k in itertools.product(range(grid[0][0] + 1), range(grid[1][1] + 1), range(grid[2][2] + 1)):
a = [i, j, k]
b = [grid[idx][idx] - v for idx, v in enumerate(a)]
if (sum(a) * 3) + (sum(b) * 3) == all:
print("Yes")
exit()
print('No')
if __name__ == '__main__':
main()
|
s857614420
|
p02865
|
u527616458
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 29 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
a = int(input())
print(a/2-1)
|
s947032191
|
Accepted
| 17 | 2,940 | 85 |
a = int(input())
if a%2==0:
print(int((a/2)-1))
elif a%2==1:
print(int((a-1)/2))
|
s111686651
|
p03377
|
u214344212
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X=list(map(int,input().split()))
if A<=X<=A+B:
print('Yes')
else:
print('No')
|
s244534586
|
Accepted
| 17 | 2,940 | 90 |
A,B,X=list(map(int,input().split()))
if A<=X<=A+B:
print('YES')
else:
print('NO')
|
s621970301
|
p03361
|
u787562674
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 1,325 |
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
H, W = map(int, input().split())
field = [input() for i in range(H)]
count = 0
print(field)
for i in range(H):
for j in range(W):
if (i == 0 and j == 0) or (i == H-1 and j == 0) or (i == 0 and j == W-1) or (i == H-1 and j == W-1):
pass
elif i == 0:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#':
count += 1
elif i == H-1:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i-1][j] != '#':
count += 1
elif j == 0:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#':
count += 1
elif j == W-1:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i+1][j] != '#' and field[i-1][j] != '#':
count += 1
elif field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#' and field[i-1][j] != '#':
count += 1
print('No' if count>=1 else 'Yes')
|
s550079290
|
Accepted
| 19 | 3,064 | 1,317 |
H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
count = 0
for i in range(H):
for j in range(W):
if (i == 0 and j == 0) or (i == H-1 and j == 0) or (i == 0 and j == W-1) or (i == H-1 and j == W-1):
pass
elif i == 0:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#':
count += 1
elif i == H-1:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i-1][j] != '#':
count += 1
elif j == 0:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#':
count += 1
elif j == W-1:
if field[i][j] == '#' and field[i][j-1] != '#' and field[i+1][j] != '#' and field[i-1][j] != '#':
count += 1
elif field[i][j] == '#' and field[i][j-1] != '#' and field[i][j+1] != '#' and field[i+1][j] != '#' and field[i-1][j] != '#':
count += 1
print('No' if count>=1 else 'Yes')
|
s663882049
|
p02795
|
u731368968
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 110 |
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 the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
H=int(input())
W=int(input())
N=int(input())
if H<W:
H,W=W,H
ans = N // H
if N % H > 0: N += 1
print(ans)
|
s678265827
|
Accepted
| 17 | 2,940 | 112 |
H=int(input())
W=int(input())
N=int(input())
if H<W:
H,W=W,H
ans = N // H
if N % H > 0: ans += 1
print(ans)
|
s627527410
|
p02612
|
u771634798
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,140 | 43 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
ans = n % 1000
print(ans)
|
s402500569
|
Accepted
| 28 | 9,140 | 79 |
n = int(input())
mod = n % 1000
ans = 1000 - mod if mod != 0 else 0
print(ans)
|
s966408187
|
p03470
|
u498136917
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 82 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
n_d = list(map(int, input().split()))
d = n_d[1:]
max_d = len(set(d))
print(max_d)
|
s980314159
|
Accepted
| 17 | 2,940 | 86 |
x = int(input())
y = [int(input()) for i in range(x)]
max_d = len(set(y))
print(max_d)
|
s306593966
|
p02613
|
u768256617
| 2,000 | 1,048,576 |
Wrong Answer
| 149 | 16,052 | 253 |
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())
l=[]
for i in range(n):
s=input()
l.append(s)
ac=l.count('AC')
wa=l.count('WA')
tle=l.count('TLE')
re=l.count('RE')
print('AC ' +'x' + str(ac))
print('WA ' +'x' + str(wa))
print('TLE ' +'x' + str(tle))
print('RE ' +'x' + str(re))
|
s647705059
|
Accepted
| 157 | 16,152 | 256 |
n=int(input())
l=[]
for i in range(n):
s=input()
l.append(s)
ac=l.count('AC')
wa=l.count('WA')
tle=l.count('TLE')
re=l.count('RE')
print('AC ' +'x ' + str(ac))
print('WA ' +'x ' + str(wa))
print('TLE ' +'x ' + str(tle))
print('RE ' +'x ' + str(re))
|
s060496081
|
p04011
|
u864047888
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 147 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n=int(input())
k=int(input())
x=int(input())
y=int(input())
ans=0
for i in range(n):
if n>k:
ans+=y
else:
ans+=x
print(ans)
|
s711500358
|
Accepted
| 19 | 2,940 | 151 |
n=int(input())
k=int(input())
x=int(input())
y=int(input())
ans=0
for i in range(1,n+1):
if i>k:
ans+=y
else:
ans+=x
print(ans)
|
s484325886
|
p02646
|
u579015878
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,180 | 175 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if W>=V:
print('No')
else:
key=abs(A-B)
if key+W*T>V*T:
print('No')
else:
print('Yes')
|
s670487478
|
Accepted
| 18 | 9,176 | 175 |
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if W>=V:
print('NO')
else:
key=abs(A-B)
if key+W*T>V*T:
print('NO')
else:
print('YES')
|
s720342852
|
p03860
|
u996665352
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 29 |
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()
print("A"+s[0]+"C")
|
s448975783
|
Accepted
| 17 | 2,940 | 41 |
a,s,c=input().split()
print("A"+s[0]+"C")
|
s060713350
|
p02613
|
u835283937
| 2,000 | 1,048,576 |
Wrong Answer
| 153 | 9,420 | 335 |
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.
|
from collections import defaultdict
def main():
N = int(input())
c = defaultdict(int)
for i in range(N):
c[input()] += 1
print("AC × {}".format(c["AC"]))
print("WA × {}".format(c["WA"]))
print("TLE × {}".format(c["TLE"]))
print("RE × {}".format(c["RE"]))
if __name__ == "__main__":
main()
|
s981432417
|
Accepted
| 139 | 9,448 | 331 |
from collections import defaultdict
def main():
N = int(input())
c = defaultdict(int)
for i in range(N):
c[input()] += 1
print("AC x {}".format(c["AC"]))
print("WA x {}".format(c["WA"]))
print("TLE x {}".format(c["TLE"]))
print("RE x {}".format(c["RE"]))
if __name__ == "__main__":
main()
|
s950322183
|
p02742
|
u023751250
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 52 |
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 top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
a,b=map(int,input().split())
print(-(int(-(a+b)/2)))
|
s797327579
|
Accepted
| 18 | 2,940 | 93 |
a,b=map(int,input().split())
if(a==1 or b==1):
print(1)
else:
print(int((a*b)/2)+(a*b)%2)
|
s603613907
|
p03418
|
u604262137
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 3,064 | 296 |
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.
|
K = input().split()
N = int(K[0])
K = int(K[1])
count = 0
for b in range(K+1, N+1):
for l in range(K, b):
count += int((N-l)/b)
print(count)
if K != 0:
for a in range(K, N+1):
count += N-a
if K == 0:
for a in range(1, N+1):
count += N-a
print(count)
|
s143929190
|
Accepted
| 195 | 3,064 | 498 |
K = input().split()
N = int(K[0])
K = int(K[1])
count = 0
for b in range(K+1, N+1):
siki1 = int((N-K)/b)
siki2 = int((N-b+1)/b)
if siki1 <= siki2:
count += (b-K)*siki1
elif siki1 > siki2:
count += (b-K)*siki1
count -= (b-N-1)*(siki1 - siki2)
count -= b*(int((siki1*(siki1+1))/2) - int((siki2*(siki2+1))/2))
if K != 0:
for a in range(K, N+1):
count += N-a
if K == 0:
for a in range(1, N+1):
count += N-a
print(count)
|
s181279440
|
p03555
|
u086503932
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 75 |
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.
|
C=list(open(0).read())
print('YES')if C[:3] == C[-1:-4:-1] else print('NO')
|
s910416595
|
Accepted
| 17 | 2,940 | 57 |
print('YES')if input() == input()[::-1] else print('NO')
|
s165637154
|
p02833
|
u130335779
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 68 |
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
n = int(input())
print(n)
half = n // 2
ans = half / 5
print(ans)
|
s905729258
|
Accepted
| 18 | 2,940 | 146 |
n = int(input())
if (n % 2 == 1):
print(0)
else:
ans = 0
d = 10
while d <= n:
ans += n // d
d *= 5
print(ans)
|
s724545368
|
p02257
|
u279605379
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,504 | 231 |
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.
|
def prime(n):
s=2
while(s*s <= n):
if(n%s==0):
return False
s+=2
return True
n=int(input())
for i in range(n):
x = input()
if prime(int(x)):
print(x)
|
s936796954
|
Accepted
| 950 | 7,700 | 285 |
def prime(n):
s=3
while(s*s <= n):
if(n%s==0):
return False
s+=2
return True
n=int(input())
num=0
for i in range(n):
x = int(input())
if prime(x) and x%2!=0:
num+=1
if x==2:
num+=1
print(num)
|
s854381443
|
p04043
|
u570018655
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 128 |
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.
|
abc = list(map(int, input().split()))
abc.sort()
print(abc)
if [5, 5, 7] == abc:
ans = "YES"
else:
ans = "NO"
print(ans)
|
s505235843
|
Accepted
| 19 | 2,940 | 117 |
abc = list(map(int, input().split()))
abc.sort()
if [5, 5, 7] == abc:
ans = "YES"
else:
ans = "NO"
print(ans)
|
s509657055
|
p03377
|
u750651325
| 2,000 | 262,144 |
Wrong Answer
| 38 | 10,384 | 594 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
a,b,c = I()
if c > a+b:
print("YES")
else:
print("NO")
|
s640176133
|
Accepted
| 37 | 10,296 | 577 |
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
A,B,X=I()
print("YES" if A<=X<=A+B else "NO")
|
s431994136
|
p03698
|
u174766008
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 116 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
s = input()
for i in range(len(s)):
if s[i] in s[i+1:]:
print('No')
break
else:
print('Yes')
|
s287775748
|
Accepted
| 18 | 2,940 | 72 |
N=input()
if len(N)==len(set(N)):
print("yes")
else:
print("no")
|
s928822061
|
p03636
|
u177132624
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 42 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s=input()
print(s[0],len(s)-2,s[len(s)-1])
|
s294167875
|
Accepted
| 17 | 2,940 | 47 |
s=input()
print(s[0]+str(len(s)-2)+s[len(s)-1])
|
s741024874
|
p02613
|
u431860365
| 2,000 | 1,048,576 |
Wrong Answer
| 147 | 9,008 | 242 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N=int(input())
a=0
w=0
t=0
r=0
for i in range(N):
s=input()
if s=="AC":
a+=1
elif s=="WA":
w+=1
elif s=="TLE":
t+=1
elif s=="RE":
r+=1
print("AC × ",a)
print("WA × ",w)
print("TLE × ",t)
print("RE × ",r)
|
s139806399
|
Accepted
| 144 | 9,204 | 222 |
N=int(input())
a=0
w=0
t=0
r=0
for i in range(N):
s=input()
if s=="AC":
a+=1
elif s=="WA":
w+=1
elif s=="TLE":
t+=1
else:
r+=1
print("AC x",a)
print("WA x",w)
print("TLE x",t)
print("RE x",r)
|
s751291095
|
p03160
|
u737840172
| 2,000 | 1,048,576 |
Wrong Answer
| 119 | 20,504 | 340 |
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 |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
# Vicfred
# dynamic programming
n = int(input())
h = [0]+list(map(int, input().split()))
dp = [0]*(n + 1)
dp[1] = 0
dp[2] = abs(h[1] - h[0])
for i in range(3, n + 1):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
dp[i - 2] + abs(h[i] - h[i - 2])
)
print(dp[n])
|
s366491716
|
Accepted
| 124 | 20,628 | 340 |
# Vicfred
# dynamic programming
n = int(input())
h = [0]+list(map(int, input().split()))
dp = [0]*(n + 1)
dp[1] = 0
dp[2] = abs(h[2] - h[1])
for i in range(3, n + 1):
dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
dp[i - 2] + abs(h[i] - h[i - 2])
)
print(dp[n])
|
s095275237
|
p03155
|
u127499732
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 99 |
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
|
def main():
import sys
n,h,w=map(int,open(0).read().split())
ans=(n-h-1)*(n-w+1)
print(ans)
|
s055474686
|
Accepted
| 17 | 2,940 | 134 |
def main():
import sys
n,h,w=map(int,open(0).read().split())
ans=(n-h+1)*(n-w+1)
print(ans)
if __name__=="__main__":
main()
|
s122923698
|
p03555
|
u594956556
| 2,000 | 262,144 |
Wrong Answer
| 20 | 2,940 | 79 |
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.
|
S1 = input()
S2 = input()
if S1 == S2[::-1]:
print('Yes')
else:
print('No')
|
s825787470
|
Accepted
| 17 | 2,940 | 80 |
S1 = input()
S2 = input()
if S1 == S2[::-1]:
print('YES')
else:
print('NO')
|
s362343798
|
p02578
|
u920391637
| 2,000 | 1,048,576 |
Wrong Answer
| 90 | 32,368 | 216 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
def main():
N = int(input())
A = list(map(int, input().split()))
i = A[0]
T = 0
for n in A:
if n > i:
T += n -i
if n < i:
T = i
print(T)
if __name__ == "__main__":
main()
|
s146699499
|
Accepted
| 98 | 32,124 | 231 |
def main():
N = int(input())
A = list(map(int, input().split()))
m = A[0]
S = 0
for a in A:
if m - a > 0:
S += m - a
if m < a:
m = a
print(S)
if __name__ == "__main__":
main()
|
s400169334
|
p02821
|
u779455925
| 2,000 | 1,048,576 |
Wrong Answer
| 1,945 | 14,636 | 936 |
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?
|
#from collections import *
#from itertools import *
#from bisect import *
from heapq import *
#import copy
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
ng=-1
ok=N**2+1
while ok>ng+1:
mid=(ok+ng)//2
K=0
idx=0
for i in range(N-1,-1,-1):
X=mid-A[i]
while idx<N and A[idx]>=X:
idx+=1
K+=idx
if K>M:
ng=mid
else:
ok=mid
#print(mid)
idx=0
lst=[0 for i in range(N)]
for i in range(N-1,-1,-1):
X=mid-A[i]
while idx<N and A[idx]>=X:
idx+=1
lst[i]=idx*2
value=0
for a,i in zip(A,lst):
value+=a*i
value-=mid*(sum(lst)//2-M)
print(value)
|
s872148502
|
Accepted
| 1,315 | 14,268 | 937 |
#from collections import *
#from itertools import *
#from bisect import *
from heapq import *
#import copy
#N=int(input())
#X,Y=map(int,input().split())
#S=list(map(int,input().split()))
N,M=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
ng=-1
ok=max(A)*2+1
while ok>ng+1:
mid=(ok+ng)//2
K=0
idx=0
for i in range(N-1,-1,-1):
X=mid-A[i]
while idx<N and A[idx]>=X:
idx+=1
K+=idx
if K>M:
ng=mid
else:
ok=mid
idx=0
lst=[0 for i in range(N)]
for i in range(N-1,-1,-1):
X=ng-A[i]
while idx<N and A[idx]>=X:
idx+=1
lst[i]=idx*2
value=0
for a,i in zip(A,lst):
value+=a*i
value-=ng*(sum(lst)//2-M)
print(value)
|
s202794553
|
p03448
|
u317710033
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 396 |
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.
|
five = int(input())
one_hundred = int(input())
fifty = int(input())
total = int(input())
count = 0
x = total//50
if 0<= x <=fifty:
if 0 <= x//2 <= one_hundred:
if 0 <= x//10 <= five:
count = ( 1 + (x//2 + 1) + (x//10 + 1))
else:
count = ( 1 + (x//2 + 1) + five)
else:
count = (1 + one_hundred + five)
else:
count = (fifty + one_hundred + five)
print(count)
|
s280409313
|
Accepted
| 50 | 3,060 | 230 |
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for x in range(0, A+1):
for y in range(0, B+1):
for z in range(0, C+1):
if x*500 + y*100 + z*50 == X:
count +=1
print(count)
|
s902178421
|
p04012
|
u736474437
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 135 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w=input()
flag=True
for i in str(w):
if str(w).count(i)==2:
continue
else:
flag=False
print("Yes" if flag==True else "No")
|
s761359645
|
Accepted
| 17 | 2,940 | 142 |
w=input()
flag=True
for i in str(w):
if int(str(w).count(i))%2==0:
continue
else:
flag=False
print("Yes" if flag==True else "No")
|
s387164270
|
p03151
|
u811176339
| 2,000 | 1,048,576 |
Wrong Answer
| 103 | 24,084 | 414 |
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 pass all the examinations, and he has decided to ask a magician, Aoki, to change the readiness for as few examinations as possible so that he can pass all of them, while not changing the total readiness. For Takahashi, find the minimum possible number of indices i such that A_i and C_i are different, for a sequence C_1, C_2, ..., C_{N} that satisfies the following conditions: * The sum of the sequence A_1, A_2, ..., A_{N} and the sum of the sequence C_1, C_2, ..., C_{N} are equal. * For every i, B_i \leq C_i holds. If such a sequence C_1, C_2, ..., C_{N} cannot be constructed, print -1.
|
n = int(input())
la = [int(w) for w in input().split()]
lb = [int(w) for w in input().split()]
ld = [a-b for a, b in zip(la, lb)]
if sum(ld) < 0:
print(-1)
exit()
llower = [w for w in ld if w < 0]
lupper = [w for w in ld if w > 0]
lowsum = sum(llower)
lupper.sort(reverse=True)
ans = len(llower)
print(llower)
for d in lupper:
if lowsum >= 0:
break
ans += 1
lowsum += d
print(ans)
|
s851546576
|
Accepted
| 100 | 24,060 | 400 |
n = int(input())
la = [int(w) for w in input().split()]
lb = [int(w) for w in input().split()]
ld = [a-b for a, b in zip(la, lb)]
if sum(ld) < 0:
print(-1)
exit()
llower = [w for w in ld if w < 0]
lupper = [w for w in ld if w > 0]
lowsum = sum(llower)
lupper.sort(reverse=True)
ans = len(llower)
for d in lupper:
if lowsum >= 0:
break
ans += 1
lowsum += d
print(ans)
|
s974721703
|
p03555
|
u017271745
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 138 |
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.
|
c = [input() for i in range(2)]
ans = 'No'
if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
ans = 'Yes'
print(ans)
|
s631126034
|
Accepted
| 17 | 2,940 | 138 |
c = [input() for i in range(2)]
ans = 'NO'
if c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:
ans = 'YES'
print(ans)
|
s528558957
|
p03997
|
u558059388
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,052 | 68 |
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)
|
s444231104
|
Accepted
| 17 | 2,940 | 62 |
a=int(input())
b=int(input())
h=int(input())
print((a+b)*h//2)
|
s063031309
|
p03598
|
u658993896
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 99 |
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 type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
input()
K=int(input())
ans = [min(x-0,K-x) for x in list(map(int,input().split()))]
print(sum(ans))
|
s758114240
|
Accepted
| 17 | 2,940 | 99 |
input();K=int(input())
ans=[min(x-0,K-x) for x in list(map(int,input().split()))]
print(sum(ans)*2)
|
s128938396
|
p03698
|
u774160580
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 77 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S = input()
if len(S) != len(set(S)):
print("yes")
else:
print("no")
|
s494890278
|
Accepted
| 17 | 2,940 | 77 |
S = input()
if len(S) == len(set(S)):
print("yes")
else:
print("no")
|
s892425049
|
p02606
|
u583507988
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,156 | 99 |
How many multiples of d are there among the integers between L and R (inclusive)?
|
l, r, d = map(int, input().split())
a = r//d
b = l//d
if b%d==0:
print(a-b+1)
else:
print(a-b)
|
s609668859
|
Accepted
| 24 | 9,092 | 99 |
l, r, d = map(int, input().split())
a = r//d
b = l//d
if l%d==0:
print(a-b+1)
else:
print(a-b)
|
s625582414
|
p02841
|
u114920558
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 88 |
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
s = input().split()
t = input().split()
if s[0] != s[1]:
print("1")
else:
print("0")
|
s329009696
|
Accepted
| 17 | 2,940 | 88 |
s = input().split()
t = input().split()
if s[0] != t[0]:
print("1")
else:
print("0")
|
s135532634
|
p03024
|
u089142196
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 60 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
if input().count("o")>=8:
print("YES")
else:
print("NO")
|
s185052653
|
Accepted
| 17 | 2,940 | 76 |
S=input()
if S.count("o")+(15-len(S))>=8:
print("YES")
else:
print("NO")
|
s574221972
|
p02607
|
u153729035
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,104 | 75 |
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
input()
a = list(map(int, input().split()))
sum([ai % 2 for ai in a[::2]])
|
s900048306
|
Accepted
| 27 | 9,088 | 82 |
input()
a = list(map(int, input().split()))
print(sum([ai % 2 for ai in a[::2]]))
|
s247864891
|
p02936
|
u151005508
| 2,000 | 1,048,576 |
Wrong Answer
| 2,107 | 73,504 | 450 |
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
N, Q = map(int, input().split())
ab=[]
for _ in range(N-1):
ab.append(tuple(map(int, input().split())))
px=[]
for _ in range(Q):
px.append(tuple(map(int, input().split())))
print(N,Q,ab,px)
counter=[0]*N
def func(start, plus, counter):
counter[start-1]+=plus
for val in ab:
if start==val[0]:
func(val[1], plus, counter)
for val in px:
func(val[0], val[1], counter)
print(' '.join(list(map(str, counter))))
|
s521356993
|
Accepted
| 1,690 | 276,160 | 648 |
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
N, Q = map(int, input().split())
ab=[]
for _ in range(N-1):
ab.append(tuple(map(int, input().split())))
px=[]
for _ in range(Q):
px.append(tuple(map(int, input().split())))
cnt=[0]*(N+1)
for el in px:
cnt[el[0]] += el[1]
#print(cnt)
lst=[[] for _ in range(N+1)]
for el in ab:
lst[el[0]].append(el[1])
lst[el[1]].append(el[0])
#print(lst)
seen = set()
def dfs(n):
seen.add(n)
for child in lst[n]:
if child not in seen:
cnt[child]+=cnt[n]
dfs(child)
dfs(1)
#print(cnt)
print(' '.join(list(map(str, cnt[1:]))))
|
s700543174
|
p03730
|
u471214054
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 126 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
A, B, C = map(int, input().split())
ans = 'No'
for i in range(A, B*A+1, A):
if i % B == C:
ans = 'Yes'
print(ans)
|
s521905988
|
Accepted
| 17 | 2,940 | 126 |
A, B, C = map(int, input().split())
ans = 'NO'
for i in range(A, B*A+1, A):
if i % B == C:
ans = 'YES'
print(ans)
|
s797947036
|
p04044
|
u054556734
| 2,000 | 262,144 |
Wrong Answer
| 408 | 29,136 | 585 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n,l = imap()
s = []
for i in range(n): s.append(sinput())
ans = "".join(s)
print(ans)
|
s756168349
|
Accepted
| 281 | 19,744 | 593 |
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
n,l = imap()
s = []
for i in range(n): s.append(sinput())
ans = "".join(sorted(s))
print(ans)
|
s759062368
|
p03729
|
u937303520
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,024 | 168 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
A,B,C = input().split()
def answer(A, B , C) -> str:
if A[-1] == B[0] and B[-1]== C[0]:
return('Yes')
else:
return('No')
print(answer(A, B, C))
|
s528697444
|
Accepted
| 25 | 9,060 | 94 |
a,b,c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
print("YES")
else:
print("NO")
|
s048231167
|
p03361
|
u203382704
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,064 | 711 |
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
H, W = map(int,input().split())
mp = [list(input()) for i in range(H)]
for i in range(H):
mp[i].insert(0,'.')
mp[i].append('.')
lo = ['.' for i in range(W+2)]
mp.insert(0,lo)
mp.append(lo)
dir =[[-1,0], [0,-1], [0,1], [1,0]]
def check(x,y):
if mp[x][y] =='#':
bw =False
for i in range(len(dir)):
if mp[x + dir[i][0]][y + dir[i][1]] =='#':
bw = True
if bw == True:
return True
else:
return False
else:
return True
ok =True
for i in range(1,H+1):
for k in range(1,W+1):
if check(i,k) == False:
ok = False
break
if ok == True:
print('YES')
else:
print('NO')
|
s415212025
|
Accepted
| 21 | 3,064 | 709 |
H, W = map(int,input().split())
mp = [list(input()) for i in range(H)]
for i in range(H):
mp[i].insert(0,'.')
mp[i].append('.')
lo = ['.' for i in range(W+2)]
mp.insert(0,lo)
mp.append(lo)
dir =[[-1,0], [0,-1], [0,1], [1,0]]
def check(x,y):
if mp[x][y] =='#':
bw =False
for i in range(len(dir)):
if mp[x + dir[i][0]][y + dir[i][1]] =='#':
bw = True
if bw == True:
return True
else:
return False
else:
return True
ok =True
for i in range(1,H+1):
for k in range(1,W+1):
if check(i,k) == False:
ok = False
break
if ok == True:
print('Yes')
else:
print('No')
|
s272718948
|
p03504
|
u079022693
| 2,000 | 262,144 |
Wrong Answer
| 676 | 33,480 | 1,153 |
Joisino is planning to record N TV programs with recorders. The TV can receive C channels numbered 1 through C. The i-th program that she wants to record will be broadcast from time s_i to time t_i (including time s_i but not t_i) on Channel c_i. Here, there will never be more than one program that are broadcast on the same channel at the same time. When the recorder is recording a channel from time S to time T (including time S but not T), it cannot record other channels from time S-0.5 to time T (including time S-0.5 but not T). Find the minimum number of recorders required to record the channels so that all the N programs are completely recorded.
|
def main():
N,C=map(int,input().split())
stc=[0]*N
for i in range(N):
abc=list(map(int,input().split()))
stc[i]=abc
stc.sort()
print(stc)
flag=False
max_count=0
chain=[]
for i in range(N):
if i==0:
count=1
max_count=max(count,max_count)
else:
if stc[i-1][1]>stc[i][0]-0.5 and flag==False:
if stc[i-1][2]!=stc[i][2]:
count=2
max_count=max(count,max_count)
flag=True
chain=[i-1,i]
elif flag:
for j in chain:
if stc[j][1]<=stc[i][1]-0.5:
flag=False
chain=[]
if flag:
for j in chain:
if stc[j][2]==stc[i][2]:
flag=False
chain=[]
if flag:
count+=1
max_count=max(count,max_count)
chain.append(i)
print(max_count)
print(count)
if __name__=="__main__":
main()
|
s074330234
|
Accepted
| 634 | 35,500 | 1,050 |
def main():
N,C=map(int,input().split())
stc=[0]*N
for i in range(N):
abc=list(map(int,input().split()))
stc[i]=abc
a=[0]*(C+1)
stc.sort(key=lambda x:(x[2],x[0]))
c=1
for i in range(N):
while stc[i][2]!=c:
c+=1
if stc[i][2]==c:
a[c]+=1
for i in range(1,C+1):
a[i]+=a[i-1]
table=[0]*(2*10**5+2)
for i in range(C):
for j in range(a[i],a[i+1]):
if j==a[i]:
table[stc[j][0]*2-1]+=1
table[stc[j][1]*2]-=1
else:
if stc[j-1][1]==stc[j][0]:
table[stc[j][0]*2]+=1
table[stc[j][1]*2]-=1
else:
table[stc[j][0]*2-1]+=1
table[stc[j][1]*2]-=1
M=0
for i in range(len(table)):
if 0<i:
table[i]+=table[i-1]
for i in range(len(table)):
if M<table[i]:
M=table[i]
print(M)
if __name__=="__main__":
main()
|
s440252706
|
p03067
|
u890638336
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 179 |
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.
|
ABC = input()
list_ABC=list(ABC)
A = list_ABC[1]
B = list_ABC[2]
C = list_ABC[3]
if A < C and C < B:
print('Yes')
elif B < C and C < A:
print('Yes')
else:
print('No')
|
s991549151
|
Accepted
| 17 | 3,060 | 205 |
ABC = input().split()
list_ABC = list(ABC)
A = int(list_ABC[0])
B = int(list_ABC[1])
C = int(list_ABC[2])
if A < C and C < B:
print('Yes')
elif B < C and C < A:
print('Yes')
else:
print('No')
|
s820679536
|
p03456
|
u163320134
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 109 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b=map(int,input().split())
num=a*1000+b
for i in range(350):
if i**2 == num:
print('Yes')
print('No')
|
s800700421
|
Accepted
| 17 | 2,940 | 159 |
a,b=map(int,input().split())
num=int(str(a)+str(b))
flag=False
for i in range(350):
if i**2 == num:
flag=True
if flag:
print('Yes')
else:
print('No')
|
s736122138
|
p02612
|
u772649753
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 8,968 | 40 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print((10000-N)//1000)
|
s237274687
|
Accepted
| 27 | 9,152 | 38 |
N = int(input())
print((10000-N)%1000)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.