akhauriyash/Code-Regression huggingface dataset:
// AtCoder template
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

ll dp[3001][3001];

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

    const ll MOD = 998244353;
    int n,s; cin >> n >> s;
    int a[n]; rep(i,n) cin >> a[i];
  	dp[0][0] = 1LL;
    rep(i,n){
        for(int j = 0; j <= s; ++j){
            dp[i+1][j] += 2*dp[i][j];
          	dp[i+1][j] %= MOD;
          	if(j - a[i] >= 0){
              dp[i+1][j] += dp[i][j-a[i]];
              dp[i+1][j] %= MOD;
            }
        }
    }
  
    cout << dp[n][s] << endl;
}

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

template<class T>
struct Dinic {
	using value_type = T;
private :
	const value_type INF = numeric_limits<value_type>::max();
	struct Edge {
	public : 
		int to, rev; value_type cap;
		Edge (int to, value_type cap, int rev) :
			to(to), cap(cap), rev(rev) { }
    };
    vector<int> level, idx;
    vector<vector<Edge>> g;
public : 
	Dinic (int n) : g(n), level(n), idx(n) { }

	Dinic (int l, int r, vector<pair<int, int>> &edges) : g(l + r + 2), level(l + r + 2), idx(l + r + 2) {
		for (int i = 1; i <= l; i++) add_edge(0, i, 1);
		for (int i = 1; i <= r; i++) add_edge(l + i, l + r + 1, 1);
		for (const auto &p : edges) add_edge(p.first + 1, p.second + l + 1, 1);
	}

	void add_edge (int from, int to, value_type cost) {
		g[from].emplace_back(to, cost, g[to].size());
		g[to].emplace_back(from, 0, g[from].size() - 1);
	}

	void init (int s) {
		fill(level.begin(), level.end(), -1); level[s] = 0;
		queue<int> que; que.emplace(s);
		while (not que.empty()) {
			const int v = que.front(); que.pop();
			for (const Edge &e : g[v]) {
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					que.emplace(e.to);
				}
			}
		}
	}

	value_type find_flow (int v, int t, value_type f) {
		if (v == t) return f;
		for (int &i = idx[v]; i < g[v].size(); i++) {
			Edge &e = g[v][i];
			if (e.cap > 0 and level[v] < level[e.to]) {
				value_type flow = find_flow(e.to, t, min(f, e.cap));
				if (flow > 0) {
					e.cap -= flow;
					g[e.to][e.rev].cap += flow;
					return flow;
				}
			}
		}
		return 0;
	}

	value_type max_flow (int s, int t) {
		value_type ret = 0;
		while (true) {
			init(s);
			if (level[t] < 0) break;
			fill(idx.begin(), idx.end(), 0);
			while (true) {
				value_type flow = find_flow(s, t, INF);
				if (flow <= 0) break;
				ret += flow;
			}
		}
		return ret;
	}

	vector<pair<int, int>> bipartite_matching (int l, int r) {
		max_flow(0, l + r + 1);
		vector<pair<int, int>> ret;
		for (int v = 1; v <= l; v++) {
			for (const auto &e : g[v]) {
				if (e.to == 0 or e.cap > 0) continue;
				ret.emplace_back(v - 1, e.to - l - 1);
				break;
			}
		}
		return ret;
	}

};

int main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int l, r, m;
	cin >> l >> r >> m;
	vector<pair<int, int>> e(m);
	for (int i = 0; i < m; i++) {
		cin >> e[i].first >> e[i].second;
	}
	
	Dinic<int> g(l, r, e);
	
	cout << g.max_flow(0, l + r + 1) << '\n';
	
	return 0;
}


Measured memory_bytes: 3428
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define MOD 1000000007

#define ARRAY_MAX 1005

/*素因数分解*/
map<ll,ll> prime_factorization(ll m){

    map<ll,ll> tmp;
    for(ll i = 2;i * i <= m;i++){
        while (m % i == 0) {
            tmp[i]++;
            m /= i;
        }
    }
    if(m != 1){
        tmp[m] = 1;
    }
    tmp[1] = 1;
    return tmp;
}

