output_description stringlengths 15 956 | submission_id stringlengths 10 10 | status stringclasses 3 values | problem_id stringlengths 6 6 | input_description stringlengths 9 2.55k | attempt stringlengths 1 13.7k | problem_description stringlengths 7 5.24k | samples stringlengths 2 2.72k |
|---|---|---|---|---|---|---|---|
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s893774823 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=input().split()
int a
int b
int c
if (c>=a)and(c<=b):
print('Yes')
else:
print('No')
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s035529859 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | print((lambda a,b,c: "YES" if a<=c&&c<=b else "NO")(*[int(_) for _ in input().split()])) | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s935499957 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
if a<=c and b>=c:
print("Yes")
else;
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s254543384 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
if c>=a andc<=b:
print("Yes")
else:
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s100621806 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C |
A, B, C = map(int, input().split())
print("Yes" if C >= A and C =< B else "No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s334016520 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input()split())
if a<=c<=b:
print("Yes")
else:
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s212764096 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | print("NYoe s"[eval(input().replace(" ","<=")::2)]) | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s846446223 | Wrong Answer | p03719 | Input is given from Standard Input in the following format:
A B C | print()
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s048518608 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c = map(int, input().split())
print('Yes' ifa<=c<=b else 'No') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s478033877 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int, input().split())
print("Yes" a <= c and c <= b else "No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s363343711 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
print('Yes' if a <= c <= b else ''No') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s505710211 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | [a,b,c]=list(map(int,input().split()))
if a<b<c
print:{"true"} | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s233264627 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s122804311 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | p=map(int,input().split());print('Yes'if p[0<=p[2]<=p[1]else'No') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s206668963 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | if A<=C or C<=B then:
print("Yes") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s247387672 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=input().split()
int a
int b
int c
if c>=a and c<=b:
print('YES')
else:
print('NO') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s536086509 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int, input().split())
if a <= c and c <= b:
print("Yes")
eles:
print('No') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s676244041 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c = for i in input().split()
if(a <= c && c <= b)
print('Yes')
else
print('No')
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s168288368 | Wrong Answer | p03719 | Input is given from Standard Input in the following format:
A B C | # https://atcoder.jp/contests/abc061/tasks/abc061_d
import sys
# coding: utf-8
# Your code here!
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s131349817 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c = map(int,input().split())
if c => a and c =< b:
print("Yes")
else:
print("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s687093468 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
.
if a<=c and b>=c:
print("Yes")
else:
print("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s786917239 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=map(int,input().split())
if a<= c and b=>c:
print("Yes")
else:
print("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s835429068 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a b c = map(int, input().split())
if a<=c and c<=b:
print("Yes")
else:
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s619032717 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a b c = map(int, input().split())
if a<=c and c<=b:
print("Yes")
else:
print(”No”) | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s130711326 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | i = int(input().split())
if (i[0] <= i[2]) && (i[1] >= i[2]):
print("Yes")
else:
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s036365873 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int,input().split())
if c >= a and c =< b:
print ("Yes")
else:
print ("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s469092547 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int input().split())
if a <= c amd c <= b:
print("Yes")
else:
print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s369452600 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c=input().split()
int a
int b
int c
if c=>a and c=<b:
print('YES')
else:
print('NO') | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s686351828 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | N, M = map(int, input().split())
array = [tuple(int(x) for x in input().split()) for x in range(M)]
score = [-float("inf") for x in range(N)]
score[0] = 0
check = 0
while True:
if N == 0:
check = score[-1]
elif N < 0:
if check == score[-1]:
pass
elif check > score[-1]:
print("inf")
break
elif check < score[-1]:
print(check)
break
now = score.copy()
for j in array:
if score[j[0] - 1] + j[2] > score[j[1] - 1]:
score[j[1] - 1] = score[j[0] - 1] + j[2]
if now == score:
print(score[-1])
break
N += -1
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s802213412 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | # ABC061C
import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ans = ""
for a, b in ab:
for i in range(b):
now += 1
if now == K:
print(a)
sys.exit(0)
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s098746075 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | import sys
n,m = [int(x) for x in sys.stdin.readline().split()]
r = [0] * n
for i in range m:
a, b = [int(x) for x in sys.stdin.readline().split()]
r[a-1] += 1
r[b-1] += 1
for i in range n:
print(r[i]) | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s041302173 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int,input().split())
if a =< c =< b:
print ("Yes")
else:
print ("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s062483371 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c, = map(int, input().split())
pront("Yes") if a <= c =< b else print("No") | Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s818635951 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a,b,c = map(int, input().split()
print('Yes') if a<=c<=b else print('No')
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s749329306 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | map(int, sys.stdin.readline().split())
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
If the condition is satisfied, print `Yes`; otherwise, print `No`.
* * * | s455437157 | Runtime Error | p03719 | Input is given from Standard Input in the following format:
A B C | a, b, c = map(int input().split())
if a <= c and c <= b:
print("Yes")
else:
print("No")
| Statement
You are given three integers A, B and C. Determine whether C is not less than
A and not greater than B. | [{"input": "1 3 2", "output": "Yes\n \n\nC=2 is not less than A=1 and not greater than B=3, and thus the output should\nbe `Yes`.\n\n* * *"}, {"input": "6 5 4", "output": "No\n \n\nC=4 is less than A=6, and thus the output should be `No`.\n\n* * *"}, {"input": "2 2 2", "output": "Yes"}] |
The output should be composed of lines each corresponding to an input line
except the last zero. An output line includes the number of representations
for the input integer as the sum of one or more consecutive prime numbers. No
other characters should be inserted in the output. | s154353708 | Accepted | p00836 | The input is a sequence of positive integers each in a separate line. The
integers are between 2 and 10 000, inclusive. The end of the input is
indicated by a zero. | p = []
a = [0] * 2 + [1] * 10001
for i in range(2, int(10000**0.5) + 1):
if a[i]:
for j in range(i * i, 10001, i):
a[j] = 0
for i in range(2, 10001):
if a[i]:
p += [i]
b = [0] * 5736397
for i in range(len(p)):
c = 0
for j in range(i, len(p)):
c += p[j]
b[c] += 1
while 1:
n = int(input())
if n == 0:
break
print(b[n])
| A: Sum of Consecutive Prime Numbers
Some positive integers can be represented by a sum of one or more consecutive
prime numbers. How many such representations does a given positive integer
have? For example, the integer 53 has two representations 5 + 7 + 11 + 13 + 17
and 53. The integer 41 has three representations 2 + 3 + 5 + 7 + 11 + 13, 11 +
13 + 17, and 41. The integer 3 has only one representation, which is 3\. The
integer 20 has no such representations. Note that summands must be consecutive
prime numbers, so neither 7 + 13 nor 3 + 5 + 5 + 7 is a valid representation
for the integer 20.
Your mission is to write a program that reports the number of representations
for the given positive integer. | [{"input": "3\n 17\n 41\n 20\n 666\n 12\n 53\n 0", "output": "1\n 2\n 3\n 0\n 0\n 1\n 2"}] |
Print the number of the possible ways to paint the balls.
* * * | s551277621 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | import sys
def resolve():
input = sys.stdin.readline
N, K = map(int, input().rstrip().split())
print(K * pow(K - 1, N - 1))
import sys
from io import StringIO
import unittest
class TestClass(unittest.TestCase):
def assertIO(self, input, output):
stdout, stdin = sys.stdout, sys.stdin
sys.stdout, sys.stdin = StringIO(), StringIO(input)
resolve()
sys.stdout.seek(0)
out = sys.stdout.read()[:-1]
sys.stdout, sys.stdin = stdout, stdin
self.assertEqual(out, output)
def test_入力例_1(self):
input = """2 2"""
output = """2"""
self.assertIO(input, output)
def test_入力例_2(self):
input = """1 10"""
output = """10"""
self.assertIO(input, output)
def test_入力例_3(self):
input = """10 8"""
output = """322828856"""
self.assertIO(input, output)
if __name__ == "__main__":
# unittest.main()
resolve()
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s181406874 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | from statistics import mean, median, variance, stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
from operator import itemgetter
# 以下てんぷら
def j(q):
if q == 1:
print("Yes")
else:
print("No")
exit(0)
def ct(x, y):
if x > y:
print("+")
elif x < y:
print("-")
else:
print("?")
def ip():
return int(input())
rem = pow(10, 9) + 7
# n = ip() #入力整数1つ
x, y = (int(i) for i in input().split()) # 入力整数横2つ以上
# a = [int(i) for i in input().split()] #入力整数配列
# a = input() #入力文字列
# a = input().split() #入力文字配列
# n = ip() #入力セット(整数改行あり)(1/2)
# a=[input() for i in range(x)] #入力セット(整数改行あり)(2/2)
# jの変数はしようできないので注意
# 全足しにsum変数使用はsum関数使用できないので注意
# こっから本文
print(y * pow(y - 1, x - 1))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s711185083 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | sample = input() # two numbers in a string
new_sample = sample.split(" ")
ball = int(new_sample[0]) # number of balls
color = int(new_sample[1]) # number of colors
if color == 1 and ball > 1:
print(0)
else:
product = color
# for i in range(1, ball):
for i in range(1, ball):
product *= (color-1)
print(product)
# 3 balls, 10 colors
# 1st spot, 10 choices
# 2nd spot, 9 choices
# 3rd spot, 9 choices
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s918227226 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | import math
n,k=map(int,input().split())
if n % k == 0:
x= n//k
print(x*math.factorial(k))
"""else:
r= n % k
div=n-r
y=div//k
sum= y*(math.factorial(k))
z=nCr(k,r)
sum+=z
print(sum)
"""
def nCr(n,r):
f = math.factorial
return f(n) / f(r) / f(n-r) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s995923769 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | a = list(map(int,input().strip())
b = a[0] #色の数
c = a[1] #ボールの数
ans = (b*(b-1)**(c-1))
print(ans) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s225242922 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | n, c = map(int, input().split())
print(c * (c - 1) ** (n - 1))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s451670787 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | n,k = map(int,input().split())
print(k*((k-1)**(n-1)) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s200392038 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | import sys
## io ##
def IS():
return sys.stdin.readline().rstrip()
def II():
return int(IS())
def MII():
return list(map(int, IS().split()))
def MIIZ():
return list(map(lambda x: x - 1, MII()))
## dp ##
def DD2(d1, d2, init=0):
return [[init] * d2 for _ in range(d1)]
def DD3(d1, d2, d3, init=0):
return [DD2(d2, d3, init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str:
return format(x, "b") # rev => int(res, 2)
def to_oct(x: int) -> str:
return format(x, "o") # rev => int(res, 8)
def to_hex(x: int) -> str:
return format(x, "x") # rev => int(res, 16)
MOD = 10**9 + 7
def divc(x, y) -> int:
return -(-x // y)
def divf(x, y) -> int:
return x // y
def gcd(x, y):
while y:
x, y = y, x % y
return x
def lcm(x, y):
return x * y // gcd(x, y)
def enumerate_divs(n):
"""Return a tuple list of divisor of n"""
return [(i, n // i) for i in range(1, int(n**0.5) + 1) if n % i == 0]
def get_primes(MAX_NUM=10**3):
"""Return a list of prime numbers n or less"""
is_prime = [True] * (MAX_NUM + 1)
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX_NUM**0.5) + 1):
if not is_prime[i]:
continue
for j in range(i * 2, MAX_NUM + 1, i):
is_prime[j] = False
return [i for i in range(MAX_NUM + 1) if is_prime[i]]
## libs ##
from itertools import (
accumulate as acc,
combinations as combi,
product,
combinations_with_replacement as combi_dup,
)
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
# ======================================================#
def main():
n, k = MII()
print(k * (k - 1) ** (n - 1))
if __name__ == "__main__":
main()
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s401715226 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | nums = [int(e) for e in input().split()]
val = nums[1]
for i in range(nums[0] - 1):
val = val * (nums[1] - 1)
print(val)
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s093608041 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K |
def abc046_b():
n, k = map(int, input().split())
return k * ((k - 1) ** (n - 1))
if __name__ == '__main__':
print(abc046_b()) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s320253634 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | n = list(map(int, input().split()))
x = n[1] * ((n[1] - 1) ** (n[0] - 1))
print(x)
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s361988558 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | ilne = input().split(' ')
print(int(line[0])*((int(line[0])-1)**(int(line[1])-1)) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s805073437 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | N = input().split()
print(int(N[1]) * (int(N[1]) - 1) ** (int(N[0]) - 1))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s320456195 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | line = input().split(" ")
print(int(line[1]) * ((int(line[1]) - 1) ** (int(line[0]) - 1)))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s689898015 | Accepted | p03963 | The input is given from Standard Input in the following format:
N K | a, b = (int(_) for _ in input().split())
print(int(b * ((b - 1) ** (a - 1))))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s168688592 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | N, K = [int(input()) for _ in range(2)]
A = int((K - 1) ** N)
print(int(A * K))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s082717617 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | n,k=map(int,input().split())
print(k*((k-1)**(n-1)) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s205998776 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | N, K input().split()
print(K * (K - 1) ** (N - 1)) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s967909088 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | N,K=map(int,input().split())
print(K*((K-1)^^(N-1))) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s091780197 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | N,K=map(int,input().split())
print(K*(K-1)**(N-1) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s250800850 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | list = [x for x in input()]
print(max(x))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s143382112 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | a = input().split()
n = int[0]
k = int[1]
print(2 ** (n - 1) * k)
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s983228649 | Runtime Error | p03963 | The input is given from Standard Input in the following format:
N K | N, K = map(int, input().split())
print(K * ((K-1)**(N-1)) | Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
Print the number of the possible ways to paint the balls.
* * * | s011747939 | Wrong Answer | p03963 | The input is given from Standard Input in the following format:
N K | s = input().split()
N = int(s[0])
K = int(s[1])
print(K * ((K - 1) ** N))
| Statement
There are N balls placed in a row. AtCoDeer the deer is painting each of these
in one of the K colors of his paint cans. For aesthetic reasons, any two
adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls. | [{"input": "2 2", "output": "2\n \n\nWe will denote the colors by 0 and 1. There are two possible ways: we can\neither paint the left ball in color 0 and the right ball in color 1, or paint\nthe left in color 1 and the right in color 0.\n\n* * *"}, {"input": "1 10", "output": "10\n \n\nSince there is only one ball, we can use any of the ten colors to paint it.\nThus, the answer is ten."}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s373030868 | Accepted | p02671 | Input is given from Standard Input in the following format:
N
T | import sys
readline = sys.stdin.readline
N = int(readline())
P3 = [pow(3, i) for i in range(N + 1)]
St = [1 if s == "R" else 0 for s in readline().strip()]
LS = len(St)
ans = [None] * P3[N]
arr = [None] * P3[N]
ans[0] = 0
arr[0] = St[:]
REV = (0, 2, 1)
for l in range(N):
p3l = P3[l]
for i in range(p3l):
k0, k1, k2 = 0, 1, 2
r0, r1, r2 = [], [], []
for s in arr[i]:
if s:
k0 += 1
k1 += 1
k2 += 1
if k0 == 3:
k0 = 0
r0.append(1)
if k1 == 3:
k1 = 0
r1.append(1)
if k2 == 3:
k2 = 0
r2.append(1)
else:
k0 = REV[k0]
k1 = REV[k1]
k2 = REV[k2]
if r0 and r0[-1] == 0:
r0.pop()
else:
r0.append(0)
if r1 and r1[-1] == 0:
r1.pop()
else:
r1.append(0)
if r2 and r2[-1] == 0:
r2.pop()
else:
r2.append(0)
arr[2 * p3l + i] = r2[:]
arr[p3l + i] = r1[:]
arr[i] = r0[:]
a = ans[i]
ans[2 * p3l + i] = k2 * p3l + a
ans[p3l + i] = k1 * p3l + a
ans[i] = k0 * p3l + a
print(*ans)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s337684361 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | inputNum = int(input())
input()
if inputNum == 1:
print("2 0 1")
elif inputNum == 2:
print("3 8 1 0 5 7 6 2 4")
elif inputNum == 3:
print("23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10")
else:
for i in range(0, (3**inputNum) - 1):
print(i, end=" ")
print((3**inputNum) - 1)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s168841523 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | n = int(input())
print(n**2)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s370876864 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | num = int(input())
judge = list(input())
def Base_10_to_n(X, n):
X_dumy = X
out = ""
while X_dumy > 0:
out = str(X_dumy % n) + out
X_dumy = int(X_dumy / n)
return out
pos = [0] * 3**num
for p in pos:
x10 = p
x3 = Base_10_to_n(x10, 3)
pos[p] = x3
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s098441635 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | t = int(input())
n = input()
print(1)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s733075220 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | input()
print(1)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s832541245 | Accepted | p02671 | Input is given from Standard Input in the following format:
N
T | # salsa=0, rumba=1
# [0 1 0 1] 1より上の位に帯する操作
# 繰り上がりを考慮しつつ、3(より上)の位に対する操作を考える
# [1] 1の位が0である数字の、3の位に対する操作
# [0 1 0] 1の位が1である数字の、3の位に対する操作
# [] 1の位が2である数字の、3の位に対する操作
# ある数字が"2"の時にルンバが来れば繰り上がる(上の位にルンバが波及)
# それ以外の状態では、上の位にとってルンバは無いのと同じことになる
# サルサは常に影響するが、連続した2つのサルサは打ち消し合い、無いのと同じことになる
# 再帰的に上の位を決める
# [] 3,1の位が00,10である数字の、9の位に対する操作
# [1] 3,1の位が20である数字の、9の位に対する操作
# [] 3,1の位が01,21である数字の、9の位に対する操作
# [0 1 0] 3,1の位が11である数字の、9の位に対する操作
# [] 3,1の位が02,12,22である数字の、9の位に対する操作
# 一度繰り上がったら、例えば100.. と0がd個続くとして、
# 更にその上の位に波及させるには 2^d オーダーの操作が必要となるので、各操作列は徐々に減っていく
n = int(input())
t = input()
op = [[int(c == "R") for c in t]]
ans = [0]
for d in range(n):
k = 3**d
nop = []
nans = [0] * (k * 3)
for g in range(3): # d桁目の数
for i in range(k): # d桁目未満の数
opg = op[i]
opn = []
h = g
for o in opg:
if o == 0:
if len(opn) > 0 and opn[-1] == 0:
opn.pop()
else:
opn.append(0)
if h == 1:
h = 2
elif h == 2:
h = 1
else:
if h == 2:
h = 0
opn.append(1)
else:
h += 1
nop.append(opn)
nans[g * k + i] = h * k + ans[i]
op = nop
ans = nans
print(*ans)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
You should print on Standard Output:
P_0 P_1 \cdots P_{3^N-1}
* * * | s380572953 | Wrong Answer | p02671 | Input is given from Standard Input in the following format:
N
T | import sys
def ternary(n):
if n == 0:
return "0"
nums = []
while n:
n, r = divmod(n, 3)
nums.append(str(r))
return "".join(reversed(nums))
def swap(str):
swapped = ""
for c in str:
if c == "1":
swapped += "2"
elif c == "2":
swapped += "1"
else:
swapped += c
return swapped
if __name__ == "__main__":
lines = []
for line in sys.stdin:
line = line.rstrip("\r\n")
lines.append(line)
N = int(lines[0])
T = lines[1]
P = list(range(0, 3**N))
for t in T:
if t == "R":
for i in range(len(P)):
P[i] = (P[i] + 1) % len(P)
elif t == "S":
for i in range(len(P)):
P[i] = int(swap(ternary(P[i])), 3)
print(P)
| Statement
There are 3^N people dancing in circle. We denote with 0,1,\dots, 3^{N}-1 the
positions in the circle, starting from an arbitrary position and going around
clockwise. Initially each position in the circle is occupied by one person.
The people are going to dance on two kinds of songs: salsa and rumba.
* When a salsa is played, the person in position i goes to position j, where j is the number obtained replacing all digits 1 with 2 and all digits 2 with 1 when reading i in base 3 (e.g., the person in position 46 goes to position 65).
* When a rumba is played, the person in position i moves to position i+1 (with the identification 3^N = 0).
You are given a string T=T_1T_2\cdots T_{|T|} such that T_i=`S` if the i-th
song is a salsa and T_i=`R` if it is a rumba. After all the songs have been
played, the person that initially was in position i is in position P_i.
Compute the array P_0,P_1,\dots, P_{3^N-1}. | [{"input": "1\n SRS", "output": "2 0 1 \n \n\nBefore any song is played, the positions are: 0, 1, 2.\n\nWhen we say \"person i\", we mean \"the person that was initially in position i\".\n\n 1. After the first salsa, the positions are: 0, 2, 1.\n 2. After the rumba, the positions are: 1, 0, 2 (so, person 0 is in position 1, person 1 is in position 0 and person 2 is in position 2).\n 3. After the second salsa, the positions are 2, 0, 1 (so, person 0 is in position 2, person 1 is in position 0 and person 2 is in position 1).\n\n* * *"}, {"input": "2\n RRSRSSSSR", "output": "3 8 1 0 5 7 6 2 4 \n \n\n* * *"}, {"input": "3\n SRSRRSRRRSRRRR", "output": "23 9 22 8 3 7 20 24 19 5 18 4 17 12 16 2 6 1 14 0 13 26 21 25 11 15 10"}] |
Print the maximum possible value of X-Y.
* * * | s569587032 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
for i in range(n):
if v[i] > c[i]:
ans + = (v[i]-c[i])
else:
continue
print(ans) | Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s562792158 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | input()
v=list(map(int,input().split())
c=list(map(int,input().split())
a=[max(0,i-j) for i,j in zip(v,c)]
print(sum(a)) | Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s799296891 | Accepted | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | n = int(input())
value_list = [int(i) for i in input().split(" ")]
cost_list = [int(i) for i in input().split(" ")]
profit = 0
for value, cost in zip(value_list, cost_list):
if value > cost:
profit += value - cost
print(profit)
| Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s401085536 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | num = int(input())
lists = [list(map(int, input().split())) for i in range(2)]
nums = [lists[0][j] - lists[1][j] for j in range(num)]
print(sorted(nums, reverse=True)[0] + sorted(nums, reverse=True)[1])
| Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s829506513 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | n = input()
vli = list(map(int, input().split()))
cli = list(map(int, input().split()))
for i in n:
sli = []
sli.append(vli[i] - cli[i])
for j in n:
ans = []
if sli[j] > 0:
ans.append(sli[j])
print(sum(ans))
| Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s563183309 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | n = int(input())
v = map(int, input().split())
c = map(int, input().split())
max_val = 0
for _v, _c in zip(v, c):
if _v - _c > 0:
max_val += _v - _c
print(max_val | Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s128439016 | Runtime Error | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | N = map(int, input().split())
values = [int(input()) for _ in range(N)]
costs = [int(input()) for _ in range(N)]
# N = 3
# values = [10, 2, 5]
# costs = [6, 3, 4]
# N = 4
# values = [13, 21, 6, 19]
# costs = [11, 30, 6, 15]
# N = 1
# values = [1,]
# costs = [50,]
def calculate_maximum_gain(values, costs):
gain = 0
for value, cost in zip(values, costs):
if value - cost > 0:
gain = gain + value - cost
return gain
print(calculate_maximum_gain(values, costs))
| Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the maximum possible value of X-Y.
* * * | s251012337 | Accepted | p03060 | Input is given from Standard Input in the following format:
N
V_1 V_2 ... V_N
C_1 C_2 ... C_N | """
N 個の宝石があり、i 番目の宝石の価値は Viです。
あなたはこれらの宝石の中からいくつかを選んで手に入れます。
このとき、1つも選ばなくとも、全て選んでも構いません。
ただし、i番目の宝石を手に入れる場合コスト Ciを支払わなければいけません。
手に入れた宝石の価値の合計を X、支払ったコストの合計を Yとします。
X−Yの最大値を求めてください。
制約
入力は全て整数である。
1≤N≤20
1≤Ci,Vi≤50
X - Y = Σ(Vi - Ci)
Vi - Ci > 0のものを全て取得する
"""
N = int(input())
v_list = input().split(" ")
c_list = input().split(" ")
v_list = [int(i) for i in v_list]
c_list = [int(i) for i in c_list]
sumValue = 0
for i in range(N):
substantialValue = v_list[i] - c_list[i]
if substantialValue > 0:
sumValue += substantialValue
print(sumValue)
| Statement
There are N gems. The value of the i-th gem is V_i.
You will choose some of these gems, possibly all or none, and get them.
However, you need to pay a cost of C_i to get the i-th gem.
Let X be the sum of the values of the gems obtained, and Y be the sum of the
costs paid.
Find the maximum possible value of X-Y. | [{"input": "3\n 10 2 5\n 6 3 4", "output": "5\n \n\nIf we choose the first and third gems, X = 10 + 5 = 15 and Y = 6 + 4 = 10. We\nhave X-Y = 5 here, which is the maximum possible value.\n\n* * *"}, {"input": "4\n 13 21 6 19\n 11 30 6 15", "output": "6\n \n\n* * *"}, {"input": "1\n 1\n 50", "output": "0"}] |
Print the highest possible value achievable.
* * * | s391707545 | Runtime Error | p03430 | Input is given from Standard Input in the following format:
S
K | # coding=utf-8
def lcs(s1, s2):
table = []
for _ in range(100):
table.append([0 for _ in range(100)])
for y in range(1, len(s1) + 1):
for x in range(1, len(s2) + 1):
match = 0
if s1[y - 1] == s2[x - 1]:
match = 1
v1 = table[y - 1][x - 1] + match
v2 = table[y - 1][x]
v3 = table[y][x - 1]
table[y][x] = max(v1, v2, v3)
return table[len(s1)][len(s2)]
def log(s, s2):
return
print("---")
print("s :" + "".join(s))
print("s2:" + "".join(s2))
s = list(input())
k = int(input())
s2 = s[::-1]
log(s, s2)
ab = set(s)
for i in range(k):
idx = -1
char = ""
r = -1
for j in range(len(s)):
for x in ab:
t = s[:]
t[j] = x
t2 = t[::-1]
if lcs(t, t2) > r:
r = lcs(t, t2)
idx = j
char = x
s[idx] = char
s2 = s[::-1]
log(s, s2)
print(lcs(s, s2))
| Statement
Takahashi has decided to give a string to his mother.
The _value_ of a string T is the length of the longest common subsequence of T
and T', where T' is the string obtained by reversing T. That is, the value is
the longest length of the following two strings that are equal: a subsequence
of T (possibly non-contiguous), and a subsequence of T' (possibly non-
contiguous).
Takahashi has a string S. He wants to give her mother a string of the highest
possible value, so he would like to change at most K characters in S to any
other characters in order to obtain a string of the highest possible value.
Find the highest possible value achievable. | [{"input": "abcabcabc\n 1", "output": "7\n \n\nChanging the first character to `c` results in `cbcabcabc`. Let this tring be\nT, then one longest common subsequence of T and T' is `cbabcbc`, whose length\nis 7.\n\n* * *"}, {"input": "atcodergrandcontest\n 3", "output": "15"}] |
Print the highest possible value achievable.
* * * | s385698451 | Wrong Answer | p03430 | Input is given from Standard Input in the following format:
S
K | def examA():
N = I()
ans = 0
print(ans)
return
# 参考 https://atcoder.jp/contests/agc021/submissions/8392122
def examB():
def norm2(vec):
return math.sqrt(vec[0] ** 2 + vec[1] ** 2)
# any 2 points must have different position.
def ConvexHull(point_list):
pos2idx = {point_list[i]: i for i in range(len(point_list))}
y_val = defaultdict(list)
x_list = sorted(list(set([p[0] for p in point_list])))
for x, y in point_list:
y_val[x].append(y)
upper = [(x_list[0], max(y_val[x_list[0]]))]
lower = [(x_list[0], min(y_val[x_list[0]]))]
prev = float("inf")
for xi in x_list[1:]:
x0, y0 = upper[-1]
x1, y1 = xi, max(y_val[xi])
if (y1 - y0) / (x1 - x0) < prev:
upper.append((x1, y1))
prev = (y1 - y0) / (x1 - x0)
else:
while True:
x0, y0 = upper[-1]
if len(upper) == 1:
upper.append((x1, y1))
break
x00, y00 = upper[-2]
if (y1 - y0) / (x1 - x0) > (y1 - y00) / (x1 - x00):
upper.pop()
else:
prev = (y1 - y0) / (x1 - x0)
upper.append((x1, y1))
break
prev = -float("inf")
for xi in x_list[1:]:
x0, y0 = lower[-1]
x1, y1 = xi, min(y_val[xi])
if (y1 - y0) / (x1 - x0) > prev:
lower.append((x1, y1))
prev = (y1 - y0) / (x1 - x0)
else:
while True:
x0, y0 = lower[-1]
if len(lower) == 1:
lower.append((x1, y1))
break
x00, y00 = lower[-2]
if (y1 - y0) / (x1 - x0) < (y1 - y00) / (x1 - x00):
lower.pop()
else:
prev = (y1 - y0) / (x1 - x0)
lower.append((x1, y1))
break
# return upper, lower
# return [pos2idx[xy] for xy in upper], [pos2idx[xy] for xy in lower]
upper_idx, lower_idx = [pos2idx[xy] for xy in upper], [
pos2idx[xy] for xy in lower
]
if upper_idx[-1] == lower_idx[-1]:
upper_idx.pop()
CH_idx = upper_idx
CH_idx.extend(reversed(lower_idx))
if CH_idx[0] == CH_idx[-1] and len(CH_idx) > 1:
CH_idx.pop()
return CH_idx
N = I()
P = [[] for _ in range(N)]
D = defaultdict(int)
for i in range(N):
x, y = LI()
P[i] = (x, y)
D[(x, y)] = i
C = ConvexHull(P)
ans = [0] * N
if len(C) == 2:
for c in C:
ans[c] = 0.5
for v in ans:
print(v)
return
# print(C)
for i, c in enumerate(C):
s, t, u = C[i - 1], C[i], C[(i + 1) % len(C)]
x0, y0 = P[s]
x1, y1 = P[t]
x2, y2 = P[u]
vec0 = (y0 - y1, x1 - x0)
vec1 = (y1 - y2, x2 - x1)
ans[t] = math.acos(
(vec0[0] * vec1[0] + vec0[1] * vec1[1]) / (norm2(vec0) * norm2(vec1))
) / (2 * math.pi)
for v in ans:
print(v)
return
def examC():
ans = 0
print(ans)
return
def examD():
S = SI()
N = len(S)
K = I()
if K > 100:
K = 100
dp = [[[0] * (K + 1) for _ in range(N)] for i in range(N)]
for i in range(N):
for j in range(K + 1):
dp[i][i][j] = 1
for i in range(2, N + 1):
for k in range(K + 1):
for l, r in enumerate(range(i - 1, N)):
if S[l] == S[r]:
dp[l][r][k] = dp[l + 1][r - 1][k] + 2
else:
if k > 0:
dp[l][r][k] = max(
dp[l + 1][r][k],
dp[l][r - 1][k],
dp[l + 1][r - 1][k - 1] + 2,
)
else:
dp[l][r][k] = max(dp[l + 1][r][k], dp[l][r - 1][k])
ans = max(dp[0][-1])
# print(dp)
print(ans)
return
def examE():
ans = 0
print(ans)
return
def examF():
ans = 0
print(ans)
return
from decimal import Decimal as dec
import sys, bisect, itertools, heapq, math, random
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I():
return int(input())
def LI():
return list(map(int, sys.stdin.readline().split()))
def DI():
return dec(input())
def LDI():
return list(map(dec, sys.stdin.readline().split()))
def LSI():
return list(map(str, sys.stdin.readline().split()))
def LS():
return sys.stdin.readline().split()
def SI():
return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10 ** (-12)
alphabet = [chr(ord("a") + i) for i in range(26)]
sys.setrecursionlimit(10**7)
if __name__ == "__main__":
examD()
"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""
| Statement
Takahashi has decided to give a string to his mother.
The _value_ of a string T is the length of the longest common subsequence of T
and T', where T' is the string obtained by reversing T. That is, the value is
the longest length of the following two strings that are equal: a subsequence
of T (possibly non-contiguous), and a subsequence of T' (possibly non-
contiguous).
Takahashi has a string S. He wants to give her mother a string of the highest
possible value, so he would like to change at most K characters in S to any
other characters in order to obtain a string of the highest possible value.
Find the highest possible value achievable. | [{"input": "abcabcabc\n 1", "output": "7\n \n\nChanging the first character to `c` results in `cbcabcabc`. Let this tring be\nT, then one longest common subsequence of T and T' is `cbabcbc`, whose length\nis 7.\n\n* * *"}, {"input": "atcodergrandcontest\n 3", "output": "15"}] |
Print the highest possible value achievable.
* * * | s890049244 | Wrong Answer | p03430 | Input is given from Standard Input in the following format:
S
K | import sys
readline = sys.stdin.readline
S = list(map(ord, readline().strip()))
N = len(S)
S = [None] + S + [None]
K = int(readline())
dp = [[[0] * (K + 1) for _ in range(N + 2)] for _ in range(N + 2)]
for i in range(1, N + 1):
dp[i][i][0] = 1
for i in range(1, N):
if S[i] == S[i + 1]:
dp[i][i + 1][0] = 2
elif K:
dp[i][i + 1][0] = 1
dp[i][i + 1][1] = 2
for s in range(3, N + 1):
for i in range(1, N - s + 2):
j = i + s - 1
if S[i] == S[j]:
for k in range(K + 1):
dp[i][j][k] = max(
dp[i + 1][j][k], dp[i][j - 1][k], 2 + dp[i + 1][j - 1][k]
)
else:
dp[i][j][0] = max(dp[i + 1][j][0], dp[i][j - 1][0], dp[i + 1][j - 1][0])
for k in range(1, K + 1):
dp[i][j][k] = max(
dp[i + 1][j][k],
dp[i][j - 1][k],
dp[i + 1][j - 1][k],
2 + dp[i + 1][j - 1][k - 1],
dp[i + 1][j - 1][k],
)
print(max(dp[1][N][k] for k in range(K + 1)))
| Statement
Takahashi has decided to give a string to his mother.
The _value_ of a string T is the length of the longest common subsequence of T
and T', where T' is the string obtained by reversing T. That is, the value is
the longest length of the following two strings that are equal: a subsequence
of T (possibly non-contiguous), and a subsequence of T' (possibly non-
contiguous).
Takahashi has a string S. He wants to give her mother a string of the highest
possible value, so he would like to change at most K characters in S to any
other characters in order to obtain a string of the highest possible value.
Find the highest possible value achievable. | [{"input": "abcabcabc\n 1", "output": "7\n \n\nChanging the first character to `c` results in `cbcabcabc`. Let this tring be\nT, then one longest common subsequence of T and T' is `cbabcbc`, whose length\nis 7.\n\n* * *"}, {"input": "atcodergrandcontest\n 3", "output": "15"}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s662185850 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | import numpy as np
# initialization
nmatch = np.array([0, 2, 5, 5, 4, 5, 6, 3, 7, 6])
N, M = map(int, input().split())
dp = [-1] * (N + 1) # contains the number of digits it can make
dp[0] = 0
ff = np.array(list(map(int, input().split()))).reshape(-1, 1)
fg = nmatch[ff].reshape(-1, 1)
Atemp = np.concatenate([ff, fg], axis=1)
index0 = np.argsort(Atemp[:, 0])
index1 = np.argsort(Atemp[:, 1])
A = Atemp[index1] # sorted by the number of matches: ascending
B = Atemp[index0]
B = B[::-1] # sorted by the number: descending
for i in range(1, N + 1):
for k in range(M):
j = A[k, 1]
i_old = i - j # available matches
if (i - j) < 0:
break
if (i - j) == 0 and dp[i] == -1:
dp[i] = 1
if dp[i_old] != -1 and dp[i_old] + 1 > dp[i]:
dp[i] = dp[i_old] + 1
# print(dp)
ndigits = dp[N]
j = N
final_number = ""
for l in range(ndigits, 0, -1):
index = 0
while True:
temp_j = j - B[index, 1]
if temp_j < 0:
index += 1
continue
if dp[temp_j] + 1 == dp[j]:
final_number += str(B[index, 0])
j = temp_j
break
else:
index += 1
if index > M:
break
print(int(final_number))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s085183930 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | import copy
n, m = map(int, input().rstrip().split())
number_list = list(map(int, input().rstrip().split()))
number_list.sort()
match = [2, 5, 5, 4, 5, 6, 3, 7, 6]
new_match = []
answer = []
for i in number_list:
new_match.append(match[i - 1])
for index in range(m):
value = new_match[index]
new_match_tmp = copy.copy(new_match)
new_match_tmp.remove(value)
maximum = max(new_match_tmp)
# 商と余りを計算
quotient = int(n / value)
remainder = n % value
answer_tmp = [number_list[index]] * quotient
# 余りがあるなら余りをなくすように組み合わせを考える
if remainder != 0:
while True:
quotient -= 1
remainder += value
answer_tmp.pop(0)
if remainder in new_match:
answer_tmp.append(number_list[new_match.index(remainder)])
break
elif remainder > maximum:
try:
minimum = min(new_match_tmp)
remainder -= minimum
answer_tmp.append(number_list[new_match.index(minimum)])
except:
answer_tmp = []
break
if remainder == n:
answer_tmp = []
break
if len(answer_tmp) != 0:
answer.append(answer_tmp)
answer.sort(key=lambda x: len(x), reverse=True)
ans = reversed(answer[0])
print(*ans, sep="")
print()
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s528879942 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | n = int(input())
a_s = list(map(int, input().split()))
while True:
a_s = set(a_s)
a_s.discard(0)
a_s = list(a_s)
index = a_s.index(min(a_s))
for i in range(len(a_s)):
if i != index and min(a_s) != 0:
a_s[i] = a_s[i] % min(a_s)
if len(a_s) == 1:
break
print(sum(a_s))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s185307478 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | N, M = map(int, input().split())
A = list(map(int, input().split()))
dp = [False for i in range(N + 10)]
memo = [[] for i in range(N + 10)]
taiou = [[1, 2], [2, 5], [3, 5], [4, 4], [5, 5], [6, 6], [7, 3], [8, 7], [9, 6]]
matchi = []
for i in range(1, 10):
if i in A:
matchi.append(taiou[i - 1])
matchi = sorted(matchi, key=lambda x: -x[0])
matchi = sorted(matchi, key=lambda x: x[1])
# for i in range(1,len(matchi)):
# if matchi[i][1] == matchi[i-1][1]:
minma = matchi[0][1]
# print(matchi)
# print(minma)
# dp[0] = F
for i in range(len(matchi)):
dp[matchi[i][1]] = True
memo[matchi[i][1]].append(matchi[i][0])
for i in range(N):
for j in range(len(matchi)):
if dp[i - matchi[j][1]]:
dp[i] = True
memo[i] = memo[i] + memo[i - matchi[j][1]]
memo[i].append(matchi[j][0])
break
# print(dp)
# print(memo)
maxi = N
for i in range(N // minma, 0, -1):
if dp[N - i * minma]:
maxi = i
# print(maxi)
break
ans = sorted([matchi[0][0]] * maxi + memo[N - maxi * minma], reverse=True)
for i in range(len(ans)):
print(ans[i], sep="", end="")
print("")
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s424592444 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | import sys
sys.setrecursionlimit(999999)
dicte = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
n, m = map(int, input().split())
arr = list(map(int, input().split()))
dp = [-1 for i in range(n + 1)]
def cast(a, b):
return int(str(a) + str(b))
def solve(curn):
maxi = -1
if dp[curn] != -1:
return dp[curn]
for j in arr:
if curn - dicte[j] >= 0:
dp[curn - dicte[j]] = solve(curn - dicte[j])
if dp[curn - dicte[j]] == None:
maxi = max(j, maxi)
else:
maxi = max(cast(j, dp[curn - dicte[j]]), maxi)
if maxi == -1:
return None
return maxi
print(solve(n))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s560825991 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | """
Match Matching
提出 #4299735 を参考に作成
"""
def solve():
# 初期値の設定
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
# 丁度n本で作成できる最大桁数を格納する.
# 初期値は -inf (丁度使い切ることは不可能) としておく
dp = [-1 * float("inf")] * (N + 1)
# 動的計画法で丁度n本のマッチを使うときに作れる最大桁数を計算する
dp[0] = 0
for a in A:
if num[a] <= N:
dp[num[a]] = 1
for n in range(1, N + 1):
for a in A:
if n - num[a] >= 0:
# マッチがnum[a]本あるときにaが作れるなら,
# n - num[a]本の時よりも1桁多く作れるはず.
# これをすべてのAに対して行い、その中で最大となった桁数を求める.
dp[n] = max(dp[n], dp[n - num[a]] + 1)
# print('各本数丁度で作れる最大桁数')
# print(dp)
# 回答となる数値を算出
ans = ""
for i in range(dp[N]): # dp[N]桁の数を上位の桁から決定していく
for a in A:
# num[a]本使って数を作ったとき,
# N - num[a] 本で作れる桁数よりも N 本で作れる桁数のほうが1多い場合,
# numを作っても最終的に作れる数の桁数は変わらない.
# そのため dp[N] - 1 == dp[N - num[a]] を満たすような最大のAを作り,
# 作成する数の上位桁に使用すればよい.
# 同じ本数のマッチを使用する場合はより大きい数を採用する.
# そのためAはあらかじめ降順にソートしておく.
if dp[N] - 1 == dp[N - num[a]]:
ans += str(a)
N -= num[a]
break
# print('現在の残本数', N, '採用された数', a)
print(ans)
if __name__ == "__main__":
solve()
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s699497895 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | import bisect
f_inf = float("inf")
def cal(syurui, d, index):
if d == "e":
return syurui[index]
elif d == "w":
return syurui[index - 1]
A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
s.sort()
t = [int(input()) for i in range(B)]
t.sort()
for i in range(Q):
x = int(input())
s_index = bisect.bisect_left(s, x)
t_index = bisect.bisect_left(t, x)
if s_index == len(s) and t_index == len(t):
print(max(abs(x - s[s_index - 1]), abs(x - t[t_index - 1])))
elif s_index == len(s):
s.insert(0, -f_inf)
t.insert(0, -f_inf)
print(
min(
max(abs(x - s[s_index]), abs(x - t[t_index])),
2 * abs(x - s[s_index]) + abs(x - t[t_index + 1]),
abs(x - s[s_index]) + 2 * abs(x - t[t_index + 1]),
)
)
elif t_index == len(t):
s.insert(0, -f_inf)
t.insert(0, -f_inf)
print(
min(
max(abs(x - s[s_index]), abs(x - t[t_index])),
2 * abs(x - s[s_index + 1]) + abs(x - t[t_index]),
abs(x - s[s_index + 1]) + 2 * abs(x - t[t_index]),
)
)
else:
s.insert(0, -f_inf)
t.insert(0, -f_inf)
print(
min(
max(abs(x - s[s_index]), abs(x - t[t_index])),
max(abs(x - s[s_index + 1]), abs(x - t[t_index + 1])),
2 * abs(x - s[s_index + 1]) + abs(x - t[t_index]),
2 * abs(x - s[s_index]) + abs(x - t[t_index + 1]),
abs(x - s[s_index + 1]) + 2 * abs(x - t[t_index]),
abs(x - s[s_index]) + 2 * abs(x - t[t_index + 1]),
)
)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s968430883 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | N, M = map(int, input().split())
a_list = list(map(int, input().split()))
items = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
dp = [0] * (N + 1)
b_list = []
for a in a_list:
need = items[a]
if need <= N:
dp[need] = a
b_list.append(a)
M = len(b_list)
b_list.sort()
for i in range(N + 1):
for b in b_list:
if i - items[b] >= 0:
if dp[i - items[b]] != 0:
cnt = 0
num = dp[i - items[b]]
while num >= 1:
cnt += 1
num //= 10
tmp = max(b * (10**cnt) + dp[i - items[b]], dp[i - items[b]] * 10 + b)
dp[i] = max(tmp, dp[i])
print(dp[N])
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s961785862 | Wrong Answer | p03125 | Input is given from Standard Input in the following format:
A B | a = [int(x) for x in input().split()]
print(a[0] - a[1])
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s375183595 | Wrong Answer | p03125 | Input is given from Standard Input in the following format:
A B | N, K = list(map(int, input().split()))
print(N + K) if K % N == 0 else print(N - K)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s435527154 | Accepted | p03125 | Input is given from Standard Input in the following format:
A B | num1, num2 = [int(_) for _ in input().split()]
for i in range(num2):
if num2 % (i + 1) == 0:
if i + 1 == num1:
ans = num2 + num1
break
else:
ans = num2 - num1
print(ans)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s546114148 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | m = list(map(int, input().split()))
hp = list(map(int, input().split()))
result = 0
checkyakusuru = []
checkodd = []
checkeven = []
if hp.count(hp[0]) == m[0]:
result = hp[0]
minhp = min(hp)
for p in hp:
if p % minhp == 0:
checkyakusuru.append(1)
if checkyakusuru.count(1) == m[0]:
result = p
break
else:
if p % 2 == 0:
checkeven.append(1)
if checkeven.count(1) == m[0]:
result = 2
else:
result = 1
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s850064227 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | n, m = list(map(int, input().split()))
b = [0 for i in range(m)]
for i in range(n):
ka = list(map(int, input().split()))
k = ka[0]
a = ka[1:]
for j in range(k):
b[a[j] - 1] += 1
c = 0
for i in range(m):
if b[i] == n:
c += 1
print(c)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s934089158 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | N = int(input())
A = list(map(int, input().split()))
# 2整数の最大公約数を求める
def gcd2(x, y):
while y != 0:
x, y = y, x % y
return x
# N 整数の最大公約数を求める
# A = [A[0],...,A[N]] とする
def gcd(A):
ans = A[0]
for i in range(1, N): # range(1,N)= 1,2,...,N-1
ans = gcd2(ans, A[i])
return ans
print(gcd(A))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s168623444 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | n, m = map(int, input().split())
mt = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
a = sorted(map(int, input().split()))
dp = [""] * (n + 1)
dp[0] = "*"
for i in range(n + 1):
if not dp[i]:
continue
for j in a:
if i + mt[j] < n + 1:
dp[i + mt[j]] = str(j) + dp[i]
print("".join(sorted(dp[-1][:-1])[::-1]))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s328089821 | Wrong Answer | p03125 | Input is given from Standard Input in the following format:
A B | from sys import stdin
import sys
N, M = map(int, stdin.readline().rstrip().split())
if N == 0:
print(1)
sys.exit()
list = [set(stdin.readline().rstrip().split()[1:]) for _ in range(0, N)]
print(list)
fav = list[0]
for i in range(1, N):
fav = fav.intersection(list[i])
print(len(fav))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s539244923 | Accepted | p03125 | Input is given from Standard Input in the following format:
A B | n, k = map(int, input().split())
print(n + k if k % n == 0 else k - n)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s303596038 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
canmake = dict()
b = []
for i in a:
b.append(num[i])
if num[i] not in canmake.keys():
canmake[num[i]] = i
b.sort()
c = []
d = []
amari = n % b[0]
longest = n // b[0]
if amari == 0:
print(str(b[0]) * (n // b[0]))
# 何ケタ減らすと丁度になるか求める
for i in range(1, len(b)):
count = 0
now = amari
while True:
count += 1
now += b[0]
if count > b[i]:
break
if now % b[i] == 0:
c.append(count - now // b[i])
d.append((count, now // b[i], b[i]))
break
res = min(c)
ans = []
for i in range(c.count(res)):
an = dict()
idx = c.index(res)
an[b[0]] = longest - d[idx][0]
an[d[idx][2]] = d[idx][1]
ans.append(an)
c[idx] = -1
result = 0
for i in ans:
x = []
for i in an.keys():
x.append((canmake[i], an[i]))
x.sort(key=lambda y: y[0])
re = ""
for i in range(len(x)):
y = x.pop()
re += str(y[0]) * y[1]
ima = int(re)
if ima > result:
result = ima
if amari != 0:
print(result)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s648621306 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | n, m = map(int, input().split(" "))
ai = list(sorted(map(int, input().split(" "))))
required_maches = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
used_numbers = dict()
def evaluate(l):
if l == None:
return -9999999999999999999999999999999
if l == []:
return 0
return int("".join(reversed([str(i) for i in sorted(l)])))
min_maches = min([required_maches[x] for x in ai])
def find(matches_count_to_use):
if matches_count_to_use not in used_numbers:
if matches_count_to_use < 0:
used_numbers[matches_count_to_use] = None
elif matches_count_to_use == 0:
used_numbers[matches_count_to_use] = []
else:
candidates = list(
filter(
lambda x: find(matches_count_to_use - required_maches[x]) != None,
ai,
)
)
if len(candidates) == 0:
used_numbers[matches_count_to_use] = None
else:
number_to_use = max(
candidates,
key=lambda x: evaluate(
find(matches_count_to_use - required_maches[x]) + [x]
),
)
prev = find(matches_count_to_use - required_maches[number_to_use])
used_numbers[matches_count_to_use] = prev + [number_to_use]
return used_numbers[matches_count_to_use]
print(evaluate(find(n)))
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
If A is a divisor of B, print A + B; otherwise, print B - A.
* * * | s926481240 | Runtime Error | p03125 | Input is given from Standard Input in the following format:
A B | INF = float("inf")
n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [2, 5, 5, 4, 5, 6, 3, 7, 6]
l = [[x, cost[x - 1]] for x in a]
l = sorted(l, key=lambda x: x[1] * 10 - x[0])
r = l[0]
k = max((n - 210), 0) // r[1]
n -= r[1] * k
_max = [0] + [-INF] * n
for i in range(1, n + 1):
for x in l:
if x[1] <= i:
_max[i] = max(_max[i], _max[i - x[1]] * 10 + x[0])
ans = str(_max[n]) + str(r[0]) * k
print(ans)
| Statement
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A. | [{"input": "4 12", "output": "16\n \n\nAs 4 is a divisor of 12, 4 + 12 = 16 should be printed.\n\n* * *"}, {"input": "8 20", "output": "12\n \n\n* * *"}, {"input": "1 1", "output": "2\n \n\n1 is a divisor of 1."}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.