50 переведите программу с pascal на python: var a: array[1..40000,1..2] of byte; f: text; n,i,j,k: integer; begin assign(f,'input.txt'); reset(f); read(f,n); for i: =1 to n do read(f,a[i,1],a[i,2]); close(f); k: =0; for i: =1 to n-1 do for j: =i+1 to n do if(a[i,1]=a[j,1])or(a[i,1]=a[j,2]) or(a[i,2]=a[j,1])or(a[i,2]=a[j,2])then inc(k); assign(f,'output.txt'); rewrite(f); write(f,k); close(f); end.
with open('input.txt', 'r') as f:
n = int(f.readline())
for i in range(n):
inp = f.readline()
x, y = list(map(int, inp.split()))
a.append((x, y))
k = 0
for i in range(n - 1):
for j in range(i + 1, n):
if (a[i][0] == a[j][0]) or (a[i][0] == a[j][1]) or (a[i][1] == a[j][0]) or (a[i][1] == a[j][1]): k += 1
with open('output.txt, w') as f:
f.write(k)
https://pastebin.com/sHe7sFyc - тут все отформатировано красиво(просто на знаниях неудобно вставлять код)