Вітаю Вас, Гість

Задача А.
#include <set>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
   freopen("kinder.dat","r",stdin);
   freopen("kinder.ans","w",stdout);
   int n,cur;
   scanf("%d", &n);
   set<int> mem;
   while(scanf("%d", &cur)==1) mem.insert(cur);
   int k=n - mem.size();
   if(k==0)printf("Success!\n");
        else
                   {
                           printf("%d\n", k);
                           int N = (int)mem.size();
                           for(int i=1; i<=n;i++)
                                   {
                                           mem.insert(i);
                                           if((int)mem.size()!=N){N++;printf("%d ",i);}
                                   }
                }
    return 0;
}


Задача В.
#include<iostream>
using namespace std;
int a[1001][1001];
int BSLeft(int A[], int key, int z)
{
        int l=-1, r=z, m;
        while (l<r-1)
        {
                m=(r+l)/2;
                if (A[m]<key) l=m; else r=m;
        }
        return r;
}

int BSRight(int A[], int key,int z)
{
        int l=-1, r=z, m;
        while (l<r-1)
        {
                m=(r+l)/2;
                if (A[m]<=key) l=m;else r=m;
        }
        return r;
}

int main()
{
        freopen("modelm.dat","r",stdin);
        freopen("modelm.ans","w",stdout);
        int n;
        scanf("%d\n",&n);
        for(int i=0;i<n;i++)
                for(int j=0;j<n;j++)
                                        scanf("%d",&a[i][j]);
        int k,t;
        while (scanf("%d %d\n",&k,&t)==2)
        {
                        int x=BSLeft(a[k-1], t,n);
                        int y=BSRight(a[k-1], t,n);
                        if(y==x)cout<<-1<<' ';else cout<<y-x<<' ';

        }


}

Задача С.
#include<iostream>
#include<cstring>
using namespace std;
int a[1002][1002];
int main()
{
        int k,N,i,j,nomi;
        freopen("c.dat","r",stdin);
        freopen("c.ans","w",stdout);
        scanf("%d",&N);
        for(i=0;i<N;i++)
                for(j=0;j<N;j++) scanf("%d",&a[i][j]);
        for(i=0;i<N;i++)scanf("%d",&a[i][N]);
        for(i=0;i<N;i++)
         {
                k=-1;
                nomi=a[i][N];
                for(j=0;a[i][j]!=nomi;j++);
                if(j!=N){cout<<j+1<<' ';}else cout<<k<<' ';
         }
}

Задача D.
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include <algorithm>
using namespace std;

int main()
{
       freopen("sum.dat","r",stdin);
       freopen("sum.ans","w",stdout);
       int n, target;
       scanf("%d %d\n",&n,&target);
       vector <pair<int, int> >a;
       for (int i = 0; i < n; i++)
        {
            int num;
            scanf("%d\n",&num);
            a.push_back(make_pair(num, i + 1));
        }
        sort(a.begin(), a.end());
        int l = 0;
        int r = n - 1;
        while (l < r)
         {
            if (a[l].first + a[r].first > target)
                r--;
            else
            if (a[l].first + a[r].first == target)
                       {
                               cout << min(a[l].second, a[r].second) << ' ' << max(a[l].second, a[r].second)<<'\n';
                               return 0;
                       }
            else
                l++;
         }

         cout << "IMPOSSIBLE";
         return 0;

}

Задача Е.
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int main()
{
    freopen("e.dat","r",stdin);
    freopen("e.ans","w",stdout);
    int n;
    cin>>n; n=2*n;
    vector<unsigned int>nums(n);
    for(int i=0;i<n;i++) scanf("%d",&nums[i]);
    int xr = 0;
    for (int i=0; i<n; i++ ) xr ^= nums[i];
    int lastBit = xr - (xr & (xr - 1));
    int a = 0;
    for (int i=0;i<n;i++)
      {
        if ((nums[i] & lastBit) == lastBit) a ^= nums[i];
      }
    int b=xr^a; if (a>b)swap(a,b);
    cout<< a<<' '<< b<<'\n';
}