Source Code
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ii pair <int,int>
#define F first
#define S second
#define ever (;;)

bool same,Not;
int n,k,m,sum;

int main()
{
    scanf("%d%d%d",&n,&k,&m);
    for(int i=1;i<=n;i++)
    {
        int x1,x2;
        scanf("%d%d",&x1,&x2);

        if( x1%2 == x2%2 )
            same = 1;
        else
            Not = 1;

        sum += x1%2;
    }

    sum %= 2;

    if( !Not )
    {
        if( sum == m )
            printf("1\n");
        else
            printf("2\n");

        return 0;
    }

    if( !same )
    {
        if( k&1 )
            sum ^= 1;

        if( sum == m )
            printf("1\n");
        else
            printf("2\n");

        return 0;
    }

    if( k%2 == 1 )
        printf("1\n");
    else
        printf("2\n");
}
Copy
Cliffs of Dover Naseem17
GNU G++17
123 ms
876 KB
Accepted