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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s484167437 | p03048 | u914330401 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 13,512 | 262 | 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... | r, g, b, n = map(int, input().split())
ans = 0
for i in range(n+1):
for j in range(n+1):
k = (n - (i*r+j*g))/b
#for k in range(n+1):
if k < 0:
continue
if i*r+j*g+k*b == n and k.is_integer():
ans += 1
print(i, j, k)
print(ans) | s724642762 | Accepted | 1,526 | 2,940 | 164 | R, G, B, N = map(int, input().split())
ans = 0
for i in range(N//R+1):
for j in range((N-R*i)//G+1):
if (N - R*i - G*j) % B == 0:
ans += 1
print(ans) |
s477351715 | p02412 | u941509088 | 1,000 | 131,072 | Wrong Answer | 20 | 7,548 | 261 | Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9 | while True:
n, x = map(int, input().split())
if n == x == 0:
break
count = 0
for i in range(1,n):
for j in range(1,n):
for k in range(1,n):
if i+j+k ==x:
count += 1
print(count) | s042681358 | Accepted | 2,890 | 7,676 | 308 | while True:
n, x = map(int, input().split())
if n == x == 0:
break
count = 0
for i in range(1,n+1):
for j in range(1,n+1):
for k in range(1,n+1):
if (i < j < k):
if i+j+k == x:
count += 1
print(count) |
s916492624 | p03659 | u686036872 | 2,000 | 262,144 | Wrong Answer | 213 | 24,812 | 208 | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let th... | N = int(input())
A = list(map(int, input().split()))
a = sum(A)
B=[0]*N
B[0] = A[0]
saitei = float("inf")
for i in range(1, N):
B[i] += B[i-1]
saitei = min(abs(B[i]-(a-B[i])), saitei)
print(saitei) | s027048671 | Accepted | 241 | 24,832 | 222 | N = int(input())
A = list(map(int, input().split()))
a = sum(A)
B=[0]*N
B[0] = A[0]
saitei = float("inf")
for i in range(N-1):
saitei = min(abs(B[i]-(a-B[i])), saitei)
B[i+1] += (A[i+1] + B[i])
print(saitei) |
s722241766 | p03474 | u030090262 | 2,000 | 262,144 | Wrong Answer | 17 | 3,068 | 126 | 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=list(map(int,input().split()))
S=input()
print(a[0])
if S.count("-") ==1 and S[a[0]]=="-":
print("Yes")
else:
print("No")
| s655801270 | Accepted | 17 | 2,940 | 114 | a=list(map(int,input().split()))
S=input()
if S.count("-") ==1 and S[a[0]]=="-":
print("Yes")
else:
print("No")
|
s394130011 | p04043 | u089376182 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 84 | 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 ... | abc = list(input())
print('YES' if abc.count('5')==2 & abc.count('7')==1 else 'NO')
| s804171877 | Accepted | 17 | 2,940 | 97 | abc = input().replace(' ', '')
print('YES' if abc.count('7')==1 and abc.count('5')==2 else 'NO') |
s685697756 | p03575 | u575431498 | 2,000 | 262,144 | Wrong Answer | 22 | 3,064 | 1,237 | You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a _bridge_. Find the number of the edges that are bridges among the M ... | class UnionFind(object):
def __init__(self, n=1):
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.par[x]
d... | s568294714 | Accepted | 23 | 3,064 | 1,069 | class UnionFind(object):
def __init__(self, n):
self.par = [i for i in range(n)]
self.rank = [0 for _ in range(n)]
self._size = n
def find(self, x):
if self.par[x] == x:
return x
else:
self.par[x] = self.find(self.par[x])
return self.p... |
s679248795 | p02843 | u605086727 | 2,000 | 1,048,576 | Wrong Answer | 73 | 9,840 | 350 | AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi want... | X = int(input())
price = [100, 101, 102, 103, 104, 105]
dp = [False for _ in range(X + 1)]
dp[0] = True
for i in range(1, X + 1):
for j in range(6):
if i - price[j] >= 0:
if dp[i - price[j]]:
dp[i] = True
break
else:
dp[i] = False
if dp[X]:
prin... | s689695967 | Accepted | 78 | 9,776 | 343 | X = int(input())
price = [100, 101, 102, 103, 104, 105]
dp = [False for _ in range(X + 1)]
dp[0] = True
for i in range(1, X + 1):
for j in range(6):
if i - price[j] >= 0:
if dp[i - price[j]]:
dp[i] = True
break
else:
dp[i] = False
if dp[X]:
prin... |
s453817557 | p03023 | u333404917 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 30 | Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units. | N = int(input())
print(N-1*90) | s007139151 | Accepted | 18 | 2,940 | 33 | N = int(input())
print((N-2)*180) |
s223176300 | p03644 | u677320550 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 88 | 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... | a=int(input())
if 1==a:
print(a)
else:
while 0!=a%2:
a=a-1
print(a)
| s020552563 | Accepted | 17 | 2,940 | 158 | a=int(input())
b=int(2)
c=int
if 1==a:
print(a)
else:
while b<100:
c=b
b=b*2
if(a<b)and(a>=c):
print (c)
|
s169136756 | p03359 | u897302879 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 64 | 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 ... | y, m = map(int, input().split())
print(y + (1 if y <= m else 0)) | s527810023 | Accepted | 17 | 2,940 | 68 | y, m = map(int, input().split())
print(y - 1 + (1 if y <= m else 0)) |
s012652130 | p03680 | u268792407 | 2,000 | 262,144 | Wrong Answer | 205 | 7,852 | 276 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | n=int(input())
a=[int(input()) for i in range(n)]
memo=[0]*n
for i in range(n):
if i == 0:
k=0
memo[0]=1
ans=0
else:
k=a[k]-1
if memo[k]==0:
memo[k]=1
else:
print(-1)
exit()
ans += 1
if k==2:
print(ans)
exit()
| s752186610 | Accepted | 202 | 7,852 | 270 | n=int(input())
a=[int(input()) for i in range(n)]
memo=[0]*n
for i in range(n):
if i == 0:
k=0
memo[0]=1
ans=0
else:
k=a[k]-1
if memo[k]==0:
memo[k]=1
else:
print(-1)
exit()
ans += 1
if k==1:
print(ans)
exit() |
s252045596 | p03993 | u354638986 | 2,000 | 262,144 | Wrong Answer | 52 | 14,004 | 260 | There are N rabbits, numbered 1 through N. The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i. For a pair of rabbits i and j (i<j), we call the pair (i,j) a _friendly pair_ if the following condition is met. * Rabbit i likes rabbit j and rabbit j likes rabbit i. Calculat... | def main():
n = int(input())
a = list(map(int, input().split()))
pair = 0
for i in range(n):
if a[i-1] == i - 1 and a[i-1] >= i - 1:
pair += 1
print(pair)
if __name__ == "__main__":
main() | s177045544 | Accepted | 65 | 13,940 | 265 | def main():
n = int(input())
a = list(map(int, input().split()))
pair = 0
for i in range(n):
if a[a[i]-1] == i + 1 and a[a[i]-1] <= a[i]:
pair += 1
print(pair)
if __name__ == "__main__":
main() |
s489032007 | p03795 | u095969144 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 57 | 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 ... | i = int(input())
x = i * 800
y = i % 15 * 200
print(x -y) | s956856545 | Accepted | 17 | 2,940 | 58 | i = int(input())
x = i * 800
y = i // 15 * 200
print(x -y) |
s176365023 | p03501 | u391328897 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 66 | You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. | n, a, b = map(int, input().split())
print(n*a if n*a >= b else b)
| s012325403 | Accepted | 18 | 2,940 | 65 | n, a, b = map(int, input().split())
print(n*a if n*a <= b else b) |
s796976644 | p03486 | u217574754 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 226 | You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order. |
s = input()
t = input()
# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]
if s == t:
print("NO")
elif st_list == sorted(st_list):
print("YES")
else:
print("NO") | s701856414 | Accepted | 17 | 2,940 | 244 | # coding: utf-8
s = input()
t = input()
# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]
if s == t:
print("No")
elif st_list == sorted(st_list):
print("Yes")
else:
print("No")
|
s476133906 | p03494 | u088974156 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 142 | 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()))
ans=0
while all(a%2==0 for a in A):
for i in range(n):
A[i]=A[i]/2
ans+=1
print(ans) | s844053311 | Accepted | 19 | 3,060 | 148 | n=int(input())
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
for i in range(n):
A[i]=A[i]/2
ans+=1
print(ans) |
s364955514 | p03693 | u607563136 | 2,000 | 262,144 | Wrong Answer | 27 | 9,020 | 59 | 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 i... | print("Yes" if int(input().replace(" ",""))%4==0 else "No") | s331306123 | Accepted | 28 | 9,048 | 59 | print("YES" if int(input().replace(" ",""))%4==0 else "NO") |
s818425861 | p03379 | u916806287 | 2,000 | 262,144 | Wrong Answer | 2,116 | 181,912 | 172 | When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..... | n = int(input())
x = list(map(int, input().split()))
print(x[:2] + x[3:])
a = map(lambda x: x[(n-1)//2], [sorted(x[:i] + x[i+1:]) for i in range(n)])
for i in a:
print(i) | s393348687 | Accepted | 413 | 25,620 | 153 | n = int(input())
x = list(map(int, input().split()))
m1, m2 = sorted(x)[n//2-1], sorted(x)[n//2]
for i in x:
print(m1) if i >= (m1+m2)/2 else print(m2) |
s355084726 | p03573 | u568426505 | 2,000 | 262,144 | Wrong Answer | 24 | 9,064 | 28 | You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. | eval(input().replace(*" ^")) | s619705904 | Accepted | 29 | 8,944 | 35 | print(eval(input().replace(*" ^"))) |
s776295830 | p02396 | u222716853 | 1,000 | 131,072 | Wrong Answer | 90 | 5,904 | 174 | 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 give... | a = []
while True:
b = input()
b = int(b)
if b == 0:
break
else:
a.append(b)
for i in range(len(a)):
print("Case "+str(i)+": "+str(a[i]))
| s777486083 | Accepted | 90 | 5,900 | 186 | a = []
while True:
b = input()
b = int(b)
if b == 0:
break
else:
a.append(b)
for i in range(len(a)):
c = i+1
print("Case "+str(c)+": "+str(a[i]))
|
s343756108 | p03854 | u625811641 | 2,000 | 262,144 | Wrong Answer | 2,104 | 3,956 | 338 | 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 = list(input())
s.reverse()
s = "".join(s)
before_s = s
while(True):
if s[:5]=="maerd" or s[:5] =="esare":
s = s[5:]
elif s[:7]=="remaerd" :
s = s[7:]
elif s[:6] == "resare":
s = s[6:]
if s == "":
ans = "Yes"
break
if s == before_s:
ans ="No"
... | s369067622 | Accepted | 73 | 3,956 | 352 | s = list(input())
s.reverse()
s = "".join(s)
for _ in range(10**5):
before_s = s
if s[:5]=="maerd" or s[:5] =="esare":
s = s[5:]
elif s[:7]=="remaerd" :
s = s[7:]
elif s[:6] == "resare":
s = s[6:]
if s == "":
ans = "YES"
break
if s == before_s:
an... |
s502675499 | p03779 | u469953228 | 2,000 | 262,144 | Wrong Answer | 119 | 3,920 | 71 | There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be a... | X=int(input())
for i in range(10**5):
if (1+i)*i//2>=X:
print(i) | s480064785 | Accepted | 27 | 2,940 | 82 | X=int(input())
for i in range(10**5):
if (1+i)*i//2>=X:
print(i)
exit() |
s716481652 | p03719 | u414558682 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 259 | You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. | # coding: utf-8
# Your code here!
A, B, C = map(int, input().split())
# print(A)
# print(C)
if C >= A and C <= B:
print('YES')
else:
print('NO') | s206444302 | Accepted | 17 | 2,940 | 339 | # coding: utf-8
# Your code here!
A, B, C = map(int, input().split())
# print(A)
# print(C)
if C >= A and C <= B:
print('Yes')
else:
print('No') |
s190722614 | p02390 | u853619096 | 1,000 | 131,072 | Wrong Answer | 20 | 7,648 | 98 | Write a program which reads an integer $S$ [second] and converts it to $h:m:s$ where $h$, $m$, $s$ denote hours, minutes (less than 60) and seconds (less than 60) respectively. | s = int(input())
a = s//(60*60)
b = (s-(a*60*60))//60
c = s-(b*60)
print("{}:{}:{}".format(a,b,c)) | s986193832 | Accepted | 30 | 7,648 | 96 | s=int(input())
h=s//3600
ss=(s-3600*h)//60
se=(s-3600*h-ss*60)
print("{}:{}:{}".format(h,ss,se)) |
s201435361 | p03759 | u785578220 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 84 | Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. | a ,b,c= map(int, input().split())
if b - a == c-b:
print("Yes")
else:print("NO") | s662930038 | Accepted | 17 | 2,940 | 84 | a ,b,c= map(int, input().split())
if b - a == c-b:
print("YES")
else:print("NO") |
s652377153 | p03385 | u484856305 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 59 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | a=input()
if "abc" in a:
print("Yes")
else:
print("No") | s944886538 | Accepted | 17 | 2,940 | 73 | a=input()
if set("abc") == set(a):
print("Yes")
else:
print("No") |
s036185416 | p03997 | u746849814 | 2,000 | 262,144 | Wrong Answer | 20 | 2,940 | 66 | 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) | s181648396 | Accepted | 17 | 2,940 | 68 | a = int(input())
b = int(input())
h = int(input())
print((a+b)*h//2) |
s757508395 | p03160 | u087474779 | 2,000 | 1,048,576 | Wrong Answer | 145 | 13,928 | 321 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | n = int(input())
h = [int(hi) for hi in input().split()]
inf = float('inf')
dp = [inf] * n
dp[0] = 0
for i in range(n):
dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
# dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
# dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])
... | s505344121 | Accepted | 182 | 13,980 | 265 | n = int(input())
h = [int(hi) for hi in input().split()]
inf = float('inf')
dp = [inf] * n
dp[0] = 0
for i in range(0, n-1):
dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]))
if i < n-2:
dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]))
print(dp[-1]) |
s913991199 | p02747 | u269724549 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 71 | A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string. | s=input()
if(s.count("hi")==len(s)):
print("Yes")
else:
print("No") | s013040646 | Accepted | 18 | 2,940 | 74 | s=input()
if(2*s.count("hi")==len(s)):
print("Yes")
else:
print("No")
|
s150995829 | p02612 | u348171775 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,068 | 58 | 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())
while N >= 0:
N -= 1000
print(1000+N) | s746883037 | Accepted | 30 | 9,148 | 31 | N = -int(input())
print(N%1000) |
s362369295 | p03944 | u163501259 | 2,000 | 262,144 | Wrong Answer | 29 | 9,164 | 552 | 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) po... | import sys
input = sys.stdin.readline
def main():
Wr, Hu, N = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
Wl, Hd = 0, 0
for x, y ,a in C:
if Wr <= Wl or Hu <= Hd:
print(0)
return
if a == 1:
Wl = x
if a == ... | s399713410 | Accepted | 25 | 9,108 | 615 | import sys
input = sys.stdin.readline
def main():
Wr, Hu, N = map(int, input().split())
C = [list(map(int, input().split())) for i in range(N)]
Wl, Hd = 0, 0
for x, y ,a in C:
if a == 1:
if Wl <= x:
Wl = x
if a == 2:
if Wr >= x:
Wr... |
s853291950 | p02418 | u663910047 | 1,000 | 131,072 | Wrong Answer | 30 | 7,348 | 112 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | s = input()
p = input()
S = s+s
index = S.find(str(p))
if index == 0:
print ("Yes")
else:
print("No") | s932397870 | Accepted | 20 | 7,476 | 113 | s = input()
p = input()
S = s+s
index = S.find(str(p))
if index != -1:
print ("Yes")
else:
print("No") |
s564937784 | p03796 | u555947166 | 2,000 | 262,144 | Wrong Answer | 34 | 2,940 | 108 | Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. | N = int(input())
power = 1
hou = pow(10, 9)+7
for i in range(1, N):
power = power * i % hou
print(power) | s620366884 | Accepted | 34 | 2,940 | 113 | N = int(input())
power = 1
hou = pow(10, 9)+7
for i in range(1, N+1):
power = (power * i) % hou
print(power)
|
s386040699 | p02678 | u201514991 | 2,000 | 1,048,576 | Wrong Answer | 2,348 | 123,184 | 852 | 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 th... | nm = list(map(int,input().split()))
n = nm[0]
m = nm[1]
a = []
b = []
for i in range(0, m):
ab = list(map(int,input().split()))
a.append(ab[0])
b.append(ab[1])
signs = [0]*(n+1)
signs[1]=-1
now = [1]
nexx = []
while True:
for i in now:
for j in range(0,m):
if a[j] == i:
... | s158739230 | Accepted | 1,475 | 48,812 | 573 | n, m = map(int,input().split())
graph = {}
for i in range(0, m):
am, bm = map(int, input().split())
if am not in graph:
graph[am] = [bm]
else:
graph[am].append(bm)
if bm not in graph:
graph[bm] = [am]
else:
graph[bm].append(am)
signs = {1:0}
current = [1]
while curren... |
s386895875 | p02612 | u129749062 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,144 | 30 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | N = int(input())
print(N%1000) | s085201775 | Accepted | 24 | 9,020 | 72 | N= int(input())
if N%1000==0:
print(0)
else:
print(1000-(N%1000))
|
s040412993 | p03657 | u791838908 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 102 | Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them ca... | A, B = map(int, input().split())
print("Possible" if ((A) % 3 == 0 or (B) % 3 == 0) else "Impossible") | s330263548 | Accepted | 17 | 2,940 | 122 | A, B = map(int, input().split())
print("Possible" if ((A) % 3 == 0 or (B) % 3 == 0 or (A + B) % 3 == 0) else "Impossible") |
s346311411 | p02407 | u836133197 | 1,000 | 131,072 | Wrong Answer | 20 | 5,600 | 161 | Write a program which reads a sequence and prints it in the reverse order. | n = int(input())
a = list(map(int, input().split()))
b = []
count = 0
for i in a:
count += 1
b.append(a[n-count])
print(b)
print(" ".join(map(str, b)))
| s723717514 | Accepted | 20 | 5,596 | 152 | n = int(input())
a = list(map(int, input().split()))
b = []
count = 0
for _ in a:
count += 1
b.append(a[n-count])
print(" ".join(map(str, b)))
|
s317034778 | p00004 | u358919705 | 1,000 | 131,072 | Wrong Answer | 20 | 7,428 | 202 | Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution. | import sys
for line in sys.stdin:
a, b, c, d, e, f = map(float, line.split())
print('{0:.3f} {1:.3f}'.format(round((c * e - b * f) / (a * e - b * d), 3), round((a * f - c * d) / a * e - b * d))) | s575043553 | Accepted | 20 | 7,344 | 267 | while True:
try:
a, b, c, d, e, f = map(float, input().split())
x = round((c * e - b * f) / (a * e - b * d), 3)
y = round((a * f - c * d) / (a * e - b * d), 3)
print('{0:.3f} {1:.3f}'.format(x + 0, y + 0))
except:
break |
s275263646 | p03149 | u272557899 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 141 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | a = input().split()
a = [int(m) for m in a]
a = set(a)
b = [1, 9, 7, 4]
b = set(b)
if len(a & b) == 4:
print("Yes")
else:
print("No") | s719161653 | Accepted | 17 | 3,060 | 141 | a = input().split()
a = [int(m) for m in a]
a = set(a)
b = [1, 9, 7, 4]
b = set(b)
if len(a & b) == 4:
print("YES")
else:
print("NO") |
s801133465 | p02408 | u476441153 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 670 | Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond. | h = [i for i in range(1,14)]
c = [i for i in range(1,14)]
d = [i for i in range(1,14)]
s = [i for i in range(1,14)]
x = int(input())
for i in range(x):
ss, nn = map(str, input().split())
try:
if ss == "H":
h.remove(int(nn))
elif ss == "C":
c.remove(int(nn))
eli... | s460788478 | Accepted | 20 | 5,608 | 670 | h = [i for i in range(1,14)]
c = [i for i in range(1,14)]
d = [i for i in range(1,14)]
s = [i for i in range(1,14)]
x = int(input())
for i in range(x):
ss, nn = map(str, input().split())
try:
if ss == "H":
h.remove(int(nn))
elif ss == "C":
c.remove(int(nn))
eli... |
s419290491 | p03447 | u146575240 | 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? | # A - Buying Sweets
X = int(input())
A = int(input())
B = int(input())
ans = (X-A)//B
print(ans) | s131306611 | Accepted | 17 | 2,940 | 98 | # A - Buying Sweets
X = int(input())
A = int(input())
B = int(input())
ans = (X-A) % B
print(ans) |
s932457553 | p03433 | u572142121 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | 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())
mod = N%500
if mod <= A:
print('No')
else :
print('Yes') | s831483427 | Accepted | 17 | 2,940 | 95 | N = int(input())
A = int(input())
mod = N%500
if mod <= A:
print('Yes')
else :
print('No') |
s564740978 | p03351 | u923712635 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 142 | Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either ... | a,b,c,d = [int(x) for x in input().split()]
if(abs(a-c)<d):
print('Yes')
elif(abs(a-b)<d and abs(c-b)<d):
print('Yes')
else:
print('No') | s261199466 | Accepted | 17 | 3,060 | 145 | a,b,c,d = [int(x) for x in input().split()]
if(abs(a-c)<=d):
print('Yes')
elif(abs(a-b)<=d and abs(c-b)<=d):
print('Yes')
else:
print('No') |
s615774230 | p03563 | u847033024 | 2,000 | 262,144 | Wrong Answer | 23 | 8,996 | 52 | 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 cont... | a = int(input())
b = int(input())
print(b + (a - b)) | s701478057 | Accepted | 29 | 9,156 | 52 | a = int(input())
b = int(input())
print(b + (b - a)) |
s754855199 | p03711 | u248670337 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 83 | 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. | S="_ACABABAABABA"
a,b=map(int,input().split())
print("YES" if S[a]==S[b] else "NO") | s215039197 | Accepted | 17 | 2,940 | 83 | S="_ACABABAABABA"
a,b=map(int,input().split())
print("Yes" if S[a]==S[b] else "No") |
s790929504 | p03149 | u033524082 | 2,000 | 1,048,576 | Wrong Answer | 18 | 3,192 | 1,415 | You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974". | import sys
s=input()
a=0
b=0
c=0
d=0
e=0
f=0
g=0
while s[a]!="k":
a+=1
if a==len(s):
print("NO")
sys.exit()
b=a+1
while s[b]!="e":
b+=1
if b==len(s):
print("NO")
sys.exit()
c=b+1
while s[c]!="y":
c+=1
if c==len(s):
print("NO")
sys.exit()
d=c+1
whi... | s769647045 | Accepted | 17 | 3,064 | 297 | a,b,c,d=map(int,input().split())
x=0
list=[]
list.append(a)
list.append(b)
list.append(c)
list.append(d)
for i in range(4):
if list[i]==1:
x+=1000
elif list[i]==9:
x+=900
elif list[i]==7:
x+=70
elif list[i]==4:
x+=4
print("YES" if x==1974 else "NO") |
s909850868 | p03369 | u591764610 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 29 | In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ... | print(700+input().count('o')) | s883973912 | Accepted | 18 | 2,940 | 33 | print(700+100*input().count('o')) |
s443914677 | p02690 | u744920373 | 2,000 | 1,048,576 | Wrong Answer | 63 | 9,692 | 915 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i... | s398754850 | Accepted | 27 | 9,168 | 959 | import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i... |
s701982659 | p03251 | u332906195 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 216 | 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 incli... | # -*- coding: utf-8 -*-
N, M, X, Y = map(int, input().split())
Xl = list(map(int, input().split())) + [X]
Yl = list(map(int, input().split())) + [Y]
if max(Xl) < min(Yl):
print("War")
else:
print("No War")
| s319697495 | Accepted | 18 | 2,940 | 199 | # -*- coding: utf-8 -*-
N, M, X, Y = map(int, input().split())
Xl = list(map(int, input().split())) + [X]
Yl = list(map(int, input().split())) + [Y]
print("No War" if max(Xl) < min(Yl) else "War")
|
s185008617 | p03007 | u969190727 | 2,000 | 1,048,576 | Wrong Answer | 343 | 13,940 | 239 | 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... | import heapq
n=int(input())
A=[int(i) for i in input().split()]
heapq.heapify(A)
for i in range(n-2):
a1=heapq.heappop(A)
a2=heapq.heappop(A)
print(a1,a2)
heapq.heappush(A,a1-a2)
a1=heapq.heappop(A)
a2=heapq.heappop(A)
print(a2,a1) | s920536563 | Accepted | 446 | 25,768 | 1,305 | import heapq
n=int(input())
Ans=[]
A=[int(i) for i in input().split()]
A.sort()
if A[0]>=0:
Ans=[]
heapq.heapify(A)
for i in range(n-2):
a1=heapq.heappop(A)
a2=heapq.heappop(A)
Ans.append([a1,a2])
heapq.heappush(A,a1-a2)
a1=heapq.heappop(A)
a2=heapq.heappop(A)
Ans.append([a2,a1])
print(a2-... |
s659099920 | p03971 | u629607744 | 2,000 | 262,144 | Wrong Answer | 114 | 4,016 | 289 | There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from t... | n,A,B=map(int,input().split())
s=input()
cnt_b=0
cnt_c=0
for i in range(n):
if s[i]=='a':
if i<=A+B+cnt_c:
print('Yes')
else:
print('No')
elif s[i]=='b':
cnt_b+=1
if i<=A+B+cnt_c and cnt_b<=B:
print('Yes')
else:
print('No')
elif s[i]=='c':
print('No')
cnt_c+=1 | s622756891 | Accepted | 109 | 4,712 | 227 | n,A,B=map(int,input().split())
s=list(input())
cnt=0
cnt_b=0
for i in range(n):
if s[i]=='a' and cnt<A+B:
print('Yes')
cnt+=1
elif s[i]=='b' and cnt<A+B and cnt_b<B:
print('Yes')
cnt_b+=1
cnt+=1
else:
print('No') |
s913569631 | p04044 | u761062383 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 124 | 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 sm... | n,l = [int(i) for i in input().split()]
ss = [input() for _ in range(n)]
ss.sort()
for s in ss:
print(s, sep="")
print("") | s055536590 | Accepted | 18 | 3,060 | 128 | n, l = [int(i) for i in input().split()]
ss = [input() for _ in range(n)]
ss.sort()
for s in ss:
print(s, end="")
print("")
|
s875594951 | p00015 | u617990214 | 1,000 | 131,072 | Wrong Answer | 20 | 7,616 | 130 | A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647. Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers. If given integers or t... | n=int(input())
ans_list=[]
for i in range(n):
a=int(input())
b=int(input())
ans_list.append(a+b)
for i in ans_list:
print(i) | s547696876 | Accepted | 20 | 7,648 | 197 | n=int(input())
ans_list=[]
for i in range(n):
a=int(input())
b=int(input())
c=a+b
if max(a,b,c)>=10**80:
ans_list.append("overflow")
else:
ans_list.append(c)
for i in ans_list:
print(i) |
s251136652 | p03469 | u970197315 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 71 | 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 col... | # ABC085 A - Already 2018
S = input()
S.replace('2017','2018')
print(S) | s703207721 | Accepted | 17 | 2,940 | 83 | # ABC085 A - Already 2018
S = input()
S = S.replace('2017/01/','2018/01/')
print(S) |
s448726127 | p03549 | u925364229 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 112 | 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 th... | N,M = map(int,input().split(" "))
A = 100 * (N-M) + 1900 * M
C = A / ((2**M) - 1)
ans = C * (2**M)
print(ans) | s645669735 | Accepted | 18 | 2,940 | 98 | N,M = map(int,input().split(" "))
A = 100 * (N-M) + 1900 * M
ans = A * (2**M)
print(int(ans)) |
s431453758 | p03674 | u952708174 | 2,000 | 262,144 | Wrong Answer | 2,110 | 20,900 | 840 | You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given s... | def D_11(x):
n = x[0]
a = x[1:]
import collections
freq = collections.Counter(a).most_common(1)
index = [i for i, x in enumerate(a) if x == freq[0][0]]
l, r = index[0] + 1, index[1] + 1
import scipy.misc as scm
for k in range(1, n + 2, 1):
combination = scm.... | s693537432 | Accepted | 232 | 31,568 | 1,313 | def d_11(MOD=10**9 + 7):
class Combination(object):
__slots__ = ["mod", "factorial", "inverse"]
def __init__(self, max_n: int = 10**6, mod: int = 10**9 + 7):
fac, inv = [1], []
fac_append, inv_append = fac.append, inv.append
for i in range(1, max_n + 1)... |
s417883259 | p03448 | u017415492 | 2,000 | 262,144 | Wrong Answer | 48 | 3,060 | 190 | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co... | a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a):
for j in range(b):
for k in range(c):
if 500*i+100*j+10*k==x:
count+=1
print(count) | s349940697 | Accepted | 51 | 3,188 | 196 | a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
if 500*i+100*j+50*k==x:
count+=1
print(count) |
s204765383 | p03997 | u728566015 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 106 | 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. | # -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
S = (a + b) * h / 2
print(S)
| s289361915 | Accepted | 18 | 2,940 | 117 | # -*- coding: utf-8 -*-
a = int(input())
b = int(input())
h = int(input())
S = (a + b) * h / 2
S = int(S)
print(S)
|
s251989079 | p02600 | u298976461 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,132 | 293 | M-kun is a competitor in AtCoder, whose highest rating is X. In this site, a competitor is given a _kyu_ (class) according to his/her highest rating. For ratings from 400 through 1999, the following kyus are given: * From 400 through 599: 8-kyu * From 600 through 799: 7-kyu * From 800 through 999: 6-kyu * Fr... | a = int(input())
if 400 <= a <= 599:
print("8")
if 600 <= a <= 799:
print("8")
if 800 <= a <= 999:
print("8")
if 1000 <= a <= 1199:
print("8")
if 1200 <= a <= 1399:
print("8")
if 1400 <= a <= 1599:
print("8")
if 1600 <= a <= 1799:
print("8")
if 1800 <= a <= 1999:
print("8") | s970531115 | Accepted | 34 | 9,068 | 308 | a = int(input())
if 400 <= a <= 599:
print("8")
if 600 <= a <= 799:
print("7")
if 800 <= a <= 999:
print("6")
if 1000 <= a <= 1199:
print("5")
if 1200 <= a <= 1399:
print("4")
if 1400 <= a <= 1599:
print("3")
if 1600 <= a <= 1799:
print("2")
if 1800 <= a <= 1999:
print("1")
|
s771484312 | p02409 | u435300817 | 1,000 | 131,072 | Wrong Answer | 20 | 7,720 | 412 | You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth fl... | #!/usr/bin/env python3
n = int(input())
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
dormitory = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
for b, f, r, v in matrix:
dormitory[b - 1][f - 1][r - 1] += v
for i in range(4):
for... | s695954358 | Accepted | 20 | 7,748 | 547 | #!/usr/bin/env python3
n = int(input())
matrix = []
while n > 0:
values = [int(x) for x in input().split()]
matrix.append(values)
n -= 1
official_house = [[[0 for z in range(10)] for y in range(3)] for x in range(4)]
Min = 0
Max = 9
for b, f, r, v in matrix:
num = official_house[b - 1][f - 1][r - 1]
... |
s095217309 | p03972 | u591287669 | 2,000 | 262,144 | Wrong Answer | 1,063 | 35,012 | 305 | On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers. There are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and... | w,h = map(int,input().split())
arr=[]
for i in range(w):
arr.append( (int(input()),'p') )
for i in range(h):
arr.append( (int(input()),'q') )
arr.sort()
print(arr)
ans=0
for a in arr:
if a[1]=='p':
ans+=a[0]*(h+1)
w-=1
else:
ans+=a[0]*(w+1)
h-=1
print(ans)
| s551927395 | Accepted | 841 | 24,660 | 306 | w,h = map(int,input().split())
arr=[]
for i in range(w):
arr.append( (int(input()),'p') )
for i in range(h):
arr.append( (int(input()),'q') )
arr.sort()
#print(arr)
ans=0
for a in arr:
if a[1]=='p':
ans+=a[0]*(h+1)
w-=1
else:
ans+=a[0]*(w+1)
h-=1
print(ans)
|
s781680763 | p02612 | u555311916 | 2,000 | 1,048,576 | Wrong Answer | 29 | 9,116 | 54 | 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. | price = int(input())
change = price%1000
print(change) | s839699186 | Accepted | 28 | 9,020 | 104 | price = int(input())
if price%1000 == 0:
change = 0
else:
change = 1000-price%1000
print(change) |
s168183605 | p00010 | u724548524 | 1,000 | 131,072 | Wrong Answer | 20 | 5,680 | 446 | Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface. | import math
for _ in range(int(input())):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3... | s441020577 | Accepted | 20 | 5,676 | 446 | import math
for _ in range(int(input())):
x1, y1, x2, y2, x3, y3 = map(float, input().split())
p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))
q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3... |
s802065766 | p03957 | u010733367 | 1,000 | 262,144 | Wrong Answer | 24 | 3,064 | 65 | This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtai... | S = input()
if "CF" in S:
print("Yes")
else:
print("No")
| s796926915 | Accepted | 23 | 3,064 | 237 | S = input()
if "C" in S and "F" in S:
C_ind = S.index("C")
S_inv = S[::-1]
S_ind = S_inv.find("F")
S_ind = len(S) - S_ind - 1
if C_ind < S_ind:
print("Yes")
else:
print("No")
else:
print("No")
|
s690568745 | p02645 | u466916194 | 2,000 | 1,048,576 | Wrong Answer | 22 | 9,016 | 39 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. |
s=input(" ")
s=s.lower()
print(s[0:3]) | s399023421 | Accepted | 21 | 9,088 | 33 | s=input()
s.lower()
print(s[0:3]) |
s226007429 | p02389 | u592365052 | 1,000 | 131,072 | Wrong Answer | 20 | 5,576 | 62 | Write a program which calculates the area and perimeter of a given rectangle. | a, b = map(int, input().split())
"{} {}".format(a*b, (a+b)*2)
| s431090279 | Accepted | 20 | 5,576 | 69 | a, b = map(int, input().split())
print("{} {}".format(a*b, (a+b)*2))
|
s810682544 | p03251 | u977661421 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,064 | 894 | 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 incli... | # -*- coding: utf-8 -*-
n, m, X, Y = map(int,input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
flag = False
for z in range(X + 1, Y + 1):
count_x = 0
count_y = 0
for i in x:
if i < z:
count_x += 1
for i in y:
if i >= z:
cou... | s689062583 | Accepted | 20 | 3,064 | 895 | # -*- coding: utf-8 -*-
n, m, X, Y = map(int,input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
flag = False
for z in range(X + 1, Y + 1):
count_x = 0
count_y = 0
for i in x:
if i < z:
count_x += 1
for i in y:
if i >= z:
cou... |
s658368915 | p03814 | u353797797 | 2,000 | 262,144 | Wrong Answer | 43 | 3,512 | 541 | Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends w... | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(ro... | s892373496 | Accepted | 30 | 3,512 | 541 | import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(ro... |
s106020489 | p03089 | u422886513 | 2,000 | 1,048,576 | Wrong Answer | 1,367 | 18,916 | 947 | Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N oper... | import numpy as np
def input_line():
N = int(input())
b = [int(i) for i in input().split()]
tmp = []
for i in b:
tmp.append(i - 1)
b = tmp
return N, np.array(b)
def possible_check(b):
counter = [0] * 100
if (max(b) >= len(b)):
print(-1)
exit()
... | s852432939 | Accepted | 18 | 3,060 | 273 | N = int(input())
B = list(map(int,input().split()))
ans = []
while B:
for i,a in reversed(list(enumerate(B))):
if i+1 == a:
ans.append(a)
del B[i]
break
else:
print(-1)
exit()
print(*ans[::-1], sep='\n') |
s575008763 | p02865 | u597455618 | 2,000 | 1,048,576 | Wrong Answer | 125 | 2,940 | 91 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | n = int(input())
ans = 0
for i in range(n//2):
if n-i != i:
ans += 1
print(ans) | s153817785 | Accepted | 117 | 2,940 | 96 | n = int(input())
ans = 0
for i in range(1, n//2+1):
if n-i != i:
ans += 1
print(ans) |
s567603655 | p03605 | u546853743 | 2,000 | 262,144 | Wrong Answer | 28 | 9,140 | 114 | 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? | n = int(input())
t = n // 10
n -= t
if t==9:
print('Yes')
elif n == 9:
print('Yes')
else:
print('No')
| s901947011 | Accepted | 25 | 9,000 | 117 | n = int(input())
t = n // 10
n -= t*10
if t==9:
print('Yes')
elif n == 9:
print('Yes')
else:
print('No')
|
s129583200 | p02694 | u133583235 | 2,000 | 1,048,576 | Wrong Answer | 24 | 9,224 | 88 | 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 abo... | X = int(input())
t = 100
cnt = 0
while t <= X:
t = t*1.01//1
cnt += 1
print(cnt) | s296354436 | Accepted | 18 | 9,168 | 85 | X = int(input())
t = 100
cnt = 0
while t < X:
t = t*1.01//1
cnt += 1
print(cnt) |
s649548248 | p00310 | u737311644 | 1,000 | 262,144 | Wrong Answer | 20 | 5,544 | 96 | 選手のみなさん、パソコン甲子園にようこそ。パソコン甲子園では、現在、プログラミング部門、モバイル部門、そして、いちまいの絵CG部門、計3部門の競技が開催されています。 各部門の参加者数が与えられたとき、参加者の総数を計算するプログラムを作成せよ。 | while True:
try:
a,b,c=map(int,input().split)
print(a+b+c)
except:break
| s356441775 | Accepted | 20 | 5,588 | 98 | while True:
try:
a,b,c=map(int,input().split())
print(a+b+c)
except:break
|
s075924489 | p03400 | u445511055 | 2,000 | 262,144 | Wrong Answer | 19 | 3,060 | 345 | 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 ... | # -*- coding: utf-8 -*-
def main():
"""Function."""
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
x += n
for i in range(1, d):
print(i)
for j in range(n):
if i % a[j] == 0:
x += 1
print(x)
if __name__ =... | s723200051 | Accepted | 19 | 3,060 | 328 | # -*- coding: utf-8 -*-
def main():
"""Function."""
n = int(input())
d, x = map(int, input().split())
a = [int(input()) for _ in range(n)]
x += n
for i in range(1, d):
for j in range(n):
if i % a[j] == 0:
x += 1
print(x)
if __name__ == "__main__":
... |
s507645364 | p02399 | u987701388 | 1,000 | 131,072 | Wrong Answer | 20 | 5,608 | 76 | 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) | x=input().split()
a=int(x[0])
b=int(x[1])
d=a//b
r=a%b
f=a/b
print(d,r,f)
| s686682762 | Accepted | 20 | 5,608 | 113 | x=input().split()
a=int(x[0])
b=int(x[1])
d=a//b
r=a%b
f=a/b
u=float(f)
print('{0} {1} {2:.5f}'.format(d,r,u))
|
s792782661 | p03457 | u414626225 | 2,000 | 262,144 | Wrong Answer | 355 | 9,216 | 534 | AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1... | N = int(input())
t_before = 0
x_before = 0
y_before = 0
def judge(t_plus, x_diff, y_diff):
distance = abs(x_diff) + abs(y_diff)
if (t_plus % 2) != (distance % 2):
return False
if distance > t_plus:
return False
return True
for i in range(N):
t, x, y = map(int, input().split())
... | s463135188 | Accepted | 412 | 52,300 | 642 | N = int(input())
t_before = 0
x_before = 0
y_before = 0
travel_list = [map(int, input().split()) for _ in range(N)]
def judge(t_plus, x_diff, y_diff):
distance = abs(x_diff) + abs(y_diff)
if (t_plus % 2) != (distance % 2):
return False
if distance > t_plus:
return False
return True
i... |
s052874599 | p03476 | u711539583 | 2,000 | 262,144 | Wrong Answer | 368 | 14,424 | 414 | We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i. | import sys
input = sys.stdin.readline
n = 10 ** 5
memo = [1] * (n+1)
for i in range(2, n):
for j in range(2, n):
if i * j > n:
break
memo[i*j] = 0
for i in range(n+1):
x = memo[i]
if x % 2 == 0 or memo[(x+1) // 2] == 0:
memo[i] = 0
c = [0]
for x in memo[1:]:
c.append(c[-1]+x)
q... | s896964011 | Accepted | 347 | 13,984 | 422 | import sys
input = sys.stdin.readline
n = 10 ** 5
memo = [1] * (n+1)
for i in range(2, n):
for j in range(2, n):
if i * j > n:
break
memo[i*j] = 0
memo2 = memo[:]
memo2[1] = 0
for x in range(n+1):
if x % 2 == 0 or memo[(x+1) // 2] == 0:
memo2[x] = 0
c = [0]
for x in memo2[1:]:
c.append(c[-... |
s731694325 | p02255 | u071759777 | 1,000 | 131,072 | Wrong Answer | 20 | 7,764 | 187 | 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 ... | n = int(input())
a = [int(x) for x in input().split()]
for i in range(1, n):
k, j = a[i], i-1
while j >= 0 and a[j] > k:
a[j+1], j = a[j], j-1
a[j+1] = k
print(*a) | s489763157 | Accepted | 20 | 8,060 | 184 | n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
k, j = a[i], i-1
while j >= 0 and a[j] > k:
a[j+1], j = a[j], j-1
a[j+1] = k
print(*a) |
s229369494 | p00144 | u352394527 | 1,000 | 131,072 | Wrong Answer | 20 | 6,000 | 584 | インターネットでは、データはパケットに分割され、パケットごとにルータと呼ばれる中継機器を介して宛先に転送されます。各ルータはパケットに記載された宛先から次に転送すべきルータを判断します。さらに、無限にルータ間を転送され続けることを防ぐため、パケットには TTL(Time To Live) という値が付加されています。ルータは受け取ったパケットの TTL を 1 減算し、その結果が 0 ならそのパケットを破棄し、それ以外なら次のルータに転送します。 そこで、ネットワークの設計を手助けするプログラムを作ることになりました。ネットワークの接続情報と送信パケットの情報を入力として、各パケットが宛先ルータに到着するまでに経由するルータの数の... | from collections import deque
n = int(input())
rlst = [None] * (n + 1)
#print(rlst)
for _ in range(n):
lst = list(map(int, input().split()))
r = lst[0]
print(r)
lst = lst[2:]
rlst[r] = lst
p = int(input())
for _ in range(p):
s, d, v = map(int, input().split())
visited = [False] * (n + 1)
visited[s] = ... | s423232212 | Accepted | 100 | 6,004 | 626 | from collections import deque
n = int(input())
rlst = [None] * (n + 1)
for _ in range(n):
lst = list(map(int, input().split()))
r = lst[0]
lst = lst[2:]
rlst[r] = lst
p = int(input())
for _ in range(p):
s, d, v = map(int, input().split())
visited = [False] * (n + 1)
visited[s] = True
que = deque()
... |
s739067190 | p04045 | u064434060 | 2,000 | 262,144 | Wrong Answer | 150 | 12,504 | 842 | 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 ... | import sys
import numpy as np
input=sys.stdin.readline
n,k=map(int,input().split())
d=list(map(int,input().split()))
res=[]
for i in range(10):
if i not in d:
res.append(i)
ans=0
ansmax=0
ansmin=0
n_s=str(n)
l=len(n_s)
M=max(res)
for i in range(l):
ansmax+=M*10**(l-i-1)
if n>ansmax:
if res[0]!=0:
... | s281157479 | Accepted | 148 | 12,504 | 836 | import sys
import numpy as np
input=sys.stdin.readline
n,k=map(int,input().split())
d=list(map(int,input().split()))
res=[]
for i in range(10):
if i not in d:
res.append(i)
ans=0
ansmax=0
ansmin=0
n_s=str(n)
l=len(n_s)
M=max(res)
for i in range(l):
ansmax+=M*10**(l-i-1)
if n>ansmax:
if res[0]!=0:
... |
s561071689 | p03377 | u927534107 | 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,x=map(int,input().split())
print("Yes" if a<=x<=a+b else "No") | s513005474 | Accepted | 17 | 2,940 | 66 | a,b,x=map(int,input().split())
print("YES" if a<=x<=a+b else "NO") |
s318317694 | p03385 | u343902538 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 135 | You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`. | S = input()
# S = 'abc'
if ('abc' in 'a'):
if(S.find('b')):
if(S.find('c')):
print('Yes')
else:
print('No') | s616277689 | Accepted | 17 | 2,940 | 102 | S = input()
# S = 'abc'
if('a' in S and 'b' in S and 'c' in S):
print('Yes')
else:
print('No') |
s185539754 | p03997 | u288087195 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 77 | 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. | t = [int(input()) for i in range(3)]
total = (t[0]+t[1])*t[2]/2
print(total) | s360295777 | Accepted | 17 | 2,940 | 80 | t = [int(input()) for i in range(3)]
sum = (t[0]+t[1])* t[2]/2
print(int(sum))
|
s416588816 | p03502 | u639426108 | 2,000 | 262,144 | Wrong Answer | 19 | 3,064 | 196 | 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. | A = int(input())
N = A
a = []
for i in reversed(range(len(str(N)))):
a.append(int(N/10**(i)))
N -= int(N/10**i)*10**i
X = sum(a)
print(X)
print(a)
if A % X == 0:
print("Yes")
else:
print("No") | s244255918 | Accepted | 18 | 3,060 | 178 | A = int(input())
N = A
a = []
for i in reversed(range(len(str(N)))):
a.append(int(N/10**(i)))
N -= int(N/10**i)*10**i
X = sum(a)
if A % X == 0:
print("Yes")
else:
print("No") |
s409104697 | p03455 | u288696571 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 105 | 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())
sum = a + b
if sum % 2 == 0:
print ("even")
else :
print ("odd")
| s409384555 | Accepted | 17 | 2,940 | 106 | a,b = map(int, input().split())
sum = a * b
if sum % 2 == 0 :
print ("Even")
else :
print ("Odd")
|
s949799921 | p02417 | u539753516 | 1,000 | 131,072 | Wrong Answer | 20 | 5,548 | 92 | Write a program which counts and reports the number of each alphabetical letter. Ignore the case of characters. | s=input()
for str in list("abcdefghijklmnopqrstuvwxyz"):
print(*[str,":",s.count(str)])
| s682722559 | Accepted | 20 | 5,564 | 148 | import sys
s = ""
for line in sys.stdin:
s+=line
s=s.lower()
for str in list("abcdefghijklmnopqrstuvwxyz"):
print(*[str,":",s.count(str)])
|
s951837301 | p03494 | u440161695 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 171 | 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()))
mini=100100100100
for i in range(N):
a=i
c=0
while a%2!=0:
a//=2
c+=1
if mini>c:
mini=c
print(mini) | s057077517 | Accepted | 19 | 2,940 | 121 | input()
A=list(map(int,input().split()))
ans=0
while all(a%2==0 for a in A):
A=[a/2 for a in A]
ans+=1
print(ans) |
s836727106 | p03644 | u432226259 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 315 | 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... | def devide(dev):
count = 0
while dev % 2 == 0:
dev /= 2
count += 1
return count
n = int(input())
count_cal = []
for i in range(1, n+1):
count_cal.append(devide(i))
MAX = count_cal[0]
for k in range(len(count_cal)):
if MAX <= count_cal[k]:
MAX = count_cal[k]
ans = k
print(count_cal)
print(ans + 1) | s494939958 | Accepted | 17 | 3,064 | 298 | def devide(dev):
count = 0
while dev % 2 == 0:
dev /= 2
count += 1
return count
n = int(input())
count_cal = []
for i in range(1, n+1):
count_cal.append(devide(i))
MAX = count_cal[0]
for k in range(len(count_cal)):
if MAX <= count_cal[k]:
MAX = count_cal[k]
ans = k
print(ans + 1) |
s050826297 | p02678 | u930574673 | 2,000 | 1,048,576 | Wrong Answer | 2,250 | 42,768 | 633 | 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 th... | N, M = [int(x) for x in input().split()]
path = []
for i in range(M):
t1, t2 = [int(x) for x in input().split()]
if t1 < t2:
path.append((t1, t2))
else:
path.append((t2, t1))
path.sort()
print(path)
bread = [1] + [0] * (N-1)
while True:
for i in reversed(range(len(path))):
if bread[path[i][0]-1] == ... | s853425319 | Accepted | 1,449 | 59,440 | 460 | N, M = [int(x) for x in input().split()]
path = []
for i in range(N):
path.append([])
for i in range(M):
t1, t2 = [int(x) for x in input().split()]
path[t1-1].append((t1,t2))
path[t2-1].append((t2,t1))
l = [1]
ans = [1] + [0] * (N-1)
while len(l) > 0:
t = l.pop(0)
for i in range(len(path[t-1])):
if ans[... |
s049919077 | p03545 | u757117214 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 178 | 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 in... | import sys
a,b,c,d=[i for i in input()]
op=["+","-"]
for i in op:
for j in op:
for k in op:
if eval(a+i+b+j+c+k+d)==7:
print(a+i+b+j+c+k+d)
sys.exit() | s002729948 | Accepted | 20 | 3,060 | 225 | S = input()
def saiki(i,s):
if i == 3:
if eval(s) == 7:
print(str(s) + "=7")
exit()
else:
return
saiki(i+1,s+"+"+S[i+1])
saiki(i+1,s+"-"+S[i+1])
saiki(0,S[0])
|
s497488815 | p03110 | u826557401 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 229 | 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`... | N = int(input())
sum_jpy = 0
sum_bit = 0
sum_all = 0
for _ in range(N):
x,u = map(str, input().split())
if u == "JPY":
sum_jpy += int(x)
else:
sum_bit += float(x)
sum_all = int(sum_jpy + 380000 * sum_bit)
print(sum_all) | s690298260 | Accepted | 17 | 3,060 | 244 | N = int(input())
sum_jpy = 0.0
sum_bit = 0.0
sum_all = 0.0
btc = 380000.0
for _ in range(N):
x,u = map(str, input().split())
if u == "JPY":
sum_jpy += float(x)
else:
sum_bit += float(x)
sum_all = sum_jpy + btc * sum_bit
print(sum_all) |
s287816129 | p03171 | u221301671 | 2,000 | 1,048,576 | Wrong Answer | 2,112 | 17,616 | 222 | Taro and Jiro will play the following game against each other. Initially, they are given a sequence a = (a_1, a_2, \ldots, a_N). Until a becomes empty, the two players perform the following operation alternately, starting from Taro: * Remove the element at the beginning or the end of a. The player earns x points, w... | import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()], dtype=np.int64)
s = np.copy(a)
for i in range(1, n):
s = np.maximum(a[:n-i]-s[1:n-i+1], a[i:]-s[:n-i])
print(i, s)
print(s[0])
| s401560476 | Accepted | 191 | 12,500 | 206 | import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()], dtype=np.int64)
s = np.copy(a)
for i in range(1, n):
s = np.maximum(a[:n-i]-s[1:n-i+1], a[i:]-s[:n-i])
print(s[0])
|
s836058314 | p03697 | u513081876 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 78 | You are given two integers A and B as the input. Output the value of A + B. However, if A + B is 10 or greater, output `error` instead. | a, b = map(int, input().split())
if a+b >= 10:print('error')
else:print('a+b') | s035683710 | Accepted | 18 | 2,940 | 76 | a, b = map(int, input().split())
if a+b >= 10:print('error')
else:print(a+b) |
s914812082 | p03861 | u784022244 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 149 | 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())
#a<=n<=b
if a%x==0:
first=a//x
else:
first=(a//x)*x+x
if first>b:
print(0)
else:
print((b-first)//x+1)
| s540605975 | Accepted | 17 | 3,068 | 113 | a,b,x=map(int, input().split())
MIN=a+(x-a%x)%x
#print(MIN)
if MIN>b:
print(0)
else:
print(1+(b-MIN)//x) |
s373684685 | p03160 | u450904670 | 2,000 | 1,048,576 | Wrong Answer | 404 | 13,924 | 336 | There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of... | n = int(input())
h = list(map(int, input().split()))
dp = [ 10**10 for _ in range(n)]
dp[0] = 0
dp[1] = dp[0] + abs(h[1] - h[0])
if(n > 2):
for i in range(2, n):
dp[i] = min([dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2])])
print(i, dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2]... | s955698234 | Accepted | 153 | 13,976 | 259 | n = int(input())
h = list(map(int, input().split()))
dp = [ 10**10 for _ in range(n)]
dp[0] = 0
dp[1] = dp[0] + abs(h[1] - h[0])
if(n > 2):
for i in range(2, n):
dp[i] = min([dp[i-1] + abs(h[i] - h[i - 1]), dp[i-2] + abs(h[i] - h[i - 2])])
print(dp[-1]) |
s371349847 | p03999 | u630211216 | 2,000 | 262,144 | Wrong Answer | 27 | 8,972 | 223 | 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. ... | S=input()
N=len(S)
ans=2**(N-1)*int(S[-1])
for i in range(1<<(N-1)):
res=1
for j in range(N-1):
if (i>>j)%2==1:
res*=10
else:
res=1
ans+=res*int(S[N-1-j])
print(ans)
| s398136151 | Accepted | 28 | 9,180 | 223 | S=input()
N=len(S)
ans=2**(N-1)*int(S[-1])
for i in range(1<<(N-1)):
res=1
for j in range(N-1):
if (i>>j)%2==1:
res*=10
else:
res=1
ans+=res*int(S[N-2-j])
print(ans)
|
s771981835 | p03698 | u752898745 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 48 | 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(s))::2]) | s768428666 | Accepted | 18 | 2,940 | 48 | s=input()
print("yneos"[len(s)!=len(set(s))::2]) |
s322797522 | p03417 | u982762220 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 154 | There is a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially every card faces up. We will perform the following op... | N, M = map(int, input().split())
s, l = min(N, M), max(N, M)
if s == 1:
print(l - 1)
elif s == 2:
print(l)
else:
print(s * l - (s * 2 + l * 2 - 4)) | s560712545 | Accepted | 17 | 3,060 | 188 | N, M = map(int, input().split())
s, l = min(N, M), max(N, M)
if s == 1 and l == 1:
print(1)
elif s == 1:
print(l - 2)
elif s == 2:
print(0)
else:
print(s * l - (s * 2 + l * 2 - 4)) |
s984796784 | p02612 | u586639900 | 2,000 | 1,048,576 | Wrong Answer | 26 | 9,144 | 45 | 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())
res = N // 1000
print(res) | s167981036 | Accepted | 28 | 9,156 | 105 | N = int(input())
reminder = N % 1000
if reminder:
res = 1000 - reminder
print(res)
else:
print(0) |
s859630673 | p03607 | u612975321 | 2,000 | 262,144 | Wrong Answer | 148 | 9,080 | 120 | You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many... | n = int(input())
d = {}
for i in range(n):
a = int(input())
if a in d:
d[a] ^= 1
print(sum(d.values())) | s252708675 | Accepted | 170 | 19,140 | 147 | n = int(input())
d = {}
for i in range(n):
a = int(input())
if a in d:
d[a] ^= 1
else:
d[a] = 1
print(sum(d.values())) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.