int main(){

    ll n,p;
    cin >> n >> p;
    map<ll,ll> mp = prime_factorization(p);
    ll ans = 1LL;
    for(auto itr:mp){
        for(ll i = 0;i < itr.second/n;i++){
            ans *= itr.first;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
//#include"functions.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define LDEPS 1e-9
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,m,n) for(int a=m;a<n;a++)
#define repn(a,m,n,p) for(int a=m;a<n;a+=p)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0xff,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	int c=a+b;int d=a-b;int e=a*b;
	cout<<max(c,max(d,e));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a+b)
    {
        cout<<min(k,a);
    }
    else
    {
       long long rem = k-a-b;
       long long res = a-rem;
       cout<<res; 
    }
    
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
	int N;

	cin >> N;

	for (int i = 0; i <= N; i += 4) {
		for (int j = 0; j + i <= N; j += 7) {
			if (i + j == N) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

bool is_prime(int n){
    int ans = 0;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0)ans++;
        if(n % i == 0 && i * i != n && n % (n/i) == 0)ans++;
    }
    return (ans == 2 ? true : false);
}
int main() {
    int n;
    cin >> n;
    int cnt = 0;
    int i = 1;
    while(cnt < n){
        if(is_prime(i) && i % 5 == 1){
            cout << i << " ";
            cnt++;
        }
        i++;
    }
    cout << endl;
}


Measured memory_bytes: 3640
def show(array):
    for i in range(len(array)):
        if (i+1) >= len(array):
            print(array[i])
        else:
            print(array[i], end=' ')


def bubble_sort(c, n):
    for i in range(0, n):
        for j in range(n-1, i, -1):
            if c[j][1:] < c[j-1][1:]:
                c[j], c[j-1] = c[j-1], c[j]

    return c

def selection_sort(c, n):
    for i in range(0, n):
        
        minj = i
        for j in range(i+1, n):
            if c[j][1:] < c[minj][1:]:
                minj = j
        # if i != minj:
        c[i], c[minj] = c[minj], c[i]
    return c


def main():
    N = int(input())
    cards = list(input().split(' '))
    cards2 = cards.copy()

    # value_sorted = sorted(cards, key=lambda x: x[1:])
    bubble_result = bubble_sort(cards, N)
    selection_result = selection_sort(cards2, N)

    show(bubble_result)
    print('Stable')
    show(selection_result)
    if bubble_result == selection_result:
        print('Stable')
    else:
        print('Not stable')


main()


Measured memory_bytes: 5616
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<limits.h>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int IINF=INT32_MAX;
static const ll LINF=INT64_MAX;
static const ll mod=1e9+7;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

int K;
string S;

int main(){
    cin>>K;
    cin>>S;
    if(S.size()<=K)cout<<S<<endl;
    else {
        for(int i=0;i<K;++i)cout<<S[i];
        cout<<"..."<<endl;
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,w;cin>>h>>w;
  vector<vector<char > >mat(h,vector<char >(w,'.'));
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      cin>>mat[i][j];
  //note which rows have complete 
  vector<int >rows(h,0);
  vector<int >cols(w,0);
  for(int i=0;i<h;i++){
  	int times=0;
    for(int j=0;j<w;j++)if(mat[i][j]=='.')times++;
    if(times==w)rows[i]=1;
  }
  for(int j=0;j<w;j++){
  	int times=0;
    for(int i=0;i<h;i++)if(mat[i][j]=='.')times++;
    if(times==h)cols[j]=1;
  }
  for(int i=0;i<h;i++){
  	if(rows[i]==1)continue;
    for(int j=0;j<w;j++)if(cols[j]!=1)cout<<mat[i][j];
    cout<<'\n';
  }
}

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

using namespace std;

const long long INF = 1LL << 60;
typedef long long int lli;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n;
    cin >> n;

    int k[n][3];
    for (int i = 0; i < n; ++i) {
        cin >> k[i][0] >> k[i][1] >> k[i][2];
    }

    lli happy[n][3];
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) happy[i][j] = 0;
    }

    happy[0][0] = k[0][0];
    happy[0][1] = k[0][1];
    happy[0][2] = k[0][2];

    for (int i = 1; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            happy[i][j] = max(happy[i-1][(j+1)%3] + k[i][j], happy[i-1][(j+2)%3] + k[i][j]);
        }
    }

    lli ans = 0;
    chmax(ans, happy[n-1][0]);
    chmax(ans, happy[n-1][1]);
    chmax(ans, happy[n-1][2]);

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

Measured memory_bytes: 7152
using System;
namespace Program_0188 {
	class Program {
		static void Main(string[] args) {
			while (true) {
				int n = int.Parse(Console.ReadLine());
				if (n == 0) break;
				int[] a = new int[n];
				for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine());
				int d = int.Parse(Console.ReadLine());
				int l = 0, r = n - 1, c = 0;
				while (r - l >= 0) {
					int m = (l + r) / 2; c++;
					if (a[m] == d) break;
					if (a[m] < d) l = m + 1;
					else r = m - 1;
				}
				Console.WriteLine(c);
			}
		}
	}
}

