TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools
n=int(input())
a=[]
for i in range(n):
    a.append(i+1)
b=[]
for per in itertools.permutatiton(a):
    b.append(list(per))
c=b.index(list(map(int,input().split())))
d=b.index(list(map(int,input().split())))
print(abs(c-d))

import itertools
n=int(input())
a=[]
for i in range(n):
    a.append(i+1)
b=[]
for per in itertools.permutations(a):
    b.append(list(per))
c=b.index(list(map(int,input().split())))
d=b.index(list(map(int,input().split())))
print(abs(c-d))

Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools

N = int(input())
P_ar = list(map(int,input().split()))
Q_ar = list(map(int,input().split()))

List = list(map(list,list(itertools.permutations(range(N)))))

for i in range(N):
  P_ar[i]-=1
  Q_ar[i]-=1

a=-1
b=-1

for i in range(len(List)):
  if List[i]==P_ar:
    a=i
    break

for i in range(len(List)):
  if List[i]==Q_ar:
    b=i
    break


import itertools

N = int(input())
P_ar = list(map(int,input().split()))
Q_ar = list(map(int,input().split()))

List = list(map(list,list(itertools.permutations(range(N)))))

for i in range(N):
  P_ar[i]-=1
  Q_ar[i]-=1

a=-1
b=-1

for i in range(len(List)):
  if List[i]==P_ar:
    a=i
    break

for i in range(len(List)):
  if List[i]==Q_ar:
    b=i
    break

print(abs(a-b))

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
from itertools import permutations

n = int(input)
p = list(map(int, input().split()))
q = list(map(int, input().split()))

allp = p.copy()
allp.sort()
allperms = list(map(list, permutations(allp)))
print(abs(allperms.index(p) - allperms.index(q))) 

from itertools import permutations

n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

allp = p.copy()
allp.sort()
allperms = list(map(list, permutations(allp)))
print(abs(allperms.index(p) - allperms.index(q))) 


Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):

Python 3 
File
Edit
View
Insert
Cell
Kernel
Widgets
Help

import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
arrayp=[1]
for iii in range(n-1):
    arrayp+=[1]
arrayq=[1]
for jjj in range(n-1):
    arrayq+=[1]
pnum=0
qnum=0
for i in range(n-1):
    prank=0
    for ii in range(p[i]):
        if arrayp[ii]==1:
            prank+=1
    pnum=pnum+(prank-1)*math.factorial(n-i-1)
    arrayp[p[i]-1]=0
for j in range(n-1):
    qrank=0
    for jj in range(q[j]):
        if arrayq[jj]==1:
            qrank+=1
    qnum=qnum+(qrank-1)*math.factorial(n-j-1)
    arrayq[q[j]-1]=0
print(abs(pnum-qnum))
8

import math
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
arrayp=[1]
for iii in range(n-1):
    arrayp+=[1]
arrayq=[1]
for jjj in range(n-1):
    arrayq+=[1]
pnum=0
qnum=0
for i in range(n-1):
    prank=0
    for ii in range(p[i]):
        if arrayp[ii]==1:
            prank+=1
    pnum=pnum+(prank-1)*math.factorial(n-i-1)
    arrayp[p[i]-1]=0
for j in range(n-1):
    qrank=0
    for jj in range(q[j]):
        if arrayq[jj]==1:
            qrank+=1
    qnum=qnum+(qrank-1)*math.factorial(n-j-1)
    arrayq[q[j]-1]=0
print(abs(pnum-qnum))

Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import math
n=int(input())
p=list(input().split())
q=list(input().split())
cntp=0
cntq=0
for i in range(n-2):
  cntp+=(int(p[0])-1)*math.factorial(n-i-1)
  cntq+=(int(q[0])-1)*math.factorial(n-i-1)
print(abs(cntp-cntq))

import itertools
n=int(input())
p=''.join(list(input().split()))
q=''.join(list(input().split()))
l=[]
for a in itertools.permutations(range(1,n+1),n):
  l.append(a)
