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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s205571599
|
p02279
|
u533883485
| 2,000 | 131,072 |
Wrong Answer
| 30 | 7,688 | 1,116 |
A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node." Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ : * node ID of _u_ * parent of _u_ * depth of _u_ * node type (root, internal node or leaf) * a list of chidlren of _u_ If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent. A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node** The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_. The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_. Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1. Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input. **Fig. 2**
|
# coding=utf-8
class Node:
def __init__(self, idx, degree, children=None):
self.id = idx
self.parent = -1 #??????
self.depth = 0 #??????
self.type = None #??????
self.children = children
n = int(input())
data = [list(map(int, input().split())) for x in range(n)]
node_list = []
for data_row in data:
idx, degree, *children = data_row
node = Node(idx, degree, children)
node_list.append(node)
for i, node in enumerate(node_list):
if node.children:
node.type = "internal node"
for child in node.children:
node_list[child].parent = i
else:
node.type = "leaf"
for i, node in enumerate(node_list):
depth = 0
parent = node.parent
#?????\???type
if parent == -1:
node.type = "root"
while parent != -1:
parent = node_list[parent].parent
depth += 1
node.depth = depth
for node in node_list:
print("node:", str(node.id) + ", parent =", str(node.parent) + ", depth =", str(node.depth) + ",", node.type + "," , node.children)
|
s714758956
|
Accepted
| 1,160 | 68,488 | 1,124 |
# coding=utf-8
class Node:
def __init__(self, idx, degree, children=None):
self.id = idx
self.parent = -1 #??????
self.depth = 0 #??????
self.type = None #??????
self.children = children
n = int(input())
data = [list(map(int, input().split())) for x in range(n)]
node_list = [None for i in range(n)]
for data_row in data:
idx, degree, *children = data_row
node = Node(idx, degree, children)
node_list[idx] = node
for node in node_list:
i = node.id
if node.children:
node.type = "internal node"
for child in node.children:
node_list[child].parent = i
else:
node.type = "leaf"
for i, node in enumerate(node_list):
depth = 0
parent = node.parent
#?????\???type
if parent == -1:
node.type = "root"
while parent != -1:
parent = node_list[parent].parent
depth += 1
node.depth = depth
for node in node_list:
print("node {}: parent = {}, depth = {}, {}, {}".format(node.id, node.parent, node.depth, node.type, node.children))
|
s923549533
|
p03351
|
u280552586
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 79 |
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())
print('Yes' if abs(a-c) <= d else 'No')
|
s795901899
|
Accepted
| 18 | 2,940 | 114 |
a, b, c, d = map(int, input().split())
print('Yes' if abs(a-b) <= d and abs(b-c) <= d or abs(a-c) <= d else 'No')
|
s006195873
|
p03456
|
u502200133
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 142 |
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a, b = map(str, input().split())
num = int(a + b)
num1 = num ** 0.5
num2 = num1 * num1
if num1 == num2:
print("Yes")
else:
print("No")
|
s068899356
|
Accepted
| 17 | 2,940 | 146 |
a, b = map(str, input().split())
num = int(a + b)
num1 = int(num ** 0.5)
num2 = num1 * num1
if num == num2:
print("Yes")
else:
print("No")
|
s060010027
|
p02694
|
u919235786
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,206 | 9,068 | 84 |
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?
|
x=float(input())
a=float(100)
y=0
while a<x:
a*=1.01
a=a%1
y+=1
print(y)
|
s283539824
|
Accepted
| 23 | 9,092 | 107 |
x=float(input())
a=float(100)
y=0
import math
while a<x:
a=a*1.01
a=math.floor(a)
y+=1
print(y)
|
s132059796
|
p03149
|
u095021077
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 149 |
You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".
|
n=list(map(int, input().split()))+[1, 9, 7, 4]
if n.index(1)<4 and n.index(9)<4 and n.index(7)<4 and n.index(4)<4:
print('Yes')
else:
print('No')
|
s135644264
|
Accepted
| 17 | 3,060 | 149 |
n=list(map(int, input().split()))+[1, 9, 7, 4]
if n.index(1)<4 and n.index(9)<4 and n.index(7)<4 and n.index(4)<4:
print('YES')
else:
print('NO')
|
s358256842
|
p02612
|
u081714930
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,148 | 60 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
if n>=1000:
print(0)
else:
print(1000-n)
|
s793833771
|
Accepted
| 27 | 9,096 | 79 |
n=int(input())
while n>=0:
if 0<n<=1000:
print(1000-n)
n-=1000
|
s753146281
|
p03860
|
u806392288
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
AtCoder,s,Contest = map(str, input().split())
print(AtCoder[0] + " " + s[0] + " " + Contest[0])
|
s243721739
|
Accepted
| 17 | 2,940 | 85 |
AtCoder,s,Contest = map(str, input().split())
print(AtCoder[0] + s[0] + Contest[0])
|
s080729688
|
p03943
|
u757274384
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 144 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c = map(int ,input().split())
if a+b == c :
print("YES")
elif a+c == b:
print("YES")
elif b+c == a:
print("YES")
else :
print("NO")
|
s136837493
|
Accepted
| 17 | 2,940 | 107 |
a,b,c = map(int ,input().split())
if a == b+c or b == a+c or c == a+b:
print("Yes")
else :
print("No")
|
s823813239
|
p03943
|
u470359972
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 124 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=map(int,input().split())
#print(a,b,c)
#print(max(a,b,c))
if max(a,b,c)==(a+b+c)/2:
print("YES")
else:
print("NO")
|
s175304174
|
Accepted
| 17 | 2,940 | 124 |
a,b,c=map(int,input().split())
#print(a,b,c)
#print(max(a,b,c))
if max(a,b,c)==(a+b+c)/2:
print("Yes")
else:
print("No")
|
s477910299
|
p03712
|
u744898490
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 260 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
mat_small = []
xy = input().split(' ')
for i in range(int(xy[0])):
mat_small.append(input())
big = [(int(xy[0])+ 2)* '#' for a in range(int(xy[0])+ 2) ]
for s in range(1, (int(xy[0])+ 1)):
big[s] = '#' + mat_small[s-1] + '#'
print( big)
|
s611655165
|
Accepted
| 17 | 3,064 | 272 |
mat_small = []
xy = input().split(' ')
for i in range(int(xy[0])):
mat_small.append(input())
big = [(int(xy[1])+ 2)* '#' for a in range(int(xy[0])+ 2) ]
for s in range(1, (int(xy[0])+ 1)):
big[s] = '#' + mat_small[s-1] + '#'
for v in big:
print(v)
|
s044241809
|
p03476
|
u810787773
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,206 | 31,368 | 890 |
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
import numpy as np
def seachPrimeNum(N):
max = int(np.sqrt(N))
seachList = [i for i in range(2,N+1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
#def numsearch(list):
#print(i)
#if (i+1)/2 not in list:
#list.remove(i)
def main():
Q = int(input())
list = seachPrimeNum(100000)
#list2 = numsearch(list)
#print(list2)
c = [0]*100001
c[0] = 0
for i in range(1,100001,1):
#print(i)
if i in list and (i+1)/2 in list:
c[i] = c[i-1]+1
else:
c[i] = c[i-1]
#print(c)
for i in range(Q):
l,r = map(int,input().split())
print(c[r]-c[l-1])
main()
|
s553281476
|
Accepted
| 568 | 32,424 | 1,139 |
import numpy as np
def seachPrimeNum(N):
max = int(np.sqrt(N))
seachList = [i for i in range(2,N+1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
#def numsearch(list):
#print(i)
#if (i+1)/2 not in list:
#list.remove(i)
def main():
Q = int(input())
list = seachPrimeNum(100000)
check = [0]*100001
primeCheck = [0]*100001
for i in list:
primeCheck[i] = 1
for i in list:
if i == 2:
continue
tmp = int((i+1)/2)
if primeCheck[tmp] == 1:
check[i] = 1
c = [0]*100001
c[0] = 0
for i in range(1,100001,1):
#print(i)
if check[i] == 1:
c[i] = c[i-1]+1
else:
c[i] = c[i-1]
#print(c)
for i in range(Q):
l,r = map(int,input().split())
print(c[r]-c[l-1])
main()
|
s564794065
|
p04044
|
u263933075
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 46 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
a = input().split()
a.sort()
print("".join(a))
|
s377354642
|
Accepted
| 17 | 3,060 | 106 |
a=list(map(int,input().split()))
b=[]
for i in range(a[0]):
b.append(input())
b.sort()
print("".join(b))
|
s960583643
|
p03644
|
u742899538
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 157 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
nums = [1, 2, 4, 8, 16, 32, 64]
N = int(input())
result = nums[0]
for num in nums:
if N > num:
reuslt = num
else:
break
print(result)
|
s035390216
|
Accepted
| 17 | 2,940 | 158 |
nums = [1, 2, 4, 8, 16, 32, 64]
N = int(input())
result = nums[0]
for num in nums:
if N >= num:
result = num
else:
break
print(result)
|
s912778667
|
p02607
|
u674588203
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,060 | 155 |
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=int(input())
ai=list(map(int,input().split()))
ans=0
for i in range(N):
if i%2==0:
pass
if ai[i] %2==1:
ans+=1
print(ans)
|
s377800815
|
Accepted
| 24 | 9,096 | 155 |
N=int(input())
ai=list(map(int,input().split()))
ans=0
for i in range(N):
if i%2==1:
continue
if ai[i] %2==1:
ans+=1
print(ans)
|
s056068077
|
p02678
|
u285891772
| 2,000 | 1,048,576 |
Wrong Answer
| 831 | 50,604 | 1,237 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N, M = MAP()
graph = defaultdict(list)
for _ in range(M):
a, b = MAP()
graph[a-1].append(b-1)
graph[b-1].append(a-1)
print(graph)
check = [-1]*(N)
check[0] = 0
q = deque([0])
while q:
#print(q)
p = q.popleft()
for x in graph[p]:
#print(x)
if check[x] == -1:
check[x] = p+1
q.append(x)
if -1 in check:
print("No")
exit()
else:
print("Yes")
for i in range(1, N):
print(check[i])
|
s521326346
|
Accepted
| 733 | 45,148 | 1,238 |
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
N, M = MAP()
graph = defaultdict(list)
for _ in range(M):
a, b = MAP()
graph[a-1].append(b-1)
graph[b-1].append(a-1)
#print(graph)
check = [-1]*(N)
check[0] = 0
q = deque([0])
while q:
#print(q)
p = q.popleft()
for x in graph[p]:
#print(x)
if check[x] == -1:
check[x] = p+1
q.append(x)
if -1 in check:
print("No")
exit()
else:
print("Yes")
for i in range(1, N):
print(check[i])
|
s411249295
|
p00718
|
u328199937
| 1,000 | 131,072 |
Wrong Answer
| 60 | 6,300 | 1,237 |
Prof. Hachioji has devised a new numeral system of integral numbers with four lowercase letters "m", "c", "x", "i" and with eight digits "2", "3", "4", "5", "6", "7", "8", "9". He doesn't use digit "0" nor digit "1" in this system. The letters "m", "c", "x" and "i" correspond to 1000, 100, 10 and 1, respectively, and the digits "2", ...,"9" correspond to 2, ..., 9, respectively. This system has nothing to do with the Roman numeral system. For example, character strings > "5m2c3x4i", "m2c4i" and "5m2c3x" correspond to the integral numbers 5234 (=5*1000+2*100+3*10+4*1), 1204 (=1000+2*100+4*1), and 5230 (=5*1000+2*100+3*10), respectively. The parts of strings in the above example, "5m", "2c", "3x" and "4i" represent 5000 (=5*1000), 200 (=2*100), 30 (=3*10) and 4 (=4*1), respectively. Each of the letters "m", "c", "x" and "i" may be prefixed by one of the digits "2", "3", ..., "9". In that case, the prefix digit and the letter are regarded as a pair. A pair that consists of a prefix digit and a letter corresponds to an integer that is equal to the original value of the letter multiplied by the value of the prefix digit. For each letter "m", "c", "x" and "i", the number of its occurrence in a string is at most one. When it has a prefix digit, it should appear together with the prefix digit. The letters "m", "c", "x" and "i" must appear in this order, from left to right. Moreover, when a digit exists in a string, it should appear as the prefix digit of the following letter. Each letter may be omitted in a string, but the whole string must not be empty. A string made in this manner is called an _MCXI-string_. An MCXI-string corresponds to a positive integer that is the sum of the values of the letters and those of the pairs contained in it as mentioned above. The positive integer corresponding to an MCXI-string is called its MCXI-value. Moreover, given an integer from 1 to 9999, there is a unique MCXI-string whose MCXI-value is equal to the given integer. For example, the MCXI-value of an MCXI-string "m2c4i" is 1204 that is equal to `1000 + 2*100 + 4*1`. There are no MCXI-strings but "m2c4i" that correspond to 1204. Note that strings "1m2c4i", "mcc4i", "m2c0x4i", and "2cm4i" are not valid MCXI-strings. The reasons are use of "1", multiple occurrences of "c", use of "0", and the wrong order of "c" and "m", respectively. Your job is to write a program for Prof. Hachioji that reads two MCXI-strings, computes the sum of their MCXI-values, and prints the MCXI-string corresponding to the result.
|
ans_list = []
n = int(input())
def mcxl2digit(s):
ans = 0
dig = 1
for i in range(len(s)):
if "2" <= s[i] <= "9":
dig = int(s[i])
else:
if s[i] == "m":
key = 100
elif s[i] == "c":
key = 100
elif s[i] == "x":
key = 10
else:
key = 1
ans += key * dig
dig = 1
return ans
def digit2mcxl(i):
return_list = []
m = i // 1000
if m != 0 and m != 1:
return_list.append(str(m))
if m != 0:
return_list.append("m")
i = i % 1000
c = i // 100
if c != 0 and c != 1:
return_list.append(str(c))
if c != 0:
return_list.append("c")
i = i % 100
x = i // 10
if x != 0 and x != 1:
return_list.append(str(x))
if x != 0:
return_list.append("x")
i = i % 10
l = i
if l != 0 and l != 1:
return_list.append(str(l))
if l != 0:
return_list.append("l")
return return_list
for i in range(n):
a, b = input().split()
ans = (mcxl2digit(a) + mcxl2digit(b))
ans = digit2mcxl(ans)
ans_list.append(ans)
for i in ans_list:
print("".join(i))
|
s141270628
|
Accepted
| 60 | 6,296 | 1,301 |
ans_list = []
n = int(input())
def mcxl2digit(s):
ans = 0
dig = 1
for i in range(len(s)):
if "2" <= s[i] <= "9":
dig = int(s[i])
else:
if s[i] == "m":
key = 1000
elif s[i] == "c":
key = 100
elif s[i] == "x":
key = 10
else:
key = 1
ans += key * dig
dig = 1
return ans
def digit2mcxl(i):
return_list = []
m = i // 1000
if m != 0 and m != 1:
return_list.append(str(m))
if m != 0:
return_list.append("m")
i = i % 1000
c = i // 100
if c != 0 and c != 1:
return_list.append(str(c))
if c != 0:
return_list.append("c")
i = i % 100
x = i // 10
if x != 0 and x != 1:
return_list.append(str(x))
if x != 0:
return_list.append("x")
i = i % 10
l = i
if l != 0 and l != 1:
return_list.append(str(l))
if l != 0:
return_list.append("i")
return return_list
for i in range(n):
a, b = input().split()
ans = (mcxl2digit(a) + mcxl2digit(b))
#print(ans)
ans = digit2mcxl(ans)
ans_list.append(ans)
for i in ans_list:
print("".join(i))
|
s756098286
|
p03943
|
u410118019
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 46 |
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()))
print(sum(a))
|
s887205742
|
Accepted
| 17 | 2,940 | 96 |
a,b,c=map(int,input().split())
if a+b==c or a+c==b or b+c==a:
print("Yes")
else:
print("No")
|
s175400759
|
p02410
|
u587193722
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,656 | 345 |
Write a program which reads a $ n \times m$ matrix $A$ and a $m \times 1$ vector $b$, and prints their product $Ab$. A column vector with m elements is represented by the following equation. \\[ b = \left( \begin{array}{c} b_1 \\\ b_2 \\\ : \\\ b_m \\\ \end{array} \right) \\] A $n \times m$ matrix with $m$ column vectors, each of which consists of $n$ elements, is represented by the following equation. \\[ A = \left( \begin{array}{cccc} a_{11} & a_{12} & ... & a_{1m} \\\ a_{21} & a_{22} & ... & a_{2m} \\\ : & : & : & : \\\ a_{n1} & a_{n2} & ... & a_{nm} \\\ \end{array} \right) \\] $i$-th element of a $m \times 1$ column vector $b$ is represented by $b_i$ ($i = 1, 2, ..., m$), and the element in $i$-th row and $j$-th column of a matrix $A$ is represented by $a_{ij}$ ($i = 1, 2, ..., n,$ $j = 1, 2, ..., m$). The product of a $n \times m$ matrix $A$ and a $m \times 1$ column vector $b$ is a $n \times 1$ column vector $c$, and $c_i$ is obtained by the following formula: \\[ c_i = \sum_{j=1}^m a_{ij}b_j = a_{i1}b_1 + a_{i2}b_2 + ... + a_{im}b_m \\]
|
x, y = [int(i) for i in input().split()]
date = [[int(i) for i in input().split()]for i in range(1,x+1)]
date2 =[int(input())for i in range(1,y+1)]
date3 =[]
for k in range(x):
print(date[k])
print(date2)
for a in range(0,x):
for b in range(0,y):
date3 += [date2[b]*date[a][b]]
for h in range(0,len(date3)-1):
print(date3[h])
|
s112182578
|
Accepted
| 20 | 8,492 | 304 |
x, y = [int(i) for i in input().split()]
date = [[int(i) for i in input().split()]for i in range(1,x+1)]
date2 =[int(input())for i in range(1,y+1)]
date3 =[]
for a in range(0,x):
for b in range(0,y,):
date3 += [date2[b]*date[a][b]]
for d in range(0,len(date3),y):
print(sum(date3[d:d+y]))
|
s524551212
|
p03386
|
u064408584
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 134 |
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())
c=list(range(a,a+k))
d=list(range(b-k+1,b+1))
e=set(c+d)
for i in e:
if a<=i<=b:
print(i)
|
s871288382
|
Accepted
| 17 | 3,060 | 149 |
a,b,k =map(int, input().split())
c=list(range(a,a+k))
d=list(range(b-k+1,b+1))
e=list(set(c+d))
e.sort()
for i in e:
if a<=i<=b:
print(i)
|
s079733774
|
p03544
|
u244836567
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,192 | 92 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n=int(input())
a=2
b=1
c=3
i=0
while i<n:
d=a
e=b
a=b
b=c
c=a+b+c
i=i+1
print(a)
|
s637804976
|
Accepted
| 29 | 9,164 | 74 |
n=int(input())
a=2
b=1
i=0
while i<n:
d=a
a=b
b=d+b
i=i+1
print(a)
|
s886621805
|
p03711
|
u516447519
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,216 | 386 |
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
|
H,W = [int(i) for i in input().split()]
if H % 3 == 0 or W % 3 == 0:
print(0)
else:
s = []
for i in range(1,H//2 +1):
j = W//2
a = [i*W,j*(H-i),(W-j)*(H-i)]
b = max(a) - min(a)
s.append(b)
for i in range(1,W//2+1):
j = H//2
a = [H*i,(W-i)*j,(W-i)*(H-j)]
b = max(a) - min(a)
s.append(b)
print(min(s))
|
s407839595
|
Accepted
| 23 | 9,160 | 181 |
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
a,b = [int(i) for i in input().split()]
if a in A and b in A:
print('Yes')
elif a in B and b in B:
print('Yes')
else:
print('No')
|
s701200680
|
p03024
|
u883203948
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 100 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
data = input()
x = data.count("o")
if x + 15-len(data) >= 8:
print("yes")
else:
print("no")
|
s767858881
|
Accepted
| 18 | 3,064 | 100 |
data = input()
x = data.count("o")
if x + 15-len(data) >= 8:
print("YES")
else:
print("NO")
|
s099344722
|
p03730
|
u790012205
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 147 |
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 i * A % B == C:
print('Yes')
sys.exit()
print('No')
|
s694705150
|
Accepted
| 25 | 9,168 | 151 |
import sys
A, B, C = map(int, input().split())
N = A
while N < A * B:
if N % B == C:
print('YES')
sys.exit()
N += A
print('NO')
|
s986620735
|
p03485
|
u017415492
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 64 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import math
a,b=map(int,input().split())
print(math.ceil(a+b/2))
|
s478590746
|
Accepted
| 29 | 9,060 | 66 |
import math
a,b=map(int,input().split())
print(math.ceil((a+b)/2))
|
s103990365
|
p03486
|
u329706129
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 135 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
s = input()
t = input()
s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))
print(s, t)
print('Yes') if s < t else print('No')
|
s024824104
|
Accepted
| 18 | 2,940 | 123 |
s = input()
t = input()
s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))
print('Yes') if s < t else print('No')
|
s500587993
|
p03501
|
u808569469
| 2,000 | 262,144 |
Wrong Answer
| 25 | 8,976 | 77 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
n, a, b = map(int, input().split())
price = [a * n] + [b]
print(max(price))
|
s262084635
|
Accepted
| 29 | 8,964 | 58 |
n, a, b = map(int, input().split())
print(min(a * n, b))
|
s283154969
|
p03814
|
u702996070
| 2,000 | 262,144 |
Wrong Answer
| 57 | 3,816 | 231 |
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`.
|
#!/usr/bin/env python3
if __name__ == '__main__':
s = str(input())
L = len(s)
beg = -1
end = -1
for i in range(0,L):
if s[i]=='A' and beg==-1:
beg = i
elif s[i]=='Z':
end = i
print(s[beg:end-beg+1])
|
s076225766
|
Accepted
| 60 | 3,516 | 224 |
#!/usr/bin/env python3
if __name__ == '__main__':
s = str(input())
L = len(s)
beg = -1
end = -1
for i in range(0,L):
if s[i]=='A' and beg==-1:
beg = i
elif s[i]=='Z':
end = i
print(end-beg+1)
|
s411506070
|
p02678
|
u863433366
| 2,000 | 1,048,576 |
Wrong Answer
| 632 | 34,136 | 408 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
from collections import deque
n, m = map(int, input().split())
ab = [[] for i in range(n+1)]
for i in range(m):
a, b = map(int, input().split())
ab[a].append(b)
ab[b].append(a)
ans = [-1]*(n+1)
que = deque([1])
while que:
q = que.popleft()
for i in ab[q]:
if ans[i] == -1:
que.append(i)
ans[i] = q
print("YES")
for i in range(2,n+1):
print(ans[i])
|
s849125441
|
Accepted
| 661 | 33,900 | 379 |
from collections import deque
n, m = map(int, input().split())
ab = [[] for i in range(n+1)]
for i in range(m):
a, b = map(int,input().split())
ab[a].append(b)
ab[b].append(a)
ans = [-1]*(n+1)
que = deque([1])
while que:
q = que.popleft()
for i in ab[q]:
if ans[i] == -1:
que.append(i)
ans[i] = q
print("Yes")
for i in range(2,n+1):
print(ans[i])
|
s247025542
|
p04043
|
u580404776
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 90 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
A=list(map(int,input().split()))
print("Yes" if A.count(5)==2 and A.count(7)==1 else "No")
|
s376339221
|
Accepted
| 17 | 2,940 | 90 |
A=list(map(int,input().split()))
print("YES" if A.count(5)==2 and A.count(7)==1 else "NO")
|
s258896926
|
p03495
|
u633914031
| 2,000 | 262,144 |
Wrong Answer
| 148 | 33,312 | 284 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
if A[i] in ball.keys():
ball[A[i]]+=1
else:
ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
for i in range(K):
result+=1
print(result)
|
s645824363
|
Accepted
| 168 | 33,152 | 314 |
N,K=map(int, input().split())
A=list(map(int, input().split()))
ball={}
result=0
for i in range(N):
if A[i] in ball.keys():
ball[A[i]]+=1
else:
ball[A[i]]=1
sorted_ball = sorted(list(ball.values()))
if len(sorted_ball) > K:
for i in range(len(sorted_ball)-K):
result+=sorted_ball[i]
print(result)
|
s725327555
|
p03658
|
u808373096
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
Snuke has N sticks. The length of the i-th stick is l_i. Snuke is making a snake toy by joining K of the sticks together. The length of the toy is represented by the sum of the individual sticks that compose it. Find the maximum possible length of the toy.
|
N, K = map(int, input().split())
L = sorted([int(_) for _ in range(N)], reverse=True)
print(sum(L[:K]))
|
s264036714
|
Accepted
| 21 | 3,316 | 110 |
N, K = map(int, input().split())
L = sorted(list(map(int, input().split())), reverse=True)
print(sum(L[:K]))
|
s062123458
|
p03005
|
u030726788
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 98 |
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
|
n,k = map(int,input().split())
mi = 1
ma = 1 + k-n
if(k==1):
print(0)
else:
print(ma-mi)
|
s193532360
|
Accepted
| 17 | 2,940 | 99 |
n,k = map(int,input().split())
mi = 1
ma = 1 + n-k
if(k==1):
print(0)
else:
print(ma-mi)
|
s190109060
|
p02747
|
u701638736
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 304 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
hitachi = input(' please input > ')
j = 0
tmp = 0
def check_hit(a,b):
if a == b:
return 1
return 0
for i in hitachi:
if j % 2 == 0:
tmp += int(check_hit(i,"h"))
else:
tmp += int(check_hit(i,"i"))
if tmp == len(hitachi):
print("Yse")
else:
print("No")
|
s243368228
|
Accepted
| 19 | 3,060 | 318 |
hitachi = input()
j = 0
tmp = 0
def check_hit(a,b):
if a == b:
return 1
return 0
for i in hitachi:
if j % 2 == 0:
tmp += int(check_hit(i,"h"))
else:
tmp += int(check_hit(i,"i"))
j+=1
if tmp == len(hitachi) and j%2==0 and tmp > 0:
print("Yes")
else:
print("No")
|
s106154486
|
p03447
|
u143492911
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 57 |
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x=int(input())
a=int(input())
b=int(input())
print(x-a-b)
|
s396622176
|
Accepted
| 18 | 2,940 | 72 |
x=int(input())
a=int(input())
b=int(input())
v=x-a
c=v//b
print(v-(c*b))
|
s210307042
|
p03433
|
u183976155
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 89 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
if N % 500 <= A:
print("YES")
else:
print("NO")
|
s566445648
|
Accepted
| 17 | 2,940 | 89 |
N = int(input())
A = int(input())
if N % 500 <= A:
print("Yes")
else:
print("No")
|
s563095421
|
p03067
|
u973013625
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 93 |
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
|
a, b, c = map(int, input().split())
print('Yes' if (a>c and b<c) or (a<c and b<c) else 'No' )
|
s389482968
|
Accepted
| 17 | 2,940 | 93 |
a, b, c = map(int, input().split())
print('Yes' if (a>c and b<c) or (a<c and b>c) else 'No' )
|
s703775981
|
p03471
|
u845937249
| 2,000 | 262,144 |
Wrong Answer
| 780 | 3,064 | 458 |
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
n, y = map(int, input().split())
#a
#b
#c
i = 0
j = 0
k = 0
l = [-1,-1,-1]
#print(l)
for i in reversed(range(0,n+1)):
#print('i= %d' % i)
if y >= i*10000:
for j in reversed(range(0,n-i+1)):
#print('j= %d' % j)
k = n - i - j
#print('k= %d' % k)
if y == i*10000 + j*5000 + k*1000:
l = [i, j, k]
#print(l)
print(l)
|
s222797450
|
Accepted
| 724 | 3,064 | 637 |
n, y = map(int, input().split())
i = 0
j = 0
k = 0
l = [-1,-1,-1]
#print(l)
for i in reversed(range(0,n+1)):
#print('i= %d' % i)
if y >= i*10000:
for j in reversed(range(0,n-i+1)):
#print('j= %d' % j)
k = n - i - j
#print('k= %d' % k)
if y == i*10000 + j*5000 + k*1000:
l = [i, j, k]
break
else:
continue
break
#------------------------------------
#print(l)
print(l[0], l[1], l[2])
|
s784231363
|
p04014
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 210 |
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
|
n = int(input())
s = int(input())
if s == 1:
print(n)
exit()
if s == n:
print(n+1)
exit()
if n%2 == 0 and s > n//2:
print(-1)
exit()
if n%2 == 1 and s > n//2+1:
print(-1)
exit()
|
s844833669
|
Accepted
| 642 | 3,064 | 654 |
n = int(input())
s = int(input())
if s == n:
print(n+1)
exit()
if s > n%2+n//2:
print(-1)
exit()
ans = float("INF")
for i in range(2,int(n**0.5)+1):
x = n
count = 0
while x >= i:
count += x%i
x //= i
if count + x == s:
print(i)
exit()
now = 2
li = int(n**0.5)+1
while True:
x = n//now
if x < li:
break
count = 0
y = n
while y >= x:
count += y%x
y //= x
count += y
if count <= s and (s-count)%now == 0:
z = x-n//(now+1)
if (s-count)//now < z:
ans = x-(s-count)//now
now += 1
print(min(ans,n-s+1))
|
s342644162
|
p03815
|
u163320134
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 104 |
Snuke has decided to play with a six-sided die. Each of its six sides shows an integer 1 through 6, and two numbers on opposite sides always add up to 7. Snuke will first put the die on the table with an arbitrary side facing upward, then repeatedly perform the following operation: * Operation: Rotate the die 90° toward one of the following directions: left, right, front (the die will come closer) and back (the die will go farther). Then, obtain y points where y is the number written in the side facing upward. For example, let us consider the situation where the side showing 1 faces upward, the near side shows 5 and the right side shows 4, as illustrated in the figure. If the die is rotated toward the right as shown in the figure, the side showing 3 will face upward. Besides, the side showing 4 will face upward if the die is rotated toward the left, the side showing 2 will face upward if the die is rotated toward the front, and the side showing 5 will face upward if the die is rotated toward the back. Find the minimum number of operation Snuke needs to perform in order to score at least x points in total.
|
n=int(input())
ans=2*n//11
n-=11*(n//11)
if n==0:
ans+=0
elif n<=6:
ans+=1
else:
ans+=2
print(ans)
|
s779918393
|
Accepted
| 17 | 2,940 | 100 |
n=int(input())
ans=2*(n//11)
n=n%11
if n==0:
ans+=0
elif n<=6:
ans+=1
else:
ans+=2
print(ans)
|
s431066965
|
p03547
|
u556589653
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 123 |
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
S = input().split()
X = int(S[0],16)
Y = int(S[1],16)
if X<Y:
print("<")
if X == Y:
print("=")
else:
print(">")
|
s592921874
|
Accepted
| 17 | 3,060 | 125 |
S = input().split()
X = int(S[0],16)
Y = int(S[1],16)
if X<Y:
print("<")
elif X == Y:
print("=")
else:
print(">")
|
s916563561
|
p03998
|
u790048565
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 299 |
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
Sa = input()
Sb = input()
Sc = input()
dic = {'a':Sa, 'b':Sb, 'c':Sc}
doCont = True
person = 'a'
result = ''
while doCont:
drop_card = dic[person][0]
dic[person] = dic[person][1:]
if (len(dic[person]) == 0):
doCont = False
result = person.upper()
person = drop_card
print(result)
|
s482798284
|
Accepted
| 17 | 3,064 | 309 |
Sa = input()
Sb = input()
Sc = input()
dic = {'a':Sa, 'b':Sb, 'c':Sc}
doCont = True
person = 'a'
result = ''
while doCont:
if (len(dic[person]) == 0):
doCont = False
result = person.upper()
break
drop_card = dic[person][0]
dic[person] = dic[person][1:]
person = drop_card
print(result)
|
s089140421
|
p03623
|
u347397127
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,016 | 84 |
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
a,b,c=map(int,input().split())
if abs(a-b)>abs(a-c):
print("A")
else:
print("B")
|
s095497236
|
Accepted
| 26 | 9,092 | 85 |
a,b,c=map(int,input().split())
if abs(a-b)<abs(a-c):
print("A")
else:
print("B")
|
s194785241
|
p02608
|
u807315165
| 2,000 | 1,048,576 |
Wrong Answer
| 918 | 98,264 | 515 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
# this is the third task
from collections import defaultdict
N=int(input())
n=1
s=3
brkLoop=False
while True :
r=(s)**2-(1)-(1)-(n)
if ( r >= N ):
break;
else:
n=n+1
s=s+1
out=defaultdict(list)
for (x,y,z) in tuple((i,j,k) for i in range(1, n+1) for j in range (1,n+1) for k in range(1,n+1)):
r=(x+y+z)**2-(x*y)-(y*z)-(x*z)
if ( r < N ):
out[r].append((x,y,z))
for i in range(1,N):
if ( i in out):
print (len(out[i]))
else:
print(0)
|
s596833785
|
Accepted
| 874 | 98,180 | 519 |
# this is the third task
from collections import defaultdict
N=int(input())
n=1
s=3
brkLoop=False
while True :
r=(s)**2-(1)-(1)-(n)
if ( r >= N ):
break;
else:
n=n+1
s=s+1
out=defaultdict(list)
for (x,y,z) in tuple((i,j,k) for i in range(1, n+1) for j in range (1,n+1) for k in range(1,n+1)):
r=(x+y+z)**2-(x*y)-(y*z)-(x*z)
if ( r <= N ):
out[r].append((x,y,z))
for i in range(1,N+1):
if ( i in out):
print (len(out[i]))
else:
print(0)
|
s336939080
|
p02608
|
u021019433
| 2,000 | 1,048,576 |
Wrong Answer
| 160 | 9,332 | 279 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
f = lambda x, y, z: (x + y + z) ** 2 - x * y - y * z - z * x - 1
n = int(input())
a = [0] * n
z = 1
while f(1, 1, z) < n:
y = 1
while y < z and f(1, y, z) < n:
x = 1
while f(x, y, z) < n:
a[f(x, y, z)] += 1
x += 1
y += 1
z += 1
print(*a, sep='\n')
|
s622377954
|
Accepted
| 281 | 9,384 | 269 |
f = lambda x, y, z: (x + y + z) ** 2 - x * y - y * z - z * x - 1
n = int(input())
a = [0] * n
z = 1
while f(1, 1, z) < n:
y = 1
while f(1, y, z) < n:
x = 1
while f(x, y, z) < n:
a[f(x, y, z)] += 1
x += 1
y += 1
z += 1
print(*a, sep='\n')
|
s773308839
|
p02678
|
u985972698
| 2,000 | 1,048,576 |
Wrong Answer
| 2,206 | 25,404 | 625 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
# -*- coding: utf-8 -*-
def input_one_number():
return int(input())
def input_multiple_number():
return map(int, input().split())
def input_multiple_number_as_list():
return list(map(int, input().split()))
N,M = input_multiple_number()
A = [0]*M
B = [0]*M
ans = [0]*(N-1)
for i in range(M):
A[i],B[i] = input_multiple_number()
def DFS(K):
michi = []
for i in range(len(A)):
if A[i] == K:
if ans[B[i]-1-1] == 0:
ans[B[i]-1-1] = K
michi.append(B[i])
elif B[i] == K:
if ans[A[i]-1-1] == 0:
ans[A[i]-1-1] = K
michi.append(A[i])
for i in michi:
DFS(i)
DFS(1)
print(ans)
|
s329299949
|
Accepted
| 1,412 | 34,356 | 614 |
# -*- coding: utf-8 -*-
def input_one_number():
return int(input())
def input_multiple_number():
return map(int, input().split())
def input_multiple_number_as_list():
return list(map(int, input().split()))
N,M = input_multiple_number()
shilve = [-1]*(N+1)
michi = [[] for _i in range(N+1)]
for i in range(M):
a,b = input_multiple_number()
michi[a].append(b)
michi[b].append(a)
que = [1]
while len(que) > 0:
now_heya = que.pop(0)
for nexthop in michi[now_heya]:
if shilve[nexthop] == -1:
shilve[nexthop] = now_heya
que.append(nexthop)
print("Yes")
for i in shilve[2:]:
print(i)
|
s782323964
|
p03545
|
u275812163
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 224 |
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.
|
I = input()
for param in range(2**(len(I)-1)):
ans = ""
for i in range(len(I)):
ans += I[i] + ["+","-",""][((param >> i) & 1) if i != len(I) - 1 else 2]
if eval(ans) == 7:
print(ans)
break
|
s663440031
|
Accepted
| 17 | 3,060 | 230 |
I = input()
for param in range(2**(len(I)-1)):
ans = ""
for i in range(len(I)):
ans += I[i] + ["+","-",""][((param >> i) & 1) if i != len(I) - 1 else 2]
if eval(ans) == 7:
print(ans+"=7")
break
|
s679562377
|
p03737
|
u865413330
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 72 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
s1, s2, s3 = input().split()
print((s1[0] + s2[0] + s3[0]).capitalize())
|
s731901545
|
Accepted
| 18 | 2,940 | 67 |
s1, s2, s3 = input().split()
print((s1[0] + s2[0] + s3[0]).upper())
|
s636218241
|
p02255
|
u929141425
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 235 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
print("----------")
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
print(*A)
A[j+1] = v
print(*A)
|
s431981198
|
Accepted
| 20 | 5,980 | 197 |
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
|
s841423192
|
p03844
|
u064408584
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 79 |
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
|
a,b,c=input().split()
if b=='+0':print(int(a)+int(c))
else:print(int(a)-int(c))
|
s703216812
|
Accepted
| 17 | 2,940 | 78 |
a,b,c=input().split()
if b=='+':print(int(a)+int(c))
else:print(int(a)-int(c))
|
s067376052
|
p00007
|
u028347703
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,672 | 114 |
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
|
import math
n = int(input())
b = 100
for i in range(n):
b += b * 0.05
b = math.ceil(b)
print("%d" % b * 1000)
|
s910513924
|
Accepted
| 20 | 5,660 | 117 |
import math
n = int(input())
b = 100
for i in range(n):
b += b * 0.05
b = math.ceil(b)
b *= 1000
print("%d" % b)
|
s643109181
|
p03795
|
u339199690
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 69 |
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.
|
import math
n = int(input())
print(math.factorial(n) % (10**9 + 7))
|
s444039459
|
Accepted
| 25 | 9,100 | 61 |
N = int(input())
x = 800 * N
y = 200 * (N // 15)
print(x - y)
|
s400364667
|
p04043
|
u277641173
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 194 |
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(str,input().split())
if (len(a)==5 and len(b)==5 and len(c)==7) or(len(a)==5 and len(c)==5 and len(b)==7) or (len(c)==5 and len(b)==5 and len(a)==7):
print("YES")
else:
print("NO")
|
s072941743
|
Accepted
| 18 | 2,940 | 149 |
a,b,c=map(int,input().split())
if (a==5 and b==5 and c==7) or(a==5 and c==5 and b==7) or (c==5 and b==5 and a==7):
print("YES")
else:
print("NO")
|
s394036528
|
p03679
|
u484856305
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 140 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
a,b,c=map(int,input().split())
l=abs(b-c)
print(l)
if a+1<l:
print("dangerous")
elif a>l:
print("delicious")
else:
print("safe")
|
s443929621
|
Accepted
| 17 | 2,940 | 116 |
x,a,b=map(int,input().split())
if a>=b:
print("delicious")
elif a+x>=b:
print("safe")
else:
print("dangerous")
|
s991133900
|
p02291
|
u426534722
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,724 | 733 |
For given three points p1, p2, p, find the reflection point x of p onto p1p2.
|
import sys
from itertools import starmap
readline = sys.stdin.readline
class Segment(object):
__slots__ = ('fi', 'se')
def __init__(self, fi, se):
self.fi = fi
self.se = se
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def norm(base):
return abs(base) ** 2
def project(s, p2):
base = s.fi - s.se
r = dot(p2 - s.fi, base) / norm(base)
return s.fi + base * r
def reflect(s, p):
return p + (project(s, p) - p) * 2.0
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
p1 = reflect(s, complex(*map(float, readline().split())))
print(p1.real, p1.imag)
|
s579501599
|
Accepted
| 30 | 7,904 | 763 |
import sys
from itertools import starmap
readline = sys.stdin.readline
class Segment(object):
__slots__ = ('fi', 'se')
def __init__(self, fi, se):
self.fi = fi
self.se = se
def cross(a, b):
return a.real * b.imag - a.imag * b.real
def dot(a, b):
return a.real * b.real + a.imag * b.imag
def norm(base):
return abs(base) ** 2
def project(s, p2):
base = s.fi - s.se
r = dot(p2 - s.fi, base) / norm(base)
return s.fi + base * r
def reflect(s, p):
return p + (project(s, p) - p) * 2.0
s = Segment(*starmap(complex, zip(*[map(float, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
p1 = reflect(s, complex(*map(float, readline().split())))
print("{0:.10f} {1:.10f}".format(p1.real, p1.imag))
|
s957967014
|
p03495
|
u412563426
| 2,000 | 262,144 |
Wrong Answer
| 305 | 55,056 | 302 |
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them.
|
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
B = set(a)
d = Counter(a)
num = len(B) - k
c = d.most_common()
print(c)
ans = 0
for i in range(1, num+1):
ans += c[-i][1]
print(ans)
|
s428115386
|
Accepted
| 225 | 50,484 | 293 |
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
B = set(a)
d = Counter(a)
num = len(B) - k
c = d.most_common()
ans = 0
for i in range(1, num+1):
ans += c[-i][1]
print(ans)
|
s835070122
|
p03626
|
u982762220
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 507 |
We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors. Find the number of such ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given to you as two strings S_1 and S_2 in the following manner: * Each domino is represented by a different English letter (lowercase or uppercase). * The j-th character in S_i represents the domino that occupies the square at the i-th row from the top and j-th column from the left.
|
N = int(input())
S1 = input()
S2 = input()
res = 6
idx = 0
s = []
mod = 1000000007
while idx < N:
if S1[idx] == S2[idx]:
s.append(0)
else:
s.append(1)
idx += 1
idx += 1
res = 3 if s[0] == 0 else 6
for idx in range(1, len(s)):
prev, cur = s[idx-1], s[idx]
if prev == 0:
if cur == 0:
res *= 2
else:
res *= 1
else:
if cur == 0:
res *= 2
else:
res *= 3
res %= mod
print(res)
|
s949315330
|
Accepted
| 17 | 3,064 | 503 |
N = int(input())
S1 = input()
S2 = input()
res = 6
idx = 0
s = []
mod = 1000000007
while idx < N:
if S1[idx] == S2[idx]:
s.append(0)
else:
s.append(1)
idx += 1
idx += 1
res = 3 if s[0] == 0 else 6
for idx in range(1, len(s)):
prev, cur = s[idx-1], s[idx]
if prev == 0:
if cur == 0:
res *= 2
else:
res *= 2
else:
if cur == 0:
res *= 1
else:
res *= 3
res %= mod
print(res)
|
s787178069
|
p03486
|
u685263709
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 133 |
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
|
S = ''.join(sorted(list(input())))
T = ''.join(sorted(list(input()), reverse=True))
if S < T:
print('YES')
else:
print('NO')
|
s534063302
|
Accepted
| 17 | 2,940 | 133 |
S = ''.join(sorted(list(input())))
T = ''.join(sorted(list(input()), reverse=True))
if S < T:
print('Yes')
else:
print('No')
|
s854189742
|
p03598
|
u882370611
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 162 |
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. * When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. * When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots.
|
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
ans += 2 * min(x[i], k-x[i]) + max(x[i], k-x[i])
print(ans)
|
s181159037
|
Accepted
| 17 | 3,060 | 142 |
n = int(input())
k = int(input())
x = list(map(int, input().split()))
ans = 0
for i in range(n):
ans += 2 * min(x[i], k-x[i])
print(ans)
|
s030518823
|
p03457
|
u612261372
| 2,000 | 262,144 |
Wrong Answer
| 410 | 27,380 | 303 |
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())
P = [list(map(int, input().split())) for i in range(N)]
P.insert(0,[0,0,0])
ans = "YES"
for i in range(N):
norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
if (P[i+1][0]-P[i][0])%2 != norm%2:
ans = "NO"
break
#else:
# if norm %2 == 0:
# break
print(ans)
|
s367169401
|
Accepted
| 410 | 27,380 | 284 |
N = int(input())
P = [list(map(int, input().split())) for i in range(N)]
P.insert(0,[0,0,0])
ans = "Yes"
for i in range(N):
norm = abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])
move = (P[i+1][0]-P[i][0]) - norm
if ((move%2 != 0) or (move < 0)):
ans = "No"
break
print(ans)
|
s973522106
|
p03477
|
u865413330
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 147 |
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")
if (a + b) < (c + d):
print("Right")
else:
print("Balanced")
|
s542731782
|
Accepted
| 18 | 3,060 | 149 |
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")
|
s448339963
|
p03543
|
u274615057
| 2,000 | 262,144 |
Wrong Answer
| 27 | 8,824 | 155 |
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
|
def main():
n = input()
if len(n) == 1 or len(n) == 2:
print('Yes')
else:
print('No')
if __name__ == "__main__":
main()
|
s078671434
|
Accepted
| 27 | 9,072 | 356 |
def main():
n = input()
cnt = 0
if n[0] == n[1]:
cnt += 1
else:
cnt = 0
for i in range(2, 4):
if n[i-1] == n[i]:
cnt += 1
else:
cnt -= 1
if cnt >= 2:
print('Yes')
break
if cnt < 2:
print('No')
if __name__ == "__main__":
main()
|
s247991460
|
p03360
|
u267325300
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 95 |
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times: * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n. What is the largest possible sum of the integers written on the blackboard after K operations?
|
A, B, C = map(int, input().split())
K = int(input())
m = max(A, B, C)
print(A + B + C + 3 * m)
|
s370349426
|
Accepted
| 17 | 3,064 | 104 |
A, B, C = map(int, input().split())
K = int(input())
m = max(A, B, C)
print(A + B + C + (2**K - 1) * m)
|
s871652427
|
p02408
|
u792747184
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 745 |
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
n = int(input())
for i in range(n):
k = input().split()
if k[0] == 'S':
for i in range(1,14):
if int(k[1])==i:
continue
else:
print('S {0}'.format(i))
if k[0] == 'H':
for i in range(1,14):
if int(k[1])==i:
continue
else:
print('H {0}'.format(i))
if k[0] == 'C':
for i in range(1,14):
if int(k[1])==i:
continue
else:
print('C {0}'.format(i))
if k[0] == 'D':
for i in range(1,14):
if int(k[1])==i:
continue
else:
print('D {0}'.format(i))
|
s435319535
|
Accepted
| 20 | 5,616 | 691 |
n = int(input())
S = [1,2,3,4,5,6,7,8,9,10,11,12,13]
C = [1,2,3,4,5,6,7,8,9,10,11,12,13]
H = [1,2,3,4,5,6,7,8,9,10,11,12,13]
D = [1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(n):
variations,number = input().split()
if variations == 'S':
S.remove(int(number))
if variations == 'C':
C.remove(int(number))
if variations == 'H':
H.remove(int(number))
if variations == 'D':
D.remove(int(number))
for i in range(len(S)):
print('{} {}'.format('S',S[i]))
for i in range(len(H)):
print('{} {}'.format('H',H[i]))
for i in range(len(C)):
print('{} {}'.format('C',C[i]))
for i in range(len(D)):
print('{} {}'.format('D',D[i]))
|
s835528006
|
p03557
|
u803848678
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 28,568 | 463 |
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
N = int(input())
ue = list(set(list(map(int, input().split()))))
mid = list(set(list(map(int, input().split()))))
bot = list(set(list(map(int, input().split()))))
ue.sort()
mid.sort()
bot.sort()
ans = 0
for i in ue:
for j in mid:
if j <= i:
continue
else:
for k in range(len(bot)):
if bot[k] <= j:
continue
else:
ans += len(bot) - k
print(ans)
|
s674247167
|
Accepted
| 319 | 23,360 | 323 |
import bisect
N = int(input())
ue = (list(map(int, input().split())))
mid = (list(map(int, input().split())))
bot = (list(map(int, input().split())))
ue.sort()
mid.sort()
bot.sort()
ans = 0
for i in mid:
ans += bisect.bisect_left(ue, i) * (len(bot) - bisect.bisect_right(bot, i))
print(ans)
|
s779638791
|
p03555
|
u945359338
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
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 = input()
B = input()
if A == B[::-1]:
print("Yes")
else:
print("No")
|
s569013783
|
Accepted
| 17 | 2,940 | 71 |
A = input()
B = input()
print("YES") if A == B[::-1] else print("NO")
|
s142939560
|
p00001
|
u538041865
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,644 | 209 |
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
|
inputList = []
while True:
try:
num = int(input())
except EOFError:
break
inputList.append(num)
inputList.sort()
for x in range(len(inputList) - 1, -1, -1):
print(inputList[x])
|
s911321383
|
Accepted
| 20 | 7,632 | 221 |
inputList = []
while True:
try:
num = int(input())
except EOFError:
break
inputList.append(num)
inputList.sort()
length = len(inputList)
for i in range(3):
print(inputList[length - i - 1])
|
s094316228
|
p03469
|
u835482198
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 32 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
s = input()
print('2017/s[4:]')
|
s112501781
|
Accepted
| 17 | 2,940 | 42 |
s = input()
print('2018{}'.format(s[4:]))
|
s802646904
|
p03861
|
u792512290
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split(" "))
print((b-a)//x)
|
s390672752
|
Accepted
| 17 | 2,940 | 74 |
a, b, x = map(int, input().split(" "))
ans = b//x - (a - 1)//x
print(ans)
|
s412575676
|
p03779
|
u934868410
| 2,000 | 262,144 |
Wrong Answer
| 28 | 2,940 | 66 |
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
x=int(input())
s = 0
t = 0
while s < x:
s += t
t += 1
print(t)
|
s130496047
|
Accepted
| 28 | 2,940 | 98 |
x=int(input())
s = 0
t = 0
while True:
s += t
if s >= x:
break
t += 1
print(t)
|
s203461786
|
p03943
|
u235066013
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 105 |
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a,b,c=[int(i) for i in input().split()]
if a+b==c or b+c==a or c+a==b:
print('YES')
else:
print('NO')
|
s729940869
|
Accepted
| 17 | 2,940 | 111 |
a,b,c=[int(i) for i in input().split()]
if (a+b)==c or (b+c)==a or (c+a)==b:
print('Yes')
else:
print('No')
|
s141191320
|
p02612
|
u038404105
| 2,000 | 1,048,576 |
Wrong Answer
| 31 | 9,144 | 30 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s747688290
|
Accepted
| 24 | 9,148 | 77 |
n = int(input())
if n%1000 == 0:
print(0)
else:
print(1000 - n%1000)
|
s701496519
|
p03079
|
u646130340
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 97 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
A, B, C = map(int, input().split())
if A == B and B == C:
print('YES')
else:
print('NO')
|
s430984312
|
Accepted
| 17 | 2,940 | 96 |
A, B, C = map(int, input().split())
if A == B and B == C:
print('Yes')
else:
print('No')
|
s432030937
|
p03814
|
u033606236
| 2,000 | 262,144 |
Wrong Answer
| 39 | 3,516 | 269 |
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`.
|
Strings = input()
for i in range(0,len(Strings)):
if Strings[i] == "A":
length = i
print(i)
break
for i in range(len(Strings))[::-1]:
if Strings[i] == "Z":
length2 = i
print(i)
break
print(length2 - length +1 )
|
s188233818
|
Accepted
| 36 | 3,512 | 235 |
Strings = input()
for i in range(0,len(Strings)):
if Strings[i] == "A":
length = i
break
for i in range(len(Strings))[::-1]:
if Strings[i] == "Z":
length2 = i
break
print(length2 - length +1 )
|
s597441281
|
p03545
|
u098572984
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 387 |
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.
|
from itertools import product
s = tuple(map(int, tuple(input())))
options = (-1, 1)
for op1, op2, op3 in product(options, repeat=3):
if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
_op1 = "+" if op1 == 1 else "-"
_op2 = "+" if op2 == 1 else "-"
_op3 = "+" if op3 == 1 else "-"
print(s[0], _op1, s[1], _op2, s[2], _op3, s[3])
exit()
|
s936861007
|
Accepted
| 18 | 3,064 | 401 |
from itertools import product
s = tuple(map(int, tuple(input())))
options = (-1, 1)
for op1, op2, op3 in product(options, repeat=3):
if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
_op1 = "+" if op1 == 1 else "-"
_op2 = "+" if op2 == 1 else "-"
_op3 = "+" if op3 == 1 else "-"
print(s[0], _op1, s[1], _op2, s[2], _op3, s[3], "=7", sep="")
exit()
|
s920124021
|
p03129
|
u849756457
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,104 | 97 |
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
N, K = [int(i) for i in input().split()]
if K < (N - 1) // 2:
print("YES")
else:
print("NO")
|
s889654031
|
Accepted
| 30 | 9,156 | 105 |
N, K = [int(i) for i in input().split()]
if (K - 1) <= (N - 1) // 2:
print("YES")
else:
print("NO")
|
s229855636
|
p03564
|
u880277518
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 115 |
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n=int(input())
k=int(input())
s=1
for i in range(n):
if (2*s)<k:
s=2*s
else:
s+=k
print(s)
|
s546785422
|
Accepted
| 17 | 2,940 | 94 |
N=int(input())
K=int(input())
n=1
for i in range(N):
n=min(n*2,n+K)
#print(n)
print(n)
|
s681236318
|
p03912
|
u223904637
| 2,000 | 262,144 |
Wrong Answer
| 184 | 21,808 | 659 |
Takahashi is playing with N cards. The i-th card has an integer X_i on it. Takahashi is trying to create as many pairs of cards as possible satisfying one of the following conditions: * The integers on the two cards are the same. * The sum of the integers on the two cards is a multiple of M. Find the maximum number of pairs that can be created. Note that a card cannot be used in more than one pair.
|
n,m=map(int,input().split())
p=[0]*m
pp=[[] for i in range(m)]
l=list(map(int,input().split()))
l.sort()
for i in l:
p[i%m]+=1
ans=0
if m%2==0:
ans+=p[m//2]//2
p[m//2]=0
ans+=p[0]//2
p[0]=0
for i in range(1,m//2):
if p[i]>=p[m-i]:
ans+=p[m-i]
p[i]-=p[m-i]
p[m-i]=0
else:
ans+=p[i]
p[i]=0
p[m-i]-=p[i]
f=1
l.append(-1)
for i in range(n):
if l[i]==l[i+1]:
f+=1
else:
if f>=2:
if p[l[i]%m]>=f:
ans+=f//2
p[l[i]%m]-=(f//2)*2
else:
ans+=p[l[i]%m]//2
p[l[i]%m]=0
f=1
print(ans)
|
s135750411
|
Accepted
| 200 | 14,072 | 712 |
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
p = [0]*m
q = [0]*m
cnt = 1
for i in range(n):
q[x[i]%m] += 1
if i == n-1 or x[i] != x[i+1]:
p[x[i]%m] += cnt//2
cnt = 1
else:
cnt += 1
res = 0
for i in range(m):
if i==0:
res += q[0]//2
continue
if i > m-i:
break
if i == m-i:
res += q[i]//2
continue
if q[i] >= q[m-i]:
res += q[m-i]
q[i] -= q[m-i]
res += min(q[i]//2,p[i])
else:
res += q[i]
q[m-i] -= q[i]
res += min(q[m-i]//2,p[m-i])
print(res)
|
s498332007
|
p03730
|
u396890425
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 121 |
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c=map(int, input().split())
list=[]
for i in range(b):
list.append(a*(i+1)%b)
print('Yes' if c in list else 'No')
|
s915961692
|
Accepted
| 17 | 2,940 | 121 |
a,b,c=map(int, input().split())
list=[]
for i in range(b):
list.append(a*(i+1)%b)
print('YES' if c in list else 'NO')
|
s795271362
|
p03693
|
u403551852
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 80 |
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')
|
s492124132
|
Accepted
| 17 | 2,940 | 80 |
r,g,b = map(int,input().split())
print('YES' if (r*100+g*10+b)%4 == 0 else 'NO')
|
s823116067
|
p03672
|
u928784113
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 211 |
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
S = input()
for i in range(len(S)):
S = S[:-1]
if len(S) % 2 == 1:
continue
else:
if S[:len(S)//2] == S[len(S)//2:len(S)]:
print(len(S))
else:
continue
|
s414727021
|
Accepted
| 17 | 3,060 | 251 |
S = input()
S = S[:-1]
def cutstring(s):
n = len(s)
if n % 2 == 1:
return cutstring(s[:-1])
else:
if s[:n//2] == s[n//2:]:
return n
else:
return cutstring(s[:-1])
ans = cutstring(S)
print(ans)
|
s320118741
|
p03610
|
u493491792
| 2,000 | 262,144 |
Wrong Answer
| 39 | 3,316 | 101 |
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
n=input()
print(len(n))
word=""
for i in range(len(n)):
if i%2==0:
word+=n[i]
print(word)
|
s485151565
|
Accepted
| 40 | 3,188 | 87 |
n=input()
word=""
for i in range(len(n)):
if i%2==0:
word+=n[i]
print(word)
|
s097181408
|
p03544
|
u731368968
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 91 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n = int(input())
l = [2, 0]
for i in range(2, n):
l.append(l[-1] + l[-2])
print(l[-1])
|
s752697547
|
Accepted
| 18 | 2,940 | 92 |
n = int(input())
l = [2, 1]
for i in range(2, n+1):
l.append(l[-1] + l[-2])
print(l[n])
|
s807858810
|
p03962
|
u014333473
| 2,000 | 262,144 |
Wrong Answer
| 33 | 9,064 | 24 |
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
|
print(len(set(input())))
|
s263805884
|
Accepted
| 25 | 9,020 | 32 |
print(len(set(input().split())))
|
s027102348
|
p03455
|
u874081738
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 99 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
a, b = map(int,input().split())
if (a*b)%2 == 0:
print("Odd")
else:
print("Even")
|
s766896239
|
Accepted
| 17 | 3,064 | 95 |
a, b = map(int,input().split())
if (a*b)%2 :
print("Odd")
else:
print("Even")
|
s947495744
|
p03251
|
u911575040
| 2,000 | 1,048,576 |
Wrong Answer
| 309 | 2,940 | 258 |
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())
ans="No War"
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(x+1,y+1):
for j in range(n):
for k in range(m):
if a[j]>=i or i>b[k]:
ans="War"
print(ans)
|
s679923170
|
Accepted
| 21 | 3,060 | 266 |
N, M, X, Y = map(int, input().split())
list_x = [int(i) for i in input().split()]
list_y = [int(j) for j in input().split()]
if max(list_x) >= min(list_y):
print('War')
else:
if X < max(list_x) + 1 <= Y:
print('No War')
else:
print('War')
|
s942702828
|
p04029
|
u032798323
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 60 |
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
|
N = int(input())
a = 0
for i in range(N):
a+= i
print(a)
|
s542354061
|
Accepted
| 17 | 2,940 | 62 |
N = int(input())
a = 0
for i in range(N):
a+= i+1
print(a)
|
s769385084
|
p03719
|
u443736699
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
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 = list(map(int,input().strip().split()))
if c>=a and c<=b:
print("YES")
exit()
print("NO")
|
s769520495
|
Accepted
| 17 | 2,940 | 103 |
a,b,c = list(map(int,input().strip().split()))
if c >= a and c <=b:
print("Yes")
else:
print("No")
|
s015116374
|
p03438
|
u838644735
| 2,000 | 262,144 |
Wrong Answer
| 24 | 4,596 | 517 |
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
|
def main():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
expected = sum(B) - sum(A)
if expected < 0:
print('NO')
return
add_a, add_b = 0, 0
for i in range(N):
a, b = A[i], B[i]
if a > b:
add_b += a - b
elif a < b:
add_a += (b - a) // 2
if add_a + add_b <= expected:
print('YES')
else:
print('NO')
if __name__ == '__main__':
main()
|
s155921420
|
Accepted
| 24 | 4,596 | 535 |
def main():
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
expected = sum(B) - sum(A)
if expected < 0:
print('No')
return
add_a, add_b = 0, 0
for i in range(N):
a, b = A[i], B[i]
if a > b:
add_b += a - b
elif a < b:
add_a += (b - a + 1) // 2
if add_a <= expected and add_b <= expected:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
s844633422
|
p00016
|
u957840591
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,900 | 302 |
When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at the center of town. However, now buildings are crammed side by side and people can not walk along exactly what the paper says in. Your task is to write a program which hunts for the treature on the paper. For simplicity, 1 step is equivalent to 1 meter. Input consists of several pairs of two integers d (the first integer) and t (the second integer) separated by a comma. Input ends with "0, 0". Your program should print the coordinate (x, y) of the end point. There is the treature where x meters to the east and y meters to the north from the center of town. You can assume that d ≤ 100 and -180 ≤ t ≤ 180\.
|
from math import *
x = 0
y = 0
D = []
A = []
while True:
d, a = map(int, input().split(","))
if a == 0 and d == 0:
break
else:
D.append(d)
A.append(a)
for i in range(len(A)):
x = x + D[i] * cos(A[i] * pi / 180)
y = y + D[i] * sin(A[i] * pi / 180)
print(x,y)
|
s663548685
|
Accepted
| 30 | 7,856 | 551 |
from math import *
x = 0
y = 0
D = []
A = []
sum_a = -90
while True:
d, a = map(int, input().split(","))
if a == 0 and d == 0:
break
else:
D.append(d)
A.append(a)
for i in range(len(A)):
x = x + D[i] * cos(sum_a * pi / 180)
y = y - D[i] * sin(sum_a * pi / 180)
if abs(x-round(x))<10**(-7):
x=round(x)
if abs(y - round(y)) < 10 ** (-7):
y=round(y)
sum_a += A[i]
if x >= 0:
print(floor(x))
else:
print(floor(x)+1)
if y >= 0:
print(floor(y))
else:
print(floor(y)+1)
|
s424202397
|
p00711
|
u741801763
| 1,000 | 131,072 |
Wrong Answer
| 310 | 7,652 | 1,035 |
There is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. But he can't move on red tiles, he can move only on black tiles. Write a program to count the number of black tiles which he can reach by repeating the moves described above.
|
if __name__ == "__main__":
while 1:
w,h = list(map(int,input().strip().split()))
if w == h == 0:break
data = []
data = []
for _ in range(h):data.append(list(input()))
visited = []
for i in range(h):
if '@'in data[i]:stack= [(i,data[i].index('@'))]
count = 0
while len(stack) !=0:
y,x= stack.pop()
count +=1
if y-1 >= 0 and not (y-1,x)in visited and data[y -1][x] == '.':
visited.append((y-1,x))
stack.append((y-1,x))
if x -1 >= 0 and not (y,x-1)in visited and data[y][x-1] == '.':
visited.append((y,x-1))
stack.append((y,x-1))
if y +1 < h and not (y+1,x)in visited and data[y +1][x] == '.':
visited.append((y+1,x))
stack.append((y+1,x))
if x + 1 < w and not (y,x+1)in visited and data[y][x +1] == '.':
visited.append((y,x+1))
stack.append((y,x+1))
|
s050711682
|
Accepted
| 300 | 7,736 | 1,099 |
if __name__ == "__main__":
while 1:
w,h = list(map(int,input().strip().split()))
if w == h == 0:break
data = []
data = []
for _ in range(h):data.append(list(input()))
visited = []
for i in range(h):
if '@'in data[i]:stack= [(i,data[i].index('@'))]
count = 0
while len(stack) !=0:
y,x= stack.pop()
count +=1
if y-1 >= 0 and not (y-1,x)in visited and data[y -1][x] == '.':
visited.append((y-1,x))
stack.append((y-1,x))
if x -1 >= 0 and not (y,x-1)in visited and data[y][x-1] == '.':
visited.append((y,x-1))
stack.append((y,x-1))
if y +1 < h and not (y+1,x)in visited and data[y +1][x] == '.':
visited.append((y+1,x))
stack.append((y+1,x))
if x + 1 < w and not (y,x+1)in visited and data[y][x +1] == '.':
visited.append((y,x+1))
stack.append((y,x+1))
print(count)
|
s099889214
|
p03048
|
u593567568
| 2,000 | 1,048,576 |
Wrong Answer
| 1,723 | 2,940 | 171 |
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
R,G,B,N = map(int,input().split())
ans = 0
for r in range(R):
if N < r:
continue
for g in range(G):
if (N - r - g) <= B:
ans += 1
print(ans)
|
s515730448
|
Accepted
| 1,912 | 2,940 | 260 |
R,G,B,N = map(int,input().split())
ans = 0
for r in range(3010):
red = r * R
if N < red:
break
for g in range(3010):
green = g * G
blue = N - red - green
if blue < 0:
break
if blue % B == 0:
ans += 1
print(ans)
|
s216429949
|
p02390
|
u064313887
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 93 |
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 % 3600) % 60
print(h,":",m,":",s)
|
s291464243
|
Accepted
| 20 | 5,584 | 85 |
x = int(input())
h = x // 3600
m = x % 3600 // 60
s = x % 60
print(h,m,s,sep=':')
|
s365873461
|
p03455
|
u889564559
| 2,000 | 262,144 |
Wrong Answer
| 148 | 12,504 | 194 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import numpy as np
a, b = map(str,input().split())
target = int(a + b)
target_full = np.sqrt(target)
target_resid = target_full % 1
if target_resid == 0:
print("Yes")
else:
print("No")
|
s673755590
|
Accepted
| 17 | 2,940 | 108 |
a, b = map(int,input().split())
target = a * b
if target % 2 == 1:
print("Odd")
else:
print("Even")
|
s645959709
|
p03636
|
u187205913
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 56 |
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
print('{}{}{}'.format(s[1],len(s)-2,s[-1]))
|
s696774369
|
Accepted
| 18 | 2,940 | 55 |
s = input()
print('{}{}{}'.format(s[0],len(s)-2,s[-1]))
|
s745752342
|
p03494
|
u296463304
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,112 | 222 |
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
f=input("")
ra=input("")
a=ra.split()
lista=[int(s) for s in a]
mix=1
base=0
for num in lista:
for n in range(9):
if num % 2**n :
pass
else:
break
if base<n:
bace=n
print(n)
|
s221781657
|
Accepted
| 27 | 9,128 | 207 |
# coding = utf-8
n=input("")
a=input("")
a=a.split(" ")
a=[int(s) for s in a]
a.sort()
base=100000
n=1
for num in a:
while num%2**n==0:
n=n+1
n=n-1
if n < base:
base=n
print(base)
|
s542307038
|
p03361
|
u679888753
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,064 | 409 |
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
|
H, W = map(int, input().split())
S = [['.']*(W + 2)] + [list('.' + input() + '.') for _ in range(H)] + [['.']*(W + 2)]
# print(S)
for i in range(1, H):
for k in range(1, W):
if S[i][k] == '#' and S[i][k - 1] != '#' and S[i - 1][k] != '#' and S[i][k + 1] != '#' and S[i + 1][k] != '#':
print('Yes')
exit()
print('No')
|
s950152637
|
Accepted
| 18 | 3,064 | 409 |
H, W = map(int, input().split())
S = [['.']*(W + 2)] + [list('.' + input() + '.') for _ in range(H)] + [['.']*(W + 2)]
# print(S)
for i in range(1, H):
for k in range(1, W):
if S[i][k] == '#' and S[i][k - 1] != '#' and S[i - 1][k] != '#' and S[i][k + 1] != '#' and S[i + 1][k] != '#':
print('No')
exit()
print('Yes')
|
s834914520
|
p03729
|
u739721456
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 100 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
print("Yes")
else:
print("No")
|
s543831561
|
Accepted
| 17 | 2,940 | 100 |
w=input().split()
if w[0][-1]==w[1][0] and w[1][-1]==w[2][0]:
print("YES")
else:
print("NO")
|
s360623357
|
p02603
|
u462329577
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,240 | 761 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
# init
tmp = a[0]
bit_buy = 1
init_bit = 1
money = 1000
ans = money
stock_num = 0
for i in range(1, n):
if bit_buy and a[i] > a[i - 1]:
stock_num = money // a[i - 1]
money = money - stock_num * a[i - 1]
tmp = a[i - 1]
bit_buy = 0
init_bit = 0
if (init_bit and i == n - 1) or (bit_buy == 0 and (a[i] < a[i - 1])):
money += stock_num * a[i - 1]
ans = max(ans, money)
bit_buy = 1
stock_num = 0
print(i, a[i], money)
money += stock_num * tmp
ans = max(ans, money)
print(ans)
|
s991644993
|
Accepted
| 29 | 9,172 | 237 |
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
soko = a[0]
urine = 0
ans = 1000
for i in range(len(a) - 1):
if a[i] < a[i + 1]:
ans += (ans // a[i]) * (a[i + 1] - a[i])
#print(ans)
print(ans)
|
s969731517
|
p03555
|
u218494572
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
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.
|
s = input()
t = input()
if s[0] == t[2] and s[1] == t[2] and s[2] == t[0]:
print('YES')
else:
print('NO')
|
s184960542
|
Accepted
| 17 | 2,940 | 114 |
s = input()
t = input()
if s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:
print('YES')
else:
print('NO')
|
s089591736
|
p03854
|
u248670337
| 2,000 | 262,144 |
Wrong Answer
| 23 | 6,516 | 87 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
import re
print('Yes' if re.match('^(dream|dreamer|erase|eraser)+$',input()) else 'No')
|
s814154062
|
Accepted
| 23 | 6,516 | 87 |
import re
print('YES' if re.match('^(dream|dreamer|erase|eraser)+$',input()) else 'NO')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.