Measured memory_bytes: 9148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

vector<int> color(210);
vector<vector<int>> g(210);
bool dfs(int x,int c){
	color[x]=c;
	for(auto itr:g[x]){
		if(color[itr]==c) return false;
		if(color[itr]==0 && !dfs(itr,-c)) return false;
	}
	return true;
}
/*
ll dfs2(ll v,ll sum){
  used[v]=true;
  cout<<v+1<<' '<<sum<<endl;
  ll ret=0;
  bool flag=false;
  for(auto itr:g[v]){
    if(!used[itr]){
      ret=max(ret,dfs2(itr,sum+1));
      flag=true;
    }
  }
  if(flag) return ret;
  else return sum;
}
*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<string> s(n);
  rep(i,n) cin>>s[i];
  rep(i,n)rep(j,n){
    if(s[i][j]=='1'){
      g[i].push_back(j);
    }
  }
  bool flag=dfs(0,1);
  if(!flag) cout<<-1<<endl;
  else{
    ll ans=0;
    rep(i,n){
      queue<ll> que;
      que.push(i);
      vector<ll> d(n,1e9);
      d[i]=1;
      while(!que.empty()){
        ll v=que.front();
        que.pop();
        for(auto itr:g[v]){
          if(d[itr]==1e9){
            d[itr]=d[v]+1;
            que.push(itr);
          }
        }
      }
      //cout<<i<<' ';
      //cout_vec(d);
      ans=max(ans,*max_element(begin(d),end(d)));
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 512
N, M = map(int, input().split())

forw = set()
backw = set()

for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    forw.add(b)
  if b == N:
    backw.add(a)

if len(forw&backw) > 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 57944
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
	int n,i,j,f;
	char s[1030],q[30],sq[30];
	scanf("%d",&n);
	while(n--){
		scanf("%s",s);
		sprintf(q,"%c",s[0]);
		//strcpy(q,sq);
		f=1;
		for(i=3;i<strlen(s);i+=3){
			if(s[i-1]=='>'){
				if(f==strlen(q)){
					sprintf(sq,"%s%c",q,s[i]);
					strcpy(q,sq);
					f++;
				}else f++;
			}else{
				if(f==1){
					sprintf(sq,"%c%s",s[i],q);
					strcpy(q,sq);
				}else f--;
			}
			//printf("%d %s\n",f,q);
		}
		printf("%s\n",q);
	}
	return 0;
}

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

namespace ABC141
{
    class ABC141_C
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = s[0];
            int k = s[1];
            int q = s[2];
            
            var p = Enumerable.Repeat(0, n).ToArray();
            for (int i = 0; i < q; i++)
            {
                p[int.Parse(Console.ReadLine())-1]++;
            }

            for (int j = 0; j < n; j++)
            {
                if (p[j] <= q-k)
                    Console.WriteLine("No");
                else
                    Console.WriteLine("Yes");
            }
        }
    }
}

Measured memory_bytes: 18908
#include<bits/stdc++.h>
#define int long long
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h;
    cin>>h;
    int p=log2(h)+1;
    int ans=pow(2,p)-1;
    cout<<ans<<endl;
    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX=100;
const int WMAX=100000;
int N, W;
long long dp[NMAX+1][WMAX+1];

int main() {
  cin >> N >> W;
  vector<long long> w(N), v(N);
  for(int i = 0; i < N; ++i) {
    cin >> w[i] >> v[i];
  }
  for(int i = N-1; i >= 0; --i) {
    for(int j  = 0; j <= W; ++j) {
      if(j < w[i]) {
        dp[i][j] = dp[i+1][j];
      } else {
        dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i]);
      }
    }
  }
  cout << dp[0][W] << endl;

  return 0;
}


Measured memory_bytes: 78336
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll a;
	long double b;
	cin>>a>>b;
	cout<<(ll)((a*(ll)(b*100+0.5)/100))<<endl;
	return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []a = new int [n];
		int count = 0;
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < n - 2; i++) {
			if((a[i+1] > a[i] && a[i+1] < a[i+2]) || (a[i+1] < a[i] && a[i+1] > a[i+2])) {
				count++;
			}
		}
		System.out.println(count);
		
		

	}

}


Measured memory_bytes: 23380
#include <iostream>
using namespace std;

int main () {
	int a,b;
	
	cin >> a >> b ;
	
	if(a < b) {
	cout << "a < b" << endl;
	}
	
	else if (a > b){
	cout << "a > b" << endl;
	}
	
	else {
	cout << "a == b" << endl;
	}
	
	return 0;

}

Measured memory_bytes: 1156
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long

using namespace std;

int main()
{
	string a,b;
	cin >> a >> b;
	int otpt = 0;
	for (int i=0;i<a.length();i++)
	{
		if (a[i]==b[i])
		{
			otpt++;
		}
	}
	cout << otpt;
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

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

	string k;

	cin >> k; 
	if (k[2] == k[3] && k[4] == k[5]) {
		cout << "Yes";
	}
	else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
int m, n;
int po[13] = {};

void init(){
    po[0] = 1;
    for(int i = 1; i < 13; i++) po[i] = po[i - 1] * 3;
}

int dfs(vector<string> &data, vector<int> &dp, int S){
    
    int ret = dp[S];
    if(ret != MOD) return ret;
    string state = "";
    int temp_S = S;
    for(int i = 0; i < m; i++){
        string add = "";
        if(S % 3 == 0) add = "0";
        else if(S % 3 == 1) add = "1";
        else add = "2";
        
        state = add + state;
        S /= 3;
    }

    //cout << "state is " << state << endl;
    //残っている data の数
    int cnt = 0;
    
    for(int i = 0; i < n; i++){
        bool ok = true;
        for(int j = 0; j < m; j++){
            if(state[j] == '2') continue;
            if(data[i][j] != state[j]) ok = false;
        }
        cnt += ok;
    }

    if(cnt <= 1){
        ret = 0;
        dp[S] = ret;
        //cout << "dp[" + state + "] = " << dp[S] << endl;        
        return ret;
    }

    // 未決定 (2) のところを 0 or 1 に変更して遷移する
    S = temp_S;
    
    for(int i = 0; i < m; i++){
        if(state[i] == '2'){
            int T1 = S + po[m - i - 1] * (0 - 2);
            int T2 = S + po[m - i - 1] * (1 - 2);
            //cout << S << " " << state << " " << T1 << " " << T2 << endl;
            int temp = max(dfs(data, dp, T1), dfs(data, dp, T2)) + 1;
            ret = min(ret, temp);
        }
    }

    dp[S] = ret;
    //cout << "dp[" + state + "] = " << dp[S] << endl;            
    return ret;
}

signed main(){

    init();

    while(1){
        cin >> m >> n;
        if(n == 0) break;
        vector<string> data(n);
        for(int i = 0; i < n; i++) cin >> data[i];

        int S = (int)po[m] - 1;

        // 状態 S を特定するために必要な最大の質問回数
        vector<int> dp(S + 1, MOD);
        cout << dfs(data, dp, S) << endl;
    }

    return 0;
}


Measured memory_bytes: 4456
n=int(input())
s_=[input() for _ in range(2)]
mod=pow(10,9)+7
s=[1]
for i in range(n-1):
  if s_[0][i]==s_[0][i+1]:
    s[-1]+=1
  else:
    s.append(1)
ans=3*s[0]
for i in range(1,len(s)):
  if s[i-1]==1:
    ans*=2
    ans%=mod
  elif s[i]==2:
    ans*=3
    ans%=mod
print(ans%mod)


Measured memory_bytes: 3064
/*coderanant*/
//not done

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;
int a[100001];
int memo[100001];
int dp(int n)
{
	if(n<1)
		return mod;
	if(n==1)
		return 0;
	if(memo[n]!=-1)
        return memo[n];
    memo[n]=min(dp(n-1)+abs(a[n-1]-a[n]),dp(n-2)+abs(a[n-2]-a[n]));
    return memo[n];
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/in.txt","r",stdin);
    // 	freopen("/home/akmittal/Desktop/Competitive Programming/out.txt","w",stdout);
    // #endif
    int n;
    cin>>n;
    int i;
    memset(memo,-1,sizeof(memo));
    f1(i,1,n+1)
    cin>>a[i];
    cout<<dp(n);
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String t = scan.next();
		int a = scan.nextInt();
		int b = scan.nextInt();

		String u = scan.next();
		if(u.equals(s))
			a--;
		else
			b--;
		System.out.println(a + " " + b);
	}
}