ip=l.index(p)
iq=l.index(q)
print(abs(ip-iq))

import math
n=int(input()
p=list(input().split())
q=list(input().split())
cntp=0
cntq=0
for i in range(n-2):
  cntp+=(p[0]-1)*math.factorial(n-i-1)
  cntq+=(q[0]-1)*math.factorial(n-i-1)
print(abs(cntp-cntq))

import itertools
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
l=[]
for a in itertools.permutations(range(1,n+1),n):
  l.append(a)
ip=l.index(tuple(p))
iq=l.index(tuple(q))
print(abs(ip-iq))

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
n=int(input())
a=map(int,input().split())
import copy
import itertools
c = itertools.permutations(a, n)
#c=copy.copy(a).sort()
b=map(int,input().split())
print(a)
print(b)
print(c)


n=int(input())
a=[0]*n
b=[0]*n
a[:]=map(int,input().split())
import itertools
c=list(itertools.permutations(a, n))
c.sort()
b[:]=map(int,input().split())
a=tuple(a)
b=tuple(b)
"""
print(a)
print(b)
print(c)
"""
print(abs(c.index(a)-c.index(b)))


Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
n_list = [i for i in range(1,N+1)]
n_perm = sorted(list(itertools.permutations(n_list, N)))
a = 0
b = 0

for i in range(N):
    if list(n_perm[i]) == P:
        a = i
        break

for k in range(N):
    if list(n_perm[k]) == Q:
        b = k
        break
        
print(abs(a-b))    

from itertools import permutations
n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))
P=sorted(list(permutations(range(1,n+1),n)))
print(abs(P.index(p)-P.index(q)))

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))


import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.pop(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))


import math
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
lis1 = [i for i in range(1,N+1)]
lis2 = [i for i in range(1,N+1)]
def number(a, lis):
  total_order = 1
  for i in range(N):
    tmp_order = lis.index(a[i])
    lis.remove(a[i])
    total_order += tmp_order * math.factorial(len(lis))
  return total_order
print(abs(number(P, lis1) - number(Q, lis2)))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools
n=int(input())
l=list(itertools.permutations(range(1,n+1),n))

a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
a_index=0
b_index=0

for i in range(len(l)):
    print(l[i])
    if l[i]==a:
        a_index=i+1
    elif l[i]==b:
        b_index=i+1
    else:
        continue

result=abs(a_index-b_index)
print(result)

import itertools
n=int(input())
l=list(itertools.permutations(range(1,n+1),n))

a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))
a_index=0
b_index=0

for i in range(len(l)):
    if l[i]==a:
        a_index=i+1
    elif l[i]==b:
        b_index=i+1
    else:
        continue
if a_index==0 or b_index==0:
    print(0)
else:    
    result=abs(a_index-b_index)
    print(result)

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

index = []

for i, s in enumerate(itertools.permutations(range(1, n+1),n)):
    if s == p or s == q:
        index.append(i)

if not index:
    print(abs(index[0]-index[1]))
else:
    print('0')




import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

index = []

for i, s in enumerate(itertools.permutations(range(1, n+1),n)):
    if s == p or s == q:
        index.append(i)

print(len(index))

if len(index) == 2:
    print(abs(index[0]-index[1]))
else:
    print('0')




import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

index = []

for i, s in enumerate(itertools.permutations(range(1, n+1),n)):
    if s == p or s == q:
        index.append(i)

print(len(index))

if len(index) != 2:
    print(abs(index[0]-index[1]))
else:
    print('0')




import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

index = []

for i, s in enumerate(itertools.permutations(range(1, n+1),n)):
    if s == p or s == q:
        index.append(i)


if len(index) == 2:
    print(abs(index[0]-index[1]))
else:
    print('0')




Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)
    
def check_order(k):
    res = 0
    for _ in range(n):
        if len(k) == 1:
            break
        s = k[0]
        c = 0
        for i in k:
            if s >= i:
                 c += 1
        k.pop(0)
        res += math.factorial(c-1)
    return res

p_order = check_order(p)
q_order = check_order(q)

