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
s178981340
p03457
u588526762
2,000
262,144
Wrong Answer
18
3,060
210
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()) prev_t = 0 for i in range(n): t, x, y = map(int, input().split()) if (x + y) > (t - prev_t) or (x + y + (t - prev_t)) % 2: print('No') exit() prev_t = t print('Yes')
s882628905
Accepted
326
3,060
145
for _ in range(int(input())): t, x, y = map(int, input().split()) if (x + y + t) % 2 or (x + y) > t: print('No') exit(0) print('Yes')
s611796072
p03478
u224156735
2,000
262,144
Wrong Answer
33
3,064
129
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive).
n,a,b = map(int, input().split()) count=0 for i in range(1,n+1): if sum(int(j) for j in str(i))<=b: count+=i print(count)
s300308027
Accepted
33
2,940
132
n,a,b = map(int, input().split()) count=0 for i in range(1,n+1): if a<=sum(int(j) for j in str(i))<=b: count+=i print(count)
s056386897
p03131
u170324846
2,000
1,048,576
Wrong Answer
17
3,064
321
Snuke has one biscuit and zero Japanese yen (the currency) in his pocket. He will perform the following operations exactly K times in total, in the order he likes: * Hit his pocket, which magically increases the number of biscuits by one. * Exchange A biscuits to 1 yen. * Exchange 1 yen to B biscuits. Find the maximum possible number of biscuits in Snuke's pocket after K operations.
KAB = [int(x) for x in input().split()] K = KAB[0] A = KAB[1] B = KAB[2] count = 1 if (A - B <= 1) or K <= A: print(K + 1) else: count = A K = K - A + 1 if K % 2 == 1: print(B - A, K // 2) count = count + 1 + (B - A) * (K // 2) else: count += (B - A) * K // 2 print(count)
s980617776
Accepted
18
3,064
291
KAB = [int(x) for x in input().split()] K = KAB[0] A = KAB[1] B = KAB[2] count = 1 if (B - A <= 2) or K <= A: print(K + 1) else: count = A K = K - A + 1 if K % 2 == 1: count = count + 1 + (B - A) * (K // 2) else: count += (B - A) * K // 2 print(count)
s618348358
p02612
u647835149
2,000
1,048,576
Wrong Answer
27
9,144
49
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
N = int(input()) otsuri = N % 1000 print (otsuri)
s258730132
Accepted
28
9,164
92
n = int(input()) otsuri = 1000-n%1000 if otsuri == 1000: print(0) else: print(otsuri)
s235258174
p04029
u526094365
2,000
262,144
Wrong Answer
17
2,940
66
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
N = int(input()) t = 0 for i in range(N): t = t + i print(t)
s383900300
Accepted
17
2,940
71
N = int(input()) t = 0 for i in range(1, N+1): t = t + i print(t)
s540876334
p03080
u146597538
2,000
1,048,576
Wrong Answer
17
2,940
87
There are N people numbered 1 to N. Each person wears a red hat or a blue hat. You are given a string s representing the colors of the people. Person i wears a red hat if s_i is `R`, and a blue hat if s_i is `B`. Determine if there are more people wearing a red hat than people wearing a blue hat.
s = list(input()) if s.count('R') > s.count('B'): print('Yes') else: print('No')
s275009584
Accepted
18
2,940
105
n = list(input()) s = list(input()) if s.count('R') > s.count('B'): print('Yes') else: print('No')
s661492365
p03457
u506689504
2,000
262,144
Wrong Answer
320
3,060
154
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()) for i in range(n): t, x, y = map(int, input().split()) if x+y < t or (x+y+t) % 2: print("No") exit() print("Yes")
s978221350
Accepted
323
3,060
157
n = int(input()) for i in range(n): t, x, y = map(int, input().split()) if x+y > t or (x+y+t) % 2!=0: print("No") exit() print("Yes")
s159509866
p03796
u161271485
2,000
262,144
Wrong Answer
17
2,940
147
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.
def kaijo(N): if N == 1: return 1 else: return N * kaijo(N-1) if __name__ == '__main__': print(kaijo(4) % (10**9 + 7))
s736574138
Accepted
33
3,060
189
def process(N): ans = 1 while N > 1: ans = ans * N % (10**9 + 7) N -= 1 return ans if __name__ == '__main__': n = int(input().strip()) print(process(n))
s990971528
p02261
u949517845
1,000
131,072
Wrong Answer
20
7,716
1,804
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).
class Card(object): def __init__(self, card): self._suit = card[0] self._value = int(card[1]) def __eq__(self, other): if other is None: return False return self.__dict__ == other.__dict__ def getValue(self): return self._value def toString(self): return self._suit + str(self._value) def card_bubbleSort(lst, n): for i in range(0, n): for j in range(n-1, i, -1): if lst[j].getValue() < lst[j-1].getValue(): tmp = lst[j] lst[j] = lst[j-1] lst[j-1] = tmp return lst def card_selectionSort(lst, n): for i in range(0, n): minj = i for j in range(i, n): if lst[j].getValue() < lst[minj].getValue(): minj = j if i != minj: tmp = lst[i] lst[i] = lst[minj] lst[minj] = tmp return lst def isStable(in_lst, out_lst, n): for i in range(0, n): for j in range(i+1, n): for a in range(0, n): for b in range(a+1, n): if in_lst[i].getValue() == in_lst[j].getValue() \ and in_lst[i] == out_lst[b] \ and in_lst[j] == out_lst[a]: return False return True if __name__ == "__main__": n = int(input()) lst = input().split() func_table = [card_bubbleSort, card_selectionSort] for func in func_table: cards = [Card(item) for item in lst] result = func(cards, n) cards = [Card(item) for item in lst] print(" ".join([card.toString() for card in result])) if isStable(cards, result, n): print("Stable") else: print("Not Stable")
s526693610
Accepted
230
7,892
1,804
class Card(object): def __init__(self, card): self._suit = card[0] self._value = int(card[1]) def __eq__(self, other): if other is None: return False return self.__dict__ == other.__dict__ def getValue(self): return self._value def toString(self): return self._suit + str(self._value) def card_bubbleSort(lst, n): for i in range(0, n): for j in range(n-1, i, -1): if lst[j].getValue() < lst[j-1].getValue(): tmp = lst[j] lst[j] = lst[j-1] lst[j-1] = tmp return lst def card_selectionSort(lst, n): for i in range(0, n): minj = i for j in range(i, n): if lst[j].getValue() < lst[minj].getValue(): minj = j if i != minj: tmp = lst[i] lst[i] = lst[minj] lst[minj] = tmp return lst def isStable(in_lst, out_lst, n): for i in range(0, n): for j in range(i+1, n): for a in range(0, n): for b in range(a+1, n): if in_lst[i].getValue() == in_lst[j].getValue() \ and in_lst[i] == out_lst[b] \ and in_lst[j] == out_lst[a]: return False return True if __name__ == "__main__": n = int(input()) lst = input().split() func_table = [card_bubbleSort, card_selectionSort] for func in func_table: cards = [Card(item) for item in lst] result = func(cards, n) cards = [Card(item) for item in lst] print(" ".join([card.toString() for card in result])) if isStable(cards, result, n): print("Stable") else: print("Not stable")
s023785204
p02865
u900303768
2,000
1,048,576
Wrong Answer
21
3,060
79
How many ways are there to choose two distinct positive integers totaling N, disregarding the order?
n = int(input()) if n%2 == 0: print((n+1)//2) else: print((n+1)//2-1)
s415013167
Accepted
20
3,316
79
n = int(input()) if n%2 == 0: print((n)//2-1) else: print((n+1)//2-1)
s608410036
p03377
u227762254
2,000
262,144
Wrong Answer
22
3,316
112
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals.
#coding: utf-8 A,B,X = map(int,input().split()) if A <= X and A + B >= X: print("Yes") else: print("No")
s087023767
Accepted
17
2,940
91
A,B,X = map(int,input().split()) if A <= X <= A + B: print("YES") else: print("NO")
s421581817
p03997
u952940200
2,000
262,144
Wrong Answer
17
2,940
69
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.
up=int(input()) down=int(input()) h=int(input()) print((up+down)*h/2)
s593875949
Accepted
17
2,940
70
up=int(input()) down=int(input()) h=int(input()) print((up+down)*h//2)
s481548936
p03971
u163073599
2,000
262,144
Wrong Answer
107
4,016
339
There are N participants in the CODE FESTIVAL 2016 Qualification contests. The participants are either students in Japan, students from overseas, or neither of these. Only Japanese students or overseas students can pass the Qualification contests. The students pass when they satisfy the conditions listed below, from the top rank down. Participants who are not students cannot pass the Qualification contests. * A Japanese student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B. * An overseas student passes the Qualification contests if the number of the participants who have already definitively passed is currently fewer than A+B and the student ranks B-th or above among all overseas students. A string S is assigned indicating attributes of all participants. If the i-th character of string S is `a`, this means the participant ranked i-th in the Qualification contests is a Japanese student; `b` means the participant ranked i-th is an overseas student; and `c` means the participant ranked i-th is neither of these. Write a program that outputs for all the participants in descending rank either `Yes` if they passed the Qualification contests or `No` if they did not pass.
n, a, b = (int(s) for s in input().strip().split(' ')) s = input() passed = 0 b_passed = 0 for c in range(0,len(s)): if s[c] == "a" and passed < a+b: passed += 1 print("yes") elif s[c] == "b" and passed < a+b and b_passed < b: passed+=1 b_passed+=1 print("yes") else: print("no")
s768836216
Accepted
107
4,040
339
n, a, b = (int(s) for s in input().strip().split(' ')) s = input() passed = 0 b_passed = 0 for c in range(0,len(s)): if s[c] == "a" and passed < a+b: passed += 1 print("Yes") elif s[c] == "b" and passed < a+b and b_passed < b: passed+=1 b_passed+=1 print("Yes") else: print("No")
s785189370
p03494
u106778233
2,000
262,144
Wrong Answer
26
9,116
148
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 = list(map(int,input().split())) cnt = 0 for i in range(n): while A[i]%2 ==0 : cnt+= 1 A[i]//=2 print(cnt)
s015504586
Accepted
28
9,136
177
n = int(input()) A = list(map(int,input().split())) for i in range(n): cnt = 0 while A[i]%2 ==0 : cnt+= 1 A[i]//=2 A[i] = cnt print(min(A))
s629801446
p03798
u549383771
2,000
262,144
Wrong Answer
893
3,572
1,312
Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbered i (2≤i≤N-1) is adjacent to the animals numbered i-1 and i+1. Also, the animal numbered 1 is adjacent to the animals numbered 2 and N, and the animal numbered N is adjacent to the animals numbered N-1 and 1. There are two kinds of animals in this zoo: honest sheep that only speak the truth, and lying wolves that only tell lies. Snuke cannot tell the difference between these two species, and asked each animal the following question: "Are your neighbors of the same species?" The animal numbered i answered s_i. Here, if s_i is `o`, the animal said that the two neighboring animals are of the same species, and if s_i is `x`, the animal said that the two neighboring animals are of different species. More formally, a sheep answered `o` if the two neighboring animals are both sheep or both wolves, and answered `x` otherwise. Similarly, a wolf answered `x` if the two neighboring animals are both sheep or both wolves, and answered `o` otherwise. Snuke is wondering whether there is a valid assignment of species to the animals that is consistent with these responses. If there is such an assignment, show one such assignment. Otherwise, print `-1`.
def add_ans(i,ans,circle): if circle[i] == 'o': if ans[i] == 'S': ans += ans[i-1] else: if ans[i-1] == 'S': ans += 'W' else: ans += 'S' if circle[i] == 'x': if ans[i] == 'W': ans += ans[i-1] else: if ans[i-1] == 'S': ans += 'W' else: ans += 'S' return ans def check_last(ans,circle): if circle[0] == 'o': if ans[0] == 'S': last = ans[1] else: if ans[1] == 'S': last = 'W' else: last = 'S' if circle[0] == 'x': if ans[0] == 'W': last = ans[1] else: if ans[1] == 'S': last = 'W' else: last = 'S' if last == ans[-1]: return 1 else : return 0 flag = True n = int(input()) circle = input() ans_list = ['SS' , 'SW' , 'WS' , 'WW'] for ans in ans_list: for i in range(1,len(circle)): ans = add_ans(i,ans,circle) if check_last(ans , circle) == 1: print(ans) flag = False break if flag: print('-1')
s433975934
Accepted
1,371
3,576
1,780
def add_ans(i,ans,circle): if circle[i] == 'o': if ans[i] == 'S': ans += ans[i-1] else: if ans[i-1] == 'S': ans += 'W' else: ans += 'S' if circle[i] == 'x': if ans[i] == 'W': ans += ans[i-1] else: if ans[i-1] == 'S': ans += 'W' else: ans += 'S' return ans def check_last(ans,circle): if circle[0] == 'o': if ans[0] == 'S': last = ans[1] else: if ans[1] == 'S': last = 'W' else: last = 'S' elif circle[0] == 'x': if ans[0] == 'W': last = ans[1] else: if ans[1] == 'S': last = 'W' else: last = 'S' if circle[-1] == 'o': if ans[-1] == 'S': first = ans[-2] else: if ans[-2] == 'S': first = 'W' else: first = 'S' elif circle[-1] == 'x': if ans[-1] == 'W': first = ans[-2] else: if ans[-2] == 'S': first = 'W' else: first = 'S' if (last == ans[-1]) & (first == ans[0]): return 1 else : return 0 flag = True n = int(input()) circle = input() ans_list = ['SS' , 'SW' , 'WS' , 'WW'] for ans in ans_list: for i in range(1,len(circle)-1): ans = add_ans(i,ans,circle) if check_last(ans , circle) == 1: print(ans) flag = False break if flag: print('-1')
s089863596
p03545
u308919961
2,000
262,144
Wrong Answer
17
3,064
543
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with `+` or `-` so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
abcd = input() ans_word = [] for i in range(2**3): ans = int(abcd[0]) for j in range(3): #print(str(i) + ' ' + str(j)) if((i>>j)&1 == 1): ans += int(abcd[j+1]) else: ans -= int(abcd[j+1]) #print(ans) if(ans == 7): for k in range(3): ans_word.append(abcd[k]) if((i>>k)&1 == 1): ans_word.append('+') else: ans_word.append('-') ans_word.append("=7") print("".join(ans_word)) break
s782484222
Accepted
17
3,064
574
abcd = input() ans_word = [] for i in range(2**3): ans = int(abcd[0]) for j in range(3): #print(str(i) + ' ' + str(j)) if((i>>j)&1 == 1): ans += int(abcd[j+1]) else: ans -= int(abcd[j+1]) #print(ans) if(ans == 7): for k in range(4): ans_word.append(abcd[k]) if((i>>k)&1 == 1): ans_word.append('+') else: if(k < 3): ans_word.append('-') ans_word.append("=7") print("".join(ans_word)) break
s552981260
p03543
u075303794
2,000
262,144
Wrong Answer
17
2,940
89
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**. You are given a 4-digit integer N. Answer the question: Is N **good**?
n = list(int(x) for x in input()) if len(set(n)) >= 3: print('Yes') else: print('No')
s473296714
Accepted
19
3,060
126
n = input() if n[1] != n[2]: print("No") else: if n[0] == n[1] or n[-1] == n[1]: print("Yes") else: print("No")
s551214674
p02697
u937642029
2,000
1,048,576
Wrong Answer
225
52,864
1,926
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.
import sys, bisect, math, itertools, string, queue, copy # import numpy as np from collections import Counter,defaultdict,deque from itertools import permutations, combinations from heapq import heappop, heappush from fractions import gcd # input = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 def inp(): return int(input()) def inpm(): return map(int,input().split()) def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) def inplm(n): return list(int(input()) for _ in range(n)) def inplL(n): return [list(input()) for _ in range(n)] def inplT(n): return [tuple(input()) for _ in range(n)] def inpll(n): return [list(map(int, input().split())) for _ in range(n)] def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) def main(): n,m = inpm() ans = [] if m%2 == 0: for i in range(m): print(i+1,n-i) return dic = defaultdict(int) dic1 = defaultdict(int) for i in range(m): if i == 0: ans.append([1,n]) dic[1] += 1 dic[n] += 1 dic1[n-2] += 1 dic1[0] += 1 elif i == 1: ans.append([2,n-2]) dic[2] += 1 dic[n-2] += 1 dic1[n-5] += 1 dic1[3] += 1 elif i%2 == 0: dic[ans[-1][0]+2] += 1 dic[ans[-1][1]+1] += 1 num = ans[-1][1]+1 - ans[-1][0]-2 -1 dic1[ num] += 1 dic1[n-2-num] += 1 ans.append([ans[-1][0]+2,ans[-1][1]+1]) else: dic[ans[-1][0]-1] += 1 dic[ans[-1][1]-2] += 1 num = ans[-1][1]+1 - ans[-1][0]-2 -1 dic1[ num] += 1 dic1[n-2-num] += 1 ans.append([ans[-1][0]-1,ans[-1][1]-2]) for i in range(len(ans)): print(*ans[i]) if __name__ == "__main__": main()
s455447670
Accepted
76
9,176
291
import sys input = sys.stdin.readline sys.setrecursionlimit(10**8) def main(): n,m = map(int,input().split()) x = m//2 y = m - x for i in range(x): print(i+1,2*x+1-i) for i in range(y): print(2*x+2+i,2*x+2*y+1-i) if __name__ == "__main__": main()
s945973882
p02843
u798818115
2,000
1,048,576
Wrong Answer
17
2,940
119
AtCoder Mart sells 1000000 of each of the six items below: * Riceballs, priced at 100 yen (the currency of Japan) each * Sandwiches, priced at 101 yen each * Cookies, priced at 102 yen each * Cakes, priced at 103 yen each * Candies, priced at 104 yen each * Computers, priced at 105 yen each Takahashi wants to buy some of them that cost exactly X yen in total. Determine whether this is possible. (Ignore consumption tax.)
X=int(input()) temp=-(-X//105) hiku=temp*105-X print(temp*5) print(hiku) if temp*5>=hiku: print(1) else: print(0)
s593991507
Accepted
17
2,940
92
X=int(input()) temp=-(-X//105) hiku=temp*105-X if temp*5>=hiku: print(1) else: print(0)
s699185290
p03997
u496280557
2,000
262,144
Wrong Answer
30
8,916
74
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively. An example of a trapezoid Find the area of this trapezoid.
a = int(input()) b = int(input()) h = int(input()) print((a + b) * h / 2)
s199489437
Accepted
26
9,152
75
a = int(input()) b = int(input()) h = int(input()) print((a + b) * h // 2)
s945178062
p03399
u811730180
2,000
262,144
Wrong Answer
17
2,940
74
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 = input() b = input() c = input() d = input() print(min(a,b) + min(c,d))
s805926787
Accepted
17
2,940
94
a = input() b = input() c = input() d = input() print(min(int(a),int(b)) + min(int(c),int(d)))
s866137726
p00002
u814278309
1,000
131,072
Wrong Answer
20
5,656
75
Write a program which computes the digit number of sum of two integers a and b.
import math a,b=map(int,input().split()) c=int(math.log10(a+b)+1) print(c)
s553598962
Accepted
20
5,588
97
while True: try: a,b=map(int,input().split()) print(len(str(a+b))) except: break
s325049573
p03673
u842230338
2,000
262,144
Wrong Answer
17
2,940
57
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
a = input().split() s = a[::-2]+a[::2] print(" ".join(s))
s771387306
Accepted
50
26,276
121
n = int(input()) a = input().split() if n%2 == 0: s = a[::-2]+a[::2] else: s = a[::-2]+a[1::2] print(" ".join(s))
s020047591
p04043
u940533000
2,000
262,144
Wrong Answer
18
2,940
173
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order. To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
A,B,C = map(int, input().split()) if (A == 5 and B == 5 and C == 7) or (A == 5 and B == 7 and C == 5) or (A == 7 and B == 5 and C == 5): print('Yes') else: print('No')
s547359107
Accepted
17
2,940
173
A,B,C = map(int, input().split()) if (A == 5 and B == 5 and C == 7) or (A == 5 and B == 7 and C == 5) or (A == 7 and B == 5 and C == 5): print('YES') else: print('NO')
s145854997
p03578
u098968285
2,000
262,144
Time Limit Exceeded
2,105
34,988
489
Rng is preparing a problem set for a qualification round of CODEFESTIVAL. He has N candidates of problems. The difficulty of the i-th candidate is D_i. There must be M problems in the problem set, and the difficulty of the i-th problem must be T_i. Here, one candidate of a problem cannot be used as multiple problems. Determine whether Rng can complete the problem set without creating new candidates of problems.
# return [[0 for i in range(m)] for j in range(n)] # n = int(input()) # a, b = map(int, input().split()) N = int(input()) D = list(map(int, input().split())) M = int(input()) T = list(map(int, input().split())) D.sort() T.sort() i = 0 ans = "YES" for e in T: while True: if i >= N: ans = "NO" break else: if D[i] != e: i += 1 if ans == "NO": break print(ans)
s374932714
Accepted
362
35,420
382
N = int(input()) D = list(map(int, input().split())) M = int(input()) T = list(map(int, input().split())) D.sort() T.sort() i = 0 ans = "YES" for e in T: flag = True while flag: if i >= N: ans = "NO" break else: if D[i] == e: flag = False i += 1 if ans == "NO": break print(ans)
s901882545
p03565
u698771758
2,000
262,144
Wrong Answer
17
3,064
355
E869120 found a chest which is likely to contain treasure. However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters. He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`. One more thing he found is a sheet of paper with the following facts written on it: * Condition 1: The string S contains a string T as a contiguous substring. * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1. Print the string S. If such a string does not exist, print `UNRESTORABLE`.
S=input() T=input() t=len(T) for i in range(len(S)-t+1): a=c=0 for j in range(t): k=S[-t-i+j] if k ==T[j] or k=="?" :c+=1 if c==t: print(i,len(S)-t) bef=S[:len(S)-t-i].replace("?","a") aft="" if i!=0:aft=S[-i:].replace("?","a") print(bef+T+aft) exit() print("UNRESTORABLE")
s388529457
Accepted
17
3,064
323
S=input() T=input() t=len(T) for i in range(len(S)-t+1): a=c=0 for j in range(t): k=S[-t-i+j] if k ==T[j] or k=="?" :c+=1 if c==t: bef=S[:len(S)-t-i].replace("?","a") aft="" if i!=0:aft=S[-i:].replace("?","a") print(bef+T+aft) exit() print("UNRESTORABLE")
s822591408
p03827
u629350026
2,000
262,144
Wrong Answer
17
3,060
155
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).
s=int(input()) t=str(input()) t=list(t) ans=0 temp=0 for i in range(0,s): if t=="I": ans=ans+1 else: ans=ans-1 temp=max(ans,temp) print(temp)
s431533200
Accepted
17
3,060
158
s=int(input()) t=str(input()) t=list(t) ans=0 temp=0 for i in range(0,s): if t[i]=="I": ans=ans+1 else: ans=ans-1 temp=max(ans,temp) print(temp)
s004008298
p03592
u608088992
2,000
262,144
Wrong Answer
302
3,060
171
We have a grid with N rows and M columns of squares. Initially, all the squares are white. There is a button attached to each row and each column. When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa. When a button attached to a column is pressed, the colors of all the squares in that column are inverted. Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.
N, M, K = map(int, input().split()) for n in range(N + 1): for m in range(M + 1): if n * (M - m) + m * (N - n) == K: print("Yes") break else: print("No")
s812963012
Accepted
209
3,064
433
import sys def solve(): input = sys.stdin.readline N, M, K = map(int, input().split()) possible = False for i in range(N + 1): for j in range(M + 1): black = (N - i) * j + i * (M - j) if black == K: print("Yes") possible = True break if possible: break else: print("No") return 0 if __name__ == "__main__": solve()
s741520212
p02602
u664884522
2,000
1,048,576
Wrong Answer
2,206
34,112
318
M-kun is a student in Aoki High School, where a year is divided into N terms. There is an exam at the end of each term. According to the scores in those exams, a student is given a grade for each term, as follows: * For the first through (K-1)-th terms: not given. * For each of the K-th through N-th terms: the multiplication of the scores in the last K exams, including the exam in the graded term. M-kun scored A_i in the exam at the end of the i-th term. For each i such that K+1 \leq i \leq N, determine whether his grade for the i-th term is **strictly** greater than the grade for the (i-1)-th term.
N,K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] score = [1 for x in range(N-K+1)] for k in range(len(score)): for j in range(K): score[k] *= A[K+k-1-j] for i in range(1,len(score)): if score[i] > score[i-1]: print("Yes") else: print("No") print(score)
s501086715
Accepted
159
31,612
172
N,K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] for j in range(N-K): if A[j+K] > A[j]: print("Yes") else: print("No")
s413228408
p00001
u452926933
1,000
131,072
Wrong Answer
20
5,592
133
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.
num = 3 mountains = list(map(int, input())) mountains = sorted(mountains, reverse=True) for i in range(num): print(mountains[i])
s455533909
Accepted
20
5,604
154
num = 10 top = 3 mountains = [int(input()) for i in range(num)] mountains = sorted(mountains, reverse=True) for i in range(top): print(mountains[i])
s885560864
p03455
u383764785
2,000
262,144
Wrong Answer
18
2,940
129
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
# -*- coding: utf-8 -*- a, b = map(int, input().split()) if a % 2 == 0 or b % 2 == 0: print('even') else: print('odd')
s711897668
Accepted
18
2,940
129
# -*- coding: utf-8 -*- a, b = map(int, input().split()) if a % 2 == 0 or b % 2 == 0: print('Even') else: print('Odd')
s893573332
p03657
u240793404
2,000
262,144
Wrong Answer
17
2,940
120
Snuke is giving cookies to his three goats. He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins). Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
a,b = map(int,input().split()) if a % 3 == 0 or b%3 == 0 or (a+b)%3 ==3: print("Possible") else: print("Impossible")
s194854665
Accepted
17
2,940
120
a,b = map(int,input().split()) if a % 3 == 0 or b%3 == 0 or (a+b)%3 ==0: print("Possible") else: print("Impossible")
s086616238
p03556
u357751375
2,000
262,144
Wrong Answer
39
9,160
66
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.
n = int(input()) i = 1 while i ** 2 < n: i += 1 print(i ** 2)
s000615787
Accepted
37
9,128
72
n = int(input()) i = 1 while i ** 2 <= n: i += 1 print((i - 1) ** 2)
s141154317
p03354
u649373416
2,000
1,048,576
Wrong Answer
2,106
33,520
1,068
We have a permutation of the integers from 1 through N, p_1, p_2, .., p_N. We also have M pairs of two integers between 1 and N (inclusive), represented as (x_1,y_1), (x_2,y_2), .., (x_M,y_M). AtCoDeer the deer is going to perform the following operation on p as many times as desired so that the number of i (1 ≤ i ≤ N) such that p_i = i is maximized: * Choose j such that 1 ≤ j ≤ M, and swap p_{x_j} and p_{y_j}. Find the maximum possible number of i such that p_i = i after operations.
N,M = [int(it) for it in input().split()] pli=[int(it)-1 for it in input().split()] sli=[ (lambda a,b:[min(a,b),max(a,b)])(*[int(it)-1 for it in input().split()]) for i in range(M)] ue = [-1]*N dw = [[] for i in range(N)] for a,b in sli: if ( b == ue[a] ): continue if (1==1): _a = ue[a] if ue[a]!=-1 else a _b = ue[b] if ue[b]!=-1 else b if len(dw[_b])>0: dw[_a].extend(dw[_b]) for _p in dw[_b]: ue[_p]=_a dw[_b]=[] dw[_a].append(_b) ue[_b]=_a #if (ue[b]==-1): # dw[_a].append(b) # ue[b]=_a #print (a,b) s = 0 for j in range(N): if (ue[j]==-1): le = len(dw[j]) if (le==0): if pli[j]==j: s += 1 else: x,y=0,0 dw[j].append(j) dw[j].sort() pli.sort() len_dw = len(dw[j]) len_pli = len(pli) for i in range(2*N): if (dw[j][x]==pli[y]): s+=1 x+=1 y+=1 elif (dw[j][x]<pli[y]): x+=1 else: y+=1 if (x==len_dw or y==len_pli): break print (s)
s085704235
Accepted
627
36,140
695
N,M = [int(it) for it in input().split()] pli=[int(it)-1 for it in input().split()] sli=[ [int(it)-1 for it in input().split()] for i in range(M)] ue = [-1]*N dw = [[] for i in range(N)] for a,b in sli: if ( b == ue[a] or a == ue[b] ): continue else: _a = ue[a] if ue[a]!=-1 else a _b = ue[b] if ue[b]!=-1 else b if (_a == _b and _a != -1): continue if (len(dw[_a]) < len(dw[_b])): _a,_b=_b,_a if len(dw[_b])>0: dw[_a].extend(dw[_b]) for _p in dw[_b]: ue[_p]=_a dw[_b]=[] dw[_a].append(_b) ue[_b]=_a s = 0 for i in range(N): if ue[i]==-1: ue[i]=i for i in range(N): if (ue[i]==ue[pli[i]]): s+=1 print (s)
s504064501
p03486
u443630646
2,000
262,144
Wrong Answer
24
3,068
336
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()) s.sort() t = list(input()) t.sort() j = 0 for i in s: if j > len(t): print('No') break if i < t[j]: print('Yes') break if i > t[j]: print('No') break if (i == t[j] and i == s[-1]): print('No') break if i == t[j]: j += 1
s388691837
Accepted
17
2,940
122
s = list(input()) s.sort() t = list(input()) t.sort(reverse=True) j = 0 if(s<t): print('Yes') else: print('No')
s469357072
p03943
u031146664
2,000
262,144
Wrong Answer
17
2,940
105
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.
num = list(map(int,input().split())) num.sort() print("YES") if num[0]+num[1] == num[2] else print("NO")
s232956788
Accepted
17
2,940
105
num = list(map(int,input().split())) num.sort() print("Yes") if num[0]+num[1] == num[2] else print("No")
s075060424
p03455
u167681750
2,000
262,144
Wrong Answer
20
2,940
78
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("odd") if a*b%2 == 1 else print("even")
s310576608
Accepted
17
2,940
84
a, b = map(int, input().split()) print("Odd") if (a * b) % 2 == 1 else print("Even")
s625591678
p04011
u477977638
2,000
262,144
Wrong Answer
17
2,940
65
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 [0]*4) print(n*x-(x-y)*max(k-n,0))
s489123437
Accepted
17
2,940
65
n,k,x,y=(int(input()) for i in [0]*4) print(n*x-(x-y)*max(n-k,0))
s393679583
p03339
u494927057
2,000
1,048,576
Wrong Answer
73
3,700
235
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()) S = input() cost = S.count('E') ans = N for c in S: if c == 'E': cost -= 1 else: if ans > cost: ans = cost cost += 1 else: if ans > cost: ans = cost print(cost)
s491043078
Accepted
70
3,700
234
N = int(input()) S = input() cost = S.count('E') ans = N for c in S: if c == 'E': cost -= 1 else: if ans > cost: ans = cost cost += 1 else: if ans > cost: ans = cost print(ans)
s094570355
p03047
u267222408
2,000
1,048,576
Wrong Answer
17
2,940
66
Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers?
#input N, K = input().split() #output print(int(N) + int(K) - 1)
s975566911
Accepted
17
2,940
48
n, k =input().split() print(int(n) - int(k) + 1)
s235285087
p04029
u914773681
2,000
262,144
Wrong Answer
18
2,940
106
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
def main(): N = int(input()) sum = 0 for i in range(1,N+1): sum = sum + i return sum main()
s471485002
Accepted
17
2,940
105
def main(): N = int(input()) sum = 0 for i in range(1,N+1): sum = sum + i print(sum) main()
s852717733
p03385
u221345507
2,000
262,144
Wrong Answer
18
2,940
162
You are given a string S of length 3 consisting of `a`, `b` and `c`. Determine if S can be obtained by permuting `abc`.
s=input().replace("abc","").replace("acb","").replace("bac","").replace("bca","").replace("cab","").replace("cba","") if s: print("NO") else: print("YES")
s641225868
Accepted
19
3,064
267
S = input() S1='abc' S2='acb' S3='bac' S4='bca' S5='cab' S6='cba' if S==S1: print ('Yes') elif S==S2: print ('Yes') elif S==S3: print ('Yes') elif S==S4: print ('Yes') elif S==S5: print ('Yes') elif S==S6: print ('Yes') else: print ('No')
s794514165
p03407
u093033848
2,000
262,144
Wrong Answer
18
2,940
91
An elementary school student Takahashi has come to a variety store. He has two coins, A-yen and B-yen coins (yen is the currency of Japan), and wants to buy a toy that costs C yen. Can he buy it? Note that he lives in Takahashi Kingdom, and may have coins that do not exist in Japan.
a, b, c = map(int, input().split()) if a + b <= c: print("Yes") else : print("No")
s681790493
Accepted
18
2,940
91
a, b, c = map(int, input().split()) if a + b >= c: print("Yes") else : print("No")
s631795341
p03645
u050428930
2,000
262,144
Wrong Answer
2,104
4,084
320
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services. Help him.
N,M=map(int,input().split()) s=[] for j in range(M): x=list(input().split()) if str(N) in x and "1" in x: print("POSSIBLE") exit() if str(N) in x: s+=x if "1" in x: if x[0] in s or x[1] in s: print("POSSIBLE") exit() print("IMPOSSIBLE")
s758115161
Accepted
759
23,268
336
N,M=map(int,input().split()) s=[] for j in range(M): x=list(map(int,input().split())) if N in x and 1 in x: print("POSSIBLE") exit() if N in x: x.remove(N) s+=x if 1 in x: x.remove(1) s+=x if len(list(set(s)))!=len(s): print("POSSIBLE") exit() print("IMPOSSIBLE")
s647441705
p03493
u129492036
2,000
262,144
Wrong Answer
18
2,940
41
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.
s1 = input().split() print(s1.count("1"))
s094932340
Accepted
17
2,940
29
s=input() print(s.count("1"))
s808371829
p02398
u648117624
1,000
131,072
Wrong Answer
20
5,592
158
Write a program which reads three integers a, b and c, and prints the number of divisors of c between a and b.
a, b, c = map(int, input().split()) yakusuu = [] for i in range(a, b+1): if (c % a == 0) and (c % b == 0): yakusuu.append(i) print(yakusuu)
s012595718
Accepted
20
5,600
146
a, b, c = map(int, input().split()) yakusuu = [] for i in range(a, b+1): if (c % i == 0): yakusuu.append(i) print(len(yakusuu))
s855117905
p03110
u851704997
2,000
1,048,576
Wrong Answer
27
9,188
218
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?
N = int(input()) ans = 0 for i in range(N): x,u = map(str,input().split()) if(u == "JPY"): ans += int(x) else: x = x.replace(".","") ans += (int(x) * 380000 // 10**8) print(str(ans))
s984265537
Accepted
24
9,116
217
N = int(input()) ans = 0 for i in range(N): x,u = map(str,input().split()) if(u == "JPY"): ans += int(x) else: x = x.replace(".","") ans += (int(x) * 380000 / 10**8) print(str(ans))
s831123958
p03487
u503901534
2,000
262,144
Wrong Answer
2,104
14,692
344
You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a **good sequence**. Here, an sequence b is a **good sequence** when the following condition holds true: * For each element x in b, the value x occurs exactly x times in b. For example, (3, 3, 3), (4, 2, 4, 1, 4, 2, 4) and () (an empty sequence) are good sequences, while (3, 3, 3, 3) and (2, 4, 1, 4, 2) are not. Find the minimum number of elements that needs to be removed so that a will be a good sequence.
n = int(input()) an = list(map(int,input().split())) anset = list(set(an)) counter = 0 for i in range(len(anset)): while an.count(anset[i]) > anset[i]: couonter = counter + 1 an.remove(anset[i]) while 0 < an.count(anset[i]) < anset[i]: counter = counter + 1 an.remove(anset[i]) print(counter)
s449831835
Accepted
126
20,460
419
n = int(input()) an = list(map(int,input().split())) anset = list(set(an)) andict = {} for i in range(len(an)): if an[i] in andict: andict[an[i]] = andict[an[i]] + 1 else: andict.update({an[i]:1}) counter = 0 for i ,j in andict.items(): if i == j : None elif i > j: counter = counter + j elif i < j: counter = counter + j - i print(counter)
s326185863
p02659
u169165784
2,000
1,048,576
Wrong Answer
108
27,148
97
Compute A \times B, truncate its fractional part, and print the result as an integer.
import numpy A, B = input().split() A = int(A) B = float(B) print(numpy.int(numpy.floor(A * B)))
s508976699
Accepted
106
27,092
103
import numpy A, B = input().split() A = int(A) B = int(numpy.round(float(B) * 100)) print(A * B // 100)
s862336276
p02260
u682153677
1,000
131,072
Wrong Answer
20
5,608
385
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) count = 0 for i in range(N): minj = i for j in range(i, N): if A[j] < A[minj]: minj = j A[i], A[minj] = A[minj], A[i] count += 1 for i in range(N): if i == N - 1: print("{0}".format(A[i])) else: print("{0} ".format(A[i]), end="") print(count)
s214713200
Accepted
20
5,612
488
# -*- coding: utf-8 -*- N = int(input()) A = list(map(int, input().split())) count = 0 flag = 0 for i in range(N): if N == 1: break minj = i for j in range(i, N): if A[j] < A[minj]: minj = j flag = 1 if flag == 1: A[i], A[minj] = A[minj], A[i] count += 1 flag = 0 for i in range(N): if i == N - 1: print("{0}".format(A[i])) else: print("{0} ".format(A[i]), end="") print(count)
s647434304
p02255
u966364923
1,000
131,072
Wrong Answer
20
7,748
291
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key A[j+1] = A[j] j-- A[j+1] = key Note that, indices for array elements are based on 0-origin. To illustrate the algorithms, your program should trace intermediate result for each step.
def insertionsSort(A): N = len(A) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(*A) N = int(input()) A = list(map(int, input().split())) insertionsSort(A)
s092052441
Accepted
30
8,084
305
def insertionsSort(A): print(*A) N = len(A) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(*A) N = int(input()) A = list(map(int, input().split())) insertionsSort(A)
s215026612
p03720
u577927591
2,000
262,144
Wrong Answer
17
3,060
224
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?
N, M = list(map(int, input().split())) array= [0] * (N+1) for i in range(1, M+1): a, b = list(map(int, input().split())) array[a] = array[a] +1 array[b] = array[b] +1 for j in range(1, N): print(array[j])
s006200275
Accepted
17
3,060
226
N, M = list(map(int, input().split())) array= [0] * (N+1) for i in range(1, M+1): a, b = list(map(int, input().split())) array[a] = array[a] +1 array[b] = array[b] +1 for j in range(0, N): print(array[j+1])
s089179546
p03162
u194894739
2,000
1,048,576
Wrong Answer
512
15,728
382
Taro's summer vacation starts tomorrow, and he has decided to make plans for it now. The vacation consists of N days. For each i (1 \leq i \leq N), Taro will choose one of the following activities and do it on the i-th day: * A: Swim in the sea. Gain a_i points of happiness. * B: Catch bugs in the mountains. Gain b_i points of happiness. * C: Do homework at home. Gain c_i points of happiness. As Taro gets bored easily, he cannot do the same activities for two or more consecutive days. Find the maximum possible total points of happiness that Taro gains.
N = int(input()) A = []; B = []; C = [] for i in range(N): a, b, c = map(int, input().split()) A.append(a); B.append(b); C.append(c) dp = [[0,0,0]]*(N+1) for i in range(N): dp[i+1][0] = max(dp[i+1][0], dp[i][1], dp[i][2]) + A[i] dp[i+1][1] = max(dp[i+1][1], dp[i][2], dp[i][0]) + B[i] dp[i+1][2] = max(dp[i+1][2], dp[i][0], dp[i][1]) + C[i] print(max(dp[N]))
s193042900
Accepted
504
32,428
358
N = int(input()) table = [] for i in range(N): a, b, c = map(int, input().split()) table.append((a,b,c)) dpA = [0]*(N+1) dpB = [0]*(N+1) dpC = [0]*(N+1) for i in range(N): a, b, c = table[i] dpA[i+1] = max(dpB[i], dpC[i]) + a dpB[i+1] = max(dpC[i], dpA[i]) + b dpC[i+1] = max(dpA[i], dpB[i]) + c print(max(dpA[N], dpB[N], dpC[N]))
s000143293
p02399
u656153606
1,000
131,072
Wrong Answer
30
7,724
99
Write a program which reads two integers a and b, and calculates the following values: * a ÷ b: d (in integer) * remainder of a ÷ b: r (in integer) * a ÷ b: f (in real number)
a, b = [int(i) for i in input().split()] d = int(a / b) r = a % b f = float(a / b) print(d, r, f)
s494813902
Accepted
20
7,536
129
a, b = [float(i) for i in input().split()] d = int(a / b) r = int(a % b) f = float(a) / float(b) print('%s %s %.5f' %(d, r, f))
s108230288
p03738
u580920947
2,000
262,144
Wrong Answer
17
2,940
195
You are given two positive integers A and B. Compare the magnitudes of these numbers.
# -*- coding: utf-8 -*- a = int(input()) b = int(input()) def comp(a, b): if a < b: print("LESS") if a < b: print("GREATER") else: print("EQUAL")
s345033982
Accepted
17
2,940
217
# -*- coding: utf-8 -*- a = int(input()) b = int(input()) def comp(a, b): if a < b: print("LESS") elif a > b: print("GREATER") else: print("EQUAL") comp(a, b)
s530358982
p03359
u695079172
2,000
262,144
Wrong Answer
17
2,940
178
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?
def main(): a,b = list(map(int,input().split())) print(solve(a,b)) def solve(a,b): m = (a-1) * 12 n = b if b < 12 else 12 if __name__ == '__main__': main()
s411497250
Accepted
17
2,940
186
def main(): a,b = list(map(int,input().split())) print(solve(a,b)) def solve(a,b): m = a-1 n = 1 if a <= b else 0 return m + n if __name__ == '__main__': main()
s313411818
p02936
u645250356
2,000
1,048,576
Wrong Answer
2,105
62,936
660
Given is a rooted tree with N vertices numbered 1 to N. The root is Vertex 1, and the i-th edge (1 \leq i \leq N - 1) connects Vertex a_i and b_i. Each of the vertices has a counter installed. Initially, the counters on all the vertices have the value 0. Now, the following Q operations will be performed: * Operation j (1 \leq j \leq Q): Increment by x_j the counter on every vertex contained in the subtree rooted at Vertex p_j. Find the value of the counter on each vertex after all operations.
from collections import Counter,defaultdict import sys,heapq,bisect,math,itertools,string,queue mod = 10**9+7 def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpl_str(): return list(sys.stdin.readline().split()) def conb(n,r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n,q = inpl() ki = [[] for i in range(n)] ans = [0] * n for i in range(n-1): a,b = inpl() ki[a-1].append(b) for i in range(q): p,x = inpl() ans[p-1] += x st = [1] while st: tmp = st.pop() for j in ki[tmp-1]: ans[j-1] += ans[tmp-1] st += ki[tmp-1] print(ans)
s887911380
Accepted
1,084
224,604
795
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,pprint,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 mod2 = 998244353 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) def inpln(n): return list(int(sys.stdin.readline()) for i in range(n)) n,q = inpl() g = [[]for i in range(n)] c = [0 for i in range(n)] seen = [False] * n for i in range(n-1): a,b = inpl() g[a-1].append(b-1) g[b-1].append(a-1) for i in range(q): a,b = inpl() c[a-1] += b def dfs(node): for v in g[node]: if seen[v]: continue c[v] += c[node] seen[v] = True dfs(v) seen[0] = True dfs(0) print(*c)
s717252825
p02260
u776401692
1,000
131,072
Wrong Answer
20
5,600
278
Write a program of the Selection Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: SelectionSort(A) 1 for i = 0 to A.length-1 2 mini = i 3 for j = i to A.length-1 4 if A[j] < A[mini] 5 mini = j 6 swap A[i] and A[mini] Note that, indices for array elements are based on 0-origin. Your program should also print the number of swap operations defined in line 6 of the pseudocode in the case where i ≠ mini.
def selectsort(A): t=0 for i in range(0,len(A)): mini=i for j in range(i, len(A)): if A[j]<A[mini]: mini=j if i!=mini: temp=A[i] A[i]=A[mini] A[mini]=temp t+=1 return t input=input() A=[int(s) for s in input.split(' ')] t=selectsort(A) print (A,t)
s369108620
Accepted
20
5,604
312
def selectsort(A): t=0 for i in range(0,len(A)): mini=i for j in range(i, len(A)): if A[j]<A[mini]: mini=j if i!=mini: temp=A[i] A[i]=A[mini] A[mini]=temp t+=1 return t input() input=input() A=[int(s) for s in input.split(' ')] t=selectsort(A) print (' '.join(map(str,A))) print(t)
s441288641
p03068
u565387531
2,000
1,048,576
Wrong Answer
17
3,060
169
You are given a string S of length N consisting of lowercase English letters, and an integer K. Print the string obtained by replacing every character in S that differs from the K-th character of S, with `*`.
N = int(input()) S = str(input()) K = int(input()) t = S[K - 1] print(t) ans = '' for i in S: if i == t: ans += i else: ans += '*' print(ans)
s543258845
Accepted
17
2,940
159
N = int(input()) S = str(input()) K = int(input()) t = S[K - 1] ans = '' for i in S: if i == t: ans += i else: ans += '*' print(ans)
s464304678
p04043
u015084832
2,000
262,144
Wrong Answer
26
9,032
266
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.
def main(): a, b, c = map(int, input().split()) list = [] list.append(a) list.append(b) list.append(c) if list.count(5) == 2 and list.count(7) == 1 : print("Yes") else : print("No") if __name__ == '__main__': main()
s090263467
Accepted
29
9,016
266
def main(): a, b, c = map(int, input().split()) list = [] list.append(a) list.append(b) list.append(c) if list.count(5) == 2 and list.count(7) == 1 : print("YES") else : print("NO") if __name__ == '__main__': main()
s718706480
p02272
u918276501
1,000
131,072
Wrong Answer
20
7,680
675
Write a program of a Merge Sort algorithm implemented by the following pseudocode. You should also report the number of comparisons in the Merge function. Merge(A, left, mid, right) n1 = mid - left; n2 = right - mid; create array L[0...n1], R[0...n2] for i = 0 to n1-1 do L[i] = A[left + i] for i = 0 to n2-1 do R[i] = A[mid + i] L[n1] = SENTINEL R[n2] = SENTINEL i = 0; j = 0; for k = left to right-1 if L[i] <= R[j] then A[k] = L[i] i = i + 1 else A[k] = R[j] j = j + 1 Merge-Sort(A, left, right){ if left+1 < right then mid = (left + right)/2; call Merge-Sort(A, left, mid) call Merge-Sort(A, mid, right) call Merge(A, left, mid, right)
def merge(A, left, mid, right): L = A[left:mid] + [int(1e9)] R = A[mid:right] + [int(1e9)] i,j = 0,0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 global count count += (right - left) def merge_sort(A, left, right): if left+1 < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid, right) merge(A, left, mid, right) if __name__=='__main__': A = list(map(int, input().strip().split())) count = 0 merge_sort(A, 0, len(A)) print(" ".join(map(str, A))) print(count)
s328872163
Accepted
3,710
68,908
691
def merge(A, left, mid, right): L = A[left:mid] + [int(1e9)] R = A[mid:right] + [int(1e9)] i,j = 0,0 for k in range(left, right): if L[i] <= R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 global count count += (right - left) def merge_sort(A, left, right): if left+1 < right: mid = (left + right) // 2 merge_sort(A, left, mid) merge_sort(A, mid, right) merge(A, left, mid, right) if __name__=='__main__': n = int(input()) A = list(map(int, input().strip().split())) count = 0 merge_sort(A, 0, n) print(" ".join(map(str, A))) print(count)
s127644645
p02743
u106297876
2,000
1,048,576
Wrong Answer
17
2,940
151
Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?
a,b,c = map(int, input().split()) l = 4 * a * b r = (c * c - a * a - b * b) * (c * c - a * a - b * b) if l < r: print("Yes") else: print("No")
s761354165
Accepted
17
3,060
201
a,b,c = map(int, input().split()) l = 4 * a * b r = (c - a - b) * (c - a - b) if c - a - b <= 0: print("No") elif c < a or c < b: print("No") elif l < r: print("Yes") else: print("No")
s440756806
p03448
u039623862
2,000
262,144
Wrong Answer
49
3,060
229
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()) cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i + 100*b + 50*c == x: cnt += 1 print(cnt)
s945373007
Accepted
54
3,060
229
a = int(input()) b = int(input()) c = int(input()) x = int(input()) cnt = 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: cnt += 1 print(cnt)
s363151238
p03160
u450983668
2,000
1,048,576
Wrong Answer
151
15,516
380
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
def chmin(a, b): if a > b: return b else: return a def main(): dp = [1e4+10]*100010 hs = [0]*100010 N = int(input()) hs[:N] = map(int, input().split()) dp[0] = 0 for i in range(N): dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i])) dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i])) print(dp[:N], dp[N-1]) if __name__ == '__main__': main()
s178907761
Accepted
132
15,516
381
def chmin(a, b): if a > b: return b else: return a def main(): dp = [1e9]*100010 hs = [0]*100010 N = int(input()) hs[:N] = map(int, input().split()) dp[0] = 0 for i in range(N): dp[i+1] = chmin(dp[i+1], dp[i]+abs(hs[i+1]-hs[i])) dp[i+2] = chmin(dp[i+2], dp[i]+abs(hs[i+2]-hs[i])) print(dp[N-1]) return if __name__ == '__main__': main()
s694877678
p03434
u339025042
2,000
262,144
Wrong Answer
17
3,064
220
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() Alice = 0 Bob = 0 for i, num in enumerate(A): if i//2 == 0: Alice += num else: Bob += num print(Alice - Bob)
s525670380
Accepted
18
3,060
219
N = int(input()) A = list(map(int, input().split())) A.sort() A.reverse() Alice = 0 Bob = 0 for i, num in enumerate(A): if i%2 == 0: Alice += num else: Bob += num print(Alice - Bob)
s366663461
p03193
u623687794
2,000
1,048,576
Wrong Answer
22
3,060
128
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally). Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate. Out of the N materials, how many can produce an H \times W plate if properly cut?
n,h,w=map(int,input().split()) ans=0 for i in range(n): a,b=map(int,input().split()) if a<=h and b<=w:ans+=1 print(ans)
s091782812
Accepted
20
3,060
128
n,h,w=map(int,input().split()) ans=0 for i in range(n): a,b=map(int,input().split()) if a>=h and b>=w:ans+=1 print(ans)
s649449958
p02795
u984276646
2,000
1,048,576
Wrong Answer
17
2,940
119
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()) M = max(H, W) if N % M: S = N // M else: S = N // M + 1 print(S)
s205381721
Accepted
18
2,940
125
H = int(input()) W = int(input()) N = int(input()) M = max(H, W) if N % M == 0: S = N // M else: S = N // M + 1 print(S)
s744660034
p04029
u062484507
2,000
262,144
Wrong Answer
17
2,940
111
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?
S = input() ans = "" for i in S: if i == "B": ans = ans[0:-1] else: ans += i print(ans)
s671039988
Accepted
17
2,940
68
N = int(input()) a = [i for i in range(N+1)] ans = sum(a) print(ans)
s092539799
p02842
u430928274
2,000
1,048,576
Wrong Answer
31
9,052
208
Takahashi bought a piece of apple pie at ABC Confiserie. According to his memory, he paid N yen (the currency of Japan) for it. The consumption tax rate for foods in this shop is 8 percent. That is, to buy an apple pie priced at X yen before tax, you have to pay X \times 1.08 yen (rounded down to the nearest integer). Takahashi forgot the price of his apple pie before tax, X, and wants to know it again. Write a program that takes N as input and finds X. We assume X is an integer. If there are multiple possible values for X, find any one of them. Also, Takahashi's memory of N, the amount he paid, may be incorrect. If no value could be X, report that fact.
N = int(input()) if (N*100)%108 == 0 : print(N/1.08) else : for i in range(1,100) : if (N*100+i) % 108 == 0 : print((N*100+i)/108) break else : print(":(")
s735474658
Accepted
27
9,136
218
N = int(input()) if (N*100)%108 == 0 : print(int(N/1.08)) else : for i in range(1,100) : if (N*100+i) % 108 == 0 : print(int((N*100+i)/108)) break else : print(":(")
s834422973
p03644
u537550206
2,000
262,144
Wrong Answer
17
3,060
199
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()) n_dict = {} count = 0 for i in range(1,n + 1): tmp = i while i % 2 == 0: i = i/2 count += 1 n_dict[tmp] = count print(max(n_dict, key=n_dict.get))
s900103209
Accepted
17
2,940
64
n = int(input()) a = 1 while a <= n: a = a * 2 print(a // 2)
s774751612
p03760
u597047658
2,000
262,144
Wrong Answer
17
3,060
237
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
o, e = input(), input() s = '' o_idx = 0 e_idx = 0 i = 0 while o_idx < len(o) or e_idx < len(e): if i % 2 == 0: s += o[o_idx] o_idx += 1 else: s += e[e_idx] e_idx += 1 i += 1 print(i) print(s)
s012493375
Accepted
18
3,060
228
o, e = input(), input() s = '' o_idx = 0 e_idx = 0 i = 0 while o_idx < len(o) or e_idx < len(e): if i % 2 == 0: s += o[o_idx] o_idx += 1 else: s += e[e_idx] e_idx += 1 i += 1 print(s)
s587746823
p03997
u613858382
2,000
262,144
Wrong Answer
17
2,940
56
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.
def calculate_area(a, b, h): return int((a + b)*h/2)
s896328420
Accepted
19
2,940
113
input_list = [int(input()) for i in range(3)] S = int((input_list[0] + input_list[1])*input_list[2]/2) print(S)
s363875901
p02401
u747009765
1,000
131,072
Wrong Answer
20
7,640
264
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b. The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.
while True: a, op, b = input().split() a = int(a) b = int(b) if op == '?': break if op == '+': print(a + b) if op == '-': print(a - b) if op == '*': print(a *b) if op == '/': print(a / b)
s272937916
Accepted
20
7,660
265
while True: a, op, b = input().split() a = int(a) b = int(b) if op == '?': break if op == '+': print(a + b) if op == '-': print(a - b) if op == '*': print(a *b) if op == '/': print(a // b)
s554830651
p02620
u830054172
2,000
1,048,576
Wrong Answer
364
9,292
1,141
"Local search" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process, the quality of the solution is gradually improved over time. The pseudo-code is as follows. solution = compute an initial solution (by random generation, or by applying other methods such as greedy) while the remaining time > 0: slightly modify the solution (randomly) if the solution gets worse: restore the solution For example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q. The pseudo-code is as follows. t[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy) while the remaining time > 0: pick d and q at random old = t[d] # Remember the original value so that we can restore it later t[d] = q if the solution gets worse: t[d] = old The most important thing when using the local search method is the design of how to modify solutions. 1. If the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small. 2. In order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification. In this problem C, we focus on the second point. The score after the modification can, of course, be obtained by calculating the score from scratch. However, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification. From another viewpoint, the impossibility of such a fast incremental calculation implies that a small modification to the solution affects a majority of the score calculation. In such a case, we may need to redesign how to modify solutions, or there is a high possibility that the problem is not suitable for local search. Let's implement fast incremental score computation. It's time to demonstrate the skills of algorithms and data structures you have developed in ABC and ARC! In this kind of contest, where the objective is to find a better solution instead of the optimal one, a bug in a program does not result in a wrong answer, which may delay the discovery of the bug. For early detection of bugs, it is a good idea to unit test functions you implemented complicated routines. For example, if you implement fast incremental score calculation, it is a good idea to test that the scores computed by the fast implementation match the scores computed from scratch, as we will do in this problem C.
from bisect import bisect_left D = int(input()) C = [0]+list(map(int, input().split())) S = [0]+[[0] + list(map(int, input().split())) for _ in range(D)] contest = [[0] for _ in range(27)] SL, sch = 0, [0] for d in range(1, D+1): t = int(input()) sch.append(t) contest[t].append(d) SL += S[d][t] for i in range(1, 27): SL -= C[i]*(d-contest[i][-1]) for i in range(1, 27): contest[i].append(D+1) # print(S) M = int(input()) for i in range(M): d, q = map(int, input().split()) SL += S[d][q]-S[d][sch[d]] ind = bisect_left(contest[sch[d]], d) # print("2", ind) k = d-contest[sch[d]][ind-1] l = contest[sch[d]][ind+1]-d SL -= C[sch[d]]*k*l del contest[sch[d]][ind] ind = bisect_left(contest[q], d) contest[q].insert(ind, d) k = d-contest[q][ind-1] l = contest[q][ind+1]-d SL += C[q]*k*l sch[d] = q # print(SL)
s670253413
Accepted
587
9,176
1,139
from bisect import bisect_left D = int(input()) C = [0]+list(map(int, input().split())) S = [0]+[[0] + list(map(int, input().split())) for _ in range(D)] contest = [[0] for _ in range(27)] SL, sch = 0, [0] for d in range(1, D+1): t = int(input()) sch.append(t) contest[t].append(d) SL += S[d][t] for i in range(1, 27): SL -= C[i]*(d-contest[i][-1]) for i in range(1, 27): contest[i].append(D+1) # print(S) M = int(input()) for i in range(M): d, q = map(int, input().split()) SL += S[d][q]-S[d][sch[d]] ind = bisect_left(contest[sch[d]], d) # print("2", ind) k = d-contest[sch[d]][ind-1] l = contest[sch[d]][ind+1]-d SL -= C[sch[d]]*k*l del contest[sch[d]][ind] ind = bisect_left(contest[q], d) contest[q].insert(ind, d) k = d-contest[q][ind-1] l = contest[q][ind+1]-d SL += C[q]*k*l sch[d] = q print(SL)
s345801245
p03351
u925353288
2,000
1,048,576
Wrong Answer
30
9,072
927
Three people, A, B and C, are trying to communicate using transceivers. They are standing along a number line, and the coordinates of A, B and C are a, b and c (in meters), respectively. Two people can directly communicate when the distance between them is at most d meters. Determine if A and C can communicate, either directly or indirectly. Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.
a,b,c,d = map(int,input().split()) Between_a_to_c = abs( a - c ) Between_a_to_b = abs( a - b ) Between_b_to_c = abs( b - c ) if Between_a_to_c < d : print('Yes') elif Between_a_to_b < d : if Between_b_to_c < d : print('Yes') else: print('No') else: print('No')
s355737730
Accepted
30
9,176
936
a,b,c,d = map(int,input().split()) Between_a_to_c = abs( a - c ) Between_a_to_b = abs( a - b ) Between_b_to_c = abs( b - c ) if not Between_a_to_c > d: print('Yes') elif not Between_a_to_b > d: if not Between_b_to_c > d: print('Yes') else: print('No') else: print('No')
s129403303
p03049
u060938295
2,000
1,048,576
Wrong Answer
42
3,700
510
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.
# -*- coding: utf-8 -*- """ Created on Sun May 12 12:43:59 2019 @author: Yamazaki Kenichi """ N = int(input()) S = [input() for i in range(N)] ans = 0 firstB, lastA, u = 0, 0, 0 for s in S: flg = False for c in s: if flg and c == "B": ans += 1 flg = False if c == 'A': flg = True if s[0] == 'B': firstB += 1 if s[-1] == 'A': lastA += 1 if s[0] == 'B' and s[-1] == 'A': u += 1 ans += min(firstB,lastA,u-1) print(ans)
s228335604
Accepted
41
3,700
563
# -*- coding: utf-8 -*- """ Created on Sun May 12 12:43:59 2019 @author: Yamazaki Kenichi """ N = int(input()) S = [input() for i in range(N)] ans = 0 firstB, lastA, u = 0, 0, 0 for s in S: flg = False for c in s: if flg and c == "B": ans += 1 flg = False if c == 'A': flg = True if s[0] == 'B': firstB += 1 if s[-1] == 'A': lastA += 1 if s[0] == 'B' and s[-1] == 'A': u += 1 ans += min(firstB,lastA) ans -= 1 if u == firstB and u == lastA and u != 0 else 0 print(ans)
s463414036
p02409
u488038316
1,000
131,072
Wrong Answer
30
7,824
611
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.
# -*-coding:utf-8 import fileinput import math def main(): offiHouse = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)] n = int(input()) for i in range(n): a, b, c, d = map(int, input().split()) offiHouse[a-1][b-1][c-1] += d for i in range(4): for j in range(3): for k in range(10): if(k == 9): print('%d' % offiHouse[i][j][k]) else: print('%d ' % offiHouse[i][j][k], end='') print('####################') if __name__ == '__main__': main()
s137930233
Accepted
30
7,912
529
# -*-coding:utf-8 import fileinput import math def main(): offiHouse = [[[0 for i3 in range(10)] for i2 in range(3)] for i1 in range(4)] n = int(input()) for i in range(n): a, b, c, d = map(int, input().split()) offiHouse[a-1][b-1][c-1] += d for i in range(4): for j in range(3): for k in range(10): print('', offiHouse[i][j][k], end='') print() if(i != 3): print('#' * 20) if __name__ == '__main__': main()
s653686996
p03470
u435281580
2,000
262,144
Wrong Answer
17
2,940
129
An _X -layered kagami mochi_ (X ≥ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?
def kagamimochi(diameters): return len(list(set(diameters))) n = int(input()) kagamimochi([int(input()) for _ in range(n)])
s921547999
Accepted
18
3,060
135
def kagamimochi(diameters): return len(list(set(diameters))) n = int(input()) print(kagamimochi([int(input()) for _ in range(n)]))
s821272036
p02578
u904331908
2,000
1,048,576
Wrong Answer
121
32,272
192
N persons are standing in a row. The height of the i-th person from the front is A_i. We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person: Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool. Find the minimum total height of the stools needed to meet this goal.
n = int(input()) s = list(map(int, input().split())) print(s) top = s[0] count = 0 for x in s : if x <= top : count = count + top - x else : top = x print(count)
s526951864
Accepted
105
32,148
182
n = int(input()) s = list(map(int, input().split())) top = s[0] count = 0 for x in s : if x <= top : count = count + top - x else : top = x print(count)
s679287503
p00002
u731896389
1,000
131,072
Wrong Answer
20
7,536
93
Write a program which computes the digit number of sum of two integers a and b.
import sys for line in sys.stdin: a,b = map(int,input().split()) print(len(str(a+b)))
s853099196
Accepted
20
7,548
94
import sys for line in sys.stdin: a,b = line.split(" ") print(len(str(int(a)+int(b))))
s418187216
p03607
u548303713
2,000
262,144
Wrong Answer
249
8,284
290
You are playing the following game with Joisino. * Initially, you have a blank sheet of paper. * Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. * Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?
n=int(input()) a=[] for i in range(n): a.append(int(input())) a2=sorted(a) num=a2[0] count=1 ans=0 for i in range(1,n): if a2[i]==num: count+=1 else: if count%2==1: ans+=num num=a2[i] count=1 if count%2==1: ans+=num print(ans)
s843020639
Accepted
259
8,280
286
n=int(input()) a=[] for i in range(n): a.append(int(input())) a2=sorted(a) num=a2[0] count=1 ans=0 for i in range(1,n): if a2[i]==num: count+=1 else: if count%2==1: ans+=1 num=a2[i] count=1 if count%2==1: ans+=1 print(ans)
s979540494
p03760
u276115223
2,000
262,144
Wrong Answer
17
2,940
175
Snuke signed up for a new website which holds programming competitions. He worried that he might forget his password, and he took notes of it. Since directly recording his password would cause him trouble if stolen, he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions. You are given two strings O and E. O contains the characters at the odd- numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order. Restore the original password.
o, e = [input() for _ in range(2)] passwd = ''.join([o[i] + e[i] for i in range(len(e))]) print(passwd if len(o) == len(passwd) else passwd + o[-1])
s525376972
Accepted
17
2,940
170
o, e = [input() for _ in range(2)] passwd = ''.join([o[i] + e[i] for i in range(len(e))]) print(passwd if len(o) == len(e) else passwd + o[-1])
s263639649
p03573
u901582103
2,000
262,144
Wrong Answer
20
3,060
79
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.
a,b,c=map(int,input().split()) if a==b or a==c: print(a) else: print(b)
s065249852
Accepted
18
2,940
95
a,b,c=map(int,input().split()) if a==b: print(c) elif b==c: print(a) else: print(b)
s354542138
p02315
u426534722
1,000
131,072
Wrong Answer
20
7,576
352
You have N items that you want to put them into a knapsack. Item i has value vi and weight wi. You want to find a subset of items to put such that: * The total value of the items is as large as possible. * The items have combined weight at most W, that is capacity of the knapsack. Find the maximum total value of items in the knapsack.
N, W = [int(i) for i in input().split()] dp = [[0 for j in range(W + 1)] for i in range(N + 1)] v = w = 0 for i in range(0, N): v, w = [int(i) for i in input().split()] for j in range(0, W + 1): if j < w : dp[i][j] = dp[i + 1][j] else : dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v) print(dp[-1][W])
s502665100
Accepted
1,090
27,984
342
N, W = [int(i) for i in input().split()] dp = [[0 for j in range(W + 1)] for i in range(N + 1)] v = w = 0 for i in range(N - 1, -1, -1): v, w = [int(i) for i in input().split()] for j in range(0, W + 1): dp[i][j] = dp[i + 1][j] if j >= w : dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v) print(dp[0][W])
s373064086
p02841
u399155892
2,000
1,048,576
Wrong Answer
18
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.
M1, D1 = map(int, input().split()) M2, D2 = map(int, input().split()) if M1 != M2: print(0) else: print(1)
s521428470
Accepted
17
2,940
112
M1, D1 = map(int, input().split()) M2, D2 = map(int, input().split()) if M1 != M2: print(1) else: print(0)
s923522707
p03861
u488178971
2,000
262,144
Wrong Answer
17
2,940
113
You are given nonnegative integers a and b (a ≤ b), and a positive integer x. Among the integers between a and b, inclusive, how many are divisible by x?
# ABC 046 B a,b,x =map(int,input().split()) if a ==0: print(b//x - a//x + 1) else: print(b//x - a//x)
s213990329
Accepted
19
2,940
116
# ABC 046 B a,b,x =map(int,input().split()) if a %x ==0: print(b//x - a//x + 1) else: print(b//x - a//x)
s507863382
p00004
u058433718
1,000
131,072
Wrong Answer
20
7,600
560
Write a program which solve a simultaneous equation: ax + by = c dx + ey = f The program should print x and y for given a, b, c, d, e and f (-1,000 ≤ a, b, c, d, e, f ≤ 1,000). You can suppose that given equation has a unique solution.
# ax + by = c # dx + ey = f import sys def inverse(a, b, d, e): deta = a * e - b * d return (deta, e, -b, -d, a) while True: data = sys.stdin.readline() if data is None or data.strip() == '': break data = data.strip().split(' ') print('data:%s' % data) a, b, c, d, e, f = [float(i) for i in data] inv = inverse(a, b, d, e) print('inv:', inv) x = (inv[1] * c + inv[2] * f) / inv[0] y = (inv[3] * c + inv[4] * f) / inv[0] print('%.4f %.4f' % (x, y))
s489603143
Accepted
20
7,440
517
# ax + by = c # dx + ey = f import sys def inverse(a, b, d, e): deta = a * e - b * d return (deta, e, -b, -d, a) while True: data = sys.stdin.readline() if data is None or data.strip() == '': break data = data.strip().split(' ') a, b, c, d, e, f = [float(i) for i in data] inv = inverse(a, b, d, e) x = (inv[1] * c + inv[2] * f) / inv[0] + 0 y = (inv[3] * c + inv[4] * f) / inv[0] + 0 print('%.3f %.3f' % (x, y))
s741333218
p03155
u844789719
2,000
1,048,576
Wrong Answer
17
2,940
68
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?
N, H, W = [int(input()) for _ in range(3)] print((N - H) * (N - W))
s071859988
Accepted
17
2,940
76
N, H, W = [int(input()) for _ in range(3)] print((N - H + 1) * (N - W + 1))
s797616907
p03449
u196675341
2,000
262,144
Wrong Answer
19
3,064
375
We have a 2 \times N grid. We will denote the square at the i-th row and j-th column (1 \leq i \leq 2, 1 \leq j \leq N) as (i, j). You are initially in the top-left square, (1, 1). You will travel to the bottom-right square, (2, N), by repeatedly moving right or down. The square (i, j) contains A_{i, j} candies. You will collect all the candies you visit during the travel. The top-left and bottom-right squares also contain candies, and you will also collect them. At most how many candies can you collect when you choose the best way to travel?
n = int(input()) n1 = list(map(int,input().strip().split(' '))) n2 = list(map(int,input().strip().split(' '))) path = [] path.append(n1) path.append(n2) sum_list = [] for i in range(n): sum = 0 for j in range(i+1): sum += path[0][j] for k in range(i,n): sum += path[1][k] sum_list.append(sum) print(sum_list) print(max(sum_list))
s422674299
Accepted
19
3,064
359
n = int(input()) n1 = list(map(int,input().strip().split(' '))) n2 = list(map(int,input().strip().split(' '))) path = [] path.append(n1) path.append(n2) sum_list = [] for i in range(n): sum = 0 for j in range(i+1): sum += path[0][j] for k in range(i,n): sum += path[1][k] sum_list.append(sum) print(max(sum_list))
s714613175
p03469
u921830178
2,000
262,144
Wrong Answer
17
2,940
33
On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in `yyyy/mm/dd` format. For example, January 23, 2018 should be written as `2018/01/23`. After finishing the document, she noticed that she had mistakenly wrote `2017` at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to `2018` and prints it.
S = input() print("2019"+S[4:12])
s486948385
Accepted
17
2,940
33
S = input() print("2018"+S[4:12])
s707393345
p03759
u470542271
2,000
262,144
Wrong Answer
17
2,940
96
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 = map(int, input().split()) if (b - a == c - b): print('Yes') else: print('No')
s292350060
Accepted
17
2,940
96
a, b, c = map(int, input().split()) if (b - a == c - b): print('YES') else: print('NO')
s437903930
p02927
u864069774
2,000
1,048,576
Wrong Answer
21
3,060
230
Today is August 24, one of the five Product Days in a year. A date m-d (m is the month, d is the date) is called a Product Day when d is a two-digit number, and all of the following conditions are satisfied (here d_{10} is the tens digit of the day and d_1 is the ones digit of the day): * d_1 \geq 2 * d_{10} \geq 2 * d_1 \times d_{10} = m Takahashi wants more Product Days, and he made a new calendar called Takahashi Calendar where a year consists of M month from Month 1 to Month M, and each month consists of D days from Day 1 to Day D. In Takahashi Calendar, how many Product Days does a year have?
M,D = map(int,input().split()) c = 0 for m in range(M+1): for d in range(D): d1 = d%10 d10 = int((d-d1)/10) if d1 >= 2 and d10 >= 2 and d1*d10 == m: print(d1,d10) c+=1 print(c)
s491758221
Accepted
21
2,940
210
M,D = map(int,input().split()) c = 0 for m in range(1,M+1): for d in range(1,D+1): d1 = d%10 d10 = int((d-d1)/10) if d1 >= 2 and d10 >= 2 and d1*d10 == m: c+=1 print(c)
s085065495
p03455
u836467497
2,000
262,144
Wrong Answer
17
2,940
111
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
# -*- coding: utf-8 -*- a, b = map(int, input().split()) if a % b == 0: print('Even') else: print('Odd')
s072453484
Accepted
18
2,940
114
# -*- coding: utf-8 -*- a, b = map(int, input().split()) if (a * b) % 2 == 0: print('Even') else: print('Odd')
s358501694
p03860
u609061751
2,000
262,144
Wrong Answer
17
2,940
81
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.
import sys input = sys.stdin.readline x = input().split() print("A" + x[0] + "C")
s764596766
Accepted
17
2,940
84
import sys input = sys.stdin.readline x = input().split() print("A" + x[1][0] + "C")
s488896927
p02613
u103341055
2,000
1,048,576
Wrong Answer
145
9,188
190
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()) d = {"AC":0,"WA":0,"TLE":0,"RE":0} for _ in range(N): d[input()] += 1 print("AC x",d["AC"]) print("WA x 0",d["WA"] ) print("TLE x 0",d["TLE"]) print("RE x 0",d["RE"])
s955722956
Accepted
144
9,192
184
N = int(input()) d = {"AC":0,"WA":0,"TLE":0,"RE":0} for _ in range(N): d[input()] += 1 print("AC x",d["AC"]) print("WA x",d["WA"] ) print("TLE x",d["TLE"]) print("RE x",d["RE"])
s750496604
p02742
u212263866
2,000
1,048,576
Wrong Answer
17
3,064
249
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:
datas = input().split(" ") h = int(datas[0]) w = int(datas[1]) if( h % 2 == 0 and w % 2 == 0): print( h /2 * w/2 ) elif( h % 2 == 0 ): print( h //2 * w//2 + 1 ) elif( w % 2 == 0): print( h //2 * w//2 + 1 ) else: print( h //2 * w//2 + 1 )
s672870693
Accepted
17
3,064
341
datas = input().split(" ") h = int(datas[0]) w = int(datas[1]) if( h==1 ): print(1) elif( w== 1): print(1) elif( h % 2 == 0 and w % 2 == 0): print( h * w//2 ) elif( h % 2 == 0 ): print( (h * (w-1))//2 + h // 2 ) elif( w % 2 == 0): print( (w * (h-1))//2 + w // 2 ) else: print( ((h-1) * (w-1))//2 + (h-1) // 2 + w // 2 +1 )
s691639496
p03720
u123745130
2,000
262,144
Wrong Answer
17
3,060
288
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?
n,m=map(int,input().split()) x_l=[] for i in range(m): x_l+= list(map(int,input().split())) # print(n,m,x_l) dic={} for i in x_l: if i not in dic: dic[i]=1 else:dic[i]+=1 # print(dic) for i in range(m+1): if i not in dic: continue else: print(dic[i])
s050680637
Accepted
17
3,060
259
n,m=map(int,input().split()) x_l=[] for i in range(m): x_l+= list(map(int,input().split())) dic={} for i in x_l: if i not in dic: dic[i]=1 else:dic[i]+=1 for i in range(1,n+1): if i not in dic: print(0) else: print(dic[i])
s671778907
p03228
u629540524
2,000
1,048,576
Wrong Answer
26
9,116
142
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi: * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person. Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.
a,b,k = map(int,input().split()) for i in range(k): if a%2==1: a-=1 b+=a//2 if b%2==1: b-=1 a+=b//2 print(a,b)
s510638378
Accepted
29
9,176
243
a,b,k = map(int,input().split()) for i in range(k): if i%2==0: if a%2==1: a-=1 c =a//2 b+=c a-=c else: if b%2==1: b-=1 c =b//2 a+=c b-=c print(a,b)
s947446450
p03606
u633000076
2,000
262,144
Wrong Answer
20
3,064
272
Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000. According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are sitting at the theater now?
N = int(input()) x = [] y = [] for i in range(0,N): x1,y1=[int(i) for i in input().split()] x.append(x1) y.append(y1) print(x) total=0 for j in range(0,N): if x[j]<y[j]: total=total+y[j]-x[j]+1 elif x[j]==y[j]: total+=1 print(total)
s589894960
Accepted
21
3,064
273
N = int(input()) x = [] y = [] for i in range(0,N): x1,y1=[int(i) for i in input().split()] x.append(x1) y.append(y1) #print(x) total=0 for j in range(0,N): if x[j]<y[j]: total=total+y[j]-x[j]+1 elif x[j]==y[j]: total+=1 print(total)
s205529860
p03447
u916743460
2,000
262,144
Wrong Answer
20
3,316
78
You went shopping to buy cakes and donuts with X yen (the currency of Japan). First, you bought one cake for A yen at a cake shop. Then, you bought as many donuts as possible for B yen each, at a donut shop. How much do you have left after shopping?
money = int(input()) a = int(input()) b = int(input()) print(money - (a + b))
s075036450
Accepted
17
2,940
109
money = int(input()) a = int(input()) b = int(input()) money -= a while money >= b: money -= b print(money)