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 TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s674717675 | Wrong Answer | p03777 | The input is given from Standard Input in the following format:
a b | print(input()[0])
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s266440868 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | H * H = H
H * D = D
D * H = D
D * D = H
a, b = map(str, input().split())
print(a * b)
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s506476099 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b=map(str,input().split());print('DH'[a==b::2] | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s196829665 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = input.split()
print("H" if a == b else D"") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s466519818 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | if input()==input(): print('H')
else print('D') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s982118612 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = input().split()
if a = 'H':
if b = 'H':
print('H')
else:
print('D')
else:
if b = 'H':
print('D')
else:
print('H')
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s351268596 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = input().split()
if a == "H" and b == "H":
print("H")
elif a == "H" and b == "D":
print("D")
elif a == "D" and b == "H":
print("D")
else: a == "D" and b == "D":
print("H")
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s400907824 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split())
if a == H:
if b == H:
print("H")
else:
print("D")
else if a == D:
if b == H:
print("D")
else:
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s331739389 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str , input().split())
if a == "H":
if b == "H":
print("H")
else:
print("D")
elif b == "H":
print("D")
else:
print("H")
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s618979944 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split())
if a == "H" and b == "H":
print("H")
elif a == "H" and b == "D":
print("D")
elif a == "D" and b == "H":
print("D")
else: a == "D" and b == "D":
print("H")
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s185428469 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | X = int(input())
dist = [0]
prev_dist = [0]
time = 0
while not X in dist:
time += 1
for i in prev_dist:
if not i + time in dist:
dist.append(i + time)
if not i - time in dist:
dist.append(i - time)
prev_dist = dist[:]
print(time)
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s159457084 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = input().split()
if a = 'H' and b ='H':
print('H')
elif a = 'H' and b ='D':
print('D')
elif a = 'D' and b = 'H':
print('D')
elif a = 'D' and b = 'D':
print('H') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s545093034 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a = input()
t = input()
if a == "H" and t == "H":
print("H")
elif a == "H" and t == "D":
print("D")
elif a == "D" and t == "H":
print("D")
elif a == "D" and t == "D"
print("H")
else:
pass | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s202449477 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a = input()
b = input()
flag = true
if (a=='H') and (b=='H')
flag = true
if (a=='H') and (b=='D')
flag = false
if (a=='D') and (b=='H')
flag = false
if (a=='D') and (b=='d')
flag = true
print(flag?H:D) | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s927026361 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b |
if a + W < b:
print(b - a - W)
elif a + W = b:
print(0)
elif (b < a + W) & (a < b):
print(0)
elif a == b:
print(0)
elif b < a:
print(0)
elif a = b + W:
print(0)
elif b + W < a:
print(a - b - W)
else:
pass
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s543156932 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split())
if a='H' and b = 'H':
print('H')
if a='D' and b = 'H':
print('D')
if a='H' and b = 'D':
print('D')
if a='D' and b = 'D':
print('H') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s699661555 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | import itertools
N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
need = []
iranaiko = []
for a in A:
if a >= K:
need.append(a)
elif a in need:
need.append(a)
elif a in iranaiko:
pass
else:
z = 0
B = A[:]
B.remove(a)
fusoku = [K - i - 1 for i in range(a)]
for bi, b in enumerate(B):
if b >= K:
break
B = B[: bi + 1]
for i in range(1, len(B) + 1):
C = list(itertools.combinations(B, i))
for c in C:
if sum(c) in fusoku:
need.append(a)
z = 1
break
if z == 1:
break
if z == 0:
iranaiko.append(a)
print(N - len(need))
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s867325957 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split())
if a == "H" and b == "H":
print("H")
elif a== "H"and b == "D":
print("D")
elif a == "D" and b == "H":
print("D")
else;
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s970903064 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = map(int, input().split())
if a ='H' and b ='H':
print('H')
elif a ='H' and b ='D':
print('D')
elif a ='D' and b ='H':
print('D')
else:
print('H')
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s948389675 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split()
if a == "H" and b == "H":
print("H")
elif a == "H" and b == "D":
print("D")
elif a == "D" and b == "H":
print("D")
else: a == "D" and b == "D":
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s576369255 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = input().split()
if a == "H":
print(b)
else if b == "H":
print(a)
else:
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s568862813 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = input().split()
if a='H' and b='H':print('H')
elif a='D' and b='D':print('H')
else:print('D') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s559991888 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = input().split()
if a == H:
if b == H:
print("H")
else:
print("D")
else if a == D:
if b == H:
print("D")
else:
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s666671923 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b=input().split()
if a=="H":
f=True
else:
f=False
if f:
print("H" if b=="H" else "D")
else:
print("H" if b=="D" else "D" | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s920445708 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b=input().split()
if a=='H':
print('H')
else:
if b=='D'
print('H')
else:
print('D') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s578701300 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = input().split(' ')
if a == "H":
print(b)
else if b == "H":
print(a)
else:
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s365187975 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = (str(x) for x in input().split())
if a = "H":
pass
elif b = "H":
b = "D"
else:
b = "H"
print(b)
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s841822443 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b= map(str, input().split())
if a=="H":
print(b)
else:
if b = "H":
print("D")
if b = "D":
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s344219268 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split())
num = 0
if a == "D"
num = num + 1
if b == "D"
num = num + 1
if num%2 == 0:
print("H")
else:
print("D") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s525870611 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a, b = input().split()
if a == 'H':
print(b)
elif a == 'D' and b =='H'
print('D')
else:
print('H') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s401035331 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = input().split()
ans = 1
if a == "D":
ans *= -1
if b == "D":
ans *= -1
if ans = 1:
print("H")
else:
print("D") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s505242988 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b=map(str,input().split())
if a=="H" and b="H" or a=="D" and b="D":
print("H")
else:
print("D") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s407530328 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b =map(str ,input().split()))
if b=="H:
print(a):
else b=="D":
if a=="H":
print("D"):
if a=="D":
print("H")
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s055846004 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | arg = input().split(' ')
a = arg[0]
b = arg[1]'
if a=='D':
b = 'D' if b=='H' else 'H'
print(b) | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s410490156 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(int,input().split())
if (a=='H' and b == 'H')or(a == 'D'an b =='D'):
print('H')
else:
print('D') | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s950167130 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b=input().split()
if a == "H":
print("H")
else if a == "D" and b == "H":
print("D")
else:
print("H") | Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s946466783 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b = map(str,input().split(' '))
if a == 'H':
print(b)
elif a == 'D' and b == 'H':
print('D')
else
:print('H')
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s010361023 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | x = int(input())
a = 0
for i in range(1, 10**9):
if a >= x:
print(i - 1)
break
a += i
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
If TopCoDeer is honest, print `H`. If he is dishonest, print `D`.
* * * | s818648089 | Runtime Error | p03777 | The input is given from Standard Input in the following format:
a b | a,b =map(str,input().split())
if b=="H:
print(a)
else b=="D":
if a=="H":
print("D")
if a=="D":
print("H")
| Statement
Two deer, AtCoDeer and TopCoDeer, are playing a game called _Honest or
Dishonest_. In this game, an honest player always tells the truth, and an
dishonest player always tell lies. You are given two characters a and b as the
input. Each of them is either `H` or `D`, and carries the following
information:
If a=`H`, AtCoDeer is honest; if a=`D`, AtCoDeer is dishonest. If b=`H`,
AtCoDeer is saying that TopCoDeer is honest; if b=`D`, AtCoDeer is saying that
TopCoDeer is dishonest.
Given this information, determine whether TopCoDeer is honest. | [{"input": "H H", "output": "H\n \n\nIn this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.\n\n* * *"}, {"input": "D H", "output": "D\n \n\nIn this input, AtCoDeer is dishonest. Hence, contrary to what he says,\nTopCoDeer is dishonest.\n\n* * *"}, {"input": "D D", "output": "H"}] |
Print the answer.
* * * | s526299994 | Accepted | p02865 | Input is given from Standard Input in the following format:
N | p, q = divmod(int(input()), 2)
print(p - (q ^ 1))
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s816571872 | Runtime Error | p02865 | Input is given from Standard Input in the following format:
N | num1 = input()
num2 = input()
sum = int(num1) + int(num2)
print(sum)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s082079712 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | N = input()
if (int(N) % 2) == 0:
print(int(int(N) / 2))
else:
print(int((int(N) - 1) / 2))
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s305764561 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | a = (int)(input())
print(a // 2)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s732112576 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | def add(x, y):
sum = x + y
return sum
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s591831875 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | s = int(input())
print(((s + 1) / 2) - 1)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s814032894 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | print(int(input()) // 2 - 0.5)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s886851993 | Runtime Error | p02865 | Input is given from Standard Input in the following format:
N | import sys
readline = sys.stdin.readline
from itertools import accumulate
from collections import Counter
from bisect import bisect as br, bisect_left as bl
class PMS:
# 1-indexed
def __init__(self, A, B, issum=False):
# Aに初期状態の要素をすべて入れる,Bは値域のリスト
self.X, self.comp = self.compress(B)
self.size = len(self.X)
self.tree = [0] * (self.size + 1)
self.p = 2 ** (self.size.bit_length() - 1)
self.dep = self.size.bit_length()
CA = Counter(A)
S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)]))
for i in range(1, 1 + self.size):
self.tree[i] = S[i] - S[i - (i & -i)]
if issum:
self.sumtree = [0] * (self.size + 1)
Ssum = [0] + list(
accumulate([CA[self.X[i]] * self.X[i] for i in range(self.size)])
)
for i in range(1, 1 + self.size):
self.sumtree[i] = Ssum[i] - Ssum[i - (i & -i)]
def compress(self, L):
# 座圧
L2 = list(set(L))
L2.sort()
C = {v: k for k, v in enumerate(L2, 1)}
# 1-indexed
return L2, C
def leng(self):
# 今入っている個数を取得
return self.count(self.X[-1])
def count(self, v):
# v(Bの元)以下の個数を取得
i = self.comp[v]
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def less(self, v):
# v(Bの元である必要はない)未満の個数を取得
i = bl(self.X, v)
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def leq(self, v):
# v(Bの元である必要はない)以下の個数を取得
i = br(self.X, v)
s = 0
while i > 0:
s += self.tree[i]
i -= i & -i
return s
def add(self, v, x):
# vをx個入れる,負のxで取り出す,iの個数以上取り出すとエラーを出さずにバグる
i = self.comp[v]
while i <= self.size:
self.tree[i] += x
i += i & -i
def get(self, i):
# i番目の値を取得
if i <= 0:
return -1
s = 0
k = self.p
for _ in range(self.dep):
if s + k <= self.size and self.tree[s + k] < i:
s += k
i -= self.tree[s]
k //= 2
return self.X[s]
def gets(self, v):
# 累積和がv以下となる最大のindexを返す
v1 = v
s = 0
k = self.p
for _ in range(self.dep):
if s + k <= self.size and self.sumtree[s + k] < v:
s += k
v -= self.sumtree[s]
k //= 2
if s == self.size:
return self.leng()
return self.count(self.X[s]) + (v1 - self.countsum(self.X[s])) // self.X[s]
def addsum(self, i, x):
# sumを扱いたいときにaddの代わりに使う
self.add(i, x)
x *= i
i = self.comp[i]
while i <= self.size:
self.sumtree[i] += x
i += i & -i
def countsum(self, v):
# v(Bの元)以下のsumを取得
i = self.comp[v]
s = 0
while i > 0:
s += self.sumtree[i]
i -= i & -i
return s
def getsum(self, i):
# i番目までのsumを取得
x = self.get(i)
return self.countsum(x) - x * (self.count(x) - i)
N, K = map(int, readline().split())
C = list(range(K + 2 * N, K + 3 * N))
A = list(range(K, K + N))
B = list(range(K + N, K + 2 * N))
Ans = []
ans = 1
BB = PMS(B, B)
if sum(A) + sum(B) > sum(C):
ans = -1
else:
Ao = [A[i] for i in range(N) if A[i] % 2]
Ae = [A[i] for i in range(N) if not A[i] % 2]
if len(Ao) < len(Ae):
AA = Ae + Ao
else:
AA = Ao + Ae
for a, c in zip(AA, C):
bx = c - a
k = BB.leq(bx)
if k == 0:
ans = -1
break
b = BB.get(k)
Ans.append((a, b, c))
BB.add(b, -1)
if ans != -1:
print("\n".join("{} {} {}".format(*an) for an in Ans))
else:
print(ans)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s935943294 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | n = int(input())
a, b = divmod(n, 2)
if b == 0:
a += 1
print(a)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s372683585 | Accepted | p02865 | Input is given from Standard Input in the following format:
N | print(0 - -int(input()) // 2 - 1)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s351406053 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | print(round(int(input()) / 2) - 1)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s990703004 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | N = int(input()) - 1
print(N // 2 - N % 2)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s574414848 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | int = int(input())
print(int * (int - 1) / 2 + int)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s083368030 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | print(int(input()) // 2)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s230860439 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | int(input()) // 2
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s808840047 | Runtime Error | p02865 | Input is given from Standard Input in the following format:
N | print(round(input() / 2) - 1)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s373610105 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | print(round((int(input()) - 1) / 2))
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s876898902 | Wrong Answer | p02865 | Input is given from Standard Input in the following format:
N | num = int(input())
print((num - 1) % 2)
exit(0)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the answer.
* * * | s223765023 | Runtime Error | p02865 | Input is given from Standard Input in the following format:
N | N = int(input)
print(N // 2)
| Statement
How many ways are there to choose two distinct positive integers totaling N,
disregarding the order? | [{"input": "4", "output": "1\n \n\nThere is only one way to choose two distinct integers totaling 4: to choose 1\nand 3. (Choosing 3 and 1 is not considered different from this.)\n\n* * *"}, {"input": "999999", "output": "499999"}] |
Print the number of the possible orders in which they were standing, modulo
10^9+7.
* * * | s692676437 | Runtime Error | p03848 | The input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | N=int(input())
A=list(map(int,input().split()))
if N%2==0:
for i in range (N):
A[i]%2!=1:
print(0)
exit()
print((2**N)%(10**9+7))
else:
for i in range (N):
A[i]%2!=0:
print(0)
exit()
if min(A)!=0:
print(0)
exit()
else:
print((2**(N-1))%(10**9+7)) | Statement
There are N people, conveniently numbered 1 through N. They were standing in a
row yesterday, but now they are unsure of the order in which they were
standing. However, each person remembered the following fact: the absolute
difference of the number of the people who were standing to the left of that
person, and the number of the people who were standing to the right of that
person. According to their reports, the difference above for person i is A_i.
Based on these reports, find the number of the possible orders in which they
were standing. Since it can be extremely large, print the answer modulo
10^9+7. Note that the reports may be incorrect and thus there may be no
consistent order. In such a case, print 0. | [{"input": "5\n 2 4 4 0 2", "output": "4\n \n\nThere are four possible orders, as follows:\n\n * 2,1,4,5,3\n * 2,5,4,1,3\n * 3,1,4,5,2\n * 3,5,4,1,2\n\n* * *"}, {"input": "7\n 6 4 0 2 4 0 2", "output": "0\n \n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\n* * *"}, {"input": "8\n 7 5 1 1 7 3 5 3", "output": "16"}] |
Print the number of the possible orders in which they were standing, modulo
10^9+7.
* * * | s039549768 | Runtime Error | p03848 | The input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
m[i]+=1
ans=1
for i in range(n-1,0,-2):
d[i]!=2:
ans=0
if d[0]!=n%2:
ans=0
if ans:
print(2**(n//2)%1000000007)
else:
print(0)
| Statement
There are N people, conveniently numbered 1 through N. They were standing in a
row yesterday, but now they are unsure of the order in which they were
standing. However, each person remembered the following fact: the absolute
difference of the number of the people who were standing to the left of that
person, and the number of the people who were standing to the right of that
person. According to their reports, the difference above for person i is A_i.
Based on these reports, find the number of the possible orders in which they
were standing. Since it can be extremely large, print the answer modulo
10^9+7. Note that the reports may be incorrect and thus there may be no
consistent order. In such a case, print 0. | [{"input": "5\n 2 4 4 0 2", "output": "4\n \n\nThere are four possible orders, as follows:\n\n * 2,1,4,5,3\n * 2,5,4,1,3\n * 3,1,4,5,2\n * 3,5,4,1,2\n\n* * *"}, {"input": "7\n 6 4 0 2 4 0 2", "output": "0\n \n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\n* * *"}, {"input": "8\n 7 5 1 1 7 3 5 3", "output": "16"}] |
Print the number of the possible orders in which they were standing, modulo
10^9+7.
* * * | s447930208 | Runtime Error | p03848 | The input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)
ll pw(ll n,ll m){
if(m==0) return 1;
else if(m%2==0) return pw(n*n,m/2);
else return n*pw(n,m-1);
}
int main(){
ll n,a[100010];
cin>>n;
fr(i,n) cin>>a[i];
sort(a,a+n);
for(int i=n-1;i>=0;i-=2) a[i]++;
bool f=1;
fr(i,n) if(a[i]!=i+1) f=0;
cout<<(f?pw(2,n/2):0)<<endl;
} | Statement
There are N people, conveniently numbered 1 through N. They were standing in a
row yesterday, but now they are unsure of the order in which they were
standing. However, each person remembered the following fact: the absolute
difference of the number of the people who were standing to the left of that
person, and the number of the people who were standing to the right of that
person. According to their reports, the difference above for person i is A_i.
Based on these reports, find the number of the possible orders in which they
were standing. Since it can be extremely large, print the answer modulo
10^9+7. Note that the reports may be incorrect and thus there may be no
consistent order. In such a case, print 0. | [{"input": "5\n 2 4 4 0 2", "output": "4\n \n\nThere are four possible orders, as follows:\n\n * 2,1,4,5,3\n * 2,5,4,1,3\n * 3,1,4,5,2\n * 3,5,4,1,2\n\n* * *"}, {"input": "7\n 6 4 0 2 4 0 2", "output": "0\n \n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\n* * *"}, {"input": "8\n 7 5 1 1 7 3 5 3", "output": "16"}] |
Print the number of the possible orders in which they were standing, modulo
10^9+7.
* * * | s692610192 | Runtime Error | p03848 | The input is given from Standard Input in the following format:
N
A_1 A_2 ... A_N | from collections import Counter
n = int(input())
a = list(map(int, input().split()))
h = Counter()
for x in a:
h[x] += 1
f = True
for k, v in h..most_common():
if n % 2 == 1 and k == 0:
if v != 1:
f = False
break
elif v != 2:
f = False
break
MOD = 1000000007
def mpow(n, p, mod):
r = 1
while p > 0:
if p & 1 == 1:
r = r * n % mod
n = n * n % mod
p >>= 1
return r
print(mpow(2, int(n / 2), MOD) if f else 0) | Statement
There are N people, conveniently numbered 1 through N. They were standing in a
row yesterday, but now they are unsure of the order in which they were
standing. However, each person remembered the following fact: the absolute
difference of the number of the people who were standing to the left of that
person, and the number of the people who were standing to the right of that
person. According to their reports, the difference above for person i is A_i.
Based on these reports, find the number of the possible orders in which they
were standing. Since it can be extremely large, print the answer modulo
10^9+7. Note that the reports may be incorrect and thus there may be no
consistent order. In such a case, print 0. | [{"input": "5\n 2 4 4 0 2", "output": "4\n \n\nThere are four possible orders, as follows:\n\n * 2,1,4,5,3\n * 2,5,4,1,3\n * 3,1,4,5,2\n * 3,5,4,1,2\n\n* * *"}, {"input": "7\n 6 4 0 2 4 0 2", "output": "0\n \n\nAny order would be inconsistent with the reports, thus the answer is 0.\n\n* * *"}, {"input": "8\n 7 5 1 1 7 3 5 3", "output": "16"}] |
For each dataset, print in a line two numbers describing the height and width,
namely _h_ and _w_ (> _h_), of the smallest wide integral rectangle bigger
than the one described in the dataset. Put a space between the numbers. No
other characters are allowed in the output.
For any wide integral rectangle given in the input, the width and height of
the smallest wide integral rectangle bigger than the given one are both known
to be not greater than 150.
In addition, although the ordering of wide integral rectangles uses the
comparison of lengths of diagonal lines, this comparison can be replaced with
that of squares (self-products) of lengths of diagonal lines, which can avoid
unnecessary troubles possibly caused by the use of floating-point numbers. | s237594187 | Wrong Answer | p00767 | The entire input consists of multiple datasets. The number of datasets is no
more than 100. Each dataset describes a wide integral rectangle by specifying
its height and width, namely _h_ and _w_ , separated by a space in a line, as
follows.
> _h_ _w_
For each dataset, _h_ and _w_ (>_h_) are both integers greater than 0 and no
more than 100.
The end of the input is indicated by a line of two zeros separated by a space. | while True:
h, w = map(int, input().split())
if not h:
break
diagonal = h**2 + w**2
ans = []
append = ans.append
for y in range(1, 151):
for x in range(y + 1, 151):
if x**2 + y**2 > diagonal:
append((x**2 + y**2, y, x))
break
print(*sorted(ans)[0][1:])
| Integral Rectangles
Let us consider rectangles whose height, _h_ , and width, _w_ , are both
integers. We call such rectangles _integral rectangles_. In this problem, we
consider only wide integral rectangles, i.e., those with _w_ > _h_.
We define the following ordering of wide integral rectangles. Given two wide
integral rectangles,
1. The one shorter in its diagonal line is smaller, and
2. If the two have diagonal lines with the same length, the one shorter in its height is smaller.

Given a wide integral rectangle, find the smallest wide integral rectangle
bigger than the given one. | [{"input": "2\n 1 3\n 2 3\n 1 4\n 2 4\n 5 6\n 1 8\n 4 7\n 98 100\n 99 100\n 0 0", "output": "3\n 2 3\n 1 4\n 2 4\n 3 4\n 1 8\n 4 7\n 2 8\n 3 140\n 89 109"}] |
For each dataset, print in a line two numbers describing the height and width,
namely _h_ and _w_ (> _h_), of the smallest wide integral rectangle bigger
than the one described in the dataset. Put a space between the numbers. No
other characters are allowed in the output.
For any wide integral rectangle given in the input, the width and height of
the smallest wide integral rectangle bigger than the given one are both known
to be not greater than 150.
In addition, although the ordering of wide integral rectangles uses the
comparison of lengths of diagonal lines, this comparison can be replaced with
that of squares (self-products) of lengths of diagonal lines, which can avoid
unnecessary troubles possibly caused by the use of floating-point numbers. | s589810145 | Accepted | p00767 | The entire input consists of multiple datasets. The number of datasets is no
more than 100. Each dataset describes a wide integral rectangle by specifying
its height and width, namely _h_ and _w_ , separated by a space in a line, as
follows.
> _h_ _w_
For each dataset, _h_ and _w_ (>_h_) are both integers greater than 0 and no
more than 100.
The end of the input is indicated by a line of two zeros separated by a space. | t = [(i * i + j * j, (i, j)) for i in range(1, 151) for j in range(i + 1, 151)]
t.sort()
d = {a[1]: b[1] for a, b in zip(t, t[1:])}
res = []
for e in iter(input, "0 0"):
h, w = map(int, e.split())
ans = d[h, w]
res.append(" ".join(map(str, ans)))
print("\n".join(map(str, res)))
| Integral Rectangles
Let us consider rectangles whose height, _h_ , and width, _w_ , are both
integers. We call such rectangles _integral rectangles_. In this problem, we
consider only wide integral rectangles, i.e., those with _w_ > _h_.
We define the following ordering of wide integral rectangles. Given two wide
integral rectangles,
1. The one shorter in its diagonal line is smaller, and
2. If the two have diagonal lines with the same length, the one shorter in its height is smaller.

Given a wide integral rectangle, find the smallest wide integral rectangle
bigger than the given one. | [{"input": "2\n 1 3\n 2 3\n 1 4\n 2 4\n 5 6\n 1 8\n 4 7\n 98 100\n 99 100\n 0 0", "output": "3\n 2 3\n 1 4\n 2 4\n 3 4\n 1 8\n 4 7\n 2 8\n 3 140\n 89 109"}] |
For each dataset, print in a line two numbers describing the height and width,
namely _h_ and _w_ (> _h_), of the smallest wide integral rectangle bigger
than the one described in the dataset. Put a space between the numbers. No
other characters are allowed in the output.
For any wide integral rectangle given in the input, the width and height of
the smallest wide integral rectangle bigger than the given one are both known
to be not greater than 150.
In addition, although the ordering of wide integral rectangles uses the
comparison of lengths of diagonal lines, this comparison can be replaced with
that of squares (self-products) of lengths of diagonal lines, which can avoid
unnecessary troubles possibly caused by the use of floating-point numbers. | s965682557 | Accepted | p00767 | The entire input consists of multiple datasets. The number of datasets is no
more than 100. Each dataset describes a wide integral rectangle by specifying
its height and width, namely _h_ and _w_ , separated by a space in a line, as
follows.
> _h_ _w_
For each dataset, _h_ and _w_ (>_h_) are both integers greater than 0 and no
more than 100.
The end of the input is indicated by a line of two zeros separated by a space. | a_list = []
for i in range(1, 151):
for j in range(1, 151):
tmp_list = []
tmp_list.append(i**2 + j**2)
tmp_list.append(i)
tmp_list.append(j)
a_list.append(tmp_list)
a_list.sort()
while True:
n = input()
n = n.split()
h = int(n[0])
w = int(n[1])
flag = 0
if h == 0 and w == 0:
break
a = h**2 + w**2
for i in range(len(a_list)):
if a == a_list[i][0] and flag == 0:
if h < a_list[i][1] and a_list[i][1] < a_list[i][2]:
print(str(a_list[i][1]) + " " + str(a_list[i][2]))
flag = 1
elif a < a_list[i][0] and flag == 0:
if a_list[i][1] < a_list[i][2]:
print(str(a_list[i][1]) + " " + str(a_list[i][2]))
flag = 1
| Integral Rectangles
Let us consider rectangles whose height, _h_ , and width, _w_ , are both
integers. We call such rectangles _integral rectangles_. In this problem, we
consider only wide integral rectangles, i.e., those with _w_ > _h_.
We define the following ordering of wide integral rectangles. Given two wide
integral rectangles,
1. The one shorter in its diagonal line is smaller, and
2. If the two have diagonal lines with the same length, the one shorter in its height is smaller.

Given a wide integral rectangle, find the smallest wide integral rectangle
bigger than the given one. | [{"input": "2\n 1 3\n 2 3\n 1 4\n 2 4\n 5 6\n 1 8\n 4 7\n 98 100\n 99 100\n 0 0", "output": "3\n 2 3\n 1 4\n 2 4\n 3 4\n 1 8\n 4 7\n 2 8\n 3 140\n 89 109"}] |
For each dataset, print in a line two numbers describing the height and width,
namely _h_ and _w_ (> _h_), of the smallest wide integral rectangle bigger
than the one described in the dataset. Put a space between the numbers. No
other characters are allowed in the output.
For any wide integral rectangle given in the input, the width and height of
the smallest wide integral rectangle bigger than the given one are both known
to be not greater than 150.
In addition, although the ordering of wide integral rectangles uses the
comparison of lengths of diagonal lines, this comparison can be replaced with
that of squares (self-products) of lengths of diagonal lines, which can avoid
unnecessary troubles possibly caused by the use of floating-point numbers. | s909261058 | Wrong Answer | p00767 | The entire input consists of multiple datasets. The number of datasets is no
more than 100. Each dataset describes a wide integral rectangle by specifying
its height and width, namely _h_ and _w_ , separated by a space in a line, as
follows.
> _h_ _w_
For each dataset, _h_ and _w_ (>_h_) are both integers greater than 0 and no
more than 100.
The end of the input is indicated by a line of two zeros separated by a space. | while True:
H, W = map(int, input().split())
if H == 0:
break
d0 = H * H + W * W
ans_d = ans_h = ans_w = 10**9
for w in range(2, 151):
for h in range(1, w):
d = h * h + w * w
if d <= d0:
continue
if d <= ans_d:
ans_h = h
ans_w = w
if d < ans_d:
ans_d = d
break
print("{0} {1}".format(ans_h, ans_w))
| Integral Rectangles
Let us consider rectangles whose height, _h_ , and width, _w_ , are both
integers. We call such rectangles _integral rectangles_. In this problem, we
consider only wide integral rectangles, i.e., those with _w_ > _h_.
We define the following ordering of wide integral rectangles. Given two wide
integral rectangles,
1. The one shorter in its diagonal line is smaller, and
2. If the two have diagonal lines with the same length, the one shorter in its height is smaller.

Given a wide integral rectangle, find the smallest wide integral rectangle
bigger than the given one. | [{"input": "2\n 1 3\n 2 3\n 1 4\n 2 4\n 5 6\n 1 8\n 4 7\n 98 100\n 99 100\n 0 0", "output": "3\n 2 3\n 1 4\n 2 4\n 3 4\n 1 8\n 4 7\n 2 8\n 3 140\n 89 109"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s707426684 | Wrong Answer | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | import sys
from math import factorial
def main():
packages, remainder = receiveInputData()
packages.countOddAndEven()
even_ways = packages.calculateEvenWays()
odd_ways_remainder0, odd_ways_remainder1 = packages.calculateOddWays()
if remainder.isZero():
print(even_ways * odd_ways_remainder0)
return
print(even_ways * odd_ways_remainder1)
class Package:
def __init__(self, packages_list, packages_num):
if not isinstance(packages_list, list):
print("Package Class argument error")
sys.exit(1)
# 問題の制約では、1以上50以下である
if packages_num < 1 or packages_num > 50:
print("Package Class Restriction error")
print(packages_num)
sys.exit(1)
self.packages = packages_list
self.packages_num = packages_num
# 中に入っているビスケットの数が偶数の袋、奇数の袋それぞれ数える
def countOddAndEven(self):
self.packages_num_of_odd_biscuits = 0
self.packages_num_of_even_biscuits = 0
for pack_i, biscuits_num in enumerate(self.packages):
if biscuits_num % 2 == 0:
self.packages_num_of_even_biscuits += 1
else:
self.packages_num_of_odd_biscuits += 1
print(self.packages_num_of_odd_biscuits)
# 偶数個含まれる袋の選び方は何通りかを返す
# 袋ごとに 食べる 食べない の2通りなので
# m袋あれば 2^m通り
def calculateEvenWays(self):
return 2**self.packages_num_of_even_biscuits
def calculateOddWays(self):
count_combination_list = self.calculateCombination(
self.packages_num_of_odd_biscuits
)
# あまりPが0の場合
# 奇数個含まれる袋は、偶数個選ばなければならない
selected_even_odds = sum(count_combination_list[::2])
# あまりPが1の場合
# 奇数個含まれる袋は、奇数個選ばなければならない
selected_odd_odds = sum(count_combination_list[1::2])
return selected_even_odds, selected_odd_odds
def calculateCombination(self, n):
# i番目にはnCi
select_ways_of_odd = [1]
for select_num in range(1, n + 1):
n_C_i = factorial(n) // (factorial(select_num) * factorial(n - select_num))
select_ways_of_odd.append(n_C_i)
return select_ways_of_odd
class Remainder:
def __init__(self, remainder_0or1):
if not isinstance(remainder_0or1, int):
print("Remainder Class argument error")
sys.exit(1)
# 問題の制約では、0か1
if remainder_0or1 != 0 and remainder_0or1 != 1:
print("Remainder Class Restriction error")
sys.exit(1)
self.remainder = remainder_0or1
def isZero(self):
if self.remainder == 0:
return True
return False
def receiveInputData():
N, P = map(int, input().split())
A = list(map(int, input().split()))
return Package(A, N), Remainder(P)
if __name__ == "__main__":
main()
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s058528207 | Accepted | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | # -*- coding: utf-8 -*-
#############
# Libraries #
#############
import sys
input = sys.stdin.readline
import math
# from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache
#############
# Constants #
#############
MOD = 10**9 + 7
INF = float("inf")
#############
# Functions #
#############
######INPUT######
def I():
return int(input().strip())
def S():
return input().strip()
def IL():
return list(map(int, input().split()))
def SL():
return list(map(str, input().split()))
def ILs(n):
return list(int(input()) for _ in range(n))
def SLs(n):
return list(input().strip() for _ in range(n))
def ILL(n):
return [list(map(int, input().split())) for _ in range(n)]
def SLL(n):
return [list(map(str, input().split())) for _ in range(n)]
######OUTPUT######
def P(arg):
print(arg)
return
def Y():
print("Yes")
return
def N():
print("No")
return
def E():
exit()
def PE(arg):
print(arg)
exit()
def YE():
print("Yes")
exit()
def NE():
print("No")
exit()
#####Shorten#####
def DD(arg):
return defaultdict(arg)
#####Inverse#####
def inv(n):
return pow(n, MOD - 2, MOD)
######Combination######
kaijo_memo = []
def kaijo(n):
if len(kaijo_memo) > n:
return kaijo_memo[n]
if len(kaijo_memo) == 0:
kaijo_memo.append(1)
while len(kaijo_memo) <= n:
kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
return kaijo_memo[n]
gyaku_kaijo_memo = []
def gyaku_kaijo(n):
if len(gyaku_kaijo_memo) > n:
return gyaku_kaijo_memo[n]
if len(gyaku_kaijo_memo) == 0:
gyaku_kaijo_memo.append(1)
while len(gyaku_kaijo_memo) <= n:
gyaku_kaijo_memo.append(
gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo), MOD - 2, MOD) % MOD
)
return gyaku_kaijo_memo[n]
def nCr(n, r):
if n == r:
return 1
if n < r or r < 0:
return 0
ret = 1
ret = ret * kaijo(n) % MOD
ret = ret * gyaku_kaijo(r) % MOD
ret = ret * gyaku_kaijo(n - r) % MOD
return ret
######Factorization######
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-(n**0.5) // 1)) + 1):
if temp % i == 0:
cnt = 0
while temp % i == 0:
cnt += 1
temp //= i
arr.append([i, cnt])
if temp != 1:
arr.append([temp, 1])
if arr == []:
arr.append([n, 1])
return arr
#####MakeDivisors######
def make_divisors(n):
divisors = []
for i in range(1, int(n**0.5) + 1):
if n % i == 0:
divisors.append(i)
if i != n // i:
divisors.append(n // i)
return divisors
#####MakePrimes######
def make_primes(N):
max = int(math.sqrt(N))
seachList = [i for i in range(2, N + 1)]
primeNum = []
while seachList[0] <= max:
primeNum.append(seachList[0])
tmp = seachList[0]
seachList = [i for i in seachList if i % tmp != 0]
primeNum.extend(seachList)
return primeNum
#####GCD#####
def gcd(a, b):
while b:
a, b = b, a % b
return a
#####LCM#####
def lcm(a, b):
return a * b // gcd(a, b)
#####BitCount#####
def count_bit(n):
count = 0
while n:
n &= n - 1
count += 1
return count
#####ChangeBase#####
def base_10_to_n(X, n):
if X // n:
return base_10_to_n(X // n, n) + [X % n]
return [X % n]
def base_n_to_10(X, n):
return sum(int(str(X)[-i - 1]) * n**i for i in range(len(str(X))))
#####IntLog#####
def int_log(n, a):
count = 0
while n >= a:
n //= a
count += 1
return count
#############
# Main Code #
#############
N, P = IL()
A = IL()
A = [a % 2 for a in A]
dic = Counter(A)
if P == 0:
A = dic[0]
B = dic[1]
temp = 0
for i in range(B + 1)[::2]:
temp += nCr(B, i)
print(temp * pow(2, A))
else:
A = dic[0]
B = dic[1]
temp = 0
for i in range(B + 1)[1::2]:
temp += nCr(B, i)
print(temp * pow(2, A))
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s251188687 | Accepted | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)
# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)
def nck(n, k, kaijyo):
return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
def npk(n, k, kaijyo):
if k == 0 or k == n:
return n % MOD
return (kaijyo[n] * divide(kaijyo[n - k])) % MOD
def fact_and_inv(SIZE):
inv = [0] * SIZE # inv[j] = j^{-1} mod MOD
fac = [0] * SIZE # fac[j] = j! mod MOD
finv = [0] * SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2, SIZE):
inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
fac[i] = fac[i - 1] * i % MOD
finv[i] = finv[i - 1] * inv[i] % MOD
return fac, finv
def renritsu(A, Y):
# example 2x + y = 3, x + 3y = 4
# A = [[2,1], [1,3]])
# Y = [[3],[4]] または [3,4]
A = np.matrix(A)
Y = np.matrix(Y)
Y = np.reshape(Y, (-1, 1))
X = np.linalg.solve(A, Y)
# [1.0, 1.0]
return X.flatten().tolist()[0]
class TwoDimGrid:
# 2次元座標 -> 1次元
def __init__(self, h, w, wall="#"):
self.h = h
self.w = w
self.size = (h + 2) * (w + 2)
self.wall = wall
self.get_grid()
# self.init_cost()
def get_grid(self):
grid = [self.wall * (self.w + 2)]
for i in range(self.h):
grid.append(self.wall + getS() + self.wall)
grid.append(self.wall * (self.w + 2))
self.grid = grid
def init_cost(self):
self.cost = [INF] * self.size
def pos(self, x, y):
# 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
return y * (self.w + 2) + x
def getgrid(self, x, y):
return self.grid[y][x]
def get(self, x, y):
return self.cost[self.pos(x, y)]
def set(self, x, y, v):
self.cost[self.pos(x, y)] = v
return
def show(self):
for i in range(self.h + 2):
print(self.cost[(self.w + 2) * i : (self.w + 2) * (i + 1)])
def showsome(self, tgt):
for t in tgt:
print(t)
return
def showsomejoin(self, tgt):
for t in tgt:
print("".join(t))
return
def search(self):
grid = self.grid
move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
move_eight = [
(0, 1),
(0, -1),
(1, 0),
(-1, 0),
(1, 1),
(1, -1),
(-1, 1),
(-1, -1),
]
# for i in range(1, self.h+1):
# for j in range(1, self.w+1):
# cx, cy = j, i
# for dx, dy in move_eight:
# nx, ny = dx + cx, dy + cy
def judge(mid, cnt, n):
xx = cnt[0]
if ((mid + 1) * (xx - 1)) >= n:
return False
elif (mid + 1) * xx <= n:
return True
yoyu = n % (mid + 1)
if Counter(cnt)[xx] <= yoyu:
return True
else:
return False
def solve():
n, k = getList()
nums = getList()
for num in nums:
if num % 2 == 1:
print(pow(2, n - 1))
return
if k == 0:
print(pow(2, n))
else:
print(0)
def main():
n = getN()
for _ in range(n):
solve()
return
if __name__ == "__main__":
# main()
solve()
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s516996064 | Accepted | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | # https://atcoder.jp/contests/agc017/tasks/agc017_a
# dpっぽくね?
"""
dp[i][p] ... 袋の選び方の通りの総数 [0,i)まで見たとき、余りがpになる場合
if A[i]が偶数
選ぶときの通りの数
dp[i+1][0] += dp[i][0]*2
dp[i+1][1] += dp[i][1]*2
∵偶+偶→偶、奇+偶→奇 でもともとの通りの数に影響を与えない
if A[i]が奇数
dp[i+1][0] += dp[i][1]+dp[i][0]
dp[i+1][1] += dp[i][0]+dp[i][1]
∵偶+奇→奇、奇+奇→偶 で遷移するので選ぶときと選ばないときで遷移先が異なる
"""
N, P = map(int, input().split())
A = list(map(int, input().split()))
dp0 = 1
dp1 = 0
for a in A:
if a & 1:
new0 = dp0 + dp1
new1 = new0
else:
new0 = dp0 * 2
new1 = dp1 * 2
dp0 = new0
dp1 = new1
print(dp1 if P & 1 else dp0)
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s041727966 | Runtime Error | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = 0
for a in A:
if a % 2 != 0:
odd += 1
if odd == 0
if P == 1:
res = 0
else:
res = 2 ** N
else:
res = 2 ** (N - 1)
print(res) | Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s634063879 | Runtime Error | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | N, A, B, C, D = map(int, input().split())
if N > 30 and D > 1:
flag = 10**9
else:
flag = pow(D, N - 1)
B -= A
if N % 2 == 1:
if (
(
B % (C + D) <= (N - 1) * (D - C) / 2
or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2
)
and B <= flag
and B >= -flag
):
print("YES")
else:
print("NO")
else:
if (
abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2
and B <= flag
and B >= -flag
):
print("YES")
else:
print("NO")
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s009966845 | Wrong Answer | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | n, r = map(int, input().split())
c = [i % 2 for i in list(map(int, input().split()))]
p = sum(c)
print((2 ** (n - 1)) if p == 0 else (0 if r != 1 else 2**n))
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s922150993 | Runtime Error | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | def main():
N, P = map(int, input().split())
*A, = map(int, input().split())
editorial(N, P, A)
def editorial(N, P, A):
odds = [a for a in A if a % 2 == 1]
odd = len(odds)
even = N - odd
if odd == 0:
if P = 1:
print(0)
else:
print(2 ** N)
return
# ある奇数袋を取り除いて、残りでの組み合わせ(選ぶ選ばないの2通りがN-1)
ans = 2 ** (N - 1)
# s = 組み合わせのビスケット枚数
# P=0,s:奇数であるとき、加えるのは1通り
# P=0,s:奇数でないとき、加えないのは1通り
# P=1,s:奇数であるとき、加えないのは1通り
# P=1,s:奇数でないとき、加えるのは1通り
print(ans)
if __name__ == '__main__':
main()
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s539365411 | Runtime Error | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | n,p=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(n):
if a[i]%2==1:
c=1
break
if c=1:print(2**(n-1))
else:
if p=0:print(2**(n))
else:print(0) | Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
Print the number of ways to select bags so that the total number of biscuits
inside is congruent to P modulo 2.
* * * | s450527344 | Runtime Error | p03665 | Input is given from Standard Input in the following format:
N P
A_1 A_2 ... A_N | num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd = len([a for a in bags if (a % 2 == 1]))
if congr_factor == 0 and odd == 0:
print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
print(0)
else:
print(2 ** (num_bags-1))
| Statement
There are N bags of biscuits. The i-th bag contains A_i biscuits.
Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.
He would like to select bags so that the total number of biscuits inside is
congruent to P modulo 2. How many such ways to select bags there are? | [{"input": "2 0\n 1 3", "output": "2\n \n\nThere are two ways to select bags so that the total number of biscuits inside\nis congruent to 0 modulo 2:\n\n * Select neither bag. The total number of biscuits is 0.\n * Select both bags. The total number of biscuits is 4.\n\n* * *"}, {"input": "1 1\n 50", "output": "0\n \n\n* * *"}, {"input": "3 0\n 1 1 1", "output": "4\n \n\nTwo bags are distinguished even if they contain the same number of biscuits.\n\n* * *"}, {"input": "45 1\n 17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26", "output": "17592186044416"}] |
If there exists a tree satisfying the condition in the statement, print `Yes`;
otherwise, print `No`. Then, if such a tree exists, print the 2N-1 edges of
such a tree in the subsequent 2N-1 lines, in the following format:
a_{1} b_{1}
\vdots
a_{2N-1} b_{2N-1}
Here each pair (a_i, b_i) means that there is an edge connecting Vertex a_i
and b_i. The edges may be printed in any order.
* * * | s761588925 | Accepted | p02977 | Input is given from Standard Input in the following format:
N | n = int(input())
p = print
b = 1 << (n.bit_length() - 1)
if n == b:
p("No")
exit()
p("Yes")
p(n + 1, n + 2)
for i in range(3, n + 1, 2):
p(1, i)
p(1, i - 1)
p(i, n + i - 1)
p(i - 1, n + i)
if ~n & 1:
p(b, n)
p(n ^ 1 ^ b, n + n)
| Statement
You are given an integer N. Determine if there exists a tree with 2N vertices
numbered 1 to 2N satisfying the following condition, and show one such tree if
the answer is yes.
* Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i. | [{"input": "3", "output": "Yes\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n \n\n * The sample output represents the following graph: \n\n\n\n* * *"}, {"input": "1", "output": "No\n \n\n * There is no tree satisfying the condition."}] |
If there exists a tree satisfying the condition in the statement, print `Yes`;
otherwise, print `No`. Then, if such a tree exists, print the 2N-1 edges of
such a tree in the subsequent 2N-1 lines, in the following format:
a_{1} b_{1}
\vdots
a_{2N-1} b_{2N-1}
Here each pair (a_i, b_i) means that there is an edge connecting Vertex a_i
and b_i. The edges may be printed in any order.
* * * | s213714510 | Accepted | p02977 | Input is given from Standard Input in the following format:
N | n = int(input())
l = 1
while n > l:
l *= 2
if n == l:
print("No")
quit()
print("Yes")
for i in range((n - 1) // 2):
t = i * 2
print(1, 2 + t)
print(2 + t, 3 + t)
print(1, 3 + n + t)
print(3 + n + t, 2 + n + t)
print(3, 1 + n)
if n % 2 == 0:
print(n, (n & -n) + 1 + n)
print(2 * n, n - (n & -n))
| Statement
You are given an integer N. Determine if there exists a tree with 2N vertices
numbered 1 to 2N satisfying the following condition, and show one such tree if
the answer is yes.
* Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i. | [{"input": "3", "output": "Yes\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n \n\n * The sample output represents the following graph: \n\n\n\n* * *"}, {"input": "1", "output": "No\n \n\n * There is no tree satisfying the condition."}] |
If there exists a tree satisfying the condition in the statement, print `Yes`;
otherwise, print `No`. Then, if such a tree exists, print the 2N-1 edges of
such a tree in the subsequent 2N-1 lines, in the following format:
a_{1} b_{1}
\vdots
a_{2N-1} b_{2N-1}
Here each pair (a_i, b_i) means that there is an edge connecting Vertex a_i
and b_i. The edges may be printed in any order.
* * * | s679375084 | Wrong Answer | p02977 | Input is given from Standard Input in the following format:
N | import sys
# sys.stdin=open("data.txt")
input = sys.stdin.readline
mii = lambda: map(int, input().split())
# n=4k+3 <=> the line graph works
# these fail: 1 2 4 8 16 32 ...
# 1 2 3 1 2 3
# 4 5 1 4 5
# 6 7 1 6 7
# so n=2k+1 (except n=1) works
def get(n):
e = []
p = 1
while p * 2 <= n:
p *= 2
if n != p:
# make line graph
m = n
while m % 4 != 3:
m -= 1
for i in range(1, m):
e.append([i, i + 1])
e.append([n + i, n + i + 1])
e.append([m, n + 1])
if n % 4 == 1 or n % 4 == 2:
m = n
if n % 4 == 2:
m -= 1
e.append([m - 1, m])
e.append([m, n + 1])
e.append([n + 1, n + m - 1])
e.append([n + m - 1, n + m])
if n % 4 == 0 or n % 4 == 2: # not a power of 2
t = n - 1
e.append([n, t])
for i in range(1, n + 1):
t ^= i
if t == n:
e.append([n + i, n + n])
break
return e
n = int(input())
e = get(n)
for i, j in e:
print("%d %d" % (i, j))
"""
def dfs(u):
vis[u]=1
root[u]^=(u-1)%n+1
for v in g[u]:
if vis[v]: continue
root[v]=root[u]
dfs(v)
for n in range(1,50):
g=[[] for _ in range(2*n+1)]
e=get(n)
if not e: continue
assert len(e)==n*2-1
for i,j in e:
g[i].append(j)
g[j].append(i)
for i in range(1,n+1):
vis=[0]*(2*n+1)
root=[0]*(2*n+1)
dfs(i)
assert root[n+i]==i
"""
| Statement
You are given an integer N. Determine if there exists a tree with 2N vertices
numbered 1 to 2N satisfying the following condition, and show one such tree if
the answer is yes.
* Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i. | [{"input": "3", "output": "Yes\n 1 2\n 2 3\n 3 4\n 4 5\n 5 6\n \n\n * The sample output represents the following graph: \n\n\n\n* * *"}, {"input": "1", "output": "No\n \n\n * There is no tree satisfying the condition."}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s960059730 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input():
return int(input())
def i_map():
return map(int, input().split())
def i_list():
return list(i_map())
def i_row(N):
return [i_input() for _ in range(N)]
def i_row_list(N):
return [i_list() for _ in range(N)]
def s_input():
return input()
def s_map():
return input().split()
def s_list():
return list(s_map())
def s_row(N):
return [s_input for _ in range(N)]
def s_row_str(N):
return [s_list() for _ in range(N)]
def s_row_list(N):
return [list(s_input()) for _ in range(N)]
def lcm(a, b):
return a * b // gcd(a, b)
sys.setrecursionlimit(10**6)
INF = float("inf")
MOD = 10**9 + 7
num_list = []
str_list = []
def main():
n, m = i_map()
for _ in range(m):
a, b = i_map()
num_list.append(a)
num_list.append(b)
num_counter = Counter(num_list)
for i in range(1, n + 1):
print(num_counter[i])
if __name__ == "__main__":
main()
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s667174044 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit
import heapq
import itertools
import operator
inf = float("inf")
def get_int():
return int(input())
def get_float():
return float(input())
def get_str():
return input().strip()
def get_list_of_int():
return [int(i) for i in input().split()]
def get_list_of_float():
return [float(f) for f in input().split()]
def get_list_of_char():
return list(input().strip())
def get_data(n, order=None, **kwargs):
if not order:
order = range(len(kwargs))
it = iter(order)
var, fn = zip(*sorted(sorted(kwargs.items()), key=lambda _: next(it)))
rows = []
for _ in range(n):
rows.append(input().split())
columns = zip(*rows)
exec(
"global "
+ ", ".join(var)
+ "\n"
+ "\n".join(
v + "=list(map(fn[{}], data[{}]))".format(i, i) for i, v in enumerate(var)
),
globals(),
{"fn": list(fn), "data": list(columns)},
)
return
# inputs
N, M = 0, 0
A, B = [], []
def set_inputs():
global N, M, A, B
N, M = get_list_of_int()
get_data(M, A=int, B=int)
return
def main():
setrecursionlimit(100000)
set_inputs()
s = "".join(list(map(lambda x: chr(ord("A") + x), A + B)))
for i in range(N):
print(s.count(chr(ord("A") + i + 1)))
return
if __name__ == "__main__":
main()
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s088833136 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = list(map(int, input().split())
A = [0 for _ in range(N)]
for i in range(M):
a, b = list(map(int, input().split())
A[a-1] += 1
A[b-1] += 1
for i range(N):
print(str(A[i])) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s761721597 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, _, *L = map(int, open(0).read().split())
for n in range(N):
print(L.count(n + 1))
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s421489489 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N,_,*L=map(int,open(0).read().split());for n in range(N):print(L.count(n+1)) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s624548898 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | n,m = map(int,input().split())
ar=[0]*n
for i in range(m):
a,b = map(int,input().split())
ar[a-1] += 1
ar[b-1] += 1
for i in range(n):
print(ar[i]) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s188070889 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = input().split()
for i in range(1, M+1):
a, b = input().split()
for i in range(1, N+1):
print(a.count("i")+b.count("i") | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s148620360 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | 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
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
# ======================================================#
def main():
n, m = MII()
loads = {i: [] for i in range(n)}
for i in range(m):
a, b = MIIZ()
loads[a].append(b)
loads[b].append(b)
for l in loads.values():
print(len(l))
if __name__ == "__main__":
main()
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s266611882 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | n,m = map(int,input().split())
x =[0]*n
for i in range(m):
a,b = map(int,input().split())
x[a-1]+=1
x[b-1]+=1
for i in range(n):
print(x[i] | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s054980930 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | import sys
def input():
return sys.stdin.readline().strip()
def resolve():
n, m = map(int, input().split()) # 頂点の数、辺の数
edge = [
[] * n for i in range(n)
] # rangeに頂点の数。繋がっている頂点を投入するリスト
for i in range(m): # rangeに辺の数
x, y = map(int, input().split())
x, y = x - 1, y - 1
edge[x].append(y)
edge[y].append(x) # 有向ならコメントアウト
for i in range(n):
print(len(edge[i]))
resolve()
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s220516691 | Wrong Answer | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | from collections import Counter
def getinputdata():
# 配列初期化
array_result = []
data = input()
array_result.append(data.split(" "))
flg = 1
try:
while flg:
data = input()
array_temp = []
if data != "":
array_result.append(data.split(" "))
flg = 1
else:
flg = 0
finally:
return array_result
arr_data = getinputdata()
n = int(arr_data[0][0])
m = int(arr_data[0][1])
arr = []
for i in range(1, 1 + m):
arr.append(arr_data[i][0])
arr.append(arr_data[i][1])
list01 = Counter(arr)
for k in sorted(list01):
print(list01[k])
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s132803204 | Accepted | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = map(int, input().rstrip().split())
ab = [list(map(int, input().rstrip().split())) for _ in range(M)]
count = [[0] * N for _ in range(N)]
for road in ab:
count[road[0] - 1][road[1] - 1] += 1
count[road[1] - 1][road[0] - 1] += 1
for i in range(N):
print(sum(count[i]))
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s020845257 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = map(int, input().split())
ABs = [input().split() for i in range(M)]
MPs = {}
for a, b in ABs:
a = int(a)
b = int(b)
if a not in MPs:
MPs[a] = 1
else:
MPs[a] += 1
if b not in MPs:
MPs[b] = 1
else:
MPs[b] += 1
for mp in range(1, N+1):
if mp not in MPs:
MPs[mp] = '0'
for y in sorted(MPs.values()):
print(y) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s878045161 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | S = input()
ans = 0
for i in range(2 ** (len(S) - 1)): # 総当たり
tmp = S[0] # 先頭だけ格納
for j in range(len(S) - 1): # mask
if i & (1 << j): # iと1をjbitシフトしたものを比較
tmp += "+"
tmp += S[j + 1]
ans += eval(tmp)
print(ans)
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s619903619 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | import numpy as np
N,M =[int(i) for i in input().split()]
a = np.ones(M)
b = np.ones(M)
for i in in range(M):
a[i],b[i] = [int(j) for j in input().split()]
ans = np.zeros(N)
for i in range(N):
A = int(a[i]-1)
B = int(b[i]-1)
ans[A]+=1
ans[B]+=1
for i in range(N):
print(ans[i])
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s150863383 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = map(int, input().split())
ab = []
for _ in range(M):
ab.append(map(int, input().split())
bs = [0] * N
for c in range(N):
for i in range(M):
if c+1==ab[i][0] or c+1==ab[i][1]:
bs[c] += 1
for _ in range(N):
print(bs[_] ) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s301591648 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N, M = map(int, input().split())
ab = []
for _ in range(M):
ab.append(list(map(int, input().split()))
bs = [0] * N
for c in range(N):
for i in range(M):
if c+1==ab[i][0] or c+1==ab[i][1]:
bs[c] += 1
for _ in range(N):
print(bs[_] ) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s821933127 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | n, m = map(int,input().split())
c = [0 for i in range(n)]
for i in range(m)
a, b = map(int,input().split())
c[a-1] += 1
c[b-1] += 1
for i in len(c):
print(c[i]) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s224638421 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | a,b=map(int,input().split())
alllist=[]
for i in range(b):
tmp=list(map(int,input().split())
alllist.append(tmp)
for chk in range(a):
print(list.alllist(chk+1)) | Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s780121069 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | N,M = map(int,input().split())
R = []
for i in range(M):
r = list(map(int,input().split()))
R.append(r)
for l in range(N):
ans = []
ans = [i for i in R if i = l ]
print(len(ans))
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Print the answer in N lines. In the i-th line (1≤i≤N), print the number of
roads connected to city i.
* * * | s228182897 | Runtime Error | p03720 | Input is given from Standard Input in the following format:
N M
a_1 b_1
:
a_M b_M | n, m = map(int, input().split())
a = list(map(int, input().split() for i in range(n)))
for i in range(1, n + 1):
print(a.count(i))
| Statement
There are N cities and M roads. The i-th road (1≤i≤M) connects two cities a_i
and b_i (1≤a_i,b_i≤N) bidirectionally. There may be more than one road that
connects the same pair of two cities. For each city, how many roads are
connected to the city? | [{"input": "4 3\n 1 2\n 2 3\n 1 4", "output": "2\n 2\n 1\n 1\n \n\n * City 1 is connected to the 1-st and 3-rd roads.\n * City 2 is connected to the 1-st and 2-nd roads.\n * City 3 is connected to the 2-nd road.\n * City 4 is connected to the 3-rd road.\n\n* * *"}, {"input": "2 5\n 1 2\n 2 1\n 1 2\n 2 1\n 1 2", "output": "5\n 5\n \n\n* * *"}, {"input": "8 8\n 1 2\n 3 4\n 1 5\n 2 8\n 3 7\n 5 2\n 4 1\n 6 8", "output": "3\n 3\n 2\n 2\n 2\n 1\n 1\n 2"}] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.