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
p03222
u211160392
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
["H,W,K = map(int,input().split())\nmove= [0]*(W-1)\ncount = 0\nMOD = 10**9+7\n\nif W == 1:\n print(1)\n exit()\n\nfor i in range(2**(W-1),2**W):\n b = bin(i)[3:]\n flag = True\n for j in range(W-2):\n if b[j] == '1' and b[j+1] == '1':\n flag = False\n if flag :\n count += 1\n...
['Wrong Answer', 'Accepted']
['s632681784', 's721527780']
[3064.0, 3064.0]
[19.0, 19.0]
[829, 810]
p03222
u253209284
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['def memorize(func):\n memo = {}\n def wrapper(*args):\n if args not in memo:\n memo[args] = func(*args)\n return memo[args]\n return wrapper\n\n@memorize\ndef amida(W): \n if W<2:\n return 1\n else:\n return amida(W-1)+amida(W-2)\n\n@memorize\ndef amida2(W, H, x...
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s061952662', 's446081938', 's610624454', 's537733581']
[3064.0, 3064.0, 3188.0, 3316.0]
[17.0, 18.0, 18.0, 20.0]
[622, 653, 664, 650]
p03222
u268181283
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['H,W,K = map(int, input().split())\n\ndp = [[0]*W for _ in range(H+1)]\ndp[0][0] = 1\nif W==1:\n print(1)\nelse:\n for i in range(H):\n for j in range(2**(W-1)):\n flag = True\n for k in range(W-1):\n if k != W-2:\n \n if (((j >> k) & 1)&((j >> k+1) & 1)):\n flag = Fa...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s532407828', 's927946879', 's834755145']
[3064.0, 3064.0, 3064.0]
[18.0, 55.0, 53.0]
[692, 807, 793]
p03222
u268210555
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['h, w, k = map(int, input().split())\na = [0]*(w-1) + [1,1]\nfor i in range(w-1):\n a[i] = a[i-1] + a[i-2]\ndp = [0]*(w+1)\ntmp = [0]*(w+1)\ndp[0] = 1\nfor _ in range(1, h+1):\n for i in range(w):\n tmp[i] = (dp[i]*a[i-1]*a[w-i-2]\n + dp[i+1]*a[i-1]*a[w-i-3]\n + dp[i-1]*a[i-2]*a[w-i-...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s305300062', 's410257503', 's966611835']
[3064.0, 3064.0, 3064.0]
[19.0, 23.0, 19.0]
[359, 377, 359]
p03222
u360116509
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
["def main():\n H, W, K = list(map(int, input().split()))\n dp = [[0 for _ in range(W)] for _ in range(H + 1)]\n dp[0][0] = 1\n\n for i in range(H):\n for j in range(1 << (W - 1)):\n if '11' in bin(j):\n continue\n j <<= 1\n for w in range(W):\n ...
['Wrong Answer', 'Accepted']
['s262488563', 's881970645']
[3064.0, 3064.0]
[36.0, 35.0]
[683, 649]
p03222
u375616706
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['h,w,k = list(map(int,input().split()))\n\nmat = [[0 for i in range(w+1)] for j in range(h+1)]\nmat[0][0]=1\n\nfor i in range(1,h+1):\n for j in range(w):\n if j==0:\n mat[i][j]=mat[i-1][j]+mat[i-1][j+1]\n elif j==w-1:\n mat[i][j]=mat[i-1][j]+mat[i-1][j-1]\n else:\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s247799891', 's731705226', 's906743352']
[3064.0, 3064.0, 3064.0]
[18.0, 18.0, 41.0]
[396, 390, 873]
p03222
u480300350
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['h, w, k = map(int, input().split())\nmod = 10 ** 9 + 7\n\ndp = [[0] * (w + 1) for _ in range(h + 1)]\nfor i in range(w + 1):\n dp[0][i] = 1 if i == 1 else 0\n\n\ndef calc_pow(from_col, to_col):\n assert(1<=from_col<=w and 1<=to_col<=w)\n if from_col == 1 or to_col == 1 or from_col == w or to_col == w:\n return ...
['Wrong Answer', 'Accepted']
['s901753842', 's624453921']
[3188.0, 3188.0]
[22.0, 95.0]
[774, 1217]
p03222
u506858457
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['\nh, w, k = map(int, input().split())\nmemo = defaultdict(lambda:defaultdict(int))\ndef dfs(x, y):\n if y == h:\n if x == k - 1:\n return 1\n else:\n return 0\n if y in memo[x]:\n return memo[x][y]\n\n ans = 0\n for i in range(1 << w - 1):\n flg = True\n ...
['Runtime Error', 'Accepted']
['s202280536', 's762451553']
[3064.0, 3436.0]
[18.0, 115.0]
[1323, 1358]
p03222
u512007680
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['MOD = 10 ** 9 +7\nh, w, k = map(int,input().split())\n\nif w == 1:\n print(1)\nelse:\n acr = []\n for p in range(2**(w-1)):\n det = 0\n pp = p\n exist = [0] * (w-1)\n for i in range(w-1):\n exist[i] = pp % 2\n pp = pp // 2\n for ii in range(w-2):\n ...
['Runtime Error', 'Accepted']
['s135568696', 's701719563']
[3064.0, 3064.0]
[18.0, 45.0]
[809, 942]
p03222
u545314527
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['import itertools\n\nH,W,K = map(int, input().split())\np = 1000000007\n\nif K - 1 > H:\n print(0)\n exit(0)\n\nR = []\nfor r in itertools.product( [0,1], repeat=(W-1) ):\n if 1 not in list(map(lambda i : r[i]*r[i+1], range(len(r)-1)) ):\n R.append(r)\n\n\nM = [ (\n len( list( filter( lambda r:r[0]=...
['Runtime Error', 'Accepted']
['s906948590', 's311685712']
[3188.0, 3188.0]
[21.0, 20.0]
[1021, 1038]
p03222
u606045429
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['mod = 10 ** 9 + 7\nfib = [1, 1, 2, 3, 5, 8, 13, 21, 34]\n\nH, W, K = map(int, input().split())\n\ndp = [0] * W\ndp[0] = 1\n\nfor _ in range(H):\n\n T = [0] * W\n\n for i in range(W):\n if 0 < i:\n T[i] += T[i - 1] * fib[i - 1] * fib[W - i - 1]\n\n T[i] += T[i] * fib[i] * fib[W - i - 1]\...
['Wrong Answer', 'Accepted']
['s900885606', 's478862453']
[3064.0, 3064.0]
[18.0, 18.0]
[431, 433]
p03222
u608088992
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['H, W, K = map(int, input().split())\nmod = 7 + 10**9\nNo = [1 for i in range(7)] \nNo[1], No[2], No[3], No[4] = 2, 3, 5, 8\nNo[5], No[6]= 13, 21\n\nif W == 1:\n print(1)\nelse:\n DP = [[0 for w in range(W)] for h in range(H)]\n DP[0][0], DP[0][1] = No[max(0, W-2)], No[max(0, W-3)]\n for h in range(1, H):\...
['Wrong Answer', 'Accepted']
['s700939195', 's893473204']
[3188.0, 3188.0]
[19.0, 21.0]
[1035, 1057]
p03222
u619819312
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['a,b,c=map(int,input().split())\ns=[[0]*b for i in range(a+1)]\ns[0][0]=1\nprint(s)\nk=[[1,1,1],[2,1,1,1,2],[3,2,2,1,2,2,3],[5,3,3,2,4,2,3,3,5],[8,5,5,3,6,4,6,3,5,5,8],[13,8,8,5,10,6,9,6,10,5,8,8,13],[21,13,13,8,16,10,15,9,15,10,16,8,13,13,21]]\nif b==1:\n print(1)\nelif c-a>=2:\n print(0) \nelse:\n d=k[b-...
['Wrong Answer', 'Accepted']
['s753057310', 's966505984']
[3188.0, 3188.0]
[18.0, 18.0]
[642, 637]
p03222
u725578977
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['# -*- coding: utf-8 -*-\n\nh, w, k = map(int, input().split())\n\n\ndef f(x):\n lst = [1, 2, 3, 5, 7, 13, 19]\n if 0 <= x < 7:\n return lst[x]\n else:\n return 1\n\n\nptn = [[0] * (w + 2) for _ in range(w + 2)]\nfor i in range(w + 2):\n for j in range(w + 2):\n if i == 0 or i == w+1 o...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s013138480', 's067514444', 's680731766']
[3572.0, 3572.0, 3064.0]
[41.0, 41.0, 37.0]
[952, 961, 937]
p03222
u729008627
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['import numpy as np\nH, W, K = map(int, input().split())\np = 10**9 + 7\nr = [1, 1, 2, 3, 5, 8, 13, 21, 34]\ndp = np.zeros([H + 1, W], dtype=int)\ndp[0, 0] = 1\nfor h in range(H):\n for w in range(W):\n if w != 0:\n dp[h+1, w] += ((dp[h, w-1] * r[w-1])%p * r[W-1-w])%p\n dp[h+1, w] = ((dp[h,...
['Wrong Answer', 'Accepted']
['s876626017', 's731328352']
[12516.0, 12508.0]
[160.0, 162.0]
[471, 472]
p03222
u762557532
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['from collections import deque\nfrom copy import deepcopy\n\nH, W, K = map(int, input().split())\n\nmod = int(1e9+7)\n\n\nperm_lst = []\ndef bfs():\n dq = deque() \n dq.append(([],0))\n while dq:\n post, line = dq.popleft()\n if line < W: \n post_tmp = deepcopy(post) \n post_tm...
['Wrong Answer', 'Accepted']
['s867071417', 's278567607']
[3824.0, 3572.0]
[39.0, 40.0]
[1244, 1246]
p03222
u782098901
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['MOD = 1000000007\n\n\ndef main():\n H, W, K = map(int, input().split())\n dp = [[0] * W] * (H + 1)\n dp[0][0] = 1\n for i in range(H):\n for j in range(W):\n for k in range(1 << (W - 1)):\n ok = True\n for l in range(W - 2):\n \n ...
['Wrong Answer', 'Accepted']
['s822165738', 's206622103']
[3064.0, 3064.0]
[152.0, 146.0]
[861, 891]
p03222
u790905630
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['import itertools\n\ndef fibonacci(n):\n if (n == 0):\n f_n = 1\n elif (n == 1):\n f_n = 1\n else:\n f_n = fibonacci(n-1) + fibonacci(n-2)\n\n return f_n\n\ndef X_amida_number(W, W_i):\n x_amida = "0" * (W - 1)\n left_x_amida = x_amida[:(W_i-2)] if(W_i-2 >= 0) else ""\n right_...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s143784212', 's233306591', 's076359549']
[3192.0, 3192.0, 3192.0]
[19.0, 20.0, 19.0]
[2132, 2132, 2059]
p03222
u797994565
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['H,W,K = map(int,input().split())\nmod = 10**9+7\ndp = [[0 for i in range(W)] for j in range(H+1)]\ndp[0][0] = 1\ndp_x = [[0,0] for i in range(W)]\ndp_o = [[0,0] for i in range(W)]\ndp_x[0][0] = 1\ndp_x[0][1] = 1\nfor i in range(W-1):\n dp_x[i+1][0] = dp_x[i][0]+dp_x[i][1]\n dp_x[i+1][1] =dp_x[i][0]\ndp_o[0][0] ...
['Wrong Answer', 'Accepted']
['s556987285', 's514094365']
[3828.0, 3192.0]
[29.0, 19.0]
[1161, 1147]
p03222
u909643606
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['def comb(n):\n if n % 2 == 0:\n N = n / 2\n num = 2 ** N + 2 ** N - 1\n else:\n N = ( n + 1 ) / 2\n num = 2 ** N + 2 ** ( N - 1 ) - 1\n return int(num)\n\nd = 1000000007\n\nh, w, k = [int(i) for i in input().split()]\nkuji = [0 for i in range(w)]\nkuji[0] = 1\nprint(kuji)\nfor i in range(h):\n\n kuji2...
['Wrong Answer', 'Accepted']
['s625456981', 's299005119']
[3064.0, 3064.0]
[23.0, 50.0]
[678, 1206]
p03222
u955251526
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['h, w, k = map(int, input().split())\ndp = [[0 for _ in range(w)] for _ in range(h+1)]\nperm = [1, 2, 3, 5, 8, 13, 21, 34]\nfor row in range(h+1):\n for col in range(w):\n if row == 0:\n dp[row][col] = int(col == 0)\n else:\n if col > 0:\n dp[row][col] += dp[row-1]...
['Wrong Answer', 'Accepted']
['s421214634', 's158849835']
[3188.0, 3064.0]
[20.0, 20.0]
[581, 672]
p03222
u968846084
2,000
1,048,576
Amidakuji is a traditional method of lottery in Japan. To make an amidakuji, we first draw W parallel vertical lines, and then draw horizontal lines that connect them. The length of each vertical line is H+1 Find the number of the valid amidakuji that satisfy the following condition, modulo 1\ 000\ 000\ 007: if we t...
['h,w,k=map(int,input().split())\nmod=10**9+7\nfib=[1,1]\nfor i in range(6):\n fib.append(fib[-2]+fib[-1])\nprint(fib)\ndp=[[0]*w for i in range(h+1)]\ndp[0][0]=1\nfor i in range(h):\n for j in range(w):\n if j==0:\n dp[i+1][j]=(dp[i][j]*fib[j]*fib[w-j-1]+dp[i][j+1]*fib[j]*fib[w-j-2])%(mod)\n elif j==w-1:\...
['Runtime Error', 'Accepted']
['s296248642', 's069631922']
[3064.0, 3064.0]
[19.0, 18.0]
[528, 558]
p03231
u027253287
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n, x = map(int, input().split())\na = sorted(list(map(int, input().split())))\nfor i in range(n) :\n x -= a[i]\n if(x == 0) : \n print(i+1)\n exit()\n elif(a[i] > x) : print(i)', 'def gcm(a, b) :\n while(b) :\n a, b = b, a%b\n return a\ndef lcm(a, b) :\n return int(a*b/gcm(a, b))\n\nn, m = map(int, inp...
['Runtime Error', 'Accepted']
['s526362464', 's121167396']
[3316.0, 4824.0]
[18.0, 49.0]
[178, 403]
p03231
u030726788
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(m,n):\n while (m % n != 0):\n n,m = m%n,n\n return(n)\n\ndef lcm(m,n):\n return(m * n // gcd(m,n))\n\nn,m = map(int,input().split())\n\ns = input()\nt = input()\n\n\ng = gcd(m,n)\n\nif(g in [n,m]):\n print(-1)\nelse:\n x = lcm(m,n)\n a = x // n\n b = x // m\n for i in range(x//n...
['Runtime Error', 'Accepted']
['s805898739', 's675119975']
[3316.0, 3316.0]
[17.0, 19.0]
[433, 425]
p03231
u038676814
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m = (int(i) for i in input().split())\ns = input()\nt = input()\ndef gcd(a,b):\n\tif a%b: return gcd(b,a%b)\n\telse: return b\ng = gcd(n,m)\nprint(g)', 'n,m = (int(i) for i in input().split())\ns = input()\nt = input()\ndef gcd(a,b):\n\tif a%b: return gcd(b,a%b)\n\telse: return b\ng = gcd(n,m)\nng, mg = n//g, m//g\...
['Wrong Answer', 'Accepted']
['s957792095', 's024563217']
[3316.0, 3316.0]
[18.0, 18.0]
[142, 239]
p03231
u067983636
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import numpy as np\nN = int(input())\nA = list(map(int, input().split()))\nR = np.zeros(N + 1, dtype="int32")\nP = np.ones(N + 1, dtype="int32")\nmod = 10 ** 9 + 7\n\ndef rev(a):\n return pow(a, mod - 2, mod)\n \nfor n in range(N + 1):\n R[n] = (R[n - 1] + rev(n)) % mod\n if n != 0:\n P[n] = P[n - ...
['Runtime Error', 'Runtime Error', 'Accepted']
['s726240007', 's901755156', 's079852448']
[13368.0, 14416.0, 3316.0]
[163.0, 149.0, 19.0]
[436, 428, 386]
p03231
u077291787
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['# AGC028\nfrom fractions import gcd\n\n\ndef main():\n n, m = tuple(map(int, input().rstrip().split()))\n S, T = tuple(input().rstrip() for _ in range(2))\n l = n // gcd(n, m) * m\n x = [""] * l\n for i in range(n): # place S in x\n j = (l // n) * i\n x[j] = S[i]\n\n for i in range(m)...
['Runtime Error', 'Accepted']
['s479046608', 's495529374']
[189788.0, 3316.0]
[180.0, 17.0]
[503, 352]
p03231
u088863512
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd\n# def input(): return sys.stdin.readline()[:-1] # warning not \\n\n\n\n\n\ndef solve():\n n, m = [int(x) for x in input().split()]\n s = input()\n t = input()\n g = gcd(n, m)\n ans = ...
['Runtime Error', 'Accepted']
['s267656103', 's342900034']
[9616.0, 9584.0]
[30.0, 34.0]
[724, 724]
p03231
u092781267
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['input_lines = input().split()\nN = int(input_lines[0])\nM = int(input_lines[1])\nS = input()\nT = input()\n\ndef gcd(a, b):\n while b > 0:\n a, b = b, a%b\n return a\n\ndef lcm(a, b):\n return a*b/gcd(a, b)\n\nL = int(lcm(N,M))\nx = 1\ncount = 0\nif N >= M:\n big = N\n small = M\nelse:\n big = M\n s...
['Runtime Error', 'Accepted']
['s819476007', 's731798163']
[3316.0, 3444.0]
[1805.0, 203.0]
[950, 811]
p03231
u124498235
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['from collections import defaultdict\nimport math\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nans = int((n*m)/math.gcd(n,m))\ng = math.gcd(n,m)\nfor i in range(g):\n print (i*(n//g),i*(m//g))\n if s[i*(n//g)] != t[i*(m//g)]:\n print (-1)\n exit()\nprint (ans)', 'import math\nn,m = map(int, in...
['Wrong Answer', 'Accepted']
['s667156472', 's641192478']
[9400.0, 9224.0]
[34.0, 29.0]
[271, 207]
p03231
u125205981
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import platform\nver = platform.python_version_tuple()\nif int(ver[1]) < 5:\n from fractions import gcd\nelse:\n from math import gcd\nfrom sys import stdin\n\ndef main():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n L = lcm(N, M)\n ans = [None] * 10000000000\n for i in r...
['Runtime Error', 'Accepted']
['s863498458', 's336932938']
[5712.0, 13376.0]
[46.0, 109.0]
[738, 635]
p03231
u130037310
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N,M = map(int,input().split())\nS = input()\nT = input()\nans = 0\na = 2\n\nif S[0] != T[0]:ans = -1\n\nelif N % M != 0 and M % N != 0:\n if N >= M:\n while True:\n if N * a % M == 0:\n ans = N * a\n b = int(N*a/M)\n for i in range(M):\n ...
['Runtime Error', 'Accepted']
['s595788977', 's801972659']
[3444.0, 3444.0]
[33.0, 32.0]
[1069, 1087]
p03231
u131881594
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m=map(int,input().split())\ns=input()\nt=input()\n\ndef gcd(a,b):\n if b==0: return a\n return gcd(b,a%b)\n\nG=gcd(n,m)\na,b = n//G,m//G\ns=s[1::a]\nt=t[1::b]\nif s==t: print(a*b*G)\nelse: print(-1)', 'n,m=map(int,input().split())\ns=input()\nt=input()\n\ndef gcd(a,b):\n if b==0: return a\n return gcd(b...
['Wrong Answer', 'Accepted']
['s640752945', 's403917428']
[9284.0, 9380.0]
[26.0, 29.0]
[193, 193]
p03231
u134019875
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b != 0:\n a, b = b, a % b\n return b\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nn, m = map(int, input().split())\ns = str(input())\nt = str(input())\nl = lcc(n, m)\nL = [0] * l\nfor i in range(n):\n L[i*(l//n)] = s[i]\nfor j in ra...
['Runtime Error', 'Accepted']
['s409913409', 's196290684']
[3316.0, 3316.0]
[18.0, 19.0]
[465, 351]
p03231
u136647933
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\n\nx,y=map(int,input().split())\nS=input()\nT=input()\nGCD=gcd(x,y)\nLCM=(x * y) // GCD\n\nx_new=x//GCD\ny_new=y//GCD\nfor i in range(0,GCD-1):\n if S[(x_new)*i]==T[(y_new)*i]:\n result=LCM\n else:\n result=-1\n break\nprint(result)', 'def gcd(a,b):\n ...
['Runtime Error', 'Accepted']
['s712298245', 's192829111']
[3316.0, 3316.0]
[20.0, 19.0]
[279, 277]
p03231
u151625340
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N,M = map(int,input().split())\nS = input()\nT = input()\nflag = True\ndef lcm(a, b): \n def gcd(a, b): \n while b:\n a, b = b, a % b\n return a\n return a * b // gcd(a, b)\nL = lcm(N,M)\n\nif S[0] == T[0 and S[N-1] == T[M-1]:\n flag = True\nelse:\n flag = False\nif flag:\n pri...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s361027812', 's523684747', 's914907282']
[3060.0, 3316.0, 3316.0]
[18.0, 18.0, 39.0]
[599, 600, 504]
p03231
u166696759
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n if b > a:\n gcd(b, a)\n while b:\n\t a, b = b, a % b\n return a\n\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nl = n * m // gcd(n, m)\na = l // n\nb = l // m\n#print(a, b)\n#a(i-1) = b(j-i) -> ai = bj + (a-b)\nres = False\nclear_all = True\nfor i in range(1,n+1):\n...
['Runtime Error', 'Accepted']
['s619519123', 's449194811']
[3316.0, 3316.0]
[29.0, 46.0]
[496, 503]
p03231
u170201762
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['from math import gcd\nN,M = map(int,input().split())\ns = input()\nt = input()\ng = gcd(N,M)\nl = N*M//g\n\nn = N//g\nm = M//g\n\nans = l\n\nfor i in range(l):\n if s[i*n]!=t[i*m]:\n ans = -1\n break\nprint(ans)\n\n', 'import math\nN,M = map(int,input().split())\nS = input()\nT = input()\n\nflag = Tr...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s113870358', 's132291642', 's144805419', 's061658038']
[3060.0, 2940.0, 3064.0, 3316.0]
[17.0, 25.0, 19.0, 34.0]
[214, 262, 249, 291]
p03231
u177040005
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a,b):\n if b == 0:\n return abs(a)\n else:\n return gcd(b, a%b)\n\nN,M = map(int, input().split())\nS = input()\nT = input()\n\nprint(-1)\nexit()\n', 'import bisect\n\ndef gcd(a,b):\n if b == 0:\n return abs(a)\n else:\n return gcd(b, a%b)\n\nN,M = map(int, input().spli...
['Wrong Answer', 'Accepted']
['s277061772', 's592357057']
[3316.0, 11036.0]
[17.0, 137.0]
[163, 766]
p03231
u189575640
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import sys\nN,M = [int(n) for n in input().split()]\nS = str(input())\nT = str(input())\n\n# N < M\ndef gcd(N,M):\n if(N > M):\n tmp = N\n N = M\n M = tmp\n r = M % N\n while(r != 0):\n M = N\n N = r\n r = M%N\n return N\n\ndef lcm(N,M):\n return(N*M/gcd(N,M))\...
['Wrong Answer', 'Accepted']
['s057186267', 's370467307']
[3444.0, 3444.0]
[18.0, 18.0]
[739, 913]
p03231
u193264896
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["import sys\nfrom fractions import gcd\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, M = map(int, readline().split())\n S = readline().decode('utf-8')\n T = readline().decode('utf-8')\n lcm = N*M//gcd(N,M)\n if lcm==N or ...
['Wrong Answer', 'Accepted']
['s555289451', 's124364070']
[5244.0, 9448.0]
[36.0, 28.0]
[400, 506]
p03231
u197704813
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['print(-1)', 'def gcd(a, b):\n while b > 0:\n a, b = b, a%b\n return a\n\nN,M = map(int,input().split(" "))\nS = input()\nT = input()\nN = len(S)\nM = len(T)\nx = gcd(N,M)\ny = int(N*M/x)\n\nfor i in range(x):\n if S[int(i*y/M)] == T[int(i*y/N)]:\n continue\n else:\n print(-1)\n exit()\...
['Wrong Answer', 'Accepted']
['s764132567', 's002793207']
[2940.0, 3316.0]
[17.0, 19.0]
[9, 296]
p03231
u199295501
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import fraction\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\nN, M = map(int, input().split())\nS = input()\nT = input()\n\nlcm_num = lcm(N,M)\n\nX_s = ["" for i in range(lcm_num)]\nX_t = ["" for i in range(lcm_num)]\n\n# print(X_s,X_t)\n\nfor i in range(N):\n tmp = i*lcm_num // N + 1\n X_s[tmp-1] = ...
['Runtime Error', 'Accepted']
['s510276890', 's595555427']
[3188.0, 3316.0]
[19.0, 19.0]
[560, 374]
p03231
u213580455
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n c = a%b\n while(c != 0):\n a = b\n b = c\n c = a%b\n return b\n\ndef answer(s, t):\n a = len(s)\n b = len(t)\n if a[0] != b[0]:\n return -1\n if a < b:\n temp = a\n a = b\n b = temp\n gcdAB = gcd(a, b)\n if gcdAB == 1:\n ...
['Runtime Error', 'Accepted']
['s023511928', 's502669739']
[3444.0, 3444.0]
[17.0, 28.0]
[713, 761]
p03231
u242525751
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b): \n if b == 0: return a\n return gcd(b, a % b)\nn, m = map(int, input().split())\ng = gcd(n, m)\nl = n * m / g\nn = n/g\nm = m/g\ns = list(str(input()))[::int(n)]\nt = list(str(input()))[::int(m)]\nif s == t:\n print(l)\nelse:\n print("-1")', 'def gcd(a, b): \n if b == 0: return a\n return gcd(...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s611609941', 's729376184', 's654486657']
[4160.0, 4160.0, 4160.0]
[20.0, 22.0, 20.0]
[247, 247, 250]
p03231
u254871849
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["# 2019-11-28 02:28:10(JST)\nimport sys\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef main():\n n, m = map(int, sys.stdin.readline().split())\n s, t = sys.stdin.read().split()\n\n g = gcd(n, m)\n l = lcm(n, m)\n\n if g == 1...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s359728304', 's429076448', 's809669475', 's959743044', 's918182165']
[3444.0, 3444.0, 3444.0, 3444.0, 3444.0]
[18.0, 18.0, 19.0, 22.0, 18.0]
[649, 649, 648, 614, 490]
p03231
u257374434
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\nN,M= list(map(int,input().split()))\nS =input()\nT=input()\n\n\nL = N*M//math.gcd(N,M)\n\nd = dict()\n\nfor i in range(N):\n print(1+(L//N)*i)\n index = 1+(L//N)*i\n d[index] = S[i]\n\nfor j in range(M):\n index = (1+(L//M)*j)\n if index in d:\n if d[index]!=T[j]:\n print...
['Runtime Error', 'Accepted']
['s511395989', 's192308334']
[3316.0, 15396.0]
[18.0, 78.0]
[334, 446]
p03231
u305018585
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = map(int, input().split(\' \'))\nS = input()\nT = input()\nimport numpy as np\ndef gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n \nL = lcm(N,M)\n#max_n = max(N,M)\n\nx1 = [1] + [(i *(L/N)) +1for i in range(1, N)] \nx2 = [1]+ [(i *(L/M)) +1for i in ra...
['Wrong Answer', 'Accepted']
['s032745878', 's822324271']
[26408.0, 3316.0]
[499.0, 21.0]
[546, 319]
p03231
u328207927
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['\ndef gcd(a, b):\n while b:\n a,b=b,a%b\n return a\ndef lcm(x,y):\n return (x * y) // gcd(x, y)\n\ndef atwo(n,m,s,t):\n l=lcm(n,m)\n gc=gcd(n,m)\n if s[0::n//gc]==t[0::m//gc]:\n print(l)\n exit()\n else:\n print(-1)\n exit()', 'def gcd(a, b):\n while b:\n...
['Wrong Answer', 'Accepted']
['s435866753', 's973060273']
[3060.0, 3316.0]
[18.0, 18.0]
[268, 333]
p03231
u352558780
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\n\n \n\n \nN,M = map(int,input().split())\nS = input()\nT = input()\n\npair = {N:S,M:T}\n\n\ndef lcd(n,m):\n return int(n * m / gcd(n,m))\ndef gcd(n,m):\n if n % m == 0:\n return m\n else:\n return gcd(m,n % m)\n# return int(m*n/math.gcd(n,m))\n \ndef prove(n,m):\n if gcd(n...
['Runtime Error', 'Accepted']
['s519559400', 's289199847']
[3064.0, 3828.0]
[17.0, 22.0]
[756, 542]
p03231
u371763408
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m=map(int,input().split())\ns=input()\nt=input()\n\ndef gcd(x,y):\n r=x%y\n return gcd(y,r) if r else y\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\nL=lcm(n,m)\ng=gcd(n,m)\nif s[0]==t[0]:\n X=[""]*(L+1)\n print(X)\nelse:\n print(-1)\n exit()\nfor i in range(1,g):\n X[int(i*L/n)+1]=s[i]\nfor i in ran...
['Runtime Error', 'Runtime Error', 'Accepted']
['s897368850', 's925924396', 's484461775']
[464572.0, 187764.0, 3316.0]
[1508.0, 133.0, 19.0]
[417, 393, 276]
p03231
u388697579
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import numpy as np# your code goes here\ndef eucrid(a, b):\n\tif (a > b):\n\t\tbuf = a\n\t\ta = b\n\t\tb = buf\n\tif (b % a == 0):\n\t\treturn a\n\telse:\n\t\treturn eucrid(b%a, a)\n\t\t\ndef main():\n\tbuf = input().split()\n\ts = input()\n\tt = input()\n\tn = len(s)\n\tm = len(t)\n\t\n\tbig = n*m//eucrid(n, m)\n\tf...
['Runtime Error', 'Accepted']
['s984431933', 's271557071']
[21232.0, 12712.0]
[2109.0, 179.0]
[524, 645]
p03231
u408620326
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["def main():\n import sys\n sys.setrecursionlimit(10**6)\n input = sys.stdin.readline\n\n def gcd(a, b):\n if b == 0:\n return a\n return gcd(b, a % b)\n \n N, M = [int(x) for x in input().strip().split()]\n S = input().strip()\n T = input().strip()\n L = (N * M) // ...
['Runtime Error', 'Accepted']
['s114373662', 's919769192']
[187764.0, 15772.0]
[131.0, 71.0]
[649, 626]
p03231
u411923565
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['#66 A - Two Abbreviations\nimport math\nN,M = map(int,input().split())\nS = input()\nT = input()\n\nL = N*M//math.gcd(N,M)\n\ndist_N = L//N\ndist_M = L//M\nlis = [0]*L\n\ni = 0\nfor n in range(0,L,dist_N):\n lis[n] = S[i]\n i += 1\n print(lis)\n \nj = 0\nfor m in range(0,L,dist_M):\n if lis[m] == 0:\n ...
['Runtime Error', 'Accepted']
['s351931102', 's821704522']
[397852.0, 9304.0]
[2377.0, 26.0]
[463, 436]
p03231
u427344224
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = map(int, input().split())\nS = input()\nT = input()\n\n# if a < b:\n\n# else:\n# return a if b == 0 else gcd(b, a % b)\n\nimport fractions\ndef lcm(a, b):\n return a * b // fractions.gcd(b, a % b)\n\n\nL = lcm(N, M)\n\nr = ["*" for i in range(L)]\nf = False\n\ns_step = L // N\nt_step = L // ...
['Runtime Error', 'Accepted']
['s295411545', 's674696434']
[508500.0, 3444.0]
[2132.0, 19.0]
[1532, 681]
p03231
u488884575
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\nn,m=map(int,input().split())\ns=input()\nt=input()\ng = n * m // math.gcd(n, m)\n\nsnum=[i*g/n+1 for i in range(n)]\ntnum=[i*g/m+1 for i in range(m)]\nprint(snum,tnum)\n\nif n<m:\n s,t=t,s\n snum,tnum=tnum,snum\nfor i in range(len(snum)):\n if snum[i] in tnum:\n if s[i]!=t[tnum.index(snum...
['Wrong Answer', 'Accepted']
['s957652270', 's403134234']
[18640.0, 9236.0]
[2208.0, 31.0]
[359, 306]
p03231
u495561847
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\n\nn, m = map(int, input().split())\ns = input()\nt = input()\n\ncnt = 1\nns = 1\nnt = 1\nss = 0\ntt = 0\nfail = False\n\nll = (n * m) // math.gcd(x, y)\nl = ll\n\nwhile l <= n * m:\n fail = False\n while not( ns >= l or nt >= l):\n while not(ns <= nt):\n nt += l / m \n ...
['Runtime Error', 'Accepted']
['s319320343', 's109531136']
[3316.0, 3316.0]
[18.0, 82.0]
[535, 581]
p03231
u513081876
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["N, M = map(int, input().split())\nS = input()\nT = input()\n\ndef gcd(a, b):\n while b!= 0:\n a, b = b, a%b\n return a\n\nif N == M:\n if S == T:\n print('N')\n else:\n print(-1)\n \nelse:\n if S[0] == T[0]:\n lcm = a*b//(gcd(a, b))\n print(lcm)\n \n ...
['Runtime Error', 'Accepted']
['s750177111', 's790914907']
[3316.0, 3316.0]
[19.0, 20.0]
[353, 279]
p03231
u513434790
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import sys\n\nN, M = map(int, input().split())\nS = input()\nT = input()\n\ndef gcd(a, b):\n while b :\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\nL = lcm(N, M)\nX = [["A"] for i in range(L)]\n\nfor i in range(N):\n index = i * (L // N)\n X[index] = S[i]\n\nfor ...
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s038031956', 's246806906', 's355068609', 's814456180']
[594548.0, 187764.0, 187764.0, 3316.0]
[2142.0, 364.0, 373.0, 17.0]
[434, 447, 445, 249]
p03231
u540572789
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\ndef lcm(a, b):\n\treturn a * b // gcd (a, b)\nn, m = map(int,input().split())\ns = input()\nt = input()\nj = 0\na = gcd(n, m)\nfor i, c in enumerate(s):\n\tif i % a == 0:\n\t\tif c != t[i // a * m]:\n\t\t\tj = -1\n\t\t\tbreak\nif j >= 0:\n\tj = lcm(n, m)\np...
['Runtime Error', 'Accepted']
['s725971848', 's180090257']
[3316.0, 3316.0]
[21.0, 38.0]
[292, 315]
p03231
u554871639
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\ndef main():\n N, M = map(int, input().split())\n S = input()\n T = input()\n result = N * M / math.gcd(N, M)\n cand = (result / N) * (result / M) / math.gcd((result / N), (result / M))\n for i in range(0, result / cand):\n if S[(i * cand) / (result / N)] != T[(i * cand) / (result...
['Runtime Error', 'Runtime Error', 'Accepted']
['s616718381', 's648138250', 's887852746']
[3316.0, 4624.0, 3316.0]
[17.0, 30.0, 20.0]
[371, 512, 498]
p03231
u598229387
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import fractions\nn,m=map(int,input().split())\ns=input()\nt=input()\n\nf1=fractions.gcd(n,m)\nf1=n*m//f1\nif s[0]!=t[0]:\n print(-1)\n\nelif max(n,m)%min(n,m)!=0:\n print(f1)\nelif n==m:\n if s==t:\n print(n)\n else:\n print(-1)\nelif n>m:\n f1=fractions.gcd(n,m)\n f1=n*m//f1\n \n ...
['Wrong Answer', 'Accepted']
['s357356458', 's232157627']
[5432.0, 3316.0]
[36.0, 19.0]
[684, 397]
p03231
u603234915
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(A, B):\n while B != 0:\n A, B = B, A%B\n return A\n\nN, M = map(int, input().split())\nS = input()\nT = input()\ncan = True\nagc = N // gcd(N, M) * M\nL_N = agc // N\nL_M = agc // M\ni = 0\n\nwhile i*L_M < agc and i*L_N < agc:\n if S[i*L_M] != T[i*L_N]:\n can = False\n break\n ...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s477422778', 's756207510', 's967690585', 's333758596']
[3316.0, 3316.0, 2940.0, 3316.0]
[19.0, 19.0, 17.0, 19.0]
[351, 351, 323, 347]
p03231
u607865971
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = [int(x) for x in input().split(" ")]\nS = input()\nT = input()\n\nN = len(S)\nM = len(T)\n\n\ndef gcd(a, b):\n if (a < b):\n return gcd(b, a)\n if a % b == 0:\n return b\n else:\n return gcd(b, a % b)\n\n\ndef maxkobai(a, b):\n return a * b // gcd(a, b)\n\n\n#print(gcd(N, M))\n...
['Wrong Answer', 'Accepted']
['s667485819', 's713007517']
[1538056.0, 16380.0]
[2130.0, 102.0]
[672, 538]
p03231
u610734676
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\n\nN, M = list(map(int, input().split()))\nS = input()\nT = input()\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\nsuccess = False;\nans = 0\n_lcm = lcm(N, M)\nfor k in range(1, N*M//_lcm + 1):\n ans = k * _lcm\n s = [(i * ans)//N + 1 for i in range(N)]\n t = [(i * ans)//M + 1 for i i...
['Runtime Error', 'Accepted']
['s428347206', 's940354296']
[3444.0, 4328.0]
[18.0, 63.0]
[748, 1246]
p03231
u623819879
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m=map(int, input().split())\ns=input()\nt=input()\ndef euc(x,y):\n if x % y==0:\n return x\n else:\n return euc(max(x,y) % min (x,y),min(x,y))\nd=euc(n,m)\nans=int(n*m/d)\nif d==1:\n print(n*m)\nelse:\n for i in range(d):\n if s[i*int(n/d)]!=t[i*int(m/d)]:\n ans=-1\n print(ans)', 'n,m=map(int, in...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s291219991', 's750718974', 's890481016', 's131040648']
[3316.0, 3316.0, 3316.0, 3316.0]
[18.0, 18.0, 18.0, 31.0]
[283, 278, 283, 346]
p03231
u668503853
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, M: int, S: str, T: str):\n # from math import gcd\n from fractions import gcd\n\n def lcm(a: int, b: int):\n return (a * b) // gcd(a, b)\n\n l = lcm(N, M)\n\n x = [''] * l\n\n for i in range(N):\n x[i*(l//N)] = S[i]\n\n for i...
['Runtime Error', 'Accepted']
['s838009018', 's394809220']
[189776.0, 3316.0]
[188.0, 19.0]
[1026, 194]
p03231
u678167152
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = map(int, input().split())\nS = input()\nT = input()\n\nfrom collections import gcd\n\ndef solve(N,M,S,T):\n g = gcd(N,M)\n for i in range(g):\n if S[N//g*i]!=T[M//g*i]:\n return -1\n ans = N*M//g\n return ans\nprint(solve(N,M,S,T))', 'from math import gcd\ndef solve():\n N, M = m...
['Runtime Error', 'Accepted']
['s557944502', 's020568238']
[3572.0, 9224.0]
[21.0, 28.0]
[255, 220]
p03231
u687574784
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m = list(map(int, input().split()))\ns = input()\nt = input()\nimport math\n\n\ngcd = math.gcd(n, m)\nprint(s[::n//gcd] ,t[::m//gcd])\nif s[::n//gcd] == t[::m//gcd]:\n print(n * m // gcd)\nelse:\n print(-1)\n', 'n,m = list(map(int, input().split()))\ns = input()\nt = input()\nimport math\n\n\ngcd = math.gcd(n...
['Wrong Answer', 'Accepted']
['s583150817', 's537022676']
[9136.0, 9280.0]
[27.0, 26.0]
[269, 236]
p03231
u690781906
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n if a < b:\n a, b = b, a\n while a % b != 0:\n a, b = b, a % b\n return b\n\n\nN, M = map(int, input().split())\nS = input()\nT = input()\nx = gcd(N, M)\nn = N // x\nm = M // x\n\nfor i in range(3):\n if S[n*i] == T[m*i]:\n print(-1)\n break\nprint(N*M//x)\n', '...
['Runtime Error', 'Accepted']
['s513704008', 's851460450']
[9352.0, 9264.0]
[30.0, 30.0]
[294, 295]
p03231
u704563784
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a // gcd (a, b) * b\n\nn, m = map(int, input().split())\ns = input()\nt = input()\n\nans = lcm(n, m)\n\nchk = {}\n\nfor i in range(n):\n d = ans//n\n chk[i*d] = s[i]\nfor i in range(m):\n d = ans//m\n if i*d ...
['Wrong Answer', 'Accepted']
['s777188188', 's979499777']
[15396.0, 15396.0]
[62.0, 68.0]
[371, 371]
p03231
u749614185
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['from math import gcd\n \na,b=map(int, input().split())\nc=input()\nd=input()\n \ne=gcd(n,m)\n \nae=a//e\nbe=b//e\n \nfor i in range(0,e):\n if c[ae*i]!=d[be*i]:\n print(-1)\n exit()\nprint(ae*be*e)', 'from math import gcd\n \nn,m=map(int, input().split())\ns=input()\nt=input()\n \ng=gcd(n,m)\n \nng=n...
['Runtime Error', 'Accepted']
['s383240450', 's486220513']
[9276.0, 9064.0]
[24.0, 32.0]
[199, 199]
p03231
u750651325
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): r...
['Runtime Error', 'Accepted']
['s938236375', 's333590429']
[10612.0, 10668.0]
[33.0, 40.0]
[681, 686]
p03231
u752767312
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return int(a)\n r = a % b\n return gcd(b, r)\n\ndef lcm(a,b):\n return int(a*b/gcd(a,b))\n \nN,M = map(int,input().split())\nS = input()\nT = input()\nL = lcm(N,M)\nflag = True\nmin_len = min(Na,M)\ns_index = int(int(L/M)/gcd(int(L/M),...
['Runtime Error', 'Accepted']
['s047384969', 's507001975']
[3444.0, 3444.0]
[18.0, 19.0]
[719, 718]
p03231
u782098901
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def 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)\n\n\ndef main():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n g = gcd(N, M)\n for i in range(g):\n if S[i * N // g] != T[i * M // g]:\n ...
['Wrong Answer', 'Runtime Error', 'Accepted']
['s250772611', 's505055877', 's446038218']
[3316.0, 3316.0, 3316.0]
[18.0, 18.0, 19.0]
[364, 358, 354]
p03231
u793460864
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = map(int, input().split())\nS = str(input())\nT = str(input())\n\ndef lcm(x, y):\n def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n return (x * y) // gcd(x, y)\nX = lcm(N ,M)\n\nif S[0] != T[0]:\n print(-1)\nelif X == N*M:\n print(N*M)\nelse:\n for i in range(1,(N...
['Runtime Error', 'Accepted']
['s930092029', 's698751568']
[3064.0, 3316.0]
[18.0, 19.0]
[639, 534]
p03231
u815763296
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\nN, M = map(int, input().split())\nS = list(input())\nT = list(input())\n\nlcm = (N * M) // math.gcd(N, M)\nans = lcm\nansS = ["0"]*lcm\nansT = ["0"]*lcm\nSp = lcm//N\nTp = lcm//M\n\n\nfor i in range(10000000000):\n if Sp*i > lcm:\n break\n if i > N:\n break\n ansS[Sp*i] = S[i]\n\nf...
['Runtime Error', 'Accepted']
['s043315444', 's409803358']
[379112.0, 10352.0]
[503.0, 31.0]
[558, 315]
p03231
u835283937
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['import math\ndef main5():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n G = math.gcd(N, M)\n L = (N * M) // G\n\n for i in range(G):\n if S[i * N // G] != T[i * M // G]:\n print(-1)\n exit()\n\n print(L)\n\nif __name__ == "__main__":\n main4()'...
['Runtime Error', 'Accepted']
['s768014979', 's602250876']
[9144.0, 9400.0]
[24.0, 31.0]
[300, 300]
p03231
u842170774
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["Jupyter Notebook\nAGC-n\nCurrent Kernel Logo\nPython 3 \n\n\n1\n#A\n2\nN=input()\n3\nA_list=list(map(int,input().split()))\n4\nn=0\n5\nfor i in range(len(A_list)-1):\n6\n if A_list[i]==A_list[i+1]:\n7\n A_list[i+1]+=10000\n8\n n+=1\n9\nprint(n)\n1\n2 3 4 5\n0\n\n1\n#B\n2\nimport math\n3\nT=int(input(...
['Runtime Error', 'Accepted']
['s516210602', 's961687743']
[2940.0, 3316.0]
[18.0, 24.0]
[5563, 412]
p03231
u871841829
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N, M = map(int, input().split())\nS = input()\nT = input()\n\nimport sys\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n gcd(b%a, a)\n\ng = gcd(N, M)\nsn = N/g\nsm = M/g\n\nok = True\nfor k in range(0, g):\n a = k * sn\n b = k * sm\n if S[a] != T[b]:\n ok = False\n break...
['Runtime Error', 'Wrong Answer', 'Accepted']
['s143917580', 's908759684', 's040200832']
[3316.0, 3316.0, 3316.0]
[18.0, 18.0, 19.0]
[341, 117, 352]
p03231
u879870653
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def gcd(m,n) :\n x = max(m,n)\n y = min(m,n)\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 lcm(m,n) :\n return int(m*n/gcd(m,n))\n\nN,M = map(int,input().split())\nS = list(inp...
['Runtime Error', 'Accepted']
['s534998746', 's489146907']
[7988.0, 8664.0]
[46.0, 80.0]
[755, 1227]
p03231
u888337853
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["import sys\nimport re\nimport math\nimport collections\nimport decimal\nimport bisect\nimport itertools\nimport fractions\n\nimport copy\n\n# import heapq\n# from collections import deque\n\n\n\nINF = sys.maxsize\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline()....
['Runtime Error', 'Runtime Error', 'Accepted']
['s066234550', 's948278807', 's571066223']
[195628.0, 195628.0, 19372.0]
[185.0, 184.0, 73.0]
[896, 896, 1025]
p03231
u896726004
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['from fractions import gcd\n\ndef lcm(m, n):\n return (m * n) // gcd(m, n)\n\ndef lcm_list(a):\n x = a[0]\n for i in range(1, len(a)):\n x = (x * a[i]) // gcd(x, a[i])\n return x\n\nN, M = map(int, input().split())\nS = input()\nT = input()\n\nl = lcm(N, M)\n\nif l==N or l==M:\n print(-1)\nelse:\...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s304536648', 's859830823', 's915960853', 's714345206']
[5340.0, 5688.0, 5340.0, 9316.0]
[36.0, 54.0, 36.0, 30.0]
[311, 325, 325, 324]
p03231
u924406834
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['n,m = map(int,input().split())\ns = str(input())\nt = str(input())\na = 0\ndef get_gcd(a, b):\n if a < b:\n a, b = b, a\n if a % b == 0:\n return b\n else:\n return get_gcd(b, a % b)\ndef get_lcm(a, b, gcd):\n lcm = a * b // gcd\n return lcm\nsaisyou = get_lcm(n,m,get_gcd(n,m))\nan...
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s347894583', 's548558643', 's752001512', 's985357040', 's792176136']
[3444.0, 3444.0, 3316.0, 3444.0, 3444.0]
[19.0, 18.0, 18.0, 21.0, 21.0]
[752, 1043, 798, 1047, 683]
p03231
u932913455
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['def main28():\n import sys\n N, M = (int(x) for x in input().split())\n\n if N >= M:\n S = input()\n T = input()\n else:\n T = input()\n S = input()\n\n def lcm(n, m):\n gcd = 0\n for i in range(1, min(n, m)):\n if n % i == 0 and m % i == 0:\n ...
['Runtime Error', 'Accepted']
['s836933869', 's215091041']
[3316.0, 3316.0]
[35.0, 41.0]
[624, 662]
p03231
u939552576
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
["import math\nimport numpy as np\nN,M = map(int,input().split())\nS = input()\nT = input()\n\nL = N*M // math.gcd(N,M)\n\nX = np.zeros(L, dtype=np.str)\n\nfor i in range(N):\n X[i*(L//N)] = S[i]\n\nfor i in range(M):\n if X[i*(L//M)] == '':\n X[i*(L//M)] = T[i]\n elif X[i*(L//M)] != T[i]:\n prin...
['Runtime Error', 'Runtime Error', 'Accepted']
['s299519384', 's938140165', 's264263459']
[21096.0, 104904.0, 18672.0]
[832.0, 708.0, 40.0]
[333, 416, 517]
p03231
u941438707
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['print(-1)', 'from math import *\na,b=map(int,input().split())\ns=input()\nt=input()\ng=gcd(a,b)\nfor i in range(g):\n if s[a//g*i]!=t[b//g*i]:\n print(-1)\n exit()\nprint(a*b//g)']
['Wrong Answer', 'Accepted']
['s464261625', 's826200987']
[8920.0, 9156.0]
[29.0, 29.0]
[9, 173]
p03231
u941753895
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['# GCD\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\n# LCM\ndef lcm(x,y):\n return x*y/gcd(x,y)\n\na,b=map(int,input().split())\nif a%b==0 or b%a==0:\n print(-1)\nelse:\n print(lcm(a,b))', '# GCD\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\n# LCM\ndef lcm(x,y):\n return x*y/gcd(x,y)\n\na,b=m...
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s229995223', 's435835719', 's872471001', 's807762264']
[3060.0, 3308.0, 5416.0, 17408.0]
[18.0, 18.0, 39.0, 67.0]
[185, 154, 929, 909]
p03231
u970738863
2,000
1,048,576
You are given a string S of length N and another string T of length M. These strings consist of lowercase English letters. A string X is called a **good string** when the following conditions are all met: * Let L be the length of X. L is divisible by both N and M. * Concatenating the 1-st, (\frac{L}{N}+1)-th, (2 ...
['N,M = map(int,input().split())\nS = input()\nT = input()\n\ndef gcd(a,b):\n while b>0:\n a,b = b,a%b\n return a\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nL = lcm(N,M)\nG = gcd(N,M)\nn = L//N\nm = L//M\n\ns = [S[i*m] for i in range(G)]\nt = [T[i*n] for i in range(G)]\n\nif s == t or (G == 1 and S[0]==...
['Runtime Error', 'Accepted']
['s988032624', 's983559229']
[3188.0, 3700.0]
[18.0, 23.0]
[339, 338]
p03232
u013408661
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['import math\nN=int(input())\nnumber=list(map(int,input().split()))\nSUM=[]\nsum=0\np=10**9 +7\n\nx=math.factorial(N)%p\n\nfor i in range(1,N+1):\n \n k=pow(i,p-2,p)\n sum+= (x*k)%p\n sum= sum%p\n SUM.append(sum)\n\n\n\nfor i in range(N):\n ans+= (number[i]*(SUM[i]+SUM[N-i-1]-x))%p\n ans= ans%p\n\nprint(ans)', ...
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s169479322', 's212355888', 's502853036', 's538405482', 's540664093', 's642549655', 's957565099']
[15020.0, 15020.0, 15020.0, 15020.0, 15148.0, 15020.0, 15020.0]
[654.0, 398.0, 43.0, 376.0, 647.0, 721.0, 713.0]
[495, 284, 297, 294, 480, 308, 501]
p03232
u067983636
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['N = int(input())\nA = list(map(int, input().split()))\nR = [0] * (N + 1)\nP = [1] * (N + 1)\nmod = 10 ** 9 + 7\n\ndef power(x, y):\n if y == 0:\n return 1\n elif y == 1: \n return x % mod\n elif y % 2 == 0: \n return power(x, y//2)**2 % mod\n else: \n return power(x, y//2)**2 *...
['Wrong Answer', 'Accepted']
['s700713108', 's485599383']
[1620640.0, 24340.0]
[2206.0, 1620.0]
[587, 555]
p03232
u089032001
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['ef multiply(x, y):\n return (x * y) % mod\n\n\ndef power(x, y):\n if y == 0:\n return 1\n elif y == 1:\n return x\n elif x == 1:\n return 1\n elif x == 0:\n return 0\n else:\n # print(mod)\n tmp = power(x, y // 2)\n return (multiply(tmp, tmp) * [1, x]...
['Runtime Error', 'Accepted']
['s828102766', 's152777587']
[2940.0, 14480.0]
[17.0, 1994.0]
[763, 764]
p03232
u218843509
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['import sys\nsys.setrecursionlimit(10**7)\n\nn = int(input())\n#a = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\ndef extended_euclid(x, y):\n c0, c1 = x, y\n a0, a1 = 1, 0\n b0, b1 = 0, 1\n\n while c1 != 0:\n m = c0 % c1\n q = c0 // c1\n\n c0, c1 = c1, m\n a0, a1 = a1, ...
['Runtime Error', 'Accepted']
['s181152208', 's800783014']
[7124.0, 91636.0]
[406.0, 598.0]
[840, 839]
p03232
u283869437
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['m=10**9+7\ninput()\ni=s=r=0\nf=1\na=map(int,input().split())\nfor _ in a:\n s+=pow(i+1,m-2,m)\n r+=a[i]*~-s+a[~i]*s\n i+=1\n f=f*i%m\nprint(r*f%m)', 'm=10**9+7\ninput()\ni=s=r=0\nf=1\na=input().split()\nfor _ in a:\n s+=pow(i+1,m-2,m);r+=int(a[i])*~-s+int(a[~i])*s;i+=1;f=f*i%m\nprint(r*f%m)']
['Runtime Error', 'Accepted']
['s047048093', 's233602815']
[11480.0, 11484.0]
[27.0, 500.0]
[136, 134]
p03232
u562016607
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
['N=int(input())\nA=[int(i) for i in input().split()]\nP=10**9+7\ndef egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return (lastx, lasty, a)\ndef inv...
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s065326361', 's448006244', 's110702582']
[19068.0, 19212.0, 23168.0]
[526.0, 960.0, 563.0]
[583, 774, 685]
p03232
u745087332
2,000
1,048,576
There are N blocks arranged in a row, numbered 1 to N from left to right. Each block has a weight, and the weight of Block i is A_i. Snuke will perform the following operation on these blocks N times: * Choose one block that is still not removed, and remove it. The cost of this operation is the sum of the weights of...
["# coding:utf-8\n\nimport sys\n\n\ninput = sys.stdin.readline\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\n\n\ndef pow_mod(a, p):\n if p == 0: return 1\n\n if p % 2 == 0:\n half_p = p // 2\n half = pow_mod(a, half_p)\n return half * half...
['Wrong Answer', 'Accepted']
['s026502307', 's535253599']
[15200.0, 23372.0]
[1575.0, 176.0]
[1069, 1323]
p03233
u170201762
2,000
1,048,576
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in thi...
['N = int(input())\nC = [list(map(int,input().split())) for i in range(N)]\nC.sort()\nans0 = 0\nans1 = 0\nans2 = 0\nAM = []\nAm = []\nBM = []\nBm = []\nfor i in range(N):\n ans0 += C[i][0]\n ans1 += C[i][1]\n Min = min(C[i][0],C[i][1])\n Max = max(C[i][0],C[i][1])\n ans2 += Min\n if Min == C[i][0]:\n ...
['Runtime Error', 'Accepted']
['s034615879', 's796329243']
[29600.0, 42220.0]
[613.0, 784.0]
[553, 452]
p03233
u340781749
2,000
1,048,576
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in thi...
['n = int(input())\naaa = [tuple(map(int, input().split())) for _ in range(n)]\nlo = [min(a) for a in aaa]\nhi = [max(a) for a in aaa]\nlo.sort(reverse=True)\nhi.sort()\nans = sum(lo)\n\nfor l, h in zip(lo, hi):\n if l <= h:\n break\n ans += h\n ans -= l\n\nprint(ans)\n', 'from operator import itemgette...
['Wrong Answer', 'Accepted']
['s494471230', 's772781587']
[18580.0, 41644.0]
[438.0, 632.0]
[269, 689]
p03233
u816116805
2,000
1,048,576
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in thi...
['#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n\n#\n\n"""\nAGC028 C\n"""\n\nimport itertools\nfrom operator import itemgetter\n\nn = int(input())\nabli0 = [tuple(map(int, input().split())) for i in range(n)]\neabli0 = enumerate(abli0)\nabli1 = list(map(lambda t: ((t[1][0], t[0], 0), (t[1][1], t[0], 1)), eabli0))\na...
['Wrong Answer', 'Accepted']
['s294780802', 's557510241']
[46664.0, 36164.0]
[2110.0, 651.0]
[1005, 872]
p03233
u834415466
2,000
1,048,576
We have a directed weighted graph with N vertices. Each vertex has two integers written on it, and the integers written on Vertex i are A_i and B_i. In this graph, there is an edge from Vertex x to Vertex y for all pairs 1 \leq x,y \leq N, and its weight is {\rm min}(A_x,B_y). We will consider a directed cycle in thi...
['n=int(input())\na=[]\nb=[]\nfor i in range(n):\n p,q=map(int,input().split())\n a.append(p)\n a.append(q)\na.sort()\nresult=0\nfor i in range(n):\n result+=a[i]\nprint(result)', 'n=int(input())\na=[]\nb=[]\nfor i in range(n):\n p,q=map(int,input().split())\n a.append((p,i,0))\n a.append((q,i,1))\...
['Wrong Answer', 'Accepted']
['s222632415', 's988603380']
[11784.0, 31736.0]
[407.0, 563.0]
[176, 715]