akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    auto mat = make_v(n, n, 0);
    REP(i, 0, n) {
        REP(j, 0, n) {
            cin >> mat[i][j];
        }
    }
    auto acc = make_v(n, n + 1, 0LL);
    REP(i, 0, n) {
        REP(j, 0, n) {
            acc[i][j + 1] += acc[i][j] + mat[i][j];
        }
    }
    ll ans = -(1LL << 60);
    REP(i, 0, n + 1) {
        REP(j, i + 1, n + 1) {
            ll t = 0;
            REP(k, 0, n) {
                if (t >= 0) {
                    t += acc[k][j] - acc[k][i];
                } else {
                    t = acc[k][j] - acc[k][i];
                }
                ans = max(ans, t);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, k;
    int x1, y1, x2, y2;
    cin >> h >> w >> k;
    cin >> x1 >> y1 >> x2 >> y2;
    x1--, y1--, x2--, y2--;
    VV<char> grid(h, V<char>(w));
    rep(i, h) rep(j, w) cin >> grid[i][j];
    VV<> dis(h, V<>(w, INF));
    dis[x1][y1] = 0;
    queue<P> q;
    q.push(P(x1, y1));
    while(!q.empty()) {
        P p = q.front();
        q.pop();

        int x = p.first;
        int y = p.second;

        rep(i, 4) srepn(j, 1, k) {
            int nx = x + dx[i] * j;
            int ny = y + dy[i] * j;
            if(!isIn(nx, ny, h, w)) break;
            if(isIn(nx, ny, h, w)) {
                if(grid[nx][ny] == '@') break;
                else if(dis[x][y] >= dis[nx][ny]) break;
                else if(dis[nx][ny] == INF){
                    dis[nx][ny] = dis[x][y] + 1;
                    q.push(P(nx, ny));
                }
            }
        }
    }
    cout << (dis[x2][y2] == INF ? -1 : dis[x2][y2])  << endl;
}

Measured memory_bytes: 11980
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

bool CheckKaibunString(string S)
{
	string temp = S;
	reverse(temp.begin(), temp.end());
	return S == temp;
}

int main(void)
{
	
	bool flag;

	string S;
	cin >> S;

	int N = (S.length() - 1) / 2;

	flag = CheckKaibunString(S) && CheckKaibunString(S.substr(N + 1)) && CheckKaibunString(S.substr(0, N));
	cout << (flag?"Yes":"No") << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#pragma warning (disable:4996)

int main()
{
	int num = 0;
	while (scanf("%d",&num)!=EOF)
	{
		int arr[102][102] = { 0 }, ans[102][102] = { 0 };
		for (int i = 0; i < num; i++)
		{
			scanf("%d %d", &arr[i][0], &arr[i][1]);
			int temp = 2;
			for (int j = 0; j < arr[i][1]; j++)
			{
				scanf("%d", &arr[i][temp]);
				temp++;
			}
		}
		for (int i = 0; i < num; i++)
		{
			int temp = 2;
			for (int j = 0; j < arr[i][1]; j++)
			{
				ans[i][arr[i][temp] - 1]++;
				temp++;
			}
			printf("%d", ans[i][0]);
			for (int j = 1; j < num; j++)
			{
				printf(" %d", ans[i][j]);
			}
			printf("\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2776
using System;


namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string ABC = Console.ReadLine();
            string[] abc = (ABC.Split(' '));
            int a = int.Parse(abc[0]);
            int b = int.Parse(abc[1]);
            int c = int.Parse(abc[2]);
            int count = 0;

            for (int i = a; i <= b; i++)
            {
                if (c % i == 0)
                    count++;
            }
            Console.WriteLine(count);   
        }
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    vector<char> a(3), b(3);
    rep(i, 0, 3) cin >> a.at(i) >> b.at(i);
    reverse(all(b));
    if (a == b) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,s,p,t=0;
    cin>>n;
    if(n%2==1){
        s=n/2;
        s+=1;
        p=n/2;
    }
    else{
        s=n/2;
        p=n/2;
    }
    t=s*p;
    cout<<t<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <vector>

struct HLDecomposition {
  struct Node {
    int ord, par, depth;
    int idx;
    int path_id = -1;
    Node() {}
  };

  const int N;
  std::vector<std::vector<int>> tree, pathes;
  std::vector<Node> nodes;
  std::vector<int> Q;

  HLDecomposition(int N) : N(N), tree(N), nodes(N) {}
  void add_edge(int u, int v) {
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  void build(int root = 0) {
    Q.reserve(N);
    Q.push_back(root);
    nodes[root].par = -1;
    nodes[root].depth = 0;
    for (int i = 0; i < Q.size(); i++) {
      int u = Q[i];
      auto& U = nodes[u];
      U.ord = i;
      for (int v : tree[u]) {
        if (U.par == v) continue;
        auto& V = nodes[v];
        V.par = u;
        V.depth = U.depth + 1;
        Q.push_back(v);
      }
    }
    decomposition();
  }
  void for_each(int u, int v, std::function<void(int, int, int)> f) const {
    while (nodes[u].path_id != nodes[v].path_id) {
      int head_u = pathes[nodes[u].path_id][0];
      int head_v = pathes[nodes[v].path_id][0];
      if (nodes[head_u].depth > nodes[head_v].depth) {
        std::swap(u, v);
        std::swap(head_u, head_v);
      }
      f(nodes[v].path_id, 0, nodes[v].idx + 1);
      v = nodes[head_v].par;
    }
    if (nodes[v].idx < nodes[u].idx) std::swap(u, v);
    f(nodes[v].path_id, nodes[u].idx, nodes[v].idx + 1);
  }
  int lca(int u, int v) const {
    int x;
    for_each(u, v, [&](int p, int l, int r) { x = pathes[p][l]; });
    return x;
  }
  void decomposition() {
    std::vector<int> subtree_size(N, 1);
    for (int i = N - 1; i > 0; i--) {
      subtree_size[nodes[Q[i]].par] += subtree_size[Q[i]];
    }
    for (int u : Q) {
      auto& U = nodes[u];
      if (U.path_id == -1) {
        U.path_id = pathes.size();
        pathes.emplace_back();
      }
      pathes[U.path_id].push_back(u);

      int max_subsize = -1, selected = -1;
      for (int v : tree[u]) {
        if (U.par == v) continue;
        if (max_subsize >= subtree_size[v]) continue;
        max_subsize = subtree_size[v];
        selected = v;
      }
      if (selected != -1) nodes[selected].path_id = U.path_id;
    }
    for (auto&& path : pathes) {
      for (int i = 0; i < path.size(); i++) {
        nodes[path[i]].idx = i;
      }
    }
  }
};
#include <cstdio>
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
// clang-format off
template<typename T=int>inline T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}if(m)x=-x;return x;}
template<typename T=int>inline void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on

int main() {
  int N = rd();
  HLDecomposition hl(N);
  for (int i = 0; i < N; i++) {
    int k = rd();
    for (int j = 0; j < k; j++) {
      hl.add_edge(i, rd());
    }
  }
  hl.build(0);
  int Q = rd();
  for (int i = 0; i < Q; i++) {
    int u = rd(), v = rd();
    wr(hl.lca(u, v));
  }
  return 0;
}

Measured memory_bytes: 16476
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N, K = MAP()
    A = LIST()
    dic = defaultdict(int)
    for x in A:
        dic[x] += 1

    dic_ = sorted(dic.items(), key=lambda x: x[1])
    # print(dic_)

    ans = 0
    if len(dic.keys()) > K:
        M = len(dic.keys()) - K
        for i in range(M):
            ans += dic_[i][1]
        print(ans)
    else:
        print(ans)


if __name__ == '__main__':
    main()


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

int main() {
	// your code goes here
	long long n,d,c=0;
	cin>>n>>d;
	while(n--)
	{
		long long x,y,i,j;
		cin>>x>>y;
		if(sqrt((x*x)+(y*y))<=d)
		c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { -1, 0, 1, 0 };

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin >> s;

	map<char, int> mp;
	for (auto c : s) {
		mp[c]++;
	}

	for (auto p : mp) {
		if (p.second != 2) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define umap unordered_map
#define uset unordered_set
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define ull unsigned ll
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(x) cout<<#x<<' '<<'='<<' '<<x<<'\n'
#define fo(i,a,b) for(int i=a;i<b;i++)
//typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
// const int mod=1e9+7;
// ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// ll modInverse(ll a){return power(a,mod-2);}
ll n,m,a,b,c,k,temp,x,y;
const int MAXN=100000+11;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>m;
if(n==1 || m==1)
{cout<<1;return ;}
ll evenrows=n/2;
ll evencolums=m/2;
ll oddrows=n-evenrows;
ll oddcolums=m-evencolums;
ll ans=(evencolums*evenrows+oddcolums*oddrows);
cout<<ans;





return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define printx(x) printf("%lld\n",x);
#define printxy(x,y) cout << x << y <<endl;
#define printxyz(x,y,z) cout << x << y << z <<endl;
#define deba(a) cout << #a << a << endl;
#define debab(a,b) cout << #a << a << #b << b << endl;
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	ll n, k;
	cin >> n >> k;
	ll a[k];
	rep(i, 0, k)
	cin >> a[i];
	while (true)
	{
		ll fl = 0;
		string s = to_string(n);
		// deba(s);
		for (int i = 0; i < s.length(); i++)
		{
			fl = 0;
			rep(j, 0, k)
			{
				// deba(s[i]);
				int x = (s[i] - '0');
				// deba(x);
				if (x == a[j])
				{
					fl = 1;
					break;
				}
			}
			if (fl == 1)
				break;
		}
		if (fl == 1)
			n++;
		else
			break;
	}
	cout << n;
	return 0;
}

Measured memory_bytes: 3740
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var mod = 998244353;
function mul(){for(var a=arguments,r=a[0],i=a.length;--i;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i])%mod;return r;}
var fac=[],finv=[],invs=[],pow2=[];
function fset(n){
  fac.length=n+1,fac[0]=fac[1]=1;
  for(var i=2;i<=n;)fac[i]=mul(fac[i-1],i++);
  finv.length=n+1,finv[0]=finv[1]=1,finv[n]=inv(fac[n]);
  for(i=n;2<i;)finv[i-1]=mul(finv[i],i--);
  //invs.length=n+1,invs[0]=invs[1]=1;
  //for(i=2;i<=n;)invs[i]=mul(fac[i-1],finv[i++]);
  //pow2.length=n+1,pow2[0]=1;
  //for(i=1;i<=n;i++)pow2[i]=pow2[i-1]*2%mod;
}
function inv(b){for(var a=mod,u=0,v=1,t;b;v=t)t=a/b|0,a-=t*b,u-=t*v,t=a,a=b,b=t,t=u,u=v;u%=mod;return u<0?u+mod:u;}
function pow(a,n){for(var r=1;n;a=mul(a,a),n>>=1)if(n&1)r=mul(a,r);return r;}
function ncr(n,r){return mul(fac[n],finv[r],finv[n-r]);}
function npr(n,r){return mul(fac[n],finv[r]);}
function mput(n){return (n%mod+mod)%mod;}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), s = next();
  var a = nexts(n);
  var dp = xArray(0,s+1);
  dp[0] = pow(2,n);
  var inv2 = inv(2);
  for(var i = 0; i < n; i++){
    for(var j = s-a[i]; j >= 0; j--){
      dp[j+a[i]] += mul(dp[j],inv2);
      dp[j+a[i]] %= mod;
    }
  }
  return dp[s];
}

Measured memory_bytes: 35652
import itertools

N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))
temp = itertools.product([0, 1], repeat=N)
ans = 0
for T in temp:
    an = 0
    for i, e in enumerate(T):
        if e == 1:
            an += V[i] - C[i]
    ans = max(ans,an)
print(ans)


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

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int n,m,k;
int kai[11], ans;
int s[11][11],p[11];
signed main() {
    cin >> n>> m;
    for (int i=0;i<m;i++) {
        cin >> kai[i];
        for (int j=0;j<kai[i];j++) {
            cin >> s[i][j];
        }
    }
    for (int i=0;i<m;i++) {
        cin >> p[i];
    }

    ans = pow(2,n);
    for (int i=0;i<(1<<n);i++) {
        int cnt[11] = {0,0,0,0,0,0,0,0,0,0,0};
        for (int j=0;j<n;j++) {
            // j番目がon
            if ((1<<j)&i) {
                for (int k=0;k<m;k++) {
                    for (int l=0;l<kai[k];l++) {
                        if (s[k][l] == j+1) {
                            cnt[k]++;
                        }
                    }
                }
            }
        }
        for (int j=0;j<m;j++) {
            if (cnt[j]%2 != p[j]) {
                ans--;
                break;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int p[5];
  int k;
  int flag = 0;
  scanf("%d",&p[0]);
  scanf("%d",&p[1]);
  scanf("%d",&p[2]);
  scanf("%d",&p[3]);
  scanf("%d",&p[4]);
  scanf("%d",&k);

  for(int i = 0; i < 5; i ++){
    for(int j = 0; j < 5; j ++){
      if(p[i] - p[j] <= 0){
        break;
      }else{
        if(p[i] - p[j] > k){
          flag = 1;
        }
      }
    }
  }

  if(flag){
    printf(":(");
  }else{
    printf("Yay!");
  }
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int g[5][5];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	rep(i, 3) rep(j, 3) cin >> g[i][j];	
	int n;
	cin >> n;
	map<int, int> v;
	rep(i, n){
		int x;
		cin >> x;
		v[x] = 1;
	}
	rep(i, 3){
		if(v[g[i][0]] && v[g[i][1]] && v[g[i][2]]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	rep(i, 3){
		if(v[g[0][i]] && v[g[1][i]] && v[g[2][i]]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	if(v[g[0][0]] && v[g[1][1]] && v[g[2][2]]){
		cout << "Yes" << endl;
		return 0;
	}
	if(v[g[0][2]] && v[g[1][1]] && v[g[2][0]]){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define len(val) static_cast<ll>(val.size())
#define rep(i, n) for(ll i=0; i<(n); i++)

const ll MAXN = 4000;
const ll MAXM = 400000;
const ll INF = 1e18;
ll N, M;

struct UnionFind
{
    std::vector<ll> data;
    UnionFind(ll size) : data(size, -1){}
    void initialize(void){
        for(ll i=0; i<(ll)data.size(); i++) data[i] = i;
    }
    bool merge(ll x, ll y){
        x = find(x); y = find(y);
        if(x == y) return false;
        else{ data[x] = y; return true; }
    }
    ll find(ll x){ //根っこを見つける関数
        if(data[x] == x) return x;
        else return data[x] = find(data[x]); //経路圧縮
    }
    bool isSame(ll x, ll y){
        return find(x) == find(y);
    }
};

struct edge{
  ll u, v, cost;
};

bool comp(const edge& r, const edge& l){
  return r.cost < l.cost;
}

edge es[MAXM];
ll mx[MAXN][MAXN];
bool visited[MAXN];
vector<P> G[MAXN];

void dfs(ll v, ll p, ll m = -1)
{
  if(visited[v]) return;
  mx[p][v] = m;
  visited[v] = true;
  for(auto a : G[v]){
    dfs(a.first, p, max(m, a.second));
  }
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> M;
  rep(i, M){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    es[i] = edge{a, b, c};
  }
  ll sum = 0;
  {
    sort(es, es+M, comp);
    UnionFind uf(N);
    uf.initialize();
    ll cnt = 0;
    rep(i, M){
      edge& e = es[i];
      if(!uf.isSame(e.u, e.v)){
        uf.merge(e.u, e.v);
        es[cnt] = edge{e.u, e.v, e.cost};
        cnt++;
        sum += e.cost;
        G[e.u].push_back(make_pair(e.v, e.cost));
        G[e.v].push_back(make_pair(e.u, e.cost));
      }
    }
  }
  for(int i=0; i<N; i++){
    memset(visited, false, sizeof(visited));
    dfs(i, i);
  }

  ll Q;
  cin >> Q;
  rep(q, Q){
    ll s, t;
    cin >> s >> t;
    s--; t--;
    cout << sum-mx[s][t] << endl;
  }
}


Measured memory_bytes: 136192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
ll dp[3003][3003][2];
ll a[3003];
ll f(int i,int j,int k)
{
       if(i>j){return 0;}
       if(dp[i][j][k] != -1){return dp[i][j][k];}
       if(k==0){
              return dp[i][j][k] = max(a[i]+f(i+1,j,1),a[j]+f(i,j-1,1));
       }
       else{
              return dp[i][j][k] = min(-a[i]+f(i+1,j,0),-a[j]+f(i,j-1,0));
       }
}
int main()
{
       int n;
       cin>>n;
       arrin(a,n);
       memset(dp,-1,sizeof dp);
       cout<<f(0,n-1,0)<<endl;
}


Measured memory_bytes: 141312
#include<cstdio>


int main(void){
  unsigned long long n,ans=0;

  scanf("%llu",&n);

  if(n%11==0)
    ans+=(n/11)*2 ;
  else if(n%11>6)
    ans+=(n/11)*2 +2;
  else
    ans+=(n/11)*2  + 1;

  printf("%llu\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include <atcoder/dsu>
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {
    int N, Q;
    cin >> N >> Q;
    atcoder::dsu d(N);
    for (int z = 0; z < Q; z++) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) {
            d.merge(u, v);
        }else {
            cout << (d.same(u, v) ? 1 : 0) << "\n";
        }
    }
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int r;
  cin>>r;

  cout<<3*r*r<<endl;


  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var roundSqrtN = Math.Round(Math.Sqrt(N));
            var ret = N - 1;
            for (int i = 2; i < roundSqrtN + 1; i++)
            {
                long a = N % i;
                if ( a == 0)
                {
                    ret = Math.Min(ret, i + N / i - 2);
                }
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        string S = cin.nextString();

        int a = 0;
        int b = 0;
        int num1 = 0;
        int num2 = 0;

        for (int i = 0; i < 4; i++)
        {
            if (a == 0)
            {
                a = S[i];
                num1++;
            }
            else if (b == 0 && a != S[i])
            {
                b = S[i];
                num2++;
            }
            else if (a == S[i])
            {
                num1++;
            }
            else if (b == S[i])
            {
                num2++;
            }
        }

        if (num1 == 2 && num2 == 2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


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

int main() {

    while(true){

        int n,p;

        cin >> n >> p;

        if(n == 0){
            break;
        }

        int maxp = p;

        list<pair<int,int> > l;

        for(int i=0; i<n; i++){
            l.push_back(make_pair(0,i));
        }

        list<pair<int,int> >::iterator itr = l.begin();

        while(true){

            if(p > 0){
                p--;
                itr->first++;
                if(itr->first == maxp){
                    cout << itr->second << endl;
                    break;
                }
            }
            else{
                p += itr->first;
                itr->first = 0;
            }

            itr++;

            if(itr == l.end()){
                itr = l.begin();
            }

        }

    }

    return 0;
}


Measured memory_bytes: 3000
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n;
	cin >> n;
	long long int a[100000];
	long long int g = 0, k = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		
			g+=a[i];
		
	}
	if (g % 2 == 1)
	{
		cout << "NO" << endl;
	}
	else
	{
		
			cout << "YES" << endl;
		
	}

}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		long h = sc.nextInt();
		long w = sc.nextInt();
		
		int n = sc.nextInt();
		
		HashSet<Long> hs1 = new HashSet<>();
		HashSet<Long> hs2 = new HashSet<>();
		
		for (int i = 0; i < n; i++) {
			long a = sc.nextInt() - 1;
			long b = sc.nextInt() - 1;
			hs1.add(a * w + b);
		}
		
		long[] count = new long[10];
		count[0] = (h - 2) * (w - 2);
		
		for (long l : hs1) {
			long a = l / w;
			long b = l % w;
			for (long i = a - 1; i <= a + 1; i++) {
				for (long j = b - 1; j <= b + 1; j++) {
					
					if (0 < i && i < h - 1 && 0 < j && j < w - 1 && !hs2.contains(i * w + j)) {
						
						int tmp = 0;
						for (long ii = i - 1; ii <= i + 1; ii++) {
							for (long jj = j - 1; jj <= j + 1; jj++) {
								if (hs1.contains(ii * w + jj)) tmp++;
							}
						}
						count[tmp]++;
						count[0]--;
						hs2.add(i * w + j);
						
					}
				}
			}
		}
		
		for (int i = 0; i < 10; i++) {
			out.println(count[i]);
		}
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 110560
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+10;
ll max2d=1e3+3;
ll INF = 1e18;
const ll lg=22; 

void code_idhr_h(){
    ll N,K; cin>>N>>K;
    ll A[N+3]; mem(A , 0);
    for(ll i=1; i<=N; i++) cin>>A[i];
    ll def[N+3]; mem(def , 0);
    while(K--){
        for(ll j=1; j<=N; j++){
            ll pos1 = max(1ll , j-A[j]);
            ll pos2 = min(N , j+A[j])+1;
            def[pos1]++;
            def[pos2]--;
        }
        ll cnt = 0;
        for(ll j=1; j<=N; j++){
            def[j] += def[j-1];
            A[j] = min(N , def[j]);
            if(A[j]==N) cnt++;
        }
        if(cnt==N) break;
        mem(def , 0);
    }
    for(ll i=1; i<=N; i++) cout<<A[i]<<" ";
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	ll n,m;
	cin >> n >> m;
	ll ans=0;
	ans+=min(n,m/2);
	ans+=max(0LL,(m-2*n)/4);
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int a,b;cin>>a>>b;
    if(a>=b){
        rep(i,a)cout<<b;
        cout<<endl;
    }else{
        rep(i,b)cout<<a;
        cout<<endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

const int N=1e5+5;
int n;
int a[N],b[N];
long long ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n+1;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) scanf("%d",b+i);
	for(int i=1;i<=n;i++){
		int gt=min(a[i],b[i]);
		a[i]-=gt;
		b[i]-=gt;
		ans+=1ll*gt;
		gt=min(a[i+1],b[i]);
		a[i+1]-=gt;
		b[i]-=gt;
		ans+=1ll*gt;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		System.out.println(Math.max(c+b-a, 0));
		sc.close();
	}
}

Measured memory_bytes: 23252
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
inline int Rand(){return rand()*32768+rand();}
int get_id(char c){
	if(c>='a'&&c<='z')return c-'a';
	if(c>='A'&&c<='Z')return c-'A'+26;
	return c-'0'+52;
}
char rev(int x){
	if(x<26)return 'a'+x;
	if(x<52)return 'A'+x-26;
	return '0'+x-52;
}
int cnt[66],func[66],n,tot_ask;
string cmp="";
int dp[199][199];
int dist(string s){
	memset(dp,inf,sizeof dp);
	dp[0][0]=0;tot_ask++; 
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=cmp.size();j++){
			if(j)dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
			if(i)dp[i][j]=min(dp[i][j],dp[i-1][j]+1);
			if(i&&j)dp[i][j]=min(dp[i][j],dp[i-1][j-1]+(s[i-1]!=cmp[j-1]));
		}
	}
	return dp[s.size()][cmp.size()];
}
int ask(string s){
	#ifdef LOCAL
		return dist(s);
	#endif
	cout<<"? "<<s<<endl;
	fflush(stdout);int x;cin>>x;return x;
}
int Get(string ret,string s,int pos,char c){
	int tot=ret.size()+1+s.size()-pos;
	string ss=ret+c+getstr(s,pos,s.size()-1);
	tot=ss.size();
	#ifdef LOCAL
		return dist(ss)==n-tot;
	#endif
	return n-tot==ask(ss);
}
string merge(string s1,string s2){
	int pos=0;
	string ret="";
	if(rand()&1)swap(s1,s2);
	for(int i=0;i<s1.size();i++){
		while(pos<s2.size()&&Get(ret,s2,pos,s1[i])==0)
		ret.push_back(s2[pos]),pos++;
		ret.push_back(s1[i]);
	}
	while(pos<s2.size())ret.push_back(s2[pos++]);
	return ret;
}
int main(){
	srand(time(0));
	for(int i=0;i<128;i++)cmp.push_back(rev(rand()%62));
	for(int i=0;i<62;i++){
		string s="";s.push_back(rev(i));
		for(int i=0;i<7;i++)s=s+s;
		int got=ask(s);
		cnt[i]=128-got;
	}
	for(int i=0;i<62;i++)n+=cnt[i];
	set<pair<int,string> >s;
	for(int i=0;i<62;i++){
		if(cnt[i]){
			string ins="";
			for(int j=0;j<cnt[i];j++)ins.push_back(rev(i));
			s.insert(make_pair(cnt[i],ins));
		}
	}
	while(s.size()>1){
		string s1=s.begin()->second;s.erase(s.begin());
		string s2=s.begin()->second;s.erase(s.begin());
		string s3=merge(s1,s2);
		s.insert(make_pair(s3.size(),s3));
	}
	cout<<"! "<<s.begin()->second<<endl;
	if(tot_ask>=860-128)assert(0);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1000000007;

inline void update_diff(vector<unordered_map<int,int>>& cur, vector<unordered_map<int,int>>& prev, 
        vector<vector<int32_t>>& diff, const int row_id, const int W, const int H, const int max_diff) {
  for (auto pat : prev[0]) {
    int new_diff = diff[row_id][0] + pat.first;
    if ((W + (H - row_id)) * max_diff >= new_diff)
      cur[0][new_diff]++;
    new_diff = abs(diff[row_id][0] - pat.first);
    if ((W + (H - row_id)) * max_diff >= new_diff)
      cur[0][new_diff]++;
  }
  for (int c = 1; c < W; c++) {
    for(auto pat : prev[c]) {
      int new_diff = diff[row_id][c] + pat.first;
      if ((W -c + H - row_id) * max_diff >= new_diff)
        cur[c][new_diff]++;
      new_diff = abs(diff[row_id][c] - pat.first);
      if ((W -c + H - row_id) * max_diff >= new_diff)
        cur[c][new_diff]++;
    }
    for(auto pat : cur[c-1]) {
      int new_diff = diff[row_id][c] + pat.first;
      if ((W -c + H - row_id) * max_diff >= new_diff)
        cur[c][new_diff]++;
      new_diff = abs(diff[row_id][c] - pat.first);
      if ((W -c + H - row_id) * max_diff >= new_diff)
        cur[c][new_diff]++;
    }
  }
  return;
}

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int32_t H, W;
  cin >> H >> W;
  vector<vector<int32_t>> diff(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> diff[i][j]; 
    }
  }
  int max_diff = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int tmp = 0;
      cin >> tmp;
      diff[i][j] = abs(diff[i][j] - tmp); 
      max_diff = max(max_diff, diff[i][j]);
    }
  }

  vector<unordered_map<int,int>> diff_patA(W);
  diff_patA[0][diff[0][0]]++;
  for (int c = 1; c < W; c++) {
    for(auto pat : diff_patA[c-1]) {
      int new_diff = diff[0][c] + pat.first;
      diff_patA[c][new_diff]++;
      new_diff = abs(diff[0][c] - pat.first);
      diff_patA[c][new_diff]++;
    }
  }
  vector<unordered_map<int,int>> diff_patB(W);
  for (int row_id = 1; row_id < H;) {
    update_diff(diff_patB, diff_patA, diff, row_id, W, H, max_diff);
    row_id++;
    if (row_id == H) {
      break;
    }
    for (auto& map : diff_patA) {
      map.clear();
    }
    update_diff(diff_patA, diff_patB, diff, row_id, W, H, max_diff);
    row_id++;
    if (row_id == H) {
      diff_patB = diff_patA;
      break;
    }
    for (auto& map : diff_patB) {
      map.clear();
    }
  }

  int min_diff = INT_MAX;
  for (auto res : diff_patB[W-1]) {
    min_diff = min(min_diff, res.first);
  }
  cout << min_diff << endl;
  return 0;
}


Measured memory_bytes: 23040
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int n = 0;
    int ans = INT_MAX;
    cin >> n;
    long long buf = 0;
    for (int i=0; i<n; i++) {
        cin >> buf;
        int count = 0;
        while (buf%2 == 0) {
            buf /= 2;
            count++;
        }
        if (count < ans) ans = count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <bits/stdc++.h>

using namespace std;

int main()
{
#ifdef _MSC_VER
	freopen("e.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false);
	int n, m, l;
	cin >> n >> m >> l;
	++n;
	++m;
	vector<vector<long long>> a(n, vector<long long>(m));
	for (int i = 0; i < l; i++) {
		int x, y, v;
		cin >> x >> y >> v;
		--x;
		--y;
		a[x][y] = v;
	}
	vector<vector<vector<long long>>> f(n, vector<vector<long long>>(m, vector<long long>(4)));
	for (int x = 0; x < n; x++) {
		for (int y = 0; y < m; y++) {
			for (int c = 0; c <= 3; c++) {
				if (x + 1 < n) {
					f[x + 1][y][0] = max(f[x + 1][y][0], f[x][y][c] + (c + 1 <= 3 ? a[x][y] : 0));
				}
				if (y + 1 < m) {
					f[x][y + 1][c] = max(f[x][y + 1][c], f[x][y][c]);
					if (c + 1 <= 3) {
						f[x][y + 1][c + 1] = max(f[x][y + 1][c + 1], f[x][y][c] + a[x][y]);
					}
				}
			}
		}
	}
	cout << f[n - 1][m - 1][0] << endl;
	return 0;
}


Measured memory_bytes: 706460
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

struct UnionFind {
  vector<int> par;
    
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
    
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
    
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
    
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
    
  int size(int x) {
    return -par[root(x)];
  }
};


vector<pair<int, int> > Input;
vector<int> Output;

signed main() {
  int N, M; cin  >> N >> M;
  
  UnionFind Forest(N);
  
  for (int i = 0; i < M; i++) {
    int a, b; cin >> a >> b;
    a--; b--;
    Input.push_back(make_pair(a, b));
  }


  long long cur = N * (N - 1) / 2;

  Output.push_back(cur);
  
  for (int i = Input.size() - 1; i >= 0; i--) {
    pair<int, int> A = Input[i];
    if (Forest.issame(A.first, A.second)) {
      Output.push_back(cur);
    } else {
      // cout << "A is :"  << endl;
      // cout << A.first << " " << A.second << endl;
      // cout << "Forest is :" << endl;
      // cout << Forest.size(A.first) << " " << Forest.size(A.second) << endl;
      cur = cur - Forest.size(A.first) * Forest.size(A.second);
      Output.push_back(cur);
      Forest.merge(A.first, A.second);
    }
  }

  reverse(Output.begin(), Output.end());

  for (int i = 1; i < Output.size(); i++) {
    cout << Output[i] << endl;
  }
}


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  ll n, a, b, c, d, e;
  cin >> n>> a>> b>> c>> d>> e;

    cout << (n-1+min({a, b, c, d, e}))/min({a, b, c, d, e})+4 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int N,S=0;
  int B[102];
  scanf("%d",&N);
  for(int i=1;i<N;i++)
    scanf("%d",B+i);
  B[0]=B[1];
  B[N]=B[N-1];
  for(int i=1;i<=N;i++){
    S+=(B[i-1]<=B[i]?B[i-1]:B[i]);
  }
  printf("%d\n",S);
  return 0;
}

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

struct point{
  double x, y;
};

void koch(int n, point p1, point p2){
  point  p3, p4, p5;
  double rad60=M_PI*60.0/180.0;
  
  if(n==0) return;
  
  p3.x=(2.0*p1.x+p2.x)/3.0;
  p3.y=(2.0*p1.y+p2.y)/3.0;

  p4.x=(p1.x+2.0*p2.x)/3.0;
  p4.y=(p1.y+2.0*p2.y)/3.0;

  p5.x=(p4.x-p3.x)*cos(rad60)-(p4.y-p3.y)*sin(rad60)+p3.x;
  p5.y=(p4.x-p3.x)*sin(rad60)+(p4.y-p3.y)*cos(rad60)+p3.y;

  koch(n-1, p1, p3);
  printf("%.8f %.8f\n", p3.x, p3.y);
  koch(n-1, p3, p5);
  printf("%.8f %.8f\n", p5.x, p5.y);
  koch(n-1, p5, p4);
  printf("%.8f %.8f\n", p4.x, p4.y);
  koch(n-1, p4, p2);
}

int main(void){
  int n;
  point p1, p2;
  
  scanf("%d", &n);

  p1.x=0.0; p1.y=0.0;
  p2.x=100.0; p2.y=0;
  
  printf("%.8f %.8f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);
  
  return 0;
}


Measured memory_bytes: 3184