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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s122779256
|
p03698
|
u934442292
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,776 | 127 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
import string
al = string.ascii_lowercase
S = input()
ans = "Yes"
for a in al:
if S.count(a) > 1:
ans = "No"
print(ans)
|
s911119712
|
Accepted
| 26 | 3,776 | 127 |
import string
al = string.ascii_lowercase
S = input()
ans = "yes"
for a in al:
if S.count(a) > 1:
ans = "no"
print(ans)
|
s319396807
|
p02917
|
u881141729
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 288 |
There is an integer sequence A of length N whose values are unknown. Given is an integer sequence B of length N-1 which is known to satisfy the following: B_i \geq \max(A_i, A_{i+1}) Find the maximum possible sum of the elements of A.
|
while True:
try:
num = int(input())
lst = list(map(int, input().split()))
point = lst[-1]
ans = 0
for n in lst[-1::-1]:
point = min(point, n)
ans += point
ans += point
print(ans)
except:
break
|
s615480679
|
Accepted
| 17 | 3,060 | 326 |
while True:
try:
num = int(input())
lst = list(map(int, input().split()))
ans = 0
ans += lst[-1] + lst[0]
if num == 2:
print(ans)
continue
for i in range(1, num-1):
ans += min(lst[i], lst[i-1])
print(ans)
except:
break
|
s588614931
|
p03861
|
u902130170
| 2,000 | 262,144 |
Wrong Answer
| 2,104 | 2,940 | 131 |
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())
count = 0
for i in range(a,b):
if(i % x):
count += 1
print(count)
|
s520002015
|
Accepted
| 18 | 2,940 | 181 |
a, b, x = map(int, input().split())
all_count = 0
dev = 0
if b > 0:
all_count = b // x
if a > 0:
dev = (a-1) // x
else:
dev = -1
print(all_count - dev)
|
s727904482
|
p02659
|
u984276646
| 2,000 | 1,048,576 |
Wrong Answer
| 26 | 9,092 | 60 |
Compute A \times B, truncate its fractional part, and print the result as an integer.
|
A, B = map(float, input().split())
F = A * B
print(round(F))
|
s633512467
|
Accepted
| 22 | 9,164 | 81 |
A, B = input().split()
A = int(A)
B = float(B)
X = A * round(100*B)
print(X//100)
|
s981091338
|
p02612
|
u111652094
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,132 | 31 |
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)
|
s192867042
|
Accepted
| 32 | 9,152 | 71 |
N=int(input())
if N%1000==0:
print(0)
else:
print(1000-N%1000)
|
s740812959
|
p02612
|
u670469727
| 2,000 | 1,048,576 |
Wrong Answer
| 30 | 9,056 | 34 |
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)
|
s981842764
|
Accepted
| 31 | 9,152 | 80 |
n = int(input())
m = n % 1000
if m == 0:
print(0)
else:
print(1000 - m)
|
s621336893
|
p02936
|
u896741788
| 2,000 | 1,048,576 |
Wrong Answer
| 2,109 | 117,924 | 657 |
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.
|
m=lambda:map(int,input().split())
n,q=m()
edges=[set()for _ in range(n)]
for i in range(n-1):
a,b=m()
a-=1;b-=1
edges[a].add(b);edges[b].add(a)
rank={}
R=[0]
par={}
r=0;rep=[];pre=[0]
cnt=n-1
ok=[0]*n
ok[0]=1
while cnt!=0:
ret=0;r+=1
for i in pre:
for j in edges[i]:
if ok[j]:continue
ok[j]=1
rank[j]=r
ret+=1
par[j]=i
rep.append(j)
cnt-=ret
pre=rep;rep=[]
R+=pre
cou=[0]*n
for _ in range(q):
root,v=m()
root-=1
cou[root]+=v
rcou=[0]*n;rcou[0]=cou[0]
print(cou[0])
for i in R[1:]:
p=cou[i]+rcou[par[i]]
print(p)
rcou[i]=p
|
s236051528
|
Accepted
| 917 | 234,440 | 652 |
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n, q = map(int, input().split())
edges=[[] for i in range(1+n)]
for i in range(n-1):
_,__=map(int,input().split())
edges[_].append(__)
edges[__].append(_)
"""
"""
cnt=[0]*(1+n)
for i in range(q):
x,p=map(int,input().split())
cnt[x]+=p
def f(now,pars_value,par):
cnt[now]+=pars_value
a=cnt[now]
for i in edges[now]:
if i!=par:f(i,a,now)
f(1,0,-1)
print(*cnt[1:])
|
s514372197
|
p02536
|
u288430479
| 2,000 | 1,048,576 |
Wrong Answer
| 308 | 12,960 | 1,299 |
There are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: * Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?
|
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m = map(int,input().split())
u = UnionFind(n)
for i in range(m):
a,b = map(int,input().split())
u.union(a-1,b-1)
a = u.roots()
print(len(a))
|
s331895114
|
Accepted
| 326 | 12,932 | 1,301 |
class UnionFind():
def __init__(self, n):
self.n = n
self.parents = [-1] * n
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
def size(self, x):
return -self.parents[self.find(x)]
def same(self, x, y):
return self.find(x) == self.find(y)
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
def group_count(self):
return len(self.roots())
def all_group_members(self):
return {r: self.members(r) for r in self.roots()}
def __str__(self):
return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m = map(int,input().split())
u = UnionFind(n)
for i in range(m):
a,b = map(int,input().split())
u.union(a-1,b-1)
a = u.roots()
print(len(a)-1)
|
s615669034
|
p02601
|
u471217476
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,172 | 137 |
M-kun has the following three cards: * A red card with the integer A. * A green card with the integer B. * A blue card with the integer C. He is a genius magician who can do the following operation at most K times: * Choose one of the three cards and multiply the written integer by 2. His magic is successful if both of the following conditions are satisfied after the operations: * The integer on the green card is **strictly** greater than the integer on the red card. * The integer on the blue card is **strictly** greater than the integer on the green card. Determine whether the magic can be successful.
|
a,b,c=map(int,input().split())
k=int(input())
c=0
while a>=b:
b*=2
c+=1
while b>=c:
c*=2
c+=1
if c<=k:
print('Yes')
else:print('No')
|
s258540739
|
Accepted
| 29 | 9,200 | 145 |
a,b,c=map(int,input().split())
k=int(input())
ans=0
while a>=b:
b*=2
ans+=1
while b>=c:
c*=2
ans+=1
if ans<=k:
print('Yes')
else:print('No')
|
s105574583
|
p04044
|
u510331904
| 2,000 | 262,144 |
Wrong Answer
| 26 | 8,952 | 24 |
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.
|
#!/usr/bin/env python3
|
s191541417
|
Accepted
| 29 | 9,084 | 100 |
N, L = [int(i) for i in input().split()]
S = sorted([input() for _ in range(N)])
print(*S, sep="")
|
s283157432
|
p02603
|
u614381513
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,100 | 449 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
n = int(input())
a = list(map(int, input().split()))
prev = a[0]
mon = 1000
stc = 0
for i in range(1, n):
print(prev)
if prev < a[i]:
stc = mon // prev
mon = mon - stc * prev
print("stc = {} mon = {}" .format(stc, mon))
elif prev > a [i]:
mon = mon + stc * prev
stc = 0
print("stc = {} mon = {}" .format(stc, mon))
prev = a[i]
if stc != 0:
mon = mon + stc * a[n - 1]
print(mon)
|
s739756276
|
Accepted
| 27 | 9,072 | 434 |
n = int(input())
a = list(map(int, input().split()))
prev = a[0]
mon = 1000
stc = 0
for i in range(1, n):
#print(prev)
if prev < a[i]:
stc = mon // prev
mon = mon - stc * prev
mon = stc * a[i] + mon
#print("stc = {} mon = {}" .format(stc, mon))
elif prev >= a [i]:
pass
#print("stc = {} mon = {}" .format(stc, mon))
prev = a[i]
#mon = mon + stc * a[n - 1]
print(mon)
|
s352813443
|
p02842
|
u038724782
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 145 |
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())
n0 = int(n/1.08)
while int(n0 * 1.08) < n:
n0 += 1
if int(n0 * 1.08) == n:
print(int(n0 * 1.08))
else:
print(':(')
|
s467181162
|
Accepted
| 17 | 2,940 | 133 |
n = int(input())
n0 = int(n/1.08)
while int(n0 * 1.08) < n:
n0 += 1
if int(n0 * 1.08) == n:
print(n0)
else:
print(':(')
|
s945443957
|
p03729
|
u403301154
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 92 |
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
|
a, b, c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
print("Yes")
else:
print("No")
|
s429767962
|
Accepted
| 17 | 2,940 | 92 |
a, b, c = input().split()
if a[-1]==b[0] and b[-1]==c[0]:
print("YES")
else:
print("NO")
|
s554096414
|
p03944
|
u288786530
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 365 |
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
|
(w, h, n) = map(int, input().split())
minx = 0
maxx = w
miny = 0
maxy = h
for i in range(n):
x, y, a = map(int, input().split())
if a == 1:
maxx = min(maxx, x)
elif a == 2:
minx = max(minx, x)
elif a == 3:
maxy = min(maxy, y)
else:
miny = max(miny, y)
ans = (maxx - minx) * (maxy - miny)
if minx < maxx and miny < maxy:
print(ans)
else:
print(0)
|
s609599026
|
Accepted
| 17 | 3,064 | 367 |
(w, h, n) = map(int, input().split())
minx = 0
maxx = w
miny = 0
maxy = h
for i in range(n):
x, y, a = map(int, input().split())
if a == 2:
maxx = min(maxx, x)
elif a == 1:
minx = max(minx, x)
elif a == 4:
maxy = min(maxy, y)
else:
miny = max(miny, y)
ans = (maxx - minx) * (maxy - miny)
if minx < maxx and miny < maxy:
print(ans)
else:
print(0)
|
s051263464
|
p03474
|
u073606136
| 2,000 | 262,144 |
Wrong Answer
| 31 | 8,992 | 412 |
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.
|
import math
is_no = 0
num1, num2 = map(int, input().split())
str1 = input()
table = list(str1)
print(table)
for i in range(num1):
if table[i].isdigit():
continue
else:
is_no = 1
if table[num1] != '-':
is_no = 1
for j in range(num2, num1+num2+1):
if table[j].isdigit():
continue
else:
is_no = 1
if is_no == 0:
print('Yes')
elif is_no == 1:
print('No')
|
s453190158
|
Accepted
| 29 | 9,088 | 279 |
import math
is_no = 0
num1, num2 = map(int, input().split())
str1 = input()
table = list(str1)
count = 0
for i in range(len(str1)):
if table[i] == '-':
count += 1
else:
continue
if count == 1 and table[num1] =='-':
print('Yes')
else:
print('No')
|
s434237959
|
p03597
|
u407016024
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 47 |
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*2-A)
|
s878646041
|
Accepted
| 17 | 2,940 | 48 |
N = int(input())
A = int(input())
print(N**2-A)
|
s529860048
|
p03486
|
u166340293
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 178 |
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()
s=[str(a) for a in S]
t=[str(b) for b in T]
s.sort()
t.sort(reverse=True)
s=''.join(s)
t=''.join(t)
print(s)
if s[0]<t[0]:
print ("Yes")
else:
print("No")
|
s527424613
|
Accepted
| 16 | 3,060 | 163 |
S=input()
T=input()
s=[str(a) for a in S]
t=[str(b) for b in T]
s.sort()
t.sort(reverse=True)
s=''.join(s)
t=''.join(t)
if s<t:
print ("Yes")
else:
print("No")
|
s788632463
|
p02260
|
u637322311
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 495 |
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.
|
def print_list(A):
print(*A, sep=" ")
def swap(a, b):
return b, a
def find_minj(A, i, n):
minj = i
for j in range(i, n):
if A[j] < A[minj]:
minj = j
return minj
def selection_sort(A, n):
print_list(A)
replace_num = 0
for i in range(0, n):
minj = find_minj(A, i, n)
A[i], A[minj] = swap(A[i], A[minj])
replace_num += 1
print(replace_num)
n = int(input())
A = list(map(int,input().split()))
selection_sort(A, n)
|
s762032702
|
Accepted
| 20 | 5,608 | 530 |
def print_list(A):
print(*A, sep=" ")
def swap(a, b):
return b, a
def find_minj(A, i, n):
minj = i
for j in range(i, n):
if A[j] < A[minj]:
minj = j
return minj
def selection_sort(A, n):
replace_num = 0
for i in range(0, n):
minj = find_minj(A, i, n)
if A[i] > A[minj]:
A[i], A[minj] = swap(A[i], A[minj])
replace_num += 1
print_list(A)
print(replace_num)
n = int(input())
A = list(map(int,input().split()))
selection_sort(A, n)
|
s901412388
|
p03377
|
u385309449
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 106 |
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.
|
x,y,z = map(int,input().split())
if x > z :
print('No')
elif x+y < x:
print('No')
else:
print('Yes')
|
s439460500
|
Accepted
| 17 | 2,940 | 106 |
x,y,z = map(int,input().split())
if x > z :
print('NO')
elif x+y < z:
print('NO')
else:
print('YES')
|
s375929802
|
p02612
|
u133236239
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,156 | 126 |
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.
|
money = int(input())
for i in range(1, 10):
if money < i * 1000 :
print(i * 1000 - money)
else:
pass
|
s462438422
|
Accepted
| 29 | 9,060 | 58 |
money = int(input())
print((1000 - money % 1000) % 1000)
|
s572450557
|
p03605
|
u853900545
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 50 |
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=input()
print(('No','Yes') [n[1]==9 or n[0]==9])
|
s708690529
|
Accepted
| 17 | 2,940 | 59 |
n=str(input())
print(('No','Yes') [n[1]=='9' or n[0]=='9'])
|
s287257377
|
p02795
|
u185424824
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 72 |
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
H = int(input())
W = int(input())
N = int(input())
print(N // max(H,W))
|
s735481488
|
Accepted
| 17 | 2,940 | 132 |
H = int(input())
W = int(input())
N = int(input())
if N % max(H,W) == 0:
print(N // max(H,W))
else:
print(N // max(H,W) + 1)
|
s995619457
|
p03711
|
u777028980
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 227 |
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.
|
a,b=map(int,input().split())
if(a==4 or a==6 or a==9 or a==11):
aa=2
elif(a==2):
aa=3
else:
aa=1
if(b==4 or b==6 or b==9 or b==11):
bb=2
elif(b==2):
bb=3
else:
bb=1
if(aa==bb):
print("YES")
else:
print("NO")
|
s828736973
|
Accepted
| 18 | 3,064 | 227 |
a,b=map(int,input().split())
if(a==4 or a==6 or a==9 or a==11):
aa=2
elif(a==2):
aa=3
else:
aa=1
if(b==4 or b==6 or b==9 or b==11):
bb=2
elif(b==2):
bb=3
else:
bb=1
if(aa==bb):
print("Yes")
else:
print("No")
|
s592623763
|
p04012
|
u493916575
| 2,000 | 262,144 |
Wrong Answer
| 23 | 3,064 | 151 |
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
|
w = input()
cnt = 26*[0]
for i in w:
cnt[ord(i)-ord("a")] += 1
for c in cnt:
if c % 2 != 0:
print("NO")
exit()
print("YES")
|
s033999724
|
Accepted
| 24 | 3,188 | 151 |
w = input()
cnt = 26*[0]
for i in w:
cnt[ord(i)-ord("a")] += 1
for c in cnt:
if c % 2 != 0:
print("No")
exit()
print("Yes")
|
s081090837
|
p03449
|
u222841610
| 2,000 | 262,144 |
Wrong Answer
| 38 | 3,828 | 475 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
count = 0
max1 = 0
for i in range(n):
for j in range(n):
if j < i:
count += a1[j]
print (i,j,count)
elif j==i:
count += (a1[j] + a2[j])
print (i,j,count)
else:
count += a2[j]
print (i,j,count)
if max1 < count:
max1 = count
print (count,max1)
count = 0
print (max1)
|
s784808780
|
Accepted
| 18 | 3,060 | 167 |
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
m = 0
for i in range(n):
m = max(m, sum(a1[:i+1])+sum(a2[i:]))
print (m)
|
s230313401
|
p03435
|
u819208902
| 2,000 | 262,144 |
Wrong Answer
| 219 | 12,232 | 802 |
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left. According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j. Determine if he is correct.
|
import numpy as np
if __name__ == '__main__':
rows = []
for i in range(3):
rows.append([int(i) for i in input().split()])
mat = np.matrix(rows)
upper_a = [mat[i, :].max() for i in range(3)]
upper_b = [mat[:, i].max() for i in range(3)]
print(upper_a)
print(upper_b)
for a1 in range(upper_a[0]):
bs = [v - a1 for v in mat[0, :].tolist()[0]]
# print(bs)
for a2 in range(upper_a[1]):
vals = [a2 + b for b in bs]
# print(vals)
if vals == mat[1, :].tolist()[0]:
for a3 in range(upper_a[2]):
vals = [a3 + b for b in bs]
if vals == mat[2, :].tolist()[0]:
print('Yes')
exit(0)
print('No')
|
s029554709
|
Accepted
| 223 | 13,240 | 804 |
import numpy as np
if __name__ == '__main__':
rows = []
for i in range(3):
rows.append([int(i) for i in input().split()])
mat = np.matrix(rows)
upper_a = [mat[i, :].max() for i in range(3)]
upper_b = [mat[:, i].max() for i in range(3)]
# print(upper_a)
# print(upper_b)
for a1 in range(upper_a[0]+1):
bs = [v - a1 for v in mat[0, :].tolist()[0]]
# print(bs)
for a2 in range(upper_a[1]+1):
vals = [a2 + b for b in bs]
# print(vals)
if vals == mat[1, :].tolist()[0]:
for a3 in range(upper_a[2]+1):
vals = [a3 + b for b in bs]
if vals == mat[2, :].tolist()[0]:
print('Yes')
exit(0)
print('No')
|
s785066755
|
p02612
|
u518958552
| 2,000 | 1,048,576 |
Wrong Answer
| 28 | 9,076 | 32 |
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.
|
s = int(input())
print(s % 1000)
|
s890485638
|
Accepted
| 30 | 9,152 | 80 |
s = int(input())
if s % 1000 == 0:
print(0)
else:
print(1000 - s % 1000)
|
s136090276
|
p03007
|
u956194864
| 2,000 | 1,048,576 |
Wrong Answer
| 44 | 13,936 | 92 |
There are N integers, A_1, A_2, ..., A_N, written on a blackboard. We will repeat the following operation N-1 times so that we have only one integer on the blackboard. * Choose two integers x and y on the blackboard and erase these two integers. Then, write a new integer x-y. Find the maximum possible value of the final integer on the blackboard and a sequence of operations that maximizes the final integer.
|
n = int(input())
ai = [int(x) for x in input().split()]
print(6)
print(-1, 1)
print(2, -4)
|
s000413000
|
Accepted
| 1,776 | 14,264 | 403 |
n = int(input())
ai = [int(x) for x in input().split()]
ai.sort()
temp = [abs(x) for x in ai[1:-1]]
o1 = -ai[0] + sum(temp) + ai[-1]
print(o1)
temp1 = ai.pop(-1)
num_p = sum(x >= 0 for x in ai)
if num_p == len(ai):
num_p -= 1
for i in range(num_p):
temp2 = ai.pop(-1)
print(ai[0], temp2)
ai[0] -= temp2
for i in range(len(ai)):
temp2 = ai.pop(0)
print(temp1, temp2)
temp1 -= temp2
|
s598033426
|
p02796
|
u888092736
| 2,000 | 1,048,576 |
Wrong Answer
| 350 | 36,088 | 218 |
In a factory, there are N robots placed on a number line. Robot i is placed at coordinate X_i and can extend its arms of length L_i in both directions, positive and negative. We want to remove zero or more robots so that the movable ranges of arms of no two remaining robots intersect. Here, for each i (1 \leq i \leq N), the movable range of arms of Robot i is the part of the number line between the coordinates X_i - L_i and X_i + L_i, excluding the endpoints. Find the maximum number of robots that we can keep.
|
(N,), *XL = [list(map(int, s.split())) for s in open(0)]
XL.sort(key=lambda x: x[0] + x[1])
print(XL)
curr = -float("inf")
ans = 0
for x, l in XL:
if x - l >= curr:
curr = x + l
ans += 1
print(ans)
|
s405427146
|
Accepted
| 223 | 25,876 | 226 |
N, *XL = map(int, open(0).read().split())
XL = sorted((x + l, x - l) for x, l in zip(*[iter(XL)] * 2))
curr = -float("inf")
ans = 0
for right, left in XL:
if left >= curr:
curr = right
ans += 1
print(ans)
|
s184494810
|
p03149
|
u642012866
| 2,000 | 1,048,576 |
Wrong Answer
| 25 | 9,076 | 51 |
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".
|
print("YNeos"["".join(sorted(input()))!="1479"::2])
|
s939075809
|
Accepted
| 26 | 9,096 | 59 |
print("YNEOS"["".join(sorted(input().split()))!="1479"::2])
|
s301551376
|
p03544
|
u046136258
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 93 |
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n=int(input())
rec=[2,1]
for i in range(2,n):
rec.append(rec[i-2]+rec[i-1])
print(rec[n-1])
|
s643747048
|
Accepted
| 17 | 2,940 | 113 |
n=int(input())
rec=[2,1]
if n>=2:
for i in range(2,n+1):
rec.append(rec[i-2]+rec[i-1])
print(rec[n])
|
s291252879
|
p02413
|
u150984829
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 144 |
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
r=int(input().split()[0])
m=[list(map(int,input().split()))for _ in[0]*r]
for s in m:s.append(sum(s))or print(*s)
print(sum(c)for c in zip(*m))
|
s051604608
|
Accepted
| 20 | 6,264 | 132 |
m=[[*map(int,input().split())]for _ in[0]*int(input().split()[0])]
for s in m:s.append(sum(s))or print(*s)
print(*map(sum,zip(*m)))
|
s352899736
|
p03711
|
u996252264
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 733 |
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.
|
def rren(): return list(map(int, input().split()))
H, W = rren()
if(H % 3 == 0 or W % 3 == 0):
print(0)
else:
lis = []
ans = 114514810
for i in range(H-1):
for j in range(10):
a = H - i
b = i
c = abs(W // 2 + j)
lis = [W*a, b*c, (W-c)*b]
ans = min(ans, max(lis) - min(lis))
lis.clear()
for i in range(W-1):
for j in range(10):
a = W - i
b = i
c = abs(H // 2 + j)
lis = [H*a, b*c, (H-c)*b]
ans = min(ans, max(lis) - min(lis))
lis.clear()
for i in range(W//4, W//2):
ans = min(ans, abs(i - (W-i*2))*H)
for i in range(H//4, H//2):
ans = min(ans, abs(i - (H-i*2))*W)
print(ans)
|
s925362926
|
Accepted
| 20 | 3,316 | 272 |
def rren(): return list(map(int, input().split()))
a = ["1 3 5 7 8 10 12".split(), "4 6 9 11".split(), ["2"]]
x, y = rren()
flag = False
for i in range(3):
if(str(x) in a[i] and str(y) in a[i]):
flag = True
if(flag):
print("Yes")
else:
print("No")
|
s034938761
|
p03612
|
u572373398
| 2,000 | 262,144 |
Wrong Answer
| 87 | 13,880 | 282 |
You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can perform the following operation any number of times (possibly zero): Operation: Swap two **adjacent** elements in the permutation. You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of operations to achieve this.
|
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i, num in enumerate(p):
if i + 1 == p[i]:
temp = p[i]
try:
p[i] = p[i + 1]
p[i + 1] = temp
except IndexError:
pass
ans += 1
print(ans)
print(p)
|
s307151783
|
Accepted
| 77 | 14,004 | 273 |
N = int(input())
p = list(map(int, input().split()))
ans = 0
for i, num in enumerate(p):
if i + 1 == p[i]:
temp = p[i]
try:
p[i] = p[i + 1]
p[i + 1] = temp
except IndexError:
pass
ans += 1
print(ans)
|
s292009262
|
p03478
|
u033719192
| 2,000 | 262,144 |
Wrong Answer
| 33 | 2,940 | 150 |
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
|
N, A, B = map(int, input().split())
count = 0
for i in range(N + 1):
if A <= sum([int(s) for s in str(i)]) <= B:
count += 1
print(count)
|
s181421451
|
Accepted
| 32 | 2,940 | 151 |
N, A, B = map(int, input().split())
total = 0
for i in range(N + 1):
if A <= sum([int(s) for s in str(i)]) <= B:
total += i
print(total)
|
s931370950
|
p03635
|
u668503853
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 53 |
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
s=input()
a=s[0]
b=s[-1]
m=str(len(s)-2)
print(a+m+b)
|
s342774033
|
Accepted
| 17 | 2,940 | 47 |
n,m=map(int,input().split())
print((n-1)*(m-1))
|
s995017207
|
p03409
|
u684026548
| 2,000 | 262,144 |
Wrong Answer
| 35 | 3,684 | 456 |
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i). A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point. At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
|
n = int(input())
a = []
c = []
for i in range(n):
a.append([int(i) for i in input().split()])
for i in range(n):
c.append([int(i) for i in input().split()])
a = sorted(a)
c = sorted(c)
count = 0
while len(a) > 0:
ta, tb = a.pop()
i = len(c) - 1
while i > 0:
tc, td = c[i]
print(ta, tb, tc, td)
if ta < tc and tb < td:
count += 1
c.pop(i)
break
i -= 1
print(count)
|
s130141775
|
Accepted
| 19 | 3,064 | 410 |
n = int(input())
a = []
c = []
for i in range(n):
a.append([int(i) for i in input().split()])
for i in range(n):
c.append([int(i) for i in input().split()])
a.sort(key=lambda x:x[1], reverse=True)
c = sorted(c)
count = 0
for i, (tc, td) in enumerate(c):
for j, (ta, tb) in enumerate(a):
if ta < tc and tb < td:
count += 1
a.pop(j)
break
print(count)
|
s037806694
|
p02608
|
u362599643
| 2,000 | 1,048,576 |
Wrong Answer
| 58 | 16,996 | 252 |
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
|
N = int(input())
record = [0] * 1000000
for i in range(1,N):
for j in range(1,N):
sum = i**2 + i**2 + j**2 + i*i + i*j +j*i
if sum >= N: break
# print(i,j)
record[sum] += 3
for num in record[1:N+1]:
print(num)
|
s715239979
|
Accepted
| 158 | 9,272 | 380 |
n = int(input())
ans = [0 for _ in range(n+1)]
x = 1
y = 1
z = 1
while True:
f = x * x + y * y + z * z + x * y + y * z + z * x
if f > n:
if z > 1:
y += 1
z = 1
elif y > 1:
x += 1
y = 1
else:
break
else:
ans[f] += 1
z += 1
for i in range(1, n+1):
print(ans[i])
|
s847885065
|
p02412
|
u548155360
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,544 | 213 |
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 == 0 and x == 0:
break
ctr = 0
for i in range(1, N+1):
for j in range(i+1, N+1):
k = x - i -j
if k <= N and i != k and j != k:
ctr += 1
|
s471754497
|
Accepted
| 30 | 7,580 | 279 |
while True:
N, x = map(int,input().split())
if N == 0 and x == 0:
break
ctr = 0
for i in range(1, N+1):
for j in range(i+1, N+1):
k = x - i -j
if k <= j:
break
elif k <= N and j < k:
ctr += 1
#print("{} {} {}".format(i, j, k))
print(ctr)
|
s942807243
|
p03965
|
u667024514
| 2,000 | 262,144 |
Wrong Answer
| 49 | 3,956 | 194 |
AtCoDeer the deer and his friend TopCoDeer is playing a game. The game consists of N turns. In each turn, each player plays one of the two _gestures_ , _Rock_ and _Paper_ , as in Rock-paper-scissors, under the following condition: (※) After each turn, (the number of times the player has played Paper)≦(the number of times the player has played Rock). Each player's score is calculated by (the number of turns where the player wins) - (the number of turns where the player loses), where the outcome of each turn is determined by the rules of Rock-paper-scissors. _(For those who are not familiar with Rock-paper-scissors: If one player plays Rock and the other plays Paper, the latter player will win and the former player will lose. If both players play the same gesture, the round is a tie and neither player will win nor lose.)_ With his supernatural power, AtCoDeer was able to foresee the gesture that TopCoDeer will play in each of the N turns, before the game starts. Plan AtCoDeer's gesture in each turn to maximize AtCoDeer's score. The gesture that TopCoDeer will play in each turn is given by a string s. If the i-th (1≦i≦N) character in s is `g`, TopCoDeer will play Rock in the i-th turn. Similarly, if the i-th (1≦i≦N) character of s in `p`, TopCoDeer will play Paper in the i-th turn.
|
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
if cou > 0 and lis[i] == "g":
cou -= 1
ans += 1
else:
cou += 1
if lis[i] == "p":
ans -= 1
print(ans - cou)
|
s996939151
|
Accepted
| 44 | 3,956 | 222 |
lis = list(input())
cou = 0
ans = 0
for i in range(len(lis)):
if lis[i] == "g":
if cou > 0:
cou -= 1
ans += 1
else:
cou += 1
else:
if cou > 0:
cou -= 1
else:
cou += 1
ans -= 1
print(max(0,ans))
|
s896856142
|
p03644
|
u556589653
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 127 |
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())
num = N
hakai = 0
for i in range(8):
if N%2 == 0:
N = N//2
hakai += 1
else:
break
print(hakai)
|
s449953819
|
Accepted
| 17 | 2,940 | 69 |
import math
N = int(input())
S = math.floor(math.log2(N))
print(2**S)
|
s652305936
|
p03477
|
u992910889
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 122 |
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
|
A,B,C,D=map(int,input().split())
if A+B>C+D:
print('Left')
if A+B==C+D:
print('Balanced')
else:
print('Right')
|
s994619872
|
Accepted
| 17 | 2,940 | 124 |
A,B,C,D=map(int,input().split())
if A+B>C+D:
print('Left')
elif A+B==C+D:
print('Balanced')
else:
print('Right')
|
s255956660
|
p02413
|
u886729200
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,596 | 459 |
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
|
r,c = map(int,input().split())
num=[]
r_sum =[]
for i in range(r):
num.append([int(i) for i in input().split()])
for i in range(r):
line_sum = 0
for j in range(c):
line_sum += num[i][j]
num[i].append(line_sum)
print(num[i])
for i in range(c+1):
row_sum = 0
for j in range(r):
row_sum += num[j][i]
r_sum.append(row_sum)
num.append(r_sum)
for i in range(len(num)):
print(' '+' '.join(str(i) for i in num[i]))
|
s593119942
|
Accepted
| 20 | 5,680 | 437 |
r,c = map(int,input().split())
num=[]
r_sum =[]
for i in range(r):
num.append([int(i) for i in input().split()])
for i in range(r):
line_sum = 0
for j in range(c):
line_sum += num[i][j]
num[i].append(line_sum)
for i in range(c+1):
row_sum = 0
for j in range(r):
row_sum += num[j][i]
r_sum.append(row_sum)
num.append(r_sum)
for i in range(len(num)):
print(' '.join(str(i) for i in num[i]))
|
s679257431
|
p02396
|
u957680575
| 1,000 | 131,072 |
Wrong Answer
| 90 | 7,992 | 172 |
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.
|
a = []
while True:
n = int(input())
if n == 0:
break
a.append(n)
y = 0
z = len(a)
w = y + 1
for y in range(0,z):
print("Case"+str(w)+":",a[y])
|
s301482226
|
Accepted
| 90 | 7,960 | 176 |
a = []
while True:
n = int(input())
if n == 0:
break
a.append(n)
y = 0
z = len(a)
for y in range(0,z):
w = y + 1
print("Case",str(w)+":",a[y])
|
s595094658
|
p03407
|
u732061897
| 2,000 | 262,144 |
Wrong Answer
| 27 | 9,096 | 86 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if c >= a + 2 * b:
print('Yes')
else:
print('No')
|
s406283021
|
Accepted
| 24 | 9,080 | 89 |
a, b, c = map(int, input().split())
if c <= a + b:
print('Yes')
else:
print('No')
|
s990448689
|
p02603
|
u497952650
| 2,000 | 1,048,576 |
Wrong Answer
| 35 | 9,012 | 345 |
To become a millionaire, M-kun has decided to make money by trading in the next N days. Currently, he has 1000 yen and no stocks - only one kind of stock is issued in the country where he lives. He is famous across the country for his ability to foresee the future. He already knows that the price of one stock in the next N days will be as follows: * A_1 yen on the 1-st day, A_2 yen on the 2-nd day, ..., A_N yen on the N-th day. In the i-th day, M-kun can make the following trade **any number of times** (possibly zero), **within the amount of money and stocks that he has at the time**. * Buy stock: Pay A_i yen and receive one stock. * Sell stock: Sell one stock for A_i yen. What is the maximum possible amount of money that M-kun can have in the end by trading optimally?
|
import sys
sys.setrecursionlimit(10**9)
N = int(input())
A = list(map(int,input().split()))
l = []
s = 0
for i in range(N-1):
if A[i] > A[i+1]:
l.append([s,i])
s = i+1
else:
continue
l.append([s,N-1])
ans = 1000
for s,e in l:
kabu = (ans//A[s])
ans += (A[e]-A[s])*kabu
print(ans,kabu)
print(ans)
|
s750012356
|
Accepted
| 26 | 9,148 | 306 |
N = int(input())
A = list(map(int,input().split()))
l = []
s = 0
for i in range(N-1):
if A[i] > A[i+1]:
l.append([s,i])
s = i+1
else:
continue
l.append([s,N-1])
ans = 1000
for s,e in l:
kabu = (ans//A[s])
ans += (A[e]-A[s])*kabu
print(ans)
|
s439241712
|
p03860
|
u215414447
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 104 |
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[0],b[0],c[0])
|
s050120974
|
Accepted
| 18 | 2,940 | 111 |
a,b,c=input().split()
print(a[0],b[0],c[0],sep="")
|
s654631284
|
p02396
|
u218348721
| 1,000 | 131,072 |
Wrong Answer
| 130 | 5,604 | 135 |
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.
|
flag = "go"
while flag == "go":
x = int(input())
if x == 0:
flag = "stop"
else:
print("Case i: " + str(x))
|
s295236788
|
Accepted
| 150 | 5,604 | 171 |
flag = "go"
cnt = 0
while flag == "go":
cnt += 1
x = int(input())
if x == 0:
flag = "stop"
else:
print("Case " + str(cnt) + ": " + str(x))
|
s584345368
|
p03720
|
u996564551
| 2,000 | 262,144 |
Wrong Answer
| 25 | 9,100 | 228 |
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
N, M = input().split(' ')
N = int(N)
M = int(M)
citys = []
for i in range(M):
a, b = input().split(' ')
a = int(a)
b = int(b)
citys.append(a)
citys.append(b)
print(citys)
for i in range(1, N+1):
print(citys.count(i))
|
s684065208
|
Accepted
| 34 | 8,988 | 215 |
N, M = input().split(' ')
N = int(N)
M = int(M)
citys = []
for i in range(M):
a, b = input().split(' ')
a = int(a)
b = int(b)
citys.append(a)
citys.append(b)
for i in range(1, N+1):
print(citys.count(i))
|
s027680970
|
p03400
|
u408375121
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 149 |
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())
l = []
for i in range(N):
a = int(input())
c = (X - 1) // a
l.append(c + 1)
print(X + sum(l))
|
s751410487
|
Accepted
| 22 | 3,444 | 150 |
N = int(input())
D, X = map(int, input().split())
l = []
for i in range(N):
a = int(input())
c = (D - 1) // a
l.append(c + 1)
print(X + sum(l))
|
s883974107
|
p03693
|
u083960235
| 2,000 | 262,144 |
Wrong Answer
| 44 | 5,396 | 694 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
r, g, b = MAP()
c = 100 * r + 10 * g + b
if c % 4:
print("No")
else:
print("Yes")
|
s181480479
|
Accepted
| 17 | 2,940 | 115 |
r, g, b = map(int, input().split())
c = 100 * r + 10 * g + b
if c % 4 == 0:
print("YES")
else:
print("NO")
|
s032438163
|
p03761
|
u723654028
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 348 |
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
|
from collections import Counter
n = int(input())
keys = set()
S = []
ans = {}
for i in range(n):
counter = Counter(input())
keys = keys.intersection(counter.keys())
for k in keys:
ans[k] = min(ans.get(k, 100), counter[k])
s = ''
for k in ans.keys():
s += k * ans[k]
s = sorted(s)
sa = ''
for i in s:
sa += i
print (sa)
|
s157866723
|
Accepted
| 80 | 3,444 | 447 |
from collections import Counter
n = int(input())
keys = set()
S = []
ans = {}
for i in range(n):
counter = Counter(input())
if i == 0:
keys = set(counter.keys())
else:
keys = keys.intersection(counter.keys())
tmp = {}
for k in keys:
tmp[k] = min(ans.get(k, 100), counter[k])
ans = tmp
s = ''
for k in ans.keys():
s += k * ans[k]
s = sorted(s)
sa = ''
for i in s:
sa += i
print (sa)
|
s657393490
|
p00025
|
u766477342
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,432 | 162 |
Let's play Hit and Blow game. _A_ imagines four numbers and _B_ guesses the numbers. After _B_ picks out four numbers, _A_ answers: * The number of numbers which have the same place with numbers _A_ imagined (Hit) * The number of numbers included (but different place) in the numbers _A_ imagined (Blow) For example, if _A_ imagined numbers: 9 1 8 2 and _B_ chose: 4 1 5 9 _A_ should say 1 Hit and 1 Blow. Write a program which reads four numbers _A_ imagined and four numbers _B_ chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.
|
a = input().split()
b = input().split()
s = 0
v = 0
for i in range(len(a)):
if a[i] == b[i]:
s += 1
elif a[i] in b:
v += 1
print(*(s, v))
|
s269762353
|
Accepted
| 20 | 7,380 | 277 |
try:
while 1:
a = input().split()
b = input().split()
s = 0
v = 0
for i in range(len(a)):
if a[i] == b[i]:
s += 1
elif a[i] in b:
v += 1
print(*(s, v))
except:
pass
|
s010540448
|
p03388
|
u389910364
| 2,000 | 262,144 |
Wrong Answer
| 157 | 13,668 | 2,235 |
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.
|
import bisect
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
from operator import mul
import numpy as np
import re
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
Q = int(input())
A, B = zip(*[list(map(int, input().split())) for _ in range(Q)])
def solve(a, b):
target = a * b - 1
max_x = int(math.sqrt(target))
ret = set()
used = set()
for x in range(1, max_x + 1):
if x == a:
continue
y = target // x
while not (y not in used and y != b):
y -= 1
if y < max_x:
break
ret.add((x, y))
used.add(y)
used = set()
for y in range(1, max_x + 1):
if y == b:
continue
x = target // y
while not (x not in used and x != a):
x -= 1
if x < max_x:
break
ret.add((x, y))
used.add(x)
print(ret)
return len(ret)
def solve2(a, b):
a, b = min(a, b), max(a, b)
assert a <= b
if a == b:
return (a - 1) * 2
if a == b - 1:
return (a - 1) * 2
ret = a - 1
c = int(math.sqrt(a * b - 1))
if c * (c + 1) < a * b:
ret += c - a
# (c+1, c), (c+2, c-1), ..., (c+c-1, 1)
ret += c
else:
ret += c - a
# (c+1, c-1), (c+2, c-2), ..., (c+c-1, 1)
ret += c - 1
return ret
for a, b in zip(A, B):
print(solve2(a, b))
|
s478373341
|
Accepted
| 21 | 3,188 | 1,509 |
import math
import sys
sys.setrecursionlimit(10000)
INF = float('inf')
Q = int(input())
A, B = zip(*[list(map(int, input().split())) for _ in range(Q)])
def solve(a, b):
a, b = min(a, b), max(a, b)
assert a <= b
if a == b:
# print('c', a, b)
return (a - 1) * 2
if a == b - 1:
# print('d', a, b)
return (a - 1) * 2
c = int(math.sqrt(a * b))
if c ** 2 == a * b:
c -= 1
ret = a - 1
if c * (c + 1) < a * b:
# print('a', a, b)
ret += c - a
# (c+1, c), (c+2, c-1), ..., (c+c-1, 1)
ret += c
else:
# print('b', a, b)
ret += c - a
# (c+1, c-1), (c+2, c-2), ..., (c+c-1, 1)
ret += c - 1
return ret
for a, b in zip(A, B):
print(solve(a, b))
|
s929590798
|
p03577
|
u703890795
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 32 |
Rng is going to a festival. The name of the festival is given to you as a string S, which ends with `FESTIVAL`, from input. Answer the question: "Rng is going to a festival of what?" Output the answer. Here, assume that the name of "a festival of s" is a string obtained by appending `FESTIVAL` to the end of s. For example, `CODEFESTIVAL` is a festival of `CODE`.
|
S = input()
print(S[0:len(S)-7])
|
s011654319
|
Accepted
| 17 | 2,940 | 32 |
S = input()
print(S[0:len(S)-8])
|
s438362949
|
p00102
|
u808429775
| 1,000 | 131,072 |
Wrong Answer
| 30 | 5,620 | 626 |
Your task is to develop a tiny little part of spreadsheet software. Write a program which adds up columns and rows of given table as shown in the following figure:
|
while True:
inputCount = int(input())
if inputCount == 0:
break
table = []
for lp in range(inputCount):
content = [int(item) for item in input().split(" ")]
content.append(sum(content))
table.append(content)
table.append([])
for col in range(inputCount + 1):
total = 0
for row in range(inputCount):
total += table[row][col]
table[inputCount].append(total)
output = []
for array in table:
content = ["{:>5}".format(str(item)) for item in array]
output.append(str(content))
print("\n".join(output))
|
s072039489
|
Accepted
| 20 | 5,620 | 543 |
while True:
inputCount = int(input())
if inputCount == 0:
break
table = []
for lp in range(inputCount):
content = [int(item) for item in input().split(" ")]
content.append(sum(content))
table.append(content)
table.append([])
for col in range(inputCount + 1):
total = 0
for row in range(inputCount):
total += table[row][col]
table[inputCount].append(total)
for array in table:
print("".join("{:>5}".format(item) for item in array))
|
s866049078
|
p03698
|
u105124953
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 111 |
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
st = input()
tmp = []
for s in st:
tmp.append(s)
if tmp == set(tmp):
print('yes')
else:
print('no')
|
s447158770
|
Accepted
| 17 | 2,940 | 121 |
st = input()
tmp = []
for s in st:
tmp.append(s)
if len(tmp) == len(set(tmp)):
print('yes')
else:
print('no')
|
s527142980
|
p02612
|
u658600714
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,076 | 31 |
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)
|
s443002669
|
Accepted
| 30 | 9,052 | 85 |
import math
n = int(input())
if n%1000 == 0:
print(0)
else:
print(1000 - n%1000)
|
s340618433
|
p03963
|
u824326335
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 49 |
There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors. Find the number of the possible ways to paint the balls.
|
n,k=map(int,input().split())
print(k+(k-1)*(n-1))
|
s986152447
|
Accepted
| 17 | 2,940 | 51 |
n,k=map(int,input().split())
print(k*(k-1)**(n-1))
|
s278205721
|
p03394
|
u926678805
| 2,000 | 262,144 |
Wrong Answer
| 30 | 4,316 | 156 |
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.
|
data=[2,3,25]
for i in range(1,30001):
if (i%2==0 or i%3==0 or i%25==0) and (i!=2 and i!=3 and i!=25):
data.append(i)
print(data[:int(input())])
|
s579569986
|
Accepted
| 34 | 4,684 | 368 |
data=[]
for i in range(1,30001):
if i%2==0 or i%3==0:
data.append(i)
k=int(input())
if k==3:
print(*[2,5,63])
elif k==4:
print(*[2,5,20,63])
elif k==5:
print(*[2,5,20,63,30])
else:
ans=data[:k]
sm=sum(ans)
if sm%6==2:
ans[4]=30000
elif sm%6==3:
ans[5]=30000
elif sm%6==5:
ans[5]=29998
print(*ans)
|
s709850040
|
p03643
|
u316603606
| 2,000 | 262,144 |
Wrong Answer
| 28 | 9,016 | 54 |
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.
|
N = input ('iydfcgb.gdcg.kdwgivw.guv')
print ('ABC'+N)
|
s447319165
|
Accepted
| 32 | 9,016 | 28 |
N = input ()
print ('ABC'+N)
|
s155125004
|
p04014
|
u884982181
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 84 |
For integers b (b \geq 2) and n (n \geq 1), let the function f(b,n) be defined as follows: * f(b,n) = n, when n < b * f(b,n) = f(b,\,{\rm floor}(n / b)) + (n \ {\rm mod} \ b), when n \geq b Here, {\rm floor}(n / b) denotes the largest integer not exceeding n / b, and n \ {\rm mod} \ b denotes the remainder of n divided by b. Less formally, f(b,n) is equal to the sum of the digits of n written in base b. For example, the following hold: * f(10,\,87654)=8+7+6+5+4=30 * f(100,\,87654)=8+76+54=138 You are given integers n and s. Determine if there exists an integer b (b \geq 2) such that f(b,n)=s. If the answer is positive, also find the smallest such b.
|
n = int(input())
s = int(input())
if s <= (n+1)//2:
print(n-s+1)
else:
print(-1)
|
s773358262
|
Accepted
| 691 | 3,064 | 422 |
import math
n = int(input())
s = int(input())
if n == s:
print(n+1)
exit()
ru = math.ceil(math.sqrt(n))+1
for i in range(2,ru+1):
b = n+0
a = 0
while b:
a +=b%i
b//=i
if s == a:
print(i)
exit()
for i in range(ru,0,-1):
q = s-i
if q <0:
continue
c = (n-q)// i
if c <= ru-1:
continue
b = n+0
a = 0
while b:
a+=b%c
b//=c
if a == s:
print(c)
exit()
print(-1)
|
s501935485
|
p03693
|
u458608788
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 71 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a,b,c=map(int,input().split())
print("NO" if 100*a+10*b+c%4 else "YES")
|
s037964966
|
Accepted
| 17 | 2,940 | 74 |
a,b,c=map(int,input().split())
print("NO" if (100*a+10*b+c)%4 else "YES")
|
s456420433
|
p03449
|
u777207626
| 2,000 | 262,144 |
Wrong Answer
| 156 | 12,412 | 222 |
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
|
import numpy as np
n = int(input())
d = np.array([[int(i) for i in input().split()]for _ in range(2)])
ans = [0 for i in range(n)]
print(d)
for i in range(n):
ans[i] = d[0,0:i].sum()+d[1,i:].sum()+d[0,i]
print(max(ans))
|
s088684888
|
Accepted
| 157 | 12,412 | 213 |
import numpy as np
n = int(input())
d = np.array([[int(i) for i in input().split()]for _ in range(2)])
ans = [0 for i in range(n)]
for i in range(n):
ans[i] = d[0,0:i].sum()+d[1,i:].sum()+d[0,i]
print(max(ans))
|
s985074924
|
p02692
|
u667024514
| 2,000 | 1,048,576 |
Wrong Answer
| 196 | 16,236 | 2,509 |
There is a game that involves three variables, denoted A, B, and C. As the game progresses, there will be N events where you are asked to make a choice. Each of these choices is represented by a string s_i. If s_i is `AB`, you must add 1 to A or B then subtract 1 from the other; if s_i is `AC`, you must add 1 to A or C then subtract 1 from the other; if s_i is `BC`, you must add 1 to B or C then subtract 1 from the other. After each choice, none of A, B, and C should be negative. Determine whether it is possible to make N choices under this condition. If it is possible, also give one such way to make the choices.
|
def answer(x):
print("Yes")
for i in range(n):
if s[i] == "AB":
if x[0][0]:
print("B")
x[0][0] -= 1
else:
print("A")
elif s[i] == "AC":
if x[1][0]:
print("C")
x[1][0] -= 1
else:
print("A")
else:
if x[2][0]:
print("C")
x[2][0] -= 1
else:
print("B")
exit()
n,a,b,c = map(int,input().split())
s = [str(input()) for i in range(n)]
cnt = [0 for i in range(3)]
for ss in s:
if ss == "AB":
a += 1
b += 1
cnt[0] += 1
elif ss == "AC":
a += 1
c += 1
cnt[1] += 1
else:
b += 1
c += 1
cnt[2] += 1
a,b,c = a//2,b//2,c//2
all = min(min(cnt),min(a,b,c))
a,b,c = a-all,b-all,c-all
for i in range(3):
cnt[i] -= all
# cnt=["AB","AC","BC"]
print(a,b,c)
#"AB"=0
if cnt[0] == 0:
ACdeA = min(cnt[1],a)
BCdeB = min(cnt[2],b)
ACdeC = cnt[1]-ACdeA
BCdeC = cnt[2]-BCdeB
if ACdeC + BCdeC <= c:
answer([[all,0],[ACdeA,all+ACdeC],[all+BCdeB,BCdeC]])
if cnt[1] == 0:
ABdeA = min(cnt[0],a)
BCdeC = min(cnt[2],c)
ABdeB = cnt[0]-ABdeA
BCdeB = cnt[2]-BCdeC
if ABdeB + BCdeB <= b:
answer([[all+ABdeA,ABdeB],[0,all],[all+BCdeB,BCdeC]])
if cnt[2] == 0:
ABdeB = min(cnt[0],b)
ACdeC = min(cnt[1],c)
ABdeA = cnt[0]-ABdeB
ACdeA = cnt[1]-ACdeC
if ABdeA + ACdeA <= a:
answer([[all+ABdeA,ABdeB],[ACdeA,ACdeC+all],[all,0]])
if a == 0:
ABdeB = cnt[0]
ACdeC = cnt[1]
b -= ABdeB
c -= ACdeC
if b >= 0 and c >= 0:
BCdeB = min(b,cnt[2])
BCdeC = cnt[2]-BCdeB
if BCdeC <= c:
answer([[all,ABdeB],[0,ACdeC+all],[all+BCdeB,BCdeC]])
b += ABdeB
c += ACdeC
if b == 0:
ABdeA = cnt[0]
BCdeC = cnt[2]
a -= ABdeA
c -= BCdeC
if a >= 0 and c >= 0:
ACdeA = min(a,cnt[1])
ACdeC = cnt[1]-ACdeA
if ACdeC <= c:
answer([[all+ABdeA,0],[ACdeA,ACdeC+all],[all,BCdeC]])
a += ABdeA
c += BCdeC
if c == 0:
ACdeA = cnt[1]
BCdeB = cnt[2]
a -= ACdeA
b -= BCdeB
if a >= 0 and b >= 0:
ABdeA = min(a,cnt[0])
ABdeB = cnt[0]-ABdeA
if ABdeB <= b:
answer([[all+ABdeA,ABdeB],[ACdeA,all],[BCdeB+all,0]])
print("No")
|
s482759265
|
Accepted
| 276 | 16,376 | 2,451 |
n,a,b,c = map(int,input().split())
s = [str(input()) for i in range(n)]
lis = [a,b,c]
ans = ""
for i in range(n-1):
if lis[ord(s[i][0]) - ord("A")] == 0 and lis[ord(s[i][1]) - ord("A")] == 0:
print("No")
exit()
if s[i] == s[i+1]:
if lis[ord(s[i][0])-ord("A")] == 0:
ans += s[i][0]
lis[ord(s[i][0])-ord("A")] += 1
lis[ord(s[i][1])-ord("A")] -= 1
else:
ans += s[i][1]
lis[ord(s[i][0])-ord("A")] -= 1
lis[ord(s[i][1])-ord("A")] += 1
else:
if s[i] == "AB":
if s[i+1] == "AC":
if lis[1] == 0:
ans += "B"
lis[1] += 1
lis[0] -= 1
else:
ans += "A"
lis[0] += 1
lis[1] -= 1
else:
if lis[0] == 0:
ans += "A"
lis[0] += 1
lis[1] -= 1
else:
ans += "B"
lis[0] -= 1
lis[1] += 1
elif s[i] == "AC":
if s[i+1] == "AB":
if lis[2] == 0:
ans += "C"
lis[2] += 1
lis[0] -= 1
else:
ans += "A"
lis[0] += 1
lis[2] -= 1
else:
if lis[0] == 0:
ans += "A"
lis[0] += 1
lis[2] -= 1
else:
ans += "C"
lis[0] -= 1
lis[2] += 1
else:
if s[i+1] == "AB":
if lis[2] == 0:
ans += "C"
lis[2] += 1
lis[1] -= 1
else:
ans += "B"
lis[2] -= 1
lis[1] += 1
else:
if lis[1] == 0:
ans += "B"
lis[1] += 1
lis[2] -= 1
else:
ans += "C"
lis[2] += 1
lis[1] -= 1
if lis[ord(s[-1][0])-ord("A")] == 0:
if lis[ord(s[-1][1])-ord("A")] == 0:
print("No")
exit()
else:
ans += s[-1][0]
else:
ans += s[-1][1]
print("Yes")
for i in range(n):
print(ans[i])
|
s165502201
|
p03089
|
u288430479
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 263 |
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 operations. If it is, show one possible sequence of operations that achieves it.
|
n = int(input())
l = list(map(int,input().split()))
l1 = []
for i in range(n):
for j in range(n-1-i,-1,-1):
if l[j]==j+1:
l1.append(l[j])
del l[j]
break
else:
continue
if len(l)==0:
for j in l1:
print(j)
else:
print(-1)
|
s924214359
|
Accepted
| 18 | 3,064 | 269 |
n = int(input())
l = list(map(int,input().split()))
l1 = []
for i in range(n):
for j in range(n-1-i,-1,-1):
if l[j]==j+1:
l1.append(l[j])
del l[j]
break
else:
continue
if len(l)==0:
for j in l1[::-1]:
print(j)
else:
print(-1)
|
s382216539
|
p03162
|
u511379665
| 2,000 | 1,048,576 |
Wrong Answer
| 498 | 25,292 | 404 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n=int(input())
h=[]
for i in range(n):
p,q,r=map(int,input().split())
h.append([p,q,r])
dp=[[0 for _ in range(3)]]*(n+1)
dp[0][0]=h[0][0]
dp[0][1]=h[0][1]
dp[0][2]=h[0][2]
for i in range(0,n-1):
dp[i+1][0]=max(dp[i][1],dp[i][2])+h[i+1][0]
dp[i + 1][1] = max(dp[i][0], dp[i][2])+h[i+1][1]
dp[i + 1][2] = max(dp[i][0], dp[i][1])+h[i+1][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))
|
s164421984
|
Accepted
| 589 | 42,588 | 458 |
n=int(input())
H=[]
for i in range(n):
a,b,c=map(int,input().split())
H.append([a,b,c])
if n==1:
print(max(H[0][0],H[0][1],H[0][2]))
exit()
dp=[[0,0,0]for j in range(n)]
for i in range(3):
dp[0][i]=H[0][i]
for i in range(0,n-1):
dp[i+1][0]=max(dp[i][1],dp[i][2])+H[i+1][0]
dp[i + 1][1] = max(dp[i][0], dp[i][2]) + H[i + 1][1]
dp[i + 1][2] = max(dp[i][1], dp[i][0]) + H[i + 1][2]
print(max(dp[n-1][0],dp[n-1][1],dp[n-1][2]))
|
s942421151
|
p02412
|
u184749404
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,588 | 286 |
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 == 0 and x==0:
break
else:
sum = 0
for i in range(1,n-1):
for j in range(i+1,n):
for k in range(j+1,n+1):
if i+j+k == 9:
sum+= 0
|
s018227686
|
Accepted
| 500 | 5,592 | 282 |
while True:
n,x = map(int,input().split())
if n == 0 and x==0:
break
else:
sum = 0
for i in range(1,n-1):
for j in range(i+1,n):
for k in range(j+1,n+1):
if i+j+k == x:
sum+= 1
print(sum)
|
s789230259
|
p03379
|
u038408819
| 2,000 | 262,144 |
Wrong Answer
| 349 | 25,224 | 187 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
N = int(input())
a = list(map(int, input().split()))
a.sort()
right = N // 2
left = right - 1
for i in range(N):
if i < N / 2:
print(a[right])
else:
print(a[left])
|
s550985598
|
Accepted
| 314 | 25,556 | 225 |
N = int(input())
a = list(map(int, input().split()))
a_sort = sorted(a)
right = a_sort[N // 2]
left = a_sort[N // 2 - 1]
for i in range(N):
if a[i] <= left:
print(right)
elif a[i] >= right:
print(left)
|
s399299315
|
p03089
|
u923341003
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,316 | 79 |
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 operations. If it is, show one possible sequence of operations that achieves it.
|
N = int(input())
b = list(map(int, input().split()))
if b[0] > 1:
print(-1)
|
s127911611
|
Accepted
| 17 | 3,060 | 353 |
N = int(input())
B = list(map(int,input().split()))
A = []
while B:
flag = True
for i in reversed(range(len(B))):
if B[i] == i + 1:
flag = False
A.append(B[i])
B.pop(i)
break
if flag:
print(-1)
break
if flag == False:
for a in reversed(A):
print(a)
|
s307563865
|
p04011
|
u697615293
| 2,000 | 262,144 |
Wrong Answer
| 34 | 9,156 | 149 |
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = 0
for i in range(1,a+1):
if i >= b:
e += d
else:
e += c
print(e)
|
s817655247
|
Accepted
| 28 | 9,132 | 151 |
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = 0
for i in range(1,a+1):
if i >= b+1:
e += d
else:
e += c
print(e)
|
s809434149
|
p03162
|
u916796264
| 2,000 | 1,048,576 |
Wrong Answer
| 405 | 30,264 | 207 |
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
|
n=int(input())
dp=[]
for i in range(n):
l=list(map(int,input().split()))
dp.append(l)
for i in range(1,n):
for j in range(3):
dp[i][(j%3)]+=max(dp[i][(j+1)%3],dp[i][(j+2)%3])
print(max(dp[n-1]))
|
s840358233
|
Accepted
| 414 | 30,260 | 208 |
n=int(input())
dp=[]
for i in range(n):
l=list(map(int,input().split()))
dp.append(l)
for i in range(1,n):
for j in range(3):
dp[i][(j%3)]+=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])
print(max(dp[n-1]))
|
s832379758
|
p03593
|
u631277801
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,444 | 1,395 |
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter. Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition: * Every row and column in A' can be read as a palindrome. Determine whether he can create a matrix satisfying the condition.
|
import sys
stdin = sys.stdin
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from collections import Counter
h,w = li()
cnt = Counter([])
for _ in range(h):
tmp = lc()
for c in tmp:
cnt[c] += 1
print(cnt)
exist = True
if h%2 == 0 and w%2 == 0:
for key,value in cnt.items():
if value%4 != 0:
exist = False
break
elif h%2 == 1 and w%2 == 1:
odd = 0
mod4_2 = 0
for key,value in cnt.items():
if value % 2 == 1:
odd += 1
elif value % 4 == 2:
mod4_2 += 1
if odd > 1:
exist = False
elif mod4_2 > (h+w-2)//2:
exist = False
else:
odmax = 0
if h%2 == 0:
odmax = h//2
else:
odmax = w//2
mod4_2 = 0
for key, value in cnt.items():
if value%2 != 0:
exist = False
break
elif value%4 == 2:
mod4_2 +=1
if mod4_2 > odmax:
exist = False
if exist:
print("Yes")
else:
print("No")
|
s392120029
|
Accepted
| 22 | 3,316 | 1,650 |
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())
from collections import defaultdict
def judge(cnts, h, w):
odd_cnt = 0
mod4_2_cnt = 0
mod4_0_cnt = 0
for key, val in cnts.items():
if val % 2 == 1:
odd_cnt += 1
elif val % 4 == 2:
mod4_2_cnt += 1
else:
mod4_0_cnt += 1
if h == 1 and w == 1:
return True
elif h == 1:
if w % 2 == 1:
return True if odd_cnt == 1 else False
else:
return True if odd_cnt == 0 else False
elif w == 1:
if h % 2 == 1:
return True if odd_cnt == 1 else False
else:
return True if odd_cnt == 0 else False
elif h % 2 == 1 and w % 2 == 1:
return True if mod4_2_cnt == (w//2 + h//2) and odd_cnt == 1 else False
elif h%2 == 1:
return True if mod4_2_cnt == (w//2) and odd_cnt == 0 else False
elif w%2 == 1:
return True if mod4_2_cnt == (h//2) and odd_cnt == 0 else False
else:
return True if mod4_2_cnt == 0 and odd_cnt == 0 else False
h, w = li()
a = [ns() for _ in range(h)]
char_cnt = defaultdict(int)
for ai in a:
for aij in ai:
char_cnt[aij] += 1
print("Yes" if judge(char_cnt, h, w) else "No")
|
s303520902
|
p03796
|
u978510477
| 2,000 | 262,144 |
Wrong Answer
| 28 | 2,940 | 74 |
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())
c = 1
for i in range(N):
c = c*i % (10**9 + 7)
print(c)
|
s262119912
|
Accepted
| 35 | 2,940 | 91 |
N = int(input())
c = 1
mod = 10**9 + 7
for i in range(2, N+1):
c = c * i % mod
print(c)
|
s047521566
|
p03646
|
u820351940
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 171 |
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. * Determine the largest element in the sequence (if there is more than one, choose one). Decrease the value of this element by N, and increase each of the other elements by 1. It can be proved that the largest element in the sequence becomes N-1 or smaller after a finite number of operations. You are given an integer K. Find an integer sequence a_i such that the number of times we will perform the above operation is exactly K. It can be shown that there is always such a sequence under the constraints on input and output in this problem.
|
k = int(input())
n = 50
coef = k // n
if k <= 50: coef, n = 1, k
a = list(reversed(range(coef, coef + n)))
for i in range(k - coef * n):
a[i] += 1
print(n)
print(*a)
|
s877201244
|
Accepted
| 17 | 3,060 | 257 |
k = int(input())
if k in [0, 1]:
print(["4\n3 3 3 3", "3\n1 0 3"][k])
__import__("sys").exit()
n = 50
coef = k // n
if k <= 50: coef, n = 1, k
a = list(reversed(range(coef, coef + n)))
for i in range(k - coef * n):
a[i] += 1
print(n)
print(*a)
|
s767902860
|
p03251
|
u106297876
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 3,064 | 355 |
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( )))
z=list(range(X+1,Y+1))
def x_f(x):
if x<Z:
return x
def y_f(y):
if y>=Z:
return y
ans='War'
for Z in z:
x_a=list(filter(x_f, x))
y_a=list(filter(y_f, y))
if len(x_a)==X and len(y_a)==Y:
ans='No War'
print(ans)
|
s889577732
|
Accepted
| 21 | 3,064 | 299 |
n,m,X,Y=map(int,input().split( ))
x_l=list(map(int,input().split( )))
y_l=list(map(int,input().split( )))
z_l=list(range(X+1,Y+1))
ans='War'
for z in z_l:
x=list(filter(lambda x: x<z, x_l))
y=list(filter(lambda y: y>=z, y_l))
if len(x)==n and len(y)==m:
ans=('No War')
print(ans)
|
s549649175
|
p02614
|
u224554402
| 1,000 | 1,048,576 |
Wrong Answer
| 244 | 9,112 | 880 |
We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is `.`, and black if c_{i,j} is `#`. Consider doing the following operation: * Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns. You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.
|
h,w,k = list(map(int, input().split()))
masu = [input() for _ in range(h)]
ans = 0
def count_num(m, target, goal):
for i in range(h):
count = sum(map(lambda x: x.count(target), m))
return count == goal
def change_row(m, i_row_0):
m[i_row_0] = 'r'*w
return m
def change_col(m, j_col_0):
for i in range(h):
if j_col_0 < w:
m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
return m
for idx_h in range(2**h):
for idx_w in range(2**w):
m = masu.copy()
for i_row, row in enumerate(m):
if idx_h & (2 ** i_row) > 0:
m = change_row(m, i_row)
for j_col, col in enumerate(row):
if idx_w & (2 ** j_col) > 0:
m = change_col(m, j_col)
print(m)
if count_num(m, '#', k):
ans += 1
print(ans)
|
s682972801
|
Accepted
| 241 | 8,928 | 881 |
h,w,k = list(map(int, input().split()))
masu = [input() for _ in range(h)]
ans = 0
def count_num(m, target, goal):
for i in range(h):
count = sum(map(lambda x: x.count(target), m))
return count == goal
def change_row(m, i_row_0):
m[i_row_0] = 'r'*w
return m
def change_col(m, j_col_0):
for i in range(h):
if j_col_0 < w:
m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
return m
for idx_h in range(2**h):
for idx_w in range(2**w):
m = masu.copy()
for i_row, row in enumerate(m):
if idx_h & (2 ** i_row) > 0:
m = change_row(m, i_row)
for j_col, col in enumerate(row):
if idx_w & (2 ** j_col) > 0:
m = change_col(m, j_col)
#print(m)
if count_num(m, '#', k):
ans += 1
print(ans)
|
s532595706
|
p03351
|
u489959379
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 110 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a, b, c, d = map(int, input().split())
d_ac = abs(c - a)
if d_ac <= d:
print("Yes")
else:
print("No")
|
s381792210
|
Accepted
| 17 | 2,940 | 214 |
a, b, c, d = map(int, input().split())
d_ac = abs(c - a)
d_ab = abs(b - a)
d_bc = abs(c - b)
if d_ac <= d:
print("Yes")
else:
if d_ab <= d and d_bc <= d:
print("Yes")
else:
print("No")
|
s871363261
|
p02612
|
u752500421
| 2,000 | 1,048,576 |
Wrong Answer
| 29 | 9,144 | 146 |
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.
|
def main():
n = int(input())
if n < 1000:
print(n)
else:
print(str(n)[1:])
if __name__ == "__main__":
main()
|
s240870360
|
Accepted
| 31 | 9,144 | 153 |
def main():
n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n % 1000)
if __name__ == "__main__":
main()
|
s539715569
|
p02612
|
u141419468
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,152 | 31 |
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)
|
s669135991
|
Accepted
| 27 | 9,140 | 75 |
N = int(input())
if N%1000 == 0:
print(0)
else:
print(1000-N%1000)
|
s784994742
|
p03387
|
u993435350
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 191 |
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
L = sorted(list(map(int,input().split())))
A = L[0]
B = L[1]
C = L[2]
dif1 = C - A
dif2 = C - B
if (dif1 + dif2) % 2 == 0:
print((dif1 + dif2)/2)
else:
print((dif1 + dif2) // 2 + 1)
|
s978092559
|
Accepted
| 17 | 3,060 | 201 |
L = sorted(list(map(int,input().split())))
A = L[0]
B = L[1]
C = L[2]
dif1 = C - A
dif2 = C - B
if (dif1 + dif2) % 2 == 0:
print(int((dif1 + dif2)/2))
else:
print(((dif1 + dif2) // 2 ) + 2)
|
s197904621
|
p03599
|
u027622859
| 3,000 | 262,144 |
Wrong Answer
| 241 | 3,064 | 556 |
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. * Operation 1: Pour 100A grams of water into the beaker. * Operation 2: Pour 100B grams of water into the beaker. * Operation 3: Put C grams of sugar into the beaker. * Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water.
|
a, b, c, d, e, f = map(int, input().split())
max_concentration = 0
for i in range(1, f + 1, 100 * a):
for j in range(1, f - i + 1, 100 * b):
y = min((i + j) * e // 100, f - i - j)
for k in range(0, y + 1, c):
for l in range(0, y - k + 1, d):
concentration = 100 * (k + l) / (i + j + k + l)
if max_concentration <= concentration:
max_concentration = concentration
res1 = i + j + k + l
res2 = k + l
print(str(res1) + ' ' + str(res2))
|
s406434136
|
Accepted
| 2,427 | 12,440 | 786 |
a,b,c,d,e,f = map(int, input().split())
sugar = []
for i in range(f):
for j in range(f):
y = i*c + j*d
if y <= f:
sugar.append(y)
water = []
for i in range(0, f//100+1):
for j in range(0, f//100+1):
x = i*a*100 + j*b*100
if x <= f:
water.append(x)
max_concentration = 0
ans1, ans2 = 0, 0
for x in water:
for y in sugar:
if x == 0 and y == 0:
continue
elif e * (x // 100) < y:
continue
elif x + y > f:
continue
else:
concentration = (100 * y) / (x+y)
if max_concentration <= concentration:
max_concentration = concentration
ans1 = x+y
ans2 = y
print("{} {}".format(ans1, ans2))
|
s605711701
|
p03448
|
u706078123
| 2,000 | 262,144 |
Wrong Answer
| 174 | 4,068 | 455 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a = int(input())
b = int(input())
c = int(input())
x = int(input())
i1, i2, i3 = 0, 0, 0
m1, m2, m3, p = 0, 0, 0, 0
while i1 <= a:
m1 = 500 * i1
while i2 <= b:
m2 = m1 + 100 * i2
while i3 <= c:
m3 = m2 + 50 * i3
print(str(i1) + str(i2) + str(i3) + str(m3))
if m3 < x:
i3 += 1
continue
elif m3 > x:
break
else:
p += 1
break
i3 = 0
i2 += 1
i2 = 0
i1 += 1
print(p)
|
s024483112
|
Accepted
| 53 | 3,064 | 314 |
a = int(input())
b = int(input())
c = int(input())
x = int(input())
i1, i2, i3, p = 0, 0, 0, 0
while i1 <= a:
while i2 <= b:
while i3 <= c:
m = 500 * i1 + 100 * i2 + 50 * i3
if m > x:
break
elif m == x:
p += 1
i3 += 1
i3 = 0
i2 += 1
i2 = 0
i1 += 1
print(p)
|
s055003487
|
p03455
|
u548514780
| 2,000 | 262,144 |
Wrong Answer
| 26 | 9,036 | 83 |
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())
c=a*b
if a%2==0:
print('Even')
else:
print('Odd')
|
s985036198
|
Accepted
| 25 | 8,988 | 83 |
a,b=map(int, input().split())
c=a*b
if c%2==0:
print('Even')
else:
print('Odd')
|
s987577073
|
p02416
|
u313021086
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,576 | 80 |
Write a program which reads an integer and prints sum of its digits.
|
i = int(input())
sum = 0
while i != 0:
sum += i
i = int(input())
print(sum)
|
s600636619
|
Accepted
| 20 | 5,592 | 180 |
number = input()
length = len(number)
while number != "0":
i = 0
sum = 0
while i < length:
sum += int(number[i])
i += 1
print(sum)
number = input()
length = len(number)
|
s565106439
|
p03485
|
u558764629
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 50 |
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b = map(int,input().split())
print((a+b+0.5)/2)
|
s360287225
|
Accepted
| 17 | 2,940 | 55 |
a,b = map(int,input().split())
print(int((a+b)/2+0.5))
|
s410076355
|
p04043
|
u730449065
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 211 |
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.
|
l = list(map(int, input().split()))
count = count2 = 0
for i in range(3):
if(l[i] == 5):
count+=1
elif(l[i] == 7):
count2 += 1
if(count == 2 and count2 == 1):
print("Yes")
else:
print("No")
|
s778105440
|
Accepted
| 17 | 2,940 | 211 |
l = list(map(int, input().split()))
count = count2 = 0
for i in range(3):
if(l[i] == 5):
count+=1
elif(l[i] == 7):
count2 += 1
if(count == 2 and count2 == 1):
print("YES")
else:
print("NO")
|
s509397634
|
p02795
|
u347064383
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 109 |
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
from math import ceil
H = int(input())
W = int(input())
N = int(input())
m = max(H, W)
print(ceil(N // m))
|
s355609889
|
Accepted
| 18 | 2,940 | 108 |
from math import ceil
H = int(input())
W = int(input())
N = int(input())
m = max(H, W)
print(ceil(N / m))
|
s038714941
|
p03827
|
u957872856
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 164 |
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
|
n = int(input())
s = input()
count = 0
l = []
for i in s:
if s == "I":
count += 1
l.append(count)
else:
count -= 1
l.append(count)
print(max(l))
|
s037112983
|
Accepted
| 17 | 2,940 | 138 |
n = int(input())
S = input()
cnt = 0
ans = 0
for s in S:
if s == "I":
cnt += 1
else:
cnt -= 1
ans = max(ans, cnt)
print(ans)
|
s981172283
|
p03352
|
u603067482
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,060 | 261 |
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())
i_max = math.floor(math.sqrt(X))
result = 1
for i in range(2,i_max+1,1):
for j in range(1,X):
n = (i**j)
if (n > X):
break
else:
result = max(result, n)
print("result =",result)
|
s759689665
|
Accepted
| 18 | 3,068 | 250 |
import math
X = int(input())
i_max = math.floor(math.sqrt(X))
result = 1
for i in range(2,i_max+1,1):
for j in range(2,X):
n = (i**j)
if (n > X):
break
else:
result = max(result, n)
print(result)
|
s386424831
|
p04043
|
u060793972
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 81 |
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.
|
if sorted(input().split())==['5','5','7']:
print('Yes')
else:
print('No')
|
s601816789
|
Accepted
| 17 | 2,940 | 81 |
if sorted(input().split())==['5','5','7']:
print('YES')
else:
print('NO')
|
s373463719
|
p03407
|
u721316601
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 33 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
num = input().split()
print(num)
|
s812665377
|
Accepted
| 17 | 2,940 | 105 |
num = input().split()
if int(num[0]) + int(num[1]) < int(num[2]):
print('No')
else:
print('Yes')
|
s764050705
|
p03795
|
u823044869
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 40 |
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
|
n = int(input())
print(n*800-n/15*200)
|
s236921789
|
Accepted
| 17 | 3,064 | 41 |
n = int(input())
print(n*800-n//15*200)
|
s500808148
|
p02261
|
u285980122
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 799 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def BubbleSort(C, N):
for i in range(0,N):
for j in range(N-1,i,-1):
if C[j][1:] < C[j-1][1:]:
tmp = C[j]
C[j] = C[j-1]
C[j-1] = tmp
ret = " ".join(C)
print(ret)
print("stable")
return ret
def SelectionSort(C, N):
for i in range(0,N):
minj = i
for j in range(i,N):
if C[j][1:] <= C[minj][1:]:
minj = j
tmp = C[i]
C[i] = C[minj]
C[minj] = tmp
ret = " ".join(C)
print(ret)
return ret
N = int(input())
C = input().split(" ")
ret_B = BubbleSort(C,N)
ret_S = SelectionSort(C,N)
if ret_B == ret_S:
print("stable")
else:
print("Not stable")
|
s887175543
|
Accepted
| 30 | 6,340 | 777 |
import copy
def BubbleSort(C, N):
for i in range(0,N):
for j in range(N-1,i,-1):
if C[j][1:] < C[j-1][1:]:
C[j] , C[j-1] = C[j-1] , C[j]
ret = " ".join(C)
print(ret)
print("Stable")
return ret
def SelectionSort(C, N):
for i in range(0,N):
minj = i
for j in range(i,N):
if C[j][1:] < C[minj][1:]:
minj = j
C[i] , C[minj] = C[minj] , C[i]
ret = " ".join(C)
print(ret)
return ret
N = int(input())
C = input().split(" ")
ret_B = BubbleSort(copy.deepcopy(C),N)
ret_S = SelectionSort(copy.deepcopy(C),N)
if ret_B == ret_S:
print("Stable")
else:
print("Not stable")
|
s275546403
|
p02972
|
u037430802
| 2,000 | 1,048,576 |
Wrong Answer
| 211 | 10,708 | 391 |
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
n = int(input())
a = list(map(int, input().split()))
idx = n//2
ans = [0] * n
ans[idx:] = a[idx:]
#print("--", ans, idx)
for i in range(idx):
tmp = sum(a[(idx-1)::(idx-i)])
#print(a[(idx-1)::(idx-i)],tmp)
if tmp % 2 == a[idx-i]:
ans[idx-(i+1)] = 0
else:
ans[idx-(i+1)] = 1
cnt = sum(ans)
if cnt == 0:
print(0)
else:
print(cnt)
print(*ans)
|
s006670868
|
Accepted
| 248 | 17,200 | 302 |
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
b = set()
for i in range(n-1, -1, -1):
tmp = sum(ans[i::i+1])
if tmp % 2 == a[i]:
continue
else:
b.add(i+1)
ans[i] = 1
cnt = len(b)
if cnt == 0:
print(0)
else:
print(cnt)
print(*b)
|
s172719931
|
p02407
|
u692415695
| 1,000 | 131,072 |
Wrong Answer
| 50 | 7,756 | 100 |
Write a program which reads a sequence and prints it in the reverse order.
|
# (c) midandfeed
q = [int(x) for x in input().split()]
for x in q[::-1]:
print(x, end=' ')
print()
|
s736900566
|
Accepted
| 20 | 7,760 | 176 |
# (c) midandfeed
int(input())
q = [int(x) for x in input().split()]
for i in range(len(q)-1, -1, -1):
print(q[i], end='')
if (i == 0):
print()
else:
print(' ', end='')
|
s353463856
|
p03379
|
u146575240
| 2,000 | 262,144 |
Wrong Answer
| 2,105 | 26,052 | 241 |
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 =[]
ans = []
for i in range(N):
B = 0
X2 = copy.copy(X)
X2.pop(i)
X2.sort(reverse=True)
B = X2[(N//2)-1]
ans.append(B)
print(ans)
|
s692614165
|
Accepted
| 311 | 27,156 | 260 |
# C - Many Medians
import copy
N = int(input())
X = list(map(int, input().split()))
X2 = []
X2 = copy.copy(X)
X2.sort(reverse=True)
Xm_1 = X2[N//2]
Xm_2 = X2[(N//2)-1]
for i in range(N):
if X[i] <= Xm_1:
print(Xm_2)
else:
print(Xm_1)
|
s272642800
|
p03719
|
u746233170
| 2,000 | 262,144 |
Wrong Answer
| 20 | 3,060 | 117 |
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 -*-
x=input()
y=[]
y=x.split(" ")
if y[2]>=y[0] and y[2]<=y[1]:
print("yes")
else:
print("no")
|
s348971453
|
Accepted
| 17 | 2,940 | 140 |
# -*- coding: utf-8 -*-
x=input()
y=[]
y=x.split(" ")
if int(y[2])>=int(y[0]) and int(y[2])<=int(y[1]):
print("Yes")
else:
print("No")
|
s097032089
|
p00093
|
u546285759
| 1,000 | 131,072 |
Wrong Answer
| 50 | 9,092 | 247 |
西暦 a 年から b 年までの間にあるすべてのうるう年を出力するプログラムを作成してください。 うるう年の条件は、次のとおりとします。ただし、0 < a ≤ b < 3,000 とします。与えられた期間にうるう年がない場合には "NA"と出力してください。 * 西暦年が 4 で割り切れる年であること。 * ただし、100 で割り切れる年はうるう年としない。 * しかし、400 で割り切れる年はうるう年である。
|
import calendar as C
while 1:
a,b=map(int, input().split())
if a==0:break
if sum([1 for i in range(a,b+1) if C.isleap(i)])==0:
print("NA")
else:
for i in range(a,b+1):
if C.isleap(i)and i%100!=0:print(i)
|
s431462595
|
Accepted
| 40 | 9,052 | 272 |
from calendar import isleap
flag = False
while True:
a, b = map(int, input().split())
if a == 0:
break
if flag:
print()
flag = True
ans = [i for i in range(a, b+1) if isleap(i)]
print("\n".join(map(str, ans)) if len(ans) else "NA")
|
s306910208
|
p03068
|
u064963667
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 269 |
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
|
n = int(input())
string = input()
k = int(input())
key = string[k-1]
index_list = [i for i,letter in enumerate(string) if letter == key]
word = ["*" for i in range(len(string))]
for elem in index_list:
print(elem)
word[elem] = key
word = "".join(word)
print(word)
|
s819197165
|
Accepted
| 17 | 3,064 | 256 |
n = int(input())
string = input()
k = int(input())
key = string[k-1]
index_list = [i for i,letter in enumerate(string) if letter == key]
word = ["*" for i in range(len(string))]
for elem in index_list:
word[elem] = key
word = "".join(word)
print(word)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.