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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s831890134
|
p03719
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 121
|
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.
|
num = list(map(int, input().split(' ')))
if num[0] <= num[2] and num[1] >= num[2]:
print("yes")
else:
print("no")
|
s902462521
|
Accepted
| 18
| 2,940
| 121
|
num = list(map(int, input().split(' ')))
if num[0] <= num[2] and num[1] >= num[2]:
print("Yes")
else:
print("No")
|
s850736441
|
p03474
|
u097317219
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 159
|
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()
s_list = list(s)
if len(s) == (a+b+1) and s_list[a] == "-" and s.count("-") == 1:
print("YES")
else:
print("NO")
|
s118547762
|
Accepted
| 17
| 2,940
| 159
|
a,b = map(int,input().split())
s = input()
s_list = list(s)
if len(s) == (a+b+1) and s_list[a] == "-" and s.count("-") == 1:
print("Yes")
else:
print("No")
|
s295850386
|
p03360
|
u903005414
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 73
|
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 = list(map(int, input().split()))
K = int(input())
print(2**K * max(A))
|
s232436856
|
Accepted
| 17
| 2,940
| 89
|
A = list(map(int, input().split()))
K = int(input())
print((2**K - 1) * max(A) + sum(A))
|
s837087652
|
p03170
|
u945228737
| 2,000
| 1,048,576
|
Wrong Answer
| 63
| 3,828
| 335
|
There is a set A = \\{ a_1, a_2, \ldots, a_N \\} consisting of N positive integers. Taro and Jiro will play the following game against each other. Initially, we have a pile consisting of K stones. The two players perform the following operation alternately, starting from Taro: * Choose an element x in A, and remove exactly x stones from the pile. A player loses when he becomes unable to play. Assuming that both players play optimally, determine the winner.
|
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
dp = [None] * (K + 1)
dp[0] = False
for k in range(1, K + 1):
for a in A:
if a <= k:
dp[k] = not dp[k - a]
break
if dp[k] is None:
dp[k] = False
print('First' if dp[-1] else 'Second')
|
s130614925
|
Accepted
| 948
| 3,828
| 303
|
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
dp = [False] * (K + 1)
# dp[0] = False
for k in range(1, K + 1):
for a in A:
if a <= k and not dp[k - a]:
dp[k] = True
break
print('First' if dp[-1] else 'Second')
|
s417158474
|
p03778
|
u905582793
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 61
|
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
|
w,a,b=map(int,input().split())
print(max(0,min(b-a-w,a-b-w)))
|
s502168107
|
Accepted
| 17
| 2,940
| 110
|
w,a,b=map(int,input().split())
if b<=a<=b+w or a<=b<=a+w:
print(0)
else:
print(min(abs(b-a-w),abs(a-b-w)))
|
s072496073
|
p03352
|
u299801457
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 62
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
import math
x=int(input())
root_x=int(math.sqrt(x))
print(x*x)
|
s694060724
|
Accepted
| 18
| 3,064
| 187
|
import math
x=int(input())
log_x=int(math.log(x,2))
cand=[0 for i in range(1001)]
cand[0]=1
for i in range(2,1000):
cand[i]=int(pow(x,1.0/i))**i
cand[1000]=1000
print(max(cand[:x+1]))
|
s586466724
|
p03456
|
u946424121
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 156
|
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number.
|
a,b = map(int, input().split())
n = 10*a + b
sq_l = []
for i in range(n):
sq = i **2
sq_l.append(sq)
if n in sq_l:
print("Yes")
else:
print("No")
|
s674463961
|
Accepted
| 17
| 2,940
| 91
|
n = int(input().replace(" ",""))
if n == int(n**0.5)**2:
print("Yes")
else:
print("No")
|
s211548095
|
p03720
|
u604262137
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 223
|
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
ith = input().split()
hyou += ith
hyou = list(map(int,hyou))
print(hyou)
j = 1
while j <= N:
print(hyou.count(j))
j += 1
|
s858347641
|
Accepted
| 17
| 3,060
| 212
|
table = input().split()
N,M = int(table[0]),int(table[1])
hyou = []
for i in range(M):
ith = input().split()
hyou += ith
hyou = list(map(int,hyou))
j = 1
while j <= N:
print(hyou.count(j))
j += 1
|
s528603511
|
p03813
|
u111365959
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise. You are given Smeke's current rating, x. Print `ABC` if Smeke will participate in ABC, and print `ARC` otherwise.
|
a = int(input())
print('ABC') if a>=1200else print('ARC')
|
s258319453
|
Accepted
| 17
| 2,940
| 59
|
a = int(input())
print('ARC') if a>=1200 else print('ABC')
|
s390292260
|
p02865
|
u261423637
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 66
|
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)-1)
else:
print(n/2)
|
s018876757
|
Accepted
| 17
| 2,940
| 77
|
n=int(input())
if n%2==0:
print(int((n/2)-1))
else:
print(int(n/2))
|
s847310904
|
p03610
|
u818655004
| 2,000
| 262,144
|
Wrong Answer
| 40
| 3,188
| 102
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s = input()
res = s[0]
for i in range(len(s)):
if i>0:
if i%2==0:
res += s[i]
|
s993475078
|
Accepted
| 45
| 3,188
| 113
|
s = input()
res = s[0]
for i in range(len(s)):
if i>0:
if i%2==0:
res += s[i]
print(res)
|
s339726578
|
p03502
|
u745087332
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 372
|
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
# coding:utf-8
INF = float('inf')
def inpl(): return list(map(int, input().split()))
def is_harshad(n):
p = n
tmp = 0
while p >= 10:
p, q = divmod(p, 10)
tmp += q
tmp += p
print(tmp)
if n % tmp == 0:
return True
else:
return False
N = int(input())
if is_harshad(N):
print('Yes')
else:
print('No')
|
s633984270
|
Accepted
| 17
| 3,060
| 359
|
# coding:utf-8
INF = float('inf')
def inpl(): return list(map(int, input().split()))
def is_harshad(n):
p = n
tmp = 0
while p >= 10:
p, q = divmod(p, 10)
tmp += q
tmp += p
if n % tmp == 0:
return True
else:
return False
N = int(input())
if is_harshad(N):
print('Yes')
else:
print('No')
|
s449259765
|
p03625
|
u863370423
| 2,000
| 262,144
|
Wrong Answer
| 110
| 18,568
| 276
|
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())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]
for i in range(n):
if(vals[i] in d.keys()):
d[vals[i]] += 1
else:
d[vals[i]] = 1
print(d)
for i in d.keys():
if(d[i] >= 2):
a.append(i)
a.sort()
print(a[-1]*a[-2])
|
s895786003
|
Accepted
| 106
| 18,316
| 328
|
n = int(input())
vals = list(map(int, input().split()))
d= {}
a = [0, 0]
for i in range(n):
if(vals[i] in d.keys()):
d[vals[i]] += 1
else:
d[vals[i]] = 1
for i in d.keys():
if(d[i] >= 4):
a.append(i)
a.append(i)
elif(d[i] >= 2):
a.append(i)
a.sort()
print(a[-1]*a[-2])
|
s281692527
|
p03503
|
u281303342
| 2,000
| 262,144
|
Wrong Answer
| 157
| 3,064
| 505
|
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period.
|
N = int(input())
F,P,b,T = [],[],1,-9999999999
for i in range(N):
F.append(list(map(int,input().split())))
for i in range(N):
P.append(list(map(int,input().split())))
while b < 1 << 10:
bs = "{0:10b}".format(b)
bsi = 0
S = [0]*N
for c in bs:
if c == "1":
for i in range(N):
S[i] += F[i][bsi]
bsi += 1
t = 0
for i in range(N):
t += P[i][S[i]]
if T < t:
print("T",T,"t",t)
T = t
b += 1
print(T)
|
s946298610
|
Accepted
| 253
| 3,064
| 455
|
N = int(input())
F = ["".join(input().split()) for _ in range(N)]
P = [list(map(int,input().split())) for _ in range(N)]
Ans = -9999999999
for i in range(1 << 10):
xx = bin(i)[2::].zfill(10)
if xx == "0000000000":
continue
ans = 0
for i in range(N):
cnt = 0
for j in range(10):
if xx[j]=="1" and F[i][j]=="1":
cnt += 1
ans += P[i][cnt]
Ans = max(Ans,ans)
print(Ans)
|
s388608832
|
p03473
|
u982762220
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 22
|
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
print(24-int(input()))
|
s004708552
|
Accepted
| 18
| 2,940
| 22
|
print(48-int(input()))
|
s447280939
|
p03844
|
u379559362
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,064
| 139
|
Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either `+` or `-`. Your task is to evaluate the formula instead of her.
|
aopb = input().split()
print(aopb)
if aopb[1] == '+':
print(int(aopb[0]) + int(aopb[2]))
else:
print(int(aopb[0]) - int(aopb[2]))
|
s647811850
|
Accepted
| 23
| 3,188
| 127
|
aopb = input().split()
if aopb[1] == '+':
print(int(aopb[0]) + int(aopb[2]))
else:
print(int(aopb[0]) - int(aopb[2]))
|
s009372036
|
p02260
|
u972731768
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 224
|
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
|
i=input
N=int(i())
A=list(map(int,i().split()))
r = range
c=0
for i in r(N):
minj=i
for j in r(i,N):
if A[j] < A[minj]:
minj = j
A[i],A[minj] = A[minj],A[i]
c+=1
print(*A)
print(c)
|
s767324650
|
Accepted
| 20
| 5,608
| 186
|
i=input
N=int(i())
A=list(map(int,i().split()))
r=range
c=0
for i in r(N):
m=i
for j in r(i,N):
if A[j] < A[m]:m=j
if i!=m:A[i],A[m]=A[m],A[i];c+=1
print(*A)
print(c)
|
s738517096
|
p04043
|
u778348725
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 232
|
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.
|
print("A,B,Cの値を入力してください")
A,B,C = map(int,input().split())
if(A+B+C==17):
if((A==5 or A==7) and (B==5 or B==7) and (C==5 or C==7)):
print("YES")
else:
print("NO")
else:
print("NO")
|
s923774238
|
Accepted
| 17
| 2,940
| 341
|
input_list = list(map(int,input().split()))
sort_list = sorted(input_list)
if(sum(sort_list) == 17):
if(sort_list[0]==5 and sort_list[1]==5 and sort_list[2]==7):
print("YES")
else:
print("NO")
else:
print("NO")
|
s263259564
|
p03999
|
u814171899
| 2,000
| 262,144
|
Wrong Answer
| 33
| 3,188
| 215
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
import math
def func(n_str, ptr):
print(n_str)
if len(n_str)==ptr:
return int(eval(n_str))
return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()
print(func(s, 1))
|
s341593765
|
Accepted
| 32
| 3,064
| 217
|
import math
def func(n_str, ptr):
# print(n_str)
if len(n_str)==ptr:
return int(eval(n_str))
return func(n_str, ptr+1) + func(n_str[:ptr]+"+"+n_str[ptr:], ptr+2)
s = input()
print(func(s, 1))
|
s972096649
|
p03828
|
u373274281
| 2,000
| 262,144
|
Wrong Answer
| 29
| 3,572
| 357
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
n = int(input())
m = pow(10, 9) + 7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*32
for i in range(2, n+1):
for p in primes:
print(i, p)
while(i % p == 0):
D[p] += 1
i //= p
if i == 1:
break
print(D)
score = 1
for p in primes:
score = score * (D[p] + 1)
print(score)
print(score % m)
|
s866625158
|
Accepted
| 20
| 3,064
| 299
|
n = int(input())
m = 10**9+7
primes = [2,3,5,7,11,13,17,19,23,29,31]
D = [0]*1001
for i in range(2, n+1):
for p in primes:
while(i % p == 0):
D[p] += 1
i //= p
if i > 1:
D[i] += 1
score = 1
for d in D:
score = (score * (d + 1)) % m
print(score)
|
s505115385
|
p03474
|
u197078193
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 261
|
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()
flag = True
for i in range(A):
if not '0' <= S[i] <= '9':
flag = False
if S[A] != '-':
flag = False
for i in range(B):
if not '0' <= S[A+i] <= '9':
flag = False
if flag:
print('Yes')
else:
print('No')
|
s239105100
|
Accepted
| 19
| 3,060
| 268
|
A,B = map(int,input().split())
S = input()
flag = True
for i in range(A):
if not '0' <= S[i] <= '9':
flag = False
if S[A] != '-':
flag = False
for i in range(B):
if not '0' <= S[A+i+1] <= '9':
flag = False
if flag:
print('Yes')
else:
print('No')
|
s448424752
|
p03624
|
u619785253
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,316
| 26
|
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
|
word = input()
print(word)
|
s100810850
|
Accepted
| 78
| 4,324
| 268
|
#from collections import Counter
word = list(input())
word.sort()
#print(set(word))
#print(word)
ans = []
for i in [chr(i) for i in range(97, 97+26)]:
n = word.count(i)
if n == 0:
ans.append(i)
break
else:
ans.append('None')
print(ans[0])
|
s061722079
|
p02694
|
u169678167
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,168
| 126
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
X = int(input())
Z = 100
res = 0
while (X >= Z):
Z += Z*0.01
Z = math.floor(Z)
res += 1
print(res)
|
s852160363
|
Accepted
| 23
| 9,168
| 125
|
import math
X = int(input())
Z = 100
res = 0
while (X > Z):
Z += Z*0.01
Z = math.floor(Z)
res += 1
print(res)
|
s425934783
|
p03854
|
u576917603
| 2,000
| 262,144
|
Wrong Answer
| 94
| 3,188
| 309
|
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`.
|
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
for i in l:
if a[-7:]==i:
a=a[:-7]
elif a[-6:]==i:
a=a[:-6]
elif a[-5:]==i:
a=a[:-5]
else:
pass
if len(a)==0:
print("Yes")
else:
print("No")
|
s948393725
|
Accepted
| 91
| 3,188
| 309
|
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
for i in l:
if a[-7:]==i:
a=a[:-7]
elif a[-6:]==i:
a=a[:-6]
elif a[-5:]==i:
a=a[:-5]
else:
pass
if len(a)==0:
print("YES")
else:
print("NO")
|
s537688904
|
p03048
|
u452913314
| 2,000
| 1,048,576
|
Wrong Answer
| 2,104
| 3,060
| 209
|
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())
count = 0
for r in range(N):
for g in range(N):
b = (N - R*r - G*g) / B
if b >= 0 and b.is_integer():
count += 1
print(count, R, G, B, N)
|
s642033976
|
Accepted
| 1,712
| 3,064
| 261
|
R, G, B, N = map(int, input().split())
box = sorted([R,G,B],reverse=True)
count = 0
for x in range(0,N+1,box[0]):
for y in range(0,N+1 - x ,box[1]):
z = (N - x - y) / box[2]
if z >= 0 and z.is_integer():
count += 1
print(count)
|
s080206261
|
p03139
|
u340781749
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 3,316
| 70
|
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 = list(map(int, input().split()))
print(min(a, b), a + b - n)
|
s152392549
|
Accepted
| 17
| 2,940
| 78
|
n, a, b = list(map(int, input().split()))
print(min(a, b), max(0, a + b - n))
|
s284917344
|
p03597
|
u763249708
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,136
| 45
|
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black?
|
n = int(input())
a = int(input())
print(n-a)
|
s878205950
|
Accepted
| 27
| 9,156
| 48
|
n = int(input())
a = int(input())
print(n*n-a)
|
s061114636
|
p03455
|
u626000772
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 114
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import math
a, b = input().split()
c = int(a+b)
d = math.sqrt(c)
if d * d == c :
print("Yes")
else :
print("No")
|
s496869402
|
Accepted
| 18
| 2,940
| 124
|
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
if a*b % 2 == 0 :
print("Even")
else :
print("Odd")
|
s617656845
|
p03853
|
u281610856
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 193
|
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())
matrix = []
for i in range(H):
matrix.append(list(map(str, input().split())))
for j in range(H):
ans = ','.join(matrix[i])
print(ans)
print(ans)
|
s270826067
|
Accepted
| 17
| 3,060
| 193
|
H, W = map(int, input().split())
matrix = []
for i in range(H):
matrix.append(list(map(str, input().split())))
for j in range(H):
ans = ','.join(matrix[j])
print(ans)
print(ans)
|
s529779720
|
p03828
|
u832039789
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,064
| 494
|
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.
|
n = int(input())
sosu = []
primes = list(range(n+1))
primes[1] = 0
for i in range(2,int(n**.5)+1):
if primes[i]!=0:
for j in range(i*2,n+1,i):
primes[j] = 0
primes = [prime for prime in primes if prime!=0]
power = []
for prime in primes:
p = prime
tmp = 0
while p<=n:
tmp += n // p
p *= prime
power.append(tmp)
print(power)
res = 1
mod = 10**9+7
for i in power:
res *= i + 1
res %= mod
print(res)
|
s609961529
|
Accepted
| 17
| 3,188
| 495
|
n = int(input())
sosu = []
primes = list(range(n+1))
primes[1] = 0
for i in range(2,int(n**.5)+1):
if primes[i]!=0:
for j in range(i*2,n+1,i):
primes[j] = 0
primes = [prime for prime in primes if prime!=0]
power = []
for prime in primes:
p = prime
tmp = 0
while p<=n:
tmp += n // p
p *= prime
power.append(tmp)
#print(power)
res = 1
mod = 10**9+7
for i in power:
res *= i + 1
res %= mod
print(res)
|
s990661827
|
p03605
|
u374802266
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 71
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
a=input()
if a[0]==9 or a[1]==9:
print('Yes')
else:
print('No')
|
s739263806
|
Accepted
| 17
| 2,940
| 58
|
s=input()
print('Yes' if s[0]=='9' or s[1]=='9' else 'No')
|
s943881320
|
p03494
|
u940939306
| 2,000
| 262,144
|
Wrong Answer
| 19
| 2,940
| 172
|
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 = [int(x) for x in input().split()]
b = 0
while len(list(filter(lambda i : i % 2 != 0, list(a)))) == 0 :
a = list(map(lambda x: x/2, a))
b += 1
b
|
s448251714
|
Accepted
| 19
| 2,940
| 179
|
N = int(input())
a = [int(x) for x in input().split()]
b = 0
while len(list(filter(lambda i : i % 2 != 0, list(a)))) == 0 :
a = list(map(lambda x: x/2, a))
b += 1
print(b)
|
s452306924
|
p02842
|
u492511953
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 83
|
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
n = int(input())
f = int(n/1.08)
if (f+1)*1.08 != n:
print(':(')
else:
print(f)
|
s134228969
|
Accepted
| 17
| 2,940
| 163
|
n = int(input())
f = int(n/1.08)
if int(f*1.08) != n and int((f+1)*1.08) != n:
print(':(')
elif int(f*1.08) == n:
print(f)
else:
print(f+1)
|
s049359853
|
p03711
|
u151107315
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 215
|
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.
|
x,y = map(int,input().split())
li = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i, l in enumerate(li):
if x in l and y in l:
print("YES")
break
if i == len(li) - 1:
print("No")
|
s769564260
|
Accepted
| 17
| 2,940
| 215
|
x,y = map(int,input().split())
li = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i, l in enumerate(li):
if x in l and y in l:
print("Yes")
break
if i == len(li) - 1:
print("No")
|
s823990505
|
p02396
|
u500257793
| 1,000
| 131,072
|
Time Limit Exceeded
| 9,990
| 5,708
| 73
|
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.
|
x=int(input())
i=1
while not x==0:
print(f"Case {i}: {x}")
i=i+1
|
s114682041
|
Accepted
| 140
| 5,596
| 106
|
i = 0
while True:
x = int(input()); i += 1
if x == 0: break
print("Case {}: {}".format(i, x))
|
s703335460
|
p03860
|
u908349502
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 46
|
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.
|
a,b,c=input().split()
print('A'+b.upper()+'C')
|
s540997955
|
Accepted
| 17
| 2,940
| 50
|
a,b,c=input().split()
print('A'+b[0].upper()+'C')
|
s127738275
|
p03494
|
u830462928
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 213
|
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.
|
a = list(map(int, input().split()))
def calc(a):
return a /2
count = 0
for i in range(0, 99999999):
if sum(a) % 2 == 0:
count += 1
a = list(map(calc,a))
else:
break
print(count)
|
s357296802
|
Accepted
| 159
| 12,508
| 292
|
n = input()
a = list(map(int, input().split()))
import numpy as np
a = np.array(a)
count = 0
while (True):
exist_odd = False
for i in a:
if i % 2 != 0:
exist_odd = True
if exist_odd:
break
a = a / 2
count += 1
print(count)
|
s088409277
|
p03485
|
u564906058
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 64
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int,input().split())
x = (a+b)/2
print(int((x+9)//10))
|
s036906054
|
Accepted
| 17
| 2,940
| 57
|
a, b = map(int, input().split())
print((a + b + 1) // 2)
|
s057464988
|
p03997
|
u051237313
| 2,000
| 262,144
|
Wrong Answer
| 25
| 9,156
| 75
|
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)
|
s525498693
|
Accepted
| 25
| 9,116
| 72
|
a, b, h = [int(input()) for i in range(3)]
print(int((a + b) * h / 2))
|
s731045630
|
p03095
|
u896741788
| 2,000
| 1,048,576
|
Wrong Answer
| 41
| 4,648
| 148
|
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
from itertools import groupby as gb
n,s=open(0)
n=int(n)
s=sorted(s)
ans=1
mod=10**9+7
for i,x in gb(s):
ans=ans*(len(list(x))+1)%mod
print(ans-1)
|
s663044296
|
Accepted
| 41
| 4,648
| 155
|
from itertools import groupby as gb
n,s=open(0)
n=int(n)
s=sorted(s[:-1])
ans=1
mod=10**9+7
for i,x in gb(s):
ans=ans*(len(list(x))+1)%mod
print(ans-1)
|
s386292364
|
p03338
|
u513081876
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 157
|
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.
|
n = int(input())
ans = 0
for i in range(1, 33):
if n == i*i:
print(i*i)
break
elif n < i*i:
print((i-1)*(i-1))
break
|
s380145899
|
Accepted
| 18
| 2,940
| 127
|
N = int(input())
S = input()
ans = 0
for i in range(N - 1):
ans = max(ans, len(set(S[:i + 1]) & set(S[i + 1:])))
print(ans)
|
s592237867
|
p04030
|
u016323272
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 230
|
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?
|
#ABC043.B
s = input()
L = []
def kan(a):
if s =='0':
L.append('0')
elif s =='1':
L.append('1')
else:
if L !=[]:
L.pop()
for b in L:
kan(b)
c =''
for d in L:
c +=d
print(c)
|
s606521790
|
Accepted
| 17
| 2,940
| 230
|
#ABC043.B
s = input()
L = []
def kan(a):
if a =='0':
L.append('0')
elif a =='1':
L.append('1')
else:
if L !=[]:
L.pop()
for b in s:
kan(b)
c =''
for d in L:
c +=d
print(c)
|
s871256696
|
p03564
|
u749770850
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 117
|
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value: * Operation A: The displayed value is doubled. * Operation B: The displayed value increases by K. Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.
|
n = int(input())
k = int(input())
d = 1
for i in range(n):
print(d)
if d < k:
d = d*2
else:
d += k
print(d)
|
s682428378
|
Accepted
| 17
| 2,940
| 115
|
n = int(input())
k = int(input())
d = 1
for i in range(n):
if d + k <= d * 2:
d += k
else:
d *= 2
print(d)
|
s720508520
|
p03644
|
u299251530
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 52
|
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())
import math
print(int(math.sqrt(n)))
|
s947746733
|
Accepted
| 17
| 2,940
| 181
|
n=int(input())
result = 1
for i in range(n):
a = n-i
while a % 2 == 0:
a /= 2
if a == 1:
result = n-i
break
else:
continue
break
print(result)
|
s695322363
|
p03836
|
u281303342
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 296
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
# python3 (3.4.3)
import sys
input = sys.stdin.readline
# main
Sx,Sy,Tx,Ty = map(int,input().split())
dx = Tx - Sx
dy = Ty - Sy
ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dy
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dy+1) + "U"
print(ans1 + ans2 + ans3 + ans4)
|
s042775124
|
Accepted
| 18
| 3,060
| 567
|
# Python3 (3.4.3)
import sys
input = sys.stdin.readline
# -------------------------------------------------------------
# function
# -------------------------------------------------------------
# -------------------------------------------------------------
# main
# -------------------------------------------------------------
Sx,Sy,Tx,Ty = map(int,input().split())
dx = Tx - Sx
dy = Ty - Sy
ans1 = "U"*dy + "R"*dx
ans2 = "D"*dy + "L"*dx
ans3 = "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans4 = "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
print(ans1 + ans2 + ans3 + ans4)
|
s639465873
|
p03433
|
u292735000
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 89
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
n = int(input())
a = int(input())
if n % 500 + a > n:
print('Yes')
else:
print('No')
|
s330026180
|
Accepted
| 17
| 2,940
| 92
|
n = int(input())
a = int(input())
if n % 500 - a <= 0:
print('Yes')
else:
print('No')
|
s065860500
|
p02831
|
u917441099
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 192
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
Ar =list(map(int,input().split()))
if Ar[0]>=Ar[1]:
A=Ar[0]
B=Ar[1]
else:
A=Ar[1]
B=Ar[0]
print(A,B)
r=None
while r!=0:
r = (A%B)
A = B
B = r
Ans=int(Ar[0]*Ar[1]/A)
print(Ans)
|
s301766460
|
Accepted
| 18
| 3,060
| 181
|
Ar =list(map(int,input().split()))
if Ar[0]>=Ar[1]:
A=Ar[0]
B=Ar[1]
else:
A=Ar[1]
B=Ar[0]
r=None
while r!=0:
r = (A%B)
A = B
B = r
Ans=int(Ar[0]*Ar[1]/A)
print(Ans)
|
s275270045
|
p03493
|
u151281299
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 162
|
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.
|
n = int(input())
count = 0
if n % 100 == 1:
count += 1
n = n % 100
if n % 10 == 1:
count += 1
n = n % 10
if n == 1:
count += 1
print(count)
|
s882662658
|
Accepted
| 17
| 2,940
| 219
|
n = int(input())
count = 0
if int(n / 100) == 1:
count += 1
n = n % 100
else:
pass
if int(n / 10) == 1:
count += 1
n = n % 10
else:
pass
if n == 1:
count += 1
else:
pass
print(count)
|
s707430214
|
p02694
|
u508061226
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,288
| 86
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x = int(input());
ans = math.log(1.01, x / 100);
print(math.ceil(ans));
|
s860020526
|
Accepted
| 22
| 9,180
| 105
|
import math
x = int(input());
a = 100;
i = 0;
while a < x:
i += 1;
a += int(a * 0.01);
print(i)
|
s802769241
|
p02608
|
u048004795
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,024
| 1,035
|
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
# -*- coding: utf-8 -*-
import sys
import math
def main():
input = sys.stdin.readline
N = int(input())
result = 0
ok_flag = False
for n in range(N+1):
root_n = int(math.sqrt(n)) + 1
if n < 3:
print(0)
continue
for i in range(1,root_n):
for j in range(1,root_n):
for k in range(i,root_n):
if i*i + j*j + k*k + i*j + i*k + j*k == n:
if i == j and j == k:
result += 1
elif i == j or j == k or i == k:
result += 3
else:
result += 6
print(result)
result = 0
ok_flag = True
break
if ok_flag:
break
if ok_flag:
break
if not ok_flag:
print(0)
ok_flag = False
|
s470534031
|
Accepted
| 759
| 9,152
| 545
|
# -*- coding: utf-8 -*-
import sys
import math
def main():
input = sys.stdin.readline
N = int(input())
result = 0
ans_list = [0]*(N+1)
root_n =int(math.sqrt(N))+1
for i in range(1,root_n):
for j in range(1,root_n):
for k in range(1,root_n):
f = i**2+j**2+k**2+i*j+i*k+j*k
if f <= N:
ans_list[f] += 1
for i in range(1,N+1):
print(ans_list[i])
return
if __name__ == '__main__':
main()
|
s913148666
|
p02694
|
u310245677
| 2,000
| 1,048,576
|
Wrong Answer
| 24
| 9,160
| 100
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import math
x=int(input())
a=100
cnt=0
while a<x:
a*=1.01
cnt+=1
a=int(a)
print(a)
print(cnt)
|
s799810879
|
Accepted
| 23
| 9,172
| 91
|
import math
x=int(input())
a=100
cnt=0
while a<x:
a*=1.01
cnt+=1
a=int(a)
print(cnt)
|
s438929021
|
p02853
|
u326775883
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 287
|
We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen. DISCO-Kun took the X-th place in Coding Contest and the Y-th place in Robot Maneuver. Find the total amount of money he earned.
|
a = list(map(int, input().split()))
for i in range(len(a)):
if a[i] == 1:
a[i] = 300000
elif a[i] == 2:
a[i] = 200000
elif a[i] == 3:
a[i] = 100000
else:
a[i] = 0
if a[0] == 1 and a[1] == 1:
p = a[0] + a[1] + 400000
else:
p = a[0] + a[1]
print(p)
|
s779142523
|
Accepted
| 17
| 3,064
| 285
|
a = list(map(int, input().split()))
for i in range(len(a)):
if a[i] == 1:
a[i] = 300000
elif a[i] == 2:
a[i] = 200000
elif a[i] == 3:
a[i] = 100000
else:
a[i] = 0
if a[0] == 300000 and a[1] == 300000:
p = 1000000
else:
p = a[0] + a[1]
print(p)
|
s952411409
|
p04045
|
u131881594
| 2,000
| 262,144
|
Time Limit Exceeded
| 2,205
| 9,084
| 151
|
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())
d=set(map(int,input().split()))
i=n
while True:
if not set((str(i)))&d: i+=1
else:
print(i)
exit()
|
s732051246
|
Accepted
| 43
| 9,104
| 249
|
n,k=map(int,input().split())
d=set(map(int,input().split()))
i=n
while True:
temp=i
flag=1
while temp>0:
if temp%10 in d:
flag=0
break
temp//=10
if flag:
print(i)
break
i+=1
|
s287499384
|
p03545
|
u552192779
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 460
|
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.
|
abcd = input()
num = [int(i) for i in abcd]
def solve(i,a,seven,ans):
if i == 3:
if seven == 7:
return ans
else:
return False
if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))
print(solve(0,num,num[0],str(num[0])))
|
s234911699
|
Accepted
| 17
| 3,064
| 491
|
abcd = input()
num = [int(i) for i in abcd]
anslist = []
def solve(i,a,seven,ans):
if i == 3:
if seven == 7:
return ans+'=7'
else:
return False
if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))
print(solve(0,num,num[0],str(num[0])))
|
s744080020
|
p03997
|
u393512980
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 93
|
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.
|
l=[int(input()) for _ in range(3)]
print((l[0]+l[1])//2 * l[2])
|
s755152224
|
Accepted
| 17
| 2,940
| 65
|
l=[int(input()) for _ in range(3)]
print(int((l[0]+l[1])/2*l[2]))
|
s973602257
|
p03371
|
u480821607
| 2,000
| 262,144
|
Wrong Answer
| 30
| 3,060
| 142
|
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(20001):
ans = min(ans, i*c + (x - i//2)*a + (y - i//2)*b)
print(ans)
|
s871997698
|
Accepted
| 530
| 3,060
| 153
|
a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(500000):
ans = min(ans, i*c + max(0,x - i//2)*a + max(0,y - i//2)*b)
print(ans)
|
s766172788
|
p03352
|
u089142196
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 3,316
| 122
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
X=int(input())
ans=0
for i in range(100):
for j in range(20):
if i**j<=X:
ans=max(ans,i**j)
print(ans)
|
s684853294
|
Accepted
| 18
| 2,940
| 126
|
X=int(input())
ans=0
for i in range(1,100):
for j in range(2,20):
if i**j<=X:
ans=max(ans,i**j)
print(ans)
|
s978339671
|
p03625
|
u113971909
| 2,000
| 262,144
|
Wrong Answer
| 92
| 14,252
| 265
|
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 = list(map(int,input().split()))
#A.sort(reverse = True)
Al=list(set(A))
Al.sort(reverse = True)
HW = []
for i in Al:
n = A.count(i)
for j in range(min(n//2,2)):
HW.append(i)
if len(HW)>=2:
break
HW = HW + [0,0]
print(HW[0]*HW[1])
|
s444528520
|
Accepted
| 115
| 14,252
| 292
|
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)
HW = []
i = 1
while i<N:
if A[i]==A[i-1]:
n = A.count(A[i])
HW += [A[i]]*(min(n//2,2))
i = i + n -1
else:
i = i + 1
if len(HW)>=2:
break
if len(HW)<2:
print(0)
else:
print(HW[0]*HW[1])
|
s298374767
|
p02402
|
u565781955
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,668
| 82
|
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
input()
num = [int(i) for i in input().split()]
print (min(num),max(num),min(num))
|
s590096216
|
Accepted
| 40
| 8,668
| 82
|
input()
num = [int(i) for i in input().split()]
print (min(num),max(num),sum(num))
|
s742025997
|
p03852
|
u075155299
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 105
|
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`.
|
n=input()
for i in ["a","i","u","e","o"]:
if i in n:
print("vowel")
else:
print("consonant")
|
s557197754
|
Accepted
| 17
| 2,940
| 85
|
n=input()
if n in ["a","i","u","e","o"]:
print("vowel")
else:
print("consonant")
|
s579217435
|
p04002
|
u536113865
| 3,000
| 262,144
|
Wrong Answer
| 3,164
| 210,068
| 488
|
We have a grid with H rows and W columns. At first, all cells were painted white. Snuke painted N of these cells. The i-th ( 1 \leq i \leq N ) cell he painted is the cell at the a_i-th row and b_i-th column. Compute the following: * For each integer j ( 0 \leq j \leq 9 ), how many subrectangles of size 3×3 of the grid contains exactly j black cells, after Snuke painted N cells?
|
ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))
h,w,n = ai()
bl = [ai_() for _ in range(n)]
from collections import defaultdict
d = defaultdict(int)
from itertools import product
for a,b in bl:
for da,db in product((-1,0,1), repeat=2):
print(a+da,b+db)
if 0 < a+da < h-1 and 0 < b+db < w-1:
d[(a+da, b+db)] += 1
print((h-2)*(w-2) - len(d))
l = list(d.values())
for i in range(1, 10):
print(l.count(i))
|
s900992403
|
Accepted
| 1,732
| 191,972
| 478
|
ai_ = lambda: [int(x)-1 for x in input().split()]
ai = lambda: list(map(int, input().split()))
h,w,n = ai()
bl = [ai_() for _ in range(n)]
from collections import defaultdict
d = defaultdict(int)
from itertools import product
l = list(product((-1,0,1), repeat=2))
for a,b in bl:
for da,db in l:
if 0 < a+da < h-1 and 0 < b+db < w-1:
d[(a+da, b+db)] += 1
print((h-2)*(w-2) - len(d))
ll = list(d.values())
for i in range(1, 10):
print(ll.count(i))
|
s147305837
|
p02394
|
u648470099
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,600
| 379
|
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())
x_max=int(x+r)
x_min=int(x-r)
y_max=int(y+r)
y_min=int(y-r)
print(x_max,x_min,y_max,y_min)
if y_max >= w:
print("No")
else:
if y_min <= 0:
print("No")
else:
if x_max >= h:
print("No")
else:
if x_min <= 0:
print("No")
else:
print("Yes")
|
s103022466
|
Accepted
| 50
| 7,684
| 376
|
w,h,x,y,r=map(int, input().split())
x_max=int(x+r)
x_min=int(x-r)
y_max=int(y+r)
y_min=int(y-r)
#print(x_max,x_min,y_max,y_min)
if y_max > h:
print("No")
else:
if y_min < 0:
print("No")
else:
if x_max > w:
print("No")
else:
if x_min < 0:
print("No")
else:
print("Yes")
|
s469654963
|
p03854
|
u342042786
| 2,000
| 262,144
|
Wrong Answer
| 56
| 3,188
| 459
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
S = input()
S = S[::-1]
divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
divide[i] = divide[i][::-1]
length1 = 0
length2 = 0
can = 0
flag = True
while flag:
length1 = length2
for i in range(4):
if S[length1:length1+len(divide[i])] == divide[i]:
length2 = length1 + len(divide[i])
if length1 == length2:
flag = False
if len(S) == length2:
print("YES")
else:
print("NO")
print(length2)
|
s286866643
|
Accepted
| 54
| 3,188
| 449
|
S = input()
S = S[::-1]
divide = ["dream", "dreamer", "erase", "eraser"]
for i in range(4):
divide[i] = divide[i][::-1]
length1 = 0
length2 = 0
can = 0
flag = True
while flag:
length1 = length2
for i in range(4):
if S[length1:length1+len(divide[i])] == divide[i]:
length2 = length1 + len(divide[i])
if length1 == length2:
flag = False
if len(S) == length2:
print("YES")
else:
print("NO")
|
s523475897
|
p02393
|
u335511832
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,392
| 114
|
Write a program which reads three integers, and prints them in ascending order.
|
a = [i for i in input().split()]
b = []
for i in range(len(a)):
b = a.pop(a.index(min(a)))
print(" ".join(b))
|
s124097144
|
Accepted
| 20
| 7,492
| 139
|
a = [i for i in input().split()]
b = []
for i in range(len(a)):
b.append(a.pop(a.index(min(a))))
print(" ".join([str(i) for i in b]))
|
s101674860
|
p04029
|
u844123804
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 39
|
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?
|
num = int(input())
print((1+num)*num/2)
|
s394779938
|
Accepted
| 17
| 2,940
| 40
|
num = int(input())
print((1+num)*num//2)
|
s359935455
|
p03493
|
u786229198
| 2,000
| 262,144
|
Wrong Answer
| 24
| 8,956
| 24
|
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.
|
X = input()
X.count('1')
|
s894555396
|
Accepted
| 26
| 9,016
| 31
|
X = input()
print(X.count('1'))
|
s609570019
|
p03547
|
u205561862
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 28
|
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
print(max(input().split()))
|
s551445443
|
Accepted
| 17
| 2,940
| 95
|
X,Y = map(str,input().split())
if(X > Y):print(">")
if(X is Y):print("=")
if(X < Y):print("<")
|
s553421203
|
p03611
|
u521271655
| 2,000
| 262,144
|
Wrong Answer
| 87
| 20,804
| 167
|
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≤i≤N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.
|
n = int(input())
num = list(map(int,input().split()))
lis = [0]*(max(num)+2)
for i in num:
lis[i-1] +=1
lis[i] +=1
lis[i+1] +=1
print(lis)
print(max(lis))
|
s910081327
|
Accepted
| 82
| 20,816
| 238
|
n = int(input())
num = list(map(int,input().split()))
lis = [0]*(max(num)+4)
for i in num:
if i == 0:
lis[i] +=1
lis[i+1] +=1
else:
lis[i-1] +=1
lis[i] +=1
lis[i+1] +=1
print(max(lis))
|
s967631304
|
p02578
|
u414980766
| 2,000
| 1,048,576
|
Wrong Answer
| 144
| 32,244
| 139
|
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())
a=list(map(int, input().split()))
ans=0
for i in range(1, n):
s=a[i] - a[i-1]
if s<0:
ans-=s
a[i]-=s
|
s617538226
|
Accepted
| 139
| 32,380
| 150
|
n=int(input())
a=list(map(int, input().split()))
ans=0
for i in range(1, n):
s=a[i] - a[i-1]
if s<0:
ans-=s
a[i]-=s
print(ans)
|
s584186669
|
p02846
|
u375076148
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 532
|
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.
|
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
print('infinity')
else:
if A[0]*T[0]+A[1]*T[1] < B[0]*T[0]+B[1]*T[1]:
C = A
A = B
B = C
if A[0] > B[0]:
print('0')
else:
bcover = (B[0]-A[0])*T[0]
tcover = A[0]*T[0]+A[1]*T[1] - B[0]*T[0]-B[1]*T[1]
print(A,B,bcover,tcover, bcover/tcover)
if bcover%tcover == 0:
print(int(bcover/tcover)*2)
else:
print(int(bcover/tcover)*2+1)
|
s426016444
|
Accepted
| 17
| 3,064
| 488
|
T = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0]*T[0]+A[1]*T[1] == B[0]*T[0]+B[1]*T[1]:
print('infinity')
else:
if A[0]*T[0]+A[1]*T[1] < B[0]*T[0]+B[1]*T[1]:
C = A
A = B
B = C
if A[0] > B[0]:
print('0')
else:
bcover = (B[0]-A[0])*T[0]
tcover = A[0]*T[0]+A[1]*T[1] - B[0]*T[0]-B[1]*T[1]
if bcover%tcover == 0:
print(int(bcover/tcover)*2)
else:
print(int(bcover/tcover)*2+1)
|
s380948860
|
p02612
|
u919235786
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 9,084
| 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)
|
s139758268
|
Accepted
| 30
| 9,152
| 78
|
n=int(input())
ans=1000-n%1000
if ans==1000:
print(0)
else:
print(ans)
|
s979483628
|
p00007
|
u403901064
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,624
| 204
|
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
week = int(input())
base = 100000
x = 1
for i in range(week):
x = round(x * 1.05 + 0.004 ,2)
print(x)
if __name__ == '__main__':
main()
|
s391453178
|
Accepted
| 20
| 7,680
| 246
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def main():
week = int(input())
base = 100000
x = base
for i in range(week):
x = round(x * 1.05)
if x % 1000 > 0:
x = (x // 1000) *1000 +1000
print(x)
if __name__ == '__main__':
main()
|
s429929886
|
p03643
|
u133038626
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 13
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
"ABC"+input()
|
s881624034
|
Accepted
| 17
| 3,068
| 20
|
print("ABC"+input())
|
s443277319
|
p04044
|
u310381103
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,160
| 85
|
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=list(map(str,input().split()))
s=sorted(s)
print(s[0])
|
s672321583
|
Accepted
| 28
| 9,108
| 128
|
n,l=map(int,input().split())
s=[]
ss=''
for i in range(n):
s.append(input())
s=sorted(s)
for i in range(n):
ss+=s[i]
print(ss)
|
s529304400
|
p03408
|
u589967459
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 565
|
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.
|
from sys import stdin
num_blue = stdin.readline().rstrip()
word_blue = []
for i in range(int(num_blue)) :
word_blue.append(stdin.readline().rstrip())
print(word_blue)
num_red = stdin.readline().rstrip()
word_red = []
for i in range(int(num_red)) :
word_red.append(stdin.readline().rstrip())
print(word_red)
counter_max = 0
for i in range(int(num_blue)):
counter = word_blue.count(word_blue[i]) - word_red.count(word_blue[i])
if counter > counter_max:
counter_max = counter
if counter < 0 :
counter = 0
print(counter)
|
s170921173
|
Accepted
| 17
| 3,064
| 490
|
from sys import stdin
num_blue = stdin.readline().rstrip()
word_blue = []
for i in range(int(num_blue)) :
word_blue.append(stdin.readline().rstrip())
num_red = stdin.readline().rstrip()
word_red = []
for i in range(int(num_red)) :
word_red.append(stdin.readline().rstrip())
counter_max = 0
for i in range(int(num_blue)):
counter = word_blue.count(word_blue[i]) - word_red.count(word_blue[i])
if counter > counter_max:
counter_max = counter
print(counter_max)
|
s685125951
|
p03251
|
u407016024
| 2,000
| 1,048,576
|
Wrong Answer
| 20
| 3,060
| 197
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x) < min(y):
print('No war')
else:
print('War')
|
s130394591
|
Accepted
| 17
| 3,060
| 197
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
if max(x) < min(y):
print('No War')
else:
print('War')
|
s198348027
|
p02612
|
u017415492
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 9,092
| 72
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n=int(input())
if n%1000==0:
print(n//1000)
else:
print((n//1000)+1)
|
s026656609
|
Accepted
| 28
| 9,148
| 75
|
n=int(input())
if n%1000==0:
print(0)
else:
print(1000*((n//1000)+1)-n)
|
s193167262
|
p03400
|
u503111914
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 152
|
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp.
|
N = int(input())
D,X = map(int,input().split())
result = X
for i in range(N):
A = int(input())
for j in range(1,D,A):
result += 1
print(result)
|
s969870654
|
Accepted
| 18
| 2,940
| 155
|
N = int(input())
D,X = map(int,input().split())
result = X
for i in range(N):
A = int(input())
for j in range(1,D+1,A):
result += 1
print(result)
|
s063130721
|
p03131
|
u346308892
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 202
|
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
def input_space():
return list(map(int,input().split(" ")))
K,A,B=input_space()
if B-A<=2:
res=K+1
else:
c=B/A
k=c-1
t=(K-A+1)//2
mod=(K-A+1)%2
res=A+t*k*A+mod
print(res)
|
s428934040
|
Accepted
| 18
| 3,060
| 270
|
def input_space():
return list(map(int,input().split(" ")))
K,A,B=input_space()
if B-A<=2:
res=K+1
else:
c=B-A
k=c-1
t=max(0,(K-A+1)//2)
mod=(K-A+1)%2
res=A+t*c+mod
print(res)
|
s042063993
|
p02371
|
u022407960
| 1,000
| 131,072
|
Wrong Answer
| 30
| 8,096
| 1,620
|
Given a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
4
0 1 2
1 2 1
1 3 3
output:
5
"""
import sys
from collections import deque
from math import isinf
def generate_adj_table(v_table):
for each in v_table:
v_from, v_to, edge_weight = map(int, each)
init_adj_table[v_from][v_to] = edge_weight
init_adj_table[v_to][v_from] = edge_weight
return init_adj_table
def graph_bfs(v_init):
global distance
distance = [float('inf')] * vertices
distance[v_init] = 0
queue.appendleft(v_init)
while queue:
current = queue.popleft()
adj_weight = adj_table[current]
for adj in adj_weight.keys():
if isinf(distance[adj]):
distance[adj] = distance[current] + adj_weight[adj]
queue.append(adj)
return None
def solve():
graph_bfs(init_v)
diameter, bridge_v = 0, 0
for v in range(vertices):
if isinf(distance[v]):
continue
if diameter < distance[v]:
diameter = distance[v]
bridge_v = v
break
graph_bfs(bridge_v)
diameter = 0
for v in range(vertices):
if isinf(distance[v]):
continue
diameter = max(diameter, distance[v])
return diameter
if __name__ == '__main__':
_input = sys.stdin.readlines()
vertices = int(_input[0])
v_info = map(lambda x: x.split(), _input[1:])
queue = deque()
distance = [float('inf')] * vertices
init_adj_table = tuple(dict() for _ in range(vertices))
adj_table = generate_adj_table(v_info)
init_v = 0
print(solve())
|
s400870552
|
Accepted
| 480
| 63,092
| 1,714
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
4
0 1 2
1 2 1
1 3 3
output:
5
"""
import sys
from math import isinf
from collections import deque
def generate_adj_table(v_table, init_adj_table):
for each in v_table:
source, target, cost = map(int, each)
init_adj_table[source][target] = cost
init_adj_table[target][source] = cost
return init_adj_table
def graph_bfs(current, v_num, adj_table):
queue = deque()
distance = [float('inf')] * v_num
distance[current] = 0
queue.appendleft(current)
while queue:
current = queue.popleft()
for adj, cost in adj_table[current].items():
if isinf(distance[adj]):
distance[adj] = distance[current] + cost
queue.append(adj)
return distance
def calc_tree_diameter(v_num, adj_table):
init_v = 0
distance_1 = graph_bfs(init_v, v_num, adj_table)
d1, bridge_v = 0, 0
for v, each in enumerate(distance_1):
if isinf(each):
continue
elif d1 < each:
d1 = each
bridge_v = v
distance_2 = graph_bfs(bridge_v, v_num, adj_table)
d2 = 0
for each in distance_2:
if isinf(each):
continue
d2 = max(d2, each)
return d2
def solve():
_input = sys.stdin.readlines()
v_num = int(_input[0])
edges = map(lambda x: x.split(), _input[1:])
init_adj_table = tuple(dict() for _ in range(v_num))
adj_table = generate_adj_table(edges, init_adj_table)
ans = calc_tree_diameter(v_num, adj_table)
print(ans)
return None
if __name__ == '__main__':
solve()
|
s819954975
|
p03447
|
u479060428
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 97
|
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?
|
N=int(input())
A=int(input())
a=int(N/500)
if N-a*500<=A:
print("Yes")
else :
print("No")
|
s108006461
|
Accepted
| 17
| 2,940
| 74
|
X=int(input())
A=int(input())
B=int(input())
a=X-A
b=int(a/B)
print(a-b*B)
|
s377861350
|
p02271
|
u564464686
| 5,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 445
|
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_.
|
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
B[i]=int(B[i])
c=0
for j in range(n-1):
for k in range(j+1,n):
sum=A[j]+A[k]
if sum==B[i] and c==0:
c+=1
C.append("yes")
if c==0:
C.append("no")
for i in range(q):
print(C[i])
|
s183751270
|
Accepted
| 6,230
| 43,100
| 509
|
import itertools
n=int(input())
A=[0 for i in range(n)]
A=input().split()
for i in range(n):
A[i]=int(A[i])
q=int(input())
B=[0 for i in range(q)]
B=input().split()
C=[]
for i in range(q):
B[i]=int(B[i])
l=[0,1]
p=[]
k=0
D=[]
for v in itertools.product(l,repeat=n):
sum=0
for i in range(n):
if v[i]==1:
sum=sum+A[i]
D.append(sum)
k+=1
for i in range(q):
if B[i] in D:
C.append("yes")
else:
C.append("no")
for i in range(q):
print(C[i])
|
s226091548
|
p02258
|
u901205536
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,592
| 212
|
You can obtain profits from foreign exchange margin transactions. For example, if you buy 1000 dollar at a rate of 100 yen per dollar, and sell them at a rate of 108 yen per dollar, you can obtain (108 - 100) × 1000 = 8000 yen. Write a program which reads values of a currency $R_t$ at a certain time $t$ ($t = 0, 1, 2, ... n-1$), and reports the maximum value of $R_j - R_i$ where $j > i$ .
|
n = int(input())
max_profit = -1000000000
min_value = 1000000000
for i in range(n):
num = int(input())
max_profit = max(max_profit, num-min_value)
min_value = min(i, min_value)
print(max_profit)
|
s582941779
|
Accepted
| 580
| 5,616
| 226
|
n = int(input())
ns = []
max_profit = -1000000000
min_value = int(input())
for i in range(1,n):
num = int(input())
max_profit = max(max_profit, num-min_value)
min_value = min(num, min_value)
print(max_profit)
|
s498486167
|
p02936
|
u367130284
| 2,000
| 1,048,576
|
Wrong Answer
| 2,118
| 247,420
| 1,168
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
from collections import*
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import*
from heapq import*
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
n,q=map(int,input().split())
d=defaultdict(list)
parent=defaultdict(int)
for i in range(n-1):
a,b=map(int,input().split())
d[a].append(b)
def DFS(point,d,s):
for i in d[point]:
if len(d[i])==0:
parent[i]+=s
else:
parent[i]+=s
DFS(i,d,s)
ans=0
for i in range(q):
a,b=map(int,input().split())
if a==1:
parent[a]+=b
DFS(a,d,b)
print(*[v for k,v in sorted(parent.items())])
|
s661436884
|
Accepted
| 1,722
| 282,448
| 769
|
from collections import*
import sys
sys.setrecursionlimit(10**8)
input=sys.stdin.readline
def main():
n,q=map(int,input().split())
d=defaultdict(list)
cost=[0]*(n+10)
TF=[1]+[0]*(n-1)
for i in range(n-1):
a,b=map(int,input().split())
d[a].append(b)
d[b].append(a)
for i in range(q):
a,b=map(int,input().split())
cost[a]+=b
def dfs(cost,point):
if len(d[point])==0:
return 0
for i in d[point]:
if TF[i-1]:
continue
TF[i-1]=1
cost[i]+=cost[point]
dfs(cost,i)
TF[i-1]=0
dfs(cost,1)
print(*cost[1:n+1])
if __name__ == '__main__':
main()
|
s950916277
|
p03433
|
u812137330
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 91
|
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N = int(input())
A = int(input())
if N % 500 <= A:
print("YES")
else:
print("NO")
|
s899426603
|
Accepted
| 17
| 2,940
| 91
|
N = int(input())
A = int(input())
if N % 500 <= A:
print("Yes")
else:
print("No")
|
s062820776
|
p03095
|
u720636500
| 2,000
| 1,048,576
|
Wrong Answer
| 60
| 3,956
| 127
|
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
|
N = int(input())
S = input()
lis = list(S)
k = 1
se = set(lis)
for item in se:
l = lis.count(item)
k = k*(l + 1)
print(k)
|
s597643985
|
Accepted
| 60
| 3,956
| 145
|
N = int(input())
S = input()
lis = list(S)
k = 1
se = set(lis)
for item in se:
l = lis.count(item)
k = k*(l + 1)
print((k - 1)%(10**9 + 7))
|
s527242848
|
p03455
|
u542739769
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
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")
|
s498939015
|
Accepted
| 17
| 2,940
| 92
|
a, b = map(int, input().split())
if (a*b) % 2 == 0:
print("Even")
else:
print("Odd")
|
s050934835
|
p03565
|
u957084285
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 655
|
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
|
s = list(input())
t = list(input())
ans = []
for i in range(len(s)-len(t)+1):
if s[i] == '?' or s[i] == t[0]:
ok = True
j = 1
while j < len(t) and ok:
if s[i+j] == '?' or s[i+j] == t[j]:
j += 1
continue
else:
ok = False
if ok:
f = [x for x in s]
print(f, t)
for j in range(len(t)):
f[i+j] = t[j]
f = "".join(f)
f.replace('?', 'a')
ans.append(f)
if s[i] == '?':
s[i] = 'a'
if ans:
print(sorted(ans)[0])
else:
print("UNRESTORABLE")
|
s053882571
|
Accepted
| 18
| 3,064
| 695
|
s = list(input())
t = list(input())
ans = []
for i in range(len(s)-len(t)+1):
if s[i] == '?' or s[i] == t[0]:
ok = True
j = 1
while j < len(t) and ok:
if s[i+j] == '?' or s[i+j] == t[j]:
j += 1
continue
else:
ok = False
if ok:
f = [x for x in s]
for j in range(len(t)):
f[i+j] = t[j]
for j in range(i+1,len(s)):
if f[j] == '?':
f[j] = 'a'
f = "".join(f)
ans.append(f)
if s[i] == '?':
s[i] = 'a'
if ans:
print(sorted(ans)[0])
else:
print("UNRESTORABLE")
|
s678281638
|
p03433
|
u197078193
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 88
|
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())
r = N%500
if r > A:
print('Yes')
else:
print('No')
|
s478532499
|
Accepted
| 17
| 2,940
| 88
|
N = int(input())
A = int(input())
r = N%500
if r > A:
print('No')
else:
print('Yes')
|
s103988757
|
p03434
|
u252964975
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 170
|
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
total = total + A_list[i*2]
print(total)
|
s785377851
|
Accepted
| 19
| 3,060
| 190
|
N=int(input())
A_list=list(map(int, input().split()))
A_list = sorted(A_list, reverse=True)
total = 0
for i in range((N+1)//2):
total = total + A_list[i*2]
print(total-(sum(A_list)-total))
|
s355912081
|
p03471
|
u207363774
| 2,000
| 262,144
|
Wrong Answer
| 2,103
| 3,064
| 494
|
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,Q = (map(int,input().split()))
for a in range(N+1):
A = a*10000
if A > Q:
continue
if A == Q:
print("{0},0,0".format(a))
exit()
for b in range(a,N-a+1):
B = A+b*5000
if B > Q:
continue
if B == Q:
print("{0},{1},0".format(a,b))
exit()
for c in range(a+b,N-a-b+1):
if B+c*1000 == Q:
print("{0},{1},{2}".format(a,b,c))
exit()
print("-1,-1,-1")
|
s719767098
|
Accepted
| 1,308
| 3,064
| 515
|
N,Q = (map(int,input().split()))
for a in range(N,-1,-1):
A = a*10000
if A > Q:
continue
if (a==N)and(A == Q):
print("{0} 0 0".format(a))
exit()
for b in range(N-a,-1,-1):
B = A+b*5000
if B > Q:
continue
if (a+b==N)and(B == Q):
print("{0} {1} 0".format(a,b))
exit()
if ((Q-B)%1000==0)and((Q-B)/1000==(N-a-b)):
print("{0} {1} {2}".format(a,b,int((Q-B)/1000)))
exit()
print("-1 -1 -1")
|
s791398972
|
p03836
|
u735069283
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,064
| 635
|
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
a,b,c,d = map(int,input().split())
r=str()
if c-a>0:
r += 'R'*(c-a)
else:
r +='L'*(a-c)
if d-b>0:
r += 'U'*(d-b)
else:
r += 'D'(b-d)
for i in range(len(r)):
if r[i]=='R':
r +='L'
if r[i]=='L':
r +='R'
if r[i]=='U':
r +='D'
if r[i]=='D':
r +='U'
t=len(r)
if d-b>0:
r += 'D'
else:
r += 'U'
if c-a>0:
r += 'R'*(c-a+1)
else:
r +='L'*(a-c+1)
if d-b>0:
r += 'U'*(d-b+1)
else:
r += 'D'(b-d+1)
if c-a>0:
r += 'L'
else:
r +='R'
for i in range(t+1,len(r)):
if r[i]=='R':
r +='L'
if r[i]=='L':
r +='R'
if r[i]=='U':
r +='D'
if r[i]=='D':
r +='U'
print(r)
|
s009286838
|
Accepted
| 18
| 3,060
| 174
|
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
R1='U'*dy+'R'*dx
R2='D'*dy+'L'*dx
R3='L'+'U'*(dy+1)+'R'*(dx+1)+'D'
R4='R'+'D'*(dy+1)+'L'*(dx+1)+'U'
print(R1+R2+R3+R4)
|
s288372704
|
p02936
|
u877415670
| 2,000
| 1,048,576
|
Wrong Answer
| 2,102
| 91,156
| 326
|
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
|
N, Q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(N-1)]
px = [[int(i) for i in input().split()] for i in range(Q)]
ab.sort()
weight = [0]*N
for i in range(len(px)):
weight[px[i][0]-1]+=px[i][1]
for g in range(len(ab)):
weight[ab[g][1]-1] += weight[ab[g][0]-1]
print(weight)
|
s697971990
|
Accepted
| 1,864
| 88,692
| 327
|
N, Q = (int(i) for i in input().split())
ab = [[int(i) for i in input().split()] for i in range(N-1)]
px = [[int(i) for i in input().split()] for i in range(Q)]
ab.sort()
weight = [0]*N
for i in range(len(px)):
weight[px[i][0]-1]+=px[i][1]
for g in range(len(ab)):
weight[ab[g][1]-1] += weight[ab[g][0]-1]
print(*weight)
|
s443826353
|
p03377
|
u413888809
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,c=map(int,input().split())
print(["NO","YES"][c-a<0 or c-a>b])
|
s796032946
|
Accepted
| 17
| 2,940
| 66
|
a,b,c=map(int,input().split())
print(["YES","NO"][c-a<0 or c-a>b])
|
s873303938
|
p02401
|
u126478680
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,612
| 301
|
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.
|
#! python3
# simple_calculator.py
operations = {'+': lambda a, b: a+b,
'-': lambda a, b: a-b,
'*': lambda a, b: a*b,
'/': lambda a, b: a/b}
while True:
a, op, b = input().split(' ')
if op == '?': break
print(operations[op](int(a), int(b)))
|
s654011285
|
Accepted
| 20
| 5,600
| 305
|
#! python3
# simple_calculator.py
operations = {'+': lambda a, b: a+b,
'-': lambda a, b: a-b,
'*': lambda a, b: a*b,
'/': lambda a, b: int(a/b)}
while True:
a, op, b = input().split(' ')
if op == '?': break
print(operations[op](int(a), int(b)))
|
s556790901
|
p03388
|
u504836877
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 409
|
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
Q = int(input())
L = []
for i in range(Q):
L.append([int(x) for x in input().split()])
for i in range(Q):
a = min(L[i])
b = max(L[i])
if a == b:
ans = 2*a-2
elif a+1 == b:
ans = 2*a-1
else:
c = int((a*b)**0.5)
if c**2 == a*b:
c -= 1
if c*(c+1) >= a*b:
ans = 2*c-2
else:
ans = 2*c-1
print(ans)
|
s772309448
|
Accepted
| 18
| 3,064
| 409
|
Q = int(input())
L = []
for i in range(Q):
L.append([int(x) for x in input().split()])
for i in range(Q):
a = min(L[i])
b = max(L[i])
if a == b:
ans = 2*a-2
elif a+1 == b:
ans = 2*a-2
else:
c = int((a*b)**0.5)
if c**2 == a*b:
c -= 1
if c*(c+1) >= a*b:
ans = 2*c-2
else:
ans = 2*c-1
print(ans)
|
s385870881
|
p02694
|
u003034853
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 9,164
| 102
|
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?
|
count = 0
x = int(input())
bal = 100
while bal<=x:
count+=1
bal = int(bal*(1.01))
print(count)
|
s356456889
|
Accepted
| 23
| 9,168
| 101
|
count = 0
x = int(input())
bal = 100
while bal<x:
count+=1
bal = int(bal*(1.01))
print(count)
|
s664740497
|
p03494
|
u281610856
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 151
|
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())
l = [int(_) for _ in input().split()]
for i in l:
count = 0
while i % 2 == 0:
i //= 2
count += 1
print(count)
|
s005285825
|
Accepted
| 18
| 3,060
| 197
|
ans = 10**9
n = int(input())
l = list(map(int,input().split()))
for i in l:
count = 0
while i % 2 == 0:
i //= 2
count += 1
if count < ans:
ans = count
print(ans)
|
s822187385
|
p03545
|
u597374218
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 271
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
for j in range(digits):
if (i>>j)&1:
op[j]="+"
else:
op[j]="-"
if eval(A+op[0]+B+op[1]+C+op[2]+D)==7:
print(A+op[0]+B+op[1]+C+op[2]+D)
break
|
s911667055
|
Accepted
| 17
| 3,060
| 308
|
ABCD=input()
digits=3
ops=[""]*(digits+1)
for i in range(1<<digits):
for j in range(digits):
if (i>>j)&1:
ops[j]="+"
else:
ops[j]="-"
evals=""
for num,op in zip(ABCD,ops):
evals+=num+op
if eval(evals)==7:
print(evals+"=7")
break
|
s478086986
|
p02401
|
u216425054
| 1,000
| 131,072
|
Time Limit Exceeded
| 40,000
| 8,296
| 244
|
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.
|
[a,op,b]=[x for x in input().split()]
a=int(a)
b=int(b)
while True:
if a==0 and b==0:
break
elif op=="+":
print(a+b)
elif op=="-":
print(a-b)
elif op=="*":
print(a*b)
else:
print(a//b)
|
s515984213
|
Accepted
| 20
| 7,652
| 258
|
while True:
[a,b,c]=[x for x in input().split()]
[a,c]=[int(a),int(c)]
op=b
if op=="?":
break
elif op=="+":
print(a+c)
elif op=="-":
print(a-c)
elif op=="*":
print(a*c)
else:
print(a//c)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.