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
s844266498
p03155
u405256066
2,000
1,048,576
Wrong Answer
17
2,940
153
It has been decided that a programming contest sponsored by company A will be held, so we will post the notice on a bulletin board. The bulletin board is in the form of a grid with N rows and N columns, and the notice will occupy a rectangular region with H rows and W columns. How many ways are there to choose where to put the notice so that it completely covers exactly HW squares?
from sys import stdin N=int(stdin.readline().rstrip()) H=int(stdin.readline().rstrip()) W=int(stdin.readline().rstrip()) ans=int(N/H)*int(W/H) print(ans)
s094344834
Accepted
17
2,940
151
from sys import stdin N=int(stdin.readline().rstrip()) H=int(stdin.readline().rstrip()) W=int(stdin.readline().rstrip()) ans=(N-H+1)*(N-W+1) print(ans)
s080601189
p03457
u772180901
2,000
262,144
Wrong Answer
377
27,300
471
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
n = int(input()) me = [0,0] arr = [] for i in range(n): arr += [list(map(int,input().split()))] for t in arr: for _ in range(t[0]): if me[0] < t[1]: me[0] += 1 elif me[0] > t[1]: me[0] -= 1 elif me[1] < t[2]: me[1] += 1 elif me[1] > t[2]: me[1] -= 1 else: me[0] += 1 if me != t[1:]: break if me == arr[-1][1:]: print("Yes") else: print("No")
s107377733
Accepted
445
27,300
518
n = int(input()) me = [0,0] arr = [] tmp = 0 flg = True for i in range(n): arr += [list(map(int,input().split()))] for t in arr: for _ in range(t[0]-tmp): if me[0] < t[1]: me[0] += 1 elif me[0] > t[1]: me[0] -= 1 elif me[1] < t[2]: me[1] += 1 elif me[1] > t[2]: me[1] -= 1 else: me[0] += 1 tmp = t[0] if me != t[1:]: flg = False break if flg: print("Yes") else: print("No")
s848455642
p03377
u367130284
2,000
262,144
Wrong Answer
19
2,940
68
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
a,b,x=map(int,input().split());print("NYoe s"[x in range(a,b+1)::2])
s954304455
Accepted
17
2,940
70
a,b,x=map(int,input().split());print("NYOE S"[x in range(a,a+b+1)::2])
s380069310
p02669
u169138653
2,000
1,048,576
Wrong Answer
420
11,140
784
You start with the number 0 and you want to reach the number N. You can change the number, paying a certain amount of coins, with the following operations: * Multiply the number by 2, paying A coins. * Multiply the number by 3, paying B coins. * Multiply the number by 5, paying C coins. * Increase or decrease the number by 1, paying D coins. You can perform these operations in arbitrary order and an arbitrary number of times. What is the minimum number of coins you need to reach N? **You have to solve T testcases.**
from math import ceil import sys sys.setrecursionlimit(10**7) memo=dict() def dfs(x,a,b,c,d): if x==0: return 0 if x==1: return d if x in memo: return memo[x] l2=2*(x//2) r2=2*ceil(x/2) l3=3*(x//3) r3=3*ceil(x/3) l5=5*(x//5) r5=5*ceil(x/5) mini=10**18 mini=min(mini,abs(l2-x)*d+a+dfs(x//2,a,b,c,d)) mini=min(mini,abs(r2-x)*d+a+dfs(ceil(x/2),a,b,c,d)) mini=min(mini,abs(l3-x)*d+b+dfs(x//3,a,b,c,d)) mini=min(mini,abs(r3-x)*d+b+dfs(ceil(x/3),a,b,c,d)) mini=min(mini,abs(l5-x)*d+c+dfs(x//5,a,b,c,d)) mini=min(mini,abs(r5-x)*d+c+dfs(ceil(x/5),a,b,c,d)) memo[x]=mini return mini t=int(input()) for _ in range(t): memo=dict() n,a,b,c,d=map(int,input().split()) print(dfs(n,a,b,c,d))
s202302455
Accepted
378
10,948
765
import sys sys.setrecursionlimit(10**7) t=int(input()) for _ in range(t): memo=dict() n,a,b,c,d=map(int,input().split()) def dfs(x): if x==0: return 0 if x==1: return d if x in memo: return memo[x] l2=2*(x//2) r2=2*(-(-x//2)) l3=3*(x//3) r3=3*(-(-x//3)) l5=5*(x//5) r5=5*(-(-x//5)) mini=d*x mini=min(mini,abs(l2-x)*d+a+dfs(l2//2)) mini=min(mini,abs(r2-x)*d+a+dfs(r2//2)) mini=min(mini,abs(l3-x)*d+b+dfs(l3//3)) mini=min(mini,abs(r3-x)*d+b+dfs(r3//3)) mini=min(mini,abs(l5-x)*d+c+dfs(l5//5)) mini=min(mini,abs(r5-x)*d+c+dfs(r5//5)) memo[x]=mini return mini print(dfs(n))
s823325649
p03006
u832039789
2,000
1,048,576
Wrong Answer
1,812
5,720
1,224
There are N balls in a two-dimensional plane. The i-th ball is at coordinates (x_i, y_i). We will collect all of these balls, by choosing two integers p and q such that p \neq 0 or q \neq 0 and then repeating the following operation: * Choose a ball remaining in the plane and collect it. Let (a, b) be the coordinates of this ball. If we collected a ball at coordinates (a - p, b - q) in the previous operation, the cost of this operation is 0. Otherwise, including when this is the first time to do this operation, the cost of this operation is 1. Find the minimum total cost required to collect all the balls when we optimally choose p and q.
from fractions import gcd n = int(input()) l = [] for i in range(n): x,y = map(int,input().split()) l.append([x, y]) res = 10 ** 100 for i in range(n): for j in range(i + 1, n): sa = [] invalid = False for p,q in zip(l[i], l[j]): sa.append(p - q) if not invalid: g = gcd(sa[0], sa[1]) sa[0] //= g sa[1] //= g cnt = 0 flag = [False] * n for p in range(n): if flag[p]: continue cnt += 1 flag[p] = True for q in range(p, n): sb = [] for a,b in zip(l[p], l[q]): sb.append(a - b) if sa[0] == 0: if sb[0] == 0 and sb[1] % sa[1] == 0: flag[q] = True elif sa[1] == 0: if sb[1] == 0 and sb[0] % sa[0] == 0: flag[q] = True else: if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0: if sb[0] // sa[0] == sb[1] // sa[1]: flag[q] = True res = min(res, cnt) print(res)
s490229111
Accepted
394
3,064
1,630
n = int(input()) if n == 1: print(1) exit() l = [] for i in range(n): x,y = map(int,input().split()) l.append([x, y]) res = 10 ** 100 for i in range(n): for j in range(i + 1, n): sa = [] invalid = False for p,q in zip(l[i], l[j]): sa.append(p - q) cnt = 0 flag = [False] * n for p in range(n): if not flag[p]: cnt += 1 flag[p] = True nxt = [l[p][0] + sa[0], l[p][1] + sa[1]] for q in range(n): if l[q] == nxt: if flag[q]: cnt -= 1 else: flag[q] = True # cnt = 0 # for p in range(n): # if flag[p]: # continue # cnt += 1 # flag[p] = True # for q in range(p + 1, n): # if flag[q]: # continue # sb = [] # sb.append(a - b) # if sa[0] == 0: # if sb[0] == 0 and sb[1] % sa[1] == 0: # flag[q] = True # elif sa[1] == 0: # if sb[1] == 0 and sb[0] % sa[0] == 0: # flag[q] = True # else: # if sb[0] % sa[0] == 0 and sb[1] % sa[1] == 0: # if sb[0] // sa[0] == sb[1] // sa[1]: # flag[q] = True res = min(res, cnt) print(res)
s838259924
p02608
u970267139
2,000
1,048,576
Wrong Answer
2,205
9,176
338
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
from math import sqrt from math import floor n = int(input()) for i in range(n): n2 = floor(sqrt(i)) ans = 0 for x in range(1, n2): for y in range(1, n2): for z in range(1, n2): if i == pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x: ans += 1 print(ans)
s242933217
Accepted
916
9,128
263
n = int(input()) ans = [0] * n for x in range(1, 101): for y in range(1, 101): for z in range(1, 101): a = x**2 + y**2 + z**2 + x*y + y*z + z*x if a >= 1 and a <= n: ans[a - 1] += 1 for a in ans: print(a)
s644607464
p03067
u756604554
2,000
1,048,576
Wrong Answer
17
2,940
88
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.
a, b, c = map(int, input().split(' ')) if b > c: print('yes') else: print('no')
s087644086
Accepted
17
3,060
326
a, b, c = map(int, input().split(' ')) if a > b and b > c and a > c: print('No') if a > c and a > b and c > b: print('Yes') elif b > a and b > c and a > c: print('No') elif b > c and c > a and b > a: print('Yes') elif c > a and c > b and a > b: print('No') elif c > b and c > a and b > a: print('No')
s770895678
p03997
u761565491
2,000
262,144
Wrong Answer
17
2,940
70
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a+b)*h*0.5)
s314131814
Accepted
17
2,940
75
a = int(input()) b = int(input()) h = int(input()) print(int((a+b)*h*0.5))
s359125718
p03089
u143492911
2,000
1,048,576
Wrong Answer
18
3,060
330
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
n=int(input()) B=list(map(int,input().split())) flag=True ans=[] while flag and len(B): for i in range(len(B)-1,-1,-1): if B[i]==i+1: del B[i] ans.append(i+1) break else: flag=False break if not flag: print(-1) else: for anse in ans: print(anse)
s372930740
Accepted
18
3,060
330
n=int(input()) B=list(map(int,input().split())) flag=True ans=[] while flag and len(B): for i in range(len(B)-1,-1,-1): if B[i]==i+1: del B[i] ans.append(i+1) break else: flag=False break if not flag: print(-1) else: for i in ans[::-1]: print(i)
s642454360
p04030
u973108807
2,000
262,144
Wrong Answer
17
2,940
125
Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the `0` key, the `1` key and the backspace key. To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string: * The `0` key: a letter `0` will be inserted to the right of the string. * The `1` key: a letter `1` will be inserted to the right of the string. * The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted. Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter `0` stands for the `0` key, the letter `1` stands for the `1` key and the letter `B` stands for the backspace key. What string is displayed in the editor now?
s = input() ans = "" for k in s: if k == 'B': if len(s) > 0: ans = ans[:len(s)-1] else: ans += k print(ans)
s703006526
Accepted
17
2,940
126
s = input() ans = "" for k in s: if k == 'B': if ans != "": ans = ans[:len(ans)-1] else: ans += k print(ans)
s447495980
p02612
u911516631
2,000
1,048,576
Wrong Answer
29
9,136
24
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.
print(int(input())%1000)
s157941171
Accepted
28
9,056
36
print((10000 - int(input())) % 1000)
s927462654
p02396
u775586391
1,000
131,072
Wrong Answer
80
8,216
135
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets. Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.
l = [] while True: i = str(input()) if i == '0': break else: l.append(i) t = 0 for i in l: print('Case '+str(t)+': '+i)
s138403404
Accepted
80
8,060
144
l = [] while True: i = str(input()) if i == '0': break else: l.append(i) t = 0 for i in l: t += 1 print('Case '+str(t)+': '+i)
s911932502
p03795
u746419473
2,000
262,144
Wrong Answer
18
2,940
26
Snuke has a favorite restaurant. The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer. So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.
print(10**int(input())+7)
s352225294
Accepted
17
2,940
43
n = int(input()) print(n*800 - n//15*200)
s634406394
p00282
u221679506
1,000
131,072
Wrong Answer
20
7,572
315
大きな数を表そうとすると、文字数も多くなるし、位取りがわからなくなってしまうので、なかなか面倒です。大きな数をわかりやすく表すために、人々は数の単位を使ってきました。江戸時代に書かれた「塵劫記」という本の中では、数の単位が次のように書かれています。 たとえば、2の100乗のようなとても大きな数は、126穣7650(じょ)6002垓2822京9401兆4967億320万5376と表せます。それでは、正の整数 m と n が与えられたとき、m の n 乗を塵劫記の単位を使って上のように表すプログラムを作成してください。
s = ("","Man","Oku","Cho","Kei","Gai","Jo", "Jou","Ko","Kan","Sei","Sai","Gok","Ggs", "Asg","Nyt","Fks","Mts") while True: m,n = map(int,input().split()) if m == 0 and n == 0: break ans = "" for i in range(0,len(str(m**n)),4): x = m**n//(10**i)%10000#m^n / 10^i ans = str(x) + s[i//4] + ans print(ans)
s018085376
Accepted
20
7,676
328
s = ("","Man","Oku","Cho","Kei","Gai","Jo", "Jou","Ko","Kan","Sei","Sai","Gok","Ggs", "Asg","Nyt","Fks","Mts") while True: m,n = map(int,input().split()) if m == 0 and n == 0: break ans = "" for i in range(0,len(str(m**n)),4): x = m**n//(10**i)%10000#m^n / 10^i if x > 0: ans = str(x) + s[i//4] + ans print(ans)
s589398269
p02265
u150984829
1,000
131,072
Wrong Answer
20
5,600
175
Your task is to implement a double linked list. Write a program which performs the following operations: * insert x: insert an element with key x into the front of the list. * delete x: delete the first element which has the key of x from the list. If there is not such element, you need not do anything. * deleteFirst: delete the first element from the list. * deleteLast: delete the last element from the list.
s=[] for _ in range(int(input())): e=input() if e[0]=='i':s=[e.split()[1]]+s else: n=len(s) if n==6:s.remove(e.split()[1]) elif n%2:s=s[1:] else:s.pop() print(*s)
s781524829
Accepted
770
69,740
268
import collections,sys def s(): d=collections.deque() input() for e in sys.stdin: if'i'==e[0]:d.appendleft(e[7:-1]) else: if' '==e[6]: m=e[7:-1] if m in d:d.remove(m) elif'i'==e[7]:d.popleft() else:d.pop() print(*d) if'__main__'==__name__:s()
s047825349
p03855
u116348130
2,000
262,144
Wrong Answer
2,107
54,912
1,379
There are N cities. There are also K roads and L railways, extending between the cities. The i-th road bidirectionally connects the p_i-th and q_i-th cities, and the i-th railway bidirectionally connects the r_i-th and s_i-th cities. No two roads connect the same pair of cities. Similarly, no two railways connect the same pair of cities. We will say city A and B are _connected by roads_ if city B is reachable from city A by traversing some number of roads. Here, any city is considered to be connected to itself by roads. We will also define _connectivity by railways_ similarly. For each city, find the number of the cities connected to that city by both roads and railways.
import copy import itertools def flatdupdel(fl): return set(list(itertools.chain.from_iterable(fl))) def find_root(roads, search): # s_list = [search] global rootlist if len(roads) >= 1 and len(search) >= 1: for num in search: list_mutch = [] for ind, road in enumerate(roads): if num in road: list_mutch.append(road) roads.pop(ind) if len(list_mutch) >= 1: li = flatdupdel(list_mutch) rootlist.append(li) find_root(roads, li) return 0 def find_dup(l1, l2): j_list = l1 + l2 return [x for x in set(j_list) if j_list.count(x) > 1] n, k, l = map(int, input().split()) w = [list(map(int, input().split())) for i in range(k+l)] ro = w[:k] ra = w[l:] ro_roots = {} ra_roots = {} answer = [] for num in range(1, n+1): ro_c = copy.copy(ro) rootlist = [] find_root(ro_c, [num]) final = list(flatdupdel(rootlist)) if final: final.remove(num) ro_roots[num] = final for num in range(1, n+1): ra_c = copy.copy(ra) rootlist = [] find_root(ra_c, [num]) final = list(flatdupdel(rootlist)) if final: final.remove(num) ra_roots[num] = final for i in range(1, n+1): answer.append(len(find_dup(ro_roots[i], ra_roots[i])) + 1) print(*answer)
s928427595
Accepted
1,028
41,472
1,598
from collections import* import sys input = sys.stdin.readline class UnionFind(object): def __init__(self, n): self.parents = [-1 for i in range(n)] def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x return n, k, l = map(int, input().split()) ro_cl = UnionFind(n) ra_cl = UnionFind(n) d = defaultdict(int) # ================================================================= # ra = w[l:] # for p, q in ro: # for p, q in ra: # ================================================================= for i in range(k): p, q = map(int, input().split()) ro_cl.union(p-1, q-1) for i in range(l): p, q = map(int, input().split()) ra_cl.union(p-1, q-1) # ================================================================= for i in range(n): d[(ro_cl.find(i), ra_cl.find(i))] += 1 print(*[d[(ro_cl.find(i), ra_cl.find(i))]for i in range(n)])
s422772805
p03759
u248221744
2,000
262,144
Wrong Answer
17
2,940
91
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 = list(map(int, input().split())) if b-a == c-b: print("Yes") else: print("No")
s609057472
Accepted
17
2,940
91
a, b, c = list(map(int, input().split())) if b-a == c-b: print("YES") else: print("NO")
s910809492
p03433
u551109821
2,000
262,144
Wrong Answer
17
2,940
90
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()) if (N-A)%500==0: print('Yes') else: print('No')
s560080922
Accepted
17
2,940
88
N = int(input()) A = int(input()) if N%500 <= A: print('Yes') else: print('No')
s346556856
p03943
u822353071
2,000
262,144
Wrong Answer
22
3,064
372
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.
# starttime=time.clock() A,B,C =input().split() a=int(A) b=int(B) c=int(C) print(a+c) if a>b: temp = a a = b b = temp if b>c: temp = b b = c c = temp if (a+b)==c: print("Yes") else: print("No") #
s487474373
Accepted
21
3,064
176
a,b,c = map(int,input().split()) if a>b: temp = a a = b b = temp if b>c: temp = b b = c c = temp if (a+b)==c: print("Yes") else: print("No")
s648968180
p03605
u923659712
2,000
262,144
Wrong Answer
17
2,940
67
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?
n=input() if n[0]==9 or n[1]==9: print("Yes") else: print("No")
s720978655
Accepted
17
2,940
71
n=input() if n[0]=="9" or n[1]=="9": print("Yes") else: print("No")
s443657264
p03672
u653807637
2,000
262,144
Wrong Answer
17
2,940
166
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.
# encoding:utf-8 S = input() for i in range(2 , len(S), 2): mid_p = int((len(S) - i)/2) if S[0:mid_p] == S[mid_p:(len(S) - i)]: print(S[0:(len(S) - i)]) break
s349298245
Accepted
17
2,940
163
# encoding:utf-8 S = input() for i in range(2 , len(S), 2): mid_p = int((len(S) - i)/2) if S[0:mid_p] == S[mid_p:(len(S) - i)]: print(int(len(S) - i)) break
s607839028
p03352
u968649733
2,000
1,048,576
Wrong Answer
17
3,060
30
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
print(int(int(input())**0.25))
s845844564
Accepted
18
3,060
212
X = int(input()) max_v = 1 b = 2 for i in range(2, X): b =i for j in range(2,X): p = j if b**p > max_v and b**p <= X: #print(b, p) max_v = b**p elif b**p > X: break print(max_v)
s969232746
p03377
u608726540
2,000
262,144
Wrong Answer
17
2,940
116
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
li = list(map(int,input().split())) if li[0]<=li[2] and li[0]+li[1]>=li[2]: print('Yes') else: print('No')
s649480629
Accepted
17
2,940
116
li = list(map(int,input().split())) if li[0]<=li[2] and li[0]+li[1]>=li[2]: print('YES') else: print('NO')
s324316752
p03089
u580697892
2,000
1,048,576
Wrong Answer
17
3,060
307
Snuke has an empty sequence a. He will perform N operations on this sequence. In the i-th operation, he chooses an integer j satisfying 1 \leq j \leq i, and insert j at position j in a (the beginning is position 1). You are given a sequence b of length N. Determine if it is possible that a is equal to b after N operations. If it is, show one possible sequence of operations that achieves it.
#coding: utf-8 n = int(input()) a = [] b = list(map(int, input().split())) b_sort = sorted(b) cnt = 0 for i in range(1, n+1): if b_sort[i-1] <= i: a.append(b_sort[i-1]) else: pass print(a) if len(a) == len(b_sort): for i in range(len(a)): print(a[i]) else: print(-1)
s897297971
Accepted
20
3,064
371
#coding: utf-8 n = int(input()) a = [] b = list(map(int, input().split())) flag = True for _ in range(n): add = 0 for j in range(1, len(b)+1): if j == b[j-1]: add = max(add, j) if add == 0: flag = False break a.append(add) del b[add-1] if flag: for i in range(len(a)): print(a[-i-1]) else: print(-1)
s474864769
p02277
u657361950
1,000
131,072
Wrong Answer
20
5,600
867
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode: Partition(A, p, r) 1 x = A[r] 2 i = p-1 3 for j = p to r-1 4 do if A[j] <= x 5 then i = i+1 6 exchange A[i] and A[j] 7 exchange A[i+1] and A[r] 8 return i+1 Quicksort(A, p, r) 1 if p < r 2 then q = Partition(A, p, r) 3 run Quicksort(A, p, q-1) 4 run Quicksort(A, q+1, r) Here, A is an array which represents a deck of cards and comparison operations are performed based on the numbers. Your program should also report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
class Card: def __init__(self, m, n, o): self.m = m self.n = n self.o = o def __str__(self): return str(self.m + ' ' + str(self.n)) def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp def partition(a, f, c): x = a[c].n i = f - 1 for j in range(f, c): if a[j].n <= x: i += 1 swap(a, i, j) swap(a, i + 1, c) return i + 1 def quick_sort(a, f, c): if (f < c): q = partition(a, f, c) quick_sort(a, f, q - 1) quick_sort(a, q + 1, c) def check_stability(a): for i in range(1, len(a)): c1 = a[i-1] c2 = a[i] if (c1.n == c2.n and c1.o > c2.o): return False return True n = int(input()) cards = [] for i in range(n): m, num = map(str, input().split()) cards.append(Card(m, num, i)) quick_sort(cards, 0, n - 1) if (check_stability(cards)): print('Stable') else: print('Not stable') for i in range(n): print(cards[i])
s712210441
Accepted
1,410
29,656
880
class Card: def __init__(self, m, n, o): self.m = m self.n = n self.o = o def __str__(self): return str(self.m + ' ' + str(self.n)) def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp def partition(a, f, c): x = a[c].n i = f - 1 for j in range(f, c): if a[j].n <= x: i += 1 swap(a, i, j) swap(a, i + 1, c) return i + 1 def quick_sort(a, f, c): if (f < c): q = partition(a, f, c) quick_sort(a, f, q - 1) quick_sort(a, q + 1, c) def check_stability(a): for i in range(1, len(a)): c1 = a[i-1] c2 = a[i] if (c1.n == c2.n and c1.o > c2.o): return False return True n = int(input()) cards = [] for i in range(n): m, num = map(str, input().split()) cards.append(Card(m, int(num), i)) quick_sort(cards, 0, n - 1) if (check_stability(cards) == True): print('Stable') else: print('Not stable') for i in range(n): print(cards[i])
s713362409
p03997
u956866689
2,000
262,144
Wrong Answer
18
2,940
92
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.
# -*- coding:utf-8 -*- a = int(input()) b = int(input()) h= int(input()) print((a+b)*h/2)
s567304669
Accepted
18
2,940
97
# -*- coding:utf-8 -*- a = int(input()) b = int(input()) h= int(input()) print(int((a+b)*h/2))
s387580759
p03227
u683134447
2,000
1,048,576
Wrong Answer
17
2,940
70
You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.
s = input() if len(s) == 3: print(reversed(s)) else: print(s)
s624623084
Accepted
17
2,940
66
s = input() if len(s) == 3: print(s[::-1]) else: print(s)
s151864059
p03339
u013408661
2,000
1,048,576
Wrong Answer
2,104
5,916
324
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = `E`, and west if S_i = `W`. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions.
n=int(input()) line=list(str(input())) def turn_e(x): count=0 for i in range(x): if line[x]=='W': count+=1 return count def turn_w(x): count=0 for i in range(x+1,n): if line[x]=='E': count+=1 return count v=n for i in range(n): if (turn_e(i)+turn_w(i))<v: v=turn_e(i)+turn_w(i) print(v)
s554639144
Accepted
195
3,700
163
n=int(input()) s=input() e=s.count('E') w=0 ans=e+w p=0 for i in s: if p==1: w+=1 p=0 if i=='E': e-=1 else: p=1 ans=min(ans,e+w) print(ans)
s022262598
p03457
u530786533
2,000
262,144
Wrong Answer
32
9,192
261
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.
n = int(input()) curx, cury = 0, 0 ans = 'Yes' prev_t = 0 for _ in range(n): t, x, y = map(int, input().split()) d = abs(x - curx) + abs(y - cury) if d > (t - prev_t) or (t - prev_t) % 2 != d % 2: ans = 'No' break prev_t = t print(ans)
s824066711
Accepted
228
9,188
271
n = int(input()) curt, curx, cury = 0, 0, 0 ans = 'Yes' for _ in range(n): t, x, y = map(int, input().split()) d = abs(x - curx) + abs(y - cury) if d > (t - curt) or (t - curt) % 2 != d % 2: ans = 'No' break curt, curx, cury = t, x, y print(ans)
s846440313
p00042
u301729341
1,000
131,072
Wrong Answer
30
7,756
629
宝物がたくさん収蔵されている博物館に、泥棒が大きな風呂敷を一つだけ持って忍び込みました。盗み出したいものはたくさんありますが、風呂敷が耐えられる重さが限られており、これを超えると風呂敷が破れてしまいます。そこで泥棒は、用意した風呂敷を破らず且つ最も価値が高くなるようなお宝の組み合わせを考えなくてはなりません。 風呂敷が耐えられる重さ W、および博物館にある個々のお宝の価値と重さを読み込んで、重さの総和が W を超えない範囲で価値の総和が最大になるときの、お宝の価値総和と重さの総和を出力するプログラムを作成してください。ただし、価値の総和が最大になる組み合わせが複数あるときは、重さの総和が小さいものを出力することとします。
C_num = 1 while True: Nap = [] W = int(input()) if W == 0: break N = int(input()) for i in range(N): v,w = map(int,input().split(",")) Nap.append([v,w]) DP = [[0 for j in range(W + 1)] for i in range(N + 1)] for i in range(1,N+1): for j in range(W+1): if j - Nap[i-1][1] >= 0: DP[i][j] = max(DP[i-1][j],DP[i - 1][j - Nap[i - 1][1]] + Nap[i - 1][0]) else: DP[i][j] = DP[i-1][j] omo = DP[N].index(DP[N][W]) print("Case ",C_num,":",sep = "",end = "\n") print(DP[N][W]) print(omo)
s079563928
Accepted
1,240
20,020
644
C_num = 1 while True: Nap = [] W = int(input()) if W == 0: break N = int(input()) for i in range(N): v,w = map(int,input().split(",")) Nap.append([v,w]) DP = [[0 for j in range(W + 1)] for i in range(N + 1)] for i in range(1,N+1): for j in range(W+1): if j - Nap[i-1][1] >= 0: DP[i][j] = max(DP[i-1][j],DP[i - 1][j - Nap[i - 1][1]] + Nap[i - 1][0]) else: DP[i][j] = DP[i-1][j] omo = DP[N].index(DP[N][W]) print("Case ",C_num,":",sep = "",end = "\n") print(DP[N][W]) print(omo) C_num += 1
s570499261
p03160
u863370423
2,000
1,048,576
Wrong Answer
151
13,928
284
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
N = int(input()); salto = [int(i) for i in input().split()]; Costo = [float('inf')]*(N - 2)+[0, abs(salto[1] - salto[0])] ; for i in range(2, N): Costo[i] = min(Costo[i - 2] + abs(salto[i] - salto[i - 2]), Costo[i - 1] + abs(salto[i] - salto[i - 1])); print(Costo[N - 1]);
s830327515
Accepted
117
20,572
202
n=int(input()) h=list(map(int,input().split())) dp=[0]*(n+1) dp[0]=0 dp[1]=abs(h[1]-h[0]) for i in range(2,n): dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])) # print(dp) print(dp[-2])
s443584726
p04011
u409064224
2,000
262,144
Wrong Answer
17
2,940
119
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()) x = int(input()) y = int(input()) if n <= k: print(x*n) else: print(x*n+(k-n)*y)
s421213584
Accepted
17
2,940
120
n = int(input()) k = int(input()) x = int(input()) y = int(input()) if n > k: print(k*x + (n-k)*y) else: print(n*x)
s417697833
p03485
u294385082
2,000
262,144
Wrong Answer
17
2,940
70
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.
from math import ceil a,b = map(int,input().split()) print(ceil(a*b))
s377410534
Accepted
17
2,940
75
from math import ceil a,b = map(int,input().split()) print(ceil((a+b)/2))
s230910796
p00001
u584935933
1,000
131,072
Wrong Answer
30
7,388
480
There is a data which provides heights (in meter) of mountains. The data is only for ten mountains. Write a program which prints heights of the top three mountains in descending order.
inp=[] for i in range(0,10): inp.append(input()) INP=[0,0,0,0,0,0,0,0,0,0] for i in range(0,10): for j in range(i+1,10): if inp[i]==inp[j]: INP[i]+=1 INP[j]+=1 elif inp[i]<inp[j]: INP[j]+=1 else: INP[i]+=1 z = 0 for i in range(9,-1,-1): if z >= 3: break for j in range(0,10): if i == INP[j]: print(inp[j]) z+=1 if z >= 3: break
s535362378
Accepted
20
7,648
498
a=[] for i in range(0,10): a.append(input()) inp = list(map(int,a)) INP=[0,0,0,0,0,0,0,0,0,0] for i in range(0,10): for j in range(i+1,10): if inp[i]<inp[j]: INP[j]+=1 elif inp[i]>inp[j]: INP[i]+=1 else: INP[i]+=1 INP[j]+=1 z = 0 for i in range(9,-1,-1): if z >= 3: break for j in range(0,10): if i == INP[j]: print(inp[j]) z+=1 if z >= 3: break
s339141063
p02659
u165318982
2,000
1,048,576
Wrong Answer
28
9,064
86
Compute A \times B, truncate its fractional part, and print the result as an integer.
import math A, B = list(map(float, input().split())) ans = math.ceil(A * B) print(ans)
s570871074
Accepted
34
10,064
102
from decimal import Decimal import math a, b = input().split() print(math.floor(int(a) * Decimal(b)))
s129797437
p03455
u693694535
2,000
262,144
Wrong Answer
17
2,940
77
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%2==0: print('Even') else: print('Odd')
s681845694
Accepted
17
2,940
81
a,b=map(int,input().split()) if (a*b)%2==0: print('Even') else: print('Odd')
s298359345
p03473
u568426505
2,000
262,144
Wrong Answer
26
9,044
22
How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
print(int(input())+24)
s593857853
Accepted
24
8,976
22
print(48-int(input()))
s772571755
p03711
u470542271
2,000
262,144
Wrong Answer
17
2,940
160
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
x, y = map(int, input().split()) l1 = [1,3,5,7,8,10,12] l2 = [4,6,9,11] l3 = [2] print((x in l1 and y in l1) or (x in l2 and y in l2) or (x in l3 and y in l3))
s945475356
Accepted
17
2,940
198
x, y = map(int, input().split()) l1 = [1,3,5,7,8,10,12] l2 = [4,6,9,11] l3 = [2] if ((x in l1 and y in l1) or (x in l2 and y in l2) or (x in l3 and y in l3)): print('Yes') else: print('No')
s908264052
p03737
u064246852
2,000
262,144
Wrong Answer
17
2,940
42
You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words.
print(str.upper("".join(input().split())))
s277188798
Accepted
18
2,940
61
print(str.upper("".join(map(lambda x:x[0],input().split()))))
s957062706
p03485
u782269159
2,000
262,144
Wrong Answer
17
2,940
59
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()) c = -(-(a+b)/2) print(c)
s593433152
Accepted
17
2,940
60
a, b = map(int, input().split()) c = -(-(a+b)//2) print(c)
s427133859
p03659
u853900545
2,000
262,144
Wrong Answer
2,108
24,820
192
Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it. They will share these cards. First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards. Here, both Snuke and Raccoon have to take at least one card. Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively. They would like to minimize |x-y|. Find the minimum possible value of |x-y|.
n = int(input()) a = list(map(int,input().split())) c = 10**9 if n == 2: print(a[0]-a[1]) else: for i in range(n-2): c = min(c,abs(sum(a[:n-1-i:])-sum(a[n:1+i:-1]))) print(c)
s689473510
Accepted
172
24,824
239
n = int(input()) a = list(map(int,input().split())) A = sum(a[:n-1])-a[n-1] c = n*(10**9) c = min(c,abs(A)) if n == 2: print(abs(a[0]-a[1])) else: for i in range(1,n-2): A=A-2*a[n-1-i] c = min(c,abs(A)) print(c)
s975687380
p03478
u815659544
2,000
262,144
Wrong Answer
52
2,940
223
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
l = list(map(int, input().split())) cursum = 0 for n in range(1, l[0]+1): s = 0 x = n while x > 0: s += x % 10 x = int(x/10) if s <= l[2] and s >= l[1]: cursum += n print(n)
s413523548
Accepted
30
2,940
161
n,a,b = map(int, input().split()) cursum = 0 for x in range(1, n+1): y = sum(map(int, str(x))) if a <= y and y <= b: cursum += x print(cursum)
s579713702
p03163
u558242240
2,000
1,048,576
Wrong Answer
2,108
18,920
394
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
import numpy as np n, w = map(int, input().split()) wv = [tuple(map(int, input().split())) for _ in range(n)] dp = np.zeros((n+1, w), np.int64) for i in range(n): for sum_w in range(w): wi = wv[i][0] vi = wv[i][1] if sum_w - wi >= 0: dp[i+1][sum_w] = dp[i][sum_w - wi] + vi dp[i+1][sum_w] = max(dp[i][sum_w], dp[i+1][sum_w]) print(dp[n][w-1])
s549587108
Accepted
299
91,480
284
import numpy as np n, w = map(int, input().split()) wv = [tuple(map(int, input().split())) for _ in range(n)] dp = np.zeros((n+1, w+1), np.int64) for i, (wi, vi) in enumerate(wv): dp[i + 1] = dp[i] np.maximum(dp[i+1][wi:], dp[i][:-wi] + vi, out=dp[i+1][wi:]) print(dp[n, w])
s035167208
p02861
u026862065
2,000
1,048,576
Wrong Answer
17
3,064
324
There are N towns in a coordinate plane. Town i is located at coordinates (x_i, y_i). The distance between Town i and Town j is \sqrt{\left(x_i- x_j\right)^2+\left(y_i-y_j\right)^2}. There are N! possible paths to visit all of these towns once. Let the length of a path be the distance covered when we start at the first town in the path, visit the second, third, \dots, towns, and arrive at the last town (assume that we travel in a straight line from a town to another). Compute the average length of these N! paths.
n = int(input()) l, l1, l2 = list(""), list(""), list("") for i in range(n): x, y = map(int, input().split()) l1.append(x) l2.append(y) for i in range(n - 1): for j in range(i + 1, n): l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5) print(l) print('{:.10f}'.format(2 * sum(l) / len(l)))
s090699354
Accepted
17
3,064
310
n = int(input()) l, l1, l2 = list(""), list(""), list("") for i in range(n): x, y = map(int, input().split()) l1.append(x) l2.append(y) for i in range(n - 1): for j in range(i + 1, n): l.append(((l1[i] -l1[j]) ** 2 + (l2[i] - l2[j]) ** 2) ** 0.5) print('{:.10f}'.format(2 * sum(l) / n))
s896125756
p02742
u667024514
2,000
1,048,576
Wrong Answer
17
2,940
57
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:
n,m=map(int,input().split()) print((n//2+n%1)*(m//2+m%2))
s394662373
Accepted
17
2,940
108
import math h,w = map(int,input().split()) if h == 1 or w == 1: print(1) else: print(math.ceil((h*w)/2))
s700936854
p03494
u830054172
2,000
262,144
Wrong Answer
20
2,940
285
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: * Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform.
N = int(input()) A = [int(l) for l in input().split()] count1 = 0 k = 0 while True: count2 = 0 for i in range(N): if A[i]/2** k % 2 !=0: break else: count2 += 1 if count2 == N: count1 += 1 else: break k += 1
s483031887
Accepted
19
2,940
175
n = int(input()) a = list(map(int, input().split())) ans = [] for i in a: cnt = 0 while i%2 == 0: i /= 2 cnt += 1 ans.append(cnt) print(min(ans))
s651231294
p03434
u279229189
2,000
262,144
Wrong Answer
18
3,064
482
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
data = [input() for x in range(0, 2, 1)] cards = [int(x) for x in data[1].split(" ")] for i in range(0, len(cards), 1): for j in range(i + 1, len(cards), 1): if cards[i] > cards[j]: tmp1 = cards[i] tmp2 = cards[j] cards[i] = tmp2 cards[j] = tmp1 print(cards) alice = 0 bob = 0 for i, v in enumerate(cards): if i %2 == 0: alice += v else: bob += v print(alice - bob)
s572295401
Accepted
18
3,064
468
data = [input() for x in range(0, 2, 1)] cards = [int(x) for x in data[1].split(" ")] for i in range(0, len(cards), 1): for j in range(i + 1, len(cards), 1): if cards[i] < cards[j]: tmp1 = cards[i] tmp2 = cards[j] cards[i] = tmp2 cards[j] = tmp1 alice = 0 bob = 0 for i, v in enumerate(cards): if i %2 == 0: alice += v else: bob += v print(alice - bob)
s488197800
p04012
u592248346
2,000
262,144
Wrong Answer
17
2,940
122
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = list(input()) x = set(w) for i in x: if w.count(i)%2!=0: print("NO") break else: print("YES")
s756633982
Accepted
19
2,940
121
w = list(input()) x = set(w) for i in x: if w.count(i)%2!=0: print("No") break else: print("Yes")
s139896119
p00008
u301461168
1,000
131,072
Wrong Answer
30
7,536
228
Write a program which reads an integer n and identifies the number of combinations of a, b, c and d (0 ≤ a, b, c, d ≤ 9) which meet the following equality: a + b + c + d = n For example, for n = 35, we have 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).
n = int(input().rstrip()) cnt = 0 for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == n: cnt = cnt + 1 print(str(cnt))
s624323176
Accepted
190
7,492
342
while True: try: cnt = 0 n = int(input()) for a in range(10): for b in range(10): for c in range(10): for d in range(10): if a + b + c + d == n: cnt = cnt + 1 print(str(cnt)) except: break
s666514641
p03139
u225388820
2,000
1,048,576
Wrong Answer
17
2,940
59
We conducted a survey on newspaper subscriptions. More specifically, we asked each of the N respondents the following two questions: * Question 1: Are you subscribing to Newspaper X? * Question 2: Are you subscribing to Newspaper Y? As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2. What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y? Write a program to answer this question.
n,a,b=map(int,input().split()) print(max(a+b-n,0),min(a,b))
s138223808
Accepted
17
2,940
59
n,a,b=map(int,input().split()) print(min(a,b),max(a+b-n,0))
s577095374
p03657
u201082459
2,000
262,144
Wrong Answer
18
2,940
95
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a,b = map(int,input().split()) if a+b % 3 == 0: print('Possible') else: print('Impossible')
s363555063
Accepted
17
2,940
171
a,b = map(int,input().split()) if (a+b) % 3 == 0: print('Possible') elif a % 3 == 0: print('Possible') elif b % 3 == 0: print('Possible') else: print('Impossible')
s914629371
p03623
u798316285
2,000
262,144
Wrong Answer
17
2,940
119
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
s=input() for i in range(ord("a"),ord("z")+1): if chr(i) not in s: print(chr(i)) break else: print("None")
s592699872
Accepted
17
2,940
71
x,a,b=map(int,input().split()) print("A" if abs(x-a)<abs(x-b) else "B")
s935761581
p03623
u608726540
2,000
262,144
Wrong Answer
17
2,940
89
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b=map(int,input().split()) if abs(x-a)>abs(x-b): print('A') else: print('B')
s075888704
Accepted
17
2,940
89
x,a,b=map(int,input().split()) if abs(x-a)<abs(x-b): print('A') else: print('B')
s039322914
p03359
u219369949
2,000
262,144
Wrong Answer
18
2,940
83
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 + 1: print(a) else: print(a + 1)
s464787081
Accepted
17
2,940
79
a, b = map(int, input().split()) if a > b: print(a - 1) else: print(a)
s586830234
p03672
u739843002
2,000
262,144
Wrong Answer
24
9,048
242
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.
def isEvenStr(s): if len(s) % 2 == 1: return False elif s[0:int(len(s)/2)] == s[int(len(s)/2):]: return True else: return False s = input() i = 0 while not isEvenStr(s): s = s[:-1] i += 1 if isEvenStr(s): print(i)
s394754981
Accepted
24
9,036
268
def isEvenStr(s): if len(s) % 2 == 1: return False elif s[0:int(len(s)/2)] == s[int(len(s)/2):]: return True else: return False s = input() l = len(s) i = 0 while not isEvenStr(s) or i == 0: s = s[:-1] i += 1 if isEvenStr(s): print(l - i)
s405543523
p03695
u644907318
2,000
262,144
Wrong Answer
17
3,064
541
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
N = int(input()) A = sorted(list(map(int,input().split()))) G = {i:0 for i in range(9)} for i in range(N): if A[i]<=399: G[0] += 1 elif A[i]<=799: G[1] += 1 elif A[i]<=1199: G[2] += 1 elif A[i] <= 1599: G[3] += 1 elif A[i] <= 1999: G[4] += 1 elif A[i] <= 2399: G[5] += 1 elif A[i] <= 2799: G[6] += 1 elif A[i] <= 3199: G[7] += 1 else: G[8] += 1 cnt = 0 for i in range(8): if G[i] > 0: cnt += 1 cmin = cnt cmax = cmin+G[8]
s680190503
Accepted
17
3,064
612
N = int(input()) A = sorted(list(map(int,input().split()))) G = {i:0 for i in range(9)} for i in range(N): if A[i]<=399: G[0] += 1 elif A[i]<=799: G[1] += 1 elif A[i]<=1199: G[2] += 1 elif A[i] <= 1599: G[3] += 1 elif A[i] <= 1999: G[4] += 1 elif A[i] <= 2399: G[5] += 1 elif A[i] <= 2799: G[6] += 1 elif A[i] <= 3199: G[7] += 1 else: G[8] += 1 cnt = 0 for i in range(8): if G[i] > 0: cnt += 1 if cnt==0: cmin = 1 cmax = G[8] else: cmin = cnt cmax = cmin+G[8] print(cmin,cmax)
s721033324
p03448
u516494592
2,000
262,144
Wrong Answer
54
3,316
282
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for i in range(A + 1): for j in range(B + 1): for k in range(C + 1): total = 500 * A + 100 * B + 50 * C if total == X: count = count + 1 print(count)
s746558790
Accepted
55
3,060
282
A = int(input()) B = int(input()) C = int(input()) X = int(input()) count = 0 for a in range(A + 1): for b in range(B + 1): for c in range(C + 1): total = 500 * a + 100 * b + 50 * c if total == X: count = count + 1 print(count)
s062839152
p02409
u442346200
1,000
131,072
Wrong Answer
30
6,720
332
You manage 4 buildings, each of which has 3 floors, each of which consists of 10 rooms. Write a program which reads a sequence of tenant/leaver notices, and reports the number of tenants for each room. For each notice, you are given four integers b, f, r and v which represent that v persons entered to room r of fth floor at building b. If v is negative, it means that −v persons left. Assume that initially no person lives in the building.
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)] n = int(input()) for c in range(n): (b, f, r, v) = [int(i) for i in input().split()] data[b-1][f-1][r-1] += v for b in range(4): for f in range(3): for r in range(10): print(' {0}'.format(data[b][f][r]), end='') print() print('#' * 20)
s158287288
Accepted
30
6,724
378
data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)] count = int(input()) for c in range(count): (b, f, r, v) = [int(x) for x in input().split()] data[b - 1][f - 1][r - 1] += v for b in range(4): for f in range(3): for r in range(10): print('',data[b][f][r], end='') print() if b < 3: print('#' * 20)
s092887595
p00038
u075836834
1,000
131,072
Wrong Answer
50
7,620
840
ポーカーの手札データを読み込んで、それぞれについてその役を出力するプログラムを作成してください。ただし、この問題では、以下のルールに従います。 * ポーカーはトランプ 5 枚で行う競技です。 * 同じ数字のカードは 5 枚以上ありません。 * ジョーカーは無いものとします。 * 以下のポーカーの役だけを考えるものとします。(番号が大きいほど役が高くなります。) 1. 役なし(以下に挙げるどれにも当てはまらない) 2. ワンペア(2 枚の同じ数字のカードが1 組ある) 3. ツーペア(2 枚の同じ数字のカードが2 組ある) 4. スリーカード(3 枚の同じ数字のカードが1 組ある) 5. ストレート(5 枚のカードの数字が連続している) ただし、A を含むストレートの場合、A で終わる並びもストレートとします。つまり、A を含むストレート は、A 2 3 4 5 と 10 J Q K A の2種類です。J Q K A 2 などのように、A をまたぐ並び はストレートではありません。(この場合、「役なし」になります)。 6. フルハウス(3 枚の同じ数字のカードが1 組と、残りの2 枚が同じ数字のカード) 7. フォーカード(4 枚の同じ数字のカードが1 組ある)
def function(a,b,c,d,e): A=[a,b,c,d,e] A.sort() #4card if A[0]==A[1]==A[2]==A[3] or A[1]==A[2]==A[3]==A[4]: print("four card") #Full house elif (A[0]==A[1] and A[2]==A[3]==A[4]) or (A[0]==A[1]==A[2] and A[3]==A[4]): print("full house") #straight A????????? elif A[0]==1 and A[1]==10 and A[2]==11 and A[3]==12 and A[4]==13: print("straight") #straight A??????????????? elif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4: print("straight") #threee elif A[0]==A[1]==A[2] or A[1]==A[2]==A[3] or A[2]==A[3]==A[4]: print("threee card") elif (A[0]==A[1] and A[2]==A[3]) or (A[1]==A[2] and A[3]==A[4]): print("two pair") elif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]: print("one pair") else: print("null") while True: try: a,b,c,d,e=map(float,input().split(',')) function(a,b,c,d,e) except EOFError: break
s640366106
Accepted
30
7,752
694
def function(a,b,c,d,e): A=[a,b,c,d,e] A.sort() if A[0]==A[3] or A[1]==A[4]: print("four card") elif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]): print("full house") elif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]: print("three card") elif (A[0]==A[1] and A[2]==A[3]) or (A[0]==A[1] and A[3]==A[4]) or (A[1]==A[2] and A[3]==A[4]): print("two pair") elif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]: print("one pair") elif A==[1,10,11,12,13]: print("straight") elif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4: print("straight") else: print("null") while True: try: a,b,c,d,e=map(int,input().split(',')) function(a,b,c,d,e) except EOFError: break
s109737899
p02268
u153665391
1,000
131,072
Wrong Answer
20
7,760
618
You are given a sequence of _n_ integers S and a sequence of different _q_ integers T. Write a program which outputs C, the number of integers in T which are also in the set S.
def binary_search(S, n, index ): if S[index] == n: return 'eq' elif S[index] < n: return 'bt' elif S[index] > n: return 'lt' n = int(input()) S = [int(i) for i in input().split()] q = int(input()) T = [int(i) for i in input().split()] cnt = 0 for i in T: mini = 0 maxi = len(T) - 1 while int(maxi - mini) >= 0: index = int( mini + maxi ) rs = binary_search(S, i, index ) if rs == 'eq': cnt += 1 break elif rs == 'bt': mini = index + 1 elif rs == 'lt': maxi = index - 1 print(cnt)
s128915765
Accepted
390
16,708
519
N = int(input()) S = list(map(int, input().split())) Q = int(input()) T = list(map(int, input().split())) def binary_search(target_num, head, tail): while head <= tail: idx = int((head+tail)/2) if target_num == S[idx]: return True elif target_num < S[idx]: tail = idx - 1 else: head = idx + 1 return False match_count = 0 for target_num in T: if binary_search(target_num, 0, len(S)-1): match_count += 1 print(str(match_count))
s411442969
p02694
u285891772
2,000
1,048,576
Wrong Answer
30
10,072
828
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 X = INT() a = 100 ans = 0 while a <= X: a *= 1.01 a = int(a) ans += 1 print(ans)
s813814338
Accepted
29
10,040
825
import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd from itertools import accumulate, permutations, combinations, product, groupby from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 X = INT() a = 100 ans = 0 while a < X: a = int(1.01*a) ans += 1 print(ans)
s700587922
p03160
u755215227
2,000
1,048,576
Wrong Answer
17
2,940
20
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
times = int(input())
s355295368
Accepted
157
14,400
400
times = int(input()) line = input() list1 = [] if times <= 1: print("%s" % 0) else: for i in line.split(): if i: list1.append(int(i)) mem = [0] * times mem[-2] = abs(list1[-1] - list1[-2]) for i in range(len(list1)-3, -1, -1): step1 = abs(list1[i] - list1[i+1]) + mem[i+1] step2 = abs(list1[i] - list1[i+2]) + mem[i+2] mem[i] = min(step1,step2) print("%s" % mem[0])
s484933864
p03827
u128914900
2,000
262,144
Wrong Answer
17
2,940
110
You have an integer variable x. Initially, x=0. Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`. Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
n = int(input()) s = input() x = 0 for i in range(n): if s[i] == "I": x +=1 else: x = x-1 print(x)
s182307923
Accepted
18
3,060
180
n = int(input()) s = input() x = 0 result = 0 for i in range(n): if s[i] == "I": x +=1 result = max(x,result) else: x = x-1 result = max(x,result) print(result)
s653097789
p03549
u521323621
2,000
262,144
Wrong Answer
95
9,400
186
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is `YES` or `NO`. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: * Submit the code. * Wait until the code finishes execution on all the cases. * If the code fails to correctly solve some of the M cases, submit it again. * Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).
import math n,m = map(int, input().split()) ans = 0 time = (n-m) * 100 + m * 1900 for i in range(1,100000): ans += pow(1-pow(0.5,m),i-1) * pow(0.5,m) * time * i print(math.ceil(ans))
s245216834
Accepted
678
9,596
297
import math n,m = map(int, input().split()) ans = 0 time = (n-m) * 100 + m * 1900 for i in range(1, 1000000): ans += pow(1-pow(0.5,m),i-1) * pow(0.5,m) * time * i temp = math.ceil(ans) if str(temp)[-1] == "1": print(temp - 1) elif str(temp)[-1] == "9": print(temp + 1) else: print(temp)
s234206312
p02645
u366424761
2,000
1,048,576
Wrong Answer
21
9,084
30
When you asked some guy in your class his name, he called himself S, where S is a string of length between 3 and 20 (inclusive) consisting of lowercase English letters. You have decided to choose some three consecutive characters from S and make it his nickname. Print a string that is a valid nickname for him.
s = str(input()) print(s[0:2])
s331218026
Accepted
20
9,020
25
s = input() print(s[0:3])
s544176328
p03610
u080990738
2,000
262,144
Wrong Answer
66
3,188
174
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.
alphabet="abcdefghijklmnopqrstuvwxyz" st=input() s="" for i in range(0,len(st)): if alphabet.index(st[i]) % 2 == 0: s+=str(st[i]) else: pass print(s)
s548080130
Accepted
41
3,188
115
st=input() s="" for i in range(0,len(st)): if i % 2 ==0: s+=str(st[i]) else: pass print(s)
s823829530
p04012
u396391104
2,000
262,144
Wrong Answer
17
2,940
80
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = list(input()) print("Yes") if len(w) == len(list(set(w)))*2 else print("No")
s171953008
Accepted
17
2,940
88
w = list(input()) for c in w: if w.count(c)%2: print("No") exit() print("Yes")
s329113158
p03448
u744034042
2,000
262,144
Wrong Answer
46
3,060
233
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count = 0 for i in range(a): for j in range(b): for k in range(c): if 500*i + 100*j + 50*k == x: count += 1 print(int(count))
s538300467
Accepted
50
3,064
239
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i + 100*j + 50*k == x: count += 1 print(int(count))
s454962156
p03680
u142415823
2,000
262,144
Wrong Answer
191
7,080
207
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 = [0 for _ in range(N)] for i in range(N): a[i] = int(input()) c = 0 x = 1 while(x != 2): x = a[x-1] if not x: c = -1 break else: c += 1 a[x - 1] = False print(c)
s128559366
Accepted
229
7,080
217
N = int(input()) a = [0 for _ in range(N)] for i in range(N): a[i] = int(input()) c = 0 x = 1 while(x != 2): nex = a[x-1] if not nex: c = -1 break else: c += 1 a[x-1] = 0 x = nex print(c)
s570627617
p03352
u323626540
2,000
1,048,576
Wrong Answer
17
3,060
171
You are given a positive integer X. Find the largest _perfect power_ that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2.
X = int(input()) ans = 0 if X == 1: print(1) exit() for b in range(2, 32): p = 0 while b ** (p+1) <= X: p += 1 ans = max(ans, b**p) print(ans)
s833020009
Accepted
17
3,060
207
X = int(input()) ans = 0 if X < 2**2: print(1) exit() for b in range(2, 32): p = 2 if b ** p > X: continue while b ** (p+1) <= X: p += 1 ans = max(ans, b**p) print(ans)
s429875160
p03433
u563145186
2,000
262,144
Wrong Answer
17
2,940
109
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()) t = N%500 if t <= A: print("yes") else: print("no")
s996425555
Accepted
17
2,940
108
N = int(input()) A = int(input()) t = N%500 if t <= A: print("Yes") else: print("No")
s270245415
p03049
u389679466
2,000
1,048,576
Wrong Answer
35
3,956
642
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
import math N = int(input()) l = [] for i in range(N): l.append(input()) default = sum(['AB' in i for i in l]) print(l) a = sum([i[-1]=='A' and i[0]!='B' for i in l]) b = sum([i[0]=='B' and i[-1]!='A' for i in l]) ab = sum([i[0]=='B' and i[-1]=='A' for i in l]) # print("a = ", str(a)) # print("b = ", str(b)) if a == b: num = a + math.floor(ab/2) else: min = min(a, b) max = max(a, b) gap = abs(a-b) if ab <= gap: num = min + ab elif ab > gap: num = max + math.floor((ab - gap)/2) print(num + default)
s983075747
Accepted
35
3,700
595
# wrong answer... import math N = int(input()) l = [] for i in range(N): l.append(input()) default = sum([i.count('AB') for i in l]) a = sum([i[-1]=='A' and i[0]!='B' for i in l]) b = sum([i[0]=='B' and i[-1]!='A' for i in l]) ab = sum([i[0]=='B' and i[-1]=='A' for i in l]) num = 0 if ab == 0: num = min(a, b) elif a + b > 0: num = min(a, b) + ab else: num = ab -1 print(num + default)
s610122851
p03693
u810735437
2,000
262,144
Wrong Answer
64
5,844
313
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?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array from bisect import * from collections import * import fractions import heapq from itertools import * import math import re import string R, G, B = map(int, input().split()) if int(R + G + B) % 4 == 0: ans = 'YES' else: ans = 'NO' print(ans)
s918910123
Accepted
41
5,460
303
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import array from bisect import * from collections import * import fractions import heapq from itertools import * import math import re import string R, G, B = input().split() if int(R + G + B) % 4 == 0: ans = 'YES' else: ans = 'NO' print(ans)
s522632526
p03624
u538956308
2,000
262,144
Wrong Answer
20
3,956
105
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print `None` instead.
S = input() str = "abcdefghijklmnopqrstuvwxyz" l1 = list(str) l2 = list(S) l3 = set(l1)-set(l2) print(l3)
s738280449
Accepted
21
3,956
168
S = input() str = "abcdefghijklmnopqrstuvwxyz" l1 = list(str) l2 = list(S) l3 = list(set(l1)-set(l2)) l3.sort() if len(l3)==0: print("None") else: print(l3[0])
s038679274
p02401
u067975558
1,000
131,072
Wrong Answer
30
6,740
360
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: i = input().split() result = 0 if i[1] == '+': print(int(i[0]) + int(i[2])) elif i[1] == '-': print(int(i[0]) - int(i[2])) elif i[1] == '/': print(int(i[0]) / int(i[2])) elif i[1] == '*': print(int(i[0]) * int(i[2])) elif i[1] == '?': break
s810239461
Accepted
40
6,732
407
result = [] while True: i = input().split() if i[1] == '+': result = result +[int(i[0]) + int(i[2])] elif i[1] == '-': result = result + [int(i[0]) - int(i[2])] elif i[1] == '/': result = result + [int(int(i[0]) / int(i[2]))] elif i[1] == '*': result = result + [int(i[0]) * int(i[2])] elif i[1] == '?': break for i in result: print(i)
s742988873
p03502
u039623862
2,000
262,144
Wrong Answer
22
3,316
76
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 = input() print('Yes' if sum([int(c) for c in n]) % int(n) == 0 else 'No')
s165105586
Accepted
19
2,940
77
n = input() print('Yes' if int(n) % sum([int(c) for c in n]) == 0 else 'No')
s205321075
p03486
u143492911
2,000
262,144
Wrong Answer
17
2,940
108
You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s' < t' for the lexicographic order.
s=list(input()) t=list(input()) s.sort() t.sort() t.reverse() if s<t: print("yes") else: print("no")
s646615284
Accepted
17
2,940
108
s=list(input()) t=list(input()) s.sort() t.sort() t.reverse() if s<t: print("Yes") else: print("No")
s481404564
p03679
u167908302
2,000
262,144
Wrong Answer
17
2,940
143
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
#coding:utf-8 x, a, b = map(int, input().split()) if a <= b: print('delicious') elif (a+x) <= b: print('safe') else: print('dangerous')
s565436994
Accepted
17
2,940
144
#coding:utf-8 x, a, b = map(int, input().split()) if a >= b: print('delicious') elif (a+x) >= b: print('safe') else: print('dangerous')
s908073046
p03778
u143051858
2,000
262,144
Wrong Answer
17
2,940
122
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
W,a,b = map(int,input().split()) if a+W < b: print(abs(b-a+W)) elif b+W < a: print(abs(b+W-a)) else: print(0)
s116336088
Accepted
18
2,940
122
W,a,b = map(int,input().split()) if a+W < b: print(abs(a+W-b)) elif b+W < a: print(abs(b+W-a)) else: print(0)
s544407584
p03163
u059436995
2,000
1,048,576
Wrong Answer
17
3,064
351
There are N items, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), Item i has a weight of w_i and a value of v_i. Taro has decided to choose some of the N items and carry them home in a knapsack. The capacity of the knapsack is W, which means that the sum of the weights of items taken must be at most W. Find the maximum possible sum of the values of items that Taro takes home.
n, W =map(int,input().split()) w = [0] * n v = [0] * n for i in range(n): w[i], v[i] = map(int, input().split()) def ks(W,w,v,n): if n == 0 or W == 0 : return 0 if (w[n-1] > W): return ks(W, w, v, n - 1) else: return max(v[n - 1] + ks(W - w[n - 1], w, v, n - 1), ks(W, w, v, n - 1))
s981778223
Accepted
290
18,208
207
import numpy as np N,W = map(int,input().split()) ndp = np.zeros(W+1,dtype= np.int64) for _ in range(N): w,v = map(int,input().split()) np.maximum(ndp[:-w] + v, ndp[w:], out = ndp[w:]) print(ndp[-1])
s205510903
p03997
u156346531
2,000
262,144
Wrong Answer
17
2,940
134
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.
ue = int(input("上底:")) sita = int(input("下底:")) takasa = int(input("高さ:")) men = (ue+sita)*takasa/2 print(int(men))
s885857293
Accepted
17
2,940
101
ue = int(input()) sita = int(input()) takasa = int(input()) men = (ue+sita)*takasa/2 print(int(men))
s800882895
p03796
u537782349
2,000
262,144
Wrong Answer
35
2,940
90
Snuke loves working out. He is now exercising N times. Before he starts exercising, his _power_ is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7.
a = int(input()) b = 1 for i in range(a, 0, -1): b = b * i % (10 ** 9 + 7) print(b+b)
s313116931
Accepted
34
2,940
90
a = int(input()) b = 1 for i in range(1, a + 1): b = (b * i) % (10 ** 9 + 7) print(b)
s603857777
p02694
u973013625
2,000
1,048,576
Wrong Answer
23
9,156
88
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
x = int(input()) a = 100 c = 0 while a <= x: a += int(a * 0.01) c += 1 print(c)
s765060152
Accepted
23
9,160
87
x = int(input()) a = 100 c = 0 while a < x: a += int(a * 0.01) c += 1 print(c)
s933247708
p02314
u957470671
1,000
131,072
Wrong Answer
20
5,612
241
Find the minimum number of coins to make change for n cents using coins of denominations d1, d2,.., dm. The coins can be used any number of times.
n, m = input().split() n, m = int(n), int(m) C = [int(c) for c in input().split()] # Coin Changing Problem INF = float('inf') T = [INF] * n T[0] = 0 for c in C: for j in range(c, n): T[j] = min(T[j], T[j - c] + 1) print(T[-1])
s639840254
Accepted
530
7,524
230
n, m = input().split() n, m = int(n), int(m) C = [int(c) for c in input().split()] # Coin Changing Problem T = [0] + [float('inf')] * n for c in C: for j in range(c, n+1): T[j] = min(T[j], T[j - c] + 1) print(T[-1])
s345803894
p02261
u370086573
1,000
131,072
Wrong Answer
30
7,740
1,044
Let's arrange a deck of cards. There are totally 36 cards of 4 suits(S, H, C, D) and 9 values (1, 2, ... 9). For example, 'eight of heart' is represented by H8 and 'one of diamonds' is represented by D1. Your task is to write a program which sorts a given set of cards in ascending order by their values using the Bubble Sort algorithms and the Selection Sort algorithm respectively. These algorithms should be based on the following pseudocode: BubbleSort(C) 1 for i = 0 to C.length-1 2 for j = C.length-1 downto i+1 3 if C[j].value < C[j-1].value 4 swap C[j] and C[j-1] SelectionSort(C) 1 for i = 0 to C.length-1 2 mini = i 3 for j = i to C.length-1 4 if C[j].value < C[mini].value 5 mini = j 6 swap C[i] and C[mini] Note that, indices for array elements are based on 0-origin. For each algorithm, report the stability of the output for the given input (instance). Here, 'stability of the output' means that: cards with the same value appear in the output in the same order as they do in the input (instance).
def bubble_sort(r, n): flag = True while flag: flag = False for i in range(n - 1, 0, -1): if r[i - 1][1] > r[i][1]: r[i - 1], r[i] = r[i], r[i - 1] flag = True return r def select_sort(r, n): for i in range(0, n): minj = i for j in range(i, n): if r[j][1] < r[minj][1]: minj = j if i != minj: r[i], r[minj] = r[minj], r[i] return r def stable_sort(r, sort_r): for i in range(len(r)): for j in range(i + 1, len(r)): for a in range(len(sort_r)): for b in range(a + 1, len(sort_r)): if r[i][1] == r[j][1] and r[i] == sort_r[b] and r[j] == sort_r[a]: return "Not Stable" return "Stable" N = int(input()) R = list(input().split()) C = R[:] BS_R = bubble_sort(R, N) SS_R = select_sort(C, N) print(*BS_R) print(stable_sort(R, BS_R)) print(*SS_R) print(stable_sort(R, SS_R))
s775073974
Accepted
120
7,848
1,173
def selectionSort(n, A): cnt = 0 for i in range(n): minj = i for j in range(i, n): if A[minj][1] > A[j][1]: minj = j if i != minj: A[i], A[minj] = A[minj], A[i] cnt += 1 return A def bubbleSort(n, A): flag = True cnt = 0 while flag: flag = False for j in range(n - 1, 0, -1): if A[j - 1][1] > A[j][1]: A[j - 1], A[j] = A[j], A[j - 1] cnt += 1 flag = True return A def stableSort(input, output): n = len(input) for i in range(n): for j in range(i + 1, n): for a in range(n): for b in range(a + 1, n): if input[i][1] == input[j][1] and input[i] == output[b] and input[j] == output[a]: return print("Not stable") return print("Stable") if __name__ == '__main__': n = int(input()) R = list(map(str, input().split())) C = R[:] D = R[:] SR = selectionSort(n, R) BR = bubbleSort(n, C) print(*BR) stableSort(D,BR) print(*SR) stableSort(D,SR)
s482453211
p03944
u595716769
2,000
262,144
Wrong Answer
186
3,316
725
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
w, h, n = map(int, input().split()) L = [] for i in range(n): L.append([int(i) for i in input().split()]) Z = [[1]*w for i in range(h)] print(Z) for i in range(n): if L[i][2] == 1: for j in range(h): for k in range(w): if k < L[i][0]: Z[j][k] = 0 elif L[i][2] == 2: for j in range(h): for k in range(w): if k >= L[i][0]: Z[j][k] = 0 elif L[i][2] == 3: for j in range(h): for k in range(w): if j < L[i][0]: Z[j][k] = 0 elif L[i][2] == 4: for j in range(h): for k in range(w): if j >= L[i][0]: Z[j][k] = 0 print(Z) out = 0 for i in range(h): for j in range(w): out += Z[i][j] print(out)
s309572633
Accepted
178
3,188
706
w, h, n = map(int, input().split()) L = [] for i in range(n): L.append([int(i) for i in input().split()]) Z = [[1]*w for i in range(h)] for i in range(n): if L[i][2] == 1: for j in range(h): for k in range(w): if k < L[i][0]: Z[j][k] = 0 elif L[i][2] == 2: for j in range(h): for k in range(w): if k >= L[i][0]: Z[j][k] = 0 elif L[i][2] == 3: for j in range(h): for k in range(w): if j < L[i][1]: Z[j][k] = 0 elif L[i][2] == 4: for j in range(h): for k in range(w): if j >= L[i][1]: Z[j][k] = 0 out = 0 for i in range(h): for j in range(w): out += Z[i][j] print(out)
s105196805
p01131
u509775126
8,000
131,072
Wrong Answer
70
5,620
449
Alice さんは Miku さんに携帯電話でメールを送ろうとしている。 携帯電話には入力に使えるボタンは数字のボタンしかない。 そこで、文字の入力をするために数字ボタンを何度か押して文字の入力を行う。携帯電話の数字ボタンには、次の文字が割り当てられており、ボタン 0 は確定ボタンが割り当てられている。この携帯電話では 1 文字の入力が終わったら必ず確定ボタンを押すことになっている。 * 1: . , ! ? (スペース) * 2: a b c * 3: d e f * 4: g h i * 5: j k l * 6: m n o * 7: p q r s * 8: t u v * 9: w x y z * 0: 確定ボタン 例えば、ボタン 2、ボタン 2、ボタン 0 と押すと、文字が 'a' → 'b' と変化し、ここで確定ボタンが押されるので、文字 b が出力される。 同じ数字を続けて入力すると変化する文字はループする。すなわち、ボタン 2 を 5 回押して、次にボタン 0 を押すと、文字が 'a' → 'b' → 'c' → 'a' → 'b' と変化し、ここで確定ボタンを押されるから 'b' が出力される。 何もボタンが押されていないときに確定ボタンを押すことはできるが、その場合には何も文字は出力されない。 あなたの仕事は、Alice さんが押したボタンの列から、Alice さんが作ったメッセージを再現することである。
n = int(input()) string = ["", ".,!?", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] for i in range(n): s = input() count = 0 num = int(s[0]) for c, c1 in zip(s, s[1:]): if c == c1: count += 1 else: if num != 0: print(string[num][count % len(string[num])], end="") else: pass num = int(c1) count = 0 print()
s298654014
Accepted
60
5,624
460
n = int(input()) string = ["", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"] for i in range(n): s = input() count = 0 num = int(s[0]) for c, c1 in zip(s, s[1:]): if c == c1: count += 1 else: if num != 0: print(string[num][count % len(string[num])], end="") else: pass num = int(c1) count = 0 print()
s338066952
p03623
u674588203
2,000
262,144
Wrong Answer
17
2,940
60
Snuke lives at position x on a number line. On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery. Snuke decided to get food delivery from the closer of stores A and B. Find out which store is closer to Snuke's residence. Here, the distance between two points s and t on a number line is represented by |s-t|.
x,a,b=map(int,input().split()) print(min(abs(x-a),abs(x-b)))
s698030655
Accepted
17
2,940
112
x,a,b=map(int,input().split()) DisXA=abs(a-x) DisXB=abs(b-x) if DisXA<DisXB: print('A') else: print('B')
s054385453
p03997
u598016178
2,000
262,144
Wrong Answer
17
2,940
49
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.
print((int(input())+int(input()))*int(input())/2)
s489305513
Accepted
17
2,940
50
print((int(input())+int(input()))*int(input())//2)
s325023429
p03679
u955248595
2,000
262,144
Wrong Answer
26
9,096
101
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs `delicious` if he found it delicious, `safe` if he did not found it delicious but did not get a stomachache either, and `dangerous` if he got a stomachache.
X,A,B = (int(T) for T in input().split()) ['delicious','safe','dangerous'][(B-A>0)*(1+((X-(B-A))<0))]
s469967448
Accepted
29
9,028
108
X,A,B = (int(T) for T in input().split()) print(['delicious','safe','dangerous'][(B-A>0)*(1+((X-(B-A))<0))])
s650800071
p03591
u157461801
2,000
262,144
Wrong Answer
17
2,940
171
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
def solution(): s = list(input().strip()) if len(s) < 4: print('NO') else: s = ''.join(s[:4]) if s == 'YAKI': print('YES') else: print('NO') solution()
s126112907
Accepted
17
2,940
171
def solution(): s = list(input().strip()) if len(s) < 4: print('No') else: s = ''.join(s[:4]) if s == 'YAKI': print('Yes') else: print('No') solution()
s680764193
p02612
u009248415
2,000
1,048,576
Wrong Answer
26
9,156
33
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.
print(n := (int(input()) % 1000))
s525722987
Accepted
27
9,024
120
n = int(input()) ans = 0 if (n % 1000) == 0: print(ans := 0) elif (n % 1000) != 0: print(ans := (1000 - (n % 1000)))
s568781941
p03478
u030726788
2,000
262,144
Wrong Answer
21
3,060
147
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
a,b,c=map(int,input().split()) count=0 for i in range(1,a+1): x=i//10000+i//1000+i//100+i//10+i%10 if(x<=c and x>=b): count+=1 print(count)
s377385939
Accepted
24
3,064
169
a,b,c=map(int,input().split()) count=0 for i in range(1,a+1): x=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+i%10 if(x<=c and x>=b): count+=i print(count)
s803776418
p03672
u131634965
2,000
262,144
Wrong Answer
17
3,060
326
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() s=s[:len(s)-1] flag=True while(flag): if len(s)%2==0: left=s[:len(s)//2] right=s[len(s)//2:] print(left,right) if left==right: print(len(s)) flag=False else: s=s[0:len(s)-1] else: s=s[0:len(s)-1] print(s)
s839198107
Accepted
18
3,060
283
s=input() s=s[:len(s)-1] flag=True while(flag): if len(s)%2==0: left=s[:len(s)//2] right=s[len(s)//2:] if left==right: print(len(s)) flag=False else: s=s[0:len(s)-1] else: s=s[0:len(s)-1]
s039309628
p03370
u695079172
2,000
262,144
Wrong Answer
17
3,060
168
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≤ i ≤ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: * For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition.
n,x=map(int,input().split()) answer=0 mn=1000 for i in range(n): temp=int(input()) answer += temp mn = min(temp,mn) x -= temp answer += (x//mn)*mn print(answer)
s220641776
Accepted
17
3,060
164
n,x=map(int,input().split()) answer=0 mn=1000 for i in range(n): temp=int(input()) answer += 1 mn = min(temp,mn) x -= temp answer += (x//mn) print(answer)
s436313987
p03555
u723721005
2,000
262,144
Wrong Answer
17
2,940
71
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.
a,b=input(),input() print('YES' if reversed(list(a))==list(b)else 'NO')
s023779162
Accepted
17
3,060
291
str = input() newStr = input() def f(s): s = list(s) if len(s) <= 1: return s i = 0 length = len(s) while i< length/2: s[i],s[length-1-i] = s[length-1-i],s[i] i += 1 return ''.join(s) if newStr == f(str): print('YES') else: print('NO')
s357358932
p03049
u923712635
2,000
1,048,576
Wrong Answer
41
3,700
562
Snuke has N strings. The i-th string is s_i. Let us concatenate these strings into one string after arranging them in some order. Find the maximum possible number of occurrences of `AB` in the resulting string.
N = int(input()) s = [input() for _ in range(N)] num_a = 0 num_b = 0 num_ba = 0 num_ab = 0 for i in s: if(i[-1]=='A' and i[0]=='B'): num_ba += 1 elif(i[-1]=='A'): num_a+=1 elif(i[0]=='B'): num_b+=1 last = '' for k in i: if(k=='A'): last = 'A' elif(last == 'A' and k=='B'): num_ab += 1 last = '' else: last = '' num_conn = min(num_a,num_b) if(num_ba>0 and num_a!=num_b): print(num_ab+num_ba+num_conn) else: print(num_ab+num_ba+num_conn-1)
s462771627
Accepted
42
3,700
661
N = int(input()) s = [input() for _ in range(N)] ans = 0 num_a = 0 num_b = 0 num_ba = 0 num_ab = 0 for i in s: if(i[-1]=='A' and i[0]=='B'): num_ba += 1 elif(i[-1]=='A'): num_a+=1 elif(i[0]=='B'): num_b+=1 last = '' for k in i: if(k=='A'): last = 'A' elif(last == 'A' and k=='B'): num_ab += 1 last = '' else: last = '' ans += num_ab num_conn = min(num_a,num_b) if(num_a!=num_b and num_ba!=0): ans+=num_ba+num_conn elif(num_ba==0): ans+=num_conn elif(num_a==0 and num_b==0): ans+=num_ba-1 else: ans+=num_ba+num_conn print(ans)
s890111253
p03711
u628965061
2,000
262,144
Wrong Answer
17
2,940
84
Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below. Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.
S="XACABABAABABA" x,y=map(int,input().split()) print("YES" if S[x]==S[y] else 'NO ')
s505479557
Accepted
17
2,940
83
S="XACABABAABABA" x,y=map(int,input().split()) print("Yes" if S[x]==S[y] else 'No')
s727122914
p03970
u503111914
2,000
262,144
Wrong Answer
17
2,940
114
CODE FESTIVAL 2016 is going to be held. For the occasion, Mr. Takahashi decided to make a signboard. He intended to write `CODEFESTIVAL2016` on it, but he mistakenly wrote a different string S. Fortunately, the string he wrote was the correct length. So Mr. Takahashi decided to perform an operation that replaces a certain character with another in the minimum number of iterations, changing the string to `CODEFESTIVAL2016`. Find the minimum number of iterations for the rewrite operation.
S = "CODEFESTIVAL2016" s = input() result = 0 for i in range(16): if S[i] == s[i]: result += 1 print(result)
s208014249
Accepted
17
2,940
115
S = "CODEFESTIVAL2016" s = input() result = 0 for i in range(16): if S[i] != s[i]: result += 1 print(result)
s165356558
p03387
u064408584
2,000
262,144
Wrong Answer
17
3,064
207
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.
a=list(map(int,input().split())) a.sort() print(a) count=(a[2]-a[0])//2 count+=(a[2]-a[1])//2 if (a[2]-a[0])%2+(a[2]-a[1])%2 == 2: count+=1 elif (a[2]-a[0])%2+(a[2]-a[1])%2 ==1: count+=2 print(count)
s578416700
Accepted
17
3,064
198
a=list(map(int,input().split())) a.sort() count=(a[2]-a[0])//2 count+=(a[2]-a[1])//2 if (a[2]-a[0])%2+(a[2]-a[1])%2 == 2: count+=1 elif (a[2]-a[0])%2+(a[2]-a[1])%2 ==1: count+=2 print(count)