Measured memory_bytes: 23764
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  int i, A[N], B[N], C[N-1];
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }  for(i=0;i<N;i++){
    scanf("%d",&B[i]);
  }  for(i=0;i<N-1;i++){
    scanf("%d",&C[i]);
  }
  int j, count=0;
  for(j=0;j<N;j++){
    count+=B[A[j]-1];
    if(j>0&&A[j-1]+1==A[j]){
      count+=C[A[j-1]-1];
    }

  }
   
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 128
//abc129_e.cpp
//Tue Jun  2 23:00:20 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string l;
	cin >> l;

	ll dp[2][l.size()+1];
	for (int i=0;i<2;i++){
		for (int j=0;j<l.size()+1;j++){
			dp[i][j] = 0;
		}
	}

	dp[0][0] = 1;
	dp[1][0] = 0;

	for (int i=1;i<l.size()+1;i++){
		if (l[i-1]=='1'){
			dp[0][i] = dp[0][i-1]*2%MOD;
			dp[1][i] = (dp[1][i-1]*3+dp[0][i-1])%MOD;
		}else {
			dp[0][i] = dp[0][i-1]%MOD;
			dp[1][i] = dp[1][i-1]*3%MOD;
		}
	}

	ll ans = (dp[0][l.size()]+dp[1][l.size()])%MOD;
	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 2048
