akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> v(4);
    for(int i = 0; i < 4; i++) {
        cin >> v[i];
    }
    int ans = INF;
    for(int i = 0; i < 4; i++) {
        for(int j = i + 1; j < 4; j++) {
            vector<bool> used(4, 0);
            used[i] = used[j] = 1;
            int sum1 = v[i] + v[j];
            int sum2 = accumulate(ALL(v), 0) - sum1;
            chmin(ans, abs(sum1 - sum2));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3212
import collections
import sys
input=sys.stdin.readline

n=int(input())
ans=[0]*n
tmp=[]
for x in range(1,int(n**0.5)+1): #可能なすべてのx,y,zについてx^2+y^2+z^2+xy+yz+zxの値を求める
   for y in range(1,int(n**0.5)+1):
       for z in range(1,int(n**0.5)+1):
           tmp.append(x**2+y**2+z**2+x*y+y*z+z*x)
cnt=collections.Counter(tmp) #x^2+y^2+z^2+xy+yz+zxの値の個数を数える
for i in range(1,n+1): #各iについて、x^2+y^2+z^2+xy+yz+zxの値がiであるものの個数が答えとなる
   print(cnt[i])

Measured memory_bytes: 51000
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int mp[(int) 2e5];
int main() {
	run();
	int n;
	cin >> n;
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	int q;
	cin >> q;
	while (q--) {
		int b, c;
		cin >> b >> c;
		sum += 1LL * mp[b] * (c - b);
		mp[c] += mp[b];
		mp[b] = 0;
		cout << sum << endl;
	}
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
	long long int sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
    	if(i%3!=0 && i%5!=0){
    		sum+=i;
		}
	}
	cout<<sum;
    
//system("pause");
return 0;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 2e5 + 10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;

ll a[maxN];
ll b[maxN];
int main()
{
	int n,m;
	ll k;
	cin>>n>>m>>k;
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
	}
	for(int i=1;i<=n;i++)
	{
		a[i] += a[i-1];
	}
	for(int j=1;j<=m;j++)
	{
		b[j] += b[j-1]; 
	}
	for(int i=0;i<=n;i++)
	{
		ll res = k-a[i];
		if(res < 0)continue;
		int pos = upper_bound(b+1,b+1+m,res) - b - 1;
		ans = max(ans,i+pos);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6668
/*
    Author : zzugzx
    Lang : C++
    Blog : blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1e9+7;
//const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 1e6+10;
const ll inf = 0x3f3f3f3f;
const int dir[][2]={{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};


ll a[maxn],b[maxn];
long double d1[maxn],d2[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    int n, k;
    cin >> n >> k;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if (x > 0) a[++aa] = x;
        else if (x < 0) b[++bb] = x;
        else cc++;
    }
    ll ans = 1;
    if (aa + bb / 2 * 2 >= k && (aa || k % 2 != 1)){
        sort(a + 1, a + 1 + aa);
        reverse(a + 1, a + 1 + aa);
        sort(b + 1, b + 1 + bb);
        for (int i = 1; i <= aa; i++)
            d1[i] = d1[i - 1] + log(a[i]);
        for (int i = 1; i <= bb; i++)
            d2[i] = d2[i - 1] + log(-b[i]);
        long double res = 0;
        int id = 0;
        for (int i = 0; i <= bb && i <= k; i += 2)
            if (k - i <= aa && d2[i] + d1[k - i] >= res)
                res = d2[i] + d1[k - i], id = i;
        for (int i = 1; i <= id; i++)
            ans = ans * b[i] % mod;
        for (int i = 1;i <= k - id; i++)
            ans = ans * a[i] % mod;
        cout << (ans % mod + mod) % mod << endl;
    }
    else if (cc) cout << 0 << endl;
    else {
        sort(a + 1, a + 1 + aa);
        sort(b + 1, b + 1 + bb);
        reverse(b + 1, b + 1 + bb);
        for (int i = 1; i <= aa; i++)
            d1[i] = d1[i - 1] + log(a[i]);
        for (int i = 1; i <= bb; i++)
            d2[i] = d2[i - 1] + log(-b[i]);
        long double res = -1;
        int id = 0;
        for (int i = 1; i <= bb && i <= k; i += 2)
            if (k - i <= aa && (d2[i] + d1[k - i] <= res || res == -1))
                res = d2[i] + d1[k - i], id = i;
        for (int i = 1; i <= id; i++)
            ans = ans * b[i] % mod;
        for (int i = 1;i <= k - id; i++)
            ans = ans * a[i] % mod;
        cout << (ans % mod + mod);
    }
    return 0;
}


Measured memory_bytes: 8472
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int m = o[1];
            var a = new int[m];
            var b = new int[m];
            for(int i=0;i<m;++i)
            {
                var p = ReadAndParseIntArr();
                a[i] = p[0];
                b[i] = p[1];
            }
            int[] islands = new int[n+1];

            // 1から行ける島
            for(int i=0;i<a.Length;++i)
            {
                if( a[i] != 1) { continue; }
                islands[b[i]]++;
            }
            // Nから行ける島
            for(int i=0;i<b.Length;++i)
            {
                if( b[i] != n) { continue; }
                islands[a[i]]++;
            }
            string ans = islands.Any(p => p == 2) ? "POSSIBLE" : "IMPOSSIBLE";
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 17444
#include <bits/stdc++.h>
#include <cmath>

#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

int main() {

    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;

    cout << (char)toupper(s1.front());
    cout << (char)toupper(s2.front());
    cout << (char)toupper(s3.front());

    cout << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int     main() {
        long N;
        cin >> N;
        vector<long> M(N+1);
        vector<long> A(N);
        for (long i=0; i<N; i++) {
                cin >> A.at(i);
        }
        M.at(0)=0;
        for (long i=1;i<=N; i++) {
               M.at(i)=2*(A.at(i-1)-M.at(i-1)/2);
        }
        while (M.at(0) != M.at(N)){
                M.at(0)=(M.at(0)+M.at(N))/2;
                for (long i=1;i<=N; i++) {
                       M.at(i)=2*(A.at(i-1)-M.at(i-1)/2);
                }
        }
        for (long i=0; i<N; i++) {
                cout <<M.at(i) << " ";
        }
        cout << endl;
        return 0;
}

Measured memory_bytes: 2944
//                             In The Name Of Allah                                           
//                             	Mohammad Hosseini
#include <bits/stdc++.h>
#define	ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define pb push_back
#define int long long
#define ld long double
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std; 

const int N = 3e5 + 100, OO = 724249387, T = 1e6 + 100, M = 1e9 + 7, P = 6151, SQ = 280, lg = 30;
typedef pair <int, int> pii;
unordered_map <int, int> mp, is;
int n, a[N];

int32_t main() {
	use_fast;
	cin >> n;
	set <pii> st;
	int MX = 1e5;
	for(int i = 1; i <= MX; i++)
		is[i * i] = i;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		int cnt = a[i], pre = 1;
		for(int j = 2; j * j * j <= a[i]; j++) 
			if(a[i] % (j * j * j) == 0)
				cnt = a[i] / (j * j * j);
		for(int j = 2; j * j * j <= a[i]; j++) {
			int cmp = j * j * j;
			while(a[i] % cmp == 0)
				a[i] /= cmp;
			if(a[i] % (j * j) == 0)
				pre *= j, a[i] /= j, a[i] /= j;
			else if(a[i] % j == 0)
				pre *= j * j, a[i] /= j;
		}
		mp[cnt]++;
		if(is[a[i]] != 0) {
			pre *= is[a[i]];
			st.insert({cnt, pre});
		}
		else {
			if((a[i] * a[i] > MX && pre > MX) || a[i] > MX)
				st.insert({cnt, 0});
			else 
				st.insert({cnt, pre * a[i] * a[i]}), pre *= a[i] * a[i];
		}
	}
	int ans = 0;
	for(auto u : st) {
		if(u.ff == 1) {
			ans++;
			continue;
		}
		if(mp[u.ff] < mp[u.ss])
			continue;
		mp[u.ss] = 0;
		ans += mp[u.ff];
	}
	cout << ans << endl;
	return 0;
}
/*
be carefull :
1- if not solve after 20 min, read again twice
2- after submit read the code again
3- fun with contest
4- uploaded by ubuntu 20.04 
5- ...
*/


Measured memory_bytes: 22412
#include<stdio.h>
#define ll long long
ll dp[200100]={0};
ll qp[200100]={0};
int main(){
    ll n,i;
    scanf("%lld",&n);
    ll a[n];
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
        dp[a[i]]++;
    for(i=1;i<=n;i++){
        qp[i]=dp[i]*(dp[i]-1)/2;
    }
    ll sum=0;
    for(i=0;i<=n;i++)
        sum+=qp[i];
    for(i=0;i<n;i++){
        if(dp[a[i]]==0||dp[a[i]]==1)
            printf("%lld\n",sum);
        else if(dp[a[i]]==n){
            printf("%lld\n",(n-2)*(n-1)/2);
        }
        else{
            ll ans,p;
            p=dp[a[i]]-1;
            ans=p*(p-1)/2;
            printf("%lld\n",sum-qp[a[i]]+ans);
        }
    }
    return 0;
}

Measured memory_bytes: 6144
#include <iostream>

using namespace std;

int n;
int v[200000];
int a1[200000] = {};
int a2[200000] = {};

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (i % 2 == 0) a1[v[i]]++;
    else a2[v[i]]++;
  }
  int a1max = 0, a2max = 0;
  for (int i = 0; i <= 100000; i++) {
    if (a1[i] > a1[a1max]) a1max = i;
    if (a2[i] > a2[a2max]) a2max = i;
  }
  //cout << "prev :a1max, a2max " << a1max << ", " << a2max << endl;

  if (a1max == a2max){
    int a1temp = 0, a2temp = 0;
    for (int i = 0; i <= 100000; i++) {
      if (a1[i] >= a1[a1temp]) a1temp = i;
      if (a2[i] >= a2[a2temp]) a2temp = i;
    }

    if (a1max != a1temp) a1max = a1temp;
    else if (a2max != a2temp) a2max = a2temp;
    else {
      int a1temp = 0, a2temp = 0;
      for (int i = 0; i <= 100000; i++) {
        if (a2[i] > a2[a2temp] && i != a1max) a2temp = i;
        if (a1[i] > a1[a1temp] && i != a2max) a1temp = i;
      }
      if((a1[a1max] - a1[a1temp]) > (a2[a2max] - a2[a2temp])) a2max = a2temp;
      else a1max = a1temp;
    }
  }
  
  //cout << "a1max, a2max " << a1max << ", " << a2max << endl;
  int ans = 0;
  for (int i = 0; i <= 100000; i++) {
    if (i != a1max) ans += a1[i];
    if (i != a2max) ans += a2[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
X, Y = parseMap(split(readline()))

flag = false
for turu in 0:100
    for kame in 0:100
        if (turu * 2) + (kame * 4) == Y && turu + kame == X
            flag = true
            break
        end
    end
    if flag
        break
    end
end


if flag
    println("Yes")
else
    println("No")
end

end

main()

Measured memory_bytes: 162620
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
ans = []
for i in reversed(range(1, N+1)):
    a = A[i-1]
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a += B[tmp-1]
    if a % 2 == 1:
        ans.append(i)
    B[i-1] = a % 2
print(len(ans))
for a in ans:
    print(a)

Measured memory_bytes: 12028
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> x(N), y(N);
  REP(i, N) cin >> x[i] >> y[i];

  vector<int> v(N);
  REP(i, N) v[i] = i;
  double ans = 0;
  do{
    REP(i, N-1){
      ans += hypot(x[v[i+1]]-x[v[i]], y[v[i+1]]-y[v[i]]);
    }
  }while(next_permutation(ALL(v)));

  while(N--){
    ans /= N+1;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forab(i, a, b) for(int i=(a);i<(b);++i)
#define foreach(i, n) for (__typeof(n.begin()) i = n.begin(); i != n.end(); ++i)
#define sqr(x) ((x)*(x))
#define clr(a, b) memset(a, b, sizeof(a))
#define MP make_pair
#define PB push_back
#define SZ(a) ((int)a.size())
#define all(a) (a).begin(),(a).end()
#define inf 0x3f3f3f3f
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
const double eps = 1e-8;
int dcmp(double x) { if (x < -eps) return -1; else return x > eps;}
#define se(x) cout<<#x<<" = "<<x<<endl

#ifdef CHEN_PC
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif

const int N = 310;
const int N2 = N * 2;
const int mod = 1000000007; // 10^9+7
int n, m;
char plane[N][N];
int sum[N2][N2];
int mark[N2][N2];

ll solve() {
    ll ans = 0;
    int n2 = 601;

    clr(mark, 0);
    clr(sum, 0);
    forn (i, n) forn (j, m) {
        if (plane[i][j] == '.') continue;
        mark[i - j + 300][i + j] = 1;
        sum[i - j + 300][i + j] = 1;
    }
    forn (i, n2) forn (j, n2) {
        sum[i][j + 1] += sum[i][j];
    }
    forn (x, n2) {
        forn (y1, n2) if (mark[x][y1]) {
            forab (y2, y1+1, n2) if (mark[x][y2]) {
                int d = y2 - y1;
                if (x - d >= 0) {
                    ans += sum[x - d][y2] - sum[x - d][y1] + mark[x - d][y1];
                }
                if (x + d <= n2) {
                    ans += sum[x + d][y2] - sum[x + d][y1] + mark[x + d][y1];
                }
            }
        }
    }

    clr(mark, 0);
    clr(sum, 0);
    forn (i, n) forn (j, m) {
            if (plane[i][j] == '.') continue;
            mark[i + j][i - j + 300] = 1;
            sum[i + j][i - j + 300] = 1;
        }
    forn (i, n2) forn (j, n2) {
            sum[i][j + 1] += sum[i][j];
        }
    forn (x, n2) {
        forn (y1, n2) if (mark[x][y1]) {
                forab (y2, y1+1, n2) if (mark[x][y2]) {
                        int d = y2 - y1;
                        if (x - d >= 0) {
                            ans += sum[x - d][y2 - 1] - sum[x - d][y1];
                        }
                        if (x + d <= n2) {
                            ans += sum[x + d][y2 - 1] - sum[x + d][y1];
                        }
                    }
            }
    }
	return ans;
}

int main(int argc, char *argv[]) {
#ifdef CHEN_PC
	freopen("E.in", "r", stdin);
#endif

	while (scanf("%d%d", &n, &m) != EOF) {
	    forn (i, n) {
	        scanf("%s", plane[i]);
	    }
		ll ret = solve();
		printf("%lld\n", ret);
	}
	return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

    int k,a,b;
    cin >> k;
    cin >> a >> b;

    if(b%k <= b-a) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
typedef long long int ll;
static const int MAX_N = 50;
static const int MAX_X = 50;

int N, A;
int x[MAX_N];
ll memo[MAX_N +1][MAX_N+1][MAX_N*MAX_X+1];

int main() {
	cin >> N >> A;
	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}
	memo[0][0][0] = 1;//[何枚目まで使うか][何枚使うか][カードの和]
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= N * MAX_X; k++) {
				//新しく追加されるカードが「和」より大きかったら[何枚目まで使うか]によらず値は変化しない
				if (j == 0 || k < x[i - 1]) {
					memo[i][j][k] = memo[i - 1][j][k];
				}
				//そうでなければ、[何枚目まで使うか][何枚使うか]が1ずつ少なく、[カードの和]が新しく追加したカード分少ないものを足す

				else {
					memo[i][j][k] = memo[i - 1][j][k] + memo[i - 1][j - 1][k - x[i - 1]];
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		ans += memo[N][i][i * A];
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 49152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    cout << (a[0] ^ 5 || a[1] ^ 5 || a[2] ^ 7 ? "NO" : "YES");
    
}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

#include <stdio.h>
using namespace std;

int main(void) {
	int n;
	string sTaro, sHanako;
	int pointTaro = 0;
	int pointHanako = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> sTaro >> sHanako;
		if (sTaro > sHanako)
			pointTaro += 3;
		else if (sTaro < sHanako)
			pointHanako += 3;
		else {
			pointTaro += 1;
			pointHanako += 1;
		}
	}
	cout << pointTaro << " " << pointHanako << endl;
	return 0;
}



Measured memory_bytes: 3172
# YouTube解説
MOD = 1000000007
n, k = [int(x) for x in input().split()]
d = [pow(k // i, n, MOD) for i in range(1, k + 1)]
d.insert(0, 0)

for i in range(k, 0, -1):  # 大きいほうから
    for j in range(i * 2, k + 1, i):  # iの倍数
        # d[6] = d'[6] - d[12] - d[18] ...
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i, item in enumerate(d):
    ans += i * item
    ans %= MOD
print(ans)


Measured memory_bytes: 11424
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns          #-}
{-# LANGUAGE CPP                   #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings     #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce
 
main :: IO ()
main = do
    [a, b, q] <- map read.words <$> getLine :: IO [Int]
    sstsxs <- U.unfoldrN (a + b + q) (B.readInt.B.dropWhile isSpace) <$> B.getContents
    let (ss, tsxs) = U.splitAt a sstsxs
    let (ts, xs) = U.splitAt b tsxs
    putStr.unlines.map show $ solve ss ts xs
 
inf :: Int
inf = 0x3f3f3f3f3f3f3f3f
 
solve :: U.Vector Int -> U.Vector Int -> U.Vector Int -> [Int]
solve ss ts xs = map f $ U.toList xs
  where
    f x = minimum
        [ abs (sl - x) + abs (tl - sl) `min` abs (tr - sl)
        , abs (sr - x) + abs (tl - sr) `min` abs (tr - sr)
        , abs (tl - x) + abs (sl - tl) `min` abs (sr - tl)
        , abs (tr - x) + abs (sl - tr) `min` abs (sr - tr)
        ]
      where
        (!sl, !sr) = neighbor x ss
        (!tl, !tr) = neighbor x ts
 
neighbor :: Int -> U.Vector Int -> (Int, Int)
neighbor x vec
    | x < U.head vec = (inf, U.head vec)
    | i + 1 < U.length vec = (U.unsafeIndex vec i, U.unsafeIndex vec (i + 1))
    | otherwise = (U.last vec, inf)
  where
    i = upperBound 0 (U.length vec - 1) (\i -> U.unsafeIndex vec i <= x)
 
-------------------------------------------------------------------------------
 
lowerBound :: (Integral i) => i -> i -> (i -> Bool) -> i
lowerBound low high p = go low high
  where
    go !low !high
        | high <= low = high
        | p mid       = go low       mid
        | otherwise   = go (mid + 1) high
      where
        h = toInteger high
        l = toInteger low
        mid = fromIntegral $ l + div (h - l) 2
{-# INLINE lowerBound #-}
 
upperBound :: (Integral i) => i -> i -> (i -> Bool) -> i
upperBound low high p
    | p high = high
    | otherwise = lowerBound low high (not.p) - 1
{-# INLINE upperBound #-}

Measured memory_bytes: 9724
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const double eps=1e-9;
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
int main(){
	int i,j,k,m,n,l,r;
	n=read();l=read();r=read();
	if((r-l)%2==1)puts("Borys");
	else puts("Alice");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

stack<char> slime;
string S;
int main(){
  int n;
  cin >> n;
  cin >> S;
  slime.push(S[0]);
  rep(i, S.size()){
    if(slime.top() != S[i]) slime.push(S[i]);
  }
  cout << slime.size() <<endl;
}
  

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
	int x;
	cin >> x;
	int z;
	if (x % 2 == 0)
	{
		z = x / 2;
	}
	else
	{
		z = (x / 2) + 1;
	}
	double y;
	y = z;
	y /= x;
	cout.precision(10);
	cout << fixed << y;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

struct SegTree {
    int n, len;
    vii lo, hi;
    vll seg;
    SegTree (int n) : n(n) {
        len = 4 * n + 1;
        lo.assign(len, 0);
        hi.assign(len, 0);
        seg.assign(len, 0);
        init(1, 1, n);
    }

    void init(int i, int l, int r) {
        lo[i] = l;
        hi[i] = r;
        if (l == r) return;
        int m = (l + r) / 2;
        init(2 * i, l, m);
        init(2 * i + 1, m + 1, r);
    }

    void update(int i, ll del) {
        incr(1, i, del);
    }

    void incr(int i, int j, ll del) {
        if (lo[i] > j or hi[i] < j) return;
        if (lo[i] == hi[i]) {
            seg[i] += del;
            return;
        }
        incr(2 * i, j, del);
        incr(2 * i + 1, j, del);
        seg[i] = max(seg[2 * i], seg[2 * i + 1]);
        // cerr << j << ", " << i << ": " << seg[i] << '\n';
    }

    ll maximum(int i) {
        return read(1, 1, i);
    }

    ll read(int i, int l, int r) {
        ll v = seg[i];
        if (lo[i] > r or hi[i] < l) return 0;
        if (l <= lo[i] and hi[i] <= r) return seg[i];
        
        ll res = read(2 * i, l, r);
        res = max(res, read(2 * i + 1, l, r));

        return res;
    }
};

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n;
    cin >> n;
    SegTree s(n);
    vii v(n);
    for (int &e : v) cin >> e;
    for (int i : v) {
        ll a;
        cin >> a;
        // cerr << i << ": " << s.maximum(i) << '\n';
        s.update(i, a + s.maximum(i));
        // cerr << i << ": " << s.maximum(i) << '\n';
    }
    // s.t();
    cout << s.maximum(n) << '\n';
}


Measured memory_bytes: 13568
import bisect
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = int(input())

cnt = 0
LUN = [[0] * 10 for _ in range(11)]
LUN_AC = [[0] * 10 for _ in range(11)]
LUN[0] = [1] * 10
LUN_AC[1] = [0] + [1] * 9

cnt = 0
for i in range(1, 11):
    # i桁目のLUN数
    for d in range(10):
        c = 0
        c += LUN[i-1][d - 1] if 1 <= d and i > 1 else 0
        c += LUN[i - 1][d]
        c += LUN[i - 1][d + 1] if d < 9 and i > 1 else 0

        if d != 0:
            cnt += c

        LUN[i][d] = c
        LUN_AC[i][d] = cnt

        #print("i,d,cnt", i, d, cnt)

        if K <= cnt:
            break

    if K <= cnt:
        break

#print(i, d)

keta = i
rest = K - cnt + c

ans = []
ans.append(d)

for i in range(keta - 1, 0, -1):
    #print("i,d,rest", i, d, rest)
    c1 = LUN[i][d - 1] if 1 <= d else 0
    if rest <= c1:
        ans.append(d - 1)
        d = d - 1
        continue
    else:
        rest -= c1

    c2 = LUN[i][d]

    if rest <= c2:
        ans.append(d)
        continue
    else:
        rest -= c2

    c3 = LUN[i][d + 1] if d < 9 else 0

    if rest <= c3:
        ans.append(d + 1)
        d = d + 1
        continue
    else:
        rest -= c3

    if rest >= 0:
        print(-1)
        exit()

print("".join(map(str, ans)))


Measured memory_bytes: 3316
#include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define mp make_pair
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

const ll mod = 998244353;
int main(){
    int n=in(),k=in();
    vecpii p(k);
    rep(i,k){
      int x=in(),y=in();
      p[i]=mp(x,y+1);
    }
    vecll ans(n*2+10),plus(n*2+10);
    ans[0]=1;
    plus[1]=-1;
    REP(e,p){
        plus[e.first]++;
        plus[e.second]--;
    }
    rep(i,n-1){
        ans[i+1]=((ans[i]+plus[i+1])%mod+mod)%mod;
        REP(e,p){
            plus[i+1+e.first]+=ans[i+1];
            plus[i+1+e.second]-=ans[i+1];
        }
    }
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 9584
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans = Integer.MAX_VALUE;
        int s1 = n / 6, s2 = n / 9;
        int[] TS = new int[n + 10];
        int[] TN = new int[n + 10];
        for (int i = 0; i <= n; i += 6) {
            int temp = i;
            while (temp / 6 > 0) {
                temp /= 6;
                TS[i] += temp % 6;
            }
            for (int j = 0; j < 6; j++) {
                if (i + j <= n) TS[i + j] = TS[i] + j;
            }
        }
        for (int i = 0; i <= n; i += 9) {
            int temp = i;
            while (temp / 9 > 0) {
                temp /= 9;
                TN[i] += temp % 9;
            }
            for (int j = 0; j < 9; j++) {
                if (i + j <= n) TN[i + j] = TN[i] + j;
            }
        }
        for (int i = 0; i <= s2; i++) {
            int nine=9*i;
            int six=(n-nine)-(n-nine)%6;
            if(six+nine<=n)ans=min(TS[six]+TN[nine]+(n-six-nine),ans);
        }
        out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N; 
    char S[10001];
    cin >> N;
    scanf("%s", S);
    int len = (int)strlen(S);
    rep(i, len){
        int word = (int)S[i] + N;
        if(word > (int)'Z'){
            word = (int)'A' + (word - (int)'Z' - 1);
        }
        S[i] = (char)word;
    }
    printf("%s\n", S);
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long;
const ll MAXS = 20;
const ll MAXN = 50;

class Node
{
public:
    ll Cost;
    ll Index;

    bool IsReversed;
    string LR;

public:
    Node(ll cost, ll index, bool isReversed, const string& lr)
    : Cost(cost), Index(index), IsReversed(isReversed), LR(lr)
    {}

public:
    bool operator<(const Node& node) const
    {
        return Cost != node.Cost ? Cost > node.Cost : Index > node.Index;
    }
};

bool isMatched(const string& lhs, const string& rhs)
{
    const auto ln = lhs.size(), rn = rhs.size();
    const auto n = min(ln, rn);

    rep (i, n) { if (lhs[i] != rhs[rn - i - 1]) { return false; } }
    return true;
}

int main()
{
    ll N;
    cin >> N;

    vector<string> S(N);
    vector<ll> C(N);
    rep (i, N) { cin >> S[i] >> C[i]; }

    ll ans = -1;

    priority_queue<Node> Q;
    rep (i, N) { Q.emplace(C[i], 0, false, S[i]); }

    set<string> LL, RR;

    while (!Q.empty())
    {
        const auto node = Q.top();
        Q.pop();

        if (isMatched(node.LR, node.LR))
        {
            ans = node.Cost;
            break;
        }

        // キャッシュを更新する
        {
            auto& cache = node.IsReversed ? RR : LL;
            if (cache.find(node.LR) != cache.end()) { continue; }

            cache.insert(node.LR);
        }

        // node -> index に 遷移する
        rep (i, N)
        {
            const auto& lhs = node.IsReversed ? S[i] : node.LR;
            const auto& rhs = node.IsReversed ? node.LR : S[i];

            // 相違が発生して遷移できない
            if (!isMatched(lhs, rhs)) { continue; }

            const auto newCost  = node.Cost + C[i];
            const auto newIndex = node.Index + 1;

            const auto isReversed = lhs.size() < rhs.size();

            // 残った方でチャレンジする
            const auto ss = isReversed ? rhs.substr(0, rhs.size() - lhs.size())
                                       : lhs.substr(rhs.size(), lhs.size() - rhs.size());

            auto& cache = isReversed ? RR : LL;
            if (cache.find(ss) != cache.end()) { continue; }

            Q.emplace(newCost, newIndex, isReversed, ss);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3700
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)

	res := "Yes"
	if len(S)%2 == 0 {
		for i := 0; i < len(S); i += 2 {
			char := S[i : i+2]
			if char != "hi" {
				res = "No"
			}
		}
	} else {
		res = "No"
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

int max = 55555;

int main(){
    int N;
    std::cin >> N;
    std::vector< int > P;
    std::vector< bool > Pb(max+1, true);
    int cnt = 0;
    for(int i=2; i<=max; i++){
        if(Pb[i]){
            P.push_back(i);
            if(i % 5 == 1){
                std::cout << i << std::endl;
                cnt++;
                if(cnt == N){
                    return 0;
                }
            }
            for(int j=i+i; j<=max; j+=i){
                Pb[j] = false;
            }
        }
    }
    
    
    return 0;
    
}


Measured memory_bytes: 3584
N,M,C = list(map(int, input().split()))
B = list(map(int,(input().split())))

A = []
count=0
for i in range(N):
    #A.append(list(map(int,(input().split()))))
    inp = list(map(int,(input().split())))
    su=0
    for j in range(M):
        su+=inp[j]*B[j]
    #print(su)
    if su+C>0:
        count+=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;

const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline int read()
{
    int x=0,fg=1;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=100010;
typedef pair<int,int> pii;
vector<pii> a[5];
stack<int> st;
bool vis[N];
int R,C,n;

pii check(int x,int y)
{
    if(x==0) return pii(1,y);
    if(y==C) return pii(2,x);
    if(x==R) return pii(3,y);
    if(y==0) return pii(4,x);
    return pii(0,0);
}

int main()
{
    int x1,y1,x2,y2;pii d1,d2;
    R=read();C=read();n=read();
    for(int i=1;i<=n;i++)
    {
        x1=read();y1=read();x2=read();y2=read();
        d1=check(x1,y1);d2=check(x2,y2);
        if(!d1.first||!d2.first) continue;
        a[d1.first].push_back(pii(d1.second,i));
        a[d2.first].push_back(pii(d2.second,i));
    }
    sort(a[1].begin(),a[1].end());
    sort(a[2].begin(),a[2].end());
    sort(a[3].begin(),a[3].end(),[](pii x,pii y){return x>y;});
    sort(a[4].begin(),a[4].end(),[](pii x,pii y){return x>y;});
    for(int i=1;i<=4;i++)for(pii x : a[i])
    {
        int y=x.second;
        if(!vis[y]) st.push(y),vis[y]=1;
        else if(st.top()!=y) return !puts("NO");
        else st.pop();
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 3544
program main
  implicit none
  character(100000) :: s
  integer :: i, cnt
  read(*, *) s
  cnt = 0
  do i = 2, len(trim(s))
    if (s(i - 1:i - 1) /= s(i:i)) then
      cnt = cnt + 1
    end if
  end do
  write(*, "(i0)") cnt
  contains
end


Measured memory_bytes: 700
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long q = sc.nextInt();
		long[] point = new long[n];
		for(int i = 0; i < n; i++) {
			point[i] = 0;
		}
		for(int i = 0; i < q; i++) {
			int ac = sc.nextInt() - 1;
			point[ac]++;
		}
		for(int i = 0; i < n; i++) {
			if(k - (q - point[i]) > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 69176
#include <iostream>

using namespace std;
int main(void){
    // Your code here!
    int N = 0;
    cin >> N;
    
    int A[N];
    int Ans[N+1];
    
    for(int i = 1; i < N; i++) {
        cin >> A[i];
        Ans[i] = 0;
    }
    Ans[N]=0;
    
    for(int i = 1; i < N; i++) {
        Ans[A[i]]++;
    }
    
    for(int i = 1; i < N+1; i++) {
        cout << Ans[i] << endl;
    }
    
    
    
    

}


Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

#define rep(i, n) for(int i=0;i<n;i++)

using namespace std;
int main() {
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s == "abc")
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++) {
        for (int j = i; j <= 9; j++) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define si(x) (ll)((x).size())
#define pb push_back
#define F first
#define S second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
#define all(x) (x).begin(), (x).end()
#define make_unique(x) (x).resize(unique(all(x))-(x).begin())

void solve()
{
    ll n, k, s;
    cin >> n >> k >> s;
    rep(i, k)
    cout << s << " ";
    rep(i, n - k)
    cout << (s == 1 ? s + 1 : s - 1) << " ";







}

int main()
{




    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;

    while(t--)
    {
        solve();
        // cout << endl;
    }


}




Measured memory_bytes: 1280
# coding: utf-8

import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def main():
    n,m = na()#swich,light
    ks = []
    swicthToLight = [[] for _ in range(n)]
    for i in range(m):
        ss = na()
        k = ss.pop(0)
        ks += [k]
        for s in ss:
            swicthToLight[s-1] += [i]
    ps = na()
    ans = 0
    for i in range(pow(2,n)):
        pstmp = [i for i in ps]
        for j in range(n):
            if ((i>>j) & 1):
                for light in swicthToLight[j]:
                    pstmp[light] += 1
                    pstmp[light] %= 2
        if sum(pstmp) == 0:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 42716
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll M, D;
	cin >> M >> D;

	ll ans = 0;

	repn(i, M)repn(j, D) {
		ll x = j / 10;
		ll y = j % 10;
		if (x >= 2 && y >= 2 && x*y == i) { ans++; }
	}
	cout << ans;
	system("PAUSE");

}


Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>


using namespace std;
typedef long long ll;

ll total = 1;
vector<ll > length;
vector<ll > P_length;

ll sum(ll N, ll X){
    if(N == 0){
        if(X <= 0){
            return 0;
        }else{
            return 1;
        }
    }else if(X <= 1 + length[N-1]){
        return sum(N-1, X-1);
    }else{
        return P_length[N-1] + 1 + sum(N-1, X-2-length[N-1]);
    }
}

int main(){

    ll N, X;
    cin >> N >> X;

    //length 
    length = vector<ll > (N + 1, 1);
    P_length = vector<ll >(N + 1, 1);
    for(ll i = 1; i <= N; i++){
        length[i] = 2 * length[i-1] + 3;
        P_length[i] = 2 * P_length[i-1] + 1;
    }
    /*
    cout << length[N] << endl;
    //バンズのとこだけ
    if(N >= X){
        cout << "0" << endl;
        return 0;
    }
    //パティをすべて食べれるとき
    if(N >= length[N] - X ){
        cout << P_length[N] << endl;
        return 0;
    }
    //パティを半分くらいまで食べれるとき
    if(length[N - 1] == X){
        cout << P_length[N-1] << endl;
        return 0; 
    }
    //半分より少し多めに食べれるとき
    if(length[N - 1] + 1 <= X || length[N - 1] + (N - 1) >= X){
        cout << P_length[N-1] + 1 << endl;
        return 0; 
    }
    */
    //それ以外 レベルLバーガーの中にL-1バーガー更にL-1バーガーの中に．．．というとき
    total = sum(N,X);
    cout << total << endl;

}

Measured memory_bytes: 384
s=input()
k=int(input())
l=[]
for v in range(len(s)):
  if s[v] not in l:
    l.append(s[v])
if k>1:
  for w in range(len(s)-1):
    if s[w:w+2] not in l:
      l.append(s[w:w+2])
if k>2:
  for x in range(len(s)-2):
    if s[x:x+3] not in l:
      l.append(s[x:x+3])
if k>3:
  for y in range(len(s)-3):
    if s[y:y+4] not in l:
      l.append(s[y:y+4])
if k>4:
  for z in range(len(s)-4):
    if s[z:z+5] not in l:
      l.append(s[z:z+5])
l.sort()
print(l[k-1])

Measured memory_bytes: 4072
# -*- coding: utf-8 -*-
# import math

X,Y = list(map(int, input().rstrip().split()))
#-----

calc = X
cnt = 0

while calc <= Y:
    calc *= 2
    cnt += 1

print(cnt)


# エラーになる・・・
# calc = math.log( (Y / X) , 2) + 1
# print( int(calc) )


Measured memory_bytes: 2940
//
//  main.cpp
//  walkAndTeleport
//
//  Created by Moondongguk on 2017. 1. 20..
//  Copyright © 2017년 Moondongguk. All rights reserved.
//
#include <stdio.h>
#include <iostream>

using namespace std;

long long town[100001];
long long int n, walk, teleport, dist;
long long piro;

int main(int argc, const char * argv[]) {
    scanf("%lld%lld%lld", &n, &walk, &teleport);
    for(int i=0;i<n;i++)
        scanf("%lld", &town[i]);
    
    for(int i=0;i<n-1;i++)
    {
        dist=town[i+1]-town[i];
        piro+=min(dist*walk, teleport);
    }
    cout<<piro<<endl;
    return 0;
}


Measured memory_bytes: 1024
from collections import defaultdict

blue=int(input())
blueList = []

for i in range(blue):
  blueList.append(input())

red=int(input())
redList = []

for i in range(red):
  redList.append(input())

dict = defaultdict(int)

for b in blueList:
  dict[b] += 1

for r in redList:
  dict[r] -= 1

max = -10000

for s in dict:
  if dict[s] > max:
    max = dict[s]

if max <= 0:
  max = 0
print(max)

Measured memory_bytes: 3316
#include<cstdio>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;

const int MAX=100005;
long long a[MAX];

int main()
{
    int t;
    while(~scanf("%d",&t))
    {
        for(int i=0;i<t;i++)
        {
            cin>>a[i];
        }
        sort(a,a+t);
        long long x=0,y=0,x1=1,y1=1;
        for(int i=t-2;i>=0;i--)
        {
            if(x1&&a[i]==a[i+1]) { x=a[i]; x1=0; i--; continue;}

            if(!x1&&y1&&a[i]==a[i+1]) { y=a[i]; y1=0;}

            if(y1+x1==0)break;

        }
        long long s=x*y;
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  int num0 = 0, num1 = 0;
  cin >> s;
  rep(i,s.length()){
    if (s[i] == '0') num0++;
    else
      num1++;
  }

  int ans = 2 * min(num0, num1);

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512