print(abs(p_order-q_order))

import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def check_order(k):
    res = 0
    for _ in range(n):
        if len(k) == 1:
            break
        s = k[0]
        c = 0
        for i in k:
            if s >= i:
                 c += 1
        k.pop(0)
        res += math.factorial(len(k)) * (c-1)
    return res

p_order = check_order(p)
q_order = check_order(q)

print(abs(p_order-q_order))

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
N = int(input())
P = list(map(int, input().split()))
Q=list(map(int, input().split()))
l = [i for i in range(N)]

fac = [0] * 8
fac[1] = 1
for i in range(2, N):
    fac[i] = i * fac[i - 1]
print(fac)
a = 0
l = list(range(1, N + 1))
for i in range(N):
    a += l.index(P[i]) * fac[len(l) - 1]
    print(l.index(P[i]), fac[len(l) - 1])
    l.remove(P[i])

b = 0
l = list(range(1, N + 1))
for i in range(N):
    b += l.index(Q[i]) * fac[len(l) - 1]
    l.remove(Q[i])

print(abs(a-b))

N = int(input())
P = list(map(int, input().split()))
Q=list(map(int, input().split()))
l = [i for i in range(N)]

fac = [0] * 8
fac[1] = 1
for i in range(2, N):
    fac[i] = i * fac[i - 1]

a = 0
l = list(range(1, N + 1))
for i in range(N):
    a += l.index(P[i]) * fac[len(l) - 1]
    l.remove(P[i])

b = 0
l = list(range(1, N + 1))
for i in range(N):
    b += l.index(Q[i]) * fac[len(l) - 1]
    l.remove(Q[i])

print(abs(a-b))

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools

n = int(input())
p = tuple(map(int, input().split())
q = tuple(map(int, input().split())

l = list(itertools.permutations(range(1, n+1)))
a = l.index(p)
b = l.index(q)

print(abs(a-b))

import itertools
 
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
 
l = list(itertools.permutations(range(1, n+1)))
a = l.index(p)
b = l.index(q)
 
print(abs(a-b))

Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools

n = int(input())
p = [i for i in map(int, input().split())]
q = [i for i in map(int, input().split())]

sorted_list = sorted(p)
all_list = []

def listExcludedIndices(data, indices=[]):
	return [x for i, x in enumerate(data) if i not in indices]

def permutationListRecursive(data, r):
	if r <= 0 or r > len(data):
		return []
	
	result = []
	_permutationListRecursive(data, r, [], result)
	return result

def _permutationListRecursive(data, r, progress, result):
	if r == 0:
		result.append(progress)
		return
	
	for i in range(len(data)):
		_permutationListRecursive(listExcludedIndices(data, [i]), r - 1, progress + [data[i]], result)


a = -1
b = -1

for i, list_ in enumerate(permutationListRecursive(sorted_list, n)):
	#print(list_)
	if list_ == p:
		a = i

	if list_ == q:
		b = i

	if a != -1 and b != -1:
		break

print(abs(a-b))


Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
n=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]
import itertools
ct=1
for c in itertools.permutations(range(n),n):
  c=list(c)
  for i in range(n):
    if P[i]-1==c[i]:
      continue
    else:
      break
  else:
    a=ct
  for i in range(n):
    if Q[i]-1==c[i]:
      continue
    else:
      break
  else:
    b=ct
  ct+=1
print(a-b)




n=int(input())
P=[int(i) for i in input().split()]
Q=[int(i) for i in input().split()]
import itertools
ct=1
for c in itertools.permutations(range(n),n):
  c=list(c)
  for i in range(n):
    if P[i]-1==c[i]:
      continue
    else:
      break
  else:
    a=ct
  for i in range(n):
    if Q[i]-1==c[i]:
      continue
    else:
      break
  else:
    b=ct
  ct+=1
print(abs(a-b))




Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l = list(range(1,n+1))
dic = {}

for i,j in enumerate(itertools.permutations(l)):
    dic[j] = i+1
print(abs(dic[p]-dic[q]))

import itertools
 
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

l = list(range(1,n+1))
dic = {}

for i,j in enumerate(itertools.permutations(l)):
    dic[j] = i+1
print(abs(dic[p]-dic[q]))

Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools
import math
n = int(input())
p = input().split()
q = input().split()

p_mojiretu = ""
q_mojiretu = ""

for x in p:
    p_mojiretu += x
for x in q:
    q_mojiretu += x

print(p_mojiretu)
print(q_mojiretu)

cnt = 1
index_a = 0
index_b = 0

for i in itertools.permutations(range(1, n+1)):
    s = "".join(str(x) for x in i)
    print(s)
    if s == p_mojiretu:
        index_a = cnt
    if s == q_mojiretu:
        index_b = cnt
    cnt += 1
print(abs(index_a - index_b))


import itertools
import math
n = int(input())
p = input().split()
q = input().split()

p_mojiretu = ""
q_mojiretu = ""

for x in p:
    p_mojiretu += x
for x in q:
    q_mojiretu += x


cnt = 1
index_a = 0
index_b = 0

for i in itertools.permutations(range(1, n+1)):
    s = "".join(str(x) for x in i)
    if s == p_mojiretu:
        index_a = cnt
    if s == q_mojiretu:
        index_b = cnt
    cnt += 1
print(abs(index_a - index_b))


Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import math
import itertools

n = int(input())
p_list = list(map(int, input().split()))
q_list = list(map(int, input().split()))
num_list = []
num = 0
a = 0
b = 0

for i in itertools.permutations(range(1,n+1)):
    num_list = list(i)
    num += 1
    if num_list == p_list:
        a = num
    if num_list == q_list:
        b = num

print(math.fabs(a-b))

import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

num_list = list(itertools.permutations(range(1,n+1)))

print(abs(num_list.index(p)-num_list.index(q)))

Verdicts: Wrong Answer

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):
import itertools