#include <iostream>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
int main(){
	int n,a[100002];
	cin >> n;
	FOR(i,1,n+1) cin >> a[i];
	int bt = a[1];
	FOR(i,1,100002){
		if(bt == 2){
			cout << i;
			break;
		}
		if(bt == 0){
			cout << -1;
			break;
		}
		a[0]=a[bt]; a[bt]=0; bt=a[0];
	}
	return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

var S string
var tokens = []string{"dream", "dreamer", "erase", "eraser"}

// 2018-11-03T17:36:05+0800
// 2018-11-03T17:42:17+0800 Try DFS
// 2018-11-03T18:04:01+0800 Try submitting.
func main() {
	fmt.Scanf("%s", &S)
	if dfs(0) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func dfs(index int) bool {
	if len(S) == index {
		return true
	}
	if len(S)-index < 5 {
		return false
	}
	if len(S)-index > 7 {
		return (S[index:index+5] == tokens[0] && dfs(index+5)) ||
			(S[index:index+5] == tokens[2] && dfs(index+5)) ||
			(S[index:index+6] == tokens[3] && dfs(index+6)) ||
			(S[index:index+7] == tokens[1] && dfs(index+7))
	}
	if len(S)-index == 5 {
		return S[index:index+5] == tokens[0] || S[index:index+5] == tokens[2]
	}
	if len(S)-index == 6 {
		return S[index:index+6] == tokens[3]
	}
	if len(S)-index == 7 {
		return S[index:index+7] == tokens[1]
	}
	return false
}

Measured memory_bytes: 6144
#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, K; 
  cin >> N >> K;

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

  sort(ALL(A));

  int ans = INF;
  REP(i, N-K+1){
    chmin(ans, A[i+K-1]-A[i]);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(ll)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define rep2(i,j,n) for(int j=i;j<n;j++)
#define rep3(i,j,n) for(int j=i;j<=n;j++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define sp(n) cout << fixed << setprecision(n)
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 ll;
using namespace std;
int main(void){
    ll n;cin>>n;
    map<ll,ll> mp;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
    }
   ll res=0;
    for(auto&p:mp){
        res+=p.second*(p.second-1)/2;
    }
    rep(i,n){
        ll r=res-mp[a[i]]+1;
        cout<<r<<endl;
    }
}


Measured memory_bytes: 12800
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int m;
	cin >> m;
	cout << 48 - m << endl;
}



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

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

int main(){
  int n;
  cin >> n;
  double a = 1.0/2.0,b = (double)((n+1)/2)/n;
  if(n%2 == 0){
    cout << fixed << setprecision(7) << a << endl;
  }
  else cout << fixed << setprecision(7) << b << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
typedef long long ll;
const int inf = 100100100;


int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin >> a;
    mp[a]++;
  }

  int m;
  cin >> m;
  rep(i,m){
    int a;
    cin >> a;
    if(mp[a]==0){
      cout << "NO" << endl;
      return 0;
    }else mp[a]--;
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 12880
#include <cstdio>
using namespace std;
int A,B,C,need,maxnum;
int main ()
{
	scanf("%d%d%d%d",&A,&B,&C,&need);
	if (need<=A)
	{
		maxnum=need;
		printf("%d",maxnum);
	}
	else
	{
		maxnum+=A;
		need-=A;
		if (need<=B)
		{
			printf("%d",maxnum);
		}
		else
		{
			need-=B;
			maxnum-=need;
			printf("%d",maxnum);
		}
	}
	return 0;
}

Measured memory_bytes: 1728
package main

import (
	"bufio"
	"fmt"
	"os"
)

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func main() {
	s := readLine()
	ans := make([]rune, len(s))
	for i, S := range s {
		if 'a' <= S && S <= 'z' {
			ans[i] = S - ('a' - 'A')
		} else if 'A' <= S && S <= 'Z' {
			ans[i] = S + ('a' - 'A')
		} else {
			ans[i] = S
		}
	}
	fmt.Println(string(ans))
}



Measured memory_bytes: 1180
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int n, k;
    cin>>n>>k;
    set<int> s;
    for(int i = 1; i <= n; i++)
        s.insert(i);
    while(k--){
        int p;
        cin>>p;
        while(p--){
            int x;
            cin>>x;
            s.erase(x);
        }
    }
    cout<<s.size();
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>

using namespace std;

#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
/////////////

int const N = 1e5 + 41;
int const M = 17;
int const INF = 2e9 + 41;

int n, x[N], l, q;
int d[N][M];

int calc(int a, int b){
	int ret = 0;
	fdr(i, 0, M){
		if(d[a][i] < b){
			ret += (1 << i);
			a = d[a][i];
		}
	}
	return ret + 1;
}

void solve(){
	cin >> n;
	fr(i, 0, n) cin >> x[i];
	x[n] = INF;
	cin >> l;
	int lp = 0;
	int rp = 0;
	while(lp < n){
		if(x[rp] - x[lp] <= l){
			++rp;
		}else{
			d[lp][0] = rp-1;
			++lp;
		}
	}
	fr(i, 1, M){
		fr(j, 0, n){
			int nxt = d[j][i-1];
			if(nxt == n) d[j][i] = nxt;
			else{
				d[j][i] = d[nxt][i-1];
			}
		}
	}
	cin >> q;
	fr(i, 0, q){
		int a, b;
		cin >> a >> b;
		--a;--b;
		if(a > b) swap(a, b);
		int ans = calc(a, b);
		cout << ans << endl;
	}
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	solve();

	return 0;
}

Measured memory_bytes: 7808
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        sc.close();
        char[] c = S.toCharArray();
        int N = S.length();
        int idx = 0;
        int[] num = new int[N];
        while(idx < N){
            if(idx < N && c[idx] == 'R'){
                int cnt = 0;
                while(c[idx] == 'R'){
                    idx++;
                    cnt++;
                }
                num[idx] += (cnt)/2;
                num[idx-1] += (cnt+1)/2;
            }
            if(c[idx] == 'L'){
                int count = 0;
                int start = idx;
                while(idx < N &&c[idx] == 'L'){
                    idx++;
                    count++;
                }
                num[start] += (count+1)/2;
                num[start-1] += (count)/2;
            }
        }

        for(int i = 0; i < N; i++){
            System.out.print(num[i] + " ");
        }
   }
}

