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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s177767147
|
p03698
|
u379142263
| 2,000
| 262,144
|
Wrong Answer
| 153
| 12,484
| 259
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
s = input()
l = set(s)
if len(s) == l:
print("yes")
else:
print("no")
|
s811585859
|
Accepted
| 147
| 12,508
| 360
|
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
s = input()
li = []
for i in range(len(s)):
for j in range(len(li)):
if s[i] == li[j]:
print("no")
sys.exit()
li.append(s[i])
print("yes")
|
s888034350
|
p03713
|
u088552457
| 2,000
| 262,144
|
Wrong Answer
| 593
| 3,064
| 555
|
There is a bar of chocolate with a height of H blocks and a width of W blocks. Snuke is dividing this bar into exactly three pieces. He can only cut the bar along borders of blocks, and the shape of each piece must be a rectangle. Snuke is trying to divide the bar as evenly as possible. More specifically, he is trying to minimize S_{max} \- S_{min}, where S_{max} is the area (the number of blocks contained) of the largest piece, and S_{min} is the area of the smallest piece. Find the minimum possible value of S_{max} - S_{min}.
|
h, w = map(int, input().split())
s_org = h * w
answer = h * w
for i in range(2):
if i == 1:
h, w = w, h
for height in range(1, h+1):
s1 = height * w
remain_height = h - height
s2 = remain_height * int(w / 2)
s3 = s_org - (s1 + s2)
s_max = max([s1, s2, s3])
s_min = min([s1, s2, s3])
answer = min([answer, (s_max - s_min)])
s1 = height * w
s2 = (h - height) * w
s3 = s_org - (s1 + s2)
s_max = max([s1, s2, s3])
s_min = min([s1, s2, s3])
answer = min([answer, (s_max - s_min)])
print(answer)
|
s417642053
|
Accepted
| 626
| 3,064
| 564
|
h, w = map(int, input().split())
s_org = h * w
answer = h * w
for i in range(2):
if i == 1:
h, w = w, h
for height in range(1, h+1):
s1 = height * w
remain_height = h - height
s2 = remain_height * int(w / 2)
s3 = s_org - (s1 + s2)
s_max = max([s1, s2, s3])
s_min = min([s1, s2, s3])
answer = min([answer, (s_max - s_min)])
s1 = height * w
s2 = int((h - height) / 2) * w
s3 = s_org - (s1 + s2)
s_max = max([s1, s2, s3])
s_min = min([s1, s2, s3])
answer = min([answer, (s_max - s_min)])
print(answer)
|
s052124967
|
p03543
|
u126823513
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 101
|
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**?
|
int_n = int(input())
if str(int_n).count(str(int_n)[0]) == 4:
print("Yes")
else:
print("No")
|
s023042645
|
Accepted
| 17
| 2,940
| 224
|
n = input()
counter = 0
tmp = ""
for w in n:
if tmp != w:
counter = 1
tmp = w
else:
counter += 1
if counter >= 3:
print("Yes")
exit(0)
else:
print("No")
|
s197027483
|
p03129
|
u290187182
| 2,000
| 1,048,576
|
Wrong Answer
| 25
| 3,828
| 362
|
Determine if we can choose K different integers between 1 and N (inclusive) so that no two of them differ by 1.
|
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
def lcm(x, y):
return (x * y) // math.gcd(x, y)
if __name__ == '__main__':
a = [int(i) for i in input().split()]
if a[0]//2 >=a[1] :
print("YES")
else:
print("NO")
|
s857462282
|
Accepted
| 26
| 3,828
| 405
|
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque
def lcm(x, y):
return (x * y) // math.gcd(x, y)
if __name__ == '__main__':
a = [int(i) for i in input().split()]
if a[0] % 2 ==1:
a[0] +=1
if a[0]//2 >=a[1] :
print("YES")
else:
print("NO")
|
s611350283
|
p03473
|
u063346608
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 49
|
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
M = int(input())
answer = 24 - M
print(answer)
|
s959870597
|
Accepted
| 18
| 2,940
| 54
|
M = int(input())
answer = 24 - M + 24
print(answer)
|
s410913854
|
p03795
|
u798260206
| 2,000
| 262,144
|
Wrong Answer
| 24
| 9,172
| 38
|
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)
|
s395030116
|
Accepted
| 27
| 9,112
| 40
|
n= int(input())
print(n*800-n//15*200)
|
s038712217
|
p03543
|
u992910889
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 66
|
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**?
|
N=set(input())
if len(N)<1:
print('Yes')
else:
print('No')
|
s023418102
|
Accepted
| 17
| 2,940
| 60
|
a,b,c,d=input()
print('Yes' if a==b==c or b==c==d else 'No')
|
s848196784
|
p03814
|
u103902792
| 2,000
| 262,144
|
Wrong Answer
| 39
| 3,748
| 152
|
Snuke has decided to construct a string that starts with `A` and ends with `Z`, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with `A` and ends with `Z`.
|
s = input()
for a in range(len(s)):
if s[a]=='A':
break
s = s[::-1]
for z in range(len(s)):
if s[z] =='Z':
break
s= s[::-1]
print(s[a:-z+1])
|
s097331108
|
Accepted
| 36
| 3,516
| 142
|
s = input()
for a in range(len(s)):
if s[a]=='A':
break
s = s[::-1]
for z in range(len(s)):
if s[z] =='Z':
break
print(len(s)-z-a)
|
s114883831
|
p03606
|
u899421906
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 203
|
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
|
N = int(input())
l = []
r = []
for i in range(N):
temp_l, temp_r = input().split()
l.append(int(temp_l))
r.append(int(temp_r))
ans = 0
for i in range(N):
ans += l[i] - r[i] + 1
print(ans)
|
s382505726
|
Accepted
| 20
| 3,060
| 203
|
N = int(input())
l = []
r = []
for i in range(N):
temp_l, temp_r = input().split()
l.append(int(temp_l))
r.append(int(temp_r))
ans = 0
for i in range(N):
ans += r[i] - l[i] + 1
print(ans)
|
s981404725
|
p03674
|
u918935103
| 2,000
| 262,144
|
Wrong Answer
| 2,105
| 25,920
| 437
|
You are given an integer sequence of length n+1, a_1,a_2,...,a_{n+1}, which consists of the n integers 1,...,n. It is known that each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of the different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7.
|
n = int(input())
mod = 10**9 + 7
a = list(map(int,input().split()))
il = [[]for i in range(n)]
for i in range(n+1):
il[a[i]-1].append(i)
if len(il[a[i]-1]) > 1:
p,q = il[a[i]-1]
comb = 1
c = p + n - q
for i in range(n+1):
comb = comb*(n+1-i)//(i+1)
if c >= i:
comb2 = 1
for j in range(i):
comb2 = comb2*(c-j)//(j+1)
print((comb-comb2)%mod)
else:
print(comb%mod)
|
s022939633
|
Accepted
| 1,441
| 23,044
| 731
|
def extgcd(a,b):
r = [1,0,a]
w = [0,1,b]
while w[2] != 1:
q = r[2]//w[2]
r2 = w
w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
r = r2
w = w2
return [w[0],w[1]]
def mod_inv(a,mod):
x = extgcd(a,mod)[0]
return (mod + x % mod)% mod
n = int(input())
mod = 10**9 + 7
a = list(map(int,input().split()))
il = [[]for i in range(n)]
for i in range(n+1):
il[a[i]-1].append(i)
if len(il[a[i]-1]) > 1:
p,q = il[a[i]-1]
comb = 1
comb2 = 1
c = p + n - q
for i in range(n+1):
comb = (((comb*(n+1-i))%mod)*mod_inv(i+1,mod))%mod
if c >= i:
print((comb-comb2)%mod)
comb2 = (((comb2*(c-i))%mod)*mod_inv(i+1,mod))%mod
else:
print(comb%mod)
|
s628985710
|
p03110
|
u776311944
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 266
|
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
#coding:utf-8
def main():
N = int(input())
money = []
for i in range(N):
x, u = input().split()
if u == 'BTC':
x = float(x) * 380000
money.append(int(x))
print(sum(money))
if __name__ == "__main__":
main()
|
s360828690
|
Accepted
| 17
| 3,060
| 299
|
#coding:utf-8
def main():
N = int(input())
money = []
for i in range(N):
x, u = input().split()
if u == 'BTC':
x = float(x) * 380000
money.append(float(x))
moneysum = float(sum(money))
print(moneysum)
if __name__ == "__main__":
main()
|
s341412064
|
p02608
|
u642528832
| 2,000
| 1,048,576
|
Wrong Answer
| 460
| 9,388
| 209
|
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())
r = range(1,101)
l = [0]*n
for x in r:
for y in r:
for z in r:
t = x*x+y*y+z*z+y*z+z*x+x*y
if t == n:
l[t-1] +=1
for i in l:
print(i)
|
s626034085
|
Accepted
| 473
| 9,364
| 207
|
n = int(input())
r = range(1,101)
l = [0]*n
for x in r:
for y in r:
for z in r:
t = x*x+y*y+z*z+y*z+z*x+x*y
if t <= n:
l[t-1] +=1
for i in l:
print(i)
|
s125590640
|
p03739
|
u852690916
| 2,000
| 262,144
|
Wrong Answer
| 412
| 14,468
| 592
|
You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one. At least how many operations are necessary to satisfy the following conditions? * For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero. * For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.
|
n = int(input())
A = list(map(int, input().split()))
ans = 0
total = A[0]
if A[0] == 0:
ans += 1
total = -A[1] // A[1]
for i in range(1, len(A)):
print(total, ans, A[i], total + A[i])
if total > 0:
if total + A[i] >= 0:
ans += total + A[i] + 1
print("1 ans +=", total + A[i] + 1)
total = -1
else:
total += A[i]
else:
if total + A[i] <= 0:
ans += 1 - (total + A[i])
print("2 ans +=", 1 - (total + A[i]))
total = 1
else:
total += A[i]
print(ans)
|
s135473114
|
Accepted
| 173
| 14,332
| 388
|
n = int(input())
A = list(map(int, input().split()))
ans = {True:0, False:0}
for s in [True, False]:
sign = s
total = 0
for i in range(len(A)):
if total + A[i] == 0 or sign == (total + A[i] > 0):
ans[s] += abs(total + A[i]) + 1
total = -1 if sign else 1
else:
total += A[i]
sign = total > 0
print(min(ans.values()))
|
s342240101
|
p00007
|
u500396695
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,648
| 125
|
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week. Write a program which computes the amount of the debt in n weeks.
|
import math
n = int(input())
debt = 100000
for i in range(n):
debt = int(math.ceil((debt * 1.05 / 1000) * 1000))
print(debt)
|
s998588105
|
Accepted
| 30
| 7,632
| 123
|
import math
n = int(input())
debt = 100000
for i in range(n):
debt = int(math.ceil(debt * 1.05 / 1000)) * 1000
print(debt)
|
s279123070
|
p03854
|
u154297942
| 2,000
| 262,144
|
Wrong Answer
| 72
| 3,316
| 385
|
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times: * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.
|
s = input()
s_rev = s[::-1]
while s_rev[0:1]:
if s_rev.startswith("maerd"):
s_rev = s_rev[5::1]
elif s_rev.startswith("remaerd"):
s_rev = s_rev[7::1]
elif s_rev.startswith("esare"):
s_rev = s_rev[5::1]
elif s_rev.startswith("resare"):
s_rev = s_rev[6::1]
else:
print("NO")
break
if s_rev[0:1]==False:
print("YES")
|
s823932259
|
Accepted
| 74
| 3,316
| 394
|
s = input()
s_rev = s[::-1]
while s_rev[0:1]:
if s_rev.startswith("maerd"):
s_rev = s_rev[5::1]
elif s_rev.startswith("remaerd"):
s_rev = s_rev[7::1]
elif s_rev.startswith("esare"):
s_rev = s_rev[5::1]
elif s_rev.startswith("resare"):
s_rev = s_rev[6::1]
else:
print("NO")
break
if bool(s_rev[0:1]) == False:
print("YES")
|
s628066121
|
p03769
|
u340781749
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,104
| 215
|
We will call a string x _good_ if it satisfies the following condition: * Condition: x can be represented as a concatenation of two copies of another string y of length at least 1. For example, `aa` and `bubobubo` are good; an empty string, `a`, `abcabcabc` and `abba` are not good. Eagle and Owl created a puzzle on good strings. Find one string s that satisfies the following conditions. It can be proved that such a string always exists under the constraints in this problem. * 1 ≤ |s| ≤ 200 * Each character of s is one of the 100 characters represented by the integers 1 through 100. * Among the 2^{|s|} subsequences of s, exactly N are good strings.
|
n = int(input())
ans = []
c = 1
can = (1 << 40) - 1
needs = 41
while n:
if n >= can:
n -= can
ans.extend([c] * needs)
c += 1
else:
can >>= 1
needs -= 1
print(*ans)
|
s479825891
|
Accepted
| 33
| 9,372
| 3,288
|
def test():
from itertools import combinations
s = '111223111223'
result = 0
for k in range(1, len(s) // 2 + 1):
for idx in combinations(range(len(s)), 2 * k):
success = True
for ii in range(k):
if s[idx[ii]] != s[idx[ii + k]]:
success = False
break
if success:
result += 1
print(result)
n = int(input())
factorials = [1, 1]
for i in range(2, 40):
factorials.append(factorials[-1] * i)
patterns = {}
for i in range(2, 40):
base = (1 << (i - 1)) - 1
gain = base
chars = i
if gain > n:
break
if gain not in patterns or chars < patterns[gain][0]:
patterns[gain] = (chars, (i,))
if i % 2 == 1:
continue
a = i // 2
ncr1 = factorials[i] // factorials[a] // factorials[a] - 1
for b in range(1, a + 1):
base2 = (1 << (2 * b - 1)) - 1
ncr2 = factorials[2 * b] // factorials[b] // factorials[b] - 1
gain = base + base2 + ncr1 * ncr2
chars = i + 2 * b
if gain > n:
break
if gain not in patterns or chars < patterns[gain][0]:
patterns[gain] = (chars, (a, b))
for c in range(1, b + 1):
base3 = (1 << (2 * c - 1)) - 1
ncr3 = factorials[2 * c] // factorials[c] // factorials[c] - 1
gain = base + base2 + base3 + ncr1 * ncr2 * ncr3 + ncr1 * ncr2 + ncr2 * ncr3 + ncr3 * ncr1
chars = i + 2 * b + 2 * c
if gain > n:
break
if gain not in patterns or chars < patterns[gain][0]:
patterns[gain] = (chars, (a, b, c))
for d in range(1, c + 1):
base4 = (1 << (2 * d - 1)) - 1
ncr4 = factorials[2 * d] // factorials[d] // factorials[d] - 1
gain = base + base2 + base3 + base4 + ncr1 * ncr2 * ncr3 * ncr4
gain += ncr1 * ncr2 * ncr3 + ncr1 * ncr2 * ncr4 + ncr1 * ncr3 * ncr4 + ncr2 * ncr3 * ncr4
gain += ncr1 * ncr2 + ncr1 * ncr3 + ncr1 * ncr4 + ncr2 * ncr3 + ncr2 * ncr4 + ncr3 * ncr4
chars = i + 2 * b + 2 * c + 2 * d
if gain > n:
break
if gain not in patterns or chars < patterns[gain][0]:
patterns[gain] = (chars, (a, b, c, d))
def dfs(use, i, remaining, total_char):
if remaining == 0:
return total_char <= 200
for j in range(i, len(patterns)):
gain, (chars, lengths) = patterns[j]
if total_char + remaining * chars / gain > 200:
break
if gain > remaining:
continue
use.append(lengths)
result = dfs(use, j, remaining - gain, total_char + chars)
if result:
return True
use.pop()
return False
patterns = sorted(patterns.items(), key=lambda item: item[0] / item[1][0], reverse=True)
use = []
result = dfs(use, 0, n, 0)
assert result
ans = []
c = 1
for lengths in use:
if len(lengths) == 1:
ans.extend([c] * lengths[0])
c += 1
else:
for _ in range(2):
for i, l in enumerate(lengths):
ans.extend([c + i] * l)
c += len(lengths)
print(len(ans))
print(*ans)
|
s129659482
|
p03623
|
u824237520
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 67
|
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
|
x, a, b = map(int, input().split())
print(min(abs(x-a), abs(x-b)))
|
s785713238
|
Accepted
| 17
| 2,940
| 96
|
x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
print('B')
else:
print('A')
|
s025492571
|
p03001
|
u094932051
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 298
|
There is a rectangle in a coordinate plane. The coordinates of the four vertices are (0,0), (W,0), (W,H), and (0,H). You are given a point (x,y) which is within the rectangle or on its border. We will draw a straight line passing through (x,y) to cut the rectangle into two parts. Find the maximum possible area of the part whose area is not larger than that of the other. Additionally, determine if there are multiple ways to cut the rectangle and achieve that maximum.
|
while True:
try:
W, H, x, y = map(int, input().split())
cut = (x == W // 2) + (y == H // 2)
if cut > 0:
area = (W * H) / 2
else:
area = min(x*H, y*W)
print(area, 1 if cut > 1 else 0)
except:
break
|
s381333070
|
Accepted
| 17
| 3,060
| 247
|
while True:
try:
W, H, x, y = map(int, input().split())
if (x*2 == W) and (y*2 == H):
res = 1
else:
res = 0
print("%.6f %d" % (W*H/2, res))
except:
break
|
s134564919
|
p03556
|
u882370611
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 35
|
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
|
n=int(input())
print(int(n**(1/2)))
|
s439802247
|
Accepted
| 18
| 2,940
| 38
|
n=int(input())
print(int(n**(1/2))**2)
|
s694954965
|
p03957
|
u426964396
| 1,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 223
|
This contest is `CODEFESTIVAL`, which can be shortened to the string `CF` by deleting some characters. Mr. Takahashi, full of curiosity, wondered if he could obtain `CF` from other strings in the same way. You are given a string s consisting of uppercase English letters. Determine whether the string `CF` can be obtained from the string s by deleting some characters.
|
s = input()
m = 0
n = 0
a = 0
b = 0
for i in range(len(s)):
if i == 'C':
m += 1
a = i
elif i == 'F':
n += 1
b = i
if a < b and m > 1 and n > 1:
print('Yes')
else:
print('No')
|
s719685691
|
Accepted
| 17
| 3,060
| 268
|
string=str(input())
swich1=0
swich2=0
final_swich=0
for i in range(len(string)):
if string[i]=='C':
swich1=1
elif swich1==1 and string[i]=='F':
swich2=1
print("Yes")
final_swich=1
break
if final_swich==0:
print("No")
|
s394365498
|
p00003
|
u123596571
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,548
| 129
|
Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.
|
while True:
try:
a,b,c = map(int, input().split())
except:
exit()
if c**2 == a**2 + b**2:
print(YES)
else:
print(NO)
|
s363626914
|
Accepted
| 40
| 7,528
| 138
|
n = int(input())
for _ in range(n):
num = sorted(map(int, input().split()))
print("YES" if num[2]**2 == num[1]**2 + num[0]**2 else "NO")
|
s840515287
|
p02694
|
u195177386
| 2,000
| 1,048,576
|
Wrong Answer
| 22
| 9,168
| 91
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
b = 100
ans = 0
while b <= X:
b += int(b*0.01)
ans += 1
print(ans)
|
s564495327
|
Accepted
| 22
| 9,168
| 90
|
X = int(input())
b = 100
ans = 0
while b < X:
b += int(b*0.01)
ans += 1
print(ans)
|
s513013386
|
p03447
|
u366886346
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 58
|
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
|
x=int(input())
a=int(input())
b=int(input())
print(x-a-b)
|
s194862347
|
Accepted
| 17
| 2,940
| 73
|
x=int(input())
a=int(input())
b=int(input())
c=(x-a)//b
print(x-a-(b*c))
|
s376191957
|
p02983
|
u094932051
| 2,000
| 1,048,576
|
Wrong Answer
| 19
| 3,060
| 376
|
You are given two non-negative integers L and R. We will choose two integers i and j such that L \leq i < j \leq R. Find the minimum possible value of (i \times j) \mbox{ mod } 2019.
|
while True:
try:
L, R = map(int, input().split())
if L%2019==0 or R%2019==0 or L<=2019<=R or R-L+1>=2019:
print(0)
continue
mod = []
for i in range(L, R+1):
mod.append(i%2019)
if len(mod) >= 2019:
break
mod.sort()
print(mod[0]*mod[1])
except:
break
|
s506183833
|
Accepted
| 799
| 3,060
| 327
|
MOD = 2019
while True:
try:
L, R = map(int, input().split())
ans = 2019*2019
if R-L <= MOD-1:
for i in range(L, R+1):
for j in range(i+1, R+1):
ans = min(ans, i*j%MOD)
print(ans)
else:
print(0)
except:
break
|
s550316707
|
p02393
|
u461552210
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,572
| 72
|
Write a program which reads three integers, and prints them in ascending order.
|
# coding: utf-8
n = list(map(int, input().split()))
n.sort()
print(n)
|
s760725373
|
Accepted
| 20
| 5,584
| 98
|
# coding: utf-8
n = list(map(int, input().split()))
n.sort()
n = map(str, n)
print(' '.join(n))
|
s093138536
|
p03044
|
u619819312
| 2,000
| 1,048,576
|
Wrong Answer
| 908
| 92,120
| 431
|
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 painted in the same color, the distance between them is an even number. Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.
|
import sys
sys.setrecursionlimit(10000000)
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
a,b,c=map(int,input().split())
s[a].append([b,c])
s[b].append([a,c])
def dfs(x):
h[x]=False
for i in s[x]:
if h[i[0]]:
g[i[0]]=g[x]+i[1]
dfs(i[0])
dfs(1)
print(g)
for i in range(1,n+1):
if g[i]%2==0:
print(0)
else:
print(1)
|
s231775341
|
Accepted
| 916
| 88,792
| 422
|
import sys
sys.setrecursionlimit(10000000)
n=int(input())
s=[[]for i in range(n+1)]
g=[0]*(n+1)
h=[True]*(n+1)
for i in range(n-1):
a,b,c=map(int,input().split())
s[a].append([b,c])
s[b].append([a,c])
def dfs(x):
h[x]=False
for i in s[x]:
if h[i[0]]:
g[i[0]]=g[x]+i[1]
dfs(i[0])
dfs(1)
for i in range(1,n+1):
if g[i]%2==0:
print(0)
else:
print(1)
|
s710536649
|
p03657
|
u808593466
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 125
|
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
|
A, B = map(int, input().split())
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
print("possible")
else:
print("impossible")
|
s735822499
|
Accepted
| 17
| 2,940
| 125
|
A, B = map(int, input().split())
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
print("Possible")
else:
print("Impossible")
|
s461694285
|
p03493
|
u627283301
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 172
|
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.
|
sample=input()
one_count=0
s=0
for i in sample:
if sample[s] == "1":
one_count+=1
s+=1
else:
s+=1
print("1が",one_count,"個含まれています")
|
s386772829
|
Accepted
| 17
| 2,940
| 138
|
sample=input()
one_count=0
s=0
for i in sample:
if sample[s] == "1":
one_count+=1
s+=1
else:
s+=1
print(one_count)
|
s415813277
|
p03730
|
u413165887
| 2,000
| 262,144
|
Wrong Answer
| 20
| 3,060
| 85
|
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a, b, c = map(int, input().split())
if c%a==0:
print("YES")
else:
print("NO")
|
s647520654
|
Accepted
| 17
| 2,940
| 136
|
import sys
a, b, c = map(int, input().split())
for i in range(b):
if (i*a)%b==c:
print("YES")
sys.exit()
print("NO")
|
s691587944
|
p03544
|
u060464363
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 138
|
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)
|
num = list(map(int, input().split()))
a = [1,2]
for i in range(86):
temp = a[i] + a[i+1]
a.append(temp)
ans = int(num[0])
print(a[ans])
|
s861960715
|
Accepted
| 20
| 2,940
| 138
|
num = list(map(int, input().split()))
a = [2,1]
for i in range(86):
temp = a[i] + a[i+1]
a.append(temp)
ans = int(num[0])
print(a[ans])
|
s846042668
|
p02613
|
u052833850
| 2,000
| 1,048,576
|
Wrong Answer
| 152
| 9,216
| 264
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
S=input()
if S=='AC':
ac+=1
if S=='WA':
wa+=1
if S=='TLE':
tle+=1
if S=='RE':
re+=1
#print(ac,wa,tle,re)
print('AC ×',ac)
print('WA ×',wa)
print('TLE ×',tle)
print('RE ×',re)
|
s252464646
|
Accepted
| 154
| 9,056
| 232
|
N=int(input())
ac=0
wa=0
tle=0
re=0
for i in range(N):
S=input()
if S=='AC':
ac+=1
if S=='WA':
wa+=1
if S=='TLE':
tle+=1
if S=='RE':
re+=1
print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(ac,wa,tle,re))
|
s625517154
|
p02422
|
u650790815
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,608
| 275
|
Write a program which performs a sequence of commands to a given string $str$. The command is one of: * print a b: print from the a-th character to the b-th character of $str$ * reverse a b: reverse from the a-th character to the b-th character of $str$ * replace a b p: replace from the a-th character to the b-th character of $str$ with p Note that the indices of $str$ start with 0.
|
s = input()
for i in range(int(input())):
cmd = input().split()
a,b = map(int,[cmd[1],cmd[2]])
if cmd[0] == 'reverse':
s = s[:b] + s[a:b+1][::-1]+ s[b+1:]
elif cmd[0] == 'replace':
s = s[:b] + cmd[3] + s[b+1:]
else:
print(s[a:b+1])
|
s084784114
|
Accepted
| 20
| 7,600
| 273
|
s = input()
n = int(input())
for i in range(n):
cmd = input().split()
a,b = map(int,[cmd[1],cmd[2]])
if cmd[0] == 'print':print(s[a:b+1])
elif cmd[0] == 'reverse':s = s[:a] + s[a:b+1][::-1] + s[b+1:]
elif cmd[0] == 'replace':s = s[:a] + cmd[3] + s[b+1:]
|
s277972291
|
p03228
|
u435986930
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 242
|
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 person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
|
a,b,k = (int(x) for x in input().split())
cnt = 0
while cnt < k:
if a % 2 !=0:
a -= 1
a = a/2
b += a
cnt += 1
if b % 2 !=0:
b -= 1
b = b/2
a += b
cnt += 1
a = int(a)
b = int(b)
print(a,b,k)
|
s327834174
|
Accepted
| 18
| 3,064
| 253
|
A,B,K = (int(x) for x in input().split())
while K != 0:
if A % 2 !=0:
A -= 1
A = A/2
B += A
K -= 1
if K ==0:
break
if B % 2 !=0:
B -= 1
B = B/2
A += B
K -= 1
A = int(A)
B = int(B)
print(A,B)
|
s745617831
|
p03477
|
u608088992
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 105
|
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())
print("Left" if A+B==C+D else "Balanced" if A+B==C+D else "Right")
|
s965722965
|
Accepted
| 18
| 2,940
| 105
|
A, B, C, D = map(int, input().split())
print("Left" if A+B>C+D else "Balanced" if A+B==C+D else "Right")
|
s941868080
|
p03386
|
u663014688
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 280
|
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())
arr = []
arr.append(a)
arr.append(b)
for i in range(1,k):
arr.append(a+i)
arr.append(b-1)
arr = sorted(arr)
print(arr)
|
s909935695
|
Accepted
| 17
| 3,060
| 247
|
a,b,k = map(int, input().split())
for i in range(a, min(a+k,b+1)):
print(i)
for i in range(max(a+k,b-k+1), b+1):
print(i)
|
s494598573
|
p02694
|
u656801456
| 2,000
| 1,048,576
|
Wrong Answer
| 2,294
| 48,960
| 295
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
import sys
def main():
x = int(input())
i = 100
n = 1
cnt = 0
while True:
n += 0.01
cnt += 1
print(i*n)
if(i*n>x-1):
print(cnt)
break
sys.exit()
if __name__ == "__main__":
main()
|
s541782056
|
Accepted
| 28
| 9,008
| 301
|
import math
import sys
def main():
x = int(input())
ai = 100
y=1
n = 0
for i in range(x):
ai = math.floor(ai*1.01)
n += 1
if(ai>x-1):
print(n)
break
sys.exit()
if __name__ == "__main__":
main()
|
s010892245
|
p03197
|
u242031676
| 2,000
| 1,048,576
|
Wrong Answer
| 180
| 7,072
| 79
|
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 at the same time must all have different colors. The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
|
print("fsiercsotn d"[(sum([int(input())for i in range(int(input()))])-1)%2::2])
|
s550286437
|
Accepted
| 181
| 3,880
| 77
|
print("sfeicrosntd"[sum([int(input())%2 for i in range(int(input()))])>0::2])
|
s557547821
|
p04035
|
u396391104
| 2,000
| 262,144
|
Wrong Answer
| 128
| 14,060
| 281
|
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
n,l = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
if a[i]+a[i+1] >= l:
print("Possible")
for j in range(1,i+1):
print(j)
for k in range(i,n-1):
print(k+1)
exit()
print("Impossible")
|
s934419301
|
Accepted
| 123
| 14,060
| 282
|
n,l = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
if a[i]+a[i+1] >= l:
print("Possible")
for j in range(1,i+1):
print(j)
for k in range(n-1,i,-1):
print(k)
exit()
print("Impossible")
|
s737435147
|
p02578
|
u093010575
| 2,000
| 1,048,576
|
Wrong Answer
| 353
| 32,268
| 200
|
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
|
n=int(input())
l=list(map(int,input().split()))
x = 0
for a in range(n-1):
if l[a]>l[a+1] :
x=l[a] - l[a+1] + x
l[a+1]=l[a]
print("l[a],x,l[a+1]=", l[a], x, l[a+1])
print(x)
|
s679677852
|
Accepted
| 147
| 32,164
| 201
|
n=int(input())
l=list(map(int,input().split()))
x = 0
for a in range(n-1):
if l[a]>l[a+1] :
x=l[a] - l[a+1] + x
l[a+1]=l[a]
#print("l[a],x,l[a+1]=", l[a], x, l[a+1])
print(x)
|
s135108070
|
p03545
|
u225528554
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 776
|
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
|
if __name__=="__main__":
n = input()
s = list(n)
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a-b-c>=7:
print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
elif a-b+c>=7:
print(s[0] + "-" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif a-b+c<7:
print(s[0] + "-" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif a-b-c<7:
print(s[0] + "-" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif a+b-c>=7:
print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
elif a+b+c>=7:
print(s[0] + "+" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif a+b+c<7:
print(s[0] + "+" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif a+b-c<7:
print(s[0] + "+" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
|
s919048150
|
Accepted
| 17
| 3,064
| 797
|
if __name__=="__main__":
n = input()
s = list(n)
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
if a+b+c+d==7:
print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7")
elif a-b-c-d==7:
print(s[0] + "-" + s[1] + "-" + s[2] + "-" + s[3] + "=7")
elif a-b+c+d==7:
print(s[0] + "-" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
elif a-b-c+d==7:
print(s[0] + "-" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif a+b-c-d==7:
print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
elif a+b+c-d==7:
print(s[0] + "+" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
elif a+b-c+d==7:
print(s[0] + "+" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
elif a-b+c-d==7:
print(s[0] + "-" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
|
s418044803
|
p02927
|
u006251926
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 214
|
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
|
M, D = map(int, input().split())
count = 0
for d in range(D - 1):
d += 2
d1 = int(d/10)
d2 = d - d1 * 10
if d1 * d2 <= M and d1 > 1 and d2 > 1:
print(d1, d2)
count += 1
print(count)
|
s101935633
|
Accepted
| 17
| 2,940
| 192
|
M, D = map(int, input().split())
count = 0
for d in range(D - 1):
d += 2
d1 = int(d/10)
d2 = d - d1 * 10
if d1 * d2 <= M and d1 > 1 and d2 > 1:
count += 1
print(count)
|
s612574791
|
p03543
|
u027675217
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 267
|
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**?
|
n = input()
n_list = []
for i in n:
n_list.append(i)
print(n_list)
if n_list[1]==n_list[2]==n_list[0]:
print("Yes")
elif n_list[2]==n_list[3]==n_list[1]:
print("Yes")
elif n_list[0]==n_list[1]==n_list[2]==n_list[3]:
print("Yes")
else:
print("No")
|
s892679517
|
Accepted
| 17
| 3,060
| 253
|
n = input()
n_list = []
for i in n:
n_list.append(i)
if n_list[1]==n_list[2]==n_list[0]:
print("Yes")
elif n_list[2]==n_list[3]==n_list[1]:
print("Yes")
elif n_list[0]==n_list[1]==n_list[2]==n_list[3]:
print("Yes")
else:
print("No")
|
s813897655
|
p02612
|
u785573018
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,140
| 30
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
n = int(input())
print(n%1000)
|
s727343105
|
Accepted
| 31
| 9,088
| 79
|
n = int(input())
if n%1000 == 0:
print(n%1000)
else:
print(1000-n%1000)
|
s159743145
|
p03605
|
u904995051
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,012
| 59
|
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?
|
c = input()
if c in "9":
print("Yes")
else:
print("No")
|
s989640836
|
Accepted
| 24
| 8,964
| 59
|
c = input()
if "9" in c:
print("Yes")
else:
print("No")
|
s409250177
|
p03470
|
u125097160
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 109
|
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 have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
allrunrun = int(input())
moti = [int(i) for i in input().split()]
tyouhuku = set(moti)
print(len(tyouhuku))
|
s046203838
|
Accepted
| 17
| 2,940
| 114
|
allrunrun = int(input())
moti = [int(input()) for i in range(allrunrun)]
tyouhuku = set(moti)
print(len(tyouhuku))
|
s875164961
|
p04035
|
u796424048
| 2,000
| 262,144
|
Wrong Answer
| 147
| 14,060
| 434
|
We have N pieces of ropes, numbered 1 through N. The length of piece i is a_i. At first, for each i (1≤i≤N-1), piece i and piece i+1 are tied at the ends, forming one long rope with N-1 knots. Snuke will try to untie all of the knots by performing the following operation repeatedly: * Choose a (connected) rope with a total length of at least L, then untie one of its knots. Is it possible to untie all of the N-1 knots by properly applying this operation? If the answer is positive, find one possible order to untie the knots.
|
N,L = list(map(int,input().split()))
a = list(map(int,input().split()))
a.append(0)
b = []
res = "Impossible"
for i in range(N):
if L <= (a[i]+a[i+1]):
count = i
res = "Possible"
break
if res =="Possible":
for j in range(count):
b.append(a[j])
for k in range(count,N)[::-1]:
b.append(a[k])
print(res)
for l in range(len(b)):
print(b[l])
else:
print(res)
|
s077237733
|
Accepted
| 147
| 14,060
| 432
|
N,L = list(map(int,input().split()))
a = list(map(int,input().split()))
a.append(0)
b = []
res = "Impossible"
for i in range(N):
if L <= (a[i]+a[i+1]):
count = i
res = "Possible"
break
if res =="Possible":
for j in range(count):
b.append(j+1)
for k in range(count+1,N)[::-1]:
b.append(k)
print(res)
for l in range(len(b)):
print(b[l])
else:
print(res)
|
s700664949
|
p03409
|
u575653048
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,064
| 289
|
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())
red = [list(map(int, input().split())) for i in range(n)]
blue = [list(map(int, input().split())) for i in range(n)]
red.sort()
blue.sort()
ans = 0
for i in range(n):
if red[i][0] > blue[0][0] and red[i][1] > blue[0][1]:
ans += 1
del blue[0]
print(ans)
|
s065282033
|
Accepted
| 19
| 3,064
| 437
|
n = int(input())
red = [list(map(int, input().split())) for i in range(n)]
blue = [list(map(int, input().split())) for i in range(n)]
red = sorted(red, key = lambda x: x[1])
blue.sort()
ans = 0
for i in range(n):
a = 0
for j in range(len(red)):
if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
a = j
if blue[i][0] > red[a][0] and blue[i][1] > red[a][1]:
ans += 1
del red[a]
print(ans)
|
s784992273
|
p03457
|
u045176840
| 2,000
| 262,144
|
Wrong Answer
| 291
| 25,532
| 406
|
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
|
n = int(input())
points = []
for i in range(n):
points.append([i for i in map(int, input().split())])
can = True
for i in range(len(points)-1):
move_n = points[i+1][0] - points[i][0]
dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
if move_n < dist or dist % 2 != move_n % 2:
can = False
break
if can:
print('YES')
else:
print('NO')
|
s239750676
|
Accepted
| 298
| 25,456
| 679
|
n = int(input())
points = []
points.append([0, 0, 0])
can = True
for i in range(n):
points.append([i for i in map(int, input().split())])
move_n = points[i+1][0] - points[i][0]
dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
if move_n < dist or dist % 2 != move_n % 2:
can = False
break
# print(points)
# can = True
# move_n = points[i+1][0] - points[i][0]
# dist = abs(points[i+1][1] - points[i][1]) + abs(points[i+1][2] - points[i][2])
# if move_n < dist or dist % 2 != move_n % 2:
# can = False
# break
if can:
print('Yes')
else:
print('No')
|
s880134565
|
p03377
|
u108617242
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 128
|
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 a > x:
print('NO')
elif a + b >= x:
print('Yes')
elif a + b < x:
print('No')
|
s233351902
|
Accepted
| 19
| 2,940
| 128
|
a, b, x = map(int, input().split())
if a > x:
print('NO')
elif a + b >= x:
print('YES')
elif a + b < x:
print('NO')
|
s710120995
|
p03673
|
u933341648
| 2,000
| 262,144
|
Wrong Answer
| 49
| 25,540
| 128
|
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
|
n = int(input())
a = input().split()
if n % 2 == 0:
b = a[::-2] + a[::2]
else:
b = a[::-2] + a[1::2]
print(''.join(b))
|
s440708324
|
Accepted
| 52
| 26,180
| 129
|
n = int(input())
a = input().split()
if n % 2 == 0:
b = a[::-2] + a[::2]
else:
b = a[::-2] + a[1::2]
print(' '.join(b))
|
s236235042
|
p03943
|
u685244071
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 108
|
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.
|
a, b, c = map(int, input().split())
if a+b-c==0 or b+c-a==0 or c+a-c==0:
print('Yes')
else:
print('No')
|
s237162498
|
Accepted
| 18
| 2,940
| 109
|
a, b, c = map(int, input().split())
if a+b-c==0 or b+c-a==0 or c+a-b==0:
print('Yes')
else:
print('No')
|
s242620663
|
p02406
|
u074747865
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,588
| 95
|
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 is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
|
n=int(input())
c=1
while c <=n:
if c%3==0:
print(c)
elif c%10==3:
print(c)
c +=1
|
s055549933
|
Accepted
| 20
| 6,124
| 123
|
n=int(input())
d=[]
for i in range(1,n+1):
if i%3==0 or "3" in str(i):
d.append(i)
print(" ",end="")
print(*d)
|
s175425723
|
p02694
|
u279735925
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,172
| 139
|
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
|
X = int(input())
start = 100
i = 0
while True:
i += 1
start += start * 0.01
start = int(start)
if start > X:
print(i)
break
|
s853107727
|
Accepted
| 22
| 9,016
| 140
|
X = int(input())
start = 100
i = 0
while True:
i += 1
start += start * 0.01
start = int(start)
if start >= X:
print(i)
break
|
s676933431
|
p03861
|
u445624660
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 82
|
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
|
a, b, x = map(int, input().split())
print((b//x) - (a//x) + 1 if a//x == 0 else 0)
|
s719139159
|
Accepted
| 31
| 9,000
| 104
|
a, b, x = map(int, input().split())
if a == 1:
print(b // x)
else:
print(b // x - (a - 1) // x)
|
s951999263
|
p03079
|
u912862653
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 94
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
S = sorted(list(input()))
T = sorted(list('yahoo'))
if S==T:
print('YES')
else:
print('NO')
|
s447126659
|
Accepted
| 17
| 2,940
| 86
|
A, B, C = map(int, input().split())
if A==B and B==C:
print('Yes')
else:
print('No')
|
s011420808
|
p02402
|
u474232743
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,568
| 110
|
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
a = list(map(int, input().split()))
a.sort()
mi = a[0]
mx = a[-1]
sm = sum(a)
print('%d %d %d' % (mi, mx, sm))
|
s297382185
|
Accepted
| 40
| 8,708
| 88
|
input()
a = list(map(int, input().split()))
print('%d %d %d' % (min(a), max(a), sum(a)))
|
s484118223
|
p03730
|
u672475305
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 129
|
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c = map(int,input().split())
for i in range(1,b):
n = a*i
if n%b==c:
print('Yes')
exit()
print('No')
|
s756158922
|
Accepted
| 17
| 2,940
| 129
|
a,b,c = map(int,input().split())
for i in range(1,b):
n = a*i
if n%b==c:
print('YES')
exit()
print('NO')
|
s664669092
|
p02277
|
u949338836
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,660
| 1,118
|
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Quicksort(A, p, r) 1 if p < r 2 then q = Partition(A, p, r) 3 run Quicksort(A, p, q-1) 4 run Quicksort(A, q+1, r) Here, A is an array which represents a deck of cards and comparison operations are performed based on the numbers. Your program should also 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).
|
#coding:utf-8
#1_6_C
def partition(A, p, r):
x = int(A[r][1])
i = p - 1
for j in range(p, r):
if int(A[j][1]) <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quick_sort(A, p, r):
if p < r:
q = partition(A, p, r)
quick_sort(A, p, q - 1)
quick_sort(A, q + 1, r)
return A
class CheckStable:
def __init__(self):
self.d = dict() # Key is number. Value is array of suit.
def store_cards(self, cards):
for i in range(n):
if cards[i][1] in self.d:
self.d[cards[i][1]].append(cards[i][0])
else:
self.d[cards[i][1]] = [cards[i][0]]
def is_stable(self, cards):
for item in reversed(cards):
if self.d[item[1]].pop() != item[0]:
return "Not Stable"
return "Stable"
n = int(input())
cards = [tuple(input().split()) for i in range(n)]
d = CheckStable()
d.store_cards(cards)
quick_sort(cards, 0, n - 1)
print(d.is_stable(cards))
for i in range(n):
print(' '.join(cards[i]))
|
s562858624
|
Accepted
| 1,450
| 24,912
| 1,118
|
#coding:utf-8
#1_6_C
def partition(A, p, r):
x = int(A[r][1])
i = p - 1
for j in range(p, r):
if int(A[j][1]) <= x:
i += 1
A[i], A[j] = A[j], A[i]
A[i + 1], A[r] = A[r], A[i + 1]
return i + 1
def quick_sort(A, p, r):
if p < r:
q = partition(A, p, r)
quick_sort(A, p, q - 1)
quick_sort(A, q + 1, r)
return A
class CheckStable:
def __init__(self):
self.d = dict() # Key is number. Value is array of suit.
def store_cards(self, cards):
for i in range(n):
if cards[i][1] in self.d:
self.d[cards[i][1]].append(cards[i][0])
else:
self.d[cards[i][1]] = [cards[i][0]]
def is_stable(self, cards):
for item in reversed(cards):
if self.d[item[1]].pop() != item[0]:
return "Not stable"
return "Stable"
n = int(input())
cards = [tuple(input().split()) for i in range(n)]
d = CheckStable()
d.store_cards(cards)
quick_sort(cards, 0, n - 1)
print(d.is_stable(cards))
for i in range(n):
print(' '.join(cards[i]))
|
s283878153
|
p03737
|
u244836567
| 2,000
| 262,144
|
Wrong Answer
| 30
| 9,092
| 116
|
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.
|
a,b,c=input().split()
d=a[0]+b[0]+c[0]
d.replace("abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
print(d)
|
s731759528
|
Accepted
| 29
| 9,040
| 55
|
a,b,c=input().split()
d=a[0]+b[0]+c[0]
print(d.upper())
|
s731966570
|
p03377
|
u336624604
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 75
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a,b,x = map(int, input().split())
print('Yes' if a+b>=x and a<=x else 'No')
|
s006649698
|
Accepted
| 17
| 2,940
| 75
|
a,b,x = map(int, input().split())
print('YES' if a+b>=x and a<=x else 'NO')
|
s913379715
|
p03698
|
u590647174
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 217
|
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
|
def judge(S):
a = list(S)
for i in range(len(a)):
for j in range(len(a)):
if a[i]==a[j]:
print("no")
return
print("yes")
return
S = input()
judge(S)
|
s466661934
|
Accepted
| 17
| 2,940
| 228
|
def judge(S):
a = list(S)
for i in range(len(a)):
for j in range(len(a)):
if a[i]==a[j] and i != j:
print("no")
return
print("yes")
return
S = input()
judge(S)
|
s621152939
|
p02408
|
u661284763
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,668
| 199
|
Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers). The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.
|
data = [
"{0} {1}".format(s, r)
for s in ('S', 'H', 'C', 'D')
for r in range(1, 13 + 1)
]
count = int(input())
for c in range(count):
card = input()
data.remove(card)
print(data)
|
s029006410
|
Accepted
| 30
| 7,712
| 215
|
data = [
"{0} {1}".format(s, r)
for s in ('S', 'H', 'C', 'D')
for r in range(1, 13 + 1)
]
count = int(input())
for c in range(count):
card = input()
data.remove(card)
for c in data:
print(c)
|
s578302089
|
p03476
|
u183840468
| 2,000
| 262,144
|
Wrong Answer
| 2,105
| 23,244
| 483
|
We say that a odd number N is _similar to 2017_ when both N and (N+1)/2 are prime. You are given Q queries. In the i-th query, given two odd numbers l_i and r_i, find the number of odd numbers x similar to 2017 such that l_i ≤ x ≤ r_i.
|
import math
def like_2017(n):
if n == 1: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
for l in range(2,int(math.sqrt((n+1)/2)) + 1):
if ((n+1)/2)%l ==0:
return False
return True
q = int(input())
L = [[int(i) for i in input().split()] for _ in range(q)]
for l,r in L:
length = [i for i in range(l,r+1) if i % 2 == 1 and like_2017(i)]
print(length,len(length))
|
s992256141
|
Accepted
| 741
| 24,644
| 555
|
import math
def like_2017(n):
if n == 1: return False
if n == 2: return False
for k in range(2, int(math.sqrt(n)) + 1):
if n % k == 0:
return False
for l in range(2,int(math.sqrt((n+1)/2)) + 1):
if ((n+1)/2)%l ==0:
return False
return True
q = int(input())
L = [[int(i) for i in input().split()] for _ in range(q)]
ans = [0 for _ in range(10**5+1)]
for i in range(3,10**5):
ans[i+1] = ans[i] + 1 if like_2017(i) else ans[i]
for l,r in L:
print(ans[r+1] - ans[l])
|
s011296151
|
p03945
|
u582243208
| 2,000
| 262,144
|
Wrong Answer
| 45
| 3,188
| 114
|
Two foxes Jiro and Saburo are playing a game called _1D Reversi_. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is `B`, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is `W`, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place.
|
s=input()
turn=s[0]
res=1
for i in range(1,len(s)):
if s[i]!=turn:
res+=1
turn=s[i]
print(res)
|
s101488271
|
Accepted
| 46
| 3,188
| 114
|
s=input()
turn=s[0]
res=0
for i in range(1,len(s)):
if s[i]!=turn:
res+=1
turn=s[i]
print(res)
|
s489057007
|
p04031
|
u140251125
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 282
|
Evi has N integers a_1,a_2,..,a_N. His objective is to have N equal **integers** by transforming some of them. He may transform each integer at most once. Transforming an integer x into another integer y costs him (x-y)^2 dollars. Even if a_i=a_j (i≠j), he has to pay the cost separately for transforming each of them (See Sample 2). Find the minimum total cost to achieve his objective.
|
# input
n = int(input())
A = list(map(int, input().split()))
ans1 = sum(A) // n + (sum(A) % n != 0)
ans2 = ans1 - 1
cost1 = 0
cost2 = 0
for i in range(n):
cost1 += (A[i] - ans1) ** 2
cost2 += (A[i] - ans2) ** 2
if cost1 <= cost2:
print(ans1)
else:
print(ans2)
|
s569746798
|
Accepted
| 17
| 3,064
| 247
|
# input
n = int(input())
A = list(map(int, input().split()))
ans1 = sum(A) // n + (sum(A) % n != 0)
ans2 = ans1 - 1
cost1 = 0
cost2 = 0
for i in range(n):
cost1 += (A[i] - ans1) ** 2
cost2 += (A[i] - ans2) ** 2
print(min(cost1, cost2))
|
s017005295
|
p03471
|
u805867943
| 2,000
| 262,144
|
Wrong Answer
| 2,103
| 3,064
| 1,603
|
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
|
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
result_10000, result_5000, result_1000 = -1, -1, -1
found = False
for num_10000 in reversed(range(0, Y//10000 + 1)):
y_10000 = Y - 10000 * num_10000
n_10000 = N - num_10000
if y_10000 == 0 and n_10000 == 0:
print(10000, y_10000, n_10000)
result_10000, result_5000, result_1000 = num_10000, 0, 0
found = True
break
else:
for num_5000 in reversed(range(0, y_10000//5000 + 1)):
y_5000 = y_10000 - 5000 * num_5000
n_5000 = n_10000 - num_5000
if y_5000 == 0 and n_5000 == 0 and num_10000 + num_5000 == N:
print(5000, y_5000, n_5000)
result_10000, result_5000, result_1000 = num_10000, num_5000, 0
found = True
break
else:
for num_1000 in reversed(range(0, y_5000//1000 + 1)):
y_1000 = y_5000 - 1000 * num_1000
n_1000 = n_5000 - num_1000
if y_1000 == 0 and n_1000 == 0 and num_10000 + num_5000 + num_1000 == N:
print(1000, y_1000, n_1000)
result_10000, result_5000, result_1000 = num_10000, num_5000, num_1000
found = True
break
if found:
break
if found:
break
print(result_10000, result_5000, result_1000)
|
s436690153
|
Accepted
| 46
| 3,188
| 1,597
|
# -*- coding: utf-8 -*-
N, Y = map(int, input().split())
result_10000, result_5000, result_1000 = -1, -1, -1
found = False
for num_10000 in reversed(range(0, Y//10000 + 1)):
y_10000 = Y - 10000 * num_10000
n_10000 = N - num_10000
if y_10000 == 0 and n_10000 == 0:
result_10000, result_5000, result_1000 = num_10000, 0, 0
found = True
break
else:
for num_5000 in reversed(range(0, y_10000//5000 + 1)):
y_5000 = y_10000 - 5000 * num_5000
n_5000 = n_10000 - num_5000
if y_5000 < 0 or n_5000 < 0:
break
if y_5000 == 0 and n_5000 == 0 and num_10000 + num_5000 == N:
result_10000, result_5000, result_1000 = num_10000, num_5000, 0
found = True
break
else:
num_1000 = y_5000 // 1000
y_1000 = y_5000 - 1000 * num_1000
n_1000 = n_5000 - num_1000
if y_1000 == 0 and n_1000 == 0 and num_10000 + num_5000 + num_1000 == N:
result_10000, result_5000, result_1000 = num_10000, num_5000, num_1000
found = True
break
if found:
break
if found:
break
print(result_10000, result_5000, result_1000)
|
s448291324
|
p03852
|
u454760747
| 2,000
| 262,144
|
Wrong Answer
| 35
| 9,780
| 126
|
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.
|
I = input()
import re
if re.match("(a|i|u|e|o)1", I):
print('vowel', flush=True)
else:
print('consonant', flush=True)
|
s950264008
|
Accepted
| 35
| 9,760
| 171
|
I = input()
import re
# if re.match("^(a|i|u|e|o){1}$", I):
if I in 'aiueo':
# if 'aiueo'.find(I):
print('vowel', flush=True)
else:
print('consonant', flush=True)
|
s101133418
|
p03970
|
u657512990
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 125
|
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 certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
|
#list(map(int, input().split()))
s=input()
t='CODEFESTIVAL2016'
ans=0
for i in range(16):
if t[i]==s[i]:ans+=1
print(ans)
|
s159362998
|
Accepted
| 17
| 2,940
| 125
|
#list(map(int, input().split()))
s=input()
t='CODEFESTIVAL2016'
ans=0
for i in range(16):
if t[i]!=s[i]:ans+=1
print(ans)
|
s636245148
|
p03730
|
u131634965
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 265
|
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 objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
A, B, C = map(int, input().split())
if C%2==0:
if (A%2==0 and B%2==0) or (A%2==1 and B%2==1):
print("YES")
else:
print("NO")
else:
if (A%2==0 and B%2==1) or (A%2==1 and B%2==0):
print("YES")
else:
print("NO")
|
s005847536
|
Accepted
| 17
| 2,940
| 139
|
a,b,c = map(int,input().split())
for i in range(1000):
s = a*i
if s%b == c:
print("YES")
exit()
else:
pass
print("NO")
|
s602174370
|
p04043
|
u006738234
| 2,000
| 262,144
|
Wrong Answer
| 24
| 8,976
| 252
|
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.
|
a = list(map(int, input().split()))
cnt_five = 0
cnt_seven = 0
for i in range(3):
if (a[i] == 5):
cnt_five += 1
if (a[i] == 7):
cnt_seven += 1
if(cnt_five == 2 and cnt_seven == 1):
print('Yes')
else:
print('No')
|
s497697664
|
Accepted
| 25
| 9,116
| 252
|
a = list(map(int, input().split()))
cnt_five = 0
cnt_seven = 0
for i in range(3):
if (a[i] == 5):
cnt_five += 1
if (a[i] == 7):
cnt_seven += 1
if(cnt_five == 2 and cnt_seven == 1):
print('YES')
else:
print('NO')
|
s282015708
|
p03494
|
u724687935
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 182
|
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())
li = list(map(int, input().split()))
max_2 = 0
for num in li:
two = 0
if num % 2 == 0:
num /= 2
two += 1
else:
if two > max_2:
max_2 = two
|
s335673829
|
Accepted
| 18
| 2,940
| 181
|
N = int(input())
A = list(map(int, input().split()))
ans = 0
B = []
for a in A:
cnt = 0
while a % 2 == 0:
a //= 2
cnt += 1
B.append(cnt)
print(min(B))
|
s029159278
|
p03997
|
u861796198
| 2,000
| 262,144
|
Wrong Answer
| 31
| 9,020
| 67
|
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
|
a = int(input())
b = int(input())
h = int(input())
print((a+b)*h/2)
|
s371247352
|
Accepted
| 28
| 8,996
| 87
|
a = int(input())
b = int(input())
h = int(input())
area = (a+b)*(h/2)
print(int(area))
|
s867730212
|
p02795
|
u539005641
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,064
| 107
|
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.
|
a,b,c=[int(input()) for i in range(3)]
def main(a,b,c):
x=max([a,b])
return int(c/x)+1
main(a,b,c)
|
s575882242
|
Accepted
| 17
| 2,940
| 156
|
a,b,c=[int(input()) for i in range(3)]
def main(a,b,c):
x=max([a,b])
if c%x==0:
print(int(c/x))
else:
print(int(c/x+1))
main(a,b,c)
|
s593671159
|
p04043
|
u298101891
| 2,000
| 262,144
|
Wrong Answer
| 28
| 8,996
| 114
|
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.
|
a=input().strip().split(" ")
b=[int(i) for i in a].sort()
if b == [5,5,7]:
print("YES")
else:
print("NO")
|
s576948664
|
Accepted
| 25
| 9,036
| 152
|
a = input().strip()
lst=[]
for i in a:
if i != " ":
lst.append(i)
lst.sort()
if lst == ['5','5','7']:
print("YES")
else:
print("NO")
|
s553379127
|
p02842
|
u830881690
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 8,932
| 158
|
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())
if n%1.08==0:
print(n//1.08)
else:
x_init=n//1.08 + 1
x_n = int(1.08*x_init)
if x_n ==n:
print(x_init)
else:
print(':(')
|
s888161065
|
Accepted
| 27
| 9,104
| 165
|
n = int(input())
if n%1.08==0:
print(int(n//1.08))
else:
x_init=n//1.08 + 1
x_n = int(1.08*x_init)
if x_n ==n:
print(int(x_init))
else:
print(':(')
|
s002842209
|
p03352
|
u102461423
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 114
|
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
|
X = int(input())
se = set(n**e for n in range(32) for e in range(11) if n**e <= X)
answer = max(se)
print(answer)
|
s452753694
|
Accepted
| 17
| 2,940
| 116
|
X = int(input())
se = set(n**e for n in range(32) for e in range(2,11) if n**e <= X)
answer = max(se)
print(answer)
|
s593612848
|
p03469
|
u753682919
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 48
|
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
|
s=list(input())
n=s[8:]
print("2018/01/"+str(n))
|
s494236209
|
Accepted
| 17
| 2,940
| 53
|
s=list(input())
print("2018/01/"+str(s[8])+str(s[9]))
|
s520727098
|
p03407
|
u201660334
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 98
|
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 = list(map(int, input().split()))
if a[0] + a[1] == a[2]:
print("Yes")
else:
print("No")
|
s866981357
|
Accepted
| 17
| 2,940
| 98
|
a = list(map(int, input().split()))
if a[0] + a[1] >= a[2]:
print("Yes")
else:
print("No")
|
s990986982
|
p03761
|
u086503932
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,316
| 300
|
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())
S = [input() for _ in range(n)]
ans = Counter(S[0])
for i in range(1,n):
tmp = Counter(S[i])
for a in ans.keys():
if a in tmp:
ans[a] = min(ans[a],tmp[a])
else:
ans[a] = 0
x = ''
for a in ans.items():
x += a[0]*a[1]
print(x)
|
s256773260
|
Accepted
| 30
| 9,144
| 291
|
N = int(input())
INF = 10**12
ans = [INF] * 26
for _ in range(N):
S = input()
tmp = [0] * 26
for s in S:
tmp[ord(s)-ord('a')] += 1
for i in range(26):
ans[i] = min(ans[i],tmp[i])
ansS = ''
for i in range(26):
ansS += chr(i+97) * ans[i]
print(ansS)
|
s729828055
|
p03377
|
u339851548
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 97
|
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
|
a, b, c = map(int, input().split())
if c < a or c > a + b:
print('No')
else:
print('Yes')
|
s026684590
|
Accepted
| 18
| 2,940
| 97
|
a, b, c = map(int, input().split())
if c < a or c > a + b:
print('NO')
else:
print('YES')
|
s098268972
|
p02795
|
u376420711
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 63
|
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.
|
ans = "123"
print(ans.replace(input(),"").replace(input(),""))
|
s454544136
|
Accepted
| 18
| 2,940
| 55
|
h, w, n = map(int, open(0))
print(0 - -n // max(h, w))
|
s482331821
|
p03110
|
u918009437
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 3,060
| 312
|
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
if __name__ == '__main__':
N = int(input())
xu_list = [list(map(str, input().split())) for i in range(N)]
answer = 0
for xu in xu_list:
if xu[1] == 'JPY':
answer += int(xu[0])
elif xu[1] == 'BTC':
answer += int(float(xu[0]) * 380000.0)
print(answer)
|
s642437535
|
Accepted
| 17
| 3,060
| 307
|
if __name__ == '__main__':
N = int(input())
xu_list = [list(map(str, input().split())) for i in range(N)]
answer = 0
for xu in xu_list:
if xu[1] == 'JPY':
answer += int(xu[0])
elif xu[1] == 'BTC':
answer += float(xu[0]) * 380000.0
print(answer)
|
s510979495
|
p03644
|
u994521204
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 79
|
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.
|
a=int(input())
c=0
for i in range(7):
if a%2==0:
c+=1
a=a//2
print(c)
|
s369527014
|
Accepted
| 17
| 3,060
| 164
|
n=int(input())
if n>=64:
print(64)
elif n>=32:
print(32)
elif n>=16:
print(16)
elif n>=8:
print(8)
elif n>=4:
print(4)
elif n>=2:
print(2)
else:print(1)
|
s077536637
|
p03470
|
u051496905
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 35
|
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 have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
|
P = [1,2,3,4,5]
S = sum(P)
print(S)
|
s302373260
|
Accepted
| 19
| 3,060
| 119
|
N = int(input())
P = [int(input()) for i in range(N)]
s = set()
for i in range(N):
s.add(P[i])
L = len(s)
print(L)
|
s992251576
|
p03779
|
u797550216
| 2,000
| 262,144
|
Wrong Answer
| 29
| 2,940
| 113
|
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
x = int(input())
for i in range(1,10**5):
ans = (i*(i+1)//2)
if ans > x:
print(i)
break
|
s073520431
|
Accepted
| 30
| 2,940
| 115
|
x = int(input())
for i in range(1,10**5):
ans = (i*(i+1)//2)
if ans >= x:
print(i)
break
|
s943111708
|
p03999
|
u089142196
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 333
|
You are given a string S consisting of digits between `1` and `9`, inclusive. You can insert the letter `+` into some of the positions (possibly none) between two letters in this string. Here, `+` must not occur consecutively after insertion. All strings that can be obtained in this way can be evaluated as formulas. Evaluate all possible formulas, and print the sum of the results.
|
S=input()
N=len(S)
dp=[[0]*(N+1) for _ in range(2)]
dp[0][1]=int(S[0])
dp[1][1]=int(S[0])
for i in range(2,N+1):
dp[0][i]= dp[1][i-1] + int(S[i-1])
a= dp[0][i-2]+int(S[i-2:i])
b= int(str(dp[1][i-1])+str(S[i-1]))
dp[1][i]= max(a,b)
print(dp)
ans=max(dp[0][-1],dp[1][-1])
print(ans)
|
s097264471
|
Accepted
| 21
| 3,064
| 260
|
from itertools import product
S=input()
N=len(S)
a=product(["+",""],repeat=N-1)
ans=0
for i,p in enumerate(a):
bun = S[0]
for j in range(N-1):
bun += p[j]+S[j+1]
nums=bun.split("+")
tmp=0
for num in nums:
tmp+=int(num)
ans+=tmp
print(ans)
|
s384749603
|
p03845
|
u152614052
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,040
| 4
|
Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.
|
6
9
|
s959682346
|
Accepted
| 28
| 9,176
| 196
|
n = int(input())
t_li = list(map(int,input().split()))
m = int(input())
d_li=[list(map(int,input().split())) for i in range(m)]
time = sum(t_li)
for i, j in d_li:
print(time - t_li[i-1] + j)
|
s568974267
|
p03455
|
u989326345
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 93
|
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())
A=(a*b)%2
if A==0:
print("even")
else:
print("odd")
|
s007899884
|
Accepted
| 17
| 2,940
| 90
|
a,b=map(int,input().split())
c=(a*b)%2
if c==1:
print('Odd')
else:
print('Even')
|
s597992363
|
p02615
|
u556657484
| 2,000
| 1,048,576
|
Wrong Answer
| 224
| 31,440
| 175
|
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i. The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere. When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0. What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ANS = A[0]
for i in range(N-2):
index = i // 2
print(index)
ANS += A[index+1]
print(ANS)
|
s070623822
|
Accepted
| 143
| 31,512
| 158
|
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ANS = A[0]
for i in range(N-2):
index = i // 2
ANS += A[index+1]
print(ANS)
|
s218628250
|
p03637
|
u811436126
| 2,000
| 262,144
|
Wrong Answer
| 58
| 14,252
| 201
|
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
|
n = int(input())
a = list(map(int, input().split()))
odd = sum([1 for i in a if i % 2 == 0])
multiple4 = sum([1 for i in a if i % 4 == 0])
if odd <= multiple4:
print('Yes')
else:
print('No')
|
s076487498
|
Accepted
| 66
| 14,252
| 360
|
n = int(input())
a = list(map(int, input().split()))
even = sum([1 for i in a if i % 2 == 0])
odd = sum([1 for i in a if i % 2 != 0])
multiple4 = sum([1 for i in a if i % 4 == 0])
flag = False
if even - multiple4 == 0:
if multiple4 >= odd - 1:
flag = True
else:
if multiple4 >= odd:
flag = True
print('Yes') if flag else print('No')
|
s357121988
|
p02613
|
u592246102
| 2,000
| 1,048,576
|
Wrong Answer
| 26
| 9,136
| 201
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
a = input()
ac = a.count('AC')
wa = a.count('WA')
tle = a.count('TLE')
re = a.count('RE')
print('AC × '+ str(ac))
print('WA × '+ str(wa))
print('CLE × '+ str(tle))
print('RE × '+ str(re))
|
s881388110
|
Accepted
| 140
| 16,252
| 226
|
N = int(input())
a = [input() for i in range(N)]
ac = a.count('AC')
wa = a.count('WA')
tle = a.count('TLE')
re = a.count('RE')
print('AC x '+ str(ac))
print('WA x '+ str(wa))
print('TLE x '+ str(tle))
print('RE x '+ str(re))
|
s080979326
|
p02601
|
u155394679
| 2,000
| 1,048,576
|
Wrong Answer
| 31
| 9,132
| 305
|
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.
|
[r, g, b] = map(int,input().split(' '))
K = int(input())
loop = 1
flag = False
while loop <= K:
if b <= r or b <= g:
b*=2
loop += 1
continue
if g <= r:
g*=2
loop += 1
continue
if r < g < b:
flag = True
break
loop += 1
if flag:
print('Yes')
else:
print('No')
|
s725329430
|
Accepted
| 29
| 9,204
| 307
|
[r, g, b] = map(int,input().split(' '))
K = int(input())
loop = 1
flag = False
while loop <= K+1:
if b <= r or b <= g:
b*=2
loop += 1
continue
if g <= r:
g*=2
loop += 1
continue
if r < g < b:
flag = True
break
loop += 1
if flag:
print('Yes')
else:
print('No')
|
s348595975
|
p03860
|
u685983477
| 2,000
| 262,144
|
Wrong Answer
| 26
| 9,020
| 35
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s = input()
print(s[0]+s[8]+s[10])
|
s449850225
|
Accepted
| 26
| 8,972
| 61
|
s = list(input().split())
print(s[0][0] + s[1][0] + s[2][0])
|
s768512367
|
p03555
|
u043877190
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 103
|
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 a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print("Yes")
else:
print("No")
|
s977082594
|
Accepted
| 18
| 2,940
| 104
|
a=input()
b=input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
print("YES")
else:
print("NO")
|
s307291433
|
p02646
|
u317710033
| 2,000
| 1,048,576
|
Wrong Answer
| 21
| 9,180
| 180
|
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print('No')
else:
if (v-w)*t >= abs(a-b):
print('Yes')
else:
print('No')
|
s967218934
|
Accepted
| 20
| 9,180
| 180
|
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if v <= w:
print('NO')
else:
if (v-w)*t >= abs(a-b):
print('YES')
else:
print('NO')
|
s982828956
|
p02831
|
u595289165
| 2,000
| 1,048,576
|
Wrong Answer
| 35
| 5,048
| 120
|
Takahashi is organizing a party. At the party, each guest will receive one or more snack pieces. Takahashi predicts that the number of guests at this party will be A or B. Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted. We assume that a piece cannot be divided and distributed to multiple guests.
|
import fractions
a, b = map(int, input().split())
def lcm(x, y):
return x*y/fractions.gcd(x, y)
print(lcm(a, b))
|
s767058696
|
Accepted
| 18
| 2,940
| 187
|
def gcd(x, y):
if x == 0:
return y
else:
return gcd(y % x, x)
def lcm(x, y):
return x * y // gcd(x, y)
a, b = map(int, input().split())
print(lcm(a, b))
|
s438647622
|
p02612
|
u072719787
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,052
| 40
|
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())
n = N % 1000
print(n)
|
s858894920
|
Accepted
| 29
| 9,004
| 79
|
N = int(input())
n = N % 1000
if n == 0:
print(n)
else:
print(1000-n)
|
s031362120
|
p03050
|
u017810624
| 2,000
| 1,048,576
|
Wrong Answer
| 249
| 3,060
| 94
|
Snuke received a positive integer N from Takahashi. A positive integer m is called a _favorite number_ when the following condition is satisfied: * The quotient and remainder of N divided by m are equal, that is, \lfloor \frac{N}{m} \rfloor = N \bmod m holds. Find all favorite numbers and print the sum of those.
|
n=int(input())
ct=0
for i in range(1,int(n**0.5)):
if (n-i)%i==0:
ct+=(n-i)//i
print(ct)
|
s872136819
|
Accepted
| 222
| 3,060
| 225
|
n=int(input())
if n==1:
print(0)
else:
ct=0
for i in range(1,int(n**0.5)):
if (n-i)%i==0:
ct+=(n-i)//i
if (n-int(n**0.5))%int(n**0.5)==0:
x=(n-int(n**0.5))//int(n**0.5)
if n//x==n%x:ct+=x
print(ct)
|
s940117206
|
p04011
|
u480847874
| 2,000
| 262,144
|
Wrong Answer
| 41
| 3,064
| 322
|
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.
|
def B(w,arpha,count):
for c in w:
for i,a in enumerate(arpha):
if c == a:
count[i]+=1
for i in count:
if i % 2 != 0:
return print("No")
print("Yes")
w = input()
arpha = [chr(i) for i in range(97,97+26)]
count = [0 for i in range(26)]
B(w,arpha,count)
|
s200997553
|
Accepted
| 39
| 3,064
| 164
|
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
sum = 0
for n in range(N):
if n < K:
sum +=X
else:
sum +=Y
print(sum)
|
s300421004
|
p03486
|
u214434454
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 356
|
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_lis = []
t_lis = []
for i in range(len(s)):
s_lis.append(s[i])
for i in range(len(t)):
t_lis.append(t[i])
s_lis.sort()
t_lis.sort(reverse = True)
s1 = ""
t1 = ""
for i in range(len(s_lis)):
s1 += s_lis[i]
for i in range(len(t_lis)):
t1 += t_lis[i]
print(s1, t1)
if s1 < t1:
print("Yes")
else:
print("No")
|
s192691665
|
Accepted
| 17
| 3,064
| 357
|
s = input()
t = input()
s_lis = []
t_lis = []
for i in range(len(s)):
s_lis.append(s[i])
for i in range(len(t)):
t_lis.append(t[i])
s_lis.sort()
t_lis.sort(reverse = True)
s1 = ""
t1 = ""
for i in range(len(s_lis)):
s1 += s_lis[i]
for i in range(len(t_lis)):
t1 += t_lis[i]
#print(s1, t1)
if s1 < t1:
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.