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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s721184627
|
p02842
|
u547728429
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 188 |
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
N = int(input())
X = int(N / 1.08)
ans = -1
while X * 1.08 <= N:
print(X)
if int(X * 1.08) == N:
ans = X
X += 1
if ans > 0:
print(ans)
else:
print(":(")
|
s956850754
|
Accepted
| 17 | 2,940 | 180 |
N = int(input())
X = int(N / 1.08)
ans = -1
while int(X * 1.08) <= N:
if int(X * 1.08) == N:
ans = X
X += 1
if ans > 0:
print(ans)
else:
print(":(")
|
s322005271
|
p03486
|
u970198631
| 2,000 | 262,144 |
Wrong Answer
| 30 | 9,076 | 150 |
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().split()
s.sort(reverse =True)
t = input().split()
t.sort()
list1 = [s,t]
list1.sort()
if list1[0] == t:
print('No')
else:
print('Yes')
|
s514492524
|
Accepted
| 27 | 8,948 | 148 |
s = list(input())
s.sort()
t = list(input())
t.sort(reverse =True)
list1 = [s,t]
list1.sort()
if list1[0] == t:
print('No')
else:
print('Yes')
|
s172404863
|
p03998
|
u697696097
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 186 |
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.
|
import sys
d={}
d["a"]=list(input())
d["b"]=list(input())
d["c"]=list(input())
turn="a"
while 1:
turn2=d[turn].pop(0)
if len(d[turn])==0:
print(turn)
sys.exit()
turn=turn2
|
s145091731
|
Accepted
| 43 | 5,628 | 526 |
import sys
from io import StringIO
import unittest
def yn(b):
print("Yes" if b==1 else "No")
return
def resolve():
readline=sys.stdin.readline
d={"a":0,"b":1,"c":2}
win=["A","B","C"]
s=[0]*3
s[0]=list(readline().rstrip())
s[1]=list(readline().rstrip())
s[2]=list(readline().rstrip())
turn=0
while 1:
if len(s[turn])==0:
print(win[turn])
return
turn=d[s[turn].pop(0)]
return
if 'doTest' not in globals():
resolve()
sys.exit()
|
s589812209
|
p03436
|
u513434790
| 2,000 | 262,144 |
Wrong Answer
| 2,112 | 150,860 | 722 |
We have an H \times W grid whose squares are painted black or white. The square at the i-th row from the top and the j-th column from the left is denoted as (i, j). Snuke would like to play the following game on this grid. At the beginning of the game, there is a character called Kenus at square (1, 1). The player repeatedly moves Kenus up, down, left or right by one square. The game is completed when Kenus reaches square (H, W) passing only white squares. Before Snuke starts the game, he can change the color of some of the white squares to black. However, he cannot change the color of square (1, 1) and (H, W). Also, changes of color must all be carried out before the beginning of the game. When the game is completed, Snuke's score will be the number of times he changed the color of a square before the beginning of the game. Find the maximum possible score that Snuke can achieve, or print -1 if the game cannot be completed, that is, Kenus can never reach square (H, W) regardless of how Snuke changes the color of the squares. The color of the squares are given to you as characters s_{i, j}. If square (i, j) is initially painted by white, s_{i, j} is `.`; if square (i, j) is initially painted by black, s_{i, j} is `#`.
|
from scipy.sparse.csgraph import dijkstra
H, W = map(int, input().split())
s = [input() for _ in range(H)]
graph = [[0 for _ in range(H*W)] for _ in range(H*W)]
for i in range(H):
for j in range(W-1):
if s[i][j] == s[i][j+1] == ".":
graph[j+(W*i)][j+(W*i)+1] = 1
graph[j+(W*i)+1][j+(W*i)] = 1
for i in range(H-1):
for j in range(W):
if s[i][j] == s[i+1][j] == ".":
graph[j+(W*i)][j+(W*(i+1))] = 1
graph[j+(W*(i+1))][j+(W*i)] = 1
d = dijkstra(graph)
cnt = 0
for i in s:
for j in range(W):
if i[j] == ".":
cnt += 1
if d[0][H*W-1] == float("inf"):
print(-1)
else:
print(cnt-d[0][H*W-1]-1)
|
s891184206
|
Accepted
| 28 | 3,700 | 610 |
from collections import deque
H, W = map(int, input().split())
S = [input() for i in range(H)]
C = sum(i.count('.') for i in S)
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = deque([(0, 0, 0)])
used = {(0, 0)}
res = []
while que:
s, t, cost = que.popleft()
if s == H-1 and t == W-1:
res = cost
break
for di, dj in dd:
xi = s + di; yj = t + dj
if (not 0 <= xi < H) or (not 0 <= yj < W) or S[xi][yj] == '#' or (xi, yj) in used:
continue
used.add((xi, yj))
que.append((xi, yj, cost + 1))
if res:
print(C - 1 - res)
else:
print(-1)
|
s992431484
|
p02743
|
u929996201
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,020 | 102 |
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
|
a,b,c = map(int,input().split())
if(pow(a,2)+pow(b,2) < pow(c,2)):
print("Yes")
else:
print("No")
|
s879347953
|
Accepted
| 27 | 9,156 | 104 |
a,b,c = map(int,input().split())
d = c-a-b
if(0 < d and d*d > 4*a*b):
print("Yes")
else:
print("No")
|
s584358838
|
p03721
|
u223904637
| 2,000 | 262,144 |
Wrong Answer
| 512 | 29,648 | 189 |
There is an empty array. The following N operations will be performed to insert integers into the array. In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array. Find the K-th smallest integer in the array after the N operations. For example, the 4-th smallest integer in the array \\{1,2,2,3,3,3\\} is 3.
|
n,k=map(int,input().split())
l=[]
for i in range(n):
l.append(list(map(int,input().split())))
l.sort()
i=n-1
ans=0
while k>0:
k=k-l[i][1]
ans=l[i][0]
i=i-1
print(ans)
|
s996106936
|
Accepted
| 498 | 27,872 | 187 |
n,k=map(int,input().split())
l=[]
for i in range(n):
l.append(list(map(int,input().split())))
l.sort()
i=0
ans=0
while k>0:
k=k-l[i][1]
ans=l[i][0]
i=i+1
print(ans)
|
s907125882
|
p03110
|
u370429695
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 171 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
num = int(input())
total = 0
for i in range(num):
li = input().split()
if li[1] == "JPY":
total += int(li[0])
else:
total += int(float(li[0])) * 380000
print(total)
|
s354602476
|
Accepted
| 17 | 2,940 | 166 |
num = int(input())
total = 0
for i in range(num):
li = input().split()
if li[1] == "JPY":
total += int(li[0])
else:
total += float(li[0]) * 380000
print(total)
|
s828473344
|
p03448
|
u749770850
| 2,000 | 262,144 |
Wrong Answer
| 29 | 3,060 | 240 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
c = 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if (500 * i) + (100 * j) + (50 * k) == x:
c = c + 1
print(c)
|
s873311954
|
Accepted
| 50 | 3,060 | 265 |
a= int(input())
b= int(input())
c= int(input())
x= int(input())
ans=0
for i in range (a+1):
for j in range (b+1):
for k in range (c+1):
if 500*i+100*j+50*k == x:
ans = ans + 1
else:
pass
print(ans)
|
s317435148
|
p03407
|
u077019541
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 84 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
A,B,C = map(int,input().split())
if C>=A+B*2:
print("Yes")
else:
print("No")
|
s164438153
|
Accepted
| 18 | 2,940 | 81 |
A,B,C = map(int,input().split())
if C>A+B:
print("No")
else:
print("Yes")
|
s212036981
|
p04043
|
u075785512
| 2,000 | 262,144 |
Wrong Answer
| 37 | 3,064 | 162 |
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.
|
#coding :UTF-8
#ABC042
list=input().split(" ")
list.sort()
print(list)
if list[0]=="5" and list[1]=="5" and list[2]=="7":
print("YES")
else:
print("NO")
|
s944794115
|
Accepted
| 39 | 3,064 | 160 |
#coding :UTF-8
#ABC042
list=input().split()
list.sort()
#print(list)
if list[0]=="5" and list[1]=="5" and list[2]=="7":
print("YES")
else:
print("NO")
|
s414566189
|
p02364
|
u927793658
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,460 | 1 |
Find the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph G = (V, E).
|
s889227707
|
Accepted
| 670 | 23,144 | 578 |
from heapq import *
def find(A,x):
p = A[x]
if p == x:
return x
a = find(A,p)
A[x] = a
return a
def union(A, x, y):
if find(A,x) > find(A,y):
bx, by = find(A,y), find(A,x)
else:
bx, by = find(A,x), find(A,y)
A[y] = bx
A[by] = bx
N, M = map( int, input().split())
V = [ i for i in range(N)]
H = [(0,0,0)]*M
for i in range(M):
s,t,w = map( int, input().split())
H[i] = (w,s,t)
heapify(H)
ans = 0
while H:
w,s,t = heappop(H)
if find(V,s) != find(V,t):
union(V,s,t)
ans += w
print(ans)
|
|
s348011801
|
p02613
|
u713014053
| 2,000 | 1,048,576 |
Wrong Answer
| 151 | 9,224 | 389 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
t = int(input())
d = dict()
d['TLE'] = 0
d['AC'] = 0
d['WA'] = 0
d['RE'] = 0
while t > 0:
s = input()
if s == 'TLE':
d['TLE'] += 1
elif s == 'WA':
d['WA'] += 1
elif s == 'RE':
d['RE'] += 1
elif s == 'AC':
d['AC'] += 1
t-=1
print('AC', 'X' ,d['AC'])
print('WA', 'X' ,d['WA'])
print('TLE', 'X' ,d['TLE'])
print('RE', 'X' ,d['RE'])
|
s630156185
|
Accepted
| 156 | 9,200 | 389 |
t = int(input())
d = dict()
d['TLE'] = 0
d['AC'] = 0
d['WA'] = 0
d['RE'] = 0
while t > 0:
s = input()
if s == 'TLE':
d['TLE'] += 1
elif s == 'WA':
d['WA'] += 1
elif s == 'RE':
d['RE'] += 1
elif s == 'AC':
d['AC'] += 1
t-=1
print('AC', 'x' ,d['AC'])
print('WA', 'x' ,d['WA'])
print('TLE', 'x' ,d['TLE'])
print('RE', 'x' ,d['RE'])
|
s249364032
|
p03360
|
u497883442
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 133 |
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 = list(map(int, input().split()))
k = int(input())
m = max(a,b,c)
l = m
for i in range(k-1):
l *= 2
print(sum([a,b,c])+l+m)
|
s668367792
|
Accepted
| 18 | 3,060 | 131 |
a,b,c = list(map(int, input().split()))
k = int(input())
m = max(a,b,c)
l = m
for i in range(k):
l *= 2
print(sum([a,b,c])-m+l)
|
s426074233
|
p02264
|
u530663965
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,012 | 1,025 |
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
|
from collections import deque
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes = processes, time = process_time)
for r in result:
print('{0} {1}'.format(r.name, r.time))
def run_roundrobin(processes, time, total_time = 0, result=[]):
if not processes:
return result
p = processes.popleft()
if p.time < time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return run_roundrobin(processes, time, total_time, result)
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main()
|
s159427103
|
Accepted
| 400 | 19,716 | 968 |
from collections import deque
def main():
process_count, process_time, processes = get_input()
result = run_roundrobin(processes=processes, time=process_time)
for r in result:
print(r.name, r.time)
def run_roundrobin(processes, time, total_time=0, result=[]):
while processes:
p = processes.popleft()
if p.time <= time:
total_time += p.time
p.time = total_time
result.append(p)
else:
total_time += time
p.time -= time
processes.append(p)
return result
def get_input():
count, time = list(map(lambda x: int(x), input().split(' ')))
processes = deque([])
for _ in range(count):
im = input().split(' ')
p = Process(im[0], int(im[1]))
processes.append(p)
return count, time, processes
class Process():
def __init__(self, name, time):
self.name = name
self.time = time
main()
|
s007299087
|
p03449
|
u555947166
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 177 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
N = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
x = [(sum(row1[:i]) + sum(row2[i-1:N+1])) for i in range(1, N+1)]
print(min(x))
|
s664467950
|
Accepted
| 17 | 3,060 | 176 |
N = int(input())
row1 = list(map(int, input().split()))
row2 = list(map(int, input().split()))
x = [(sum(row1[:i]) + sum(row2[i-1:N+1])) for i in range(1, N+1)]
print(max(x))
|
s031098062
|
p03361
|
u496744988
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,064 | 512 |
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.
|
import sys
h, w = map(int, input().split())
s = [input() for _ in range(h)]
print(s)
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for i in range(h):
for j in range(w):
if s[i][j] == '.':
continue
flag = 0
for k in range(4):
dh = i + dy[k]
dw = j + dx[k]
# print(dh, dw)
if 0 <= dh < h and 0 <= dw < w and s[dh][dw] == '#':
flag = 1
if flag == 0:
print('No')
sys.exit()
print('Yes')
|
s398241238
|
Accepted
| 23 | 3,064 | 503 |
import sys
h, w = map(int, input().split())
s = [input() for _ in range(h)]
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
for i in range(h):
for j in range(w):
if s[i][j] == '.':
continue
flag = 0
for k in range(4):
dh = i + dy[k]
dw = j + dx[k]
# print(dh, dw)
if 0 <= dh < h and 0 <= dw < w and s[dh][dw] == '#':
flag = 1
if flag == 0:
print('No')
sys.exit()
print('Yes')
|
s272959393
|
p03795
|
u077671688
| 2,000 | 262,144 |
Wrong Answer
| 26 | 8,868 | 496 |
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.
|
# abc055_a
N = int(input('整数を入力してね>'))
X = 800 * N
Y = (N/15)*200
print(X - Y)
|
s298947749
|
Accepted
| 25 | 9,124 | 65 |
N = int(input(''))
x = (800 * N)
y = (int(N/15)*200)
print(x - y)
|
s604078447
|
p03612
|
u732061897
| 2,000 | 262,144 |
Wrong Answer
| 63 | 20,472 | 142 |
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
|
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
if P[i] == i + 1:
ans += 1
print(max(ans - 1, 0))
|
s672042508
|
Accepted
| 85 | 20,540 | 266 |
N = int(input())
P = list(map(int, input().split()))
ans = 0
for i in range(N):
if i == N-1:
if P[i] == i+1:
ans +=1
break
a, b = P[i], P[i + 1]
if a == i + 1:
ans += 1
P[i] = b
P[i + 1] = a
print(ans)
|
s548571693
|
p02401
|
u179070318
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 273 |
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
|
while True:
a,op,b = [x for x in input().split( )]
a,b = [int(y) for y in [a,b]]
if op =='+':
print(a+b)
elif op =='-':
print(a-b)
elif op =='*':
print(a*b)
elif op =='/':
print(a/b)
elif op =='?':
break
|
s911807211
|
Accepted
| 20 | 5,604 | 274 |
while True:
a,op,b = [x for x in input().split( )]
a,b = [int(y) for y in [a,b]]
if op =='+':
print(a+b)
elif op =='-':
print(a-b)
elif op =='*':
print(a*b)
elif op =='/':
print(a//b)
elif op =='?':
break
|
s119498917
|
p03555
|
u118147328
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 136 |
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.
|
C1 = input()
C2 = input()
if C1[0] == C2[2] and\
C1[1] == C2[1] and\
C1[2] == C2[0]:
print("Yes")
else:
print("No")
|
s887981161
|
Accepted
| 17 | 2,940 | 136 |
C1 = input()
C2 = input()
if C1[0] == C2[2] and\
C1[1] == C2[1] and\
C1[2] == C2[0]:
print("YES")
else:
print("NO")
|
s954711612
|
p03502
|
u318859025
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 102 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
n=int(input())
li=[int(i) for i in str(n)]
sum=sum(li)
if n%sum==0:
print("YES")
else:
print("NO")
|
s774803079
|
Accepted
| 17 | 2,940 | 102 |
n=int(input())
li=[int(i) for i in str(n)]
sum=sum(li)
if n%sum==0:
print("Yes")
else:
print("No")
|
s823287216
|
p03361
|
u477977638
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,444 | 321 |
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=["."+input()+"." for i in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flag=0
print(s)
for i in range(h):
for j in range(w):
print(s[i][j])
if s[i][j]=="#":
if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
flag=1
print("Yes" if flag==0 else "No")
|
s467483053
|
Accepted
| 18 | 3,064 | 301 |
h,w=map(int,input().split())
s=["."+input()+"." for i in range(h)]
s=["."*(w+2)]+s+["."*(w+2)]
flag=0
for i in range(1,h+1):
for j in range(1,w+1):
if s[i][j]=="#":
if s[i-1][j]=="." and s[i+1][j]=="." and s[i][j-1]=="." and s[i][j+1]==".":
flag=1
print("Yes" if flag==0 else "No")
|
s860375296
|
p00352
|
u108948964
| 1,000 | 262,144 |
Wrong Answer
| 20 | 5,532 | 37 |
Alice and Brown are brothers in a family and each receives pocket money in celebration of the coming year. They are very close and share the total amount of the money fifty-fifty. The pocket money each receives is a multiple of 1,000 yen. Write a program to calculate each one’s share given the amount of money Alice and Brown received.
|
inp = input().split(" ")
print(inp)
|
s042933566
|
Accepted
| 20 | 5,580 | 54 |
a, b = map(int, input().split())
print((a + b) // 2)
|
s670667389
|
p03338
|
u455317716
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 3,064 | 235 |
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
N = int(input())
S = input()
result = 0
for i in range(N):
x = S[:i]
y = S[i:]
print(x,y)
x_set,y_set = set(),set()
for ii in x:
x_set.add(ii)
for ii in y:
y_set.add(ii)
result = max(len(x_set & y_set),result)
print(result)
|
s413991926
|
Accepted
| 18 | 3,060 | 266 |
n = int(input()) - 1
s = input()
result_list = list()
for i in range(n):
x = s[:i+1]
y = s[i+1:]
comon_set_len = len(set(ii for ii in x) & set(iii for iii in y))
result_list.append(comon_set_len)
result_list.sort(reverse = True)
print(result_list[0])
|
s645777579
|
p03719
|
u444238096
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
A, B, C = map(int, input().split())
if C>=A and C<=B:
print("YES")
else:
print("NO")
|
s783125506
|
Accepted
| 17 | 2,940 | 92 |
A, B, C = map(int, input().split())
if C>=A and C<=B:
print("Yes")
else:
print("No")
|
s195713332
|
p03377
|
u519923151
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,116 | 90 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x = map(int, input().split())
if a<= x <= a+b:
print("Yes")
else:
print("No")
|
s009790760
|
Accepted
| 28 | 9,148 | 90 |
a,b,x = map(int, input().split())
if a<= x <= a+b:
print("YES")
else:
print("NO")
|
s265149661
|
p03759
|
u053535689
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,100 | 103 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
# 058a
a, b, c = map(int, input().split())
if b - a == c - b:
print('Yes')
else:
print('No')
|
s411796495
|
Accepted
| 31 | 9,132 | 103 |
# 058a
a, b, c = map(int, input().split())
if b - a == c - b:
print('YES')
else:
print('NO')
|
s307323212
|
p03379
|
u771532493
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 25,220 | 133 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N=int(input())
L=[int(i) for i in input().split()]
L.sort()
for i in range(N):
Lcopy=L[:]
del Lcopy[i]
print(Lcopy[N//2-1])
|
s153841260
|
Accepted
| 319 | 25,228 | 153 |
N=int(input())
L=[int(i) for i in input().split()]
L1=sorted(L)
a=L1[N//2]
b=L1[N//2-1]
for i in range(N):
if L[i]<a:
print(a)
else:
print(b)
|
s273607289
|
p02396
|
u998185318
| 1,000 | 131,072 |
Wrong Answer
| 140 | 5,596 | 137 |
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
|
cnt = 1
while True:
in_value = int(input())
if in_value == 0:
break
print("Case " + str(cnt) + ": " + str(in_value))
|
s479474187
|
Accepted
| 90 | 5,908 | 295 |
def input_until_zero():
rtn_list = []
while True:
in_value = int(input())
if in_value == 0:
break
rtn_list.append(in_value)
return rtn_list
rtn = input_until_zero()
for i in range(len(rtn)):
print("Case " + str(i + 1) + ": " + str(rtn[i]))
|
s625854222
|
p03720
|
u633548583
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 102 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m=map(int,input().split())
a=list(map(int,input().split()))
print(a.count(i) for i in range (1,n+1))
|
s772300761
|
Accepted
| 17 | 2,940 | 168 |
n,m=map(int,input().split())
li=[]
for i in range(m):
a,b=map(int,input().split())
li.append(a)
li.append(b)
for j in range(1,n+1):
print(li.count(j))
|
s942772834
|
p02646
|
u801049006
| 2,000 | 1,048,576 |
Wrong Answer
| 24 | 9,176 | 161 |
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v - w > 0 and abs(a-b) / (v-w) > t:
print("YES")
else:
print("NO")
|
s675030959
|
Accepted
| 21 | 9,180 | 162 |
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v - w > 0 and abs(a-b) / (v-w) <= t:
print("YES")
else:
print("NO")
|
s552161429
|
p02692
|
u296150111
| 2,000 | 1,048,576 |
Wrong Answer
| 142 | 16,320 | 663 |
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
|
n,a,b,c=map(int,input().split())
s=[input() for _ in range(n)]
if a+b+c==0:
print("No")
elif a+b+c==1:
for x in s:
if x=="AB":
if a==b==0:
print("No")
exit()
elif a==0:
a+=1
b-=1
else:
b+=1
a-=1
elif x=="BC":
if b==c==0:
print("No")
exit()
elif b==0:
b+=1
c-=1
else:
c+=1
b-=1
else:
if c==a==0:
print("No")
exit()
elif c==0:
c+=1
a-=1
else:
a+=1
c-=1
else:
if s[0]=="AB":
if a==b==0:
print("No")
else:
print("Yes")
elif s[0]=="BC":
if b==c==0:
print("No")
else:
print("Yes")
else:
if c==a==0:
print("No")
else:
print("Yes")
|
s306416893
|
Accepted
| 186 | 17,100 | 1,666 |
n,a,b,c=map(int,input().split())
s=[input() for _ in range(n)]
if a+b+c==0:
print("No")
elif a+b+c==1:
ans=[]
for x in s:
if x=="AB":
if a==b==0:
print("No")
exit()
elif a==0:
a+=1
b-=1
ans.append("A")
else:
b+=1
a-=1
ans.append("B")
elif x=="BC":
if b==c==0:
print("No")
exit()
elif b==0:
b+=1
c-=1
ans.append("B")
else:
c+=1
b-=1
ans.append("C")
else:
if c==a==0:
print("No")
exit()
elif c==0:
c+=1
a-=1
ans.append("C")
else:
a+=1
c-=1
ans.append("A")
print("Yes")
for x in ans:
print(x)
else:
ans=[]
if s[0]=="AB":
if a==b==0:
print("No")
exit()
else:
print("Yes")
elif s[0]=="BC":
if b==c==0:
print("No")
exit()
else:
print("Yes")
else:
if c==a==0:
print("No")
exit()
else:
print("Yes")
s.append("AB")
for i in range(len(s)-1):
x=s[i]
if x=="AB":
if a<b:
a+=1
b-=1
ans.append("A")
elif a>b:
b+=1
a-=1
ans.append("B")
else:
if "A" not in s[i+1]:
b+=1
a-=1
ans.append("B")
else:
a+=1
b-=1
ans.append("A")
elif x=="BC":
if b<c:
b+=1
c-=1
ans.append("B")
elif b>c:
c+=1
b-=1
ans.append("C")
else:
if "B" not in s[i+1]:
c+=1
b-=1
ans.append("C")
else:
b+=1
c-=1
ans.append("B")
else:
if c<a:
c+=1
a-=1
ans.append("C")
elif c>a:
a+=1
c-=1
ans.append("A")
else:
if "C" not in s[i+1]:
a+=1
c-=1
ans.append("A")
else:
c+=1
a-=1
ans.append("C")
for x in ans:
print(x)
|
s299043070
|
p03377
|
u726439578
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 108 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,c =map(int,input().split())
if b>c:
print("NO")
elif a+b>=c :
print("YES")
else:
print("NO")
|
s371318155
|
Accepted
| 21 | 3,188 | 88 |
a,b,c =map(int,input().split())
if a>c or a+b<c:
print("NO")
else:
print("YES")
|
s060495366
|
p02612
|
u735091636
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,176 | 321 |
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.
|
import sys
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]
def main():
N = II()
print(N%1000)
if __name__ == "__main__":
main()
|
s207541077
|
Accepted
| 30 | 9,184 | 389 |
import sys
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]
def main():
N = II()
ans = 1000-N%1000
if ans==1000:
print(0)
else:
print(ans)
if __name__ == "__main__":
main()
|
s898141327
|
p02678
|
u166340293
| 2,000 | 1,048,576 |
Wrong Answer
| 2,207 | 48,464 | 447 |
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.
|
N,M=map(int,input().split())
r=[]
for i in range(M):
r.append(list(map(int,input().split())))
q=[0]
d=[0]+[-1]*N
ans=[0]+[-1]*N
while q:
u=q.pop(0)
for v in range(M):
if r[v][0]-1==u:
o=r[v][1]
if d[o-1]<=0:
d[o-1]=d[u]+1
ans[o-1]=u
q.append(o-1)
elif r[v][1]-1==u:
o=r[v][0]
if d[o-1]<0:d[o-1]=d[u]+1;q.append(o-1);ans[o-1]=u
print("Yes")
for i in range(1,N):
print(i+1,ans[i]+1)
|
s021573372
|
Accepted
| 1,470 | 37,268 | 399 |
N,M=map(int,input().split())
r=[]
k=[]
for i in range(N):
k.append([])
for i in range(M):
a,b=map(int,input().split())
k[a-1].append(b)
k[b-1].append(a)
d=[0]+[-1]*N
ans=[0]+[-1]*N
q=[0]
while q:
u=q.pop(0)
for v in range(len(k[u])):
o=k[u][v]
if d[o-1]<=0:
d[o-1]=d[u]+1
ans[o-1]=u
q.append(o-1)
print("Yes")
for i in range(1,N):
print(ans[i]+1)
|
s221075782
|
p02833
|
u454524105
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 133 |
For an integer n not less than 0, let us define f(n) as follows: * f(n) = 1 (if n < 2) * f(n) = n f(n-2) (if n \geq 2) Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).
|
n = int(input())
if n % 2 == 1: print(0)
else:
ans = 0
n /= 2
while n:
ans += n / 5
n /= 5
print(ans)
|
s750402218
|
Accepted
| 17 | 2,940 | 189 |
n = int(input())
if n % 2 == 1: print(0)
else:
ans = 0
i = 1
while True:
a = 2 * 5**i
if n // a == 0: break
ans += (n // a)
i += 1
print(ans)
|
s237667337
|
p03693
|
u217303170
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 83 |
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=input().split()
x=r+g+b
y=int(x)
if y%4==0:
print('Yes')
else:
print('No')
|
s140133331
|
Accepted
| 17 | 2,940 | 82 |
r,g,b=input().split()
x=r+g+b
y=int(x)
if y%4==0:
print('YES')
else:
print('NO')
|
s463954773
|
p03049
|
u845333844
| 2,000 | 1,048,576 |
Wrong Answer
| 46 | 3,064 | 351 |
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
|
n=int(input())
sum=0
a=0
b=0
ab=0
for i in range(n):
x=input()
m=len(x)
if x[0]=='B' and x[m-1]=='A':
ab+=1
elif x[0]=='B':
b+=1
elif x[m-1]=='A':
a+=1
for j in range(m-1):
if x[j]=='A' and x[j+1]=='B':
sum+=1
if a==b:
print(sum+a+ab-1)
else:
print(sum+min(a,b)+ab)
|
s533955208
|
Accepted
| 45 | 3,064 | 465 |
n=int(input())
sum=0
a=0
b=0
ab=0
for i in range(n):
x=input()
m=len(x)
if x[0]=='B' and x[m-1]=='A':
ab+=1
elif x[0]=='B':
b+=1
elif x[m-1]=='A':
a+=1
for j in range(m-1):
if x[j]=='A' and x[j+1]=='B':
sum+=1
if ab==0:
print(sum+min(a,b))
else:
if a==0 and b==0:
print(sum+ab-1)
elif a==0 or b==0:
print(sum+ab)
else:
print(sum+ab+1+min(a-1,b-1))
|
s821449514
|
p03408
|
u917138620
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 301 |
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
in_num = input()
in_data=[]
for i in range(0,int(in_num)):
in_data.append(input())
out_num = input()
out_data = []
for i in range(0,int(out_num)):
out_data.append(input())
max_count=0
for n in in_data:
tmp = out_data.count(n)
if tmp > max_count:
max_count = tmp
print(max_count)
|
s980555767
|
Accepted
| 17 | 3,064 | 320 |
in_num = input()
in_data=[]
for i in range(0,int(in_num)):
in_data.append(input())
out_num = input()
out_data = []
for i in range(0,int(out_num)):
out_data.append(input())
max_count=0
for n in in_data:
tmp = in_data.count(n) - out_data.count(n)
if tmp > max_count:
max_count = tmp
print(max_count)
|
s466295010
|
p02806
|
u857428111
| 2,525 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 559 |
Niwango created a playlist of N songs. The title and the duration of the i-th song are s_i and t_i seconds, respectively. It is guaranteed that s_1,\ldots,s_N are all distinct. Niwango was doing some work while playing this playlist. (That is, all the songs were played once, in the order they appear in the playlist, without any pause in between.) However, he fell asleep during his work, and he woke up after all the songs were played. According to his record, it turned out that he fell asleep at the very end of the song titled X. Find the duration of time when some song was played while Niwango was asleep.
|
#!/usr/bin/env python3
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
a=sys.stdin.readlines()
#print(a)
N,X=int(a[0]),a[-1]
#print(N)
slept=0
ans=0
for i in range(1,1+N):
t,l=a[i].split()
#print(t,l)
if slept:ans+=int(l)
if t==X:slept=1
print(ans)
#%%submit!
resolve()
|
s858491264
|
Accepted
| 18 | 3,064 | 586 |
#!/usr/bin/env python3
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
a=sys.stdin.readlines()
#print(a)
N,X=int(a[0].rstrip()),a[-1].rstrip()
#print(N)
slept=0
ans=0
for i in range(1,1+N):
t,l=a[i].rstrip().split()
#print(t,l)
if slept:ans+=int(l)
if t==X:slept=1
print(ans)
#%%submit!
resolve()
|
s664975141
|
p03681
|
u172569352
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 81 |
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
|
N, M = [int(i) for i in input().split()]
L = abs(N - M)
if L >= 2:
print(0)
|
s092431393
|
Accepted
| 703 | 5,180 | 254 |
import math
N, M = [int(i) for i in input().split()]
r = pow(10, 9) + 7
L = abs(N - M)
if L >= 2:
print(0)
elif L == 0:
E = 2*math.factorial(N)*math.factorial(M)
print(E % r)
else:
E = math.factorial(N)*math.factorial(M)
print(E % r)
|
s948659051
|
p03696
|
u703890795
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 254 |
You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of `(`, X and `)` in this order is also a correct bracket sequence. * If X and Y are correct bracket sequences, the concatenation of X and Y in this order is also a correct bracket sequence. * Every correct bracket sequence can be derived from the rules above. Find the shortest correct bracket sequence that can be obtained. If there is more than one such sequence, find the lexicographically smallest one.
|
N = int(input())
S = input()
T = []
for s in S:
if s == "(":
T.append(-1)
else:
T.append(1)
c = 0
U = ""
for i in range(N):
c += T[i]
if c > 0:
U += "("
c -= 1
if T[i] == -1:
U += "("
else:
U += ")"
print(U + ")"*(-c))
|
s687014826
|
Accepted
| 17 | 3,060 | 265 |
N = int(input())
S = input()
T = []
c = 0
m = 0
for s in S:
if s == ")":
c += 1
else:
if c > 0:
m += c
c = 0
c -= 1
if c > 0:
m += c
c = 0
print("("*m + S + ")"*(-c))
|
s502418103
|
p03047
|
u661439250
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 44 |
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
N, K = map(int, input().split())
print(N-K)
|
s653472558
|
Accepted
| 17 | 2,940 | 46 |
N, K = map(int, input().split())
print(N-K+1)
|
s612380096
|
p02612
|
u078276601
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,096 | 47 |
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())
change = N%1000
print(change)
|
s661552335
|
Accepted
| 29 | 9,112 | 66 |
N = int(input())
change = ((N+1000-1)//1000)*1000-N
print(change)
|
s228354082
|
p02742
|
u546501940
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 137 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
x,y = map(int,input().split())
if x ==1 or y ==1:
print(1)
exit(0)
if x%2==0 or y%2==0:
print(x*y/2)
exit(0)
print((x*y/2+1))
|
s936587920
|
Accepted
| 17 | 2,940 | 149 |
x,y = map(int,input().split())
if x ==1 or y ==1:
print(1)
exit(0)
if x%2==0 or y%2==0:
print(int(x/2*y))
exit(0)
a=int(x*y/2)+1
print(a)
|
s170046250
|
p02613
|
u970133396
| 2,000 | 1,048,576 |
Wrong Answer
| 145 | 16,484 | 183 |
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
from collections import Counter
n = int(input().strip())
L = [input().strip() for _ in range(n)]
cnt=Counter(L)
for x in ["AC", "WA", "TLE", "RE"]:
print(x+" × "+str(cnt[x]))
|
s655354004
|
Accepted
| 146 | 16,616 | 180 |
from collections import Counter
n = int(input().strip())
L = [input().strip() for _ in range(n)]
cnt=Counter(L)
for x in ["AC", "WA", "TLE", "RE"]:
print(x+" x "+str(cnt[x]))
|
s811261310
|
p02399
|
u385991569
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,620 | 176 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 12 16:30:47 2017
@author: gedyra
"""
a,b = list(map(int, input().split()))
d = int(a/b)
r = a%b
f = float(a/b)
print(d, r, f)
|
s913522856
|
Accepted
| 20 | 7,624 | 98 |
a,b = list(map(int, input().split()))
d = a//b
r = a%b
f = ('{:.5f}'.format(a/b))
print(d, r, f)
|
s494923422
|
p03469
|
u078349616
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 37 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
print(input().replace("2018","2017"))
|
s542397398
|
Accepted
| 22 | 2,940 | 37 |
print(input().replace("2017","2018"))
|
s925170775
|
p02748
|
u686253980
| 2,000 | 1,048,576 |
Wrong Answer
| 2,105 | 36,608 | 407 |
You are visiting a large electronics store to buy a refrigerator and a microwave. The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen. You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time. You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.
|
A, B, M = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []
for i in range(M):
c = [int(i) for i in input().split(" ")]
C.append(c)
print(a)
m = 1000000
for i in a:
for j in b:
cost = i + j
if m >= cost:
m = cost
for c in C:
cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
if m >= cost:
m = cost
print(m)
|
s778320744
|
Accepted
| 457 | 32,492 | 328 |
A, B, M = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
C = []
for i in range(M):
c = [int(i) for i in input().split(" ")]
C.append(c)
m = min(a) + min(b)
for c in C:
cost = a[c[0] - 1] + b[c[1] - 1] - c[2]
if m >= cost:
m = cost
print(m)
|
s050407811
|
p03448
|
u825528847
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,572 | 256 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
for j in range(B+1):
tmp = i * 500 + j * 100
if (X - tmp) % 50 == 0 and tmp <= X:
print(i, j)
ans += 1
print(ans)
|
s401871240
|
Accepted
| 58 | 3,316 | 222 |
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A+1):
for j in range(B+1):
for k in range(C+1):
ans += 1 * ((i * 500 + j * 100 + k * 50) == X)
print(ans)
|
s629526794
|
p02612
|
u229950162
| 2,000 | 1,048,576 |
Wrong Answer
| 32 | 9,048 | 40 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input().rstrip())
print(n%1000)
|
s973228429
|
Accepted
| 27 | 9,056 | 47 |
n = int(input().rstrip())
print((1000-n)%1000)
|
s448707478
|
p03359
|
u859897687
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 38 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a=input();print(int(a[0])-(a[0]>a[1]))
|
s186938108
|
Accepted
| 17 | 2,940 | 43 |
a,b=map(int,input().split())
print(a-(a>b))
|
s650523727
|
p03354
|
u766684188
| 2,000 | 1,048,576 |
Wrong Answer
| 697 | 36,100 | 886 |
We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized: * Choose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}. Find the maximum possible number of i such that p_i = i after operations.
|
n,m=map(int,input().split())
P=list(map(int,input().split()))
edges=[list(map(int,input().split())) for _ in range(m)]
class UnionFind:
def __init__(self,n):
self.par=[i for i in range(n+1)]
self.rank=[0]*(n+1)
def find(self,x):
if self.par[x]==x:
return x
else:
self.par[x]=self.find(self.par[x])
return self.par[x]
def union(self,x,y):
x=self.find(x)
y=self.find(y)
if x==y:
return
if self.rank[x]<self.rank[y]:
self.par[x]=y
else:
self.par[y]=x
if self.rank[x]==self.rank[y]:
self.rank[x]+=1
def same_check(self,x,y):
return self.find(x)==self.find(y)
uf=UnionFind(n)
ans=0
for i,j in edges:
uf.union(i,j)
for i in range(n):
if uf.same_check(i,P[i]):
ans+=1
print(ans)
|
s975639851
|
Accepted
| 713 | 36,100 | 898 |
#ARC097-D
n,m=map(int,input().split())
P=list(map(int,input().split()))
edges=[list(map(int,input().split())) for _ in range(m)]
class UnionFind:
def __init__(self,n):
self.par=[i for i in range(n+1)]
self.rank=[0]*(n+1)
def find(self,x):
if self.par[x]==x:
return x
else:
self.par[x]=self.find(self.par[x])
return self.par[x]
def union(self,x,y):
x=self.find(x)
y=self.find(y)
if x==y:
return
if self.rank[x]<self.rank[y]:
self.par[x]=y
else:
self.par[y]=x
if self.rank[x]==self.rank[y]:
self.rank[x]+=1
def same_check(self,x,y):
return self.find(x)==self.find(y)
uf=UnionFind(n)
ans=0
for i,j in edges:
uf.union(i,j)
for i in range(n):
if uf.same_check(i+1,P[i]):
ans+=1
print(ans)
|
s123267010
|
p02972
|
u798818115
| 2,000 | 1,048,576 |
Wrong Answer
| 50 | 7,148 | 160 |
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
# coding: utf-8
# Your code here!
M=int(input())
B=list(map(int,input().split()))
l=[0]*M
for i in range(1,-int(-M**0.5//1)+1):
print(i)
|
s420812760
|
Accepted
| 787 | 14,044 | 575 |
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
count=0
ans=[]
hako=[0]*N
for i in range(N)[::-1]:
all=0
for j in range(i,N)[::i+1]:
if i==j:
continue
all^=hako[j]
if all==1:
if A[i]==1:
continue
else:
hako[i]=1
count+=1
ans.append(i+1)
else:
if A[i]==1:
hako[i]=1
count+=1
ans.append(i+1)
else:
continue
ans.sort()
print(count)
print(*ans)
#print(hako)
|
s717599315
|
p02608
|
u347600233
| 2,000 | 1,048,576 |
Wrong Answer
| 2,205 | 9,008 | 257 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
n = int(input())
ans = [0] * (n + 1)
for x in range(1, n):
for y in range(1, n):
for z in range(1, n):
if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
ans[x**2 + y**2 + z**2 + x*y + y*z + z*x] += 1
print(*ans, sep='\n')
|
s542137698
|
Accepted
| 194 | 9,588 | 325 |
n = int(input())
ans = [0] * (n + 1)
a = [1, 3, 6]
for x in range(1, int(n**0.5) + 1):
for y in range(x, int(n**0.5) + 1):
for z in range(y, int(n**0.5) + 1):
v = x**2 + y**2 + z**2 + x*y + y*z + z*x
if v <= n:
ans[v] += a[len(set([x, y, z])) - 1]
print(*ans[1:], sep='\n')
|
s265536113
|
p02694
|
u605327527
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 9,160 | 141 |
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?
|
import math
n = int(input())
cash = 100
count = 0
while n >= cash:
cash = cash + math.floor(cash * 0.01)
count += 1
print(count)
|
s582590841
|
Accepted
| 23 | 9,156 | 140 |
import math
n = int(input())
cash = 100
count = 0
while n > cash:
cash = cash + math.floor(cash * 0.01)
count += 1
print(count)
|
s366353230
|
p02257
|
u123669391
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,640 | 277 |
A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7. Write a program which reads a list of _N_ integers and prints the number of prime numbers in the list.
|
n = int(input())
sum = 0
for _ in range(n):
a = int(input())
if a == 2:
continue
for i in range(a):
x = i + 2
if a%x == 0:
sum += 1
print(a)
break
if x > a ** 0.5:
break
print(n - sum)
|
s438135678
|
Accepted
| 1,970 | 5,668 | 257 |
n = int(input())
sum = 0
for _ in range(n):
a = int(input())
if a == 2:
continue
for i in range(a):
x = i + 2
if a%x == 0:
sum += 1
break
if x > a ** 0.5:
break
print(n - sum)
|
s401694326
|
p03759
|
u609987416
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a,b,c = map(int, input().split())
if (b - a == c - b):
print("Yes")
else:
print("No")
|
s608919429
|
Accepted
| 17 | 2,940 | 93 |
a,b,c = map(int, input().split())
if (b - a == c - b):
print("YES")
else:
print("NO")
|
s480801960
|
p03814
|
u814986259
| 2,000 | 262,144 |
Wrong Answer
| 25 | 6,180 | 89 |
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
S=list(input())
a_id=S.index("A")
z_id=list(reversed(S)).index("Z")
print(z_id - a_id +1)
|
s592832420
|
Accepted
| 25 | 6,180 | 98 |
S=list(input())
l =len(S)
a_id=S.index("A")
z_id=list(reversed(S)).index("Z")
print(l-z_id - a_id)
|
s750702572
|
p04043
|
u787059958
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,168 | 170 |
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.
|
ans = []
A, B, C = map(int, input().split())
ans.append(A)
ans.append(B)
ans.append(C)
if ans.count(5) == 2 and ans.count(7) == 1:
print('Yes')
else:
print('No')
|
s987825104
|
Accepted
| 21 | 9,064 | 170 |
ans = []
A, B, C = map(int, input().split())
ans.append(A)
ans.append(B)
ans.append(C)
if ans.count(5) == 2 and ans.count(7) == 1:
print('YES')
else:
print('NO')
|
s781081448
|
p03829
|
u873917047
| 2,000 | 262,144 |
Wrong Answer
| 100 | 14,252 | 221 |
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the other towns. You have two ways to travel: * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction. * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered. Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
|
#coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
out=0
for i in range(0,N-1):
d=lis[i+1]-lis[i]
if d < (B-A):
out=out+d
else:
out=out+B
print(out)
|
s364575661
|
Accepted
| 101 | 14,252 | 221 |
#coding: UTF-8
N, A, B=map(int, input().split())
lis=list(map(int,input().split()))
#print(lis)
out=0
for i in range(0,N-1):
d=(lis[i+1]-lis[i])*A
if d < B:
out=out+d
else:
out=out+B
print(out)
|
s814129986
|
p03110
|
u653807637
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 171 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n = int(input())
bs = [input().split() for _ in range(n)]
ans = 0
for b in bs:
if b[1] == "BTC":
ans += float(b[0]) * 380000
else:
ans += int(b[0])
print(int(ans))
|
s191890358
|
Accepted
| 17 | 2,940 | 170 |
n = int(input())
bs = [input().split() for _ in range(n)]
ans = 0
for b in bs:
if b[1] == "BTC":
ans += float(b[0]) * 380000.0
else:
ans += float(b[0])
print(ans)
|
s345606411
|
p03478
|
u441320782
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 11 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
print(2/10)
|
s448012045
|
Accepted
| 35 | 9,420 | 176 |
N,A,B=map(int,input().split())
ans=[]
for i in range(1,N+1):
j=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+(i%10)//1
if A<=j<=B:
ans.append(i)
print(sum(ans))
|
s012242515
|
p03048
|
u664762434
| 2,000 | 1,048,576 |
Wrong Answer
| 1,300 | 3,060 | 173 |
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())
x = N//R
ans = 0
for i in range(x+1):
M = N - i*R
for j in range((M+1)//G):
L = M - j*G
if L%B == 0:
ans += 1
print(ans)
|
s158125816
|
Accepted
| 1,554 | 3,060 | 173 |
R,G,B,N = map(int,input().split())
x = N//R
ans = 0
for i in range(x+1):
M = N - i*R
for j in range((M//G)+1):
L = M - j*G
if L%B == 0:
ans += 1
print(ans)
|
s778649164
|
p03861
|
u183840468
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
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 = [int(i) for i in input().split()]
if (b-a)%x == 0:
print(b//x - a//x)
else:
print(b//x - a//x+1)
|
s754901187
|
Accepted
| 17 | 3,064 | 89 |
a,b,c = [int(i) for i in input().split()]
print(b//c - (a-1)//c if a > 0 else b//c + 1)
|
s731136722
|
p00020
|
u518711553
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,288 | 27 |
Write a program which replace all the lower-case letters of a given text with the corresponding captital letters.
|
print(input().capitalize())
|
s780308590
|
Accepted
| 30 | 7,940 | 109 |
from functools import reduce
from operator import add
print(reduce(add, map(str.capitalize, input()[:]), ''))
|
s955213006
|
p03730
|
u760794812
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,148 | 112 |
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())
for i in range(B):
if (i+1)*A%B== C:
print('Yes')
exit()
print('No')
|
s054740555
|
Accepted
| 25 | 9,156 | 111 |
A,B,C = map(int,input().split())
for i in range(B):
if (i+1)*A%B== C:
print('YES')
exit()
print('NO')
|
s654273656
|
p02409
|
u780342333
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,708 | 394 |
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
|
nums = [[[0 for x in range(0, 10)] for x in range(0, 3)] for x in range(0, 4)]
input1='''1 1 3 8
3 2 2 7
4 3 8 1'''.split("\n")
print(input1)
for e in input1:
efbv = e.split(" ")
e_b, e_f, e_r, e_v = map(int, efbv)
nums[e_b - 1][e_f - 1][e_r -1] += e_v
for b in range(4):
for f in range (3):
print(" " + " ".join(map(str, nums[b][f])))
if b != 3: print("#" * 20)
|
s045166549
|
Accepted
| 30 | 5,628 | 372 |
buildings = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
n = int(input())
for _ in range(n):
b, f, r, v = map(int, input().split())
buildings[b-1][f-1][r-1] += v
sep_count = len(buildings) - 1
for b in buildings:
for f in b:
print(" ",end="")
print(*f)
if sep_count != 0:
print("#" * 20)
sep_count -= 1
|
s073489618
|
p02690
|
u621345513
| 2,000 | 1,048,576 |
Wrong Answer
| 73 | 15,720 | 240 |
Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X.
|
x = int(input())
from itertools import product
tot_comb = [el for el in product(list(range(-120, 121)), list(range(-120, 121))) if el[0]!=el[1]]
tot_comb += [(0,0)]
num_dict = {el[0]**5 - el[1]**5: el for el in tot_comb}
print(num_dict[x])
|
s754326276
|
Accepted
| 68 | 15,724 | 264 |
x = int(input())
from itertools import product
tot_comb = [el for el in product(list(range(-120, 121)), list(range(-120, 121))) if el[0]!=el[1]]
tot_comb += [(0,0)]
num_dict = {el[0]**5 - el[1]**5: el for el in tot_comb}
pair = num_dict[x]
print(pair[0], pair[1])
|
s674373108
|
p03494
|
u774411119
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 265 |
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
|
N=int(input())
suji=input()
I1=suji.split(" ")
I=list(map(int,I1))
wari=2
n=0
kazu=0
X=1
while n<3:
if I[n]%wari==0:
n+=1
if I[N-1]%2==0:
wari=wari*2
kazu+=1
n=0
else:
X=0
break
print(kazu)
|
s304924235
|
Accepted
| 160 | 12,508 | 301 |
import math
import numpy as np
N = int(input())
A_list = list(map(int, input().split()))
np_A = np.array(A_list)
tmp_cou = 0
x = 1
while x==1:
for i in np_A:
if i % 2 == 0:
tmp_cou += 1
else:
x = 2
np_A = np_A/2
cou = math.floor(tmp_cou/N)
print(cou)
|
s036171757
|
p02388
|
u128236306
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,600 | 36 |
Write a program which calculates the cube of a given integer x.
|
x = input()
x = int(x)
print(x ^ 3)
|
s719055299
|
Accepted
| 20 | 7,624 | 36 |
x = input()
x = int(x)
print(x ** 3)
|
s288752509
|
p03110
|
u994521204
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 158 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
n=int(input())
c=0
for i in range(n):
x,u=input().split()
if u=='JPY':
c+=int(x)
elif u=='BTC':
c+=int(380000 * float(x))
print(c)
|
s782777825
|
Accepted
| 17 | 2,940 | 153 |
n=int(input())
c=0
for i in range(n):
x,u=input().split()
if u=='JPY':
c+=int(x)
elif u=='BTC':
c+=380000 * float(x)
print(c)
|
s267306023
|
p03854
|
u350248178
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 160 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s=input()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream","")
if s=="":
print("Yes")
else:
print("No")
|
s168234642
|
Accepted
| 19 | 3,188 | 160 |
s=input()
s=s.replace("eraser","")
s=s.replace("erase","")
s=s.replace("dreamer","")
s=s.replace("dream","")
if s=="":
print("YES")
else:
print("NO")
|
s202597438
|
p03228
|
u022871813
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 3,444 | 415 |
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
a, b, k = map(int, input().split())
for i in range(k):
if i%2 == 0:
if a%2 == 0:
a /= 2
b += 2
elif a%2 == 1:
a -= 1
a /= 2
b += a
elif i%2 == 1:
if b%2 == 0:
b /= 2
a += b
elif a%2 == 1:
b -= 1
b /= 2
a += 2
print(int(a),int(b))
print(int(a),int(b))
|
s913490836
|
Accepted
| 17 | 3,064 | 390 |
a, b, k = map(int, input().split())
for i in range(k):
if i%2 == 0:
if a%2 == 0:
a /= 2
b += a
elif a%2 == 1:
a -= 1
a /= 2
b += a
elif i%2 == 1:
if b%2 == 0:
b /= 2
a += b
elif b%2 == 1:
b -= 1
b /= 2
a += b
print(int(a),int(b))
|
s436137771
|
p03720
|
u369338402
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 221 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m=map(int,input().split())
roads=[]
for i in range(m):
roads.append(input().split())
count=0
for j in range(1,n+1):
for k in range(m):
if roads[k][0]==j or roads[k][1]==j:
count+=1
print(count)
count=0
|
s739615717
|
Accepted
| 19 | 3,060 | 253 |
n,m=map(int,input().split())
roads=[]
for i in range(m):
roads.append(input().split())
count=0
for j in range(1,n+1):
for k in range(m):
if int(roads[k][0])==j or int(roads[k][1])==j:
count+=1
#print('road')
print(count)
count=0
|
s821848339
|
p03575
|
u599547273
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 486 |
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M edges.
|
n, m = map(int, input().split(" "))
a = [list(map(int, input().split(" "))) for i in range(m)]
a_counts = [0]*n
for a_i in sum(a, []):
a_counts[a_i-1] += 1
bridge_count = 0
for i, count in enumerate(a_counts):
if count == 1:
p = i+1
while a_counts[p-1] <= 2:
for j, a_i in enumerate(a):
if a_i and p in a_i and a_counts[p-1] <= 2:
print(a_i)
a_i.remove(p)
print(a_i)
p = a_i[0]
a[j] = None
bridge_count += 1
break
print(bridge_count)
|
s765855814
|
Accepted
| 18 | 3,064 | 499 |
n, m = map(int, input().split(" "))
a = [list(map(int, input().split(" "))) for i in range(m)]
a_connects = [[] for i in range(n)]
for x, y in a:
a_connects[x-1].append(y-1)
a_connects[y-1].append(x-1)
a_connect_sums = [len(connect) for connect in a_connects]
bridge_count = 0
while 1 in a_connect_sums:
x = a_connect_sums.index(1)
y = a_connects[x][0]
a_connects[x].remove(y)
a_connects[y].remove(x)
a_connect_sums[x] -= 1
a_connect_sums[y] -= 1
bridge_count += 1
print(bridge_count)
|
s425790771
|
p03251
|
u685662874
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 285 |
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())
Xpoints=list(map(int, input().split()))
Ypoints=list(map(int, input().split()))
for z in range(-100, 101):
if X < z and z <= Y:
if max(Xpoints) < z:
if min(Ypoints) >= z:
print('No War')
else:
print('War')
|
s622464221
|
Accepted
| 18 | 3,060 | 309 |
N,M,X,Y=map(int, input().split())
Xpoints=list(map(int, input().split()))
Ypoints=list(map(int, input().split()))
isWar='War'
for z in range(-99, 101):
if X < z and z <= Y:
if max(Xpoints) < z:
if min(Ypoints) >= z:
isWar = 'No War'
break
print(isWar)
|
s685276730
|
p03854
|
u358957649
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,188 | 668 |
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`.
|
def main(s):
t = ""
e = ["dream","erase","eraser","dreamer"]
while len(t) < len(s) :
val = ""
c = t
for i in e:
val = t + i
if s[:len(val)] != val:
continue
else:
t = val
break
if s == t:
return True
if t == c:
return False
s = input()
print("Yes" if main(s) else "No")
|
s737587152
|
Accepted
| 1,213 | 3,992 | 512 |
def main(s):
e = ["dreamer","eraser","dream","erase"]
t = [""]
while len(t) > 0:
val = t.pop(0)
for i in e:
tar = val + i
if s[:len(tar)] == tar:
if s == tar:
return True
else:
t.append(tar)
return False
s = input()
print("YES" if main(s) else "NO")
|
s071555510
|
p04043
|
u024422110
| 2,000 | 262,144 |
Wrong Answer
| 26 | 8,928 | 121 |
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 = input().split()
five = a.count(5)
seven = a.count(7)
if five == 2 and seven == 1:
print('YES')
else:
print('NO')
|
s980048399
|
Accepted
| 27 | 8,824 | 125 |
a = input().split()
five = a.count('5')
seven = a.count('7')
if five == 2 and seven == 1:
print('YES')
else:
print('NO')
|
s938180597
|
p03645
|
u085883871
| 2,000 | 262,144 |
Wrong Answer
| 632 | 18,912 | 554 |
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
|
import math
def solve(n, m, a, b):
islands = []
for i in range(m):
if(a[i] == 1):
islands.append(b[i])
if(b[i] == 1):
islands.append(a[i])
for i in range(m):
if(a[i] == m and b[i] in islands):
return "POSSIBLE"
if(b[i] == m and a[i] in islands):
return "POSSIBLE"
return "IMPOSSIBLE"
(n, m) = map(int, input().split())
a = []
b = []
for i in range(m):
(ai, bi) = map(int, input().split())
a.append(ai)
b.append(bi)
print(solve(n, m, a, b))
|
s160073796
|
Accepted
| 635 | 21,888 | 538 |
def solve(n, m, a, b):
islands = set()
for i in range(m):
if(a[i] == 1):
islands.add(b[i])
if(b[i] == 1):
islands.add(a[i])
for i in range(m):
if(a[i] == n and b[i] in islands):
return "POSSIBLE"
if(b[i] == n and a[i] in islands):
return "POSSIBLE"
return "IMPOSSIBLE"
(n, m) = map(int, input().split())
a = []
b = []
for i in range(m):
(ai, bi) = map(int, input().split())
a.append(ai)
b.append(bi)
print(solve(n, m, a, b))
|
s553863673
|
p03131
|
u214866184
| 2,000 | 1,048,576 |
Wrong Answer
| 2,104 | 3,060 | 260 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k, a, b = map(int, input().split())
if b-a < 2 or a > k - 2:
print(k)
else:
num = a
c = k - a
if c % 2 != 0:
c -= 1
num += 1
while c > 0:
c -= 2
num += b - a
print(num)
|
s460169301
|
Accepted
| 18 | 3,060 | 222 |
k, a, b = map(int, input().split())
if b - a < 2 or a > k - 1:
print(k + 1)
else:
num = a
c = k - a + 1
if c % 2 != 0:
c -= 1
num += 1
num += c//2*(b-a)
print(num)
|
s687149946
|
p03719
|
u518556834
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
a,b,c = map(int,input().split())
if a <= b <= c:
print("Yes")
else:
print("No")
|
s213148589
|
Accepted
| 17 | 2,940 | 80 |
a,b,c = map(int,input().split())
if a<=c<=b:
print("Yes")
else:
print("No")
|
s358947764
|
p02399
|
u547492399
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,640 | 67 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = input().split()
a = int(a)
b = int(b)
print(a//b, a%b, a/b)
|
s271417202
|
Accepted
| 20 | 7,672 | 86 |
a, b = input().split()
a = int(a)
b = int(b)
print(a//b, a%b, "{0:.5f}".format(a/b))
|
s734505881
|
p03407
|
u598684283
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,048 | 86 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if a + b >= c:
print("YES")
else:
print("No")
|
s793952300
|
Accepted
| 27 | 9,068 | 86 |
a,b,c = map(int,input().split())
if a + b >= c:
print("Yes")
else:
print("No")
|
s796073285
|
p03067
|
u161442663
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 115 |
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())
if A<B and B<C:
print("Yes")
elif C<B and B<A:
print("Yes")
else:
print("No")
|
s604856314
|
Accepted
| 17 | 2,940 | 115 |
A,C,B=map(int,input().split())
if A<B and B<C:
print("Yes")
elif C<B and B<A:
print("Yes")
else:
print("No")
|
s011514196
|
p00035
|
u299798926
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,592 | 628 |
平面上の異なる 4 点 $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, $D(x_d, y_d)$ の座標を読み込んで、それら 4 点を頂点とした四角形 $ABCD$ に凹みがなければ YES、凹みがあれば NO と出力するプログラムを作成してください。 凹みのある四角形とは図 1 のような四角形です。
|
def judge(p1,p2,p3,p4):
t1 = (p1[0] - p3[0]) * (p2[1] - p1[1]) + (p1[1] - p3[1]) * (p1[0] - p2[0])
t2 = (p1[0] - p3[0]) * (p4[1] - p1[1]) + (p1[1] - p3[1]) * (p1[0] - p4[0])
t3 = (p2[0] - p4[0]) * (p1[1] - p2[1]) + (p2[1] - p4[1]) * (p2[0] - p1[0])
t4 = (p2[0] - p4[0]) * (p3[1] - p2[1]) + (p2[1] - p4[1]) * (p2[0] - p3[0])
return t1*t2<0 and t3*t4<0
while True:
try:
x1,y1,x2,y2,x3,y3,x4,y4=map(float, input().split(","))
A=[x1,y1]
B=[x2,y2]
C=[x3,y3]
D=[x4,y4]
print(A,B,C,D)
if judge(A,B,C,D)==True or judge(A,D,B,C)==True :
print("YES")
else:
print("NO")
except EOFError:
break
|
s820064668
|
Accepted
| 30 | 5,588 | 589 |
def judge(p1,p2,p3,p4):
t1 = (p3[0] - p4[0]) * (p1[1] - p3[1]) + (p3[1] - p4[1]) * (p3[0] - p1[0])
t2 = (p3[0] - p4[0]) * (p2[1] - p3[1]) + (p3[1] - p4[1]) * (p3[0] - p2[0])
t3 = (p1[0] - p2[0]) * (p3[1] - p1[1]) + (p1[1] - p2[1]) * (p1[0] - p3[0])
t4 = (p1[0] - p2[0]) * (p4[1] - p1[1]) + (p1[1] - p2[1]) * (p1[0] - p4[0])
return t1*t2>0 and t3*t4>0
while True:
try:
x1,y1,x2,y2,x3,y3,x4,y4=map(float, input().split(","))
A=[x1,y1]
B=[x2,y2]
C=[x3,y3]
D=[x4,y4]
if judge(A,B,C,D)==False :
print("NO")
else:
print("YES")
except EOFError:
break
|
s382834850
|
p03448
|
u374765578
| 2,000 | 262,144 |
Wrong Answer
| 56 | 2,940 | 186 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a,b,c,x = open(0)
d=0
x = int(x)
for i in range(int(a)+1):
for j in range(int(b)+1):
for k in range(int(c)+1):
500*i + 100*j + 50*k == x
d += 1
print(d)
|
s999749279
|
Accepted
| 51 | 2,940 | 192 |
a,b,c,x = open(0)
d=0
x = int(x)
for i in range(int(a)+1):
for j in range(int(b)+1):
for k in range(int(c)+1):
if 500*i + 100*j + 50*k == x:
d += 1
print(d)
|
s066983918
|
p03455
|
u064827461
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 114 |
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(str, input().split())
n = int(a+b)
m = n**0.5
if int(m)-m == 0:
print('Yes')
else:
print('No')
|
s537276136
|
Accepted
| 17 | 2,940 | 87 |
a, b = map(int, input().split())
if(a*b%2 == 0 ):
print('Even')
else:
print('Odd')
|
s107706359
|
p02694
|
u293523199
| 2,000 | 1,048,576 |
Wrong Answer
| 21 | 9,168 | 135 |
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?
|
import math
X = int(input())
money = 100
year = 0
while(money <= X):
money += math.floor(money * 0.01)
year += 1
print(year)
|
s035309453
|
Accepted
| 22 | 9,164 | 134 |
import math
X = int(input())
money = 100
year = 0
while(money < X):
money += math.floor(money * 0.01)
year += 1
print(year)
|
s011293786
|
p03486
|
u553919982
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 304 |
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 = list(input())
N = len(S)
T = list(input())
M = len(T)
S.sort()
T.sort()
mmm = min(N, M)
for i in range(mmm):
if S[i] > T[i]:
print("No")
exit()
elif S[i] < T[i]:
print("Yes")
exit()
else:
continue
if N < M:
print("Yes")
else:
print("No")
|
s745876744
|
Accepted
| 17 | 3,064 | 318 |
S = list(input())
N = len(S)
T = list(input())
M = len(T)
S.sort()
T.sort(reverse = True)
mmm = min(N, M)
for i in range(mmm):
if S[i] > T[i]:
print("No")
exit()
elif S[i] < T[i]:
print("Yes")
exit()
else:
continue
if N < M:
print("Yes")
else:
print("No")
|
s357562793
|
p03470
|
u225482186
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 233 |
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
n = int(input())
mochi = []
for i in range(n):
mochi.append(int(input()))
print (mochi)
mochi_use = sorted(mochi,reverse = True)
ans = 1
for i in range(n-1):
if mochi_use[i] > mochi_use[i+1]:
ans += 1
print(ans)
|
s046515255
|
Accepted
| 18 | 3,060 | 218 |
n = int(input())
mochi = []
for i in range(n):
mochi.append(int(input()))
mochi_use = sorted(mochi,reverse = True)
ans = 1
for i in range(n-1):
if mochi_use[i] > mochi_use[i+1]:
ans += 1
print(ans)
|
s686046560
|
p03433
|
u160659351
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
#88
N = int(input())
A = int(input())
if N%500 >= A:
print("Yes")
else:
print("No")
|
s268050713
|
Accepted
| 17 | 3,064 | 93 |
#88
N = int(input())
A = int(input())
if N%500 <= A:
print("Yes")
else:
print("No")
|
s082387053
|
p03624
|
u580093517
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,188 | 55 |
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
print(set(map(chr,range(97,123)))-set(input())or"None")
|
s308223993
|
Accepted
| 19 | 3,188 | 117 |
letters="abcdefghijklmnopqrstuvwxyz"
ans=sorted(set(letters)^set(input()))
print("None" if len(ans) == 0 else ans[0])
|
s527514707
|
p03720
|
u597436499
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 300 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
n,m = map(int, input().split())
ab = []
for _ in range(m):
ab.append(list(map(int, input().split())))
ans = {}
for i in range(1, m+1):
ans.update({i : 0})
for i in range(m):
for j in range(2):
if ab[i][j] in ans:
ans[ab[i][j]] += 1
for v in ans.values():
print(v)
|
s819716974
|
Accepted
| 17 | 3,060 | 300 |
n,m = map(int, input().split())
ab = []
for _ in range(m):
ab.append(list(map(int, input().split())))
ans = {}
for i in range(1, n+1):
ans.update({i : 0})
for i in range(m):
for j in range(2):
if ab[i][j] in ans:
ans[ab[i][j]] += 1
for v in ans.values():
print(v)
|
s737404289
|
p02612
|
u736443076
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,140 | 43 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
ans = n % 1000
print(ans)
|
s148051370
|
Accepted
| 31 | 9,148 | 109 |
n = int(input())
if n % 1000 == 0:
print(0)
elif n % 1000 != 0:
ans = 1000 - n % 1000
print(ans)
|
s698046073
|
p03385
|
u118211443
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 55 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
s=input()
print("YES" if len(s)==len(set(s)) else "NO")
|
s638829670
|
Accepted
| 17 | 2,940 | 55 |
s=input()
print("Yes" if len(s)==len(set(s)) else "No")
|
s117790207
|
p00003
|
u776559258
| 1,000 | 131,072 |
Wrong Answer
| 40 | 7,700 | 129 |
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
n=int(input())
for i in range(n):
a,b,c=[int(j) for j in input().split()]
if a==b and b==c:
print("YES")
else:
print("NO")
|
s348279267
|
Accepted
| 50 | 7,524 | 146 |
n=int(input())
for i in range(n):
x=[int(j) for j in input().split()]
x.sort()
if x[2]**2==x[0]**2+x[1]**2:
print("YES")
else:
print("NO")
|
s748326947
|
p03944
|
u711741418
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,064 | 611 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
W, H, N = list(map(int, input().split()))
minX = 0
maxX = W
minY = 0
maxY = H
def calc():
print(maxX)
print(minX)
print(maxY)
print(minY)
if maxX < minX or maxY < minY:
return 0
return (maxX - minX) * (maxY - minY)
for i in range(N):
x, y, a = list(map(int, input().split()))
if a is 1:
if minX < x:
minX = x
elif a is 2:
if maxX > x:
maxX = x
elif a is 3:
if minY < y:
minY = y
elif a is 4:
if maxY > y:
maxY = y
print(calc())
|
s050455596
|
Accepted
| 23 | 3,064 | 547 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
W, H, N = list(map(int, input().split()))
minX = 0
maxX = W
minY = 0
maxY = H
def calc():
if maxX < minX or maxY < minY:
return 0
return (maxX - minX) * (maxY - minY)
for i in range(N):
x, y, a = list(map(int, input().split()))
if a is 1:
if minX < x:
minX = x
elif a is 2:
if maxX > x:
maxX = x
elif a is 3:
if minY < y:
minY = y
elif a is 4:
if maxY > y:
maxY = y
print(calc())
|
s152051238
|
p03369
|
u365375535
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 51 |
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
S = input()
price = 700 + S.count("o")
print(price)
|
s298719225
|
Accepted
| 17 | 3,064 | 55 |
S = input()
price = 700 + S.count("o")*100
print(price)
|
s349858376
|
p02742
|
u150985282
| 2,000 | 1,048,576 |
Wrong Answer
| 19 | 2,940 | 120 |
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
[H, W] = list(map(int, input().split()))
area = H*W
if area%2 == 0:
print(area/2)
if area%2 == 1:
print(area//2 + 1)
|
s718437440
|
Accepted
| 17 | 2,940 | 172 |
[H, W] = list(map(int, input().split()))
area = H*W
if H == 1 or W == 1:
print(1)
else:
if area%2 == 0:
print(int(area/2))
if area%2 == 1:
print(area//2 + 1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.