def checkArrays(arr1, arr2):
    if len(arr1) != len(arr2):
        return False

    for i in range(len(arr1)):
        if arr1[i] != arr2[i]:
            return False

    return True


n = int(input())

arrays = list(itertools.permutations([i for i in range(1, n + 1)]))

p = list(map(int, input().split()))
q = list(map(int, input().split()))

a = b = 1
for i in range(len(arrays)):
    ar = list(arrays[i])
    if checkArrays(ar, p):
        a = i + 1
    if checkArrays(ar, q):
        b = i + 1

print(abs(a, b))



import itertools

n = int(input())

array = [i for i in range(1, n + 1)]
gen_array = itertools.permutations(array, n)

a = list(map(int, input().split()))
b = list(map(int, input().split()))

idx = 1
for lis in gen_array:
    if list(lis) == a:
        num_a = idx
    if list(lis) == b:
        num_b = idx
    idx += 1

print(abs(num_a - num_b))


Verdicts: Runtime Error

Accepted
Problem: We have two permutations P and Q of size N (that is, P and Q are both rearrangements of (1,~2,~...,~N)).  There are N! possible permutations of size N. Among them, let P and Q be the a-th and b-th lexicographically smallest permutations, respectively. Find |a - b|.

Submission attempts (in order):


import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = list(range(1,N+1))
b = itertools.permutations(a)

ans1 = 1
ans2 = 1

for i in b:
    if i == P:
        break
    ans1 += 1

b = itertools.permutations(a)

for i in b:
    if i == Q:
        break
    ans2 += 1

print(ans1, ans2)

print(abs(ans1-ans2))



import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a = list(range(1,N+1))
b = itertools.permutations(a)

ans1 = 1
ans2 = 1

for i in b:
    if i == P:
        break
    ans1 += 1

b = itertools.permutations(a)

for i in b:
    if i == Q:
        break
    ans2 += 1

print(abs(ans1-ans2))

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
str1 = input()
str2 = input()
str3 = ""

for i in range(0,n):
  str = (str1 + str2)[i::n]
  str3 += str

print(str3)

n = int(input())
str1,str2 = input().split()
str3 = ""

