ADDED   SRM/697-U/1A-U.cpp
Index: SRM/697-U/1A-U.cpp
==================================================================
--- SRM/697-U/1A-U.cpp
+++ SRM/697-U/1A-U.cpp
@@ -0,0 +1,92 @@
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <algorithm>
+#include <numeric>
+#include <iterator>
+#include <functional>
+#include <complex>
+#include <queue>
+#include <stack>
+#include <cmath>
+#include <cassert>
+#include <tuple>
+using namespace std;
+typedef long long LL;
+typedef complex<double> CMP;
+
+class DivisibleSetDiv1 { public:
+	string isPossible(vector <int> b)
+	{
+		return solve(b) ? "Possible" : "Impossible";
+	}
+
+	bool solve(vector<int> b)
+	{
+		sort(b.begin(), b.end());
+		int n = b.size();
+
+		int sum = 0;
+		for(int i=0; i<b.size(); ++i)
+			sum += (n-i);
+		for(int i=0; i<b.size(); ++i)
+			if(sum > (b[i]+1)*(n-i))
+				return false;
+		return true;
+	}
+};
+
+// BEGIN CUT HERE
+#include <ctime>
+double start_time; string timer()
+ { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
+template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
+ { os << "{ ";
+   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
+   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
+void verify_case(const string& Expected, const string& Received) {
+ bool ok = (Expected == Received);
+ if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
+ cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
+#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
+#define END	 verify_case(_, DivisibleSetDiv1().isPossible(b));}
+int main(){
+
+CASE(0)
+	int b_[] = {2,1};
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = "Possible"; 
+END
+CASE(1)
+	int b_[] = {1,1};
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = "Impossible"; 
+END
+CASE(2)
+	int b_[] = {7, 7, 7};
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = "Possible"; 
+END
+CASE(3)
+	int b_[] = {5,3,5,4,6,1,3,7,9,6,2,5,4,1,1,9,6,10,10,6,10,7,7,8};
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = "Impossible"; 
+END
+CASE(4)
+	int b_[] = {2,3,4};
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = "Possible"; 
+END
+/*
+CASE(5)
+	int b_[] = ;
+	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
+	string _ = ; 
+END
+*/
+}
+// END CUT HERE

ADDED   SRM/697-U/1B.cpp
Index: SRM/697-U/1B.cpp
==================================================================
--- SRM/697-U/1B.cpp
+++ SRM/697-U/1B.cpp
@@ -0,0 +1,136 @@
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <algorithm>
+#include <numeric>
+#include <iterator>
+#include <functional>
+#include <complex>
+#include <queue>
+#include <stack>
+#include <cmath>
+#include <cassert>
+#include <tuple>
+using namespace std;
+typedef long long LL;
+typedef complex<double> CMP;
+
+static const unsigned MODVAL = 1000000007;
+
+class XorOrderDiv1 { public:
+	int get(int m, int n, int a0, int b)
+	{
+		vector<int> a;
+		for(int i=0; i<n; ++i)
+			a.push_back(int((a0 + LL(i)*b) % (1LL<<m)));
+		sort(a.begin(), a.end());
+		return solve(a, m);
+	}
+
+	int solve(const vector<int>& A, int M)
+	{
+		vector<int> d;
+		return solve_rec(A, 0, A.size(), M-1, d);
+	}
+
+	int solve_rec(const vector<int>& A, int s, int e, int bit, vector<int>& d)
+	{
+		if(s==e)
+			return 0;
+
+		if(bit == -1) {
+			const int M = d.size();
+			LL q = 0;
+			LL sigma = 0;
+			for(int m=M-1; m>=0; --m)
+			{
+				LL qprev = q;
+				LL dd = d[m];
+				q = dd*dd%MODVAL*(1LL<<(M-m-1)) + sigma*dd%MODVAL*(1LL<<(M-m-1)) + 2*qprev;
+				sigma += dd;
+			}
+			return int(q % MODVAL);
+		}
+
+		int m=s;
+		for(; m<e; ++m)
+			if(A[m]&(1<<bit))
+				break;
+
+		int ans = 0;
+		d.push_back(e-m);
+		ans ^= solve_rec(A, s, m, bit-1, d);
+		d.pop_back();
+		d.push_back(m-s);
+		ans ^= solve_rec(A, m, e, bit-1, d);
+		d.pop_back();
+		return ans;
+	}
+};
+
+// BEGIN CUT HERE
+#include <ctime>
+double start_time; string timer()
+ { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
+template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
+ { os << "{ ";
+   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
+   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
+void verify_case(const int& Expected, const int& Received) {
+ bool ok = (Expected == Received);
+ if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
+ cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
+#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
+#define END	 verify_case(_, XorOrderDiv1().get(m, n, a0, b));}
+int main(){
+
+CASE(0)
+	int m = 2; 
+	int n = 3; 
+	int a0 = 0; 
+	int b = 1; 
+	int _ = 8; 
+END
+CASE(1)
+	int m = 3; 
+	int n = 5; 
+	int a0 = 1; 
+	int b = 3; 
+	int _ = 48; 
+END
+CASE(2)
+	int m = 16; 
+	int n = 100; 
+	int a0 = 41; 
+	int b = 5; 
+	int _ = 523436032; 
+END
+CASE(3)
+	int m = 30; 
+	int n = 200000; 
+	int a0 = 399; 
+	int b = 18082016; 
+	int _ = 408585698; 
+END
+/*
+CASE(4)
+	int m = ; 
+	int n = ; 
+	int a0 = ; 
+	int b = ; 
+	int _ = ; 
+END
+CASE(5)
+	int m = ; 
+	int n = ; 
+	int a0 = ; 
+	int b = ; 
+	int _ = ; 
+END
+*/
+}
+// END CUT HERE