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
p03127
u455317716
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na_li = list(set(int(x) for x in input().split()))\n\nwhile 1:\n res = a_li[-1]\n a_li.sort(reverse = True)\n cou = 0\n for i in a_li[:-1]:\n a_li[cou] = i % a_li[-1]\n cou += 1\n print(a_li)\n a_li = list(set(a_li))\n try:\n a_li.remove(0)\n except:\n pass\n print(a_li)\n if len(a_li) == 0:\n print(res)\n break\n if len(a_li) == 1:\n print(a_li[0])\n break\n', 'n = int(input())\na_li = list(set(int(x) for x in input().split()))\n\nwhile 1:\n res = a_li[-1]\n a_li.sort(reverse = True)\n cou = 0\n for i in a_li[:-1]:\n a_li[cou] = i % a_li[-1]\n cou += 1\n a_li = list(set(a_li))\n try:\n a_li.remove(0)\n except:\n pass\n if len(a_li) == 0:\n print(res)\n break\n if len(a_li) == 1:\n print(a_li[0])\n break\n']
['Runtime Error', 'Accepted']
['s683715962', 's850894299']
[142216.0, 19728.0]
[1420.0, 128.0]
[448, 412]
p03127
u457683760
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import numpy as np\n\nn = int(input())\nA = np.array([int(i) for i in input().split()])\n\nA=np.sort(A)\ns=A[0]\nfor i in range(max([n, s])):\n c = A[0]\n A = A % c\n A[0] = c\n z=A.count(0)\n A=np.sort(A)[z:]\n for j in range(len(A)):\n if A[0] != 0:\n break\n A = np.delete(A, 0)\n if len(A) == 1:\n break\nprint (A[0])', 'import numpy as np\n\nn = int(input())\nA = np.array([int(i) for i in input().split()])\n\nA=np.sort(A)\ns=A[0]\nfor i in range(max([n, s])):\n c = A[0]\n A = A % c\n A[0] = c\n z=len(A) - np.count_nonzero(A)\n A=np.sort(A)[z:]\n if len(A) == 1:\n break\nprint (A[0])\n\n']
['Runtime Error', 'Accepted']
['s902273707', 's974342394']
[23088.0, 23120.0]
[191.0, 200.0]
[355, 279]
p03127
u460245024
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['_N = input()\nA_list = list(map(int, input().split()))\n\nprint("{}".format(A_list))\n\nwhile len(A_list) > 1:\n min_A = min(A_list)\n A_list = [min_A] + [A % min_A for A in A_list if A % min_A != 0]\n print("{}".format(A_list))\n\nprint("{}".format(A_list[0]))', '_N = input()\nA_list = list(map(int, input().split()))\n\nwhile len(A_list) > 1:\n min_A = min(A_list)\n A_list = [min_A] + [A % min_A for A in A_list if A % min_A != 0]\n\nprint("{}".format(A_list[0]))']
['Wrong Answer', 'Accepted']
['s018138551', 's937682001']
[14252.0, 14248.0]
[90.0, 76.0]
[260, 201]
p03127
u465699806
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["n = int(input())\nai = list(map(int, input().split(' ')))\nwhile len(ai) > 1:\n print(ai)\n ai = list(sorted(ai))\n ai_head = ai[0]\n ai = list(filter(lambda x: x != 0, map(lambda x: x%ai_head, list(ai[1:]))))\n ai.append(ai_head)\nprint(ai[0])", "n = int(input())\nai = list(map(int, input().split(' ')))\nwhile len(ai) > 1:\n ai = list(sorted(list(ai)))\n ai_head = ai[0]\n ai = list(filter(lambda x: x != 0, map(lambda x: x%ai_head, list(ai[1:]))))\n ai.append(ai_head)\nprint(ai[0])"]
['Wrong Answer', 'Accepted']
['s762221622', 's664767866']
[14224.0, 14252.0]
[185.0, 168.0]
[251, 243]
p03127
u476124554
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from queue import PriorityQueue\nN = int(input())\nA = map(int, input().split())\nq = PriorityQueue\nfor a in A:\n q.put(a)\nx = q.get()\nwhile not q.empty():\n y=q.get()\n if y == 0:\n break\n q.put(x % y)\n x = y\nprint(x)', 'from queue import PriorityQueue\nN = int(input())\nA = map(int, input().split())\nq = PriorityQueue()\nfor a in A:\n q.put(-a)\nx = -q.get()\nwhile not q.empty():\n y = -q.get()\n if y == 0:\n break\n q.put(-(x % y))\n x = y\nprint(x)']
['Runtime Error', 'Accepted']
['s361376172', 's458840484']
[12212.0, 15192.0]
[36.0, 1826.0]
[219, 243]
p03127
u478588435
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from functools import reduce\nfrom math import gcd\ninput()\nAi = list(map(int, input().strip()))\nprint(reduce(gcd, Ai))', 'from functools import reduce\ndef gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n else:\n return gcd(b, a%b)\ninput()\nAi = list(map(int, input().split()))\nprint(reduce(gcd, Ai))']
['Runtime Error', 'Accepted']
['s151094756', 's280057608']
[3572.0, 14600.0]
[23.0, 85.0]
[117, 219]
p03127
u483722302
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['# -*- coding: utf-8 -*-\nN = map(int, input())\nA = list(map(int, input().split()))\n\nwhile len(A) >= 2:\n largest_elem = A.index(max(A))\n x = A.pop(largest_elem)\n largest_elem = A.index(max(A))\n y = A.pop(largest_elem)\n print(x, y)\n if x == 1 and y == 1:\n A.append(y)\n elif x % y == 0:\n A.append(y)\n else:\n A.append(x % y)\n A.append(y)\n\nprint(A[0])\n', '# -*- coding: utf-8 -*-\nN = map(int, input())\nA = list(map(int, input().split()))\n\nwhile len(A) >= 2:\n idx = A.index(min(A))\n x = A.pop(idx)\n B = list()\n for i in range(len(A)):\n if A[i] % x != 0:\n B.append(A[i] % x)\n B.append(x)\n A = B[:]\n\nprint(A[0])\n']
['Wrong Answer', 'Accepted']
['s080638003', 's066224800']
[14252.0, 14248.0]
[2104.0, 94.0]
[398, 289]
p03127
u485716382
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["def main():\n N = int(input())\n monsters = list(map(int, input().split()))\n\n monsters = sorted(monsters)\n \n\n last = 10000\n while True:\n # print('==============================')\n \n for i in range(1, len(monsters)):\n monsters[i] = monsters[i] % monsters[0]\n\n \n if 0 in monsters:\n monsters.remove(0)\n monsters = sorted(monsters)\n\n \n if len(monsters) == 2:\n last = int(abs(monsters[1] - monsters[0]))\n monsters.remove(monsters[1])\n\n if len(monsters) == 1:\n break\n print(last)\n\n \n\nmain()\n", "def gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a%b)\n\ndef main():\n N = int(input())\n An = list(map(int, input().split(' ')))\n\n\n An = sorted(An)\n An = [gcd(a_n, An[0]) for a_n in An]\n print(min(An))\n\nmain()"]
['Runtime Error', 'Accepted']
['s068945031', 's177532378']
[14252.0, 15020.0]
[132.0, 203.0]
[613, 237]
p03127
u496744988
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = list(map(int, input().split()))\nmini = a.pop(a.index(min(a)))\nsemi_mini = a.pop(a.index(min(a)))\nprint(mini, semi_mini)\nwhile mini > 0 and semi_mini > 0:\n if semi_mini > mini:\n semi_mini -= mini\n else:\n mini -= semi_mini\nprint(max(mini, semi_mini))\n', 'n = int(input())\na = list(map(int, input().split()))\n\n\ndef gcd(a, b):\n if b > 0:\n return gcd(b, a % b)\n else:\n return a\n\n\n\nif len(a) == 1:\n print(a[0])\nelse:\n element = gcd(a[0], a[1])\n if len(a) == 2:\n print(element)\n else:\n for i in range(2, n):\n element = gcd(element, a[i])\n print(element)\n']
['Wrong Answer', 'Accepted']
['s440397863', 's335460257']
[14252.0, 14252.0]
[47.0, 87.0]
[290, 402]
p03127
u497883442
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = list(map(int,input().split()))\na = sorted(a)\ndef gcd(a,b):\n c = a%b\n if c == 0:\n return b\n 0else:\n return gcd(b,c)\nc = 0\nfor i in a[1:]:\n c_ = gcd(i,a[0])\n if c_ == 1:\n c = 1\n break\n else:\n if c_ < c or c == 0:\n c = c_\nprint(c)\n', 'n = int(input())\na = list(map(int,input().split()))\na = sorted(a)\ndef gcd(a,b):\n c = a%b\n if c == 1:\n return b\n else:\n return gcd(b,c)\nc = 0\nfor i in a[1:]:\n c_ = gcd(i,a[0])\n if c_ == 1:\n c = 1\n break\n else:\n if c_ < c:\n c = c_\nprint(c)', 'n = int(input())\na = list(map(int,input().split()))\na = sorted(a)\ndef gcd(a,b):\n c = a%b\n if c == 0:\n return b\n else:\n return gcd(b,c)\nc = 0\nfor i in a[1:]:\n c_ = gcd(i,a[0])\n if c_ == 1:\n c = 1\n break\n else:\n if c_ < c or c == 0:\n c = c_\nprint(c)\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s403976233', 's564362555', 's059525354']
[2940.0, 14252.0, 14252.0]
[17.0, 82.0, 118.0]
[275, 263, 274]
p03127
u502283124
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from sys import stdin\nimport numpy as np\n\nN = int(stdin.readline().rstrip().split()[0])\nA = [int(x) for x in stdin.readline().rstrip().split()]\n# N, X = [int(x) for x in stdin.readline().rstrip().split()]\n\ndef G(_a, _b):\n if _a>=_b:\n a, b = _a, _b\n else:\n a, b = _b, _a\n \n while True:\n c = a%b\n if c == 0:\n break\n a,b = b,c\n \n return b\n\ndef func(L):\n \n if len(unique_L)==1:\n return unique_L[0]\n elif min(unique_L)==1:\n return 1\n else:\n g = G(unique_L[-2], unique_L[-1])\n unique_L[-2] = g\n unique_L.pop()\n return func(unique_L)\nprint(func(list(set(A))))\n ', 'from sys import stdin\nimport numpy as np\n\nN = int(stdin.readline().rstrip().split()[0])\nA = [int(x) for x in stdin.readline().rstrip().split()]\n# N, X = [int(x) for x in stdin.readline().rstrip().split()]\n\ndef G(_a, _b):\n if _a>=_b:\n a, b = _a, _b\n else:\n a, b = _b, _a\n \n while True:\n c = a%b\n if c == 0:\n break\n a,b = b,c\n \n return b\n\nL = np.array(list(set(A)))\nmini = np.min(L)\nyaku = [1]\ni=2\nr_mini = np.sqrt(mini)\nwhile i<=r_mini:\n if mini%i==0:\n yaku.append(i)\n i+=1\nyaku2 = list(map(lambda x: int(mini/x), yaku))\nyaku = yaku[::-1]\nyaku2.extend(yaku)\nfor y in yaku2:\n if np.sum(L%y)==0:\n ans = y\n break\n\nprint(ans)']
['Runtime Error', 'Accepted']
['s591924712', 's025670919']
[23316.0, 23384.0]
[190.0, 252.0]
[630, 658]
p03127
u512007680
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['#ABC118_C\n\nimport fraction\n\nn = int(input())\na = list(map(int,input().split()))\n\nx = fraction.gcd(a[0],a[1])\n\nif n != 2:\n for i in range(2,n):\n x = fraction.gcd(x,a[i])\n \nprint(x)', 'INF = 10 ** 10\n\ndef num(k):\n if k == 1:\n return 2\n elif k == 7:\n return 3\n elif k == 4:\n return 4\n elif k == 2 or k == 3 or k == 5:\n return 5\n elif k == 6 or k == 9:\n return 6\n elif k == 8:\n return 7\n\nn, m = map(int,input().split())\nl = list(map(int,input().split()))\nl.sort(reverse = True)\n \ndp = [(-1) * INF] * (n+1)\n\ndp[0] = 0\n\nfor i in range(2,n+1):\n can = []\n for x in l:\n if i-num(x)>=0:\n can.append(dp[i-num(x)]+1)\n if can == []:\n dp[i] = (-1) * INF\n else:\n dp[i] = max(can)\n \n#print(dp)\n\nanslist = [0] * dp[n]\n\nleft = n\n\nfor j in range(dp[n],0,-1):\n if j == 1:\n for x in l:\n if num(x) == left:\n anslist[j-1] = x\n break\n else:\n for x in l:\n if dp[left-num(x)] == j - 1:\n anslist[j-1] = x\n left = left-num(x)\n break\n \n #print([j,x,left])\n#print(anslist)\n \n \nans = 0\n\nfor j in range(0,dp[n]):\n ans = ans + anslist[j] * (10 ** j)\n\nprint(ans)\n \n ', 'def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\nn = int(input())\na = list(map(int,input().split()))\n\nx = gcd(a[0],a[1])\n\nif n != 2:\n for i in range(2,n):\n x = gcd(x,a[i])\n \nprint(x)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s142052934', 's670699244', 's648181538']
[2940.0, 3064.0, 14252.0]
[19.0, 18.0, 77.0]
[196, 1232, 216]
p03127
u516554284
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n=int(input())\na=list(map(int,input().split()))\n\na=sorted(a)\n\ndef make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n \nc=make_divisors(a[0])\nd=list(c.keys)\n\nd=d.sorted\nf=[]\nfor y in range(len(d))\n e=d[y]\n ch=0\n for x in range(1,n):\n if not a[x]%e==0:\n continue\n ch+=1\n if ch==n-1:\n f.append(e)\n \nprint(max(f))\n \n \n ', 'n=int(input())\na=list(map(int,input().split()))\n\na=sorted(a)\n\ndef make_divisors(n):\n lower_divisors , upper_divisors = [], []\n i = 1\n while i*i <= n:\n if n % i == 0:\n lower_divisors.append(i)\n if i != n // i:\n upper_divisors.append(n//i)\n i += 1\n return lower_divisors + upper_divisors[::-1]\n \nc=make_divisors(a[0])\n\n\nd=sorted(c)\nf=[]\nfor y in range(len(d)):\n e=d[y]\n ch=0\n for x in range(1,n):\n if not a[x]%e==0:\n continue\n ch+=1\n if ch==n-1:\n f.append(e)\n \nprint(max(f))']
['Runtime Error', 'Accepted']
['s401931660', 's062116898']
[9020.0, 20000.0]
[26.0, 917.0]
[587, 557]
p03127
u518042385
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['def gcd(n,m):\n a=min(n,m)\n b=max(n,m)\n while a!=0:\n b,a=a,b%a\n return a\nn=int(input())\nl=list(map(int,input().split()))\nans=l[0]\nfor i in range(1,n):\n ans=gcd(ans,l[i])\nprint(ans)', 'def gcd(n,m):\n a=min(n,m)\n b=max(n,m)\n while a!=0:\n b,a=a,b%a\n return b\nn=int(input())\nl=list(map(int,input().split()))\nans=l[0]\nfor i in range(1,n):\n ans=gcd(ans,l[i])\nprint(ans)']
['Wrong Answer', 'Accepted']
['s774005050', 's322028949']
[14252.0, 14252.0]
[101.0, 110.0]
[187, 187]
p03127
u518064858
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse: \n x=1\n while x>0:\n c=sorted(b)\n c[1]=c[1]-c[0]\n c=sorted(list(set(c)))\n if c[0]==1:\n x=0\n if len(c)==1:\n print(2)\n exit()\nprint(1)\n \n \n\n\n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse: \n x=1\n while x>0:\n c=sorted(b)\n if c[1]%c[0]!=0:\n c[1]=c[1]%c[0]\n else:\n c[1]=c[0]\n c=sorted(list(set(c)))\n if c[0]==1:\n x=0\n if len(c)==1:\n print(2)\n exit()\nprint(1)\n \n \n\n\n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse: \n x=1\n while x>0:\n c=sorted(b)\n c[1]=c[1]-c[0]\n c=sorted(list(set(c)))\n if c[0]==1:\n x=0\n if len(c)==1:\n print(2):\n exit()\nprint(1)\n \n \n\n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse:\n c=sorted(b)\n x=1\n while x>0:\n v=c[0]\n for i in range(len(c)):\n if i!=0:\n c[i]=c[i]%v\n c.removed(0)\n c=sorted(list(set(c)))\n if len(c)==1:\n print(c[0])\n exit()\n if c[0]==1:\n x=0\nprint(1)\n \n \n\n\n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse:\n c=sorted(b)\n x=1\n while x>0:\n v=c[0]\n for i in range(len(c)):\n if i!=0:\n c[i]=c[i]%v\n c.remove(0)\n c=sorted(list(set(c)))\n if len(c)==1:\n print(c[0])\n exit()\n if c[0]==1:\n x=0\nprint(1)\n \n \n\n\n\n', 'n=int(input())\na=list(map(int,input().split()))\nb=list(set(a)) \nif len(b)==1:\n print(b[0])\n exit()\nelse:\n c=sorted(b)\n x=1\n while x>0:\n v=c[0]\n for i in range(len(c)):\n if i!=0:\n c[i]=c[i]%v\n while 0 in c:\n c.remove(0)\n c=sorted(list(set(c)))\n if len(c)==1:\n print(c[0])\n exit()\n if c[0]==1:\n x=0\nprint(1)\n \n \n\n\n\n']
['Time Limit Exceeded', 'Time Limit Exceeded', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s031503590', 's047581070', 's108792064', 's669544840', 's818355652', 's180566470']
[16008.0, 15884.0, 3064.0, 14480.0, 14480.0, 14436.0]
[2104.0, 2104.0, 17.0, 119.0, 123.0, 623.0]
[338, 403, 338, 430, 430, 456]
p03127
u527261492
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import math\nn=int(input())\na=list(map(int,input().split()))\nprint(math.gcd(a))\n ', 'n=int(input())\na=list(map(int,input().split()))\ndef gcd(x,y):\n while x%y>0:\n x,y=y,x%y\n return y\na.sort(reverse=True)\nans=a[0]\nfor j in range(n-1):\n ans=gcd(ans,a[j+1])\nprint(ans)\n ']
['Runtime Error', 'Accepted']
['s026058407', 's155459337']
[15020.0, 14252.0]
[43.0, 117.0]
[85, 188]
p03127
u528376608
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["def main():\n\tN = int(input())\n\tA = list(map(int, input().split()))\n\twhile(len(A) != 1):\n\t\tA.sort()\n\t\tmini = A[0]\n\t\tfor i in range(1, len(A)):\n\t\t\tif i >= len(A):\n\t\t\t\tcontinue\n\t\t\tif A[i] % mini == 0:\n\t\t\t\tA.pop(i)\n\t\t\telse:\n\t\t\t\tA[i] = A[i] % mini\n\t\tA = QUICKSORT(A)\n\t\tpiv = A[0]\n\t\tfor i in range(1, len(A)):\n\t\t\tif i >= len(A):\n\t\t\t\tcontinue\n\t\t\tif A[i] == piv:\n\t\t\t\tA.pop(i)\n\tprint(A[0])\n\nif __name__ == '__main__':\n\tmain()", "def main():\n\tN = int(input())\n\tA = list(map(int, input().split()))\n\twhile(len(A) != 1):\n\t\tA.sort()\n\t\tmini = A[0]\n\t\ti = 1\n\t\twhile(True):\n\t\t\tif A[i] % mini == 0:\n\t\t\t\tA.pop(i)\n\t\t\telse:\n\t\t\t\tA[i] = A[i] % mini\n\t\t\t\ti += 1\n\t\t\tif i == len(A):\n\t\t\t\tbreak\n\t\tA = list(set(A))\n\tprint(A[0])\n\nif __name__ == '__main__':\n\tmain()"]
['Runtime Error', 'Accepted']
['s897077718', 's970565447']
[14428.0, 14252.0]
[832.0, 1573.0]
[416, 312]
p03127
u528470578
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int, input().split()))\n\nAs = sorted(A)\nAs = [a%As[0] if a%As[0] != 0 else As[0] for a in As]\nAs = sorted(As)\n\ndef judge(tmp_one, tmp_two):\n flg = 1\n \n while flg:\n if tmp_two % tmp_one == 0:\n tmp_two = tmp_one\n else:\n tmp_two = tmp_two % tmp_one\n \n if tmp_one % tmp_two == 0:\n tmp_one = twp_two\n else:\n tmp_one = tmp_one % tmp_two\n if tmp_one == tmp_two:\n flg = 0\n \n return tmp_one\ntmp_one = As[0]\nfor i in range(1, N):\n if i == N - 1:\n tmp_two = As[i]\n elif As[i] != As[0]:\n tmp_two = As[i]\n break\n \nans = judge(tmp_one, tmp_two)\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\n\ndef gcd(n, m):\n if n < m:\n temp = n\n n = m\n m = temp\n \n def ecd(n, m):\n if n % m == 0:\n return m\n else:\n temp = n % m\n a = ecd(m, temp)\n return a\n \n return ecd(n, m)\n\ntemp = gcd(A[0], A[1])\nfor i in range(0, N-1):\n temp = gcd(temp, A[i])\n \nprint(temp)']
['Runtime Error', 'Accepted']
['s359646985', 's850149076']
[14480.0, 14228.0]
[138.0, 113.0]
[733, 409]
p03127
u529012223
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fractions\n\nN = int(input())\nA = list(map(int, input().split()))\nans = A[0]\nfor i in range(1, N):\n ans = gcd(ans, A[i])\n \nprint(ans)', 'import math\nfrom functools import reduce\n\ndef gcd(v1, v2):\n if v1 == 0 or v2 == 0:\n return max(v1, v2)\n if v1 % v2 == 0:\n return v2\n return gcd(v2, v1%v2)\n\nN = int(input())\nA = list(map(int, input().split()))\n\nprint(reduce(gcd, A))']
['Runtime Error', 'Accepted']
['s785131869', 's305685448']
[16240.0, 14756.0]
[60.0, 87.0]
[144, 254]
p03127
u539517139
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["n=int(input())\na=list(map(int,input().split()))\nwhile len(a)>1:\n a.sort()\n for i in range(1,n):\n a[i]=a[i]%a[0]\n a.replace(0,'')\n n=len(a)\nprint(a[0])", 'n=int(input())\na=list(map(int,input().split()))\nwhile len(a)>1:\n a.sort()\n for i in range(1,n):\n a[i]=a[i]%a[0]\n a=[i for i in a if not i==0]\n n=len(a)\nprint(a[0])']
['Runtime Error', 'Accepted']
['s273930142', 's960535591']
[15020.0, 14252.0]
[101.0, 167.0]
[157, 170]
p03127
u556589653
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int,input().split()))\nnow = A[0]\nfor i in range(1,N):\n now = math.gcd(A[i],now)\nprint(now)', 'import math\nN = int(input())\nA = list(map(int,input().split()))\nnow = A[0]\nfor i in range(1,N):\n now = math.gcd(A[i],now)\nprint(now)\n']
['Runtime Error', 'Accepted']
['s560936652', 's407654882']
[20128.0, 20332.0]
[50.0, 68.0]
[123, 136]
p03127
u562753067
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import math\n\nn = int(input())\na = [int(x) for x in input().split(" ")]\ng = a.sort()[n - 1]\n\nfor i in range(1, n):\n g = math.gcd(g, a[i])\n \nprint(g)', 'import math\n\n\nn = int(input())\na = [int(x) for x in input().split(" ")]\ng = a.sort()[n - 1]\n\n\nfor i in range(1, n):\n g = math.gcd(g, a[i])\n\n\nprint(g)', 'import math\n\nn = int(input())\na = [int(x) for x in input().split(" ")]\n\nfor i in range(1, n):\n g = math.gcd(g, a[i])\n \n \nprint(g)', 'import math\n\nn = int(input())\na = [int(x) for x in input().split(" ")]\ng = a.sort()[n - 1]\n\nfor i in range(1, n):\n g = math.gcd(g, a[i])\n\nprint(g)\n', 'def gcd(a, b):\n while a != b:\n if a < b:\n b = b - a\n else:\n a = a - b\n return a\n\ndef m(a):\n a.sort()\n b = []\n for i in range(len(a) // 2):\n b.append(gcd(a[i], a[i + 1]))\n return b\n\n \nn = int(input())\na = [int(x) for x in input().split(" ")]\n\nwhile len(a) > 1:\n a = m(a)\n\nprint(g)\n', 'def gcd(a, b):\n while b != a:\n if a < b:\n b = b % a\n if b == 0:\n return a\n elif b < a:\n a = a % b\n if a == 0:\n return b\n return a\n\ndef m(a):\n a.sort()\n l = len(a)\n b = []\n for i in range(l // 2):\n b.append(gcd(a[i], a[l - i - 1]))\n if l % 2 == 1:\n b.append(a[l // 2])\n return list(set(b))\n\n \nn = int(input())\na = [int(x) for x in input().split(" ")]\n\nwhile len(a) > 1:\n a = m(a)\n\nprint(a[0])\n']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s074497268', 's246047787', 's455117914', 's509823560', 's888927444', 's255128722']
[14252.0, 14252.0, 14252.0, 14252.0, 14252.0, 14484.0]
[81.0, 79.0, 46.0, 82.0, 2104.0, 202.0]
[153, 152, 138, 150, 347, 524]
p03127
u570417673
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = [int(i) for i in input().split()]\n\nwhile len(A) > 1:\n min_num = min(A)\n min_index = A.index(min(A))\n for i in range(len(A)):\n if i != min_index:\n A[i] = A[i] % min_num\n if(A[i] == 0):\n A.pop(i)\n\n\nprint(A[0])', 'N = int(input())\nA = [int(i) for i in input().split()]\n\nwhile len(A) > 1:\n min_num = min(A)\n min_index = A.index(min(A))\n for i in range(len(A)):\n if i != min_index:\n A[i] = A[i] % min_num\n\n while 0 in A:\n A.remove(0)\n\nprint(A[0])']
['Runtime Error', 'Accepted']
['s658287466', 's044462828']
[14252.0, 14252.0]
[813.0, 1599.0]
[251, 245]
p03127
u581403769
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = [int(input()) for i in range(n)]\n\ng = gcd(a[0], a[1])\nfor i in range(2, n):\n g = gcd(g, a[i])\n \nprint(g)', 'n = int(input())\na = list(map(int, input().split()))\n\ndef gcd(p, q):\n if q == 0:\n return p\n else:\n return gcd(q, p % q)\n\ng = gcd(a[0], a[1])\nfor i in range(2, n):\n g = gcd(g, a[i])\n\nprint(g)']
['Runtime Error', 'Accepted']
['s289701266', 's313949348']
[11016.0, 20084.0]
[35.0, 87.0]
[131, 213]
p03127
u585056683
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import random\nn = int(input())\nenemies = list(map(int,input().split()))\nwhile True:\n en_at = random.randrange(len(enemies))\n while True:\n en_h = random.randrange(len(enemies))\n if en_at != en_h: break\n enemies[en_h]-=enemies[en_at]\n if enemies[en_h]<=0: enemies.pop(en_h)\n if len(enemies)==1:\n break\nprint(enemies[0])', 'import math\nfrom functools import reduce\n\nn = int(input())\nenemies = list(map(int,input().split()))\ngcd(reduce(math.gcd, enemies))', 'from functools import reduce\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\nn = int(input())\nenemies = list(map(int,input().split()))\nprint(reduce(gcd, enemies))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s269687754', 's834555287', 's539205427']
[15404.0, 14764.0, 14596.0]
[1333.0, 47.0, 76.0]
[331, 130, 186]
p03127
u593567568
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int,input().split()))\n\nA.sort()\nstack = A[1:]\nm = A[0]\n\nwhile stack:\n stack = list(stack)\n l = []\n for x in stack:\n if x % m == 0:\n continue\n l.append(x % m)\n \n m = min(l)\n stack = set(l)\n\nprint(m)\n\n\n\n\n', 'N = int(input())\nA = list(map(int,input().split()))\n\nA.sort()\nstack = A[1:]\nm = A[0]\n\nwhile stack:\n stack = list(stack)\n l = []\n for x in stack:\n if x % m == 0:\n continue\n l.append(x % m)\n \n if not l:\n break\n l.append(m)\n m = min(l)\n stack = set(l)\n\nprint(m)\n']
['Runtime Error', 'Accepted']
['s619315534', 's935955183']
[14252.0, 14224.0]
[114.0, 113.0]
[249, 281]
p03127
u607563136
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = list(map(int,input().split()))\nx = a[0]\nfor i in range(1,n):\n x,y = max(x,a[i]),min(x,a[i])\n print(x,y)\n while y!=0:x,y=y,x%y\nprint(x)', 'n = int(input())\na = list(map(int,input().split()))\n\nx = a[0]\nfor i in range(1,n):\n x,y = max(x,a[i]),min(x,a[i])\n while y!=0:x,y=y,x%y\nprint(x)']
['Wrong Answer', 'Accepted']
['s298226488', 's683426506']
[19924.0, 20044.0]
[158.0, 105.0]
[164, 150]
p03127
u609061751
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nimport numpy as np\nN = int(input())\nA = [int(x) for x in readline().rstrip().split()]\nA = np.array(A, np.int64)\nwhile len(A) > 1:\n A = A[np.nonzero(A)]\n A = np.sort(A)\n minA = A[0]\n A %= minA\n A[0] = minA\nA = A[np.nonzero(A)]\nprint(A[0])', 'import sys\ninput = sys.stdin.readline\nimport numpy as np\nN = int(input())\nA = [int(x) for x in input().rstrip().split()]\nA = np.array(A, np.int64)\nwhile len(A) > 1:\n A = A[np.nonzero(A)]\n A = np.sort(A)\n minA = A[0]\n A %= minA\n A[0] = minA\nA = A[np.nonzero(A)]\nprint(A[0])\n']
['Runtime Error', 'Accepted']
['s414439515', 's048435400']
[21444.0, 23124.0]
[199.0, 199.0]
[368, 288]
p03127
u619197965
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['#copy code\nfrom fractions import gcd\nn=int(input())\na=[int(i) for i in input().split()]\nc=a[0]\nfor i in a:\n c=gcd(c,a)\nprint(c)\n', 'from fractions import gcd\nn=int(input())\na=[int(i) for i in input().split()]\nc=a[0]\nfor i in a:\n c=gcd(c,a)\nprint(c)\n', '\nn=int(input())\na=[int(i) for i in input().split()]\nc=a[0]\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\nfor i in a:\n c=gcd(c,i)\nprint(c)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s123496817', 's237728949', 's733218600']
[16280.0, 16280.0, 14252.0]
[63.0, 65.0, 71.0]
[131, 120, 153]
p03127
u619670102
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['#coding:utf-8\n\nn = int(input())\na = list(map(int,input().split()))\n\nwhile len(a)>1:\n for i in range(1,len(a)):\n a[i] %= a[0]\n a.sort()\n while True:\n if a[0] == 0:\n a.remove(0)\n else:\n break;\n\n', '#coding:utf-8\n\nn = int(input())\na = list(map(int,input().split()))\n\nwhile len(a)>1:\n for i in range(1,len(a)):\n a[i] %= a[0]\n a.sort()\n while True:\n if a[0] == 0:\n a.remove(0)\n else:\n break;\n\nprint(a[0])']
['Wrong Answer', 'Accepted']
['s028018831', 's341210861']
[14252.0, 14252.0]
[1648.0, 1638.0]
[214, 225]
p03127
u620846115
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\nxlist = list(map(int,input().split()))\na = xlist[0]\nfor i in range(1,n):\n a = fractions.gcd(a,xlist[i])\nprint(a)', 'from functools import reduce\nfrom math import gcd\nn = int(input())\nxlist = list(map(int,input().split()))\nprint(reduce(gcd, xlist))']
['Runtime Error', 'Accepted']
['s954776433', 's476882067']
[19876.0, 20480.0]
[52.0, 64.0]
[130, 131]
p03127
u623231048
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\nli = list(map(int,input().split()))\n\nwhile len(li) > 1:\n a = min(li)\n for i in range(len(li)):\n li[i] %= a\n if li[i] == 0:\n li.pop(i)\n \nprint(li[0])\n ', 'n = int(input())\nli = list(map(int,input().split()))\n\nwhile len(li) > 1:\n a = min(li)\n for i in range(len(li)):\n if li[i] != a:\n li[i] %= a\n li = list(set(li))\n if 0 in li:\n li.remove(0)\n \nprint(li[0])\n ']
['Runtime Error', 'Accepted']
['s437215160', 's435633637']
[14252.0, 14252.0]
[798.0, 72.0]
[188, 226]
p03127
u626337957
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nLifes = map(int, input().split())\n\nLifes.sort(key=lambda x:-x)\n\nans = Lifes[N-1]\n\nfor i in range(N):\n for j in range(i, N):\n life = Lifes[i] - Lifes[j]\n if life > 0:\n\t ans = min(ans, life)\nprint(ans)', 'N = int(input())\nLifes = map(int, input().split())\n\nLifes.sort(key=lambda x:-x)\n\nans = Lifes[N-1]\n\nfor i in range(N):\n for j in range(i, N):\n life = Lifes[i] - Lifes[j]\n if life > 0:\n ans = min(ans, life)\nprint(ans)\n', 'N = int(input())\nLifes = list(map(int, input().split()))\n\nLifes.sort(key=lambda x:-x)\n\nans = Lifes[N-1]\n\n\n# for j in range(i, N):\n# life = Lifes[i]%Lifes[j]\n# if life > 0:\n# ans = min(ans, life)\n# print(ans)\n\nupdate = True\nwhile update:\n min_num = ans\n for i in range(N):\n life_mod = Lifes[i]%ans\n if life_mod > 0:\n Lifes[i] = life_mod\n if min_num > life_mod:\n min_num = life_mod\n if ans == min_num:\n update=False\n else:\n ans = min_num\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s201642441', 's507624789', 's628278946']
[2940.0, 11100.0, 14224.0]
[17.0, 27.0, 147.0]
[224, 228, 559]
p03127
u626881915
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = list(map(int, input().split()))\nwhile len(a) > 0:\n m = min(a)\n a = [a[i]%m for i in range(len(a)) if a[i]%m > 0]\n a.append(m)\nprint(m)\n', 'n = int(input())\na = list(map(int, input().split()))\nwhile len(a) > 1:\n m = min(a)\n a = [a[i]%m for i in range(len(a)) if a[i]%m > 0]\n a.append(m)\nprint(m)\n']
['Time Limit Exceeded', 'Accepted']
['s550240220', 's698776938']
[14224.0, 14224.0]
[2108.0, 80.0]
[159, 159]
p03127
u628047647
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fraction\nn = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor x in a:\n ans = fraction.gcd(x,ans)\nprint(ans)\n\n', 'def gcd(a, b):\n if b == 0:\n return a\n return gcd(b,a%b)\nn = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor x in a:\n ans = gcd(x,ans)\nprint(ans)']
['Runtime Error', 'Accepted']
['s149765463', 's690051243']
[2940.0, 14224.0]
[17.0, 73.0]
[133, 175]
p03127
u635958201
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from functions import gcd \nfrom functools import reduce\n\nN=int(input())\nA=list(map(int,input().split()))\n\nprint(reduce(gcd,A))', 'print(1)', 'from functools import reduce\n\nN=int(input())\nA=list(map(int,input().split()))\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\nprint(reduce(gcd,A))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s066922976', 's492385927', 's247917305']
[2940.0, 2940.0, 14596.0]
[17.0, 17.0, 70.0]
[126, 8, 159]
p03127
u639426108
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int, input().split()))\nj = 0\nA.sort()\nfor n in A:\n\tif n%2 == 1:\n\t\tj = 1\na = 0\nfor n in range(1, len(A)-1):\n\tif A[n] % A[0] == 1\n\t\ta = 1\nif a == 0:\n\tj = 3\nif A[0] == A[-1]:\n\tj = 2\nif j == 0:\n\tprint(2)\nelif j == 1:\n\tprint(1)\nelif j == 3:\n\tprint(A[0])\nelse:\n\tprint(A[0])', 'def Gcd(a,b):\n\tif a<b:\n\t\treturn Gcd(b,a)\n\telse:\n\t\tif a%b:\n\t\t\treturn Gcd(b, a%b):\n\t\telse:\n\t\t\treturn b\nN = int(input())\narr = list(map(int,input().split()))\ngcd = arr[0]\nfor i in arr:\n\tgcd = Gcd(gcd, i)\nprint(gcd)', 'def gcd(a, b):\n if a%b ==0:\n return b\n else:\n return gcd(b, a%b)\n\nn = int(input())\na = list(map(int, input().split()))\na.sort()\nfor i in range(n-1):\n a[i+1] = gcd(a[i], a[i+1])\nprint(a[n-1])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s240854057', 's725777627', 's088356050']
[3064.0, 2940.0, 14252.0]
[17.0, 18.0, 135.0]
[297, 211, 214]
p03127
u641406334
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\nmonster = sorted(list(map(int,input().split())))\nmin_HP = min(monster)\ncnt=0\nwhile True:\n tmp = int(monster[-1]/monster[-2])\n monster[-1]-=monster[-2]*tmp\n if monster[-1]<=0:\n monster.pop(-1)\n monster = sorted(monster)\n if min_HP==monster[0]:\n cnt+=1\n if cnt>=2:\n print(min_HP)\n exit()\n else:\n min_HP = monster[0]\n cnt=0\n print(monster)', 'n = int(input())\nmonster = list(map(int,input().split()))\ncnt = 0\nif min(monster)==max(monster):\n print(min(monster))\n exit()\n\nfor hp in monster:\n if hp%2==0:\n cnt+=1\nprint(1 if cnt>0 else 2)\n', 'def gcd(a, b):\n while b:\n a, b = b, a % b\n \n return a\n\nn = int(input())\nmonster = sorted(list(map(int,input().split())))\nans = []\nfor i in range(n-1):\n g = gcd(monster[i], monster[i+1])\n ans.append(g)\nprint(min(ans))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s298540169', 's447677918', 's170682490']
[14252.0, 14224.0, 14224.0]
[101.0, 60.0, 188.0]
[385, 198, 223]
p03127
u645250356
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fraction\ndef monsters(li,n):\n t = temp\n for i in range(1,n-1):\n t = fraction.gcd(t,li[i+1])\n return t\n\nn = int(input())\nli_a = list(map(int,input().split()))\ntemp = li_a[0]\nprint(monsters(li_a,n))', 'import fractions\ndef monsters(li,n):\n t = temp\n for i in range(1,n-1):\n t = fractions.gcd(t,li[i+1])\n return t\n\nn = int(input())\nli_a = list(map(int,input().split()))\ntemp = li_a[0]\nprint(monsters(li_a,n))', 'def gcd(a,b):\n while b:\n a,b = b,a % b\n return a\ndef monsters(li,n):\n t = temp\n for i in range(n-1):\n t = gcd(li[i+1],t)\n return t\n\nn = int(input())\nli_a = list(map(int,input().split()))\ntemp = li_a[0]\nprint(monsters(li_a,n))']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s128395513', 's134397724', 's454376717']
[3064.0, 16296.0, 14252.0]
[18.0, 92.0, 65.0]
[219, 221, 254]
p03127
u655048024
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor i in range(1,N):\n ans = gcd(ans,a[i])\nprint(ans)', 'import math\nN = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor i in range(1,N):\n ans = math.gcd(ans,a[i])\nprint(ans)\n']
['Runtime Error', 'Accepted']
['s880645003', 's721707411']
[19972.0, 20172.0]
[48.0, 69.0]
[116, 134]
p03127
u655110382
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = input()\nA = {int(x) for x in input().split()}\n\nwhile len(A) == 1:\n mn = min(A)\n A = {x % mn for x in A if x % mn != 0}\n A.add(mn)\nprint(A.pop())\n', 'N = input()\nA = {int(x) for x in input().split()}\n\nwhile len(A) != 1:\n mn = min(A)\n A = {x % mn for x in A if x % mn != 0}\n A.add(mn)\nprint(A.pop())']
['Wrong Answer', 'Accepted']
['s563006604', 's657339892']
[19724.0, 19724.0]
[2104.0, 83.0]
[158, 157]
p03127
u667458133
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(max(int, input().split()))\n\ndef gcd(x, y):\n if x % y == 0:\n return y\n else:\n gcd(y, x % y)\n\nnum = A[0]\nfor i in range(1, N):\n num = gcd(max(num, A[i]), min(num, A[i]))\n\nprint(num)', 'N = int(input())\nA = list(map(int, input().split()))\n \ndef gcd(x, y):\n if x % y == 0:\n return y\n else:\n return gcd(y, x % y)\n \nnum = A[0]\nfor i in range(1, N):\n num = gcd(max(num, A[i]), min(num, A[i]))\n \nprint(num)\n']
['Runtime Error', 'Accepted']
['s591477207', 's217838326']
[11096.0, 14252.0]
[26.0, 111.0]
[214, 225]
p03127
u672494157
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import sys\nimport math\nfrom collections import deque\n\nsys.setrecursionlimit(4100000)\n\n\ndef inputs(num_of_input):\n ins = [input() for i in range(num_of_input)]\n return ins\n\n\ndef gcd_multi(nums):\n if len(nums) == 0:\n return 0\n if len(nums) <= 2:\n return min(nums)\n\n ret = math.gcd(nums.pop(), nums.pop())\n while len(nums) > 0:\n ret = math.gcd(ret, nums.pop())\n return ret\n\n\ndef solve(inputs):\n monsters = string_to_int(inputs[0])\n return gcd_multi(monsters)\n\n\ndef string_to_int(string):\n return list(map(lambda x: int(x), string.split()))\n\n\nif __name__ == "__main__":\n ret = solve(inputs(1))\n print(ret)\n', 'import sys\nfrom collections import deque\n\nsys.setrecursionlimit(4100000)\n\n\ndef inputs(num_of_input):\n ins = [input() for i in range(num_of_input)]\n return ins\n\n\ndef gcd(a, b):\n if a == 0:\n return b\n if b == 0:\n return a\n\n if a > b:\n return gcd(b, a % b)\n else:\n return gcd(a, b % a)\n\n\ndef gcd_multi(nums):\n if len(nums) == 0:\n return 0\n if len(nums) == 1:\n return nums[0]\n\n ret = gcd(nums.pop(), nums.pop())\n while len(nums) > 0:\n ret = gcd(ret, nums.pop())\n return ret\n\n\ndef solve(inputs):\n monsters = string_to_int(inputs[0])\n return gcd_multi(monsters)\n\n\ndef string_to_int(string):\n return list(map(lambda x: int(x), string.split()))\n\n\nif __name__ == "__main__":\n input()\n ret = solve(inputs(1))\n print(ret)']
['Wrong Answer', 'Accepted']
['s197320528', 's036289166']
[3316.0, 15420.0]
[21.0, 101.0]
[659, 810]
p03127
u676496404
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['def gcd(m,n):\n while n:\n m,n = n, m%n\n return m\nn = int(input())\nm = map(int,input().split())\nans = m[0]\nfor i in range(1,n):\n ans = gcd(m[i],ans)\nprint(ans)', 'def gcd(m,n):\n while n:\n m,n = n, m%n\n return m\nn = int(input())\nm = list(map(int,input().split()))\nans = m[0]\nfor i in range(1,n):\n ans = gcd(m[i],ans)\nprint(ans)']
['Runtime Error', 'Accepted']
['s444100380', 's620035540']
[11096.0, 14224.0]
[30.0, 73.0]
[173, 179]
p03127
u682467216
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from math import floor, ceil, sqrt, factorial, log\nfrom itertools import accumulate, permutations, combinations, product, combinations_with_replacement\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush, heappushpop\nimport sys\nINF = float(\'inf\')\nmod = 10**9+7\n\n# 1 2 3\n# a, b, c = LI()\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\n\n# a = I()\n\n\ndef I(): return int(sys.stdin.buffer.readline())\n\n\n# a, b = LS()\n\n\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\').split()\n\n# a = S()\n\n\ndef S(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\')\n\n# 2\n# 1\n# 2\n# [1, 2]\n\n\ndef IR(n): return [I() for i in range(n)]\n\n# 2\n# 1 2 3\n# 4 5 6\n# [[1,2,3], [4,5,6]]\n\n\ndef LIR(n): return [LI() for i in range(n)]\n\n# 2\n# abc\n\n\n\n\ndef SR(n): return [S() for i in range(n)]\n\n# 2\n\n\n\n\n\ndef LSR(n): return [LS() for i in range(n)]\n\n# 2\n# abcd\n# efgh\n# [[a,b,c,d], [e,f,g,h]]\n\n\ndef SRL(n): return [list(S()) for i in range(n)]\n\n\ndef main():\n n = I()\n lst = LI()\n flg = 0\n for a in lst:\n if a % 2 == 1:\n flg = 1\n break\n if flg == 1:\n print(1)\n else:\n m = min(lst)\n for i in range(n):\n if lst[i] % m == 0:\n lst[i] = m\n else:\n lst[i] %= m\n print(min(min(lst), m - min(lst)))\n\n\nif __name__ == "__main__":\n main()\n', 'from math import floor, ceil, sqrt, factorial, log, gcd\nfrom itertools import accumulate, permutations, combinations, product, combinations_with_replacement\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush, heappushpop\nimport sys\nINF = float(\'inf\')\nmod = 10**9+7\n\n\ndef lcm(a, b): return a * b / gcd(a, b)\n\n# 1 2 3\n# a, b, c = LI()\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\n\n# a = I()\n\n\ndef I(): return int(sys.stdin.buffer.readline())\n\n\n# a, b = LS()\n\n\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\').split()\n\n# a = S()\n\n\ndef S(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\')\n\n# 2\n# 1\n# 2\n# [1, 2]\n\n\ndef IR(n): return [I() for i in range(n)]\n\n# 2\n# 1 2 3\n# 4 5 6\n# [[1,2,3], [4,5,6]]\n\n\ndef LIR(n): return [LI() for i in range(n)]\n\n# 2\n# abc\n\n\n\n\ndef SR(n): return [S() for i in range(n)]\n\n# 2\n\n\n\n\n\ndef LSR(n): return [LS() for i in range(n)]\n\n# 2\n# abcd\n# efgh\n# [[a,b,c,d], [e,f,g,h]]\n\n\ndef SRL(n): return [list(S()) for i in range(n)]\n\n\ndef main():\n n = I()\n lst = LI()\n print(gcd(lst))\n\n\nif __name__ == "__main__":\n main()\n', 'from math import floor, ceil, sqrt, factorial, log, gcd\nfrom itertools import accumulate, permutations, combinations, product, combinations_with_replacement\nfrom bisect import bisect_left, bisect_right\nfrom collections import Counter, defaultdict\nfrom heapq import heappop, heappush, heappushpop\nimport sys\nINF = float(\'inf\')\nmod = 10**9+7\n\n\ndef lcm(a, b): return a * b / gcd(a, b)\n\n# 1 2 3\n# a, b, c = LI()\n\n\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\n\n# a = I()\n\n\ndef I(): return int(sys.stdin.buffer.readline())\n\n\n# a, b = LS()\n\n\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\').split()\n\n# a = S()\n\n\ndef S(): return sys.stdin.buffer.readline().rstrip().decode(\'utf-8\')\n\n# 2\n# 1\n# 2\n# [1, 2]\n\n\ndef IR(n): return [I() for i in range(n)]\n\n# 2\n# 1 2 3\n# 4 5 6\n# [[1,2,3], [4,5,6]]\n\n\ndef LIR(n): return [LI() for i in range(n)]\n\n# 2\n# abc\n\n\n\n\ndef SR(n): return [S() for i in range(n)]\n\n# 2\n\n\n\n\n\ndef LSR(n): return [LS() for i in range(n)]\n\n# 2\n# abcd\n# efgh\n# [[a,b,c,d], [e,f,g,h]]\n\n\ndef SRL(n): return [list(S()) for i in range(n)]\n\n\ndef main():\n n = I()\n lst = LI()\n ans = lst[0]\n for i in range(1, n):\n ans = gcd(ans, lst[i])\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s141928068', 's581556071', 's219489688']
[19220.0, 19248.0, 19172.0]
[66.0, 48.0, 59.0]
[1512, 1248, 1317]
p03127
u684120680
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fractions\nimport functools\n\nn = int(input())\na = [int(i) for i in input().split()]\na = list(set(a))\n\nb = [i%2 for i in a if i%2 !=0]\n\nif len(b) != 0:\n print(1)\nelse:\n print(functools.reduce(fractions.gcd, a))', 'def gcd(a,b):\n if a%b == 0:\n return(a)\n else:\n return(gcd(b,a%b))\n\nn = int(input())\na = [int(i) for i in input().split()]\na.sort()\n\nfor i in range(n-1):\n a.insert(0,gcd(a[1],a[0]))\n del a[1:3]\n\nprint(a[0])', 'def gcd(a,b):\n if b == 0:\n return(a)\n else:\n return(gcd(b,a%b))\n\nn = int(input())\na = [int(i) for i in input().split()]\na.sort()\n\ntmp = a[0]\nfor i in range(1,n):\n tmp = gcd(a[i],tmp)\n\nans = tmp\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s828365216', 's885454892', 's520618849']
[16496.0, 14224.0, 14224.0]
[85.0, 2104.0, 118.0]
[217, 215, 213]
p03127
u687044304
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['# -*- coding:utf-8 -*-\nimport fractions\n\ndef solve():\n N = input()\n A = list(map(int, input().split()))\n\n \n \n\n ans = A[0]\n for i in range(1, N):\n ans = fractions.gcd(ans, A[i])\n print(ans)\n\nif __name__ == "__main__":\n solve()\n', 'def gcd(a, b):\n \n if b == 0:\n return a\n else:\n return gcd(b, a%b)\n\n\ndef solve():\n N = int(input())\n A = [int(x) for x in input().split(" ")]\n\n A.sort(reverse=True)\n ans = A[0]\n for i in range(1, N):\n ans = gcd(ans, A[i])\n\n print(ans)\n\n\nif __name__ == "__main__":\n solve()']
['Runtime Error', 'Accepted']
['s813035672', 's922313596']
[16276.0, 14252.0]
[63.0, 125.0]
[398, 374]
p03127
u688375653
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['INFO=int(input())\n\nDATA=list(map(int, input().split(" ")))\nDATA=sorted(DATA)\n\ndef Euclidean(m,n):\n while n!=0:\n temp = n\n n = m%n\n m=temp\n return m\n \noutput=DATA[0]\nfor i in range(1,INFO):\n print(output)\n output = Euclidean(DATA[i], output)\nprint(output)', 'INFO=int(input())\nDATA=list(map(int, input().split(" ")))\nDATA=sorted(DATA)\ndef Euclidean(m,n):\n while n!=0:\n temp = n\n n = m%n\n m=temp\n return m\n \noutput=DATA[0]\nfor i in range(1,INFO):\n output = Euclidean(DATA[i], output)\n\nprint(output)']
['Wrong Answer', 'Accepted']
['s403352460', 's158054616']
[14252.0, 14224.0]
[172.0, 108.0]
[290, 271]
p03127
u712975113
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N=int(input())\na=list(map(int,input().split()))\ndef u(x,y):\n if x%y==0:\n return y\n else:\n return u(y,x%y)\nb=list(range(N-1))\nfor i in range(1,N):\n b[i-1]=u(a[i-1],a[i])\nprint(int(b[N-2]))', 'N=int(input())\na=list(map(int,input().split()))\ndef u(x,y):\n if x%y==0:\n return y\n else:\n return u(y,x%y)\nb=list(range(N-1))\nfor i in range(1,N):\n b[i]=u(b[i-1],a[i])\nprint(int(b[N-2]))', 'N=int(input())\na=list(map(int,input().split()))\ndef u(x,y):\n if x%y==0:\n return y\n else:\n return u(y,x&y)\nb=list(range(N-1))\nfor i in range(1,N):\n b[i-1]=u(a[i-1],a[i])\nprint(int(b[N-2]))', 'N=int(input())\na=list(map(int,input().split()))\ndef u(x,y):\n if x%y==0:\n return y\n else:\n return u(y,x%y)\nb=list(range(N))\nb[0]=a[0]\nfor i in range(1,N):\n b[i]=u(b[i-1],a[i])\nprint(int(b[N-1]))']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s182190553', 's692070075', 's816961065', 's561973678']
[14252.0, 14224.0, 14252.0, 14252.0]
[432.0, 97.0, 109.0, 97.0]
[210, 208, 210, 216]
p03127
u714533789
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import random\n\nn = int(input())\nm = [int(i) for i in input().split()]\n\nwhile True:\n\ta = m.pop(random.randrange(n)); n -= 1\n\tb = m.pop(random.randrange(n)); n -= 1\n\ta -= b\n\tm.extend([a, b]); n += 2\n\tprint(m)\n\tfor i in m:\n\t\tif i <= 0:\n\t\t\tm.remove(i); n -= 1\n\tif len(m) == 1: print(m[0]); exit()', 'def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\nn = int(input())\na = list(map(int, input().split()))\nans = a[0]\nfor i in range(1, n):\n\tans = gcd(ans, a[i])\nprint(ans)']
['Runtime Error', 'Accepted']
['s479971287', 's952602918']
[142904.0, 15020.0]
[2104.0, 72.0]
[292, 172]
p03127
u729938879
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\nmonsters = list(map(int, input().split()))\ndef gcd(a, b):\n if b == 0: \n return a\n else:\n return gcd(b, a%b)\ngcd(4,2)\n\ndef gcd_more(a):\n ans = a[0]\n for i in range(1,len(a)):\n ans = gcd(ans, a[i])\n return ans\ngcd_more(monsters)', 'n = int(input())\nmonsters = list(map(int, input().split()))\ndef gcd(a, b):\n if b == 0: \n return a\n else:\n return gcd(b, a%b)\ngcd(4,2)\n\ndef gcd_more(a):\n ans = a[0]\n for i in range(1,len(a)):\n ans = gcd(ans, a[i])\n return ans\nprint(gcd_more(monsters))']
['Wrong Answer', 'Accepted']
['s265401722', 's361329192']
[14224.0, 14224.0]
[84.0, 84.0]
[280, 287]
p03127
u732468087
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nHPs = list(map(int, input().split()))\n\nwhile len(HPs) > 1:\n HPs.sort()\n for i in range(len(HPs)-1):\n HPs[i+1] = HPs[i+1] % HPs[0]\n HPs.remove(0)\n\nprint(HPs[0])', 'N = int(input())\nHPs = list(map(int, input().split()))\n\nwhile len(HPs) > 1:\n HPs.sort()\n for i in len(HPs):\n HPs[i+1] = HPs[i+1] % HPs[0]\n HPs.remove(0)\n\nprint(HPs[0])', 'N = int(input())\nHPs = list(map(int, input().split()))\n\nprint(N)\nprint(HPs)\n\nwhile len(HPs) > 1:\n HPs.sort()\n for i in range(len(HPs)-1):\n HPs[i+1] = HPs[i+1] % HPs[0]\n if 0 in HPs: \n HPs.remove(0)\n\nprint(HPs[0])', 'N = int(input())\nHPs = list(map(int, input().split()))\n\nwhile len(HPs) > 1:\n HPs.sort()\n for i in range(len(HPs)-1):\n HPs[i+1] = HPs[i+1] % HPs[0]\n while 0 in HPs:\n HPs.remove(0)\n\nprint(HPs[0])']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s380244694', 's515995199', 's826050220', 's947759113']
[14224.0, 14828.0, 14224.0, 14224.0]
[145.0, 77.0, 155.0, 1705.0]
[192, 183, 235, 216]
p03127
u732870425
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nans = A[0]\nfor i in range(n):\n ans = gcd(ans, A[i])\n\n print(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nans = A[0]\nfor i in range(n):\n ans = gcd(ans, A[i])\n\nprint(ans)', 'N = int(input())\nA = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nans = A[0]\nfor i in range(N):\n ans = gcd(ans, A[i])\n\nprint(ans)']
['Runtime Error', 'Runtime Error', 'Accepted']
['s149222683', 's187624843', 's276096499']
[14252.0, 14224.0, 14224.0]
[43.0, 43.0, 92.0]
[211, 207, 207]
p03127
u756782069
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import numpy as np\nN = int(input())\nA = list(map(int,input().split()))\nflag = 0\n#mi = min(A)\nQ = np.array(A)\nan = 1\ndef toku(Q):\n mi = min(Q)\n R1 = Q % mi\n if any(R1) == 0:\n flag = 1\n an = mi\n return(R1)\n else:\n R = R1[R1!=0]\n return(R)\n\nwhile flag == 1:\n Q = toku(Q)\n\nprint(an)', 'import numpy as np\nN = int(input())\nA = list(map(int,input().split()))\nflag = 0\n#mi = min(A)\nQ = np.array(A)\nan = 1\ndef toku(Q):\n mi = min(Q)\n R1 = Q % mi\n if any(R1) == 0:\n flag = 1\n an = mi\n return flag, an, R1\n else:\n flag = 0\n an = 1\n ind = np.argmin(Q)\n R1[ind] = mi\n R = R1[R1!=0]\n return flag, an, R\n\nwhile flag == 0:\n flag,an,PP = toku(Q)\n Q = PP\n\nprint(an)']
['Wrong Answer', 'Accepted']
['s590593636', 's079934942']
[24356.0, 23136.0]
[181.0, 210.0]
[328, 446]
p03127
u762540523
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\ndef gcdl(l):\n from functools import reduce\n reduce(lambda x, y: gcd(x, y), a)\nn=input()\nprint(gcdl(list(map(int,input().split()))))', 'def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\ndef gcdl(l):\n from functools import reduce\n return reduce(lambda x, y: gcd(x, y), l)\nn=input()\nprint(gcdl(list(map(int,input().split()))))']
['Runtime Error', 'Accepted']
['s567097311', 's943038351']
[14252.0, 14252.0]
[48.0, 73.0]
[202, 209]
p03127
u782685137
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N=input()\nA=set(map(int,input().split()))\nR=max(A)\nwhile 1:\n r=min(A)\n if r==R:break\n A=set(i if i<=r else i%r for i in A)\n A=set(i for i in A if i!=0)\n R=r\n print(A)\nprint(R)', 'input()\nA=set(map(int,input().split()))\nR=max(A)\nwhile 1:\n r=min(A)\n if r==R:break\n A=set(i%r for i in A)-{0}|{r};R=r\nprint(R)']
['Wrong Answer', 'Accepted']
['s120986604', 's987229647']
[19728.0, 19728.0]
[80.0, 78.0]
[193, 126]
p03127
u783420291
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import random\nN = int(input())\nA = list(map(int, input().split()))\n\nwhile len(A) != 1:\n print(A)\n attack_monster = random.randint(0,10**9) % len(A)\n damage_monster = random.randint(0,10**9) % len(A)\n if attack_monster != damage_monster:\n A[damage_monster] = A[damage_monster] - A[attack_monster]\n if A[damage_monster] <= 0:\n del A[damage_monster]\nprint(A[0])', 'def euclid_devider(num_devided, num_devider):\n while num_devided % num_devider != 0:\n temp = num_devided % num_devider\n num_devided = num_devider\n num_devider = temp\n return num_devider\n\nN = int(input())\nA = list(map(int, input().split()))\nans = A[0]\nfor i in range(1,N):\n ans = euclid_devider(A[i], ans)\nprint(ans)']
['Runtime Error', 'Accepted']
['s761206973', 's688367662']
[143548.0, 14252.0]
[1760.0, 71.0]
[395, 345]
p03127
u784169501
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["N = int(input())\nL = [int(s) for s in input().split(' ')]\n\nwhile len(L) > 1:\n\tL.sort()\n if L[-1] % L[0] == 0:\n L.pop()\n else:\n L[-1] = L[-1] % L[0]\nprint(L[0])", "N = int(input())\nL = [int(s) for s in input().split(' ')]\n\nwhile len(L) > 1:\n L.sort()\n L_new = [L[0]]\n for l in L[1:]:\n v = l % L_new[0]\n if v != 0:\n L_new.append(v)\n L = L_new\nprint(L[0])"]
['Runtime Error', 'Accepted']
['s014360880', 's188101501']
[2940.0, 14252.0]
[17.0, 158.0]
[175, 204]
p03127
u795021383
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nlista = list(set(sorted(list(map(int, input().split())))))\nlength = len(lista)\nwhile length>1:\n print(length)\n print(lista)\n for n in range(1, length):\n print(lista[n-1])\n lista[n] = lista[n]%lista[0]\n print(lista)\n lista.sort()\n print(lista)\n lista = list(set(lista))\n if lista[0] == 0:\n lista.remove(0)\n print(lista)\n length = len(lista)\nprint(lista[0]) \n', 'N = int(input())\nlista = sorted(list(map(int, input().split())))\nlength = 2\nwhile length>1:\n #print(length)\n #print(lista)\n for n in range(1, length):\n print(lista[n-1])\n lista[n] = lista[n]%lista[0]\n #print(lista)\n lista = list(set(lista))\n lista.sort()\n if lista[0] == 0:\n lista.remove(0)\n #print(lista)\n length = len(lista)\nprint(lista[0]) ', 'N = int(input())\nlista = sorted(list(map(int, input().split())))\nlength = 2\nwhile length>1:\n #print(length)\n #print(lista)\n for n in range(1, length):\n lista[n] = lista[n]%lista[0]\n #print(lista)\n lista = list(set(lista))\n lista.sort()\n if lista[0] == 0:\n lista.remove(0)\n #print(lista)\n length = len(lista)\nprint(lista[0]) \n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s670056725', 's966464835', 's205856837']
[69520.0, 14864.0, 14864.0]
[2108.0, 236.0, 154.0]
[428, 394, 369]
p03127
u800396927
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int,input().split()))\n\n\n# ans = set()\n# for a in A:\n# if a%v!=0:\n# ans.add(a%v)\n# ans.add(v)\n# return ans\n\n# while len(A)>1:\n# A = helper(A)\n# print(min(A))\ndef gcd(x,y):\n if y==0: return x\n return gcd(y,x%y)\nans = A[0]\nfor a in A:\n ans = gcd(ans,i)\nprint(ans)', 'N = int(input())\nA = list(map(int,input().split()))\n\ndef gcd(x,y):\n if y==0: return x\n return gcd(y,x%y)\nans = A[0]\nfor a in A:\n ans = gcd(ans,a)\nprint(ans)']
['Runtime Error', 'Accepted']
['s434452235', 's365913251']
[14252.0, 14224.0]
[42.0, 84.0]
[371, 165]
p03127
u810356688
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["import sys\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n n=int(input())\n A=np.array([int(_) for _ in input().split()])\n while A.size>1:\n min_A=np.min(A)\n A=np.fmod(A,min_A)\n A=A[A>0]\n A=np.append(A,min_A)\n print(A)\n print(A[0])\n \n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nimport numpy as np\ndef main():\n n=int(input())\n A=np.array([int(_) for _ in input().split()])\n while A.size>1:\n min_A=np.min(A)\n A=np.fmod(A,min_A)\n A=A[A>0]\n A=np.append(A,min_A)\n print(A[0])\n \n\nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s056962973', 's836076574']
[23120.0, 23116.0]
[187.0, 187.0]
[352, 335]
p03127
u812587837
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['\nN = int(input())\nA = list(map(int, input().split()))\n\nwhile(len(set(A)) != 1):\n print(A)\n for i in range(N):\n if A[i] > min(A):\n time = A[i] // min(A)\n if time == 1:\n A[i] =A[i] - time * min(A)\n else:\n A[i] =A[i] - (time - 1) * min(A)\n \nprint(min(A))', '\nN = int(input())\nA = list(map(int, input().split()))\njlist=[True]\ncnt = 0\nwhile(min(A) !=1 and len(set(A)) != 1):\n cnt = 0\n for i in range(N):\n if A[i] - min(A) > 0:\n A[i] = A[i] - min(A)\n print(A)\nprint(min(A))', '\nN = int(input())\nA = list(map(int, input().split()))\n\nwhile(len(set(A)) != 1):\n minA = min(A)\n for i in range(N):\n if A[i] > minA:\n time = A[i] // minA\n if time == 1:\n A[i] =A[i] - time * minA\n else:\n A[i] =A[i] - (time - 1) * minA\n \nprint(min(A))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s184888026', 's626339977', 's190182931']
[14480.0, 142676.0, 14480.0]
[2108.0, 2104.0, 257.0]
[373, 272, 371]
p03127
u813450934
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = list(map(int, input().split()))\na.sort()\nwhile len(a) >= 2 :\n k = a[1] % a[0]\n if k == 0 :\n a.pop(1)\n else :\n a[1] = k\n a.sort()\n print(a)\n if a[0] == 1 :\n break\nprint(a[0])\n', 'n = int(input())\na = list(map(int, input().split()))\na.sort()\nwhile len(a) >= 2 :\n k = a[1] % a[0]\n if k == 0 :\n a.pop(1)\n else :\n a[1] = k\n a[0], a[1] = a[1], a[0]\nprint(a[0])\n']
['Runtime Error', 'Accepted']
['s483334489', 's795104859']
[142648.0, 14252.0]
[1866.0, 1595.0]
[234, 207]
p03127
u814781830
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\narray = [int(k) for k in input().split()]\narray.reverse()\nresult = 0\nm = 0\nfor i, num in enumerate(array):\n if i == 0:\n m = num\n else:\n if m % num != 0:\n result += num - m % num\nprint(result)', 'N = int(input())\nMONSTER = list(map(int, input().split()))\n\ndef euclidean(a, b):\n if b == 0:\n return a\n return euclidean(b, a % b)\n\nfor i in range(1, len(MONSTER)):\n MONSTER[i] = euclidean(MONSTER[i-1], MONSTER[i])\nprint(MONSTER[len(MONSTER) - 1])\n']
['Wrong Answer', 'Accepted']
['s597376324', 's785790014']
[14224.0, 14224.0]
[87.0, 97.0]
[239, 254]
p03127
u815666840
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['infa = 10**10\nn = int(input())\na = list(map(int,input().split()))\n\nfor k in range(infa):\n mina = min(a)\n print("ループ")\n\n for i in range(len(a)):\n \n if a[i] == mina:\n a[i] = mina\n else:\n a[i] = a[i] % mina\n \n a = [j for j in a if not j == 0]\n\n if len(a) == a.count(mina):\n break\n\nprint(mina)\n', 'infa = 10**10\nn = int(input())\na = list(map(int,input().split()))\n\nfor k in range(infa):\n mina = min(a)\n\n for i in range(len(a)):\n \n if a[i] == mina:\n a[i] = mina\n else:\n a[i] = a[i] % mina\n \n a = [j for j in a if not j == 0]\n\n if len(a) == a.count(mina):\n break\n\nprint(mina)\n']
['Wrong Answer', 'Accepted']
['s227172094', 's475090708']
[14252.0, 14224.0]
[104.0, 108.0]
[363, 340]
p03127
u823885866
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import math\nfrom functools import reduce\nprint(reduce(math.gcd,map(int,input().split())))', 'import math\nprint(reduce(math.gcd,map(int,input().split())))', 'import math\nimport functools\ninput()\nprint(functools.reduce(math.gcd,map(int,input().split())))']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s166649349', 's473562248', 's260646112']
[9576.0, 9108.0, 17568.0]
[33.0, 25.0, 56.0]
[89, 60, 95]
p03127
u824237520
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import numpy as np\n\nn = int(input())\nx = list(map(int, input().split()))\n\ndef numpy_gcd(a, b):\n a, b = np.broadcast_arrays(a, b)\n a = a.copy()\n b = b.copy()\n pos = np.nonzero(b)[0]\n while len(pos) > 0:\n b2 = b[pos]\n a[pos], b[pos] = b2, a[pos] % b2\n pos = pos[b[pos] != 0]\n return a\n\nwhile len(x) > 1:\n i = 0\n next = []\n while i < len(x) - 1:\n next.append(numpy_gcd(x[i],x[i+1]))\n i += 2\n\n x = [] + next\n\nprint(x[0])', 'n = int(input())\nx = list(map(int, input().split))\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\nwhile len(x) > 1:\n i = 0\n next = []\n while i < len(x) - 1:\n next.append(gcd(x[i], x[i+1]))\n i += 2\n\n x = [] + next\n\nprint(x[0])', 'n = int(input())\nx = list(map(int, input().split()))\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\nwhile len(x) > 1:\n i = 0\n next = []\n while i < len(x) - 1:\n next.append(gcd(x[i], x[i+1]))\n i += 2\n\n x = [] + next\n\nprint(x[0])']
['Runtime Error', 'Runtime Error', 'Accepted']
['s123110486', 's305564962', 's619828108']
[23084.0, 5132.0, 14252.0]
[182.0, 19.0, 248.0]
[481, 322, 324]
p03127
u828365778
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['input()\nA = list(map(int, input().split(" ")))\nA.sort()\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\nrtn = 0\nfor i in range(0,len(A)-1):\n print(A[i], A[i+1], gcd(A[i], A[i+1]))\n A[i+1] = gcd(A[i], A[i+1])\nprint(A[-1])', 'input()\nA = list(map(int, input().split(" ")))\nA.sort()\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\nrtn = 0\nfor i in range(0,len(A)-1):\n A[i+1] = gcd(A[i], A[i+1])\nprint(A[-1])']
['Wrong Answer', 'Accepted']
['s378749837', 's487212071']
[14252.0, 14252.0]
[333.0, 126.0]
[241, 198]
p03127
u840958781
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n=int(input())\na=list(map(int,input().split()))\nwhile len(a)>1:\n s=min(a)\n a = list(map(lambda x:x-min(a), a))\n a = [i for i in a if i != 0]+[s]\nprint(int(a))', 'n=int(input())\na=list(map(int,input().split()))\namin=min(a)\nwhile len(a)>1:\n s=min(a)\n a = list(map(lambda x:x%s, a))\n a = [i for i in a if i > 0]+[s]\nprint(a[0])']
['Runtime Error', 'Accepted']
['s067013360', 's528173561']
[15020.0, 14224.0]
[2104.0, 82.0]
[167, 171]
p03127
u844902298
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fraction\nn = int(input())\na = list(map(int,input().split()))\nans = a[0]\n\nfor i in range(1,len(a)):\n ans =fraction.gcd(ans,a[i])\nprint(ans)', 'n = int(input())\na = list(map(int,input().split()))\nans = a[0]\n\ndef gcd(x,y):\n d = 0\n if max(x,y) == x:\n x,y = y,x\n while True:\n if y%x == 0:\n return x\n else:\n d = y%x\n y,x = x,d\n\nfor i in range(1,len(a)):\n ans = gcd(ans,a[i])\nprint(ans)']
['Runtime Error', 'Accepted']
['s104129571', 's955436686']
[2940.0, 14252.0]
[18.0, 89.0]
[146, 301]
p03127
u863150907
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['Keita [9:48 PM]\nimport numpy as np\n\nN=int(input()) \nlistA = list(map(int,input().split()))\n\nminA = min(listA)\n\nwhile True:\n minA = min(listA)\n minApos = np.argmin(listA)\n listA = [x % minA for x in listA]\n listA[minApos] = minA\n listA= [x for x in listA if x >0]\n if len(set(listA))==1:\n print(minA)\n break', 'import numpy as np\n \nN=int(input()) \nlistA = list(map(int,input().split()))\n \nminA = min(listA)\n \nwhile True:\n minA = min(listA)\n minApos = np.argmin(listA)\n listA = [x % minA for x in listA]\n listA[minApos] = minA\n listA= [x for x in listA if x >0]\n if len(set(listA))==1:\n print(minA)\n break']
['Runtime Error', 'Accepted']
['s958279022', 's130599261']
[2940.0, 23108.0]
[17.0, 217.0]
[333, 320]
p03127
u866769581
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int,input().split()))\nfor main_loop in range (0,N): \n A.sort()\n de = A.count(0)\n del A[:de]\n li = len(A)\n if A[0] == 1:\n break\n print(A)\n for x in range(1,li):\n A[x] = A[x]%A[0]\n print(A[x])\nprint(A[0])', 'N = int(input())\nA = list(map(int,input().split()))\nflag = True\nwhile len(A) > 1:\n A.sort()\n devided_num = int(A[0])\n devi_lis = [devided_num]\n As = A\n As.pop(0)\n A =[_%devided_num for _ in As if _%devided_num > 0]\n A += devi_lis\nprint(A)', 'N = int(input())\nA = list(map(int,input().split()))\nwhile len(A) > 1:\n A.sort()\n devided_num = int(A[0])\n devi_lis = [devided_num]\n As = A\n As.pop(0)\n A =[_%devided_num for _ in As if _%devided_num > 0]\n A += devi_lis\nprint(A[0])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s263645564', 's781195207', 's388012132']
[14224.0, 14252.0, 14224.0]
[393.0, 138.0, 142.0]
[277, 259, 250]
p03127
u883203948
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\n\ndata = [int(i) for i in input().split()]\n\ni = 0\ndef euq(x,y):\n a = max(x,y)\n b = min(x,y)\n if a % b == 0:\n return b\n else:\n \treturn euq(b, a % b)\n \nprint(data)\n\nwhile i < N-1:\n com = euq(data[i],data[i + 1])\n data[i+1] = com\n i += 1\n \n \n\nprint(com)\n', 'N = int(input())\n\ndata = [int(i) for i in input().split()]\n\ni = 0\ndef euq(x,y):\n a = max(x,y)\n b = min(x,y)\n if a % b == 0:\n return b\n else:\n \treturn euq(b, a % b)\n \nprint(data)\n\nwhile i < N-1:\n com = euq(data[i],data[i + 1])\n data[i+1] = com\n i += 1\n \n \n\nprint(com)\n', 'n = int(input())\ndata = [int(s) for s in input().split()]\n\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n\n\nx = gcd(data[0], data[1])\nfor i in range(2,n-1):\n x = gcd(x,data[i])\nprint(x)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s548912952', 's859785470', 's095610386']
[14252.0, 14224.0, 14224.0]
[150.0, 151.0, 91.0]
[283, 283, 224]
p03127
u887207211
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import sys \nstdin = sys.stdin\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : map(int, stdin.readline().split())\n\nn = ni()\na = list(na())\n\ndef gcd(n, m):\n while m:\n n, m = m, n%m\n return n\n\nans = 1\nfor e in a:\n ans = gcd(ans, e)\nprint(ans)', 'import sys \nstdin = sys.stdin\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : map(int, stdin.readline().split())\n\nn = ni()\na = list(na())\n\ndef gcd(n, m):\n while m:\n n, m = m, n%m\n return n\n\nans = a[0]\nfor e in a[1:]:\n ans = gcd(ans, e)\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s761558936', 's152238564']
[14172.0, 14172.0]
[71.0, 68.0]
[275, 283]
p03127
u892796322
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = int(input())\na = sorted(list(map(int, input().split())))\nwhile True:\n a = list(set(a))\n tmp = a[:]\n for i in tmp:\n if i == a[0]:\n continue\n elif i % a[0] == 0:\n a.remove(i)\n else:\n a.append(i % a[0])\n a.sort()\n if len(a) == 1:\n break\nprint(a[0])\n', 'n = int(input())\na = sorted(list(map(int, input().split())))\nwhile True:\n a = sorted(list(set(a)))\n tmp = sorted(a[:])\n for i in tmp:\n if i == a[0]:\n continue\n elif i % a[0] == 0:\n a.remove(i)\n else:\n a.append(i % a[0])\n if i % a[0] == 1:\n print(1)\n exit()\n a.remove(i)\n if len(a) == 1:\n break\nprint(a[0])\n']
['Time Limit Exceeded', 'Accepted']
['s796860504', 's256416705']
[84204.0, 14864.0]
[2106.0, 334.0]
[326, 431]
p03127
u902468164
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import fraction as math\n\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ninput()\n\nli = [int(i) for i in input().split(" ")]\n\nprint(gcd(*li))', 'from functools import reduce\n\ndef mgcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef gcd(*numbers):\n return reduce(mgcd, numbers)\n\ninput()\n\nli = [int(i) for i in input().split(" ")]\n\nprint(gcd(*li))\n']
['Runtime Error', 'Accepted']
['s483388260', 's737009383']
[2940.0, 14596.0]
[17.0, 73.0]
[179, 218]
p03127
u902973687
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nA = list(map(int, input().split()))\n\ndp = [[max(A) + 1 for _ in range(N)] for _ in range(max(A) + 1)]\nfor i in range(N):\n dp[0][i] = A[i]\nfor i in range(max(A)):\n for j in range(N):\n for k in range(N):\n if not j == k:\n if not dp[i][j] - dp[i][k] <= 0:\n dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] - dp[i][k])\nresult = max(A)\nfor i in dp:\n result = min(result, min(i))\nprint(result)\n', 'N = int(input())\nA = list(map(int, input().split()))\n\n\ndef dcg(a, b):\n while not (a == 0 or b == 0):\n if a > b:\n a %= b\n else:\n b %= a\n return a + b\n\n\nfor i in range(N-1):\n A[i+1] = dcg(A[i], A[i+1])\nprint(A[-1])\n']
['Wrong Answer', 'Accepted']
['s089078395', 's906080418']
[314612.0, 14224.0]
[2125.0, 96.0]
[458, 258]
p03127
u916908463
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import random\n\nN = int(input())\nhps = list(map(int, input().split()))\n\ndef is_fighting(hps):\n suverve = 0\n for hp in hps:\n if hp > 0:\n suverve += 1\n\n if suverve == 1:\n return False\n return True\n\ndef can_atack(hp):\n if hp <= 0:\n return False\n return True\n\nwhile is_fighting(hps):\n a = random.randrange(N)\n b = random.randrange(N)\n while a == b:\n b = random.randrange(N)\n\n if not can_atack(hps[a]) or not can_atack(hps[b]):\n continue\n hps[b] = hps[b] - hps[a] \n \nfor hp in hps:\n if hp > 0:\n print(hp)\n exit()', 'N = int(input())\nhps = sorted(list(map(int, input().split())))\n\nwhile len(hps) > 1:\n for i in range(1, len(hps)):\n hps[i] = hps[i] % hps[0]\n hps = sorted(set(hps))\n if 0 in hps:\n hps.remove(0)\nprint(hps[0])']
['Wrong Answer', 'Accepted']
['s880915516', 's388975851']
[15404.0, 14252.0]
[2104.0, 113.0]
[605, 229]
p03127
u922416423
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N =int(input())\nA = list(map(int, input().split()))\n\n\n\ndef gcd(x,y): \n while y != 0:\n x , y = y , x % y \n return x\n\n\n\n\n\n\ndef gcd(A):\n ans = A[0]\n for i in range(1,N) #range(1,N)= 1,2,...,N-1\n ans = gcd(ans, A[i])\n return ans\nprint(gcd(A))', 'N =int(input())\nA = list(map(int, input().split()))\n\n\n\ndef gcd2(x,y): \n while y != 0:\n x , y = y , x % y \n return x\n\n\n\n\n\n\ndef gcd(A):\n ans = A[0]\n for i in range(1,N): #range(1,N)= 1,2,...,N-1\n ans = gcd2(ans, A[i])\n return ans\nprint(gcd(A))']
['Runtime Error', 'Accepted']
['s553881564', 's049467087']
[2940.0, 14228.0]
[18.0, 70.0]
[376, 379]
p03127
u937529125
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n = map(int, input().split())\nx = list(map(int, input().split()))\ns = math.gcd(x[0],x[1])\nfor i in x:\n s = math.gcd(s,i)\n\nprint(s)', 'import math\nn = int(input())\nl = [int(i) for i in input().split()]\n\ndef gcd(x, y):\n if y == 0:\n return x\n else:\n return gcd(y, x % y) \ns = gcd(l[0],l[1])\nfor i in l:\n s = gcd(s,i)\n \n\nprint(s)']
['Runtime Error', 'Accepted']
['s552679110', 's831739459']
[14252.0, 14252.0]
[41.0, 88.0]
[133, 229]
p03127
u940990031
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['from functools import reduce\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\nnumbers = [int(x) for x in input().split()]\nprint(reduce(gcd, numbers))', 'from functools import reduce\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\nn = int(input())\nnumbers = [int(x) for x in input().split()]\nprint(reduce(gcd, numbers))']
['Wrong Answer', 'Accepted']
['s202432633', 's318495290']
[3700.0, 14748.0]
[24.0, 78.0]
[218, 235]
p03127
u941753895
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n n=I()\n l=LI()\n\n l=list(set(l))\n\n if len(l)==1:\n return l[0]\n\n f=False\n for x in l:\n if x%2==0:\n f=True\n\n if f:\n return 1\n return 2\n\nprint(main())\n', 'import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef I(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\n# GCD\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\ndef main():\n n=I()\n l=LI()\n\n a=l[0]\n for x in l[1:]:\n a=gcd(a,x)\n\n return a\n\nprint(main())\n']
['Wrong Answer', 'Accepted']
['s339430931', 's822715532']
[16600.0, 16604.0]
[83.0, 86.0]
[459, 434]
p03127
u945418216
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['#C\nn = int(input())\naa = list(map(int,input().split()))\n\nprint(aa)\ndef mod(xx):\n bb=[]\n for i in range(len(xx)):\n b = xx[i] if (0<xx[i] and xx[i] <= min(xx)) else xx[i] % min(xx)\n if b>0:\n bb.append(b)\n return bb\n\nwhile True:\n bb = mod(aa)\n # print(bb)\n if min(aa)==min(bb):\n break\n aa=bb\nprint(min(bb))', 'n = int(input())\naa = list(map(int,input().split()))\n\ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\nans=aa[0]\nfor i in range(1,n):\n ans = gcd(ans, aa[i])\nprint(ans)']
['Wrong Answer', 'Accepted']
['s985789976', 's804388550']
[14252.0, 14252.0]
[2104.0, 73.0]
[356, 175]
p03127
u957722693
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n=int(input())\nl=list(map(int,input().split()))\nans=0\ndef gcd(a,b):\n if b==0:return a\n return gcd(b,a%b)\nif n==1:\n ans=x[0]\nelse:\n element = gcd(x[0], x[1])\n if n==2:\n ans=element\n else:\n for i in range(2,n):\n element=gcd(element,x[i])\n ans=element\nprint(ans)', 'n=int(input())\nl=list(map(int,input().split()))\nans=0\ndef gcd(a,b):\n if b==0:return a\n return gcd(b,a%b)\nif n==1:\n ans=l[0]\nelse:\n element = gcd(l[0], l[1])\n if n==2:\n ans=element\n else:\n for i in range(2,n):\n element=gcd(element,l[i])\n ans=element\nprint(ans)']
['Runtime Error', 'Accepted']
['s738882370', 's053732021']
[14252.0, 14252.0]
[42.0, 87.0]
[307, 307]
p03127
u963903527
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['N = int(input())\nl = [int(i) for i in input().split()]\n\nl = sorted(l)\n\nsema = True\nfor i in range(len(l)):\n for j in range(i + 1,len(l)):\n if not l[j] % l[i] == 0:\n sema = False\n break\npre = min(l)\nif sema == True:\n print(pre)\nelse:\n m = l[1] % l[0]\n for i in range(2, len(l)):\n a = l[i] % m\n if a < m and a >= 1:\n m = a\n else:\n print(m)', 'N = int(input())\nl = [int(i) for i in input().split()]\n\nl = sorted(l)\n\n\npre = min(l)\nans = pre\nif all([i % pre == 0 for i in l]):\n print(pre)\nelse:\n\n m = l[1] % l[0]\n for i in range(2, len(l)):\n if i ==2:\n m = l[1] % l[0]\n if m != 0:\n a = l[i] % m\n if a < m and a >= 1:\n m = a\n else:\n ans = m\nprint(ans)\n', 'from fractions import gcd\nfrom functools import reduce\ninput()\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\nprint(gcd(*[int(i) for i in input().split()]))', 'N = int(input())\nl = [int(i) for i in input().split()]\n\nl = sorted(l)\n\n\nsema = True\nmod_list = []\nfor i in range(len(l)):\n for j in range(i + 1,len(l)):\n if not l[j] % l[i] == 0:\n sema = False\n mod_list.append(l[j] % l[i])\nmod_list = set(mod_list)\nif sema == True:\n print(min(l))\nelse:\n ans = min(l)\n print(min([i % m for i in l for m in mod_list if i % m != 0]))\n', '# import math\nfrom functools import reduce\ninput()\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b, a%b)\n\ndef gcds(*numbers):\n return reduce(gcd, numbers)\nprint(gcds(*[int(i) for i in input().split()]))']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s069295111', 's422702556', 's574904639', 's754802112', 's691012200']
[14356.0, 14252.0, 16276.0, 190896.0, 14596.0]
[2104.0, 131.0, 65.0, 2115.0, 86.0]
[421, 401, 165, 405, 234]
p03127
u978261660
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['def main():\n _ = input()\n monsters = [int(n) for n in input().split(" ")]\n max_gcd = reduce(math.gcd, monsters)\n print(max_gcd)\n\nif __name__ == "__main__":\n main()', 'from functools import reduce\n\ndef gcd(a, b):\n x = max(a, b)\n y = min(a, b)\n if x % y == 0:\n return y\n else:\n while x % y != 0:\n z = x % y\n x = y \n y = z\n else:\n return z\n\ndef main():\n _ = input()\n monsters = [int(n) for n in input().split(" ")]\n max_gcd = reduce(gcd, monsters)\n print(max_gcd)\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s523474482', 's578137807']
[14224.0, 14596.0]
[45.0, 98.0]
[178, 421]
p03127
u986985627
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
["from sys import stdin, exit\nfrom math import factorial\ninput = stdin.readline\nlmi = lambda: list(map(int, input().split()))\nmi = lambda: map(int, input().split())\nsi = lambda: input().strip('\\n')\nssi = lambda: input().strip('\\n').split()\n\nn = int(input())\narr = lmi()\na = min(arr)\nfor i in range(n):\n arr[i] %= a\nprint(min(arr))", "from sys import stdin\ninput = stdin.readline\nlmi = lambda: list(map(int, input().split()))\nmi = lambda: map(int, input().split())\nsi = lambda: input().strip('\\n')\nssi = lambda: input().strip('\\n').split()\n\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a%b)\n\n\nn = int(input())\narr = lmi()\nfor i in range(1, n):\n arr[i] = gcd(arr[i], arr[i-1])\nprint(arr[n-1])"]
['Wrong Answer', 'Accepted']
['s485796327', 's560843730']
[14252.0, 14168.0]
[62.0, 89.0]
[331, 394]
p03127
u994521204
2,000
1,048,576
There are N monsters, numbered 1, 2, ..., N. Initially, the health of Monster i is A_i. Below, a monster with at least 1 health is called alive. Until there is only one alive monster, the following is repeated: * A random alive monster attacks another random alive monster. * As a result, the health of the monster attacked is reduced by the amount equal to the current health of the monster attacking. Find the minimum possible final health of the last monster alive.
['n=int(input())\nA=list(map(int,input().split()))\ndef gcd(a,b):\n if b==0:\n return(a)\n else:\n return(gcd(b,b%a))\nans=A[0]\nfor i in range(n-1):\n ans=gcd(ans,A[i+1])\nprint(ans)\n', 'n=int(input())\nA=list(map(int,input().split()))\ndef gcd(a,b):\n if b>a:\n return(gcd(b,a))\n elif b==0:\n return(a)\n else:\n return(gcd(b,a%b))\nans=A[0]\nfor i in range(n-1):\n ans=gcd(ans,A[i+1])\nprint(ans)\n']
['Wrong Answer', 'Accepted']
['s956739438', 's850608107']
[14252.0, 15020.0]
[105.0, 94.0]
[195, 234]
p03128
u013408661
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['n,m=map(int,input().split())\na=list(map(int,input().split()))\ndp=[0]*(n+1)\nans=[0]*(n+1)\nnum=[0,2,5,5,4,5,6,3,7,6]\nINF=10**18\nfor i in range(1,n+1):\n stack=[]\n for j in m:\n if i-num[j]>=0:\n stack.append(dp[i-num[j]])\n else:\n stack.append(-INF)\n dp[i]=max(stack)+1\n if dp[i]>0:\n ans[i] += ans[i-num[stack.index(max(stack))]]+num[stack.index(max(stack))]*10**(dp[i]-1)\nprint(ans[n])', 'n,m=map(int,input().split())\na=list(map(int,input().split()))\ndp=[0]*(n+1)\nans=[0]*(n+1)\nnum=[0,2,5,5,4,5,6,3,7,6]\nINF=10**18\nfor i in range(1,n+1):\n stack=[]\n for j in a:\n if i-num[j]>=0:\n stack.append(dp[i-num[j]])\n else:\n stack.append(-INF)\n dp[i]=max(stack)+1\n if dp[i]>0:\n ans[i] += ans[i-num[stack.index(max(stack))]]+num[stack.index(max(stack))]*10**(dp[i]-1)\nprint(ans[n])', 'n,m=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\na.reverse()\ndp=[0]*(n+1)\nans=[0]*(n+1)\nnum=[0,2,5,5,4,5,6,3,7,6]\nINF=10**18\nfor i in range(1,n+1):\n stack=[]\n chance=[]\n for j in a:\n if i-num[j]>=0:\n stack.append(dp[i-num[j]])\n chance.append([dp[i-num[j]],ans[i-num[j]]])\n else:\n stack.append(-INF)\n chance.append([-1,-1])\n dp[i]=max(stack)+1\n if dp[i]>0:\n for v in range(len(stack)):\n if stack[v]==max(stack):\n ans[i] += chance[v][1]+a[v]*10**(dp[i]-1)\n break\nprint(ans[n])']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s224450623', 's643678483', 's015871971']
[3188.0, 14332.0, 14824.0]
[18.0, 304.0, 387.0]
[403, 403, 549]
p03128
u016567570
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['N, M = map(int, input().split())\nA_list = list(map(int, input().split()))\ncost_Dict = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}\nA_Dict = {}\nfor x in A_list:\n A_Dict[x] = cost_Dict[x]\nmin_digit = min(A_Dict, key=A_Dict.get)\nmin_cost = min(A_Dict.values())\nmin_num = min_cost\nlow_digit_num = (N // min_num)-1\nres_matches = N - min_num*low_digit_num\nX = list(A_Dict.keys())\nX.sort()\nX = X[::-1]\nfor x in X:\n if A_Dict[x] <= res_matches:\n max_digit = x\n break\nans = str(max_digit)\nfor i in range(low_digit_num):\n ans += str(min_digit)\nprint(ans)', 'N, M = map(int, input().split())\nA_list = list(map(int, input().split()))\ncost_Dict = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}\nA_Dict = {}\nfor x in A_list:\n A_Dict[x] = cost_Dict[x]\n#def A_cost(x):\n# return A_Dict[x]\ndp = [-float(\'inf\')] * (N+1)\ndp[0] = 0\n\nA_list = list(A_Dict.keys())\nA_list.sort(reverse=True)\n\nfor i in range(N+1):\n _list = []\n for x in A_list:\n if i - A_Dict[x] < 0:\n continue\n else:\n dp[i] = max(dp[i], dp[i-A_Dict[x]]+1)\n\nans = ""\ncost = N\nwhile cost > 0:\n for x in A_list:\n if cost - A_Dict[x] < 0:\n continue\n elif dp[cost - A_Dict[x]] == dp[cost] - 1:\n ans += str(x)\n cost -= A_Dict[x]\n break\n\nprint(ans)']
['Wrong Answer', 'Accepted']
['s199445885', 's321281056']
[3064.0, 3420.0]
[19.0, 96.0]
[554, 742]
p03128
u025235255
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['n, m = map(int, input().split())\na = list(map(int, input().split()))\nuse = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\ndp = [[0] * 10 for i in range(n+1)]\n\ndef makenum(x,y):\n res = 0\n for i in range(y):\n res = res* 10 + x\n return res\n \nfor i in range(1,n+1):\n kouho = []\n for j in a:\n if i - use[j] >= 0:\n if dp[i-use[j]] == [0] * 10 and i - use[j] != 0: \n continue \n else:\n copy = dp[i-use[j]][:]\n copy[j] += 1\n kouho.append(copy)\n if kouho == []: \n continue \n else:\n usearray = []\n usenum = 0\n for array in kouho:\n tmpnum = 0\n for k in range(9,0,-1):\n tmpnum = tmpnum * (10**array[k]) + makenum(k,array[k])\n if tmpnum > usenum:\n usearray = array\n usenum = usenum\n dp[i] = usearray\nans = ""\nfor i in range(9,0,-1):\n ans += (str(i) * dp[n][i])\nprint(ans)', 'n, m = map(int, input().split())\na = list(map(int, input().split()))\nuse = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\ndp = [[0] * 10 for i in range(n+1)]\nfor i in range(1,n+1):\n kouho = []\n for j in a:\n if i - use[j] >= 0:\n if dp[i-use[j]] == [0] * 10 and i - use[j] != 0: \n continue \n else:\n copy = dp[i-use[j]][:]\n copy[j] += 1\n kouho.append(copy)\n if kouho == []: \n continue \n else:\n usearray = []\n accnum = "0"\n for array in kouho:\n tmpnum = ""\n for k in range(9,0,-1):\n tmpnum += (str(k) * array[k])\n if int(tmpnum) > int(accnum):\n usearray = array\n accnum = tmpnum\n dp[i] = usearray\nans = ""\nfor i in range(9,0,-1):\n ans += (str(i) * dp[n][i])\nprint(0)', 'n, m = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nuse = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\ndp = [[0] * 10 for i in range(n+1)]\nfor i in range(1,n+1):\n for j in a:\n if i - use[j] >= 0:\n if dp[i-use[j]] == [0] * 10 and i - use[j] != 0: \n continue \n else:\n if sum(dp[i-use[j]])+1 >= sum(dp[i]):\n copy = dp[i-use[j]][:]\n copy[j] += 1\n dp[i] = copy\nans = ""\nfor i in range(9,0,-1):\n ans += (str(i) * dp[n][i])\nprint(ans)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s293434613', 's872203354', 's822093807']
[4900.0, 4884.0, 4972.0]
[2104.0, 2104.0, 127.0]
[1060, 946, 615]
p03128
u029169777
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['N,M=map(int,input().split())\n\nA=list(map(int,input().split()))\nA.sort(reverse=True)\nhonsuu=[0,2,5,5,4,5,6,3,7,6]\n\ndef ketadp(N,M,A):\n dp=[0]*(N+1)\n for i in range(N):\n for j in A:\n if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):\n dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)\n return dp\n \n\nans=""\nketa=ketadp(N,M,A)\nremain=keta[N]\nmatch=N\n#print(A)\n\nwhile(match>0):\n for i in A:\n \n if(keta[match-honsuu[i]]==remain-1):\n ans+=str(i)\n remain-=1\n match-=honsuu[i]\n break;\nprint(ans) ', 'N,M=map(int,input().split())\n\nA=list(map(int,input().split()))\nA.sort(reverse=True)\nhonsuu=[0,2,5,5,4,5,6,3,7,6]\n\ndef ketadp(N,M,A):\n dp=[0]*(N+1)\n for i in range(N):\n for j in A:\n if (i+1-honsuu[j])==0 or (i+1-honsuu[j]>0 and dp[i+1-honsuu[j]]!=0):\n dp[i+1]=max(dp[i+1],dp[i+1-honsuu[j]]+1)\n return dp\n \n\nans=""\nketa=ketadp(N,M,A)\nremain=keta[N]\nmatch=N\n#print(keta)\n\nwhile(match>0):\n for i in A:\n \n if match-honsuu[i]<0:\n continue;\n if(keta[match-honsuu[i]]==remain-1) and not (match-honsuu[i]!=0 and remain==1):\n ans+=str(i)\n remain-=1\n match-=honsuu[i]\n break;\nprint(ans)']
['Runtime Error', 'Accepted']
['s788347876', 's527822160']
[3368.0, 3368.0]
[2104.0, 110.0]
[587, 673]
p03128
u034128150
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['def max_for_str(a, b):\n if len(a) > len(b):\n return a\n elif len(a) < len(b):\n return b\n else:#This case is unlikely to happen.\n for c1, c2 in zip(a, b):\n if c1 > c2:\n return a\n elif c1 < c2:\n return b\n return a\n \nmatch = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n\nN, M = map(int, input().split())\nAs = list(input().split())\n\ndp = [None] * (N+1)\ndp[0] = ""\n\nfor i in range(N+1):\n for A in As:\n if i - match[int(A)] >= 0 and not dp[i - match[int(A)]] is None:\n if dp[i] is None:\n if A >= dp[i - match[int(A)]]:\n dp[i] = A + dp[i - match[int(A)]]\n else:\n dp[i] = max_for_str(dp[i] , A + dp[i - match[int(A)]])\n \nprint(dp[N])', 'def max_for_str(a, b):\n if len(a) > len(b):\n return a\n elif len(a) < len(b):\n return b\n else:#This case is unlikely to happen.\n for c1, c2 in zip(a, b):\n if c1 > c2:\n return a\n elif c1 < c2:\n return b\n return a\n \nmatch = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n\nN, M = map(int, input().split())\nAs = list(input().split())\n\ndp = [None] * (N+1)\ndp[0] = ""\n\nfor i in range(N+1):\n for A in As:\n if i - match[int(A)] >= 0 and not dp[i - match[int(A)]] is None:\n if dp[i] is None:\n dp[i] = A + dp[i - match[int(A)]]\n else:\n dp[i] = max_for_str(dp[i] , A + dp[i - match[int(A)]])\n\nprint(dp[N])']
['Wrong Answer', 'Accepted']
['s388926722', 's525913747']
[27764.0, 28916.0]
[86.0, 179.0]
[806, 739]
p03128
u046187684
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['def solve(string):\n n, m, *a = map(int, string.split())\n needs = {i + 1: n for i, n in enumerate(map(int, "2 5 5 4 5 6 3 7 6".split()))}\n if 2 in a and 5 in a:\n a.remove(2)\n if 3 in a and 5 in a:\n a.remove(3)\n if 2 in a and 3 in a:\n a.remove(2)\n if 6 in a and 9 in a:\n a.remove(6)\n b = sorted(a, key=lambda x: needs[x])\n index = 0\n base = str(b[0]) * (n // needs[b[0]])\n n %= needs[b[0]]\n while n > 0:\n use = [_b for _b in b if needs[_b] <= needs[b[0]] + n]\n if max(use) == b[0]:\n return base\n tmp_n = use[-1]\n tmp_c = n // (needs[tmp_n] - needs[b[0]])\n base = base[:-tmp_c] + str(tmp_n) * tmp_c\n n -= (needs[tmp_n] - needs[b[0]]) * tmp_c\n else:\n tmp_n = max(use)\n tmp_c = n // (needs[tmp_n] - needs[b[0]])\n base = base[:index] + str(tmp_n) * tmp_c + base[index + tmp_c:]\n n -= (needs[tmp_n] - needs[b[0]]) * tmp_c\n index += tmp_c\n return base\n\n\nif __name__ == \'__main__\':\n print(solve(\'\\n\'.join([input(), input()])))\n', 'def solve(string):\n n, m, *a = map(int, string.split())\n needs = {i + 1: n for i, n in enumerate(map(int, "2 5 5 4 5 6 3 7 6".split()))}\n if 2 in a and 5 in a:\n a.remove(2)\n if 3 in a and 5 in a:\n a.remove(3)\n if 2 in a and 3 in a:\n a.remove(2)\n if 6 in a and 9 in a:\n a.remove(6)\n b = sorted(a, key=lambda x: needs[x])\n index = 0\n base = str(b[0]) * (n // needs[b[0]])\n n %= needs[b[0]]\n while n > 0:\n print(base)\n print(n)\n use = [_b for _b in b if needs[_b] <= needs[b[0]] + n]\n if len(use) == 1:\n base = base[:-1]\n n += needs[b[0]]\n elif max(use) == b[0]:\n tmp_n = use[-1]\n tmp_c = n // (needs[tmp_n] - needs[b[0]])\n base = base[:-tmp_c] + str(tmp_n) * tmp_c\n n -= (needs[tmp_n] - needs[b[0]]) * tmp_c\n else:\n tmp_n = max(use)\n tmp_c = n // (needs[tmp_n] - needs[b[0]])\n base = base[:index] + str(tmp_n) * tmp_c + base[index + tmp_c:]\n n -= (needs[tmp_n] - needs[b[0]]) * tmp_c\n index += tmp_c\n return base\n\n\nif __name__ == \'__main__\':\n print(solve(\'\\n\'.join([input(), input()])))\n ', 'def solve(string):\n n, m, *a = map(int, string.split())\n needs = {i + 1: n for i, n in enumerate(map(int, "2 5 5 4 5 6 3 7 6".split()))}\n if 2 in a and 5 in a or 2 in a and 3 in a:\n a.remove(2)\n if 3 in a and 5 in a:\n a.remove(3)\n if 6 in a and 9 in a:\n a.remove(6)\n a = sorted(a, key=lambda x: needs[x])\n index = 0\n base = str(a[0]) * (n // needs[a[0]])\n n %= needs[a[0]]\n while n > 0:\n use = [_b for _b in a if needs[_b] <= needs[a[0]] + n]\n if len(use) == 1:\n base = base[:-1]\n n += needs[a[0]]\n continue\n flag = max(use) == a[0]\n tmp_n = use[-1] if flag else max(use)\n tmp_c = n // (needs[tmp_n] - needs[a[0]])\n if flag:\n base = base[:-tmp_c] + str(tmp_n) * tmp_c\n else:\n base = base[:index] + str(tmp_n) * tmp_c + base[index + tmp_c:]\n index += tmp_c\n n -= (needs[tmp_n] - needs[a[0]]) * tmp_c\n return base\n\n\nif __name__ == \'__main__\':\n print(solve(\'\\n\'.join([input(), input()])))']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s511016319', 's974589442', 's914381507']
[3064.0, 3188.0, 3064.0]
[18.0, 19.0, 18.0]
[1116, 1216, 1064]
p03128
u047023156
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
["import sys\nfrom operator import itemgetter\nfrom collections import deque\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = [i for i in range(1, 10)]\nC = [2, 5, 5, 4, 5, 6, 3, 7, 6]\ninf = float('inf')\ncosts = {m: C[m-1] for m in A}\nprint(costs)\ndp = deque([0])\n\nfor i in range(1, N+1):\n dp.append(max([dp[i-c] if i - c >= 0 else -inf for c in costs.values()])+1)\n\ndigits = list(costs.keys())\ndigits.sort(reverse=True)\nresult = deque()\nnum = N\nfor _ in range(dp[N]):\n for i in digits:\n if num >= costs[i] and dp[num-costs[i]] != -inf and dp[num-costs[i]] == dp[num]-1:\n result.append(str(i))\n num -= costs[i]\n break\n\nprint(''.join(result))", "import sys\nfrom operator import itemgetter\nfrom collections import deque\ninput = sys.stdin.readline\n\nN, M = map(int, input().split())\nA = list(map(int, input().split()))\nB = [i for i in range(1, 10)]\nC = [2, 5, 5, 4, 5, 6, 3, 7, 6]\ninf = float('inf')\ncosts = {m: C[m-1] for m in A}\ndp = deque([0])\n\nfor i in range(1, N+1):\n dp.append(max([dp[i-c] if i - c >= 0 else -inf for c in costs.values()])+1)\n\ndigits = list(costs.keys())\ndigits.sort(reverse=True)\nresult = deque()\nnum = N\nfor _ in range(dp[N]):\n for i in digits:\n if num >= costs[i] and dp[num-costs[i]] != -inf and dp[num-costs[i]] == dp[num]-1:\n result.append(str(i))\n num -= costs[i]\n break\n\nprint(''.join(result))"]
['Wrong Answer', 'Accepted']
['s833191430', 's903570619']
[4060.0, 4060.0]
[79.0, 78.0]
[786, 773]
p03128
u047816928
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
["cost = [None,2,5,5,4,5,6,3,7,6]\n\nAset = {}\nfor a in A:\n c = cost[a]\n Aset[c] = max(Aset[c], a) if c in Aset else a\nA = sorted([v for k,v in Aset.items()])\n\ndp = [None]*(N+1)\ndp[0] = (0,[0]*len(A))\n\nfor ia, a in enumerate(A):\n c = cost[a]\n for i in range(c, N+1):\n t = dp[i-c]\n if t and (dp[i]==None or t[0]+1>=dp[i][0]):\n dp[i] = (t[0]+1, t[1].copy())\n dp[i][1][ia] += 1\n \t\nl=[]\nfor i in range(len(A)):\n l += [A[len(A)-1-i]]*dp[N][1][len(A)-1-i]\n\nprint(*l, sep='')", "N, M = list(map(int, input().split()))\nA = list(map(int, input().split()))\ncost = [None,2,5,5,4,5,6,3,7,6]\n\nAset = {}\nfor a in A:\n c = cost[a]\n Aset[c] = max(Aset[c], a) if c in Aset else a\nA = sorted([v for k,v in Aset.items()])\n\ndp = [None]*(N+1)\ndp[0] = (0,[0]*len(A))\n\nfor ia, a in enumerate(A):\n c = cost[a]\n for i in range(c, N+1):\n t = dp[i-c]\n if t and (dp[i]==None or t[0]+1>=dp[i][0]):\n dp[i] = (t[0]+1, t[1].copy())\n dp[i][1][ia] += 1\n \t\nl=[]\nfor i in range(len(A)):\n l += [A[len(A)-1-i]]*dp[N][1][len(A)-1-i]\n\nprint(*l, sep='')"]
['Runtime Error', 'Accepted']
['s651160326', 's775682498']
[3064.0, 6388.0]
[18.0, 53.0]
[520, 595]
p03128
u054106284
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['N, M = (int(i) for i in input().split())\nA = [int(i) for i in input().split()]\nnum = [0,2,5,5,4,5,6,3,7,6]\n\nDP = [0] * (N+1)\n\nfor i in range(N+1):\n for j in range(M):\n n = num[A[j]]\n if i - n >= 0:\n DP[i] = max(DP[i], DP[i-n]+1)\n\nA.sort(reverse = True)\n\nans = ""\nremain = DP[N]\nmatch = N\nwhile match > 0:\n for i in range(M):\n n = num[A[i]]\n if match - n >= 0 and DP[match - n] == DP[match] - 1:\n ans += str(A[i])\n match -= n\n break\nprint(ans)', "N, M = (int(i) for i in input().split())\nA = [int(i) for i in input().split()]\nnum = [0,2,5,5,4,5,6,3,7,6] \n\nD = {} \nfor i in range(M):\n n = num[A[i]]\n if D.get(n):\n D[n] = max(D[n], A[i])\n else:\n D[n] = A[i]\n\n\nDP = [(-1, -1)]*(N+1) \nDP[0] = (0, 0)\nfor i in range(N+1):\n for key in D:\n if i - key >= 0 and DP[i-key] != -1:\n temp = (DP[i-key][0] + 1, max(DP[i-key][1], D[key]))\n DP[i] = max(DP[i], temp)\n\n\nans = ''\nnow = N\nwhile now > 0:\n ans += str(DP[now][1])\n now = now - num[DP[now][1]]\nprint(ans)\n"]
['Time Limit Exceeded', 'Accepted']
['s380459567', 's848358886']
[3348.0, 4028.0]
[2104.0, 88.0]
[520, 713]
p03128
u057109575
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['def printing(a_start, a_2, n):\n a_3 = []\n mod_list = []\n \n for i in range(len(a_2)):\n if (a_2[i][1] % a_start[1] not in mod_list) and (a_2[i][1] % a_start[1] != 0):\n a_3.append(a_2[i])\n mod_list.append(a_2[i][1] % a_start[1])\n \n a_3.sort(key=lambda x: x[1], reverse=True)\n if len(a_3) >= 2:\n if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a3[1][0] and a_3[1][0] > a_start[0]:\n a_3.pop(0)\n\n ans = ""\n while n % a_start[1] != 0:\n for i in range(len(a_3)):\n if n % a_start[1] >= a_3[i][1] % a_start[1]:\n n -= a_3[i][1]\n ans += str(a_3[i][0])\n break\n elif n % a_start[1] == 0:\n break\n else:\n n -= a_3[0][1]\n ans += str(a_3[0][0])\n \n ans = ans + str(a_start[0]) * (n // a_start[1])\n ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)\n print(\'\'.join(ans_list))\n\n \ndef main():\n N, M = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n a_list = []\n a_2 = []\n \n for i in range(M):\n if num[a[i]] not in a_list:\n a_2.append([a[i], num[a[i]]])\n a_list.append(num[a[i]])\n\n a_2.sort(key=lambda x: x[1])\n a_start = a_2.pop(0)\n printing(a_start, a_2, N)\n \n\nif __name__ == \'__main__\':\n main()', 'def printing(a_start, a_2, n):\n a_3 = []\n mod_list = []\n \n for i in range(len(a_2)):\n if (a_2[i][1] % a_start[1] not in mod_list) and (a_2[i][1] % a_start[1] != 0):\n a_3.append(a_2[i])\n mod_list.append(a_2[i][1] % a_start[1])\n \n a_3.sort(key=lambda x: x[1], reverse=True)\n if len(a_3) >= 2:\n if (a_start[0] + a_3[-1][0] < n) and (a_3[0][0] < a3[1][0]) and (a_3[1][0] > a_start[0]):\n a_3.pop()\n\n ans = ""\n while n % a_start[1] != 0:\n for i in range(len(a_3)):\n if n % a_start[1] >= a_3[i][1] % a_start[1]:\n n -= a_3[i][1]\n ans += str(a_3[i][0])\n break\n elif n % a_start[1] == 0:\n break\n else:\n n -= a_3[0][1]\n ans += str(a_3[0][0])\n \n ans = ans + str(a_start[0]) * (n // a_start[1])\n ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)\n print(\'\'.join(ans_list))\n\n \ndef main():\n N, M = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n a_list = []\n a_2 = []\n \n for i in range(M):\n if num[a[i]] not in a_list:\n a_2.append([a[i], num[a[i]]])\n a_list.append(num[a[i]])\n\n a_2.sort(key=lambda x: x[1])\n a_start = a_2.pop(0)\n printing(a_start, a_2, N)\n \n\nif __name__ == \'__main__\':\n main()', 'def printing(a_start, a_2, n):\n a_3 = []\n mod_list = []\n \n for i in range(len(a_2)):\n if (a_2[i][1] % a_start[1] not in mod_list) and (a_2[i][1] % a_start[1] != 0):\n a_3.append(a_2[i])\n mod_list.append(a_2[i][1] % a_start[1])\n \n a_3.sort(key=lambda x: x[1], reverse=True)\n if len(a_3) >= 2:\n if a_start[0] + a_3[-1][0] < n and a_3[0][0] < a3[1][0] and a_3[1][0] > a_start[0]:\n a_3.pop()\n\n ans = ""\n while n % a_start[1] != 0:\n for i in range(len(a_3)):\n if n % a_start[1] >= a_3[i][1] % a_start[1]:\n n -= a_3[i][1]\n ans += str(a_3[i][0])\n break\n elif n % a_start[1] == 0:\n break\n else:\n n -= a_3[0][1]\n ans += str(a_3[0][0])\n \n ans = ans + str(a_start[0]) * (n // a_start[1])\n ans_list = sorted([ans[i] for i in range(len(ans))], reverse=True)\n print(\'\'.join(ans_list))\n\n \ndef main():\n N, M = map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n a_list = []\n a_2 = []\n \n for i in range(M):\n if num[a[i]] not in a_list:\n a_2.append([a[i], num[a[i]]])\n a_list.append(num[a[i]])\n\n a_2.sort(key=lambda x: x[1])\n a_start = a_2.pop(0)\n printing(a_start, a_2, N)\n \n\nif __name__ == \'__main__\':\n main()', "def main():\n N, M = map(int, input().split())\n alist = list(map(int, input().split()))\n alist.sort(reverse=True)\n nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]\n\n dp = [-1 for _ in range(N + 1)]\n dp[0] = 0\n for a in alist:\n n = nums[a]\n for i in range(N - n + 1):\n if dp[i] == -1:\n continue\n dp[i + n] = max(dp[i + n], dp[i] * 10 + a)\n\n print(dp[-1])\n \n\nif __name__ == '__main__':\n main()"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s190424983', 's646379449', 's688329227', 's069778449']
[3192.0, 3444.0, 3192.0, 16496.0]
[18.0, 22.0, 18.0, 108.0]
[1288, 1293, 1287, 416]
p03128
u062459048
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
['n,m = map(int,input().split())\nA = list(map(int,input().split()))\n\nsu = [0,2,5,5,4,5,6,3,7,6]\n\ndp = [0]*(n+1)\n\nfor i in range(1,n+1):\n for j in A:\n if i >= su[j]:\n dp[i] = max(dp[i],dp[i-su[j]]*10+j)\n \nprint(dp[-1])\n \n\n\n\n', 'n,m = map(int,input().split())\nA = list(map(int,input().split()))\n\nsu = [0,2,5,5,4,5,6,3,7,6]\n\ndp = [-1]*(n+1)\n\nfor i in range(1,n+1):\n for j in A:\n if i >= su[j]:\n dp[i] = max(dp[i],dp[i-su[j]]*10+j)\n \nprint(dp[-1])\n', 'n,m = map(int,input().split())\nA = list(map(int,input().split()))\n\nsu = [0,2,5,5,4,5,6,3,7,6]\n\ndp = [-1]*(n+1)\ndp[0] = 0\n\nfor i in range(1,n+1):\n for j in A:\n if i >= su[j]:\n dp[i] = max(dp[i],dp[i-su[j]]*10+j)\n \nprint(dp[-1])']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s787964138', 's923939928', 's372298347']
[14388.0, 3060.0, 14516.0]
[148.0, 68.0, 150.0]
[236, 231, 240]
p03128
u064408584
2,000
1,048,576
Find the largest integer that can be formed with exactly N matchsticks, under the following conditions: * Every digit in the integer must be one of the digits A_1, A_2, ..., A_M (1 \leq A_i \leq 9). * The number of matchsticks used to form digits 1, 2, 3, 4, 5, 6, 7, 8, 9 should be 2, 5, 5, 4, 5, 6, 3, 7, 6, respectively.
["n,m=map(int, input().split())\nmt=[0,2,5,5,4,5,6,3,7,6]\na=sorted(map(int, input().split()))\ndp=['']*(n+1)\ndp[0]='*'\nfor i in range(n+1):\n if not dp[i]:continue\n for j in a:\n if i+mt[j]<n+1:\n dp[i+mt[j]]=dp[i]+str(j)\nprint(dp[-1][1:])", "n,m=map(int, input().split())\nhon=[2,5,5,4,5,6,3,7,6]\na=list(map(int, input().split()))\ns=sorted(set([hon[i-1] for i in a]))\nx=s[0]*s[1]+1\ndp=[[-100]*(x+1) for i in range(len(s)+1)]\nfor i in range(1,len(s)+1):\n for j in range(x+1):\n if j%s[i-1]==0:\n dp[i][j]=max(dp[i][j],j//s[i-1])\n for k in range(1,j+1):\n if (j-k)%s[i-1]==0:\n dp[i][j]=max(dp[i][j],(j-k)//s[i-1]+dp[i-1][k])\nans=[]\nif n>x:\n ans+=[min(s)]*-(-(n-x)//min(s))\n n=n+(-(n-x)//min(s))*min(s)\nfrom itertools import product\nfor i in product(s,repeat=dp[-1][n]):\n if sum(i)==n:break\nans+=list(i)\nimport bisect\nansf=[]\nfor i in ans:\n t=9-hon[::-1].index(i)\n bisect.insort_left(ansf,t)\nprint(*ansf[::-1],sep='')", 'n,m=map(int, input().split())\nmt=[0,2,5,5,4,5,6,3,7,6]\na=sorted(map(int, input().split()))[::-1]\ndp=[-1]*(n+1)\ndp[0]=0\nfor i in range(n+1):\n if dp[i]==-1:continue\n for j in a:\n if i+mt[j]<n+1:\n dp[i+mt[j]]=max(dp[i]*10+j,dp[i+mt[j]])\nprint(dp[-1])']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s598451458', 's845161500', 's198082748']
[29684.0, 4212.0, 14708.0]
[105.0, 32.0, 165.0]
[256, 737, 271]