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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s901809319
|
p03371
|
u888100977
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 341 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
a,b,c,x,y = map(int,input().split())
p = max(x,y)
q = min(x,y)
ans = 0
if a+b>=2*c:
if p == x:
ans += 2*c*q + min(a,2*c)*(p-q)
else:
ans += 2*c*q + min(b,2*c)*(p-q)
else:
if p == x:
ans += (a+b)*q + min(a,2*c)*(p-q)
else:
ans += (a+b)*q + min(b,2*c)*(p-q)
print(ans)
print(a,b,c,x,y)
|
s214979593
|
Accepted
| 17 | 3,064 | 343 |
a,b,c,x,y = map(int,input().split())
p = max(x,y)
q = min(x,y)
ans = 0
if a+b>=2*c:
if p == x:
ans += 2*c*q + min(a,2*c)*(p-q)
else:
ans += 2*c*q + min(b,2*c)*(p-q)
else:
if p == x:
ans += (a+b)*q + min(a,2*c)*(p-q)
else:
ans += (a+b)*q + min(b,2*c)*(p-q)
print(ans)
# print(a,b,c,x,y)
|
s655171935
|
p02363
|
u165578704
| 1,000 | 131,072 |
Wrong Answer
| 30 | 6,360 | 1,114 |
# -*- coding: utf-8 -*-
import sys
from copy import deepcopy
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')
def warshall_floyd(N: int, graph: list) -> list:
res = deepcopy(graph)
for i in range(N):
res[i][i] = 0
for k in range(N):
for i in range(N):
for j in range(N):
res[i][j] = min(res[i][j], res[i][k] + res[k][j])
for i in range(N):
if res[i][i] < 0:
return []
return res
N,M=MAP()
G=[[INF]*N for i in range(N)]
for i in range(M):
s,t,d=MAP()
G[s][t]=d
ans=warshall_floyd(N, G)
if not len(ans):
print('NEGATIVE CYCLE')
exit()
for i in range(N):
print(*ans[i])
|
s514413224
|
Accepted
| 510 | 7,244 | 1,211 |
# -*- coding: utf-8 -*-
import sys
from copy import deepcopy
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')
def warshall_floyd(N: int, graph: list) -> list:
res = deepcopy(graph)
for i in range(N):
res[i][i] = 0
for k in range(N):
for i in range(N):
for j in range(N):
res[i][j] = min(res[i][j], res[i][k] + res[k][j])
for i in range(N):
if res[i][i] < 0:
return []
return res
N,M=MAP()
G=[[INF]*N for i in range(N)]
for i in range(M):
s,t,d=MAP()
G[s][t]=d
ans=warshall_floyd(N, G)
if not len(ans):
print('NEGATIVE CYCLE')
exit()
for i in range(N):
for j in range(N):
if ans[i][j]==INF:
ans[i][j]='INF'
for i in range(N):
print(*ans[i])
|
|
s398015148
|
p03385
|
u964904181
| 2,000 | 262,144 |
Wrong Answer
| 118 | 27,096 | 113 |
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
|
import numpy as np
S=input()
s = [st for st in S]
if len(np.unique(s)) == 3:
print("YES")
else:
print("NO")
|
s432924178
|
Accepted
| 119 | 27,108 | 113 |
import numpy as np
S=input()
s = [st for st in S]
if len(np.unique(s)) == 3:
print("Yes")
else:
print("No")
|
s569004824
|
p03836
|
u259861571
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 372 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
# AtCoder
sx, sy, tx, ty = map(int, input().split())
path = []
dx = tx-sx
dy = ty-sy
# first
path.append('U'*dy)
path.append('R'*dx)
# second
path.append('D'*dy)
path.append('L'*dx)
# third
path.append('L')
path.append('U'*(dy+1))
path.append('R'*(dx+1))
# forth
path.append('R')
path.append('D'*(dy+1))
path.append('L'*(dx+1))
path.append('U')
print(''.join(path))
|
s380449827
|
Accepted
| 18 | 3,064 | 389 |
# AtCoder
sx, sy, tx, ty = map(int, input().split())
path = []
dx = tx-sx
dy = ty-sy
# first
path.append('U'*dy)
path.append('R'*dx)
# second
path.append('D'*dy)
path.append('L'*dx)
# third
path.append('L')
path.append('U'*(dy+1))
path.append('R'*(dx+1))
path.append('D')
# forth
path.append('R')
path.append('D'*(dy+1))
path.append('L'*(dx+1))
path.append('U')
print(''.join(path))
|
s743068244
|
p03416
|
u292810930
| 2,000 | 262,144 |
Wrong Answer
| 122 | 2,940 | 138 |
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())
answer = 0
for i in range(A,B+1):
if list(str(i)) == list(str(i)):
answer += 1
print(answer)
|
s419567283
|
Accepted
| 123 | 2,940 | 146 |
A, B = map(int, input().split())
answer = 0
for i in range(A,B + 1):
if list(str(i)) == list(str(i))[::-1]:
answer += 1
print(answer)
|
s929605856
|
p03712
|
u102242691
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 150 |
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
|
h,w = map(int,input().split())
s = [input() for i in range(h)]
print("#" * w * 2)
for i in range(h):
print("#" + s[i] + "#")
print("#" * w * 2)
|
s840738965
|
Accepted
| 18 | 2,940 | 125 |
h,w = map(int,input().split())
l = "#"*(w+2)
print(l)
for i in range(h):
tmp = input()
print("#"+tmp+"#")
print(l)
|
s199625527
|
p03971
|
u592743763
| 2,000 | 262,144 |
Wrong Answer
| 77 | 9,216 | 432 |
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
|
datalist=list(map(int,input().split()))
N,A,B=datalist[0],datalist[1],datalist[2]
strings=str(input())
na,nb=0,0
for i in range(len(strings)):
if strings[i]=="a":
if na + nb < A+B:
print("YES")
na += 1
else:
print("NO")
elif strings[i]=="b":
if na + nb < A+B:
if nb <= B:
print("YES")
nb += 1
else:
print("NO")
else:
print("NO")
else:
print("NO")
|
s149403321
|
Accepted
| 61 | 10,684 | 497 |
datalist=list(map(int,input().split()))
N, A, B = datalist[0], datalist[1], datalist[2]
strings=str(input())
na,nb=0,0
out=[]
for i in range(len(strings)):
if strings[i]=="a":
if na + nb < A+B:
out.append("Yes")
na += 1
else:
out.append("No")
elif strings[i]=="b":
if na + nb < A+B:
if nb < B:
out.append("Yes")
nb += 1
else:
out.append("No")
else:
out.append("No")
else:
out.append("No")
print("\n".join(out))
|
s480436195
|
p03251
|
u016901717
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 244 |
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
n,m,X,Y=map(int,input().split())
x=sorted(map(int,input().split()))
y=sorted(map(int,input().split()))
if Y-X>=1:
for i in range(X+1,Y):
if x[n-1]<i and y[0]>=i:
print("War")
exit()
else:
print("No War")
|
s101831473
|
Accepted
| 17 | 3,060 | 233 |
n,m,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
x_max=max(x)
y_min=min(y)
if (y_min-x_max > 0) and (Y-X > 0) and (X<y_min) and (x_max<Y):
print("No War")
else:
print("War")
|
s830133646
|
p03160
|
u852798899
| 2,000 | 1,048,576 |
Wrong Answer
| 228 | 13,928 | 248 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
n = int(input())
h = list(map(int, input().split()))
dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[i])
print(dp[n-1])
|
s639914569
|
Accepted
| 131 | 13,928 | 223 |
n = int(input())
h = list(map(int, input().split()))
dp = [0 for i in range(n)]
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[n-1])
|
s213346149
|
p03855
|
u919730120
| 2,000 | 262,144 |
Wrong Answer
| 1,216 | 37,924 | 1,626 |
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
|
#UNIONFIND
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self._root(self.table[x])
return self.table[x]
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
if d1 == d2:
self.table[r1] -= 1
else:
self.table[r1] = r2
if __name__ == '__main__':
n,k,l=map(int,input().split())
pq=UnionFind(n+1)
rs=UnionFind(n+1)
for i in range(k):
p,q=map(int,input().split())
pq.union(p,q)
for i in range(l):
r,s=map(int,input().split())
rs.union(r,s)
sameroot=[]
for i in range(1,n+1):
sameroot.append([pq._root(i),rs._root(i),i])
sameroot.sort()
sameroot.append([0,0,n+1])
cnt=[0]*(n+1)
bx,by=0,0
samelist=[]
for x,y,i in sameroot:
if bx==x and by==y:
samelist.append(i)
else:
k=len(samelist)
if k>0:
for j in samelist:
cnt[j]=k
samelist=[i]
bx,by=x,y
print(cnt[1:])
|
s229276244
|
Accepted
| 1,223 | 48,552 | 1,645 |
#UNIONFIND
class UnionFind:
def __init__(self, n):
self.table = [-1] * n
def _root(self, x):
if self.table[x] < 0:
return x
else:
self.table[x] = self._root(self.table[x])
return self.table[x]
def find(self, x, y):
return self._root(x) == self._root(y)
def union(self, x, y):
r1 = self._root(x)
r2 = self._root(y)
if r1 == r2:
return
d1 = self.table[r1]
d2 = self.table[r2]
if d1 <= d2:
self.table[r2] = r1
if d1 == d2:
self.table[r1] -= 1
else:
self.table[r1] = r2
if __name__ == '__main__':
n,k,l=map(int,input().split())
pq=UnionFind(n+1)
rs=UnionFind(n+1)
for i in range(k):
p,q=map(int,input().split())
pq.union(p,q)
for i in range(l):
r,s=map(int,input().split())
rs.union(r,s)
sameroot=[]
for i in range(1,n+1):
sameroot.append([pq._root(i),rs._root(i),i])
sameroot.sort()
sameroot.append([0,0,n+1])
cnt=[0]*(n+1)
bx,by=0,0
samelist=[]
for x,y,i in sameroot:
if bx==x and by==y:
samelist.append(i)
else:
k=len(samelist)
if k>0:
for j in samelist:
cnt[j]=k
samelist=[i]
bx,by=x,y
print(' '.join(map(str,cnt[1:])))
|
s093165903
|
p03371
|
u626337957
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 200 |
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.
|
A, B, AB, X, Y = map(int, input().split())
ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
ans2 = A*(X-Y) + AB*Y
ans3 = AB*X
else:
ans2 = A*(Y-X) + AB*X
ans3 = AB*Y
print(min(ans1, ans2, ans3))
|
s615318180
|
Accepted
| 17 | 3,060 | 209 |
A, B, AB, X, Y = map(int, input().split())
ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
ans2 = A*(X-Y) + AB*Y*2
ans3 = AB*X*2
else:
ans2 = B*(Y-X) + AB*X*2
ans3 = AB*Y*2
print(min(ans1, ans2, ans3))
|
s974990576
|
p03378
|
u170183831
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 178 |
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal.
|
n, m, x = map(int, input().split())
count1 = x
count2 = n - x
for a in map(int, input().split()):
if a < x:
count1 += 1
else:
count2 += 1
print(min(count1, count2))
|
s568974656
|
Accepted
| 17 | 2,940 | 174 |
n, m, x = map(int, input().split())
count1 = 0
count2 = 0
for a in map(int, input().split()):
if a < x:
count1 += 1
else:
count2 += 1
print(min(count1, count2))
|
s663147328
|
p03957
|
u821262411
| 1,000 | 262,144 |
Wrong Answer
| 23 | 3,064 | 119 |
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=str(input())
if s.find('C')>0 and s.find('C')>0 and s.find('C')<s.rfind('F'):
print('Yes')
else:
print('No')
|
s789937335
|
Accepted
| 23 | 3,064 | 142 |
s=str(input())
p=list('ABDEGHIJKLMNOPQRSTUVWXYZ')
for i in p:
s=s.replace(i,'')
if 'CF' in s:
print('Yes')
else:
print('No')
|
s986212832
|
p03997
|
u099918199
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 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)
|
s428447156
|
Accepted
| 27 | 9,164 | 72 |
a = int(input())
b = int(input())
h = int(input())
print((a+b) * h // 2)
|
s035615459
|
p02646
|
u614181788
| 2,000 | 1,048,576 |
Wrong Answer
| 23 | 9,180 | 179 |
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())
ans = 0
if v == w:
pass
elif v>w and abs(a-b)//(v-w) <= t :
ans = 1
print(["No","Yes"][ans])
|
s147758851
|
Accepted
| 23 | 9,192 | 231 |
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
ans = 0
if a == b:
ans = 1
if v == w:
ans = 0
elif v>w and abs(a-b)/(v-w) <= t :
ans = 1
if ans == 0:
print("NO")
else:
print("YES")
|
s841500195
|
p04044
|
u780475861
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,188 | 111 |
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L. She will concatenate all of the strings in some order, to produce a long string. Among all strings that she can produce in this way, find the lexicographically smallest one. Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds: * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i. * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.
|
n,l = [int(i) for i in input().split()]
lst = []
for _ in range(n):
lst.append(input())
lst.sort()
print(lst)
|
s873409723
|
Accepted
| 17 | 3,060 | 139 |
n,l = [int(i) for i in input().split()]
lst = []
for _ in range(n):
lst.append(input())
lst.sort()
s = ''
for i in lst:
s += i
print(s)
|
s937972187
|
p03606
|
u940102677
| 2,000 | 262,144 |
Wrong Answer
| 19 | 2,940 | 96 |
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())
s = 0
for i in range(n):
l, r = map(int, input().split())
s += r-l
print(s)
|
s427634088
|
Accepted
| 26 | 2,940 | 98 |
n = int(input())
s = 0
for i in range(n):
l, r = map(int, input().split())
s += r-l+1
print(s)
|
s012423517
|
p03160
|
u570545613
| 2,000 | 1,048,576 |
Wrong Answer
| 119 | 13,980 | 342 |
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
|
def frog(arr):
n=len(arr)
if n<=1:
return 0
dp=[0]*(n+1)
dp[2]=abs(arr[0]-arr[1])
if n==2:
return dp[2]
for i in range(3,n+1):
dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
return dp[n]
n=int(input())
arr=[int(i) for i in input().split()]
frog(arr)
|
s505600614
|
Accepted
| 132 | 13,928 | 207 |
n=int(input())
arr=[int(i) for i in input().split()]
dp=[0]*(n+1)
dp[2]=abs(arr[0]-arr[1])
for i in range(3,n+1):
dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3]))
print(dp[n])
|
s843973003
|
p03433
|
u323210830
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 117 |
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins.
|
N=int(input())
A=int(input())
for x in range(A-1):
if (N-x)%500==0:
print("YES")
break
else:
print("NO")
|
s224195757
|
Accepted
| 17 | 2,940 | 78 |
N=int(input())
A=int(input())
if N%500<=A:
print("Yes")
else:
print("No")
|
s862195518
|
p03131
|
u989623817
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 431 |
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
|
k, a, b = map(int, input().split())
if a+2 > b:
print(1 + k)
exit()
roop_turn = a+2
if k < roop_turn-1:
print(1 + k)
exit()
ret = b
remaining = k - roop_turn-1
q, mod = divmod(remaining, 2)
ret += (b-a)*q + mod
print(ret)
|
s760083435
|
Accepted
| 17 | 3,060 | 433 |
k, a, b = map(int, input().split())
if a+2 > b:
print(1 + k)
exit()
roop_turn = a+2
if k < roop_turn-1:
print(1 + k)
exit()
ret = b
remaining = k - (roop_turn-1)
q, mod = divmod(remaining, 2)
ret += (b-a)*q + mod
print(ret)
|
s617932055
|
p03737
|
u288500098
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 110 |
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.
|
s1,s2,s3 = map(str, input().split())
s1 = s1.upper()
s2 = s2.upper()
s3 = s3.upper()
print(s1[0],s2[0],s3[0])
|
s656445649
|
Accepted
| 17 | 2,940 | 110 |
s1,s2,s3 = map(str, input().split())
s1 = s1.upper()
s2 = s2.upper()
s3 = s3.upper()
print(s1[0]+s2[0]+s3[0])
|
s214172583
|
p03845
|
u816631826
| 2,000 | 262,144 |
Wrong Answer
| 31 | 9,328 | 467 |
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.
|
from collections import *
from itertools import *
from math import *
n=int(input())
a=sorted(list(map(int,input().split())))
b=list(Counter(a))
mod=7+10**9
if n%2==1:
if a[0]!=0:
print(0)
exit()
for i in range(1,n):
if ceil(i/2)*2!=a[i]:
print(0)
exit()
print(2**(n//2)%mod)
if n%2==0:
for i in range(n):
if floor(i/2)*2+1!=a[i]:
print(0)
exit()
print(2**(n//2)%mod)
|
s685193572
|
Accepted
| 24 | 9,164 | 182 |
N = int(input())
T = list(map(int, input().split()))
t = sum(T)
M = int(input())
S = [list(map(int, input().split())) for _ in range(M)]
for s in S:
print(t - T[s[0] - 1] + s[1])
|
s276930247
|
p03369
|
u835482198
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 57 |
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 three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s = input()
print(700 + 100 * len(s.replace('x', 'o')))
|
s177787128
|
Accepted
| 17 | 2,940 | 56 |
s = input()
print(700 + 100 * len(s.replace('x', '')))
|
s470129947
|
p02272
|
u662418022
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,624 | 913 |
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
|
# -*- coding: utf-8 -*-
def merge(A, left, mid, right):
global cnt
n1 = mid - left
n2 = right - mid
L = [None]*(n1+1)
R = [None]*(n2+1)
for i in range(n1):
L[i] = A[left + i]
for i in range(n2):
R[i] = A[mid + i]
L[n1] = float('inf')
R[n2] = float('inf')
i = 0
j = 0
for k in range(left, right):
cnt += 1
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
print(A, left, mid, right)
mergeSort(A, left, mid)
mergeSort(A, mid, right)
merge(A, left, mid, right)
if __name__ == '__main__':
n = int(input())
S = [int(s) for s in input().split(" ")]
cnt = 0
mergeSort(S, 0, n)
print(" ".join(map(str, S)))
print(cnt)
|
s055953832
|
Accepted
| 4,200 | 66,732 | 788 |
# -*- coding: utf-8 -*-
def merge(A, left, mid, right):
global cnt
n1 = mid - left
n2 = right - mid
L = A[left:left+n1]
R = A[mid:mid+n2]
L.append(float('inf'))
R.append(float('inf'))
i = 0
j = 0
for k in range(left, right):
cnt += 1
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
mergeSort(A, left, mid)
mergeSort(A, mid, right)
merge(A, left, mid, right)
if __name__ == '__main__':
n = int(input())
S = [int(s) for s in input().split(" ")]
cnt = 0
mergeSort(S, 0, n)
print(" ".join(map(str, S)))
print(cnt)
|
s925305747
|
p00022
|
u299798926
| 1,000 | 131,072 |
Wrong Answer
| 40 | 5,640 | 123 |
Given a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that, a subsequence of one element is also a _contiquous_ subsequence.
|
while(1):
a=[]
n = int(input())
if n==0:
break
a=[int(input()) for i in range(n)]
print(sum(a))
|
s061062034
|
Accepted
| 1,710 | 188,644 | 316 |
while(1):
a=[]
n = int(input())
if n==0:
break
a=[int(input()) for i in range(n)]
result=[]
for i in range(n):
result1=a[i]
result.append(result1)
for j in range(i+1,n):
result1=result1+a[j]
result.append(result1)
print(max(result))
|
s652901617
|
p02422
|
u656153606
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,536 | 361 |
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.
|
str = input().casefold()
q = int(input())
for i in range(q):
command = input().split()
a = int(command[1])
b = int(command[2])
if command[0] == "print":
print(str[a:b+1])
elif command[0] == 'reverse':
str = str[a] + str[a:b+1][::-1] + str[b+a:]
elif command[0] == "replace":
str = str[:a] +command[3] + str[b+1:]
|
s108874622
|
Accepted
| 20 | 7,732 | 302 |
s = input()
for i in range(int(input())):
cmd = input().split()
a,b = [int(x) for x in cmd[1:3]]
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:]
|
s572882376
|
p03836
|
u076917070
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 607 |
Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up. Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1. Here, both the x\- and y-coordinates before and after each movement must be integers. He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy). Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty). Under this condition, find a shortest path for him.
|
import sys
input = sys.stdin.readline
def main():
sx, sy, tx, ty = map(int, input().split())
ans = ""
for _ in range(ty-sy):
ans += "U"
for _ in range(tx-sx):
ans += "R"
for _ in range(ty-sy):
ans += "D"
for _ in range(tx-sx):
ans += "L"
ans += "L"
for _ in range(ty-sy+1):
ans += "U"
for _ in range(tx-sx+1):
ans += "R"
ans += "D"
ans += "R"
for _ in range(tx-sx+1):
ans += "D"
for _ in range(ty-sy+1):
ans += "L"
ans += "U"
print(ans)
if __name__ == '__main__':
main()
|
s693426698
|
Accepted
| 24 | 3,064 | 607 |
import sys
input = sys.stdin.readline
def main():
sx, sy, tx, ty = map(int, input().split())
ans = ""
for _ in range(ty-sy):
ans += "U"
for _ in range(tx-sx):
ans += "R"
for _ in range(ty-sy):
ans += "D"
for _ in range(tx-sx):
ans += "L"
ans += "L"
for _ in range(ty-sy+1):
ans += "U"
for _ in range(tx-sx+1):
ans += "R"
ans += "D"
ans += "R"
for _ in range(ty-sy+1):
ans += "D"
for _ in range(tx-sx+1):
ans += "L"
ans += "U"
print(ans)
if __name__ == '__main__':
main()
|
s179484188
|
p03673
|
u171065106
| 2,000 | 262,144 |
Wrong Answer
| 2,206 | 24,924 | 109 |
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()
b = []
for i in a:
b.append(i)
b.reverse()
print("".join(b))
|
s381551304
|
Accepted
| 87 | 29,756 | 287 |
n = 4
a = [1, 2, 3, 4]
n = int(input())
a = input().split()
if n % 2 == 0:
y = [a[j] for j in range(1, n, 2)][::-1]
z = [a[j] for j in range(0, n, 2)]
else:
y = [a[j] for j in range(0, n, 2)][::-1]
z = [a[j] for j in range(1, n, 2)]
print(" ".join(map(str, y + z)))
|
s163947638
|
p02612
|
u161857931
| 2,000 | 1,048,576 |
Wrong Answer
| 27 | 9,140 | 31 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
N = int(input())
print(N%1000)
|
s716006833
|
Accepted
| 28 | 9,144 | 62 |
N = int(input())
print(1000 - N%1000 if N%1000 != 0 else "0")
|
s206674519
|
p02400
|
u865138391
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,400 | 92 |
Write a program which calculates the area and circumference of a circle for given radius r.
|
import math
a = float(input())
print("{0:.6f}, {1:.6f}".format(a*a*math.pi, a*2.0*math.pi))
|
s045063922
|
Accepted
| 20 | 7,468 | 91 |
import math
a = float(input())
print("{0:.6f} {1:.6f}".format(a*a*math.pi, a*2.0*math.pi))
|
s335356920
|
p03478
|
u136395536
| 2,000 | 262,144 |
Wrong Answer
| 47 | 3,628 | 303 |
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).
|
charN,charA,charB =input().split()
N = int(charN)
A = int(charA)
B = int(charB)
total = 0
for i in range(N):
tmp = 0
chartmp = str(i+1)
for j in range(len(chartmp)):
tmp = tmp + int(chartmp[j])
print(tmp)
if (tmp>=A and tmp <= B):
total = total + (i+1)
print(total)
|
s629845865
|
Accepted
| 41 | 3,316 | 218 |
N,A,B = (int(i) for i in input().split())
total = 0
for i in range(1,N+1):
s = str(i)
num = 0
for j in range(len(s)):
num += int(s[j])
if num <= B and num >= A:
total += i
print(total)
|
s918034763
|
p03555
|
u516272298
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 135 |
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 = list(str(input()))
e = list(str(input()))
if a[0] == e[2] and a[1] == e[1] and a[2] == e[0]:
print("Yes")
else:
print("No")
|
s402217860
|
Accepted
| 17 | 2,940 | 89 |
a = str(input())
e = str(input())
if a == e[::-1]:
print("YES")
else:
print("NO")
|
s120467688
|
p03369
|
u668503853
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
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 three characters long, and if the first character in S is `o`, it means the ramen should be topped with boiled egg; if that character is `x`, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen.
|
s=input()
print(500 + s.count("o")*100)
|
s002790347
|
Accepted
| 17 | 2,940 | 40 |
s=input()
print(700 + s.count("o")*100)
|
s174077606
|
p04043
|
u167140942
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 157 |
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,b,c = map(int,input().split())
if (a == 5 or a == 7) and (b == 5 or b == 7) and (c == 5 or c == 7) and a + b + c == 17:
print("Yes")
else:
print("No")
|
s955916602
|
Accepted
| 17 | 3,064 | 157 |
a,b,c = map(int,input().split())
if (a == 5 or a == 7) and (b == 5 or b == 7) and (c == 5 or c == 7) and a + b + c == 17:
print("YES")
else:
print("NO")
|
s146599067
|
p03731
|
u768816323
| 2,000 | 262,144 |
Wrong Answer
| 161 | 26,708 | 183 |
In a public bath, there is a shower which emits water for T seconds when the switch is pushed. If the switch is pushed when the shower is already emitting water, from that moment it will be emitting water for T seconds. Note that it does not mean that the shower emits water for T additional seconds. N people will push the switch while passing by the shower. The i-th person will push the switch t_i seconds after the first person pushes it. How long will the shower emit water in total?
|
N, Y = map(int, input().split())
t = list(int (i) for i in input().split())
w=0
for i in range(len(t)-1):
if t[i+1]-t[i]<=Y:
w+=t[i+1]-t[i]
else:
w+=Y
print(w)
|
s051098637
|
Accepted
| 161 | 26,832 | 188 |
N, Y = map(int, input().split())
t = list(int (i) for i in input().split())
w=0
for i in range(len(t)-1):
if t[i+1]-t[i]<=Y:
w+=t[i+1]-t[i]
else:
w+=Y
w+=Y
print(w)
|
s241987227
|
p03644
|
u172393892
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 317 |
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
|
n = int(input())
ans = 0
count = 0
best = 0
for i in range(n, 0, -1):
count = 0
x = i
while True:
if x % 2 == 0:
count += 1
x = x / 2
else:
break
if count > best:
best = count
ans = i
if count == 0:
ans = i
print(ans)
|
s127217403
|
Accepted
| 17 | 3,060 | 316 |
n = int(input())
ans = 0
count = 0
best = 0
for i in range(n, 0, -1):
count = 0
x = i
while True:
if x % 2 == 0:
count += 1
x = x / 2
else:
break
if count > best:
best = count
ans = i
if ans == 0:
ans = 1
print(ans)
|
s156988236
|
p01131
|
u024384030
| 8,000 | 131,072 |
Wrong Answer
| 30 | 6,248 | 413 |
Alice さんは Miku さんに携帯電話でメールを送ろうとしている。 携帯電話には入力に使えるボタンは数字のボタンしかない。 そこで、文字の入力をするために数字ボタンを何度か押して文字の入力を行う。携帯電話の数字ボタンには、次の文字が割り当てられており、ボタン 0 は確定ボタンが割り当てられている。この携帯電話では 1 文字の入力が終わったら必ず確定ボタンを押すことになっている。 * 1: . , ! ? (スペース) * 2: a b c * 3: d e f * 4: g h i * 5: j k l * 6: m n o * 7: p q r s * 8: t u v * 9: w x y z * 0: 確定ボタン 例えば、ボタン 2、ボタン 2、ボタン 0 と押すと、文字が 'a' → 'b' と変化し、ここで確定ボタンが押されるので、文字 b が出力される。 同じ数字を続けて入力すると変化する文字はループする。すなわち、ボタン 2 を 5 回押して、次にボタン 0 を押すと、文字が 'a' → 'b' → 'c' → 'a' → 'b' と変化し、ここで確定ボタンを押されるから 'b' が出力される。 何もボタンが押されていないときに確定ボタンを押すことはできるが、その場合には何も文字は出力されない。 あなたの仕事は、Alice さんが押したボタンの列から、Alice さんが作ったメッセージを再現することである。
|
d = {'1': ['.', ',', '!', '?', ' '], '2': ['a', 'b', 'c'], '3': ['d', 'e', 'f'], '4': ['g', 'h', 'i'], '5': ['j', 'k', 'l'], '6': ['m', 'n', 'o'], '7': ['p', 'q', 'r', 's'], '8': ['t', 'u', 'v'], '9': ['w', 'x', 'y', 'z']}
n = int(input())
m = [input() for i in range(n)]
for mm in m:
l = [x for x in mm.split('0') if not x == '']
for x in l:
print(d[x[0]][len(x)%len(d[x[0]]) - 1])
print()
|
s285054434
|
Accepted
| 40 | 6,516 | 421 |
d = {'1': ['.', ',', '!', '?', ' '], '2': ['a', 'b', 'c'], '3': ['d', 'e', 'f'], '4': ['g', 'h', 'i'], '5': ['j', 'k', 'l'], '6': ['m', 'n', 'o'], '7': ['p', 'q', 'r', 's'], '8': ['t', 'u', 'v'], '9': ['w', 'x', 'y', 'z']}
n = int(input())
m = [input() for i in range(n)]
for mm in m:
l = [x for x in mm.split('0') if not x == '']
for x in l:
print(d[x[0]][len(x)%len(d[x[0]]) - 1], end='')
print()
|
s049912535
|
p02697
|
u116233709
| 2,000 | 1,048,576 |
Wrong Answer
| 73 | 9,304 | 112 |
You are going to hold a competition of one-to-one game called AtCoder Janken. _(Janken is the Japanese name for Rock-paper-scissors.)_ N players will participate in this competition, and they are given distinct integers from 1 through N. The arena has M playing fields for two players. You need to assign each playing field two distinct integers between 1 and N (inclusive). You cannot assign the same integer to multiple playing fields. The competition consists of N rounds, each of which proceeds as follows: * For each player, if there is a playing field that is assigned the player's integer, the player goes to that field and fight the other player who comes there. * Then, each player adds 1 to its integer. If it becomes N+1, change it to 1. You want to ensure that no player fights the same opponent more than once during the N rounds. Print an assignment of integers to the playing fields satisfying this condition. It can be proved that such an assignment always exists under the constraints given.
|
n,m=map(int,input().split())
if m==1:
print(1,2)
else:
for i in range(1,m+1):
print(i,m*2-i+1)
|
s918576625
|
Accepted
| 82 | 9,280 | 127 |
n,m=map(int,input().split())
l=m//2
for i in range(l):
print(1+i,1+2*l-i)
for j in range(m-l):
print(1+2*l+1+j,2*m+1-j)
|
s829657749
|
p03024
|
u948618130
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 117 |
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament. The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day. Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.
|
N = input()
num = 0
for i in N:
if i == 'x':
num += 1
if num >= 8:
print('No')
else:
print('Yes')
|
s021888043
|
Accepted
| 17 | 2,940 | 117 |
N = input()
num = 0
for i in N:
if i == 'x':
num += 1
if num >= 8:
print('NO')
else:
print('YES')
|
s378295966
|
p03605
|
u979554218
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 39 |
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?
|
print(sum([c == '9' for c in input()]))
|
s457025881
|
Accepted
| 19 | 2,940 | 75 |
if [1 for c in input() if c == '9']:
print('Yes')
else:
print('No')
|
s590478090
|
p04043
|
u039360403
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 81 |
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
|
a=input().split()
print('YES' if a.count('5')==1 and a.count('7')==2 else 'NO')
|
s155156831
|
Accepted
| 17 | 2,940 | 81 |
a=input().split()
print('YES' if a.count('5')==2 and a.count('7')==1 else 'NO')
|
s172002263
|
p04031
|
u021759654
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 179 |
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.
|
n = int(input())
a_list = list(map(int, input().split()))
b = sum(a_list)//n
ans1 = sum([(a-b)^2 for a in a_list])
ans2 = sum([(a-b-1)^2 for a in a_list])
print(min(ans1,ans2))
|
s735542258
|
Accepted
| 17 | 3,060 | 189 |
n = int(input())
a_list = list(map(int, input().split()))
b = sum(a_list) // n
ans1 = sum([(a-b)**2 for a in a_list])
b += 1
ans2 = sum([(a-b)**2 for a in a_list])
print(min(ans1,ans2))
|
s615079313
|
p03623
|
u873269440
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 82 |
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('A' if abs(x-a) < abs(x-b) else print('B'))
|
s790628029
|
Accepted
| 17 | 2,940 | 75 |
x,a,b = map(int,input().split())
print('A' if abs(x-a) < abs(x-b) else 'B')
|
s776633773
|
p03673
|
u527261492
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 281 |
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=6
a=[0,6,7,6,7,0]
b=[]
if n%2==0:
for i in range(n-1,0,-2):
b.append(a[i])
for j in range(0,n-1,2):
b.append(a[j])
print(b)
else:
for i in range(n-1,-1,-2):
b.append(a[i])
for j in range(1,n-1,2):
b.append(a[i])
print(b)
|
s319772724
|
Accepted
| 187 | 26,020 | 312 |
n=int(input())
a=list(map(int,input().split()))
b=[]
if n%2==0:
for i in range(n-1,0,-2):
b.append(a[i])
for j in range(0,n-1,2):
b.append(a[j])
print(*b)
else:
for i in range(n-1,-1,-2):
b.append(a[i])
for j in range(1,n-1,2):
b.append(a[j])
print(*b)
|
s690162511
|
p03543
|
u864453204
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 303 |
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**?
|
x=input(int)
x=str(x)
if x[0]==x[1]:
if x[1]==x[2]:
print("Yes")
elif x[1]!=x[2]:
print("No")
elif x[0]!=x[1]:
if x[1]==x[2]:
if x[2]==x[3]:
print("Yes")
elif x[2]!=x[3]:
print("No")
elif x[1]!=x[2]:
print("No")
|
s272806440
|
Accepted
| 17 | 3,060 | 296 |
x=str(input())
if x[0]==x[1]:
if x[1]==x[2]:
print("Yes")
elif x[1]!=x[2]:
print("No")
elif x[0]!=x[1]:
if x[1]==x[2]:
if x[2]==x[3]:
print("Yes")
elif x[2]!=x[3]:
print("No")
elif x[1]!=x[2]:
print("No")
|
s869848152
|
p03555
|
u950708010
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 131 |
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.
|
from sys import stdin
a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
if b[::-1] == a:
print('Yes')
else:
print('No')
|
s073962820
|
Accepted
| 18 | 2,940 | 147 |
from sys import stdin
a = stdin.readline().rstrip()
b = stdin.readline().rstrip()
if b[::-1] == a and a[::-1] ==b:
print('YES')
else:
print('NO')
|
s318409356
|
p03352
|
u113971909
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 55 |
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.
|
a=int(input())
import math
b=int(math.sqrt(a))
print(b)
|
s799362168
|
Accepted
| 17 | 2,940 | 188 |
X = int(input())
if X != 1:
A =[]
for b in range(1,int(X**0.5)+1):
for p in range(2,X):
if b**p > X:
A.append(b**(p-1))
break
print(max(A))
else:
print(1)
|
s652071204
|
p03673
|
u919633157
| 2,000 | 262,144 |
Wrong Answer
| 179 | 26,172 | 199 |
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=list(input().split())
even,odd=[],[]
for i in range(n):
if i%2==0:even+=[a[i]]
else:odd+=[a[i]]
if n%2==0:print(*odd[::-1]+even,sep='')
else:print(*even[::-1]+odd,sep='')
|
s878442383
|
Accepted
| 177 | 24,516 | 178 |
from collections import deque
n=int(input())
a=list(input().split())
que=deque()
for i in range(n):
if n%2==i%2:que.append(a[i])
else:que.appendleft(a[i])
print(*que)
|
s730526273
|
p03455
|
u506549878
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 90 |
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
n, m = map(int, input().split())
if (n*m)%2 == 2:
print('Even')
else:
print('Odd')
|
s408362764
|
Accepted
| 17 | 2,940 | 84 |
k, s = map(int, input().split())
if (k*s)%2==0:
print('Even')
else:
print('Odd')
|
s673445631
|
p03139
|
u075155299
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 106 |
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
|
n,a,b=map(int,input().split())
m=0
s=0
if a>b:
m=a
else:
m=b
if a+b>n:
s=a+b-n
print(m,s)
|
s201883194
|
Accepted
| 17 | 2,940 | 107 |
n,a,b=map(int,input().split())
m=0
s=0
if a<b:
m=a
else:
m=b
if a+b>n:
s=a+b-n
print(m,s)
|
s337870341
|
p03351
|
u533679935
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 2,940 | 91 |
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
|
a,b,c,d=map(int,input().split())
if a-b <d or a-c <d:
print('yes')
else:
print('No')
|
s217219551
|
Accepted
| 17 | 2,940 | 123 |
a,b,c,d=map(int,input().split())
if abs(a-b) <= d and abs(b-c) <= d or abs(a-c) <= d:
print('Yes')
else:
print('No')
|
s919388670
|
p03657
|
u800610991
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 141 |
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())
#print(a,b)
c = 0
if a/3 == 0 or b/3 == 0 or (a+b)/3 ==0:
print('Possible')
else:
print('Impossible')
|
s513401818
|
Accepted
| 17 | 2,940 | 142 |
a,b = map(int,input().split())
#print(a,b)
#c = 0
if a%3 == 0 or b%3 == 0 or (a+b)%3 ==0:
print('Possible')
else:
print('Impossible')
|
s093722545
|
p03447
|
u279493135
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 73 |
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*(X-a)//b)
|
s896205899
|
Accepted
| 17 | 2,940 | 72 |
X = int(input())
a = int(input())
b = int(input())
print(X-a-(X-a)//b*b)
|
s479413526
|
p02393
|
u027634846
| 1,000 | 131,072 |
Wrong Answer
| 30 | 7,516 | 59 |
Write a program which reads three integers, and prints them in ascending order.
|
num = list(map(int, input().split()))
num.sort()
print(num)
|
s856572635
|
Accepted
| 20 | 7,644 | 78 |
num = list(map(int, input().split()))
num.sort()
print(' '.join(map(str,num)))
|
s379694057
|
p03943
|
u373529207
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 111 |
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.
|
v = list(map(int, input().split()))
v = sorted(v)
if v[0]+v[1] == v[2]:
print("YES")
else:
print("NO")
|
s381582183
|
Accepted
| 17 | 2,940 | 111 |
v = list(map(int, input().split()))
v = sorted(v)
if v[0]+v[1] == v[2]:
print("Yes")
else:
print("No")
|
s958002514
|
p03473
|
u580362735
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 28 |
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
|
M = int(input())
print(24-M)
|
s470349977
|
Accepted
| 17 | 2,940 | 30 |
M = int(input())
print(48 - M)
|
s727574751
|
p03943
|
u395894569
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 97 |
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 or b+c==a or a+c==b:
print('YES')
else:
print('NO')
|
s270226415
|
Accepted
| 17 | 2,940 | 97 |
a,b,c=map(int,input().split())
if a+b==c or b+c==a or a+c==b:
print('Yes')
else:
print('No')
|
s569664005
|
p03386
|
u002459665
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,064 | 593 |
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.
|
def main():
a, b, k = map(int, input().split())
ans = set()
for i in range(k):
x = a + i
if x <= b:
ans.add(x)
y = b - i
if a <= y:
ans.add(y)
for i in sorted(list(ans)):
print(i)
def main2():
a, b, k = map(int, input().split())
ans = []
if 2 * k < b - a + 1:
for i in range(k):
ans.append(a + i)
ans.append(b - i)
else:
for i in range(a, b + 1):
ans.append(i)
for i in ans:
print(i)
if __name__ == '__main__':
main2()
|
s880236904
|
Accepted
| 19 | 3,064 | 601 |
def main():
a, b, k = map(int, input().split())
ans = set()
for i in range(k):
x = a + i
if x <= b:
ans.add(x)
y = b - i
if a <= y:
ans.add(y)
for i in sorted(list(ans)):
print(i)
def main2():
a, b, k = map(int, input().split())
ans = []
if 2 * k >= b - a + 1:
for i in range(a, b + 1):
ans.append(i)
else:
for i in range(k):
ans.append(a + i)
ans.append(b - i)
for i in sorted(ans):
print(i)
if __name__ == '__main__':
main2()
|
s591086308
|
p03474
|
u934788990
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,060 | 162 |
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen `-`, and the other characters are digits from `0` through `9`. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom.
|
a,b=map(int,input().split())
s = input()
if len(s)==a+b+1 and s[a] == '-' and s[a:]=="0123456789" and s[:b]=="0123456789":
print('Yes')
else:
print('No')
|
s499977963
|
Accepted
| 19 | 2,940 | 167 |
a,b=map(int,input().split())
p=input()
frag=True
if len(p)!=a+b+1 or p.count("-")!=1:
frag=False
if p[a]!="-":
frag=False
print("Yes" if frag==True else "No")
|
s906583834
|
p03448
|
u668503853
| 2,000 | 262,144 |
Wrong Answer
| 53 | 3,060 | 207 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans= 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
s = 500*i + 100*j + 50*j
if s==x:
ans+=1
print(ans)
|
s838458650
|
Accepted
| 55 | 3,064 | 208 |
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans= 0
for i in range(a+1):
for j in range(b+1):
for k in range(c+1):
s = 500*i + 100*j + 50*k
if s==x:
ans+=1
print(ans)
|
s113826166
|
p03434
|
u564368158
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 167 |
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
|
n = int(input())
a = list(map(int, input().split()))
a.sort()
x = y = 0
for i, j in enumerate(a):
if i%2 == 0:
x += j
else:
y += j
print(x - y)
|
s199558425
|
Accepted
| 17 | 2,940 | 181 |
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
x = y = 0
for i, j in enumerate(a):
if i%2 == 0:
x += j
else:
y += j
print(x - y)
|
s522277015
|
p02831
|
u419963262
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 3,064 | 302 |
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.
|
def gcd(a,b):
x=int(max(a,b))
y=int(min(a,b))
if x%y==0:
return y
else:
while x%y!=0:
z=x%y
x=y
y=z
else:
return z
a,b = map(int, input().split())
if a<b:
L=a
S=b
print((a*b)/gcd(L,S))
elif a>b:
L=b
S=a
print((a*b)/gcd(L,S))
else:
print(a)
|
s251990111
|
Accepted
| 17 | 3,060 | 191 |
def GCD(a,b):
c=b//a
d=b%a
if d==0:
return a
else:
return GCD(d,a)
A,B=map(int,input().split())
if A>B:
a=A
b=B
else:
a=B
b=A
print(int(a*b/GCD(a,b)))
|
s141884632
|
p03693
|
u607074939
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 99 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
r , g , b = map(int, input().split())
s = 10*g+b
if(s%4==0):
print("Yes")
else:
print("No")
|
s242656300
|
Accepted
| 17 | 2,940 | 99 |
r , g , b = map(int, input().split())
s = 10*g+b
if(s%4==0):
print("YES")
else:
print("NO")
|
s332219345
|
p03563
|
u322422986
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 117 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
n = int(input())
k = int(input())
v = 1
for i in range(n):
if 2*v < v + k:
v = 2*v
else:
v = v+k
print(v)
|
s323777981
|
Accepted
| 18 | 2,940 | 54 |
old = int(input())
new = int(input())
print(2*new-old)
|
s493209381
|
p03044
|
u556589653
| 2,000 | 1,048,576 |
Wrong Answer
| 640 | 49,404 | 435 |
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.
|
from collections import deque
N = int(input())
g = [[] for i in range(N)]
for i in range(N-1):
u,v,w = map(int,input().split())
g[u-1].append([v-1,w])
g[v-1].append([u-1,w])
q = deque([])
ans = [-1] * N
q.append(0)
while len(q) > 0:
e = q.popleft()
for i in g[e]:
if ans[i[0]] > -1:
continue
ans[i[0]] += i[1]
q.append(i[0])
for i in range(len(ans)):
if ans[i]%2 == 1:
print(1)
continue
print(0)
|
s035843373
|
Accepted
| 782 | 46,740 | 488 |
from collections import deque
N = int(input())
g = [[] for i in range(N)]
for i in range(N-1):
u,v,w = map(int,input().split())
g[u-1].append([v-1,w])
g[v-1].append([u-1,w])
q = deque()
check = [0] * N
check[0] = 1
q.append(0)
ans = [-1] * N
ans[0] = 0
while len(q) > 0:
e = q.popleft()
for i,j in g[e]:
if check[i] == 1:
continue
ans[i] = (ans[e] + j) %2
check[i] = 1
q.append(i)
for i in range(N):
print(ans[i])
|
s695195102
|
p03502
|
u813238682
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 223 |
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number.
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(input())
n = N
sumup = 0
while N != 0:
print(N % 10)
sumup += (N % 10)
N = N // 10
if n % sumup == 0:
print('Yes')
else:
print('No')
|
s671986259
|
Accepted
| 17 | 2,940 | 224 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N = int(input())
n = N
sumup = 0
while N != 0:
#print(N % 10)
sumup += (N % 10)
N = N // 10
if n % sumup == 0:
print('Yes')
else:
print('No')
|
s045583128
|
p03469
|
u629350026
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 44 |
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.
|
ds=str(input())
ds=ds.replace("2017","2018")
|
s987487040
|
Accepted
| 17 | 2,940 | 54 |
ds=str(input())
ds=ds.replace("2017","2018")
print(ds)
|
s119416590
|
p03494
|
u270962921
| 2,000 | 262,144 |
Time Limit Exceeded
| 2,108 | 3,060 | 234 |
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.
|
import math
N = int(input())
a = list(map(int, input().split()))
number = 0
sign = True
while sign:
for x in a:
if x % 2 != 0:
sign = False
print(number)
break
else:
pass
number += 1
|
s498359011
|
Accepted
| 19 | 3,060 | 235 |
import math
N = int(input())
a = list(map(int, input().split()))
number = 0
sign = True
while sign:
for i in range(N):
if a[i] % 2 != 0:
sign = False
print(number)
break
else:
a[i] /= 2
number += 1
|
s699542103
|
p03394
|
u532966492
| 2,000 | 262,144 |
Wrong Answer
| 156 | 7,036 | 346 |
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.
|
def main():
from fractions import gcd
n=int(input())
for i in range(n-2):
n_2=n-2-i
n_3=i+1
wa=n_2*2+n_3*3
print(n_2,n_3,wa)
for j in range(1,30000):
if (n_3*3+j)%2==0 and (n_2*2+j)%3==0 and gcd(wa,j)>=2:
print(*([2]*n_2+[3]*n_3+[j]))
return 0
main()
|
s921441984
|
Accepted
| 40 | 4,560 | 779 |
def main():
n=int(input())
if n==3:
print(2,5,63)
return 0
ans=[2,3]
cnt=0
i=10
while cnt<n-4:
if i%2==0 or i%3==0:
ans.append(i)
cnt+=1
i+=1
a=sum(ans)
if n==20000:
ans.pop()
ans.pop()
ans.append(8)
ans.append(9)
elif n==19999:
ans.pop()
ans.append(8)
if a%6==0:
ans.append(4)
ans.append(8)
elif a%6==1:
ans.append(8)
ans.append(9)
elif a%6==2:
ans.append(4)
ans.append(6)
elif a%6==3:
ans.append(6)
ans.append(9)
elif a%6==4:
ans.append(8)
ans.append(6)
elif a%6==5:
ans.append(9)
ans.append(4)
print(*ans)
main()
|
s472258796
|
p00100
|
u661290476
| 1,000 | 131,072 |
Wrong Answer
| 40 | 8,120 | 333 |
There is data on sales of your company. Your task is to write a program which identifies good workers. The program should read a list of data where each item includes the employee ID _i_ , the amount of sales _q_ and the corresponding unit price _p_. Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p × q) is greater than or equal to 1,000,000 in the order of inputting. If there is no such employees, the program should print "NA". You can suppose that _n_ < 4000, and each employee has an unique ID. The unit price _p_ is less than or equal to 1,000,000 and the amount of sales _q_ is less than or equal to 100,000.
|
from collections import defaultdict as dd
while True:
n=int(input())
if n==0:
break
data=dd(int)
for i in range(n):
a,b,c=map(int,input().split())
data[a]+=b*c
f=False
for i,j in data.items():
if j>=1000000:
print(i)
f=True
if f:
print("NA")
|
s378250559
|
Accepted
| 30 | 7,812 | 331 |
while True:
n = int(input())
if n == 0:
break
emp = [0] * 4001
used = set()
for i in range(n):
e, p, q = map(int, input().split())
emp[e] += p * q
if 1000000 <= emp[e] and e not in used:
print(e)
used.add(e)
if len(used) == 0:
print("NA")
|
s122235574
|
p03555
|
u015318452
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,064 | 826 |
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 math
def A():
a, b = [int(x) for x in input().split()]
print(math.ceil((a + b)/2))
def B():
a = ''.join(sorted(list(input()), key=lambda x:ord(x)))
b = ''.join(sorted(list(input()), key=lambda x:-ord(x)))
if a < b:
print('Yes')
else:
print('No')
def C():
N = input()
A = [x for x in input().split()]
counter = {}
for a in A:
if(a in counter):
counter[a] += 1
else:
counter[a] = 1
remove_count = 0
for key in counter:
if counter[key] - int(key) >= 0:
remove_count += counter[key] - int(key)
else:
remove_count += counter[key]
print(remove_count)
def E():
s1 = input()
s2 = input()
if s1 == s2[::-1]:
print('Yes')
else:
print('No')
E()
|
s050360100
|
Accepted
| 17 | 3,064 | 826 |
import math
def A():
a, b = [int(x) for x in input().split()]
print(math.ceil((a + b)/2))
def B():
a = ''.join(sorted(list(input()), key=lambda x:ord(x)))
b = ''.join(sorted(list(input()), key=lambda x:-ord(x)))
if a < b:
print('Yes')
else:
print('No')
def C():
N = input()
A = [x for x in input().split()]
counter = {}
for a in A:
if(a in counter):
counter[a] += 1
else:
counter[a] = 1
remove_count = 0
for key in counter:
if counter[key] - int(key) >= 0:
remove_count += counter[key] - int(key)
else:
remove_count += counter[key]
print(remove_count)
def E():
s1 = input()
s2 = input()
if s1 == s2[::-1]:
print('YES')
else:
print('NO')
E()
|
s942059554
|
p03486
|
u126823513
| 2,000 | 262,144 |
Wrong Answer
| 18 | 3,060 | 187 |
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.
|
str_s = input()
str_t = input()
str_s_d = sorted(str_s)
str_t_d = sorted(str_t, reverse=True)
print(str_s_d)
print(str_t_d)
if str_s_d < str_t_d:
print("Yes")
else:
print("No")
|
s124194794
|
Accepted
| 17 | 2,940 | 156 |
str_s = input()
str_t = input()
str_s_d = sorted(str_s)
str_t_d = sorted(str_t, reverse=True)
if str_s_d < str_t_d:
print("Yes")
else:
print("No")
|
s569354353
|
p03448
|
u226179530
| 2,000 | 262,144 |
Wrong Answer
| 21 | 3,316 | 904 |
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
|
import re
import sys
def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
def check(x, a, b, c):
diff = x - 500 * a - 100 * b
if diff >= 0 and diff % 50 == 0 and diff // 50 <= c:
print(a,b,diff // 50)
return True
else:
return False
def main():
a = i_input() # 500
b = i_input() # 100
c = i_input() # 50
x = i_input() # sum
count = 0
for i in range(a + 1):
for j in range(b + 1):
if check(x, i, j, c):
count += 1
print(count)
if __name__ == "__main__":
main()
|
s257186767
|
Accepted
| 20 | 3,188 | 874 |
import re
import sys
def i_input(): return int(input())
def s_input(): return map(int,input().split())
def l_input(): return list(map(int, input().split()))
def check(x, a, b, c):
diff = x - 500 * a - 100 * b
if diff >= 0 and diff % 50 == 0 and diff // 50 <= c:
return True
else:
return False
def main():
a = i_input() # 500
b = i_input() # 100
c = i_input() # 50
x = i_input() # sum
count = 0
for i in range(a + 1):
for j in range(b + 1):
if check(x, i, j, c):
count += 1
print(count)
if __name__ == "__main__":
main()
|
s538300648
|
p02747
|
u978640776
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 281 |
A Hitachi string is a concatenation of one or more copies of the string `hi`. For example, `hi` and `hihi` are Hitachi strings, while `ha` and `hii` are not. Given a string S, determine whether S is a Hitachi string.
|
a = list(map(str, input().split()))
num = len(a)
TorF = True
if num % 2 == 0:
for i in range(num/2):
if not a(2*i ) == 'h' and a(2*i + 1) == 'i':
TorF = False
break
else:
TorF = False
if TorF == True:
print('Yes')
else:
print('No')
|
s413206423
|
Accepted
| 17 | 3,060 | 285 |
a = input()
l = list(a)
num = len(l)
TorF = True
if num % 2 == 0:
b = int(num/2)
for i in range(b):
if not (a[2*i] == 'h' and a[2*i + 1] == 'i'):
TorF = False
break
else:
TorF = False
if TorF == True:
print('Yes')
else:
print('No')
|
s683008699
|
p02261
|
u938045879
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,612 | 942 |
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
|
def bubbleSort(c, n):
flag = 1
while(flag) :
flag = 0
for i in reversed(range(1,n)):
if(c[i][1] < c[i-1][1]):
c[i], c[i-1] = c[i-1], c[i]
flag = 1
return c
def selectionSort(c,n):
for i in range(n):
minj = i
for j in range(i, n):
if(c[j][1] < c[minj][1]):
minj = j
c[i], c[minj] = c[minj], c[i]
return c
def isStable(c1, c2, n):
for i in range(n):
if(c1[i] != c2[i]):
return False
return True
n = int(input())
c = input().split(' ')
trump = [list(i) for i in c]
bubble = ["".join(s) for s in bubbleSort(trump, n)]
selection = ["".join(s) for s in selectionSort(trump, n)]
str_bubble = " ".join(bubble)
str_selection = " ".join(selection)
print(str_bubble)
print('Stable')
print(str_selection)
if isStable(bubble, selection, n):
print('Stable')
else:
print('Not stable')
|
s000307452
|
Accepted
| 20 | 5,612 | 971 |
def bubbleSort(c, n):
flag = 1
while(flag) :
flag = 0
for i in reversed(range(1,n)):
if(c[i][1] < c[i-1][1]):
c[i], c[i-1] = c[i-1], c[i]
flag = 1
return c
def selectionSort(c,n):
for i in range(n):
minj = i
for j in range(i, n):
if(c[j][1] < c[minj][1]):
minj = j
c[i], c[minj] = c[minj], c[i]
return c
def isStable(c1, c2, n):
for i in range(n):
if(c1[i] != c2[i]):
return False
return True
n = int(input())
c = input().split(' ')
trump = [list(i) for i in c]
bubble = ["".join(s) for s in bubbleSort(trump, n)]
trump = [list(i) for i in c]
selection = ["".join(s) for s in selectionSort(trump, n)]
str_bubble = " ".join(bubble)
str_selection = " ".join(selection)
print(str_bubble)
print('Stable')
print(str_selection)
if isStable(bubble, selection, n):
print('Stable')
else:
print('Not stable')
|
s270423938
|
p03574
|
u859897687
| 2,000 | 262,144 |
Wrong Answer
| 25 | 3,064 | 378 |
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 containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process.
|
h,w=map(int,input().split())
m=[[0for _ in range(w+2)]for _ in range(h+2)]
for y in range(h):
s=input()
for x in range(w):
if s[x]=="#":
for i in [-1,0,1]:
for j in [-1,0,1]:
m[y+j][x+i]+=1
m[y+1][x+1]=9
for y in range(1,h+1):
ans=""
for x in range(1,w+1):
if m[y][x]>9:
ans+="#"
else:
ans+=str(m[y][x])
print(ans)
|
s804692267
|
Accepted
| 24 | 3,064 | 376 |
h,w=map(int,input().split())
m=[[0for _ in range(w+2)]for _ in range(h+2)]
for y in range(h):
s=input()
for x in range(w):
if s[x]=="#":
for i in [0,1,2]:
for j in [0,1,2]:
m[y+j][x+i]+=1
m[y+1][x+1]=9
for y in range(1,h+1):
ans=""
for x in range(1,w+1):
if m[y][x]>8:
ans+="#"
else:
ans+=str(m[y][x])
print(ans)
|
s835301822
|
p02398
|
u316246166
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,580 | 101 |
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
|
a, b, c = map(int, input().split())
x = 0
while a > b:
if c % a == 0:
x = x + 1
|
s299114426
|
Accepted
| 20 | 5,596 | 117 |
a, b, c = map(int, input().split())
x = 0
for i in range(a, b+1):
if c % i == 0:
x += 1
print(x)
|
s843064329
|
p04043
|
u255595446
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 158 |
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.
|
N = list(map(int,input().split()))
if 7 in N:
N.remove(7)
if 5 in N:
if sum(N) == 10:
print("Yes")
exit()
print("No")
|
s843611418
|
Accepted
| 17 | 2,940 | 253 |
import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
# N = list(map(int,input().split()))
N = list(map(int,input().split()))
N.sort()
if sum(N)==17 and int(N[0]) == int(N[1]) == 5:
print('YES')
else:
print("NO")
|
s658938868
|
p03407
|
u561828236
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 86 |
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
|
a,b,c = map(int,input().split())
if a + b <= c:
print("Yes")
else:
print("No")
|
s493909816
|
Accepted
| 17 | 2,940 | 87 |
a,b,c = map(int,input().split())
if a + b >= c:
print("Yes")
else:
print("No")
|
s793635312
|
p03605
|
u752552310
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 74 |
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
n = input()
if n[0] == 9 or n[1] == 9:
prnit("Yes")
else:
print("No")
|
s728501481
|
Accepted
| 17 | 2,940 | 79 |
n = input()
if n[0] == "9" or n[1] == "9":
print("Yes")
else:
print("No")
|
s342563921
|
p03693
|
u095756391
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
|
a, g, b = map(int, input().split())
num = a*100 + g*10 + b
if num % 4 == 0:
print('Yes')
else:
print('No')
|
s499078975
|
Accepted
| 17 | 2,940 | 113 |
r, g, b = map(int, input().split())
num = r*100 + g*10 + b
if num % 4 == 0:
print('YES')
else:
print('NO')
|
s236232907
|
p03563
|
u966000628
| 2,000 | 262,144 |
Wrong Answer
| 18 | 2,940 | 112 |
Takahashi is a user of a site that hosts programming contests. When a user competes in a contest, the _rating_ of the user (not necessarily an integer) changes according to the _performance_ of the user, as follows: * Let the current rating of the user be a. * Suppose that the performance of the user in the contest is b. * Then, the new rating of the user will be the avarage of a and b. For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000. Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest. Find the performance required to achieve it.
|
N = int(input())
K = int(input())
i = 1
for num in range(N):
if i < K:
i *= 2
else:
i += K
print (i)
|
s041045769
|
Accepted
| 28 | 3,316 | 49 |
R = int(input())
G = int(input())
print (2*G - R)
|
s803996645
|
p03798
|
u619458041
| 2,000 | 262,144 |
Wrong Answer
| 74 | 4,312 | 3,071 |
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
|
import sys
def make_pos(pos, S):
N = len(S)
for i in range(1, N-1):
if pos[i] == 'S':
if S[i] == 'o':
pos[i+1] = pos[i-1]
else:
if pos[i-1] == 'S':
pos[i+1] = 'W'
else:
pos[i+1] = 'S'
else:
if S[i] == 'o':
if pos[i-1] == 'S':
pos[i+1] = 'W'
else:
pos[i+1] = 'S'
else:
pos[i+1] = pos[i-1]
if pos[0] == 'S':
if S[0] == 'o':
if pos[1] == pos[N-1]:
return pos
else:
return False
else:
if pos[1] != pos[N-1]:
return pos
else:
return False
else:
if S[0] == 'o':
if pos[1] != pos[N-1]:
return pos
else:
return False
def main():
input = sys.stdin.readline
N = int(input())
S = str(input().strip())
if S[0] == 'o':
# Case 1 pos 0 is Sheep and neighbors are Wolves.
pos = [0 for _ in range(N)]
pos[0] = 'S'
pos[1] = 'W'
pos[N-1] = 'W'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 2: pos0 is Sheep ans neighbors are Sheeps.
pos = [0 for _ in range(N)]
pos[0] = 'S'
pos[1] = 'S'
pos[N-1] = 'S'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 3: pos0 is wolf and neibors are Sheep-Wolf.
pos = [0 for _ in range(N)]
pos[0] = 'W'
pos[1] = 'S'
pos[N-1] = 'W'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 4: pos0 is wolf and neibors are Wolf-Sheep.
pos = [0 for _ in range(N)]
pos[0] = 'W'
pos[1] = 'W'
pos[N-1] = 'S'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
else:
# Case 1 pos 0 is Sheep and neighbors are Sheep-Wolf.
pos = [0 for _ in range(N)]
pos[0] = 'S'
pos[1] = 'S'
pos[N-1] = 'W'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 2: pos0 is Sheep ans neighbors are Wolf-Sheep.
pos = [0 for _ in range(N)]
pos[0] = 'S'
pos[1] = 'W'
pos[N-1] = 'S'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 3: pos0 is wolf and neibors are Sheeps.
pos = [0 for _ in range(N)]
pos[0] = 'W'
pos[1] = 'S'
pos[N-1] = 'S'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
# Case 4: pos0 is wolf and neibors are Wolves.
pos = [0 for _ in range(N)]
pos[0] = 'W'
pos[1] = 'W'
pos[N-1] = 'W'
pos = make_pos(pos, S)
if pos:
return ''.join(pos)
return -1
if __name__ == '__main__':
print(main())
|
s555609488
|
Accepted
| 132 | 4,972 | 1,863 |
import sys
def check(pos, S, index):
N = len(S)
right = (index + 1) % N
left = (index + (N - 1)) % N
if pos[index] == 0:
if S[index] == 'o':
return pos[left] == pos[right]
else:
return pos[left] != pos[right]
else:
if S[index] == 'o':
return pos[left] != pos[right]
else:
return pos[left] == pos[right]
def make_pos(pos, S):
"""Sheep: 0, Wolf: 1"""
N = len(S)
for i in range(1, N-1):
if pos[i] == 0:
if S[i] == 'o':
pos[i+1] = pos[i-1]
else:
pos[i+1] = (pos[i-1] + 1) % 2
else:
if S[i] == 'o':
pos[i+1] = (pos[i-1] + 1) % 2
else:
pos[i+1] = pos[i-1]
if check(pos, S, 0) and check(pos, S, N-1):
return pos
else:
return False
def main():
input = sys.stdin.readline
N = int(input())
S = str(input().strip())
pos = [-1 for _ in range(N)]
pos[0] = 0
pos[1] = 0
pos = make_pos(pos, S)
if pos:
ans = ['S' if n == 0 else 'W' for n in pos]
return ''.join(ans)
pos = [-1 for _ in range(N)]
pos[0] = 0
pos[1] = 1
pos = make_pos(pos, S)
if pos:
ans = ['S' if n == 0 else 'W' for n in pos]
return ''.join(ans)
pos = [-1 for _ in range(N)]
pos[0] = 1
pos[1] = 0
pos = make_pos(pos, S)
if pos:
ans = ['S' if n == 0 else 'W' for n in pos]
return ''.join(ans)
pos = [-1 for _ in range(N)]
pos[0] = 1
pos[1] = 1
pos = make_pos(pos, S)
if pos:
ans = ['S' if n == 0 else 'W' for n in pos]
return ''.join(ans)
return -1
if __name__ == '__main__':
print(main())
|
s867674625
|
p03228
|
u002459665
| 2,000 | 1,048,576 |
Wrong Answer
| 18 | 3,060 | 301 |
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 = list(map(int, input().split()))
for i in range(K):
if i % 2 == 0:
if A % 2 == 1:
A -= 1
B += A // 2
A = A // 2
else:
if B % 2 == 1:
B -= 1
A += B // 2
B = B // 2
print(A, B)
|
s662056726
|
Accepted
| 17 | 3,060 | 297 |
A, B, K = list(map(int, input().split()))
for i in range(K):
if i % 2 == 0:
if A % 2 == 1:
A -= 1
B += A // 2
A = A // 2
else:
if B % 2 == 1:
B -= 1
A += B // 2
B = B // 2
print(A, B)
|
s858084576
|
p03079
|
u338208364
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 90 |
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
A,B,C = list(map(int, input().split()))
if A==B and B==C:
print("yes")
else:
print("No")
|
s328091871
|
Accepted
| 17 | 2,940 | 90 |
A,B,C = list(map(int, input().split()))
if A==B and B==C:
print("Yes")
else:
print("No")
|
s655186626
|
p03814
|
u368796742
| 2,000 | 262,144 |
Wrong Answer
| 41 | 4,840 | 158 |
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`.
|
l = list(input())
for i in range(len(l)):
if l[i] == "A":
a = i
break
for i in range(len(l)):
if l[-1-i] == "Z":
b = i
break
print(b-a+1)
|
s122746042
|
Accepted
| 41 | 4,840 | 164 |
l = list(input())
for i in range(len(l)):
if l[i] == "A":
a = i
break
for i in range(len(l)):
if l[-1-i] == "Z":
b = len(l)-i
break
print(b-a)
|
s829647281
|
p03854
|
u918373199
| 2,000 | 262,144 |
Wrong Answer
| 17 | 3,188 | 423 |
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()
flag = 0
while True:
if S.startswith("dream") or S.startswith("erase"):
S = S[5:]
if S.startswith("ase"):
S = S[3:]
if S.startswith("aser"):
S = S[4:]
if S.startswith("dreamer"):
S = S[7:]
if S.startswith("eraser"):
S = S[6:]
elif S == "":
break
else:
flag = 1
break
print("YES" if flag == 0 else "NO")
|
s390278825
|
Accepted
| 68 | 3,188 | 330 |
S = input()
flag = 0
S = S[::-1]
while True:
if S.startswith("maerd") or S.startswith("esare"):
S = S[5:]
elif S.startswith("remaerd"):
S = S[7:]
elif S.startswith("resare"):
S = S[6:]
elif S == "":
break
else:
flag = 1
break
print("YES" if flag == 0 else "NO")
|
s196183426
|
p03455
|
u321035578
| 2,000 | 262,144 |
Wrong Answer
| 31 | 9,092 | 85 |
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 == 0:
print('Odd')
else:
print('Even')
|
s050838394
|
Accepted
| 28 | 9,136 | 86 |
a,b = map(int,input().split())
if a*b % 2 == 1:
print('Odd')
else:
print('Even')
|
s829468066
|
p02255
|
u148477094
| 1,000 | 131,072 |
Wrong Answer
| 20 | 5,600 | 219 |
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 A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
|
N=int(input("N"))
A=[0]*N
A=input().split()
print(A)
for i in range(1,len(A)):
j = i
while (j > 0) and (A[j-1] > A[j]) :
tmp = A[j-1]
A[j-1] = A[j]
A[j] = tmp
j -= 1
print(A)
|
s676843102
|
Accepted
| 20 | 5,976 | 143 |
n=int(input())
a=input().split()
for i in range(n):
k=int(a[i])
j=i-1
while j>=0 and int(a[j])>k:
a[j+1]=a[j]
j-=1
a[j+1]=k
print(*a)
|
s825246273
|
p03997
|
u027675217
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 70 |
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))
|
s440602117
|
Accepted
| 17 | 2,940 | 70 |
a = int(input())
b = int(input())
h = int(input())
print(((a+b)*h)//2)
|
s843578330
|
p04030
|
u802963389
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 113 |
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
|
s = input()
ans = []
for i in s:
if i == "B":
if ans:
ans.pop()
else:
ans.append(i)
print(*ans)
|
s875531889
|
Accepted
| 19 | 3,060 | 98 |
s = input()
ans = ""
for i in s:
if i == "B":
ans = ans[:-1]
else:
ans += i
print(ans)
|
s051787155
|
p03478
|
u819135704
| 2,000 | 262,144 |
Wrong Answer
| 36 | 9,152 | 218 |
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())
def f(x):
sum = 0
while x > 0:
sum += x % 10
x //= 10
return sum
count = 0
for i in range(N):
if A <= f(i+1) <= B:
count += i
print(count)
|
s658706644
|
Accepted
| 32 | 8,932 | 220 |
N, A, B = map(int, input().split())
def f(x):
sum = 0
while x > 0:
sum += x % 10
x //= 10
return sum
count = 0
for i in range(N):
if A <= f(i+1) <= B:
count += i+1
print(count)
|
s989490087
|
p03401
|
u528470578
| 2,000 | 262,144 |
Wrong Answer
| 199 | 15,032 | 274 |
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
|
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
kane = []
for i in range(1, N+2):
kane.append(abs(A[i] - A[i-1]))
skane = sum(kane)
print(kane)
for i in range(1, N+1):
print(skane - kane[i-1] - kane[i] + abs(A[i+1] - A[i-1]))
|
s706454080
|
Accepted
| 196 | 14,048 | 261 |
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
kane = []
for i in range(1, N+2):
kane.append(abs(A[i] - A[i-1]))
skane = sum(kane)
for i in range(1, N+1):
print(skane - kane[i-1] - kane[i] + abs(A[i+1] - A[i-1]))
|
s218277192
|
p03457
|
u766486294
| 2,000 | 262,144 |
Wrong Answer
| 285 | 9,220 | 444 |
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.
|
# -*- coding: utf-8 -*-
import math
lastT, lastX, lastY = 0, 0, 0
flag = True
N = int(input())
for i in range(N):
t, x, y = map(int, input().split())
if ( t - lastT < math.fabs(x - lastX) + math.fabs(y - lastY)
or ( (t - lastT) - math.fabs(x - lastX) - math.fabs(y - lastY) ) % 2 == 1 ):
flag = False
lastT = t
lastX = x
lastY = y
print(flag)
|
s499796479
|
Accepted
| 273 | 9,104 | 444 |
# -*- coding: utf-8 -*-
import math
lastT, lastX, lastY = 0, 0, 0
flag = "Yes"
N = int(input())
for i in range(N):
t, x, y = map(int, input().split())
if ( t - lastT < math.fabs(x - lastX) + math.fabs(y - lastY)
or ( (t - lastT) - math.fabs(x - lastX) - math.fabs(y - lastY) ) % 2 == 1 ):
flag = "No"
lastT = t
lastX = x
lastY = y
print(flag)
|
s142545183
|
p03150
|
u227082700
| 2,000 | 1,048,576 |
Wrong Answer
| 17 | 2,940 | 131 |
A string is called a KEYENCE string when it can be changed to `keyence` by removing its contiguous substring (possibly empty) only once. Given a string S consisting of lowercase English letters, determine if S is a KEYENCE string.
|
s=input()
if "keyence" in s:exit(print("YES"))
for i in range(1,6):
if s[:i]+s[-(6-i):]=="keyence":exit(print("YES"))
print("NO")
|
s903228605
|
Accepted
| 23 | 2,940 | 154 |
s=input()
if "keyence"==s:exit(print("YES"))
for i in range(10):
for j in range(i,len(s)):
if s[:i]+s[j:]=="keyence":exit(print("YES"))
print("NO")
|
s462089482
|
p02694
|
u250554058
| 2,000 | 1,048,576 |
Wrong Answer
| 20 | 9,160 | 108 |
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())
num = 100
count = 0
while x == num:
num = num + (num // 100)
count += 1
print(count)
|
s380765873
|
Accepted
| 24 | 9,100 | 107 |
x = int(input())
num = 100
count = 0
while x > num:
num = num + (num // 100)
count += 1
print(count)
|
s449013590
|
p03478
|
u186542450
| 2,000 | 262,144 |
Wrong Answer
| 19 | 3,060 | 133 |
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())
i = 1
count = 0
for i in range(n+1):
if(a <= i and b >= i):
count += 1
print(count)
|
s281323711
|
Accepted
| 38 | 3,060 | 175 |
N, A, B = map(int, input().split())
sum_som = 0
for i in range(1, N + 1):
if A <= (sum(list(map(int, list(str(i)))))) <= B:
sum_som = sum_som + i
print(sum_som)
|
s641284215
|
p02612
|
u282652245
| 2,000 | 1,048,576 |
Wrong Answer
| 33 | 9,144 | 110 |
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
def main():
A = int(input())
s = A % 1000
print(s)
if __name__ == '__main__':
main()
|
s588860390
|
Accepted
| 29 | 9,152 | 162 |
def main():
A = int(input())
s = A % 1000
if s == 0:
print(s)
else:
print(1000-s)
if __name__ == '__main__':
main()
|
s093239361
|
p00423
|
u052758509
| 1,000 | 131,072 |
Wrong Answer
| 20 | 7,596 | 457 |
A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う.最初に, 2 人は与えられた n 枚ずつのカードを,裏向きにして横一列に並べる.その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき,書かれた数字が大きい方のカードの持ち主が,その 2 枚のカードを取る.このとき,その 2 枚のカードに書かれた数字の合計が,カードを取ったプレーヤーの得点となるものとする.ただし,開いた 2 枚のカードに同じ数字が書かれているときには,引き分けとし,各プレーヤーが自分のカードを 1 枚ずつ取るものとする. 例えば, A,B の持ち札が,以下の入力例 1 から 3 のように並べられている場合を考えよう.ただし,入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i + 1 行目(i = 1,2,... ,n)には A の左から i 枚目のカードの数字と B の左から i 枚目の カードの数字が,空白を区切り文字としてこの順で書かれている.すなわち,入力ファイルの 2 行目以降は,左側の列が A のカードの並びを,右側の列が B のカードの並びを,それぞれ表している.このとき,ゲーム終了後の A と B の得点は,それぞれ,対応する出力例に示したものとなる. 入力ファイルに対応するゲームが終了したときの A の得点と B の得点を,この順に空白を区切り文字として 1 行に出力するプログラムを作成しなさい.ただし, n ≤ 10000 とする. 入力例1 | 入力例2 | 入力例3 ---|---|--- 3| 3| 3 9 1| 9 1| 9 1 5 4| 5 4| 5 5 0 8| 1 0| 1 8 出力例1 | 出力例2 | 出力例3 19 8| 20 0| 15 14
|
def _resulting(ab):
a, b = 0, 0
for itr in ab:
if itr[0] > itr[1]:
a = a + (itr[0] + itr[1])
elif itr[0] < itr[1]:
b = b + (itr[0] + itr[1])
else:
a = a + itr[0]
b = b + itr[1]
return a, b
if __name__ == '__main__':
N = int(input())
ab = []
for itr in range(0, N):
ab.append(list(map(int, input().split())))
a, b = _resulting(ab)
print(a, b)
|
s762305906
|
Accepted
| 120 | 9,208 | 569 |
def _resulting(ab):
a, b = 0, 0
for itr in ab:
if itr[0] > itr[1]:
a = a + (itr[0] + itr[1])
elif itr[0] < itr[1]:
b = b + (itr[0] + itr[1])
else:
a = a + itr[0]
b = b + itr[1]
return a, b
if __name__ == '__main__':
while True:
N = int(input())
if N != 0:
ab = []
for itr in range(0, N):
ab.append(list(map(int, input().split())))
a, b = _resulting(ab)
print(a, b)
else:
break
|
s699821752
|
p03738
|
u937642029
| 2,000 | 262,144 |
Wrong Answer
| 17 | 2,940 | 111 |
You are given two positive integers A and B. Compare the magnitudes of these numbers.
|
a=int(input())
b=int(input())
if(a>b):
print("GREATER")
if(a<b):
print("LESS")
else:
print("EQUAL")
|
s159150304
|
Accepted
| 17 | 3,064 | 113 |
a=int(input())
b=int(input())
if(a>b):
print("GREATER")
elif(a<b):
print("LESS")
else:
print("EQUAL")
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.