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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s195521290
|
p02865
|
u762182313
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 60 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
a=int(input())
if a%2==1:
print(a//2)
else:
print(a/2+a)
|
s029614579
|
Accepted
| 18 | 2,940 | 61 |
a=int(input())
if a%2==1:
print(a//2)
else:
print(a//2-1)
|
s664957232
|
p03487
|
u513081876
| 2,000 | 262,144 |
Wrong Answer
| 110 | 21,228 | 202 |
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
|
import collections
N = int(input())
a = [int(i) for i in input().split()]
hint = collections.Counter(a)
b = hint.most_common()
ans = 0
for val, num in b:
if val != num:
ans += num
print(ans)
|
s263076941
|
Accepted
| 112 | 21,228 | 221 |
import collections
N = int(input())
a = [int(i) for i in input().split()]
ans = 0
num = collections.Counter(a).most_common()
for a, b in num:
if b < a:
ans += b
elif a < b:
ans += b-a
print(ans)
|
s682789490
|
p02846
|
u455533363
| 2,000 | 1,048,576 |
Wrong Answer
| 160 | 13,152 | 432 |
Takahashi and Aoki are training for long-distance races in an infinitely long straight course running from west to east. They start simultaneously at the same point and moves as follows **towards the east** : * Takahashi runs A_1 meters per minute for the first T_1 minutes, then runs at A_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. * Aoki runs B_1 meters per minute for the first T_1 minutes, then runs at B_2 meters per minute for the subsequent T_2 minutes, and alternates between these two modes forever. How many times will Takahashi and Aoki meet each other, that is, come to the same point? We do not count the start of the run. If they meet infinitely many times, report that fact.
|
import numpy
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
v1=b1-a1
v2=b2-a2
print(v1,v2)
x1=v1*t1
x2=v2*t2
print(x1,x2)
if numpy.sign(x1)==numpy.sign(x2):
#print("one")
print(0)
elif abs(x2)-abs(x1)<0:
#print("two")
print(0)
elif -x1==x2:
print("infinity")
else:
#print("hello")
print(x1,2*(abs(x2)-abs(x1)))
print(2*(x1//(abs(x2)-abs(x1)))+1)
|
s604332797
|
Accepted
| 149 | 12,504 | 446 |
import numpy
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
v1=b1-a1
v2=b2-a2
x1=v1*t1
x2=v2*t2
di = abs(abs(x2)-abs(x1))
if numpy.sign(x1)==numpy.sign(x2):
print(0)
elif abs(x2)<abs(x1):
print(0)
elif abs(x1)==abs(x2):
print("infinity")
else:
if abs(x1)%di==0:
print(abs(int(2*(x1/di))))
else:
print(abs(int(2*(x1//di)+1)))
|
s905432690
|
p02865
|
u802341442
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 75 |
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
|
n = int(input())
if n % 2 == 0:
print(n // 2)
else:
print((n-1)//2)
|
s886542913
|
Accepted
| 17 | 2,940 | 79 |
n = int(input())
if n % 2 == 0:
print(n // 2 - 1)
else:
print((n-1)//2)
|
s969367554
|
p03505
|
u846150137
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 130 |
_ButCoder Inc._ runs a programming competition site called _ButCoder_. In this site, a user is given an integer value called rating that represents his/her skill, which changes each time he/she participates in a contest. The initial value of a new user's rating is 0, and a user whose rating reaches K or higher is called _Kaiden_ ("total transmission"). Note that a user's rating may become negative. Hikuhashi is a new user in ButCoder. It is estimated that, his rating increases by A in each of his odd-numbered contests (first, third, fifth, ...), and decreases by B in each of his even-numbered contests (second, fourth, sixth, ...). According to this estimate, after how many contests will he become Kaiden for the first time, or will he never become Kaiden?
|
from math import ceil
k,a,b=map(int,input().split())
k-=a
if k<=0:
print(1)
elif a>b:
print(1+ceil(k/(a-b)))
else:
print(-1)
|
s572959561
|
Accepted
| 17 | 3,060 | 128 |
from math import ceil
k,a,b=map(int,input().split())
if k<=a:
print(1)
elif a>b:
print(1+(k-b-1)//(a-b)*2)
else:
print(-1)
|
s206487889
|
p03737
|
u871841829
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 156 |
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
|
s = input()
upper_diff = ord('A') - ord('a')
def to_upper(c: str) -> str:
return chr(ord(c) + upper_diff)
out = "".join(map(to_upper, s))
print(out)
|
s154990367
|
Accepted
| 17 | 2,940 | 189 |
s = input().split()
upper_diff = ord('A') - ord('a')
def to_upper(c):
# print("c:", c)
return chr(ord(c) + upper_diff)
out = "".join(map(to_upper, [x[0] for x in s]))
print(out)
|
s693282488
|
p02255
|
u409699893
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,696 | 218 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
n = int(input())
x = list(map(int,input().split()))
for i in range(1,n):
v = x[i]
j = i - 1
while j >= 0:
if x[j] > v:
x[j + 1] = x[j]
x[j] = v
j += -1
print (*x)
|
s921844955
|
Accepted
| 20 | 8,000 | 229 |
n = int(input())
x = list(map(int,input().split()))
print (*x)
for i in range(1,n):
v = x[i]
j = i - 1
while j >= 0:
if x[j] > v:
x[j + 1] = x[j]
x[j] = v
j += -1
print (*x)
|
s802848475
|
p03679
|
u649558044
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 103 |
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
|
x, a, b = map(int, input().split())
print('delicious' if b <= a else 'safe' if b <= x else 'dangerous')
|
s590038742
|
Accepted
| 17 | 2,940 | 107 |
x, a, b = map(int, input().split())
print('delicious' if b <= a else 'safe' if b <= a + x else 'dangerous')
|
s508346656
|
p00032
|
u436634575
| 1,000 | 131,072 |
Wrong Answer
| 40 | 6,720 | 177 |
機械に辺・対角線の長さのデータを入力し、プラスティック板の型抜きをしている工場があります。この工場では、サイズは様々ですが、平行四辺形の型のみを切り出しています。あなたは、切り出される平行四辺形のうち、長方形とひし形の製造個数を数えるように上司から命じられました。 「機械に入力するデータ」を読み込んで、長方形とひし形の製造個数を出力するプログラムを作成してください。
|
import sys
c1 = c2 = 0
for line in sys.stdin:
a, b, c = map(int, line.split(','))
if a**2 + b**2 == c**2:
c1 += 1
elif a == b:
c2 += 1
print(c1, c2)
|
s176787409
|
Accepted
| 30 | 6,720 | 183 |
import sys
c1 = c2 = 0
for line in sys.stdin:
a, b, c = map(int, line.split(','))
if a**2 + b**2 == c**2:
c1 += 1
elif a == b:
c2 += 1
print(c1)
print(c2)
|
s229192220
|
p03854
|
u799479335
| 2,000 | 262,144 |
Wrong Answer
| 68 | 3,316 | 347 |
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
a[i] = ch[::-1]
T = ''
S = S[::-1]
flag = True
while flag:
if S[:5] in a:
S = S[5:]
elif S[:6] in a:
S = S[6:]
elif S[:7] in a:
S = S[7:]
elif len(S)==0:
ans = 'Yes'
flag = False
else:
ans = 'No'
flag = False
print(ans)
|
s992650566
|
Accepted
| 69 | 3,316 | 339 |
S = input()
a = ['dream','dreamer','erase','eraser']
for i,ch in enumerate(a):
a[i] = ch[::-1]
S = S[::-1]
flag = True
while flag:
if len(S)==0:
ans = 'YES'
flag = False
elif S[:5] in a:
S = S[5:]
elif S[:6] in a:
S = S[6:]
elif S[:7] in a:
S = S[7:]
else:
ans = 'NO'
flag = False
print(ans)
|
s294234620
|
p02399
|
u811841526
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,560 | 61 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a,b = map(int,input().split())
d = a // b
r = a % b
f = a / b
|
s876119153
|
Accepted
| 20 | 5,608 | 97 |
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d, r, '{:.5f}'.format(f))
|
s972435023
|
p03478
|
u062306892
| 2,000 | 262,144 |
Wrong Answer
| 31 | 3,060 | 130 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
n,a,b = map(int, input().split())
ans = 0
for i in range(1, n+1):
if a<=sum([int(c) for c in str(i)])<=b:
ans+=1
print(ans)
|
s449817243
|
Accepted
| 33 | 3,060 | 130 |
n,a,b = map(int, input().split())
ans = 0
for i in range(1, n+1):
if a<=sum([int(c) for c in str(i)])<=b:
ans+=i
print(ans)
|
s743808378
|
p03067
|
u357751375
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,084 | 127 |
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 b > a:
z = a
a = b
b = z
if a <= c <= b:
print('Yes')
else:
print('No')
|
s206485189
|
Accepted
| 25 | 9,116 | 127 |
a,b,c = map(int,input().split())
if a > b:
z = a
a = b
b = z
if a <= c <= b:
print('Yes')
else:
print('No')
|
s376069134
|
p03129
|
u029169777
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 76 |
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())
if N/2>K-1:
print('Yes')
else:
print('No')
|
s857000700
|
Accepted
| 17 | 2,940 | 77 |
N,K=map(int,input().split())
if N/2>K-1:
print('YES')
else:
print('NO')
|
s126838888
|
p03150
|
u674588203
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,064 | 646 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
S=input()
if S=='keyence':
print('YES')
else:
pass
if S[:6]=='keyence' or S[-7:-1]=='keyence':
print('YES')
else:
pass
if S[0]=='k':
if S[-6:-1]=='eyence':
print('YES')
else:
pass
if S[:1]=='ke':
if S[-5:-1]=='yence':
print('YES')
else:
pass
if S[:2]=='key':
if S[-4:-1]=='ence':
print('YES')
else:
pass
if S[:3]=='keye':
if S[-3:-1]=='nce':
print('YES')
else:
pass
if S[:4]=='keyen':
if S[-2:-1]=='ce':
print('YES')
else:
pass
if S[:5]=='keyen':
if S[-1]=='e':
print('YES')
else:
pass
|
s267570121
|
Accepted
| 17 | 3,064 | 716 |
S=input()
if S=='keyence' or S[0:7]=='keyence' or S[-7:]=='keyence':
print('YES')
exit()
else:
pass
if S[0]=='k':
if S[-6:]=='eyence':
print('YES')
exit()
else:
pass
if S[:2]=='ke':
if S[-5:]=='yence':
print('YES')
exit()
else:
pass
if S[:3]=='key':
if S[-4:]=='ence':
print('YES')
exit()
else:
pass
if S[:4]=='keye':
if S[-3:]=='nce':
print('YES')
exit()
else:
pass
if S[:5]=='keyen':
if S[-2:]=='ce':
print('YES')
exit()
else:
pass
if S[:6]=='keyenc':
if S[-1]=='e':
print('YES')
exit()
else:
pass
print('NO')
|
s917137356
|
p03861
|
u161318582
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 48 |
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a,b,x = map(int,input().split())
print((b-a)//x)
|
s491148855
|
Accepted
| 17 | 2,940 | 79 |
a,b,x = map(int,input().split())
print((b-a)//x+1 if a%x == 0 else (b//x-a//x))
|
s147900207
|
p03359
|
u844123804
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 88 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
num = input().split()
if int(num[1]) >=11:
print(num[0])
else:
print(int(num[0])-1)
|
s393778219
|
Accepted
| 17 | 2,940 | 98 |
num = input().split()
if int(num[1]) >= int(num[0]):
print(num[0])
else:
print(int(num[0])-1)
|
s252028211
|
p03795
|
u369338402
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 52 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n=int(input())
x=n*800
y=(n-n%15)/15
print(int(x-y))
|
s816381688
|
Accepted
| 17 | 2,940 | 58 |
n=int(input())
x=n*800
y=((n-n%15)/15)*200
print(int(x-y))
|
s502807499
|
p03563
|
u488497128
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 159 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
import sys
num = 1
n = int(sys.stdin.readline().strip())
k = int(sys.stdin.readline().strip())
for i in range(n):
num = min(num + k, 2 * num)
print(num)
|
s636307799
|
Accepted
| 18 | 2,940 | 103 |
import sys
r = int(sys.stdin.readline().strip())
g = int(sys.stdin.readline().strip())
print(2*g - r)
|
s776029437
|
p03556
|
u667024514
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 67 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
a = int(input())
import math
b = math.sqrt(a)
c = float(b)
print(c)
|
s346498752
|
Accepted
| 17 | 2,940 | 57 |
import math
print(math.floor(math.sqrt(int(input())))**2)
|
s469903092
|
p02386
|
u567380442
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,760 | 851 |
Write a program which reads $n$ dices constructed in the same way as [Dice I](description.jsp?id=ITP1_11_A), and determines whether they are all different. For the determination, use the same way as [Dice III](description.jsp?id=ITP1_11_C).
|
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]
print(mask)
def set_top(dice, top):
return [dice[i] for i in mask[top]]
def twist(dice):
return [dice[i] for i in (0, 3, 1, 4, 2, 5)]
def equal(dice1, dice2):
for i in range(6):
tmp_dice = set_top(dice2, i)
for _ in range(4):
if dice1 == tmp_dice:
return True
tmp_dice = twist(tmp_dice)
return False
def diff_check_all(dices, n):
for i in range(n -1):
for j in range(i + 1, n):
print(i,j)
if equal(dices[i], dices[j]):
return False
return True
n = int(input())
dices = [input().split() for _ in range(n)]
print('Yes' if diff_check_all(dices, n) else 'No')
|
s908206580
|
Accepted
| 90 | 6,756 | 881 |
mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]
mask += [[mask[1][i] for i in mask[1]]]
def set_top(dice, top):
return [dice[i] for i in mask[top]]
def twist(dice):
return [dice[i] for i in (0, 3, 1, 4, 2, 5)]
def equal(dice1, dice2):
if sorted(dice1) != sorted(dice2):
return False
for i in range(6):
tmp_dice = set_top(dice2, i)
for _ in range(4):
if dice1 == tmp_dice:
return True
tmp_dice = twist(tmp_dice)
return False
def diff_check_all(dices, n):
for i in range(n -1):
for j in range(i + 1, n):
if equal(dices[i], dices[j]):
return False
return True
n = int(input())
dices = [input().split() for _ in range(n)]
print('Yes' if diff_check_all(dices, n) else 'No')
|
s459690003
|
p03048
|
u002459665
| 2,000 | 1,048,576 |
Time Limit Exceeded
| 2,104 | 2,940 | 223 |
Snuke has come to a store that sells boxes containing balls. The store sells the following three kinds of boxes: * Red boxes, each containing R red balls * Green boxes, each containing G green balls * Blue boxes, each containing B blue balls Snuke wants to get a total of exactly N balls by buying r red boxes, g green boxes and b blue boxes. How many triples of non-negative integers (r,g,b) achieve this?
|
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(3001):
for j in range(3001):
x = n - (r * i + g * j)
if x < 0:
continue
if x % b == 0:
cnt += 1
print(cnt)
|
s739644076
|
Accepted
| 1,728 | 3,060 | 280 |
def main():
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(n+1):
for j in range(n+1):
b_num = n - r*i - g*j
if b_num >= 0 and b_num % b == 0:
cnt += 1
print(cnt)
if __name__ == "__main__":
main()
|
s959826301
|
p03485
|
u217888679
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,316 | 47 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
print(-(-(a+b)/2))
|
s245125016
|
Accepted
| 18 | 2,940 | 49 |
a,b=map(int,input().split())
print(-(-(a+b)//2))
|
s220464612
|
p03433
|
u245641078
| 2,000 | 262,144 |
Wrong Answer
| 29 | 9,172 | 59 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N,A = map(int,open(0))
print("YES" if A>=(N%500) else "NO")
|
s140855928
|
Accepted
| 26 | 9,056 | 68 |
N,A = int(input()),int(input())
print("Yes" if A>=(N%500) else "No")
|
s826409647
|
p02255
|
u908238078
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 366 |
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))
def insertion_sort(A, N):
for i in range(1, N):
key = A[i]
j = i - 1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1] = key
for a in A:
print(str(a) + ' ', end='')
print('')
insertion_sort(A, N)
|
s535069663
|
Accepted
| 20 | 5,596 | 357 |
N = int(input().rstrip())
A = list(map(int, input().rstrip().split()))
def insertion_sort(A, N):
for i in range(N):
key = A[i]
j = i - 1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1] = key
string = list(map(str, A))
print(' '.join(string))
insertion_sort(A, N)
|
s423653512
|
p03852
|
u941884460
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 154 |
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()
vow = ['a','i','u','e','o']
for i in range(len(vow)):
if i in vow:
print('vowel')
break
if i == len(vow)-1:
print('consonant')
|
s699609983
|
Accepted
| 18 | 2,940 | 96 |
c = input()
vow = ['a','i','u','e','o']
if c in vow:
print('vowel')
else:
print('consonant')
|
s647701039
|
p03713
|
u466105944
| 2,000 | 262,144 |
Wrong Answer
| 333 | 3,184 | 987 |
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
|
import time
H,W = map(int,input().split())
def calc_ans(H,W):
ans = float('inf')
halfed_w = W//2
for h in range(1,H):
a = h*W
b1 = (H-h)//2*W
c1 = (H-h-(H-h)//2)*W
b2 = (H-h)*halfed_w
c2 = (H-h)*(W-halfed_w)
result1 = max(a,b1,c1)-min(a,b1,c1)
result2 = max(a,b2,c2)-min(a,b2,c2)
ans = min(ans,result1,result2)
halfed_h = H//2
for w in range(1,W):
a = w*H
b1 = (W-w)//2*H
c1 = (W-w-(W-w)//2)*H
b2 = (W-w)*halfed_h
c2 = (W-w)*(H-halfed_h)
result1 = max(a,b1,c1)-min(a,b1,c1)
result2 = max(a,b2,c2)-min(a,b2,c2)
ans = min(ans,result1,result2)
print(ans)
start = time.time()
calc_ans(H,W)
elapsed_time = time.time()-start
print('elapsed_time:{0}' .format(elapsed_time)+'[sec]')
|
s828051793
|
Accepted
| 341 | 3,064 | 864 |
H,W = map(int,input().split())
def calc_ans(H,W):
ans = float('inf')
halfed_w = W//2
for h in range(1,H):
a = h*W
b1 = (H-h)//2*W
c1 = (H-h-(H-h)//2)*W
b2 = (H-h)*halfed_w
c2 = (H-h)*(W-halfed_w)
result1 = max(a,b1,c1)-min(a,b1,c1)
result2 = max(a,b2,c2)-min(a,b2,c2)
ans = min(ans,result1,result2)
halfed_h = H//2
for w in range(1,W):
a = w*H
b1 = (W-w)//2*H
c1 = (W-w-(W-w)//2)*H
b2 = (W-w)*halfed_h
c2 = (W-w)*(H-halfed_h)
result1 = max(a,b1,c1)-min(a,b1,c1)
result2 = max(a,b2,c2)-min(a,b2,c2)
ans = min(ans,result1,result2)
print(ans)
calc_ans(H,W)
|
s949424963
|
p03565
|
u035901835
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,316 | 509 |
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`.
|
Sd=input()
T=input()
i=len(Sd)-len(T)
j=0
flag=True
while(1):
print('searching',i,j,Sd[i],T[j])
if Sd[i]==T[j] or Sd[i]=='?':
flag=True
print('find',i,j,Sd[i],T[j])
if j==len(T)-1:
print('complete')
break
j+=1
i+=1
else:
flag=False
i-=j+1
j=0
if i<0:
print('not find')
break
if flag:
print((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
else:
print('UNRESTORABLE')
|
s396406753
|
Accepted
| 17 | 3,064 | 545 |
Sd=input()
T=input()
i=len(Sd)-len(T)
j=0
ans=[]
flag=False
while(1):
if i<0:
#print('not find')
break
#print('searching',i,j,Sd[i],T[j])
if Sd[i]==T[j] or Sd[i]=='?':
#print('find',i,j,Sd[i],T[j])
if j==len(T)-1:
ans.append((Sd[:i-j]+T+Sd[i-j+len(T):]).replace('?','a'))
i-=j+1
j=0
flag=True
continue
j+=1
i+=1
else:
i-=j+1
j=0
if flag:
ans.sort()
print(ans[0])
else:
print('UNRESTORABLE')
|
s034785151
|
p03557
|
u434872492
| 2,000 | 262,144 |
Wrong Answer
| 308 | 23,360 | 310 |
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.
|
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
C.sort(reverse=True)
ans = 0
for i in B:
a = bisect.bisect_left(A,i)
b = bisect.bisect_left(C,i)
ans += a*b
print(ans)
|
s412101816
|
Accepted
| 318 | 22,720 | 324 |
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
B.sort()
#C.sort(reverse=True)
C.sort()
ans = 0
for i in B:
a = bisect.bisect_left(A,i)
b = N - bisect.bisect_right(C,i)
ans += a*b
print(ans)
|
s907479829
|
p03549
|
u159335277
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
|
n, m = list(map(int, input().split()))
print((m * 1800 + 100 * (n - m)) * (2 ** m))
|
s590295090
|
Accepted
| 17 | 2,940 | 85 |
n, m = list(map(int, input().split()))
print((m * 1900 + 100 * (n - m)) * (2 ** m))
|
s882581464
|
p00002
|
u459418423
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,548 | 183 |
Write a program which computes the digit number of sum of two integers a and b.
|
import sys
tokens = []
for line in sys.stdin.readlines():
tokens.append(list(map(int, line.strip().split())))
for i in range(len(tokens)):
print(tokens[i][0] + tokens[i][1])
|
s282990466
|
Accepted
| 30 | 7,672 | 199 |
import sys
import math
while True:
line = sys.stdin.readline()
if not line:
break
token = list(map(int, line.strip().split()))
print(int(math.log10(token[0] + token[1]) + 1))
|
s164268372
|
p02393
|
u839008951
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,572 | 248 |
Write a program which reads three integers, and prints them in ascending order.
|
def parseSpaceDivideIntArgs(arg):
tmpArr = arg.split()
ret = []
for s in tmpArr:
ret.append(int(s))
return ret
# instr = input()
instr = "3 2 4"
instrSpl = parseSpaceDivideIntArgs(instr)
instrSpl.sort()
print(instrSpl)
|
s764848280
|
Accepted
| 20 | 5,596 | 490 |
def parseSpaceDivideIntArgs(arg):
tmpArr = arg.split()
ret = []
for s in tmpArr:
ret.append(int(s))
return ret
def getArr2SpaceDivideStr(arg):
ret = ""
isFirst = True
for s in arg:
if not isFirst:
ret += ' '
else:
isFirst = False
ret += str(s)
return ret
instr = input()
# instr = "10000 1000 100"
instrSpl = parseSpaceDivideIntArgs(instr)
instrSpl.sort()
print(getArr2SpaceDivideStr(instrSpl))
|
s716300327
|
p03477
|
u771532493
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 117 |
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
a,b,c,d=map(int,input().split())
if a+b<c+d:
print('Left')
elif a+b<c+d:
print('Right')
else:
print('Balanced')
|
s661263657
|
Accepted
| 17 | 2,940 | 118 |
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')
|
s686528986
|
p02602
|
u671889550
| 2,000 | 1,048,576 |
Wrong Answer
| 2,207 | 49,956 | 200 |
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
|
import numpy as np
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
if np.prod(a[i-k+1:i]) > np.prod(a[i-k:i-1]):
print('Yes')
else:
print('No')
|
s403578245
|
Accepted
| 139 | 31,568 | 154 |
n, k = map(int, input().split())
a = list(map(int, input().split()))
for i in range(k, n):
if a[i - k] < a[i]:
print('Yes')
else:
print('No')
|
s339725870
|
p02678
|
u668199686
| 2,000 | 1,048,576 |
Wrong Answer
| 2,207 | 46,576 | 626 |
There is a cave. The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside. It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage. Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1. * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible. Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.
|
n, m = map(int, input().split())
connections = [list(map(int, input().split())) for _ in range(m)]
weights = [2e5 + 10] * n
weights[0] = 1
directions = [1] * n
for _ in range(m):
for con in connections:
r1 = con[0]
r2 = con[1]
w1 = weights[r1 - 1]
w2 = weights[r2 - 1]
if w1 < 2e5 + 10 and w1 + 1 < w2:
weights[r2 - 1] = w1 + 1
directions[r2 - 1] = r1
if w2 < 2e5 + 10 and w2 + 1 < w1:
weights[r1 - 1] = w2 + 1
directions[r1 - 1] = r2
if max(weights) > 2e5 + 5:
print("No")
else:
for d in directions:
print(d)
|
s378755733
|
Accepted
| 436 | 54,516 | 594 |
import sys
from collections import deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = map(int, readline().split())
G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for a, b in zip(m, m):
G[a].append(b)
G[b].append(a)
par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
v = q.popleft()
for w in G[v]:
if visited[w]:
continue
visited[w] = 1
par[w] = v
q.append(w)
print('Yes')
print(*par[2:], sep='\n')
|
s588751032
|
p03068
|
u460745860
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 164 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
import sys
input=sys.stdin.readline
N=int(input())
S=input()
K=int(input())-1
for s in S:
if s != S[K]:
print("*",end='')
else:
print(s,end='')
print()
|
s783625557
|
Accepted
| 17 | 2,940 | 170 |
import sys
input=sys.stdin.readline
N=int(input())
S=input()[:-1]
K=int(input())-1
for s in S:
if s != S[K]:
print("*",end='')
else:
print(s,end='')
print()
|
s907270595
|
p03761
|
u099566485
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,064 | 286 |
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
n=int(input())
s=[]
for i in range(n):
s.append(list(input()))
l=''
for i in range(26):
t=n
for j in range(n):
if s[j].count(chr(97+i))<t:
t=s[j].count(chr(97+i))
for j in range(t):
l=l+chr(97+i)
list(l).sort()
for i in l:
print(i,end='')
|
s176878429
|
Accepted
| 19 | 3,060 | 224 |
#058-C
n=int(input())
s=[]
for i in range(n):
s.append(list(input()))
l=''
for i in range(26):
t=n+2
for j in range(n):
t=min(t,s[j].count(chr(97+i)))
for j in range(t):
l=l+chr(97+i)
print(l)
|
s729893537
|
p03997
|
u895918162
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,024 | 71 |
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) * 0.5)
|
s246213455
|
Accepted
| 27 | 9,100 | 76 |
a = int(input())
b = int(input())
h = int(input())
print(int((a+b)*h* 0.5))
|
s139152939
|
p03387
|
u321008368
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 274 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
As = [ int(i) for i in input('>> ').split()]
As.sort()
As.reverse()
o = 0
diff = As[0] - As[1]
div, mod = divmod(diff,2)
o += div
if mod == 1:
As[2] += 1
o += 1
diff = As[0] - As[2]
div, mod = divmod(diff,2)
o += div
if mod == 1:
o += 1
o += mod
print(o)
|
s700639732
|
Accepted
| 17 | 3,060 | 322 |
As = [ int(i) for i in input('').split()]
#As = "2 6 3"
As.sort()
As.reverse()
o = 0
diff = As[0] - As[1]
div, mod = divmod(diff,2)
o += div
if mod == 1:
As[2] += 1
o += 1
diff = As[0] - As[2]
div, mod = divmod(diff,2)
o += div
if mod == 1:
o += 1
o += mod
print(o)
|
s087836655
|
p03110
|
u739362834
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 166 |
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
N = int(input())
m = 0
for i in range(N):
x, y = map(str, input().split())
x = float(x)
if y == "BTC":
m += x * 380000.0
else:
m += x
|
s600797048
|
Accepted
| 17 | 2,940 | 175 |
N = int(input())
m = 0
for i in range(N):
x, y = map(str, input().split())
x = float(x)
if y == "BTC":
m += x * 380000.0
else:
m += x
print(m)
|
s755071871
|
p02279
|
u177808190
| 2,000 | 131,072 |
Wrong Answer
| 30 | 6,012 | 1,275 |
A graph _G_ = ( _V_ , _E_ ) is a data structure where _V_ is a finite set of vertices and _E_ is a binary relation on _V_ represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs). **Fig. 1** A free tree is a connnected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called "node." Your task is to write a program which reports the following information for each node _u_ of a given rooted tree _T_ : * node ID of _u_ * parent of _u_ * depth of _u_ * node type (root, internal node or leaf) * a list of chidlren of _u_ If the last edge on the path from the root _r_ of a tree _T_ to a node _x_ is ( _p_ , _x_ ), then _p_ is the **parent** of _x_ , and _x_ is a **child** of _p_. The root is the only node in _T_ with no parent. A node with no children is an **external node** or **leaf**. A nonleaf node is an **internal node** The number of children of a node _x_ in a rooted tree _T_ is called the **degree** of _x_. The length of the path from the root _r_ to a node _x_ is the **depth** of _x_ in _T_. Here, the given tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1. Fig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input. **Fig. 2**
|
import collections
def search(node, elems, tree, depth):
elems[node].append(depth)
if elems[node][0] == -1:
state = 'root'
elif not tree[node]:
state = 'leaf'
else:
state = 'internal node'
elems[node].append(state)
elems[node].append(tree[node])
depth += 1
for c in tree[node]:
search(c, elems, tree, depth)
if __name__ == '__main__':
n = int(input())
tree = collections.defaultdict(list)
elems = collections.defaultdict(list)
parents = list()
node_list = list()
for _ in range(n):
hoge = [int(x) for x in input().split()]
node_list.append(hoge[0])
tree[hoge[0]]
for childs in range(hoge[1]):
tree[hoge[0]].append(hoge[childs+2])
for key, value in tree.items():
for v in value:
elems[v].append(key)
for node in node_list:
if not elems[node]:
parents.append(node)
elems[node].append(-1)
for p in parents:
search(p, elems, tree, 0)
for key, value in elems.items():
print('node {0}: parent = {1[0]}, depth = {1[1]}, {1[2]}, '.format(key, value), end='')
print (value[-1])
|
s098721631
|
Accepted
| 1,250 | 51,720 | 1,283 |
import collections
def search(node, elems, tree, depth):
elems[node].append(depth)
if elems[node][0] == -1:
state = 'root'
elif not tree[node]:
state = 'leaf'
else:
state = 'internal node'
elems[node].append(state)
elems[node].append(tree[node])
depth += 1
for c in tree[node]:
search(c, elems, tree, depth)
if __name__ == '__main__':
n = int(input())
tree = collections.defaultdict(list)
elems = collections.defaultdict(list)
parents = list()
node_list = list()
for _ in range(n):
hoge = [int(x) for x in input().split()]
node_list.append(hoge[0])
tree[hoge[0]]
for childs in range(hoge[1]):
tree[hoge[0]].append(hoge[childs+2])
for key, value in tree.items():
for v in value:
elems[v].append(key)
for node in node_list:
if not elems[node]:
parents.append(node)
elems[node].append(-1)
for p in parents:
search(p, elems, tree, 0)
for key, value in sorted(elems.items()):
print('node {0}: parent = {1[0]}, depth = {1[1]}, {1[2]}, '.format(key, value), end='')
print (value[-1])
|
s658459092
|
p03693
|
u666608435
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 101 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r, g, b = map(int, input().split())
if (r + g + b) % 4 == 0:
print("YES")
else:
print("NO")
|
s714273399
|
Accepted
| 17 | 2,940 | 94 |
r, g, b = input().split()
if int(r + g + b) % 4 == 0:
print("YES")
else:
print("NO")
|
s393494230
|
p04011
|
u457901067
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 119 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
print(N*X)
else:
print(N*X + (N-K)*Y)
|
s361658336
|
Accepted
| 17 | 2,940 | 120 |
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if N<=K:
print(N*X)
else:
print(K*X + (N-K)*Y)
|
s301378993
|
p03853
|
u901582103
| 2,000 | 262,144 |
Wrong Answer
| 24 | 3,828 | 151 |
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h,0,-1):
L.insert(i-1,L[i-1])
for j in range(2*h):
print(*L[j])
|
s959977243
|
Accepted
| 18 | 3,060 | 159 |
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h,0,-1):
L.insert(i-1,L[i-1])
for j in range(2*h):
print(''.join(L[j]))
|
s383185783
|
p03860
|
u436110200
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 29 |
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s=input()
print("A"+s[0]+"C")
|
s816730454
|
Accepted
| 18 | 2,940 | 29 |
s=input()
print("A"+s[8]+"C")
|
s065412787
|
p03493
|
u893048163
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 56 |
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.
|
count = 0
for s in input():
count += 1
print(count)
|
s263812803
|
Accepted
| 20 | 3,060 | 77 |
count = 0
for s in input():
if s == '1':
count += 1
print(count)
|
s952007895
|
p02393
|
u721103753
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,612 | 82 |
Write a program which reads three integers, and prints them in ascending order.
|
[a,b,c] = [int(_) for _ in input().split()]
list = [a,b,c]
list.sort()
print(list)
|
s396033056
|
Accepted
| 20 | 7,452 | 71 |
a = list(i for i in input().split())
a.sort()
b = " ".join(a)
print(b)
|
s058063352
|
p00028
|
u518711553
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,692 | 206 |
Your task is to write a program which reads a sequence of integers and prints mode values of the sequence. The mode value is the element which occurs most frequently.
|
import sys
from collections import defaultdict
d = defaultdict(int)
for i in sys.stdin:
d[i] +=1
l = sorted([(k, v) for k, v in d.items()], key=lambda x:x[1], reverse=True)
print(l[0][0])
print(l[1][0])
|
s722797976
|
Accepted
| 40 | 7,860 | 203 |
import sys
from collections import defaultdict
d = defaultdict(int)
for i in sys.stdin:
d[int(i)] +=1
m = max(v for v in d.values())
for i in sorted([k for k, v in d.items() if v == m]):
print(i)
|
s062305154
|
p03760
|
u066455063
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 166 |
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
|
O = input()
E = input()
ans = []
for i in range(len(O)-1):
ans.append(O[i])
ans.append(E[i])
if len(O) > len(E):
ans.append(E[-1])
print("".join(ans))
|
s985586160
|
Accepted
| 17 | 2,940 | 202 |
O = input()
E = input()
ans = ""
if len(O) == len(E):
for i in range(len(O)):
ans += O[i] + E[i]
else:
for i in range(len(E)):
ans += O[i] + E[i]
ans += O[i+1]
print(ans)
|
s316505092
|
p03712
|
u732870425
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 216 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]
for i in range(H):
if i in (0, H):
print('#' * W)
else:
A[i][0] = '#'
A[i][-1] = '#'
print("".join(A[i]))
|
s585244126
|
Accepted
| 17 | 3,060 | 145 |
H, W = map(int,input().split())
A = [input() for _ in range(H)]
print('#' * (W+2))
for ai in A:
print('#' + ai + '#')
print('#' * (W+2))
|
s952792436
|
p02397
|
u213265973
| 1,000 | 131,072 |
Wrong Answer
| 50 | 7,540 | 236 |
Write a program which reads two integers x and y, and prints them in ascending order.
|
while True:
a = [int(i) for i in input().split(" ")]
num1 = a[0]
num2 = a[1]
if num1 <= num2:
print(num1,num2)
elif num1 > num2:
print(num2,num1)
if num1 == 0 and num2 == 0:
break
|
s510045862
|
Accepted
| 60 | 7,584 | 235 |
while True:
a = [int(i) for i in input().split(" ")]
num1 = a[0]
num2 = a[1]
if num1 == 0 and num2 == 0:
break
elif num1 <= num2:
print(num1,num2)
elif num1 > num2:
print(num2,num1)
|
s150332546
|
p02271
|
u027872723
| 5,000 | 131,072 |
Wrong Answer
| 40 | 7,752 | 472 |
Write a program which reads a sequence _A_ of _n_ elements and an integer _M_ , and outputs "yes" if you can make _M_ by adding elements in _A_ , otherwise "no". You can use an element only once. You are given the sequence _A_ and _q_ questions where each question contains _M i_.
|
# -*- coding: utf_8 -*-
from itertools import repeat
def rec(s, i, total, m):
if total == m:
return 1
if len(s) - 1 == i or total > m:
return 0
return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m)
if __name__ == "__main__":
n = int(input())
a = [int (x) for x in input().split()]
q = int(input())
m = [int (x) for x in input().split()]
for i in m:
print("yes") if rec(a, 0, 0, i) > 0 else print("no")
|
s263696799
|
Accepted
| 480 | 58,240 | 979 |
# -*- coding: utf_8 -*-
from itertools import repeat
from itertools import combinations
def rec(s, i, total, m):
if total == m:
return 1
if len(s) == i or total > m:
return 0
return rec(s, i + 1, total, m) + rec(s, i + 1, total + s[i], m)
def makeCache(s):
cache = {}
for i in range(len(s)):
comb = list(combinations(s, i))
for c in comb:
cache[sum(c)] = 1
return cache
def loop(s, m):
for i in range(len(s)):
comb = list(combinations(s, i))
for c in comb:
if sum(c) == m:
return 1
return 0
if __name__ == "__main__":
n = int(input())
a = [int (x) for x in input().split()]
q = int(input())
m = [int (x) for x in input().split()]
s = makeCache(a)
for i in m:
#print("yes") if rec(a, 0, 0, i) > 0 else print("no")
#print("yes") if loop(a, i) > 0 else print("no")
print("yes") if i in s else print("no")
|
s476773651
|
p03545
|
u411858517
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 525 |
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
import itertools
def solve(S):
bit_list = list(itertools.product([0, 1], repeat=3))
for pattern in bit_list:
count = int(S[0])
ans = S[0]
for i in range(3):
if pattern[i] == 0:
count += int(S[i+1])
ans += "+" + S[i+1]
else:
count -= int(S[i+1])
ans += "-" + S[i+1]
if count == 7:
print(ans)
break
if __name__ == '__main__':
S = input()
solve(S)
|
s358257998
|
Accepted
| 18 | 3,064 | 532 |
import itertools
def solve(S):
bit_list = list(itertools.product([0, 1], repeat=3))
for pattern in bit_list:
count = int(S[0])
ans = S[0]
for i in range(3):
if pattern[i] == 0:
count += int(S[i+1])
ans += "+" + S[i+1]
else:
count -= int(S[i+1])
ans += "-" + S[i+1]
if count == 7:
print(ans + "=7")
break
if __name__ == '__main__':
S = input()
solve(S)
|
s045323210
|
p03377
|
u500376440
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 85 |
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
A,B,X=map(int,input().split())
if B>=X-A and A<X:
print("Yes")
else:
print("No")
|
s916724667
|
Accepted
| 17 | 2,940 | 86 |
A,B,X=map(int,input().split())
if B>=X-A and A<=X:
print("YES")
else:
print("NO")
|
s680806308
|
p03447
|
u350997995
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 63 |
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x = int(input())
a = int(input())
b = int(input())
print(x-a-b)
|
s839033886
|
Accepted
| 18 | 2,940 | 65 |
x = int(input())
a = int(input())
b = int(input())
print((x-a)%b)
|
s511756681
|
p03944
|
u070423038
| 2,000 | 262,144 |
Wrong Answer
| 77 | 9,180 | 676 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
X, Y, N = map(int, input().split())
lst = [[0 for i in range(X)] for j in range(Y)]
for i in (range(N)):
x, y, a = map(int, input().split())
if a == 1:
for j in range(Y):
for k in range(x):
lst[j][k] = 1
elif a == 2:
for j in range(Y):
for k in range(X-1, x-1, -1):
lst[j][k] = 1
elif a == 3:
for j in range(y):
for k in range(X):
lst[j][k] = 1
elif a == 4:
for j in range(Y-1, y-1, -1):
for k in range(X):
lst[j][k] = 1
for i in lst:
print(i)
count = 0
for i in lst:
count += i.count(0)
print(count)
|
s669997199
|
Accepted
| 76 | 9,172 | 649 |
X, Y, N = map(int, input().split())
lst = [[0 for i in range(X)] for j in range(Y)]
for i in (range(N)):
x, y, a = map(int, input().split())
if a == 1:
for j in range(Y):
for k in range(x):
lst[j][k] = 1
elif a == 2:
for j in range(Y):
for k in range(X-1, x-1, -1):
lst[j][k] = 1
elif a == 3:
for j in range(y):
for k in range(X):
lst[j][k] = 1
elif a == 4:
for j in range(Y-1, y-1, -1):
for k in range(X):
lst[j][k] = 1
count = 0
for i in lst:
count += i.count(0)
print(count)
|
s723301355
|
p03760
|
u459697504
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 670 |
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
|
#!/usr/bin/python3
# ABC058_B
test = True
def restore():
O = input()
E = input()
password = ''
len_O = len(O)
if test:
print(len_O)
for i in range(len_O):
password += O[i]
try:
password += E[i]
except IndexError:
pass
return password
def main():
print(restore())
if __name__ == '__main__':
main()
|
s795124474
|
Accepted
| 17 | 3,064 | 671 |
#!/usr/bin/python3
# ABC058_B
test = False
def restore():
O = input()
E = input()
password = ''
len_O = len(O)
if test:
print(len_O)
for i in range(len_O):
password += O[i]
try:
password += E[i]
except IndexError:
pass
return password
def main():
print(restore())
if __name__ == '__main__':
main()
|
s890825606
|
p03494
|
u729119068
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,206 | 9,028 | 168 |
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()))
cnt=0
while True:
if [a%2 for a in A]==[0]*N:
A=[a//2 for a in A]
cnt+=1
print(cnt)
|
s570305675
|
Accepted
| 24 | 9,148 | 166 |
N=int(input())
A=list(map(int,input().split()))
cnt=0
while True:
if [a%2 for a in A]==[0]*N:
A=[a//2 for a in A]
cnt+=1
else:break
print(cnt)
|
s862518982
|
p03129
|
u539517139
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 60 |
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())
print('NO' if n<2*k else 'YES')
|
s320376985
|
Accepted
| 17 | 2,940 | 62 |
n,k=map(int,input().split())
print('NO' if n<2*k-1 else 'YES')
|
s342665275
|
p03829
|
u321623101
| 2,000 | 262,144 |
Wrong Answer
| 78 | 15,020 | 190 |
There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one- dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is X_i. You are now at town 1, and you want to visit all the other towns. You have two ways to travel: * Walk on the line. Your _fatigue level_ increases by A each time you travel a distance of 1, regardless of direction. * Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered. Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.
|
N,A,B=(int(i) for i in input().split())
X=list(map(int,input().split()))
count=0
for i in range(N-1):
M=X[i+1]-X[i]
if M>=B:
count+=M
else:
count+=B
print(count)
|
s394057516
|
Accepted
| 81 | 14,252 | 204 |
N,A,B=(int(i) for i in input().split())
X=list(map(int,input().split()))
count=0
for i in range(N-1):
M=(X[i+1]-X[i])*A
if M<=B:
count=count+M
else:
count=count+B
print(count)
|
s441395254
|
p03623
|
u771167374
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 76 |
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())
print('A' if abs(x-a)>abs(x-b) else 'B')
|
s774174855
|
Accepted
| 17 | 2,940 | 76 |
x, a, b = map(int, input().split())
print('A' if abs(x-a)<abs(x-b) else 'B')
|
s144047399
|
p03623
|
u484856305
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 90 |
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())
c=abs(x-a)
d=abs(x-b)
if c > d:
print(d)
else:
print(c)
|
s861893430
|
Accepted
| 17 | 2,940 | 95 |
x,a,b=map(int,input().split())
c=abs(x-a)
d=abs(x-b)
if c > d:
print("B")
else:
print("A")
|
s020439998
|
p03129
|
u802963389
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 89 |
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())
if (n - 1) // k >= 2:
print("YES")
else:
print("NO")
|
s598565247
|
Accepted
| 19 | 2,940 | 90 |
n, k = map(int, input().split())
if (n + 1) // k >= 2:
print("YES")
else:
print("NO")
|
s173727149
|
p03909
|
u823885866
| 2,000 | 262,144 |
Wrong Answer
| 118 | 27,128 | 633 |
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`.
|
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
h,w = rm()
for i in range(h):
a = list(rs())
for idx, j in enumerate(a):
if j == 'snuke':
print(f'{chr(65+i)}{idx+1}')
exit()
|
s814481278
|
Accepted
| 117 | 27,132 | 633 |
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce
rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7
h,w = rm()
for i in range(h):
a = list(rs())
for idx, j in enumerate(a):
if j == 'snuke':
print(f'{chr(65+idx)}{i+1}')
exit()
|
s456299335
|
p03007
|
u690536347
| 2,000 | 1,048,576 |
Wrong Answer
| 295 | 19,328 | 292 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
N = int(input())
*A, = map(int, input().split())
A.sort()
r = 1
a, b = A[0], A[1]
t = []
while 1:
x, y = (a, b) if a<b else (b, a)
t.append((x, y))
r += 1
if not r<N:
break
a, b = x-y, A[r]
a, b = t[-1]
t[-1] = (b, a)
print(len(t))
for i in t:
print(*i)
|
s842938015
|
Accepted
| 272 | 20,844 | 998 |
from bisect import bisect_left
N = int(input())
*A, = map(int, input().split())
A.sort()
if A[0]<=0 and A[-1]<=0:
ans = sum(map(abs, A[:-1]))+A[-1]
A.reverse()
r = 1
a, b = A[0], A[1]
t = []
while 1:
x, y = (a, b) if a>b else (b, a)
t.append((x, y))
r += 1
if not r<N:
break
a, b = x-y, A[r]
elif A[0]>=0 and A[-1]>=0:
ans = sum(A[1:])-A[0]
r = 1
a, b = A[0], A[1]
t = []
while 1:
x, y = (a, b) if a<b else (b, a)
t.append((x, y))
r += 1
if not r<N:
break
a, b = x-y, A[r]
a, b = t[-1]
t[-1] = (b, a)
else:
ans = sum(map(abs, A))
p = bisect_left(A, 0)
t = []
s = []
a = A[p-1]
for i in range(p, N-1):
b = A[i]
t.append((a, b))
a = a - b
c = A[N-1]
for i in ([a]+A[:p-1]):
t.append((c, i))
c = c-i
print(ans)
for i in t:
print(*i)
|
s825251777
|
p03435
|
u572142121
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 185 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
C=[list(map(int,input().split())) for i in range(3)]
print(C)
print(C[1][0])
if C[0][1]-C[0][0]==C[1][1]-C[1][0] and C[1][1]-C[1][0]==C[2][1]-C[2][0]:
print('Yes')
else:
print('No')
|
s074652945
|
Accepted
| 17 | 3,064 | 201 |
C=[list(map(int,input().split())) for i in range(3)]
for n in range(0,2):
x=C[0][2]-C[0][n]
y=C[1][2]-C[1][n]
z=C[2][2]-C[2][n]
if x!=y or y!=z :
print('No')
exit()
else:
print('Yes')
|
s466639352
|
p02601
|
u875756191
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,028 | 275 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a, b, c = map(int, input().split())
k = int(input())
m = 0
n = 1
while a > b:
m = m + 1
b = b * 2
if a < b:
break
while b > c:
n = n + 1
c = c * 2
if b < c:
break
if m + n <= k:
print('Yes')
elif m + n > k:
print('No')
|
s678305949
|
Accepted
| 28 | 9,172 | 203 |
a, b, c = map(int, input().split())
k = int(input())
times = 0
while a >= b:
b *= 2
times += 1
while b >= c:
c *= 2
times += 1
if times <= k:
print('Yes')
else:
print('No')
|
s652169678
|
p03435
|
u593567568
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 348 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
A = [list(map(int,input().split())) for _ in range(3)]
ok = True
for i in range(3):
if A[i][1] - A[i][0] == A[i][2] - A[i][1]:
continue
else:
ok = False
break
for i in range(3):
if A[1][i] - A[0][i] == A[2][i] - A[1][i]:
continue
else:
ok = False
break
if not ok:
print('No')
else:
print('Yes')
|
s012822452
|
Accepted
| 18 | 3,064 | 372 |
A = [list(map(int,input().split())) for _ in range(3)]
R1 = [A[i][1] - A[i][0] for i in range(3)]
R2 = [A[i][2] - A[i][1] for i in range(3)]
C1 = [A[1][i] - A[0][i] for i in range(3)]
C2 = [A[2][i] - A[1][i] for i in range(3)]
ok = True
for x in [R1,R2,C1,C2]:
if len(set(x)) != 1:
ok = False
break
if not ok:
print('No')
else:
print('Yes')
|
s102043532
|
p02646
|
u042497514
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,188 | 242 |
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())
ans = "No"
if A < B:
x = A + V * T
y = B + W * T
if x >= y:
ans = "Yes"
else:
x = A - V * T
y = B - W * T
if x <= y:
ans = "Yes"
print(ans)
|
s455308737
|
Accepted
| 24 | 9,188 | 242 |
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
ans = "NO"
if A < B:
x = A + V * T
y = B + W * T
if x >= y:
ans = "YES"
else:
x = A - V * T
y = B - W * T
if x <= y:
ans = "YES"
print(ans)
|
s069702672
|
p04029
|
u648452607
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 31 |
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)
|
s233967575
|
Accepted
| 17 | 2,940 | 36 |
n=int(input())
print(int((1+n)*n/2))
|
s319044169
|
p03493
|
u533344362
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 227 |
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.
|
# -*- coding: utf-8 -*-
s = input()
a = [int(c) for c in s]
count = 0
#
for i in range(1, 3):
if a[i] == 1:
count = count + 1
print(count)
|
s201059755
|
Accepted
| 17 | 2,940 | 32 |
s = input()
print(s.count('1'))
|
s990523832
|
p02400
|
u477464845
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 89 |
Write a program which calculates the area and circumference of a circle for given radius r.
|
r = float(input())
x = 3.141592653589
print("{0:.5f} {1:.5f}".format((r*2*x),(r**2*x)))
|
s914932717
|
Accepted
| 20 | 5,576 | 82 |
r = float(input())
n = 3.141592653589
print("{:.6f} {:.6f}".format(r**2*n,r*2*n))
|
s610311957
|
p03047
|
u902380746
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 3,060 | 348 |
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
|
import sys
import math
import bisect
def main():
n, k = map(int, input().split())
A = [0] * (k + 1)
A[0] = 1
for _ in range(n):
for i in range(k, -1, -1):
if i - 1 >= 0:
A[i] += A[i-1]
#print('n: %d, k: %d, A: %s' % (n, k, str(A)))
print(A[k])
if __name__ == "__main__":
main()
|
s988159614
|
Accepted
| 18 | 2,940 | 151 |
import sys
import math
import bisect
def main():
n, k = map(int, input().split())
print(n - k + 1)
if __name__ == "__main__":
main()
|
s349861811
|
p02388
|
u117140447
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 230 |
Write a program which calculates the cube of a given integer x.
|
import sys
numbers = []
max = 0
for line in sys.stdin:
numbers.append(int(line))
for i in range(0, len(numbers)):
for j in range(i,len(numbers)):
if numbers[j] - numbers[i] > max :
max = numbers[j] - numbers[i]
print(max)
|
s587093527
|
Accepted
| 20 | 5,584 | 100 |
import sys
input_number = int(input())
if __name__ == '__main__':
print(str(input_number ** 3))
|
s332555962
|
p03337
|
u345483150
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 51 |
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B.
|
a, b=map(int, input().split())
print(a+b, a-b, a*b)
|
s941572206
|
Accepted
| 17 | 2,940 | 56 |
a, b=map(int, input().split())
print(max(a+b, a-b, a*b))
|
s770809499
|
p02419
|
u283452598
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,332 | 187 |
Write a program which reads a word W and a text T, and prints the number of word W which appears in text T T consists of string Ti separated by space characters and newlines. Count the number of Ti which equals to W. The word and text are case insensitive.
|
y = input().lower()
cnt = 0
s=""
while True:
x = input().lower()
if x == "end_of_text":
break
s += x
for i in x:
if i == y:
cnt += 1
print(cnt)
|
s826818615
|
Accepted
| 20 | 7,412 | 194 |
W = input()
num = 0
while True:
line = input()
if line == 'END_OF_TEXT':
break
for word in line.split():
if word.lower() == W.lower():
num += 1
print(num)
|
s544158395
|
p03433
|
u801512570
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
if (N-A)%500==0:
print('Yes')
else:
print('No')
|
s629329127
|
Accepted
| 18 | 2,940 | 83 |
N = int(input())
A = int(input())
if N%500<=A:
print('Yes')
else:
print('No')
|
s834649318
|
p02422
|
u494314211
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,688 | 275 |
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
s=list(input())
n=int(input())
for i in range(n):
l=input().split()
if l[0]=="replace":
a=int(l[1])
b=int(l[2])
s[a:b+1]=list(l[3])
elif l[0]=="reverse":
a=int(l[1])
b=int(l[2])
s[a:b+1]=s[a:b+1:-1]
else:
a=int(l[1])
b=int(l[2])
print("".join(s[a:b+1]))
|
s821231728
|
Accepted
| 30 | 7,636 | 284 |
s=list(input())
n=int(input())
for i in range(n):
l=input().split()
if l[0]=="replace":
a=int(l[1])
b=int(l[2])
s[a:b+1]=list(l[3])
elif l[0]=="reverse":
a=int(l[1])
b=int(l[2])
c=s[a:b+1][::-1]
s[a:b+1]=c
else:
a=int(l[1])
b=int(l[2])
print("".join(s[a:b+1]))
|
s746086804
|
p03644
|
u492030100
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 150 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
N = int(input())
ans = [i * i for i in range(1, 9)]
for i in range(len(ans)):
if ans[i] > N:
print(ans[i] - 1)
exit(0)
print(64)
|
s440052292
|
Accepted
| 17 | 2,940 | 149 |
N = int(input())
ans = [2 ** i for i in range(0, 7)]
for i in range(len(ans)):
if ans[i] > N:
print(ans[i-1])
exit(0)
print(64)
|
s749728188
|
p02401
|
u400765446
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 408 |
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.
|
def main():
while True:
a, op, b = input().split()
a = int(a)
b = int(b)
if op == '?':
break
elif op == '+':
print(a + b)
elif op == '-':
print(a - b)
elif op == '*':
print(a * b)
elif op == '/':
print(a / b)
else:
pass
if __name__ == '__main__':
main()
|
s870286889
|
Accepted
| 20 | 5,604 | 323 |
while True:
x, op, y = input().split()
a = int(x)
b = int(y)
if op == '?':
break
elif op == '+':
print("{:d}".format(a+b))
elif op == '-':
print("{:d}".format(a-b))
elif op == '*':
print("{:d}".format(a*b))
elif op == '/':
print("{:d}".format(a//b))
|
s158564022
|
p04045
|
u878138257
| 2,000 | 262,144 |
Wrong Answer
| 520 | 3,060 | 200 |
Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K. She is shopping, and now paying at the cashier. Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change). However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money. Find the amount of money that she will hand to the cashier.
|
n,k = map(int, input().split())
a = list(map(int, input().split()))
d=0
e=0
for i in range(100000):
d=str(n+i)
for j in range(k):
e=e+d.count(str(a[j]))
if e==0:
print(d)
break
d=0
|
s315710569
|
Accepted
| 374 | 3,060 | 206 |
n,k = map(int, input().split())
a = list(map(int, input().split()))
d=""
e=0
for i in range(100000):
d=str(n+i)
for j in range(k):
e=e+d.count(str(a[j]))
if e==0:
print(int(d))
break
e=0
|
s613614311
|
p03359
|
u309018392
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 59 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a,b = map(int,input().split())
print(a-1) if a > b else (a)
|
s409172683
|
Accepted
| 19 | 2,940 | 64 |
a,b = map(int,input().split())
print(a-1) if a > b else print(a)
|
s149382918
|
p02612
|
u768219634
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,152 | 67 |
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.
|
x = int(input())
if x >= 30:
print("Yes")
else:
print("No")
|
s299035608
|
Accepted
| 29 | 9,152 | 76 |
n = int(input())
if n%1000 == 0:
print (0)
else:
print (1000-n%1000)
|
s785791065
|
p03501
|
u933214067
| 2,000 | 262,144 |
Wrong Answer
| 51 | 5,724 | 209 |
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
|
from statistics import mean, median,variance,stdev
import sys
import math
n=input().split()
a = []
for i in range(len(n)):
a.append(int(n[i]))
if (a[0]*a[1]) > a[2]:
print(a[0]*a[1])
else: print(a[2])
|
s137599098
|
Accepted
| 36 | 5,084 | 209 |
from statistics import mean, median,variance,stdev
import sys
import math
n=input().split()
a = []
for i in range(len(n)):
a.append(int(n[i]))
if (a[0]*a[1]) < a[2]:
print(a[0]*a[1])
else: print(a[2])
|
s233779528
|
p03139
|
u358051561
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 75 |
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.
|
n, a, b = map(int, input().split())
print('{} {}'.format(max(a, b), a+b-n))
|
s001349139
|
Accepted
| 17 | 2,940 | 82 |
n, a, b = map(int, input().split())
print('{} {}'.format(min(a, b), max(a+b-n,0)))
|
s199304096
|
p02578
|
u097852911
| 2,000 | 1,048,576 |
Wrong Answer
| 158 | 32,308 | 173 |
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n = int(input())
lis = list(map(int,input().split()))
sum = 0
for i in range(n-1):
if int(lis[i])>int(lis[i+1]):
sum += lis[i]-lis[i+1]
else:
continue
print(sum)
|
s065107364
|
Accepted
| 194 | 32,308 | 195 |
n = int(input())
lis = list(map(int,input().split()))
sum = 0
for i in range(n-1):
if int(lis[i])>int(lis[i+1]):
sum += lis[i]-lis[i+1]
lis[i+1] = lis[i]
else:
continue
print(sum)
|
s001128576
|
p02261
|
u784787519
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,892 | 1,252 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubbleSort(A,N):
flag = 1
i = 0
while flag:
flag = 0
for j in range(N-1,i,-1):
if int(A[j][1]) < int(A[j-1][1]):
tmp = A[j]
A[j] = A[j-1]
A[j-1] = tmp
flag = 1
i += 1
return A
def selectionSort(A,N):
for i in range(0,N-1):
minj = i
j=i+1
for j in range(j,N):
if int(A[j][1]) < int(A[minj][1]):
minj = j
tmp = A[minj]
A[minj] = A[i]
A[i] = tmp
return A
def isStable(ori,sorted):
for i in range(len(ori)-1):
for j in range(i+1, len(ori)-1):
for a in range(len(ori)):
for b in range(a+1, len(ori)):
if ori[i][1] == ori[j][1] and ori[i] == sorted[b] and ori[j] == sorted[a]:
return 'Not stable'
return 'Stable'
if __name__ == '__main__':
N = int(input())
numbers = input().split(' ')
n1 = numbers.copy()
n2 = numbers.copy()
A = bubbleSort(n1,N)
print(A)
print(isStable(numbers,A))
B = selectionSort(n2,N)
print(B)
print(isStable(numbers, B))
|
s038428820
|
Accepted
| 120 | 7,896 | 1,405 |
def bubbleSort(A,N):
flag = 1
i = 0
while flag:
flag = 0
for j in range(N-1,i,-1):
if int(A[j][1]) < int(A[j-1][1]):
tmp = A[j]
A[j] = A[j-1]
A[j-1] = tmp
flag = 1
i += 1
return A
def selectionSort(A,N):
for i in range(0,N-1):
minj = i
j=i+1
for j in range(j,N):
if int(A[j][1]) < int(A[minj][1]):
minj = j
tmp = A[minj]
A[minj] = A[i]
A[i] = tmp
return A
def isStable(ori,sorted):
for i in range(len(ori)-1):
for j in range(i+1, len(ori)-1):
for a in range(len(ori)):
for b in range(a+1, len(ori)):
if ori[i][1] == ori[j][1] and ori[i] == sorted[b] and ori[j] == sorted[a]:
return 'Not stable'
return 'Stable'
def output(A):
for i in range(len(A)): # output
if i == len(A) - 1:
print(A[i])
else:
print(A[i], end=' ')
if __name__ == '__main__':
N = int(input())
numbers = input().split(' ')
n1 = numbers.copy()
n2 = numbers.copy()
A = bubbleSort(n1,N)
output(A)
print(isStable(numbers,A))
B = selectionSort(n2,N)
output(B)
print(isStable(numbers, B))
|
s507643260
|
p03469
|
u544050502
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 52 |
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
S=input().split("/")
S[0]=="2018"
print("/".join(S))
|
s306539244
|
Accepted
| 17 | 2,940 | 51 |
S=input().split("/")
S[0]="2018"
print("/".join(S))
|
s035043068
|
p02389
|
u487330611
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 55 |
Write a program which calculates the area and perimeter of a given rectangle.
|
a,b=map(int,input().split())
print(a*b)
print(2*(a+b))
|
s669241159
|
Accepted
| 20 | 5,580 | 49 |
a,b=map(int,input().split())
print(a*b,2*(a+b))
|
s307709562
|
p03556
|
u190405389
| 2,000 | 262,144 |
Wrong Answer
| 29 | 3,064 | 63 |
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
N = int(input())
a = 1
while a**2 < N:
a+=1
print(a**2)
|
s006244323
|
Accepted
| 28 | 2,940 | 67 |
N = int(input())
a = 1
while a**2 <= N:
a+=1
print((a-1)**2)
|
s794056327
|
p03386
|
u823044869
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 176 |
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())
if abs(a-b)+1 <= 2*k:
for i in range(a,b+1):
print(i)
else:
for i in range(k):
print(a+i)
for i in range(k):
print(b-i)
|
s298276799
|
Accepted
| 17 | 3,060 | 221 |
a, b, k = map(int,input().split())
if abs(a-b)+1 <= 2*k:
for i in range(a,b+1):
print(i)
else:
nList = []
for i in range(k):
nList.append(a+i)
nList.append(b-i)
for i in sorted(nList):
print(i)
|
s204980186
|
p03477
|
u174536291
| 2,000 | 262,144 |
Wrong Answer
| 32 | 9,184 | 146 |
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 = list(map(int, input().split()))
l = a + b
r = c + d
if l > r:
print('Right')
elif l == r:
print('Balanced')
else:
print('Left')
|
s503445657
|
Accepted
| 29 | 9,052 | 146 |
a, b, c, d = list(map(int, input().split()))
l = a + b
r = c + d
if l > r:
print('Left')
elif l == r:
print('Balanced')
else:
print('Right')
|
s695016193
|
p03474
|
u503228842
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 213 |
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 = input()
ans = True
for s in range(a+b+1):
if s == a:
if S[s] != "-":
ans = False
if s != a:
if S[s] == "-":
ans = False
print(ans)
|
s591115879
|
Accepted
| 17 | 3,064 | 239 |
a,b = map(int,input().split())
S = input()
ans = True
for s in range(a+b+1):
if s == a:
if S[s] != "-":
ans = False
if s != a:
if S[s] == "-":
ans = False
if ans:print("Yes")
else:print("No")
|
s422438921
|
p03455
|
u304209389
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 148 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
print(a,b)
|
s947053813
|
Accepted
| 18 | 2,940 | 89 |
a,b = map(int, input().split())
if a*b % 2 == 0:
print('Even')
else:
print('Odd')
|
s591447541
|
p03251
|
u696444274
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 319 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n, m, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
#s = int(input())
z_min = X+1
z_max = Y
print(z_max)
print(z_min)
if Y-X > 0:
if z_min <= max(x) and z_max >= min(y) and min(y)-max(x)>0:
print("No War")
exit()
print("War")
|
s707206681
|
Accepted
| 39 | 5,276 | 360 |
import math
import itertools
import statistics
#import collections
n, m, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
#s = int(input())
z_min = X+1
z_max = Y
if Y-X > 0:
if z_min <= max(x) and z_max >= min(y) and min(y)-max(x)>0:
print("No War")
exit()
print("War")
|
s807100920
|
p00137
|
u314932236
| 1,000 | 131,072 |
Wrong Answer
| 30 | 5,608 | 295 |
古典的な乱数生成方法の一つである平方採中法のプログラムを作成します。平方採中法は、フォンノイマンによって 1940 年代半ばに提案された方法です。 平方採中法は、生成する乱数の桁数を n としたとき、初期値 s の2乗を計算し、その数値を 2n 桁の数値とみて、(下の例のように 2 乗した桁数が足りないときは、0 を補います。)その中央にある n 個の数字を最初の乱数とします。次にこの乱数を 2 乗して、同じ様に、中央にある n 個の数字をとって、次の乱数とします。例えば、123 を初期値とすると 1232 = 00015129 → 0151 1512 = 00022801 → 0228 2282 = 00051984 → 0519 5192 = 00269361 → 2693 26932 = 07252249 → 2522 の様になります。この方法を用いて、初期値 s(10000未満の正の整数)を入力とし、n = 4 の場合の乱数を 10 個生成し出力するプログラムを作成してください。
|
import os
import sys
def main():
n = int(input())
for i in range(1,n+1):
x = int(input())
print("Case {}:".format(i))
for j in range(10):
x = x**2
out = '{0:08d}'.format(x)
print(out[2:6])
x = int(out[2:6])
main()
|
s660718464
|
Accepted
| 20 | 5,612 | 300 |
import os
import sys
def main():
n = int(input())
for i in range(1,n+1):
x = int(input())
print("Case {}:".format(i))
for j in range(10):
x = x**2
out = '{0:08d}'.format(x)
print(int(out[2:6]))
x = int(out[2:6])
main()
|
s927044821
|
p02399
|
u766693979
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 86 |
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
|
a, b = input().split()
a = int( a )
b = int( b )
print( int( a / b ), a % b, a / b )
|
s602207194
|
Accepted
| 20 | 5,604 | 97 |
a, b = input().split()
a = int( a )
b = int( b )
print( int( a / b ), a % b, "%.5f"%( a / b ) )
|
s491879148
|
p03359
|
u663438907
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 78 |
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a, b = map(int, input().split())
ans = a - 1
if a < b:
ans += 1
print(ans)
|
s282343199
|
Accepted
| 18 | 2,940 | 81 |
a, b = map(int, input().split())
ans = a - 1
if a <= b:
ans += 1
print(ans)
|
s116070350
|
p03698
|
u782685137
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 54 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
S=input();print('YNeos'[len(S)!=len(set(list(S)))::2])
|
s835058201
|
Accepted
| 17 | 2,940 | 54 |
S=input();print('yneos'[len(S)!=len(set(list(S)))::2])
|
s888390384
|
p03992
|
u782654209
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
This contest is `CODE FESTIVAL`. However, Mr. Takahashi always writes it `CODEFESTIVAL`, omitting the single space between `CODE` and `FESTIVAL`. So he has decided to make a program that puts the single space he omitted. You are given a string s with 12 letters. Output the string putting a single space between the first 4 letters and last 8 letters in the string s.
|
s = input()
print(s[:4]+' '+s[4:]+'\n')
|
s433965675
|
Accepted
| 17 | 2,940 | 34 |
s = input()
print(s[:4]+' '+s[4:])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.