Measured memory_bytes: 42996
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
  ll n,k;
  ll a[1000000],b,c,cun[1000000]={};
  ll sum = 0;
  cin >> n;
  for (int i = 0; i < n ; i++) {
    cin >> a[i];
    sum += a[i];
    cun[a[i]]++;
  }
  ll sum2 = sum;
  
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> b >> c;
    sum -= cun[b] * b;
    sum += cun[b] * c;
    cout << sum << "\n";
    cun[c] += cun[b];
    cun[b] = 0;
  }
  return 0;
}


Measured memory_bytes: 12216
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <cstring>
#include <unordered_map>
#include <sstream>
using namespace std;
std::string to_binString(unsigned int val)
{
    if( !val )
        return std::string("0");
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 ) 
            str.insert(str.begin(), '0');  
        else
            str.insert(str.begin(), '1');  
        val >>= 1;
    }
    return str;
}
std::string to_binString2(unsigned int val, int n)
{
    std::string str;
    while( val != 0 ) {
        if( (val & 1) == 0 )  
            str.insert(str.begin(), '0');
        else
            str.insert(str.begin(), '1');
        val >>= 1;
    };
    while (str.size() != n) {
      str.insert(str.begin(), '0');
    }
    return str;
}
int jpre(string a, string b) 
{
  if ((a.find(b) == 0) || (b.find(a) == 0)){
    return 1;
  }
  return 0;

}
void nodup_push(vector<string>&newspace, string &b) 
{
  for (auto p : newspace) {
    if (jpre(p,b)) {
      cout << "  --  nodup_push (skipped): " << b << ", (because of p: " << p << ")" << endl;
      return ;
    }   
  }

  newspace.push_back(b);
  //a.insert(b);


}
void nodup_insert(set<string> &a, string b) 
{
  for (auto p : a) {
    if (jpre(p,b)) {
      return ;
    }
  }

  //a.push_back(b);
  a.insert(b);


}
int getsum_dec(int i)
{
  int sum = 0;
  while (i != 0) {
    sum += i%10;
    i = int(i / 10);
  }
  return sum;
}

