problem_id
stringlengths
6
6
user_id
stringlengths
10
10
time_limit
float64
1k
8k
memory_limit
float64
262k
1.05M
problem_description
stringlengths
48
1.55k
codes
stringlengths
35
98.9k
status
stringlengths
28
1.7k
submission_ids
stringlengths
28
1.41k
memories
stringlengths
13
808
cpu_times
stringlengths
11
610
code_sizes
stringlengths
7
505
p03639
u858994158
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
["input()\nxs=list(map(int, input().split()))\n\nf,t,z=0,0,0\nfor x in xs:\n if x % 4 == 0:\n f+=1\n elif x % 2 == 0:\n t += 1\n else:\n z += 1\nz += t\nprint('Yes' if z + 1 < f then 'No')\n", "input()\nxs=list(map(int, input().split()))\n\nf,t,z=0,0,0\nfor x in xs:\n if x % 4 == 0:\n f+=1\n elif x % 2...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s052437444', 's189337822', 's347569281']
[2940.0, 14252.0, 14252.0]
[17.0, 65.0, 64.0]
[187, 188, 188]
p03639
u859897687
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
['n=int(input())\nm=list(map(int,input().split()))\nfor i in range(n):\n a=0\n for m[i]>1:\n m[i]//=2\n a+=1\n if a>2:\n a=2\n m[i]=a\nif m.count(2)>m.count(1):\n print("Yes")\nelse:\n print("No")', 'n=int(input())\nm=list(map(int,input().split()))\nfor i in range(n):\n a=0\n while m[i]%2==0:\n m[i]...
['Runtime Error', 'Accepted']
['s147205650', 's407116213']
[2940.0, 14252.0]
[17.0, 156.0]
[196, 302]
p03639
u887207211
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
['N = int(input())\n\ntwo_ad = 0\nfour_ad = 0\nother = 0\nfor _ in range(N):\n a = int(input())\n if a % 4 == 0 and a % 2 == 0:\n four_ad += 1\n elif a % 4 == 0:\n four_ad += 1\n elif a % 2 == 0:\n two_ad += 1\n else:\n other += 1\n\nif not two_ad and not four_ad:\n ans = "No"\nelif not two_ad:\n if ...
['Runtime Error', 'Accepted']
['s909138303', 's704076638']
[5028.0, 14252.0]
[24.0, 63.0]
[516, 302]
p03639
u896741788
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
['n=int(input())\nl=[0,0,0]\nfor i in list(map(int,input().split())):\n if i%2:l[0]+=1\n elif i%4:l[1]+=1\n else:l[2]+=1\n\nprint("Yes" if l[2]>=l[0]+int(1<=l[1]) else "No")\n', 'n=int(input())\nl=list(map(int,input().split()))\nodd=len([1 for i in l if i%2])\nt4=len([1 for i in l if i%4==0])\nif odd*2<=t4:print("Ye...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s343427289', 's475463947', 's593554510', 's502530872']
[14252.0, 15020.0, 14252.0, 14252.0]
[67.0, 56.0, 56.0, 67.0]
[168, 154, 156, 169]
p03639
u903005414
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
["N = int(input())\nA = list(map(int, input().split()))\n\nnum_four = 0\nnum_two = 0\nnum_odd = 0\nfor i in range(N):\n if A[i] % 4 == 0:\n num_four += 1\n elif A[i] % 2 == 0:\n num_two += 1\n else:\n num_odd += 1\n\n# print(num_four, num_two, num_odd)\n\nv = num_four * 2\nif num_two == 0:...
['Wrong Answer', 'Accepted']
['s192207418', 's658587121']
[14224.0, 14224.0]
[72.0, 73.0]
[442, 412]
p03639
u967835038
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
["from math import ceil\nn=int(input())\nans4=0\nans2=0\nans0=0\na=list(map(int,input().split()))\nfor i in range(n):\n if a[i]%4==0:\n ans4+=1\n elif a[i]%2==0:\n ans2+=1\n else:\n ans0+=1\nif ans2>0:\n if ans0<=ans4:\n print('Yes')\n else:\n print('No')\nelse:\n if ceil((ans0+ans4)/2)>=:ans0\n ...
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s337700771', 's531957677', 's660866850', 's784280515', 's907443249', 's837669230']
[2940.0, 15020.0, 14252.0, 15020.0, 11096.0, 15020.0]
[17.0, 73.0, 70.0, 70.0, 27.0, 75.0]
[336, 331, 292, 296, 199, 336]
p03639
u999503965
2,000
262,144
We have a sequence of length N, a = (a_1, a_2, ..., a_N). Each a_i is a positive integer. Snuke's objective is to permute the element in a so that the following condition is satisfied: * For each 1 ≤ i ≤ N - 1, the product of a_i and a_{i + 1} is a multiple of 4. Determine whether Snuke can achieve his objective.
['import math\n\nn=int(input())\nl=list(map(int,input().split()))\n\nc_4=0\nc_2=0\n\nfor i in l:\n if i%4==0:\n c_4+=1\n elif i%2==0:\n c_2+=1\n\n\nif c_2==1:\n num=n\nelse:\n num=n-c_2 \n \nif matj.ceil(num/2) <= c_4:\n ans="Yes"\nelif c_2==n:\n ans="Yes"\nelse:\n ans="No"\n \nprint(ans)', 'import math...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s472530824', 's564899981', 's894127556']
[20288.0, 20476.0, 20028.0]
[65.0, 63.0, 65.0]
[276, 276, 289]
p03647
u089230684
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['s = list(map(int, input().split()))\nn, m = s[0], s[1]\nton = set()\ntom = set()\nif n == m:\n ton = {1, 2, 3}\n tom = {1, 2, 3} \nfor i in range(m):\n s = list(map(int, input().split()))\n if s[0] == m:\n tom |= set(s)\n elif s[1] == m:\n tom |= set(s)\n elif s[1] == n:\n to...
['Wrong Answer', 'Accepted']
['s497261565', 's658929450']
[12636.0, 34664.0]
[746.0, 954.0]
[508, 900]
p03647
u118642796
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['N,M = map(int,input().split())\nab = [[int(i) for i in input().split()] for _ in range(M)]\n\nA = []\nB = [0]*N\nfor a,b in ab:\n if a==1:\n A.append(a)\n if b==N:\n B[a]=1\n\nfor a in A:\n if B[a]==1:\n print("POSSIBLE")\n break\nelse:\n print("IMPOSSIBLE")', 'N,M = map(int,input().split())\nab = [[i...
['Wrong Answer', 'Accepted']
['s442409680', 's913769144']
[40856.0, 40856.0]
[643.0, 687.0]
[258, 262]
p03647
u170765582
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["a,b=map(int,input().split())\nc=[list(map(int,input().split()))for i in[0]*b]\nfor i in range(3,a+1):\n if[1,i]in c and[i,a]in c:print('POSSIBLE');exit()\nprint('IMPOSSIBLE')", "a,b=map(int,input().split())\nc=[list(map(int,input().split()))for i in[0]*b]\nd=[]\ne=[]\nfor i in c:\n if i[0]==1:d+=[i[1]]\n elif i[1]...
['Wrong Answer', 'Accepted']
['s019634879', 's624845025']
[53760.0, 61780.0]
[2109.0, 702.0]
[171, 192]
p03647
u190525112
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["a=[0]*(200001)\n\n\nN = list(map(int, input().split()))\nx = [list(map(int, input().split())) for i in range(N[1])]\n\nprint(N,x)\n\nfor i in x:\n if i[0]==1 :\n if a[i[1]]==1:\n print('POSSIBLE')\n quit()\n a[i[1]]=1\n if i[1]==N[0]:\n if a[i[0]]==1:\n prin...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s365483968', 's398989297', 's114673040']
[63252.0, 63264.0, 53284.0]
[824.0, 851.0, 746.0]
[380, 389, 369]
p03647
u243370518
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['x = input().split(" ")\nn = int(x[0])\nm = int(x[1])\n\nprobInit = set([])\nprobEnd = set([])\n\nfor i in range(m):\n edge = input().split(" ")\n if edge[0] == 0:\n probInit.add(edge[1])\n\n if edge[1] == n - 1:\n probEnd.add(edge[0])\n\nunion = probEnd.union(probInit)\nif (union == set([])):\...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s032631381', 's173522757', 's176633097', 's909698008', 's927882359', 's555029068']
[3064.0, 3064.0, 3060.0, 3060.0, 3064.0, 23196.0]
[355.0, 381.0, 18.0, 374.0, 374.0, 542.0]
[354, 353, 143, 356, 357, 359]
p03647
u280269055
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['N = int(input())\nA = list(map(int, input().split()))\n\ns = sum(A) - N*(N-1)\nm = sum(list(map(lambda x: (x+s)//N, A)))\nwhile m > s:\n s = m\n m = sum(list(map(lambda x: (x+s)//N, A)))\nelse:\n print(m)', 'N = int(input())\nA = list(map(int, input().split()))\n\ns = sum(A) - N*(N-1)\nm = list(map(lambda x:...
['Runtime Error', 'Runtime Error', 'Accepted']
['s452071527', 's820284947', 's368972242']
[3060.0, 3064.0, 18892.0]
[17.0, 17.0, 586.0]
[204, 194, 270]
p03647
u345076485
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['N,M=map(int,input().split())\na=[]\nb=[]\nfor i in range(0,M):\n\tc,d=map(int,input().split())\n\ta.append(c)\n\tb.append(d)\n\npos=0\ni=0\ng=[0 for i in range(0,M)]\nprint(g)\ne=[]\nf=[]\nk=0\nl=0\nwhile i < M and pos == 0:\n\tif a[i] == 1:\n\t\tg[b[i]] = 1\n\tif b[i] == 1:\n\t\tg[a[i]] = 1\n\ti=i+1\ni=0\nprint(g)\n...
['Runtime Error', 'Accepted']
['s251234879', 's736380465']
[23276.0, 20480.0]
[711.0, 696.0]
[465, 452]
p03647
u346308892
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['class Node:\n def __init__(self):\n pass\n\nclass Edge:\n def __init__(self,edge,cost=1):\n self.node_from=edge[0]\n self.node_to=edge[1]\n self.cost=cost\n\n def add_node(self,node):\n self.nodes.append(node)\n\nclass myGraph:\n\n def __init__(self):\n self.adj={...
['Wrong Answer', 'Accepted']
['s460740902', 's417066242']
[197528.0, 197452.0]
[1604.0, 1921.0]
[3923, 3866]
p03647
u353402627
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["n,m = map(int, input().split())\n\nislands = [0 for i in range(n)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n \n if a == 1:\n if islands[b-1] == 2:\n print('Possible')\n break\n islands[b-1] = 1\n if b == n:\n if islands[a-1] == 1:\n print('Possible')\n break\n isla...
['Wrong Answer', 'Accepted']
['s428497160', 's267291327']
[4656.0, 4656.0]
[632.0, 622.0]
[358, 358]
p03647
u353919145
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['s = list(map(int, input().split()))\nn, m = s[0], s[1]\nton = set()\ntom = set()\nfor i in range(m):\n s = list(map(int, input().split()))\n if s[0] == m:\n tom |= set(s)\n elif s[1] == m:\n tom |= set(s)\n elif s[1] == n:\n ton |= set(s)\n elif s[0] == n:\n ton |= set(s) \n...
['Wrong Answer', 'Accepted']
['s058048658', 's015641171']
[12104.0, 38352.0]
[728.0, 720.0]
[413, 354]
p03647
u397531548
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['N,M=map(int,input().split())\nx=[0]*(n+1)\ny=[0]*(n+1)\nfor i in range(M):\n a,b=map(int,input().split())\n if a==1:\n x[b]=1\n if b==N:\n y[a]=1\nfor i in range(N+1):\n if x[i]==1 and y[i]==1:\n print("POSSIBLE")\n break\nelse:\n print("IMPOSSIBLE")', 'N,M=map(int,input().s...
['Runtime Error', 'Accepted']
['s431876020', 's545572085']
[3064.0, 6132.0]
[18.0, 642.0]
[279, 279]
p03647
u450339194
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["N, M = map(int, input().split())\n\nimport sys\n\nteiki = defaultdict(set)\nfor i in range(M):\n a, b = map(int, input().split())\n teiki[a].add(b)\n\n\nif 1 not in teiki:\n print('IMPOSSIBLE')\n sys.exit()\n\nfor i in teiki[1]:\n if i in teiki and N in teiki[i]:\n print('POSSIBLE')\n sys...
['Runtime Error', 'Accepted']
['s622530278', 's137658730']
[3064.0, 45360.0]
[17.0, 772.0]
[329, 366]
p03647
u497046426
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["N, M = map(int, input().split())\nfrom_1 = [False]*N\nto_N = [False]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if a-1 == 0:\n from_1[b-1] = True\n elif b-1 == 0:\n to_N[a-1] = True\nfor i in range(1, N):\n if from_1[i] and to_N[i]:\n print('POSSIBLE')\n break\n...
['Wrong Answer', 'Accepted']
['s442039679', 's312034292']
[6132.0, 6132.0]
[590.0, 579.0]
[334, 330]
p03647
u532966492
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
["N,M=map(int,input().split())\nab=[list(map(int,input().split())) for _ in [0]*M]\ng=[set() for _ in [0]*N]\n[g[b-1].add(a-1) for a,b in ab]\n[g[a-1].add(b-1) for a,b in ab]\na=g[0]\nfor i in a:\n\tif N-1 not in g[i]:\n\t\tprint('IMPOSSIBLE')\n\t\tbreak\nelse:\n\tprint('IPOSSIBLE')", "N,M=map(int,input().split())\nab=...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s041462069', 's744964594', 's362757141']
[117432.0, 118176.0, 117432.0]
[1002.0, 1036.0, 1018.0]
[264, 268, 259]
p03647
u635277286
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['class UnionFind():\n\tdef __init__(self,size):\n\t\tself.table = [-1 for _ in range(size)]\n\n\tdef find(self,x):\n\t\twhile self.table[x] >= 0:\n\t\t\tx = self.table[x]\n\t\treturn x\n\n\tdef unite(self,x,y):\n\t\ts1 = self.find(x)\n\t\ts2 = self.find(y)\n\t\tif s1 != s2:\n\t\t\tif self.table[s1] != self.table[s2]:\...
['Wrong Answer', 'Accepted']
['s397835884', 's368287999']
[30796.0, 18892.0]
[2105.0, 622.0]
[922, 300]
p03647
u777923818
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['# -*- coding: utf-8 -*-\nimport numpy as np\n\nK = int(input())\nK = K\n\n\na = np.ones(50).astype(np.int64)*(49) + (K)//50\n\nif K%50 != 0:\n a[:K%50] += 51 - (K%50)\n a[K%50:] -= (K%50)\nelse:\n pass\n \nresult = "50\\n{}".format(a[0])\nfor a_ in a[1:]:\n result += (" {}".format(int(a_)))\n...
['Runtime Error', 'Accepted']
['s487610651', 's905427020']
[12500.0, 69984.0]
[147.0, 936.0]
[365, 651]
p03647
u816631826
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['s = list(map(int, input().split()))\nn, m = s[0], s[1]\nton = set()\ntom = set()\nif n == m:\n ton = {1, 2, 3}\n tom = {1, 2, 3} \nfor i in range(m):\n s = list(map(int, input().split()))\n if s[0] == m:\n tom |= set(s)\n elif s[1] == m:\n tom |= set(s)\n elif s[1] == n:\n to...
['Wrong Answer', 'Accepted']
['s726661874', 's233666862']
[12124.0, 6132.0]
[713.0, 579.0]
[464, 379]
p03647
u894844146
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
[' def f():\n n,m = map(int,input().split(" "))\n s = []\n w = [[] for i in range(n+2)]\n for i in range(m):\n a,b = map(int,input().split(" "))\n \n if a==1:\n s.append(b)\n if b==1:\n s.append(a)\n w[a]...
['Runtime Error', 'Accepted']
['s661510138', 's702500056']
[2940.0, 38460.0]
[17.0, 739.0]
[502, 422]
p03647
u995062424
2,000
262,144
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N. There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i. Cat Snuk...
['N, M = map(int, input().split())\ngraph = {i+1:[] for i in range(N)}\nfor i in range(M):\n a, b = map(int, input().split())\n graph[a].append(b)\n graph[b].append(a)\n\nfor value in graph[1]:\n if(N in graph[value]):\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")', 'N, M = map(int, input().sp...
['Wrong Answer', 'Accepted']
['s811770210', 's818298241']
[55520.0, 55520.0]
[869.0, 884.0]
[277, 291]
p03649
u034128150
2,000
262,144
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more th...
['N = int(input())\nlist_of_a = list(map(int, input().split()))\n\nng = max(0, sum(list_of_a)-(N-1)*N) - 1\nok = max(0, (max(list_of_a) - (N-1)) * N)\nprint(ng, ok)\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n count = 0\n for a in list_of_a:\n count += (a + mid + 1) // (N+1)\n if count <= mid:\n ...
['Wrong Answer', 'Accepted']
['s297373477', 's674717378']
[9164.0, 9184.0]
[31.0, 46.0]
[355, 571]
p03649
u057079894
2,000
262,144
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more th...
['##create with UTF-8\n\nn = int( input() )\nda=list(map(int, input(). split()))\nli=[da[i]%(n+1) for i in range(n)]\nsu=0\nans=0\nfor i in range(n):\n\tsu+=da[i]\nfor i in range(n):\n\tdiv=(n-1)-(da[i]%(n+1))\n\tnow=0\n\tju=True\n\tfor j in range(n):\n\t\tif (n+1+div+da[j])%(n+1)==n:\n\t\t\tju=False\n\t\t\tbreak\n\t\t...
['Wrong Answer', 'Accepted']
['s318859782', 's689349765']
[3064.0, 3064.0]
[18.0, 18.0]
[382, 383]
p03649
u392319141
2,000
262,144
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more th...
['N = int(input())\nA = list(map(int, input().split()))\n\ndef isOk(k):\n B = [a + k for a in A]\n cnt = 0\n for b in B:\n cnt += b // (N + 1)\n return cnt >= k\n\nok = 0\nng = 10**20\nwhile ng - ok > 1:\n mid = (ok + ng) // 2\n if isOk(mid):\n ok = mid\n else:\n ng = mid\npri...
['Wrong Answer', 'Accepted']
['s539017767', 's926145004']
[3064.0, 3064.0]
[18.0, 517.0]
[306, 225]
p03649
u606045429
2,000
262,144
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more th...
['from numpy import int64, divmod\n\nN, A = open(0)\nN, A = int(N), int64(A.split())\n\nans = 0\nS = -1\nwhile S:\n B, A = A % N, A // N\n S = B.sum()\n ans += S\n A += S - B\n\nprint(ans)\n', 'from numpy import int64\n\nN, A = open(0)\nN, A = int(N), int64(A.split())\n\nans = 0\nS = -1\nwhile S:\n B, A ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s339868393', 's718328394', 's468024194']
[12496.0, 14412.0, 12508.0]
[151.0, 2112.0, 179.0]
[186, 178, 178]
p03649
u844789719
2,000
262,144
We have a sequence of length N consisting of non-negative integers. Consider performing the following operation on this sequence until the largest element in this sequence becomes N-1 or smaller. (The operation is the same as the one in Problem D.) * Determine the largest element in the sequence (if there is more th...
['N, *A = [int(_) for _ in open(0).read().split()]\nsumB = max(0, sum(A) - N * (N - 1))\nwhile True:\n B = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]\n if sumB == sum(B):\n break\n sumB += 1\nprint(sumB)\n', 'N, *A = [int(_) for _ in open(0).read().split()]\nsumB = max(0, sum(A) - N * (N - 1))\nwhil...
['Runtime Error', 'Accepted']
['s304339144', 's398866170']
[9100.0, 9088.0]
[28.0, 46.0]
[215, 218]
p03650
u466826467
2,000
262,144
There is a directed graph with N vertices and N edges. The vertices are numbered 1, 2, ..., N. The graph has the following N edges: (p_1, 1), (p_2, 2), ..., (p_N, N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is denoted by (u, v), and a weakly connected graph is a graph which would be ...
['from collections import defaultdict\nimport heapq as hq\n\n\ndef helper(n):\n q = child_L[n]\n del child_L[n]\n\n hq.heapify(q)\n i = 0\n while q:\n t = hq.heappop(q)\n if i < t:\n break\n else:\n i += (i == t)\n\n j = i + 1\n while q:\n t = hq.he...
['Runtime Error', 'Accepted']
['s166586633', 's423097778']
[152124.0, 30288.0]
[1827.0, 509.0]
[1988, 1996]
p03651
u000085263
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n, k = map(int, input().split())\nl = list(map(int, input().split()))\nm = max(a)\ndef hcf(x, y): \n while(y): \n x, y = y, x % y \n return x \nnum1=l[0] \nnum2=l[1] \ngcd=hcf(num1,num2) \nfor i in range(2,len(l)): \n gcd=hcf(gcd,l[i])\nif k%gcd == 0 and k<=m:\n print("POSSIBLE")\nelse:\n print(...
['Runtime Error', 'Accepted']
['s859461708', 's595100258']
[19996.0, 20444.0]
[52.0, 60.0]
[316, 259]
p03651
u023229441
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k=map(int,input().split())\nA=list(map(int,input().split()))\nyes="POSSIBLE" ; no="IMPOSSIBLE"\nimport numpy as np\nq= np.gcd.reduce(A)\nif k%q==0 and max(A)-min(A)>=k:\n print(yes)\nelse:\n print(no)', 'n,k=map(int,input().split())\nA=list(map(int,input().split()))\nyes="POSSIBLE" ; no="IMPOSSIBLE"\nimport n...
['Wrong Answer', 'Accepted']
['s490935210', 's506859219']
[31472.0, 31424.0]
[143.0, 143.0]
[200, 193]
p03651
u037430802
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['\nN,K = map(int, input().split())\n\nA = list(map(int, input().split()))\n\nA.sort()\n\nif A[-1] < K:\n print("IMPOSSIBLE")\n exit()\n\nif K in A or 1 in A:\n print("POSSIBLE")\n exit()\n\ndef gcd(a,b):\n x = max([a,b])\n y = min([a,b])\n while y:\n x, y = y, x % y\n return x\n\ng = A[0...
['Runtime Error', 'Accepted']
['s079573032', 's535032689']
[3064.0, 14224.0]
[17.0, 154.0]
[395, 386]
p03651
u088863512
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd, ceil, atan, pi\ndef input(): return sys.stdin.readline()[:-1] # warning not \\n\n\n\nimport string\n\nfrom bisect import bisect_left, bisect_right\nfrom functools import lru_cache, reduce\nMOD = int...
['Wrong Answer', 'Accepted']
['s556568688', 's115404479']
[21728.0, 21616.0]
[65.0, 65.0]
[860, 848]
p03651
u136395536
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['N,K = (int(i) for i in input().split())\nA = [int(i) for i in input().split()]\n\nmakable = False\nif max(A) < K:\n makable = False\nelif K in A:\n makable = True\n\nif makable:\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")\n ', "def euclid(x,y):\n a = max(x,y)\n b = min(x,y)\n \n r = a...
['Wrong Answer', 'Accepted']
['s635028250', 's938049480']
[14252.0, 14480.0]
[48.0, 109.0]
[231, 537]
p03651
u143492911
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\nans=a[0]\nfor i in range(1,n):\n ans=gcd(ans,a[i])\nif ans%k==0:\n if k<max(a):\n print("POSSIBLE")\n exit()\nprint("IMPOSSIBLE")\n\n', 'n,k=map(int,input().split())\nt=...
['Wrong Answer', 'Accepted']
['s643058635', 's088733078']
[14100.0, 14096.0]
[74.0, 75.0]
[267, 265]
p03651
u177040005
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["def gcd(a,b):\n if b == 0:\n return abs(a)\n else:\n return gcd(b, a%b)\n\nN,K = map(int, input().split())\nA = sorted(list(map(int,input().split())))\n\nIm = 'IMPOSSIBLE'\nPo = 'POSSIBLE'\n\nif A[-1] < K:\n print(Im)\nelse:\n for i in range(N):\n if i == 0:\n gcd = gcd(A[i...
['Runtime Error', 'Accepted']
['s296423971', 's369962804']
[14252.0, 14252.0]
[77.0, 101.0]
[425, 458]
p03651
u210440747
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["from functools import reduce, gcd\n\ndef main():\n n, k = map(int, input().split())\n la = list(map(int, input().split()))\n if max(la) > k and (max(la) - k) % (reduce(gcd, la)) == 0:\n print('POSSIBLE')\n else:\n print('IMPOSSIBLE')\n \nif __name__=='__main__':\n main()", "#!/usr/bin/python3\n# -*- codin...
['Runtime Error', 'Accepted']
['s707537148', 's934367702']
[3572.0, 14596.0]
[22.0, 65.0]
[272, 401]
p03651
u225388820
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\n\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nfor i in range(1,n):\n a[0]=gcd(a[0],a[i])\nif k%a[0]==0 and k-a[0]<=max(a):\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")', 'def gcd(a,b):\n while b!=0:\n a,b=b,a%b...
['Wrong Answer', 'Accepted']
['s509032943', 's176625727']
[14100.0, 14096.0]
[81.0, 79.0]
[253, 252]
p03651
u227888331
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def gcd(a, b):\n if (b == 0):\n return a\n return gcd(b, a % b)\n\ninput1 = list(map(int,input("").split(" ")))\nA = list(map(int,input("").split(" ")))\nN = input1[0]\nK = input1[1]\nA.sort()\nif K in A:\n\tflag = True\nelif K > max(A):\n\tflag = False\nelse:\n\ttemp = A[0]\n\tfor i in range(1,N):\n\t\t...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s167791703', 's230181235', 's251603649', 's534578367', 's593448207', 's676846099', 's716023395', 's928148599']
[14224.0, 14252.0, 14224.0, 14224.0, 14252.0, 2940.0, 3060.0, 14252.0]
[129.0, 89.0, 87.0, 42.0, 102.0, 18.0, 17.0, 85.0]
[433, 271, 322, 265, 357, 343, 445, 325]
p03651
u263830634
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndef gcd(x, y):\n if x > y:\n x, y = y, x\n if y % x == 0:\n return x\n y = y % x\n return gcd(x, y)\n\nn = A[0]\nfor i in A:\n n = gcd(n, i)\n\nflag = False\nfor i in A:\n if i > K and (i - K) % n == 0:\n f...
['Wrong Answer', 'Accepted']
['s801391912', 's566176634']
[14224.0, 14100.0]
[69.0, 64.0]
[412, 413]
p03651
u266014018
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n def gcd(x,y):\n r = x%y\n if r==0:\n return y\n return gcd(y, r)\n\n n, k =map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n c = a[0]\n for i in range(n):\n...
['Runtime Error', 'Accepted']
['s836208974', 's989512574']
[8920.0, 19788.0]
[22.0, 77.0]
[456, 486]
p03651
u277429554
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["n, k = map(int, input().split())\na = list(map(int, input().split())) \na.sort()\na.reverse() \nx = a[0] \nfor i in range (1, N):\n while a[i] != 0:\n x , a[i] = a[i] , x % a[i]\nif K > a[0]:\n print('IMPOSSIBLE')\nelse:\n print('POSSIBLE' if K%x == 0 else 'IMPOSSIBLE')", "N,K = map(int, input().split())\nA =...
['Runtime Error', 'Accepted']
['s920990644', 's827136950']
[19708.0, 19948.0]
[64.0, 111.0]
[267, 266]
p03651
u283229916
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def main():\n import math\n n,k=map(int,input().split(" "))\n a=map(int,input().split(" "))\n g=a[0]\n m=max(a)\n for i in range(n):\n g=math.gcd(g,a[i])\n if k % g==0 and k<=m:\n print("POSSIBLE")\n else:\n print("IMPOSSIBLE")\n\nmain()', 'def gcd(a,b):\n if a==0: retu...
['Runtime Error', 'Accepted']
['s401045075', 's664016091']
[11052.0, 14224.0]
[26.0, 71.0]
[269, 327]
p03651
u297109012
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def factor(N):\n ret = []\n i = 2\n while N > 1:\n if N % i == 0:\n ret.append(i)\n N //= i\n else:\n i += 1\n return ret\n\nfrom collections import Counter\n\n\ndef solve(N, K, As):\n if K > max(As):\n return "IMPOSSIBLE"\n factors = [Counter(fa...
['Wrong Answer', 'Accepted']
['s814880736', 's856027241']
[14636.0, 14628.0]
[2104.0, 325.0]
[469, 1137]
p03651
u368796742
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k = map(int,input().split())\nl = sorted(list(map(int,input().split())))\nif l[-1] > k:\n print("IMPOSSIBLE")\n exit()\nx = l[0]\nfor i in range(1,n):\n if l[i]%x:\n print("POSSIBLE")\n exit()\n\nif k in l:\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")', 'import math\nn,k = map(int,i...
['Wrong Answer', 'Accepted']
['s535297264', 's046165628']
[19960.0, 20304.0]
[81.0, 64.0]
[272, 234]
p03651
u404676457
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["import sys\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\n\nif a[-1] < k:\n print('IMPOSSIBLE')\n sys.exit(0)\n\nseta = set(a)\nif k in seta:\n print('POSSIBLE')\n sys.exit(0)\nchange = True\nwhile change:\n change = False\n setb = seta.copy()\n sorteda = sorted(seta)\n...
['Runtime Error', 'Accepted']
['s077927325', 's521590636']
[14480.0, 14224.0]
[102.0, 71.0]
[593, 259]
p03651
u445624660
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['\n\n\n\n\n\n\n\n\nn, k = map(int, input().split())\narr = sorted(list(set(list(map(int, input().split())))))\nn = len(arr)\nif arr[0] == 1:\n print("POSSIBLE")\n exit()\nif n < 2 or arr[-1] < k:\n print("IMPOSSIBLE")\n exit()\n\n\ndef gcd(a, b):\n if a > b:\n a, b = b, a\n while a > 0:\n ...
['Wrong Answer', 'Accepted']
['s370220708', 's568810080']
[14480.0, 14480.0]
[133.0, 94.0]
[1310, 1792]
p03651
u474270503
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['N, K=map(int, input().split())\nA=list(sorted(list(map(int, input().split())), returned=True))\n\ndef gcd(a,b):\n\twhile b:\n\t\ta,b=b,a%b\n\treturn a\n\nif K>max(A):\n\tprint("IMPOSSIBLE")\n\texit(0)\n\ng=gcd(A[0],A[1])\nfor i in range(2,len(A)):\n\tg=gcd(g,A[i])\n\nprint("POSSIBLE" if K%g==0 else "IMPOSSIBLE")', 'N...
['Runtime Error', 'Accepted']
['s439317412', 's974609873']
[14224.0, 14224.0]
[44.0, 116.0]
[290, 249]
p03651
u518042385
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k=map(int,input().split())\nl=list(map(int,input().split()))\ndef gcd(n,m):\n a=max(n,m)\n b=min(n,m)\n while b!=0:\n a,b=b,a%b\n return a\ng=l[0]\nmax=l[0]\nfor i in range(1,1+n-1):\n g=gcd(g,l[i])\n if max<l[i]:\n max=l[i]\nif max<k:\n print("POSSIBLE")\nelif max==k:\n print("POSSIBLE")\nelse:\n if...
['Runtime Error', 'Accepted']
['s206189211', 's499029778']
[14236.0, 14224.0]
[42.0, 84.0]
[361, 388]
p03651
u535423069
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['\n# Created: Mon Mar 23 15:10:04 UTC 2020\nimport sys\n \nstdin = sys.stdin\ninf = 1 << 60\nmod = 1000000007\n \nni = lambda: int(ns())\nnin = lambda y: [ni() for _ in range(y)]\nna = lambda: list(map(int, stdin.readline().split()))\nnan = lambda y: [na() for _ in range(y)]\nnf = lambda: float(...
['Runtime Error', 'Accepted']
['s175530258', 's192421405']
[23112.0, 14252.0]
[180.0, 88.0]
[860, 960]
p03651
u555811857
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['# -*- coding: utf-8 -*-\nN, A = map(int, input().split())\ntmp = input()\nary = [int(a) for a in tmp.split()]\n\nmaximum = max(ary)\n\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return a\n c = a % b\n return gcd(b, c)\n\n\ng = None\nfor a in ary:\n if g is None:\n g ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s141945092', 's557624032', 's837104253']
[15192.0, 2090904.0, 15320.0]
[149.0, 2230.0, 86.0]
[435, 823, 422]
p03651
u557437077
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['# import math\nimport fractions\nn, k = [int(i) for i in input().split()]\na = [int(i) for i in input().split()]\na = sorted(a)\ndiv = fractions.gcd(a[0], a[1])\nfor i in range(2, n):\n div = fractions.gcd(a[i], a[i-1])\nif k % div == 0 and k <= a[-1]:\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")\n', '# ...
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s044549575', 's057690798', 's792374775', 's610253984']
[16280.0, 16048.0, 16276.0, 14252.0]
[195.0, 208.0, 134.0, 130.0]
[475, 645, 546, 344]
p03651
u620480037
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['N,K=map(int,input().split())\n\nA=list(map(int,input().split()))\n\ndef gcd(a,b):\n x=max(a,b)\n y=min(a,b)\n while x%y!=0:\n x,y=y,x%y\n return y\n \nNum=A[0]\n\nfor i in range(N):\n Num=gcd(Num,A[i])\n \nif K%Num==0:\n if K>Num:\n print("IMPOSSIBLE")\n else:\n print("...
['Wrong Answer', 'Accepted']
['s228596089', 's267193002']
[14224.0, 14224.0]
[104.0, 105.0]
[338, 341]
p03651
u635182517
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32\nType "copyright", "credits" or "license()" for more information.\n>>> \n======= RESTART: C:\\Users\\mori-\\OneDrive\\Desktop\\Python\\abc\\tenka1a.py =======\nTraceback (most recent call last):\n File "C:\\Users\\mori-\\One...
['Runtime Error', 'Accepted']
['s595810542', 's940599560']
[2940.0, 14480.0]
[18.0, 107.0]
[1601, 375]
p03651
u637175065
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): retur...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s278605785', 's340945711', 's132053746']
[16648.0, 16652.0, 16644.0]
[340.0, 91.0, 107.0]
[891, 884, 959]
p03651
u707870100
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['# -*- coding: utf-8 -*-\n#AGC014A\nimport sys\n#import collections\n\n#n= int(input())\n\ntmp = input().split()\nn,k = list(map(lambda a: int(a), tmp))\n\ntmp = input().split()\na = list(map(lambda a: int(a), tmp))\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\nmaxa=a[0]\ntmp=a[0]\nfor i in...
['Runtime Error', 'Accepted']
['s012065384', 's335507032']
[14228.0, 14228.0]
[104.0, 109.0]
[451, 454]
p03651
u785205215
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def gcd(a,b):\n while b > 0:\n a, b = b, a%b\n return a\n\ndef gcd_list(lst):\n a = gcd(lst[0],lst[1])\n i=2\n while a > 0 and i<len(lst):\n a = gcd(a, lst[i])\n if a == 1:\n return 1\n break\n i+=1\n return a\n \nn, k = (int(i) for i in input().s...
['Runtime Error', 'Runtime Error', 'Accepted']
['s027711186', 's252986215', 's468824297']
[14484.0, 14096.0, 14480.0]
[92.0, 83.0, 76.0]
[515, 530, 383]
p03651
u785578220
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['a,b=map(int, input().split())\nx = list(map(int, input().split()))\nx.sort()\np=0\nq=0\ny=0\nfor i in x:\n if p == 1 and q == 1:break\n if i == b:\n y=1\n if i%2==0:\n p=1\n else:\n q=1\nif b<=x[-1]:\n if((b%2==0 and(p*q ==0))or(p==1 and q==1)):\n m="POSSIBLE"\nif y==1:m="PO...
['Wrong Answer', 'Accepted']
['s265995951', 's072660845']
[14252.0, 14224.0]
[76.0, 173.0]
[338, 338]
p03651
u800610991
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['a,b = map(int,input().split())\nnn = list(map(int,input().split()))\nnnn = nn.copy()\n\nif b in nn:\n print(\'POSSIBLE\')\n exit()\nif b > max(nn):\n print("IMPOSSIBLE")\n exit()\nlen_nn = [0]\nwhile 1:\n lnn = len(nn)\n for x in range(len(nn)):\n for y in range(len(nn) - x -len_nn):\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s302692941', 's664938102', 's810333929']
[14096.0, 14252.0, 14480.0]
[46.0, 2104.0, 66.0]
[626, 544, 357]
p03651
u814986259
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['import collections\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nif K in A:\n print("POSSIBLE")\nelse:\n diff = collections.defaultdict(int)\n A.sort()\n idx = N - 1\n if K > A[-1]:\n print("IMPOSSIBLE")\n else:\n for i in range(N-1):\n if A[i] > K ...
['Runtime Error', 'Accepted']
['s064925775', 's386067804']
[14636.0, 14636.0]
[132.0, 1014.0]
[773, 875]
p03651
u820351940
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['a, b = map(int, input().split())\narray = list(map(int, input().split()))\nimpossible = "IMPOSSIBLE"\npossible = "POSSIBLE"\n\nif a == 1:\n if b == array[0]:\n print(possible)\n else:\n print(impossible)\n exit(0)\n\narray.sort()\narray = list(set(array))\n\nbtw = [v1 - v2 for v1, v2 in zip(arr...
['Runtime Error', 'Accepted']
['s586794451', 's494571962']
[14728.0, 14604.0]
[161.0, 154.0]
[568, 578]
p03651
u839537730
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['X, Y, Z = list(map(int, input().split(" ")))\n\nimport numpy as np\n\nABC = []\n\nfor i in range(X+Y+Z):\n ABC.append(list(map(int, input().split(" "))))\n\nABC = sorted(ABC, key=lambda row: row[0]-row[1]) \n\nans = 0\n\nABC_bk = ABC_np[:Y]\nABC_ak = ABC_np[Y:]\n\nfor k in range(Y, Y+Z):\n \n ABC_bk = ABC...
['Runtime Error', 'Accepted']
['s115477986', 's213971011']
[3064.0, 14096.0]
[19.0, 83.0]
[782, 672]
p03651
u844789719
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['import math', 'import math\nN, K = [int(_) for _ in input().split()]\nA = [int(_) for _ in input().split()]\ng = A.pop()\nfor a in A:\n g = math.gcd(g, a)', "N, K = [int(_) for _ in input().split()]\nA = [int(_) for _ in input().split()]\n\n\ndef gcd(x, y):\n if x < y:\n return gcd(y, x)\n elif y == 0...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s070835746', 's770468091', 's060142341']
[2940.0, 14252.0, 14224.0]
[18.0, 47.0, 98.0]
[11, 137, 332]
p03651
u845333844
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\nif n==1:\n x=a[0]\nelse:\n x=gcd(a[0],a[1])\n for i in range(2,n):\n x=gcd(x,a[i])\n\nif max(a)>=k and k%g==0:\n print("POSSIBLE")\nelse:\n print("IMPOSSIBLE")', 'n,k=...
['Runtime Error', 'Accepted']
['s150419565', 's151371656']
[14096.0, 14100.0]
[90.0, 89.0]
[292, 292]
p03651
u871841829
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nP = "POSSIBLE"\nIP = "IMPOSSIBLE"\n\nA.sort()\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n gcd(b, b%a)\n\nt = gcd(A[1], A[0])\nif N <= 2:\n for a in A[2:]:\n t = gcd(t, a)\n\nif K%t == 0 and K <= M:\n prin...
['Runtime Error', 'Accepted']
['s583946934', 's963585959']
[19896.0, 19800.0]
[60.0, 76.0]
[322, 330]
p03651
u879870653
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def gcd(a,b) :\n while b :\n a,b = b, a % b\n return a\n\nN,K = map(int,input().split())\nL = list(map(int,input().split()))\n\np = 10**9\nfor i in range(N-1) :\n q = gcd(L[i],L[i+1])\n if q < p :\n p = q\n\nif (K % p == 0) and (K <= max(L))\n ans = "POSSIBLE"\nelse :\n ans = "IMPOSSI...
['Runtime Error', 'Accepted']
['s538878184', 's350147871']
[2940.0, 14224.0]
[17.0, 205.0]
[317, 501]
p03651
u896741788
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['n,k=map(int,input().split())\nl=soted(map(int,input().split()))\ndef gcd(x,y):\n if y==0:return x\n return gcd(y,x%y)\nans=""\ns=0\nfor i in l:\n s=gcd(i,s)\n if s==1:break\nelse:\n if k%s!=l[-1]%s:\n ans="IM"\nprint(ans+"POSSIBLE")', 'n,k=map(int,input().split())\nl=soted(list(map(int,input().split())))\ndef...
['Runtime Error', 'Runtime Error', 'Accepted']
['s395154796', 's625076779', 's136877754']
[3064.0, 3060.0, 14108.0]
[18.0, 17.0, 104.0]
[227, 234, 249]
p03651
u926678805
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
["from functools import reduce\nn,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a, b):\n while a != 0:\n a,b=b%a,a\n return b\ndef lcm(x, y):\n return (x * y)//gcd(x, y)\nt=reduce(lcm,a)\nif t==1:\n if max(a)>=k:\n print('POSSIBLE')\n exit()\nelse:\n if k in a...
['Wrong Answer', 'Accepted']
['s541493707', 's669753508']
[14596.0, 14596.0]
[2108.0, 69.0]
[422, 436]
p03651
u974792613
2,000
262,144
There is a box containing N balls. The i-th ball has the integer A_i written on it. Snuke can perform the following operation any number of times: * Take out two balls from the box. Then, return them to the box along with a new ball, on which the absolute difference of the integers written on the two balls is writte...
['def gcd(a, b):\n return gcd(b, a % b) if b > 0 else a\n\n\nn, k = map(int, input().split())\na = list(map(int, input().split())\n \nm = max(a)\n \ng = a[0]\n \nfor i in range(n):\n g = gcd(g, a[i])\n\nif k > m:\n print("IMPOSSIBLE")\nelif k % g == 0:\n print("POSSIBLE")\nelse:\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s758854177', 's854254792', 's455700431']
[2940.0, 2940.0, 14224.0]
[17.0, 18.0, 88.0]
[320, 286, 294]
p03652
u077291787
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['from collections import deque\nfrom typing import Optional\n\n\nclass DeletableDeque:\n """Deletable Deque: a deque that supports lazy deletion of values."""\n\n __slots__ = ["_set", "_deque"]\n\n def __init__(self, *initial_values: int) -> None:\n self._set = set()\n self._deque = deque([])\n\...
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s035857929', 's129245579', 's236852242', 's844707749']
[14284.0, 14084.0, 14172.0, 14028.0]
[155.0, 149.0, 145.0, 122.0]
[3607, 3532, 3532, 1706]
p03652
u201234972
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['from collections import Counter\nN, M = map( int, input().split())\nA = [ [] for _ in range(N)]\nfor i in range(N):\n A[i] = list( map( int, input().split())) \nV = [1]*(M+1)\nans = N\nfor _ in range(M-1):\n W = []\n for i in range(N):\n while A[i]:\n a = A[i].pop(0)\n if V[a] ==...
['Wrong Answer', 'Accepted']
['s670926010', 's129791218']
[5464.0, 4700.0]
[88.0, 105.0]
[451, 476]
p03652
u223904637
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['n,m=map(int,input().split())\nk=[[0]*m for i in range(n)]\nfor i in range(n):\n k[i]=list(map(int,input().split()))\nans=1000\nfor i in range(m-1):\n ma=[0]*m\n mi=-1\n for j in range(n):\n ma[k[j][0]]+=1\n if ans>max(ma):\n ans=max(ma)\n mi=ma.index(max(ma))+1\n for j in range(n):\...
['Runtime Error', 'Accepted']
['s748647703', 's070431674']
[4288.0, 4332.0]
[37.0, 165.0]
[349, 383]
p03652
u340781749
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['n, m = map(int, input().split())\nprefers = [list(reversed(list(map(int, input().split())))) for _ in range(n)]\nitems = [True] * (m + 1)\ncompetes = {i: 0 for i in range(1, m + 1)}\npersons = [set() for _ in range(m + 1)]\n\nfor i, ps in enumerate(prefers):\n item = ps[-1]\n competes[item] += 1\n persons[it...
['Runtime Error', 'Accepted']
['s154733906', 's687040051']
[6692.0, 4588.0]
[103.0, 71.0]
[820, 650]
p03652
u375616706
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['from collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\nN, M = map(int, input().split())\nmat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]\n\nans = N\nQ = [set([v for v in range(M)])]\nwhile Q:\n C = Counter()\n sports_cand = Q.pop(0)\n ...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s538838284', 's955631849', 's024464788']
[4588.0, 13772.0, 4588.0]
[50.0, 2104.0, 1768.0]
[731, 1139, 734]
p03652
u415905784
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['N, M = map(int, input().split())\nA = [[0 for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n A[i] = [int(x) - 1 for x in input().split()]\nS = [[0, i] for i in range(M)]\nfor a in A:\n S[a[0]][0] += 1\nminmax = N\nfor _ in range(M - 1):\n _S = sorted(S, reverse=True)\n s = _S[0][1]\n minmax = min(S[s][0...
['Wrong Answer', 'Accepted']
['s661514831', 's373710075']
[4212.0, 4212.0]
[114.0, 125.0]
[421, 459]
p03652
u426108351
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['n, m = map(int, input().split())\na = [list(map(int, input().split())) for i in range(n)]\nfor i in range(n):\n a[i].reverse()\n\nans = n\nused = set()\nfor i in range(m):\n count = [0]*(m+1)\n for j in range(n):\n count[a[j][-1]] += 1\n\n ans = min(max(count), ans)\n num = count.index(max(count...
['Runtime Error', 'Runtime Error', 'Accepted']
['s574115545', 's617397519', 's507713635']
[10172.0, 10208.0, 10172.0]
[72.0, 38.0, 96.0]
[481, 412, 490]
p03652
u572142121
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['N,M=map(int, input().split())\nA=[]\nfor i in range(N):\n d=list(map(int, input().split()))\n A.append(d)\nnum=[0]*N\nans=M\nS=set()\nfor i in range(M-1):\n cnt=[0]*M\n for j in range(N):\n for k in range(M):\n d=A[j][k]-1\n if d in S:\n continue\n else:\n cnt[d]+=1\n e=max(cnt)\n...
['Wrong Answer', 'Accepted']
['s518289126', 's641406485']
[10208.0, 10284.0]
[2206.0, 86.0]
[356, 340]
p03652
u594567187
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['def dfs(people, sports, use_sports, answer):\n rank = [0 for n in range(sports)]\n for p in range(people):\n for s in (preference[p]):\n if s in use_sports:\n rank[s] += 1\n break\n will_delete = []\n max_p = max(rank)\n exclude = rank.index(max_p...
['Runtime Error', 'Accepted']
['s363918907', 's472169800']
[10404.0, 4212.0]
[2104.0, 1049.0]
[692, 532]
p03652
u624475441
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
["from collections import Counter\nfrom operator import itemgetter\n\ndef sub(prefers, canceled):\n res = Counter()\n for pref in prefers:\n p = pref[-1]\n while p in canceled:\n pref.pop()\n p = pref[-1]\n res[p] += 1\n return max(res.items(), key=itemgetter(1))\n\nde...
['Runtime Error', 'Accepted']
['s005795175', 's109941345']
[2940.0, 4580.0]
[17.0, 99.0]
[647, 648]
p03652
u814986259
2,000
262,144
Takahashi is hosting an sports meet. There are N people who will participate. These people are conveniently numbered 1 through N. Also, there are M options of sports for this event. These sports are numbered 1 through M. Among these options, Takahashi will select one or more sports (possibly all) to be played in the ev...
['N,M=map(int,input().split())\nA=[list(map(int,input().split())) for i in range(N)]\nans=N\ns=set()\nfor i in range(M-1):\n d=[0]*M\n for j in range(N):\n for k in range(M):\n if A[j][k]-1 in s:\n continue\n else:\n d[A[j][k]-1]+=1\n ans=min(ans,max(d))\n s.add(d.index(max(d)))\nprint(an...
['Wrong Answer', 'Accepted']
['s164995348', 's245909828']
[10168.0, 9980.0]
[2206.0, 923.0]
[309, 422]
p03655
u102461423
8,000
262,144
Joisino is planning on touring Takahashi Town. The town is divided into square sections by north-south and east-west lines. We will refer to the section that is the x-th from the west and the y-th from the north as (x,y). Joisino thinks that a _touring plan_ is good if it satisfies the following conditions: * Let (...
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport itertools\nimport numpy as np\nfrom functools import lru_cache\n\nX = list(map(int,readline().split()))\nY = list(map(int,readline().split()))\n\nfor i in [1,3,5]:\n X[i] += 1\n Y[i] ...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s091068610', 's281248502', 's134618058']
[323808.0, 34788.0, 200800.0]
[1077.0, 325.0, 3311.0]
[1346, 1041, 2034]
p03662
u171366497
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['N=int(input())\nfrom collections import defaultdict,deque\nbranch=defaultdict(set)\nfor i in range(N-1):\n a,b=map(int,input().split())\n a-=1\n b-=1\n branch[a]|={b}\n branch[b]|={a}\ncheck={0}\nbef=[-2]*N\nbef[0]=-1\ndist=[float(\'inf\')]*N\ndist[0]=0\nwhile len(check)>0:\n now=check.pop()\n fo...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s542676145', 's662475690', 's058435549']
[42804.0, 950400.0, 56104.0]
[652.0, 2167.0, 724.0]
[449, 549, 998]
p03662
u346308892
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['\nclass Edge:\n def __init__(self,edge,cost=1):\n self.node_from=edge[0]\n self.node_to=edge[1]\n self.cost=cost\n\n def add_node(self,node):\n self.nodes.append(node)\n\nclass myGraph:\n\n def __init__(self):\n self.adj={}\n self.nodes={}\n\n def add_edge(self,ed...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s185617994', 's992425786', 's462077828']
[3192.0, 3192.0, 105304.0]
[18.0, 18.0, 1512.0]
[3055, 3131, 3422]
p03662
u426108351
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['import sys\ninput = sys.stdin.readline\nN = int(input())\ntree = [[] for i in range(N+1)]\n\nfor i in range(N-1):\n a, b = map(int, input().split())\n tree[a].append(b)\n tree[b].append(a)\n\ndist_fennec = [100001] * (N+1)\ndist_snuke = [100001] * (N+1)\nq = [1]\ndist_fennec[1] = 0\nwhile q:\n now = q.pop...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s834701118', 's868778104', 's082517784']
[28976.0, 22704.0, 28976.0]
[434.0, 216.0, 441.0]
[851, 838, 851]
p03662
u536113865
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
["ai = lambda: list(map(int,input().split()))\nai_ = lambda: [int(x)-1 for x in input().split()]\n\nn = int(input())\n\npath = [[] for _ in range(n)]\nfor _ in range(n-1):\n a,b = ai_()\n path[a].append(b)\n path[b].append(a)\n\nfrom collections import deque\nq = deque()\nq.append(0)\n\nd1 = [float('inf') for ...
['Wrong Answer', 'Accepted']
['s653908188', 's536589500']
[39868.0, 38444.0]
[712.0, 691.0]
[875, 832]
p03662
u547167033
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
["n=int(input())\ntree=[[] for i in range(n)]\nfor i in range(n-1):\n a,b=map(int,input().split())\n tree[a-1].append(b-1)\n tree[b-1].append(a-1)\ndef dist(k):\n l=[-1]*n\n node=[k]\n while node:\n s=node.pop()\n d=l[s]\n for t in tree[s]:\n if l[t]!=-1:\n continue\n l[t]=d+1\n nod...
['Wrong Answer', 'Accepted']
['s992030622', 's082684706']
[28976.0, 28976.0]
[580.0, 536.0]
[491, 491]
p03662
u572144347
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['N=int(input())\nimport sys\nab=[list(map(int, input().split())) for _ in range (N-1)]\ncon=[[] for _ in range(N+1)]\n\n#print(ab)\nfor a,b in ab :\n con[a].append(b)\n con[b].append(a)\n\n\npc=[0]*(N+1)\nq=[(1,0)]\nvis=[False]*(N+1)\nvis[1]=True\nFcnt=N\nwhile q:\n n,c=q.pop()\n pc[n]=c\n for ch in con[n]:\n ...
['Time Limit Exceeded', 'Runtime Error', 'Accepted']
['s166148780', 's411811790', 's653256270']
[411220.0, 3064.0, 40140.0]
[2131.0, 18.0, 673.0]
[603, 598, 667]
p03662
u803848678
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
[' \n \n \n # EF-| |-GH...\n \n \n \n \n \n n = int(input())\n INF = 10**6\n graph = [[float("inf")]*n for i in range(n)]\n for i in range(n - 1):\n a, b = map(int, input().split())\n graph[a - 1][b -1] = 1\n graph[b - 1][a - 1] = 1\n \n ...
['Runtime Error', 'Accepted']
['s393382813', 's924871473']
[2940.0, 24980.0]
[17.0, 479.0]
[4670, 471]
p03662
u884982181
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['import sys\nsys.setrecursionlimit(2000000)\nn = int(input())\np = []\nfor i in range(n-1):\n p.append(list(map(int, input().split()))+ [1])\nl = [[] for i in range(n+1)]\nfor pi in p: \n l[pi[0]].append([pi[0],pi[1]])\n l[pi[1]].append([pi[1],pi[0]])\nkyo = [float("inf")]*(n+1)\nkyo[1] = 0\nmemo = [0] * (n+1...
['Wrong Answer', 'Accepted']
['s276286326', 's275474012']
[145604.0, 142340.0]
[1423.0, 1618.0]
[992, 976]
p03662
u957084285
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['n = int(input())\nedges = [[] for _ in range(n)]\n\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\n\ndef bfs(v):\n q = []\n depth = [n]*n\n q.append(v)\n depth[v] = 0\n i = 0\n while i < len(q):\n x = q[i]\n ...
['Wrong Answer', 'Accepted']
['s539314216', 's350195112']
[29788.0, 29788.0]
[584.0, 599.0]
[626, 616]
p03662
u980322611
2,000
262,144
Fennec and Snuke are playing a board game. On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the g...
['class UnionFind:\n def __init__(self, n):\n self.par = [-1 for i in range(n+1)]\n self.rank = [0] * (n+1)\n\n \n def find(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n \n de...
['Wrong Answer', 'Accepted']
['s720861703', 's184788039']
[50208.0, 50208.0]
[538.0, 512.0]
[2097, 2098]
p03665
u017810624
2,000
262,144
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 wa...
['n,p=map(int,input().split())\na=list(map(int,input().split()))\nc=0\nfor i in range(n):\n if a[i]%2==1:\n c=1\n break\nif c=1:print(2**(n-1))\nelse:\n if p=0:print(2**(n))\n else:print(0)', 'n,p=map(int,input().split())\na=list(map(int,input().split()))\nc=0\nfor i in range(n):\n if a[i]%2==1:c+=1\nif c==0:...
['Runtime Error', 'Accepted']
['s539365411', 's535662739']
[2940.0, 3060.0]
[17.0, 17.0]
[186, 225]
p03665
u022317850
2,000
262,144
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 wa...
['def cmb(n, k):\n s = 1\n for j in range(n - k):\n s *= j\n for j in range(1, k+1):\n s //= j\n return s\n\nn, p = map(int, input().split())\naa = list(map(lambda x: int(x) % 2, input().split()))\nodd = sum(aa)\neven = n - odd\nif p == 0:\n c = 2**even * sum(cmb(odd, k) for k in range(0, odd+1, 2))\n print...
['Wrong Answer', 'Accepted']
['s121503991', 's528920547']
[3064.0, 3064.0]
[17.0, 17.0]
[385, 400]
p03665
u060793972
2,000
262,144
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 wa...
['import math\ndef AGC017C(a,f):\n p=0\n for i in range(f,a,2):\n p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)\n return p\n\nn,p=map(int,input().split())\nd={1:0,0:0}\na=list(map(int,input().split()))\nfor i in a:\n d[i%2]+=1\nif p==0:\n print((2**d[0])*AGC017C(d[1]),0)\nelse:\n ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s578014510', 's974725487', 's742854494']
[3064.0, 3064.0, 3064.0]
[17.0, 18.0, 18.0]
[385, 414, 387]
p03665
u077291787
2,000
262,144
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 wa...
['\ndef main():\n n, p = tuple(map(int, input().rstrip().split()))\n A = tuple(map(lambda x: int(x) % 2, input().rstrip().split()))\n if sum(A) == n: # all numbers are even\n print(2 ** n if p == 0 else 0)\n else:\n print(2 ** (n - 1))\n\n\nif __name__ == "__main__":\n main()', '\ndef main...
['Wrong Answer', 'Accepted']
['s484665480', 's482440762']
[3316.0, 3060.0]
[23.0, 18.0]
[313, 292]
p03665
u102461423
2,000
262,144
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 wa...
['N,P = int(input())\nA = [int(x) for x in input().split()]\n\nodd = sum(x&1 for x in A)\n\nif odd:\n \n answer = 2**(N-1)\nelse:\n answer = (2 ** N) * P\n\nprint(answer)', 'import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN, P, *A = map(int,...
['Runtime Error', 'Accepted']
['s541856123', 's878844721']
[2940.0, 8996.0]
[17.0, 28.0]
[186, 272]
p03665
u106778233
2,000
262,144
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 wa...
['N,P=map(int,input().split())\nA=list(map(int,input().split()))\nfor i in range(N):\n A[i]%=2\n\nodds=sum(A)\nevens=N-odds \nif odds>0:\n ans=2**evens \n ans+=2**(odds-1)\n print(ans)\nelse:\n if P==0:\n print(2**evens)\n else:\n print(0)', 'odds=sum(A)\nevens=N-odds \nif odds>0:\n a...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s510391123', 's615371882', 's538281128']
[3060.0, 2940.0, 3064.0]
[17.0, 17.0, 17.0]
[254, 161, 254]