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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s616068261 | p03351 | u192908410 | 2,000 | 1,048,576 | Wrong Answer | 19 | 3,188 | 176 | 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. | import math
x = list(map(int, input().split()))
s = math.fabs(x[2]-x[0]) < x[3]
t = math.fabs(x[1]-x[0]) < x[3] and math.fabs(x[2]-x[1]) < x[3]
print("Yes" if s or t else "No") | s438319671 | Accepted | 18 | 3,188 | 179 | import math
x = list(map(int, input().split()))
s = math.fabs(x[2]-x[0]) <= x[3]
t = math.fabs(x[1]-x[0]) <= x[3] and math.fabs(x[2]-x[1]) <= x[3]
print("Yes" if s or t else "No") |
s308621409 | p02678 | u054556734 | 2,000 | 1,048,576 | Wrong Answer | 2,208 | 85,368 | 1,139 | 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 numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
n,m = imap()
ab = np.array([iarr()+[1] for i in range(m)])
a,b,c = ab.T[0]-1, ab.T[1]-1, ab.T[2]
adja = [[] for i in range(n)]
for i in range(m):
aa,bb = a[i],b[i]
adja[aa].append(bb)
adja[bb].append(aa)
graph = sps.csr_matrix((c,(a,b)), (n,n))
dk = sps.csgraph.dijkstra(graph,directed=0,indices=0).astype(int)
for i in range(1,n):
option = adja[i]
min = np.inf
ans = -1
for num in option:
if dk[num] < min: ans = num; min = dk[num]
print(ans+1)
| s535707165 | Accepted | 1,028 | 76,864 | 1,335 | import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
if n: return [0 for _ in range(n)]
else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
if n: return ["" for _ in range(n)]
else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]
n,m = imap()
ab = np.array([iarr() for i in range(m)])
g = adj(n+1)
for i in range(m):
aa,bb = ab[i][0],ab[i][1]
g[aa].append(bb)
g[bb].append(aa)
dep = iarr(n+1)
dep[1] = 1
q = col.deque([1])
route = iarr(n+1)
while q:
now = q.popleft()
for next in g[now]:
if dep[next]: continue
else:
q.append(next)
dep[next] = dep[now]+1
route[next] = now
print("Yes")
for ans in route[2:]: print(ans)
|
s916693301 | p03795 | u690536347 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 37 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | n=int(input())
print(n*800-200*n//15) | s345925897 | Accepted | 17 | 2,940 | 39 | n=int(input())
print(n*800-200*(n//15)) |
s709845311 | p03455 | u022830425 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 152 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | input_str = input().split(" ")
a = int(input_str[0])
b = int(input_str[1])
product = a * b
if product % 2 == 1:
print("odd")
else:
print("even")
| s534090461 | Accepted | 17 | 2,940 | 121 | ls = input().split(" ")
a = int(ls[0])
b = int(ls[1])
c = a * b
if c % 2 == 1:
print("Odd")
else:
print("Even")
|
s208529738 | p03456 | u996564551 | 2,000 | 262,144 | Wrong Answer | 26 | 9,356 | 116 | 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. | N = []
N = input().split(' ')
n = int(''.join(N))
if isinstance((n ** 0.5), int):
print('Yes')
else:
print('No') | s332848017 | Accepted | 28 | 9,332 | 117 | N = []
N = input().split(' ')
n = int(''.join(N))
W = str(n ** 0.5)
if '.0' in W:
print('Yes')
else:
print('No') |
s070932277 | p03339 | u780269042 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 12,632 | 271 | There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. | n = int(input())
s = list(input())
count=0
counts=[]
for i in range(n):
east,west = s[:i],s[i+1:]
for n in east:
if n=="w":
count+=1
for e in west:
if e == "e":
count +=1
counts.append(count)
print(min(counts)) | s471355055 | Accepted | 202 | 8,012 | 218 | n = int(input())
s = list(input())
temp = s[1:].count('E')
res = temp
for i in range(len(s)-1):
if s[i+1] == "E":
temp-=1
if s[i] == "W":
temp+=1
res = min(res,temp)
print(res)
|
s060763598 | p03416 | u347600233 | 2,000 | 262,144 | Wrong Answer | 124 | 2,940 | 215 | Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. | a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
flag = True
si = str(i)
for j in range(len(si) // 2):
if si[j] != si[-(j + 1)]:
flag = False
if flag:
cnt += 1
| s781088658 | Accepted | 124 | 3,060 | 232 | a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
flag = True
si = str(i)
for j in range(len(si) // 2):
if si[j] != si[-(j + 1)]:
flag = False
if flag:
cnt += 1
print(cnt) |
s853816383 | p03471 | u497046426 | 2,000 | 262,144 | Wrong Answer | 2,103 | 3,064 | 431 | 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())
flag = False
for z in range(N):
rem1 = N - z
for y in range(rem1):
rem2 = rem1 - y
for x in range(rem2):
val = 10000*x + 5000*y + 1000*z
if val == Y:
flag = True
break
if flag == True:
break
if flag == True:
break
if flag == False:
x = -1
y = -1
z = -1
print(x, y, z) | s699173858 | Accepted | 896 | 3,064 | 348 | N, Y = map(int, input().split())
flag = False
for z in range(N + 1)[::-1]:
rem1 = N - z + 1
for y in range(rem1)[::-1]:
x = N - z - y
val = 10000*x + 5000*y + 1000*z
if val == Y:
flag = True
break
if flag:
break
if not flag:
x = -1
y = -1
z = -1
print(x, y, z) |
s045044822 | p03472 | u827202523 | 2,000 | 262,144 | Wrong Answer | 2,104 | 13,136 | 406 | You are going out for a walk, when you suddenly encounter a monster. Fortunately, you have N katana (swords), Katana 1, Katana 2, …, Katana N, and can perform the following two kinds of attacks in any order: * Wield one of the katana you have. When you wield Katana i (1 ≤ i ≤ N), the monster receives a_i points of damage. The same katana can be wielded any number of times. * Throw one of the katana you have. When you throw Katana i (1 ≤ i ≤ N) at the monster, it receives b_i points of damage, and you lose the katana. That is, you can no longer wield or throw that katana. The monster will vanish when the total damage it has received is H points or more. At least how many attacks do you need in order to vanish it in total? | N, HP = map(int, input().split())
hit = []
throw = []
for i in range(N):
h, t = map(int, input().split())
hit.append(h)
throw.append(t)
h = max(hit)
throw.sort()
throw.reverse()
ans = 0
for t in throw:
if t < h:
break
else:
ans += 1
HP -= t
print("throw", HP, h)
if HP <= 0:
break
while HP > 0:
ans += 1
HP -= h
print(ans) | s013137397 | Accepted | 345 | 7,848 | 413 | import math
N, HP = map(int, input().split())
hit = 0
throw = []
for i in range(N):
h, t = map(int, input().split())
if h > hit:
hit = h
throw.append(t)
throw.sort()
ans = 0
for t in throw[::-1]:
if t < hit:
break
else:
ans += 1
HP -= t
if HP <= 0:
break
if HP > 0:
ans += HP // hit
if HP % hit != 0:
ans += 1
print(ans) |
s184047568 | p03997 | u898967808 | 2,000 | 262,144 | Wrong Answer | 26 | 9,136 | 68 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
print((a+b*h)//2) | s349036131 | Accepted | 27 | 9,156 | 70 | a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)//2) |
s245542691 | p02401 | u566311709 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 261 | 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 = map(str, input().split())
a = int(a)
b = int(b)
if op == "+":
print(a + b)
elif op == "-":
print(a - b)
elif op == "*":
print(a * b)
elif op == "/":
print(a / b)
elif op == "?":
break
else:
break
| s869269677 | Accepted | 20 | 5,552 | 66 | while 1:
s = input()
if "?" in s: break
print(int(eval(s)))
|
s271692858 | p03080 | u600261652 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,104 | 82 | There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. | N = int(input())
S = input()
print("Yes" if S.count("B") > S.count("R") else "No") | s308908154 | Accepted | 29 | 9,036 | 119 | def resolve():
N = int(input())
S = input()
print("Yes" if S.count("R") > S.count("B") else "No")
resolve() |
s664787636 | p03473 | u685244071 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 31 | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December? | M = int(input())
print(24 - M) | s287978263 | Accepted | 17 | 2,940 | 32 | M = int(input())
print(48 - M)
|
s896478306 | p03672 | u860002137 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 249 | 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()
def judge_s(s):
if len(s)%2==1:
return False
mid = len(s)//2
if s[:mid]==s[mid:]:
return True
for i in range(1, len(S)-1):
if judge_s(S[:-i]):
ans = S[:-i]
break
else:
print(len(ans)) | s868069947 | Accepted | 18 | 3,060 | 240 | S = input()
def judge_s(s):
if len(s)%2==1:
return False
mid = len(s)//2
if s[:mid]==s[mid:]:
return True
for i in range(1, len(S)-1):
if judge_s(S[:-i]):
ans = S[:-i]
break
print(len(ans)) |
s874143167 | p03645 | u641804918 | 2,000 | 262,144 | Wrong Answer | 572 | 13,136 | 310 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him. | N,M = map(int,input().split())
one = []
goal = []
for i in range(M):
A,B = map(int,input().split())
if A == 1: one.append(B)
elif B == 1: one.append(A)
if A == M: goal.append(B)
elif B == M: goal.append(A)
if set(goal) & set(one):
print("POSSIBLE")
else:
print("IMPOSSIBLE")
| s475606686 | Accepted | 656 | 25,796 | 332 | N,M = map(int,input().split())
one = []
goal = []
for i in range(M):
A,B = map(int,input().split())
if A == 1 :
one.append(B)
elif B == 1:
one.append(A)
if A == N or B == N:
goal.append(A)
goal.append(B)
if set(goal) & set(one):
print("POSSIBLE")
else:
print("IMPOSSIBLE")
|
s873884114 | p03719 | u382748202 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 97 | 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') | s502495391 | Accepted | 17 | 2,940 | 97 | A, B, C = map(int, input().split())
if C >= A and C <= B:
print('Yes')
else:
print('No') |
s817472086 | p03623 | u371530330 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 110 | 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|. | x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
print('a')
elif abs(x-a) > abs(x-b):
print('b') | s396727346 | Accepted | 17 | 2,940 | 111 | x,a,b = map(int, input().split())
if abs(x-a) < abs(x-b):
print('A')
elif abs(x-a) > abs(x-b):
print('B') |
s698381248 | p02612 | u216752093 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,092 | 28 | 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) | s060025919 | Accepted | 30 | 9,152 | 42 | n=int(input())
n=1000-n%1000
print(n%1000) |
s052773627 | p02927 | u580697892 | 2,000 | 1,048,576 | Wrong Answer | 27 | 3,064 | 363 | Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have? | # coding: utf-8
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
for d in range(1, D+1):
if len(str(d)) == 1:
continue
else:
d1 = int(str(d)[0])
d2 = int(str(d)[1])
if d1*d2 == m and d1 >= 2 and d2 >= 2:
ans += 1
print(m, d1*d2, d1, d2)
print(ans) | s776050439 | Accepted | 28 | 3,060 | 323 | # coding: utf-8
M, D = map(int, input().split())
ans = 0
for m in range(1, M+1):
for d in range(1, D+1):
if len(str(d)) == 1:
continue
else:
d1 = int(str(d)[0])
d2 = int(str(d)[1])
if d1*d2 == m and d1 >= 2 and d2 >= 2:
ans += 1
print(ans) |
s585974431 | p03998 | u268792407 | 2,000 | 262,144 | Wrong Answer | 19 | 3,188 | 259 | 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. | a=input()
b=input()
c=input()
s="a"
while min(len(a),len(b),len(c))>0:
if s=="a":
s=a[0]
a=a[1:]
if s=="b":
s=b[0]
b=b[1:]
if s=="c":
s=c[0]
c=c[1:]
if len(a)==0:
print("A")
if len(b)==0:
print("B")
if len(c)==0:
print("C") | s889993363 | Accepted | 17 | 3,064 | 368 | a=input()
b=input()
c=input()
s="a"
for i in range(len(a)+len(b)+len(c)):
if s=="a" and len(a)>0:
s=a[0]
a=a[1:]
elif s=="a" and len(a)==0:
print("A")
exit()
elif s=="b" and len(b)>0:
s=b[0]
b=b[1:]
elif s=="b" and len(b)==0:
print("B")
exit()
elif s=="c" and len(c)>0:
s=c[0]
c=c[1:]
else:
print("C")
exit() |
s751639729 | p03909 | u629350026 | 2,000 | 262,144 | Wrong Answer | 28 | 9,140 | 325 | There is a grid with H rows and W columns. The square at the i-th row and j-th column contains a string S_{i,j} of length 5. The rows are labeled with the numbers from 1 through H, and the columns are labeled with the uppercase English letters from `A` through the W-th letter of the alphabet. Exactly one of the squares in the grid contains the string `snuke`. Find this square and report its location. For example, the square at the 6-th row and 8-th column should be reported as `H6`. | h,w=map(int,input().split())
ha=0
wa=0
for i in range(h):
s=list(map(str,input().split()))
for j in range(w):
if s[j]=="snuke":
wa=j
ha=i+1
print(j,ha,wa)
break
ans=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
print(ans[wa]+str(ha)) | s444210333 | Accepted | 29 | 9,176 | 304 | h,w=map(int,input().split())
ha=0
wa=0
for i in range(h):
s=list(map(str,input().split()))
for j in range(w):
if s[j]=="snuke":
wa=j
ha=i+1
break
ans=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
print(ans[wa]+str(ha)) |
s897948909 | p04043 | u052221988 | 2,000 | 262,144 | Wrong Answer | 16 | 2,940 | 109 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | a, b, c = map(int, input().split())
if a*b*c == 175 and a+b+c == 17 :
print("Yes")
else :
print("No") | s789002069 | Accepted | 17 | 2,940 | 109 | a, b, c = map(int, input().split())
if a*b*c == 175 and a+b+c == 17 :
print("YES")
else :
print("NO") |
s879889259 | p03672 | u966987550 | 2,000 | 262,144 | Wrong Answer | 26 | 3,444 | 344 | 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. | from collections import deque
def main():
s=deque(input())
for i in range(0,len(s)):
s.pop()
print(s)
if len(s)%2==1:
continue
else:
if "".join(s)[0:len(s)//2]=="".join(s)[len(s)//2:len(s)]:
print(len(s))
break;
if __name__=='__main__':
main()
| s407159330 | Accepted | 24 | 3,444 | 327 | from collections import deque
def main():
s=deque(input())
for i in range(0,len(s)):
s.pop()
if len(s)%2==1:
continue
else:
if "".join(s)[0:len(s)//2]=="".join(s)[len(s)//2:len(s)]:
print(len(s))
break;
if __name__=='__main__':
main()
|
s449097031 | p03408 | u940342887 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 369 | 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. | n = int(input())
s, t = [],[]
for _ in range(n):
s.append(input())
s_dict = {s_:0 for s_ in s}
m = int(input())
for _ in range(m):
t.append(input())
t_dict = {t_:0 for t_ in t}
for i in range(n):
s_dict[s[i]] += 1
for i in range(m):
t_dict[t[i]] += 1
for i in s_dict:
if i in t_dict:
s_dict[i] -= t_dict[i]
max(s_dict.values()) | s361876513 | Accepted | 17 | 3,064 | 402 | n = int(input())
s, t = [],[]
for _ in range(n):
s.append(input())
s_dict = {s_:0 for s_ in s}
s_dict['aaaaaaaaaaa'] = 0
m = int(input())
for _ in range(m):
t.append(input())
t_dict = {t_:0 for t_ in t}
for i in range(n):
s_dict[s[i]] += 1
for i in range(m):
t_dict[t[i]] += 1
for i in s_dict:
if i in t_dict:
s_dict[i] -= t_dict[i]
print(max(s_dict.values())) |
s929094106 | p03385 | u887207211 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 70 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | S = sorted(input())
if(S == 'abc'):
print('Yes')
else:
print('No') | s108940616 | Accepted | 17 | 2,940 | 81 | S = sorted(input())
ans = "No"
if(S == ["a", "b", "c"]):
ans = "Yes"
print(ans) |
s301255403 | p04043 | u586206420 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 113 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | s = list(map(int, input().split()))
if s[0] == 5 and s[1] == 7 and s[2] == 5:
print("YES")
else:
print("NO") | s769642592 | Accepted | 17 | 2,940 | 130 | s = list(map(int, input().split()))
if s[0] + s[1] + s[2] == 17 and s[0] * s[1] * s[2] == 175:
print("YES")
else:
print("NO")
|
s457789899 | p00119 | u871745100 | 1,000 | 131,072 | Wrong Answer | 30 | 6,744 | 1,359 | まんじゅう好きの太郎くんの家でたいへんな事件がおきました。和室の仏壇に供えてあった3つのまんじゅうのうち1つが無くなっていたのです。いつかはおやつにいただこうと狙っていた太郎くんが犯人を見つけるため捜査を始めると、その日、和室に入った人が何人もいることが分かりました。そこで、これらの容疑者が部屋に入った順序を調べるため、全員に次のような形式の証言をしてもらうことにました。 容疑者 A の証言 「私は容疑者 B より先に部屋に入った。」 容疑者の一人(?)は三毛猫のタマなので証言はできませんが、幸運にも最後に部屋に入ったところを太郎くんは見ていました。 太郎くんはこれらの証言から、部屋に入った順番を推測して捜査に役立てることにしました。 例えば、6 人の容疑者がいてタマを容疑者 2 とした場合、以下のような証言が得られたとします。 容疑者 5 の証言 「私は 2 より先に部屋に入った。」 容疑者 1 の証言 「私は 4 より先に部屋に入った。」 容疑者 3 の証言 「私は 5 より先に部屋に入った。」 容疑者 4 の証言 「私は 2 より先に部屋に入った。」 容疑者 1 の証言 「私は 6 より先に部屋に入った。」 容疑者 6 の証言 「私は 4 より先に部屋に入った。」 容疑者 3 の証言 「私は 4 より先に部屋に入った。」 この証言をつなぎ合わせると、部屋に入った順序は * 3→5→1→6→4→2 * 1→6→3→4→5→2 * 3→1→6→5→4→2 など、何通りかの可能性に絞り込むことができます。 タマ (容疑者 2) 以外の容疑者全員の証言から、部屋に入った順番を推測し、可能性のある順番の 1 つを出力するプログラムを作成してください。ただし、複数の証言をする容疑者がいるかもしれませんが、どの証言も真実であり矛盾していないものとします。 | # -*- coding: utf-8 -*-
def satisfy_conditions(ans, part_evidences):
for i in range(len(part_evidences)):
x, y = part_evidences[i]
xi, yi = ans.index(x), ans.index(y)
if xi > yi:
return False
return True
if __name__ == '__main__':
m = int(input())
n = int(input())
evidences = []
ans = list(range(1, m + 1))
ans.remove(2)
ans.append(2)
for i in range(n):
x, y = map(int, input().split())
evidences.append((x, y))
for i in range(n):
x, y = evidences[i]
xi, yi = ans.index(x), ans.index(y)
if xi < yi:
continue
# ????????????????????????(x)??????????????????????????????(y)?????????????????????
# ???????????????xi???????????????y?????\??????
for j in range(xi + 1, n - 1):
# ??????????????????
ans_copy = ans[:]
ans_copy.insert(j, y)
ans_copy.remove(y)
#print(ans_copy)
if satisfy_conditions(ans_copy, evidences[:i]):
print('\n'.join(map(str, ans_copy))) | s194427928 | Accepted | 40 | 6,724 | 474 | visited = []
def dfs(v):
for i in edges[v]:
if i not in visited:
dfs(i)
visited.append(v)
if __name__ == '__main__':
m = int(input())
n = int(input())
edges = [[] for i in range(m)]
for i in range(n):
x, y = map(int, input().split())
edges[x - 1].append(y - 1)
for i in range(m):
if i not in visited:
dfs(i)
ans = reversed([i + 1 for i in visited])
print('\n'.join(map(str, ans))) |
s796165123 | p03386 | u846877959 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 255 | 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())
nums = set()
for i in range(k):
#print(a)
nums.add(a)
a += 1
if a > b:
break
for j in range(k):
#print(b)
nums.add(b)
b -= 1
if a > b:
break
for k in nums:
print(k)
| s671119065 | Accepted | 18 | 3,064 | 275 | a, b, k = map(int, input().split())
nums = set()
for i in range(k):
#print(a)
nums.add(a)
a += 1
if a > b:
break
for j in range(k):
#print(b)
nums.add(b)
b -= 1
if a > b:
break
nums = sorted(nums)
for k in nums:
print(k)
|
s457713039 | p02613 | u205758185 | 2,000 | 1,048,576 | Wrong Answer | 157 | 9,180 | 283 | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format. | n = int(input())
a = 0
w = 0
t = 0
r = 0
for i in range(n):
b = input()
if b == "AC":
a += 1
if b == "WA":
w += 1
if b == "TLE":
t += 1
if b == "RE":
r += 1
print("AC x", a)
print("WA x", w)
print("TLE x", t)
print("RE2 x", r)
| s124825013 | Accepted | 149 | 9,028 | 279 | n = int(input())
a = 0
w = 0
t = 0
r = 0
for i in range(n):
b = input()
if b == "AC":
a += 1
if b == "WA":
w += 1
if b == "TLE":
t += 1
if b == "RE":
r += 1
print("AC x", a)
print("WA x", w)
print("TLE x", t)
print("RE x", r) |
s617397569 | p03719 | u121732701 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. |
A, B, C = map(int, input().split())
if A<=C and B>=C:
print("YES")
else:
print("NO")
| s277655945 | Accepted | 17 | 2,940 | 95 |
A, B, C = map(int, input().split())
if A<=C and B>=C:
print("Yes")
else:
print("No")
|
s790562415 | p03852 | u840807329 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 69 | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | c = input()
if c[0] == "c":
print("vowel")
else:
print("consonant") | s460137319 | Accepted | 17 | 2,940 | 92 | c = input()
b =["a","i","u","e","o"]
if c[0] in b:
print("vowel")
else:
print("consonant") |
s462851360 | p03474 | u459150945 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 185 | The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. | A, B = map(int, input().split())
S = list(input().split('-'))
try:
if len(S[0]) == A and len(S2[1]) == B:
print('Yes')
else:
print('No')
except:
print('No')
| s339555721 | Accepted | 20 | 2,940 | 209 | A, B = map(int, input().split())
S = input()
if S.count('-') != 1:
print('No')
else:
S = list(S.split('-'))
if len(S[0]) == A and len(S[1]) == B:
print('Yes')
else:
print('No')
|
s365206720 | p00015 | u567380442 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 210 | A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or the sum have more than 80 digits, print "overflow". | import sys
f = sys.stdin
n = int(f.readline())
for _ in range(n):
a = f.readline().strip()
b = f.readline().strip()
c = int(a) + int(b)
c = '{}'.format(c)
print(c if len(c) else 'overflow ') | s559262615 | Accepted | 30 | 6,724 | 215 | import sys
f = sys.stdin
n = int(f.readline())
for _ in range(n):
a = f.readline().strip()
b = f.readline().strip()
c = int(a) + int(b)
c = '{}'.format(c)
print(c if len(c) <= 80 else 'overflow') |
s050274268 | p03394 | u969708690 | 2,000 | 262,144 | Wrong Answer | 33 | 11,420 | 522 | Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000. | N=int(input())
if N<=15000:
L=list(range(2,2*(N-1),2))
if N<=10000:
if (N-1)%2==0:
k=N-2
else:
k=N-1
L.append(k)
L.append(k*3)
R=list()
else:
if (N-1)%2==0:
k=N-1
else:
k=N-2
while k%2==0:
k//=2
L.append(k)
L.append(k*3)
R=list()
else:
if N%2==0:
L=list(range(2,30002,2))
N-=15000
R=list(range(3,3+6*N,6))
else:
L=list(range(2,30000,2))
N-=15000
R=list(range(3,3+6*(N+1),6))
s=L+R
print(" ".join(list(map(str,s)))) | s015542883 | Accepted | 31 | 11,400 | 558 | N=int(input())
if N==3:
print("2 5 63")
exit()
if N<=15000:
L=list(range(2,2*(N-1),2))
if N<=10000:
if (N-1)%2==0:
k=N-2
else:
k=N-1
L.append(k)
L.append(k*3)
R=list()
else:
if (N-1)%2==0:
k=N-1
else:
k=N-2
while k%2==0:
k//=2
L.append(k)
L.append(k*3)
R=list()
else:
if N%2==0:
L=list(range(2,30002,2))
N-=15000
R=list(range(3,3+6*N,6))
else:
L=list(range(2,30000,2))
N-=15000
R=list(range(3,3+6*(N+1),6))
s=L+R
print(" ".join(list(map(str,s)))) |
s549576477 | p03795 | u622568141 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 269 | 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. | # -*- coding: utf-8 -*-
import sys
import math
def main():
N = int(input())
y = math.factorial(N) % (10**9+7)
print(y)
if __name__ == '__main__':
main()
| s304769358 | Accepted | 17 | 2,940 | 263 | # -*- coding: utf-8 -*-
import sys
def main():
N = int(input())
x = 800 * N
y = 200 * int(N / 15)
print(x-y)
if __name__ == '__main__':
main()
|
s555742166 | p03625 | u190405389 | 2,000 | 262,144 | Wrong Answer | 111 | 14,244 | 203 | We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. | N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(N - 1):
if A[i] == A[i + 1]:
A[i + 1] = 0
else:
A[i] = 0
A.sort()
A.reverse()
print(A[0] * A[1])
| s931907012 | Accepted | 114 | 14,252 | 217 | N = int(input())
A = [int(x) for x in input().split()]
A.sort()
for i in range(N - 1):
if A[i] == A[i + 1]:
A[i + 1] = 0
else:
A[i] = 0
A[N - 1] = 0
A.sort()
A.reverse()
print(A[0] * A[1])
|
s417412588 | p03386 | u346395915 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 183 | 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())
li1 = [i for i in range(a,a+k) if i <= b]
li2 = [i for i in range(b+1-k,b+1) if i >= a]
li1.extend(li2)
li1 = set(li1)
for i in li1:
print(i)
| s936450600 | Accepted | 17 | 3,060 | 191 | a,b,k = map(int,input().split())
li1 = [i for i in range(a,a+k) if i <= b]
li2 = [i for i in range(b+1-k,b+1) if i >= a]
li1.extend(li2)
li1 = set(li1)
for i in sorted(li1):
print(i)
|
s659912505 | p02397 | u365921604 | 1,000 | 131,072 | Wrong Answer | 50 | 5,604 | 135 | Write a program which reads two integers x and y, and prints them in ascending order. | for i in range(0, 3000):
x, y = map(int, input().split(' '))
if x == 0 and y == 0:
break
else:
print(x, y)
| s724649751 | Accepted | 60 | 5,624 | 195 | for i in range(0, 3000):
array = [int(x) for x in input().split(' ')]
if array[0] == 0 and array[1] == 0:
break
else:
print(' '.join([str(x) for x in sorted(array)]))
|
s409333800 | p02612 | u758910826 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,140 | 48 | 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())
num = n % 1000
print(abs(num))
| s899923884 | Accepted | 32 | 9,112 | 155 | import math
n = int(input())
if n >= 1000:
s = 1000
i = 1000
while n > s:
s += i
# print(s)
print(s-n)
else:
print(1000-n)
|
s526977680 | p02694 | u634576930 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,164 | 127 | 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=int(input())
m=100
n=0
while True:
if m<=X:
n+=1
m=int(m*1.01)
else:
print(n)
exit()
| s516774350 | Accepted | 24 | 9,096 | 128 | X=int(input())
m=100
n=0
while True:
if m>=X:
print(n)
exit()
else:
n+=1
m=int(m*1.01)
|
s553590025 | p03048 | u127499732 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 3,444 | 208 | 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? | import itertools
r,g,b,n=map(int,input().split())
r,g,b=list(range(r+1)),list(range(g+1)),list(range(b+1))
count = 0
for i,j,k in itertools.product(r,g,b):
s = i + j + k
if s==n:
count+=1
print(count) | s007689310 | Accepted | 1,266 | 183,140 | 343 | import collections
import itertools
r,g,b,n=map(int,input().split())
x,y=n//r,n//g
x,y=list(range(0,r*x+1,r)),list(range(0,g*y+1,g))
l=[i+j for i,j in itertools.product(x,y) if i+j<=n]
z=collections.Counter(l)
count=0
for key,value in zip(z.keys(),z.values()):
v=n-key
if v==0:
count+=value
elif v%b==0:
count+=value
print(count) |
s947081888 | p02694 | u297089927 | 2,000 | 1,048,576 | Wrong Answer | 21 | 9,148 | 79 | 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=int(input())
m=100
ans=0
while m<=x:
m=int(m*1.01)
ans+=1
print(ans)
| s364881082 | Accepted | 19 | 9,156 | 78 | x=int(input())
m=100
ans=0
while m<x:
m=int(m*1.01)
ans+=1
print(ans)
|
s275668592 | p03795 | u033524082 | 2,000 | 262,144 | Wrong Answer | 19 | 2,940 | 37 | Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y. | n=int(input())
print(800*n-int(n/15)) | s510847891 | Accepted | 18 | 2,940 | 41 | n=int(input())
print(800*n-int(n/15)*200) |
s290224212 | p03360 | u183481524 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 202 | 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())
for i in range(K):
if A > B >= C:
A = A * 2
elif B > A >= C:
B = B * 2
elif C > B >= A:
C = C * 2
print(A+B+C)
| s167529309 | Accepted | 18 | 3,060 | 251 | A, B, C = map(int, input().split())
K = int(input())
for i in range(K):
if 2*A > (B + C):
A = A * 2
elif 2*B > (A + C):
B = B * 2
elif 2*C > (B + A):
C = C * 2
elif A == B == C:
A = A * 2
print(A+B+C)
|
s764139733 | p02410 | u661284763 | 1,000 | 131,072 | Wrong Answer | 30 | 7,640 | 236 | 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 \\] | n, m = [int(i) for i in input().split()]
matrix = []
for ni in range(n):
matrix.append([int(a) for a in input().split()])
vector = []
for mi in range(m):
vector.append(int(input()))
print(matrix)
print()
print(vector) | s786433897 | Accepted | 30 | 8,056 | 310 | n, m = [int(i) for i in input().split()]
matrix = []
for ni in range(n):
matrix.append([int(a) for a in input().split()])
vector = []
for mi in range(m):
vector.append(int(input()))
for ni in range(n):
sum = 0
for mi in range(m):
sum += matrix[ni][mi] * vector[mi]
print(sum) |
s179221367 | p02646 | u845416499 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,172 | 236 | 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. | if __name__ == '__main__':
A, V = map(int, input().strip().split(" "))
B, W = map(int, input().strip().split(" "))
T = int(input().strip())
if B + W * T <= A + W * T:
print("YES")
else:
print("No")
| s827704893 | Accepted | 20 | 9,068 | 206 | A, V = list(map(int, input().strip().split()))
B, W = list(map(int, input().strip().split()))
T = int(input().strip())
L = abs(A - B)
v = V - W
if L <= (V - W) * T:
print('YES')
else:
print('NO')
|
s594394462 | p00009 | u546285759 | 1,000 | 131,072 | Time Limit Exceeded | 40,000 | 205,336 | 509 | Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. 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. | while True:
try:
n = int(input())
count = 0
if n == 1:
print("0")
else:
a = [2*i for i in range(2, 1000000)]
b = [3*i for i in range(2, 1000000)]
c = [5*i for i in range(2, 1000000)]
d = [7*i for i in range(2, 1000000)]
for i in range(2, n+1):
if i not in a and i not in b and i not in c and i not in d:
count += 1
print(count)
except:
break | s930532876 | Accepted | 350 | 21,016 | 314 | import bisect
primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
if primes[i]:
for j in range(i*i, 1000000, i):
primes[j] = 0
primes = [i for i, v in enumerate(primes) if v]
while True:
try:
n = int(input())
except:
break
print(bisect.bisect(primes, n))
|
s711254285 | p03711 | u276192130 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 372 | 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. | import math
h, w = map(int, input().split())
low = min(h, w)
high = max(h, w)
if h%3 == 0 or w%3 == 0:
print (0)
elif (high/3) > low:
print(high - int(high/3))
else:
a = math.ceil(high/3)*low
b = (high-math.ceil(high/3))*int(low/2)
c = abs(a-b)
a = round(high/3)*low
b = (high-round(high/3))*int(low/2)
d = abs(a-b)
print (min(c, d)) | s365845983 | Accepted | 17 | 2,940 | 200 | x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
print ("Yes")
else:
print ("No")
|
s059702702 | p04030 | u779728630 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 142 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | s = input()
res = ""
for i in range(len(s)):
if s[i] == "B":
if res != "":
res = res[:len(s)-1]
else:
res += s[i]
print(res) | s184922478 | Accepted | 18 | 2,940 | 144 | s = input()
res = ""
for i in range(len(s)):
if s[i] == "B":
if res != "":
res = res[:len(res)-1]
else:
res += s[i]
print(res) |
s572493362 | p02646 | u927373043 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,180 | 225 | 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):
print("NO")
else:
x = (B-A)/(V-W)
print(x)
if(x <= T and int(x)==x):
print("YES")
else:
print("NO")
| s153776498 | Accepted | 24 | 9,040 | 183 | A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if(V <= W):
print("NO")
else:
if(abs(B-A) <= T*(V-W)):
print("YES")
else:
print("NO")
|
s986830621 | p03080 | u114648678 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 138 | There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. | N=int(input())
s=list(input().split())
for i in s:
n=0
if i=='R':
n+=1
if N/2<n:
print('Yes')
else:
print('No') | s168051841 | Accepted | 17 | 2,940 | 151 | N=int(input())
s=input()
n=0
for char in s:
if char=='R':
n+=1
else:
n+=0
if N/2<n:
print('Yes')
else:
print('No')
|
s773772688 | p03623 | u201082459 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | 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|. | x,a,b = map(int,input().split())
if x - a >= x - b:
print('A')
else:
print('B') | s868234118 | Accepted | 18 | 2,940 | 93 | x,a,b = map(int,input().split())
if abs(x - a) <= abs(x - b):
print('A')
else:
print('B') |
s965979351 | p03067 | u001024152 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 99 | 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 <= c <= b or b <= c <= a:
print("YES")
else:
print("NO") | s679235165 | Accepted | 17 | 2,940 | 99 | a,b,c = map(int, input().split())
if a <= c <= b or b <= c <= a:
print("Yes")
else:
print("No") |
s021684087 | p03658 | u637824361 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 106 | 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 = [int(i) for i in input().split()]
L.sort(reverse = True)
print(L[:K]) | s318796574 | Accepted | 17 | 2,940 | 111 | N, K = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse = True)
print(sum(L[:K])) |
s484459396 | p03050 | u063962277 | 2,000 | 1,048,576 | Wrong Answer | 153 | 3,060 | 162 | Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those. | import math
N = int(input())
ans = 0
ls = []
for i in range(1,int(math.sqrt(N))):
if N%i == 0:
ans += (N//i)-1
ls.append((N//i)-1)
print(ans) | s096843826 | Accepted | 143 | 3,064 | 153 | import math
N = int(input())
ans = 0
for i in range(1,int(math.sqrt(N))+1):
if N%i == 0 and (N//i)-1 > i:
ans = ans + (N//i)-1
print(ans) |
s114840090 | p02659 | u980932400 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,100 | 73 | Compute A \times B, truncate its fractional part, and print the result as an integer. | a,b=input().split()
a=float(a)
b=float(b)
a=a*b
print("{:.2f}".format(a)) | s359133419 | Accepted | 22 | 9,088 | 170 | a,b=input().split()
a=int(a)
bb=[0,0]
c=0
for i in b:
if(i=='.'):
c=1
continue
bb[c]*=10
bb[c]+=int(i)
res=a*bb[0] + (a*bb[1])//100
print(res) |
s538476345 | p03141 | u512294098 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 11,312 | 1,669 | There are N dishes of cuisine placed in front of Takahashi and Aoki. For convenience, we call these dishes Dish 1, Dish 2, ..., Dish N. When Takahashi eats Dish i, he earns A_i points of _happiness_ ; when Aoki eats Dish i, she earns B_i points of happiness. Starting from Takahashi, they alternately choose one dish and eat it, until there is no more dish to eat. Here, both of them choose dishes so that the following value is maximized: "the sum of the happiness he/she will earn in the end" minus "the sum of the happiness the other person will earn in the end". Find the value: "the sum of the happiness Takahashi earns in the end" minus "the sum of the happiness Aoki earns in the end". | n = int(input())
A = []
B = []
for i in range(n):
a, b = tuple(map(int, input().split(' ')))
A.append(a)
B.append(b)
eaten_dishes = set()
def taka_select():
max_choice = None
happiness = 0
opponent_happiness = 0
for i in range(n):
if i in eaten_dishes:
continue
if max_choice == None:
max_choice = i
happiness = A[i]
opponent_happiness = B[i]
elif A[i] > happiness:
max_choice = i
happiness = A[i]
opponent_happiness = B[i]
elif A[i] == happiness and B[i] > opponent_happiness:
max_choice = i
happiness = A[i]
opponent_happiness = B[i]
return max_choice, happiness
def aoki_select():
max_choice = None
happiness = 0
opponent_happiness = 0
for i in range(n):
if i in eaten_dishes:
continue
if max_choice == None:
max_choice = i
happiness = B[i]
opponent_happiness = A[i]
elif B[i] > happiness:
max_choice = i
happiness = B[i]
opponent_happiness = A[i]
elif B[i] == happiness and A[i] > opponent_happiness:
max_choice = i
happiness = B[i]
opponent_happiness = A[i]
return max_choice, happiness
total = 0
for i in range(n):
select, happiness = (0, 0)
if i % 2 == 0:
select, happiness = taka_select()
total += happiness
else:
select, happiness = aoki_select()
total -= happiness
eaten_dishes.add(select)
print(select, happiness)
print(total)
| s201754990 | Accepted | 520 | 36,880 | 479 | n = int(input())
happiness_hash = {}
for i in range(n):
a, b = tuple(map(int, input().split(' ')))
happiness_hash[i] = (a, b)
sorted_happiness = sorted(happiness_hash.items(), key = lambda x : x[1][0] + x[1][1], reverse = True)
total = 0
i = 0
for k, v in sorted_happiness:
happiness, selected = (0, k)
if i % 2 == 0:
happiness = v[0]
total += happiness
else:
happiness = v[1]
total -= happiness
i += 1
print(total) |
s135345191 | p02646 | u369796672 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,184 | 167 | 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 w >= v:
print("NO")
elif (w-v)*t>=abs(b-a):
print("YES")
else:
print("NO") | s853407405 | Accepted | 23 | 9,184 | 167 | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if w >= v:
print("NO")
elif (v-w)*t>=abs(b-a):
print("YES")
else:
print("NO") |
s003690884 | p02612 | u020933954 | 2,000 | 1,048,576 | Wrong Answer | 27 | 9,132 | 193 | 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. | num=input()
if int(num)<=1000:
change=1000-int(num)
else:
array_1=list(num)
array_1=array_1[-4:]
a=''.join(array_1)
b=int(array_1[-4])+1
pay=b*1000
change=pay-int(a) | s612489774 | Accepted | 30 | 9,116 | 362 | num=input()
if 1<=int(num)<=10000:
if int(num)<=1000:
change=1000-int(num)
else:
array_1=list(num)
array_1=array_1[-4:]
a=''.join(array_1)
b=int(array_1[-4])+1
pay=b*1000
change=pay-int(a)
if array_1[-1]=="0" and array_1[-2]=="0" and array_1[-3]=="0":
change=0
print(change) |
s872268999 | p03149 | u977193988 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 99 | 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=set(map(str,input().split()))
k={'1','9','7','4'}
if n==k:
print('Yes')
else:
print('No') | s500775788 | Accepted | 17 | 2,940 | 99 | n=set(map(str,input().split()))
k={'1','9','7','4'}
if n==k:
print('YES')
else:
print('NO') |
s113325211 | p03129 | u717671569 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 238 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | i = list(map(int, input().split()))
n = i[0]
k = i[1]
if n > 3:
if n > k - 2:
if (n % 2 == 1 and n % k == 1) or (n % 2 == 0 and n % k == 0):
print("YES")
else:
print("NO")
else:
print("NO")
else:
print("NO") | s653442921 | Accepted | 17 | 3,064 | 464 | i = list(map(int, input().split()))
n = i[0]
k = i[1]
if n >= 1 and k <= 100:
if n == 1 and k == 1:
print("YES")
elif n > k:
if n % 2 == 1:
if int(n / k) >= 2:
print("YES")
elif int(n / k) == 1 and (int(n % k) == k - 1):
print("YES")
else:
print("NO")
else:
if int(n / k) >= 2:
print("YES")
elif n % k == 0:
print("YES")
else:
print("NO")
else:
print("NO")
|
s724900795 | p04029 | u632369368 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 40 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | N = int(input())
print((1 + N) * N / 2)
| s072481481 | Accepted | 17 | 2,940 | 41 | N = int(input())
print((1 + N) * N // 2)
|
s942392027 | p03139 | u051393148 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 112 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question. | a, b, c = map(int, input().split())
_max = max(b,c)
_min = max(0, ((b+c)-a))
print('{0} {1}'.format(_max, _min)) | s160109979 | Accepted | 17 | 2,940 | 112 | a, b, c = map(int, input().split())
_max = min(b,c)
_min = max(0, ((b+c)-a))
print('{0} {1}'.format(_max, _min)) |
s772355521 | p03455 | u769739808 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 91 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = map(int, input().split())
if (a * b) % 2 :
print("Even")
else:
print("Odd") | s460644097 | Accepted | 17 | 2,940 | 96 | a, b = map(int, input().split())
if (a * b) % 2 == 0 :
print("Even")
else:
print("Odd") |
s328768015 | p03067 | u667024514 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 94 | 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 < c or c < b < a:
print("Yes")
else:
print("No") | s971152607 | Accepted | 17 | 2,940 | 94 | a,b,c = map(int,input().split())
if a < c < b or b < c < a:
print("Yes")
else:
print("No") |
s663246333 | p03494 | u039860745 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,060 | 182 | 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 = input()
li = list(map(int, input().split()))
count = 0
while(a % 2 == 0 for a in li):
li = [ a / 2 for a in li]
count += 1
# a,b = map(int, input().split())
print(count) | s524719458 | Accepted | 19 | 3,060 | 225 | n = input()
li = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in li):
li = [ a / 2 for a in li]
count += 1
# a,b = map(int, input().split())
print(count) |
s269133514 | p04044 | u575560095 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 145 | Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m. | N,L = map(int,input().split())
S = []
ans = ""
for i in range(N):
S.append(input())
sorted(S)
for i in range(len(S)):
ans += S[i]
print(ans)
| s731220154 | Accepted | 18 | 3,060 | 126 | l=[]
a=''
N,L=map(int,input().split())
for i in range(N):
l.append(input())
l.sort()
for i in range(N):
a += l[i]
print(a)
|
s742522964 | p03636 | u506287026 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 43 | 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(s[0] + s[1:-1] + s[-1])
| s875508400 | Accepted | 17 | 2,940 | 53 | s = input()
print(s[0] + str(len(s[1:-1])) + s[-1])
|
s427211843 | p03964 | u390958150 | 2,000 | 262,144 | Wrong Answer | 23 | 3,060 | 266 | AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. | ans = 0
for i in range(int(input())):
t_i, a_i = list(map(lambda x: int(x), input().split()))
if i == 0:
t, a = t_i, a_i
else:
n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
t = n*t_i
a = n*a_i
ans = t + a | s636381568 | Accepted | 22 | 3,064 | 278 | ans = 0
for i in range(int(input())):
t_i, a_i = list(map(lambda x: int(x), input().split()))
if i == 0:
t, a = t_i, a_i
else:
n = max((t + t_i - 1) // t_i, (a + a_i - 1) // a_i)
t = n*t_i
a = n*a_i
ans = t + a
print(ans) |
s040878136 | p02842 | u854061980 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 210 | 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. | s=int(input())
n = int(s/1.08)
print(n)
for i in range(n):
if int(n*1.08)==s:
print(n)
break
elif int(n*1.08)<s:
n+=1
continue
else:
print(":(")
break | s080971041 | Accepted | 17 | 3,060 | 111 | import math
s=int(input())
n = math.ceil(s/1.08)
if math.floor(n*1.08)==s:
print(n)
else:
print(":(") |
s271976441 | p04030 | u055941944 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 166 | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now? | # -*- coding utf-8 -*-
s=list(input())
ans=""
for i in range(0,len(s),1):
if s[i]==1 or s[i]==0:
ans+=ans[i]
else:
ans=ans[:-1]
print(ans)
| s752769722 | Accepted | 17 | 2,940 | 190 | # -*- coding utf-8 -*-
s=input()
ans=""
for i in range(len(s)):
if s[i]=="B":
ans=ans[:-1]
elif s[i]=="1":
ans+="1"
elif s[i]=="0":
ans+="0"
print(ans)
|
s269270236 | p02394 | u506468108 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 246 | Write a program which reads a rectangle and a circle, and determines whether the circle is arranged inside the rectangle. As shown in the following figures, the upper right coordinate $(W, H)$ of the rectangle and the central coordinate $(x, y)$ and radius $r$ of the circle are given. | W, H, x, y, r= map(int, input().split())
edgeleft = x - r
edgeright = x + r
edgetop = y + r
edgebottom = y - r
if (edgeleft <= 0) | (edgeright >= W):
print("No")
elif (edgetop >= H) | (edgebottom <= 0):
print("No")
else:
print("yes")
| s122886256 | Accepted | 20 | 5,596 | 272 | W, H, x, y, r= map(int, input().split())
edge_left = x - r
edge_right = x + r
edge_top = y + r
edge_bottom = y - r
if (edge_left < 0) | (edge_right > W):
answer = "No"
elif (edge_top > H) | (edge_bottom < 0):
answer = "No"
else:
answer = "Yes"
print(answer)
|
s694422890 | p03494 | u581603131 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 206 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = int(input())
A = list(map(int, input().split()))
count = 0
for k in range(0, 5*10**8):
for i in A:
if i%2==0:
count += 1
i = i//2
else:
break
print(count) | s178405843 | Accepted | 18 | 3,060 | 166 | N = int(input())
A = list(map(int, input().split()))
count = 0
while all(i%2==0 for i in A):
for i in range(N):
A[i] = A[i]//2
count += 1
print(count) |
s376645564 | p04043 | u442948527 | 2,000 | 262,144 | Wrong Answer | 27 | 8,964 | 91 | Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order. | s=input().split()
print(["NO","YES"]["5" in s and "7" in s and ("5 5" in s or "5 7" in s)]) | s545353237 | Accepted | 23 | 8,856 | 71 | a,b,c=sorted(input().split())
print(["NO","YES"][a==b=="5" and c=="7"]) |
s586981674 | p03693 | u989564346 | 2,000 | 262,144 | Wrong Answer | 20 | 3,064 | 168 | 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? | from sys import stdin
a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
r = (a * 100) + (b * 10) + c
if r % 4 == 0:
print("Yes")
else:
print("No")
| s840893634 | Accepted | 18 | 2,940 | 168 | from sys import stdin
a, b, c = [int(x) for x in stdin.readline().rstrip().split()]
r = (a * 100) + (b * 10) + c
if r % 4 == 0:
print("YES")
else:
print("NO")
|
s194257875 | p03129 | u777207626 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 88 | Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1. | n,k = map(int,input().split())
m = int(n/2)+n%2
ans = 'Yes' if m>=k else 'No'
print(ans) | s109894979 | Accepted | 17 | 2,940 | 88 | n,k = map(int,input().split())
m = int(n/2)+n%2
ans = 'YES' if m>=k else 'NO'
print(ans) |
s415069075 | p03739 | u457901067 | 2,000 | 262,144 | Wrong Answer | 171 | 17,108 | 759 | You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term. | N = int(input())
A = list(map(int, input().split()))
S = [0] * (N+1)
for i in range(N):
S[i+1] = S[i] + A[i]
print(S)
#S[1] > 0
ans1 = 0
work = 0
for i in range(1,N+1):
if i%2 == 1:
if S[i] + work <= 0:
temp = 1 - (S[i] + work)
ans1 += temp
work += temp
else:
# neg is required
if S[i] + work >= 0:
temp = (S[i] + work) + 1
ans1 += temp
work -= temp
#S[1] < 0
ans2 = 0
work = 0
for i in range(1,N+1):
if i%2 == 1:
# neg is required
if S[i] + work >= 0:
temp = (S[i] + work) + 1
ans2 += temp
work -= temp
else:
# neg is required
if S[i] + work <= 0:
temp = 1 - (S[i] + work)
ans2 += temp
work += temp
print(min(ans1, ans2)) | s966309992 | Accepted | 161 | 14,468 | 760 | N = int(input())
A = list(map(int, input().split()))
S = [0] * (N+1)
for i in range(N):
S[i+1] = S[i] + A[i]
#print(S)
#S[1] > 0
ans1 = 0
work = 0
for i in range(1,N+1):
if i%2 == 1:
if S[i] + work <= 0:
temp = 1 - (S[i] + work)
ans1 += temp
work += temp
else:
# neg is required
if S[i] + work >= 0:
temp = (S[i] + work) + 1
ans1 += temp
work -= temp
#S[1] < 0
ans2 = 0
work = 0
for i in range(1,N+1):
if i%2 == 1:
# neg is required
if S[i] + work >= 0:
temp = (S[i] + work) + 1
ans2 += temp
work -= temp
else:
# neg is required
if S[i] + work <= 0:
temp = 1 - (S[i] + work)
ans2 += temp
work += temp
print(min(ans1, ans2)) |
s481993396 | p03493 | u145410317 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 60 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | nums = list(map(int, input().split()))
print(nums.count(1)) | s015039703 | Accepted | 16 | 2,940 | 43 | nums = list(input())
print(nums.count("1")) |
s255593654 | p02795 | u914671452 | 2,000 | 1,048,576 | Wrong Answer | 25 | 3,060 | 128 | We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations. | h = int(input())
w = int(input())
n = int(input())
a = max(h,w)
b = a
count = 0
while b <= n:
b += a
count += 1
print(count) | s774568331 | Accepted | 18 | 3,060 | 181 | h = int(input())
w = int(input())
n = int(input())
a = max(h,w)
b = a
count = 0
if h*w == n:
print(h)
elif b >= n:
print(1)
else:
while b*count < n:
count += 1
print(count) |
s522462899 | p03477 | u152638361 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 126 | 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("Right")
elif (a+b)<(c+d):
print("Left")
else: print("Balanced") | s921513783 | Accepted | 17 | 3,060 | 126 | 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") |
s295110670 | p03079 | u328751895 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 73 | 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())
print('YES' if A == B == C else 'NO') | s048472376 | Accepted | 17 | 2,940 | 73 | A, B, C = map(int, input().split())
print('Yes' if A == B == C else 'No') |
s977256124 | p03198 | u297574184 | 2,000 | 1,048,576 | Wrong Answer | 271 | 26,180 | 699 | There are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the following operation on these integers any number of times: * Choose 1 \leq i \leq N and multiply the value of A_i by -2. Notice that he multiplies it by **minus** two. He would like to make A_1 \leq A_2 \leq ... \leq A_N holds. Find the minimum number of operations required. If it is impossible, print `-1`. | def func(i):
return numMinuss[i] * numPluss[i]
N = int(input())
As = list(map(int, input().split()))
numPluss = [0] * (N+1)
stack = [(N, As[-1])]
for i in reversed(range(1, N)):
if As[i-1] > As[i]:
k = ((As[i-1] // As[i] - 1).bit_length() + 1) // 2 * 2
numPluss[i] = k
numMinuss = [0] * (N+1)
for i in range(N-1):
pass
ans = float('inf')
for i in range(N):
num = func(i)
ans = min(ans, num)
print(ans)
| s594079172 | Accepted | 1,816 | 41,692 | 722 | from math import ceil, log2
def getNums(As, N):
dp = list(range(16))
nums = [0] * N
for i in reversed(range(N - 1)):
dx = ceil( log2( As[i] / As[i+1] ) / 2 )
if dx <= 0:
dp0 = dp[0]
dp = [dp0] * (-dx) + dp[:16+dx]
else:
dp15 = dp[15]
k = N - 1 - i
dp = dp[dx:] + list(range(dp15 + k, dp15 + k * dx + 1, k))
dp = [dpx + x for x, dpx in enumerate(dp)]
nums[i] = dp[0]
return nums
N = int(input())
As = list(map(int, input().split()))
numPstvs = getNums(As, N)
numNgtvs = getNums(As[::-1], N)[::-1]
ans = min([2 * p + 2 * m + i for i, (p, m) in enumerate(zip(numPstvs + [0], [0] + numNgtvs))])
print(ans)
|
s154940112 | p03493 | u431981421 | 2,000 | 262,144 | Wrong Answer | 2,103 | 2,940 | 215 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | a = list(map(int, input().split()))
c = 0
while True:
f = False
for i in a:
if i % 2 == 1:
f = True
if f == True:
break
for index, i in enumerate(a):
a[index] = i / 2
c += 1
print(c) | s289046769 | Accepted | 17 | 2,940 | 86 | li = list(input())
count = 0
for i in li:
if i == '1':
count += 1
print(count) |
s467976712 | p02694 | u019075898 | 2,000 | 1,048,576 | Wrong Answer | 20 | 9,076 | 107 | 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 = int(input())
bank = 100
year = 0
while bank > X:
bank = bank * 101 // 100
year += 1
print(year) | s654090417 | Accepted | 21 | 9,100 | 107 | X = int(input())
bank = 100
year = 0
while bank < X:
bank = bank * 101 // 100
year += 1
print(year) |
s810717025 | p03067 | u848647227 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 90 | 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 c > a and c < b:
print("YES")
else:
print("NO") | s892450472 | Accepted | 17 | 3,060 | 125 | a,b,c = map(int,input().split(" "))
for i in range(min(a,b),max(a,b)+1):
if i == c:
print("Yes")
exit()
print("No") |
s947752375 | p03599 | u466478199 | 3,000 | 262,144 | Wrong Answer | 3,156 | 8,944 | 566 | Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water. | a,b,c,d,e,f=map(int,input().split())
l=[0]
ans=[]
m=int(f*e/100)
for i in range(int(f//a)):
for j in range((f-100*i)//b):
for k in range(m//c):
for n in range((m-k*c)//d):
X=100*a*i+100*b*j
Y=k*c+n*d
print(0)
if X+Y==0 or X+Y>f:
continue
else:
p=100*Y/(X+Y)
mp=100*e/(100+e)
print(1)
if p<=mp:
if p>max(l):
l.append(p)
ans.append([X+Y,Y])
else:
pass
else:
continue
print(ans) | s344025261 | Accepted | 125 | 3,316 | 484 | a,b,c,d,e,f=map(int,input().split())
x=set()
y=set()
m=f//(100*a)
for i in range(m+1):
for j in range(f//(100*b)+1):
x1=i*100*a+j*100*b
if x1<=f:
x.add(x1)
m=int(f*(e/100))
for i in range(0,m+1,c):
for j in range(0,m-i+1,d):
y.add(i+j)
x.remove(0)
z=[-1]
ans=[]
for i in x:
for j in y:
if i+j<=f and j*100/(i+j)<=e*100/(100+e):
if j*100/(i+j)>max(z):
z.append(j*100/(i+j))
ans.append([i+j,j])
print(ans[-1][0],ans[-1][1])
|
s339565732 | p02409 | u527848444 | 1,000 | 131,072 | Wrong Answer | 30 | 6,724 | 229 | 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. | data = [[[0 for r in range(10)]for f in range(3)]for b in range(4)]
for b in range(4):
for f in range(3):
for r in range(10):
print(' {0}'.format(data[b][f][r]),end='')
print()
print('#' * 20) | s592157303 | Accepted | 40 | 6,720 | 364 | data = [[[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) = [int(i) for i in input().split()]
data[b - 1][f - 1][r - 1] += v
for b in range(4):
for f in range(3):
for r in range(10):
print('',data[b][f][r], end='')
print()
if b < 3:
print('#' * 20) |
s976831725 | p02744 | u459590249 | 2,000 | 1,048,576 | Wrong Answer | 171 | 14,048 | 445 | In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. For example, `abcac` and `zyxzx` are isomorphic, while `abcac` and `ppppp` are not. A string s is said to be in **normal form** when the following condition is satisfied: * For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison. For example, `abcac` is in normal form, but `zyxzx` is not since it is isomorphic to `abcac`, which is lexicographically smaller than `zyxzx`. You are given an integer N. Print all strings of length N that are in normal form, in lexicographically ascending order. | std=[]
n=int(input())
cmb=[[] for i in range(n)]
cmb[0].append("a")
tmp=[[] for i in range(n)]
if n==1:
print("a")
for i in range(1,n):
for j in range(len(cmb)):
for s in cmb[j]:
for k in range(0,j+1):
tmp[j].append(s+chr(ord("a")+k))
tmp[j+1].append(s+chr(ord("a")+k+1))
cmb=tmp
tmp=[[] for i in range(n)]
lst=[]
for i in range(len(cmb)):
for std in cmb[i]:
lst.append(std)
lst.sort()
for i in range(len(lst)):
print(lst[i]) | s031895343 | Accepted | 184 | 14,048 | 437 | std=[]
n=int(input())
cmb=[[] for i in range(n)]
cmb[0].append("a")
tmp=[[] for i in range(n)]
for i in range(1,n):
for j in range(len(cmb)):
for s in cmb[j]:
for k in range(0,j+1):
tmp[j].append(s+chr(ord("a")+k))
tmp[j+1].append(s+chr(ord("a")+k+1))
#print(cmb)
cmb=tmp
tmp=[[] for i in range(n)]
lst=[]
for i in range(len(cmb)):
for std in cmb[i]:
lst.append(std)
lst.sort()
for i in range(len(lst)):
print(lst[i]) |
s994213251 | p02262 | u231136358 | 6,000 | 131,072 | Wrong Answer | 20 | 7,772 | 663 | Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$ | def insertion_sort(A, N, gap):
cnt = 0
for i in range(gap, N):
tmp = A[i]
j = i - gap
while j>=0 and A[j] > tmp:
A[j+gap] = A[j]
j = j - gap
cnt = cnt + 1
A[j+gap] = tmp
return cnt
def shell_sort(A, N):
cnt = 0
m = 10
gaps = [int((3**item-1)/2) for item in range(1, m)]
for gap in gaps:
cnt = cnt + insertion_sort(A, N, gap)
if gap > N:
break
print(m)
print(' '.join([str(gap) for gap in gaps]))
print(cnt)
for i in range(0, N):
print(A[i])
N = int(input())
A = [int(input()) for i in range(N)]
shell_sort(A, N) | s858428445 | Accepted | 20,890 | 127,956 | 635 | def insertion_sort(A, N, gap):
global cnt
for i in range(gap, N):
tmp = A[i]
j = i - gap
while j>=0 and A[j] > tmp:
A[j+gap] = A[j]
j = j - gap
cnt += 1
A[j+gap] = tmp
def shell_sort(A, N):
gaps = [int((3**item-1)/2) for item in range(1, 100) if int((3**item-1)/2) <= N][::-1]
m = len(gaps)
for gap in gaps:
insertion_sort(A, N, gap)
print(m)
print(' '.join([str(gap) for gap in gaps]))
print(cnt)
print('\n'.join([str(item) for item in A]))
cnt = 0
N = int(input())
A = [int(input()) for i in range(N)]
shell_sort(A, N) |
s264951108 | p03565 | u759651152 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 675 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`. | #-*-coding:utf-8-*-
def main():
s_hint = list(input())
t = list(input())
for i in range(len(s_hint)):
if s_hint[i] == t[0] and len(s_hint) - i <= len(s_hint):
arry = s_hint[i+1:i + len(t)]
if len(set(arry)) == 1:
start = i
for j in range(start, start + len(t)):
s_hint[j] = t[j - start]
for k in range(len(s_hint)):
if s_hint[k] == '?':
s_hint[k] = 'a'
print(''.join(s_hint))
break
exit()
print('UNRESTORABLE')
if __name__ == '__main__':
main() | s831577165 | Accepted | 17 | 3,064 | 390 | #-*-coding:utf-8-*-
def main():
s = input()
t = input()
i = -1
for j in range(len(s) - len(t) + 1):
if all(a == '?' or a == b for a, b in zip(s[j:], t)):
i = j
if i == -1:
print('UNRESTORABLE')
else:
ans = s[:i] + t + s[i+len(t):]
ans = ans.replace('?', 'a')
print(ans)
if __name__ == '__main__':
main() |
s970495965 | p02866 | u426108351 | 2,000 | 1,048,576 | Wrong Answer | 107 | 14,396 | 136 | Given is an integer sequence D_1,...,D_N of N elements. Find the number, modulo 998244353, of trees with N vertices numbered 1 to N that satisfy the following condition: * For every integer i from 1 to N, the distance between Vertex 1 and Vertex i is D_i. | n = int(input())
a = list(map(int, input().split()))
c = [0]*(n+1)
for i in a:
c[i] += 1
ans = 1
for i in c[1:]:
ans *= i
print(ans) | s106055838 | Accepted | 137 | 14,396 | 337 | n = int(input())
a = list(map(int, input().split()))
c = [0]*(n+1)
for i in a:
c[i] += 1
ans = 1
for i in range(n+1):
if c[-1] == 0:
c.pop()
else:
break
mod = 998244353
for i in range(len(c)-1):
ans *= pow(c[i], c[i+1], mod)
ans %= mod
if a[0] != 0:
ans *= 0
if c[0] != 1:
ans *= 0
print(ans)
|
s284462961 | p03591 | u102126195 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 80 | Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`. | S = input()
print(S)
if S[:4] == "YAKI":
print("Yes")
else:
print("No")
| s612598907 | Accepted | 17 | 2,940 | 71 | S = input()
if S[:4] == "YAKI":
print("Yes")
else:
print("No")
|
s659753259 | p03386 | u035210736 | 2,000 | 262,144 | Wrong Answer | 29 | 9,120 | 161 | 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())
x = [i for i in range(a, min(a + k, b + 1))]
y = [i for i in range(max(a, b - k + 1), b + 1)]
for i in set(x + y):
print(i) | s151203240 | Accepted | 31 | 9,012 | 169 | a, b, k = map(int, input().split())
x = [i for i in range(a, min(a + k, b + 1))]
y = [i for i in range(max(a, b - k + 1), b + 1)]
for i in sorted(set(x + y)):
print(i) |
s966314704 | p00718 | u200148444 | 1,000 | 131,072 | Wrong Answer | 120 | 5,624 | 1,822 | 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. | n=int(input())
for i in range(n):
s0,s1=map(str,input().split())
ans=""
ans0=0
ans1=0
ans2=0
p=1
for j in range(len(s0)):
if s0[j]!="m" and s0[j]!="c" and s0[j]!="x" and s0[j]!="i" :
p=int(s0[j])
continue
if s0[j]=="m":
ans0+=p*1000
p=1
if s0[j]=="c":
ans0+=p*100
p=1
if s0[j]=="x":
ans0+=p*10
p=1
if s0[j]=="i":
ans0+=p*1
p=1
for k in range(len(s1)):
if s1[k]!="m" and s1[k]!="c" and s1[k]!="x" and s1[k]!="i" :
p=int(s1[k])
continue
if s1[k]=="m":
ans1+=p*1000
p=1
if s1[k]=="c":
ans1+=p*100
p=1
if s1[k]=="x":
ans1+=p*10
p=1
if s1[k]=="i":
ans1+=p*1
p=1
print(ans0)
print(ans1)
ans2=ans0+ans1
while ans2>0:
if ans2>=1000:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"m"
else:
ans=ans+sans2[0]+"m"
ans2=int(sans2[1:])
continue
if ans2>=100:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"c"
else:
ans=ans+sans2[0]+"c"
ans2=int(sans2[1:])
continue
if ans2>=10:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"x"
else:
ans=ans+sans2[0]+"x"
ans2=int(sans2[1:])
continue
if ans2>=1:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"i"
else:
ans=ans+sans2[0]+"i"
break
print(ans)
| s350369353 | Accepted | 110 | 5,632 | 1,790 | n=int(input())
for i in range(n):
s0,s1=map(str,input().split())
ans=""
ans0=0
ans1=0
ans2=0
p=1
for j in range(len(s0)):
if s0[j]!="m" and s0[j]!="c" and s0[j]!="x" and s0[j]!="i" :
p=int(s0[j])
continue
if s0[j]=="m":
ans0+=p*1000
p=1
if s0[j]=="c":
ans0+=p*100
p=1
if s0[j]=="x":
ans0+=p*10
p=1
if s0[j]=="i":
ans0+=p*1
p=1
for k in range(len(s1)):
if s1[k]!="m" and s1[k]!="c" and s1[k]!="x" and s1[k]!="i" :
p=int(s1[k])
continue
if s1[k]=="m":
ans1+=p*1000
p=1
if s1[k]=="c":
ans1+=p*100
p=1
if s1[k]=="x":
ans1+=p*10
p=1
if s1[k]=="i":
ans1+=p*1
p=1
ans2=ans0+ans1
while ans2>0:
if ans2>=1000:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"m"
else:
ans=ans+sans2[0]+"m"
ans2=int(sans2[1:])
continue
if ans2>=100:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"c"
else:
ans=ans+sans2[0]+"c"
ans2=int(sans2[1:])
continue
if ans2>=10:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"x"
else:
ans=ans+sans2[0]+"x"
ans2=int(sans2[1:])
continue
if ans2>=1:
sans2=str(ans2)
if sans2[0]=="1":
ans=ans+"i"
else:
ans=ans+sans2[0]+"i"
break
print(ans)
|
s439363589 | p03693 | u481250941 | 2,000 | 262,144 | Wrong Answer | 73 | 16,232 | 921 | 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? | #
# abc064 a
#
import sys
from io import StringIO
import unittest
def input():
return sys.stdin.readline().rstrip()
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """4 3 2"""
output = """YES"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """2 3 4"""
output = """NO"""
self.assertIO(input, output)
def resolve():
r, g, b = map(int, input().split())
if (100*r + 10*g + b) % 4:
print("YES")
else:
print("NO")
if __name__ == "__main__":
# unittest.main()
resolve()
| s394556162 | Accepted | 74 | 16,160 | 929 | #
# abc064 a
#
import sys
from io import StringIO
import unittest
def input():
return sys.stdin.readline().rstrip()
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """4 3 2"""
output = """YES"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """2 3 4"""
output = """NO"""
self.assertIO(input, output)
def resolve():
r, g, b = map(int, input().split())
if (100*r + 10*g + b) % 4 == 0:
print("YES")
else:
print("NO")
if __name__ == "__main__":
# unittest.main()
resolve()
|
s339910128 | p03861 | u278356323 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 136 | 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? | #ABC048b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
a, b, x = map(int, input().split())
print((b - a + 1) // x) | s553162726 | Accepted | 17 | 3,060 | 176 | #ABC048b
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
a, b, x = map(int, input().split())
ans = b // x - a // x
if (a % x == 0):
ans += 1
print(ans) |
s881142082 | p02741 | u144203608 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,064 | 251 | Print the K-th element of the following sequence of length 32: 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 | K=int(input())
if K==32 :
print(51)
elif K==24 :
print(15)
elif K==16 :
print(14)
elif K==8 or 12 or 18 or 20 or 27 :
print(5)
elif K==4 or 6 or 9 or 10 or 14 or 21 or 22 or 25 or 26 :
print(2)
elif K==28 or 30 :
print(4)
else :
print(1) | s363039561 | Accepted | 17 | 3,064 | 485 | K=int(input())
if K==4 :
print(2)
elif K==6 :
print(2)
elif K==8 :
print(5)
elif K==9 :
print(2)
elif K==10 :
print(2)
elif K==12 :
print(5)
elif K==14 :
print(2)
elif K==16 :
print(14)
elif K==18 :
print(5)
elif K==20 :
print(5)
elif K==21 :
print(2)
elif K==22 :
print(2)
elif K==24 :
print(15)
elif K==25 :
print(2)
elif K==26 :
print(2)
elif K==27 :
print(5)
elif K==28 :
print(4)
elif K==30 :
print(4)
elif K==32 :
print(51)
else :
print(1) |
s552309579 | p02396 | u215335591 | 1,000 | 131,072 | Wrong Answer | 160 | 5,600 | 113 | 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. | count = 1
while True:
x = int(input())
if x == 0:
break
print("Case ",count,": ", x, sep="")
| s729417342 | Accepted | 150 | 5,600 | 128 | count = 1
while True:
x = int(input())
if x == 0:
break
print("Case ",count,": ", x, sep="")
count += 1
|
s770887964 | p03852 | u045793300 | 2,000 | 262,144 | Wrong Answer | 24 | 8,996 | 172 | Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`. | s303032703 | Accepted | 32 | 9,072 | 59 | s = input()
print('vowel' if s in 'aeiou' else 'consonant') |
|
s510671342 | p03477 | u797016134 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 124 | A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right. | a,b,c,d = map(int, input().split())
if a+b>c+d:
print("Left")
if a+b<c+d:
print("Right")
else:
print("Balanced") | s200121897 | Accepted | 17 | 2,940 | 133 | a,b,c,d = map(int, input().split())
if a+b>c+d:
print("Left")
if a+b<c+d:
print("Right")
if a+b == c+d:
print("Balanced") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.