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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s989563788 | p03721 | u780962115 | 2,000 | 262,144 | Wrong Answer | 436 | 22,656 | 304 | There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1โคiโคN), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2... | n,k=map(int,input().split())
lists=[0]*n
for i in range(n):
lists[i]=tuple(map(int,input().split()))
lists=sorted(lists,key=lambda x: x[0])
print(lists)
count=0
num=0
for j in range(n):
if count<k:
count+=lists[j][1]*lists[j][0]
else:
num+=lists[j][0]
break
print(num) | s493802989 | Accepted | 413 | 19,032 | 285 | n,k=map(int,input().split())
lists=[0]*n
for i in range(n):
lists[i]=tuple(map(int,input().split()))
lists=sorted(lists,key=lambda x: x[0])
count=0
num=0
for j in range(n):
if count<k:
count=count+lists[j][1]
num=lists[j][0]
else:
break
print(num) |
s265767979 | p03827 | u923279197 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 125 | You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x duri... | s=input()
a=[0]
for i in range(len(s)):
if s[i] =='I':
a.append(a[i]+1)
else:
a.append(a[i]-1)
print(max(a))
| s198477579 | Accepted | 17 | 2,940 | 141 | n=int(input())
s=input()
x=[0]
for i in range(n):
if s[i]=='I':
x.append(x[i]+1)
else:
x.append(x[i]-1)
print(max(x)) |
s218106141 | p03836 | u311379832 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 246 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | sx, sy, tx, ty = map(int, input().split())
xtmp = abs(sx - tx)
ytmp = abs(sy - ty)
ans = 'R' * xtmp
ans += 'U' * ytmp
tmp1 = ans
tmp1 = tmp1[-1: -len(ans) - 1: -1]
tmp2 = 'LU' + ans + 'RD'
tmp3 = 'RD' + tmp1 + 'LU'
print(ans + tmp1 + tmp2 + tmp3) | s429812895 | Accepted | 17 | 3,064 | 271 | sx, sy, tx, ty = map(int, input().split())
xtmp = abs(sx - tx)
ytmp = abs(sy - ty)
ans = 'U' * ytmp
ans += 'R' * xtmp
tmp1 = ans
tmp1 = tmp1.replace('R', 'L')
tmp1 = tmp1.replace('U', 'D')
tmp2 = 'LU' + ans + 'RD'
tmp3 = 'RD' + tmp1 + 'LU'
print(ans + tmp1 + tmp2 + tmp3) |
s563615089 | p03472 | u045408189 | 2,000 | 262,144 | Wrong Answer | 2,104 | 25,760 | 737 | You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, โฆ, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 โค i โค N), the monster receives a_i points of d... | import sys
n,h=map(int,input().split())
damage=[]
attack=0
count=0
flag=True
for i in range(n):
a,b=map(int,input().split())
damage.append([i,a,b])
throw=sorted(damage,key=lambda x:x[2],reverse=True)
swung=sorted(damage,key=lambda x:x[1],reverse=True)
swungmax=swung[0][1]
kirifuda=swung[0][2]
for i in range(n):... | s033151339 | Accepted | 376 | 11,316 | 388 | import math
n,h=map(int,input().split())
A=[]
B=[]
for i in range(n):
a,b=map(int,input().split())
A.append(a)
B.append(b)
A.sort(reverse=True)
B.sort(reverse=True)
amax=A[0]
while B[-1]<amax:
B.pop()
S=0
if sum(B)>=h:
for i in range(n):
S+=B[i]
if S>=h:
print(i+1)
... |
s630757670 | p02742 | u273038590 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 87 | We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the to... | h,w = map(int, input().split())
S=h*w
if S%2==0:
print(S/2)
else:
print(S//2+1) | s189275877 | Accepted | 17 | 2,940 | 120 | h,w = map(int, input().split())
S=h*w
if h==1 or w==1:
print(1)
elif S%2==0:
print(S//2)
else:
print(S//2+1) |
s009865015 | p03228 | u221285045 | 2,000 | 1,048,576 | Wrong Answer | 27 | 3,952 | 515 | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe... | from sys import stdin
import math
import re
import queue
input = stdin.readline
MOD = 1000000007
def solve():
A,B,K = map(int, input().split())
turn = 0
while K > 0:
if turn == 0:
if A%2 == 1:
A -= 1
B += A/2
A /= 2
turn ^= 1
... | s512227953 | Accepted | 26 | 3,952 | 566 | from sys import stdin
import math
import re
import queue
input = stdin.readline
MOD = 1000000007
def solve():
A,B,K = map(int, input().split())
turn = 0
while K > 0:
if turn == 0:
if A%2 == 1:
A -= 1
B += A/2
A /= 2
turn ^= 1
... |
s091059418 | p03162 | u483645888 | 2,000 | 1,048,576 | Wrong Answer | 421 | 3,060 | 157 | Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain... | n = int(input())
a, b, c = 0, 0, 0
for i in range(n):
x, y, z = map(int, input().split())
a, b, c = a+max(y,z), b+max(x,z), c+max(x,y)
print(max(a,b,c)) | s537369141 | Accepted | 386 | 3,060 | 157 | n = int(input())
a, b, c = 0, 0, 0
for i in range(n):
x, y, z = map(int, input().split())
a, b, c = x+max(b,c), y+max(a,c), z+max(a,b)
print(max(a,b,c)) |
s019291735 | p03657 | u177398299 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 99 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca... | a, b = map(int, input().split())
print('Impossible' if a % 3 or b % 3 or a + b % 3 else 'Possible') | s765526301 | Accepted | 17 | 2,940 | 103 | a, b = map(int, input().split())
print('Impossible' if a % 3 and b % 3 and (a + b) % 3 else 'Possible') |
s257371366 | p02419 | u198574985 | 1,000 | 131,072 | Wrong Answer | 20 | 5,540 | 73 | Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive. | W = str(input()).lower()
T = str(input()).lower() *2
print(T.count(W))
| s967278487 | Accepted | 20 | 5,560 | 306 | W = str(input()).lower()
table = []
count = 0
while True:
T = str(input())
if T == "END_OF_TEXT":
break
else:
T = T.lower().split()
for j in range(len(T)):
table.append(T[j])
for i in table:
if i == W:
count += 1
print(count)
|
s271820635 | p03836 | u153902122 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 181 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | sx, sy, tx, ty = map(int,input().split())
x,y=tx-sx,ty-sy
trail='U'*x + 'R'*y
trail+='D'*y + 'L'*x
trail+='L'+'U'*(x+1)+'R'*(y+1)+'D'
trail+='R'+'D'*(y+1)+'L'*(x+1)+'U'
print(trail) | s782249137 | Accepted | 17 | 3,060 | 181 | sx, sy, tx, ty = map(int,input().split())
x,y=tx-sx,ty-sy
trail='U'*y + 'R'*x
trail+='D'*y + 'L'*x
trail+='L'+'U'*(y+1)+'R'*(x+1)+'D'
trail+='R'+'D'*(y+1)+'L'*(x+1)+'U'
print(trail) |
s143728180 | p01554 | u078042885 | 2,000 | 131,072 | Wrong Answer | 20 | 7,652 | 183 | ใใ้จๅฑใงใฏICใซใผใใ็จใใฆ้ตใ้ใ้ใใใ้ปๅญ้ ใทในใใ ใ็จใใฆใใใ ใใฎใทในใใ ใฏไปฅไธใฎใใใซๅไฝใใใ ๅใฆใผใถใผใๆใคICใซใผใใๆใซใใใใจใใใฎICใซใผใใฎIDใใทในใใ ใซๆธกใใใใ ใทในใใ ใฏIDใ็ป้ฒใใใฆใใๆใๆฝ้ ใใใฆใใใชใ้้ ใใใใใงใชใใฎใชใๆฝ้ ใใใใใใใกใใปใผใธใๅบๅใใใใ IDใ็ป้ฒใใใฆใใชใๅ ดๅใฏใ็ป้ฒใใใฆใใชใใจใใใกใใปใผใธใๅบๅใใ้้ ๅใณๆฝ้ ใฏใใใชใใใชใใ ใใฆใ็พๅจใทในใใ ใซใฏNๅใฎID(U1, U2, โฆโฆ, UN)ใ็ป้ฒใใใฆใใใๆฝ้ ใใใฆใใใ MๅICใซใผใใๆใซใใใใใใใฎIDใฏใใใใ้ ็ชใซT1, T2, โฆโฆ, TMใงใใใจใใใ ใใฎๆใฎใทในใใ ... | k=[input() for _ in range(int(input()))]
a=1
for _ in range(int(input())):
b=input()
if b in k:print(('Opend' if a>0 else 'Closed')+' by '+b);a=~a
else:print('Unknown '+b) | s000462307 | Accepted | 20 | 7,752 | 177 | k=[input() for _ in range(int(input()))]
a=1
for _ in range(int(input())):
b=input()
if b in k:print(['Closed','Opened'][a>0]+' by '+b);a=~a
else:print('Unknown '+b) |
s510067653 | p03478 | u208844959 | 2,000 | 262,144 | Wrong Answer | 33 | 3,060 | 222 | Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). | N, A, B = map(int, input().split())
sm = 0
for i in range(1, N+1):
digit = str(i)
sm_t = 0
for d in digit:
sm_t += int(d)
if sm_t >= A:
if sm_t <= B:
sm += sm_t
print(sm) | s942196080 | Accepted | 34 | 3,060 | 207 | N, A, B = map(int, input().split())
sm = 0
for i in range(1, N+1):
digit = str(i)
sm_t = 0
for d in digit:
sm_t += int(d)
if sm_t >= A and sm_t <= B:
sm += i
print(sm) |
s792928038 | p03548 | u774729733 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 84 | We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two... | x,y,z=map(int,input().split())
ans=x//(y+z)
print(ans if ans*(y+z) < x-z else ans-1) | s173611838 | Accepted | 18 | 3,064 | 85 | x,y,z=map(int,input().split())
ans=x//(y+z)
print(ans if ans*(y+z)+z <= x else ans-1) |
s360614409 | p04030 | u820461302 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 174 | 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 stri... | # -*- coding: utf-8 -*-
S = input()
T = ''
for i in range(len(S)):
if S[i] == '0':
T += '0'
elif S[i] =='1':
T += '1 '
else:
T = T[:-1]
print(T) | s533248894 | Accepted | 17 | 2,940 | 186 | # -*- coding: utf-8 -*-
S = input()
T = ''
for i in range(len(S)):
if S[i] == '0':
T += '0'
elif S[i] == '1':
T += '1'
elif S[i] == 'B':
T = T[:-1]
print(T) |
s025580338 | p03605 | u772649753 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | x = input()
if x[0] == 9 or x[1] == 9:
print("Yes")
else:
print("No") | s427852177 | Accepted | 17 | 2,940 | 77 | x = input()
if x[0] == "9" or x[1] == "9":
print("Yes")
else:
print("No") |
s290094640 | p03814 | u299251530 | 2,000 | 262,144 | Wrong Answer | 52 | 3,816 | 249 | Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w... | s = input()
a_index = 0
z_index = 0
for i in range(0, len(s)):
if s[i] == "A":
a_index = i
break
for i in range(0, len(s)):
if s[len(s)-i-1] == "Z":
z_index = len(s)-i
break
print(s[a_index:z_index]) | s274000974 | Accepted | 52 | 3,516 | 254 | s = input()
a_index = 0
z_index = 0
for i in range(0, len(s)):
if s[i] == "A":
a_index = i
break
for i in range(0, len(s)):
if s[len(s)-i-1] == "Z":
z_index = len(s)-i-1
break
print(z_index - a_index +1)
|
s708122469 | p03371 | u146346223 | 2,000 | 262,144 | Wrong Answer | 119 | 3,060 | 172 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr... | a, b, c, x, y = map(int, input().split())
ans = 0
for m in range(max(x, y)+1):
price = (2*m*c) + max(0, (x-m))*a + max(0, y-m)*b
ans = min(ans, price)
print(ans) | s393455309 | Accepted | 118 | 3,060 | 170 | a, b, c, x, y=map(int,input().split())
cnt = 10**9
for m in range(max(x,y)+1):
price = (2*m*c) + max(0,(x-m))*a + max(0,y-m)*b
cnt = min(cnt, price)
print(cnt) |
s375816102 | p03229 | u172386990 | 2,000 | 1,048,576 | Wrong Answer | 412 | 9,440 | 1,371 | You are given N integers; the i-th of them is A_i. Find the maximum possible sum of the absolute differences between the adjacent elements after arranging these integers in a row in any order you like. | N = int(input())
num_list = []
for _ in range(N):
num_list.append(int(input()))
num_sorted = sorted(num_list)
def calc_diff(add, add2, diff, diff2, num_sorted):
total = 0
for _ in range(add2):
tmp = num_sorted.pop()
total += tmp * 2
for _ in range(add):
tmp =... | s264424277 | Accepted | 410 | 9,444 | 1,382 | N = int(input())
num_list = []
for _ in range(N):
num_list.append(int(input()))
num_sorted = sorted(num_list)
def calc_diff(add, add2, diff, diff2, num_sorted):
total = 0
for _ in range(add2):
tmp = num_sorted.pop()
total += tmp * 2
for _ in range(add):
tmp... |
s672408453 | p03470 | u024768467 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 114 | 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 h... | # -*- coding: utf-8 -*-
n=int(input())
d_list=list(map(int,input().split()))
d_set = set(d_list)
print(len(d_set)) | s674884923 | Accepted | 18 | 3,060 | 137 | n=int(input())
a_list=[input() for i in range(n)]
a_list_int = [int(n) for n in a_list]
a_set_int = set(a_list_int)
print(len(a_set_int)) |
s636008283 | p03435 | u452015170 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 258 | 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) ... | c = []
for _ in range(3) :
c += [list(map(int, input().split()))]
a1 = c[1][0]-c[0][0]
a2 = c[2][0]-c[0][0]
c1 = [c[0][i] + a1 for i in range(3)]
c2 = [c[0][i] + a2 for i in range(3)]
if c[1] == c1 and c[2] == c2 :
print("yes")
else :
print("no") | s176259920 | Accepted | 17 | 3,064 | 258 | c = []
for _ in range(3) :
c += [list(map(int, input().split()))]
a1 = c[1][0]-c[0][0]
a2 = c[2][0]-c[0][0]
c1 = [c[0][i] + a1 for i in range(3)]
c2 = [c[0][i] + a2 for i in range(3)]
if c[1] == c1 and c[2] == c2 :
print("Yes")
else :
print("No") |
s843338876 | p03795 | u976225138 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ... | n = int(input())
print(800 * n - (n // 15) ** 200) | s395157774 | Accepted | 17 | 2,940 | 49 | n = int(input())
print(800 * n - 200 * (n // 15)) |
s797930758 | p03068 | u398610336 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 142 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | N = int(input())
S = list(input())
K = int(input())
a = S[K-1]
print(a)
for i in range(N):
if S[i]!=a:
S[i] = '*'
print(*S,sep='') | s676371703 | Accepted | 17 | 2,940 | 133 | N = int(input())
S = list(input())
K = int(input())
a = S[K-1]
for i in range(N):
if S[i]!=a:
S[i] = '*'
print(*S,sep='') |
s971025147 | p03090 | u404459933 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,188 | 796 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | def find(N):
k=N//2
edges=[]
if N==2*k:
for i in range(1,k):
edges+=[(i,N-i)]
edges+=[(i,i+1)]
edges+=[(N+1-i,i+1)]
edges+=[(N+1-i,N-i)]
edges+=[(k,1)]
edges+=[(k,N)]
edges+=[(k+1,1)]
edges+=[(k+1,N)]
edges=set(e... | s159812119 | Accepted | 18 | 3,188 | 1,023 | def find(N):
if N==3:
print(2)
print(1,3)
print(2,3)
return 0
if N==4:
print(4)
print(1,2)
print(2,4)
print(3,4)
print(1,3)
return 0
k=N//2
edges=[]
if N==2*k:
for i in range(1,k):
... |
s320069820 | p03659 | u010110540 | 2,000 | 262,144 | Wrong Answer | 166 | 23,800 | 215 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | import math as ma
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
A = 0
diff = 9999999999
for i in range(N):
A += a[i]
if diff > (ma.fabs(2*A - s)):
diff = ma.fabs(2*A -s)
print(diff) | s325101134 | Accepted | 171 | 23,800 | 222 | import math as ma
N = int(input())
a = list(map(int, input().split()))
s = sum(a)
A = 0
diff = 9999999999
for i in range(N-1):
A += a[i]
if diff > (ma.fabs(2*A - s)):
diff = ma.fabs(2*A -s)
print(int(diff)) |
s452387556 | p03371 | u886297662 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,060 | 253 | "Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the curr... | A, B, C, X, Y = map(int, input().split())
min = A * X + B * Y
for x in range(X+1):
for y in range(Y+1):
if x <= y:
z = 2 * (X - x)
else:
z = 2 * (Y - y)
Sum = A * x + B * y + C * z
if Sum < min:
min = Sum
print(Sum) | s202865035 | Accepted | 18 | 3,064 | 312 | A, B, C, X, Y = map(int, input().split())
Sum = A * X + B * Y
if A+B > 2*C:
if X < Y:
if 2*C <= B:
Sum = C * 2 * Y
else:
Sum = C * 2 * X + B * (Y - X)
elif Y < X:
if 2*C <= A:
Sum = C * 2 * X
else:
Sum = C * 2 * Y + A * (X - Y)
else:
Sum = C * 2 * X
print(Sum) |
s098743098 | p04031 | u786020649 | 2,000 | 262,144 | Wrong Answer | 29 | 9,060 | 153 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (iโ j), he has to pay the cost separately for transforming each of them (... | n=int(input())
integers=list(map(int,input().split()))
sql=[x*2 for x in integers]
s=sum(integers)
t=sum(sql)
m=min(s%n, n-s%n)
print((m**2-s**2)//n+t) | s051144011 | Accepted | 27 | 9,120 | 156 | n=int(input())
integers=list(map(int,input().split()))
sql=[x**2 for x in integers]
s=sum(integers)
t=sum(sql)
m=min(s%n, n-s%n)
print((m**2-s**2)//n+t) |
s327871528 | p03090 | u393481615 | 2,000 | 1,048,576 | Wrong Answer | 28 | 3,828 | 445 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | N = int(input())
bridge = []
for i in range(1, N):
for j in range(i + 1, N + 1):
if(N % 2 == 0):
if(i + j == N + 1):
print("skip = [{}, {}]".format(i,j))
continue
else:
if(i + j == N):
print("skip = [{}, {}]".format(i,j))
... | s138455681 | Accepted | 28 | 3,828 | 447 | N = int(input())
bridge = []
for i in range(1, N):
for j in range(i + 1, N + 1):
if(N % 2 == 0):
if(i + j == N + 1):
# print("skip = [{}, {}]".format(i,j))
continue
else:
if(i + j == N):
# print("skip = [{}, {}]".format(i,j))
... |
s428904567 | p03693 | u639592190 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 61 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | print("YES" if eval(input().replace(" ","+"))%4==0 else "NO") | s746572384 | Accepted | 17 | 2,940 | 60 | print("YES" if eval(input().replace(" ",""))%4==0 else "NO") |
s631626727 | p03408 | u571445182 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 473 | Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea... |
nN = int(input())
sListA = []
nListA = [ 0 for i in range(nN)]
for i in range(nN):
sTmp = input()
if sTmp in sListA:
nTmp = sListA.index(sTmp)
nListA[nTmp] += 1
else:
sListA.append(sTmp)
nTmp = sListA.index(sTmp)
nListA[nTmp] += 1
nN = int(input())
sListB = []
nListB = [ 0 for i in ra... | s516644310 | Accepted | 18 | 3,064 | 578 | nN = int(input())
sListA = []
nListA = [ 0 for i in range(202)]
for i in range(nN):
sTmp = input()
if sTmp in sListA:
nTmp = sListA.index(sTmp)
nListA[nTmp] += 1
else:
sListA.append(sTmp)
nTmp = sListA.index(sTmp)
nListA[nTmp] += 1
nN = int(input())
sListB = []
nListB = [ 0 for i in... |
s819639048 | p02612 | u960080897 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,136 | 56 | 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())
while n >= 1000:
n -= 1000
print(n) | s584891427 | Accepted | 31 | 9,148 | 80 | n = int(input())
while n >= 1000:
n -= 1000
if n != 0:
n=1000-n
print(n) |
s645370729 | p02854 | u411858517 | 2,000 | 1,048,576 | Wrong Answer | 236 | 26,396 | 242 | Takahashi, who works at DISCO, is standing before an iron bar. The bar has N-1 notches, which divide the bar into N sections. The i-th section from the left has a length of A_i millimeters. Takahashi wanted to choose a notch and cut the bar at that point into two parts with the same length. However, this may not be po... | N = int(input())
A = list(map(int, input().split()))
tmp = [0 for i in range(N+1)]
length = 0
for i in range(N):
tmp[i+1] = tmp[i] + A[i]
length += A[i]
ans = 0
for i in range(1, N+1):
ans = min(ans, abs(length - tmp[i]))
print(ans) | s577634191 | Accepted | 247 | 26,220 | 261 | N = int(input())
A = list(map(int, input().split()))
tmp = [0 for i in range(N+1)]
length = 0
for i in range(N):
tmp[i+1] = tmp[i] + A[i]
length += A[i]
ans = 10 ** 10
for i in range(1, N+1):
ans = min(ans, abs((length - tmp[i]) - tmp[i]))
print(ans)
|
s662555934 | p03575 | u846101221 | 2,000 | 262,144 | Wrong Answer | 24 | 3,064 | 1,120 | You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ... | n , m = map(int, input().split())
combis = [set(list(map(int, input().split()))) for i in range(m)]
count = 0
for i in range(m):
combis_x = combis[0:i] + combis[i+1:m]
islands = []
for combi in combis_x:
# init
if not islands:
islands.append(combi)
continue
# ... | s342077502 | Accepted | 24 | 3,064 | 1,111 | n , m = map(int, input().split())
combis = [set(list(map(int, input().split()))) for i in range(m)]
count = 0
for i in range(m):
combis_x = combis[0:i] + combis[i+1:m]
islands = []
for combi in combis_x:
# init
if not islands:
islands.append(combi)
continue
# ... |
s188936912 | p03142 | u777923818 | 2,000 | 1,048,576 | Wrong Answer | 507 | 34,408 | 269 | There is a rooted tree (see Notes) with N vertices numbered 1 to N. Each of the vertices, except the root, has a directed edge coming from its parent. Note that the root may not be Vertex 1. Takahashi has added M new directed edges to this graph. Each of these M edges, u \rightarrow v, extends from some vertex u to it... | from heapq import heappop, heappush
def inpl(): return list(map(int, input().split()))
N, M = inpl()
G = {i:[] for i in range(N)}
X = [0]*(N)
searched = [0]*(N)
for _ in range(N-1+M):
a, b = inpl()
G[a-1].append(b-1)
X[b-1] += 1
if min(X) != 0:
raise | s669902244 | Accepted | 909 | 59,700 | 610 | from collections import deque
def inpl(): return list(map(int, input().split()))
N, M = inpl()
G = {i:[] for i in range(N)}
rG = {i: [] for i in range(N)}
X = [0]*(N)
searched = [0]*(N)
for _ in range(N-1+M):
a, b = inpl()
G[a-1].append(b-1)
rG[b-1].append(a-1)
X[b-1] += 1
q = X.index(0)
T = [0]*N
Q ... |
s170699691 | p02271 | u255317651 | 5,000 | 131,072 | Wrong Answer | 30 | 5,652 | 682 | Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_. | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
for i in m:
yesorno = False
b = []
for j in a:
if j < i:
b.app... | s521474628 | Accepted | 740 | 47,160 | 724 | # -*- coding: utf-8 -*-
"""
Created on Wed May 2 21:28:06 2018
ALDS1_5a_r1
@author: maezawa
"""
import itertools as itr
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
sum_array = []
for r in range(1,n+1):
for comb in itr.combinations(a, r):
sum... |
s855989876 | p02646 | u406405116 | 2,000 | 1,048,576 | Wrong Answer | 25 | 9,192 | 203 | Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch ... | a, v = input().split(' ')
a = int(a)
v = int(v)
b, u = input().split(' ')
b = int(b)
u = int(u)
t = int(input())
if v < u:
print('No')
elif a + v * t >= b + u * t :
print('Yes')
else:
print('No') | s596867837 | Accepted | 24 | 9,208 | 243 | a, v = input().split(' ')
a = int(a)
v = int(v)
b, u = input().split(' ')
b = int(b)
u = int(u)
t = int(input())
if a <= b and a + v * t >= b + u * t :
print('YES')
elif a > b and a - v * t <= b - u * t :
print('YES')
else:
print('NO') |
s241373740 | p03759 | u612636296 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 92 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a,b,c = map(int, input().split())
if b - a == c - b:
print("Yes")
else:
print("No")
| s303567002 | Accepted | 17 | 2,940 | 92 | a,b,c = map(int, input().split())
if b - a == c - b:
print("YES")
else:
print("NO")
|
s381432363 | p03473 | u581187895 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 33 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | N = int(input())
print(N%24 + 24) | s232851463 | Accepted | 19 | 3,060 | 31 | N = int(input())
print(24-N+24) |
s247992218 | p02602 | u413369061 | 2,000 | 1,048,576 | Wrong Answer | 154 | 31,540 | 166 | M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the m... | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(k, n):
if a[i]>a[i-k]:
print('Yes')
else:
print("N0") | s293967426 | Accepted | 152 | 31,604 | 166 | n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
for i in range(k, n):
if a[i]>a[i-k]:
print('Yes')
else:
print("No") |
s844774413 | p02422 | u400765446 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 957 | Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-t... | def main():
strTxt = input()
n = int(input())
for _ in range(n):
strCmd = input().split()
if strCmd[0] == 'print':
funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))
elif strCmd[0] == 'reverse':
strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[... | s917513200 | Accepted | 20 | 5,616 | 371 | str = input()
n = int(input())
for _ in range(n):
cmd = list(input().split())
command, a, b = cmd[0], int(cmd[1]), int(cmd[2])
if command == 'replace':
str = str[:a] + cmd[3] + str[b+1:]
elif command == 'reverse':
str = str[:a] + str[a:b+1][::-1] + str[b+1:]
elif command == 'print':... |
s850189528 | p03679 | u769411997 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 142 | Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Ot... | x, a, b = map(int, input().split())
if a-b > 0:
print("delicious")
elif b > x+a:
print("dangerous")
elif b <= x:
print("safe")
| s494039568 | Accepted | 17 | 2,940 | 160 | x, a, b = map(int, input().split())
if a-b >= 0:
print("delicious")
if a-b < 0:
if b-a <= x:
print('safe')
if b > x+a:
print("dangerous")
|
s559092888 | p03944 | u263830634 | 2,000 | 262,144 | Wrong Answer | 150 | 12,504 | 337 | There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 โฆ i โฆ N) po... | import numpy as np
W, H, N = map(int, input().split())
g = np.array([[1] * W for _ in range(H)])
for _ in range(N):
x, y, a = map(int, input().split())
if a == 1:
g[:,:x] = 0
elif a == 2:
g[:,x:] = 0
elif a == 3:
g[H - y - 1:,:] = 0
elif a == 4:
g[:H - y - 1,:] = 0
... | s519161899 | Accepted | 68 | 3,064 | 634 | W, H, N = map(int, input().split())
G = [[1] * H for _ in range(W)]
for _ in range(N):
x, y, a = map(int, input().split())
if a == 1:
for x_ in range(x):
for y_ in range(H):
G[x_][y_] = 0
if a == 2:
for x_ in range(x, W):
for y_ in range(H):
... |
s019097777 | p03860 | u641722141 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 53 | Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppe... | a,b,c = input().split()
print(a[0],b[0],c[0],end ='') | s233431562 | Accepted | 18 | 2,940 | 29 | print('A' + input()[8] + 'C') |
s354381852 | p02844 | u861471387 | 2,000 | 1,048,576 | Wrong Answer | 22 | 3,572 | 294 | AtCoder Inc. has decided to lock the door of its office with a 3-digit PIN code. The company has an N-digit lucky number, S. Takahashi, the president, will erase N-3 digits from S and concatenate the remaining 3 digits without changing the order to set the PIN code. How many different PIN codes can he set this way? ... | N=int(input())
S=input()
ans=0
for i in range(10):
if str(i) in S:
a = S.find(str(i))
for j in range(10):
if str(j) in S[a+1:]:
b = S[a+1:].find(str(j))
for k in range(10):
if str(k) in S[a+b+2:]:
ans+=1
print(i,j,k)
print(ans) | s329131236 | Accepted | 20 | 3,064 | 269 | N=int(input())
S=input()
ans=0
for i in range(10):
if str(i) in S:
a = S.find(str(i))
for j in range(10):
if str(j) in S[a+1:]:
b = S[a+1:].find(str(j))
for k in range(10):
if str(k) in S[a+b+2:]:
ans+=1
print(ans) |
s153399012 | p03494 | u922172470 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 275 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | def resolve():
n = int(input())
arr = (int(x) for x in input().split())
res = 0
while True:
even = list(filter(lambda x: x%2 == 0, arr))
if len(even) > 0:
res += 1
else:
print(res)
return
resolve() | s110825059 | Accepted | 20 | 3,060 | 353 | def resolve():
n = int(input())
arr = list(map(int, input().split()))
res = 0
while True:
exist_odd = False
for num in arr:
if num % 2 != 0:
exist_odd = True
if exist_odd:
break
arr = list(map(lambda x: int(x/2), arr))
re... |
s173257606 | p03795 | u449555432 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 29 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant ... | print(int(input())*(2440//3)) | s779976888 | Accepted | 17 | 3,068 | 39 | a=int(input())
print(800*a-200*(a//15)) |
s685250987 | p03963 | u020390084 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 50 | There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls. | N,K = map(int,input().split())
print(K*(K-1)**N-1) | s062278396 | Accepted | 17 | 2,940 | 53 | N,K = map(int,input().split())
print(K*(K-1)**(N-1))
|
s870898434 | p03798 | u858742833 | 2,000 | 262,144 | Wrong Answer | 80 | 10,456 | 431 | Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2โคiโคN-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered... | def main():
N = int(input())
S = input()
M = [{'o': 0, 'x': 1}, {'o': 1, 'x': 0}]
for s1, sn in [(0, 0), (0, 1), (1, 0), (1, 1)]:
T = [s1]
p, pp = s1, sn
for s in S:
pp, p = p, M[p ^ pp][s]
T.append(p)
if (s1, sn) == (p, pp):
return T
... | s674067351 | Accepted | 81 | 10,488 | 436 | def main():
N = int(input())
S = input()
M = [{'o': 0, 'x': 1}, {'o': 1, 'x': 0}]
for s1, sn in [(0, 0), (0, 1), (1, 0), (1, 1)]:
T = [s1]
p, pp = s1, sn
for s in S:
pp, p = p, M[p ^ pp][s]
T.append(p)
if (s1, sn) == (p, pp):
return T[:... |
s906077149 | p02407 | u539753516 | 1,000 | 131,072 | Wrong Answer | 20 | 5,572 | 56 | Write a program which reads a sequence and prints it in the reverse order. | a=list(map(int, input().split()))
a.reverse()
print(*a)
| s175898051 | Accepted | 20 | 5,584 | 64 | input()
a=list(map(int, input().split()))
a.reverse()
print(*a)
|
s539503631 | p03997 | u607563136 | 2,000 | 262,144 | Wrong Answer | 30 | 9,040 | 81 | 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())
ans = (a+b)*h / 2
print(ans) | s613316174 | Accepted | 26 | 9,112 | 86 | a = int(input())
b = int(input())
h = int(input())
ans = (a+b)*h / 2
print(int(ans)) |
s973321780 | p03385 | u317711717 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | import math
a=input()
a=sorted(a)
print("Yes" if a=="abs" else "No")
| s518337759 | Accepted | 17 | 2,940 | 78 | import math
a=input()
a=sorted(a)
print("Yes" if a==["a","b","c"] else "No")
|
s857899061 | p03737 | u115877451 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | a,b,c=map(str,input().split())
print(a[0],b[0],c[0],sep='')
| s851554931 | Accepted | 17 | 2,940 | 70 | a,b,c=map(str,input().split())
d=str(a[0]+b[0]+c[0])
print(d.upper())
|
s636196322 | p02608 | u822044226 | 2,000 | 1,048,576 | Time Limit Exceeded | 2,206 | 8,880 | 208 | Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N). | N = int(input())
for x in range(1,N+1):
cnt = 0
for i in range(1,100):
for j in range(1,100):
for k in range(1,100):
if (i+j+k)**2-(i*j+i*k+j*k) == x:
cnt += 1
print(cnt) | s093651186 | Accepted | 661 | 9,236 | 229 | N = int(input())
ans = [0]*10050
for i in range(1,105):
for j in range(1,105):
for k in range(1,105):
v = (i+j+k)**2-(i*j+i*k+j*k)
if v < len(ans):
ans[v] += 1
for x in range(1,N+1):
print(ans[x]) |
s428758873 | p03711 | u256281774 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 925 | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 โค x < y โค 12), determine whether they belong to the same group. |
H,W=[int(x) for x in input().split()]
if(H%3==0 or W%3==0):
print(0)
if(H>W):
min_dif=W
else:
min_dif=H
if(H%2!=0):
for i in range(W-1):
A=(i+1)*H
B=(W-(i+1))*int(H/2)
C=H*W-A-B
D=[A,B,C]
D.sort()
if(min_dif>abs(D[0]-D[2])):
min_dif=abs(D... | s221902431 | Accepted | 17 | 3,060 | 135 | S=[0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]
a,b=[int(x) for x in input().split()]
if(S[a-1]==S[b-1]):
print("Yes")
else:
print("No") |
s288326111 | p03550 | u113971909 | 2,000 | 262,144 | Wrong Answer | 27 | 9,272 | 145 | We have a deck consisting of N cards. Each card has an integer written on it. The integer on the i-th card from the top is a_i. Two people X and Y will play a game using this deck. Initially, X has a card with Z written on it in his hand, and Y has a card with W written on it in his hand. Then, starting from X, they w... | n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
print(abs(w-a[-1]))
else:
print(max(w-a[-1], a[-1]-a[-2])) | s737805679 | Accepted | 30 | 9,264 | 155 | n, z, w = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
print(abs(w-a[-1]))
else:
print(max(abs(w-a[-1]), abs(a[-1]-a[-2]))) |
s970465229 | p03605 | u374146618 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 78 | It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? | n = input()
if (n[0]==9) or (n[1]==9):
print("Yes")
else:
print("No")
| s728163540 | Accepted | 17 | 2,940 | 82 | n = input()
if (n[0]=="9") or (n[1]=="9"):
print("Yes")
else:
print("No")
|
s299614951 | p03971 | u198930868 | 2,000 | 262,144 | Wrong Answer | 106 | 4,016 | 294 | 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 t... | i = list(map(int,input().split()))
person = i[1] + i[2]
B = i[2]
rank = input()
passp = 0
bp = 0
for i,r in enumerate(rank):
if r == "a" and passp < person:
print("Yes")
passp += 1
elif r == "b":
bp += 1
if passp < person and bp <=B:
print("Yes")
passp += 1
else:
print("No") | s710879935 | Accepted | 103 | 4,016 | 318 | N,A,B = map(int,input().split())
student = input()
passp = 0
passb = 0
ab = (A+B)
for s in student:
if s == "a":
if passp < ab:
passp += 1
print("Yes")
else:
print("No")
elif s == "b":
if passp < ab and passb < B:
passp += 1
passb += 1
print("Yes")
else:
print("No")
else:
print("No") |
s312230863 | p02279 | u007270338 | 2,000 | 131,072 | Wrong Answer | 20 | 5,600 | 693 | A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one... | #coding:utf-8
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
ID = 0
parent = -1
depth = 0
sect = data[0][2:]
print("note {}: parent = {}, depth = {}, root, {}".format(ID, parent, depth, sect))
parent = 0
depth = 1
def rootedTrees(ID, parent, depth):
if data[ID][1] == 0:
sect =... | s438633204 | Accepted | 1,970 | 43,528 | 1,528 | #coding:utf-8
n = int(input())
T = [list(map(int, input().split())) for i in range(n)]
A = []
def parentSearch():
numList = []
for t in T:
if t[1] != 0:
for num in t[2:]:
numList.append(num)
numList.sort()
for i in range(n-1):
if numList[i] != i:
... |
s448839678 | p01143 | u128811851 | 8,000 | 131,072 | Wrong Answer | 60 | 6,816 | 392 | English text is not available in this practice contest. ใใ่ฒงไนใชๅฝใฎใใฆใใฐใงๅๆขใชใๅงซๆงใฏ๏ผใใๆฅ้จๅฑใฎๅฃใๅฃใใฆใๅใๆใๅบใ๏ผ็ซถ้ฆฌใชใฉใฎใฎใฃใณใใซใ่กใใใฆใใ่ณญๅๅ ดใซๅ
ฅใฃใฆใใฃใ๏ผใจใใใ๏ผใฎใฃใณใใซใชใฉใใฃใใใจใฎใชใใๅงซๆงใฏ๏ผ้ๅธธใซ่ฒ ใใ่พผใใงใใพใฃใ๏ผใใฎ็ถๆณใใใใใใใชใใจๆใฃใใๅงซๆงใฏ๏ผไธไฝใฉใฎใใใชไป็ตใฟใงใฎใฃใณใใซใ่กใใใฆใใใใ่ชฟในใฆใฟใ๏ผใใใจ๏ผใใฎใใใชใฎใฃใณใใซใงใฏใใชใใฅใใฅใจใซๆนๅผใจๅผใฐใใๆนๅผใง้
ๅฝใๆฑบๅฎใใใฆใใใใจใ็ชใๆญขใใ๏ผ ใใชใใฅใใฅใจใซๆนๅผใจใฏ๏ผ็ซถ่ตฐใๅฏพ่ฑกใจใใใฎใฃใณใใซใซใใใฆ้
ๅฝใๆฑบๅฎใใใใใซไฝฟ็จใใ่จ็ฎๆนๆณใงใ... | #!/usr/bin/python
# -*- coding: utf-8 -*-
import math
while True:
amount, number, per = map(int, input().split())
if amount == 0 and number == 0 and per == 0:
break
vote = []
for i in range(amount):
vote.append(int(input()))
if vote[number-1] == 0:
print("0")
else:
... | s122714631 | Accepted | 50 | 6,816 | 369 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import math
while True:
amount, number, per = map(int, input().split())
if amount == 0 and number == 0 and per == 0:
break
vote = [int(input()) for _ in range(amount)]
if vote[number-1] == 0:
print("0")
else:
print(math.floor(100 *... |
s310870598 | p02420 | u455877373 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 106 | Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the las... | s=input()
for _ in range(int(input())):
a=int(input())
s=s[a:]+s[:a]
print(s)
| s465056409 | Accepted | 20 | 5,596 | 155 | while 1:
s=input()
if len(s)==1:break
for _ in range(int(input())):
a=int(input())
s=s[a:]+s[:a]
print(s)
|
s465524158 | p02731 | u693134887 | 2,000 | 1,048,576 | Wrong Answer | 310 | 2,940 | 252 | Given is a positive integer L. Find the maximum possible volume of a rectangular cuboid whose sum of the dimensions (not necessarily integers) is L. | def maxvolume (s):
maxvalue = 0
i = 1
for i in range(s - 1):
j = 1
for j in range(s):
k = s - i - j
maxvalue = max(maxvalue, i * j * k)
return maxvalue
n = int(input())
print(maxvolume(n))
| s024306422 | Accepted | 17 | 2,940 | 201 | def maxvolume(s):
length = s / 3
s -= length
breadth = s / 2
height = s - breadth
return "{:.12f}".format(length * breadth * height)
s = int(input())
print(maxvolume(s)) |
s979156823 | p03386 | u882831132 | 2,000 | 262,144 | Wrong Answer | 2,103 | 25,680 | 195 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | A, B, K = (int(x) for x in input().split())
if (A - B) // 2 >= K:
for x in range(A, A + K):
print(x)
for x in range(B-K+1, B+1):
print(x)
else:
for x in range(A, B+1):
print(x)
| s525743419 | Accepted | 18 | 3,060 | 194 | A, B, K = (int(x) for x in input().split())
if (B - A) / 2 >= K:
for x in range(A, A + K):
print(x)
for x in range(B-K+1, B+1):
print(x)
else:
for x in range(A, B+1):
print(x)
|
s914884709 | p02389 | u500396695 | 1,000 | 131,072 | Wrong Answer | 20 | 7,400 | 81 | Write a program which calculates the area and perimeter of a given rectangle. | a, b = [float(i) for i in input().split()]
s = a * b
l = (a + b) * 2
print (s, l) | s585284256 | Accepted | 40 | 7,692 | 78 | a, b = [int(i) for i in input().split()]
s = a * b
l = (a + b) * 2
print(s, l) |
s370325495 | p03719 | u322354465 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | 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())
if a <= c <= b:
print("YES")
else:
print("NO") | s970405123 | Accepted | 19 | 2,940 | 91 | a, b, c = map(int, input().split())
if a <= c <= b:
print("Yes")
else:
print("No") |
s169906094 | p03131 | u371467115 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 168 | Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the ... | k,a,b=map(int,input().split())
if k-(a-1)>=2 and b-a>=2:
if k-(a-1)%2==0:
print(a+(b-a)*(k-(a-1)//2))
else:
print(a+1+(b-a)*(k-(a-1)//2))
else:
print(k+1) | s201323792 | Accepted | 18 | 2,940 | 141 | k, a, b = map(int, input().split())
if k <= a or a+2 >= b:
print(k+1)
else:
u = k - (a-1)
print(a + (u//2) * (b-a) + u%2)
#copy code
|
s085067854 | p03693 | u277802731 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | #64a
r,g,b = map(int,input().split())
print('YES' if g*b%4==0 else 'NO') | s049830778 | Accepted | 17 | 2,940 | 78 | #64a
r,g,b = input().split()
ans = g+b
print('YES' if int(ans)%4==0 else 'NO') |
s398864094 | p03455 | u003928116 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 83 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b= map(int, input().split())
if a*b%2 == 1:
print("Odd")
else:
print("Enen") | s279115144 | Accepted | 18 | 2,940 | 83 | a, b= map(int, input().split())
if a*b%2 == 1:
print("Odd")
else:
print("Even") |
s144012777 | p03149 | u434822333 | 2,000 | 1,048,576 | Wrong Answer | 21 | 3,316 | 110 | 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 = list(map(int, input().split()))
if 1 in n and 9 in n and 7 in n and 4 in n: print('Yes')
else: print('No') | s160849463 | Accepted | 17 | 2,940 | 110 | n = list(map(int, input().split()))
if 1 in n and 9 in n and 7 in n and 4 in n: print('YES')
else: print('NO') |
s416188137 | p03068 | u868767877 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,060 | 178 | You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`. | N = int(input())
S = input()
K = int(input())
cha = S[K-1]
list_ = [s for s in S]
print(len(list_))
for i in range(N):
if cha != S[i]:
list_[i] = "*"
print("".join(list_)) | s917665424 | Accepted | 17 | 2,940 | 162 | N = int(input())
S = input()
K = int(input())
cha = S[K-1]
list_ = [s for s in S]
for i in range(N):
if cha != S[i]:
list_[i] = "*"
print("".join(list_))
|
s046864833 | p03470 | u549161102 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 68 | 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 h... | N = int(input())
for i in range(N):
l = input()
print(len(set(l))) | s330655025 | Accepted | 17 | 2,940 | 67 | N = int(input())
l = [input() for i in range(N)]
print(len(set(l))) |
s734862628 | p03713 | u987164499 | 2,000 | 262,144 | Wrong Answer | 447 | 3,064 | 437 | There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying... | h,w = map(int,input().split())
ans = 10**10
def menseki(h,w):
global ans
for i in range(1,h):
haba = w//2
ans = min(ans,max(i*w,haba*(h-i),(w-haba)*(h-i))-min(i*w,haba*(h-i),(w-haba)*(h-i)))
if h-i == 1:
continue
tate = (h-i)//2
ans = min(an... | s514154308 | Accepted | 451 | 3,064 | 441 | h,w = map(int,input().split())
ans = 10**10
def menseki(h,w):
global ans
for i in range(1,h):
haba = w//2
ans = min(ans,max(i*w,haba*(h-i),(w-haba)*(h-i))-min(i*w,haba*(h-i),(w-haba)*(h-i)))
if i == h-1:
continue
tate = (h-i)//2
ans = min(an... |
s664575434 | p03845 | u357751375 | 2,000 | 262,144 | Wrong Answer | 30 | 8,916 | 268 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1โฆiโฆN). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes d... | n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
a,b = map(int,input().split())
p.append(a)
x.append(b)
for i in range(m):
print(t)
s = list(t)
j = p[i] - 1
s[j] = x[i]
print(sum(s)) | s515591190 | Accepted | 29 | 9,192 | 242 | n = int(input())
t = list(map(int,input().split()))
m = int(input())
l = [list(map(int,input().split())) for i in range(m)]
a,b = [list(i) for i in zip(*l)]
for i in range(m):
s = list(t)
j = a[i] - 1
s[j] = b[i]
print(sum(s)) |
s952375146 | p03563 | u429029348 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 48 | Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the cont... | r=int(input())
g=int(input())
ans=g-r
print(ans) | s532180947 | Accepted | 17 | 2,940 | 50 | r=int(input())
g=int(input())
ans=2*g-r
print(ans) |
s112487024 | p03814 | u970809473 | 2,000 | 262,144 | Wrong Answer | 59 | 3,516 | 194 | Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w... | s = input()
ans = 0
flg = 0
for i in range(len(s)):
if s[i] == 'A' and flg == 0:
ans += 1
elif flg == 1 and s[i] == 'Z':
flg = 2
ans += 1
elif flg == 1:
ans += 1
print(ans) | s078823960 | Accepted | 98 | 3,516 | 306 | s = input()
ans = 0
tmp = 0
flg = 0
for i in range(len(s)):
if s[i] == 'A' and flg == 0:
ans += 1
flg = 1
elif flg == 1 and s[i] == 'Z':
flg = 2
ans += 1
elif flg == 1:
ans += 1
elif flg == 2 and s[i] == 'Z':
ans += tmp+1
tmp = 0
elif flg == 2:
tmp += 1
print(ans) |
s227498586 | p03693 | u940102677 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 87 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | r, g, b = map(int, input().split())
if 2*g + b == 0:
print('YES')
else:
print('NO') | s371950306 | Accepted | 17 | 2,940 | 91 | r, g, b = map(int, input().split())
if (2*g + b)%4 == 0:
print('YES')
else:
print('NO') |
s090078796 | p02663 | u882869256 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,200 | 145 | In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying? | a=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
b=(a[1]*60)+a[2]
c=(a[2]*60)+a[3]
print(c-b+a[4]) | s249431800 | Accepted | 23 | 9,204 | 147 | a=input().split(' ')
a[0]=int(a[0])
a[1]=int(a[1])
a[2]=int(a[2])
a[3]=int(a[3])
a[4]=int(a[4])
b=(a[0]*60)+a[1]
c=(a[2]*60)+a[3]
print((c-b)-a[4]) |
s363693124 | p03845 | u870518235 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 328 | Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1โฆiโฆN). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes d... | #Beginner 050 B
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [input() for _ in range(M)]
print(PX)
for _ in range(M):
PX[_] = list(map(int, PX[_].split()))
print(PX)
lst = []
for i in range(M):
lst.append(sum(T) - T[PX[i][0]-1] + PX[i][1])
print(lst)
for j in range(M):
print... | s098609642 | Accepted | 17 | 3,064 | 297 | #Beginner 050 B
N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [input() for _ in range(M)]
for _ in range(M):
PX[_] = list(map(int, PX[_].split()))
lst = []
for i in range(M):
lst.append(sum(T) - T[PX[i][0]-1] + PX[i][1])
for j in range(M):
print(lst[j]) |
s225694023 | p03048 | u531579566 | 2,000 | 1,048,576 | Wrong Answer | 1,582 | 3,060 | 201 | Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g... | n = list(map(int, input().split()))
rmax = int(n[3] / n[0])
ans = 0
for i in range(0, rmax+1):
sum = i * n[0]
while sum <= n[3]:
if sum % n[2] == 0:
ans += 1
sum += n[1]
print(ans) | s554744961 | Accepted | 1,603 | 3,060 | 219 | n = list(map(int, input().split()))
rmax = int(n[3] / n[0])
ans = 0
k = n[3] % n[2]
for i in range(0, rmax+1):
sum = i * n[0]
while sum <= n[3]:
if sum % n[2] == k:
ans += 1
sum += n[1]
print(ans)
|
s387652665 | p02422 | u777299405 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 322 | Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-t... | s = input()
q = int(input())
for i in range(q):
command = input().split()
a, b = int(command[1]), int(command[2]) + 1
if command[0] == "print":
print(s[a:b])
elif command[0] == "reverse":
s = s[:a] + s[a:b:-1] + s[b:]
elif command[0] == "replace":
s = s[:a] + command[3] + s[b... | s848272659 | Accepted | 40 | 6,724 | 325 | s = input()
q = int(input())
for i in range(q):
command = input().split()
a, b = int(command[1]), int(command[2]) + 1
if command[0] == "print":
print(s[a:b])
elif command[0] == "reverse":
s = s[:a] + s[a:b][::-1] + s[b:]
elif command[0] == "replace":
s = s[:a] + command[3] + ... |
s037540886 | p04031 | u771538568 | 2,000 | 262,144 | Wrong Answer | 2,104 | 12,096 | 115 | Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (iโ j), he has to pay the cost separately for transforming each of them (... | n=int(input())
a=list(map(int,input().split()))
b=sum(a)/n
c=(b*2+1)//2
s=0
for i in a:
s+=(i-s)**2
print(s)
| s803843499 | Accepted | 17 | 2,940 | 124 | n=int(input())
a=list(map(int,input().split()))
b=sum(a)/n
c=(b*2+1)//2
s=0
for i in a:
s+=(i-c)**2
s=int(s)
print(s)
|
s512896359 | p04029 | u766566560 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | N = int(input())
print((N + 1) // 2) | s942846802 | Accepted | 17 | 2,940 | 41 | N = int(input())
print((N + 1) * N // 2) |
s800443360 | p03712 | u629350026 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 222 | You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1. | h,w=map(int,input().split())
ans=[["#"]*(w+2)]
for i in range(h):
temp=list(map(str,input()))
temp.insert(0,"#")
temp.append("#")
ans.append(temp)
ans.append(["#"]*(w+2))
for i in range(h):
print("".join(ans[i])) | s289982626 | Accepted | 19 | 3,060 | 224 | h,w=map(int,input().split())
ans=[["#"]*(w+2)]
for i in range(h):
temp=list(map(str,input()))
temp.insert(0,"#")
temp.append("#")
ans.append(temp)
ans.append(["#"]*(w+2))
for i in range(h+2):
print("".join(ans[i])) |
s986903799 | p04029 | u711626986 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 185 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | a=list(map(str,input().split()))
b=[]
c=len(a)
for k in range(1,c):
if a[k]=="1":
b.append("1")
elif a[k]=="0":
b.append("0")
else:
del b[k-1]
f=" ".join(b)
print(f) | s528999092 | Accepted | 18 | 2,940 | 66 | k=input()
a=int(k)
b=1
c=0
for j in range(1,a+1):
c+=j
print(c)
|
s206076282 | p03730 | u758411830 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 395 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | A, B, C = map(int, input().split())
n = 0
cnts = [0]*A
while True:
mod = (n*B+C)%A
if cnts[mod] == 1:
print('No')
break
if mod == 0:
print('Yes')
break
n += 1
cnts[mod] = 1
| s681385049 | Accepted | 19 | 3,060 | 395 | A, B, C = map(int, input().split())
n = 0
cnts = [0]*A
while True:
mod = (n*B+C)%A
if cnts[mod] == 1:
print('NO')
break
if mod == 0:
print('YES')
break
n += 1
cnts[mod] = 1
|
s983225586 | p02692 | u638033979 | 2,000 | 1,048,576 | Wrong Answer | 247 | 16,920 | 1,087 | There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or ... | n,a,b,c = map(int,input().split())
abc = [a,b,c]
def get_index(ch):
if (ch == "A"):return 0
elif (ch == "B"):return 1
else:return 2
ans = ["Yes"]
S = [input() for _ in range(n)]
for i in range(n):
s = S[i]
s1 = get_index(s[0])
s2 = get_index(s[1])
if abc[s1] == 0 and abc[s2] == 0:
... | s957257456 | Accepted | 248 | 16,864 | 1,349 | n,a,b,c = map(int,input().split())
abc = [a,b,c]
def get_index(ch):
if (ch == "A"):return 0
elif (ch == "B"):return 1
else:return 2
ans = ["Yes"]
S = [input() for _ in range(n)]
for i in range(n):
s = S[i]
s1 = get_index(s[0])
s2 = get_index(s[1])
if abc[s1] == 0 and abc[s2] == 0:
... |
s999627617 | p02397 | u661529494 | 1,000 | 131,072 | Wrong Answer | 30 | 7,796 | 142 | Write a program which reads two integers x and y, and prints them in ascending order. | import sys
while 1:
x,y= sys.stdin.readline().split()
if x == y == "0":
break
elif int(x)>int(y):
print(x,y)
else:
print(y,x) | s958314162 | Accepted | 30 | 7,856 | 143 | import sys
while 1:
x,y= sys.stdin.readline().split()
if x == y == "0":
break
elif int(x)>int(y):
print(y,x)
else:
print(x,y) |
s344503672 | p03575 | u780962115 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 535 | You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ... | n,m=map(int,input().split())
lists=[]
for _ in range(m):
a,b=map(int,input().split())
lists.append([a,b])
justified=True
while lists and justified:
ans=0
limit=0
for i in range(1,n+1):
cnt=0
for _ in lists:
if _[0]==i or _[1]==i:
cnt+=1
in... | s744521600 | Accepted | 46 | 3,188 | 470 | n,m=map(int,input().split())
lists=[]
for _ in range(m):
a,b=map(int,input().split())
lists.append([a,b])
answer=0
for some in range(m):
ans=0
for i in range(1,n+1):
cnt=0
for _ in lists:
if _[0]==i or _[1]==i:
cnt+=1
index=lists.index(_)
... |
s635054534 | p03385 | u178432859 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 104 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | a = list(input())
a.sort()
print(a)
a = "".join(a)
if a == "abc":
print("Yes")
else:
print("No") | s252249914 | Accepted | 17 | 2,940 | 95 | a = list(input())
a.sort()
b = "".join(a)
if b == "abc":
print("Yes")
else:
print("No") |
s490849343 | p02613 | u261427665 | 2,000 | 1,048,576 | Wrong Answer | 160 | 16,176 | 771 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`,... | N = int(input())
s = [input() for i in range(N)]
def count_ac (s):
n = 0
for i in range (0, N):
if s[i] == "AC":
n = n + 1
else:
n = n
return n
def count_wa (s):
n = 0
for i in range (0, N):
if s[i] == "WA":
n = n + 1
else:
... | s449207860 | Accepted | 158 | 16,308 | 856 | N = int(input())
s = [input() for i in range(N)]
def count_ac (s):
n = 0
for i in range (0, N):
if s[i] == "AC":
n = n + 1
else:
n = n
return n
def count_wa (s):
n = 0
for i in range (0, N):
if s[i] == "WA":
n = n + 1
else:
... |
s301735160 | p03732 | u064963667 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 1,190 | You have N items and a bag of strength W. The i-th item has a weight of w_i and a value of v_i. You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W. Your objective is to maximize the total value of the selected items. | n,w = map(int,input().split())
pack_list = [list(map(int,input().split())) for _ in range(n)]
# dp = [[float('inf') for _ in range(10**7+1)] for _ in range(n+1)]
# dp[0] = [0 for _ in range(10**7+1)]
dp_dict = {0: {0:0}} # w,v
for i,pack in enumerate(pack_list):
i += 1
if i not in dp_dict:
dp_dict... | s150333862 | Accepted | 127 | 11,964 | 1,186 | n,w = map(int,input().split())
pack_list = [list(map(int,input().split())) for _ in range(n)]
# dp = [[float('inf') for _ in range(10**7+1)] for _ in range(n+1)]
# dp[0] = [0 for _ in range(10**7+1)]
dp_dict = {0: {0:0}} # w,v
for i,pack in enumerate(pack_list):
i += 1
if i not in dp_dict:
dp_dict... |
s144434376 | p02421 | u682153677 | 1,000 | 131,072 | Wrong Answer | 20 | 5,604 | 518 | Taro and Hanako are playing card games. They have n cards each, and they compete n turns. At each turn Taro and Hanako respectively puts out a card. The name of the animal consisting of alphabetical letters is written on each card, and the bigger one in lexicographical order becomes the winner of that turn. The winner ... | # -*- coding: utf-8 -*-
n = int(input())
t_point, h_point = 0, 0
for i in range(n):
t_card, h_card = list(map(str, input().split()))
if t_card is h_card:
t_point += 1
h_point += 1
else:
for j in range(min(len(t_card), len(h_card))):
if ord(t_card[j]) > ord(h_card[j])... | s327265240 | Accepted | 20 | 5,608 | 340 | # -*- coding: utf-8 -*-
n = int(input())
t_point, h_point = 0, 0
for i in range(n):
t_card, h_card = map(str, input().split())
if t_card == h_card:
t_point += 1
h_point += 1
elif t_card > h_card:
t_point += 3
elif t_card < h_card:
h_point += 3
print('{0} {1}'.format... |
s284334377 | p02831 | u904331908 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,064 | 96 | Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be ... | import math
a,b = map(int,input().split())
x = math.gcd(a,b)
y = a * b
ans = y / x
print(ans) | s982368654 | Accepted | 29 | 9,068 | 98 | import math
a,b = map(int,input().split())
x = math.gcd(a,b)
y = a * b
ans = y // x
print(ans)
|
s242202280 | p03545 | u565204025 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 395 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in... | # -*- coding: utf-8 -*-
abcd = list(input())
abcd = list(map(int,abcd))
print(abcd)
ans = ""
def dfs(i, num, s):
global ans
if i == len(abcd):
if num == 7:
s += "=7"
ans = s
return
dfs(i + 1, num + abcd[i], s + "+" + str(abcd[i]))
dfs(i + 1, num - abcd[i], s ... | s502630586 | Accepted | 19 | 3,060 | 382 | # -*- coding: utf-8 -*-
abcd = list(input())
abcd = list(map(int,abcd))
ans = ""
def dfs(i, num, s):
global ans
if i == len(abcd):
if num == 7:
s += "=7"
ans = s
return
dfs(i + 1, num + abcd[i], s + "+" + str(abcd[i]))
dfs(i + 1, num - abcd[i], s + "-" + str(a... |
s548729535 | p03140 | u629540524 | 2,000 | 1,048,576 | Wrong Answer | 34 | 9,028 | 125 | You are given three strings A, B and C. Each of these is a string of length N consisting of lowercase English letters. Our objective is to make all these three strings equal. For that, you can repeatedly perform the following operation: * Operation: Choose one of the strings A, B and C, and specify an integer i bet... | n = int(input())
x = [input() for i in range(3)]
c=0
for i in range(n):
c+=len(set([x[0][i],x[1][i],x[0][i]]))-1
print(c) | s742261028 | Accepted | 30 | 9,096 | 125 | n = int(input())
x = [input() for i in range(3)]
c=0
for i in range(n):
c+=len(set([x[0][i],x[1][i],x[2][i]]))-1
print(c) |
s526658068 | p02865 | u500297289 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 35 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | N = int(input())
print(N // 2 + 1) | s174411187 | Accepted | 20 | 2,940 | 79 | N = int(input())
if N % 2 == 0:
print(N // 2 - 1)
else:
print(N // 2)
|
s742332266 | p03447 | u492447501 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 73 | You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping? | X = int(input())
A = int(input())
B = int(input())
print(X-((X-A)//B)*B) | s911294336 | Accepted | 17 | 2,940 | 78 | X = int(input())
A = int(input())
B = int(input())
print((X-A)-((X-A)//B)*B)
|
s026806562 | p02401 | u648117624 | 1,000 | 131,072 | Wrong Answer | 20 | 5,556 | 73 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | while True:
s = input()
if '?' in s: break
print(eval(s))
| s674260197 | Accepted | 20 | 5,552 | 77 | while True:
s = input()
if '?' in s: break
print(int(eval(s)))
|
s113924161 | p03854 | u577806663 | 2,000 | 262,144 | Wrong Answer | 21 | 3,188 | 279 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s=input()
s1=s.replace("eraser","0").replace("erase","0").replace("dreamer","0").replace("dream","0")
n=len(s1)
flag=False
for i in range(0,n):
if s1[i]!='0':
flag=True
break
if flag==False:
print("Yes")
else:
print("No")
| s157498307 | Accepted | 20 | 3,188 | 279 | s=input()
s1=s.replace("eraser","0").replace("erase","0").replace("dreamer","0").replace("dream","0")
n=len(s1)
flag=False
for i in range(0,n):
if s1[i]!='0':
flag=True
break
if flag==False:
print("YES")
else:
print("NO")
|
s591516738 | p02420 | u198574985 | 1,000 | 131,072 | Wrong Answer | 20 | 5,596 | 385 | Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the las... | while True:
string = str(input())
box = ""
if string == "-":
break
shuffle = int(input())
h = [0]*shuffle
for a in range(shuffle):
h[a] = int(input())
for b in range(shuffle):
box = string[0:h[b]]
string = string[h[b]:]
string = stri... | s305785355 | Accepted | 20 | 5,600 | 363 | while True:
string = str(input())
box = ""
if string == "-":
break
shuffle = int(input())
h = [0]*shuffle
for a in range(shuffle):
h[a] = int(input())
for b in range(shuffle):
box = string[0:h[b]]
string = string[h[b]:]
string = stri... |
s472487048 | p03694 | u785205215 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 89 | It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts. There are N houses along _TopCoDeer street_. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses. Find the minimum distance to be traveled when AtCoDeer can star... | r = sorted(input().split())
max_i= int(r[len(r)-1])
min_i= int(r[0])
print(max_i - min_i) | s639869772 | Accepted | 17 | 2,940 | 100 | n = input()
r = input().split()
r =list(map(int,r))
max_i= max(r)
min_i= min(r)
print(max_i - min_i) |
s485769334 | p03997 | u327087061 | 2,000 | 262,144 | Wrong Answer | 23 | 9,036 | 66 | 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)
| s801291246 | Accepted | 22 | 9,024 | 67 | a=int(input())
b=int(input())
h=int(input())
print(((a+b)*h)//2)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.