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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s549137797
|
p03359
|
u363836311
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 67
|
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi?
|
a,b=map(int, input().split())
if a<b:
print(a)
else:
print(a-1)
|
s269296220
|
Accepted
| 17
| 2,940
| 69
|
a,b=map(int, input().split())
if a<=b:
print(a)
else:
print(a-1)
|
s374911499
|
p03998
|
u514894322
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 319
|
Alice, Bob and Charlie are playing _Card Game for Three_ , as below: * At first, each of the three players has a deck consisting of some number of cards. Each card has a letter `a`, `b` or `c` written on it. The orders of the cards in the decks cannot be rearranged. * The players take turns. Alice goes first. * If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says `a`, Alice takes the next turn.) * If the current player's deck is empty, the game ends and the current player wins the game. You are given the initial decks of the players. More specifically, you are given three strings S_A, S_B and S_C. The i-th (1≦i≦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way. Determine the winner of the game.
|
def trush_and_next(s):
if s[0] == 'A':
next = 0
elif s[0] == 'B':
next = 1
else:
next = 2
return s[1:],next
l = []
ans = 'ABC'
for i in range(3):
l.append(str(input()))
next = 0
while True:
if len(l[next]) == 0:
print(ans[next])
break
else:
l[next],next = trush_and_next(l[next])
|
s424875914
|
Accepted
| 17
| 3,064
| 319
|
def trush_and_next(s):
if s[0] == 'a':
next = 0
elif s[0] == 'b':
next = 1
else:
next = 2
return s[1:],next
l = []
ans = 'ABC'
for i in range(3):
l.append(str(input()))
next = 0
while True:
if len(l[next]) == 0:
print(ans[next])
break
else:
l[next],next = trush_and_next(l[next])
|
s003214752
|
p03997
|
u240793404
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 57
|
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,b,h = [int(input()) for i in range(3)]
print((a+b)*h/2)
|
s053053593
|
Accepted
| 17
| 2,940
| 62
|
a,b,h = [int(input()) for i in range(3)]
print(int((a+b)*h/2))
|
s196024525
|
p02613
|
u676939443
| 2,000
| 1,048,576
|
Wrong Answer
| 169
| 16,300
| 254
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
n = int(input())
abc = []
for i in range(n):
s = str(input())
abc.append(s)
print('AC × {}'.format(abc.count('AC')))
print('WA × {}'.format(abc.count('WA')))
print('TLE × {}'.format(abc.count('TLE')))
print('RE × {}'.format(abc.count('RE')))
|
s100490543
|
Accepted
| 166
| 16,160
| 251
|
n = int(input())
abc = []
for i in range(n):
s = str(input())
abc.append(s)
print('AC x {}'.format(abc.count('AC')))
print('WA x {}'.format(abc.count('WA')))
print('TLE x {}'.format(abc.count('TLE')))
print('RE x {}'.format(abc.count('RE')))
|
s126398925
|
p03680
|
u728566015
| 2,000
| 262,144
|
Wrong Answer
| 197
| 7,084
| 217
|
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.
|
N = int(input())
a = [int(input()) for _ in range(N)]
cnt = 1
button = a[0]
print(button)
while button != 2:
button = a[button - 1]
cnt += 1
if cnt > N:
print(-1)
break
else:
print(cnt)
|
s202464108
|
Accepted
| 213
| 7,080
| 236
|
N = int(input())
A = [0]
for _ in range(N):
A.append(int(input()))
button = 1
cnt = 0
for i in range(N):
if button == 2:
print(cnt)
break
else:
button = A[button]
cnt += 1
else:
print(-1)
|
s458960359
|
p00022
|
u379956761
| 1,000
| 131,072
|
Wrong Answer
| 30
| 6,780
| 136
|
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.
|
import sys
n = 1
while 1:
n = int(input())
if n == 0:
break
a = [int(input()) for _ in range(n)]
print(sum(a))
|
s831725593
|
Accepted
| 40
| 6,860
| 251
|
while 1:
n = int(input())
if n == 0:
break
a = []
for _ in range(n):
a.append(int(input()))
dp = []
dp.append(a[0])
for i in range(1,len(a)):
dp.append(max(dp[i-1] + a[i], a[i]))
print(max(dp))
|
s638627847
|
p03005
|
u597374218
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 64
|
Takahashi is distributing N balls to K persons. If each person has to receive at least one ball, what is the maximum possible difference in the number of balls received between the person with the most balls and the person with the fewest balls?
|
N,K=map(int,input().split())
print(0 if K==1 or K==N else N-K+1)
|
s973159016
|
Accepted
| 17
| 2,940
| 54
|
N,K=map(int,input().split())
print(0 if K==1 else N-K)
|
s183311156
|
p02697
|
u857605629
| 2,000
| 1,048,576
|
Wrong Answer
| 78
| 9,280
| 91
|
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())
a = 1
b = n-1
for i in range(m):
print(a,b)
a += 1
b -= 1
|
s956125083
|
Accepted
| 76
| 9,264
| 194
|
n,m = map(int,input().split())
a = int(n/2)
b = a+1
offset = False
if n%2 == 0:
offset = True
for i in range(m):
if offset and b-a >= n/2:
b += 1
offset = False
print(a,b)
a -= 1
b += 1
|
s870484353
|
p03752
|
u920103253
| 1,000
| 262,144
|
Wrong Answer
| 50
| 3,064
| 639
|
There are N buildings along the line. The i-th building from the left is colored in color i, and its height is currently a_i meters. Chokudai is a mayor of the city, and he loves colorful thigs. And now he wants to see at least K buildings from the left. You can increase height of buildings, but it costs 1 yens to increase 1 meters. It means you cannot make building that height is not integer. You cannot decrease height of buildings. Calculate the minimum cost of satisfying Chokudai's objective. Note: "Building i can see from the left" means there are no j exists that (height of building j) ≥ (height of building i) and j < i.
|
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
n,k=n1()
a=n1()
import itertools
ite=itertools.combinations(range(n),k)
ans=10**20
for line in ite:
c=0
b=a.copy()
for i in range(1,k):
if b[line[i]]<=b[line[i-1]]:
plus=b[line[i-1]]-b[line[i]]+1
b[line[i]]+=plus
c+=plus
ok=1
for i in range(n):
if b[i-1]<b[i]:
ok+=1
else:
b[i]=b[i-1]
if ok>=3:
ans=min(ans,c)
print(ans)
|
s958618708
|
Accepted
| 49
| 3,064
| 641
|
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
n,k=n1()
a=n1()
import itertools
ite=itertools.combinations(range(n),k)
ans=10**20
for line in ite:
c=0
b=a.copy()
for i in range(1,k):
if b[line[i]]<=b[line[i-1]]:
plus=b[line[i-1]]-b[line[i]]+1
b[line[i]]+=plus
c+=plus
ok=1
for i in range(1,n):
if b[i-1]<b[i]:
ok+=1
else:
b[i]=b[i-1]
if ok>=k:
ans=min(ans,c)
print(ans)
|
s089191014
|
p01102
|
u408444038
| 8,000
| 262,144
|
Wrong Answer
| 20
| 5,568
| 411
|
The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program. Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such _close_ submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
|
a1 = input()
a2 = input()
b1 = a1.split('"')
b2 = a2.split('"')
cnt = 0
if len(b1)==len(b2):
for i in range(0,len(b1)):
if i%2==0:
if b1[i]!=b2[i]:
cnt+=10000
break
if i%2!=0:
if b1[i]!=b2[i]:
cnt+=1
else:
cnt+=10000
if cnt>1:
print("DIFFERENT")
if cnt==1:
print("CLOSE")
if cnt==0:
print("IDENTICAL")
|
s618343622
|
Accepted
| 20
| 5,596
| 607
|
st = []
while(1):
a1 = input()
if a1 =='.':
break
a2 = input()
b1 = a1.split('"')
b2 = a2.split('"')
cnt = 0
if len(b1)==len(b2):
for i in range(0,len(b1)):
if i%2==0:
if b1[i]!=b2[i]:
cnt+=10000
break
if i%2!=0:
if b1[i]!=b2[i]:
cnt+=1
else:
cnt+=10000
if cnt>1:
st.append("DIFFERENT")
if cnt==1:
st.append("CLOSE")
if cnt==0:
st.append("IDENTICAL")
for i in range(len(st)):
print(st[i])
|
s331049439
|
p03609
|
u022683706
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 77
|
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds?
|
input = str(input())
word = [x for x in input]
word = word[::2]
print(word)
|
s550047766
|
Accepted
| 17
| 2,940
| 89
|
sand,t = map(int,input().split(" "))
if t >= sand:
print(0)
else:
print(sand - t)
|
s513419055
|
p02393
|
u468794560
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,452
| 1
|
Write a program which reads three integers, and prints them in ascending order.
|
s500531452
|
Accepted
| 20
| 5,596
| 232
|
table = list(map(int,input().split()))
for i in range(2,0,-1):
k = 0
while k < i:
if table[k] > table[k+1]:
table[k],table[k+1] = table[k+1],table[k]
k += 1;
print(table[0],table[1],table[2])
|
|
s047685238
|
p02370
|
u462831976
| 1,000
| 131,072
|
Wrong Answer
| 40
| 8,644
| 815
|
A directed acyclic graph (DAG) can be used to represent the ordering of tasks. Tasks are represented by vertices and constraints where one task can begin before another, are represented by edges. For example, in the above example, you can undertake task B after both task A and task B are finished. You can obtain the proper sequence of all the tasks by a topological sort. Given a DAG $G$, print the order of vertices after the topological sort.
|
# -*- coding: utf-8 -*-
import sys
import os
import pprint
from queue import Queue
"""Topological Sort"""
V, E = list(map(int, input().split()))
G = [[] for i in range(V)]
indig = [0] * V
for i in range(V):
s, t = list(map(int, input().split()))
G[s].append(t)
indig[t] += 1
q = Queue()
out = []
def bfs(node_index):
q.put(node_index)
while not q.empty():
u = q.get()
out.append(u)
for index in G[u]:
indig[index] -= 1
if indig[index] == 0:
q.put(index)
# bfs?????????
indig_copy = indig[:]
for i in range(V):
if indig_copy[i] == 0:
bfs(node_index=i)
print(out)
|
s666048172
|
Accepted
| 300
| 12,176
| 832
|
# -*- coding: utf-8 -*-
import sys
import os
import pprint
from queue import Queue
"""Topological Sort"""
V, E = list(map(int, input().split()))
G = [[] for i in range(V)]
indig = [0] * V
for i in range(E):
s, t = list(map(int, input().split()))
G[s].append(t)
indig[t] += 1
q = Queue()
out = []
def bfs(node_index):
q.put(node_index)
while not q.empty():
u = q.get()
out.append(u)
for index in G[u]:
indig[index] -= 1
if indig[index] == 0:
q.put(index)
# bfs?????????
indig_copy = indig[:]
for i in range(V):
if indig_copy[i] == 0:
bfs(node_index=i)
for v in out:
print(v)
|
s565979703
|
p02392
|
u467711590
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,584
| 88
|
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
|
a, b, c = map(int, input(). split())
if a < b < c:
print('YES')
else:
print('NO')
|
s413089297
|
Accepted
| 20
| 5,584
| 88
|
a, b, c = map(int, input(). split())
if a < b < c:
print('Yes')
else:
print('No')
|
s282767881
|
p03610
|
u960570220
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,560
| 41
|
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
|
s = list(input())
print(''.join(s[0:2]))
|
s569717205
|
Accepted
| 26
| 9,084
| 27
|
s = input()
print(s[0::2])
|
s932223829
|
p03493
|
u286943165
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 33
|
Snuke has a grid consisting of three squares numbered 1, 2 and 3. In each square, either `0` or `1` is written. The number written in Square i is s_i. Snuke will place a marble on each square that says `1`. Find the number of squares on which Snuke will place a marble.
|
s=str()
x=s.count("1")
print(x)
|
s517721503
|
Accepted
| 17
| 2,940
| 78
|
from sys import stdin
a=stdin.readline().rstrip()
x=a.count("1")
print(x)
|
s365451642
|
p03569
|
u426108351
| 2,000
| 262,144
|
Wrong Answer
| 82
| 3,316
| 640
|
We have a string s consisting of lowercase English letters. Snuke can perform the following operation repeatedly: * Insert a letter `x` to any position in s of his choice, including the beginning and end of s. Snuke's objective is to turn s into a palindrome. Determine whether the objective is achievable. If it is achievable, find the minimum number of operations required.
|
s = input()
t = s.replace("x", "")
flag = 1
for i in range(len(t)):
if t[i] != t[~i]:
flag = 0
if flag == 0:
print(-1)
else:
ans = 0
t = s[::-1]
c = 0
for i in range(len(s)):
if c >= len(t):
if s[i] == "x":
ans += 1
continue
if t[c] == s[i]:
c += 1
continue
else:
if s[i] == "x":
ans += 1
continue
else:
while t[c] == "x":
ans += 1
c += 1
else:
c += 1
print(ans//2)
|
s351237537
|
Accepted
| 83
| 3,316
| 662
|
s = input()
t = s.replace("x", "")
flag = 1
for i in range(len(t)):
if t[i] != t[~i]:
flag = 0
if flag == 0:
print(-1)
else:
ans = 0
t = s[::-1]
c = 0
for i in range(len(s)):
if c >= len(t):
if s[i] == "x":
ans += 1
continue
if t[c] == s[i]:
c += 1
continue
else:
if s[i] == "x":
ans += 1
continue
else:
while t[c] == "x":
ans += 1
c += 1
else:
c += 1
ans += len(t) - c
print(ans//2)
|
s066146328
|
p00682
|
u078042885
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,656
| 247
|
Polygons are the most fundamental objects in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If you are interested in the processing of geometric data, you'd better try some programming exercises about basic operations on polygons. Your job in this problem is to write a program that computes the area of polygons. A polygon is represented by a sequence of points that are its vertices. If the vertices p1, p2, ..., pn are given, line segments connecting pi and pi+1 (1 <= i <= n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the polygon. You can assume that the polygon is not degenerate. Namely, the following facts can be assumed without any input data checking. * No point will occur as a vertex more than once. * Two sides can intersect only at a common endpoint (vertex). * The polygon has at least 3 vertices. Note that the polygon is not necessarily convex. In other words, an inner angle may be larger than 180 degrees.
|
while 1:
n=int(input())
if n==0:break
p=[complex(*map(int,input().split())) for _ in range(n)]
s,pre=0,p[0]
while p:
now=p.pop()
s+=now.real*pre.imag-now.imag*pre.real
pre=now
print(abs(s)/2);input()
|
s147078381
|
Accepted
| 20
| 7,616
| 262
|
c=0
while 1:
n=int(input())
if n==0:break
c+=1
p=[complex(*map(int,input().split())) for _ in range(n)]
s,pre=0,p[0]
while p:
now=p.pop()
s+=now.real*pre.imag-now.imag*pre.real
pre=now
print(c,abs(s)/2);input()
|
s830616123
|
p02613
|
u991619971
| 2,000
| 1,048,576
|
Wrong Answer
| 163
| 9,196
| 636
|
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
|
#import numpy as np
#import functools
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy
N = int(input())
#A,B= map(int,input().split())
#P = list(map(int,input().split()))
#S = str(input())
#T = str(input())
a=0
b=0
c=0
d=0
for i in range(N):
S = str(input())
if S=='AC':
a+=1
elif S=='WA':
b+=1
elif S=='TLE':
c+=1
else:
d+=1
print('AC ×',a)
print('WA ×',b)
print('TLE ×',c)
print('RE ×',d)
|
s421168533
|
Accepted
| 163
| 9,200
| 632
|
#import numpy as np
#import functools
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as comb_with
#from itertools import permutations as perm
#import collections as C #most_common
#import math
#import sympy
N = int(input())
#A,B= map(int,input().split())
#P = list(map(int,input().split()))
#S = str(input())
#T = str(input())
a=0
b=0
c=0
d=0
for i in range(N):
S = str(input())
if S=='AC':
a+=1
elif S=='WA':
b+=1
elif S=='TLE':
c+=1
else:
d+=1
print('AC x',a)
print('WA x',b)
print('TLE x',c)
print('RE x',d)
|
s225194125
|
p03387
|
u105456682
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 422
|
You are given three integers A, B and C. Find the minimum number of operations required to make A, B and C all equal by repeatedly performing the following two kinds of operations in any order: * Choose two among A, B and C, then increase both by 1. * Choose one among A, B and C, then increase it by 2. It can be proved that we can always make A, B and C all equal by repeatedly performing these operations.
|
import math
def kaisuu(hoge):
a = sorted(hoge)
A = a[2]
B = a[1]
C = a[0]
print(a)
return math.floor(A-((B+C)/2))
X = list(map(int, (input()).split()))
count = 0
for i in X:
if i % 2 == 0:
count+=1
if count == 0 or count == 3:
print(kaisuu(X))
elif count == 1:
for i in range(3):
if X[i] % 2 == 1:
X[i]+=1
print(kaisuu(X)+1)
else:
for i in range(3):
if X[i] % 2 == 0:
X[i]+=1
print(kaisuu(X)+1)
|
s995921292
|
Accepted
| 17
| 3,064
| 413
|
import math
def kaisuu(hoge):
a = sorted(hoge)
A = a[2]
B = a[1]
C = a[0]
return math.floor(A-((B+C)/2))
X = list(map(int, (input()).split()))
count = 0
for i in X:
if i % 2 == 0:
count+=1
if count == 0 or count == 3:
print(kaisuu(X))
elif count == 1:
for i in range(3):
if X[i] % 2 == 1:
X[i]+=1
print(kaisuu(X)+1)
else:
for i in range(3):
if X[i] % 2 == 0:
X[i]+=1
print(kaisuu(X)+1)
|
s871955540
|
p03388
|
u552822163
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,064
| 727
|
10^{10^{10}} participants, including Takahashi, competed in two programming contests. In each contest, all participants had distinct ranks from first through 10^{10^{10}}-th. The _score_ of a participant is the product of his/her ranks in the two contests. Process the following Q queries: * In the i-th query, you are given two positive integers A_i and B_i. Assuming that Takahashi was ranked A_i-th in the first contest and B_i-th in the second contest, find the maximum possible number of participants whose scores are smaller than Takahashi's.
|
# coding=utf-8
def solve_worst(number_1, number_2):
cases = 0
if number_1 < number_2:
number_1, number_2 = number_2, number_1
if (number_1 * number_2) % (number_2 + 1) == 0:
max_1 = number_1 * number_2 // (number_2 + 1) - 1
else:
max_1 = number_1 * number_2 // (number_2 + 1)
cases += max_1
if (number_1 * number_2) % (number_1 + 1) == 0:
max_2 = number_1 * number_2 // (number_1 + 1) - 1
else:
max_2 = number_1 * number_2 // (number_1 + 1)
cases += max_2
return cases
if __name__ == '__main__':
Q = int(input())
for i in range(Q):
A, B = map(int, input().split())
worst_cases = solve_worst(A, B)
print(worst_cases)
|
s883643196
|
Accepted
| 20
| 3,188
| 883
|
# coding=utf-8
import math
def solve_worst(number_1, number_2):
cases = 0
if number_1 < number_2:
number_1, number_2 = number_2, number_1
if (number_1 * number_2) % (number_1 + 1) == 0:
max_2 = number_1 * number_2 // (number_1 + 1) - 1
else:
max_2 = number_1 * number_2 // (number_1 + 1)
cases += max_2
min_sqrt = math.floor(math.sqrt(number_1 * number_2))
if min_sqrt == number_2:
min_sqrt = number_2 + 1
cases += min_sqrt - number_2
if (number_1 * number_2) % min_sqrt == 0:
max_1 = number_1 * number_2 // min_sqrt - 2
else:
max_1 = number_1 * number_2 // min_sqrt - 1
cases += max_1
return cases
if __name__ == '__main__':
Q = int(input())
for i in range(Q):
A, B = map(int, input().split())
worst_cases = solve_worst(A, B)
print(worst_cases)
|
s215390325
|
p02607
|
u464013915
| 2,000
| 1,048,576
|
Wrong Answer
| 30
| 8,904
| 411
|
We have N squares assigned the numbers 1,2,3,\ldots,N. Each square has an integer written on it, and the integer written on Square i is a_i. How many squares i satisfy both of the following conditions? * The assigned number, i, is odd. * The written integer is odd.
|
n = int(input())
x = input().split()
masu_list = []
for i in range(n):
if not i%2==0:
masu_list.append(i)
else:
pass
answer_list=[]
for masu in masu_list:
masu = masu-1
answer_list.append(x[masu])
answer = [int(s) for s in answer_list]
answer_list_2=[]
for ans in answer:
if not ans%2==0:
answer_list_2.append(ans)
else:
pass
print(len(answer_list_2))
|
s432876763
|
Accepted
| 30
| 9,232
| 421
|
n = int(input())
x = input().split()
masu_list = []
for i in range(n):
i=i+1
if not i%2==0:
masu_list.append(i)
else:
pass
answer_list=[]
for masu in masu_list:
masu = masu-1
answer_list.append(x[masu])
answer = [int(s) for s in answer_list]
answer_list_2=[]
for ans in answer:
if not ans%2==0:
answer_list_2.append(ans)
else:
pass
print(len(answer_list_2))
|
s957724734
|
p02280
|
u855199458
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,840
| 1,527
|
A rooted binary tree is a tree with a root node in which every node has at most two children. Your task is to write a program which reads a rooted binary tree _T_ and prints the following information for each node _u_ of _T_ : * node ID of _u_ * parent of _u_ * sibling of _u_ * the number of children of _u_ * depth of _u_ * height of _u_ * node type (root, internal node or leaf) If two nodes have the same parent, they are **siblings**. Here, if _u_ and _v_ have the same parent, we say _u_ is a sibling of _v_ (vice versa). The height of a node in a tree is the number of edges on the longest simple downward path from the node to a leaf. Here, the given binary tree consists of _n_ nodes and evey node has a unique ID from 0 to _n_ -1.
|
# -*- coding: utf-8 -*-
N = int(input())
tree = [{"parent":-1, "left":-1, "right":-1, "sibling": -1} for _ in range(N)]
parent = set([n for n in range(N)])
for _ in range(N):
inp = [int(n) for n in input().split()]
tree[inp[0]]["left"] = inp[1]
tree[inp[0]]["right"] = inp[2]
tree[inp[0]]["degree"] = sum([inp[1] != -1, inp[2] != -1])
tree[inp[1]]["parent"] = inp[0]
tree[inp[2]]["parent"] = inp[0]
tree[inp[1]]["sibling"] = inp[2]
tree[inp[2]]["sibling"] = inp[1]
parent = parent.difference(inp[1:])
def set_depth(n, depth):
tree[n]["depth"] = depth
if tree[n]["left"] != -1:
set_depth(tree[n]["left"], depth+1)
if tree[n]["right"] != -1:
set_depth(tree[n]["right"], depth+1)
root = parent.pop()
set_depth(root, 0)
def set_height(n):
h1 = 0
h2 = 0
if tree[n]["right"] != -1:
h1 = set_height(tree[n]["right"]) + 1
if tree[n]["left"] != -1:
h2 = set_height(tree[n]["left"]) + 1
tree[n]["height"] = max(h1, h2)
return max(h1, h2)
set_height(root)
for n in range(N):
if tree[n]["parent"] == -1:
tree[n]["type"] = "root"
elif tree[n]["degree"] == 0:
tree[n]["type"] = "leaf"
else:
tree[n]["type"] = "internal node"
print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
.format(n, tree[n]["parent"], tree[n]["sibling"],
tree[n]["degree"], tree[n]["depth"], tree[n]["height"], tree[n]["type"]))
|
s238906448
|
Accepted
| 30
| 7,900
| 1,589
|
# -*- coding: utf-8 -*-
N = int(input())
tree = [{"parent":-1, "left":-1, "right":-1, "sibling": -1} for _ in range(N)]
parent = set([n for n in range(N)])
for _ in range(N):
inp = [int(n) for n in input().split()]
tree[inp[0]]["left"] = inp[1]
tree[inp[0]]["right"] = inp[2]
tree[inp[0]]["degree"] = sum([inp[1] != -1, inp[2] != -1])
if inp[1] != -1:
tree[inp[1]]["parent"] = inp[0]
tree[inp[1]]["sibling"] = inp[2]
if inp[2] != -1:
tree[inp[2]]["parent"] = inp[0]
tree[inp[2]]["sibling"] = inp[1]
parent = parent.difference(inp[1:])
def set_depth(n, depth):
tree[n]["depth"] = depth
if tree[n]["left"] != -1:
set_depth(tree[n]["left"], depth+1)
if tree[n]["right"] != -1:
set_depth(tree[n]["right"], depth+1)
root = parent.pop()
set_depth(root, 0)
def set_height(n):
h1 = 0
h2 = 0
if tree[n]["right"] != -1:
h1 = set_height(tree[n]["right"]) + 1
if tree[n]["left"] != -1:
h2 = set_height(tree[n]["left"]) + 1
tree[n]["height"] = max(h1, h2)
return max(h1, h2)
set_height(root)
for n in range(N):
if tree[n]["parent"] == -1:
tree[n]["type"] = "root"
elif tree[n]["degree"] == 0:
tree[n]["type"] = "leaf"
else:
tree[n]["type"] = "internal node"
print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
.format(n, tree[n]["parent"], tree[n]["sibling"],
tree[n]["degree"], tree[n]["depth"], tree[n]["height"], tree[n]["type"]))
|
s541693970
|
p01102
|
u531592024
| 8,000
| 262,144
|
Wrong Answer
| 40
| 5,588
| 811
|
The programming contest named _Concours de Programmation Comtemporaine Interuniversitaire_ (CPCI) has a judging system similar to that of ICPC; contestants have to submit correct outputs for two different inputs to be accepted as a correct solution. Each of the submissions should include the program that generated the output. A pair of submissions is judged to be a correct solution when, in addition to the correctness of the outputs, they include an identical program. Many contestants, however, do not stop including a different version of their programs in their second submissions, after modifying a single string literal in their programs representing the input file name, attempting to process different input. The organizers of CPCI are exploring the possibility of showing a special error message for such _close_ submissions, indicating contestants what's wrong with such submissions. Your task is to detect such close submissions.
|
def vals(arr):
even = True
res = [[], []]
tmp = []
for e in arr:
if e == "\"":
even = not even
res[even].append(tmp)
tmp = []
continue
tmp.append(e)
even = not even
res[even].append(tmp)
return res
while True:
str1 = input()
if str1 == ".":
break
a = vals(str1)
b = vals(input())
print(a)
print(b)
res = 0
for (x, y) in zip(a[0], b[0]):
if x != y:
res = 2
break
if res == 0:
for (a, b) in zip(a[1], b[1]):
if a != b:
if res == 1:
break
res += 1
if res == 0:
print("IDENTICAL")
elif res == 1:
print("CLOSE")
else:
print("DIFFERENT")
|
s651627311
|
Accepted
| 30
| 5,588
| 885
|
def vals(arr):
even = True
res = [[], []]
tmp = []
for e in arr:
if e == "\"":
even = not even
res[even].append(tmp)
tmp = []
continue
tmp.append(e)
even = not even
res[even].append(tmp)
return res
while True:
str1 = input()
if str1 == ".":
break
a = vals(str1)
b = vals(input())
res = 0
if len(a[0]) != len(b[0]) or len(a[1]) != len(b[1]) :
res = 2
else:
for (x, y) in zip(a[0], b[0]):
if x != y:
res = 2
break
if res == 0:
for (a, b) in zip(a[1], b[1]):
if a != b:
res += 1
if res == 2:
break
if res == 0:
print("IDENTICAL")
elif res == 1:
print("CLOSE")
else:
print("DIFFERENT")
|
s786812132
|
p03455
|
u243572357
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 70
|
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())
print('Even' if (a*b) % 2 else 'Odd')
|
s046888806
|
Accepted
| 17
| 2,940
| 86
|
a, b = map(int, input().split())
if a*b % 2 == 0:
print('Even')
else:
print('Odd')
|
s159561729
|
p03854
|
u625495026
| 2,000
| 262,144
|
Wrong Answer
| 79
| 3,636
| 351
|
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()[::-1]
dividor = ['dream','dreamer','erase','eraser']
j=0
while True:
flag = 0
for d in dividor:
print(S[j:j+len(d)])
if S[j:j+len(d)]==d[::-1]:
flag = 1
j+=len(d)
if j==len(S):
print("YES")
quit()
if flag==0:
print("NO")
quit()
|
s948428861
|
Accepted
| 44
| 3,188
| 323
|
S = input()[::-1]
dividor = ['dream','dreamer','erase','eraser']
j=0
while True:
flag = 0
for d in dividor:
if S[j:j+len(d)]==d[::-1]:
flag = 1
j+=len(d)
if j==len(S):
print("YES")
quit()
if flag==0:
print("NO")
quit()
|
s748368863
|
p02922
|
u658801777
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 2,940
| 216
|
Takahashi's house has only one socket. Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets. One power strip with A sockets can extend one empty socket into A empty sockets. Find the minimum number of power strips required.
|
while True:
try:
A, B = map(int, input().split())
if A >= B:
print(1)
else:
A -= 1
B -= 1
print(-(-B//A))
except EOFError:
break
|
s629213931
|
Accepted
| 17
| 3,060
| 258
|
while True:
try:
A, B = map(int, input().split())
if B == 1:
print(0)
elif A >= B:
print(1)
else:
A -= 1
B -= 1
print(-(-B//A))
except EOFError:
break
|
s615345079
|
p02383
|
u843628476
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,596
| 613
|
Write a program to simulate rolling a dice, which can be constructed by the following net. As shown in the figures, each face is identified by a different label from 1 to 6. Write a program which reads integers assigned to each face identified by the label and a sequence of commands to roll the dice, and prints the integer on the top face. At the initial state, the dice is located as shown in the above figures.
|
#!/usr/bin/env python
faces = list(map(int, input().split()))
print(faces)
command = list(input())
print(command)
def dice(face, command):
face_1 = {"E": 4, "W": 3, "S": 5, "N": 2}
face_2 = {"E": 4, "W": 3, "S": 1, "N": 6}
face_3 = {"E": 2, "W": 5, "S": 1, "N": 6}
face_4 = {"E": 5, "W": 2, "S": 1, "N": 6}
face_5 = {"E": 4, "W": 3, "S": 6, "N": 1}
face_6 = {"E": 4, "W": 3, "S": 2, "N": 1}
rulebase = [face_1, face_2, face_3, face_4, face_5, face_6]
return rulebase[face - 1][command]
top = 1
for c in command:
top = dice(top, c)
print(top)
print(faces[top - 1])
|
s332943158
|
Accepted
| 20
| 5,608
| 649
|
#!/usr/bin/env python
label = list(map(int, input().split()))
command = list(input())
faces = [1, 2, 3, 4, 5, 6]
def dice(command):
if command == "N":
faces[0], faces[1], faces[4], faces[5] = faces[1], faces[5], faces[0], faces[4]
elif command == "S":
faces[0], faces[1], faces[4], faces[5] = faces[4], faces[0], faces[5], faces[1]
elif command == "E":
faces[0], faces[2], faces[3], faces[5] = faces[3], faces[0], faces[5], faces[2]
else: # command W
faces[0], faces[2], faces[3], faces[5] = faces[2], faces[5], faces[0], faces[3]
for c in command:
dice(c)
print(label[faces[0] - 1])
|
s684440453
|
p03416
|
u089032001
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 225
|
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 = input().split()
kA = int(A[0:3])*100 + int(A[1:2])*10 + int(A[0:1])
kB = int(B[0:3])*100 + int(B[1:2])*10 + int(B[0:1])
maxB = int(B[0:3]) + int(kB <= int(B))
maxA = int(A[0:3]) + int(kA > int(A))
print(maxB - maxA)
|
s579167513
|
Accepted
| 17
| 3,064
| 233
|
A, B = input().split()
kA = int(A[0:3]) * 100 + int(A[1:2]) * 10 + int(A[0:1])
kB = int(B[0:3]) * 100 + int(B[1:2]) * 10 + int(B[0:1])
maxB = int(B[0:3]) + int(kB <= int(B))
maxA = int(A[0:3]) + int(kA < int(A))
print(maxB - maxA)
|
s350854732
|
p03544
|
u880277518
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 194
|
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
|
n=int(input())
l=[]
l.append(2)
l.append(1)
if n==1:
print(n)
exit()
for i in range(2,n+1):
l.append(l[i-2]+l[i-1])
print(i,l[i])
if n==i:
print(l[i])
exit()
|
s251870807
|
Accepted
| 17
| 3,060
| 176
|
n=int(input())
l=[]
l.append(2)
l.append(1)
if n==1:
print(n)
exit()
for i in range(2,n+1):
l.append(l[i-2]+l[i-1])
if n==i:
print(l[i])
exit()
|
s061125190
|
p03574
|
u273326224
| 2,000
| 262,144
|
Wrong Answer
| 194
| 13,112
| 879
|
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.
|
import numpy as np
def dot_to_zero(letter):
if letter == ".":
return "0"
else:
return "#"
h, w = map(int, input().split(' '))
a = []
for i in range(h):
s = np.array(list(map(dot_to_zero, input())))
a.append(s)
a = np.vstack(a)
def add(array):
for hei in [0,1,2]:
for wid in [0,1,2]:
if array[hei][wid] == "#":
array[hei][wid] = "#"
else:
array[hei][wid] = str(int(array[hei][wid]) + 1)
return array
a = np.pad(a, (1,1), 'edge')
print(a)
for index_h in range(1, h+1):
for index_w in range(1, w+1):
if a[index_h][index_w] == "#":
print(index_h, index_w)
a[index_h-1:index_h+2, index_w-1:index_w+2] = add(a[index_h-1:index_h+2, index_w-1:index_w+2])
a = a[1:-1, 1:-1]
for array in a:
print("".join( array.tolist() ))
|
s941095958
|
Accepted
| 184
| 12,784
| 834
|
import numpy as np
def dot_to_zero(letter):
if letter == ".":
return "0"
else:
return "#"
h, w = map(int, input().split(' '))
a = []
for i in range(h):
s = np.array(list(map(dot_to_zero, input())))
a.append(s)
a = np.vstack(a)
def add(array):
for hei in [0,1,2]:
for wid in [0,1,2]:
if array[hei][wid] == "#":
array[hei][wid] = "#"
else:
array[hei][wid] = str(int(array[hei][wid]) + 1)
return array
a = np.pad(a, (1,1), 'edge')
for index_h in range(1, h+1):
for index_w in range(1, w+1):
if a[index_h][index_w] == "#":
a[index_h-1:index_h+2, index_w-1:index_w+2] = add(a[index_h-1:index_h+2, index_w-1:index_w+2])
a = a[1:-1, 1:-1]
for array in a:
print("".join( array.tolist() ))
|
s134495119
|
p03920
|
u163320134
| 2,000
| 262,144
|
Wrong Answer
| 22
| 3,316
| 193
|
The problem set at _CODE FESTIVAL 20XX Finals_ consists of N problems. The score allocated to the i-th (1≦i≦N) problem is i points. Takahashi, a contestant, is trying to score exactly N points. For that, he is deciding which problems to solve. As problems with higher scores are harder, he wants to minimize the highest score of a problem among the ones solved by him. Determine the set of problems that should be solved.
|
n=int(input())
ans=0
ex=0
for i in range(1,10000):
tmp=i*(i+1)//2
if tmp>=n:
ans=i
ex=tmp-n
break
if n==1:
print(1)
else:
for i in range(1,ans):
if i!=ex:
print(i)
|
s824506259
|
Accepted
| 23
| 3,316
| 163
|
n=int(input())
ans=0
ex=0
for i in range(1,10000):
tmp=i*(i+1)//2
if tmp>=n:
ans=i
ex=tmp-n
break
for i in range(1,ans+1):
if i!=ex:
print(i)
|
s512850238
|
p03643
|
u102960641
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 1
|
This contest, _AtCoder Beginner Contest_ , is abbreviated as _ABC_. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer.
|
s556778548
|
Accepted
| 17
| 2,940
| 20
|
print("ABC"+input())
|
|
s523149744
|
p02972
|
u189023301
| 2,000
| 1,048,576
|
Wrong Answer
| 709
| 13,492
| 472
|
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
|
n = int(input())
lis = list(map(int, input().split()))
val = [0] * n
for i in range(n, 0, -1):
if n // i == 1:
val[i - 1] = lis[i - 1]
else:
p = n // i
a = 0
for j in range(p):
a += val[i * (j + 1) - 1]
if a % 2 == lis[i - 1]:
val[i - 1] = 0
else:
val[i - 1] = 1
t = sum(val) % 2
if lis[0] == t:
print(*[i + 1 for i in range(n) if val[i] == 1], sep=" ")
else:
print(-1)
|
s087492539
|
Accepted
| 212
| 13,088
| 465
|
import sys
input = sys.stdin.readline
def main():
n = int(input())
lis = list(map(int, input().split()))
val = [0] * n
for i in range(n, 0, -1):
if n // i == 1:
val[i - 1] = lis[i - 1]
else:
a = sum(val[i - 1::i])
if a % 2 != lis[i - 1]:
val[i - 1] ^= 1
print(sum(val))
print(*[i + 1 for i in range(n) if val[i] == 1], sep=" ")
if __name__ == '__main__':
main()
|
s828297193
|
p03379
|
u780269042
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 25,220
| 161
|
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N.
|
n = int(input())
li = list(map(int, input().split()))
for i in range(1,1+n):
li.sort()
a = li[i]
b = li[int((n+1)/2)]
print(b)
li.append(a)
|
s972192006
|
Accepted
| 288
| 25,224
| 190
|
N = int(input())
X = list(map(int, input().split()))
tmpls = sorted(X)
low = tmpls[N//2 -1]
high = tmpls[N//2]
for i in X:
if i > low:
print(low)
else:
print(high)
|
s120778603
|
p03779
|
u883048396
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 137
|
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
|
iX = int(input())
iK = int((2*(iX)) ** 0.5)
for k in [iK,iK+1]:
if k*(k-1) < iX *2 <= (k)*(k+1):
print(iX,k)
exit()
|
s550580159
|
Accepted
| 17
| 2,940
| 132
|
iX = int(input())
iK = int((2*(iX)) ** 0.5)
for k in [iK,iK+1]:
if k*(k-1) < iX *2 <= k*(k+1):
print(k)
exit()
|
s696074497
|
p03251
|
u391066416
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 161
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
print("No War") if X<Y and max(x)+1<min(y) else print("War")
|
s284472317
|
Accepted
| 18
| 3,060
| 167
|
N,M,X,Y=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
print("No War") if X<Y and max(x+[X])<min(y+[Y]) else print("War")
|
s508443384
|
p02264
|
u802537549
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,600
| 420
|
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
|
n, q = list(map(int, input().split()))
queue = [input().split() for y in range(n)]
time = 0;
print(queue[1:] + queue[:1])
while True:
if int(queue[0][1]) <= 100:
time += int(queue[0][1])
print(queue[0][0], time)
if len(queue) == 1:
break
queue.pop(0)
else:
time += 100
queue[0][1] = str(int(queue[0][1]) - 100)
queue = queue[1:] + queue[:1]
|
s168427102
|
Accepted
| 770
| 13,016
| 377
|
n, quantum = list(map(int, input().split()))
queue = []
sumOfTime = 0
for _ in range(n):
name, time = input().split()
queue.append([name, int(time)])
while len(queue) > 0:
name, time = queue.pop(0)
if time > quantum:
sumOfTime += quantum
queue.append([name, time - quantum])
else:
sumOfTime += time
print(name, sumOfTime)
|
s816709375
|
p03378
|
u102960641
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 138
|
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())
a = list(map(int, input().split()))
for i,j in enumerate(a):
if x < j:
print(min(i,n-i))
break
|
s067653498
|
Accepted
| 18
| 2,940
| 138
|
n,m,x = map(int, input().split())
a = list(map(int, input().split()))
for i,j in enumerate(a):
if x < j:
print(min(i,m-i))
break
|
s633934045
|
p03079
|
u481244478
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 104
|
You are given three integers A, B and C. Determine if there exists an equilateral triangle whose sides have lengths A, B and C.
|
str = input().split()
if str[0] == str[1] and str[1] == str[2]:
print("YES")
else:
print("NO")
|
s476115377
|
Accepted
| 17
| 2,940
| 104
|
str = input().split()
if str[0] == str[1] and str[1] == str[2]:
print("Yes")
else:
print("No")
|
s022351158
|
p03636
|
u068538925
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,100
| 43
|
The word `internationalization` is sometimes abbreviated to `i18n`. This comes from the fact that there are 18 letters between the first `i` and the last `n`. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way.
|
s = input()
print(s[:1]+str(len(s))+s[-1:])
|
s922670395
|
Accepted
| 30
| 8,888
| 45
|
s = input()
print(s[:1]+str(len(s)-2)+s[-1:])
|
s286659145
|
p03110
|
u247465867
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 187
|
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives. You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative. For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins. If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?
|
#2019/10/21
N, *x = [list(s.split()) for s in open(0)]
# print(N, x)
sum = 0
for i, j in x:
if (j == 'JPY'):
sum += float(i)
else:
sum += float(i)*38000
print(sum)
|
s331980516
|
Accepted
| 17
| 2,940
| 188
|
#2019/10/21
N, *x = [list(s.split()) for s in open(0)]
# print(N, x)
sum = 0
for i, j in x:
if (j == 'JPY'):
sum += float(i)
else:
sum += float(i)*380000
print(sum)
|
s512759295
|
p02742
|
u757030836
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 50
|
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements? Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds: * r_1 + c_1 = r_2 + c_2 * r_1 - c_1 = r_2 - c_2 For example, in the following figure, the bishop can move to any of the red squares in one move:
|
h,w = map(int,input().split())
x = h*w
print(x/2)
|
s109401287
|
Accepted
| 18
| 2,940
| 155
|
import math
h,w = map(int,input().split())
x = h*w
if h==1 or w==1:
print(1)
exit()
if x%2==0:
print(int(x/2))
else:
print(int(math.ceil(x/2)))
|
s571778674
|
p02266
|
u418996726
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,568
| 592
|
Your task is to simulate a flood damage. For a given cross-section diagram, reports areas of flooded sections. Assume that rain is falling endlessly in the region and the water overflowing from the region is falling in the sea at the both sides. For example, for the above cross-section diagram, the rain will create floods which have areas of 4, 2, 1, 19 and 9 respectively.
|
arr = list(input())
down = list()
areas = list()
for i, el in enumerate(arr):
if el == "\\":
down.append(i)
elif el == "/" and not len(down) == 0:
start_ind = down.pop()
area = i - start_ind
while len(areas) > 0 and areas[-1][0] > start_ind:
area += areas.pop()[1]
areas.append((start_ind, area))
# print("LOOP: {}".format(i))
# print("DOWN INDICES")
# print(down)
# print("AREAS")
# print(areas)
# print()
areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
print(" ".join(map(str,areas)))
|
s753032291
|
Accepted
| 30
| 6,392
| 515
|
arr = list(input())
down = list()
areas = list()
for i, el in enumerate(arr):
if el == "\\":
down.append(i)
elif el == "/" and not len(down) == 0:
start_ind = down.pop()
area = i - start_ind
while len(areas) > 0 and areas[-1][0] > start_ind:
area += areas.pop()[1]
areas.append((start_ind, area))
areas = [areas[i][1] for i in range(len(areas))]
print(sum(areas))
print(str(len(areas)) + " " + " ".join(map(str,areas)) if not len(areas) == 0 else "0")
|
s060255163
|
p02262
|
u148628801
| 6,000
| 131,072
|
Wrong Answer
| 20
| 7,740
| 768
|
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
|
import sys
import math
def insertion_sort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j = j - g
cnt += 1
A[j + g] = v
return cnt
def shell_sort(A, n):
cnt = 0
m = math.ceil(math.log(2 * n + 1) / math.log(3))
print(m)
G = [0 for i in range(m)]
G[0] = 1
for i in range(1, m):
G[i] = 3 * G[i - 1] + 1
G.reverse()
print(G[0], end = "")
for i in range(1, m):
print(" " + str(G[i]), end = "")
print("")
for i in range(m):
cnt += insertion_sort(A, n, G[i])
print(cnt)
for i in range(n):
print(A[i])
#fin = open("test.txt", "r")
fin = sys.stdin
n = int(fin.readline())
A = [0 for i in range(n)]
for i in range(n):
A[i] = int(fin.readline())
shell_sort(A, n)
|
s815926253
|
Accepted
| 19,890
| 47,552
| 769
|
import sys
import math
def insertion_sort(A, n, g):
cnt = 0
for i in range(g, n):
v = A[i]
j = i - g
while j >= 0 and A[j] > v:
A[j + g] = A[j]
j = j - g
cnt += 1
A[j + g] = v
return cnt
def shell_sort(A, n):
cnt = 0
m = math.floor(math.log(2 * n + 1) / math.log(3))
print(m)
G = [0 for i in range(m)]
G[0] = 1
for i in range(1, m):
G[i] = 3 * G[i - 1] + 1
G.reverse()
print(G[0], end = "")
for i in range(1, m):
print(" " + str(G[i]), end = "")
print("")
for i in range(m):
cnt += insertion_sort(A, n, G[i])
print(cnt)
for i in range(n):
print(A[i])
#fin = open("test.txt", "r")
fin = sys.stdin
n = int(fin.readline())
A = [0 for i in range(n)]
for i in range(n):
A[i] = int(fin.readline())
shell_sort(A, n)
|
s901348683
|
p03485
|
u739721456
| 2,000
| 262,144
|
Wrong Answer
| 19
| 3,060
| 53
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
a,b=map(int,input().split())
ans=(a+b)%2+1
print(ans)
|
s727328313
|
Accepted
| 17
| 2,940
| 96
|
a,b=map(int,input().split())
if (a+b)%2==0:
ans=(a+b)//2
else:
ans=(a+b)//2+1
print(ans)
|
s502708775
|
p03563
|
u368796742
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,064
| 555
|
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.
|
S = list(input())
T = list(input())
S1 = S[::-1]
T1 = T[::-1]
count = 0
for i in range(len(S)-len(T)+1):
count = 0
for j in range(len(T1)):
if S1[i+j] == "?" or S1[i+j] == T1[j]:
count += 1
if count == len(T1):
for k in range(len(T1)):
S1[k+i] = T1[k]
S2 = S1[::-1]
for i in S2:
if i == "?":
print("a",end="")
else:
print(i,end="")
exit()
print("UNRESTORABLE")
|
s904276910
|
Accepted
| 17
| 2,940
| 46
|
r = int(input())
g = int(input())
print(2*g-r)
|
s090662132
|
p03044
|
u261646994
| 2,000
| 1,048,576
|
Wrong Answer
| 367
| 26,100
| 196
|
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.
|
N = int(input())
color = [0]*N
uvw = [[int(item) for item in input().split()] for _ in range(N-1)]
for u, v, w in uvw:
if w % 2 == 1:
color[v-1] = int(not color[u-1])
print(color)
|
s490343819
|
Accepted
| 1,137
| 196,436
| 540
|
import sys
from collections import defaultdict
N = int(input())
sys.setrecursionlimit(1000000)
uvw = [[int(item) for item in input().split()] for _ in range(N-1)]
d = defaultdict(lambda: {})
for u, v, w in uvw:
d[u][v] = w
d[v][u] = w
dist = {1: 0}
def calc_dist(i, up):
if not(i in dist):
dist[i] = dist[up]+d[up][i]
[calc_dist(k, i) for k in list(d[i].keys())]
[calc_dist(k, 1) for k in list(d[1].keys())]
for i in range(1, N+1):
if dist[i] % 2 == 0:
print(0)
else:
print(1)
|
s671567901
|
p03693
|
u232873434
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 102
|
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())
if (100*r+10*g+b) % 4 == 0:
print("Yes")
else:
print("No")
|
s485418308
|
Accepted
| 17
| 2,940
| 100
|
r,g,b = map(int,input().split())
if (100*r+10*g+b) % 4 == 0:
print("YES")
else:
print("NO")
|
s236144103
|
p03720
|
u544050502
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 79
|
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city?
|
from itertools import chain
List=[[1,2,3],[4,5,6],[7,8,9]]
print(*chain(*List))
|
s352015407
|
Accepted
| 19
| 3,060
| 326
|
N,M=map(int,input().split())
a,b=[],[]
for i in range(M):
x,y=input().split()
a.append(x)
b.append(y)
for j in range(1,N+1):
e1=a.count("{}".format(j))
e2=b.count("{}".format(j))
print(e1+e2)
|
s827400376
|
p03635
|
u492447501
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 50
|
In _K-city_ , there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
|
n, m = map(int, input().split())
print(n-1*m-1)
|
s890953513
|
Accepted
| 17
| 2,940
| 54
|
n, m = map(int, input().split())
print((n-1)*(m-1))
|
s937364228
|
p02612
|
u326278153
| 2,000
| 1,048,576
|
Wrong Answer
| 29
| 9,088
| 34
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
a = int(input())
print(a % 1000)
|
s477921653
|
Accepted
| 28
| 9,144
| 48
|
a = int(input())
print((1000 - a % 1000)%1000)
|
s397256338
|
p03846
|
u736729525
| 2,000
| 262,144
|
Wrong Answer
| 66
| 14,820
| 465
|
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.
|
from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
def solve(N, A):
counter = Counter(A)
if N % 2 == 1:
for a, n in counter.items():
if a % 2 != 0 or n != 2:
return 0
return 2**(N//2) % 1000000007
else:
for a, n in counter.items():
if a % 2 != 1 or n != 2:
return 0
return 2**(N//2) % 1000000007
print(solve(N, A))
|
s781701044
|
Accepted
| 64
| 14,820
| 528
|
from collections import Counter
N = int(input())
A = [int(x) for x in input().split()]
def solve(N, A):
counter = Counter(A)
if N % 2 == 1:
for a, n in counter.items():
if a == 0 and n == 1:
continue
if a % 2 != 0 or n != 2:
return 0
return (2**(N//2)) % 1000000007
else:
for a, n in counter.items():
if a % 2 != 1 or n != 2:
return 0
return (2**(N//2)) % 1000000007
print(solve(N, A))
|
s399462123
|
p02397
|
u643542669
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,604
| 248
|
Write a program which reads two integers x and y, and prints them in ascending order.
|
array = list(map(int, input().split()))
array.sort()
array2 = []
while array[0] != 0 and array[1] != 0:
array2.append(array)
array = input()
array = list(map(int, inpu().split()))
array.sort()
for i in array2:
print(i[0], i[1])
|
s068157449
|
Accepted
| 50
| 5,612
| 142
|
while True:
x, y = map(int, input().split())
if x == 0 and y == 0:
break
if x > y:
x, y = y, x
print(x, y)
|
s880081268
|
p04011
|
u133327090
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 113
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n = int(input())
k = int(input())
a = int(input())
b = int(input())
print(a * n if k >= n else a * n + b * (k-n))
|
s035825554
|
Accepted
| 18
| 2,940
| 113
|
n = int(input())
k = int(input())
a = int(input())
b = int(input())
print(a * n if k >= n else a * k + b * (n-k))
|
s044677657
|
p03943
|
u681917640
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 122
|
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 c == b + c:
print('YES')
else:
print('NO')
|
s023406073
|
Accepted
| 17
| 2,940
| 116
|
a, b, c = map(int, input().split())
if a == b + c or b == c + a or c == b + a:
print('Yes')
else:
print('No')
|
s733215498
|
p03759
|
u070200692
| 2,000
| 262,144
|
Wrong Answer
| 29
| 9,108
| 111
|
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles _beautiful_ if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful.
|
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
if a-b == c-b:
print("YES")
else:
print("NO")
|
s530377634
|
Accepted
| 28
| 9,016
| 111
|
a, b, c = input().split(' ')
a = int(a)
b = int(b)
c = int(c)
if b-a == c-b:
print("YES")
else:
print("NO")
|
s067646528
|
p03401
|
u002459665
| 2,000
| 262,144
|
Wrong Answer
| 268
| 22,128
| 842
|
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()))
# ans = 0
# now = 0
# for j, a in enumerate(A):
# continue
# ans += abs(now - a)
# now = a
# ans += abs(0 - now)
# print(ans)
HEAD = []
TAIL = []
now = 0
tmp = 0
for ai in A + [0]:
tmp += abs(ai - now)
now = ai
HEAD.append(tmp)
now = 0
tmp = 0
for ai in A[::-1] + [0]:
tmp += abs(ai - now)
now = ai
TAIL.append(tmp)
print(HEAD)
print(TAIL)
ans = 0
for i in range(N):
if i == 0:
ans = abs(A[1] - 0) + TAIL[N-2]
elif i == N - 1:
ans = abs(A[N-2] - 0) + HEAD[N-2]
else:
ans = HEAD[i-1] + TAIL[N-i-2] + abs(A[i+1] - A[i-1])
print(ans)
|
s592653285
|
Accepted
| 235
| 14,048
| 320
|
N = int(input())
A = list(map(int, input().split()))
A = [0] + A + [0]
full = 0
for i in range(N + 1):
full += abs(A[i+1] - A[i])
for i in range(1, N+1):
minus = abs(A[i] - A[i-1]) + abs(A[i+1] - A[i])
plus = abs(A[i+1] - A[i-1])
x = full - minus + plus
print(x)
|
s867540784
|
p03433
|
u603324902
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 94
|
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())
b = n % 500
if a >= b:
print("YES")
else:
print("NO")
|
s499660333
|
Accepted
| 17
| 2,940
| 94
|
n = int(input())
a = int(input())
b = n % 500
if a >= b:
print("Yes")
else:
print("No")
|
s763951689
|
p03547
|
u047197186
| 2,000
| 262,144
|
Wrong Answer
| 23
| 8,880
| 90
|
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters `A`, `B`, `C`, `D`, `E` and `F` are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is `A`, `B`, `C`, `D`, `E` or `F`. When X and Y are seen as hexadecimal numbers, which is larger?
|
x, y = input().split()
if x > y:
print('<')
elif x == y:
print('=')
else:
print('>')
|
s800170401
|
Accepted
| 35
| 9,060
| 90
|
x, y = input().split()
if x > y:
print('>')
elif x == y:
print('=')
else:
print('<')
|
s847336429
|
p02388
|
u090992688
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,572
| 43
|
Write a program which calculates the cube of a given integer x.
|
x=int(input())
print("%d^3=%d" %(x,x*x*x))
|
s519125801
|
Accepted
| 20
| 5,576
| 28
|
x=int(input())
print(x*x*x)
|
s361021808
|
p03485
|
u840310460
| 2,000
| 262,144
|
Wrong Answer
| 268
| 18,368
| 75
|
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer.
|
import numpy as np
a, b = map(int, input().split())
print(np.ceil((a+b)/2))
|
s998162766
|
Accepted
| 420
| 21,776
| 80
|
a, b = map(int, input().split())
import numpy as np
print(int(np.ceil((a+b)/2)))
|
s592213759
|
p03853
|
u012694084
| 2,000
| 262,144
|
Wrong Answer
| 24
| 3,064
| 234
|
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
|
args = input().split(" ")
H = int(args[0])
c = []
for _ in range(0, H):
c.append(input())
last = len(c) - 1
for i, row in enumerate(c):
if i != last:
print("{0}\n{0}\n", row)
else:
print("{0}\n{0}", row)
|
s117561256
|
Accepted
| 24
| 3,188
| 144
|
args = input().split(" ")
H = int(args[0])
c = []
for _ in range(0, H):
c.append(input())
for row in c:
print("{0}\n{0}".format(row))
|
s219558871
|
p02841
|
u506910932
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 111
|
In this problem, a date is written as Y-M-D. For example, 2019-11-30 means November 30, 2019. Integers M_1, D_1, M_2, and D_2 will be given as input. It is known that the date 2019-M_2-D_2 follows 2019-M_1-D_1. Determine whether the date 2019-M_1-D_1 is the last day of a month.
|
a, b = map(int, input().split())
c, d = map(int, input().split())
if a != b:
print(1)
else:
print(0)
|
s323306890
|
Accepted
| 17
| 2,940
| 111
|
a, b = map(int, input().split())
c, d = map(int, input().split())
if a != c:
print(1)
else:
print(0)
|
s002894408
|
p03860
|
u660472825
| 2,000
| 262,144
|
Wrong Answer
| 29
| 8,944
| 32
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
s = input()
print("A"+s[10]+"C")
|
s571472368
|
Accepted
| 27
| 8,952
| 31
|
s = input()
print("A"+s[8]+"C")
|
s568299558
|
p03625
|
u518987899
| 2,000
| 262,144
|
Wrong Answer
| 188
| 21,412
| 360
|
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.
|
from collections import Counter
N = int(input().strip())
A = Counter(list(map(int, input().strip().split(' '))))
tmp = 0
for k,v in sorted(A.items(), reverse=True):
if v > 4:
if tmp > 0:
print(k*tmp)
exit()
else:
print(k*k)
exit()
elif v > 2:
if tmp > 0:
print(k*tmp)
exit()
else:
tmp = k
print(0)
|
s399407702
|
Accepted
| 188
| 21,412
| 363
|
from collections import Counter
N = int(input().strip())
A = Counter(list(map(int, input().strip().split(' '))))
tmp = 0
for k,v in sorted(A.items(), reverse=True):
if v >= 4:
if tmp > 0:
print(k*tmp)
exit()
else:
print(k*k)
exit()
elif v >= 2:
if tmp > 0:
print(k*tmp)
exit()
else:
tmp = k
print(0)
|
s138792718
|
p03353
|
u863442865
| 2,000
| 1,048,576
|
Wrong Answer
| 28
| 3,444
| 941
|
You are given a string s. Among the **different** substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = `ababc`, `a`, `bab` and `ababc` are substrings of s, while `ac`, `z` and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}.
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 1000000007
s = input().rstrip()
K = int(input())
a = sorted(set(s))
res = set()
n = len(s)
for i in a:
res.add(i)
if len(res)>K:
res = sorted(res)
print(res[K-1])
exit()
for j in range(n):
if s[j] == i:
for k in range(1, 5):
res.add(s[j:j+k+1])
if __name__ == '__main__':
main()
|
s033213104
|
Accepted
| 30
| 3,436
| 1,042
|
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate
#from itertools import product
from bisect import bisect_left,bisect_right
import heapq
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 1000000007
s = input().rstrip()
K = int(input())
a = sorted(set(s))
res = set()
n = len(s)
for i in a:
res.add(i)
if len(res)>=K:
res = sorted(res)
print(res[K-1])
exit()
for j in range(n):
if s[j] == i:
for k in range(1, 5):
res.add(s[j:j+k+1])
if len(res)>=K:
res = sorted(res)
print(res[K-1])
exit()
if __name__ == '__main__':
main()
|
s116263964
|
p02402
|
u488038316
| 1,000
| 131,072
|
Wrong Answer
| 30
| 7,700
| 302
|
Write a program which reads a sequence of $n$ integers $a_i (i = 1, 2, ... n)$, and prints the minimum value, maximum value and sum of the sequence.
|
# -*-coding:utf-8
import math
def main():
num = int(input())
inputLine = input()
array = list(map(int, inputLine.strip().split()))
mx = max(array)
mn = min(array)
sm = sum(array)
print('%d %d %d' % (mx, mn, sm))
if __name__ == '__main__':
main()
|
s670363813
|
Accepted
| 30
| 8,756
| 302
|
# -*-coding:utf-8
import math
def main():
num = int(input())
inputLine = input()
array = list(map(int, inputLine.strip().split()))
mx = max(array)
mn = min(array)
sm = sum(array)
print('%d %d %d' % (mn, mx, sm))
if __name__ == '__main__':
main()
|
s644177113
|
p03943
|
u397531548
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 136
|
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:
print("Yes")
if a+c==b:
print("Yes")
if c+b==a:
print("Yes")
else:
print("No")
|
s249366691
|
Accepted
| 18
| 2,940
| 98
|
A=map(int,input().split())
B=sorted(A)
if B[0]+B[1]==B[2]:
print("Yes")
else:
print("No")
|
s391041552
|
p03197
|
u434872492
| 2,000
| 1,048,576
|
Wrong Answer
| 221
| 7,072
| 210
|
There is an apple tree that bears apples of N colors. The N colors of these apples are numbered 1 to N, and there are a_i apples of Color i. You and Lunlun the dachshund alternately perform the following operation (starting from you): * Choose one or more apples from the tree and eat them. Here, the apples chosen at the same time must all have different colors. The one who eats the last apple from the tree will be declared winner. If both you and Lunlun play optimally, which will win?
|
N=int(input())
a=[]
m=10**10
for i in range(N):
a.append(int(input()))
m=min(m,a[i])
if m>N:
if N%2==0:
print("first")
else:
print("second")
exit()
else:
print("second")
|
s561237401
|
Accepted
| 207
| 7,024
| 171
|
N=int(input())
A=[]
flag=False
for i in range(N):
A.append(int(input()))
if A[i]%2==1:
flag=True
if not flag:
print("second")
else:
print("first")
|
s695340543
|
p03672
|
u170650966
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 132
|
We will call a string that can be obtained by concatenating two equal strings an _even_ string. For example, `xyzxyz` and `aaaaaa` are even, while `ababab` and `xyzxy` are not. You are given an even string S consisting of lowercase English letters. Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S. It is guaranteed that such a non-empty string exists for a given input.
|
s = input()
for i in range(len(s)//2):
s = s[:-2]
l = len(s)
if s[:l] == s[l:]:
print( l * 2)
break
|
s272499281
|
Accepted
| 17
| 2,940
| 136
|
s = input()
for i in range(len(s)//2):
s = s[:-2]
l = len(s) // 2
if s[:l] == s[l:]:
print(l * 2)
break
|
s965148612
|
p03455
|
u884276009
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 146
|
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
|
import math
a,b=map(int,input().split())
a=str(a)
b=str(b)
c=a+b
d=int(c)
e=math.sqrt(d)
if e.is_integer():
print("yes")
else:
print("no")
|
s216252795
|
Accepted
| 17
| 2,940
| 80
|
a,b=map(int,input().split())
if a*b % 2==0:
print("Even")
else:
print("Odd")
|
s710919668
|
p03712
|
u445511055
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,060
| 339
|
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.
|
# -*- coding: utf-8 -*-
def main():
"""Function."""
h, w = map(int, input().split())
sharp = ""
for _ in range(w+2):
sharp += "#"
print(sharp)
for _ in range(h):
dum = "#"
dum += str(input())
dum = "#"
print(dum)
print(sharp)
if __name__ == "__main__":
main()
|
s276258915
|
Accepted
| 19
| 3,060
| 354
|
# -*- coding: utf-8 -*-
def main():
"""Function."""
h, w = map(int, input().split())
sharp = ""
for _ in range(w+2):
sharp += "#"
print(sharp)
for _ in range(h):
dum = "#"
a = str(input())
dum += a
dum += "#"
print(dum)
print(sharp)
if __name__ == "__main__":
main()
|
s571191494
|
p03455
|
u495030644
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 87
|
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:
print('Even')
else:
print('Odd')
|
s545838174
|
Accepted
| 17
| 2,940
| 92
|
a, b = map(int, input().split())
if (a*b) % 2 == 0:
print('Even')
else:
print('Odd')
|
s868947519
|
p04011
|
u543954314
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 80
|
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
|
n, k, x, y = [int(input()) for i in range(4)]
print(min(n, k)*x + min(n-k, 0)*y)
|
s910764211
|
Accepted
| 17
| 2,940
| 80
|
n, k, x, y = [int(input()) for i in range(4)]
print(min(n, k)*x + max(n-k, 0)*y)
|
s409650935
|
p02612
|
u060432908
| 2,000
| 1,048,576
|
Wrong Answer
| 27
| 9,168
| 140
|
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
|
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))
n=I()
print(n%1000)
|
s026457226
|
Accepted
| 32
| 9,172
| 182
|
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))
n=I()
if n%1000==0:
print(0)
else:
print(1000-n%1000)
|
s844509243
|
p03351
|
u807772568
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 151
|
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 = list(map(int,input().split()))
if abs(a[0]-a[2]) < a[3] or (abs(a[0] - a[1]) < a[3] and abs(a[1] -a[2]) < a[3]):
print("Yes")
else:
print("No")
|
s764931098
|
Accepted
| 18
| 3,060
| 160
|
a = list(map(int,input().split()))
if (abs(a[0]-a[2]) <= a[3]) or ((abs(a[0] - a[1]) <= a[3]) and (abs(a[1] -a[2]) <= a[3])):
print("Yes")
else:
print("No")
|
s375330863
|
p03408
|
u287500079
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 132
|
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
|
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
ans=n-len(list(set(s)&set(t)))
print(ans)
|
s405995516
|
Accepted
| 21
| 3,316
| 294
|
from collections import Counter
n=int(input())
s=[input() for _ in range(n)]
m=int(input())
t =[input() for _ in range(m)]
sc=Counter(s)
tc=Counter(t)
u=list(set(s)&set(t))
ans=0
for i in u:
ans=max(ans,max(0,sc[i]-tc[i]))
v=list(set(s)-set(u))
for i in v:
ans=max(ans,sc[i])
print(ans)
|
s638227369
|
p02842
|
u693933222
| 2,000
| 1,048,576
|
Wrong Answer
| 33
| 3,060
| 124
|
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
|
import math
n = int(input())
for i in range(n):
if (math.floor(i * 1.08) == n):
print(i)
else:
print(":(")
|
s401300892
|
Accepted
| 25
| 3,060
| 133
|
import math
n = int(input())
for i in range(n+1):
if (i * 108 //100 == n):
print(i)
break
else:
print(":(")
|
s711124895
|
p03573
|
u618369407
| 2,000
| 262,144
|
Wrong Answer
| 27
| 8,968
| 130
|
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers.
|
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
if a == b:
print(a)
elif a == c:
print(a)
else:
print(b)
|
s917183884
|
Accepted
| 26
| 9,052
| 130
|
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
if a == b:
print(c)
elif a == c:
print(b)
else:
print(a)
|
s693814164
|
p02795
|
u740284863
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 69
|
We have a grid with H rows and W columns, where all the squares are initially white. You will perform some number of painting operations on the grid. In one operation, you can do one of the following two actions: * Choose one row, then paint all the squares in that row black. * Choose one column, then paint all the squares in that column black. At least how many operations do you need in order to have N or more black squares in the grid? It is guaranteed that, under the conditions in Constraints, having N or more black squares is always possible by performing some number of operations.
|
h = int(input())
w = int(input())
n = int(input())
print(n//max(h,w))
|
s450834895
|
Accepted
| 17
| 2,940
| 136
|
h = int(input())
w = int(input())
n = int(input())
m = max(w,h)
if n > n //m * m:
ans = n // m + 1
else:
ans = n // m
print(ans)
|
s766318302
|
p03693
|
u953379577
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 92
|
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())
if (r*100+g*10+b)%4==0:
print("Yes")
else:
print("No")
|
s174453037
|
Accepted
| 17
| 2,940
| 93
|
r,g,b = map(int,input().split())
if (r*100+g*10+b)%4==0:
print("YES")
else:
print("NO")
|
s483719881
|
p00002
|
u806182843
| 1,000
| 131,072
|
Wrong Answer
| 20
| 7,548
| 169
|
Write a program which computes the digit number of sum of two integers a and b.
|
def main():
a, b = map(int, input().split())
c = a + b
digits = 1
while c // 10 != 0:
c = c // 10
digits += 1
print(digits)
if __name__ == '__main__':
main()
|
s812889887
|
Accepted
| 20
| 7,588
| 210
|
def main():
import sys
for line in sys.stdin:
a, b = map(int, line.split())
c = a + b
digits = 1
while c // 10 != 0:
c = c // 10
digits += 1
print(digits)
if __name__ == '__main__':
main()
|
s513995249
|
p03023
|
u642012866
| 2,000
| 1,048,576
|
Wrong Answer
| 17
| 2,940
| 33
|
Given an integer N not less than 3, find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees, but do not print units.
|
N = int(input())
print(120*(N-2))
|
s092270653
|
Accepted
| 17
| 2,940
| 33
|
N = int(input())
print(180*(N-2))
|
s926090561
|
p03502
|
u173329233
| 2,000
| 262,144
|
Wrong Answer
| 21
| 3,060
| 195
|
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.
|
n_str = input()
n = int(n_str)
n_length = len(n_str)
sum1 = 0
for i in range(n_length):
n2 = int(n_str[i])
sum1 = sum1 + n2
if n % sum1 == 0:
print('yes')
else:
print('no')
|
s387520687
|
Accepted
| 17
| 2,940
| 195
|
n_str = input()
n = int(n_str)
n_length = len(n_str)
sum1 = 0
for i in range(n_length):
n2 = int(n_str[i])
sum1 = sum1 + n2
if n % sum1 == 0:
print('Yes')
else:
print('No')
|
s873297599
|
p02927
|
u672475305
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,060
| 291
|
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
|
def divisor(n):
tank = []
for i in range(1, int(n**0.5)+1):
if n%i==0:
tank.append((i, n//i))
return tank
m,d = map(int,input().split())
cnt = 0
for i in range(m):
k = divisor(i)
for x,y in k:
if x>=2 and y<=d:
cnt += 1
print(cnt)
|
s015855538
|
Accepted
| 19
| 3,064
| 469
|
def divisor(n):
tank = []
for i in range(1, int(n**0.5)+1):
if n%i==0:
tank.append((i, n//i))
return tank
m,d = map(int,input().split())
cnt = 0
for i in range(1,m+1):
k = divisor(i)
for x,y in k:
a = int(str(x)+str(y))
if a//10>=2 and a%10>=2 and a<=d:
cnt += 1
if x!=y:
b = int(str(y)+str(x))
if b//10>=2 and b%10>=2 and b<=d:
cnt += 1
print(cnt)
|
s832650996
|
p03251
|
u847758719
| 2,000
| 1,048,576
|
Wrong Answer
| 18
| 3,064
| 258
|
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
print(max_x)
print(min_y)
if max_x <= Y and max_x < min_y and min_y > X:
print("No War")
else:
print("War")
|
s177543197
|
Accepted
| 17
| 3,060
| 231
|
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
if max_x < Y and max_x < min_y and min_y > X:
print("No War")
else:
print("War")
|
s124054929
|
p03860
|
u485319545
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 78
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
a,b,c = input().split()
middle = b.capitalize()
print("A{}C".format(middle))
|
s467798704
|
Accepted
| 17
| 2,940
| 81
|
a,b,c = input().split()
middle = b.capitalize()
print("A{}C".format(middle[0]))
|
s554831257
|
p03399
|
u599547273
| 2,000
| 262,144
|
Wrong Answer
| 18
| 2,940
| 63
|
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses.
|
a,b,c,d=map(int,map(input,"abcd"));print([a,b][a>b]+[c,d][c>d])
|
s887562654
|
Accepted
| 17
| 2,940
| 61
|
a,b,c,d=[int(input())for i in"abcd"];print(min(a,b)+min(c,d))
|
s538662482
|
p03479
|
u816488327
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,188
| 89
|
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
|
from math import log2
X, Y = map(int, input().split())
ans = log2(Y / X) + 1
print(ans)
|
s631515615
|
Accepted
| 18
| 2,940
| 91
|
X, Y = map(int, input().split())
ans = 0
while X <= Y:
X *= 2
ans += 1
print(ans)
|
s332773344
|
p03386
|
u863076295
| 2,000
| 262,144
|
Wrong Answer
| 17
| 3,060
| 188
|
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
|
a,b,k = map(int,input().split())
if b-a >= k+1:
for i in range(k):
print(a+i)
for i in range(k):
print(b-a+1+i)
else:
for i in range(b-a+1):
print(a+i)
|
s990294255
|
Accepted
| 17
| 3,060
| 190
|
a,b,k = map(int,input().split())
if b-a+1 <= 2*k:
for i in range(b-a+1):
print(a+i)
else:
for i in range(k):
print(a+i)
for i in range(k):
print(b-k+1+i)
|
s370415495
|
p03860
|
u280552586
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 49
|
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name.
|
a, b, c = input().split()
print(a[0], b[0], c[0])
|
s948225247
|
Accepted
| 17
| 2,940
| 47
|
a, b, c = input().split()
print(a[0]+b[0]+c[0])
|
s675377886
|
p02238
|
u772417059
| 1,000
| 131,072
|
Wrong Answer
| 20
| 5,616
| 720
|
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving the vertex from which $v$ was discovered. This process continues until all the vertices that are reachable from the original source vertex have been discovered. If any undiscovered vertices remain, then one of them is selected as a new source and the search is repeated from that source. DFS timestamps each vertex as follows: * $d[v]$ records when $v$ is first discovered. * $f[v]$ records when the search finishes examining $v$’s adjacency list. Write a program which reads a directed graph $G = (V, E)$ and demonstrates DFS on the graph based on the following rules: * $G$ is given in an adjacency-list. Vertices are identified by IDs $1, 2,... n$ respectively. * IDs in the adjacency list are arranged in ascending order. * The program should report the discover time and the finish time for each vertex. * When there are several candidates to visit during DFS, the algorithm should select the vertex with the smallest ID. * The timestamp starts with 1.
|
n=int(input())
next=[[] for i in range(n)]
for i in range(n):
l=list(map(int,input().split()))
u=l[0]
k=l[1]
for j in range(2,k+2):
next[u-1].append(l[j]-1)
stk=[]
stk.append(0)
print(next)
time=1
d=[0 for i in range(n)]
f=[0 for i in range(n)]
while(len(stk)!=0):
if len(next[stk[-1]])==0:
if d[stk[-1]]==0:
d[stk[-1]]=time
time+=1
f[stk[-1]]=time
time+=1
stk.pop()
else:
v=min(next[stk[-1]])
if d[v]!=0:
next[stk[-1]].remove(v)
else:
if d[stk[-1]]==0:
d[stk[-1]]=time
time+=1
next[stk[-1]].remove(v)
stk.append(v)
for i in range(n):
out=[]
out.append(i+1)
out.append(d[i])
out.append(f[i])
print(*out)
|
s390194647
|
Accepted
| 20
| 5,668
| 531
|
n=int(input())
next=[[] for i in range(n)]
for i in range(n):
l=list(map(int,input().split()))
u=l[0]
k=l[1]
for j in range(2,k+2):
next[u-1].append(l[j]-1)
stk=[]
stk.append(0)
time=1
d=[0 for i in range(n)]
f=[0 for i in range(n)]
know=[0 for i in range(n)]
def dfs(x):
global time
know[x]=1
d[x]=time
time+=1
for n in next[x]:
if know[n]==0:
dfs(n)
f[x]=time
time+=1
for i in range(n):
if know[i]==0:
dfs(i)
for i in range(n):
out=[]
out.append(i+1)
out.append(d[i])
out.append(f[i])
print(*out)
|
s734610519
|
p03605
|
u442948527
| 2,000
| 262,144
|
Wrong Answer
| 28
| 9,004
| 49
|
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
|
n=input()
print(["No","Yes"][n[0]==9 or n[1]==9])
|
s816103331
|
Accepted
| 28
| 9,072
| 35
|
print(["No","Yes"]["9" in input()])
|
s968267955
|
p02694
|
u871176343
| 2,000
| 1,048,576
|
Wrong Answer
| 23
| 9,160
| 130
|
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 = list(map(int,input().split()))[0]
yen = 100
for i in range(1,10**18):
yen = int(yen*1.01)
if yen > X:
break
print(i)
|
s945882703
|
Accepted
| 24
| 9,152
| 133
|
X = list(map(int,input().split()))[0]
yen = 100
for i in range(1, 10**100):
yen = int(yen*1.01)
if yen >= X:
break
print(i)
|
s867556206
|
p03854
|
u141786930
| 2,000
| 262,144
|
Wrong Answer
| 31
| 3,188
| 410
|
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 = str(input())
S = S[::-1]
l = len(S)
i = 0
ans = 'Yes'
while True:
if S[i:i+5] == 'maerd' or S[i:i+5] == 'esare':
i += 5
if i == l:
break
elif S[i:i+6] == 'resare':
i += 6
if i == l:
break
elif S[i:i+7] == 'remaerd':
i += 7
if i == l:
break
else:
ans = 'No'
break
print(ans)
|
s109999789
|
Accepted
| 30
| 3,188
| 410
|
S = str(input())
S = S[::-1]
l = len(S)
i = 0
ans = 'YES'
while True:
if S[i:i+5] == 'maerd' or S[i:i+5] == 'esare':
i += 5
if i == l:
break
elif S[i:i+6] == 'resare':
i += 6
if i == l:
break
elif S[i:i+7] == 'remaerd':
i += 7
if i == l:
break
else:
ans = 'NO'
break
print(ans)
|
s574050908
|
p03730
|
u055941944
| 2,000
| 262,144
|
Wrong Answer
| 97
| 3,912
| 119
|
We ask you to select some number of positive integers, and calculate the sum of them. It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer. Your objective is to make the sum congruent to C modulo B. Determine whether this is possible. If the objective is achievable, print `YES`. Otherwise, print `NO`.
|
a,b,c=map(int,input().split())
for i in range(100000):
if a*i%b==c:
print("YES")
else:
print("NO")
|
s754347396
|
Accepted
| 34
| 2,940
| 127
|
a,b,c=map(int,input().split())
ans="NO"
for i in range (100000):
if a*i%b==c:
ans="YES"
break
print(ans)
|
s734911310
|
p04043
|
u772180901
| 2,000
| 262,144
|
Wrong Answer
| 18
| 3,064
| 119
|
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.
|
arr = list(map(int,input().split()))
if arr.count(7) == 1 and arr.count(5) == 2:
print("Yes")
else:
print("No")
|
s976220504
|
Accepted
| 17
| 2,940
| 119
|
arr = list(map(int,input().split()))
if arr.count(7) == 1 and arr.count(5) == 2:
print("YES")
else:
print("NO")
|
s210429092
|
p03644
|
u934868410
| 2,000
| 262,144
|
Wrong Answer
| 17
| 2,940
| 61
|
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 = 1
while ans < n:
ans *= 2
print(ans)
|
s074710564
|
Accepted
| 17
| 2,940
| 64
|
n = int(input())
ans = 1
while ans*2 <= n:
ans *= 2
print(ans)
|
s586539063
|
p03479
|
u814986259
| 2,000
| 262,144
|
Wrong Answer
| 2,104
| 2,940
| 104
|
As a token of his gratitude, Takahashi has decided to give his mother an integer sequence. The sequence A needs to satisfy the conditions below: * A consists of integers between X and Y (inclusive). * For each 1\leq i \leq |A|-1, A_{i+1} is a multiple of A_i and strictly greater than A_i. Find the maximum possible length of the sequence.
|
X,Y=map(int,input().split())
d=Y-X
k= d // X
count=0
while(1):
if k > 2**count:
break
print(count)
|
s660203584
|
Accepted
| 17
| 2,940
| 202
|
X,Y=map(int,input().split())
d=Y-X
k= Y // X
if k <= 1:
print(1)
exit(0)
count=1
while(1):
if k < 2**count:
break
elif k ==2**count:
count+=1
break
else:
count+=1
print(count)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.