for i in range(0,n):
  str = (str1 + str2)[i::n]
  str3 += str

print(str3)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S, T = map(str, input().split())
NEW = [ S[i] + T[i] for i in range (N) ]
print(NEW)

N = int(input())
S, T = map(str, input().split())
NEW_1 = [ S[i] + T[i] for i in range (N) ]
NEW_2 = "".join(NEW_1)
print(NEW_2)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N=int(input())
S,T=map(str,input().split())
S,T=list(S),list(T)
print(S[2])
x=list("a"*(N*2))
for i in range(0,N*2):
    if i%2==0:
        x[i]=S[i//2]
    else:
        x[i]=T[i//2]
x="".join(x)
print(x)


N=int(input())
S,T=map(str,input().split())
S,T=list(S),list(T)
x=list("a"*(N*2))
for i in range(0,N*2):
    if i%2==0:
        x[i]=S[i//2]
    else:
        x[i]=T[i//2]
x="".join(x)
print(x)



Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s,t = input().split()
print(s)
print(t)
for i in range(n):
    print(s[i]+t[i],end='')
else:
    print('')

n = int(input())
s,t = input().split()
tmp = ''
for i in range(n):
    tmp = tmp + s[i]+t[i]
print(tmp)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
words = input()
word = words.split(' ')
new_word = []

for i in range(2 * N):
    if i % 2 == 0:
        new_word.append(word[0][i//2])
    else:
        new_word.append(word[1][i//2])
    
print(new_word)

N = int(input())
words = input()
word = words.split(' ')
new_word = []

for i in range(2 * N):
    if i % 2 == 0:
        new_word.append(word[0][i//2])
    else:
        new_word.append(word[1][i//2])
    
print("".join(new_word))


Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s = str(input())
t = str(input())

result = ""
for i in range(n):
  result += s[i]
  result += t[i]
print(result)

n = int(input())
rawString = str(input())
splitString = rawString.split()
s = splitString[0]
t = splitString[1]

result = ""
for i in range(n):
  result += s[i]
  result += t[i]
print(result)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s, t = list(input().split())
ans = []
for i in range(n):
  ans += s[i]
  ans += t[i]

print(ans)


n = int(input()
s, t = list(input().split()
ans = []
for i in range(n):
  ans += s[i]
  ans += t[i]

print(ans)

n = int(input())
s, t = list(input().split())
ans = ""
for i in range(n):
  ans += s[i]
  ans += t[i]

print(ans)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
inputted = list(map(int, input().split()))
S = inputted[0]
T = inputted[1]

answer = ''
for s, t in zip(S, T):
    answer += s + t

answer = ''.join([s + t for s, t in zip(S, T)])

print(answer)

N = int(input())
inputted = list(map(int, input()))
S = inputted[0]
T = inputted[1]

answer = ''
for s, t in zip(S, T):
    answer += s + t

answer = ''.join([s + t for s, t in zip(S, T)])

print(answer)

N = int(input())
inputted = input().split()
S = inputted[0]
T = inputted[1]

answer = ''
for s, t in zip(S, T):
    answer += s + t

answer = ''.join([s + t for s, t in zip(S, T)])

print(answer)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):

N=input()
S=input()
T=input()

strings=[]
for i in range(int(N)):
    strings.append(S[i]+T[i])
    
print(''.join(strings))

N=input()
S=input()
T=input()

strings=[]
for s,t in zip(S,T):
    strings.append(s+t)
print(''.join( strings))

A,B = input().split()
A=int(A)
B =int(B)
for i in range(1,B+1):
  if A*i%B ==0:
    print(A*i)

N=input()
S,T=input().split()
strings=[]
for i in range(int(N)):
    strings.append(S[i]+T[i])
print(''.join(strings))

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=int(input())
s,t=map(str,input().split())
ans=""
for i in range(n)
	ans+=s[i]+t[i]
print(ans)


n=int(input())
s,t=map(str,input().split())
ans=""
for i,j in zip(s,t):
	ans+=i
	ans+=j
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s,t = ism()
ans = ''
for i in range(n):
    ans += (s[i]+t[i])

def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
s,t = ism()
ans = ''
for i in range(n):
    ans += (s[i]+t[i])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
2
ip cc

n = int(input())
s,t = map(str, input().split())
moji = ""

for i in range(n):
  moji += s[i] + t[i]

print(moji)


Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = input()
S,T = input().split()

a = []
for i in range(N):
  a.append(S[i])
  a.append(T[i])
print(a)

N = int(input())
S,T = input().split()
 
a = ""
for i in range(N):
  a+=S[i]+T[i]
print(a)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s, t = input().split(
ans = ""
for i, j in zip(s, t):
    ans += i + j
print(ans)

n = int(input())
s, t = input().split()
ans = ""
for i, j in zip(s, t):
    ans += i + j
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
w, x = input().split(" ")
s = str(w)
t = str(x)

new_str = ""

for i in range(0, 3):
    new_str += s[i]
    new_str += t[i]

print(new_str)

n = int(input())
w, x = input().split(" ")
s = str(w)
t = str(x)

new_str = ""

for i in range(0, n):
    new_str += s[i]
    new_str += t[i]

print(new_str)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
num = int(input())

s1 = input()
s2 = input()
ans=""
for i in range(num):
    ans+=s1[i]
    ans+=s2[i]

print(ans)


num = int(input())
ans=""
(s1,s2) = input().split(" ")



for i in range(num):
    ans+=s1[i]
    ans+=s2[i]

print(ans)


Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
s, t = map(str, input().split())

word = ""
for i in range(N):
    word = word + s[i]
    word = word + t[i]

input(word)

N = int(input())
s, t = map(str, input().split())

word = ""
for i in range(N):
    word = word + s[i]
    word = word + t[i]

print(word)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N=int(input())
S=input()
T=input()
U=[]
for i in range(N):
  U.append(S[i])
  U.append(T[i])
print(U)

N=int(input())
S,T=input().split()
U=[]
for i in range(N):
  U.append(S[i])
  U.append(T[i])
print("".join(U))

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
s = str(input())
cnt = 0
sle = len(s)
n = int(sle/2-1)
for a in range(n+1):
    if s[a] != s[sle-a-1]:
            s.replace(s[a],s[sle-a-1])
            cnt += 1
print(cnt)


n = int(input())
s, t = map(str, input().split())
d = ''
for i in range(n):
    d += s[i] + t[i]
print(d)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
str1 = input()
str2 = input()

ans = ''
for i in range(0, N):
  ans += str1[i] + str2[i]
print(ans)

N = int(input())
str = input()
str = str.split()
str1 = str[0]
str2 = str[1]

ans = ''
for i in range(0, N):
  ans += str1[i] + str2[i]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=input()
a = input()+input()
print(a[::2]+a[1::2])

n=input()
ans=''
for i,j in zip(*input().split()):
    ans+=i+j
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n = int(input())
s, t = [int(input()) for i in range(2)]
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)


n = int(input())
s, t = input().split()
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)


Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=int(input())
s,t=map(str,input().split())
a=[]
for i in range(n):
    a+=s[i]+t[i]
print(a)

n=int(input())
s,t=input().split()
a=""
for i in range(n):
    a+=s[i]+t[i]
print(a)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=int(input())
a=list(map(str,input().split()))
k=[]
for i in range(n):
    for j in range(2):
        k.append(a[j][i])
print(k)

n=int(input())
a=list(map(str,input().split()))
k=[]
for i in range(n):
    for j in range(2):
        k.append(a[j][i])
print(''.join(k))

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
A = input()
B = input()
 
r = ""
for i in range(N):
  r+= A[i]
  r+= B[i]
print(r)

N = int(input())
A = input()
B = input()

r = ""
for i in range(N):
  i+= A[i]
  i+= B[i]

N = int(input())
A = input()
B = input()
 
r = ""
for i in range(N):
  r+= A[i]
  r+= B[i]
print(r)

N = int(input())
A, B = input().split()
 
r = ""
for i in range(N):
  r+= A[i]
  r+= B[i]
print(r)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S,T = map(int, readline().split())

ans = []

for i in range(N):
  ans.append(S[i])
  ans.append(T[i])

print(''.join(ans))
  

import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
S,T = read().decode('utf-8').rstrip().split()
 
A = [None]*(N+N)
A[::2] = S
A[1::2] = T


print(''.join(A))

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
a, b, k = map(int, input().split())

x = min(a, k)
a -= x
k -= x
y = min(b, k)
b -= y

print(str(a),str(b))

n = int(input())
S, T = input().split()

ans = ""

for i in range(n):
    ans += S[i]+T[i]
    
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
'''input
3
4
1 2 3 6
1
8
2
1 1
'''

from sys import stdin
from collections import defaultdict


# main starts
n = int(stdin.readline().strip())
s = stdin.readline().strip()
t = stdin.readline().strip()
ans = []
for i in range(n):
	ans.append(s[i])
	ans.append(t[i])
print(''.join(ans))

'''input
2
ip cc
'''

from sys import stdin
from collections import defaultdict


# main starts
n = int(stdin.readline().strip())
s, t = stdin.readline().split()
ans = []
for i in range(n):
	ans.append(s[i])
	ans.append(t[i])
print(''.join(ans))

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S,T = input().stlip

s=''

for i in range(N):
  s+=S[i]+T[i]
  
print(s)



N = int(input())
S,T = str(input().stlip)

s=''

for i in range(N):
  s+=S[i]+T[i]
  
print(s)

N = int(input())
S,T = (input().stlip)

s=''

for i in range(N):
  s+=S[i]+T[i]
  
print(s)


n = int(input())
s,t = input().split()
n_s=""
for i in range(n):
    n_s += s[i]+t[i]

print(n_s)



Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=int(input())
s=input()
print(s.count('ABC'))

n=int(input())
s,t=input().split()
ans=''
for i in range(n):
 ans+=s[i]+t[i]
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S = list(input())
T = list(input())
ans = ""
for i in range(N):
    ans += S[i]
    ans += T[i]
print(ans)

N = int(input())
S = list(input())
ans = ""
for i in range(N):
    ans += S[i]
    ans += S[N + i + 1]
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N = int(input())
S = str(input())
T = str(input())
f = ''
for i in range(N):
    f += S[i]
    f += T[i]
print(f)

N = int(input())
S = str(input())
T = str(input())

f = ''
for i in range(N):
    f += S[i]
    f += T[i]
print(f)

N = int(input())
S = str(input())
T = str(input())
f = ''
for i in range(N):
    f += S[i]
    f += T[i]
print(f)

N = int(input())
S,T=map(str, input().split())
f = ''
for i in range(N):
    f += S[i]
    f += T[i]
print(f)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
n=int(input())
a,b=input().split()
str=""
for i in range(n):
  str+=a[i]+b[i]
  
 print(str)

n=int(input())
a,b=input().split()
str=""
for i in range(n):
    str+=a[i]+b[i]
print(str)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N=int(input())
S,T=map(input().split())
a=""
for i in range(N):
  a+=S[i]+T[i]
print(a)

N=int(input())
S,T=map(str,input().split())
a=""
for i in range(N):
  a+=S[i]+T[i]
print(a)

Verdicts: Runtime Error

Accepted
Problem: Given are strings s and t of length N each, both consisting of lowercase English letters.  Let us form a new string by alternating the characters of S and the characters of T, as follows: the first character of S, the first character of T, the second character of S, the second character of T, ..., the N-th character of S, the N-th character of T. Print this new string.

Submission attempts (in order):
N=int(input())
S=input()
T=input()
x = [S[i:i+1] for i in range(len(S))]
y = [T[i:i+1] for i in range(len(T))]

n=int(input())
s,t=input().split()
ans=""
for i in range(n):
    ans+=s[i]+t[i]
print(ans)

Verdicts: Runtime Error

Accepted