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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s943902063
|
p03485
|
u088751997
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,068
| 47
|
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())
print((a+b+1)/2)
|
s974140512
|
Accepted
| 19
| 9,152
| 48
|
a,b = map(int,input().split())
print((a+b+1)//2)
|
s793821573
|
p00015
|
u358919705
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,536
| 156
|
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow".
|
for _ in range(int(input())):
a = int(input())
b = int(input())
s = a + b
if s >= 1e79:
print('overflow')
else:
print(s)
|
s344466035
|
Accepted
| 20
| 7,640
| 160
|
for _ in range(int(input())):
a = int(input())
b = int(input())
s = a + b
if s >= 10 ** 80:
print('overflow')
else:
print(s)
|
s147912963
|
p03214
|
u879870653
| 2,525
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 158
|
Niwango-kun is an employee of Dwango Co., Ltd. One day, he is asked to generate a thumbnail from a video a user submitted. To generate a thumbnail, he needs to select a frame of the video according to the following procedure: * Get an integer N and N integers a_0, a_1, ..., a_{N-1} as inputs. N denotes the number of the frames of the video, and each a_i denotes the representation of the i-th frame of the video. * Select t-th frame whose representation a_t is nearest to the average of all frame representations. * If there are multiple such frames, select the frame with the smallest index. Find the index t of the frame he should select to generate a thumbnail.
|
N = int(input())
A = list(map(int,input().split()))
p = sum(A)/N
q = 10**9+7
for i in range(N) :
r = abs(p - A[i])
if r < q :
r = q
ans = i
print(ans)
|
s667189035
|
Accepted
| 17
| 3,060
| 193
|
N = int(input())
L = list(map(int,input().split()))
mean = sum(L)/N
q = 10**9+7
ans = -1
for i in range(N) :
di = abs(mean - L[i])
if di < q :
q = di
ans = i
print(ans)
|
s801258553
|
p03637
|
u503901534
| 2,000
| 262,144
|
Wrong Answer
| 63
| 15,020
| 354
|
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
n = int(input())
a = list(map(int,input().split()))
b_4 = 0
b_2 = 0
kisu = 0
for i in range(n):
if a[i] % 4 ==1 or 3:
kisu = kisu + 1
elif a[i] % 2 == 2:
b_2 = b_2 + 1
else:
b_4 = b_4 + 1
if b_2 == 0 and kisu - b_4 < 2:
print('Yes')
elif b_2 > 1 and b_4 - kisu <2:
print('Yes')
else:
print('No')
|
s828455711
|
Accepted
| 84
| 14,252
| 359
|
n = int(input())
a = list(map(int,input().split()))
zero = 0
two = 0
odd = 0
for i in range(len(a)):
if a[i] % 4 == 1 or a[i] % 4 == 3:
odd = odd + 1
elif a[i] % 4 == 0:
zero = zero + 1
else:
two = two + 1
if zero >= odd -1 and two == 0:
print('Yes')
elif zero >= odd:
print('Yes')
else:
print('No')
|
s674619843
|
p03836
|
u952491523
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 213
|
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())
dx = (tx - sx)
dy = (ty - sy)
s = 'U' * dy + 'R' * dx
s += 'D' * dy + 'L' * dx
s += 'L' + 'U' * (dy+1) + 'R' * (dx+1)
s += 'R' + 'D' * (dy+1) + 'L' * (dx+1)
print(s)
|
s919263215
|
Accepted
| 17
| 3,060
| 225
|
sx, sy, tx, ty = map(int,input().split())
dx = (tx - sx)
dy = (ty - sy)
s = 'U' * dy + 'R' * dx
s += 'D' * dy + 'L' * dx
s += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D'
s += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U'
print(s)
|
s449987266
|
p03433
|
u374802266
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 64
|
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,A=int(input()),int(input())
print('Yes' if N%500==A else 'No')
|
s335801963
|
Accepted
| 27
| 9,160
| 81
|
n=int(input())
a=int(input())
if n%500<=a:
print('Yes')
else:
print('No')
|
s983748047
|
p02388
|
u646500971
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,572
| 31
|
Write a program which calculates the cube of a given integer x.
|
x = int(input())
x = x * x * x
|
s409559849
|
Accepted
| 20
| 5,572
| 40
|
x = int(input())
x = x * x * x
print(x)
|
s469645560
|
p04043
|
u490489966
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 180
|
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.
|
#ABC042 A
a,b,c=map(int,input().split())
if a==b==5 and c==7:
print("Yes")
elif a==c==5 and b==7:
print("Yes")
elif b==c==5 and a==7:
print("Yes")
else:
print("No")
|
s768929509
|
Accepted
| 18
| 3,060
| 181
|
#ABC042 A
a,b,c=map(int,input().split())
if a==b==5 and c==7:
print("YES")
elif a==c==5 and b==7:
print("YES")
elif b==c==5 and a==7:
print("YES")
else:
print("NO")
|
s833055545
|
p02467
|
u978863922
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 499
|
Factorize a given integer n.
|
try:
n = int(input())
except:
exit
max_len = n
work = [1 for i in range(0,max_len+1)]
prime = []
soinsu = []
for i in range(2,max_len+1):
if (work[i] == 1 ):
prime.append(i)
j = i * 2
while ( j <= max_len ):
work[j] = 0
j += i
t = n
while (t > 1):
for i in prime:
if (t % i == 0 ):
soinsu.append(i)
t = t // i
soinsu.sort()
print (n, end ="")
for i in soinsu:
print (" ",i, end ="")
|
s428600987
|
Accepted
| 20
| 5,664
| 499
|
import math
n = int(input())
soinsu = []
c = n
if (c % 2 == 0):
while True:
soinsu.append(2)
c = c // 2
if ( c % 2 != 0):
break
len = int(math.sqrt(c)) + 1
for i in range (3,len,2):
while True:
if ( c % i != 0):
break
soinsu.append(i)
c = c // i
if ( c == 1):
break
if ( c != 1):
soinsu.append(c)
print (n,":",sep="",end="")
for i in soinsu:
print (' {}'.format(i),sep="",end="")
print("")
|
s055254215
|
p03964
|
u831695469
| 2,000
| 262,144
|
Wrong Answer
| 2,102
| 3,444
| 2,059
|
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases.
|
N = input()
t = []
a = []
for i in range(int(N)):
t_n, a_n = input().split()
t.append(int(t_n))
a.append(int(a_n))
ma = 0
t_prev = 0
a_prev = 0
for t_n, a_n in zip(t, a):
summ = t_n + a_n
summ_cp = summ
i = 0
while 1:
i += 1
summ = summ_cp * i
if summ > ma and ((t_n*i) >= t_prev) and ((a_n*i) >= a_prev):
ma = summ
break
t_prev = t_n*i
a_prev = a_n*i
print(ma)
print(t_n*i, a_n*i)
print()
print(ma)
|
s759791907
|
Accepted
| 118
| 5,332
| 1,197
|
import math
from decimal import Decimal
N = input()
t = []
a = []
for i in range(int(N)):
t_n, a_n = input().split()
t.append(Decimal(t_n))
a.append(Decimal(a_n))
t_ans = 0
a_ans = 0
for t_n, a_n in zip(t, a):
k = max(math.ceil(t_ans/t_n), math.ceil(a_ans/a_n))
if not k:
k = 1
t_ans = Decimal(k*t_n)
a_ans = Decimal(k*a_n)
print(t_ans+a_ans)
|
s987969113
|
p03555
|
u538127485
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 161
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
line1 = input().strip()
line2 = input().strip()
if line1[0] == line2[2] and line1[1] == line2[1] and line1[2] == line2[0]:
print(True)
else:
print(False)
|
s732150951
|
Accepted
| 17
| 2,940
| 162
|
line1 = input().strip()
line2 = input().strip()
if line1[0] == line2[2] and line1[1] == line2[1] and line1[2] == line2[0]:
print("YES")
else:
print("NO")
|
s728323558
|
p03494
|
u707870100
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 191
|
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.
|
# -*- coding: utf-8 -*-
tmp = input().split()
num = len(tmp)
max = 0
for j in tmp:
d = int(j)
n = 0
while(d % 2 == 0):
n=n+1
d=d/2
# print(j)
# print(n)
if(max<n):
max=n
print(n)
|
s221120878
|
Accepted
| 19
| 2,940
| 218
|
# -*- coding: utf-8 -*-
tmp = input()
tmp = input().split()
num = len(tmp)
min = int(tmp[0])
#print (min)
for j in tmp:
d = int(j)
n = 0
while(d % 2 == 0):
n=n+1
d=d/2
if(min>n):
min=n
# print(n)
print(min)
|
s987214880
|
p03555
|
u967835038
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 231
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
a=str(input())
b=str(input())
c=0
d=0
for i in range(3):
slice=a[c:c+1]
c=c+1
for j in range(3):
slice=b[d:d+1]
d=d+1
if(a[0:1]==b[2:3] and a[1:2]==b[1:2] and a[2:3]==b[0:1]):
print("Yes")
else:
print("No")
|
s987451998
|
Accepted
| 17
| 3,064
| 85
|
a=str(input())
b=str(input())
if(a==b[::-1]):
print("YES")
else:
print("NO")
|
s982804065
|
p03494
|
u681444474
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 3,060
| 215
|
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 = list(input().split())
b = [int(i) for i in a]
ans=0
def cal2(k):
return k /2
while True:
if sum(b)% 2 == 0:
b = list(map(cal2,b))
ans+=1
else:
print(ans)
print(ans)
|
s897609274
|
Accepted
| 164
| 12,484
| 190
|
import numpy as np
N=int(input())
A=list(map(int,input().split()))
A=np.array(A)
ans=2**9
for i in A:
cnt=0
while i%2==0:
i=i/2
cnt+=1
if ans > cnt:
ans=cnt
print(ans)
|
s459228690
|
p03456
|
u546417841
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 176
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a=input()
a=a.replace(' ','')
a=int(a)
print(a)
flag=False
for i in range(100):
if i*i == a:
flag=True
if flag:
print('Yes')
else:
print('No')
|
s921168047
|
Accepted
| 17
| 2,940
| 158
|
a=input()
a=a.replace(' ','')
a=int(a)
flag=False
for i in range(350):
if i*i == a:
flag=True
if flag:
print('Yes')
else:
print('No')
|
s389572635
|
p03351
|
u477343425
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 192
|
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d = map(int, input().split())
check_between_c_a = c - a <= d
check_between_cb_a = c-b <= d and b - a <= d
if(check_between_c_a and check_between_cb_a):
print('Yes')
else:
print('No')
|
s255637876
|
Accepted
| 18
| 2,940
| 142
|
a,b,c,d = map(int, input().split())
check1 = abs(c-a) <= d
check2 = abs(b-a) <= d and abs(c-b) <= d
print('Yes' if check1 or check2 else 'No')
|
s100279190
|
p03761
|
u238510421
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 692
|
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.
|
n = int(input())
s_list = list()
for i in range(n):
s_list.append(input())
dictionary_list = list()
for s in s_list:
dictionary = dict()
for w in s:
if w in dictionary:
dictionary[w] += 1
else:
dictionary[w] = 1
dictionary_list.append(dictionary)
first = dictionary_list[0]
pop_list = list()
for key,value in first.items():
for dictionary in dictionary_list[1:]:
if key in dictionary:
first[key] = min(first[key],dictionary[key])
else:
pop_list.append(key)
for p in pop_list:
if p in first:
first.pop(p)
t = ""
for k,v in first.items():
t += k*v
print(t)
|
s464460458
|
Accepted
| 25
| 3,444
| 788
|
from collections import OrderedDict
n = int(input())
s_list = list()
for i in range(n):
s_list.append(input())
dictionary_list = list()
for s in s_list:
dictionary = dict()
for w in s:
if w in dictionary:
dictionary[w] += 1
else:
dictionary[w] = 1
dictionary_list.append(dictionary)
first = dictionary_list[0]
pop_list = list()
for key,value in first.items():
for dictionary in dictionary_list[1:]:
if key in dictionary:
first[key] = min(first[key],dictionary[key])
else:
pop_list.append(key)
for p in pop_list:
if p in first:
first.pop(p)
first = OrderedDict(sorted(first.items(),key=lambda x: x[0]))
t = ""
for k,v in first.items():
t += k*v
print(t)
|
s097666104
|
p02613
|
u945065638
| 2,000
| 1,048,576
|
Wrong Answer
| 152
| 17,388
| 211
|
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())
i = []
for x in range(n):
x = input()
i.append(x)
print(i)
print('AC x ',i.count('AC'))
print('WA x ',i.count('WA'))
print('TLE x ',i.count('TLE'))
print('RE x ',i.count('RE'))
|
s794638825
|
Accepted
| 150
| 16,124
| 199
|
n = int(input())
i = []
for x in range(n):
x = input()
i.append(x)
print('AC x',i.count('AC'))
print('WA x',i.count('WA'))
print('TLE x',i.count('TLE'))
print('RE x',i.count('RE'))
|
s592928919
|
p03377
|
u280552586
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 69
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,c=map(int, input().split())
print('YES' if a+b<=c<=a+b else 'NO')
|
s810202669
|
Accepted
| 17
| 2,940
| 75
|
a, b, x = map(int, input().split())
print('YES' if a <= x <= b+a else 'NO')
|
s174718681
|
p02845
|
u329407311
| 2,000
| 1,048,576
|
Wrong Answer
| 416
| 14,396
| 244
|
N people are standing in a queue, numbered 1, 2, 3, ..., N from front to back. Each person wears a hat, which is red, blue, or green. The person numbered i says: * "In front of me, exactly A_i people are wearing hats with the same color as mine." Assuming that all these statements are correct, find the number of possible combinations of colors of the N people's hats. Since the count can be enormous, compute it modulo 1000000007.
|
n=int(input())
List=list(map(int,input().split()))
arr = [0,0,0]
ans = 1
for i in range(len(List)):
a = List[i]
b = arr.count(a)
if b > 0:
j = arr.index(a)
arr[j] = a + 1
ans = ans * b
print(b)
print(ans)
|
s687719095
|
Accepted
| 310
| 14,020
| 287
|
n=int(input())
List=list(map(int,input().split()))
arr = [0,0,0]
ans = 1
MOD = 1000000007
for i in range(len(List)):
a = List[i]
b = arr.count(a)
if b > 0:
j = arr.index(a)
arr[j] = a + 1
ans = ans * b
else:
ans = 0
break
print(ans%MOD)
|
s557256150
|
p03695
|
u030726788
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 145
|
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
|
n=int(input())
a=list(map(int,input().split()))
s=set()
fr=0
for i in a:
x=i//400
if(x<8):s.add(x)
else:fr+=1
ki=len(s)
print(min(ki+fr,8))
|
s298658727
|
Accepted
| 17
| 3,060
| 161
|
n=int(input())
a=list(map(int,input().split()))
s=set()
fr=0
for i in a:
x=i//400
if(x<8):s.add(x)
else:fr+=1
ki=len(s)
ma=ki+fr
mi=max(ki,1)
print(mi,ma)
|
s989092144
|
p03079
|
u902151549
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 100
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
hen=list(map(int,input().split()))
if max(hen)>sum(hen)-max(hen):
print("Yes")
else:
print("No")
|
s385554985
|
Accepted
| 17
| 2,940
| 90
|
hen=set(list(map(int,input().split())))
if len(hen)==1:
print("Yes")
else:
print("No")
|
s315142745
|
p03680
|
u148981246
| 2,000
| 262,144
|
Wrong Answer
| 150
| 9,124
| 254
|
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.
|
n = int(input())
cnt = 0
for i in range(n):
a = int(input())
if i ==0 and a==2:
print(0)
break
else:
if a == 2:
print(i)
break
if a == 1:
print(-1)
break
|
s395041101
|
Accepted
| 171
| 12,708
| 225
|
n = int(input())
a = [0]
for i in range(n):
a.append(int(input()))
cnt = 0
a_before = 1
while cnt <= n:
cnt += 1
if a[a_before] == 2:
print(cnt)
break
a_before = a[a_before]
else:
print(-1)
|
s343031642
|
p03352
|
u603234915
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 159
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
n = int(input())
l = []
for i in range(1,101):
for j in range(1,11):
k = i**j
if k <=n:
l.append(k)
print('{}'.format(max(l)))
|
s986291108
|
Accepted
| 17
| 2,940
| 159
|
n = int(input())
l = []
for i in range(1,101):
for j in range(2,11):
k = i**j
if k <=n:
l.append(k)
print('{}'.format(max(l)))
|
s410035971
|
p00042
|
u798803522
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,736
| 1,272
|
宝物がたくさん収蔵されている博物館に、泥棒が大きな風呂敷を一つだけ持って忍び込みました。盗み出したいものはたくさんありますが、風呂敷が耐えられる重さが限られており、これを超えると風呂敷が破れてしまいます。そこで泥棒は、用意した風呂敷を破らず且つ最も価値が高くなるようなお宝の組み合わせを考えなくてはなりません。 風呂敷が耐えられる重さ W、および博物館にある個々のお宝の価値と重さを読み込んで、重さの総和が W を超えない範囲で価値の総和が最大になるときの、お宝の価値総和と重さの総和を出力するプログラムを作成してください。ただし、価値の総和が最大になる組み合わせが複数あるときは、重さの総和が小さいものを出力することとします。
|
while True:
cnt = 0
cnt += 1
maxweight = int(input())
if maxweight == 0:
break
length = int(input())
tresure = []
dp = [[0 for n in range(length+1)] for m in range(maxweight + 1)]
answeight = 0
ansvalue = 0
for l in range(length):
v,w = (int(n) for n in input().split(","))
tresure.append([v,w])
for outer in range(length + 1):
if outer == 0:
continue
weight = tresure[outer-1][1]
value = tresure[outer-1][0]
dp[weight][outer] = max(dp[weight][outer],value)
for inner in range(maxweight + 1):
if dp[inner][outer - 1] != 0:
beforevalue = dp[inner][outer - 1]
beforeweight = inner
dp[inner][outer] = max(beforevalue,dp[inner][outer])
if beforeweight + weight <= maxweight:
nowvalue = dp[beforeweight + weight][outer]
dp[beforeweight + weight][outer] = max(nowvalue,beforevalue+value)
#print(dp)
for a in range(maxweight+1):
#print(dp[a][length])
if ansvalue < dp[a][length]:
ansvalue = dp[a][length]
answeight = a
print("Case {0}:".format(cnt))
print(ansvalue)
print(answeight)
|
s068463580
|
Accepted
| 1,740
| 19,760
| 1,268
|
cnt = 0
while True:
cnt += 1
maxweight = int(input())
if maxweight == 0:
break
length = int(input())
tresure = []
dp = [[0 for n in range(length+1)] for m in range(maxweight + 1)]
answeight = 0
ansvalue = 0
for l in range(length):
v,w = (int(n) for n in input().split(","))
tresure.append([v,w])
for outer in range(length + 1):
if outer == 0:
continue
weight = tresure[outer-1][1]
value = tresure[outer-1][0]
dp[weight][outer] = max(dp[weight][outer],value)
for inner in range(maxweight + 1):
if dp[inner][outer - 1] != 0:
beforevalue = dp[inner][outer - 1]
beforeweight = inner
dp[inner][outer] = max(beforevalue,dp[inner][outer])
if beforeweight + weight <= maxweight:
nowvalue = dp[beforeweight + weight][outer]
dp[beforeweight + weight][outer] = max(nowvalue,beforevalue+value)
#print(dp)
for a in range(maxweight+1):
#print(dp[a][length])
if ansvalue < dp[a][length]:
ansvalue = dp[a][length]
answeight = a
print("Case {0}:".format(cnt))
print(ansvalue)
print(answeight)
|
s840811124
|
p02613
|
u925242392
| 2,000
| 1,048,576
|
Wrong Answer
| 147
| 9,176
| 217
|
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())
dic={}
dic["AC"]=0
dic["WA"]=0
dic["TLE"]=0
dic["RE"]=0
for x in range(n):
a=input()
dic[a]=dic[a]+1
print("AC",x,dic["AC"])
print("WA",x,dic["WA"])
print("TLE",x,dic["TLE"])
print("RE",x,dic["RE"])
|
s249081013
|
Accepted
| 144
| 9,092
| 225
|
n=int(input())
dic={}
dic["AC"]=0
dic["WA"]=0
dic["TLE"]=0
dic["RE"]=0
for x in range(n):
a=input()
dic[a]=dic[a]+1
print("AC","x",dic["AC"])
print("WA","x",dic["WA"])
print("TLE","x",dic["TLE"])
print("RE","x",dic["RE"])
|
s581377062
|
p02692
|
u257162238
| 2,000
| 1,048,576
|
Wrong Answer
| 242
| 35,740
| 4,577
|
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 C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
|
from collections import deque
from itertools import product
import sys
import math
import numpy as np
import bisect
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def read():
N, A, B, C = map(int, input().strip().split())
S = []
for i in range(N):
s = input().strip()
S.append(s)
return N, A, B, C, S
def choose_at_corner_state(A, B, C, s):
if A == 0 and C == 0:
if s == "AC":
return ("X", -1, -1, -1)
elif s == "BC":
return ("B", A, B-1, C+1)
elif s == "AB":
return ("A", A+1, B-1, C)
elif A == 0 and B == 0:
if s == "AC":
return ("A", A+1, B, C-1)
elif s == "BC":
return ("B", A, B+1, C-1)
elif s == "AB":
return ("X", -1, -1, -1)
elif B == 0 and C == 0:
if s == "AC":
return ("A", A-1, B, C+1)
elif s == "BC":
return ("X", -1, -1, -1)
elif s == "AB":
return ("B", A-1, B+1, C)
raise ValueError()
def is_corner_state(A, B, C):
if A == 0 and B == 0:
return True
elif A == 0 and C == 0:
return True
elif B == 0 and C == 0:
return True
return False
def choose_at_normal_state(A, B, C, s0, s1):
if s0 == "BC":
if is_corner_state(A, B-1, C+1):
op0, a0, b0, c0 = ("C", A, B-1, C+1)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
elif is_corner_state(A, B+1, C-1):
op0, a0, b0, c0 = ("B", A, B+1, C-1)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
if A + B + C == 2:
return ("X", -1, -1, -1)
else:
op0, a0, b0, c0 = ("B", A, B+1, C-1)
return (op0, a0, b0, c0)
elif s0 == "AC":
if is_corner_state(A-1, B, C+1):
op0, a0, b0, c0 = ("C", A-1, B, C+1)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
if is_corner_state(A+1, B, C-1):
op0, a0, b0, c0 = ("A", A+1, B, C-1)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
if A + B + C == 2:
return ("X", -1, -1, -1)
else:
op0, a0, b0, c0 = ("A", A+1, B, C-1)
return (op0, a0, b0, c0)
elif s0 == "AB":
if is_corner_state(A-1, B+1, C):
op0, a0, b0, c0 = ("B", A-1, B+1, C)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
if is_corner_state(A+1, B-1, C):
op0, a0, b0, c0 = ("A", A+1, B-1, C)
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
if A + B + C == 2:
return ("X", -1, -1, -1)
else:
op0, a0, b0, c0 = ("A", A+1, B-1, C)
return (op0, a0, b0, c0)
raise ValueError()
def trial(N, A, B, C, S):
if A + B + C == 0:
return False, []
ans, choices = True, []
S = S + [S[-1]] # S[-1] is terminal state
if A + B + C == 1:
for i in range(N):
x, A, B, C = choose_at_corner_state(A, B, C, S[i])
if x == "X":
return False, []
else:
choices.append(x)
else:
for i in range(N):
if is_corner_state(A, B, C):
x, A, B, C = choose_at_corner_state(A, B, C, S[i])
else:
x, A, B, C = choose_at_normal_state(A, B, C, S[i], S[i+1])
if x == "X":
return False, []
else:
choices.append(x)
return ans, choices
def solve(N, A, B, C, S):
ans, choices = trial(N, A, B, C, S)
if ans:
print("Yes")
for c in choices:
print(c)
else:
print("No")
if __name__ == '__main__':
inputs = read()
outputs = solve(*inputs)
if outputs is not None:
print("{}".format(outputs))
|
s262193642
|
Accepted
| 245
| 35,760
| 4,648
|
from collections import deque
from itertools import product
import sys
import math
import numpy as np
import bisect
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def read():
N, A, B, C = map(int, input().strip().split())
S = []
for i in range(N):
s = input().strip()
S.append(s)
return N, A, B, C, S
def choose_at_corner_state(A, B, C, s):
if A == 0 and C == 0:
if s == "BC" and not is_error_state(A, B-1, C+1):
return ("C", A, B-1, C+1)
if s == "AB" and not is_error_state(A+1, B-1, C):
return ("A", A+1, B-1, C)
elif A == 0 and B == 0:
if s == "AC" and not is_error_state(A+1, B, C-1):
return ("A", A+1, B, C-1)
if s == "BC" and not is_error_state(A, B+1, C-1):
return ("B", A, B+1, C-1)
elif B == 0 and C == 0:
if s == "AC" and not is_error_state(A-1, B, C+1):
return ("C", A-1, B, C+1)
if s == "AB" and not is_error_state(A-1, B+1, C):
return ("B", A-1, B+1, C)
return ("X", -1, -1, -1)
def is_error_state(A, B, C):
if A < 0 or B < 0 or C < 0:
return True
return False
def is_corner_state(A, B, C):
if A == 0 and B == 0:
return True
elif A == 0 and C == 0:
return True
elif B == 0 and C == 0:
return True
return False
def choose_at_normal_state(A, B, C, s0, s1):
if s0 == "BC":
op0, a0, b0, c0 = ("C", A, B-1, C+1)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
op0, a0, b0, c0 = ("B", A, B+1, C-1)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
elif s0 == "AC":
op0, a0, b0, c0 = ("C", A-1, B, C+1)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
op0, a0, b0, c0 = ("A", A+1, B, C-1)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
elif s0 == "AB":
op0, a0, b0, c0 = ("B", A-1, B+1, C)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
op0, a0, b0, c0 = ("A", A+1, B-1, C)
if is_error_state(a0, b0, c0):
pass
elif is_corner_state(a0, b0, c0):
op1, a1, b1, c1 = choose_at_corner_state(a0, b0, c0, s1)
if op1 != "X":
return (op0, a0, b0, c0)
else:
return (op0, a0, b0, c0)
return ("X", -1, -1, -1)
def trial(N, A, B, C, S):
if A + B + C == 0:
return False, []
ans, choices = True, []
S = S + [S[-1]] # S[-1] is terminal state
if A + B + C == 1:
for i in range(N):
x, A, B, C = choose_at_corner_state(A, B, C, S[i])
if x == "X":
return False, []
else:
choices.append(x)
else:
for i in range(N):
if is_corner_state(A, B, C):
x, A, B, C = choose_at_corner_state(A, B, C, S[i])
else:
x, A, B, C = choose_at_normal_state(A, B, C, S[i], S[i+1])
if x == "X":
return False, []
else:
choices.append(x)
return ans, choices
def solve(N, A, B, C, S):
ans, choices = trial(N, A, B, C, S)
if ans:
print("Yes")
for c in choices:
print(c)
else:
print("No")
if __name__ == '__main__':
inputs = read()
outputs = solve(*inputs)
if outputs is not None:
print("{}".format(outputs))
|
s181583031
|
p00004
|
u560214129
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,348
| 126
|
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
|
a, b, c, d, e, f=map(float,input().split())
k=(a*e)-(b*d)
xval=(c*e)-(b*f)
yval=(a*f)-(c*d)
print("%.3f %.3f"%(xval/k,yval/k))
|
s014085899
|
Accepted
| 20
| 7,376
| 263
|
import sys
for line in sys.stdin.readlines():
a, b, c, d, e, f=map(float,line.split())
k=(a*e)-(b*d)
xval=(c*e)-(b*f)
yval=(a*f)-(c*d)
g=xval/k
h=yval/k
if(xval==0):
g=0
if(yval==0):
h=0
print("%.3f %.3f"%(g,h))
|
s625439149
|
p03555
|
u454866339
| 2,000
| 262,144
|
Wrong Answer
| 27
| 9,024
| 126
|
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
|
x = list(input())
y = list(input())
if x[0] == y[2] and x[1] == y[1] and x[2] == y[0]:
print('yes')
else:
print('no')
|
s634251991
|
Accepted
| 29
| 9,020
| 126
|
x = list(input())
y = list(input())
if x[0] == y[2] and x[1] == y[1] and x[2] == y[0]:
print('YES')
else:
print('NO')
|
s751404197
|
p03730
|
u503111914
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 141
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
import sys
A,B,C = map(int,input().split())
for i in range(1,B+1):
if A * i % B == C:
print("Yes")
sys.exit()
print("No")
|
s416403599
|
Accepted
| 22
| 2,940
| 141
|
import sys
A,B,C = map(int,input().split())
for i in range(1,B+1):
if A * i % B == C:
print("YES")
sys.exit()
print("NO")
|
s252065093
|
p03759
|
u390762426
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 43
|
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.
|
s=input()
print(s[0]+str((len(s)-2))+s[-1])
|
s748849329
|
Accepted
| 18
| 2,940
| 78
|
a,b,c=map(int,input().split())
if b-a==c-b:
print("YES")
else:
print("NO")
|
s378129446
|
p03155
|
u642012866
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,052
| 73
|
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
|
N = int(input())
H = int(input())
W = int(input())
print((H-N+1)*(W-N+1))
|
s053291541
|
Accepted
| 31
| 9,060
| 73
|
N = int(input())
H = int(input())
W = int(input())
print((N-H+1)*(N-W+1))
|
s997821785
|
p02697
|
u748241164
| 2,000
| 1,048,576
|
Wrong Answer
| 69
| 9,272
| 80
|
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
N, M = map(int, input().split())
for i in range(M):
print(i + 1, N - i)
|
s367436038
|
Accepted
| 71
| 9,264
| 274
|
N, M = map(int, input().split())
x = int(M // 2)
if M % 2 == 0:
for i in range(x):
print(i + 1, M + 1 - i)
print(M + 2 + i, 2 * M + 1 - i)
else:
for i in range(x):
print(i + 1, M - i)
for j in range(x + 1):
print(M + 1 + j, 2 * M + 1 - j)
|
s051099295
|
p03565
|
u674569298
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 612
|
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = list(input())
t = list(input())
ans = []
ok = -1
f = -1
for i in range(len(s)-len(t)+1):
# print(s[i])
a = 0
if s[i] == '?' or s[i] == t[0]:
if f is -1:
f=i
for j in range(len(t)):
# print(i,j,s[i+j],t[j])
if s[i+j] != '?' and s[i+j] != t[j]:
break
a = j
if ok == -1 and a == len(t)-1:
ok = i
if ok == -1:
print('UNRESTORABLE')
exit()
else:
for i in range(len(s)):
if s[i] == '?':
s[i] = 'a'
if ok<= i <= ok+len(t)-1:
s[i] = t[i-ok]
print(s)
|
s562031808
|
Accepted
| 18
| 3,064
| 664
|
s = list(input())
t = list(input())
ans = []
ok = -1
f = -1
if len(s)<len(t):
print('UNRESTORABLE')
exit()
for i in range(len(s)-len(t)+1):
# print(s[i])
a = 0
if s[i] == '?' or s[i] == t[0]:
if f is -1:
f=i
for j in range(len(t)):
# print(i,j,s[i+j],t[j])
if s[i+j] != '?' and s[i+j] != t[j]:
break
a = j
if a == len(t)-1:
ok = i
if ok == -1:
print('UNRESTORABLE')
exit()
else:
for i in range(len(s)):
if s[i] == '?':
s[i] = 'a'
if ok<= i <= ok+len(t)-1:
s[i] = t[i-ok]
print(''.join(s))
|
s045164713
|
p03455
|
u054935796
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
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())
c = a*b
if c%2 == 1:
print("odd")
else:
print("even")
|
s866643052
|
Accepted
| 17
| 2,940
| 91
|
a , b = map(int, input().split())
c = a*b
if c%2 == 1:
print("Odd")
else:
print("Even")
|
s547464341
|
p03957
|
u397531548
| 1,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 184
|
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
|
s=input()
for i in range(len(s)):
for j in range(i,len(s)):
if s[i]=="C":
if s[j]=="F":
print("Yes")
break
else:
print("No")
|
s682122582
|
Accepted
| 19
| 2,940
| 173
|
s=input()
a="No"
for i in range(len(s)):
for j in range(i,len(s)):
if s[i]=="C":
if s[j]=="F":
a="Yes"
break
print(a)
|
s717069604
|
p03719
|
u871596687
| 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 <= b <= c:
print("Yes")
else:
print("No")
|
s339452222
|
Accepted
| 17
| 2,940
| 93
|
a,b,c = map(int,input().split())
if a <= c and b>=c:
print("Yes")
else:
print("No")
|
s571674793
|
p02744
|
u948524308
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 451
|
In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order.
|
N=int(input())
def combi(N,K):
ans1=1
ans2=1
for i in range(K):
ans1=ans1*(N-i)
ans2=ans2*(K-i)
ans=ans1//ans2
return ans
def rec(n):
if n==1:
return 1
else:
ans=0
for i in range(1,n+1):
if i==1:
ans+=1
elif i<n:
ans+=combi(n-1,n-i)
elif i==n:
ans+=rec(n-1)
return ans
a=rec(N)
print(a)
|
s120689659
|
Accepted
| 302
| 13,172
| 414
|
N=int(input())
if N==1:
print("a")
exit()
from collections import deque
from collections import Counter
abc="abcdefghijklmnopqrstuvwxyz"
ans=["a"]
for i in range(1,N):
d=deque(ans)
ans=[]
while d:
temp=d.popleft()
temp2=list(temp)
cnt=Counter(temp2)
L=len(cnt)
for j in range(L+1):
ans.append(temp+abc[j])
for a in ans:
print(a)
|
s592183528
|
p03657
|
u623349537
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 120
|
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 can have the same number of cookies.
|
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
print("Yes")
else:
print("No")
|
s255059557
|
Accepted
| 17
| 2,940
| 133
|
A, B = map(int, input().split())
if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:
print("Possible")
else:
print("Impossible")
|
s080353474
|
p00107
|
u742505495
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,672
| 241
|
Jerry is a little mouse. He is trying to survive from the cat Tom. Jerry is carrying a parallelepiped-like piece of cheese of size _A_ × _B_ × _C_. It is necessary to trail this cheese to the Jerry's house. There are several entrances in the Jerry's house. Each entrance is a rounded hole having its own radius _R_. Could you help Jerry to find suitable holes to be survive? Your task is to create a program which estimates whether Jerry can trail the cheese via each hole. The program should print "OK" if Jerry can trail the cheese via the corresponding hole (without touching it). Otherwise the program should print "NA". You may assume that the number of holes is less than 10000.
|
import math
while True:
d,w,h = map(int,input().split())
if d == 0:
break
n = int(input())
dist = [d**2+w**2, d**2+h**2, w**2+h**2]
leng = min(dist)
for i in range(n):
if leng-int(input()) > 0:
print('OK')
else:
print('NA')
|
s793509210
|
Accepted
| 30
| 7,760
| 276
|
import math
while True:
d,w,h = map(int,input().split())
if d == 0:
break
n = int(input())
dist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]
leng = min(dist)
for i in range(n):
if 2*int(input())-leng > 0:
print('OK')
else:
print('NA')
|
s490610853
|
p03828
|
u463858127
| 2,000
| 262,144
|
Wrong Answer
| 197
| 3,188
| 1,246
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
import math
N = int(input())
class remainder():
def __init__(self, mod=(10**9 + 7)):
self.mod = mod
def mul(self, a, b):
return ((a % self.mod) * (b % self.mod)) % self.mod
def pow(self, a, b):
bp = []
#bp.append(1)
bp.append(a)
n = len(bin(b)) - 2
for x in range(n):
bp.append(bp[x]**2 % self.mod)
res = 1
for x in range(n):
if b >> x & 1:
res = (res * bp[x]) % self.mod
return res
def div(self, a, b):
return self.mul(a, self.pow(b, self.mod - 2))
def findAllOfPrime(N):
prime = [True] * (N + 1)
prime[0] = False
prime[1] = False
x = 2
while x**2 <= N:
if prime[x]:
j = 2
while x * j <= N:
prime[x * j] = False
j += 1
x += 1
return prime
re = remainder()
primes = set()
for n in range(1, N + 1):
prime = findAllOfPrime(n)
for i, p in enumerate(prime):
if p:
primes.add(i)
print(primes)
A = math.factorial(N)
ans = 1
for p in primes:
cnt = 1
while A % p == 0:
cnt += 1
A //= p
ans = re.mul(ans, cnt)
print(ans)
|
s627500885
|
Accepted
| 192
| 3,064
| 1,231
|
import math
N = int(input())
class remainder():
def __init__(self, mod=(10**9 + 7)):
self.mod = mod
def mul(self, a, b):
return ((a % self.mod) * (b % self.mod)) % self.mod
def pow(self, a, b):
bp = []
#bp.append(1)
bp.append(a)
n = len(bin(b)) - 2
for x in range(n):
bp.append(bp[x]**2 % self.mod)
res = 1
for x in range(n):
if b >> x & 1:
res = (res * bp[x]) % self.mod
return res
def div(self, a, b):
return self.mul(a, self.pow(b, self.mod - 2))
def findAllOfPrime(N):
prime = [True] * (N + 1)
prime[0] = False
prime[1] = False
x = 2
while x**2 <= N:
if prime[x]:
j = 2
while x * j <= N:
prime[x * j] = False
j += 1
x += 1
return prime
re = remainder()
primes = set()
for n in range(1, N + 1):
prime = findAllOfPrime(n)
for i, p in enumerate(prime):
if p:
primes.add(i)
A = math.factorial(N)
ans = 1
for p in primes:
cnt = 1
while A % p == 0:
cnt += 1
A //= p
ans = re.mul(ans, cnt)
print(ans)
|
s598215113
|
p03140
|
u410118019
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 218
|
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 between 1 and N (inclusive). Change the i-th character from the beginning of the chosen string to some other lowercase English letter. What is the minimum number of operations required to achieve the objective?
|
import sys
n = int(input())
a,b,c = sys.stdin
count = 0
for i in range(n):
if a[i] == b[i] == c[i]:
continue
elif a[i] == b[i] or a[i] == b[i] or b[i] == c[i]:
count += 1
else:
count += 2
print(count)
|
s932841753
|
Accepted
| 17
| 3,060
| 218
|
import sys
n = int(input())
a,b,c = sys.stdin
count = 0
for i in range(n):
if a[i] == b[i] == c[i]:
continue
elif a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
count += 1
else:
count += 2
print(count)
|
s762852531
|
p03545
|
u197553307
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 264
|
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.
|
A, B, C, D = list(input())
oplist = ['+', '-']
for op1 in oplist:
for op2 in oplist:
for op3 in oplist:
f = A + op1 + B + op2 + C + op3 + D
ans = eval(f)
if ans == 7:
print(f)
quit()
|
s249978029
|
Accepted
| 18
| 3,060
| 271
|
A, B, C, D = list(input())
oplist = ['+', '-']
for op1 in oplist:
for op2 in oplist:
for op3 in oplist:
f = A + op1 + B + op2 + C + op3 + D
ans = eval(f)
if ans == 7:
print(f + "=7")
quit()
|
s749269357
|
p03456
|
u600537133
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 102
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
num = int(input().replace(' ', ''))
if (num ** .5).is_integer():
print('OK')
else:
print('NG')
|
s194203642
|
Accepted
| 17
| 2,940
| 103
|
num = int(input().replace(' ', ''))
if (num ** .5).is_integer():
print('Yes')
else:
print('No')
|
s962966150
|
p02694
|
u721425712
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,156
| 128
|
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?
|
# B
x = int(input())
deposit = 100
count = 0
while x >= deposit:
deposit += deposit*1//100
count += 1
print(count)
|
s980755080
|
Accepted
| 22
| 9,164
| 127
|
# B
x = int(input())
deposit = 100
count = 0
while x > deposit:
deposit += deposit*1//100
count += 1
print(count)
|
s097941875
|
p04043
|
u391059484
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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.
|
def iroha(a,b,c):
if a*b*c == 5*5*7 and (a == b or a ==c):
return YES
else:
return NO
|
s020373792
|
Accepted
| 17
| 2,940
| 87
|
a,b,c = map(int, input().split())
if a*b*c == 5*5*7:
print('YES')
else:
print('NO')
|
s279302538
|
p03457
|
u991269553
| 2,000
| 262,144
|
Wrong Answer
| 858
| 3,444
| 204
|
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 t-(x+y)%2 == 0 or t == x + y:
print('Yes')
elif t-(x+y) == 1:
print('No')
else:
print('no')
|
s759753983
|
Accepted
| 459
| 34,604
| 415
|
n = int(input())
a = [input().split() for l in range(n)]
b = 0
t = [0]
x = [0]
y = [0]
for i in range(n):
t.append(a[i][0])
x.append(a[i][1])
y.append(a[i][2])
for k in range(n):
o = int(t[k+1])-int(t[k])
p = int(x[k+1])-int(x[k])
q = int(y[k+1])-int(y[k])
if (o >= p+q) and ((o - (p+q))%2 == 0):
b += 1
else:
b = b
if b == n:
print('Yes')
else:
print('No')
|
s212142684
|
p00018
|
u519227872
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,652
| 64
|
Write a program which reads five numbers and sorts them in descending order.
|
l = list(map(int,input().split()))
l.sort(reverse=True)
print(l)
|
s832074292
|
Accepted
| 20
| 7,716
| 98
|
l = list(map(int,input().split()))
l.sort(reverse=True)
l = [str(i) for i in l]
print(' '.join(l))
|
s646559695
|
p03477
|
u630211216
| 2,000
| 262,144
|
Wrong Answer
| 23
| 9,128
| 124
|
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
A,B,C,D=map(int,input().split())
if A+B>C+D:
print("left")
elif A+B<C+D:
print("Right")
else:
print("Balanced")
|
s685979367
|
Accepted
| 29
| 9,088
| 124
|
A,B,C,D=map(int,input().split())
if A+B>C+D:
print("Left")
elif A+B<C+D:
print("Right")
else:
print("Balanced")
|
s710846000
|
p02607
|
u347640436
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,000
| 86
|
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
N, *a = map(int, open(0).read().split())
print(sum(e for e in a[::2] if e % 2 == 1))
|
s259704906
|
Accepted
| 25
| 8,984
| 76
|
N, *a = map(int, open(0).read().split())
print(sum(e % 2 for e in a[::2]))
|
s171595344
|
p02831
|
u347600233
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 203
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
def gcd(a, b):
if a < b:
a, b = b, a
while b != 0 :
a, b = b, a % b
return a
def lcm(a, b):
return (a * b) / gcd(a, b)
a , b = map(int, input().split())
print(lcm(a, b))
|
s987107140
|
Accepted
| 29
| 9,100
| 77
|
from math import gcd
a, b = map(int, input().split())
print(a*b // gcd(a, b))
|
s794866495
|
p04043
|
u121698457
| 2,000
| 262,144
|
Wrong Answer
| 16
| 2,940
| 106
|
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.
|
lis = sorted(input().split())
print(lis)
if lis == ['5', '5', '7']:
print('Yes')
else:
print('No')
|
s472482786
|
Accepted
| 17
| 2,940
| 95
|
lis = sorted(input().split())
if lis == ['5', '5', '7']:
print('YES')
else:
print('NO')
|
s383452364
|
p03696
|
u623687794
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
n=int(input())
s=input()
r=0;l=0
for i in s:
if i=="(":
r+=1
else:
l+=1
print("("*l+s+")"*r)
|
s159653495
|
Accepted
| 17
| 2,940
| 172
|
n=int(input())
s=input()
r=0;l=0
for i in s:
if i=="(":
r+=1
else:
if r==0:
l+=1
continue
r-=1
print("("*l+s+")"*r)
|
s228556908
|
p03693
|
u226779434
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,008
| 78
|
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r,g,b =map(int,input().split())
print("YES" if r*100+g*10+b % 4 ==0 else "NO")
|
s000748598
|
Accepted
| 27
| 8,904
| 78
|
r,g,b =map(int,input().split())
print("YES" if (r*100+g*10+b)%4 ==0 else "NO")
|
s196335164
|
p04043
|
u530786533
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 118
|
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.
|
x = [int(i) for i in input().split()]
if (x.count(5) == 2 and x.count(7) == 1):
print('Yes')
else:
print('No')
|
s977928684
|
Accepted
| 17
| 2,940
| 118
|
x = [int(i) for i in input().split()]
if (x.count(5) == 2 and x.count(7) == 1):
print('YES')
else:
print('NO')
|
s216644142
|
p02393
|
u936401118
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,616
| 86
|
Write a program which reads three integers, and prints them in ascending order.
|
a,b,c = map(int, input().split())
if a < b < c :
print ("Yes")
else:
print ("No")
|
s495797604
|
Accepted
| 10
| 7,688
| 66
|
a = list(map(int, input().split()))
a.sort()
print(a[0],a[1],a[2])
|
s614060138
|
p02742
|
u065137691
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 98
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
a, b= map(int, input().split())
if (a * b)%2 == 0:
print((a*b)/2)
else:
print((a*b)-(a+b))
|
s977610608
|
Accepted
| 17
| 2,940
| 232
|
def main():
a, b= map(int, input().split())
if a == 1 or b == 1:
print('1')
else:
if (a*b)%2 == 0:
print(round((a*b)/2))
else:
print(round(((a//2)+(a%2))*b)-(b//2))
main()
|
s169428084
|
p03827
|
u441320782
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 95
|
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 during the operations (including before the first operation, and after the last operation).
|
N=int(input())
S=input()
x=0
for i in S:
if i=="I":
x+=1
elif i=="D":
x-=1
print(x)
|
s682570765
|
Accepted
| 17
| 2,940
| 126
|
N=int(input())
S=input()
x=0
ans=[0]
for i in S:
if i=="I":
x+=1
elif i=="D":
x-=1
ans.append(x)
print(max(ans))
|
s638013638
|
p02742
|
u137667583
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 67
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h,w = map(int,input().split())
print(int(h/2+0.5)*w-(w%2)*int(w/2))
|
s656089514
|
Accepted
| 17
| 2,940
| 90
|
h,w = map(int,input().split())
print((int(h/2+0.5)*w-(h%2)*int(w/2))if(h-1)and(w-1)else 1)
|
s817461287
|
p03997
|
u137228327
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,096
| 69
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s916102295
|
Accepted
| 26
| 9,104
| 74
|
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h/2))
|
s001213161
|
p02420
|
u587193722
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,612
| 168
|
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 last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
|
while True:
s = input()
if s == '-':
break
m = int(input())
for mi in range(m):
h = int(input())
s = s[:h] + s[h:]
print(s)
|
s135208956
|
Accepted
| 20
| 7,592
| 168
|
while True:
s = input()
if s == '-':
break
m = int(input())
for mi in range(m):
h = int(input())
s = s[h:] + s[:h]
print(s)
|
s094343799
|
p03699
|
u133936772
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 63
|
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
|
_,*l=map(int,open(0).read().split());s=sum(l);print(s*(s%10>0))
|
s936894796
|
Accepted
| 18
| 3,060
| 103
|
_,*l=map(int,open(0))
s=b=0
m=100
for i in l:
s+=i
if i%10: b=1; m=min(m,i)
print((s-m*(s%10<1))*b)
|
s684047893
|
p03852
|
u816631826
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 159
|
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
s=['a','i','o','u','e']
x=input()
falg=0
for i in s:
if (i==x):
falg=1
break
if falg==0:
print('consonant.g')
else:
print("vowel.")
|
s763610304
|
Accepted
| 17
| 3,060
| 156
|
s=['a','i','o','u','e']
x=input()
falg=0
for i in s:
if (i==x):
falg=1
break
if falg==0:
print('consonant')
else:
print("vowel")
|
s827293891
|
p03607
|
u398846051
| 2,000
| 262,144
|
Wrong Answer
| 190
| 7,072
| 238
|
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
|
N = int(input())
a = [int(input()) for _ in range(N)]
a.sort
ans = 0
now = 0
cnt = 0
for x in a:
if x == now:
cnt += 1
continue
if cnt % 2 == 1:
ans += 1
cnt = 1
if cnt % 2 == 1:
ans += 1
print(ans)
|
s240295238
|
Accepted
| 223
| 7,488
| 252
|
N = int(input())
a = [int(input()) for _ in range(N)]
a.sort()
ans = 0
now = 0
cnt = 0
for x in a:
if x == now:
cnt += 1
continue
if cnt % 2 == 1:
ans += 1
cnt = 1
now = x
if cnt % 2 == 1:
ans += 1
print(ans)
|
s971469195
|
p02390
|
u602702913
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,580
| 76
|
Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively.
|
S=int(input())
h=S//3600
m=(S%3600)//60
s=S-((h*3600)+(m*60))
print(h,m,s)
|
s413336025
|
Accepted
| 20
| 5,588
| 86
|
S=int(input())
h=S//3600
m=(S%3600)//60
s=S-((h*3600)+(m*60))
print(h,m,s, sep=':')
|
s638911658
|
p02417
|
u184749404
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,564
| 136
|
Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters.
|
import sys
s = sys.stdin.readlines()
for i in range(26):
s.count(chr(97+i))
print(chr(97+i)+" : "+str(s.count(chr(97+i))))
|
s798338174
|
Accepted
| 20
| 5,560
| 144
|
import sys
s=sys.stdin.read().lower()
for i in range(26):
s.count(chr(97+i))
print(chr(97+i)+" : "+str(s.count(chr(97+i))))
|
s709010509
|
p04043
|
u760794812
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 272
|
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())
list = []
if a == 5 or a == 7:
if b == 5 or b == 7:
if a == b and a == 7:
Answer = 'NO'
elif c == 5:
Answer = 'YES'
else:
Answer = 'NO'
else:
Answer = 'NO'
else:
Answer = 'NO'
print(Answer)
|
s095600312
|
Accepted
| 17
| 2,940
| 143
|
List = [i for i in input().split()]
List.sort()
if List[0] == '5' and List[1] == '5' and List[2] == '7':
print('YES')
else:
print('NO')
|
s415562444
|
p03386
|
u282657760
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 188
|
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 = map(int, input().split())
ans = []
for i in range(A, A+K):
ans.append(i)
for i in range(B-K+1, B+1):
ans.append(i)
ans = set(ans)
for i in ans:
if i>=A and i<=B:
print(i)
|
s348602668
|
Accepted
| 17
| 3,064
| 218
|
A,B,K = map(int, input().split())
ans = []
for i in range(A, A+K):
ans.append(i)
for i in range(B-K+1, B+1):
ans.append(i)
ans = list(set(ans))
ans.sort(reverse=False)
for i in ans:
if i>=A and i<=B:
print(i)
|
s696133734
|
p03493
|
u270962921
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 18
|
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.
|
input().count('1')
|
s936706212
|
Accepted
| 17
| 2,940
| 25
|
print(input().count('1'))
|
s931949810
|
p04043
|
u325956328
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 110
|
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 = list(map(int, input().split()))
if s.count(5) == 2 and s.count(7) == 1:
print('Yes')
else:
print('No')
|
s928532314
|
Accepted
| 18
| 2,940
| 110
|
s = list(map(int, input().split()))
if s.count(5) == 2 and s.count(7) == 1:
print('YES')
else:
print('NO')
|
s045065126
|
p03861
|
u408958033
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 278
|
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?
|
def cin():
return map(int,input().split())
def cino(test=False):
if not test:
return int(input())
else:
return input()
def cina():
return list(map(int,input().split()))
def ssplit():
return list(input().split())
a,b,c = cin()
print(b//c - a//c)
|
s071034883
|
Accepted
| 21
| 3,316
| 300
|
def cin():
return map(int,input().split())
def cino(test=False):
if not test:
return int(input())
else:
return input()
def cina():
return list(map(int,input().split()))
def ssplit():
return list(input().split())
import math
a,b,c = cin()
print(b//c - a//c+(a%c==0))
|
s220378007
|
p02613
|
u665090185
| 2,000
| 1,048,576
|
Wrong Answer
| 153
| 16,336
| 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 = "AC"
WA = "WA"
TLE = "TLE"
RE = "RE"
list = []
for i in range(N):
string = input()
list.append(string)
C0 = list.count(AC)
C1 = list.count(WA)
C2 = list.count(TLE)
C3 = list.count(RE)
print(AC+f" x {C0}")
print(AC+f" x {C1}")
print(AC+f" x {C2}")
print(AC+f" x {C3}")
|
s914582828
|
Accepted
| 156
| 16,284
| 268
|
N = int(input())
C0 = "AC"
C1 = "WA"
C2 = "TLE"
C3 = "RE"
list = []
for i in range(N):
string = input()
list.append(string)
print(f"{C0} x {list.count(C0)}")
print(f"{C1} x {list.count(C1)}")
print(f"{C2} x {list.count(C2)}")
print(f"{C3} x {list.count(C3)}")
|
s705860859
|
p02613
|
u952968889
| 2,000
| 1,048,576
|
Wrong Answer
| 172
| 23,892
| 49
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n=int(input())
a = [[input()] for i in range(n)]
|
s477408104
|
Accepted
| 152
| 16,164
| 210
|
n=int(input())
a = []
for _ in range(n):
a.append(input())
print("AC x " + str(a.count("AC")))
print("WA x " + str(a.count("WA")))
print("TLE x " + str(a.count("TLE")))
print("RE x " + str(a.count("RE")))
|
s687399188
|
p02602
|
u453623947
| 2,000
| 1,048,576
|
Wrong Answer
| 302
| 31,428
| 191
|
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 multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k) :
print(a[1+i],a[k+i])
if a[0+i] < a[k+i] :
print("Yes")
else :
print("No")
|
s549885573
|
Accepted
| 155
| 31,600
| 166
|
n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-k) :
if a[0+i] < a[k+i] :
print("Yes")
else :
print("No")
|
s319760189
|
p03474
|
u136843617
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,188
| 422
|
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
def solve():
A,B = map(int,input().split())
S = input()
seq = [str(x) for x in range(10)]
print(seq)
for i in range(A+B+1):
if i== A:
if S[i] != "-":
return False
else:
if not(S[i] in seq):
return False
return True
if __name__ == '__main__':
cond = solve()
if cond:
print("Yes")
else:
print("No")
|
s117122584
|
Accepted
| 17
| 3,060
| 407
|
def solve():
A,B = map(int,input().split())
S = input()
seq = [str(x) for x in range(10)]
for i in range(A+B+1):
if i== A:
if S[i] != "-":
return False
else:
if not(S[i] in seq):
return False
return True
if __name__ == '__main__':
cond = solve()
if cond:
print("Yes")
else:
print("No")
|
s594514287
|
p02663
|
u597455618
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 9,108
| 88
|
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?
|
h1, m1, h2, m2, k = map(int, input().split())
print(min(0, (h2*60+m2) - (h1*60+m1) - k))
|
s755834845
|
Accepted
| 20
| 9,168
| 88
|
h1, m1, h2, m2, k = map(int, input().split())
print(max(0, (h2*60+m2) - (h1*60+m1) - k))
|
s853126443
|
p03943
|
u407158193
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 119
|
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 = list(map(int,input().split()))
A.sort(reverse = True)
if A[0] == (A[1] + A[2]):
print('YES')
else:
print('NO')
|
s429486488
|
Accepted
| 17
| 2,940
| 119
|
A = list(map(int,input().split()))
A.sort(reverse = True)
if A[0] == (A[1] + A[2]):
print('Yes')
else:
print('No')
|
s176363960
|
p02394
|
u217069758
| 1,000
| 131,072
|
Wrong Answer
| 40
| 7,768
| 181
|
Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given.
|
def check(W, H, x, y, r):
if W - x < r or H - y < r:
return "No"
else:
return "Yes"
L = list(map(int, input().split()))
check(L[0], L[1], L[2], L[3], L[4])
|
s173881592
|
Accepted
| 20
| 7,772
| 124
|
W, H, x, y, r = [int(x) for x in input().split()]
print("Yes" if (W - x >= r and H - y >= r and x > 0 and y > 0) else "No")
|
s584524587
|
p03719
|
u846150137
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
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=[int(i) for i in input().split()]
print("YES" if a<=c<=b else "NO")
|
s351650989
|
Accepted
| 17
| 2,940
| 73
|
a,b,c=[int(i) for i in input().split()]
print("Yes" if a<=c<=b else "No")
|
s556145573
|
p02843
|
u699944218
| 2,000
| 1,048,576
|
Time Limit Exceeded
| 2,104
| 3,064
| 292
|
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
|
X = int(input())
flag = 0
for a in range(0,1001):
for b in range(0,1001):
for c in range(0,1001):
for d in range(0,1001):
for e in range(0,1001):
for f in range(0,1001):
if 100*a+101*b+102*c+103*d+104*e+105*f == X:
flag += 1
print(flag)
|
s380574770
|
Accepted
| 18
| 2,940
| 114
|
X = int(input())
flag = 0
for C in range(X+1):
if 100*C <= X and 105*C >= X:
flag += 1
break
print(flag)
|
s081303966
|
p03494
|
u766407523
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,104
| 2,940
| 274
|
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())
Astr = input().split()
An = []
for A in Astr:
An.append(int(A))
count = 0
end = 0
while end == 0:
for A in An:
if A%2==1:
print(count)
end = 1
break
else:
A /= 2
count += 1
|
s546750340
|
Accepted
| 19
| 3,060
| 272
|
N = int(input())
Astr = input().split()
A = []
for A_i in Astr:
A.append(int(A_i))
candidate = 0
end = 0
while end == 0:
for A_i in A:
if (A_i/2**(candidate))%2 != 0:
end = 1
break
else:
candidate += 1
print(candidate)
|
s604387747
|
p03192
|
u886274153
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 117
|
You are given an integer N that has exactly four digits in base ten. How many times does `2` occur in the base-ten representation of N?
|
suuji = input()
print('input', suuji)
kaisu = 0
for i in suuji:
if i == "2":
kaisu += 1
else:
pass
print(kaisu)
|
s624553729
|
Accepted
| 18
| 2,940
| 95
|
suuji = input()
kaisu = 0
for i in suuji:
if i == "2":
kaisu += 1
else:
pass
print(kaisu)
|
s740761938
|
p04043
|
u242580186
| 2,000
| 262,144
|
Wrong Answer
| 32
| 9,360
| 457
|
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.
|
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque
input = sys.stdin.readline
def inp():
return int(input())
def inpl():
return list(map(int, input().split()))
INF = 1001001001
# ---------------------------------------
def main():
A = inpl()
A.sort()
if A[0]==A[1]==5 and A[2]==7:
print("Yes")
else:
print("No")
main()
|
s949187482
|
Accepted
| 29
| 9,392
| 457
|
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
from collections import deque
input = sys.stdin.readline
def inp():
return int(input())
def inpl():
return list(map(int, input().split()))
INF = 1001001001
# ---------------------------------------
def main():
A = inpl()
A.sort()
if A[0]==A[1]==5 and A[2]==7:
print("YES")
else:
print("NO")
main()
|
s113026844
|
p02393
|
u138661634
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,528
| 71
|
Write a program which reads three integers, and prints them in ascending order.
|
a, b, c = map(int, input().split())
print("Yes" if a < b < c else "No")
|
s965220581
|
Accepted
| 20
| 7,664
| 66
|
l = map(int, input().split())
print(' '.join(map(str, sorted(l))))
|
s277358779
|
p03407
|
u267242314
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 83
|
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
A, B, C = map(int,input().split())
if A+B>C:
print('yes')
else:
print('no')
|
s155757948
|
Accepted
| 17
| 2,940
| 84
|
A, B, C = map(int,input().split())
if A+B>=C:
print('Yes')
else:
print('No')
|
s298694437
|
p03795
|
u314057689
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,316
| 54
|
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 = N*800
y = int(N//15)
print(x-y)
|
s506029143
|
Accepted
| 20
| 3,316
| 70
|
N = int(input())
x = N*800
y = int(N//15) * 200
print(x-y)
|
s991625954
|
p01131
|
u591052358
| 8,000
| 131,072
|
Wrong Answer
| 60
| 5,636
| 1,722
|
Alice さんは Miku さんに携帯電話でメールを送ろうとしている。 携帯電話には入力に使えるボタンは数字のボタンしかない。 そこで、文字の入力をするために数字ボタンを何度か押して文字の入力を行う。携帯電話の数字ボタンには、次の文字が割り当てられており、ボタン 0 は確定ボタンが割り当てられている。この携帯電話では 1 文字の入力が終わったら必ず確定ボタンを押すことになっている。 * 1: . , ! ? (スペース) * 2: a b c * 3: d e f * 4: g h i * 5: j k l * 6: m n o * 7: p q r s * 8: t u v * 9: w x y z * 0: 確定ボタン 例えば、ボタン 2、ボタン 2、ボタン 0 と押すと、文字が 'a' → 'b' と変化し、ここで確定ボタンが押されるので、文字 b が出力される。 同じ数字を続けて入力すると変化する文字はループする。すなわち、ボタン 2 を 5 回押して、次にボタン 0 を押すと、文字が 'a' → 'b' → 'c' → 'a' → 'b' と変化し、ここで確定ボタンを押されるから 'b' が出力される。 何もボタンが押されていないときに確定ボタンを押すことはできるが、その場合には何も文字は出力されない。 あなたの仕事は、Alice さんが押したボタンの列から、Alice さんが作ったメッセージを再現することである。
|
def moji(x,ans):
if ans == 0:
return
if x == 1:
if(ans%4==1):
str = '.'
elif(ans%4==2):
str =','
elif(ans%4==3):
str='!'
else:
str = '?'
if x == 2:
if(ans%3==1):
str = 'a'
elif(ans%3==2):
str = 'b'
else:
str = 'c'
if x == 3:
if(ans%3==1):
str = 'd'
elif(ans%3==2):
str = 'e'
else:
str = 'f'
if x == 4:
if(ans%3==1):
str = 'g'
elif(ans%3==2):
str = 'h'
else:
str = 'i'
if x == 5:
if(ans%3==1):
str = 'j'
elif(ans%3==2):
str = 'k'
else:
str = 'l'
if x == 6:
if(ans%3==1):
str = 'm'
elif(ans%3==2):
str = 'n'
else:
str = 'o'
if x == 7:
if(ans%4==1):
str = 'p'
elif(ans%4==2):
str = 'q'
elif(ans%4==3):
str ='r'
else:
str = 's'
if x == 8:
if(ans%3==1):
str = 't'
elif(ans%3==2):
str = 'u'
else:
str = 'v'
if x == 9:
if(ans%4==1):
str = 'w'
elif(ans%4==2):
str = 'x'
elif ans%4==3:
str = 'y'
else:
str = 'z'
print(str,end="")
def solve(str):
x = '-1'
ans =0
for s in str:
if s == '0':
moji(int(x),ans)
ans = 0
else:
x = s
ans +=1
N = int(input())
for i in range(N):
solve(input())
print()
|
s375463520
|
Accepted
| 60
| 5,632
| 1,765
|
def moji(x,ans):
if ans == 0:
return
if x == 1:
if(ans%5==1):
str = '.'
elif(ans%5==2):
str =','
elif(ans%5==3):
str='!'
elif ans%5==4:
str='?'
else:
str = ' '
if x == 2:
if(ans%3==1):
str = 'a'
elif(ans%3==2):
str = 'b'
else:
str = 'c'
if x == 3:
if(ans%3==1):
str = 'd'
elif(ans%3==2):
str = 'e'
else:
str = 'f'
if x == 4:
if(ans%3==1):
str = 'g'
elif(ans%3==2):
str = 'h'
else:
str = 'i'
if x == 5:
if(ans%3==1):
str = 'j'
elif(ans%3==2):
str = 'k'
else:
str = 'l'
if x == 6:
if(ans%3==1):
str = 'm'
elif(ans%3==2):
str = 'n'
else:
str = 'o'
if x == 7:
if(ans%4==1):
str = 'p'
elif(ans%4==2):
str = 'q'
elif(ans%4==3):
str ='r'
else:
str = 's'
if x == 8:
if(ans%3==1):
str = 't'
elif(ans%3==2):
str = 'u'
else:
str = 'v'
if x == 9:
if(ans%4==1):
str = 'w'
elif(ans%4==2):
str = 'x'
elif ans%4==3:
str = 'y'
else:
str = 'z'
print(str,end="")
def solve(str):
x = '-1'
ans =0
for s in str:
if s == '0':
moji(int(x),ans)
ans = 0
else:
x = s
ans +=1
N = int(input())
for i in range(N):
solve(input())
print()
|
s175899855
|
p03645
|
u248670337
| 2,000
| 262,144
|
Wrong Answer
| 574
| 11,948
| 189
|
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
n,m=map(int,input().split())
sa=set()
sb=set()
for i in range(m):
a,b=map(int,input().split())
if a==1:sb.add(b)
if b==1:sa.add(a)
print("IMPOSSIBLE" if len(sa&sb)==0 else "POSSIBLE")
|
s163992938
|
Accepted
| 621
| 18,892
| 245
|
n,m=map(int,input().split())
L1=set()
Ln=set()
for i in range(m):
a,b=map(int,input().split())
if a==1 or b==1:
L1.add(a if b==1 else b)
if a==n or b==n:
Ln.add(a if b==n else b)
print('POSSIBLE' if len(L1&Ln)!=0 else 'IMPOSSIBLE')
|
s673659364
|
p02613
|
u905329882
| 2,000
| 1,048,576
|
Wrong Answer
| 156
| 9,200
| 315
|
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())
lis = [0 for i in range(4)]
mo = ["AC","WA","TLE","RE"]
for ii in range(n):
i = input()
if i=="AC":
lis[0]+=1
elif i=="WA":
lis[1]+=1
elif i=="TLE":
lis[2]+=1
elif i == "RE":
lis[3]+=1
for i in range(4):
print(str(mo[i])+" × "+str(lis[i]))
|
s983406356
|
Accepted
| 152
| 9,212
| 332
|
n = int(input())
lis = [0 for i in range(4)]
mo = ["AC","WA","TLE","RE"]
for ii in range(n):
i = input()
if i=="AC":
lis[0]+=1
elif i=="WA":
lis[1]+=1
elif i=="TLE":
lis[2]+=1
elif i == "RE":
lis[3]+=1
for i in range(4):
tmp = "{0} x {1}".format(mo[i],lis[i])
print(tmp)
|
s278796681
|
p02268
|
u742013327
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,596
| 939
|
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
|
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
def binary_search(list_1, list_2):
count = 0
for b in list_2:
left_index = 0
right_index = len(list_1)
while left_index < right_index:
center = int((left_index + right_index) / 2)
if list_1[center] == b:
count += 1
break
elif b < list_1[center]:
right_index = center
elif b > list_1[center]:
left_index = center + 1
return count
if __name__ == "__main__":
n_listA = int(input())
a = list(set([n for n in input().split()]))
n_listB = int(input())
b = list(set([n for n in input().split()]))
print(binary_search(a,b))
|
s841477520
|
Accepted
| 430
| 17,012
| 935
|
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_B&lang=jp
def binary_search(list_1, list_2):
count = 0
for b in list_2:
left_index = 0
right_index = len(list_1)
while left_index < right_index:
center = int((left_index + right_index) / 2)
if list_1[center] == b:
count += 1
break
elif b < list_1[center]:
right_index = center
elif b > list_1[center]:
left_index = center + 1
return count
if __name__ == "__main__":
n_listA = int(input())
a = sorted(set([n for n in input().split()]))
n_listB = int(input())
b = set([n for n in input().split()])
print(binary_search(a,b))
|
s607536406
|
p03251
|
u106181248
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 349
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = max(a)+1
d = min(b)
e = 0
if c > d:
print("War")
else:
for i in range(c,d+1):
if x < i and i <= y:
print("No War")
print(i)
e = 1
break
if e == 0:
print("War")
|
s311948413
|
Accepted
| 17
| 3,064
| 328
|
n, m, x, y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = max(a)+1
d = min(b)
e = 0
if c > d:
print("War")
else:
for i in range(c,d+1):
if x < i and i <= y:
print("No War")
e = 1
break
if e == 0:
print("War")
|
s439247976
|
p03814
|
u083960235
| 2,000
| 262,144
|
Wrong Answer
| 60
| 6,888
| 337
|
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=str(input())
atoz=[]
for i in range(len(s)):
if(s[i]=="A"):
a=i
break
#print(a)
for i in range(a,len(s)):
atoz.append(s[i])
s_l=list(atoz)
#print(s_l)
r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
#print(i)
if(i!="Z"):
s_l.pop()
# print(s_l)
else:
break
# r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
print(str_s_l)
|
s563922489
|
Accepted
| 61
| 6,632
| 358
|
s=str(input())
atoz=[]
for i in range(len(s)):
if(s[i]=="A"):
a=i
break
#print(a)
for i in range(a,len(s)):
atoz.append(s[i])
s_l=list(atoz)
#print(s_l)
r_s=[]
s_l_kep=s_l
for i in (reversed(s_l)):
#print(i)
if(i!="Z"):
s_l.pop()
# print(s_l)
else:
break
# r_s.append(i)
#print(s_l)
str_s_l=''.join(s_l)
#print(str_s_l)
print(len(str_s_l))
|
s029920390
|
p02842
|
u169138653
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 89
|
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
import math
n=int(input())
if (n+1)//1.08-n//1.08>0:
print(n//1.08)
else:
print(':(')
|
s321768754
|
Accepted
| 30
| 2,940
| 92
|
n=int(input())
for i in range(n+1):
if int(1.08*i)==n:
print(i)
exit()
print(':(')
|
s139382468
|
p03090
|
u707124227
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 3,612
| 250
|
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 that at least one such graph exists under the constraints of this problem.
|
n=int(input())
if n%2==0:
for i in range(1,n):
for j in range(i+1,n+1):
if i+j!=n+1:
print(i,j)
else:
for i in range(1,n):
for j in range(i+1,n+1):
if i+j!=n:
print(i,j)
|
s538883585
|
Accepted
| 26
| 4,124
| 318
|
n=int(input())
ans=[]
if n%2==0:
for i in range(1,n):
for j in range(i+1,n+1):
if i+j!=n+1:
ans.append([i,j])
else:
for i in range(1,n):
for j in range(i+1,n+1):
if i+j!=n:
ans.append([i,j])
print(len(ans))
for i,j in ans:
print(i,j)
|
s186389528
|
p02409
|
u427088273
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,648
| 457
|
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
def create_List():
re_list = [[],[],[],[]]
for i in range(4):
for j in range(3):
re_list[i].append([0 for k in range(10)])
return re_list
num = create_List()
for _ in range(int(input())):
data = list(map(int,input().split()))
num[data[0]-1][data[1]-1][data[2]-1] = data[3]
# ????????????
for i in range(4):
for j in range(3):
print(' '.join(map(str,num[i][j])))
print('#'*20)
|
s984048473
|
Accepted
| 20
| 7,704
| 484
|
def create_List():
re_list = [[],[],[],[]]
for i in range(4):
for j in range(3):
re_list[i].append([0 for k in range(10)])
return re_list
num = create_List()
for _ in range(int(input())):
data = list(map(int,input().split()))
num[data[0]-1][data[1]-1][data[2]-1] += data[3]
# ????????????
for i in range(4):
for j in range(3):
print(' ' + ' '.join(map(str,num[i][j])))
if i == 3:
break
print('#'*20)
|
s667171834
|
p00905
|
u509278866
| 8,000
| 131,072
|
Wrong Answer
| 500
| 9,124
| 2,337
|
_Stylish_ is a programming language whose syntax comprises _names_ , that are sequences of Latin alphabet letters, three types of _grouping symbols_ , periods ('.'), and newlines. Grouping symbols, namely round brackets ('(' and ')'), curly brackets ('{' and '}'), and square brackets ('[' and ']'), must match and be nested properly. Unlike most other programming languages, Stylish uses periods instead of whitespaces for the purpose of term separation. The following is an example of a Stylish program. 1 ( Welcome .to 2 ......... Stylish ) 3 { Stylish .is 4 .....[.( a. programming . language .fun .to. learn ) 5 .......] 6 ..... Maybe .[ 7 ....... It. will .be.an. official . ICPC . language 8 .......] 9 .....} As you see in the example, a Stylish program is indented by periods. The _amount of indentation_ of a line is the number of leading periods of it. Your mission is to visit Stylish masters, learn their indentation styles, and become the youngest Stylish master. An indentation style for _well-indented_ Stylish programs is defined by a triple of integers, ( _R_ , _C_ , _S_ ), satisfying 1 ≤ _R_ , _C_ , _S_ ≤ 20\. _R_ , _C_ and _S_ are amounts of indentation introduced by an open round bracket, an open curly bracket, and an open square bracket, respectively. In a well-indented program, the amount of indentation of a line is given by _R_ ( _r o_ − _r c_) + _C_ ( _c o_ − _c c_) + _S_ ( _s o_ − _s c_), where _r o_, _c o_, and _s o_ are the numbers of occurrences of open round, curly, and square brackets in all preceding lines, respectively, and _r c_, _c c_, and _s c_ are those of close brackets. The first line has no indentation in any well- indented program. The above example is formatted in the indentation style ( _R_ , _C_ , _S_ ) = (9, 5, 2). The only grouping symbol occurring in the first line of the above program is an open round bracket. Therefore the amount of indentation for the second line is 9 * (1 − 0) + 5 * (0 − 0) + 2 *(0 − 0) = 9. The first four lines contain two open round brackets, one open curly bracket, one open square bracket, two close round brackets, but no close curly nor square bracket. Therefore the amount of indentation for the fifth line is 9 * (2 − 2) + 5 * (1 − 0) + 2 * (1 − 0) = 7. Stylish masters write only well-indented Stylish programs. Every master has his/her own indentation style. Write a program that imitates indentation styles of Stylish masters.
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
p,q = LI()
if p == 0:
break
a = [S() for _ in range(p)]
b = [S() for _ in range(q)]
aa = [[0,0,0,0]]
mc = 0
for c in a:
d = collections.Counter(c)
t = aa[-1][:]
t[0] += d['(']
t[0] -= d[')']
t[1] += d['{']
t[1] -= d['}']
t[2] += d['[']
t[2] -= d[']']
t[3] = 0
for ct in c:
if ct != '.':
break
t[3] += 1
if mc < t[3]:
mc = t[3]
aa.append(t)
k = []
for c1,c2,c3 in itertools.product(range(1,min(mc+1,21)), repeat=3):
f = True
for ci in range(p):
c = aa[ci]
if c[0] * c1 + c[1] * c2 + c[2] * c3 != aa[ci+1][3]:
f = False
break
if f:
k.append((c1,c2,c3))
bb = [[0,0,0]]
for c in b:
d = collections.Counter(c)
t = bb[-1][:]
t[0] += d['(']
t[0] -= d[')']
t[1] += d['{']
t[1] -= d['}']
t[2] += d['[']
t[2] -= d[']']
bb.append(t)
r = [0]
for c in bb[1:-1]:
s = set()
for c1,c2,c3 in k:
s.add(c[0]*c1+c[1]*c2+c[2]*c3)
if len(s) == 1:
r.append(list(s)[0])
else:
r.append(-1)
rr.append(' '.join(map(str,r)))
return '\n'.join(map(str,rr))
print(main())
|
s799660551
|
Accepted
| 430
| 9,116
| 2,395
|
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
while True:
p,q = LI()
if p == 0:
break
a = [S() for _ in range(p)]
b = [S() for _ in range(q)]
aa = [[0,0,0,0]]
mc = 0
for c in a:
d = collections.Counter(c)
t = aa[-1][:]
t[0] += d['(']
t[0] -= d[')']
t[1] += d['{']
t[1] -= d['}']
t[2] += d['[']
t[2] -= d[']']
t[3] = 0
for ct in c:
if ct != '.':
break
t[3] += 1
if mc < t[3]:
mc = t[3]
aa.append(t)
k = []
for c1,c2,c3 in itertools.product(range(1,min(mc+1,21)), repeat=3):
f = True
for ci in range(p):
c = aa[ci]
if c[0] * c1 + c[1] * c2 + c[2] * c3 != aa[ci+1][3]:
f = False
break
if f:
k.append((c1,c2,c3))
bb = [[0,0,0]]
for c in b:
d = collections.Counter(c)
t = bb[-1][:]
t[0] += d['(']
t[0] -= d[')']
t[1] += d['{']
t[1] -= d['}']
t[2] += d['[']
t[2] -= d[']']
bb.append(t)
r = [0]
for c in bb[1:-1]:
s = set()
for c1,c2,c3 in k:
s.add(c[0]*c1+c[1]*c2+c[2]*c3)
if len(s) == 1:
r.append(list(s)[0])
elif sum(c) == 0:
r.append(0)
else:
r.append(-1)
rr.append(' '.join(map(str,r)))
return '\n'.join(map(str,rr))
print(main())
|
s809440122
|
p03457
|
u798073524
| 2,000
| 262,144
|
Wrong Answer
| 325
| 3,060
| 162
|
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) > n or (x + y + t) % 2:
print("NO")
exit()
print("YES")
|
s464098713
|
Accepted
| 319
| 3,060
| 162
|
n = int(input())
for i in range(n):
t, x, y = map(int, input().split())
if (x + y) > t or (x + y + t) % 2:
print("No")
exit()
print("Yes")
|
s633612254
|
p03080
|
u163320134
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 125
|
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.
|
n=int(input())
s=input()
count=0
for i in s:
if i=='B':
count+=1
if count>(n-count):
print('Yes')
else:
print('No')
|
s587939876
|
Accepted
| 17
| 2,940
| 125
|
n=int(input())
s=input()
count=0
for i in s:
if i=='R':
count+=1
if count>(n-count):
print('Yes')
else:
print('No')
|
s263211290
|
p03545
|
u589578850
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 473
|
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.
|
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
one = -1
flg = False
for i in range(2):
for j in range(2):
for k in range(2):
if a + b*one**i + c*one**j + d*one**k == 7:
print(i,j,k)
flg = True
break
if flg:
break
if flg:
break
if i == 0 :
i_flg = "+"
else:
i_flg = "-"
if j == 0 :
j_flg = "+"
else:
j_flg = "-"
if k == 0 :
k_flg = "+"
else:
k_flg = "-"
print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')
|
s529855060
|
Accepted
| 19
| 3,188
| 456
|
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
one = -1
flg = False
for i in range(2):
for j in range(2):
for k in range(2):
if a + b*one**i + c*one**j + d*one**k == 7:
flg = True
break
if flg:
break
if flg:
break
if i == 0 :
i_flg = "+"
else:
i_flg = "-"
if j == 0 :
j_flg = "+"
else:
j_flg = "-"
if k == 0 :
k_flg = "+"
else:
k_flg = "-"
print(a,i_flg,b,j_flg,c,k_flg,d,"=7",sep='')
|
s631988679
|
p03845
|
u646352133
| 2,000
| 262,144
|
Wrong Answer
| 23
| 3,316
| 240
|
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
n = int(input())
t = list(map(int,input().split()))
m = int(input())
origin,ans = [],[]
for i in range(m):
p,x = map(int,input().split())
origin.append(t[p-1])
t[p-1] = x
ans.append(sum(t))
t[p-1] = origin[0]
origin = []
print(ans)
|
s945570505
|
Accepted
| 23
| 3,064
| 262
|
n = int(input())
t = list(map(int,input().split()))
m = int(input())
origin,ans = [],[]
for _ in range(m):
p,x = map(int,input().split())
origin.append(t[p-1])
t[p-1] = x
ans.append(sum(t))
t[p-1] = origin[0]
origin = []
for i in range(m):
print(ans[i])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.