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
s505636196
p02406
u801346721
1,000
131,072
Time Limit Exceeded
40,000
7,540
143
In programming languages like C/C++, a goto statement provides an unconditional jump from the "goto" to a labeled statement. For example, a statement "goto CHECK_NUM;" is executed, control of the program jumps to CHECK_NUM. Using these constructs, you can implement, for example, loops. Note that use of goto statement is highly discouraged, because it is difficult to trace the control flow of a program which includes goto. Write a program which does precisely the same thing as the following program (this example is wrtten in C++). Let's try to write the program without goto statements. void call(int n){ int i = 1; CHECK_NUM: int x = i; if ( x % 3 == 0 ){ cout << " " << i; goto END_CHECK_NUM; } INCLUDE3: if ( x % 10 == 3 ){ cout << " " << i; goto END_CHECK_NUM; } x /= 10; if ( x ) goto INCLUDE3; END_CHECK_NUM: if ( ++i <= n ) goto CHECK_NUM; cout << endl; }
n = int(input()) i = 1 while i <= n: if i % 3 == 0: print(' {}'.format(i)) continue elif i % 10 == 3: print(' {}'.format(i)) continue
s196356666
Accepted
40
7,964
227
n = int(input()) i = 1 for i in range(1, n + 1): if i % 3 == 0: print(' {0}'.format(i), end = '') else: st = str(i) for x in range(0, len(st)): if st[x] == '3': print(' {0}'.format(i), end = '') break print()
s172833995
p03090
u648212584
2,000
1,048,576
Wrong Answer
18
3,064
830
You are given an integer N. Build an undirected graph with N vertices with indices 1 to N that satisfies the following two conditions: * The graph is simple and connected. * There exists an integer S such that, for every vertex, the sum of the indices of the vertices adjacent to that vertex is S. It can be proved that at least one such graph exists under the constraints of this problem.
import sys input = sys.stdin.readline def main(): N = int(input()) if N == 3: print(1,3) print(2,3) elif N == 4: print(1,2) print(1,3) print(4,2) print(4,3) else: if N%2 == 0: for i in range(N//2-1): print(i+1,i+2) print(i+1,N-i-1) print(N-i,i+2) print(N-i,N-i-1) for i in range(2): print(N//2+i,1) print(N//2+i,N) else: for i in range(N//2-1): print(i+1,i+2) print(i+1,N-i-2) print(N-i-1,i+2) print(N-i-1,N-i-2) print(N//2,N) print(N//2+1,N) print(N,1) print(N,N-1) if __name__ == "__main__": main()
s731674467
Accepted
17
3,188
912
import sys input = sys.stdin.readline def main(): N = int(input()) if N == 3: print(2) print(1,3) print(2,3) elif N == 4: print(4) print(1,2) print(1,3) print(4,2) print(4,3) else: if N%2 == 0: print(N*2) for i in range(N//2-1): print(i+1,i+2) print(i+1,N-i-1) print(N-i,i+2) print(N-i,N-i-1) for i in range(2): print(N//2+i,1) print(N//2+i,N) else: print(N*2-2) for i in range(N//2-1): print(i+1,i+2) print(i+1,N-i-2) print(N-i-1,i+2) print(N-i-1,N-i-2) print(N//2,N) print(N//2+1,N) print(N,1) print(N,N-1) if __name__ == "__main__": main()
s535000081
p02606
u326408598
2,000
1,048,576
Wrong Answer
29
9,156
158
How many multiples of d are there among the integers between L and R (inclusive)?
l, r,d = map(int,input().split()) r-=1 count=0 if r<d: print(count) else: if l<d: l=d count+=1 count+=((r-l)//d) print(count)
s036557526
Accepted
25
9,176
243
l, r,d = map(int,input().split()) count=0 if r<d: print(count) else: if l<d: l=d count+=1 elif l%d==0: count+=1 elif l%d!=0: l += d-(l%d) count+=1 count+=((r-l)//d) print(count)
s520226125
p03394
u211160392
2,000
262,144
Wrong Answer
44
3,424
209
Nagase is a top student in high school. One day, she's analyzing some properties of special sets of positive integers. She thinks that a set S = \\{a_{1}, a_{2}, ..., a_{N}\\} of **distinct** positive integers is called **special** if for all 1 \leq i \leq N, the gcd (greatest common divisor) of a_{i} and the sum of the remaining elements of S is **not** 1. Nagase wants to find a **special** set of size N. However, this task is too easy, so she decided to ramp up the difficulty. Nagase challenges you to find a **special** set of size N such that the gcd of all elements are 1 and the elements of the set does not exceed 30000.
N = int(input()) a,b = 0,0 for i in range(1,5001): a = 3*i b = N-a if b <= 5000 and b%2 == 0: break for i in range(a): print(2*i+2,end=" ") for i in range(b): print(6*i+3,end=" ")
s793571956
Accepted
45
3,424
442
N = int(input()) if N == 3: print(2,5,63) exit() if N == 4: print(2,5,20,63) exit() if N == 6: print(2,4,6,3,9,24) exit() if N == 19999: for i in range(1,30000): if i%2 == 0 or i % 3 == 0: print(i,end=" ") exit() for a in range(3,15001,3): b = N-a if 1 < b <= 5000 and b%2 == 0: break for i in range(a): print(2*i+2,end=" ") for i in range(b): print(6*i+3,end=" ")
s563133568
p03681
u536034761
2,000
262,144
Wrong Answer
523
10,292
291
Snuke has N dogs and M monkeys. He wants them to line up in a row. As a Japanese saying goes, these dogs and monkeys are on bad terms. _("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.)_ Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys. How many such arrangements there are? Find the count modulo 10^9+7 (since animals cannot understand numbers larger than that). Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.
from math import factorial def combinations_count(n, r): return factorial(n) // (factorial(n - r) * factorial(r)) N, M = map(int, input().split()) mod = 10**9 + 7 print(((factorial(N) % mod) * (combinations_count(N + 1, M) % mod) * (factorial(M) % mod)) % mod if abs(N - M) <= 2 else 0)
s274673246
Accepted
275
10,048
258
from math import factorial def count(n, r): if n == r: return 2 else: return 1 N, M = map(int, input().split()) mod = 10**9 + 7 print(((factorial(N) % mod) * (count(N, M) % mod) * (factorial(M) % mod)) % mod if abs(N - M) < 2 else 0)
s734068767
p02260
u002280517
1,000
131,072
Wrong Answer
20
5,596
306
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.
n = int(input()) a = list(map(int,input().split())) count = 0 for i in range(n): minij =i for j in range(i,n): if a[j] < a[minij]: minij = j a[i],a[minij] = a[minij],a[i] count+=1 for i in range(n): print("{0} ".format(a[i]),end="") print() print(count)
s387306320
Accepted
20
5,600
292
n = int(input()) a = list(map(int,input().split())) count = 0 for i in range(n): minij =i for j in range(i,n): if a[j] < a[minij]: minij = j if a[i] > a[minij]: count+=1 a[i],a[minij] = a[minij],a[i] print(' '.join(map(str,a))) print(count)
s715262563
p02694
u727787724
2,000
1,048,576
Wrong Answer
22
9,044
65
Takahashi has a deposit of 100 yen (the currency of Japan) in AtCoder Bank. The bank pays an annual interest rate of 1 % compounded annually. (A fraction of less than one yen is discarded.) Assuming that nothing other than the interest affects Takahashi's balance, in how many years does the balance reach X yen or above for the first time?
n=int(input()) z=100 i=0 while z>n: z=z**(1.01) i+=1 print(i)
s234127459
Accepted
25
9,220
121
# coding: utf-8 # Your code here! n=int(input()) z=100 i=0 while z<n: z=z*(1.01) z=z//1 i+=1 #print(z) print(i)
s900426247
p02613
u011202375
2,000
1,048,576
Wrong Answer
155
17,408
309
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.
S=input() S=int(S) a = [input() for i in range(S)] AC=0 WA=0 TLE=0 RE=0 print(a) for a in a: if a=="AC": AC+=1 if a=="WA": WA+=1 if a=="TLE": TLE+=1 if a=="RE": RE+=1 print("AC x "+str(AC) ) print("WA x "+str(WA)) print("TLE x "+str(TLE)) print("RE x "+str(RE))
s603502803
Accepted
156
15,952
301
S=input() S=int(S) a = [input() for i in range(S)] AC=0 WA=0 TLE=0 RE=0 for a in a: if a=="AC": AC+=1 if a=="WA": WA+=1 if a=="TLE": TLE+=1 if a=="RE": RE+=1 print("AC x "+str(AC) ) print("WA x "+str(WA)) print("TLE x "+str(TLE)) print("RE x "+str(RE))
s160951245
p03523
u760961723
2,000
262,144
Wrong Answer
17
2,940
294
You are given a string S. Takahashi can insert the character `A` at any position in this string any number of times. Can he change S into `AKIHABARA`?
S = input() ans_list = ["AKIHABARA",\ "KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR",\ "KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR",\ "AKIHBR","KIHABR","KIHBAR","KIHBRA"\ "KIHBR"] if S in ans_list: print("YES") else: print("NO")
s427576019
Accepted
17
2,940
297
S = input() ans_list = ["AKIHABARA",\ "KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR",\ "KIHBARA","KIHABRA","KIHABAR","AKIHBRA","AKIHBAR","AKIHABR",\ "AKIHBR","KIHABR","KIHBAR","KIHBRA",\ "KIHBR"] if S in ans_list: print("YES") else: print("NO")
s048162199
p03997
u864900001
2,000
262,144
Wrong Answer
17
2,940
72
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.
#45 a = int(input()) ans = (a+ int(input()))/2 print(ans * int(input()))
s753003739
Accepted
17
2,940
77
#45 a = int(input()) ans = (a+ int(input()))/2 print(int(ans * int(input())))
s190744786
p04012
u118019047
2,000
262,144
Wrong Answer
17
2,940
70
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
q = input() if len(q) % 2 == 0: print("YES") else: print("NO")
s270995786
Accepted
17
2,940
104
w = input() for i in w: if w.count(i)%2!=0: print('No') break else: print('Yes')
s427301885
p02606
u647835149
2,000
1,048,576
Wrong Answer
29
9,160
107
How many multiples of d are there among the integers between L and R (inclusive)?
list = list(map(int, input().split())) sho1 = list[1] // list[2] sho2 = list[0] // list[2] print(sho2-sho1)
s958682140
Accepted
34
8,996
191
list = list(map(int,input().split())) large = list[1] // list[2] small = list[0] // list[2] amari = list[0] % list[2] if amari == 0: print(large - small + 1) else: print(large - small)
s764579753
p02613
u262039080
2,000
1,048,576
Wrong Answer
158
16,164
307
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()) S=[0]*(N+1) T=[0]*4 for i in range(N): S[i]=input() for i in range(N): if S[i]=="AC": T[0]+=1 elif S[i]=="WA": T[1]+=1 elif S[i]=="TLE": T[2]+=1 else: T[3]+=1 print("AC ×",T[0]) print("WA ×",T[1]) print("TLE ×",T[2]) print("RE ×",T[3])
s528410202
Accepted
159
16,044
303
N=int(input()) S=[0]*(N+1) T=[0]*4 for i in range(N): S[i]=input() for i in range(N): if S[i]=="AC": T[0]+=1 elif S[i]=="WA": T[1]+=1 elif S[i]=="TLE": T[2]+=1 else: T[3]+=1 print("AC x",T[0]) print("WA x",T[1]) print("TLE x",T[2]) print("RE x",T[3])
s949242029
p04029
u720417458
2,000
262,144
Wrong Answer
17
2,940
70
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()) a = 0 for i in range(N): a += i + 1 print(a)
s494305106
Accepted
17
2,940
40
N = int(input()) a = N*(N+1)//2 print(a)
s629046442
p03698
u626468554
2,000
262,144
Wrong Answer
17
2,940
286
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different.
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) #62 s = list(input().split()) jg = {} for i in range(len(s)): if s[i] in jg: print("no") break else: jg[s[i]] = 1 if i == len(s): print("yes")
s590499844
Accepted
17
2,940
281
#n = int(input()) #n,k = map(int,input().split()) #x = list(map(int,input().split())) #62 s = list(input()) jg = {} for i in range(len(s)): if s[i] in jg: print("no") break else: jg[s[i]] = 1 if i == len(s)-1: print("yes")
s995147841
p02613
u589361760
2,000
1,048,576
Wrong Answer
164
16,080
334
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()) s = [input() for i in range(n)] i = 0 a = 0 t = 0 w = 0 r = 0 for i in range(n): if s[i] == "AC": a += 1 i += 1 elif s[i] == "TLE": t += 1 i += 1 elif s[i] == "WA": w += 1 i += 1 else: r += 1 i += 1 print(. format(a, w, t, r))
s070798359
Accepted
167
16,316
331
n = int(input()) s = [input() for i in range(n)] i = 0 a = 0 t = 0 w = 0 r = 0 for i in range(n): if s[i] == "AC": a += 1 i += 1 elif s[i] == "TLE": t += 1 i += 1 elif s[i] == "WA": w += 1 i += 1 else: r += 1 i += 1 print("""AC x {0} WA x {1} TLE x {2} RE x {3}""". format(a, w, t, r))
s465051515
p03025
u268793453
2,000
1,048,576
Wrong Answer
302
27,664
876
Takahashi and Aoki will play a game. They will repeatedly play it until one of them have N wins in total. When they play the game once, Takahashi wins with probability A %, Aoki wins with probability B %, and the game ends in a draw (that is, nobody wins) with probability C %. Find the expected number of games that will be played, and print it as follows. We can represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R \times Q \equiv P\pmod {10^9+7}. (Such an integer R always uniquely exists under the constraints of this problem.)
n, a, b, c = [int(i) for i in input().split()] p = 10 ** 9 + 7 ans = 0 def fact(n, p=10**9 + 7): f = [1] for i in range(1, n+1): f.append(f[-1]*i%p) return f def invfact(n, f, p=10**9 + 7): inv = [pow(f[n], p-2, p)] for i in range(n, 0, -1): inv.append(inv[-1]*i%p) return inv[::-1] f = fact(2 * n) invf = invfact(2 * n, f) def comb(a, b): if a < b: return 0 if a < 0 or b < 0: return 0 return f[a] * invf[b] * invf[a-b] % p pow_a = [1] pow_b = [1] inv_100 = pow(100, p - 2, p) a = a * inv_100 % p b = b * inv_100 % p c = c * inv_100 % p for i in range(n): pow_a.append(pow_a[-1] * a % p) pow_b.append(pow_b[-1] * b % p) for m in range(n, 2 * n): ans += comb(m - 1, n - 1) * (pow_a[n] * pow_b[m - n] + pow_a[m - n] * pow_b[n]) * m ans %= p ans *= pow(1 - c, p - 2, p) print(ans % p)
s442257842
Accepted
301
27,944
945
n, a, b, c = [int(i) for i in input().split()] p = 10 ** 9 + 7 ans = 0 def fact(n, p=10**9 + 7): f = [1] for i in range(1, n+1): f.append(f[-1]*i%p) return f def invfact(n, f, p=10**9 + 7): inv = [pow(f[n], p-2, p)] for i in range(n, 0, -1): inv.append(inv[-1]*i%p) return inv[::-1] f = fact(2 * n) invf = invfact(2 * n, f) def comb(a, b): if a < b: return 0 if a < 0 or b < 0: return 0 return f[a] * invf[b] * invf[a-b] % p pow_a = [1] pow_b = [1] inv_100 = pow(100, p - 2, p) a = a * inv_100 % p b = b * inv_100 % p c = c * inv_100 % p inv_ab = pow(a + b, p - 2, p) a = a * inv_ab % p b = b * inv_ab % p for i in range(n): pow_a.append(pow_a[-1] * a % p) pow_b.append(pow_b[-1] * b % p) for m in range(n, 2 * n): ans += comb(m - 1, n - 1) * (pow_a[n] * pow_b[m - n] + pow_a[m - n] * pow_b[n]) * m ans %= p ans *= pow(1 - c, p - 2, p) print(ans % p)
s931351707
p03160
u295242763
2,000
1,048,576
Wrong Answer
24
9,072
218
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 aFrog(N,h): dp = [0 for i in range(10)] dp[0] = 0 dp[1] = abs(h[1]-h[0]) print(dp) for i in range(2,N): dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) return dp[N-1]
s347338572
Accepted
126
20,600
262
N = int(input()) h = list(map(int, input().split())) inf = 10**9 dp = [0] + [inf]*N for i in range(1,N): if i == 1: dp[1] = abs(h[1]-h[0]) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print(dp[N-1])
s582471397
p03712
u606523772
2,000
262,144
Wrong Answer
18
3,060
263
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
H, W = map(int, input().split()) A_list = [] for i in range(H): A = input() A_list.append(A) str1 = ["*" for _ in range(W+2)] str1 = "".join(str1) for i in range(H+2): if i==0 or i==H+1: print(str1) else: print("*"+A_list[i-1]+"*")
s719277059
Accepted
17
3,060
263
H, W = map(int, input().split()) A_list = [] for i in range(H): A = input() A_list.append(A) str1 = ["#" for _ in range(W+2)] str1 = "".join(str1) for i in range(H+2): if i==0 or i==H+1: print(str1) else: print("#"+A_list[i-1]+"#")
s268337793
p02618
u285443936
2,000
1,048,576
Wrong Answer
82
9,412
694
AtCoder currently hosts three types of contests: ABC, ARC, and AGC. As the number of users has grown, in order to meet the needs of more users, AtCoder has decided to increase the number of contests to 26 types, from AAC to AZC. For convenience, we number these 26 types as type 1 through type 26. AtCoder wants to schedule contests for D days so that user satisfaction is as high as possible. For every day, AtCoder will hold exactly one contest, and each contest will end on that day. The satisfaction is calculated as follows. * The satisfaction at the beginning of day 1 is 0. Satisfaction can be negative. * Holding contests increases satisfaction. The amount of increase will vary depending on a variety of factors. Specifically, we know in advance that holding a contest of type i on day d will increase the satisfaction by s_{d,i}. * If a particular type of contest is not held for a while, the satisfaction decreases. Each contest type i has an integer c_i, and at the end of each day d=1,2,...,D, the satisfaction decreases as follows. Let \mathrm{last}(d,i) be the last day before day d (including d) on which a contest of type i was held. If contests of type i have never been held yet, we define \mathrm{last}(d,i)=0. At the end of day d, the satisfaction decreases by \sum _{i=1}^{26}c_i \times (d-\mathrm{last}(d,i)). Please schedule contests on behalf of AtCoder. If the satisfaction at the end of day D is S, you will get a score of \max(10^6 + S, 0). There are 50 test cases, and the score of a submission is the total scores for each test case. You can make submissions multiple times, and the highest score among your submissions will be your score.
D = int(input()) c = list(map(int,input().split())) s = list(list(map(int,input().split())) for i in range(D)) t = [] score = 0 last = [0]*26 #v = [0]*D def calc(d): score = 0 t = 0 contest = 0 for i in range(26): temp = 0 temp += s[d][i] for j in range(26): temp -= c[j]*(d+1-last[j]) print(score,temp) if score > temp: continue else: score = temp contest = i return contest for d in range(D): i = calc(d) t.append(i) last[i] = d+1 for i in range(D): print(t[i])
s867632010
Accepted
80
9,304
670
D = int(input()) c = list(map(int,input().split())) s = list(list(map(int,input().split())) for i in range(D)) t = [] score = 0 last = [0]*26 #v = [0]*D def calc(d): score = 0 t = 0 contest = 0 for i in range(26): temp = 0 temp += s[d][i] for j in range(26): temp -= c[j]*(d+1-last[j]) if score > temp: continue else: score = temp contest = i return contest for d in range(D): i = calc(d) t.append(i) last[i] = d+1 for i in range(D): print(t[i]+1)
s960130477
p02264
u928329738
1,000
131,072
Wrong Answer
50
6,984
481
_n_ _q_ _name 1 time1_ _name 2 time2_ ... _name n timen_ In the first line the number of processes _n_ and the quantum _q_ are given separated by a single space. In the following _n_ lines, names and times for the _n_ processes are given. _name i_ and _time i_ are separated by a single space.
import queue procs = queue.Queue() n,q = list(map(int,input().split())) for i in range(n): name,time = input().split() procs.put((name,int(time))) time=0 doneprocs = queue.Queue() while True: if procs.empty(): break temp = procs.get() if temp[1] < q: time += temp[1] doneprocs.put((temp[0],time)) else: time+= q procs.put((temp[0],temp[1]-q)) for i in range(n): temp = doneprocs.get() print(temp[0],temp[1])
s689789688
Accepted
2,120
15,172
482
import queue procs = queue.Queue() n,q = list(map(int,input().split())) for i in range(n): name,time = input().split() procs.put((name,int(time))) time=0 doneprocs = queue.Queue() while True: if procs.empty(): break temp = procs.get() if temp[1] <= q: time += temp[1] doneprocs.put((temp[0],time)) else: time+= q procs.put((temp[0],temp[1]-q)) for i in range(n): temp = doneprocs.get() print(temp[0],temp[1])
s806222589
p02612
u425236751
2,000
1,048,576
Wrong Answer
30
9,156
123
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()) i = 1 while(True): change = N - 1000*i if change >= 1000: i+=1 else: break print(change)
s153046026
Accepted
31
8,888
118
N = int(input()) i = 1 while(True): change = 1000*i - N if change < 0: i+=1 else: break print(change)
s824918180
p03548
u998835868
2,000
262,144
Wrong Answer
49
3,064
303
We have a long seat of width X centimeters. There are many people who wants to sit here. A person sitting on the seat will always occupy an interval of length Y centimeters. We would like to seat as many people as possible, but they are all very shy, and there must be a gap of length at least Z centimeters between two people, and between the end of the seat and a person. At most how many people can sit on the seat?
x,y,z = map(int,input().split()) aa = x b1 = 0 b2 = 0 for a in range(aa): x -= y if x <= 0: break x -= z if x < 0: break b1 += 1 x = aa for a in range(aa): x -= z if x <= 0: break x -= y if x < 0: break b2 += 1 print(b1,b2) if b1 <= b2: print(b2) else: print(b1)
s825837594
Accepted
33
3,060
188
x,y,z = map(int,input().split()) aa = x b1 = 0 b2 = 0 for a in range(aa): x -= z if x < y: break x -= y if x < z: break b2 += 1 if b1 <= b2: print(b2) else: print(b1)
s115433554
p02612
u122495382
2,000
1,048,576
Wrong Answer
27
9,028
38
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()) a = n % 1000 print(a)
s674878054
Accepted
26
9,160
74
n = int(input()) a = n % 1000 if a == 0: print(a) else: print(1000- a)
s387939645
p03997
u002459665
2,000
262,144
Wrong Answer
17
2,940
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)
s394404304
Accepted
18
2,940
91
a = int(input()) b = int(input()) h = int(input()) ans = (a + b) * h / 2 print(round(ans))
s510969683
p03610
u587213169
2,000
262,144
Wrong Answer
30
4,336
76
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.
s=input() N=len(s) ans=[] for i in range(0, N, 2): ans+=s[i] print(ans)
s495147221
Accepted
28
3,188
79
s=input() N=len(s) ans=str() for i in range(0, N, 2): ans+=s[i] print(ans)
s955676058
p03095
u760171369
2,000
1,048,576
Wrong Answer
18
3,188
126
You are given a string S of length N. Among its subsequences, count the ones such that all characters are different, modulo 10^9+7. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings. Here, a subsequence of a string is a concatenation of **one or more** characters from the string without changing the order.
N = int(input()) S = input().split() cnt = 1 L = list(set(S)) for k in L: cnt *= (S.count(k) + 1) print(cnt % (10 ** 9 + 7))
s542095650
Accepted
22
3,188
117
N = input() S = input() L = list(set(S)) cnt = 1 for k in L: cnt *= (S.count(k) + 1) print((cnt - 1) % (10**9 + 7))
s054420119
p03695
u243699903
2,000
262,144
Wrong Answer
17
3,064
573
In AtCoder, a person who has participated in a contest receives a _color_ , which corresponds to the person's rating as follows: * Rating 1-399 : gray * Rating 400-799 : brown * Rating 800-1199 : green * Rating 1200-1599 : cyan * Rating 1600-1999 : blue * Rating 2000-2399 : yellow * Rating 2400-2799 : orange * Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users.
n = int(input()) color = [0] * 8 pro = 0 for ai in map(int, input().split()): print(ai) if 1 <= ai <= 399: color[0] = 1 elif 400 <= ai <= 799: color[1] = 1 elif 800 <= ai <= 1199: color[2] = 1 elif 1200 <= ai <= 1599: color[3] = 1 elif 1600 <= ai <= 1999: color[4] = 1 elif 2000 <= ai <= 2399: color[5] = 1 elif 2400 <= ai <= 2799: color[6] = 1 elif 2800 <= ai <= 3199: color[7] = 1 else: pro += 1 colSum = sum(color) print(colSum, colSum+min(8-colSum, pro))
s518233412
Accepted
17
3,064
602
n = int(input()) color = [0] * 8 pro = 0 for ai in map(int, input().split()): if 1 <= ai <= 399: color[0] = 1 elif 400 <= ai <= 799: color[1] = 1 elif 800 <= ai <= 1199: color[2] = 1 elif 1200 <= ai <= 1599: color[3] = 1 elif 1600 <= ai <= 1999: color[4] = 1 elif 2000 <= ai <= 2399: color[5] = 1 elif 2400 <= ai <= 2799: color[6] = 1 elif 2800 <= ai <= 3199: color[7] = 1 else: pro += 1 colSum = sum(color) if colSum == 0 and pro > 0: print(1, pro) else: print(colSum, colSum + pro)
s043094953
p03251
u793982420
2,000
1,048,576
Wrong Answer
17
3,064
566
Our world is one-dimensional, and ruled by two empires called Empire A and Empire B. The capital of Empire A is located at coordinate X, and that of Empire B is located at coordinate Y. One day, Empire A becomes inclined to put the cities at coordinates x_1, x_2, ..., x_N under its control, and Empire B becomes inclined to put the cities at coordinates y_1, y_2, ..., y_M under its control. If there exists an integer Z that satisfies all of the following three conditions, they will come to an agreement, but otherwise war will break out. * X < Z \leq Y * x_1, x_2, ..., x_N < Z * y_1, y_2, ..., y_M \geq Z Determine if war will break out.
# -*- coding: utf-8 -*- """ Created on Sun Sep 23 21:12:01 2018 @author: masato """ N, M, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort() xmin = x[0] ymin = y[0] xmax = x[-1] ymax = y[-1] z = max(xmax,ymin) iswar = 0 for i in range(len(x)): for j in range(len(y)): if x[i] > z: iswar = 1 break elif y[j] <= z: iswar = 1 break if iswar == 1: break if iswar == 1: print("War") else: print("No War")
s424445408
Accepted
17
3,064
542
# -*- coding: utf-8 -*- """ Created on Sun Sep 23 21:12:01 2018 @author: masato """ N, M, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort() xmin = x[0] ymin = y[0] xmax = x[-1] ymax = y[-1] z = max(xmax,ymin) iswar = 0 for i in range(len(x)): if min(ymin,Y) <= x[i]: iswar = 1 break for j in range(len(y)): if max(xmax,X) >= y[j]: iswar = 1 break if iswar == 1: print("War") else: print("No War")
s677615816
p03477
u808427016
2,000
262,144
Wrong Answer
17
2,940
308
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
import sys def solve1(s): n = len(s) i = 0 while i <= n // 2: if s[n // 2] != s[n // 2 - i]: break if s[(n - 1) // 2] != s[(n - 1) // 2 + i]: break i += 1 return (n - 1) // 2 + i line = sys.stdin.readline().strip() print(solve1(list(line)))
s680657979
Accepted
17
2,940
197
import sys line = sys.stdin.readline().strip() a, b, c, d = [int(x) for x in line.split()] if a + b == c + d: print("Balanced") elif a + b > c + d: print("Left") else: print("Right")
s839835648
p04011
u268792407
2,000
262,144
Wrong Answer
17
2,940
115
There is a hotel with the following accommodation fee: * X yen (the currency of Japan) per night, for the first K nights * Y yen per night, for the (K+1)-th and subsequent nights Tak is staying at this hotel for N consecutive nights. Find his total accommodation fee.
n=int(input()) k=int(input()) x=int(input()) y=int(input()) if n<=k: print(x * n) else: print(k * n +(n-k) * y)
s002324248
Accepted
17
2,940
115
n=int(input()) k=int(input()) x=int(input()) y=int(input()) if n<=k: print(x * n) else: print(k * x +(n-k) * y)
s344037746
p03644
u819135704
2,000
262,144
Wrong Answer
17
2,940
257
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()) count = 0 list_count = [] max_number = 0 for i in range(n): a = i + 1 while a % 2 == 0: count += 1 a /= 2 list_count.append(count) if max(list_count) == count: max_number = i + 1 print(max_number)
s929242621
Accepted
18
2,940
271
n = int(input()) count = 0 list_count = [] max_number = 0 for i in range(n): a = i + 1 while a % 2 == 0: count += 1 a /= 2 list_count.append(count) if max(list_count) == count: max_number = i + 1 count = 0 print(max_number)
s944863323
p02613
u737842024
2,000
1,048,576
Wrong Answer
143
9,108
266
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A. The problem has N test cases. For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively. See the Output section for the output format.
N=int(input()) AC=0 WA=0 TLE=0 RE=0 for i in range(N): c=input() if(c=='AC'): AC+=1 elif(c=='WA'): WA+=1 elif(c=='TLE'): TLE+=1 else: RE+=1 print("AC ×",AC) print("WA ×",WA) print("TLE ×",TLE) print("RE ×",RE)
s394012582
Accepted
146
9,208
262
N=int(input()) AC=0 WA=0 TLE=0 RE=0 for i in range(N): c=input() if(c=='AC'): AC+=1 elif(c=='WA'): WA+=1 elif(c=='TLE'): TLE+=1 else: RE+=1 print("AC x",AC) print("WA x",WA) print("TLE x",TLE) print("RE x",RE)
s253230963
p03455
u189636973
2,000
262,144
Wrong Answer
17
2,940
122
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
import sys inf = sys.maxsize a, b = map(int, input().split()) if(a%2==0 and b%2==0): print("Even") else: print("Odd")
s143633089
Accepted
17
2,940
86
a, b = map(int, input().split()) if(a*b % 2 == 0): print("Even") else: print("Odd")
s457081729
p03544
u598229387
2,000
262,144
Wrong Answer
17
3,060
141
It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers. You are given an integer N. Find the N-th Lucas number. Here, the i-th Lucas number L_i is defined as follows: * L_0=2 * L_1=1 * L_i=L_{i-1}+L_{i-2} (i≥2)
n = int(input()) a,b,c = 2,1,3 for i in range(n-3): a = b+c b = a+c c = a+b print(a if n>=4 else b if n==2 else c if n==3 else a)
s818096644
Accepted
17
2,940
70
n = int(input()) a,b = 2,1 for i in range(n): a,b = b,a+b print(a)
s021977557
p04012
u740284863
2,000
262,144
Wrong Answer
19
3,060
162
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = str(input()) count = 1 for i in range(len(w)): s = w.count(w[i]) if s % 2 != 0: print("No") count -=1 if count == 0: print("Yes")
s081054844
Accepted
29
2,940
176
w = str(input()) count = 1 for i in range(len(w)): s = w.count(w[i]) if s % 2 != 0: print("No") count -=1 break if count == 1: print("Yes")
s410446315
p03386
u600261652
2,000
262,144
Wrong Answer
2,141
619,156
454
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
def resolve(): A, B, K = map(int, input().split()) count = [A] ans = [] for _ in range(B-A): count.append(A+1) A += 1 if K > B-A-1: K = B-A+1 for i in range(K): if count[i] <= B: ans.append(count[i]) for j in range(K): if count[(j+1)*-1] >= count[K-1]: ans.append(count[j*-1]) an = sorted(set(ans)) for i in range(len(an)): print(an[i]) resolve()
s975429065
Accepted
17
3,060
252
def resolve(): A, B, K = map(int, input().split()) if 2*K > B-A+1: for _ in range(B-A+1): print(A+_) else: for i in range(K): print(A+i) for j in range(K): print(B-K+j+1) resolve()
s839698926
p03080
u765865533
2,000
1,048,576
Wrong Answer
17
3,060
137
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.
N = int(input()) s = input() RBlist = list(s) print(type(N)) r=RBlist.count('R') b=N-r if b<r: print("Yes") else: print("No")
s622898312
Accepted
17
2,940
138
N = int(input()) s = input() RBlist = list(s) #print(type(N)) r=RBlist.count('R') b=N-r if b<r: print("Yes") else: print("No")
s123979119
p03816
u297109012
2,000
262,144
Wrong Answer
62
19,324
303
Snuke has decided to play a game using cards. He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written. He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept. Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
from collections import Counter def solve(N, As): print(N, ",", As) counter = Counter(As) if len(counter) % 2 == 0: return len(counter) - 1 return len(counter) if __name__ == "__main__": N = int(input()) As = list(map(int, input().split(" "))) print(solve(N, As))
s566385193
Accepted
54
18,656
281
from collections import Counter def solve(N, As): counter = Counter(As) if len(counter) % 2 == 0: return len(counter) - 1 return len(counter) if __name__ == "__main__": N = int(input()) As = list(map(int, input().split(" "))) print(solve(N, As))
s952284011
p02659
u180528413
2,000
1,048,576
Wrong Answer
23
9,192
352
Compute A \times B, truncate its fractional part, and print the result as an integer.
import sys import math readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prl = lambda x: print(*x ,sep='\n') a,b = input().split(' ') res = int(a) * float(b) print(math.floor(res),res)
s394524499
Accepted
22
9,256
677
import sys import math readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prl = lambda x: print(*x ,sep='\n') a,b = input().split(' ') ash_1 = int(a[-1]) ash_2 = int(a[-2:]) bsh_1 = int(b[-2]) bsh_2 = int(b[-1]) bsh_0 = int(b[0]) kuri = (ash_1*bsh_1*10 + ash_2*bsh_2) //100 if len(a) == 1: res = int(a)*bsh_0 + kuri elif len(a) == 2: a1 = a[:-1] res = int(a)*bsh_0 + int(a1)*bsh_1 + kuri else: a1 = a[:-1] a2 = a[:-2] res = int(a)*bsh_0 + int(a1)*bsh_1 + int(a2)*bsh_2 + kuri print(res)
s421181818
p03591
u572032237
2,000
262,144
Wrong Answer
30
9,028
25
Ringo is giving a present to Snuke. Ringo has found out that Snuke loves _yakiniku_ (a Japanese term meaning grilled meat. _yaki_ : grilled, _niku_ : meat). He supposes that Snuke likes grilled things starting with `YAKI` in Japanese, and does not like other things. You are given a string S representing the Japanese name of Ringo's present to Snuke. Determine whether S starts with `YAKI`.
s = input() print(s[:-8])
s889947170
Accepted
26
9,036
70
s = input() if 'YAKI' in s[:4]: print('Yes') else: print('No')
s136345019
p03962
u036190609
2,000
262,144
Wrong Answer
19
2,940
36
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive. Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.
s = input() s = set(s) print(len(s))
s418983853
Accepted
17
2,940
38
s = input().split() print(len(set(s)))
s682905366
p02612
u303711501
2,000
1,048,576
Wrong Answer
27
8,980
96
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()) # X = list(input()) def p(X): print(X) while N >=1000: N -= 1000 p(N)
s572249587
Accepted
28
9,040
108
N = int(input()) add = 1000 - N%1000 if add == 1000: add = 0 else : add = 1000 - N%1000 print(add)
s211844041
p03407
u220870679
2,000
262,144
Wrong Answer
19
2,940
80
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('No') else: print('Yes')
s883737655
Accepted
17
2,940
93
a, b, c =map(int, input() .split()) if 0 <= a + b - c: print("Yes") else: print("No")
s865804904
p03699
u980783809
2,000
262,144
Wrong Answer
17
3,060
238
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade?
a = int(input()) list=[] for i in range(a): list.append(int(input())) if not sum(list)%10==0: print(sum(list)) else: for i in sorted(list): if not i%10==0: print(sum(list)-i) break print(0)
s114250441
Accepted
18
3,060
239
a = int(input()) list=[] for i in range(a): list.append(int(input())) if not sum(list)%10==0: print(sum(list)) else: for i in sorted(list): if not i%10==0: print(sum(list)-i) exit() print(0)
s422664197
p03501
u558764629
2,000
262,144
Wrong Answer
18
2,940
85
You are parking at a parking lot. You can choose from the following two fee plans: * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours. * Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours.
N,A,B = map(int,input().split()) x = N * B if x < B: print(B) else: print(x)
s044389523
Accepted
18
2,940
85
N,A,B = map(int,input().split()) x = N * A if x < B: print(x) else: print(B)
s598479408
p02612
u349863397
2,000
1,048,576
Wrong Answer
29
9,000
28
We will buy a product for N yen (the currency of Japan) at a shop. If we use only 1000-yen bills to pay the price, how much change will we receive? Assume we use the minimum number of bills required.
n=int(input()) print(n%1000)
s922002307
Accepted
32
9,508
1,055
from sys import stdin, stdout import math,sys from itertools import permutations, combinations from collections import defaultdict,deque,OrderedDict from os import path import bisect as bi import heapq def yes():print('YES') def no():print('NO') if (path.exists('input.txt')): #------------------Sublime--------------------------------------# sys.stdin=open('input.txt','r');sys.stdout=open('output.txt','w'); def I():return (int(input())) def In():return(map(int,input().split())) else: #------------------PYPY FAst I/o--------------------------------# def I():return (int(stdin.readline())) def In():return(map(int,stdin.readline().split())) def dict(a): d={} for x in a: if d.get(x,-1)!=-1: d[x]+=1 else: d[x]=1 return d def main(): try: n=I() temp=(math.ceil(n/1000)*1000)-n print(temp) except: pass M = 998244353 P = 1000000007 if __name__ == '__main__': #for _ in range(I()):main() for _ in range(1):main()
s278876585
p02255
u142825584
1,000
131,072
Wrong Answer
20
5,596
345
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 InsertionSort(l): for idx in range(1, len(l)): jdx = idx - 1 while jdx >= 0 and l[idx] < l[jdx]: l[jdx], l[idx] = l[idx], l[jdx] idx -= 1 jdx -= 1 print(" ".join(map(str, l))) def main(): in_list = list(map(int, input().split(' '))) InsertionSort(in_list) main()
s936183938
Accepted
20
5,604
403
def InsertionSort(l): print(" ".join(map(str, l))) for idx in range(1, len(l)): jdx = idx - 1 while jdx >= 0 and l[idx] < l[jdx]: l[jdx], l[idx] = l[idx], l[jdx] idx -= 1 jdx -= 1 print(" ".join(map(str, l))) def main(): _ = input() in_list = list(map(int, input().split(' '))) InsertionSort(in_list) main()
s148665866
p02534
u163393400
2,000
1,048,576
Wrong Answer
25
9,144
29
You are given an integer K. Print the string obtained by repeating the string `ACL` K times and concatenating them. For example, if K = 3, print `ACLACLACL`.
n=int(input()) print('ACK'*n)
s267905369
Accepted
29
9,080
29
n=int(input()) print('ACL'*n)
s723361812
p03438
u787456042
2,000
262,144
Wrong Answer
24
5,236
97
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
N,*A=map(int,open(0).read().split());print("YNeos"[any(a-b-A[0]+A[N]for a,b in zip(A,A[N:]))::2])
s235494596
Accepted
24
5,236
126
N,*A=map(int,open(0).read().split());print("YNeos"[sum((b-a+1)//2for a,b in zip(A[:N],A[N:])if b>a)>sum(A[N:])-sum(A[:N])::2])
s039715868
p02608
u178888901
2,000
1,048,576
Wrong Answer
2,205
9,344
341
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions: * 1 \leq x,y,z * x^2 + y^2 + z^2 + xy + yz + zx = n Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).
n = int(input()) ans = [0] * n loop = int((n/6) ** 1.5) + 1 def f(i, j, k): return i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i for i in range(1, loop+1): for j in range(1, loop+1): for k in range(1, loop+1): res = int(f(i, j, k)) if res <= n: ans[res] += 1 for a in ans: print(a)
s363549225
Accepted
947
9,504
347
n = int(input()) ans = [0] * (n + 1) loop = int(n ** .5) + 1 def f(i, j, k): return i ** 2 + j ** 2 + k ** 2 + i*j + j*k + k*i for i in range(1, loop+1): for j in range(1, loop+1): for k in range(1, loop+1): res = int(f(i, j, k)) if res <= n: ans[res] += 1 for a in ans[1:]: print(a)
s511830520
p03853
u740767776
2,000
262,144
Wrong Answer
17
3,060
90
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down).
h, q = map(int, input().split()) s =[] s.append(input()) for i in s: print(i) print(i)
s829457243
Accepted
18
3,060
111
h, q = map(int, input().split()) s =[] for i in range(h): s.append(input()) for i in s: print(i) print(i)
s361504596
p03673
u750651325
2,000
262,144
Wrong Answer
125
30,892
362
You are given an integer sequence of length n, a_1, ..., a_n. Let us consider performing the following n operations on an empty sequence b. The i-th operation is as follows: 1. Append a_i to the end of b. 2. Reverse the order of the elements in b. Find the sequence b obtained after these n operations.
n = int(input()) a = list(map(int, input().split())) odd = [] even = [] ans = [] for i in range(n): if i % 2 == 0: odd.append(a[i]) else: even.append(a[i]) if n == 1: print(a[0]) exit() else: if n % 2 == 0: even.reverse() ans = even + odd else: odd.reverse() ans = odd + even print(ans)
s219339396
Accepted
141
37,144
381
n = int(input()) a = list(map(int, input().split())) odd = [] even = [] ans = [] for i in range(n): if i % 2 == 0: odd.append(a[i]) else: even.append(a[i]) if n == 1: print(a[0]) exit() else: if n % 2 == 0: even.reverse() ans = even + odd else: odd.reverse() ans = odd + even print(" ".join(map(str,ans)))
s318467865
p02646
u155757809
2,000
1,048,576
Wrong Answer
22
9,176
173
Two children are playing tag on a number line. (In the game of tag, the child called "it" tries to catch the other child.) The child who is "it" is now at coordinate A, and he can travel the distance of V per second. The other child is now at coordinate B, and she can travel the distance of W per second. He can catch her when his coordinate is the same as hers. Determine whether he can catch her within T seconds (including exactly T seconds later). We assume that both children move optimally.
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) oni = a + v * t nige = b + w * t if oni >= nige: print('Yes') else: print('No')
s269654648
Accepted
22
9,180
200
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if a > b: a, b = b, a oni = a + v * t nige = b + w * t if oni >= nige: print('YES') else: print('NO')
s410930784
p03779
u488884575
2,000
262,144
Wrong Answer
2,104
22,556
95
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.
x = int(input()) cnt = 0 for i in range(1,x+1): cnt += i if cnt >= x: print(i)
s754756820
Accepted
25
3,064
109
x = int(input()) cnt = 0 for i in range(1,x+1): cnt += i if cnt >= x: print(i) break
s474353481
p03361
u830054172
2,000
262,144
Wrong Answer
24
3,064
533
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= `#`, and to make Square (i, j) white when s_{i, j}= `.`. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective.
h, w = list(map(int, input().split())) s = [input() for _ in range(h)] move = [(-1, 0), (1, 0), (0, -1), (0, 1)] flag = 1 for i in range(h): for j in range(w): hantei = [] if s[i][j] == "#": for dx, dy in move: if i+dx<0 or j+dy<0 or i+dx>h-1 or j+dy>w-1: continue else: hantei.append(s[i+dx][j+dy]) if "#" not in hantei: flag = 0 break if flag: print("YES") else: print("NO")
s142483677
Accepted
23
3,064
533
h, w = list(map(int, input().split())) s = [input() for _ in range(h)] move = [(-1, 0), (1, 0), (0, -1), (0, 1)] flag = 1 for i in range(h): for j in range(w): hantei = [] if s[i][j] == "#": for dx, dy in move: if i+dx<0 or j+dy<0 or i+dx>h-1 or j+dy>w-1: continue else: hantei.append(s[i+dx][j+dy]) if "#" not in hantei: flag = 0 break if flag: print("Yes") else: print("No")
s171100987
p02393
u682153677
1,000
131,072
Wrong Answer
30
5,572
79
Write a program which reads three integers, and prints them in ascending order.
# -*- coding: utf-8 -*- a = list(map(int, input().split())) a.sort() print(a)
s289781282
Accepted
20
5,592
116
# -*- coding: utf-8 -*- a = list(map(int, input().split())) a.sort() print('{0} {1} {2}'.format(a[0], a[1], a[2]))
s295097679
p04043
u961357158
2,000
262,144
Wrong Answer
17
2,940
120
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.
# -*- coding: utf-8 -*- A = list(map(int,input().split())) A.sort() if A == [5,5,7]: print("Yes") else: print("No")
s680319467
Accepted
18
2,940
120
# -*- coding: utf-8 -*- A = list(map(int,input().split())) A.sort() if A == [5,5,7]: print("YES") else: print("NO")
s614315856
p03644
u513081876
2,000
262,144
Wrong Answer
17
2,940
105
Takahashi loves numbers divisible by 2. You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique. Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder. For example, * 6 can be divided by 2 once: 6 -> 3. * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1. * 3 can be divided by 2 zero times.
N = int(input()) ans = 0 for i in range(1, N +1): if i % 2 == 0: ans = max(ans, i) print(ans)
s555790198
Accepted
17
2,940
93
N = int(input()) for i in range(1, 8): if 2**i > N: print(2**(i-1)) break
s582779858
p03693
u341736906
2,000
262,144
Wrong Answer
17
2,940
94
AtCoDeer has three cards, one red, one green and one blue. An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card. We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer. Is this integer a multiple of 4?
r,g,b = map(int,input().split()) if (100*r+10*g+b) % 4 ==0: print("Yes") else: print("No")
s293673026
Accepted
17
2,940
95
r,g,b = map(int,input().split()) if (100*r+10*g+b) % 4 == 0: print("YES") else: print("NO")
s883799447
p03729
u337820403
2,000
262,144
Wrong Answer
17
2,940
123
You are given three strings A, B and C. Check whether they form a _word chain_. More formally, determine whether both of the following are true: * The last character in A and the initial character in B are the same. * The last character in B and the initial character in C are the same. If both are true, print `YES`. Otherwise, print `NO`.
x = [i for i in input().split()] torf = [x[0][-1] == x[1][0] and x[1][-1] == x[2][0]] print("YES" if torf==True else "NO")
s634267460
Accepted
17
2,940
83
a, b, c = input().split() print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")
s172745019
p03471
u887080340
2,000
262,144
Wrong Answer
18
3,064
426
The commonly used bills in Japan are 10000-yen, 5000-yen and 1000-yen bills. Below, the word "bill" refers to only these. According to Aohashi, he received an otoshidama (New Year money gift) envelope from his grandfather that contained N bills for a total of Y yen, but he may be lying. Determine whether such a situation is possible, and if it is, find a possible set of bills contained in the envelope. Assume that his grandfather is rich enough, and the envelope was large enough.
N, Y = map(int, input().split()) en_10000 = Y // 10000 if en_10000 > N: print("-1 -1 -1") exit() Y = Y % 10000 N = N - en_10000 en_5000 = Y // 5000 if en_5000 > N: print("-1 -1 -1") exit() Y = Y % 5000 N = N - en_5000 en_1000 = Y // 1000 if en_1000 > N: print("-1 -1 -1") exit() Y = Y % 1000 N = N - en_1000 if (Y > 0) or (N > 0): print("-1 -1 -1") exit() print(en_10000,en_5000,en_1000)
s615127911
Accepted
1,552
3,064
482
N, Y = map(int, input().split()) for i in range((Y // 10000)+1)[::-1]: if ((Y - 10000 * i) < 0) and ((N - i) < 0): print("-1 -1 -1") exit() Y2 = Y - 10000*i N2 = N - i for j in range((Y2 // 5000)+1)[::-1]: if ((Y2 - 5000 * j) < 0) and ((N2 - j) < 0): print("-1 -1 -1") exit() Y3 = Y2 - 5000 * j N3 = N2 - j if N3 * 1000 == Y3: print(i, j, N3) exit() print("-1 -1 -1")
s869881671
p02420
u971748390
1,000
131,072
Wrong Answer
20
7,536
160
Your task is to shuffle a deck of n cards, each of which is marked by a alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top of the deck. The deck of cards is represented by a string as follows. abcdeefab The first character and the last character correspond to the card located at the bottom of the deck and the card on the top of the deck respectively. For example, a shuffle with h = 4 to the above deck, moves the first 4 characters "abcd" to the end of the remaining characters "eefab", and generates the following deck: eefababcd You can repeat such shuffle operations. Write a program which reads a deck (a string) and a sequence of h, and prints the final state (a string).
while(1): sen1=input() if sen1=="-": break suff=int(input()) for i in range(suff): h=int(input()) sen2=sen1[h:]+sen1[:h] print(sen2)
s423708689
Accepted
30
7,656
160
while(1): sen1=input() if sen1=="-": break suff=int(input()) for i in range(suff): h=int(input()) sen1=sen1[h:]+sen1[:h] print(sen1)
s368905861
p02613
u563217442
2,000
1,048,576
Wrong Answer
151
15,988
242
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.
counto = [] for _ in range(int(input())): s = input() counto.append(s) print("AC"+" x "+str(counto.count("AC"))) print("WC"+" x "+str(counto.count("WA"))) print("TLE"+" x "+str(counto.count("TLE"))) print("RE"+" x "+str(counto.count("RE")))
s635879156
Accepted
145
9,236
246
a = 0 w = 0 r = 0 t = 0 for _ in range(int(input())): s = input() if s=="AC": a+=1 elif s=="WA": w+=1 elif s=="TLE": t+=1 else: r+=1 print("AC "+"x "+str(a)) print("WA "+"x "+str(w)) print("TLE "+"x "+str(t)) print("RE "+"x "+str(r))
s535389338
p03457
u835322333
2,000
262,144
Wrong Answer
387
17,312
260
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()) tmp = [tuple(map(int,input().split())) for i in range(N)] ct = 0 cx = 0 cy = 0 for t,x,y in tmp: dst = abs(cx - x) + abs(cy - y) if dst > t-ct or dst%2 != (t-ct)%2: print('NO') exit() ct,cx,cy = t,x,y print('YES')
s713531798
Accepted
376
17,312
256
N = int(input()) tmp = [tuple(map(int,input().split())) for i in range(N)] ct = cx = cy = 0 for t,x,y in tmp: dst = abs(cx - x) + abs(cy - y) if dst > t-ct or dst%2 != (t-ct)%2: print('No') exit() ct,cx,cy = t,x,y print('Yes')
s150011780
p03160
u281573419
2,000
1,048,576
Wrong Answer
2,358
144,644
350
There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N.
N = int(input()) h = list(map(int, input().split())) # N = 6 # h = [30, 10, 60, 10, 60, 50] dp = [0]*(N) print("ini dp", dp) for i in range(1, N): if i == 1: dp[1] = abs(h[1]-h[0]) print("ini dp 1", dp) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print("ini dp 2", dp) print(dp[-1])
s031785637
Accepted
130
20,588
356
N = int(input()) h = list(map(int, input().split())) # N = 6 # h = [30, 10, 60, 10, 60, 50] dp = [0]*(N) for i in range(1, N): if i == 1: dp[1] = abs(h[1]-h[0]) else: dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print(dp[-1])
s926071984
p03438
u102960641
2,000
262,144
Wrong Answer
27
4,596
322
You are given two integer sequences of length N: a_1,a_2,..,a_N and b_1,b_2,..,b_N. Determine if we can repeat the following operation zero or more times so that the sequences a and b become equal. Operation: Choose two integers i and j (possibly the same) between 1 and N (inclusive), then perform the following two actions **simultaneously** : * Add 2 to a_i. * Add 1 to b_j.
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [] max_aplus = 0 min_aplus = 0 bplus = 0 for i,j in zip(a,b): if i > j: min_aplus += (i-j+1) //2 max_aplus += i-j else: bplus += j-i if bplus >= min_aplus and bplus <= max_aplus: print("Yes") else: print("No")
s645636206
Accepted
45
4,664
278
import math n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = [i-j for i,j in zip(a,b)] plus = 0 minus = 0 for i in c: if i >= 0: plus += i else: minus += math.ceil(i / 2) print("Yes") if abs(minus) >= plus else print("No")
s985089807
p03386
u982594421
2,000
262,144
Wrong Answer
17
3,060
142
Print all the integers that satisfies the following in ascending order: * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.
a, b, k = map(int, input().split()) for i in range(a, min(b, a + k + 1)): print(i) for i in range(max(b - k + 1, a + k + 1), b): print(i)
s238826682
Accepted
17
3,060
142
a, b, k = map(int, input().split()) for i in range(a, min(a + k, b + 1)): print(i) for i in range(max(b - k + 1, a + k), b + 1): print(i)
s366283854
p03997
u525796732
2,000
262,144
Wrong Answer
17
3,060
278
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.
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) a=int(input()) b=int(input()) h=int(input()) print((a+b)*h/2)
s118573954
Accepted
17
3,060
288
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) a=int(input()) b=int(input()) h=int(input()) print(int((a+b)*h/2))
s665162499
p03546
u994521204
2,000
262,144
Wrong Answer
36
3,444
491
Joisino the magical girl has decided to turn every single digit that exists on this world into 1. Rewriting a digit i with j (0≤i,j≤9) costs c_{i,j} MP (Magic Points). She is now standing before a wall. The wall is divided into HW squares in H rows and W columns, and at least one square contains a digit between 0 and 9 (inclusive). You are given A_{i,j} that describes the square at the i-th row from the top and j-th column from the left, as follows: * If A_{i,j}≠-1, the square contains a digit A_{i,j}. * If A_{i,j}=-1, the square does not contain a digit. Find the minimum total amount of MP required to turn every digit on this wall into 1 in the end.
h, w = map(int, input().split()) C = [list(map(int, input().split())) for i in range(10)] A = [list(map(int, input().split())) for i in range(h)] # warshal-floyd for k in range(10): for i in range(10): for j in range(10): C[i][j] = min(C[i][j], C[i][k] + C[k][j]) ans = 0 for i in range(h): for j in range(w): if ans == -1: ans += 0 else: ans += C[A[i][j]][1] print(ans)
s677290102
Accepted
37
3,444
495
h, w = map(int, input().split()) C = [list(map(int, input().split())) for i in range(10)] A = [list(map(int, input().split())) for i in range(h)] # warshal-floyd for k in range(10): for i in range(10): for j in range(10): C[i][j] = min(C[i][j], C[i][k] + C[k][j]) ans = 0 for i in range(h): for j in range(w): if A[i][j] == -1: ans += 0 else: ans += C[A[i][j]][1] print(ans)
s296680362
p03339
u384679440
2,000
1,048,576
Wrong Answer
218
3,672
198
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() l = 0 r = s[1:].count('E') result = l + r for i in range(1, n): if s[i] == "W": l += 1 if s[n - i] == "E": r -= 1 result = max(result, l + r) print(result)
s929253059
Accepted
215
3,700
179
N = int(input()) S = input() l = 0 r = S[1:].count('E') ans = l + r for i in range(1, N): if S[i - 1] == 'E': r -= 1 if S[i] == 'W': l += 1 ans = min(ans, l + r) print(ans)
s308680767
p02413
u567380442
1,000
131,072
Wrong Answer
30
6,720
256
Your task is to perform a simple table calculation. Write a program which reads the number of rows r, columns c and a table of r × c elements, and prints a new table, which includes the total sum for each row and column.
r, c = map(int, input().split()) arr = [] for i in range(r): arr.append(list(map(int, input().split()))) for line in arr: line.append(sum(line)) arr.append([sum([line[i] for line in arr]) for i in range(c)]) for line in arr: print(*line)
s168607120
Accepted
50
6,844
261
r, c = map(int, input().split()) arr = [] for i in range(r): arr.append(list(map(int, input().split()))) for line in arr: line.append(sum(line)) arr.append([sum([line[i] for line in arr]) for i in range(c + 1)]) for line in arr: print(*line)
s479949391
p02255
u427088273
1,000
131,072
Wrong Answer
30
7,608
236
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.
num = int(input()) sort_list = list(map(int,input().split())) v = 0 for i in range(1,num): v = sort_list[i] j = i - 1 while j >= 0 and sort_list[j] > v: sort_list[j+1] = sort_list[j] j -= 1 sort_list[j+1] = v print(*sort_list)
s812165064
Accepted
20
7,988
254
num = int(input()) sort_list = list(map(int,input().split())) print(*sort_list) v = 0 for i in range(1,num): v = sort_list[i] j = i - 1 while j >= 0 and sort_list[j] > v: sort_list[j+1] = sort_list[j] j -= 1 sort_list[j+1] = v print(*sort_list)
s290962178
p03110
u766566560
2,000
1,048,576
Wrong Answer
17
2,940
161
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?
ans = 0 N = int(input()) for _ in range(N): x, y = input().split() if y == 'JPY': ans += int(x) else: ans += round(float(x) * 380000.0) print(ans)
s932690326
Accepted
17
2,940
154
ans = 0 N = int(input()) for _ in range(N): x, y = input().split() if y == 'JPY': ans += int(x) else: ans += float(x) * 380000.0 print(ans)
s149045977
p04012
u679154596
2,000
262,144
Wrong Answer
19
3,060
93
Let w be a string consisting of lowercase letters. We will call w _beautiful_ if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful.
w = input() w_set = set(w) if len(w) / 2 == len(set(w)): print("Yes") else: print("No")
s773731552
Accepted
17
2,940
197
from sys import exit w = list(input()) w_set = list(set(w)) for i in range(len(w_set)): if w.count(w_set[i]) % 2 != 0: print("No") exit() else: if i == len(w_set)-1: print("Yes")
s240956880
p02613
u131411061
2,000
1,048,576
Wrong Answer
151
16,620
236
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.
from collections import Counter N = int(input()) d = {'AC':0, 'WA':0, 'TLE':0, 'RE:':0} for key,value in Counter([input() for _ in range(N)]).items(): d[key]=value for key,value in d.items(): print(key,'x',value)
s502801497
Accepted
145
16,616
235
from collections import Counter N = int(input()) d = {'AC':0, 'WA':0, 'TLE':0, 'RE':0} for key,value in Counter([input() for _ in range(N)]).items(): d[key]=value for key,value in d.items(): print(key,'x',value)
s223474220
p04029
u272457181
2,000
262,144
Wrong Answer
24
9,104
34
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()) print (N*(N+1)/2)
s528669032
Accepted
26
8,972
40
N = int(input()) print(int((N*(N+1))/2))
s412018768
p02398
u179070318
1,000
131,072
Wrong Answer
20
5,600
220
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 = [int(x) for x in input().split( )] div = set() for x in range(1,c+1): if c % x == 0: div.add(x) r = set() for x in range(a,b+1): r.add(x) answer_set = div&r print(' '.join(map(str,answer_set)))
s460779053
Accepted
20
5,604
137
a,b,c = [int(x) for x in input().split( )] count = 0 for number in range(a,b+1): if c % number == 0: count += 1 print(count)
s599698514
p03455
u572122511
2,000
262,144
Wrong Answer
17
2,940
153
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.
a = input() a = a.split() a = list(map(lambda x: int(x),a)) sum = 1 for i in a: sum *= i if sum % 2 == 0: print("odd") else: print("Even")
s869058502
Accepted
17
2,940
153
a = input() a = a.split() a = list(map(lambda x: int(x),a)) sum = 1 for i in a: sum *= i if sum % 2 == 0: print("Even") else: print("Odd")
s415071011
p02972
u259861571
2,000
1,048,576
Wrong Answer
50
7,148
208
There are N empty boxes arranged in a row from left to right. The integer i is written on the i-th box from the left (1 \leq i \leq N). For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it. We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied: * For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2. Does there exist a good set of choices? If the answer is yes, find one good set of choices.
# AtCoder N = int(input()) a = list(map(int, input().split())) on = -1 if all(a) != True: print(0) exit() sm = sum(a) if sm % 2 == a[0]: on = 1 print(1) print(on) exit() print(0)
s860513679
Accepted
561
13,104
288
N = int(input()) A = [0] + list(map(int, input().split())) B = [0] * (N + 1) for i in reversed(range(1, N + 1)): bl = 0 for j in range(i, N + 1, i): bl += B[j] if bl % 2 != A[i]: B[i] = 1 print(sum(B)) print(*[i for i, b in enumerate(B) if b == 1], sep=' ')
s278826691
p03408
u143051858
2,000
262,144
Wrong Answer
18
3,064
257
Takahashi has N blue cards and M red cards. A string is written on each card. The string written on the i-th blue card is s_i, and the string written on the i-th red card is t_i. Takahashi will now announce a string, and then check every card. Each time he finds a blue card with the string announced by him, he will earn 1 yen (the currency of Japan); each time he finds a red card with that string, he will lose 1 yen. Here, we only consider the case where the string announced by Takahashi and the string on the card are exactly the same. For example, if he announces `atcoder`, he will not earn money even if there are blue cards with `atcoderr`, `atcode`, `btcoder`, and so on. (On the other hand, he will not lose money even if there are red cards with such strings, either.) At most how much can he earn on balance? Note that the same string may be written on multiple cards.
s_num=int(input()) s=[] s=[input(x) for x in range(s_num)] t=[] t_num=int(input()) t=[input(x) for x in range(t_num)] max_v=0 for i in range(s_num): if max_v < (s.count(s[i]) - t.count(s[i])): max_v = (s.count(s[i]) - t.count(s[i])) print(max_v)
s450105985
Accepted
17
3,064
364
s_num=int(input()) s=[] for i in range(s_num): s.append(input()) t=[] t_num=int(input()) for i in range(t_num): t.append(input()) max=0 for i in range(s_num): if max < int(s.count(s[i]) - t.count(s[i])): max = int(s.count(s[i]) - t.count(s[i])) #print('int(s.count(s[i]) - t.count(s[i]))=',int(s.count(s[i]) - t.count(s[i]))) print(max)
s105619096
p03712
u044964932
2,000
262,144
Wrong Answer
21
4,588
326
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}. Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.
def main(): b, w = map(int, input().split()) image = [list(input()) for _ in range(b)] print(image) image.insert(0, ["#"]*w) image.append(["#"]*w) for im in image: im.insert(0, "#") im.append("#") for im in image: print(*im, sep="") if __name__ == "__main__": main()
s436292657
Accepted
21
4,596
309
def main(): b, w = map(int, input().split()) image = [list(input()) for _ in range(b)] image.insert(0, ["#"]*w) image.append(["#"]*w) for im in image: im.insert(0, "#") im.append("#") for im in image: print(*im, sep="") if __name__ == "__main__": main()
s881951561
p02742
u819465503
2,000
1,048,576
Wrong Answer
320
21,060
251
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:
import numpy as np h_w_list = [int(i) for i in input().split()] if h_w_list[0] == 1 or h_w_list[1] ==1: print(1) elif h_w_list[0]*h_w_list[1] % 2 == 0: print(h_w_list[0]*h_w_list[1]/2) else: print(np.ceil(h_w_list[0]*h_w_list[1]/2))
s083980505
Accepted
149
12,508
261
import numpy as np h_w_list = [int(i) for i in input().split()] if h_w_list[0] == 1 or h_w_list[1] ==1: print(1) elif h_w_list[0]*h_w_list[1] % 2 == 0: print(int(h_w_list[0]*h_w_list[1]/2)) else: print(int(np.ceil(h_w_list[0]*h_w_list[1]/2)))
s907668745
p03399
u609814378
2,000
262,144
Wrong Answer
17
3,064
207
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 = int(input()) B = int(input()) C = int(input()) D = int(input()) A_C = (A+C) A_D = (A+D) B_C = (B+C) B_D = (B+D) print(max(A_C,A_D,B_C,B_D))
s042995898
Accepted
17
3,060
207
A = int(input()) B = int(input()) C = int(input()) D = int(input()) A_C = (A+C) A_D = (A+D) B_C = (B+C) B_D = (B+D) print(min(A_C,A_D,B_C,B_D))
s704144660
p02389
u814278309
1,000
131,072
Wrong Answer
20
5,584
71
Write a program which calculates the area and perimeter of a given rectangle.
a, b=map(int, input().split()) print(a, b) x=a*b y=2*a+2*b print(x, y)
s239478971
Accepted
20
5,592
63
a,b=map(int,input().split()) x=a*b y=2*(a+b) print(f"{x} {y}")
s336687641
p03167
u439063038
2,000
1,048,576
Wrong Answer
657
49,360
697
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left. For each i and j (1 \leq i \leq H, 1 \leq j \leq W), Square (i, j) is described by a character a_{i, j}. If a_{i, j} is `.`, Square (i, j) is an empty square; if a_{i, j} is `#`, Square (i, j) is a wall square. It is guaranteed that Squares (1, 1) and (H, W) are empty squares. Taro will start from Square (1, 1) and reach (H, W) by repeatedly moving right or down to an adjacent empty square. Find the number of Taro's paths from Square (1, 1) to (H, W). As the answer can be extremely large, find the count modulo 10^9 + 7.
MOD = 10**9+7 H, W = map(int, input().split()) a = [input() for _ in range(H)] dp = [[0] * W for _ in range(H)] dp[0][0] = 1 for i in range(1, H): if a[i][0] != '#': dp[i][0] = dp[i-1][0] else: dp[i][0] = 0 for i in range(1, W): if a[0][i] != '#': dp[0][i] = dp[0][i-1] else: dp[0][i] = 0 for i in range(1, H): for j in range(1, W): if a[i][j] == '#': continue if a[i-1][j] != '#' and a[i][j-1] != '#': dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD elif a[i-1][j] != '#': dp[i][j] = dp[i-1][j] elif a[i][j-1] != '#': dp[i][j] = dp[i-1][j] print(dp[H-1][W-1])
s175977862
Accepted
577
51,216
382
H, W = map(int, input().split()) a = [input() for _ in range(H)] MOD = 10**9 + 7 dp = [[0]*1100 for _ in range(1100)] dp[1][1] = 1 for h in range(1, H+1): for w in range(1, W+1): if h == 1 and w == 1: continue if a[h-1][w-1] == '#': dp[h][w] = 0 else: dp[h][w] += (dp[h-1][w] + dp[h][w-1]) % MOD print(dp[H][W] % MOD)
s889396965
p02612
u475189661
2,000
1,048,576
Wrong Answer
28
9,024
61
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()) b = 0 while b > n: b += 1000 print(b-n)
s422484134
Accepted
26
9,056
58
n = int(input()) b = 0 while b < n: b += 1000 print(b-n)
s279888407
p02397
u326248180
1,000
131,072
Wrong Answer
20
7,556
104
Write a program which reads two integers x and y, and prints them in ascending order.
x, y = map(int, input().split()) if x < y: print("%d %d" % (x, y)) else: print("%d %d" % (y, x))
s546250943
Accepted
40
7,660
242
import sys while(True): x, y = map(lambda x: (int, int)[x.isdigit()](x) ,sys.stdin.readline().split(None, 1)) if x == 0 and y == 0: break if x < y: print("%d %d" % (x, y)) else: print("%d %d" % (y, x))
s998780063
p03545
u103902792
2,000
262,144
Wrong Answer
17
3,060
291
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.
s = input() def func(ac,s,op): next = s[0] if len(s) ==1: if ac + next == 7: print(str+'+'+s[0]+'=7') exit(0) if ac - next == 7: print(str+'-'+s[0]+'=7') exit(0) else: func(ac+next,s[1:],op+'+'+str(next)) func(ac-next,s[1:],op+'-'+str(next))
s598593239
Accepted
17
3,060
323
s = input() def func(ac,s,op): next = int(s[0]) if len(s) ==1: if ac + next == 7: print(op+'+'+s[0]+'=7') exit(0) if ac - next == 7: print(op+'-'+s[0]+'=7') exit(0) else: func(ac+next,s[1:],op+'+'+str(next)) func(ac-next,s[1:],op+'-'+str(next)) func(int(s[0]),s[1:],s[0])
s006608123
p03477
u708019102
2,000
262,144
Wrong Answer
17
2,940
140
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print `Left` if the balance scale tips to the left; print `Balanced` if it balances; print `Right` if it tips to the right.
a,b,c,d = [int(x) for x in input().split()] r = a+b l = c+d if r > l: print("Right") elif l > r: print("Left") else: print("Balanced")
s184705879
Accepted
18
3,060
140
a,b,c,d = [int(x) for x in input().split()] l = a+b r = c+d if r > l: print("Right") elif l > r: print("Left") else: print("Balanced")
s510594314
p03944
u292810930
2,000
262,144
Wrong Answer
149
12,508
538
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: * If a_i = 1, he painted the region satisfying x < x_i within the rectangle. * If a_i = 2, he painted the region satisfying x > x_i within the rectangle. * If a_i = 3, he painted the region satisfying y < y_i within the rectangle. * If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting.
import numpy as np W, H, N = map(int, input().split()) xlist = np.zeros(N,dtype=int) ylist = np.zeros(N,dtype=int) alist = np.zeros(N,dtype=int) for i in range(N): xlist[i], ylist[i], alist[i] = map(int, input().split()) rectangular = np.zeros((H, W)) for i in range(N): if alist[i] == 1: rectangular[:,:xlist[i]] = 1 if alist[i] == 2: rectangular[:,xlist[i]:] = 1 if alist[i] == 3: rectangular[:ylist[i],:] = 1 if alist[i] == 4: rectangular[ylist[i]:,:] = 1 sum(sum(rectangular < 1))
s805167505
Accepted
150
12,508
545
import numpy as np W, H, N = map(int, input().split()) xlist = np.zeros(N,dtype=int) ylist = np.zeros(N,dtype=int) alist = np.zeros(N,dtype=int) for i in range(N): xlist[i], ylist[i], alist[i] = map(int, input().split()) rectangular = np.zeros((H, W)) for i in range(N): if alist[i] == 1: rectangular[:,:xlist[i]] = 1 if alist[i] == 2: rectangular[:,xlist[i]:] = 1 if alist[i] == 3: rectangular[:ylist[i],:] = 1 if alist[i] == 4: rectangular[ylist[i]:,:] = 1 print(sum(sum(rectangular < 1)))
s176609741
p02409
u444997287
1,000
131,072
Wrong Answer
30
7,712
413
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.
N = int(input()) m=[] line = '' m = [[[0 for k in range(10)] for j in range(3)] for i in range(10)] for i in range(N): n = input().split() b = int(n[0]) f = int(n[1]) r = int(n[2]) v = int(n[3]) m[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): line += ' {0}'.format(m[i][j][k]) print(line) line = '' print('#'*20)
s067092519
Accepted
20
7,716
431
N = int(input()) m=[] line = '' m = [[[0 for k in range(10)] for j in range(3)] for i in range(10)] for i in range(N): n = input().split() b = int(n[0]) f = int(n[1]) r = int(n[2]) v = int(n[3]) m[b-1][f-1][r-1] += v for i in range(4): for j in range(3): for k in range(10): line += ' {0}'.format(m[i][j][k]) print(line) line = '' if i < 3: print('#'*20)
s826968930
p02261
u056253438
1,000
131,072
Wrong Answer
20
5,604
1,062
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).
_, cards = input(), input().split() def bubble_sort(array): A = array[:] for i in range(len(A)): for j in range(1, len(A) - i): if int(A[j - 1][1]) > int(A[j][1]): A[j], A[j - 1] = A[j - 1], A[j] return A def selection_sort(array): A = array[:] for i in range(len(A)): minn = i for j in range(i, len(A)): if int(A[j][1]) < int(A[minn][1]): minn = j A[i], A[minn] = A[minn], A[i] return A def is_stable(org, sorted): def get_same_numbers(array): result = {} for i in range(1, 10): result[i] = [] for j in range(len(array)): if int(array[j][1]) == i: result[i].append(array[j]) return [cards for _, cards in result.items() if len(cards) >= 2] return "Stable" if get_same_numbers(org) == get_same_numbers(sorted) else "Not Stable" a = bubble_sort(cards) print(" ".join(a)) print(is_stable(cards, a)) b = selection_sort(cards) print(" ".join(b)) print(is_stable(cards, b))
s733008742
Accepted
20
5,612
1,062
_, cards = input(), input().split() def bubble_sort(array): A = array[:] for i in range(len(A)): for j in range(1, len(A) - i): if int(A[j - 1][1]) > int(A[j][1]): A[j], A[j - 1] = A[j - 1], A[j] return A def selection_sort(array): A = array[:] for i in range(len(A)): minn = i for j in range(i, len(A)): if int(A[j][1]) < int(A[minn][1]): minn = j A[i], A[minn] = A[minn], A[i] return A def is_stable(org, sorted): def get_same_numbers(array): result = {} for i in range(1, 10): result[i] = [] for j in range(len(array)): if int(array[j][1]) == i: result[i].append(array[j]) return [cards for _, cards in result.items() if len(cards) >= 2] return "Stable" if get_same_numbers(org) == get_same_numbers(sorted) else "Not stable" a = bubble_sort(cards) print(" ".join(a)) print(is_stable(cards, a)) b = selection_sort(cards) print(" ".join(b)) print(is_stable(cards, b))
s340073746
p02613
u339194100
2,000
1,048,576
Wrong Answer
163
9,224
283
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()) a=0 w=0 t=0 r=0 for i in range(n): s=str(input()) if(s=='AC'): a+=1 elif(s=="WA"): w+=1 elif(s=="TLE"): t+=1 else: r+=1 print('AC ', '× ',a) print('WA ', '× ',w) print('TLE ', '× ',t) print('RE ', '× ',r)
s675297311
Accepted
162
9,220
263
n=int(input()) a=0 w=0 t=0 r=0 for i in range(n): s=str(input()) if(s=='AC'): a+=1 elif(s=="WA"): w+=1 elif(s=="TLE"): t+=1 else: r+=1 print('AC', 'x',a) print('WA', 'x',w) print('TLE', 'x',t) print('RE', 'x',r)
s964660572
p02288
u024715419
2,000
131,072
Wrong Answer
20
7,684
94
A binary heap which satisfies max-heap property is called max-heap. In a max- heap, for every node $i$ other than the root, $A Write a program which reads an array and constructs a max-heap from the array based on the following pseudo code. $maxHeapify(A, i)$ move the value of $A[i]$ down to leaves to make a sub-tree of node $i$ a max-heap. Here, $H$ is the size of the heap. 1 maxHeapify(A, i) 2 l = left(i) 3 r = right(i) 4 // select the node which has the maximum value 5 if l ≤ H and A[l] > A[i] 6 largest = l 7 else 8 largest = i 9 if r ≤ H and A[r] > A[largest] 10 largest = r 11 12 if largest ≠ i // value of children is larger than that of i 13 swap A[i] and A[largest] 14 maxHeapify(A, largest) // call recursively The following procedure buildMaxHeap(A) makes $A$ a max-heap by performing maxHeapify in a bottom-up manner. 1 buildMaxHeap(A) 2 for i = H/2 downto 1 3 maxHeapify(A, i)
h = int(input()) key = list(map(int,input().split())) key.sort() key.reverse() print("",*key)
s143925166
Accepted
910
65,996
451
def maxHeapify(a, i): l = 2*i r = 2*i + 1 if l <= h and a[l] > a[i]: largest = l else: largest = i if r <= h and a[r] > a[largest]: largest = r if largest != i: a[i], a[largest] = a[largest], a[i] maxHeapify(a, largest) h = int(input()) n = int(0.5*h) key = list(map(int,input().split())) key.insert(0,0) for i in range(n): j = n - i maxHeapify(key, j) print("",*key[1:])
s865411034
p03761
u202570162
2,000
262,144
Wrong Answer
19
3,064
294
Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains. Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.
alp=list('qawsedrftgyhujikoplmnbvcxz') alp.sort() cnt=[] for i in range(int(input())): tmp=[0 for _ in range(26)] for s in list(input()): tmp[alp.index(s)]+=1 cnt.append(tmp) m=57 ans='' for i in range(26): for j in range(len(cnt)): m=min(m,cnt[j][i]) ans+=alp[i]*m print(ans)
s598291516
Accepted
19
3,064
325
alp=list('qawsedrftgyhujikoplmnbvcxz') alp.sort() # print(alp) cnt=[] for i in range(int(input())): tmp=[0 for _ in range(26)] for s in list(input()): tmp[alp.index(s)]+=1 cnt.append(tmp) # print(tmp) ans='' for i in range(26): m=57 for j in range(len(cnt)): m=min(m,cnt[j][i]) ans+=alp[i]*m print(ans)
s133460154
p02412
u971748390
1,000
131,072
Wrong Answer
30
6,724
216
Write a program which identifies the number of combinations of three integers which satisfy the following conditions: * You should select three distinct integers from 1 to n. * A total sum of the three integers is x. For example, there are two combinations for n = 5 and x = 9. * 1 + 3 + 5 = 9 * 2 + 3 + 4 = 9
while True: n,x=map(int,input().split()) if n==x==0: break count=0 for i in range(n-2): for k in range(i+1,n-1): for j in range(k+1,n): if i+k+j==x : count = count +1 print('count')
s630592933
Accepted
640
6,724
234
while True: n,x=map(int,input().split()) if n==x==0 : break count = 0 for i in range(1,n-1) : for j in range(i+1,n): for k in range(j+1,n+1): if i+j+k==x : count = count +1 print(count)
s771856907
p03401
u953110527
2,000
262,144
Wrong Answer
227
14,800
383
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled.
n = int(input()) c = list(map(int,input().split())) a = [0] a += c a.append(0) b = [0 for i in range(n+1)] b[0] = abs(a[1]) count = abs(a[1]) for i in range(1,n): b[i] = abs(a[i+1]-a[i]) count += b[i] count += abs(a[n]) b[n] = abs(a[n]) print(a) print(b) for i in range(n): print(count - b[i] - b[i+1] + abs(a[i+2] - a[i])) # 0 3 5 -1 0 # 0 5 -1 0 # 0 3 -1 0 # 0 3 5 0
s523681335
Accepted
201
14,048
365
n = int(input()) c = list(map(int,input().split())) a = [0] a += c a.append(0) b = [0 for i in range(n+1)] b[0] = abs(a[1]) count = abs(a[1]) for i in range(1,n): b[i] = abs(a[i+1]-a[i]) count += b[i] count += abs(a[n]) b[n] = abs(a[n]) for i in range(n): print(count - b[i] - b[i+1] + abs(a[i+2] - a[i])) # 0 3 5 -1 0 # 0 5 -1 0 # 0 3 -1 0 # 0 3 5 0
s310224806
p02262
u387437217
6,000
131,072
Wrong Answer
20
7,820
660
Shell Sort is a generalization of [Insertion Sort](http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A) to arrange a list of $n$ elements $A$. 1 insertionSort(A, n, g) 2 for i = g to n-1 3 v = A[i] 4 j = i - g 5 while j >= 0 && A[j] > v 6 A[j+g] = A[j] 7 j = j - g 8 cnt++ 9 A[j+g] = v 10 11 shellSort(A, n) 12 cnt = 0 13 m = ? 14 G[] = {?, ?,..., ?} 15 for i = 0 to m-1 16 insertionSort(A, n, G[i]) A function shellSort(A, n) performs a function insertionSort(A, n, g), which considers every $g$-th elements. Beginning with large values of $g$, it repeats the insertion sort with smaller $g$. Your task is to complete the above program by filling ?. Write a program which reads an integer $n$ and a sequence $A$, and prints $m$, $G_i (i = 0, 1, ..., m − 1)$ in the pseudo code and the sequence $A$ in ascending order. The output of your program must meet the following requirements: * $1 \leq m \leq 100$ * $0 \leq G_i \leq n$ * cnt does not exceed $\lceil n^{1.5}\rceil$
# coding: utf-8 # Here your code ! import math n=int(input()) A=[int(input()) for i in range(n)] def insertion_sort(ar,num,g): count=0 for i in range(g,num): v=ar[i] j=i-g while j>=0 and ar[j]>v: ar[j+g]=ar[j] j=j-g count+=1 ar[j+g]=v return count def shell_sort(AR,num): count=0 m = math.floor(math.log(2 * n + 1) / math.log(3)) print(m) G = [0 for i in range(m)] G[0] = 1 for i in range(1, m): G[i] = 3 * G[i - 1] + 1 print(*G) for i in range(m): insertion_sort(AR,n,G[i]) shell_sort(A,n) for i in A: print(i)
s689029847
Accepted
20,880
47,524
670
import math n=int(input()) A=[int(input()) for i in range(n)] def insertion_sort(ar,num,g): count=0 for i in range(g,num): v=ar[i] j=i-g while j>=0 and ar[j]>v: ar[j+g]=ar[j] j=j-g count+=1 ar[j+g]=v return count def shell_sort(AR,num): count=0 m = math.floor(math.log(2 * n + 1) / math.log(3)) print(m) G = [0 for i in range(m)] G[0] = 1 for i in range(1, m): G[i] = 3 * G[i - 1] + 1 G.reverse() print(*G) for i in range(m): count+= insertion_sort(A, n, G[i]) print(count) shell_sort(A,n) for i in A: print(i)
s732273078
p02392
u344890307
1,000
131,072
Wrong Answer
20
5,600
157
Write a program which reads three integers a, b and c, and prints "Yes" if a < b < c, otherwise "No".
def main(): a,b,c=map(int,input().split()) if a<b<c: print('yes') else: print('No') if __name__=='__main__': main()
s045589874
Accepted
20
5,600
157
def main(): a,b,c=map(int,input().split()) if a<b<c: print('Yes') else: print('No') if __name__=='__main__': main()