int main()
{
  int n, b, a;
  cin >> n >> a >> b;
  int count = 0;
  for (int i = 1; i <= n; i++) {
    int tmp = getsum_dec(i);
    //cout << "debug: " << i << ": " << tmp ;
    if ( (tmp >= a) && (tmp <= b)) {
      //cout << "   HIT!!";
      count += i;
    }
    //cout << endl;
  }
  cout << count << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, m, k;
	cin>>n>>m>>k;
    int x1, y1, x2, y2;
	cin>>x1>>y1>>x2>>y2;
	x1--;
	y1--;
	x2--;
	y2--;
	char grid[n][m];
	int dist[n][m];
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			cin>>grid[i][j];
			dist[i][j] = INT_MAX;
		}
	}
 
    int d[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};
	queue<pair<int, int> > q;
	dist[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
 
		for (int i=0; i<4; i++) {
			int nx = x;
			int ny = y;
			int nd = dist[x][y]+1;
			for (int j=1; j<=k; j++) {
				nx += d[i][0];
				ny += d[i][1];
 
				if (nx<0 || nx>=n || ny<0 || ny>=m || grid[nx][ny]=='@' || dist[nx][ny]<nd) {
					break;
				}
				if (dist[nx][ny]>nd) {
					dist[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}
 
	int ans = dist[x2][y2];
	cout<<(INT_MAX==ans ? -1 : ans)<<endl;
	return 0;
}
 

Measured memory_bytes: 8976
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    
    int n,p,t;
    cin>>n>>p>>t;
    int ans=(n/p)*t;
    if(n%p!=0)
    ans+=t;
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int H, W;
    cin >> H >> W;
    vector<string> A(H);
    rep(i, H) cin >> A[i];
    
    vector<vector<int>> dp(H, vector<int>(W, inf));
    if(A[0][0] == '#') dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i, H) rep(j, W) {
        if(i == 0 && j == 0) continue;
        if(i - 1 >= 0) {
            if(A[i - 1][j] == A[i][j]) dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            else dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
        }
        if(j - 1 >= 0) {
            if(A[i][j - 1] == A[i][j]) dp[i][j] = min(dp[i][j], dp[i][j - 1]);
            else dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
        }
    }
    output((dp[H - 1][W - 1] + 1) / 2);
    
    
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	ss := make([]int, m)
	pp := make([]int, m)
	for i := 0; i < m; i++ {
		k := getNextInt(scanner)
		for j := 0; j < k; j++ {
			s := getNextInt(scanner)
			ss[i] = ss[i] | 1<<uint(s-1)
		}
	}
	for i := 0; i < m; i++ {
		pp[i] = getNextInt(scanner)
	}
	var ans int
	for i := 0; i < 1<<uint(n); i++ {
		lon := 0
		for j := 0; j < m; j++ {
			cnt := 0
			for k := 0; k < n; k++ {
				if ss[j]>>uint(k)%2 == 0 {
					continue
				}
				if i>>uint(k)%2 == 1 {
					cnt++
				}
			}
			if cnt%2 == pp[j] {
				lon++
			}
		}
		if lon == m {
			ans++
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 640
A,B = map(int,input().split())

def f0n(y):
	if y % 4 == 0:
		return y
	elif y % 4 == 2:
		return 1^y
	elif y % 4 == 3:
		return 0
	else:
		return 1
				
print(f0n(A-1)^f0n(B))

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() { // もっときれいにできなかったのか
	int n;
	cin >> n;
	V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	V b = a;
	b.erase(unique(all(b)), b.end());
	if (b.size() >= 4) {
		cout << "No" << endl;
		return 0;
	}
	map<int, int> mp;
	rep(i, n) {
		mp[a[i]]++;
	}
	if (mp[0] == n) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		if (n % 3 != 0) {
			cout << "No" << endl;
			return 0;
		}
		else {
			if (mp.size() == 2) {
				int cnt = mp[0];
				int cnt2 = mp[b[1]];
				if (cnt2 == cnt * 2) cout << "Yes" << endl;
				else cout << "No" << endl;
			}
			else {
				if ((b[0] ^ b[1]) == b[2]) {
					int cnt = mp[b[0]];
					int cnt2 = mp[b[1]];
					int cnt3 = mp[b[2]];
					if (cnt == cnt2 && cnt2 == cnt3) cout << "Yes" << endl;
					else cout << "No" << endl;
				}
				else cout << "No" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3932
s = input()

if (s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]) or (s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]) or (s[0]==s[3] and s[2]==s[1] and s[0]!=s[2]):
  print("Yes")
else:
  print("No")

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

int main(){
  string s;
  ll n;
  cin>>s>>n;
  ll len = s.size();
  for(ll i=0;i<len-1;i++){
    if(s[i]=='a')continue;
    if('z'-s[i]+1<=n) {n=n-('z'-s[i]+1);s[i]='a';}
    //cout<<n<<endl;
  }
  if(n>0) s[len-1] = 'a'+((s[len-1]-'a')+n)%26;
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  int i;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  int count=0;
  for(int j=0;j<1000;j++){
    for(i=0;i<n;i++){
      if(vec.at(i)%2==0){
        vec.at(i)/=2;
      }else{
        goto out;
      }
    }
    count++;
  }
  out:
  cout << count;
}

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

using namespace std;

const int MAX_N = 2e5 + 5;
const long long MOD = 1e9 + 7;

typedef long long ll;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, p; cin >> a >> p;
    cout << (a * 3 + p) / 2;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793
#define mod 1000000007


int main() {
	int n;
	cin >> n;
	while (pow(n, 0.5) != ceil(pow(n, 0.5)))n--;
	cout << n << endl;
	return 0;
}

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

int main()
{
  ll n,k;
  cin>>n>>k;ll a[n];
  for(ll i=0;i<n;i++)
  cin>>a[i];
   sort(a,a+n);ll sum=0;
   for(ll i=0;i<k;i++)
   {
       sum+=a[i];
   }
   cout<<sum;
}

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

int main()
{
    ll MOD = 1000000007;
    ll N;
    cin >> N;
    //cout << "N = " << N << endl;
    vector<ll> A(N, 0);
    vector<ll> B(N+1, 0);
    ll sum = 0;
    rep(i,N) {
        cin >> A[i];
#if 1
        B[i+1] = B[i] + A[i];
#else
        if (i != 0) {
            sum += A[i];
        }
#endif
    }

#if 1

#else
    vector<ll> Sumv(N-1, 0);
    rep(i,N-1) {
        if (i == 0) {
            Sumv[i] = sum % MOD;
        }
        else {
            Sumv[i] = (Sumv[i-1] - A[i]) % MOD;
        }
        //cout << "Sumv[" << i << "] = " << Sumv[i] << endl;
    }
#endif
    ll ans = 0;
    rep(i, N-1) {
#if 1
        ll sumt = (B[N] - B[i + 1]) % MOD;
        ans += A[i] * sumt;
#else
        ans += A[i] * Sumv[i];
#endif
        ans %= MOD;
    }
    cout << ans << endl;
 

}


Measured memory_bytes: 6340
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node* parent;
  struct node* left;
  struct node* right;
  int key;
};

typedef struct node* node;

void insert(int);
void inorder(node);
void preorder(node);

node tree;

int main(){
  int m,k,i;
  char a[10];

  scanf("%d",&m);
  
  for(i=0;i<m;i++){
    scanf("%s",a);
    if(a[0]=='i'){
      scanf("%d",&k);
      insert(k);
    }
    else if(a[0]=='p'){
      inorder(tree);
      printf("\n");
      preorder(tree);
      printf("\n");
    }
  }

  return 0;
}

void insert(int k){
  node y = NIL;
  node x = tree;
  node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y=x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }

  z->parent = y;

  if(y==NIL){
    tree=z;
  }
  else if(z->key < y->key){
    y->left = z;
  }
  else{
    y->right = z;
  }
}

void inorder(node tree){
  if(tree != NIL){
    inorder(tree->left);
    printf(" %d",tree->key);
    inorder(tree->right);
  }
}

void preorder(node tree){
  if(tree != NIL){
    printf(" %d",tree->key);
    preorder(tree->left);
    preorder(tree->right);
  }
}

Measured memory_bytes: 24040