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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s434463124
|
p03386
|
u848647227
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 20,176
| 96
|
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,c = map(int,input().split(" "))
for i in range(a,b+1):
if i < a+c or i > a-c:
print(i)
|
s663021064
|
Accepted
| 18
| 3,064
| 261
|
a,b,c = map(int,input().split())
ar = []
if a + c > b:
d = b+1
else:
d = a+c
for i in range(a,d):
ar.append(i)
if b - c < a:
e = a
else:
e = b-c+1
for i in range(e,b+1):
ar.append(i)
br = set(ar)
cr = sorted(br)
for i in cr:
print(i)
|
s189876984
|
p03635
|
u371467115
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 42
|
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
n,m=map(int,input().split())
print(n*m//4)
|
s333933926
|
Accepted
| 18
| 2,940
| 48
|
n,m=map(int,input().split())
print((n-1)*(m-1))
|
s024446960
|
p04043
|
u264686117
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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.
|
s = input().split()
print(s.count('5') == 2 and s.count('7') == 1)
|
s400176558
|
Accepted
| 17
| 2,940
| 86
|
s = input().split()
print('YES' if s.count('5') == 2 and s.count('7') == 1 else 'NO')
|
s385964377
|
p03545
|
u228223940
| 2,000
| 262,144
|
Wrong Answer
| 317
| 20,220
| 617
|
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 input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
import numpy
def main():
a = int(input())
a = str(a).zfill(4)
A = int(a[0])
B = int(a[1])
C = int(a[2])
D = int(a[3])
op1 = ""
op2 = ""
op3 = ""
for i in range(2):
for j in range(2):
for k in range(2):
if A + (-1) ** (i+1) * B + (-1) ** (j+1) * C + (-1) ** (k+1) * D == 7:
op1 = "-" if i == 0 else "+"
op2 = "-" if j == 0 else "+"
op3 = "-" if k == 0 else "+"
print(str(A)+op1+str(B)+op2+str(C)+op3+str(D))
exit()
main()
|
s343494800
|
Accepted
| 174
| 14,044
| 622
|
import numpy
def main():
a = int(input())
a = str(a).zfill(4)
A = int(a[0])
B = int(a[1])
C = int(a[2])
D = int(a[3])
op1 = ""
op2 = ""
op3 = ""
for i in range(2):
for j in range(2):
for k in range(2):
if A + (-1) ** (i+1) * B + (-1) ** (j+1) * C + (-1) ** (k+1) * D == 7:
op1 = "-" if i == 0 else "+"
op2 = "-" if j == 0 else "+"
op3 = "-" if k == 0 else "+"
print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
exit()
main()
|
s490582563
|
p03472
|
u976225138
| 2,000
| 262,144
|
Wrong Answer
| 230
| 17,128
| 381
|
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 damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total?
|
from math import ceil
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
a, b = map(int, input().split())
A.append(a)
B.append(b)
else:
a = max(A)
B.sort()
B.reverse()
ans = 0
for b in B:
if H <= 0:
print(ans)
break
if a < b:
H -= b
ans += 1
else:
print(ans + ceil(H / a))
break
|
s291476406
|
Accepted
| 235
| 17,048
| 359
|
from math import ceil
N, H = map(int, input().split())
A = []
B = []
for _ in range(N):
a, b = map(int, input().split())
A.append(a)
B.append(b)
else:
a = max(A)
B.sort()
B.reverse()
ans = 0
for b in B:
if H <= 0:
print(ans)
break
if a < b:
H -= b
ans += 1
else:
print(ans + ceil(H / a))
|
s055163190
|
p03433
|
u928385607
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 83
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
if n%500 <= a:
print('YES')
else:
print('NO')
|
s022954198
|
Accepted
| 17
| 2,940
| 95
|
n = int(input())
a = int(input())
b = int(n%500)
if b <= a:
print('Yes')
else:
print('No')
|
s894003561
|
p03992
|
u588341295
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 1,166
|
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
s=input()
print(s[:4]+' '+s[4:])
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
s=input()
print(s[:4]+' '+s[4:])
|
s223515940
|
Accepted
| 18
| 3,064
| 583
|
# -*- coding: utf-8 -*-
import sys
def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
s=input()
print(s[:4]+' '+s[4:])
|
s068619921
|
p02613
|
u921352252
| 2,000
| 1,048,576
|
Wrong Answer
| 159
| 16,136
| 266
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N=int(input())
S = []
for _ in range(N):
S.append(input())
a=0
b=0
c=0
d=0
for i in S:
if i=='AC':
a+=1
elif i=='WA':
b+=1
elif i=='TLE':
c+=1
else:
d+=1
print('AC×'+str(a))
print('WA×'+str(b))
print('TLE×'+str(c))
print('RE×'+str(d))
|
s448135506
|
Accepted
| 160
| 16,332
| 273
|
N=int(input())
S = []
for _ in range(N):
S.append(input())
a=0
b=0
c=0
d=0
for i in S:
if i=='AC':
a+=1
elif i=='WA':
b+=1
elif i=='TLE':
c+=1
else:
d+=1
print('AC x '+str(a))
print('WA x '+str(b))
print('TLE x '+str(c))
print('RE x '+str(d))
|
s999140042
|
p03860
|
u756696693
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 27
|
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")
|
s982243755
|
Accepted
| 17
| 2,940
| 27
|
print("A"+input()[8] + "C")
|
s089152251
|
p03698
|
u581187895
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
import sys
input = sys.stdin.readline
s = input().rstrip()
print("yes" if set(s) == s else "no")
|
s862455107
|
Accepted
| 17
| 2,940
| 91
|
S = input()
len_S = len(S)
if len_S == len(set(S)):
print("yes")
else:
print("no")
|
s402731011
|
p02601
|
u250673725
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,096
| 155
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
# cook your dish here
a,b,c = map(int, input().split())
k = int(input())
if (2*c > b and b>a) or (2*b > a and c>b):
print('Yes')
else:
print('No')
|
s367713803
|
Accepted
| 26
| 9,128
| 220
|
# cook your dish here
a,b,c = map(int, input().split())
k = int(input())
c1, c2 = 0, 0
while b<=a:
b=b*2
c1 = c1 + 1
while c <= b:
c=c*2
c2 = c2 +1
if c1 + c2 <= k:
print('Yes')
else:
print('No')
|
s523262940
|
p03457
|
u923279197
| 2,000
| 262,144
|
Wrong Answer
| 325
| 3,060
| 146
|
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())
for i in range(n):
t,x,y=map(int,input().split())
if x+y<t or (x+y+t)%2==1:
print('No')
exit()
print('Yes')
|
s586435658
|
Accepted
| 429
| 27,300
| 299
|
n = int(input())
yo =[]
for i in range(n):
yo.append(list(map(int,input().split())))
now =[0, 0, 0]
for i in range(n):
c = yo[i][0] - now[0]-(abs(yo[i][1]-now[1]) + abs(yo[i][2]-now[2]))
if c >= 0 and c%2 == 0:
now =yo[i]
else:
print('No')
exit()
print('Yes')
|
s702309836
|
p03548
|
u037221289
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 61
|
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 people, and between the end of the seat and a person. At most how many people can sit on the seat?
|
X,Y,Z = map(int,input().split(' '))
print(int((X-Z) // Y+Z))
|
s893873884
|
Accepted
| 19
| 2,940
| 62
|
X,Y,Z = map(int,input().split(' '))
print(int((X-Z) // (Y+Z)))
|
s533564942
|
p03162
|
u598229387
| 2,000
| 1,048,576
|
Wrong Answer
| 839
| 24,308
| 364
|
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 b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n=int(input())
abc=[[int(i) for i in input().split()] for j in range(n)]
dp=[[abc[0][0],abc[0][1],abc[0][2]],[0,0,0]]
for i in range(1,n):
for j in range(3):
for k in range(3):
if j!=k:
dp[1][k]=max(dp[1][k] ,dp[0][j]+abc[i][k])
dp[0][0]=dp[1][0]
dp[0][1]=dp[1][1]
dp[0][2]=dp[1][2]
print(max(dp[1]))
print(dp)
|
s370887533
|
Accepted
| 562
| 47,008
| 361
|
n=int(input())
abc=[[int(i) for i in input().split()] for j in range(n)]
dp=[[0 for i in range(3)] for j in range(n+1)]
for i in range(3):
dp[1][i]=abc[0][i]
for i in range(1,n):
dp[i+1][0]=max(dp[i][1],dp[i][2])+abc[i][0]
dp[i+1][1]=max(dp[i][2],dp[i][0])+abc[i][1]
dp[i+1][2]=max(dp[i][1],dp[i][0])+abc[i][2]
print(max(dp[-1]))
|
s297596904
|
p03759
|
u369630760
| 2,000
| 262,144
|
Wrong Answer
| 29
| 8,996
| 105
|
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 = input().split()
if int(a[2])-int(a[1]) == int(a[1])-int(a[0]):
print("Yes")
else:
print("No")
|
s911120886
|
Accepted
| 29
| 9,072
| 105
|
a = input().split()
if int(a[2])-int(a[1]) == int(a[1])-int(a[0]):
print("YES")
else:
print("NO")
|
s752030624
|
p02613
|
u767821815
| 2,000
| 1,048,576
|
Wrong Answer
| 150
| 9,212
| 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.
|
N = int(input())
ans = [0,0,0,0]
for _ in range(N):
a = input()
if a == "AC":
ans[0] += 1
elif a == "WA":
ans[1] += 1
elif a == "TLE":
ans[2] += 1
else:
ans[3] += 1
print("AC × "+ str(ans[0]))
print("WA × "+ str(ans[1]))
print("TLE × "+ str(ans[2]))
print("RE × "+ str(ans[3]))
|
s183217036
|
Accepted
| 148
| 9,208
| 332
|
N = int(input())
ans = [0,0,0,0]
for _ in range(N):
a = input()
if a == "AC":
ans[0] += 1
elif a == "WA":
ans[1] += 1
elif a == "TLE":
ans[2] += 1
else:
ans[3] += 1
print("AC x "+ str(ans[0]))
print("WA x "+ str(ans[1]))
print("TLE x "+ str(ans[2]))
print("RE x "+ str(ans[3]))
|
s247542370
|
p03997
|
u836737505
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 76
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
s = (a + b)*h/2
print(s)
|
s859353044
|
Accepted
| 17
| 2,940
| 68
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2)
|
s573433899
|
p03501
|
u771167374
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 54
|
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
n, a, b = map(int, input().split())
print(max(a*n, b))
|
s441778689
|
Accepted
| 17
| 2,940
| 54
|
n, a, b = map(int, input().split())
print(min(a*n, b))
|
s816786794
|
p03605
|
u763210820
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 52
|
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 = list(input())
print('YES' if '9' in n else 'NO')
|
s760331881
|
Accepted
| 17
| 2,940
| 52
|
n = list(input())
print('Yes' if '9' in n else 'No')
|
s242697068
|
p02850
|
u010090035
| 2,000
| 1,048,576
|
Wrong Answer
| 980
| 37,184
| 649
|
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.
|
n=int(input())
g=[[0,i,-1,[]] for i in range(n)]
for i in range(n-1):
a,b=map(int,input().split())
ga=g[a-1]
ga[0]+=1
ga[3].append(b-1)
g[a-1]=ga
gb=g[b-1]
gb[0]+=1
gb[3].append(a-1)
g[b-1]=gb
g.sort()
c=1
ans=[-1 for _ in range(n)]
for i in range(n):
nextto=g[i][3]
while(True):
nextc=[]
for j in nextto:
nextc.append(g[j][2])
nextc=list(set(nextc))
if(c not in nextc):
g[i][2]=c
ans[g[i][1]]=c
break
else:
c+=1
for i in range(n):
print(ans[i])
|
s737991632
|
Accepted
| 351
| 26,272
| 426
|
from collections import deque
n=int(input())
g=[[] for _ in range(n+1)]
e=[]
for i in range(n-1):
a,b=map(int,input().split())
g[a-1].append(b-1)
e.append(b-1)
q=deque([0])
color=[0 for _ in range(n)]
while(len(q)>0):
ei=q.popleft()
c=1
for x in g[ei]:
if c == color[ei]:
c+=1
color[x]=c
c+=1
q.append(x)
print(max(color))
for i in e:
print(color[i])
|
s346939667
|
p03493
|
u734876600
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 32
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s1s2s3=input()
s1s2s3.count("1")
|
s338345337
|
Accepted
| 17
| 2,940
| 40
|
s1s2s3=input()
print(s1s2s3.count("1"))
|
s932894779
|
p03606
|
u641446860
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
|
N = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))
|
s336800085
|
Accepted
| 20
| 3,060
| 104
|
N = int(input())
ans = 0
for _ in range(N):
l, r = map(int, input().split())
ans += r-l+1
print(ans)
|
s251692119
|
p04031
|
u288601503
| 2,000
| 262,144
|
Wrong Answer
| 32
| 2,940
| 231
|
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 (See Sample 2). Find the minimum total cost to achieve his objective.
|
#4
n=int(input())
a=list(map(int,input().split()))
mini=[]
for i in range(n):
mini.append(int(0))
for j in range(n):
mini[i]=mini[i]+(a[i]-a[j])**2
if min(mini)<mini[i]:
break
print(min(mini))
|
s972348510
|
Accepted
| 94
| 3,060
| 245
|
n=int(input())
a=list(map(int,input().split()))
mini=[]
for i in range(max(a)-min(a)+1):
mini.append(int(0))
for j in range(n):
mini[i]=mini[i]+(i+min(a)-a[j])**2
if min(mini)<mini[i]:
break
print(min(mini))
|
s635241837
|
p03568
|
u118642796
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 129
|
We will say that two integer sequences of length N, x_1, x_2, ..., x_N and y_1, y_2, ..., y_N, are _similar_ when |x_i - y_i| \leq 1 holds for all i (1 \leq i \leq N). In particular, any integer sequence is similar to itself. You are given an integer N and an integer sequence of length N, A_1, A_2, ..., A_N. How many integer sequences b_1, b_2, ..., b_N are there such that b_1, b_2, ..., b_N is similar to A and the product of all elements, b_1 b_2 ... b_N, is even?
|
N = int(input())
A = [int(i) for i in input().split()]
ans = 2**N
tmp = 1
for a in A:
if a%2==0:
tmp *= 2
print(ans - tmp)
|
s892343144
|
Accepted
| 18
| 2,940
| 131
|
N = int(input())
A = [int(i) for i in input().split()]
ans = 3**N
tmp = 1
for a in A:
if a%2==0:
tmp *= 2
print(ans - tmp)
|
s093924546
|
p03836
|
u884982181
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 142
|
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 must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
sx,sy,tx,ty = map(int,input().split())
ans = ""
ans += "U" * (ty-sy)
ans += "R" * (tx-sx)
ans += "D" * (ty-sy)
ans += "L" * (tx-sx)
print(ans)
|
s888639557
|
Accepted
| 18
| 3,064
| 278
|
sx,sy,tx,ty = map(int,input().split())
ans = ""
ans += "U" * (ty-sy)
ans += "R" * (tx-sx)
ans += "D" * (ty-sy)
ans += "L" * (tx-sx)
ans += "L"
ans += "U" * (ty-sy+1)
ans += "R" * (tx-sx+1)
ans += "D"
ans += "R"
ans += "D" * (ty-sy+1)
ans += "L" * (tx-sx+1)
ans += "U"
print(ans)
|
s051064303
|
p03573
|
u339922532
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
a, b, c = map(int, input().split())
if a == b:
print("C")
elif a == c:
print("B")
else:
print("A")
|
s665729724
|
Accepted
| 17
| 2,940
| 104
|
a, b, c = map(int, input().split())
if a == b:
print(c)
elif a == c:
print(b)
else:
print(a)
|
s158684803
|
p03455
|
u440985596
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 212
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import sys
def main():
argv = input().split()
a = int(argv[0])
b = int(argv[1])
print(oddeven(a*b))
def oddeven(n):
return 'Even' if n%2==1 else 'Odd'
if __name__ == '__main__':
main()
|
s994096248
|
Accepted
| 17
| 2,940
| 212
|
import sys
def main():
argv = input().split()
a = int(argv[0])
b = int(argv[1])
print(oddeven(a*b))
def oddeven(n):
return 'Odd' if n%2==1 else 'Even'
if __name__ == '__main__':
main()
|
s359514636
|
p00010
|
u896025703
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,732
| 551
|
Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.
|
import math
def solve(a,b,c,d,e,f):
x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
r = math.hypot(x-a, y-b)
return x,y,r
n = int(input())
for _ in range(n):
a,b,c,d,e,f = map(float, input().split())
x,y,r = solve(a,b,c,d,e,f)
x += 0.0005
y += 0.0005
r += 0.0005
print("{:.3f} {:.3f} {:.3f}".format(x, y, r))
|
s974707088
|
Accepted
| 20
| 7,768
| 512
|
import math
def solve(a,b,c,d,e,f):
x = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))
y = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))
r = math.hypot(x-a, y-b)
return x,y,r
n = int(input())
for _ in range(n):
a,b,c,d,e,f = map(float, input().split())
x,y,r = solve(a,b,c,d,e,f)
print("{:.3f} {:.3f} {:.3f}".format(x, y, r))
|
s130723032
|
p02601
|
u187883751
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,176
| 158
|
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a,b,c=map(int,input().split())
k=int(int())
t=0
while a >= b:
b *= 2
t += 1
while b >= c:
c *= 2
t += 1
if k >= t:
print('Yes')
else:
print('No')
|
s978928959
|
Accepted
| 27
| 9,100
| 161
|
a,b,c=map(int,input().split())
k=int(input())
t=0
while a >= b:
b *= 2
t += 1
while b >= c:
c *= 2
t += 1
if k >= t:
print('Yes')
else:
print('No')
|
s809621824
|
p03861
|
u689322583
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 140
|
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?
|
#coding: utf-8
a, b, x = map(int, input().split())
upper = 0
lower = 0
upper = b // x
lower = a // x
ans = int(upper - lower)
print(ans)
|
s050254844
|
Accepted
| 18
| 3,060
| 172
|
#coding: utf-8
a, b, x = map(int, input().split())
upper = 0
lower = 0
upper = b // x
lower = a // x
if(a % x == 0):
lower -= 1
ans = int(upper - lower)
print(ans)
|
s639575750
|
p03387
|
u307083029
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 414
|
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
a,b,c = map(int, input().split())
if a == b and b == c:
count=0
print(count)
exit(0)
ls = [a,b,c]
ls.sort(reverse=True)
count = 0
print(ls)
print(ls[0])
if (ls[1]-ls[2])%2 != 0:
ls[2] = ls[2]+1
ls[0] = ls[0]+1
count +=1
while ls[1] - ls[2] >= 2:
ls[2] += 2
count += 1
if ls[1] - ls[2] == 1:
ls[2] += 1
count +=1
dif = ls[0] - ls[1]
count = count + dif
print(count)
|
s942229822
|
Accepted
| 18
| 3,064
| 405
|
import sys
a,b,c = map(int, input().split())
if a == b and b == c:
count=0
print(count)
sys.exit()
ls = [a,b,c]
ls.sort(reverse=True)
count = 0
if (ls[1]-ls[2])%2 != 0:
ls[2] = ls[2]+1
ls[0] = ls[0]+1
count +=1
while ls[1] - ls[2] >= 2:
ls[2] += 2
count += 1
if ls[1] - ls[2] == 1:
ls[2] += 1
count +=1
dif = ls[0] - ls[1]
count = count + dif
print(count)
|
s654079551
|
p04044
|
u780364430
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
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.
|
n, l = map(int, input().split())
"".join(sorted([input() for _ in range(n)]))
|
s415185659
|
Accepted
| 17
| 3,060
| 84
|
n, l = map(int, input().split())
print("".join(sorted([input() for _ in range(n)])))
|
s346830064
|
p03574
|
u983918956
| 2,000
| 262,144
|
Wrong Answer
| 31
| 3,444
| 577
|
You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == ".":
cnt = 0
for di in [-1,0,1]:
for dj in [-1,0,1]:
if di == 0 and dj == 0:
continue
ni = i + di; nj = j + dj
if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
continue
if S[ni][nj] == "#":
cnt += 1
S[i][j] = cnt
for line in S:
print(*line)
|
s479049526
|
Accepted
| 32
| 3,188
| 590
|
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
for i in range(H):
for j in range(W):
if S[i][j] == ".":
cnt = 0
for di in [-1,0,1]:
for dj in [-1,0,1]:
if di == 0 and dj == 0:
continue
ni = i + di; nj = j + dj
if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
continue
if S[ni][nj] == "#":
cnt += 1
S[i][j] = str(cnt)
for line in S:
print("".join(line))
|
s222593717
|
p03089
|
u239316561
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 3,064
| 540
|
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
|
def my_index(l, x, default=False):
if x in l:
return l.index(x)
else:
return default
N = int(input())
max = 0
b = [int(x) for x in input().split()]
flag = [0 for x in range(N)]
for i in b:
if i > max:
max = i
submax = max
ans = []
while b != []:
if ((submax) == my_index(b,submax-1)):
ans.append(b.pop(submax-1))
submax = max
else :
submax = submax-1
if b[0] != 1:
print(-1)
exit()
for x in range(len(ans)):
print(ans.pop(len(ans)-1))
|
s401294096
|
Accepted
| 25
| 3,064
| 540
|
def my_index(l, x, default=False):
if x in l:
return l.index(x)
else:
return default
N = int(input())
max = 0
b = [int(x) for x in input().split()]
flag = [0 for x in range(N)]
for i in b:
if i > max:
max = i
submax = max
ans = []
while b != []:
if ((submax-1) == my_index(b,submax)):
ans.append(b.pop(submax-1))
submax = max
else :
submax = submax-1
if b[0] != 1:
print(-1)
exit()
for x in range(len(ans)):
print(ans.pop(len(ans)-1))
|
s702554875
|
p02389
|
u301461168
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,556
| 65
|
Write a program which calculates the area and perimeter of a given rectangle.
|
a, b = map(int, input().rstrip().split(" "))
print(2*(a+b), a*b)
|
s537492070
|
Accepted
| 20
| 7,524
| 65
|
a, b = map(int, input().rstrip().split(" "))
print(a*b, 2*(a+b))
|
s788336855
|
p03975
|
u005260772
| 1,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 125
|
Summer vacation ended at last and the second semester has begun. You, a Kyoto University student, came to university and heard a rumor that somebody will barricade the entrance of your classroom. The barricade will be built just before the start of the A-th class and removed by Kyoto University students just before the start of the B-th class. All the classes conducted when the barricade is blocking the entrance will be cancelled and you will not be able to attend them. Today you take N classes and class i is conducted in the t_i- th period. You take at most one class in each period. Find the number of classes you can attend.
|
a, b, c = map(int, input().split())
ans = 0
for i in range(a):
n = int(input())
if n < b:
ans += 1
print(ans)
|
s037298468
|
Accepted
| 17
| 2,940
| 135
|
a, b, c = map(int, input().split())
ans = 0
for i in range(a):
n = int(input())
if n < b or n >= c:
ans += 1
print(ans)
|
s562937847
|
p03680
|
u602500004
| 2,000
| 262,144
|
Wrong Answer
| 128
| 20,016
| 920
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
import math
import sys
import os
from operator import mul
sys.setrecursionlimit(10**7)
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))
if os.getenv("LOCAL"):
inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
sys.stdin = open(inputFile, "r")
INF = float("inf")
N = I()
a = [I() for _ in range(N)]
a = list(map(lambda x:x-1,a))
ans = -1
route = [0]
visited = set([0])
next = a[0]
while True:
if next in visited:
loopStart = route.index(next)
break
else:
route.append(next)
visited.add(next)
next = a[next]
print(route)
if 1 in visited:
ans = route.index(1)
print(ans)
|
s156302595
|
Accepted
| 120
| 20,016
| 922
|
import math
import sys
import os
from operator import mul
sys.setrecursionlimit(10**7)
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))
if os.getenv("LOCAL"):
inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
sys.stdin = open(inputFile, "r")
INF = float("inf")
N = I()
a = [I() for _ in range(N)]
a = list(map(lambda x:x-1,a))
ans = -1
route = [0]
visited = set([0])
next = a[0]
while True:
if next in visited:
loopStart = route.index(next)
break
else:
route.append(next)
visited.add(next)
next = a[next]
# print(route)
if 1 in visited:
ans = route.index(1)
print(ans)
|
s835112834
|
p03610
|
u243572357
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,192
| 20
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
print(input()[1::2])
|
s770428965
|
Accepted
| 17
| 3,192
| 19
|
print(input()[::2])
|
s787477467
|
p02398
|
u493208426
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,580
| 56
|
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
|
a, b, c = map(int, input().split())
print((b - a) % c)
|
s032638709
|
Accepted
| 20
| 5,596
| 125
|
a, b, c = map(int, input().split())
z = 0
for i in range(a, min(b + 1, c + 1)):
if c % i == 0:
z += 1
print(z)
|
s336731693
|
p02389
|
u998851054
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,696
| 73
|
Write a program which calculates the area and perimeter of a given rectangle.
|
a,b = map(int,input().strip().split())
print("%d %d" % ((2*(a+b)),(a*b)))
|
s352770314
|
Accepted
| 40
| 7,700
| 81
|
a,b = map(int,input().strip().split())
c = (a+b)*2
s = a*b
print("%d %d" % (s,c))
|
s631607701
|
p02646
|
u753854665
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,128
| 156
|
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())
a = B-A
v = V-W
v2 = v*T
if(a<=v2):
print("Yes")
else:
print("No")
|
s840936345
|
Accepted
| 24
| 9,168
| 161
|
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
a = abs(B-A)
v = V-W
v2 = v*T
if(a<=v2):
print("YES")
else:
print("NO")
|
s558433068
|
p02257
|
u269568674
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,664
| 306
|
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.
|
import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
l = input().split()
l = [int(s) for s in l]
a = 0
for i in range(0,len(l)):
if ( is_prime(l[i]) == True):
a += 1
print(a)
|
s530985077
|
Accepted
| 370
| 6,008
| 322
|
import math
def is_prime(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
return True
N = input()
N = int(N)
l = [int(input()) for i in range(N)]
a = 0
for i in range(0,len(l)):
if is_prime(l[i]) == True:
a += 1
print(a)
|
s695997242
|
p03795
|
u903574204
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,012
| 98
|
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
N = int(input())
x = 800 * N
y = 0
for i in range(N):
if i % 15 == 0:
y += 200
print (x - y)
|
s521637582
|
Accepted
| 26
| 8,932
| 45
|
N=int(input())
print(800*N - (int)(N/15)*200)
|
s877581166
|
p04011
|
u895918162
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,028
| 191
|
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.
|
total_nights = int(input())
first_nights = int(input())
first_rate = int(input())
extra_rate = int(input())
total = (first_nights * first_rate) + ((total_nights - first_nights) * extra_rate)
|
s340757945
|
Accepted
| 25
| 9,164
| 282
|
total_nights = int(input())
first_nights = int(input())
first_rate = int(input())
extra_rate = int(input())
if total_nights <= first_nights:
total = total_nights * first_rate
else:
total = (first_nights * first_rate) + ((total_nights - first_nights) * extra_rate)
print(total)
|
s438028652
|
p03761
|
u222668979
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,428
| 300
|
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.
|
from collections import Counter
n = int(input())
s = [Counter(input()) for _ in range(n)]
cnt = s[0]
for scnt in s:
for str in (scnt | cnt):
print(str)
cnt[str] = min(cnt[str], scnt[str])
a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(25)]
print(*ans, sep='')
|
s861078128
|
Accepted
| 30
| 9,416
| 281
|
from collections import Counter
n = int(input())
s = [Counter(input()) for _ in range(n)]
cnt = s[0]
for scnt in s:
for str in (scnt | cnt):
cnt[str] = min(cnt[str], scnt[str])
a = ord('a')
ans = [chr(a + i) * cnt[chr(a + i)] for i in range(26)]
print(*ans, sep='')
|
s522839476
|
p02613
|
u379378343
| 2,000
| 1,048,576
|
Wrong Answer
| 160
| 16,284
| 298
|
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())
AC=0
WA=0
TLE=0
RE=0
list1 = []
for _ in range(n):
s = input()
list1.append(s)
for i in list1:
if(i=='AC'): AC+=1
elif(i=='WA'): WA+=1
elif(i=="TLE"): TLE+=1
else:
RE+=1
print("AC x",AC )
print("WA x",WA )
print("TLE x",TLE )
print("Re x",RE )
|
s564915990
|
Accepted
| 153
| 16,556
| 399
|
from collections import Counter
n = int(input())
AC=0
WA=0
TLE=0
RE=0
list1 = []
for _ in range(n):
s = input()
list1.append(s)
counter = Counter(list1)
for item,value in counter.items():
if(item=='AC'): AC+=value
elif(item=='WA'): WA+=value
elif(item=="TLE"): TLE+=value
else:
RE+=value
print("AC x",AC )
print("WA x",WA )
print("TLE x",TLE )
print("RE x",RE )
|
s463657422
|
p03080
|
u952114288
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 52
|
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
|
input()
a=input()
print(a.count("R") > a.count("B"))
|
s192626703
|
Accepted
| 17
| 2,940
| 71
|
input()
a=input()
print("Yes" if a.count("R") > a.count("B") else "No")
|
s552134393
|
p04029
|
u397531548
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 130
|
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?
|
def candy_number():
children=input("N")
num=int(children)*(int(children)+1)/2
print("N")
print(num)
|
s320684983
|
Accepted
| 17
| 2,940
| 32
|
N=int(input())
print(N*(N+1)//2)
|
s281432666
|
p03448
|
u305760064
| 2,000
| 262,144
|
Wrong Answer
| 55
| 3,060
| 225
|
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A=int(input())
B=int(input())
C=int(input())
X=int(input())
out=0
for i in range(A):
for j in range(B):
for k in range(C):
sum = A*i + B*j + C*k
if sum==X:
out+=1
print(out)
|
s744791554
|
Accepted
| 59
| 3,060
| 236
|
A=int(input())
B=int(input())
C=int(input())
X=int(input())
out=0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
sum = i*500 + j*100 + k*50
if sum==X:
out+=1
print(out)
|
s024482221
|
p02694
|
u949210009
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 9,152
| 114
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
a = int(100)
X = int(input())
c = 0
while a <= X :
a = a + a * 0.01
a = int(a)
c = c + 1
print(c)
|
s266035068
|
Accepted
| 23
| 9,088
| 113
|
a = int(100)
X = int(input())
c = 0
while a < X :
a = a + a * 0.01
a = int(a)
c = c + 1
print(c)
|
s999741329
|
p03377
|
u616522759
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 127
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A, B, X = map(int, input().split())
if A > X:
print('No')
elif A + B >= X:
print('Yes')
elif A + B < X:
print('No')
|
s192710712
|
Accepted
| 17
| 2,940
| 127
|
A, B, X = map(int, input().split())
if A > X:
print('NO')
elif A + B >= X:
print('YES')
elif A + B < X:
print('NO')
|
s880398687
|
p04044
|
u594690363
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
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.
|
n = input()
l = ''
for i in n:
c = 0
if i == '1' or i == '0':
l += i
else:
l = l[:len(l)-1]
print(l)
|
s261897651
|
Accepted
| 17
| 3,060
| 102
|
n,m = map(int,input().split())
l = []
for i in range(n):
l.append(input())
print(''.join(sorted(l)))
|
s955784769
|
p03711
|
u977605150
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,128
| 452
|
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.
|
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
acount = 0
bcount = 0
ccount = 0
x, y = input().split()
for i in range(0, 7):
if int(x) == a[i] or int(y) == a[i]:
acount += 1
for i in range(0, 4):
if int(x) == b[i] or int(y) == b[i]:
bcount += 1
for i in range(0, 1):
if int(x) == c[0] or int(y) == c[0]:
ccount += 2
if acount == 2 or bcount == 2 or ccount == 2:
print("YES")
else:
print("NO")
|
s424492813
|
Accepted
| 23
| 9,140
| 439
|
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
acount = 0
bcount = 0
ccount = 0
x, y = input().split()
for i in range(0, 7):
if int(x) == a[i] or int(y) == a[i]:
acount += 1
for i in range(0, 4):
if int(x) == b[i] or int(y) == b[i]:
bcount += 1
if int(x) == c[0]:
ccount += 1
if int(y) == c[0]:
ccount += 1
if acount == 2 or bcount == 2 or ccount == 2:
print("Yes")
else:
print("No")
|
s295618539
|
p03023
|
u106181248
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 33
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
n = int(input())
print(180*(n-1))
|
s205749287
|
Accepted
| 17
| 2,940
| 33
|
n = int(input())
print(180*(n-2))
|
s685609317
|
p03845
|
u583507988
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 154
|
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
n = int(input())
t = [int(i) for i in input().split()]
m = int(input())
for j in range(m):
p, x = map(int, input().split())
t[p-1] = x
print(sum(t))
|
s112008213
|
Accepted
| 29
| 9,144
| 141
|
n=int(input())
t=list(map(int,input().split()))
m=int(input())
s=sum(t)
for i in range(m):
p,x=map(int,input().split())
print(s+x-t[p-1])
|
s200598251
|
p03563
|
u745554846
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
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 contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
a = int(input())
b = int(input())
print((b - (a/2)) * 2)
|
s368828489
|
Accepted
| 17
| 2,940
| 64
|
a = int(input())
b = int(input())
print(int((b - (a / 2)) * 2))
|
s406209514
|
p03436
|
u137693056
| 2,000
| 262,144
|
Wrong Answer
| 29
| 3,188
| 861
|
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
H,W=map(int,input().split())
s=[]
dst=[]
INF=1e8
for i in range(H):
s.append(input())
dst.append([INF for i in range(W)])
gx=W-1
gy=H-1
que=[]
que.append([0,0])
dst[0][0]=0
x=[-1,1,0,0]
y=[0,0,-1,1]
goalFlag=False
while len(que)>0:
p=que.pop(0)
if p[0]==gx and p[1]==gy:
goalFlag=True
break
for (dx,dy) in zip(x,y):
nextx=p[0]+dx
nexty=p[1]+dy
if H>nexty>=0 and W>nextx>=0 and s[nexty][nextx]=='.' and dst[nexty][nextx]==INF:
que.append([nextx,nexty])
dst[nexty][nextx]=dst[p[1]][p[0]]+1
print(s)
print(dst)
if goalFlag:
count=0
for h in range(H):
for w in range(W):
if h==w==0 or (h==gy and w==gx):
continue
elif s[h][w]=='.':
count+=1
print(count-dst[gy][gx]+1)
else: print(-1)
|
s668192467
|
Accepted
| 28
| 3,064
| 823
|
H,W=map(int,input().split())
s=[]
dst=[]
INF=1e8
for i in range(H):
s.append(input())
dst.append([INF for i in range(W)])
gx=W-1
gy=H-1
que=[]
que.append([0,0])
dst[0][0]=0
x=[-1,1,0,0]
y=[0,0,-1,1]
goalFlag=False
while len(que)>0:
p=que.pop(0)
if p[0]==gx and p[1]==gy:
goalFlag=True
break
for (dx,dy) in zip(x,y):
nextx=p[0]+dx
nexty=p[1]+dy
if H>nexty>=0 and W>nextx>=0 and s[nexty][nextx]=='.' and dst[nexty][nextx]==INF:
que.append([nextx,nexty])
dst[nexty][nextx]=dst[p[1]][p[0]]+1
if goalFlag:
count=0
for h in range(H):
for w in range(W):
if h==w==0 or (h==gy and w==gx):
continue
elif s[h][w]=='.':
count+=1
print(count-dst[gy][gx]+1)
else: print(-1)
|
s165524494
|
p03485
|
u401487574
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 53
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int,input().split())
s = (a+b-1)/b
print(s)
|
s882281682
|
Accepted
| 18
| 2,940
| 54
|
a,b = map(int,input().split())
s = (a+b+1)//2
print(s)
|
s773370201
|
p03644
|
u825528847
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 82
|
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.
|
N = int(input())
cnt = 0
while N % 2 == 0:
cnt += 1
N = N // 2
print(cnt)
|
s512498353
|
Accepted
| 18
| 2,940
| 242
|
N = int(input())
maxv = 0
ans = 1
for i in range(N, 0, -1):
if i % 2:
continue
tmp = 0
tmpv = i
while i % 2 == 0:
tmp += 1
i = i // 2
if tmp > maxv:
maxv = tmp
ans = tmpv
print(ans)
|
s371197519
|
p03943
|
u552738814
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,108
| 91
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c = map(int,input().split())
if a+b+c % 2 == 0:
print("Yes")
else:
print("No")
|
s934327902
|
Accepted
| 25
| 9,104
| 115
|
a,b,c = map(int,input().split())
if (a+b == c) or (a+c == b) or (b+c == a):
print("Yes")
else:
print("No")
|
s381756022
|
p03378
|
u982594421
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 145
|
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n, m, x = map(int, input().split())
c = [0] * n
for i in (map(int, input().split())):
c[i - 1] = 1
if m > x:
m, x = x , m
print(sum(c[m:x]))
|
s213034623
|
Accepted
| 17
| 2,940
| 141
|
n, m, x = map(int, input().split())
c = [0] * (n + 1)
for i in (map(int, input().split())):
c[i] = 1
print(min(sum(c[0:x]), sum(c[x:-1])))
|
s711362154
|
p04043
|
u269778596
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 179
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
li = list(map(int,input().split()))
i_5=0;i_7=0
for i in li:
if i == '5':
i_5 += 1
elif i == '7':
i_7 += 1
if i_5 == 2 and i_7 == 1:
print('YES')
else:
print('NO')
|
s267349439
|
Accepted
| 17
| 2,940
| 118
|
li = list(map(str,input().split()))
if li.count('5') == 2 and li.count('7')==1:
print('YES')
else:
print('NO')
|
s023543025
|
p03455
|
u785220618
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 89
|
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 == 0:
print('Even')
else:
print('Odd')
|
s882864113
|
Accepted
| 17
| 2,940
| 90
|
a, b = map(int, input().split())
if (a*b)%2 == 0:
print('Even')
else:
print('Odd')
|
s489315499
|
p03471
|
u208844959
| 2,000
| 262,144
|
Wrong Answer
| 1,544
| 3,064
| 288
|
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())
exist = False
for a in range(N+1):
for b in range(N+1):
c = N - a - b
if 10000 * a + 5000 * b + 1000 * c == Y:
exist = True
print("{} {} {}".format(a, b, c))
break
if ~exist:
print("-1 -1 -1")
|
s681809363
|
Accepted
| 942
| 3,064
| 304
|
N, Y = map(int, input().split())
o_a = -1
o_b = -1
o_c = -1
for a in range(N+1):
for b in range(N+1-a):
c = N - a - b
total = 10000 * a + 5000 * b + 1000 * c
if total == Y:
o_a = a
o_b = b
o_c = c
print("{} {} {}".format(o_a, o_b, o_c))
|
s708371215
|
p04012
|
u099566485
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 108
|
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=list(input())
for i in w:
if w.count(i)%2==1:
print("NO")
break
else:
print("YES")
|
s691960355
|
Accepted
| 17
| 2,940
| 127
|
w=input()
for c in 'abcdefghijklmnopqrstuvwxyz':
if w.count(c)%2:
print('No')
break
else:
print('Yes')
|
s060875442
|
p03024
|
u969190727
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 51
|
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()
print("YES" if s.count("o")>=8 else "NO")
|
s856701823
|
Accepted
| 18
| 2,940
| 50
|
s=input()
print("NO" if s.count("x")>7 else "YES")
|
s140997616
|
p03573
|
u013756322
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 76
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
a, b, c = map(int, input().split())
if (a == b):
print(a)
else:
print(c)
|
s490136012
|
Accepted
| 17
| 2,940
| 102
|
a, b, c = map(int, input().split())
if (a == b):
print(c)
elif(b == c):
print(a)
else:
print(b)
|
s445193861
|
p03494
|
u513081876
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,060
| 234
|
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
flag = True
while flag:
for i in A:
if i % 2 == 0:
i %= 2
else:
flag = False
if flag == True:
ans += 1
print(ans)
|
s275511134
|
Accepted
| 18
| 3,060
| 225
|
N = int(input())
A = [int(i) for i in input().split()]
ans = 0
check = [2**i for i in range(1, 50)]
for i in range(49):
for x in A:
if x % check[i] != 0:
break
else:
ans = i + 1
print(ans)
|
s514271413
|
p03416
|
u680004123
| 2,000
| 262,144
|
Wrong Answer
| 75
| 3,188
| 179
|
Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
|
a, b = map(int, input().split())
for i in range(a, b+1):
i = str(i)
if str(i[0]) == str(i[4]) and\
str(i[1]) == str(i[3]):
print(i)
|
s540400007
|
Accepted
| 45
| 3,060
| 197
|
a, b = map(str, input().split())
count = 0
for i in range(int(a), int(b)+1):
num = str(i)
if num[0] == num[4] and \
num[1] == num[3]:
count += 1
print(count)
|
s560228184
|
p03828
|
u514894322
| 2,000
| 262,144
|
Wrong Answer
| 26
| 3,188
| 361
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
n = int(input())
p = [2,3,5,7,11,13,17,19,23,29,31]
ll = [[0]*len(p) for _ in [0]*(n+1)]
for i in range(1,n+1):
for j in range(len(p)):
ll[i][j] = ll[i-1][j]
tmp = i
while True:
if tmp%p[j] == 0:
ll[i][j] += 1
tmp = tmp//p[j]
else:
break
print(ll[i])
ans = 1
for i in ll[-1]:
ans*=(i+1)%(10**9+7)
print(ans)
|
s908897807
|
Accepted
| 106
| 4,340
| 435
|
p=[2];A=1000
for L in range(3,A):
chk=True
for L2 in p:
if L%L2 == 0:chk=False
if chk==True:p.append(L)
n = int(input())
ll = [[0]*len(p) for _ in [0]*(n+1)]
for i in range(1,n+1):
for j in range(len(p)):
ll[i][j] = ll[i-1][j]
tmp = i
while True:
if tmp%p[j] == 0:
ll[i][j] += 1
tmp = tmp//p[j]
else:
break
ans = 1
for i in ll[-1]:
ans*=(i+1)
print(ans%(10**9+7))
|
s351407402
|
p02399
|
u879471116
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 55
|
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 = map(int, input().split())
print(a//b, a%b, a/b)
|
s895128298
|
Accepted
| 20
| 5,600
| 73
|
a, b = map(int, input().split())
print('%d %d %.5f' % (a//b, a%b, a/b))
|
s875740018
|
p02612
|
u039065404
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,104
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s564127192
|
Accepted
| 30
| 9,100
| 81
|
N = int(input())
k = N//1000
if N%1000==0:
print(0)
else:
print(1000*(k+1)-N)
|
s227964474
|
p03544
|
u607075479
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 79
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
N = int(input())
L = [2, 1]
for i in range(N):
L.append(L[-1]+L[-2])
print(N)
|
s046355845
|
Accepted
| 17
| 2,940
| 82
|
N = int(input())
L = [2, 1]
for i in range(N):
L.append(L[-1]+L[-2])
print(L[N])
|
s766837358
|
p03485
|
u506549878
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 75
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import math
k, s = map(int, input().split())
x = (k+s)/2
math.ceil(x)
|
s896936084
|
Accepted
| 18
| 2,940
| 76
|
import math
k, s = map(int, input().split())
x = (k+s)/2
print(math.ceil(x))
|
s360560049
|
p03609
|
u820351940
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 53
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
a, b = map(int, input().split())
print(max(0, b - a))
|
s957007287
|
Accepted
| 17
| 2,940
| 53
|
a, b = map(int, input().split())
print(max(0, a - b))
|
s710389645
|
p03377
|
u606033239
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 59
|
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(["No","Yes"][x-a<b])
|
s963922755
|
Accepted
| 17
| 2,940
| 63
|
a,b,x = map(int,input().split())
print(["NO","YES"][a+b>=x>=a])
|
s962883931
|
p02614
|
u237299453
| 1,000
| 1,048,576
|
Wrong Answer
| 29
| 9,144
| 293
|
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
H, W, K = map(int, input().split())
S = []
for _ in range(H):
S.append(input())
A = [[], [], [], [], [], []]
for i in range(H):
A[i].append(','.join(map(lambda x: '"{}"'.format(x), S[0])))
print(A)
|
s267691806
|
Accepted
| 65
| 9,216
| 663
|
h, w, k = map(int, input().split())
c = []
for _ in range(h):
c.append(list(input()))
all = 0
for i in c:
all += i.count("#")
ans = 0
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
for hh in range(2 ** h):
for ww in range(2 ** w):
cnt = 0
for i in range(h):
for j in range(w):
if (hh >> i) & 1 == 0 and (ww >> j) & 1 == 0:
if c[i][j] == "#":
cnt += 1
if cnt == k:
ans += 1
print(ans)
|
s551423860
|
p02613
|
u574000526
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 9,144
| 394
|
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 = {"AC": 0, "TLE": 0, "WA": 0, "RE": 0}
# a, t, w, r = 0, 0, 0, 0
for i in range(N):
s = input()
if s == "AC":
s_list["AC"] += 1
elif s == "TLE":
s_list["TLE"] += 1
elif s == "WA":
s_list["WA"] += 1
else:
s_list["RE"] += 1
print("AC × {}\nTLE × {}\nWA × {}\nRE × {}".format(s_list["AC"], s_list["TLE"], s_list["WA"], s_list["RE"]))
|
s428760375
|
Accepted
| 148
| 9,168
| 390
|
N = int(input())
s_list = {"AC": 0, "TLE": 0, "WA": 0, "RE": 0}
# a, t, w, r = 0, 0, 0, 0
for i in range(N):
s = input()
if s == "AC":
s_list["AC"] += 1
elif s == "TLE":
s_list["TLE"] += 1
elif s == "WA":
s_list["WA"] += 1
else:
s_list["RE"] += 1
print("AC x {}\nWA x {}\nTLE x {}\nRE x {}".format(s_list["AC"], s_list["WA"], s_list["TLE"], s_list["RE"]))
|
s261860306
|
p02856
|
u262597910
| 2,000
| 1,048,576
|
Wrong Answer
| 647
| 45,364
| 303
|
N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follows: * All the N contestants will participate in the first round. * When X contestants participate in some round, the number of contestants advancing to the next round will be decided as follows: * The organizer will choose two consecutive digits in the decimal notation of X, and replace them with the sum of these digits. The number resulted will be the number of contestants advancing to the next round. For example, when X = 2378, the number of contestants advancing to the next round will be 578 (if 2 and 3 are chosen), 2108 (if 3 and 7 are chosen), or 2315 (if 7 and 8 are chosen). When X = 100, the number of contestants advancing to the next round will be 10, no matter which two digits are chosen. * The preliminary stage ends when 9 or fewer contestants remain. Ringo, the chief organizer, wants to hold as many rounds as possible. Find the maximum possible number of rounds in the preliminary stage. Since the number of contestants, N, can be enormous, it is given to you as two integer sequences d_1, \ldots, d_M and c_1, \ldots, c_M, which means the following: the decimal notation of N consists of c_1 + c_2 + \ldots + c_M digits, whose first c_1 digits are all d_1, the following c_2 digits are all d_2, \ldots, and the last c_M digits are all d_M.
|
import sys
sys.stdin.readline
def main():
m = int(input())
a = [list(map(int, input().split())) for _ in range(m)]
wa = 0
length = 0
for i,j in a:
wa += i*j
length += j
print(wa,length)
print(length-1+(wa-1)//9)
if __name__=="__main__":
main()
|
s214305979
|
Accepted
| 640
| 45,364
| 304
|
import sys
sys.stdin.readline
def main():
m = int(input())
a = [list(map(int, input().split())) for _ in range(m)]
wa = 0
length = 0
for i,j in a:
wa += i*j
length += j
#print(wa,length)
print(length-1+(wa-1)//9)
if __name__=="__main__":
main()
|
s768245788
|
p04043
|
u927000908
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 90
|
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.
|
s = input()
if s.count('5') == 2 and s.count('1') == 1:
print('YES')
else:
print('NO')
|
s989113459
|
Accepted
| 17
| 2,940
| 91
|
s = input()
if s.count('5') == 2 and s.count('7') == 1:
print('YES')
else:
print('NO')
|
s460498185
|
p03504
|
u595289165
| 2,000
| 262,144
|
Wrong Answer
| 1,620
| 53,664
| 384
|
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.
|
n, c = map(int, input().split())
record = [[0]*(10**5+2) for _ in range(c+1)]
stc = [list(map(int, input().split())) for _ in range(n)]
for s, t, c in stc:
record[c][s] += 1
record[c][t] -= 1
for r in record:
for i in range(10**5+1):
r[i+1] += r[i]
ans = 0
for i in range(10**5):
y = 0
for r in record:
y += r[i]
ans = max(ans, y)
print(ans)
|
s768021165
|
Accepted
| 1,810
| 64,384
| 677
|
n, c = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(n)]
T = 10**5+1
record = [[0]*(T+3) for _ in range(c+1)]
channel = [[] for _ in range(c+1)]
stc.sort()
for s, t, c in stc:
if not channel[c]:
channel[c].append([s - 1, t])
continue
if channel[c][-1][1] == s:
channel[c][-1][1] = t
else:
channel[c].append([s-1, t])
for i, v in enumerate(channel):
for s, t in v:
record[i][s] += 1
record[i][t] -= 1
for i in record:
for j in range(T+2):
i[j+1] += i[j]
ans = 0
for i in range(T+2):
y = 0
for r in record:
y += r[i]
ans = max(ans, y)
print(ans)
|
s938106939
|
p04025
|
u102242691
| 2,000
| 262,144
|
Wrong Answer
| 110
| 4,104
| 433
|
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 (See Sample 2). Find the minimum total cost to achieve his objective.
|
n = int(input())
a = list(map(int,input().split()))
min = min(a)
max = max(a)
dis = 0
temp = 0
for i in range(n):
dis += (a[i]-min)**2
print(dis)
for i in range(min+1,max+1):
for j in range(n):
print(i,j)
temp += (a[j]-i)**2
print("AAAAA")
print(temp)
print("AAAAA")
if dis >= temp:
dis = temp
print("#####")
print(dis)
temp = 0
print(dis)
|
s679602504
|
Accepted
| 26
| 2,940
| 189
|
N = int(input())
A = list(map(int, input().split()))
ans = 10**9
for i in range(min(A), max(A)+1):
cost = 0
for a in A:
cost += (a - i) ** 2
ans = min(cost, ans)
print(ans)
|
s548302538
|
p03671
|
u266874640
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 256
|
Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively. Find the minimum total price of two different bells.
|
s = input()
s_list = []
for i in s:
s_list.append(i)
del s_list[-1]
while True:
s_half = int(len(s_list)/2)
s1 = s_list[:s_half]
s2 = s_list[s_half:]
if s1 == s2:
print(s_half*2)
break
else:
del s_list[-1]
|
s824747844
|
Accepted
| 17
| 2,940
| 63
|
a = list(map(int,input().split()))
a.sort()
print(a[0] + a[1])
|
s384674411
|
p03738
|
u506858457
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 86
|
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
A=int(input())
B=int(input())
print('GRATER' if A>B else 'LESS' if A<B else 'EQUAL')
|
s946817973
|
Accepted
| 17
| 2,940
| 87
|
A=int(input())
B=int(input())
print('GREATER' if A>B else 'LESS' if A<B else 'EQUAL')
|
s316843280
|
p03486
|
u331036636
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 394
|
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = input()
t = input()
boolist = []
dict_s = sorted({i for i in s})[::-1]
dict_t = sorted({i for i in t})[::-1]
count = [len(dict_s), len(dict_t)][len(dict_s) > len(dict_t)]-1
if len(dict_s) == len(dict_t):
print(["No", "Yes"][len(s) < len(t)])
else:
for i in range(count):
if dict_s[i] < dict_t[i]:
boolist.append(True)
print(["No", "Yes"][True in boolist])
|
s729293285
|
Accepted
| 17
| 2,940
| 89
|
s = "".join(sorted(input()))
t = "".join(sorted(input()))[::-1]
print(["No", "Yes"][s<t])
|
s499083524
|
p03697
|
u366959492
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 172
|
You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead.
|
s=input()
for i in range(len(s)):
x=-1
for j in range(len(s)):
if s[i]==s[j]:
x+=1
if x!=0:
print("no")
exit()
print("yes")
|
s053285014
|
Accepted
| 17
| 2,940
| 94
|
a,b=(int(x) for x in input().split())
if a+b>=10:
print("error")
else:
print(a+b)
|
s969247458
|
p04043
|
u722670579
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 160
|
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a,b,c=map(int,input().split())
sum=a+b+c
g=[5,7]
if a and b and c in g:
if sum==17:
print("Yes")
else:
print("No")
else:
print("No")
|
s248326724
|
Accepted
| 17
| 2,940
| 161
|
a,b,c=map(int,input().split())
sum=a+b+c
g=[5,7]
if a and b and c in g:
if sum==17:
print("YES")
else:
print("NO")
else:
print("NO")
|
s971017465
|
p04044
|
u212328220
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 163
|
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.
|
N, L = map(int, input().split())
s_list = []
for i in range(int(N)):
s_list.append((input()))
s_list = sorted(s_list)
answer = ','.join(s_list)
print(answer)
|
s013306657
|
Accepted
| 18
| 3,060
| 162
|
N, L = map(int, input().split())
s_list = []
for i in range(int(N)):
s_list.append((input()))
s_list = sorted(s_list)
answer = ''.join(s_list)
print(answer)
|
s708800338
|
p02613
|
u777916732
| 2,000
| 1,048,576
|
Wrong Answer
| 138
| 16,264
| 183
|
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=[input() for i in range(N)]
print("AC x "+str(S.count("AC")))
print("WA x "+str(S.count("WA")))
print("TEL x "+str(S.count("TEL")))
print("RE x "+str(S.count("RE")))
|
s490827561
|
Accepted
| 137
| 16,200
| 183
|
N=int(input())
S=[input() for i in range(N)]
print("AC x "+str(S.count("AC")))
print("WA x "+str(S.count("WA")))
print("TLE x "+str(S.count("TLE")))
print("RE x "+str(S.count("RE")))
|
s404769127
|
p03434
|
u903959844
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 376
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N = int(input())
list_an = input().split()
list_an_int = [int(s) for s in list_an]
list_an_int.sort()
list_an_int.reverse()
print(list_an_int)
Alice_counter = 0
Bob_counter = 0
counter = 0
for i in range(N):
if counter % 2 == 0:
Alice_counter += list_an_int[i]
else:
Bob_counter += list_an_int[i]
counter += 1
print(Alice_counter - Bob_counter)
|
s023002716
|
Accepted
| 17
| 3,064
| 356
|
N = int(input())
list_an = input().split()
list_an_int = [int(s) for s in list_an]
list_an_int.sort()
list_an_int.reverse()
Alice_counter = 0
Bob_counter = 0
counter = 0
for i in range(N):
if counter % 2 == 0:
Alice_counter += list_an_int[i]
else:
Bob_counter += list_an_int[i]
counter += 1
print(Alice_counter - Bob_counter)
|
s082395440
|
p03556
|
u045408189
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 35
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n=int(input())
print(int(n**(1/2)))
|
s137428947
|
Accepted
| 17
| 2,940
| 39
|
n=int(input())
print(int(n**(1/2))**2)
|
s381046493
|
p03024
|
u640550119
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 153
|
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 = str(input())
win = 0
for i in s:
if(i == "o"):
win += 1
win += 15- len(s)
if(win >= 8):
print("Yes")
else:
print('No')
|
s820547037
|
Accepted
| 20
| 3,060
| 153
|
s = str(input())
win = 0
for i in s:
if(i == "o"):
win += 1
win += 15- len(s)
if(win >= 8):
print("YES")
else:
print('NO')
|
s310888187
|
p02261
|
u255317651
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,616
| 1,337
|
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def selection(a, n):
cnt = 0
for i in range(n):
flag = 0
minj = i
for j in range(i+1,n):
if int(a[j][1]) < int(a[minj][1]):
minj = j
flag = 1
if flag == 1:
temp = a[minj]
a[minj] = a[i]
a[i] = temp
cnt += 1
return cnt
def bubble(a, n):
cnt = 0
for i in range(n):
for j in reversed(range(i+1,n)):
if int(a[j][1]) < int(a[j-1][1]):
temp = a[j]
a[j] = a[j-1]
a[j-1] = temp
cnt += 1
return cnt
def print_array(a):
ans = str(a[0])
for i in range(1,n):
ans += ' '+str(a[i])
print(ans)
def is_stable(a, b):
for card1 in range(len(a)):
for card2 in range(card1+1,len(a)):
if a[card1][1] == a[card2][1]:
if b.index(a[card1]) > b.index(a[card2]):
return 'Not Stable'
return 'Stable'
n = int(input())
a = input().split()
bub = a[:]
cnt = bubble(bub, n)
print_array(bub)
print(is_stable(a, bub))
sel = a[:]
cnt = selection(sel, n)
print_array(sel)
print(is_stable(a, sel))
|
s931060397
|
Accepted
| 20
| 5,624
| 1,433
|
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 28 09:21:55 2018
ALDS-1-2c
@author: maezawa
"""
def selection(a, n):
cnt = 0
for i in range(n):
flag = 0
minj = i
for j in range(i+1,n):
if int(a[j][1]) < int(a[minj][1]):
minj = j
flag = 1
if flag == 1:
temp = a[minj]
a[minj] = a[i]
a[i] = temp
cnt += 1
return cnt
def bubble(a, n):
cnt = 0
for i in range(n):
for j in reversed(range(i+1,n)):
if int(a[j][1]) < int(a[j-1][1]):
temp = a[j]
a[j] = a[j-1]
a[j-1] = temp
cnt += 1
return cnt
def print_array(a):
ans = str(a[0])
for i in range(1,n):
ans += ' '+str(a[i])
print(ans)
def is_stable(a, b):
for card1 in range(len(a)):
for card2 in range(card1+1,len(a)):
if a[card1][1] == a[card2][1]:
if b.index(a[card1]) > b.index(a[card2]):
return 'Not stable'
return 'Stable'
n = int(input())
a = input().split()
bub = a[:]
cnt = bubble(bub, n)
print_array(bub)
print(is_stable(a, bub))
sel = a[:]
cnt = selection(sel, n)
print_array(sel)
print(is_stable(a, sel))
|
s510308701
|
p04029
|
u186838327
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 33
|
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
n = int(input())
print(n*(n-1)/2)
|
s186828883
|
Accepted
| 17
| 2,940
| 35
|
n = int(input())
print(n*(n+1)//2)
|
s990749763
|
p03338
|
u859210968
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 271
|
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
N = int(input())
S = str(input())
M = 0
for n in range(1,N) :
set1 = set([])
set2 = set([])
I = set([])
for c in (S[:n]) :
set1.add(c)
for d in (S[n+1:]) :
set2.add(d)
I = set1 & set2
if(len(I)>M) :
M = len(I)
print(M)
|
s083353733
|
Accepted
| 19
| 3,064
| 269
|
N = int(input())
S = str(input())
M = 0
for n in range(1,N) :
set1 = set([])
set2 = set([])
I = set([])
for c in (S[:n]) :
set1.add(c)
for d in (S[n:]) :
set2.add(d)
I = set1 & set2
if(len(I)>M) :
M = len(I)
print(M)
|
s282064831
|
p03999
|
u010090035
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,064
| 393
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
S = str(input())
l = list(map(str,(map(bin,range(2**(len(S)-1))))))
print(l)
ans = 0
for i in range(len(l)):
ev = l[i][2:].zfill(len(S)-1)
res = 0
num_str = S[0]
for j in range(1,len(S)):
if(ev[j-1] == '0'):
num_str = num_str + S[j]
else:
res += int(num_str)
num_str = S[j]
res += int(num_str)
ans += res
print(ans)
|
s569133024
|
Accepted
| 20
| 3,188
| 384
|
S = str(input())
l = list(map(str,(map(bin,range(2**(len(S)-1))))))
ans = 0
for i in range(len(l)):
ev = l[i][2:].zfill(len(S)-1)
res = 0
num_str = S[0]
for j in range(1,len(S)):
if(ev[j-1] == '0'):
num_str = num_str + S[j]
else:
res += int(num_str)
num_str = S[j]
res += int(num_str)
ans += res
print(ans)
|
s792084870
|
p03556
|
u534953209
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 38
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
N = int(input())
print((N**0.5//1)**2)
|
s600868357
|
Accepted
| 18
| 3,060
| 43
|
N = int(input())
print(int((N**0.5//1)**2))
|
s220423679
|
p03854
|
u582243208
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,316
| 161
|
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()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream","")
if len(s)==0:
print("NO")
else:
print("YES")
|
s784960887
|
Accepted
| 24
| 3,188
| 143
|
a=["eraser","erase","dreamer","dream"]
s=input()
for i in range(4):
s=s.replace(a[i],"")
if s=="":
print("YES")
else:
print("NO")
|
s216654513
|
p03814
|
u560557614
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,500
| 69
|
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 with `Z`.
|
s = (input())
sa = s.find("a")
sz = int(s.rfind("z"))
print(sz-sa+1)
|
s766197148
|
Accepted
| 18
| 3,500
| 69
|
s = (input())
sa = s.find("A")
sz = int(s.rfind("Z"))
print(sz-sa+1)
|
s449112747
|
p01227
|
u637657888
| 5,000
| 131,072
|
Wrong Answer
| 20
| 5,452
| 1
|
ある過疎地域での話である. この地域ではカントリーロードと呼ばれるまっすぐな道に沿って, 家がまばらに建っている. 今までこの地域には電気が通っていなかったのだが, 今回政府からいくつかの発電機が与えられることになった. 発電機は好きなところに設置できるが, 家に電気が供給されるにはどれかの発電機に電線を介してつながっていなければならず, 電線には長さに比例するコストが発生する. 地域で唯一の技術系公務員であるあなたの仕事は, すべての家に電気が供給されるという条件の下で, できるだけ電線の長さの総計が短くなるような発電機 および電線の配置を求めることである. なお,発電機の容量は十分に大きいので, いくらでも多くの家に電気を供給することができるものとする. サンプル入力の1番目のデータセットを図2に示す. この問題に対する最適な配置を与えるには, 図のように x = 20 と x = 80 の位置に発電機を配置し, それぞれ図中のグレーで示した位置に電線を引けばよい. --- 図2: 発電機と電線の配置の例(入力例の最初のデータセット).
|
s761520750
|
Accepted
| 310
| 21,060
| 361
|
def cuntry(N,K,X):
if N <= K:
return 0
XX=[]
for a in range(1,N):
XX.append(X[a]-X[a-1])
XX.sort(reverse=True)
del XX[0:K-1]
return sum(XX)
n= int(input())
for j in range(n):
N, K = map(int,input().strip().split())
X = list(map(int,input().strip().split()))
if N==0:
break;
print(cuntry(N,K,X))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.