# 2853. 集合运算

#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
void print(set<int>& s)
{
cout<<"{";
if (s.size()==0)
cout<<"}"<<endl;
else
{
auto it = s.begin();
int i=0;
for (;i<s.size()-1;++it,++i)
cout<<*it<<",";
cout<<*it<<"}"<<endl;
}
}
int main()
{
int n1,n2,tmp;
set<int> x,y,a,b,c;
cin>>n1>>n2;
int i,j;
for (i=0;i<n1;++i)
{
cin>>tmp;
x.insert(tmp);
}
for (i=0;i<n2;++i)
{
cin>>tmp;
y.insert(tmp);
}
set_intersection(x.begin(),x.end(),y.begin(),y.end(),inserter(a,a.end()));
set_union(x.begin(),x.end(),y.begin(),y.end(),inserter(b,b.end()));
set_difference(x.begin(),x.end(),y.begin(),y.end(),inserter(c,c.end()));
print(a);
print(b);
print(c);
}


input()
a, b = set(input().split()), set(input().split())
for op in "&|-":
s = eval(f'sorted(a{op}b,key=int)')
print('{' + ','.join(s) + '}')


### include

using namespace std;
int T,a,b;
set xx,yy,U,I,D;
void solve()
{
set_intersection(xx.begin(),xx.end(),yy.begin(),yy.end(),inserter(I,I.begin()));
set_union(xx.begin(),xx.end(),yy.begin(),yy.end(),inserter(U,U.begin()));
set_difference(xx.begin(),xx.end(),yy.begin(),yy.end(),inserter(D,D.begin()));
return;
}
void print(set::iterator iter,set::iterator end)
{
cout<<’{‘;
int ff=1;

while(iter!=end)
{
int tmp=(*iter);
if(ff) {ff=0;cout<<tmp;}
else cout<<’,’<<tmp;
++iter;
}
cout<<”}\n”;
}
int main()
{
cin>>a>>b;
xx.clear();yy.clear();
for(int i=1;i<=a;i++)
{
int tmp;
cin>>tmp;
xx.insert(tmp);
}
for(int i=1;i<=b;i++)
{
int tmp;
cin>>tmp;
yy.insert(tmp);
}
solve();
print(I.begin(),I.end());print(U.begin(),U.end());print(D.begin(),D.end());
return 0;
}

[em:15]
[em:03]
[em:13]