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
p02685
u802963389
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['n, m, k = map(int, input().split())\n\nMOD = 998244353\n\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n<0 or k<0:\n return 0\n k=min(n-k,k)\n ans=1\n inv=[1]*(k+1)\n if k>=1:\n ans*=(n-k+1)%mod\n for i in range(2,k+1):\n inv[i]=mod-inv[mod%i]*(mod//i)%mod\n ans=ans*(n-k+i)*inv[i]%mod\n return ans\n\nans = 0\nfor i in range(k + 1):\n ans += ((m ** (i + 1)) * (m - 1) ** (n - 1 - i) * comb(n-1, i, MOD)) % MOD\nprint(ans % MOD)', 'n, m, k = map(int, input().split())\n\nMOD = 998244353\n\ndef comb(n,k,mod):\n if n<k:\n return 0\n if n<0 or k<0:\n return 0\n k=min(n-k,k)\n ans=1\n inv=[1]*(k+1)\n if k>=1:\n ans*=(n-k+1)%mod\n for i in range(2,k+1):\n inv[i]=mod-inv[mod%i]*(mod//i)%mod\n ans=ans*(n-k+i)*inv[i]%mod\n return ans\n\ndef pow_k(x, n, mod):\n \n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x % mod\n x *= x % mod\n n //= 2\n\n return K * x\n\nans = 0\nfor i in range(k + 1):\n ans += (pow_k(m, i + 1, MOD) * pow_k(m - 1, n - 1 - i, MOD) * comb(n - 1, i, MOD)) % MOD\nprint(ans % MOD)', 'n, m, k = map(int, input().split())\n\nMOD = 998244353\n\nfac = [1] * (n + 1)\ninv = [1] * (n + 1)\nfor j in range(1, n + 1):\n fac[j] = fac[j-1] * j % MOD\n\ninv[n] = pow(fac[n], MOD-2, MOD)\nfor j in range(n - 1, -1, -1):\n inv[j] = inv[j + 1] * (j + 1) % MOD\n\ndef comb(n, r):\n if r > n or n < 0 or r < 0:\n return 0\n return fac[n] * inv[n - r] * inv[r] % MOD\n\nans = 0\nfor i in range(k + 1):\n ans += (m * pow(m - 1, n - i - 1, MOD) * comb(n - 1, i)) % MOD\nprint(ans % MOD)\n']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s039493624', 's544721467', 's620240423']
[11092.0, 9268.0, 24712.0]
[2206.0, 2206.0, 652.0]
[466, 695, 483]
p02685
u810356688
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
["import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef main():\n n,m,k=map(int,input().split())\n mod=998244353\n ans=0\n for kx in range(k+1):\n ans+=m*(m-1)**(n-1-kx)%mod\n print(ans%mod)\n\n\nif __name__=='__main__':\n main()", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nclass mod_comb3:\n def __init__(self,mod=10**9+7,n_max=1):\n self.mod,self.n_max=mod,n_max\n self.fact,self.inv,self.factinv=[1,1],[0,1],[1,1]\n if 1<n_max:setup_table(n_max)\n def comb(self,n,r):\n if r<0 or n<r:return 0\n if self.n_max<n:self.setup_table(n)\n return self.fact[n]*(self.factinv[r]*self.factinv[n-r]%self.mod)%self.mod\n def setup_table(self,t):\n for i in range(self.n_max+1,t+1):\n self.fact.append(self.fact[-1]*i%self.mod)\n self.inv.append(-self.inv[self.mod%i]*(self.mod//i)%self.mod)\n self.factinv.append(self.factinv[-1]*self.inv[-1]%self.mod)\n self.n_max=t\n\ndef main():\n n,m,k=map(int,input().split())\n mod=998244353\n f=mod_comb3(mod)\n ans=0\n t=m*pow(m-1,n-1-k,mod)\n for kx in range(k,-1,-1):\n ans+=f.comb(n-1,kx)*t%mod\n t=t*(m-1)%mod\n print(ans%mod)\n\nif __name__=='__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s865984172', 's907661192']
[10720.0, 32840.0]
[2206.0, 384.0]
[253, 995]
p02685
u843135954
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\nmod = 998244353\naall = pow(m,n,mod)\n\np = n-k+1\n\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\n\nN = 10**3*3\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nif n//2 > k:\n print(aall-cmb(n+p,p,mod))\n exit()\n\nprint(aall)', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\nmod = 998244353\n\ndef cmb(n, r, p):\n if (r < 0) or (n < r):\n return 0\n r = min(r, n - r)\n return fact[n] * factinv[r] * factinv[n-r] % p\n\nN = 10 ** 6 \nfact = [1, 1] # fact[n] = (n! mod p)\nfactinv = [1, 1] # factinv[n] = ((n!)^(-1) mod p)\ninv = [0, 1] \n \nfor i in range(2, N + 1):\n fact.append((fact[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod // i)) % mod)\n factinv.append((factinv[-1] * inv[-1]) % mod)\n\nans = 0\n\nfor i in range(k+1):\n ans += pow(m-1,n-k-1,mod)*cmb(n-1,k,mod)\n\nprint(ans*m%mod)', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\nmod = 998244353\naall = pow(m,n,mod)\n\np = n-k+1\n\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**3*3\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nif n//2 > k:\n print(aall-cmb(n+p,p,mod))\n exit()\n\nprint(aall)', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\nmod = 998244353\naall = pow(m,n,mod)\n\np = n-k+1\n\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9+7 \nN = 10**3*3\ng1 = [1, 1] \ng2 = [1, 1] \ninverse = [0, 1] 計算用テーブル\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nprint(aall-cmb(n+p,p,mod))', 'import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m,k = na()\nmod = 998244353\n\n\nfact = [0] * 220000\ninvfact = [0] * 220000\n \nfact[0] = 1\nfor i in range(1, 220000):\n fact[i] = fact[i-1] * i % mod\n \ninvfact[220000 - 1] = pow(fact[220000 - 1], mod-2, mod)\n \nfor i in range(220000 - 2, -1, -1):\n invfact[i] = invfact[i+1] * (i+1) % mod\n \ndef nCk(n, k):\n if k < 0 or n < k:return 0\n return fact[n] * invfact[k] * invfact[n-k] % mod\n \nans = 0\n\nfor i in range(k+1):\n ans += pow(m-1,n-i-1,mod)*nCk(n-1,i)\n\nprint(ans*m%mod)']
['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s254501583', 's286328310', 's322700835', 's884564105', 's415526523']
[9444.0, 127584.0, 9336.0, 9428.0, 26264.0]
[28.0, 1524.0, 27.0, 28.0, 629.0]
[778, 816, 808, 767, 699]
p02685
u859897687
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['import sys\n\nn,m,k=map(int,input().split())\nMOD=998244353\n\nif n>m+k:\n print(0)\n sys.exit()\n\n\ndef COMinit():\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for i in range(2,MAX):\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD\n finv[i] = finv[i - 1] * inv[i] % MOD\n\n\ndef COM(n, k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD\n \n \nMAX=10000000\nfac=[0]*MAX\nfinv=[0]*MAX\ninv=[0]*MAX\n\nCOMinit()\n\ndef HCOM(n,r):\n return COM(n+r-1,r)\n \n#t=max(1,n-k)!\nt=m\nif n-k>1:\n for i in range(2,max(2,n-k)):\n t*=m-1\n t%=MOD\n#print(t)\n\nans=0\nfor c in range(max(1,n-k),n+1):\n if c>1:\n t*=m-1\n t%=MOD\n #print("c=",c,"t=",t,"HCOM=",HCOM(c,n-c))\n ans+=t*HCOM(c,n-c)\n ans%=MOD\n \n \n \nprint(ans)', 'import sys\n\nn,m,k=map(int,input().split())\nMOD=998244353\n\n\ndef COMinit():\n fac[0] = 1\n fac[1] = 1\n finv[0] = 1\n finv[1] = 1\n inv[1] = 1\n for i in range(2,MAX):\n fac[i] = fac[i - 1] * i % MOD\n inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD\n finv[i] = finv[i - 1] * inv[i] % MOD\n\n\ndef COM(n, k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD\n \n \nMAX=n+1\nfac=[0]*MAX\nfinv=[0]*MAX\ninv=[0]*MAX\n\nCOMinit()\n\ndef HCOM(n,r):\n return COM(n+r-1,r)\n \n#t=max(1,n-k)!\nt=m\nif n-k>1:\n for i in range(1,n-k-1):\n t*=m-1\n t%=MOD\n#print(t)\n\nans=0\nfor c in range(n-k,n+1):\n if c>1:\n t*=m-1\n t%=MOD\n #print("c=",c,"t=",t,"HCOM=",HCOM(c,n-c))\n ans+=t*HCOM(c,n-c)\n ans%=MOD\n \n \n \nprint(ans)']
['Wrong Answer', 'Accepted']
['s254471971', 's062927110']
[464180.0, 32504.0]
[2220.0, 401.0]
[851, 799]
p02685
u896741788
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['n,m,k=map(int,input().split())\nmod=998244353\nif m==1:print(0 if k!=n-1 else 1);exit()\nfact=[1]*(n-1+1)\ninv=[1]*(n-1+1)\nfor i in range(2,n-1+1):\n fact[i]=i*fact[i-1]%mod\ninv[-1]=pow(fact[-1],mod-2,mod)\nfor i in range(n-1,1,-1):\n inv[i-1]=inv[i]*i%mod\nans=0\npo=pow(m-1,n-1,mod)\nue=fact[n-1]\niii=m*pow(m-1,mod-2,mod)%mod\nfor i in range(k+1):\n ans+=ue*inv[n-1-i]%mod*inv[i]%mod*po%mod\n po*=iii\nprint(ans%mod)\n', 'n,m,k=map(int,input().split())\nmod=998244353\nif m==1:print(0 if k!=n-1 else 1);exit()\nfact=[1]*(n-1+1)\ninv=[1]*(n-1+1)\nfor i in range(2,n-1+1):\n fact[i]=i*fact[i-1]%mod\ninv[-1]=pow(fact[-1],mod-2,mod)\nfor i in range(n-1,1,-1):\n inv[i-1]=inv[i]*i%mod\ndef comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod\nans=0\npo=pow(m-1,n-1,mod)*m%mod\nue=fact[n-1]\niii=pow(m-1,mod-2,mod)%mod\nfor i in range(k+1):\n ans+=comb(n-1,i)po%mod\n po*=iii\n po%=mod\nprint(ans%mod)', 'n,m,k=map(int,input().split())\nmod1,mod2=10**9+7,998244353\nmod=mod2\nMAX=n-1\nfact=[1]*(MAX+1)\ninv=[1]*(MAX+1)\nfor i in range(2,MAX+1):\n fact[i]=i*fact[i-1]%mod\ninv[-1]=pow(fact[-1],mod-2,mod)\nfor i in range(MAX,1,-1):\n inv[i-1]=inv[i]*i%mod\ndef comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0\nans=0\ncor=pow(m-1,n-1-k,mod)\nfor i in range(k,-1,-1):\n ans=(ans+comb(n-1,i)*cor)%mod\n cor=cor*(m-1)%mod\n\nprint(m*ans%mod)']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s077037560', 's292665345', 's477138893']
[25108.0, 9100.0, 24548.0]
[2206.0, 22.0, 278.0]
[417, 467, 444]
p02685
u920103253
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['def n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\n\nn,m,k=n1()\n\nans=0\na=1\nfor i in range(k+1):\n ans+=a*m*(((m-1)**(n-1-k)))\n a=a*(n-1-i+1)//(i+1)\nprint(ans%998244353)', 'def n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\n\nn,m,k=n1()\n\nans=0\nfor i in range(k+1):\n a=1\n ans+=a*m*(((m-1)**(n-1-k)))\n a=a*(n-1-i+1)//(i+1)\nprint(ans%998244353)', 'def n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\n\nn,m,k=n1()\n\ndef cmb(n, k, mod, fac, ifac):\n \n k = min(k, n-k)\n return fac[n] * ifac[k] * ifac[n-k] % mod\n\n\ndef make_tables(mod, n):\n \n fac = [1, 1] \n ifac = [1, 1] \n inverse = [0, 1] \n\n for i in range(2, n+1):\n fac.append((fac[-1] * i) % mod)\n inverse.append((-inverse[mod % i] * (mod//i)) % mod)\n ifac.append((ifac[-1] * inverse[-1]) % mod)\n return fac, ifac\n\nans=0\na=1\nMOD=998244353\nfac, ifac = make_tables(MOD, n-1)\n \nfor i in range(k+1):\n ans+=m*pow(m-1,n-1-i,998244353)*cmb(n-1, i, MOD, fac, ifac)\nprint(ans%998244353)']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s334625964', 's511693997', 's241675210']
[10804.0, 10600.0, 32840.0]
[2206.0, 2206.0, 703.0]
[321, 325, 998]
p02685
u934868410
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['n,m,k = map(int,input().split())\nmod = 998244353\ndp = [[0] * (n+1) for i in range(n+1)]\ndp[1][0] = m\nfor i in range(2, n+1):\n dp[i][0] = (dp[i-1][0] * (m-1)) % mod\nfor i in range(2, n+1):\n dp[i][1] = (dp[i-1][0] + dp[i-1][1] * (m-1)) % mod\n\ndef xgcd(a, b):\n x0, y0, x1, y1 = 1, 0, 0, 1\n while b != 0:\n q, a, b = a // b, b, a % b\n x0, x1 = x1, x0 - q * x1\n y0, y1 = y1, y0 - q * y1\n return a, x0, y0\n\ndef modinv(a, m):\n g, x, y = xgcd(a, m)\n return x % m\n\n\nminv = modinv(m, mod)\ni = 2\nwhile i <= n:\n j = 2\n while j <= k:\n dp[i][j] = (dp[i//2][j//2] ** 2 * minv * (m-1)) % mod\n j *= 2\n i *= 2\n\nans = 0\nfor i in range(k+1):\n for j in range(50):\n if n >> j & 1:\n dp[n][i] += dp[j][i]\nprint(sum(dp[n][:k+1]))\n', 'n,m,k = map(int,input().split())\nmod = 998244353\nans = 0\nfact = [1,1]\nfinv = [1,1]\nfor i in range(2, n+1):\n fact += [fact[i-1] * i % mod]\n finv += [pow(fact[i], mod-2, mod)]\n\n\ndef comb(n,k, mod):\n return (fact[n] * finv[k] * finv[n-k]) % mod\n\n\n\nfor i in range(0, k+1):\n ans += m * pow(m-1, n-i-1, mod) * comb(n-1, i, mod)\n ans %= mod\nprint(ans)']
['Wrong Answer', 'Accepted']
['s105501654', 's072261346']
[2675788.0, 25008.0]
[2277.0, 1393.0]
[790, 359]
p02685
u937092222
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
[' = 998244353\nn, m, k = map(int, input().split())\n \nfact = [0]*(n+1)\nfact[0] = 1\nfor i in range(1, n+1):\n fact[i] = fact[i-1]*i % MOD\n \ninvfact= [0]*(n+1)\nfor i in range(n+1):\n invfact[i] = pow(fact[i], MOD-2, MOD)\n \n \ndef nCk(n, k):\n return fact[n]*invfact[k]*invfact[n-k]\n \n \nans = 0\nfor i in range(k+1):\n ans += m*pow(m-1, n-1-i, MOD)*nCk(n-1, i)\n ans %= MOD\nprint(ans)', "import sys\n \ninput = sys.stdin.readline\n \ndef comb(n, r):\n return (fact[n] * revfact[n-r] * revfact[r]) % mod\n \nmod = 998244353\nN, M, K = map(int, input().split())\n \nfact = [1] * (N + 1)\nfor i in range(1, N + 1):\n fact[i] = (fact[i-1] * i) % mod \n# print('fact:{}'.format(fact))\nrevfact = [1] * (N + 1) \nrevfact[N] = pow(fact[N], mod - 2, mod) \n# print('revfact:{}'.format(revfact))\nfor i in reversed(range(1, N)): \n revfact[i] = ((i + 1) * revfact[i + 1]) % mod\n# print('revfact:{}'.format(revfact))\n \nans = 0\nfor k in range(K + 1):\n ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod\n ans %= mod\nprint(ans)"]
['Runtime Error', 'Accepted']
['s808050834', 's719231782']
[9000.0, 24684.0]
[22.0, 659.0]
[386, 703]
p02685
u945228737
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
["def inverse(a, p):\n a_, p_ = a, p\n x, y = 1, 0\n while p_:\n t = a_ // p_\n a_ -= t * p_\n a_, p_ = p_, a_\n x -= t * y\n x, y = y, x\n x %= p\n return x\n\n\ndef solve():\n N, M, K = map(int, input().split())\n mod = 998244353\n\n nCi = [1]\n for i in range(1, N):\n nCi.append(nCi[i - 1] * (N - i) * inverse(i, mod) % mod)\n \n print(nCi)\n ans = 0\n for k in range(K + 1):\n n = N - k\n ans += M * int(pow((M - 1), n - 1, mod)) * nCi[k]\n ans %= mod\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n", "def inverse(a, p):\n a_, p_ = a, p\n x, y = 1, 0\n while p_:\n t = a_ // p_\n a_ -= t * p_\n a_, p_ = p_, a_\n x -= t * y\n x, y = y, x\n x %= p\n return x\n\n\ndef solve():\n N, M, K = map(int, input().split())\n mod = 998244353\n\n nCi = [1]\n for i in range(1, N):\n nCi.append(nCi[i - 1] * (N - i) * inverse(i, mod) % mod)\n ans = 0\n for k in range(K + 1):\n n = N - k\n ans += M * int(pow((M - 1), n - 1, mod)) * nCi[k]\n ans %= mod\n print(ans)\n\n\nif __name__ == '__main__':\n solve()\n"]
['Wrong Answer', 'Accepted']
['s672529644', 's060586783']
[21240.0, 16888.0]
[887.0, 869.0]
[634, 567]
p02685
u998262711
2,000
1,048,576
There are N blocks arranged in a row. Let us paint these blocks. We will consider two ways to paint the blocks different if and only if there is a block painted in different colors in those two ways. Find the number of ways to paint the blocks under the following conditions: * For each block, use one of the M colors, Color 1 through Color M, to paint it. It is not mandatory to use all the colors. * There may be at most K pairs of adjacent blocks that are painted in the same color. Since the count may be enormous, print it modulo 998244353.
['n,m,k=map(int,input().split())\nmod=998244353\ncntb=1\nfor i in range(k+1):\n # cntb*=(n-i)//i\n ans+=((m*pow(m-1,n-1-i,mod)%mod)*cntb)%mod\n ans%=mod\n cntb*=((n-i−1)*pow(i+1,mod-2,mod))%mod\nprint(ans%mod)', 'n,m,k=map(int,input().split())\nmod=998244353\ncntb=1\nans=0\nfor i in range(k+1):\n ans=ans+(((m*pow(m-1,n-1-i,mod))%mod)*cntb)%mod\n ans=ans%mod\n cntb=(cntb*(n-1-i)*pow(i+1,mod-2,mod))%mod\nprint(ans%mod)']
['Runtime Error', 'Accepted']
['s054470386', 's944914077']
[9036.0, 9204.0]
[25.0, 1295.0]
[215, 208]
p02686
u014800961
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['n = int(input())\nslist = []\nfor i in range(n):\n slist.append(input())\n\nfirst_list = []\nlast_list = []\nfor i in range(n):\n s = slist[i]\n\n a_count = 0\n b_count = 0\n min_s = ""\n for c in s:\n if c == ")":\n b_count-=1\n else:\n b_count+=1\n if b_count < 0:\n b_count = 0\n a_count+= 1\n min_s = ")"* a_count + "("*b_count\n\n ai = len(min_s)-b_count\n bi = b_count\n if bi-ai >= 0:\n first_list.append([min_s,ai])\n else:\n last_list.append([min_s,bi])\n\nsorted(first_list, key=lambda s: s[1])\nsorted(last_list, key=lambda s: s[1], reverse=True)\n\nans = ""\nfor i in range(len(first_list)):\n ans += first_list[i][0]\nfor i in range(len(last_list)):\n ans += last_list[i][0]\n\na_count = 0\nb_count = 0\nmin_s = ""\nfor c in s:\n if c == ")":\n b_count-=1\n else:\n b_count+=1\n if b_count < 0:\n b_count = 0\n a_count+= 1\n\nif a_count == 0 and b_count == 0:\n print("Yes")\nelse:\n print("No")', 'n = int(input())\nslist = []\nfor i in range(n):\n slist.append(input())\n\nfirst_list = []\nlast_list = []\nfirst = ""\nlast = ""\nfor i in range(n):\n s = slist[i]\n\n a_count = 0\n b_count = 0\n min_s = ""\n for c in s:\n if c == ")":\n b_count-=1\n else:\n b_count+=1\n if b_count < 0:\n b_count = 0\n a_count+= 1\n min_s = ")"* a_count + "("*b_count\n\n ai = a_count\n bi = b_count\n\n if ai == 0:\n first += min_s\n elif bi == 0:\n last += min_s\n elif bi-ai >= 0:\n first_list.append([min_s,ai])\n else:\n last_list.append([min_s,bi])\n\nfirst_list= sorted(first_list, key=lambda s: s[1])\nlast_list= sorted(last_list, key=lambda s: s[1], reverse=True)\n\nans = first\nfor i in range(len(first_list)):\n ans += first_list[i][0]\nfor i in range(len(last_list)):\n ans += last_list[i][0]\nans += last\n\na_count = 0\nb_count = 0\nmin_s = ""\nfor c in ans:\n if c == ")":\n b_count-=1\n else:\n b_count+=1\n if b_count < 0:\n b_count = 0\n a_count+= 1\n\nif a_count == 0 and b_count == 0:\n print("Yes")\nelse:\n print("No")']
['Wrong Answer', 'Accepted']
['s840914422', 's797302058']
[111580.0, 69868.0]
[2209.0, 1772.0]
[1015, 1147]
p02686
u023229441
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys\nimport math\nimport heapq\nmod=10**9+7\ninf=float("inf")\nfrom math import sqrt\nfrom collections import deque\nfrom collections import Counter\nfrom math import ceil\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom functools import lru_cache\n\n\n\n\n\n\nA=list(map(int,input().split()))\nn=len(A)\nPM=[[0,0] for i in range(n)]\nfor i in range(n):\n now=0\n mini=0\n for j in A[i]:\n if j=="(": now+=1 \n else:\n now-=1 ; mini=min(mini,now)\n PM[i]=[mini,now]\n\nif sum([PM[i][1] for i in range(n)] )!=0 : \n print("No")\n exit()\n\nMINI=0\nNOW=0\nPMf=[PM[i] for i in range(n) if PM[i][1]>=0]\nPMf.sort()\nfor i in range(len(PMf)):\n MINI=min(MINI , NOW+PMf[-i-1][0] )\n NOW+=PMf[-i-1][1]\n if MINI<0 : print("No") ; exit()\n\nPMs=[PM[i] for i in range(n) if PM[i][1]<0]\nPMs=sorted(PMs , key=lambda x : x[1]-x[0])\nfor i in range(len(PMs)):\n MINI=min(MINI , NOW+PMs[-i-1][0] )\n NOW+=PMs[-i-1][1]\n if MINI<0 : print("No") ; exit()\n\nprint("Yes")\n', 'import sys\ninput=lambda: sys.stdin.readline().strip()\n\n\nn=int(input())\nA=[]\n#\nPM=[[0,0] for i in range(n)]\nfor i in range(n):\n now=0\n mini=0\n for j in input():\n if j=="(": now+=1 \n else:\n now-=1 ; mini=min(mini,now)\n PM[i]=[mini,now]\n\nif sum( [PM[i][1] for i in range(n)] )!=0 : \n print("No")\n exit()\n\nMINI=0\nNOW=0\nPMf=[PM[i] for i in range(n) if PM[i][1]>=0]\nPMf.sort()\nfor i in range(len(PMf)):\n MINI=min(MINI , NOW+PMf[-i-1][0] )\n NOW+=PMf[-i-1][1]\n if MINI<0 : print("No") ; exit()\n\nPMs=[PM[i] for i in range(n) if PM[i][1]<0]\nPMs=sorted(PMs , key=lambda x : x[1]-x[0])\nfor i in range(len(PMs)):\n MINI=min(MINI , NOW+PMs[-i-1][0] )\n NOW+=PMs[-i-1][1]\n if MINI<0 : print("No") ; exit()\n\nprint("Yes")\n']
['Runtime Error', 'Accepted']
['s988323864', 's087580580']
[9472.0, 111496.0]
[29.0, 1869.0]
[1227, 765]
p02686
u036104576
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys\nimport itertools\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n \n# n = map(int, readline().split())\nn = int(input())\n\nls = []\nrs = []\n\ntotal = 0\nfor i in range(n):\n s = input().strip()\n\n b = 0\n h = 0\n for c in s:\n if c == \'(\':\n h += 1\n total += 1\n else:\n h -= 1\n b = min(b, h)\n total -= 1\n\n if h >= 0:\n ls.append((b, h))\n else:\n rs.append((b - h, -h))\n\nif total != 0:\n print("NO")\n exit()\n\nls = sorted(ls, reverse=True)\nrs = sorted(rs, reverse=True)\n\nb = 0\ntotal = 0\nOK = True\nfor p in ls:\n b += p[0]\n total += p[1]\n if b < 0:\n OK = False\n\nfor p in rs:\n b += p[0]\n total += p[1]\n if b < 0:\n OK = False\n\nif not OK:\n print("NO")\nelse:\n print("YES")\n\n\n', 'import sys\nimport itertools\nimport numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n \n# n = map(int, readline().split())\nn = int(readline())\n\nls = []\nrs = []\n\ntotal = 0\nS = list(map(lambda x: x.strip().decode(), readlines()))\n\nfor i in range(n):\n s = S[i]\n\n b = 0\n h = 0\n for c in s:\n if c == \'(\':\n h += 1\n else:\n h -= 1\n b = min(b, h)\n\n if h >= 0:\n ls.append((b, h))\n else:\n rs.append((b - h, -h))\n total += h\n\nif total != 0:\n print("No")\n exit()\n\nls = sorted(ls, reverse=True)\nrs = sorted(rs, reverse=True)\n\nh = 0\nOK = True\nfor p in ls:\n b = h + p[0]\n h += p[1]\n if b < 0:\n OK = False\n\nh = 0\nfor p in rs:\n b = h + p[0]\n h += p[1]\n if b < 0 or h < 0:\n OK = False\n\nif not OK:\n print("No")\nelse:\n print("Yes")\n\n\n']
['Wrong Answer', 'Accepted']
['s749992651', 's016225703']
[102108.0, 117952.0]
[1974.0, 1166.0]
[884, 906]
p02686
u044220565
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\nfrom heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\n\ndef run():\n N = int(input())\n current = 0\n ways = []\n dic = {\'(\': 1, \')\': -1}\n for _ in range(N):\n S = input()\n go = 0\n max_depth = 0\n for s in S:\n go += dic[s]\n max_depth = min(max_depth, go)\n if current + max_depth < 0:\n ways.append((go, max_depth))\n else:\n current += go\n\n ways = sorted(ways, key=lambda x:x[0], reverse=True)\n while ways:\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n current += go\n del ways[idx]\n continue\n print(\'No\')\n return None\n if current == 0:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\n#from heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\ndef run():\n N = int(input())\n ret = 0\n for _ in range(N):\n S = sysread()\n for s in S:\n ret += dic[s]\n if ret == 0:\n print(\'Yes\')\n else:\n print(\'No\')\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\nfrom heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\n\ndef run():\n N = int(input())\n current = 0\n ways = []\n dic = {\'(\': 1, \')\': -1}\n for _ in range(N):\n S = input()\n go = 0\n max_depth = 0\n for s in S:\n go += dic[s]\n max_depth = min(max_depth, go)\n if current + max_depth < 0:\n ways.append((go, max_depth))\n else:\n current += go\n\n ways = sorted(ways, key=lambda x:x[0], reverse=True)\n\n while ways:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n done = True\n if go < 0:\n break\n current += go\n del ways[idx]\n break\n if not done:\n break\n\n ways = sorted(ways, key = lambda x:x[1])\n\n while ways and current >= 0:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n current += go\n del ways[idx]\n done = True\n break\n if not done:\n print(\'No\')\n return None\n\n\n if current == 0:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\nfrom operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\nfrom heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\n\ndef run():\n N = int(input())\n current = 0\n ways = []\n dic = {\'(\': 1, \')\': -1}\n for _ in range(N):\n S = input()\n go = 0\n max_depth = 0\n for s in S:\n go += dic[s]\n max_depth = min(max_depth, go)\n if current + max_depth < 0:\n ways.append((go, max_depth))\n else:\n current += go\n\n\n ways = sorted(ways, key=lambda x:x[0], reverse=True)\n\n while ways:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n if go < 0:\n break\n current += go\n del ways[idx]\n done = True\n if not done:\n print(\'No\')\n return None\n\n ways = [(-a, b) for a, b in ways]\n ways = sorted(ways, key = itemgetter(1,0))\n\n while ways and current >= 0:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n current -= go\n del ways[idx]\n done = True\n break\n if not done:\n print(\'No\')\n return None\n\n\n if current == 0:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\n#from operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\nfrom heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\n\ndef run():\n N = int(input())\n current = 0\n ways = []\n dic = {\'(\': 1, \')\': -1}\n for _ in range(N):\n S = input()\n go = 0\n max_depth = 0\n for s in S:\n go += dic[s]\n max_depth = min(max_depth, go)\n if current + max_depth < 0:\n ways.append((go, max_depth))\n else:\n current += go\n\n ways = sorted(ways, key=lambda x:x[0], reverse=True)\n\n cont = True\n while cont and ways:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n if go < 0:\n cont = False\n break\n current += go\n del ways[idx]\n done = True\n break\n if not done:\n print(\'No\')\n return None\n\n ways = sorted(ways, key = lambda x:x[1])\n while ways and current >= 0:\n done = False\n for idx, (go, max_depth) in enumerate(ways):\n if current + max_depth >= 0:\n current += go\n del ways[idx]\n done = True\n break\n if not done:\n print(\'No\')\n return None\n\n\n if current == 0:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n run()', '# coding: utf-8\nimport sys\nfrom operator import itemgetter\nsysread = sys.stdin.readline\nread = sys.stdin.read\nfrom heapq import heappop, heappush\n#from collections import defaultdict\nsys.setrecursionlimit(10**7)\n#import math\n#from itertools import combinations, product\n\n#import numpy as np\n\ndef run():\n N = int(input())\n current = 0\n ways = []\n dic = {\'(\': 1, \')\': -1}\n SS = read().split()\n\n for S in SS:\n path = [0]\n for s in S:\n path.append(path[-1]+ dic[s])\n ways.append((path[-1], min(path)))\n\n ways_pos = sorted([(a,b) for a,b in ways if a >= 0], key = lambda x:(x[1], x[0]), reverse=True)\n ways_neg = sorted([(a,b) for a,b in ways if a < 0], key = lambda x:(x[1] - x[0], -x[0]))\n\n for i in range(len(ways_pos)):\n go, max_depth = ways_pos[i]\n if current + max_depth >= 0:\n current += go\n else:\n print("No")\n return None\n\n for i in range(len(ways_neg)):\n go, max_depth = ways_neg[i]\n if current + max_depth >= 0:\n current += go\n else:\n print("No")\n return None\n\n if current == 0:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n run()']
['Wrong Answer', 'Runtime Error', 'Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s121302134', 's272695452', 's354942074', 's364124764', 's416968816', 's311496118']
[26768.0, 9192.0, 26824.0, 26760.0, 26676.0, 198912.0]
[1256.0, 23.0, 2206.0, 1263.0, 1248.0, 994.0]
[1140, 563, 1615, 1663, 1702, 1316]
p02686
u066413086
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\ndef main():\n N = int(input())\n S = [sys.stdin.readline().strip() for i in range(N)]\n DR = []\n for s in S:\n d = 0 \n rmax = 0 \n # rmax <= d\n for lr in s:\n if lr == '(':\n d += 1\n else:\n d -= 1\n rmax = min(d, rmax)\n\n DR.append((d, rmax))\n\n # print(DR)\n \n \n \n \n\n \n DR.sort(key=lambda x: (-x[1], x[0]))\n # print(DR)\n D = 0\n ans = 'yes'\n for dr in DR:\n d, r = dr\n if D + r < 0:\n ans = 'No'\n break\n D += d\n \n if D != 0:\n ans = 'No'\n print(ans)\n\nif __name__ == '__main__':\n main()", "def check(DR):\n D = 0\n for dr in DR[::-1]:\n dmin, d = dr\n if D + dmin < 0:\n return False\n D += d\n return True\n\ndef main():\n N = int(input())\n S = []\n for i in range(N):\n S.append(input())\n\n DR1 = []\n DR2 = []\n total = 0\n for s in S:\n d = 0 \n d_min = 0 \n # d_min <= d\n for lr in s:\n if lr == '(':\n d += 1\n else:\n d -= 1\n d_min = min(d, d_min)\n total += d\n if d > 0:\n DR1.append((d_min, d))\n else:\n DR2.append((d_min - d, -d))\n\n \n DR1.sort()\n DR2.sort()\n if check(DR1) and check(DR2) and sum([d[1] for d in DR1]) == sum([d[1] for d in DR2]):\n print('Yes')\n else:\n print('No')\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Accepted']
['s697620992', 's793177420']
[163972.0, 95644.0]
[853.0, 1546.0]
[914, 968]
p02686
u084865106
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import itertools\n\nn = int(input())\n\ns = []\nfor i in range(n):\n s.append(input())\n\ncomb_s = list(itertools.combinations(s, len(s)))\n\ndef checker(x):\n jud = 1\n ans = ''.join(x)\n\n if not s:\n return jud\n\n print(ans)\n r = x.count('(')\n l = x.count(')')\n if r != l:\n jud =0\n return jud\n\n if x[0] != '(' or x[-1] != ')':\n jud =0\n\n return jud\n\ndef main():\n for i in range(len(comb_s)):\n print(comb_s[i])\n juds = checker(comb_s[i])\n if juds == 1:\n print('Yes')\n return\n\n print('No')\n return\nmain()\n", "from sys import stdin\n\ndef checker(x):\n l = x.count('(', 1, -1)\n r = len(x[1:-1]) - l\n if l != r: return 0\n\n sum = 0\n for c in x:\n print(c)\n if c == '(':\n sum = sum + 1\n else:\n sum = sum - 1\n if sum < 0:\n return 0\n if sum != 0 : return 0\n return 1\n\ndef main():\n readline = stdin.readline\n n = int(readline())\n s = tuple(readline().strip() for _ in range(n))\n\n sorted_s = sorted(s)\n jud = checker(''.join(sorted_s))\n\n if jud == 1:\n print('Yes')\n else:\n print('No')\n return\n\nif __name__ == '__main__':\n main()\n", "import itertools\n\nn = int(input())\n\ns = []\nfor i in range(n):\n s.append(input())\n\ncomb_s = list(itertools.combinations(s, len(s)))\n\ndef checker(x):\n jud = 1\n ans = ''.join(x)\n\n if not s:\n return jud\n\n print(ans)\n r = x.count('(')\n l = x.count(')')\n if r != l:\n jud =0\n return jud\n\n if x[0] != '(' or x[-1] != ')':\n jud =0\n\n return jud\n\ndef main():\n for i in range(len(comb_s)):\n print(comb_s[i])\n juds = checker(''.join(for j in comb_s[i]))\n if juds == 1:\n print('Yes')\n return\n\n print('No')\n return\nmain()\n", "import itertools\n\nn = int(input())\n\ns = []\nfor i in range(n):\n s.append(input())\n\ncomb_s = list(itertools.combinations(s, len(s)))\n\ndef checker(x):\n jud = 1\n ans = ''.join(x)\n\n if not s:\n return jud\n\n print(ans)\n r = x.count('(')\n l = x.count(')')\n if r != l:\n jud =0\n return jud\n\n if x[0] != '(' or x[-1] != ')':\n jud =0\n\n return jud\n\ndef main():\n for i in range(len(comb_s)):\n print(comb_s[i])\n juds = checker(''.join( [j for j in comb_s[i]]))\n if juds == 1:\n print('Yes')\n return\n\n print('No')\n return\nmain()\n", "import sys\nfrom itertools import permutations\nreadline = sys.stdin.readline\n\nn = int(readline())\ns = [readline().strip() for i in range(n)]\n\ncomb_s = list(permutations(s, n))\n\ndef checker(x):\n if not x: return 0\n\n if x[0] != '(' or x[-1] != ')': return 0\n\n r = x.count('(')\n l = x.count(')')\n if r != l: return 0\n\n return 1\n\ndef main():\n for i in range(len(comb_s)):\n print(''.join( [j for j in comb_s[i]]))\n jud = checker(''.join( [j for j in comb_s[i]]))\n if jud == 1:\n print('Yes')\n return\n\n print('No')\n return\n\nmain()\n", "import sys\nfrom itertools import permutations\nreadline = sys.stdin.readline\n\nn = int(readline())\ns = [readline().strip() for i in range(n)]\n\ncomb_s = list(permutations(s, n))\n\ndef checker(x):\n print(x)\n if not x: return 0\n\n if x[0] != '(' or x[-1] != ')': return 0\n\n r = x.count('(')\n l = x.count(')')\n if r != l: return 0\n\n return 1\n\ndef main():\n for i in range(len(comb_s)):\n jud = checker(''.join(comb_s[i]))\n if jud == 1:\n print('Yes')\n return\n\n print('No')\n return\n\nmain()\n", "from sys import stdin\n\ndef checker(x):\n l = x.count('(', 1, -1)\n r = len(x[1:-1]) - l\n if l != r: return 0\n\n sum = 0\n for c in x:\n print(c)\n if c == '(':\n sum = sum + 1\n else:\n sum = sum - 1\n if sum < 0:\n return 0\n return 1\n\ndef main():\n readline = stdin.readline\n n = int(readline())\n s = tuple(readline().strip() for _ in range(n))\n\n sorted_s = sorted(s)\n jud = checker(''.join(sorted_s))\n\n if jud == 1:\n print('Yes')\n else:\n print('No')\n return\n\nif __name__ == '__main__':\n main()\n", "from sys import stdin\n\ndef main():\n plus, minus = [], []\n readline = stdin.readline\n n = int(readline())\n for _ in range(n):\n s = readline().rstrip()\n if 2 * s.count('(') - len(s) > 0:\n plus.append(s)\n else:\n minus.append(s)\n plus.sort(key = lambda x: x.count(')'))\n minus.sort(key = lambda x: x.count('('), reverse = True)\n\n sum = 0\n for v in ''.join(plus + minus):\n sum = sum + (1 if v == '(' else -1)\n if sum < 0 : return print('No')\n if sum != 0:\n return print('No')\n\n return print('Yes')\n\nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s367317950', 's499450403', 's509571290', 's787491903', 's863580324', 's889694591', 's980069330', 's816873666']
[53920.0, 45376.0, 9076.0, 56668.0, 2002160.0, 2084524.0, 45356.0, 44464.0]
[1175.0, 495.0, 24.0, 1193.0, 2261.0, 2255.0, 497.0, 571.0]
[599, 631, 617, 622, 593, 544, 604, 626]
p02686
u144540235
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['# **************************************************************************** #\n# #\n# __ __ .____ .__ __. ____ #\n\n# | | | || |_| || \\ / || ,--\' #\n\n# | `-\' || | | | | || `--. #\n# Created: 2020/05/10 18:38 by Anas \\_____/ |_| |_| |_| \\____| #\n# Updated: 2020/05/10 18:38 by Anas #\n# #\n# **************************************************************************** #\n\ndef process(tab, beginning, end):\n total = beginning\n for i in tab:\n if (i[1] > total or total + i[0] < 0):\n return ("No")\n total += i[0]\n if (total == end):\n return ("Yes")\n return ("No")\n\ndef parsing():\n beginning, ending = 0\n clean = 0\n total = 0\n tab = []\n\n N = int(input())\n for i in range(N):\n s = input()\n before, after = 0, 0\n for j in s:\n if (j == \'(\'):\n after += 1\n elif (j == \')\'):\n if (after > 0):\n after -= 1\n else:\n before += 1\n if (before == 0 and after > 0):\n beginning += after\n elif (after == 0 and before > 0):\n ending += before\n elif (before > 0 or after > 0):\n tab.append((after - before, before, after))\n else:\n clean += 1\n total += before - after\n tab = sorted(tab)[::-1]\n return tab, total, beginning, ending\n\n\ntab, total, beginning, ending = parsing()\nif (total == 0 and N == 1):\n res = "Yes"\nelif ((total != 0) or ((min(beginning, ending) == 0 and clean == 0) \n or (max(beginning, ending) == 0 and clean == 1))):\n res = "No"\nelse:\n res = process(tab, beginning, ending)\nprint(res)\n', '\n\n\n\n\n\n\n\n\ndef process(tab, first, end):\n print(tab)\n print(first, end)\n total = first\n for i in tab:\n total += i[0]\n if (total < 0):\n return ("No")\n if (total == end):\n return ("Yes")\n return ("No")\n\n\n\n\nN = int(input())\n\nfirst = -1\nlast = -1\nclean = 0\ntab = []\ntotal = 0\nfor i in range(N):\n s = input()\n avant = 0\n apres = 0\n for j in s:\n if (j == \'(\'):\n apres += 1\n elif (j == \')\'):\n if (apres > 0):\n apres -= 1\n else:\n avant += 1\n if (avant == 0 and apres > 0 and first == -1):\n first = apres\n elif (apres == 0 and avant > 0 and last == -1):\n last = avant\n elif (avant > 0 or apres > 0):\n tab.append((apres - avant, avant, apres, s))\n else:\n clean += 1\n total += avant - apres\nif (first == -1 and clean > 0):\n first = 0\n clean -= 1\nif (last == -1 and clean > 0):\n last = 0\n\n\ntab = sorted(tab)\ntab = tab[::-1]\nif (total == 0 and first > -1 and last > -1):\n res = process(tab, first, last)\nelse:\n if (total == 0 and N == 1):\n res = "Yes"\n else:\n res = "No"\nprint(res)\n', '\n\n\n\n\n\n\n\n\ndef process(tab, first, end):\n total = first\n #print(tab)\n for i in tab:\n total += i[0]\n if (total < 0):\n return ("No")\n return ("Yes")\n\n\n\n\nN = int(input())\n\nfirst = -1\nlast = -1\ntab = []\nfor i in range(N):\n s = input()\n total = 0\n avant = 0\n apres = 0\n for j in s:\n if (j == \'(\'):\n apres += 1\n elif (j == \')\'):\n if (apres > 0):\n apres -= 1\n else:\n avant += 1\n if (avant == 0 and first == -1):\n first = apres\n elif (apres == 0 and last == -1):\n last = avant\n elif (avant > 0 or apres > 0):\n tab.append((apres - avant, avant, apres, s))\n total += avant - apres\n#print(tab)\n#print(total)\ntab = sorted(tab)[::-1]\nif (total == 0 and first > -1 and last > -1):\n res = process(sorted(tab), first, last)\nelse:\n if (total == 0 and N == 1):\n res = "Yes"\n else:\n res = "No"\nprint(res)\n', '# **************************************************************************** #\n# #\n# __ __ .____ .__ __. ____ #\n\n# | | | || |_| || \\ / || ,--\' #\n\n# | `-\' || | | | | || `--. #\n# Created: 2020/05/10 18:38 by Anas \\_____/ |_| |_| |_| \\____| #\n# Updated: 2020/05/10 18:42 by Anas #\n# #\n# **************************************************************************** #\n\ndef process(tab, beginning, end):\n total = beginning\n for i in tab:\n if (i[1] > total or total + i[0] < 0):\n return ("No")\n total += i[0]\n if (total == end):\n return ("Yes")\n return ("No")\n\ndef parsing(N):\n beginning, ending = 0,0\n clean = 0\n total = 0\n tab = []\n\n for i in range(N):\n s = input()\n before, after = 0, 0\n for j in s:\n if (j == \'(\'):\n after += 1\n elif (j == \')\'):\n if (after > 0):\n after -= 1\n else:\n before += 1\n if (before == 0 and after > 0):\n beginning += after\n elif (after == 0 and before > 0):\n ending += before\n elif (before > 0 or after > 0):\n tab.append((after - before, before, after))\n else:\n clean += 1\n total += before - after\n tab = sorted(tab)[::-1]\n return tab, total, beginning, ending, clean\n\n\nN = int(input())\ntab, total, beginning, ending, clean = parsing(N)\nif (total == 0 and N == 1):\n res = "Yes"\nelif ((total != 0) or ((min(beginning, ending) == 0 and clean == 0) \n or (max(beginning, ending) == 0 and clean == 1))):\n res = "No"\nelse:\n res = process(tab, beginning, ending)\nprint(res)\n']
['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s096781283', 's832027831', 's925694123', 's781937073']
[9228.0, 150572.0, 112748.0, 26600.0]
[24.0, 2226.0, 1896.0, 1175.0]
[2206, 1186, 974, 2220]
p02686
u169350228
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['n = int(input())\nsco = [] \nssum = 0\n\nfor i in range(n):\n s = input()\n sa = 0\n ms = 0\n for i in range(len(s)):\n if s[i] == "(":\n sa += 1\n else:\n sa -= 1\n if ms > sa:\n ms = sa\n sco.append([ms,sa])\n ssum += sa\n\nif not ssum == 0:\n print("No")\n exit()\n\nsco.sort(reverse = True)\nfor i in range(n):\n now = 0\n if sco[i][0] + now < 0:\n print("No")\n exit()\n else:\n now += sco[i][1]\n\nprint("Yes")\n', 'n = int(input())\nscop = [] \nscom = []\nssum = 0\n\nfor i in range(n):\n s = input()\n sa = 0\n ms = 0\n for i in range(len(s)):\n if s[i] == "(":\n sa += 1\n else:\n sa -= 1\n if ms > sa:\n ms = sa\n if sa > 0:\n scop.append([ms,sa])\n elif not sa == ms:\n scom.append([ms,sa])\n ssum += sa\n\nif not ssum == 0:\n print("No")\n exit()\n\nscop.sort(reverse = True)\nscom.sort()\n\nnow = 0\nfor i in scop:\n if now + i[0] < 0:\n print("No")\n exit()\n now += i[1]\nfor i in scom:\n if now + i[0] < 0:\n print("No")\n exit()\n now += i[1]\n\nprint("Yes")\n']
['Wrong Answer', 'Accepted']
['s315436424', 's578834278']
[98156.0, 52472.0]
[2208.0, 1891.0]
[511, 665]
p02686
u221264296
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['def pdebut(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\t\tif o<0 : return False\n\treturn o>=0\n\t\ndef pfin(s):\n\tc = 0\n\tfor o in s[::-1]:\n\t\tif o==\')\':\n\t\t\tc+=1\n\t\telse:c-=1\n\t\tif c<0: return False\n\treturn c>=0\n\t\ndef valuer(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\treturn o\n\t\nn = int(input())\nval = [0]*(n+1)\ntab = []\ndebut = []\nfin = []\nmilieu = []\nfor i in range(n):\n\ts = input()\n\ttab.append(s)\n\tif pdebut(s):\n\t\tdebut+=[i]\n\telif pfin(s):\n\t\tfin+=[i]\n\telse:\n\t\tval[i] = valuer(s)\n\t\tmilieu+=[i]\n\n\n\t# ~ return -x[1]\t\t\n\n# ~ couples.sort(key = cle)\n\nS = "".join(tab[i] for i in debut)\nS+="".join(tab[c[0]] for c in couples)\nS+= "".join(tab[i] for i in fin)\n\n# ~ print("debut",debut)\n\n# ~ print("fin",fin)\n\n# ~ print(S)\n\ndef Bon(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\t\tif o<0 : return False\n\treturn o==0\nprint("Yes" if Bon(S) else "No")\n', 'def pdebut(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\t\tif o<0 : return False\n\treturn o>=0\n\t\ndef pfin(s):\n\tc = 0\n\tfor o in s[::-1]:\n\t\tif o==\')\':\n\t\t\tc+=1\n\t\telse:c-=1\n\t\tif c<0: return False\n\treturn c>=0\n\t\ndef valuer(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\treturn o\n\t\nn = int(input())\nval = [0]*(n+1)\ntab = []\ndebut = []\nfin = []\nmilieu = []\nfor i in range(n):\n\ts = input()\n\ttab.append(s)\n\tif pdebut(s):\n\t\tdebut+=[i]\n\telif pfin(s):\n\t\tfin+=[i]\n\telse:\n\t\tval[i] = valuer(s)\n\t\tmilieu+=[i]\n\ndef cle(x):\n\treturn -x[1]\t\t\ncouples = [[i,val[i]] for i in milieu]\ncouples.sort(key = cle)\n\nS = "".join(tab[i] for i in debut)\nS+="".join(tab[c[0]] for c in couples)\nS+= "".join(tab[i] for i in fin)\n\n# ~ print("debut",debut)\n\n# ~ print("fin",fin)\n\n# ~ print(S)\n\ndef Bon(s):\n\to = 0\n\tfor c in s:\n\t\tif c==\'(\':o+=1\n\t\telse: o-=1\n\t\tif o<0 : return False\n\treturn o==0\nprint("Yes" if Bon(S) else "No")\n']
['Runtime Error', 'Accepted']
['s593397280', 's598895255']
[68556.0, 76340.0]
[1622.0, 1693.0]
[945, 929]
p02686
u223646582
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["N = int(input())\nS_list = [input() for _ in range(N)]\n\nmin_revr, min_revl = 10**20, 10**20\nleft, rev_l, rev_r, right = 0, 0, 0, 0\nfor S in S_list:\n stack = []\n l, r = 0, 0\n for s in S:\n if s == '(':\n if stack and stack[-1] == ')':\n stack.append('(')\n l = 1\n else:\n stack.append('(')\n l += 1\n else: # s==')'\n if stack and stack[-1] == '(':\n stack.pop()\n l -= 1\n else:\n stack.append(')')\n r += 1\n if l == 0:\n right += r\n elif r == 0:\n left += l\n else:\n rev_r += r\n rev_l += l\n min_revr = min(min_revr, rev_r)\n min_revl = min(min_revl, rev_l)\n # print('{} l:{} r:{} left:{} rev_l:{} rev_r:{} right:{}'.format(\n \n\nif left+rev_l == rev_r+right and left >= min_revr and min_revl <= right:\n print('Yes')\nelse:\n print('No')\n", "N = int(input())\nS_list = [input() for _ in range(N)]\n\nmin_revr, min_revl = 10**20, 10**20\nleft, rev_l, rev_r, right = 0, 0, 0, 0\nfor S in S_list:\n stack = []\n l, r = 0, 0\n for s in S:\n if s == '(':\n if stack:\n if stack[-1] == ')':\n stack.append('(')\n l = 1\n else:\n stack.append('(')\n l += 1\n else:\n stack.append('(')\n l = 1\n else: # s==')'\n if stack:\n if stack[-1] == '(':\n stack.pop()\n l -= 1\n else:\n stack.append(')')\n r += 1\n else:\n stack.append(')')\n r = 1\n if l == 0:\n right += r\n elif r == 0:\n left += l\n else:\n rev_r += r\n rev_l += l\n min_revr = min(min_revr, r)\n min_revl = min(min_revl, l)\n\nif min_revr == 10**20:\n min_revr = 0\nif min_revl == 10**20:\n min_revl = 0\n\nif left+rev_l == rev_r+right and left >= min_revr and right >= min_revl:\n print('Yes')\nelse:\n print('No')\n"]
['Wrong Answer', 'Accepted']
['s413819045', 's919949860']
[40048.0, 39948.0]
[1342.0, 1306.0]
[1010, 1186]
p02686
u307622233
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["def count_scan(s):\n max_min = 0\n compare = 0\n for c in s:\n if c == '(':\n compare += 1\n elif c == ')':\n compare -= 1\n max_min = min(max_min, compare)\n return min(max_min, compare), compare\n\n\ndef key(lst):\n m, c = lst\n if c > 0:\n return 1, m\n else:\n return -1, c - m\n\n\ndef main():\n n = int(input())\n lst = [input() for _ in range(n)]\n\n txt = 'No'\n ans = 0\n for max_min, c in sorted([count_scan(s) for s in lst],\n reverse=True,\n key=key):\n if max_min + ans < 0:\n break\n ans += c\n else:\n if ans == 0:\n txt = 'Yes'\n\n print(txt)", 'n = int(input())\nlst = [input() for _ in range(n)]\n\nlst.sort()\nd = {\'(\': 0, \')\': 0}\ntxt = \'No\'\n\nfor i in lst:\n # print(f"{i = }")\n for j in i:\n # print(f"{j = }")\n d[j] += 1\n if(d[\'(\'] < d[\')\']):\n break\n\n\nif(d[\'(\'] == d[\')\']):\n txt = \'Yes\'\n', '\nn = int(input())\nlst = [input() for _ in range(n)]\n\nlst.sort()\nd = {\'(\': 0, \')\': 0}\ntxt = \'No\'\n\nfor i in lst:\n # print(f"{i = }")\n for j in i:\n # print(f"{j = }")\n d[j] += 1\n if(d[\'(\'] < d[\')\']):\n break\n\nprint(txt)\n', "\nup_list = []\ndown_list = []\n\nfor _ in range(n):\n txt = input()\n min_comp = 10 ** 6\n compare = 0\n cnt = 0\n for s in txt:\n cnt += 1\n if s == '(':\n compare += 1\n else:\n compare -= 1\n min_comp = min(min_comp, compare)\n if compare > 0:\n up_list.append([compare, min(min_comp, 0)])\n else:\n down_list.append([compare, min(min_comp, 0) - compare])\n\n\nup_list.sort(key=lambda x: x[1], reverse=True)\ndown_list.sort(key=lambda x: x[1], reverse=False)\ntxt = 'No'\nc = 0\n\nfor t in up_list + down_list:\n if t[1] + c < 0:\n break\n else:\n c += t[0]\nelse:\n if c == 0:\n txt = 'Yes'\n\nprint(txt)", 'n = int(input())\nlst = [input() for _ in range(n)]\n\nlst.sort()\nd = {\'(\': 0, \')\': 0}\ntxt = \'Yes\'\n\nfor i in lst:\n # print(f"{i = }")\n for j in i:\n # print(f"{j = }")\n d[j] += 1\n if(d[\'(\'] < d[\')\']):\n break\n\n\nif(d[\'(\'] == d[\')\']):\n txt = \'No\'\n\nprint(txt)\n', "import sys\ninput = sys.stdin.readline\n\n# up_list = []\n# down_list = []\n\n\ndef count_scan(s):\n max_min = 0\n compare = 0\n for c in s:\n if c == '(':\n compare += 1\n elif c == ')':\n compare -= 1\n max_min = min(max_min, compare)\n return min(max_min, compare), compare\n\n\ndef key(lst):\n m, c = lst\n if c > 0:\n return 1, m\n else:\n return -1, c - m\n\n\ndef main():\n n = int(input())\n lst = [input() for _ in range(n)]\n\n # up_list.sort(key=lambda x: x[1], reverse=True)\n # down_list.sort(key=lambda x: x[1], reverse=False)\n txt = 'No'\n ans = 0\n # print(lst)\n \n # reverse=True,\n # key=key))\n for max_min, c in sorted([count_scan(s) for s in lst],\n reverse=True,\n key=key):\n \n if max_min + ans < 0:\n break\n ans += c\n else:\n if ans == 0:\n txt = 'Yes'\n\n print(txt)\n\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s307220865', 's529928349', 's533160923', 's874898413', 's891047205', 's135004977']
[9156.0, 41800.0, 41940.0, 8896.0, 41920.0, 234948.0]
[24.0, 1227.0, 1221.0, 23.0, 1220.0, 1042.0]
[724, 281, 254, 692, 293, 1127]
p02686
u347640436
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['from functools import reduce\nfrom itertools import permutations\n\ndef f(s):\n while True:\n t = s.replace(\'()\', \'\')\n if t == s:\n return s\n s = t\n\nN = int(input())\nS = [input() for _ in range(N)]\n\nl = 0\nr = 0\nfor s in S:\n t = s.count(\'(\')\n l += t\n r += len(s) - t\nif l != r:\n print(\'No\')\n exit()\n\nS = [s for s in map(f, S) if s != ""]\n\nif len(S) == 0:\n print(\'Yes\')\n exit()\n\nlS = [s for s in S if s[0] == "("]\nrS = [s for s in S if s[0] == ")"]\n\nld = {}\nfor s in lS:\n ld.setdefault(s, 0)\n ld[s] += 1\n\nrd = {}\nfor s in rS:\n rd.setdefault(s, 0)\n rd[s] += 1\n\nfor k1 in ld:\n for k2 in rd.keys():\n if f(k1 + k2) != \'\':\n continue\n t = max(ld[k1], rd[k2])\n ld[k1] -= t\n rd[k2] -= t\n\nif len(ld) == 0 and len(rd) == 0:\n print(\'Yes\')\n exit()\n\nSS = []\nfor k in ld:\n for i in range(ld[k]):\n SS.append(k)\nfor k in rd:\n for i in range(rd[k]):\n SS.append(k)\n\nfor ss in permutations(SS, len(SS)):\n t = reduce(lambda x, y: x + y, ss)\n if f(t) == \'\':\n print(\'Yes\')\n exit()\nprint(\'No\')\n', "def scan(s):\n m = 0\n a = 0\n for c in s:\n if c == '(':\n a += 1\n elif c == ')':\n a -= 1\n m = min(m, a)\n return m, a\n\n\ndef key(v):\n m, a = v\n if a >= 0:\n return 1, m, a\n else:\n return -1, a - m, a\n\nN = int(input())\nS = [input() for _ in range(N)]\n\nc = 0\nfor m, a in sorted([scan(s) for s in S], reverse=True, key=key):\n if c + m < 0:\n c += m\n break\n c += a\n\nif c == 0:\n print('Yes')\nelse:\n print('No')\n"]
['Runtime Error', 'Accepted']
['s602722918', 's097308351']
[49964.0, 171416.0]
[2207.0, 1819.0]
[1119, 503]
p02686
u392319141
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\ninput = sys.stdin.readline\n\nN = int(input())\nS = [input().rstrip() for _ in range(N)]\n\ndef calc(S):\n now = 0\n ret = 0\n for s in S:\n if s == '(':\n now += 1\n else:\n now -= 1\n ret = min(ret, now)\n return ret\n\nH = []\nP = []\nL = []\n\nfor s in S:\n less = -calc(s)\n if less == 0:\n H.append(s)\n else:\n l = s.count('(')\n r = len(s) - l\n if l >= r:\n P.append((less, s))\n else:\n L.append((less, s))\n\nP.sort(key=lambda a: a[0])\nL.sort(key=lambda a: a[0], reverse=True)\nP = [s for _, s in P]\nL = [s for _, s in L]\n\nans = ''.join(H + P + L)\nl = ans.count('(')\nr = ans.count(')')\n\nif l == r and calc(ans) == 0:\n assert 0\n print('Yes')\nelse:\n print('No')\n", "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nS = [input().rstrip() for _ in range(N)]\n\ndef canFirst(S):\n now = 0\n ret = 0\n for s in S:\n if s == '(':\n now += 1\n else:\n now -= 1\n if now < 0:\n ret = min(ret, now)\n return ret\n\nH = []\nP = []\nL = []\n\nfor s in S:\n c = canFirst(s)\n if c > 0:\n H.append(s)\n else:\n L.append((-c, s))\n\nL.sort(reverse=True)\nL = [s for _, s in L]\n\nans = ''.join(H + P + L)\nl = ans.count('(')\nr = len(ans) - l\n\nprint('Yes' if canFirst(ans) >= 0 and (l == r) else 'No')\n", "def kakko(S):\n cum = 0\n mi = 0\n for s in S:\n cum += 1 if s == '(' else -1\n mi = min(mi, cum)\n return (-mi, cum - mi)\n\nN = int(input())\nS = [kakko(input()) for _ in range(N)]\n\nplus = []\nminus = []\n\nfor l, r in S:\n if l <= r:\n plus.append((l, r))\n else:\n minus.append((l, r))\n\nplus.sort(key=lambda a: a[0])\nminus.sort(key=lambda a: a[1], reverse=True)\nM = 0\nfor l, r in (plus + minus):\n M -= l\n if M < 0:\n print('No')\n exit()\n M += r\n\nprint('Yes' if M == 0 else 'No')\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s369128179', 's706461560', 's198142326']
[66616.0, 97348.0, 163304.0]
[997.0, 992.0, 1997.0]
[779, 589, 535]
p02686
u434846982
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['from functools import reduce\nn, *s = open(0).read().split()\nu = []\nfor t in s:\n close_cnt = 0\n tmp = 0\n for c in t:\n tmp += (1 if c == \'(\' else -1)\n close_cnt = min(close_cnt, tmp)\n u.append((close_cnt, tmp - close_cnt))\nM = 10**6 + 1\nacc = 0\nfor a, b in sorted(u, key=lambda z: M * (z[0] + z[1]) - z[0]):\n if acc + a < 0:\n print("No")\n exit(0)\n else:\n acc += a + b\nprint(("No" if acc else "Yes"))', 'from functools import reduce\nn, *s = open(0).read().split()\nu = []\nfor t in s:\n close_cnt = 0\n tmp = 0\n for c in t:\n tmp += (1 if c == \'(\' else -1)\n close_cnt = min(close_cnt, tmp)\n u.append((close_cnt, tmp - close_cnt))\nM = 10**6 + 1\nacc = 0\nfor a, b in sorted(u, key=lambda z: (- M - z[0] if sum(z)>= 0 else M - z[1])):\n if acc + a < 0:\n print("No")\n exit(0)\n else:\n acc += a + b\nprint(("No" if acc else "Yes"))']
['Wrong Answer', 'Accepted']
['s918449380', 's098804497']
[139936.0, 139828.0]
[873.0, 1042.0]
[450, 466]
p02686
u447899880
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['n=int(input())\ns1=0\ns2=0\ns3=list()\ns4=list()\ns5=list()\nfor i in range(n):\n a=str(input())\n a=a.replace(r\'()\',\'\')\n if len(a)==0:\n continue\n if a[0]=="(" and a[-1]=="(":\n s1+=len(a)\n elif a[0]==")" and a[-1]==")":\n s2+=len(a)\n else:\n x=len(a.replace("(",""))\n y=len(a)-x\n if x<=y:\n s3.append([x,y])\n elif x==y:\n s4.append(x)\n else:\n s5.append([x,y])\n \ns3.sort(key=lambda x:x[0])\ns5.sort(key=lambda x:x[1])\n\nflag=0\nlimit=s1\nfor i in range(len(s3)):\n if limit>=s3[i][0]:\n limit=limit-s3[i][0]+s3[i][1]\n else:\n flag=1\n print("No")\n break\n\nif limit<max(s4):\n print("No")\n flag=1\n \nif flag==0:\n for i in range(len(s5)):\n if limit>=s5[i][1]:\n limit=limit-s3[i][1]+s3[i][0]\n else:\n flag=1\n print("No")\n break\n\nif flag==0:\n print("Yes")', 'n=int(input())\ns1=0\ns2=0\ns3=list()\ns4=list()\ns5=list()\nfor i in range(n):\n a=str(input())\n while a!=b:\n b=a\n a=a.replace(r\'()\',\'\')\n if len(a)==0:\n continue\n if a[0]=="(" and a[-1]=="(":\n s1+=len(a)\n elif a[0]==")" and a[-1]==")":\n s2+=len(a)\n else:\n x=len(a.replace("(",""))\n y=len(a)-x\n if x<y:\n s3.append([x,y])\n elif x==y:\n s4.append(x)\n else:\n s5.append([x,y])\n \ns3.sort(key=lambda x:x[0])\ns5.sort(key=lambda x:x[1])\n\nflag=0\nlimit=s1\n\nif len(s3)!=0:\n for i in range(len(s3)):\n if limit>=s3[i][0]:\n limit=limit-s3[i][0]+s3[i][1]\n else:\n flag=1\n print("No")\n break\n\nx=limit\n\nif len(s4)!=0:\n if limit<max(s4):\n print("No")\n flag=1\n\nlimit=s2\nif len(s5)!=0: \n if flag==0:\n for i in range(len(s5)):\n if limit>=s5[i][1]:\n limit=limit-s5[i][1]+s5[i][0]\n else:\n flag=1\n print("No")\n break\n\nif flag==0 and len(s4)!=0:\n if limit<max(s4):\n print("No")\n flag=1\n\nif flag==0 and x==limit:\n print("Yes")\nelif flag==0:\n print("No")\n \n \n \n', 'n=int(input())\ns1=0\ns2=0\ns3=list()\ns4=list()\ns5=list()\nfor i in range(n):\n a=str(input())\n b=str()\n while a!=b:\n b=a\n a=a.replace(r\'()\',\'\')\n if len(a)==0:\n continue\n if a[0]=="(" and a[-1]=="(":\n s1+=len(a)\n elif a[0]==")" and a[-1]==")":\n s2+=len(a)\n else:\n x=len(a.replace("(",""))\n y=len(a)-x\n if x<y:\n s3.append([x,y])\n elif x==y:\n s4.append(x)\n else:\n s5.append([x,y])\n \ns3.sort(key=lambda x:x[0])\ns5.sort(key=lambda x:x[1])\n\nflag=0\nlimit=s1\n\nif len(s3)!=0:\n for i in range(len(s3)):\n if limit>=s3[i][0]:\n limit=limit-s3[i][0]+s3[i][1]\n else:\n flag=1\n print("No")\n break\n\nx=limit\n\nif len(s4)!=0:\n if limit<max(s4):\n print("No")\n flag=1\n\nlimit=s2\nif len(s5)!=0: \n if flag==0:\n for i in range(len(s5)):\n if limit>=s5[i][1]:\n limit=limit-s5[i][1]+s5[i][0]\n else:\n flag=1\n print("No")\n break\n\nif flag==0 and len(s4)!=0:\n if limit<max(s4):\n print("No")\n flag=1\n\nif flag==0 and x==limit:\n print("Yes")\nelif flag==0:\n print("No")\n \n \n \n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s732474865', 's963808895', 's967177447']
[29900.0, 9308.0, 13216.0]
[1576.0, 26.0, 1787.0]
[951, 1273, 1285]
p02686
u479719434
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['def main():\n N = int(input())\n up_lines = []\n down_lines = []\n for i in range(N):\n s = input()\n height = 0\n bottom = 0\n for c in s:\n if c == "(":\n height += 1\n else:\n height -= 1\n bottom = min(bottom, height)\n if height > 0:\n up_lines.append((bottom, height))\n else:\n down_lines.append((bottom-height, -height))\n up_lines.sort(reverse=True, key=lambda line: line.bottom)\n down_lines.sort(reverse=True, key=lambda line: line.bottom)\n left = 0\n for bottom, height in up_lines:\n if left + bottom < 0:\n print("No")\n return\n left += height\n right = 0\n for bottom, height in down_lines:\n if right + bottom < 0:\n print("No")\n return\n right += height\n if left == right:\n print("Yes")\n else:\n print("No")\n\n\nif __name__ == "__main__":\n main()\n', 'def main():\n N = int(input())\n up_lines = []\n down_lines = []\n for i in range(N):\n s = input()\n height = 0\n bottom = 0\n for c in s:\n if c == "(":\n height += 1\n else:\n height -= 1\n bottom = min(bottom, height)\n if height > 0:\n up_lines.append((bottom, height))\n else:\n down_lines.append((bottom-height, -height))\n up_lines.sort(reverse=True, key=lambda line: line[0])\n down_lines.sort(reverse=True, key=lambda line: line[0])\n left = 0\n for bottom, height in up_lines:\n if left + bottom < 0:\n print("No")\n return\n left += height\n right = 0\n for bottom, height in down_lines:\n if right + bottom < 0:\n print("No")\n return\n right += height\n if left == right:\n print("Yes")\n else:\n print("No")\n\n\nif __name__ == "__main__":\n main()\n']
['Runtime Error', 'Accepted']
['s101451026', 's642611525']
[80372.0, 84196.0]
[1367.0, 1555.0]
[989, 981]
p02686
u497952650
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys\ndef input():\n return sys.stdin.readline().strip()\n\nN = int(input())\nS = [input() for _ in range(N)]\n\ntmp = []\nfor i,s in enumerate(S):\n tmp.append([s.count("(")-s.count(")"),i])\n\ntmp.sort(reverse=True)\n\na = 0\nb = 0\ns = ""\nfor _,i in tmp:\n s += S[i]\nprint(s)\nfor i in s:\n if i == "(":\n a += 1\n else:\n b += 1\n if b > a:\n print("No")\n exit()\n\nif a-b == 0:\n print("Yes")\nelse:\n print("No")', 'import sys\nfrom collections import deque\ndef input():\n return sys.stdin.readline().strip()\n\ndef check():\n s = input()\n m = 0\n res = deque([])\n for i in s:\n if i == "(":\n m += 1 \n else:\n m -= 1\n res.append(m)\n ##print(res)\n try:\n a = min(res)\n except:\n a = m\n return [a,m]\n\nN = int(input())\nS = [check() for _ in range(N)]\nprint(S)\nS.sort(reverse=True)\n\na = 0\nb = 0\n\nfor res,m in S:\n a += res\n b += m\n if a < 0:\n print("No")\n exit()\n\nif b == 0:\n print("Yes")\nelse:\n print("No")\n ', 'from collections import deque\n\nN = int(input())\nS = deque([input() for _ in range(N)])\n\ntmp = []\nfor i,s in enumerate(S):\n tmp.append([s.count("(")-s.count(")"),i])\n\ntmp.sort(reverse=True)\n\na = 0\nb = 0\ns = ""\nfor _,i in tmp:\n s += S[i]\nprint(s)\nfor i in range(len(s)):\n if s[i] == "(":\n a += 1\n else:\n b += 1\n if b > a:\n print("No")\n exit()\n\nif a-b == 0:\n print("Yes")\nelse:\n print("No")\n ', 'import sys\ndef input():\n return sys.stdin.readline().strip()\n\nN = int(input())\nS = [input() for _ in range(N)]\n\ntmp = []\nfor i,s in enumerate(S):\n tmp.append([s.count("(")-s.count(")"),i])\n\ntmp.sort(reverse=True)\n\na = 0\nb = 0\ns = ""\nfor _,i in tmp:\n s += S[i]\nprint(s)\nfor i in s:\n if i == "(":\n a += 1\n else:\n b += 1\n if b > a:\n print("No")\n exit()\n\nif a-b == 0:\n print("Yes")\nelse:\n print("No")', 'import sys\nfrom collections import deque\ndef input():\n return sys.stdin.readline().strip()\n\ndef check():\n s = input()\n m = 0\n res = 0\n for i in s:\n if i == "(":\n m += 1 \n else:\n m -= 1\n res = min(res,m)\n return [res,m]\n\nN = int(input())\nS = [check() for _ in range(N)]\n\nS.sort(reverse=True)\nprint(S)\n\na = 0\nb = 0\n\nfor res,m in S:\n a = b + res\n b += m\n if a < 0:\n print("No")\n exit()\n\nif b == 0:\n print("Yes")\nelse:\n print("No")', 'import sys\nfrom collections import deque\ndef input():\n return sys.stdin.readline().strip()\n\ntozan = []\ngezan = []\n\ndef check():\n s = input()\n m = 0\n res = 0\n for i in s:\n if i == "(":\n m += 1 \n else:\n m -= 1\n res = min(res,m)\n if m >= 0:\n tozan.append([res,m])\n else:\n gezan.append([res-m,res,m])\n\nN = int(input())\nfor _ in range(N):\n check()\n\ntozan.sort(reverse=True)\ngezan.sort()\n\nb = 0\n\nfor res,m in tozan:\n if b + res < 0:\n print("No")\n exit()\n b += m\n\nfor _,res,m in gezan:\n if b + res < 0:\n print("No")\n exit()\n b += m\n\nif b == 0:\n print("Yes")\nelse:\n print("No")\n ']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s012784125', 's244047315', 's703854559', 's852064775', 's925890502', 's317571252']
[139428.0, 117108.0, 140360.0, 139444.0, 117324.0, 104428.0]
[1736.0, 1978.0, 2211.0, 1809.0, 1516.0, 1366.0]
[448, 598, 441, 448, 521, 725]
p02686
u532966492
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['def main():\n from sys import stdin\n input = stdin.readline\n n = int(input())\n S = [input() for _ in [0]*n]\n s2 = []\n s3 = []\n for s in S:\n temp = [0, 0]\n m = 0\n now = 0\n for i in s:\n if i == "(":\n now += 1\n else:\n now -= 1\n m = min(m, now)\n temp = [-m, (s.count("(")-s.count(")"))-m]\n if temp[0] < temp[1]:\n s2.append(temp)\n else:\n s3.append(temp)\n s2.sort(key=lambda x: (x[0]))\n s3.sort(key=lambda x: (-x[1]))\n cnt = 0\n for i, j in s2:\n cnt -= i\n if cnt < 0:\n print("No")\n return\n cnt += j\n for i, j in s3:\n cnt -= i\n if cnt < 0:\n print("No")\n return\n cnt += j\n if cnt != 0:\n print("No")\n return\n print("Yes")\n\n\nmain()', 'def main():\n from sys import stdin\n input = stdin.readline\n n = int(input())\n S = [input() for _ in [0]*n]\n s2 = []\n s3 = []\n for s in S:\n temp = [0, 0]\n m = 0\n now = 0\n for i in s.strip(\'\\n\'):\n if i == "(":\n now += 1\n else:\n now -= 1\n m = min(m, now)\n temp = [-m, (s.count("(")-s.count(")"))-m]\n if temp[0] < temp[1]:\n s2.append(temp)\n else:\n s3.append(temp)\n s2.sort(key=lambda x: (x[0]))\n s3.sort(key=lambda x: (-x[1]))\n cnt = 0\n for i, j in s2:\n cnt -= i\n if cnt < 0:\n print("No")\n return\n cnt += j\n for i, j in s3:\n cnt -= i\n if cnt < 0:\n print("No")\n return\n cnt += j\n if cnt != 0:\n print("No")\n return\n print("Yes")\n\n\nmain()\n']
['Wrong Answer', 'Accepted']
['s788351032', 's392310458']
[175620.0, 175688.0]
[1585.0, 1460.0]
[895, 908]
p02686
u533039576
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\ninput = sys.stdin.readline\n\nn = int(input())\ns = [input() for _ in range(n)]\n\n\ndef bracket(x):\n # f: final sum of brackets '(':+1, ')': -1\n # m: min value of f\n f = m = 0\n for i in range(len(x)):\n if x[i] == '(':\n f += 1\n else:\n f -= 1\n m = min(m, f)\n # m <= 0\n return f, m\n\n\ndef func(l):\n # l = [(f, m)]\n l.sort(key=lambda x: -x[1])\n v = 0\n for fi, mi in l:\n if v + mi >= 0:\n v += fi\n else:\n return -1\n return v\n\n\nl1 = []\nl2 = []\nfor i in range(n):\n fi, mi = bracket(s[i])\n if fi >= 0:\n l1.append((fi, mi))\n else:\n l2.append((-fi, mi - fi))\n\nv1 = func(l1)\nv2 = func(l2)\nif v1 == -1 or v2 == -1:\n ans = 'No'\nelse:\n ans = 'Yes' if v1 == v2 else 'No'\n\nprint(ans)\n", "import sys\n# input = sys.stdin.readline\ninput = lambda: sys.stdin.readline().rstrip()\n\nn = int(input())\ns = [input() for _ in range(n)]\n\n\ndef bracket(x):\n # f: final sum of brackets '(':+1, ')': -1\n # m: min value of f\n f = m = 0\n for i in range(len(x)):\n if x[i] == '(':\n f += 1\n else:\n f -= 1\n m = min(m, f)\n # m <= 0\n return f, m\n\n\nl1 = []\nl2 = []\nfor i in range(n):\n fi, mi = bracket(s[i])\n if fi >= 0:\n l1.append((fi, mi))\n else:\n l2.append((fi, mi))\n\nl1.sort(key=lambda x: -x[1])\nl2.sort(key=lambda x: -(x[0] - x[1]))\nl = l1 + l2\nv = 0\nfor fi, mi in l:\n if v + mi >= 0:\n v += fi\n else:\n v = -1\n break\n\nans = 'Yes' if v == 0 else 'No'\nprint(ans)\n"]
['Wrong Answer', 'Accepted']
['s448858001', 's835466774']
[155428.0, 99504.0]
[1400.0, 1406.0]
[813, 762]
p02686
u691018832
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn = int(readline())\ns = [readline().rstrip().decode() for _ in range(n)]\ninc = []\ndec = []\nfor ss in s:\n d, r = 0, 0\n for m in ss:\n d += 1 if s == '(' else -1\n r = max(r, -d)\n (dec if d < 0 else inc).append((d, r))\ninc.sort(key=lambda x: x[1])\ndec.sort(key=lambda x: x[0] + x[1])\np1 = 0\np2 = 0\nflag = True\nfor i in inc:\n flag &= i[1] <= p1\n p1 += i[0]\nfor d in dec:\n flag &= p2 >= d[0] + d[1]\n p2 -= d[0]\nprint('Yes' if flag and p1 == p2 else 'No')\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn = int(readline())\ns = [readline().rstrip().decode() for _ in range(n)]\ninc = []\ndec = []\nfor ss in s:\n d, r = 0, 0\n for m in ss:\n d += (1 if s == '(' else -1)\n r = max(r, -d)\n (dec if d < 0 else inc).append((d, r))\ninc.sort(key=lambda x: x[1])\ndec.sort(key=lambda x: x[0] + x[1])\np1 = 0\np2 = 0\nflag = True\nfor i in inc:\n flag &= i[1] <= p1\n p1 += i[0]\nfor d in dec:\n flag &= p2 >= d[0] + d[1]\n p2 -= d[0]\nprint('Yes' if flag and p1 == p2 else 'No')\n", "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nn = int(readline())\ninc = []\ndec = []\nfor _ in range(n):\n s = readline().rstrip().decode()\n d, r = 0, 0\n for m in s:\n d += (1 if m == '(' else -1)\n r = max(r, -d)\n (dec if d < 0 else inc).append((d, r))\ninc.sort(key=lambda x: x[1])\ndec.sort(key=lambda x: x[0] + x[1])\np1 = 0\np2 = 0\nflag = True\nfor i in inc:\n flag &= i[1] <= p1\n p1 += i[0]\nfor d in dec:\n flag &= p2 >= d[0] + d[1]\n p2 -= d[0]\nflag &= p1 == p2\nprint('Yes' if flag else 'No')\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s818985889', 's891089847', 's002404821']
[95940.0, 95816.0, 84072.0]
[1017.0, 1061.0, 1064.0]
[632, 634, 627]
p02686
u764956288
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['# import sys\n# input = sys.stdin.readline\n\n\ndef solve():\n N = int(input())\n brackets_gen = (input() for _ in range(N))\n\n grads_positive = list()\n grads_negative = list()\n\n for brackets in brackets_gen:\n\n elevation, bottom = 0, 0\n\n for bk in brackets:\n\n elevation += 1 if bk == \'(\' else -1\n bottom = min(bottom, elevation)\n\n if elevation >= 0:\n grads_positive.append((bottom, elevation))\n elif elevation < 0:\n grads_negative.append((bottom - elevation, -elevation))\n\n grads_positive.sort(reverse=True)\n grads_negative.sort()\n\n def is_good(grads):\n elevation, bottom = 0, 0\n for grad in grads:\n bottom = elevation + grad[0]\n if bottom < 0:\n return False\n elevation += grad[1]\n\n if elevation == 0:\n return True\n else:\n return False\n\n if is_good(grads_positive) and is_good(grads_negative):\n return True\n else:\n return False\n\n\ndef main():\n ok = solve()\n if ok:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nreadline = sys.stdin.readline().strip\n\n\ndef solve():\n N = int(input())\n brackets_generator = (readline() for _ in range(N))\n\n grads_positive = list()\n grads_negative = list()\n\n total = 0\n for brackets in brackets_generator:\n\n elevation, bottom = 0, 0\n\n for bk in brackets:\n\n elevation += 1 if bk == \'(\' else -1\n bottom = min(bottom, elevation)\n\n if elevation >= 0:\n grads_positive.append((bottom, elevation))\n elif elevation < 0:\n grads_negative.append((bottom - elevation, -elevation))\n\n total += elevation\n\n if total != 0:\n return False\n\n grads_positive.sort(reverse=True)\n grads_negative.sort(reverse=True)\n\n def is_good(grads):\n elevation, bottom = 0, 0\n for grad in grads:\n bottom = elevation + grad[0]\n if bottom < 0:\n return False\n elevation += grad[1]\n\n return True\n\n if is_good(grads_positive) and is_good(grads_negative):\n return True\n else:\n return False\n\n\ndef main():\n ok = solve()\n if ok:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nif __name__ == "__main__":\n main()\n', 'import sys\nreadline = sys.stdin.readline\n\n\ndef solve():\n N = int(input())\n brackets_generator = (readline().strip() for _ in range(N))\n\n grads_positive = list()\n grads_negative = list()\n\n total = 0\n for brackets in brackets_generator:\n\n elevation, bottom = 0, 0\n\n for bk in brackets:\n\n elevation += 1 if bk == \'(\' else -1\n bottom = min(bottom, elevation)\n\n if elevation >= 0:\n grads_positive.append((bottom, elevation))\n elif elevation < 0:\n grads_negative.append((bottom - elevation, -elevation))\n\n total += elevation\n\n if total != 0:\n return False\n\n grads_positive.sort(reverse=True)\n grads_negative.sort(reverse=True)\n\n def is_good(grads):\n elevation, bottom = 0, 0\n for grad in grads:\n bottom = elevation + grad[0]\n if bottom < 0:\n return False\n elevation += grad[1]\n\n return True\n\n return is_good(grads_positive) and is_good(grads_negative)\n\n\ndef main():\n ok = solve()\n if ok:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nif __name__ == "__main__":\n main()\n']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s758512495', 's945665736', 's581028900']
[80416.0, 9252.0, 80296.0]
[1528.0, 25.0, 742.0]
[1168, 1215, 1167]
p02686
u808817704
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['#from collections import defaultdict, deque\n#import itertools\n#import numpy as np\n#import re\n\ndef main():\n N = int(input())\n SS = []\n for _ in range(N):\n SS.append(input())\n S = []\n for s in SS:\n while \'()\' in s:\n s = s.replace(\'()\', \'\')\n S.append(s)\n #print(S)\n S = [s for s in S if s != \'\']\n sum_op = 0\n sum_cl = 0\n S_both_op = []\n S_both_cl = []\n for s in S:\n if not \')\' in s:\n sum_op += len(s)\n elif not \'(\' in s:\n sum_cl += len(s)\n else:\n pos = s.find(\'(\')\n if pos <= len(s) - pos:\n S_both_op.append((pos, len(s)-pos)) \n else:\n S_both_cl.append((pos, len(s)-pos)) \n\n \n sort(S_both_op, key=lambda x: x[0]) \n sort(S_both_cl, key=lambda x: x[0]) \n\n for p in S_both_op:\n sum_op -= p[0]\n if(sum_op < 0 ):\n print(\'No\')\n exit()\n sum_op += p[1]\n for p in S_both_cl:\n sum_op -= p[0]\n if(sum_op < 0 ):\n print(\'No\')\n exit()\n sum_op += p[1]\n \n if sum_op == sum_cl:\n print(\'Yes\')\n else:\n print(\'No\')\n\n\nif __name__ == "__main__":\n main()', '#from collections import defaultdict, deque\n#import itertools\n#import numpy as np\n#import re\nimport bisect\n\ndef main():\n N = int(input())\n SS = []\n for _ in range(N):\n SS.append(input())\n S = []\n for s in SS:\n while \'()\' in s:\n s = s.replace(\'()\', \'\')\n S.append(s)\n #print(S)\n S = [s for s in S if s != \'\']\n sum_op = 0\n sum_cl = 0\n S_both_op = []\n S_both_cl = []\n for s in S:\n if not \')\' in s:\n sum_op += len(s)\n elif not \'(\' in s:\n sum_cl += len(s)\n else:\n pos = s.find(\'(\')\n if pos <= len(s) - pos:\n S_both_op.append((pos, len(s)-pos)) \n else:\n S_both_cl.append((pos, len(s)-pos)) \n\n \n \n \n S_both_op.sort(key=lambda x: x[0])\n S_both_cl.sort(key=lambda x: -x[1])\n\n for p in S_both_op:\n sum_op -= p[0]\n if(sum_op < 0 ):\n print(\'No\')\n exit()\n sum_op += p[1]\n\n for p in S_both_cl:\n sum_op -= p[0]\n if(sum_op < 0 ):\n print(\'No\')\n exit()\n sum_op += p[1]\n \n if sum_op == sum_cl:\n print(\'Yes\')\n else:\n print(\'No\')\n\nif __name__ == "__main__":\n main()']
['Runtime Error', 'Accepted']
['s452630178', 's451416803']
[55152.0, 56928.0]
[1194.0, 1182.0]
[1494, 1721]
p02686
u845573105
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['dicpos = {}\ndicneg = {}\n\nN = int(input())\nfor i in range(N):\n buf = [0]\n for s in input():\n if s=="(":\n buf.append(buf[-1] + 1)\n else:\n buf.append(buf[-1] - 1)\n low = min(buf)\n last = buf[-1]\n if last>0:\n if low in dicpos:\n dicpos[low].append(last)\n else:\n dicpos[low] = [last]\n else:\n if low in dicneg:\n dicneg[low].append(last)\n else:\n dicneg[low] = [last]\nneg_sorted = sorted(dicneg.items(), key=lambda x:x[0])\npos_sorted = sorted(dicpos.items(), key=lambda x:x[0], reverse=True)\nprint(neg_sorted)\nprint(pos_sorted)\nsumm = 0\nflag = 0\nfor i in pos_sorted:\n for j in i[1]:\n if summ + i[0] < 0:\n flag = 1\n print("No")\n break\n summ += j\nif flag == 0:\n for i in neg_sorted:\n for j in sorted(i[1], reverse=True):\n if summ + i[0] < 0:\n \tflag = 1\n \tprint("No")\n \tbreak \n summ += j\nif flag == 0:\n if summ == 0:\n print("Yes")\n else:\n print("No")', 'dicpos = {}\ndicneg = {}\n\nN = int(input())\nfor i in range(N):\n buf = [0]\n for s in input():\n if s=="(":\n buf.append(buf[-1] + 1)\n else:\n buf.append(buf[-1] - 1)\n low = min(buf)\n last = buf[-1]\n if last>0:\n if low in dicpos:\n dicpos[low].append(last)\n else:\n dicpos[low] = [last]\n else:\n if low-last in dicneg:\n dicneg[low-last].append(-last)\n else:\n dicneg[low-last] = [-last]\nneg_sorted = sorted(dicneg.items(), key=lambda x:x[0], reverse=True)\npos_sorted = sorted(dicpos.items(), key=lambda x:x[0], reverse=True)\n\n\nsumm = 0\nflag = 0\nfor i in pos_sorted:\n if flag == 1:\n break\n for j in i[1]:\n if summ + i[0] < 0:\n flag = 1\n print("No")\n break\n summ += j\nsumm2 = 0\nif flag == 0:\n for i in neg_sorted:\n if flag == 1:\n break\n for j in i[1]:\n if summ2 + i[0] < 0:\n flag = 1\n print("No")\n break\n summ2 += j\nif flag == 0:\n if summ == summ2:\n print("Yes")\n else:\n print("No")']
['Wrong Answer', 'Accepted']
['s782543663', 's338457023']
[21040.0, 17168.0]
[1902.0, 1836.0]
[951, 1036]
p02686
u863442865
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["print('No')", "\n\n\n\n\n\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n import math\n #from math import gcd\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n n = int(input())\n a = []\n b = []\n for _ in range(n):\n s = input().rstrip()\n \n up, down = 0, 0\n for i in s:\n if i == ')':\n up -= 1\n if down > up:\n down = up\n else:\n up += 1\n if up >= 0:\n a.append((down, up))\n else:\n b.append((up-down, down, up))\n\n a.sort(reverse=True)\n b.sort(key=lambda a: a[0],reverse=True)\n\n c = 0\n\n for d, u in a:\n if c+d < 0:\n print('No')\n break\n else:\n c += u\n else:\n for _, d, u in b:\n if c+d < 0:\n print('No')\n break\n else:\n c += u\n else:\n if c == 0:\n print('Yes')\n else:\n print('No')\n \nif __name__ == '__main__':\n main()\n"]
['Wrong Answer', 'Accepted']
['s748811941', 's067951779']
[9152.0, 84552.0]
[23.0, 568.0]
[11, 1509]
p02686
u868082223
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\nimport heapq\n\ndef end(flag):\n if flag:\n print('Yes')\n else:\n print('No')\n exit(0) \n\nn = int(input())\nplus = []\nminus = []\nzero = []\ntotal = 0\nfor i in range(n):\n s = input()[:-1] \n cnt = 0\n M = 0\n m = 0\n for t in s:\n if t == ')': \n cnt += 1\n # print('+cnt:{}'.format(cnt))\n M = max(M,cnt) \n # print('M:{}'.format(M))\n else:\n cnt -= 1\n # print('-cnt:{}'.format(cnt))\n cnt = 0\n for t in s[::-1]: \n if t == ')':\n cnt += 1\n # print('+cnt:{}'.format(cnt))\n else:\n cnt -= 1\n # print('-cnt:{}'.format(cnt))\n m = min(m,cnt) \n # print('m:{}'.format(m))\n if cnt == 0:\n zero.append((-m,M))\n else:\n plus.append((M,-cnt))\n S = (M,-cnt)\n total += cnt\nif total != 0:\n end(0)\nplus.sort()\nminus.sort()\ncnt = 0\nfor need,increase in plus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\ncnt = 0\nfor need,increase in minus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\nfor m,M in zero:\n if m > cnt or M > cnt:\n end(0)\nend(1)", "import sys\nimport heapq\n\ndef end(flag):\n if flag:\n print('Yes')\n else:\n print('No')\n exit(0) \n\nn = int(input())\nplus = []\nminus = []\nzero = []\ntotal = 0\nfor i in range(n):\n s = input()[:-1] \n cnt = 0\n M = 0\n m = 0\n for t in s:\n if t == ')': \n cnt += 1\n print('+cnt:{}'.format(cnt))\n M = max(M,cnt) \n print('M:{}'.format(M))\n else:\n cnt -= 1\n print('-cnt:{}'.format(cnt))\n cnt = 0\n for t in s[::-1]: \n if t == ')':\n cnt += 1\n print('+cnt:{}'.format(cnt))\n else:\n cnt -= 1\n print('-cnt:{}'.format(cnt))\n m = min(m,cnt) \n print('m:{}'.format(m))\n # if cnt > 0:\n # minus.append((-m,cnt))\n if cnt == 0:\n zero.append((-m,M))\n else:\n plus.append((M,-cnt))\n S = (M,-cnt)\n total += cnt\nif total != 0:\n end(0)\nplus.sort()\nminus.sort()\ncnt = 0\nfor need,increase in plus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\ncnt = 0\nfor need,increase in minus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\nfor m,M in zero:\n if m > cnt or M > cnt:\n end(0)\nend(1)\n", "import sys\nimport heapq\n\ndef end(flag):\n if flag:\n print('Yes')\n else:\n print('No')\n exit(0) \n\nn = int(input())\nplus = []\nminus = []\nzero = []\ntotal = 0\nfor i in range(n):\n s = input()[:-1] \n cnt = 0\n M = 0\n m = 0\n for t in s:\n if t == ')': \n cnt += 1\n M = max(M,cnt) \n else:\n cnt -= 1\n cnt = 0\n for t in s[::-1]: \n if t == ')':\n cnt += 1\n else:\n cnt -= 1\n m = min(m,cnt) \n if cnt == 0:\n zero.append((-m,M))\n else:\n plus.append((M,-cnt))\n S = (M,-cnt)\n total += cnt\nif total != 0:\n end(0)\nplus.sort()\nminus.sort()\ncnt = 0\nfor need,increase in plus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\ncnt = 0\nfor need,increase in minus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\nfor m,M in zero:\n if m > cnt or M > cnt:\n end(0)\nend(1)", "import sys\nimport heapq\n\ndef end(flag):\n if flag:\n print('Yes')\n else:\n print('No')\n exit(0) \n\nn = int(input())\nplus = []\nminus = []\nzero = []\ntotal = 0\nfor i in range(n):\n s = input()[:-1] \n cnt = 0\n M = 0\n m = 0\n for t in s:\n if t == ')': \n cnt += 1\n # print('+cnt:{}'.format(cnt))\n M = max(M,cnt) \n # print('M:{}'.format(M))\n else:\n cnt -= 1\n # print('-cnt:{}'.format(cnt))\n cnt = 0\n for t in s[::-1]: \n if t == ')':\n cnt += 1\n # print('+cnt:{}'.format(cnt))\n else:\n cnt -= 1\n # print('-cnt:{}'.format(cnt))\n m = min(m,cnt) \n # print('m:{}'.format(m))\n if cnt > 0:\n minus.append((-m,cnt))\n elif cnt == 0:\n zero.append((-m,M))\n else:\n plus.append((M,-cnt))\n S = (M,-cnt)\n total += cnt\nif total != 0:\n end(0)\nplus.sort()\nminus.sort()\ncnt = 0\nfor need,increase in plus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\ncnt = 0\nfor need,increase in minus:\n if cnt < need:\n end(0)\n else:\n cnt += increase\nfor m,M in zero:\n if m > cnt or M > cnt:\n end(0)\nend(1)", "import sys\n\ninput = sys.stdin.readline\n\ndef check(s):\n h = 0\n for p in s:\n b = h + p[0]\n if b < 0: return False\n h += p[1]\n return True\n\nN = int(input())\nS = [input().strip() for i in range(N)]\n\ntotal = 0\nps, ms = [], []\nfor s in S:\n h, b = 0, 0\n for c in s:\n if c == '(':\n h += 1\n else:\n h -= 1\n b = min(b, h)\n if h > 0:\n ps.append([b, h])\n else:\n ms.append([b-h, -h])\n total += h\n\nps.sort(reverse=True)\nms.sort(reverse=True)\nif check(ps) and check(ms) and total == 0:\n print('Yes')\nelse:\n print('No')"]
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s243446614', 's445693525', 's612719532', 's702157324', 's195015665']
[80428.0, 80292.0, 80284.0, 80284.0, 103692.0]
[1721.0, 2225.0, 1669.0, 1692.0, 1408.0]
[1450, 1490, 1202, 1499, 610]
p02686
u869567753
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["import sys\nreadline = sys.stdin.readline\n\ndef main():\n N = int(readline())\n Sp = []\n Sm = []\n total = 0\n bm = 0\n for i in range(N):\n l = readline().strip()\n print(l)\n b = 0\n h = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n b = min(b, h)\n if h == 0 and b != 0:\n bm = min(bm, b)\n elif h > 0:\n Sp.append([b, h])\n elif h < 0:\n Sm.append([b-h, -h])\n total += h\n Sp.append([bm, 0])\n if total != 0:\n print('No')\n exit()\n Sp.sort(key=lambda x:x[0], reverse=True)\n p = check(Sp)\n if p < 0:\n print('No')\n exit()\n Sm.sort(key=lambda x:x[0], reverse=True)\n m = check(Sm)\n if m < 0:\n print('No')\n exit()\n print('Yes')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return -1\n else:\n h += S[i][1]\n return h\n\nif __name__ == '__main__':\n main()", "def main():\n N = int(input())\n Sp = []\n Sm = []\n total = 0\n for i in range(N):\n l = input()\n u = 0\n h = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n u = min(u, h)\n if h > 0:\n Sp.append([u, h])\n else:\n Sm.append([u-h, -h])\n total += h\n if total != 0:\n print('No')\n exit()\n Sp.sort(reverse=True)\n p = check(Sp)\n if not p:\n print('No')\n exit()\n Sm.sort(reverse=True)\n m = check(Sm)\n if not m:\n print('No')\n exit()\n print('Yes')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return False\n else:\n h += S[i][1]\n return True\n\nif __name__ == '__main__':\n main()", "def main():\n N = int(input())\n Sp = []\n Sm = []\n total = 0\n for i in range(N):\n l = input()\n u = 0\n h = 0\n um = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n u = min(u, h)\n if h == 0:\n um = min(um, u)\n elif h > 0:\n Sp.append([u, h])\n else:\n Sm.append([u-h, -h])\n total += h\n if total != 0:\n print('No')\n exit()\n Sp.sort(key=lambda, x:x[0])\n p = check(Sp)\n if p < 0 or p < -um:\n print('No')\n exit()\n Sm.sort(key=lambda, x:x[0])\n m = check(Sm)\n if m < 0:\n print('No')\n exit()\n print('Yes')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return -1\n else:\n h += S[i][1]\n return h\n\nif __name__ == '__main__':\n main()", "import sys\nreadline = sys.stdin.readline\n\ndef main():\n N = int(readline())\n Sp = []\n Sm = []\n total = 0\n bm = 0\n for i in range(N):\n l = readline()\n b = 0\n h = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n b = min(b, h)\n if h == 0 and b != 0:\n bm = min(bm, b)\n elif h > 0:\n Sp.append([b, h])\n elif h < 0:\n Sm.append([b-h, -h])\n total += h\n Sp.append([bm, 0])\n if total != 0:\n print('No')\n exit()\n Sp.sort(key=lambda x:x[0], reverse=True)\n p = check(Sp)\n if p < 0:\n print('No')\n exit()\n Sm.sort(key=lambda x:x[0], reverse=True)\n m = check(Sm)\n if m < 0:\n print('No')\n exit()\n print('Yes')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return -1\n else:\n h += S[i][1]\n return h\n\nif __name__ == '__main__':\n main()", "# import numpy as np\n# import matplotlib.pyplot as plt\n# from matplotlib.image import imread\ndef init():\n global N, Sp, Sm\n N = int(input())\n Sp = []\n Sm = []\n for i in range(N):\n l = input()\n u = 0\n h = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n if h < u:\n u = h\n if h >= 0:\n Sp.append([u, h])\n else:\n Sm.append([u-h, -h])\n Sp.sort(reverse=True)\n Sm.sort(reverse=True)\n\ndef main():\n init()\n print(Sp, Sm)\n p = check(Sp)\n m = check(Sm)\n if p != -1 and m != -1 and p ==m:\n print('Yes')\n else:\n print('No')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return -1\n else:\n h += S[i][1]\n return h\n\nif __name__ == '__main__':\n main()", "import sys\nreadline = sys.stdin.readline\n\ndef main():\n N = int(readline())\n Sp = []\n Sm = []\n total = 0\n bm = 0\n for i in range(N):\n l = readline().strip()\n b = 0\n h = 0\n for j in range(len(l)):\n if l[j] == '(':\n h += 1\n else:\n h -= 1\n b = min(b, h)\n if h == 0 and b != 0:\n bm = min(bm, b)\n elif h > 0:\n Sp.append([b, h])\n elif h < 0:\n Sm.append([b-h, -h])\n total += h\n Sp.append([bm, 0])\n if total != 0:\n print('No')\n exit()\n Sp.sort(key=lambda x:x[0], reverse=True)\n p = check(Sp)\n if p < 0:\n print('No')\n exit()\n Sm.sort(key=lambda x:x[0], reverse=True)\n m = check(Sm)\n if m < 0:\n print('No')\n exit()\n print('Yes')\n\ndef check(S):\n h = 0\n for i in range(len(S)):\n if h + S[i][0] < 0:\n return -1\n else:\n h += S[i][1]\n return h\n\nif __name__ == '__main__':\n main()"]
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s109557794', 's116534109', 's239457918', 's709300924', 's822659781', 's220565068']
[100128.0, 96300.0, 9012.0, 52600.0, 105900.0, 99704.0]
[1524.0, 2161.0, 22.0, 976.0, 2222.0, 1280.0]
[897, 720, 777, 876, 820, 884]
p02686
u896741788
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['n=int(input())\npo,ne=[],[]\nnow=0\nfor i in range(n):\n p=0\n mp=0\n for j in input():\n p+=(1,-1)[j==")"]\n mp=min(p,mp)\n if mp:\n if p>=0:\n po.append((mp,p))\n else:ne.append((mp-p,-p))\n else:now+=p\npo.sort(reverse=1)\nne.sort(reevrse=1)\nfor m,p in po+ne:\n if m+now<0:print("No");exit()\n else:now+=p\nprint("No") if now else print("Yes")', 'n=int(input())\npo,ne=[],[]\nnow=0\nfor i in range(n):\n p=0\n mp=0\n for j in input():\n p+=(1,-1)[j==")"]\n mp=min(p,mp)\n if mp:\n if p>=0:\n po.append((mp,p))\n else:ne.append((mp-p,-p))\n else:now+=p\npo.sort(reverse=1)\nne.sort(reverse=1)\nfor m,p in po:\n if m+now<0:print("No");exit()\n else:now+=p\nnnow=0\nfor m,p in ne:\n if m+nnow<0:print("No");exit()\n else:nnow+=p\nprint("Yes" if now==nnow else "No") ']
['Runtime Error', 'Accepted']
['s013322478', 's727103163']
[44748.0, 44512.0]
[1600.0, 1659.0]
[388, 459]
p02686
u923172145
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys\ninput = sys.stdin.readline\n\nN = int(input())\n\nS = [input() for _ in range(N)]\nS_p = []\nS_n = []\n\nfor i in range(N):\n end = 0\n mim = 0\n for j in range(len(S[i])):\n if S[i][j] == "(":\n end += 1\n else :\n end -= 1\n mim = min(mim,end)\n \n if end >= 0:\n S_p.append((mim, end))\n else:\n S_n.append((end-mim, end))\n \nS_p.sort(reverse=True)\nS_n.sort(reverse=True)\n#print(S_p)\n#print(S_n)\n\ncheck = 0\nflag = True\nfor i in range(len(S_p)):\n if check + S_p[i][0] >= 0:\n check += S_p[i][1]\n else:\n flag = False\n break\n #print(check)\n \nfor i in range(len(S_n)):\n if check + S_n[i][1] - S_n[i][0] >= 0:\n check += S_n[i][1]\n else:\n flag = False\n break\n #print(check)\n \nif check == 0 and flag:\n flag = True\nelse:\n flag = False\n\nprint("Yes" if flag else "No")', 'N = int(input())\n\nS = [input() for _ in range(N)]\nS_t = [(0,0) for _ in range(N)]\n\nfor i in range(N):\n end = 0\n mim = 0\n for j in range(len(S[i])):\n if S[i][j] == "(":\n end += 1\n else :\n end -= 1\n mim = min(mim,end)\n \n S_t[i] = (mim, end)\n \nS_t.sort(reverse=True)\nprint(S_t)\n\ncheck = 0\nflag = True\nfor i in range(N):\n if check + S_t[i][0] >= 0:\n check += S_t[i][1]\n else:\n flag = False\n break\n print(check)\n \nif check == 0 and flag:\n flag = True\nelse:\n flag = False\n\nprint("Yes" if flag else "No")', 'import sys\ninput=lambda: sys.stdin.readline().rstrip()\n\nN = int(input())\n\nS_p = []\nS_n = []\n\nfor i in range(N):\n end = 0\n mim = 0\n for c in input():\n if c == "(":\n end += 1\n else :\n end -= 1\n mim = min(mim,end)\n \n if end >= 0:\n S_p.append([mim, end])\n else:\n S_n.append([end-mim, end])\n \nS_p.sort(reverse=True)\nS_n.sort(reverse=True)\n#print(S_p)\n#print(S_n)\n\ncheck = 0\nflag = True\nfor i in range(len(S_p)):\n if check + S_p[i][0] >= 0:\n check += S_p[i][1]\n else:\n flag = False\n break\n #print(check)\n \nfor i in range(len(S_n)):\n if check + S_n[i][1] - S_n[i][0] >= 0:\n check += S_n[i][1]\n else:\n flag = False\n break\n #print(check)\n \nif check == 0 and flag:\n flag = True\nelse:\n flag = False\n\nprint("Yes" if flag else "No")']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s435988791', 's466307589', 's573731170']
[151544.0, 109012.0, 96112.0]
[1443.0, 2223.0, 1494.0]
[809, 539, 779]
p02686
u937642029
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys, bisect, math, itertools, string, queue, copy\n# import numpy as np\n\nfrom collections import Counter,defaultdict,deque\nfrom itertools import permutations, combinations\nfrom heapq import heappop, heappush\nfrom fractions import gcd\n# input = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(input())\ndef inpm(): return map(int,input().split())\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\ndef inplm(n): return list(int(input()) for _ in range(n))\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return [list(map(int, input().split())) for _ in range(n)]\ndef inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])\n\ndef main():\n n = inp()\n s = [list(input()) for _ in range(n)]\n cnt = [[0,0] for _ in range(n)]\n for i in range(n):\n t = s[i]\n flag = 0\n l = 0\n r = 0\n for j in range(len(t)):\n if not flag and t[j] == \')\':\n r += 1\n elif t[j] == \'(\':\n flag = 1\n l += 1\n else:\n l -= 1\n if l == 0:\n flag = 0\n cnt[i] = [l,r]\n flag1 = 0\n flag2 = 0\n L,R = 0,0\n for i in range(n):\n if cnt[i][0] == 0 and cnt[i][1] != 0:\n flag1 = 1\n if cnt[i][1] == 0 and cnt[i][0] != 0:\n flag2 = 1\n L += cnt[i][0]\n R += cnt[i][1]\n if flag1 and flag2 and (L==R):\n print(\'Yes\')\n else:\n print(\'No\')\n \nif __name__ == "__main__":\n main()', 'def main():\n n = int(input())\n s = [list(input()) for _ in range(n)]\n L_cnt = []\n R_cnt = []\n LR_cnt = []\n min_l,min_r = 10**6,10**6\n for i in range(n):\n t = s[i]\n flag = 0\n l = 0\n r = 0\n for j in range(len(t)):\n if not flag and t[j] == \')\':\n r += 1\n elif t[j] == \'(\':\n flag = 1\n l += 1\n else:\n l -= 1\n if l == 0:\n flag = 0\n if r == 0 and l == 0:\n continue\n if r == 0:\n L_cnt.append(l)\n elif l == 0:\n R_cnt.append(r)\n else:\n LR_cnt.append([l,r])\n min_l = min(min_l,l)\n min_r = min(min_r,r)\n L,R = sum(L_cnt),sum(R_cnt)\n if not LR_cnt:\n if L == R:\n print(\'Yes\')\n return\n else:\n print(\'No\')\n return\n if not (L_cnt and R_cnt):\n print(\'No\')\n return\n box1 = []\n box2 = []\n for i in range(len(LR_cnt)):\n if L >= LR_cnt[i][1] and LR_cnt[i][1] <= LR_cnt[i][0]:\n L += LR_cnt[i][0] - LR_cnt[i][1]\n elif LR_cnt[i][1] <= LR_cnt[i][0]:\n box1.append(LR_cnt[i])\n else:\n box2.append(LR_cnt[i])\n for i in range(len(box1)):\n L -= box1[i][1]\n if L < 0:\n print(\'No\')\n return\n L += box1[i][0]\n for i in range(len(box2)):\n L -= box2[i][1]\n if L < 0:\n print(\'No\')\n return\n L += box2[i][0]\n if L == R:\n print(\'Yes\')\n else:\n print(\'No\')\n \nif __name__ == "__main__":\n main()']
['Wrong Answer', 'Accepted']
['s866992066', 's057141232']
[184852.0, 103796.0]
[2210.0, 1867.0]
[1677, 1687]
p02686
u968404618
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['def main():\n ## IMPORT MODULE\n #import sys\n\n \n #input=lambda :sys.stdin.readline().rstrip()\n\n #f_inf=float("inf")\n #MOD=10**9+7\n \n if \'get_ipython\' in globals(): \n ## SAMPLE INPUT\n n = 4\n S= [\'((()))\', \'((((((\', \'))))))\', \'()()()\']\n\n else:\n ##INPUT \n n = int(input())\n #a, b = map(int, input().split())\n S = [input() for _ in range(n)]\n\n ## SUBMITION CODES HERE\n def CNT(A):\n tmp, Min = 0, 0\n for a in A:\n if a == \'(\': tmp += 1\n else: -1\n Min = min(Min, tmp)\n return (-Min, tmp-Min)\n \n T = [CNT(s) for s in S]\n\n pls = []\n mis = []\n for l, r in T:\n if l <= r: pls.append((l, r))\n else: mis.append((l, r))\n\n pls.sort(key=lambda a: a[0])\n mis.sort(key=lambda a: a[1], reverse=True)\n total = pls + mis\n\n levl = 0\n for l, r in total:\n levl -= l\n if levl < 0:\n print(\'No\')\n exit()\n levl += r\n\n print(\'Yes\' if levl == 0 else \'No\')\n \nmain()', 'def main():\n ## IMPORT MODULE\n #import sys\n\n \n #input=lambda :sys.stdin.readline().rstrip()\n\n #f_inf=float("inf")\n #MOD=10**9+7\n \n if \'get_ipython\' in globals(): \n ## SAMPLE INPUT\n n = 4\n S = [\'((()))\', \'((((((\', \'))))))\', \'()()()\']\n\n else:\n ## INPUT \n n = int(input())\n #a, b = map(int, input().split())\n S = [input() for _ in range(n)]\n\n ## SUBMITION CODES HERE\n def CNT(A):\n tmp, Min = 0, 0\n for a in A:\n if a == \'(\': tmp += 1\n else: -1\n Min = min(Min, tmp)\n return (-Min, tmp-Min)\n \n T = [CNT(s) for s in S]\n\n pls = []\n mis = []\n for l, r in T:\n if l <= r: pls.append((l, r))\n else: mis.append((l, r))\n\n pls.sort(key=lambda a: a[0])\n mis.sort(key=lambda a: a[1], reverse=True)\n total = pls + mis\n\n levl = 0\n for l, r in total:\n levl -= l\n if levl < 0:\n print(\'No\')\n exit()\n levl += r\n\n print(\'Yes\' if levl == 0 else \'No\')\n \nmain()', 'def main():\n ## IMPORT MODULE\n #import sys\n\n \n #input=lambda :sys.stdin.readline().rstrip()\n\n #f_inf=float("inf")\n #MOD=10**9+7\n \n if \'get_ipython\' in globals(): \n ## SAMPLE INPUT\n n = 4\n S= [\'((()))\', \'((((((\', \'))))))\', \'()()()\']\n\n else:\n ##INPUT \n n = input()\n #a, b = map(int, input().split())\n S = [input() for _ in range(n)]\n\n ## SUBMITION CODES HERE\n def CNT(A):\n tmp, Min = 0, 0\n for a in A:\n if a == \'(\': tmp += 1\n else: -1\n Min = min(Min, tmp)\n return (-Min, tmp-Min)\n \n T = [CNT(s) for s in S]\n\n pls = []\n mis = []\n for l, r in T:\n if l <= r: pls.append((l, r))\n else: mis.append((l, r))\n\n pls.sort(key=lambda a: a[0])\n mis.sort(key=lambda a: a[1], reverse=True)\n total = pls + mis\n\n levl = 0\n for l, r in total:\n levl -= l\n if levl < 0:\n print(\'No\')\n exit()\n levl += r\n\n print(\'Yes\' if levl == 0 else \'No\')\n \nmain()', 'def main():\n ## IMPORT MODULE\n #import sys\n\n \n #input=lambda :sys.stdin.readline().rstrip()\n\n #f_inf=float("inf")\n #MOD=10**9+7\n \n if \'get_ipython\' in globals(): \n ## SAMPLE INPUT\n n = 4\n S = [\'((()))\', \'((((((\', \'))))))\', \'()()()\']\n\n else:\n ## INPUT \n n = int(input())\n #a, b = map(int, input().split())\n S = [input() for _ in range(n)]\n\n ## SUBMITION CODES HERE\n def CNT(A):\n tmp, Min = 0, 0\n for a in A:\n if a == \'(\': tmp += 1\n else: tmp -= 1\n Min = min(Min, tmp)\n return (-Min, tmp-Min)\n \n T = [CNT(s) for s in S]\n\n pls = []\n mis = []\n for l, r in T:\n if l <= r: pls.append((l, r))\n else: mis.append((l, r))\n\n pls.sort(key=lambda a: a[0])\n mis.sort(key=lambda a: a[1], reverse=True)\n total = pls + mis\n\n levl = 0\n for l, r in total:\n levl -= l\n if levl < 0:\n print(\'No\')\n exit()\n levl += r\n\n print(\'Yes\' if levl == 0 else \'No\')\n \nmain()']
['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s390102912', 's448760632', 's908035251', 's523161738']
[167144.0, 166976.0, 9164.0, 170772.0]
[1691.0, 1683.0, 24.0, 1713.0]
[967, 969, 962, 975]
p02686
u989345508
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['from itertools import *\nn,*s=open(0).read().split()\nu=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):\n if m+c<0:print("No");break\n m+=d\nelse:print(\'YNeos\'[not m::2])', 'from sys import exit\nfrom itertools import accumulate,chain\nn,*s=open(0).read().split()\nt=[2*i.count("(")-len(i) for i in s]\nif sum(t)!=0:\n print("No");exit()\nst=[[min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0)),t_] for s_,t_ in zip(s,t)]\nnow=0\nfor c in chain(sorted([x if x[1]>=0 for x in st])[::-1],sorted([x if x[1]<0 for x in st],lambda z:z[1]-z[0])[::-1]):\n if now+c[0]<0:\n print("No");exit()\n now+=c[1]\nprint("Yes")', 'import sys\nfrom functools import reduce\nn=int(input())\ns=[input() for i in range(n)]\nt=[2*(i.count("("))-len(i) for i in s]\nif sum(t)!=0:\n print("No")\n sys.exit()\nst=[[t[i]] for i in range(n)]\n\nfor i in range(n):\n now,mi=0,0\n for j in s[i]:\n if j=="(":\n now+=1\n else:\n now-=1\n mi=min(mi,now)\n st[i].append(mi)\n\nnow2=reduce(lambda a,b:a[0]+b[0],filter(lambda x:x[1]>=0,st))\nv,w=list(filter(lambda x:x[1]<0 and x[0]>=0,st)),list(filter(lambda x:x[1]<0 and x[0]<0,st))\nv.sort(reverse=True,key=lambda z:z[1])\nw.sort(key=lambda z:z[0]-z[1],reverse=True)\n\nfor vsub in v:\n if now2+vsub[1]<0:\n print("No")\n sys.exit()\n now2+=vsub[0]\nfor wsub in w:\n if now2+wsub[1]<0:\n print("No")\n sys.exit()\n now2+=wsub[0]\nprint("Yes")', 'from itertools import *\nn,*s=open(0).read().split()\nu=[[min([0,accumulate(t,lambda a,b: a+(1 if b=="(" else -1))]),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):\n if m+c<0:print("No");break\n m+=d\nelse:print("No" if m else "Yes")', 'from sys import exit\nfrom itertools import accumulate,chain\nn,*s=open(0).read().split()\nt=[2*i.count("(")-len(i) for i in s]\nif sum(t)!=0:\n print("No");exit()\nst=[[min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0)),t_] for s_,t_ in zip(s,t)]\nnow=0\nfor c in chain(sorted([x for x in st if x[1]>=0])[::-1],sorted([x for x in st if x[1]<0],lambda z:z[1]-z[0])[::-1]):\n if now+c[0]<0:\n print("No");exit()\n now+=c[1]\nprint("Yes")', 'from sys import exit\nfrom itertools import accumulate,chain\nn,*s=open(0).read().split()\nt=[2*i.count("(")-len(i) for i in s]\nif sum(t)!=0:\n print("No");exit()\n\nst=[[min(accumulate(s_,lambda a,b: a+(1 if b=="(" else -1),initial=0)),t_] for s_,t_ in zip(s,t)]\n\nnow=0\nv=list(filter(lambda x:x[0]>=0,st))\nw=list(filter(lambda x:x[0]<0,st))\nv.sort()\nw.sort()\n\nfor c in chain(v[::-1],w[::-1]):\n if now+c[1]<0:\n print("No");exit()\n now+=c[0]\nprint("Yes")', 'from itertools import *\nn,*s=open(0).read().split()\nu=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):\n if m+c<0:print("No");break\n m+=d\nelse:print(\'NYoe s\'[m::2])', 'from itertools import *\nn,*s=open(0).read().split()\nu=[[min(accumulate(chain([0],t),lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):\n if m+c<0:print("No");break\n m+=d\nelse:print("No" if m else "Yes")', 'from itertools import *\nn,*s=open(0).read().split()\nu=[[min(accumulate(t,lambda a,b: a+(1 if b=="(" else -1),initial=0)),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[1]-z[0])[::-1]):\n if m+c<0:print("No");break;m+=d\nelse:\n print("No" if m else "Yes")', 'from sys import exit\nfrom itertools import accumulate\nn=int(input())\ns=[input() for i in range(n)]\nt=[2*(i.count("("))-len(i) for i in s]\n\nst=[[t[i],min(accumulate(s[i],lambda a,b: a+(1 if b=="(" else -1),initial=0))] for i in range(n)]\n\nnow2=sum(map(lambda x:x[0],filter(lambda x:x[1]>=0,st)))\nv=list(filter(lambda x:x[1]<0 and x[0]>=0,st))\nw=list(filter(lambda x:x[1]<0 and x[0]<0,st))\nv.sort(reverse=True,key=lambda z:z[1])\nw.sort(key=lambda z:z[0]-z[1],reverse=True)\n\nfor sub in chain(v,w):\n if now2+sub[1]<0:\n print("No");exit()\n now2+=sub[0]\nprint("Yes")', 'from itertools import *\nn,*s=open(0).read().split()\nu=[[min(accumulate(chain([0],t),lambda a,b: a+(1 if b=="(" else -1))),2*t.count("(")-len(t)] for t in s]\nm=0\nfor c,d in chain(sorted([x for x in u if x[1]>=0])[::-1],sorted([x for x in u if x[1]<0],key=lambda z:z[0]-z[1])):\n if m+c<0:print("No");break\n m+=d\nelse:print("No" if m else "Yes")']
['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted']
['s050803613', 's100058436', 's158765491', 's198637634', 's366104000', 's382384887', 's514377299', 's833112459', 's880744670', 's934235648', 's201136465']
[119448.0, 9004.0, 143788.0, 44556.0, 120104.0, 127944.0, 119516.0, 119612.0, 119420.0, 111948.0, 119404.0]
[1414.0, 26.0, 2199.0, 66.0, 1313.0, 1512.0, 1423.0, 1565.0, 1333.0, 2208.0, 1559.0]
[344, 455, 810, 341, 455, 487, 341, 358, 354, 597, 348]
p02686
u994935583
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
['import sys\nreadline = sys.stdin.readline\n\ndef resolve():\n N = int(readline())\n S = [readline().strip() for i in range(N)]\n L,R = [],[]\n D = []\n for i in range(N):\n L_R = [0,0] \n for i in S:\n if i == ")":\n if L_R[1] > 0 :\n L_R[1] -= 1\n else:\n L_R[0] +=1\n if i == "(":\n L_R[1] += 1\n if L_R[0] == 0 and L_R[1] == 0:\n pass\n elif L_R[0] == 0:\n R.append(L_R[1])\n elif L_R[1] == 0:\n L.append(L_R[0])\n else:\n D.append((L_R))\n L = sum(L)\n R = sum(R)\n\n inc = []\n dec = []\n for l,r in D:\n if l > r:\n inc.append((l, r))\n else:\n dec.append((l, r))\n \n inc.sort(key=lambda x:x[1])\n dec.sort(key=lambda x:-x[1])\n \n D = inc + dec\n \n for i, (l,r) in enumerate(D):\n L -= r\n if L < 0:\n print(\'No\')\n exit(0)\n L += l\n \n if L == R:\n print(\'Yes\')\n else:\n print(\'No\')\nresolve()', "\n\nimport sys\nreadline = sys.stdin.readline\n\ndef resolve():\n N = int(readline())\n S = [readline().strip() for i in range(N)]\n L,R = [],[]\n D = []\n for s in S:\n l, r = 0, 0\n for c in s:\n if c == ')':\n if l > 0:\n l -= 1\n else:\n r += 1\n else:\n l += 1\n if l == 0 and r == 0:\n pass\n elif l == 0:\n R.append(r)\n elif r == 0:\n L.append(l)\n else:\n D.append((l, r))\n L = sum(L)\n R = sum(R)\n\n inc = []\n dec = []\n for l,r in D:\n if l > r:\n inc.append((l, r))\n else:\n dec.append((l, r))\n \n inc.sort(key=lambda x:x[1])\n dec.sort(key=lambda x:-x[1])\n \n D = inc + dec\n \n for i, (l,r) in enumerate(D):\n L -= r\n if L < 0:\n print('No')\n exit(0)\n L += l\n \n if L == R:\n print('Yes')\n else:\n print('No')\nresolve()"]
['Wrong Answer', 'Accepted']
['s813535028', 's987190171']
[116816.0, 66712.0]
[2210.0, 353.0]
[1168, 1097]
p02686
u997641430
2,000
1,048,576
A **bracket sequence** is a string that is one of the following: 1. An empty string; 2. The concatenation of `(`, A, and `)` in this order, for some bracket sequence A ; 3. The concatenation of A and B in this order, for some non-empty bracket sequences A and B / Given are N strings S_i. Can a bracket sequence be formed by concatenating all the N strings in some order?
["n = int(input())\nS = [input() for i in range(n)]\nAB = []\nfor i in range(n):\n a, b = 0, 0\n for c in S[i]:\n if c == '(':\n b += 1\n if c == ')':\n if b > 0:\n b -= 1\n else:\n a += 1\n AB.append((a, b))\nAB0 = [(a, b) for a, b in AB if -a + b >= 0]\nAB1 = [(a, b) for a, b in AB if -a + b < 0]\nAB0.sort()\nAB1.sort(key=lambda x: -x[1])\nAB = AB0 + AB1\nprint(AB)\nx = 0\nfor a, b in AB:\n x -= a\n if x < 0:\n print('No')\n exit()\n x += b\nif x == 0:\n print('Yes')\nelse:\n print('No')\n", "n = int(input())\nS = [input() for i in range(n)]\nAB = []\nfor i in range(n):\n a, b = 0, 0\n for c in S[i]:\n if c == '(':\n b += 1\n if c == ')':\n if b > 0:\n b -= 1\n else:\n a += 1\n AB.append((a, b))\nAB.sort(key=lambda x: (x[0], -x[1]))\nprint(AB)\nx = 0\nfor a, b in AB:\n x -= a\n if x < 0:\n print('No')\n exit()\n x += b\nif x == 0:\n print('Yes')\nelse:\n print('No')\n", "n = int(input())\nL, R = [], []\nfor i in range(n):\n a, b = 0, 0\n for c in input():\n if c == '(':\n b += 1\n if c == ')':\n if b > 0:\n b -= 1\n else:\n a += 1\n if -a + b > 0:\n L.append((a, b))\n else:\n R.append((a, b))\nL.sort(key=lambda x: x[0])\nR.sort(key=lambda x: x[1], reverse=True)\nx = 0\nfor a, b in L + R:\n x -= a\n if x < 0:\n print('No')\n exit()\n x += b\nif x == 0:\n print('Yes')\nelse:\n print('No')\n"]
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s285883050', 's714398281', 's348956504']
[167276.0, 163860.0, 91756.0]
[2080.0, 2117.0, 1758.0]
[578, 470, 528]
p02687
u000513658
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["#A\ns = input()\n\nif s == ABC:\n print('ARC')\nelse:\n print('ABC')", "#A\ns = input()\n\nif s == ABC:\n print('ARC')\nelse:\n print('ABC')", "#A\ns = input()\n\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s253887373', 's808851720', 's553509764']
[8960.0, 9028.0, 9092.0]
[23.0, 22.0, 22.0]
[68, 68, 70]
p02687
u001839988
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = input()\n\nif S is "ABC":\n print("ARC")\nelse:\n print("ABC")', 'S = input()\n\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Wrong Answer', 'Accepted']
['s503834205', 's086670700']
[9092.0, 8956.0]
[21.0, 18.0]
[63, 63]
p02687
u004823354
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = str(input())\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")', 'S = input()\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s302496837', 's198799188']
[8832.0, 8916.0]
[21.0, 26.0]
[66, 62]
p02687
u007637377
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['from sys import stdin\ninput = stdin.readline\n\nfrom collections import deque\n\nX = int(input())\ns = {}\nq = deque()\n\nq.append([1, 0])\nwhile True:\n\tab = q.popleft()\n\ttmp = ab[0] ** 5 - ab[1] ** 5\n\tif (tmp == X):\n\t\tprint(ab[0], ab[1])\n\t\tquit()\n\telif (tmp > X):\n\t\tq.append([ab[0] - 1, ab[1]])\n\t\tq.append([ab[0], ab[1] - 1])\n\telse:\n\t\tq.append([ab[0] + 1, ab[1]])\n\t\tq.append([ab[0], ab[1] - 1])\n', "from sys import stdin\ninput = stdin.readline\n\ns = input()\n\nif s == 'ABC':\n\tprint('ARC')\nelse:\n\tprint('ABC')\n", "#from sys import stdin\n#input = stdin.readline\n\ns = input()\n\nif s == 'ABC':\n\tprint('ARC')\nelse:\n\tprint('ABC')\n"]
['Runtime Error', 'Wrong Answer', 'Accepted']
['s538892821', 's633076528', 's695815091']
[9432.0, 8996.0, 8996.0]
[22.0, 19.0, 24.0]
[387, 108, 110]
p02687
u007738720
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["S='ABC'\nif S='ABC':\n print('ARC')\nelse:\n print('ABC')", "S=input('S')\nif S='ABC':\n print('ARC')\nelse:\n print('ABC')", "S=input()\nif S is 'ABC':\n print('ARC')\nelse:\n print('ABC')", "S=input()\nif 'B' in S:\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s521902429', 's634709231', 's751792726', 's533727136']
[8960.0, 9012.0, 9028.0, 8904.0]
[23.0, 21.0, 21.0, 24.0]
[55, 60, 60, 58]
p02687
u015993380
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["s = input()\nprint('ABC' if s == 'ARC' else 'ABC')", "s = input()\nprint('ABC' if s == 'ARC' else 'ARC')"]
['Wrong Answer', 'Accepted']
['s576885905', 's277380140']
[8924.0, 9012.0]
[22.0, 23.0]
[49, 49]
p02687
u019355060
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S=input()split()\nif S=="ABC":\n print("ARC")\nelse:\n print("ABC")', '#A,B=map(input().split())\nS=input().split()\nif S=="ABC":\n print("ARC")\nelse:\n print("ABC")', 'S=input()\nif S=="ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s517198171', 's535829145', 's965539348']
[8828.0, 9028.0, 9024.0]
[21.0, 20.0, 22.0]
[69, 96, 62]
p02687
u020798319
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s = input().split()\nif s == "ABC":\n print("ARC")\nelif s == "ARC":\n print("ABC")\n ', 'S = str(input().split())\nif S == "ABC":\n print("ARC")\nelif S == "ARC":\n print("ABC")', 's = str, input().split()\nif s == "ABC":\n print("ARC")\nelif s == "ARC":\n print("ABC")', 'S = input()\nif S == "ABC":\n print("ARC")\nelse :\n print("ABC")']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted']
['s061680371', 's452704098', 's778633826', 's292029969']
[9008.0, 8864.0, 9028.0, 8996.0]
[24.0, 25.0, 24.0, 31.0]
[83, 86, 86, 63]
p02687
u021849254
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['if int(input())==ABC:\n print("ARC")\nelse :\n print("ABC")', 'if input()=="ABC":\n print("ARC")\nelse :\n print("ABC")']
['Runtime Error', 'Accepted']
['s759386904', 's718914329']
[9100.0, 9012.0]
[22.0, 25.0]
[58, 55]
p02687
u022658079
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S=list(map(int, input().split()))\nif S==\'ARC\':\n print("ABC")\nelse:\n print("ARC")', 'S=input()\nif S=="ARC":\n print("ABC")\nelse:\n print("ARC")']
['Runtime Error', 'Accepted']
['s198642053', 's800884477']
[9100.0, 9020.0]
[24.0, 22.0]
[82, 58]
p02687
u023632682
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["S = 'ABC' or 'ARC'\nprint(S)\n\nif (S == 'ABC'):\n print('ARC')\nelse:\n print('ABC')", "S = input()#ABC or ARC\n\nif (S == 'ABC'):\n print('ARC')\nelse:\n print('ABC')"]
['Wrong Answer', 'Accepted']
['s416011773', 's011223020']
[9024.0, 8980.0]
[23.0, 19.0]
[85, 80]
p02687
u025463382
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s = input()\nif s = "ABC":\n print("ARC")\nelse:\n print("ABC")', 's = input()\nif s == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s526645967', 's313156399']
[8880.0, 9024.0]
[20.0, 22.0]
[61, 62]
p02687
u029785897
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['last_name = input()\nlast_type = last_name[:3]\n\nif last_type == "ABC":\n return "ARC"\nelse:\n return "ABC"', 'last_name = input()\nlast_type = last_name[:3]\n \nif last_type == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s154242889', 's952098959']
[9004.0, 9012.0]
[23.0, 22.0]
[105, 106]
p02687
u030278108
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = str(input())\n\nif S == ABC:\n print("ARC")\nelse:\n print("ABC")', 'S = str(input())\n\nif S == \'ABC\':\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s647997107', 's117652189']
[9088.0, 9088.0]
[19.0, 19.0]
[66, 72]
p02687
u032798323
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = input()\n\nif S == ABC:\n print("ARC")\nelse:\n print("ABC")', 'S = input()\n\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s133307830', 's048245903']
[9028.0, 9036.0]
[23.0, 20.0]
[65, 67]
p02687
u035453792
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s=input()\nif s==ABC:\n print("ARC")\nelse:\n print("ABC")\n ', 's=input()\nif s=="ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s541574077', 's699039937']
[9004.0, 9036.0]
[19.0, 21.0]
[60, 58]
p02687
u038408819
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['x = int(input())\n\nfor i in range(1000):\n #for j in range(10)\n #print(i ** 5)\n for j in range(1000):\n #print(i ** 5 - j ** 5)\n if i ** 5 - j ** 5 == x:\n print(i, j)\n quit()\n elif i ** 5 - (-j) ** 5 == x:\n print(i, -j)\n quit()\n elif (-i) ** 5 - j ** 5 == x:\n print(-i, j)\n quit()\n elif (-i) ** 5 - (-j) ** 5 == x:\n print(-i, -j)\n quit()\n', "s = input()\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Accepted']
['s793761377', 's865948092']
[9136.0, 9028.0]
[22.0, 22.0]
[467, 66]
p02687
u039189422
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['from sys import exit\n\nx=int(input())\nfor i in range(0,201):\n\tfor j in range(-200,i):\n\t\tif i**5-j**5==x:\n\t\t\tprint(i,j)\n\t\t\texit()', 's=input()\nif s=="ABC":\n\tprint("ARC")\nelse:\n\tprint("ABC")']
['Runtime Error', 'Accepted']
['s928228548', 's317663284']
[9028.0, 9024.0]
[22.0, 23.0]
[127, 56]
p02687
u042209706
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")\n', 'if S == "ABC":\n return "ARC"\nelse:\n return "ABC"', 'S = input()\nif S == "ABC":\n print "ARC"\nelse:\n print "ABC"', 'S = input()\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s085386721', 's090717114', 's452944787', 's697305803']
[9000.0, 9004.0, 8940.0, 9004.0]
[22.0, 23.0, 22.0, 20.0]
[52, 50, 60, 62]
p02687
u042347918
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['N, M = list(map(int, input().split()))\n\nH = list(map(int, input().split()))\n\nans = [1]*N\n\nfor i in range(M):\n A, B = list(map(int, input().split()))\n if H[A-1] > H[B-1]:\n ans[B-1] = 0\n elif H[A-1] < H[B-1]:\n ans[A-1] = 0\n else:\n ans[A-1] = 0\n ans[B-1] = 0\n\nprint(sum(ans))', 'import sys\nS = input()\n\nif S == "ABC":\n print("ARC")\n sys.exit()\nelse:\n print("ABC")\n sys.exit()\n']
['Runtime Error', 'Accepted']
['s334172824', 's022083392']
[9140.0, 9076.0]
[21.0, 31.0]
[312, 109]
p02687
u047502873
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = input("ABC")\nif S == \'ABC\':\n print(\'ARC\')\nelse:\n print(\'ABC\')', "S = input()\nif S == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Wrong Answer', 'Accepted']
['s615454946', 's815018182']
[8956.0, 9028.0]
[24.0, 25.0]
[71, 66]
p02687
u047719604
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['n,m = map(int,input().split())\nheight = list(map(int,input().split()))\nlst = [0]*n\nfor j in range(m):\n x,y = map(int,input().split())\nif height[x-1] >= height[y-1]:\n lst[y-1] = 1\nif height[x-1] <= height[y-1]:\n lst[x-1] = 1\nprint(lst.count(0))', 'n,m = map(int,input().split())\nheight = list(map(int,input().split()))\nlst = [0]*n\nfor j in range(m):\n x,y = map(int,input().split())\n if height[x-1] >= height[y-1]:\n lst[y-1] = 1\n if height[x-1] <= height[y-1]:\n lst[x-1] = 1\nprint(lst.count(0))', 's = input()\nif s == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Runtime Error', 'Accepted']
['s564027244', 's820756082', 's046430563']
[9084.0, 9080.0, 8916.0]
[19.0, 21.0, 24.0]
[252, 264, 62]
p02687
u048521352
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s=str(input())\nprint(s)', 's=str(input())\nif s ="ARC":\n print("ABC")\nelse:\n print("ARC")', 's=str(input())\nif s =="ARC":\n print("ABC")\nelse:\n print("ARC")']
['Wrong Answer', 'Runtime Error', 'Accepted']
['s470704180', 's961283069', 's436354768']
[9012.0, 8880.0, 9092.0]
[21.0, 23.0, 18.0]
[23, 63, 64]
p02687
u049679412
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["s = input()\nif s == 'ABC:\n\tprint('ARC')\nelse:\n\tprint('ABC') ", "s = input()\nif s == 'ABC':\n\tprint('ARC')\nelse:\n\tprint('ABC') "]
['Runtime Error', 'Accepted']
['s450803666', 's970365042']
[8900.0, 9068.0]
[19.0, 21.0]
[61, 62]
p02687
u051331793
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["s = int(input())\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')", "s = input()\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Accepted']
['s938396958', 's279809752']
[9028.0, 9024.0]
[22.0, 21.0]
[67, 62]
p02687
u051684204
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S=input()\nif S="ABC":\n print("ARC")\nelif S="ARC":\n print("ABC")', 'S=input()\nif S=="ABC":\n print("ARC")\nelif S=="ARC":\n print("ABC")']
['Runtime Error', 'Accepted']
['s554356027', 's884437431']
[8948.0, 9084.0]
[24.0, 24.0]
[65, 67]
p02687
u053699292
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["if __name__ == '__main__':\n\tS = input()\n\tif S =='ABC':\n\t\tprint('SRC')\n\telse:\n\t\tprint('ABC')\n\t", "if __name__ == '__main__':\n\tS = input()\n\tif S =='ABC':\n\t\tprint('ARC')\n\telse:\n\t\tprint('ABC')\n\t"]
['Wrong Answer', 'Accepted']
['s449829666', 's938211560']
[9016.0, 8976.0]
[22.0, 21.0]
[93, 93]
p02687
u054825571
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S=input()\nprint("ABC" if S!="ABC" else S)', 'S=input()\nprint(S if S!="ABC" else "ABC")', 'S=input()\nprint("ARC" if S=="ABC" else "ABC")']
['Wrong Answer', 'Wrong Answer', 'Accepted']
['s307087036', 's666278896', 's771387192']
[9020.0, 9024.0, 9052.0]
[28.0, 29.0, 30.0]
[41, 41, 45]
p02687
u055220405
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s = input()\nif(s[1] == "R"):\n print("ABC")\n else:\n print("ARC")\n ', 's = input()\nif(s[1] == "R"):\n print("ABC")\nelse:\n print("ARC")']
['Runtime Error', 'Accepted']
['s246038197', 's042982083']
[8896.0, 8920.0]
[21.0, 25.0]
[68, 64]
p02687
u055244973
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["S = str(input())\nif S == 'ABC'\n\tprint('ARC')\nelse S == 'ARC'\n\tprint('ABC')", "S = str(input())\nif S == 'ABC'\n\tprint('ARC')\nelif S == 'ARC'\n\tprint('ABC')", "S = str(input())\nif S == 'ABC'\n\tprint('ARC')\nelse S == 'ARC'\n\tprint('ABC')", "S = str(input())\nif S == 'ABC'\n\tprint('ARC')\nelse\n\tprint('ABC')", "S = str(input())\nif S == 'ABC':\n\tprint('ARC')\nelse:\n\tprint('ABC')"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s073631344', 's628023251', 's951890461', 's981050383', 's377678106']
[9012.0, 8788.0, 8892.0, 8948.0, 8964.0]
[23.0, 19.0, 19.0, 22.0, 19.0]
[74, 74, 74, 63, 65]
p02687
u055668007
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["import sys\ninput = sys.stdin.readline\n\nstrA = str(input())\n\nif strA == 'ABC':\n print('ARC')\nelif strA == 'ARC':\n print('ABC')\nelse:\n print('')", "import sys\ninput = sys.stdin.readline\n\nhoge = str(input())\n\nif hoge == 'ARC':\n print('ABC')\nelif hoge == 'ABC':\n print('ARC')", "import sys\ninput = sys.stdin.readline\n\nstrA = str(input())\n\n\nif strA == 'ABC':\n print('ARC')\nelif strA == 'ARC':\n print('ABC')\n", "import sys\ninput = sys.stdin.readline\n\nstrA = str(input())\n\nif strA == 'ABC':\n print('ARC')\nelse:\n print('ABC')\n", "import sys\ninput = sys.stdin.readline\n\nstrA = str(input())\n\nif strA == 'ABC':\n print('ARC')\nelif strA == 'ARC':\n print('ABC')\nelse\n print('')", "import sys\ninput = sys.stdin.readline\n\nstrA = str(input())\n\nif strA == 'ABC':\n print('ARC')\nif strA == 'ARC':\n print('ABC')\n", 'import sys\n\nimport math\ninput = sys.stdin.readline\n\nhoge = str(input().strip())\nif hoge == "ABC":\n print("ARC".strip())\nif hoge == "ARC":\n print("ABC".strip())']
['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted']
['s078695632', 's141565636', 's275440890', 's454040238', 's721212160', 's816963863', 's449036960']
[8964.0, 8972.0, 8956.0, 8956.0, 8956.0, 9028.0, 8920.0]
[22.0, 23.0, 24.0, 21.0, 23.0, 24.0, 20.0]
[145, 127, 142, 114, 144, 126, 167]
p02687
u057065089
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['N = int(input())\np = list(map(int, input().split()))\nsum = [i + 1 + x for i, x in enumerate(p)]\ndif = [i + 1 - x for i, x in enumerate(p)]\nans = 0\n\nfor i in range(N):\n ans += sum.count(dif[i])\n\nprint(ans)', 'S = input()\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s446760208', 's409493813']
[9192.0, 9032.0]
[19.0, 20.0]
[207, 66]
p02687
u058063801
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = "ABC"\nS = "ARC"', 'if S = "ABC":\n print "ARC"\nelse:\n print "ABC"', 'S = "ABC" or "ARC"', 'ABC = S\nARC = S', 'if S = "ABC"{\n print("ARC")\n}else{\n print("ABC")\n ', 'S = input()\n\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted']
['s113563255', 's218179867', 's258455309', 's744877870', 's851539210', 's229479243']
[9100.0, 8844.0, 9012.0, 8976.0, 8920.0, 9032.0]
[21.0, 20.0, 21.0, 23.0, 23.0, 24.0]
[19, 47, 18, 15, 64, 63]
p02687
u058264533
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['\nn = input()\n\nif n == ABC:\n print("ARC")\nelse:\n print("ABC")', '\nn = input()\n\nif n == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s188891405', 's179381704']
[9088.0, 8960.0]
[24.0, 20.0]
[66, 68]
p02687
u058496530
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['x = input()\n\nif x = "ABC":\n print("ARC")\nelse:\n print("ABC")', 'x = input()\n\nif x == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s455023635', 's542941372']
[8876.0, 9020.0]
[27.0, 22.0]
[62, 63]
p02687
u060012100
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s = input().split()\nif(s = \'ABC\'):\n print("ARC")\nelse:\n print("ABC")', 's= map.input()\nif(s == "ABC"):\n print("ARC")\nelse:\n print("ABC")', 's= input()\nif(s == "ABC"):\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Runtime Error', 'Accepted']
['s638755210', 's961266619', 's547180919']
[8992.0, 8628.0, 9028.0]
[24.0, 24.0, 20.0]
[70, 66, 62]
p02687
u060793972
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["printt('ARC' if input()=='ABC' else 'ABC')", 'x = int(input())\nfor i in range(-102,103):\n for j in range(-102,103):\n if (i**5)-(j**5)==x:\n print(i,j)\n exit()\n', 'mycode', "print('ARC' if input()=='ABC' else 'ABC')"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s035402065', 's118863138', 's755228423', 's957158839']
[8788.0, 9160.0, 9008.0, 8972.0]
[22.0, 24.0, 24.0, 26.0]
[42, 144, 6, 41]
p02687
u063346608
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['for okashi_number in range(k):\n\tdi = int(input())\n\tD = map(int,input().split())\n\tfor x in range(di)\n\t\tA[[x]-1] = 1\n\nfor i in range(N):\n\tif A[i] == 0:\n\tprint(A[i])\n', 'S = input()\n\nif S == "ABC":\n\tprint("ARC")\nelse:\n\tprint("ABC")']
['Runtime Error', 'Accepted']
['s136535961', 's753728124']
[8832.0, 8908.0]
[27.0, 27.0]
[163, 61]
p02687
u067095357
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['n, m = list(map(int, input().split()))\nhs = list(map(int, input().split()))\nans = [1]*n\nfor i in range(m):\n road = list(map(int, input().split()))\n if hs[road[0]-1] <= hs[road[1]-1]:\n ans[road[0]-1] = 0\n if hs[road[0]-1] >= hs[road[1]-1]:\n ans[road[1]-1] = 0\nprint(ans.count(0))\n', 's = input()\nif s == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Runtime Error', 'Accepted']
['s126735899', 's005928674']
[9172.0, 9116.0]
[20.0, 24.0]
[302, 66]
p02687
u067986264
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['x = int(input())\nfor a in range(-10000, 10000):\n for b in range(-1000, 1000):\n if a**5 - b**5 == x:\n print(a, b)\n quit()', 'x = int(input())\nfor a in range(-1000, 1000):\n for b in range(-1000, 1000):\n if a**5 - b**5 == x:\n print(a, b)\n quit()', "s = input()\nprint('ABC' if s == 'ARC' else 'ARC')\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s229062961', 's769678711', 's609998236']
[9052.0, 9060.0, 9024.0]
[20.0, 25.0, 23.0]
[152, 150, 50]
p02687
u069273180
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s=input()\n\nif s == "ABC":\n print(s)\nelse:\n print("ARC")\n', 's=input()\n \nif s == "ARC":\n print("ABC")\nelse:\n print("ARC")']
['Wrong Answer', 'Accepted']
['s749516870', 's493465866']
[9016.0, 9028.0]
[19.0, 22.0]
[58, 62]
p02687
u071829175
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = input()\nx == ARC\nif S == ARC:\n x == ABC\nprint(x)', 'S = input()\nx = "ARC"\nif S == "ARC":\n x = "ABC"\nprint(x)']
['Runtime Error', 'Accepted']
['s034844566', 's508502457']
[8896.0, 9016.0]
[20.0, 24.0]
[53, 57]
p02687
u072284094
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["if(input().rstrip() == 'ABC':\n print('ARC')\nelse:\n print('ABC')\t", "if(input().rstrip() == 'ABC'):\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Accepted']
['s369372713', 's769076276']
[9020.0, 9044.0]
[20.0, 26.0]
[68, 70]
p02687
u073800107
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['string = input()\nprint(string)', 'string = input()\n\nif string == "ABC":\n print("ARC")\nelse:\n print("ABC")']
['Wrong Answer', 'Accepted']
['s517435203', 's360288220']
[8768.0, 8960.0]
[29.0, 30.0]
[30, 73]
p02687
u075303794
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["S = input()\nif S == 'ABC':\n print('ARC')\nelif S == 'ARC'):\n print('ARC')", "S = input()\n\nif S == 'ARC':\n print('ABC')\nelif S == 'ABC':\n print('ARC')"]
['Runtime Error', 'Accepted']
['s779260843', 's742114323']
[8892.0, 8912.0]
[21.0, 20.0]
[74, 74]
p02687
u075304271
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['mport itertools\nimport math\n\ndef solve():\n s = input()\n if s == "ABC":\n print("ARC")\n else:\n print("ABC")\n return 0\n\n \nif __name__ == "__main__":\n solve()\n', 'def solve():\n s = input()\n if s == "ABC":\n print("ARC")\n else:\n print("ABC")\n return 0\n\n \nif __name__ == "__main__":\n solve()\n']
['Runtime Error', 'Accepted']
['s351201362', 's554874254']
[8944.0, 8956.0]
[19.0, 22.0]
[166, 137]
p02687
u075595666
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['x = int(input())\ndef factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n if temp!=1:\n arr.append([temp, 1])\n if arr==[]:\n arr.append([n, 1])\n return arr\n\nc = factorization(x)\n#print(c)\nchk = False\nfor i in c:\n if chk:\n break\n s,t = i\n #print(s)\n for i in range(130):\n if (i+s)**5-i**5 > x:\n break\n if (i+s)**5-i**5 == x:\n ans = (i+s,i)\n chk = True\n break\n for i in range(1,100):\n j = -1*i\n #print(j+s,j)\n if (j+s)**5-j**5 > x:\n break \n if (j+s)**5-j**5 == x:\n ans = (j+s,j)\n chk = True\n break \n \nprint(*ans)\n', 'x = int(input())\nif x == 1:\n print(0,-1)\n exit()\n \ndef divisorize(fct):\n b, e = fct.pop() \n pre_div = divisorize(fct) if fct else [[]]\n suf_div = [[(b, k)] for k in range(e + 1)]\n return [pre + suf for pre in pre_div for suf in suf_div]\n\n\ndef factorize(n):\n fct = [] \n b, e = 2, 0 \n while b * b <= n:\n while n % b == 0:\n n = n // b\n e = e + 1\n if e > 0:\n fct.append((b, e))\n b, e = b + 1, 0\n if n > 1:\n fct.append((n, 1))\n return fct\n\n\ndef num(fct):\n a = 1\n for base, exponent in fct:\n a = a * base**exponent\n return a\n\nc = []\nfct = factorize(x)\nfor div in divisorize(fct):\n c.append(num(div))\n \nchk = False\nfor s in c:\n if chk:\n break\n for i in range(1000):\n if (i+s)**5-i**5 > x:\n break\n if (i+s)**5-i**5 == x:\n ans = (i+s,i)\n chk = True\n break\n if s <1000: \n for p in range(s,1000):\n j = -1*p\n #print(s,(j+s)**5-j**5)\n if (j+s)**5-j**5 > x:\n break \n if (j+s)**5-j**5 == x:\n ans = (j+s,j)\n chk = True\n break \n for ww in range(1,(s+1)//2):\n jj = -1*ww\n if (jj+s)**5-jj**5 > x:\n break \n if (jj+s)**5-jj**5 == x:\n ans = (jj+s,jj)\n chk = True\n break \nprint(*ans)\n', "s = input()\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')\n"]
['Runtime Error', 'Runtime Error', 'Accepted']
['s554675057', 's900370472', 's631293679']
[9116.0, 9328.0, 9020.0]
[20.0, 21.0, 23.0]
[792, 1342, 63]
p02687
u080685822
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['s = input()\nif s == "ARC":\n\tprint("ABC")\nelif s == "ABC":\n print("ARC")\nelse:\n break', 's = input()\nif s == "ARC":\n\tprint("ABC")\nelse:\n print("ARC")']
['Runtime Error', 'Accepted']
['s096915920', 's799848212']
[9024.0, 9092.0]
[22.0, 20.0]
[90, 63]
p02687
u082861480
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["print('ABC' if input() == 'ARS' else 'ARS')", "print('ABC' if input() == 'ARC' else 'ARC')\n"]
['Wrong Answer', 'Accepted']
['s896232554', 's914211685']
[9068.0, 9064.0]
[21.0, 25.0]
[43, 44]
p02687
u085186789
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S =map(int, input().split(""))\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")\n', 'S =map(int, input().split())\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")', 'S =input()\nif str(S) = "ABC":\n print("ARC")\nelse:\n print("ABC")\n', 'S =input()\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")\n', "s=input()\n\nif s.find('B')==1:\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s199363854', 's274997590', 's768426341', 's815606176', 's758404436']
[8884.0, 8836.0, 8880.0, 8784.0, 9092.0]
[23.0, 29.0, 23.0, 24.0, 26.0]
[81, 78, 66, 61, 65]
p02687
u089121621
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['import numpy as np\nargList = list(map(int, input().split())) \nheights = list(map(int, input().split())) \n\n\ncheck = np.array([1]*argList[0])\n\nfor n in range(argList[1]):\n \n con = list(map(int, input().split())) \n \n if heights[con[0]-1] <= heights[con[1]-1]:\n check[con[0]-1] = 0\n if heights[con[0]-1] >= heights[con[1]-1]:\n check[con[1]-1] = 0\nprint(np.sum(check))', "s = input()\nif( s == 'ABC'):\n print('ARC')\n \nif( s == 'ARC'):\n print('ABC')"]
['Runtime Error', 'Accepted']
['s805632498', 's768324346']
[27048.0, 8944.0]
[105.0, 19.0]
[500, 77]
p02687
u091412190
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S = input()\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")', 'S == input()\nif S = "ABC":\n print("ARC")\nelse:\n print("ABC")', 'S = input()\nif S == "ABC":\n print("ARC")\nelse:\n print("ABC")\n']
['Runtime Error', 'Runtime Error', 'Accepted']
['s588739198', 's856528079', 's108260918']
[8936.0, 8824.0, 8960.0]
[23.0, 21.0, 19.0]
[61, 62, 63]
p02687
u091489347
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["if s == 'ABC':\n print('ARC')\nelse:\n print('ABC')", "s = input()\nif s == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Accepted']
['s468265607', 's421276794']
[9084.0, 9028.0]
[21.0, 19.0]
[54, 66]
p02687
u095844416
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["s=str(input())\nif s[1]==B:\n\tprint('ARC')\nelse:\n\tprint('ABC')", "s=str(input())\nif s[1]=='B':\n\tprint('ARC')\nelse:\n\tprint('ABC')"]
['Runtime Error', 'Accepted']
['s862044321', 's378549572']
[8960.0, 9028.0]
[23.0, 22.0]
[60, 62]
p02687
u097069712
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['S == input()\nif S == "ABC":\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = int(input())\nif S == "ABC"\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = map(int, input().split())\nif S = ABC\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = input()\nif S = "ABC"\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S == input()\nif S == "ABC" \n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = map(int, input().split())\nif S == ABC\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = int(put())\nif S == "ABC"\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = map(int, input().split())\nif S = ABC\n\tprint("ABC")\nelse:\n \tprint("ARC")\n', 'S = map(int, input().split())\nif S == "ABC"\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = input()\nif S == "ABC"\n\tprint("ARC")\nelse:\n \tprint("ABC")', 'S = input()\nif S == "ABC":\n\tprint("ARC")\nelse:\n \tprint("ABC")']
['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted']
['s064110411', 's240877945', 's242016566', 's276284282', 's524605014', 's546184195', 's677033016', 's706507709', 's936450015', 's939504843', 's887923468']
[8972.0, 9008.0, 9008.0, 8956.0, 8904.0, 8876.0, 9012.0, 8948.0, 9012.0, 8948.0, 8852.0]
[21.0, 22.0, 23.0, 21.0, 22.0, 20.0, 20.0, 24.0, 22.0, 23.0, 18.0]
[63, 66, 76, 60, 63, 77, 64, 77, 79, 61, 62]
p02687
u098848480
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
['# coding: utf-8\n\nX = int(input())\nflg = 0\nfor A in range(-100, 100):\n for B in range(-80, 80):\n if A ** 5 - B ** 5 == X:\n print(f"{A} {B}")\n flg = 1\n break\n if flg:\n break\n', '# coding: utf-8\n\nS = input()\narc = "ABR"\nabc = "ABC"\nif S == arc:\n print(abc)\nelif S == abc:\n print(arc)\n', '# coding: utf-8\n\nS = input()\narc = "ARC"\nabc = "ABC"\nif S == arc:\n print(abc)\nelif S == abc:\n print(arc)\n']
['Runtime Error', 'Wrong Answer', 'Accepted']
['s048147114', 's777789201', 's197223546']
[9168.0, 9092.0, 8912.0]
[19.0, 21.0, 20.0]
[225, 111, 111]
p02687
u100277898
2,000
1,048,576
AtCoder Inc. holds a contest every Saturday. There are two types of contests called ABC and ARC, and just one of them is held at a time. The company holds these two types of contests alternately: an ARC follows an ABC and vice versa. Given a string S representing the type of the contest held last week, print the string representing the type of the contest held this week.
["S = input()\nif S = 'ABC':\n print('ARC')\nelse:\n print('ABC')", "S = input()\nif S == 'ABC':\n print('ARC')\nelse:\n print('ABC')"]
['Runtime Error', 'Accepted']
['s558304279', 's593792682']
[8948.0, 9028.0]
[22.0, 21.0]
[61, 62]