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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s748302274 | p03068 | u661983922 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 244 | 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 = input()
S = input()
K = input()
char = S[int(K)-1]
#print(char)
ans = []
for j in range(len(S)):
#print(S[j])
if char != S[j]:
ans.append("*")
#print("!=")
else:
ans.append(char)
continue
print(" ".join(ans))
| s117303235 | Accepted | 17 | 2,940 | 242 | N = input()
S = input()
K = input()
char = S[int(K)-1]
#print(char)
ans = []
for j in range(len(S)):
#print(S[j])
if char != S[j]:
ans.append("*")
#print("!=")
else:
ans.append(char)
continue
print("".join(ans))
|
s504665685 | p02690 | u652656291 | 2,000 | 1,048,576 | Wrong Answer | 555 | 9,160 | 116 | Give a pair of integers (A, B) such that A^5-B^5 = X. It is guaranteed that there exists such a pair for the given integer X. | x = int(input())
for i in range(1000):
for j in range(1000):
if i**5 - j**5 == x:
print(i,j)
break | s807199380 | Accepted | 52 | 9,164 | 148 | x = int(input())
a = 0
b = 0
for i in range(-130,130):
for j in range(-130,130):
if x == (i**5) - (j**5):
a = i
b = j
print(a,b)
|
s581764055 | p03063 | u559048291 | 2,000 | 1,048,576 | Wrong Answer | 2,104 | 12,008 | 282 | There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`. Takahashi wants to change the colors of some stones to black or white so t... |
N = int(input())
S = input()
wl = []
bl = []
w=0
b=0
for i in S:
if i==".":
w+=1;
wl.append(w)
for i in reversed(S):
if i=="#":
b+=1;
bl.insert(0, b)
ans = N
for i in range(N):
if wl[i]+bl[i] > ans:
ans = wl[i]+bl[i]
print(N - ans) | s133469631 | Accepted | 164 | 12,808 | 280 |
N = int(input())
S = input()
wl = [0]
bl = [0]
w=0
b=0
for i in S:
if i==".":
w+=1;
else:
b+=1;
wl.append(w)
bl.append(b)
wmax = wl[-1]
min = wmax;
for i in range(N+1):
if wmax+bl[i]-wl[i] < min:
min = wmax+bl[i]-wl[i]
print(min)
|
s202874227 | p03386 | u939585142 | 2,000 | 262,144 | Wrong Answer | 2,245 | 4,084 | 123 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | A, B, K = map(int,input().split())
li = [i for i in range(A,B + 1)]
ans = li[:K] + sorted(li,reverse = True)[:K]
print(ans) | s382550372 | Accepted | 21 | 3,316 | 180 | A, B, K = map(int,input().split())
ans = []
for i in range(K):
if A + i <= B:
ans.append(A + i)
if B - i >= A:
ans.append(B - i)
for i in sorted(set(ans)):
print(i) |
s916800039 | p03972 | u476199965 | 2,000 | 262,144 | Wrong Answer | 987 | 26,948 | 290 | On an xy plane, in an area satisfying 0 ≤ x ≤ W, 0 ≤ y ≤ H, there is one house at each and every point where both x and y are integers. There are unpaved roads between every pair of points for which either the x coordinates are equal and the difference between the y coordinates is 1, or the y coordinates are equal and... | w,h = list(map(int,input().split()))
pq = []
for i in range(w):
pq.append((int(input()),0))
for i in range(h):
pq.append((int(input()),1))
pq.sort()
res = 0
w+=1
h+=1
dic = {0:w,1:h}
for x in pq:
print(dic[x[1]],x[0])
res += dic[1-x[1]]*x[0]
dic[x[1]] -= 1
print(res)
| s090421389 | Accepted | 660 | 24,540 | 264 | w,h = list(map(int,input().split()))
pq = []
for i in range(w):
pq.append((int(input()),0))
for i in range(h):
pq.append((int(input()),1))
pq.sort()
res = 0
w+=1
h+=1
dic = {0:w,1:h}
for x in pq:
res += dic[1-x[1]]*x[0]
dic[x[1]] -= 1
print(res)
|
s699532037 | p03388 | u118642796 | 2,000 | 262,144 | Time Limit Exceeded | 2,104 | 3,064 | 398 | 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 ... | Q = int(input())
AB = [list(map(int,input().split())) for _ in range(Q)]
def cn(A,B):
ans = 0
pre = B
score = A*B
for i in range(A+1,score+1):
tmp = (score-1)//i
if tmp < 1:
break
if tmp == pre:
ans += pre-1
break
ans += 1
pre ... | s907748337 | Accepted | 20 | 3,064 | 372 | Q = int(input())
AB = [list(map(int,input().split())) for _ in range(Q)]
def cn(A,B):
score = A*B-1
L = A+1
R = score
if L>R:
return 0
while L!=R:
tmp = (L+R)//2
if score > tmp*(tmp+1):
L = tmp+1
else:
R = tmp
return (L-1-A+score//L)
for a... |
s648631440 | p03970 | u062691227 | 2,000 | 262,144 | Wrong Answer | 23 | 9,032 | 60 | CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a ce... | s = input()
sum(a!=b for a, b in zip(s, 'CODEFESTIVAL2016')) | s571363410 | Accepted | 25 | 9,000 | 70 | s, = *open(0),
print(sum(a!=b for a, b in zip(s, 'CODEFESTIVAL2016'))) |
s020744103 | p02255 | u764759179 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 251 | Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key ... | # coding:utf-8
length = int(input())
data = list(input().split())
for i in range(1,len(data)):
tmp = data[i]
i2 = i - 1
while i2 >=0 and data[i2] > tmp:
data[i2+1] = data[i2]
i2 -= 1
data[i2+1] = tmp
print(data)
| s917588923 | Accepted | 20 | 5,604 | 430 | # coding:utf-8
def printline(data):
l=""
for i,s in enumerate(data):
l = l + str(s)
if i+1 != len(data):
l = l+" "
print(l)
length = int(input())
data = list(map(int,input().split()))
printline(data)
for i in range(1,len(data)):
tmp = data[i]
i2 = i - 1
while i2 >=... |
s137495291 | p03998 | u322185540 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 606 | Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * ... | sa = input()
sb = input()
sc = input()
acount = 0
bcount = 0
ccount = 0
flag = True
ans = ''
tmp = sa[acount]
while flag:
if tmp == 'a':
acount += 1
if acount < len(sa):
tmp = sa[acount]
else:
ans = 'a'
flag = False
if tmp == 'b':
bcount += 1
... | s092818153 | Accepted | 17 | 3,064 | 771 | sa = input()
sb = input()
sc = input()
acount = 0
bcount = 0
ccount = 0
flag = True
ans = ''
tmp = sa[acount]
if len(sa) == 1:
ans = 'A'
else:
while flag:
if tmp == 'a':
if acount == len(sa):
flag = False
ans = 'A'
else:
tmp = sa[ac... |
s009045289 | p03485 | u098968285 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 235 | 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. | import math
def makelist(n, m):
return [[0 for _ in range(m)] for _ in range(n)]
# n = int(input())
# a, b = list(map(int, input().split()))
a, b = list(map(int, input().split()))
ans = math.ceil(a / b)
print(ans)
| s432211288 | Accepted | 17 | 2,940 | 241 | import math
def makelist(n, m):
return [[0 for _ in range(m)] for _ in range(n)]
# n = int(input())
# a, b = list(map(int, input().split()))
a, b = list(map(int, input().split()))
ans = math.ceil((a + b) / 2)
print(ans)
|
s612242304 | p03644 | u427344224 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 72 | 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... | N = int(input())
num = [i for i in range(N) if i % 2 ==0][-1]
print(num) | s413918647 | Accepted | 17 | 2,940 | 95 | N = int(input())
num = 1
for i in range(1, 9):
if 2**i <= N:
num = 2**i
print(num) |
s994668308 | p04011 | u127856129 | 2,000 | 262,144 | Wrong Answer | 18 | 2,940 | 128 | 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())
if a>=b:
print(int((b*c)-((a-b)*d)))
else:
print(int(a*c))
| s853415886 | Accepted | 20 | 2,940 | 128 | a=int(input())
b=int(input())
c=int(input())
d=int(input())
if a>=b:
print(int((b*c)+((a-b)*d)))
else:
print(int(a*c))
|
s799110474 | p03478 | u840974625 | 2,000 | 262,144 | Wrong Answer | 24 | 2,940 | 186 | 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())
x = 0
for i in range(n):
q = i
w = i / 10
e = i / 100
r = i / 1000
sum = q + w + e + r
if sum >= a and sum <= b:
x += 1
print(x) | s905737721 | Accepted | 27 | 3,060 | 284 | n, a, b = map(int, input().split())
x = 0
for i in range(1, n+1):
q = i // 10000
qi = i % 10000
w = qi // 1000
wi = qi % 1000
e = wi // 100
ei = wi % 100
r = ei // 10
ri = ei % 10
t = ri
sum = q + w + e + r + t
if sum >= a and sum <= b:
x += i
print(x) |
s067474325 | p03545 | u004025573 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 407 | Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given in... | N=int(input())
a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10
ope=[-1,1]
for i in ope:
for j in ope:
for k in ope:
if a+i*b+j*c+k*d==7:
ans=[i,j,k]
l=[0]*3
for i in range(3):
if ans[i]>0:
l[i]="+"
else:
l[i]="-"
#all_ans=[str(a),l[0],str(b),l[1]... | s874462053 | Accepted | 18 | 3,064 | 411 | N=int(input())
a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10
ope=[-1,1]
for i in ope:
for j in ope:
for k in ope:
if a+i*b+j*c+k*d==7:
ans=[i,j,k]
l=[0]*3
for i in range(3):
if ans[i]>0:
l[i]="+"
else:
l[i]="-"
#all_ans=[str(a),l[0],str(b),l[1]... |
s520012173 | p03377 | u386819480 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 95 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | a,b,x = (int(_) for _ in input().split())
print('Yes') if x >= a and a+b >= x else print('No')
| s915856315 | Accepted | 17 | 3,064 | 685 | #!/usr/bin/env python3
import sys
YES = "YES" # type: str
NO = "NO" # type: str
def solve(A: int, B: int, X: int):
print(YES) if(A <= X <= A+B) else print(NO)
return
# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by us... |
s522526755 | p03470 | u309039873 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 176 | An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you h... | size = 1
N = int(input())
d_s = []
for _ in range(N):
d_s.append(int(input()))
d_s.sort()
d_s.reverse()
for i in range(1,N):
if d_s[i] > d_s[i-1]:
size += 1
print(size) | s831350895 | Accepted | 17 | 3,060 | 176 | size = 1
N = int(input())
d_s = []
for _ in range(N):
d_s.append(int(input()))
d_s.sort()
d_s.reverse()
for i in range(1,N):
if d_s[i] < d_s[i-1]:
size += 1
print(size) |
s118171851 | p03693 | u184817817 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 117 | AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this i... | #064A
r,g,b = list(map(int,input().split()))
n = r*100 + g*10 + b
if n%4 == 0:
print('Yes')
else:
print('No') | s353501740 | Accepted | 17 | 2,940 | 117 | #064A
r,g,b = list(map(int,input().split()))
n = r*100 + g*10 + b
if n%4 == 0:
print('YES')
else:
print('NO') |
s051298675 | p03645 | u078349616 | 2,000 | 262,144 | Wrong Answer | 629 | 19,956 | 351 | In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk... | N, M = map(int, input().split())
a = [0]*M
b = [0]*M
for i in range(M):
a[i], b[i] = map(int, input().split())
c = []
for i in range(M):
if b[i] == M:
c.append(a[i])
if len(c) != 0:
for i in range(M):
if a[i] == 1:
for j in range(len(c)):
if b[i] == c[j]:
print("POSSIBLE")
... | s723571617 | Accepted | 811 | 29,104 | 233 | N, M = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(M):
a, b = map(lambda x: int(x)-1, input().split())
G[a].append(b)
for v in G[0]:
if N-1 in G[v]:
print("POSSIBLE")
exit()
print("IMPOSSIBLE")
|
s515000725 | p03543 | u672794510 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 250 | We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**? | a = int(input())
result = False
h1 = -1;
h2 = -1;
while a > 0:
print(a%10)
print(h1)
print(h2)
result = result or (h1 == h2 and h1 == a%10)
h2 = h1
h1 = a%10
a = a//10;
if result:
print("Yes")
else:
print("No") | s977952656 | Accepted | 18 | 3,060 | 206 | a = int(input())
result = False
h1 = -1;
h2 = -1;
while a > 0:
result = result or (h1 == h2 and h1 == a%10)
h2 = h1
h1 = a%10
a = a//10;
if result:
print("Yes")
else:
print("No") |
s813540417 | p03862 | u698479721 | 2,000 | 262,144 | Time Limit Exceeded | 2,118 | 212,180 | 282 | There are N boxes arranged in a row. Initially, the i-th box from the left contains a_i candies. Snuke can perform the following operation any number of times: * Choose a box containing at least one candy, and eat one of the candies in the chosen box. His objective is as follows: * Any two neighboring boxes con... | n,x = map(int, input().split())
a = [int(i) for i in input().split()]
b = []
if a[0]>x:
b.append(x)
else:
b.append(a[0])
j = 1
while j <= n-1:
if b[j-1]+a[j]<=x:
b.append(a[j])
else:
b.append(x-b[j-1])
k = 0
ans =0
while k < n:
ans += a[k]-b[k]
k += 1
print(ans) | s143430975 | Accepted | 124 | 14,060 | 255 | n,x = map(int, input().split())
a = [int(i) for i in input().split()]
ans = 0
if a[0]>x:
ans += a[0]-x
a[0]=x
else:
pass
j = 1
while j <= n-1:
if a[j-1]+a[j]<=x:
j += 1
else:
ans += a[j]-x+a[j-1]
a[j]=x-a[j-1]
j += 1
print(ans) |
s179725835 | p02743 | u405256066 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 144 | Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold? | from sys import stdin
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
if a**2 + b**2 < c**2:
print("Yes")
else:
print("No") | s205444194 | Accepted | 17 | 2,940 | 159 | from sys import stdin
a,b,c = [int(x) for x in stdin.readline().rstrip().split()]
if 4*a*b < (c-a-b)**2 and (c-a-b) > 0:
print("Yes")
else:
print("No") |
s607721623 | p03730 | u694665829 | 2,000 | 262,144 | Wrong Answer | 28 | 9,184 | 179 | We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objecti... | a,b,c=map(int,input().split())
flag = False
for i in range(10000):
if (i*b+c)%a==0:
flag = True
break
if flag:
print('Yes')
else:
print('No')
| s463995659 | Accepted | 32 | 9,152 | 174 | a,b,c=map(int,input().split())
flag = False
for i in range(10000):
if (i*b+c)%a==0:
flag = True
break
if flag:
print('YES')
else:
print('NO')
|
s980734498 | p02645 | u309821257 | 2,000 | 1,048,576 | Wrong Answer | 19 | 9,020 | 109 | When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him. | # -*- coding: utf-8 -*-
_in = input()
# if True:
# print(_in)
# else:
# print(_in)
print(_in[1:3]) | s563077253 | Accepted | 21 | 8,888 | 110 | # -*- coding: utf-8 -*-
_in = input()
# if True:
# print(_in)
# else:
# print(_in)
print(_in[0:3])
|
s846120238 | p03565 | u971124021 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 506 | E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One mo... | s = input()
t = input()
s = [x for x in s[::-1]]
t = [x for x in t[::-1]]
for i in range(len(s)-len(t)):
flg = False
cnt = 0
for j in range(i+len(t)):
if s[i+j] == '?':
cnt += 1
continue
if s[i+j] == t[j]:
flg = True
else:
flg = False
break
if flg or cnt == len(t)... | s057070929 | Accepted | 17 | 3,064 | 594 | s = input()
t = input()
if len(s) < len(t):
print('UNRESTORABLE')
exit()
s = [x for x in s[::-1]]
t = [x for x in t[::-1]]
for i in range(len(s)-len(t)+1):
flg = False
cnt = 0
for j in range(len(t)):
if s[i+j] == '?':
cnt += 1
continue
if s[i+j] == t[j]:
flg = True
els... |
s791823115 | p03944 | u207056619 | 2,000 | 262,144 | Wrong Answer | 60 | 3,064 | 1,196 | There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) po... | #!/usr/bin/env python3
import sys
def solve(W: int, H: int, N: int, x: "List[int]", y: "List[int]", a: "List[int]"):
cnt = 0
for y_ in range(H + 1):
for x_ in range(W + 1):
for i in range(N):
if a[i] == 1 and x_ < x[i] or a[i] == 2 and x_ > x[i] or a[i] == 3 and y_ < y[i] or... | s779572908 | Accepted | 59 | 3,064 | 1,197 | #!/usr/bin/env python3
import sys
def solve(W: int, H: int, N: int, x: "List[int]", y: "List[int]", a: "List[int]"):
cnt = 0
for y_ in range(H):
for x_ in range(W):
for i in range(N):
if a[i] == 1 and x_ < x[i] or a[i] == 2 and x_ >= x[i] or a[i] == 3 and y_ < y[i] or a[i] =... |
s620606983 | p00101 | u314832372 | 1,000 | 131,072 | Wrong Answer | 30 | 5,592 | 192 | An English booklet has been created for publicizing Aizu to the world. When you read it carefully, you found a misnomer (an error in writing) on the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet says "Hoshino" not "Hoshina". Your task is to write a program which replace all the words "Hoshino... | var1 = int(input())
str2 = "Hoshino"
str3 = "Hoshina"
for i in range(0, var1):
str1 = input()
if str1.find(str2) >= 0:
str1 = str1.replace(str2, str3)
print(str1)
| s488320142 | Accepted | 20 | 5,592 | 187 | var1 = int(input())
str2 = "Hoshino"
str3 = "Hoshina"
for i in range(0, var1):
str1 = input()
if str1.find(str2) >= 0:
str1 = str1.replace(str2, str3)
print(str1)
|
s065435929 | p00002 | u855694108 | 1,000 | 131,072 | Wrong Answer | 20 | 7,592 | 136 | Write a program which computes the digit number of sum of two integers a and b. | def main():
a, b = map(int, input().split())
hoge = list(str(a + b))
print(len(hoge))
if __name__ == "__main__":
main() | s417788840 | Accepted | 20 | 7,540 | 157 | import sys
def main():
for line in sys.stdin:
a, b = map(int, line.split())
print(len(str(a + b)))
if __name__ == "__main__":
main() |
s940389793 | p03828 | u822961851 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 306 | You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. | def resolve():
n = int(input())
M = 10 ** 9 + 7
pl = [0] * (n + 1)
for i in range(2, n+1):
x = i
p = 2
while x > 1:
while x % p == 0:
pl[p] += 1
x //= p
p += 1
ans = 1
for s in pl:
ans *= (s+1) | s914474877 | Accepted | 34 | 3,060 | 375 | def resolve():
n = int(input())
S = [0]*(n+1)
MOD = (10 ** 9) + 7
for i in range(1, n+1):
n_i = i
p = 2
while n_i > 1:
while n_i % p == 0:
n_i //= p
S[p] += 1
p += 1
ans = 1
for s in S:
ans *= s+1
print... |
s165211349 | p03448 | u655834330 | 2,000 | 262,144 | Wrong Answer | 57 | 3,064 | 271 | You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that co... | A = input()
B = input()
C = input()
X = input()
A,B,C,X = map(int, [A,B,C,X])
count = 0
for a in range(A):
for b in range(B):
for c in range(C):
x = (a+1)*500 + (b+1)*100 + (c+1)*50
if X == x:
count += 1
print(count) | s074385346 | Accepted | 57 | 3,064 | 289 | A = input()
B = input()
C = input()
X = input()
A,B,C,X = map(int, [A,B,C,X])
pattern_count = 0
for a in range(A+1):
for b in range(B+1):
for c in range(C+1):
x = a*500 + b*100 + c*50
if X == x:
pattern_count += 1
print(pattern_count) |
s557807799 | p02659 | u999799597 | 2,000 | 1,048,576 | Wrong Answer | 28 | 8,964 | 57 | Compute A \times B, truncate its fractional part, and print the result as an integer. | a, b = map(float, input().split())
print(int(a) * int(b)) | s248330897 | Accepted | 26 | 9,016 | 90 | a, b = map(float, input().split())
ib = b * 100
ans = int(a) * round(ib) // 100
print(ans) |
s202402107 | p03377 | u384679440 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 112 | There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. | A, B, X = map(int, input().split())
if X - A < 0:
print("No")
elif X - A <= B:
print("Yes")
else:
print("No") | s223673901 | Accepted | 17 | 2,940 | 92 | A, B, X = map(int, input().split())
if A + B <= X or A > X:
print("NO")
else:
print("YES") |
s915751024 | p02928 | u075303794 | 2,000 | 1,048,576 | Wrong Answer | 2,312 | 1,340,836 | 221 | We have a sequence of N integers A~=~A_0,~A_1,~...,~A_{N - 1}. Let B be a sequence of K \times N integers obtained by concatenating K copies of A. For example, if A~=~1,~3,~2 and K~=~2, B~=~1,~3,~2,~1,~3,~2. Find the inversion number of B, modulo 10^9 + 7. Here the inversion number of B is defined as the number of o... | N,K = map(int,input().split())
A = list(map(int,input().split()))
B = []
ans = 0
{B.extend(A) for i in range(K)}
for i in range(len(B)-1):
for j in range(i,len(B)):
if B[i] > B[j]:
ans+=1
print(ans/(10**9+7))
| s668695446 | Accepted | 29 | 3,564 | 682 | from collections import Counter
class Bit:
def __init__(self, n):
self.size = n
self.tree = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, i, x):
while i <= self.size:
self.tree[i] += x
i += i & -i
n,... |
s261811416 | p03474 | u178888901 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 311 | 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. | strnum = [str(i) for i in range(10)]
a, b = input().split()
a, b = int(a), int(b)
S = input()
judge = True
for i in range(a + b + 1):
if i != a:
if i in strnum:
continue
else:
judge = False
else:
if S[i] == "-":
continue
else:
judge = False
if judge:
print("Yes")
else:
print("NO")
| s316811382 | Accepted | 18 | 3,060 | 227 | strnum = [str(i) for i in range(10)]
a, b = input().split()
a, b = int(a), int(b)
S = input()
S = S.split("-")
if len(S) == 2:
if len(S[0]) == a and len(S[1]) == b:
print('Yes')
else:
print('No')
else:
print('No')
|
s767846305 | p03555 | u662449766 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 148 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | import sys
input = sys.stdin.readline
def main():
print("YES" if input() == input()[::-1] else "NO")
if __name__ == "__main__":
main()
| s960668772 | Accepted | 17 | 2,940 | 107 | def main():
print("YES" if input() == input()[::-1] else "NO")
if __name__ == "__main__":
main()
|
s517261847 | p04011 | u057964173 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 304 | 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. | import sys
def input(): return sys.stdin.readline().strip()
def resolve():
w=list(input())
w.sort()
if len(w)%2!=0:
print('No')
else:
for i in range(0,len(w),2):
if w[i]!=w[i+1]:
print('No')
break
print('Yes')
resolve() | s123228170 | Accepted | 17 | 2,940 | 168 | def resolve():
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n<k:
print(n*x)
else:
print(k*x+(n-k)*y)
resolve() |
s718815621 | p02401 | u152353734 | 1,000 | 131,072 | Wrong Answer | 30 | 7,416 | 77 | Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part. | while True:
a = input()
if '?' in a:
break
print(eval(a)) | s440570500 | Accepted | 20 | 7,496 | 84 | while True:
a = input()
if '?' in a:
break
print("%d" % eval(a)) |
s489848426 | p03860 | u559346857 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 26 | 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 uppe... | s=input()
print("A"+s+"B") | s368810351 | Accepted | 17 | 2,940 | 25 | print("A"+input()[8]+"C") |
s499154798 | p03408 | u147458211 | 2,000 | 262,144 | Wrong Answer | 18 | 3,064 | 740 | Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will ea... | N = int(input())
words = []
blue_cards = {}
for i in range(N):
s = input()
if s in blue_cards:
blue_cards[s] = blue_cards[s] + 1
else:
blue_cards[s] = 1
if s not in words:
words.append(s)
M = int(input())
red_cards= {}
for i in range(M):
s = input()
if s in red_cards:
red_cards[s] = red_... | s661467812 | Accepted | 17 | 3,064 | 654 | N = int(input())
words = []
blue_cards = {}
for i in range(N):
s = input()
if s in blue_cards:
blue_cards[s] = blue_cards[s] + 1
else:
blue_cards[s] = 1
if s not in words:
words.append(s)
M = int(input())
red_cards= {}
for i in range(M):
s = input()
if s in red_cards:
red_cards[s] = red_... |
s896776295 | p03737 | u159335277 | 2,000 | 262,144 | Wrong Answer | 30 | 8,972 | 52 | You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. | print(''.join(map(lambda x: x[0], input().split()))) | s478965651 | Accepted | 34 | 8,984 | 61 | print(''.join(map(lambda x: x[0], input().split())).upper())
|
s064291081 | p02388 | u138422838 | 1,000 | 131,072 | Wrong Answer | 20 | 7,320 | 22 | Write a program which calculates the cube of a given integer x. | x = 3
y = x^3
print(y) | s685507751 | Accepted | 20 | 7,640 | 34 | x = input()
y = int(x)**3
print(y) |
s964204350 | p03407 | u041196979 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 90 | 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 A + B <= C:
print("Yes")
else:
print("No")
| s808669549 | Accepted | 17 | 2,940 | 89 | A, B, C = map(int, input().split())
if A + B >= C:
print("Yes")
else:
print("No") |
s373610105 | p02865 | u550061714 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 32 | How many ways are there to choose two distinct positive integers totaling N, disregarding the order? | print(round((int(input())-1)/2)) | s404615660 | Accepted | 17 | 2,940 | 49 | import math
print(math.floor((int(input())-1)/2)) |
s569879071 | p00016 | u553148578 | 1,000 | 131,072 | Wrong Answer | 20 | 5,724 | 200 | When a boy was cleaning up after his grand father passing, he found an old paper: In addition, other side of the paper says that "go ahead a number of steps equivalent to the first integer, and turn clockwise by degrees equivalent to the second integer". His grand mother says that Sanbonmatsu was standing at t... | import math
x = y = n= 0
while True:
d,a = map(int,input().split(','))
if d == a == 0: break
x += d*math.sin(math.radians(n))
y += d*math.cos(math.radians(n))
n+=a
print(map(int,(x,y)),sep='\n')
| s851284976 | Accepted | 20 | 5,716 | 201 | import math
x = y = n= 0
while True:
d,a = map(int,input().split(','))
if d == a == 0: break
x += d*math.sin(math.radians(n))
y += d*math.cos(math.radians(n))
n+=a
print(*map(int,(x,y)),sep='\n')
|
s334230411 | p02406 | u483716678 | 1,000 | 131,072 | Wrong Answer | 20 | 5,588 | 127 | In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement ... | n = int(input())
for x in range(n+1):
if(x%3==0):
print(x,end=' ')
elif(x%10 == 3):
print(x,end=' ')
| s416708655 | Accepted | 30 | 5,868 | 264 | n = int(input())
y = 1
while y <= n :
if(y % 3 == 0):
print(' %d'%y,end='')
else:
p = y
while(p != 0):
if(p % 10 == 3):
print(' %d'%y,end='')
break
p //= 10
y+=1
print()
|
s116730671 | p02850 | u685983477 | 2,000 | 1,048,576 | Wrong Answer | 808 | 65,364 | 1,007 | Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i. Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different. Among the colo... | from collections import deque
def main():
n = int(input())
tree = []
edge = [[] for _ in range(n)]
for i in range(n-1):
a,b=map(int, input().split())
tree.append([min(a,b),max(a,b),n])
edge[a-1].append([b-1,i])
edge[b-1].append([a-1,i])
cols = [0]*(n-1)
max_c = [0... | s465214691 | Accepted | 692 | 46,832 | 782 | from collections import deque,defaultdict
n = int(input())
edges = [[] for _ in range(n)]
for i in range(n-1):
a,b=map(int, input().split())
edges[a-1].append([b-1,i])
edges[b-1].append([a-1,i])
c = 1
col = [0]*(n-1)
visited = [0]*(n-1)
que=deque()
for v in edges[0]:
que.append(v)
col[v[1]]=c
vi... |
s852102285 | p03195 | u291732989 | 2,000 | 1,048,576 | Wrong Answer | 202 | 7,072 | 183 | There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen a... | N = int(input())
An = []
for p in range(N):
Ai = int(input())
An.append(Ai)
res = True
for i in An:
if i % 2 != 0:
res = False
print("first" if res else "second")
| s683037251 | Accepted | 197 | 7,072 | 183 | N = int(input())
An = []
for p in range(N):
Ai = int(input())
An.append(Ai)
res = True
for i in An:
if i % 2 != 0:
res = False
print("second" if res else "first")
|
s922192844 | p03369 | u518556834 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 51 | In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ... | s = list(input())
print(700 + 100 * s.count("○")) | s646526931 | Accepted | 17 | 2,940 | 88 | s = input()
c = 0
for i in range(3):
if s[i] == "o":
c += 1
print(700 + c*100)
|
s491806829 | p03494 | u642682703 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 218 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | evens = [6,4,10,4]
itr = 0
flg = True
while flg:
evens = list(map(lambda x: (x/2), evens))
is_evens = list(map(lambda x: x.is_integer(), evens))
if not all(is_evens):
flg = False
break
itr+=1
print(itr) | s872363370 | Accepted | 19 | 3,060 | 257 | num = input()
evens = [int(x) for x in input().split()]
itr = 0
flg = True
while flg:
evens = list(map(lambda x: (x/2), evens))
is_evens = list(map(lambda x: x.is_integer(), evens))
if not all(is_evens):
flg = False
break
itr+=1
print(itr) |
s242253957 | p02393 | u748921161 | 1,000 | 131,072 | Wrong Answer | 20 | 7,704 | 139 | Write a program which reads three integers, and prints them in ascending order. | input_str = input().split(' ')
input_int = []
for value in input_str:
input_int.append(int(value))
input_int.sort();
print(input_int); | s761463527 | Accepted | 20 | 7,692 | 181 | input_str = input().split(' ')
input_int = []
for value in input_str:
input_int.append(int(value))
input_int.sort();
print('%d %d %d'%(input_int[0],input_int[1],input_int[2])); |
s960746747 | p03139 | u227082700 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 59 | We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answ... | a,b,c=map(int,input().split());print(max(b,c),max(0,b+c-a)) | s173186197 | Accepted | 17 | 2,940 | 59 | a,b,c=map(int,input().split());print(min(b,c),max(0,b+c-a)) |
s641890480 | p02856 | u716530146 | 2,000 | 1,048,576 | Wrong Answer | 252 | 17,384 | 76 | N programmers are going to participate in the preliminary stage of DDCC 20XX. Due to the size of the venue, however, at most 9 contestants can participate in the finals. The preliminary stage consists of several rounds, which will take place as follows: * All the N contestants will participate in the first round. ... | _,*t=open(0)
a=-18
for t in t:d,c=map(int,t.split());a+=d*c+c*9
print(a//9)
| s813984942 | Accepted | 612 | 3,060 | 102 | a=0
m=int(input())
for i in range(m):
d,c=map(int,input().split())
a+=c*9+d*c
print((a-10)//9) |
s227315889 | p03394 | u694433776 | 2,000 | 262,144 | Wrong Answer | 32 | 5,084 | 608 | 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 t... | n=int(input())
ret=[2,3,4] if n>=6 else [2,3,25] if n==3 else [2,3,5,30] if n==4 else [2,3,5,30,60]
if n>=6:
def getnext(a):
if a%6==0:
return a+2
elif a%6==2:
return a+1
elif a%6==3:
return a+1
elif a%6==4:
return a+2
while len(ret... | s223478673 | Accepted | 32 | 5,084 | 610 | n=int(input())
ret=[2,3,4] if n>=6 else [2,5,63] if n==3 else [2,5,20,63] if n==4 else [2,5,20,30,63]
if n>=6:
def getnext(a):
if a%6==0:
return a+2
elif a%6==2:
return a+1
elif a%6==3:
return a+1
elif a%6==4:
return a+2
while len(r... |
s087547027 | p03574 | u887207211 | 2,000 | 262,144 | Wrong Answer | 23 | 3,064 | 766 | You are given an H × W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). `.` stands for an empty square, and `#` stands for a square con... | H, W = map(int,input().split())
S = [input() for _ in range(H)]
result = [[0 for _ in range(W+1)]for _ in range(H+1)]
for i in range(H):
for j in range(W):
if(S[i][j] == '#'):
result[i][j] = '#'
if(result[i-1][j-1] != '#'):
result[i-1][j-1] += 1
if(result[i-1][j] != '#'):
result... | s287803037 | Accepted | 24 | 3,188 | 764 | H, W = map(int,input().split())
S = [input() for _ in range(H)]
reach = [[0 for _ in range(W+1)] for _ in range(H+1)]
for i in range(H):
for j in range(W):
if(S[i][j] == "#"):
reach[i][j] = "#"
if(reach[i-1][j-1] != "#"):
reach[i-1][j-1] += 1
if(reach[i-1][j] != "#"):
reach[i-1]... |
s258856945 | p02243 | u684241248 | 1,000 | 131,072 | Wrong Answer | 30 | 6,036 | 4,527 | For a given weighted graph $G = (V, E)$, find the shortest path from a source to each vertex. For each vertex $u$, print the total weight of edges on the shortest path from vertex $0$ to $u$. | # -*- coding: utf-8 -*-
from collections import defaultdict
from heapq import heappop, heappush
def dijkstra(edges, start, *, adj_matrix=False, default_value=float('inf')):
'''
Returns best costs to each node from 'start' node in the given graph.
(Single Source Shortest Path - SSSP)
If edges is given... | s889552347 | Accepted | 460 | 68,708 | 4,374 | # -*- coding: utf-8 -*-
from heapq import heappop, heappush
def dijkstra(edges, start, *, adj_matrix=False, default_value=float('inf')):
'''
Returns best costs to each node from 'start' node in the given graph.
(Single Source Shortest Path - SSSP)
If edges is given as an adjacency list including cost... |
s000556123 | p02853 | u732870425 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 170 | We held two competitions: Coding Contest and Robot Maneuver. In each competition, the contestants taking the 3-rd, 2-nd, and 1-st places receive 100000, 200000, and 300000 yen (the currency of Japan), respectively. Furthermore, a contestant taking the first place in both competitions receives an additional 400000 yen.... | X, Y = map(int, input().split())
ans = 0
if X >= 3:
ans += (4 - X) * 100000
if Y >= 3:
ans += (4 - Y) * 100000
if X == 1 and Y == 1:
ans += 400000
print(ans) | s970646842 | Accepted | 17 | 2,940 | 170 | X, Y = map(int, input().split())
ans = 0
if X <= 3:
ans += (4 - X) * 100000
if Y <= 3:
ans += (4 - Y) * 100000
if X == 1 and Y == 1:
ans += 400000
print(ans) |
s743337277 | p04029 | u876742094 | 2,000 | 262,144 | Wrong Answer | 28 | 9,008 | 32 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n=int(input())
print(n*(n+1)/2)
| s581540154 | Accepted | 26 | 9,140 | 33 | n=int(input())
print(n*(n+1)//2)
|
s908666455 | p03696 | u329865314 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 223 | You are given a string S of length N consisting of `(` and `)`. Your task is to insert some number of `(` and `)` into S to obtain a _correct bracket sequence_. Here, a correct bracket sequence is defined as follows: * `()` is a correct bracket sequence. * If X is a correct bracket sequence, the concatenation of... | n = int(input())
s = input()
ans = ""
cur = 0
for i in s:
if i == "(":
ans += "("
cur += 1
ans += i
else:
if cur:
ans += i
cur -= 1
else:
ans = "(" + ans
ans += ")" * cur
print(ans) | s252872774 | Accepted | 17 | 3,060 | 212 | n = int(input())
s = input()
ans = ""
cur = 0
for i in s:
if i == "(":
cur += 1
ans += i
else:
if cur:
ans += i
cur -= 1
else:
ans = "(" + ans + i
ans += ")" * cur
print(ans) |
s894562398 | p02612 | u556477263 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,004 | 116 | 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. | import sys
n = int(input())
if n % 1000 == 0:
print(0)
sys.exit()
while n > 1000:
n -= 1000
print(n) | s220168034 | Accepted | 34 | 9,108 | 123 | import sys
n = int(input())
if n % 1000 == 0:
print(0)
sys.exit()
while n > 1000:
n -= 1000
print(1000 - n) |
s420104534 | p03090 | u801049006 | 2,000 | 1,048,576 | Wrong Answer | 30 | 9,072 | 57 | You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved... | n = int(input())
for i in range(n-1):
print(i+1, n)
| s042087256 | Accepted | 33 | 9,696 | 233 | n = int(input())
d = n
ans = []
if n % 2 == 1: d -= 1
for i in range(1, n+1):
for j in range(1, n+1):
if j <= i or j == d: continue
ans.append([i, j])
d -= 1
print(len(ans))
for f, s in ans:
print(f, s)
|
s371745677 | p02972 | u143903328 | 2,000 | 1,048,576 | Wrong Answer | 1,080 | 17,200 | 367 | 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 con... | n = int(input())
a = list(map(int,input().split()))
c = 0
ans = []
for i in range(n):
m = n-i
p = 1
b = 0
while m * p <= n:
tmp = m * p
if a[tmp-1] == 1:
b += 1
p += 1
if b % 2 == 1:
ans.append(m)
c += 1
if c%2 == 1:
print('-1')
else:
prin... | s803347793 | Accepted | 1,084 | 19,856 | 405 | n = int(input())
a = list(map(int,input().split()))
c = 0
d = [0] * n
ans = []
for i in range(n):
m = n-i
p = 1
b = 0
while m * p <= n:
tmp = m * p
if d[tmp-1] == 1:
b += 1
p += 1
if b % 2 != a[m-1]:
d[m-1] = 1
ans.append(m)
c += 1
if c%2 ... |
s532288470 | p03494 | u434311880 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 153 | There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. | N = int(input())
b = (int(s) for s in input().split())
x = 0
for i in b:
i = i // 2
c = i % 2
x = x + 1
if c != 0:
break
print(x) | s783035642 | Accepted | 18 | 2,940 | 144 | N = int(input())
a = list(map(int, input().split()))
cnt = 0
while all(i % 2 == 0 for i in a):
a = [i/2 for i in a]
cnt += 1
print(cnt)
|
s316827162 | p03997 | u840570107 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 84 | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid. | a = int(input())
b = int(input())
h = int(input())
ans = (a + b) * h / 2
print(ans)
| s179318234 | Accepted | 17 | 2,940 | 89 | a = int(input())
b = int(input())
h = int(input())
ans = (a + b) * h / 2
print(int(ans)) |
s567785989 | p03455 | u662573896 | 2,000 | 262,144 | Wrong Answer | 26 | 9,112 | 97 | AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd. | a, b = map(int, input().split())
if (a * b) % 2 == 1:
print ('odd')
else:
print ('even') | s666067491 | Accepted | 26 | 8,936 | 97 | a, b = map(int, input().split())
if (a * b) % 2 == 1:
print ('Odd')
else:
print ('Even') |
s760652623 | p03158 | u353797797 | 2,000 | 1,048,576 | Wrong Answer | 1,240 | 25,136 | 804 | There are N cards. The i-th card has an integer A_i written on it. For any two cards, the integers on those cards are different. Using these cards, Takahashi and Aoki will play the following game: * Aoki chooses an integer x. * Starting from Takahashi, the two players alternately take a card. The card should be c... | import sys
from bisect import *
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [L... | s060800740 | Accepted | 1,300 | 24,544 | 829 | import sys
from bisect import *
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [L... |
s848349486 | p03711 | u702719601 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 248 | 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. | data = input().split()
x = int(data[0])
y = int(data[1])
L1 = [1,3,5,7,8,10,12]
L2 = [4,6,9,11]
L3 = [2]
print(L1)
print(L2)
print(L3)
if((x in L1 and y in L1) or (x in L2 and y in L2) or (x in L3 and y in L3)):
print("Yes")
else:
print("No")
| s603266797 | Accepted | 17 | 3,060 | 217 | data = input().split()
x = int(data[0])
y = int(data[1])
L1 = [1,3,5,7,8,10,12]
L2 = [4,6,9,11]
L3 = [2]
if((x in L1 and y in L1) or (x in L2 and y in L2) or (x in L3 and y in L3)):
print("Yes")
else:
print("No")
|
s952858009 | p03478 | u343150957 | 2,000 | 262,144 | Wrong Answer | 28 | 3,060 | 185 | 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):
ans = 0
while (i // 10) != 0:
i = (i // 10)
ans += (i % 10)
if ans >= a and ans <= b:
count += 1
print(count) | s167608753 | Accepted | 37 | 3,060 | 144 | n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
if a <= sum(list(map(int, list(str(i))))) <= b:
ans += i
print(ans) |
s575658305 | p03609 | u865413330 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 109 | We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? | s = list(input())
result = ""
for i in range(len(s)):
if i % 2 != 0:
result += s[i]
print(result) | s331818852 | Accepted | 17 | 2,940 | 69 | x, t = map(int, input().split())
print(x - t) if x >= t else print(0) |
s403415258 | p02663 | u497356352 | 2,000 | 1,048,576 | Wrong Answer | 23 | 9,412 | 601 | In this problem, we use the 24-hour clock. Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying? | # coding:utf-8
import sys
import datetime
readline = sys.stdin.buffer.readline
try:
H1 = int(readline())
M1 = int(readline())
H2 = int(readline())
M2 = int(readline())
K = int(readline())
while not (0 <= H1 < 23 and 0 <= M1 < 59 and 0 <= H2 < 23 and 0 <= M2 < 59):
H1 = int(readline())
... | s004133242 | Accepted | 20 | 9,196 | 132 | import sys
readline = sys.stdin.buffer.readline
h1, m1, h2, m2, k = map(int, readline().split())
print(60 * (h2 - h1) + m2 - m1 - k) |
s039610041 | p04029 | u658978681 | 2,000 | 262,144 | Wrong Answer | 20 | 3,060 | 33 | There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? | n = int(input())
print(n*(n+1)/2) | s089529459 | Accepted | 18 | 2,940 | 34 | n = int(input())
print(n*(n+1)//2) |
s294477566 | p03555 | u725757838 | 2,000 | 262,144 | Wrong Answer | 18 | 3,060 | 69 | You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise. | a=input()
b=input()
if b[::-1]==a:
print("Yes")
else:
print("NO") | s694373802 | Accepted | 17 | 2,940 | 69 | a=input()
b=input()
if b[::-1]==a:
print("YES")
else:
print("NO") |
s262485123 | p02744 | u896741788 | 2,000 | 1,048,576 | Wrong Answer | 20 | 3,184 | 420 | In this problem, we only consider strings consisting of lowercase English letters. Strings s and t are said to be **isomorphic** when the following conditions are satisfied: * |s| = |t| holds. * For every pair i, j, one of the following holds: * s_i = s_j and t_i = t_j. * s_i \neq s_j and t_i \neq t_j. F... | from time import time
n=int(input())
from itertools import combinations as pe
al=[]
for i in range(n):
for tu in pe(range(n-1),i):
if tu:
pre=tu[0]
ans="a"*(pre+1)
for d,v in enumerate(tu[1:]):
ans+=chr(98+d)*(v-pre);pre=v
ans+=chr(ord(ans[-1... | s006517301 | Accepted | 152 | 4,404 | 162 | li="abcdefghijklmn"
n=int(input())
def f(s,l,k):
global li,n
if l==n:print(s);return
for i in range(2+k):
f(s+li[i],l+1,max(i,k))
f("a",1,0) |
s117010763 | p03693 | u632413369 | 2,000 | 262,144 | Wrong Answer | 27 | 9,096 | 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 i... | t = sum(map(int, input().split()))
print('YES' if t % 4 == 0 else 'NO') | s348639278 | Accepted | 23 | 9,160 | 93 | a, b, c = map(int, input().split())
print('YES' if (a * 100 + b * 10 + c) % 4 == 0 else 'NO') |
s347939393 | p03080 | u899929023 | 2,000 | 1,048,576 | Wrong Answer | 18 | 2,940 | 103 | There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat. | N=int(input())
st=input()
R_num = st.count('R')
if R_num*2 > N:
print('YES')
else:
print('NO') | s564687742 | Accepted | 17 | 2,940 | 104 | N=int(input())
st=input()
R_num = st.count('R')
if R_num*2 > N:
print('Yes')
else:
print('No')
|
s968734020 | p03228 | u077337864 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 173 | In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other pe... | A, B, K = map(int, input().strip().split())
for k in range(K):
if k % 2 == 0:
A = A // 2
B = B + A // 2
else:
B = B // 2
A = A + B // 2
print(A, B) | s455429653 | Accepted | 18 | 2,940 | 209 | A, B, K = map(int, input().strip().split())
for k in range(K):
if k % 2 == 0:
_A = A // 2
_B = B + A // 2
A, B = _A, _B
else:
_B = B // 2
_A = A + B // 2
A, B = _A, _B
print(A, B)
|
s434498413 | p03130 | u131634965 | 2,000 | 1,048,576 | Wrong Answer | 17 | 3,060 | 188 | There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roa... | city={1:0, 2:0, 3:0, 4:0}
for _ in range(3):
a,b=map(int, input().split())
city[a]+=1
city[b]+=1
if list(city.values()).count(2)==2:
print("Yes")
else:
print("No") | s242330009 | Accepted | 17 | 3,060 | 188 | city={1:0, 2:0, 3:0, 4:0}
for _ in range(3):
a,b=map(int, input().split())
city[a]+=1
city[b]+=1
if list(city.values()).count(2)==2:
print("YES")
else:
print("NO") |
s167732768 | p03680 | u689322583 | 2,000 | 262,144 | Wrong Answer | 224 | 7,084 | 273 | Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It ... | #coding: utf-8
N = int(input())
a = []
for i in range(N):
a.append(int(input()))
start = 0
count = 0
for i in range(N):
count += 1
next = a[start]
start = a[next-1]
if(start == 2):
print(count)
break
start -= 1
else:
print(-1) | s693512344 | Accepted | 53 | 7,068 | 162 | import sys
N = list(map(int, sys.stdin))
bot = N[1]
for i in range(N[0]):
if bot == 2:
print(i+1)
break
bot = N[bot]
else:
print(-1) |
s638037713 | p02418 | u956226421 | 1,000 | 131,072 | Wrong Answer | 20 | 7,368 | 287 | Write a program which finds a pattern $p$ in a ring shaped text $s$. | s = input()
p = input()
Ans = False
for i in range(len(s)):
for j in range(len(p)):
if i + j >= len(s):
i = -1
if s[i + j] != p[j]:
break
if j == len(p) - 1:
Ans = True
break
if Ans:
print('Yes')
else:
print('No') | s621562413 | Accepted | 60 | 7,528 | 322 | s = input()
p = input()
Ans = False
cnt = 0
for i in range(len(s)):
for j in range(len(p)):
if i + j >= len(s):
i = -j
if s[i + j] != p[j]:
break
cnt += 1
if cnt == len(p):
Ans = True
break
cnt = 0
if Ans:
print('Yes')
else:
print('No... |
s879638043 | p03493 | u962423738 | 2,000 | 262,144 | Wrong Answer | 24 | 8,948 | 50 | Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble. | n=list(map(int,input().split()))
print(n.count(1)) | s681993158 | Accepted | 28 | 8,944 | 29 | n=input()
print(n.count("1")) |
s472435594 | p03854 | u738622346 | 2,000 | 262,144 | Wrong Answer | 18 | 3,940 | 830 | You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`. | s = input()
t = ""
while len(t) < len(s):
target_len = len(s) - len(t)
if s[len(t)] == 'd':
if target_len == 5:
t += "dream"
elif target_len == 7:
t += "dreamer"
elif target_len > 7:
if s[len(t) + 5] != 'd' and s[len(t) + 7] != 'a':
t ... | s321967328 | Accepted | 50 | 3,188 | 440 | s = input()
div = ["dream", "dreamer", "erase", "eraser"]
rev = []
t = ""
s_rev = s[::-1]
for d in div:
rev.append(d[::-1])
result = True
i = 0
while i < len(s):
can_divide = False
for d in rev:
if len(s_rev) - i >= len(d) and s_rev[i:i + len(d)] == d:
can_divide = True
i +=... |
s387112457 | p03416 | u090225501 | 2,000 | 262,144 | Wrong Answer | 96 | 3,060 | 134 | Find the number of _palindromic numbers_ among the integers between A and B (inclusive). Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward. | a, b = map(int, input().split())
c = 0
for i in range(a, b + 1):
x = list(str(i))
y = reversed(x)
if x == y:
c += 1
print(c) | s295796917 | Accepted | 103 | 2,940 | 137 | a, b = map(int, input().split())
c = 0
for i in range(a, b + 1):
x = str(i)
y = ''.join(reversed(x))
if x == y:
c += 1
print(c) |
s493484404 | p02612 | u277175276 | 2,000 | 1,048,576 | Wrong Answer | 31 | 9,128 | 28 | We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required. | N=int(input())
print(N%1000) | s353094030 | Accepted | 29 | 9,124 | 65 | N=int(input())
b=N%1000
if b==0:
print(0)
else:
print(1000-b) |
s636447721 | p03044 | u188745744 | 2,000 | 1,048,576 | Wrong Answer | 339 | 28,892 | 406 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | N=int(input())
l=[0]*N
com_l=[[] for i in range(N)]
for i in range(N-1):
X,Y,Z=list(map(int,input().split()))
com_l[X-1].append((Y-1,Z%2))
for i in range(N-1):
if com_l[i] != []:
if l[i] == 0:
for j,k in com_l[i]:
if k ==1:
l[j]=1
else:
... | s609442877 | Accepted | 472 | 39,852 | 491 | from collections import deque
N=int(input())
visited=[-1]*N
l=[[] for i in range(N)]
for i in range(N-1):
a,b,c=map(int,input().split())
a-=1;b-=1
l[a].append((b,c%2))
l[b].append((a,c%2))
def ans(node,dis):
visited[node]=0
que=deque(l[node])
while que:
node,dis=que.popleft()
visited[no... |
s378476269 | p02796 | u272336707 | 2,000 | 1,048,576 | Wrong Answer | 2,105 | 30,244 | 379 | 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... | n = int(input())
li=[]
lis=[]
count_lis=[0]*n
for i in range(n):
li = list(map(int, input().split()))
lis.append(li)
lis.sort()
for i in range(n):
for j in range(i+1, n):
if lis[i][0] + lis[i][1] > lis[j][0] - lis[j][1]:
count_lis[i] += 1
count_lis[j] += 1
else:
... | s231696329 | Accepted | 521 | 20,096 | 309 | n = int(input())
lis=[]
count=0
for i in range(n):
li=[None]*2
x, l = map(int, input().split())
li[0] = x+l
li[1] = x-l
lis.append(li)
lis.sort()
kari_r = -(10 ** 18)
for r, l in lis:
if kari_r > l:
continue
count+=1
kari_r = r
print(count) |
s675774474 | p03370 | u706159977 | 2,000 | 262,144 | Wrong Answer | 354 | 3,064 | 200 | Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams o... | m,x = [int(i) for i in input().split()]
s=[]
for i in range(m):
list.append(s, int(input()))
x = x-sum(s)
print(sum(s))
print(x)
ct = 0
while x>min(s):
x = x - min(s)
ct = ct+1
print(ct+m) | s031939020 | Accepted | 355 | 3,060 | 178 | m,x = [int(i) for i in input().split()]
s=[]
for i in range(m):
list.append(s, int(input()))
x = x-sum(s)
ct = 0
while x>=min(s):
x = x - min(s)
ct = ct+1
print(ct+m) |
s921308107 | p03836 | u143976525 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 233 | Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement ... | sx,sy,tx,ty=map(int,input().split())
ans=""
y=ty-sy
x=tx-sx
ans +="U"*y
ans +="R"*x
ans +="D"*y
ans +="L"*x
ans +="L"
ans +="U"*y
ans +="R"*x
ans +="D"
ans +="R"
ans +="D"*y
ans +="L"*x
ans +="U"
print(ans) | s225235510 | Accepted | 17 | 3,064 | 321 | sx,sy,tx,ty=map(int,input().split())
ans=""
y=ty-sy
x=tx-sx
ans +="U"*y
ans +="R"*x
ans +="D"*y
ans +="L"*x
ans +="L"
ans +="U"*(y+1)
ans +="R"*(x+1)
ans +="D"
ans +="R"
ans +="D"*(y+1)
ans +="L"*(x+1)
ans +="U"
print(ans) |
s714891429 | p00085 | u546285759 | 1,000 | 131,072 | Wrong Answer | 20 | 7,564 | 203 | 昔、ヨセフのおイモというゲームがありました。n 人が参加しているとしましょう。参加者は中心を向いて円陣を組み、1 から順番に番号が振られます。アツアツのおイモがひとつ、参加者 n (左の図内側の大きい数字の 30 )に渡されます。おイモを渡された参加者は右隣の参加者にそのおイモを渡します。 m 回目に渡された人は右隣の人に渡して円陣から抜けます(左の図では m = 9 の場合を表しています) 。 回渡す毎に一人ずつぬけ、最後に残った人が勝者となり、おイモをいただきます。 n ,m が決まってから、実際におイモを渡し始める前にどこにいたら勝てるかわかるといいですよね。上の図は 30 人の参加者で 9 人ごとに抜けるというルー... | n, m = map(int, input().split())
p, i = [i+1 for i in range(n)], m
while True:
p.pop(m-1)
if len(p)==1:
print(p[0])
break
tmp = m+i-1
m = tmp%len(p) if tmp>len(p) else tmp | s685147294 | Accepted | 30 | 7,720 | 219 | while True:
n, m = map(int, input().split())
if n == 0:
break
p = [i for i in range(1, n+1)]
idx = m-1
while len(p) != 1:
v = p.pop(idx)
idx = (idx+m-1) % len(p)
print(*p) |
s192931388 | p02608 | u343744945 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 9,312 | 928 | 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). | import math
N=int(input())
sqN = int(math.sqrt(N))+1
sq=list()
for i in range(1,N):
sq.append(i*i)
def isSquare(n):
if n in sq:
return True
else:
return False
ans=list()
for i in range(min(N,6)):
ans.append(0)
if N>5:
for m in range(6,N+1):
cnt = 0
for x in range... | s163197746 | Accepted | 58 | 9,264 | 659 | N=int(input())
cnts=[0 for i in range(N+1)]
for x in range(1,100):
x2=x*x
for y in range(x,100):
y2=y*y
xy=x*y
if x2+y*y+x*y+x+y > N:
break
for z in range(y,100):
z2 = z*z
M = x2+y2+z2+xy+y*z+z*x
if M > N:
break
... |
s147818109 | p02412 | u017435045 | 1,000 | 131,072 | Wrong Answer | 20 | 5,592 | 258 | 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 1:
n, x = map(int,input().split())
if n ==0 and x ==0:
break
ans = 0
for i in range(n-1):
for j in range(i,n):
for k in range(j,n):
if i + j +k ==x:
ans += 1
print(ans)
| s134780393 | Accepted | 510 | 5,596 | 264 | while 1:
n, x = map(int,input().split())
if n == x ==0:
break
ans = 0
for i in range(1, n+1):
for j in range(i+1,n+1):
for k in range(j+1,n+1):
if i + j +k ==x:
ans += 1
print(ans)
|
s705689954 | p03672 | u827202523 | 2,000 | 262,144 | Wrong Answer | 17 | 3,064 | 275 | We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by del... | def judge(S):
half = int(len(S)/2)
if S[:half] == S[half:]:
return True
else:
return False
S= input()
l = len(S)
if l%2 == 1:
S = S[:-1]
else:
S = S[:-2]
print(S)
while S != "":
if judge(S):
break
S = S[:-2]
print(len(S)) | s174907134 | Accepted | 17 | 3,060 | 266 | def judge(S):
half = int(len(S)/2)
if S[:half] == S[half:]:
return True
else:
return False
S= input()
l = len(S)
if l%2 == 1:
S = S[:-1]
else:
S = S[:-2]
while S != "":
if judge(S):
break
S = S[:-2]
print(len(S)) |
s171990764 | p03380 | u794173881 | 2,000 | 262,144 | Wrong Answer | 154 | 14,428 | 245 | Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted. | n = int(input())
a = list(map(int,input().split()))
sort_a = sorted(a,reverse=True)
max_a = sort_a[0]
ans=0
for i in range(n):
if min(abs(max_a//2-sort_a[i]),abs(max_a//2-ans)) == abs(max_a//2-sort_a[i]):
ans = sort_a[i]
print(max_a,ans) | s029248815 | Accepted | 166 | 14,428 | 242 | n = int(input())
a = list(map(int,input().split()))
sort_a = sorted(a,reverse=True)
max_a = sort_a[0]
ans=0
for i in range(n):
if min(abs(max_a/2-sort_a[i]),abs(max_a/2-ans)) == abs(max_a/2-sort_a[i]):
ans = sort_a[i]
print(max_a,ans) |
s472034381 | p03486 | u311379832 | 2,000 | 262,144 | Wrong Answer | 17 | 3,060 | 148 | 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 = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
ss = ''.join(s)
ts = ''.join(t)
if s < t:
print('YES')
else:
print('NO') | s956109656 | Accepted | 17 | 3,060 | 148 | s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
ss = ''.join(s)
ts = ''.join(t)
if s < t:
print('Yes')
else:
print('No') |
s472826336 | p03068 | u243572357 | 2,000 | 1,048,576 | Wrong Answer | 17 | 2,940 | 143 | 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())
a = input()
l = int(input())
for i in range(n):
if a[l-1] != a[i]:
print('*', sep='')
else:
print(a[l-1], sep='')
| s361658932 | Accepted | 17 | 2,940 | 89 | input()
s = input()
n = int(input())
print(*[i if i==s[n-1] else "*" for i in s], sep='') |
s093519404 | p02261 | u159356473 | 1,000 | 131,072 | Wrong Answer | 50 | 7,680 | 852 | 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 Bubbl... | #coding:UTF-8
def BS(N,A):
for i in range(N):
for j in reversed(range(i+1,N)):
if int(A[j][1:])<int(A[j-1][1:]):
swap=A[j]
A[j]=A[j-1]
A[j-1]=swap
return A
def SS(N,A):
for i in range(N):
minj=i
for j in range(i,N):
... | s658822519 | Accepted | 50 | 7,796 | 886 | #coding:UTF-8
def BS(N,A):
for i in range(N):
for j in reversed(range(i+1,N)):
if int(A[j][1:])<int(A[j-1][1:]):
swap=A[j]
A[j]=A[j-1]
A[j-1]=swap
return A
def SS(N,A):
for i in range(N):
minj=i
for j in range(i,N):
... |
s175040961 | p03386 | u672494157 | 2,000 | 262,144 | Wrong Answer | 25 | 3,812 | 823 | Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. | import sys
from functools import reduce
import copy
import math
from pprint import pprint
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def int_inputs(num_of_input):
ins = [int(input()) for i in range(num_of_input)]
return ins
de... | s651745766 | Accepted | 40 | 4,068 | 837 | import sys
from functools import reduce
import copy
import math
from pprint import pprint
sys.setrecursionlimit(4100000)
def inputs(num_of_input):
ins = [input() for i in range(num_of_input)]
return ins
def int_inputs(num_of_input):
ins = [int(input()) for i in range(num_of_input)]
return ins
de... |
s166658261 | p03369 | u292810930 | 2,000 | 262,144 | Wrong Answer | 17 | 2,940 | 140 | In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is ... | S = input()
100
t = 0
for i in range(len(S)):
if S[i] == 'o':
t =+ 1
print(700 + t*100)
| s122639953 | Accepted | 17 | 2,940 | 160 | S = input()
t = 0
for i in range(len(S)):
if S[i] == 'o':
t += 1
print(700 + t*100)
|
s250078492 | p03044 | u227082700 | 2,000 | 1,048,576 | Wrong Answer | 2,105 | 109,564 | 185 | We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied: * For any two vertices... | n=int(input())
a=[0]*n
b=[]
for i in range(n-1):b.append(list(map(int,input().split())))
b.sort()
for i,j,k in b:
if k%2==0:a[j-1]=a[i-1]
else:a[j-1]=-(a[i-1]-1)
for i in a:print(a) | s139357246 | Accepted | 693 | 61,716 | 509 | from sys import stdin
input = stdin.readline
n=int(input())
b=[]
for i in range(n-1):b.append(list(map(int,input().split())))
def BFS(K,edges,N):
roots=[ [] for i in range(N)]
for a,b,c in edges:
roots[a-1]+=[(b-1,c)]
roots[b-1]+=[(a-1,c)]
dist=[-1]*N
stack=[]
stack.append(K)
dist[K]=0
while stack... |
s077305925 | p02612 | u827627481 | 2,000 | 1,048,576 | Wrong Answer | 28 | 9,148 | 106 | 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())
for i in range(0,11):
if i*1000 <= N and N < (i+1)*1000:
break
print(N-1000*i)
| s640314608 | Accepted | 28 | 9,156 | 112 | N = int(input())
for i in range(0,11):
if i*1000 < N and N <= (i+1)*1000:
break
print(1000*(i+1) - N)
|
s351400302 | p03699 | u149249972 | 2,000 | 262,144 | Wrong Answer | 27 | 9,176 | 270 | You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When... | g = int(input())
grades = []
for i in range(g):
grade = int(input())
grades.append(grade)
total = sum(grades)
grades.sort()
grades = [0] + grades
for grade in grades:
if (total - grade) % 10 != 0:
print(total - grade)
break
print(0)
| s581332691 | Accepted | 25 | 9,096 | 333 | g = int(input())
grades = []
for i in range(g):
grade = int(input())
grades.append(grade)
total = sum(grades)
grades.sort()
grades = [0] + grades
count = 0
for grade in grades:
if (total - grade) % 10 != 0:
print(total - grade)
break
else:
count += 1
if count == len(grades):
... |
s360039838 | p02612 | u303039933 | 2,000 | 1,048,576 | Wrong Answer | 48 | 10,712 | 2,709 | 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. | # -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal
class Scanner()... | s597029114 | Accepted | 42 | 10,708 | 2,769 | # -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal
class Scanner()... |
s522004811 | p02602 | u501451051 | 2,000 | 1,048,576 | Wrong Answer | 2,206 | 31,632 | 315 | M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the m... | n ,k = map(int, input().split())
lis = list(map(int, input().split()))
t = 1
for i in range(k):
t *= lis[i]
print(t)
for i in range(k, n):
tmp = lis[i-(k-1):i+1]
a = 1
for j in tmp:
a *= j
if a > t:
print('Yes')
else:
print('No')
t = a
a = 1 | s133356482 | Accepted | 162 | 31,440 | 192 | n ,k = map(int, input().split())
lis = list(map(int, input().split()))
for i in range(k, n):
l = lis[i-k]
r = lis[i]
if r > l:
print('Yes')
else:
print('No') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.