akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a, b;
		int gcd;
		
		while (sc.hasNext()) {
			a = sc.nextInt();
			b = sc.nextInt();
			gcd = gcd(Math.max(a, b), Math.min(a, b));
			System.out.println(gcd + " " + a / gcd * b);
		}
	}
	
	public static int gcd(int a, int b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using namespace std;

int N, K;
int h[100000 + 10];
ll dp[100000 + 10];

int main(void) {
    cin >> N >> K;
    REP(i, 1, N) {
        cin >> h[i];
    }
    
    dp[1] = 0;
    REP(i, 2, N) {
        ll max_val = -1;
        for (int j=1; j<=K && i-j >= 1; j++) {
            if (max_val == -1) {
                max_val = dp[i-j] + abs(h[i] - h[i-j]);
            } else {
                max_val = min(dp[i-j] + abs(h[i] - h[i-j]), max_val);
            }
        }
        dp[i] = max_val;
    }
    cout << dp[N] << endl;
    return 0;
}



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

int main() {

  int N;
  cin >> N;

  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }

  string result = "Yes";
  for (int i = N - 1; 0 < i; i--) {
    if (H[i] < H[i - 1]) {
      if (H[i - 1] - H[i] <= 1) {
        H[i - 1] -= H[i - 1] - H[i];
      } else {
        result = "No";
        break;
      }
    }
  }

  cout << result << endl;

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
}

signed main(){
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a, 0), q(b, 0), r(c, 0);
    rep(i, a) cin >> p[i];
    rep(i, b) cin >> q[i];
    rep(i, c) cin >> r[i];
    vector<ll> all;
    sort(p.rbegin(), p.rend());
    sort(q.rbegin(), q.rend());
    rep(i, min(x, a)) all.push_back(p[i]);
    rep(i, min(y, b)) all.push_back(q[i]);
    rep(i, c) all.push_back(r[i]);
    sort(all.rbegin(), all.rend());
    ll ans = 0;
    rep(i,min(int(x+y),int(all.size()))) ans += all[i];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 9836
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,Q,i;cin>>N>>Q;fenwick_tree<ll> F(N);
  REP(i,N){ll x;cin>>x;F.add(i,x);}
  REP(i,Q){
    ll x,u,v;cin>>x>>u>>v;
    if(x==0)F.add(u,v);
    else cout<<F.sum(u,v)<<endl;
  }
  return 0;
}

Measured memory_bytes: 8220
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
  int n,k;
  std::cin >> n >> k;
  if(k==1) print(0);
  else print(n-k);
  return 0;
}

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

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

int main(){
	int a, b, ans = 0, cnt = 0;
	cin >> a >> b;

	rep(i, 2){
		if (a >= b && cnt < 2){
			ans += a;
			--a;
			++cnt;
		}
		if (b >= a && cnt < 2){
			ans += b;
			--b;
			++cnt;
		}
	}


	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

ll n,k,W[100000];

//?????§????????????:??\???,????????§????????????????????°:??????
int V(ll P){
    ll w;
    int i=0;
    rep(j,k){
        w=0;
        while(w+W[i]<=P){
            w+=W[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

ll bina(){
    ll left=0;
    ll right=100000*10000;
    ll mid;
    while(right-left>1){
        mid=(right+left)/2;
        ll v=V(mid);
        if(v>=n) {right=mid;}
        else {left=mid;}
    }
    return right;
}

int main(void){
    cin >> n >> k;
    rep(i,n){
        cin >> W[i];
    }
    cout << bina() <<endl;
    return 0;
}

Measured memory_bytes: 3852
A,B,C = map(int,input().split())
K = int(input())
T = 0
if A < B:
  C = C * (2**K)
  if B < C:
    T = 1
else:
  N = K
  S = 0
  for i in range(N):
    B = B*2
    K -=1
    if A < B:
      S = 1
      break
  if S:
    for i in range(K):
      C = C*2
    if B < C:
      T = 1
if T:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9140
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=998244353;
const int maxn=1e5+100;

void solve(){
	int n;scd(n);
	int ans=0;
	while(n){
		if(n%10==7)ans=1;
		n/=10;
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}
int main(){
    //IOS;
    //freopen("fenwick.in","r",stdin);
    //freopen("fenwick.out","w",stdout);
    solve();
    
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    return 0;
}

Measured memory_bytes: 3168
<?php
    fscanf(STDIN,"%d%d",$N,$L);
    
    for($i=1;$i<=$N;$i++){
        $array[$i] = $L +$i - 1;
    }
    $v=INF;
    foreach($array as $key =>$value){
        if($v>abs($value)){
            $v = abs($value);
            $ans = $key;
        }
    }
    echo array_sum($array)-$array[$ans];
    
?>

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

int main(void){
	int m, n_min, n_max, n;
	while(true){
		cin >> m >> n_min >> n_max;
		if(!m&&!n_min&&!n_max) break;
		vector<int> p(m);
		for(int i = 0; i < m; ++i){
			cin >> p[i];
		}
		sort(p.rbegin(), p.rend());
		int gap = 0, ans;
		for(n = n_min; n <= n_max; ++n){
			gap = max(gap, p[n-1] - p[n]);
			if(gap == p[n-1] - p[n]) ans = n;
		}
		cout << ans << endl;
	}
	return 0;
}


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

using namespace std;

struct Circle {
    double x, y, r;    
};

istream &operator >> (istream &is, Circle &c)
{
    return is >> c.x >> c.y >> c.r;
}

double dist(double x1, double y1, double x2, double y2)
{
    return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}

int main()
{
    int N;    
    Circle c1, c2;
    cin >> N;
    while (N--) {
        cin >> c1 >> c2;
        double d = dist(c1.x, c1.y, c2.x, c2.y);
        if (c1.r + c2.r < d) {
            cout << 0 << endl;
        } else if (c2.r + d < c1.r) {
            cout << 2 << endl;
        } else if (c1.r + d < c2.r) {
            cout << -2 << endl;
        } else {
            cout << 1 << endl;
        }
    }    
    return 0;
}

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

using namespace std;

typedef long long LL;

int cnt0,cnt1;
LL f[51][2];

int main()
{
	int N,P;
	scanf("%d%d",&N,&P);
	LL ans = 1;
	for (int i=1;i<=N;i++)
	{
		int x;
		scanf("%d",&x);
		if (x&1)
			cnt1++;
		else
			cnt0++;
	}
	f[0][0] = 1;
	f[0][1] = 0;
	for (int i=1;i<=cnt1;i++)
	{
		f[i][0] = f[i-1][0] + f[i-1][1];
		f[i][1] = f[i-1][0] + f[i-1][1];
	}
	ans = f[cnt1][P];
	for (int i=1;i<=cnt0;i++)
		ans <<= 1LL;
	printf("%lld\n",ans);
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

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

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    int t = 0, h = 0; //t：太郎の得点 h:花子の得点
    for(int i = 0; i < n; i++){
        string t_card, h_card;
        cin >> t_card >> h_card;
        if(t_card > h_card) t+=3;
        else if(t_card == h_card) {t+=1; h+=1;}
        else h+=3;
    }
    cout << t << " " <<  h << endl;
}


Measured memory_bytes: 3156
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <queue>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int MOD = 1000000007;

#define N 55555
int arr[N];
void Eratosthenes(){
    for(int i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
}


int main(){
    std::ios_base::sync_with_stdio(false);

    int n; cin >> n;
    Eratosthenes();
    std::vector<int> v;
    for(int i=2; i<N; i++){
        if(arr[i] && to_string(i).back()=='1'){
            v.push_back(i);
        }
    }

    REP(i,n) cout << v[i] << " ";
    cout << '\n';

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 100010;

vi operator*(const vi& a, const vi& b)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[i] = a[b[i]];
	return res;
}

vi inv(const vi& a)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[a[i]] = i;
	return res;
}

vi qpow(const vi& a, int y)
{
	vi res(a.size());
	vector<bool> vis(a.size(), false);
	for (int i = 1; i < a.size(); ++i)
	{
		if (vis[i]) continue;
		vi cycle(1, i);
		for (int u = a[i]; u != i; u = a[u])
		{
			cycle.push_back(u);
			vis[u] = true;
		}
		for (int j = 0; j < cycle.size(); ++j) res[cycle[j]] = cycle[(j + y) % cycle.size()];
	}
	return res;
}

/*vi qpow(vi x, int y)
{
	vi out(x.size());
	for (int i = 1; i < x.size(); ++i) out[i] = i;
	while (y)
	{
		if (y & 1) out = out * x;
		x = x * x;
		y >>= 1;
	}
	return out;
}*/

int n, k;
vi f[10], g, ans;

int main()
{
	scanf("%d%d", &n, &k);
	
	f[1].resize(n + 1);
	f[2].resize(n + 1);
	
	for (int i = 1; i <= n; ++i) scanf("%d", &f[1][i]);
	for (int i = 1; i <= n; ++i) scanf("%d", &f[2][i]);
	for (int i = 3; i <= 5; ++i) f[i] = f[i - 1] * inv(f[i - 2]);
	f[0] = inv(f[2]) * f[1];
	g = f[1] * inv(f[0]) * inv(f[1]) * f[0];
	
	ans = qpow(g, k / 6) * f[k % 6] * qpow(inv(g), k / 6);
	
	for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
	
	return 0;
}

Measured memory_bytes: 5652
#include <stdio.h>

int sort(int x[],int l){
	int i,j,k;
	for(i=1;i<=l;i++){
		for(j=l;j>=i+1;j--){
			if(x[j-1]<x[j]){
				k=x[j];
				x[j]=x[j-1];
				x[j-1]=k;
			}
		}
	}
	return 0;
}

int main(void) {
	int i,d[8];
	for(i = 1;i <= 5;i++){scanf("%d",&d[i]);}
	sort(d,5);
	printf("%d %d %d %d %d\n",d[1],d[2],d[3],d[4],d[5]);
	return 0;
}

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

int main(){
int W,H,x,y,r;
cin>>W>>H>>x>>y>>r;
if((x-r)>=0&&(x+r)<=W){
if((y-r)>=0&&(y+r)<=H){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
else{cout<<"No"<<endl;
}
}

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

long long calP(long long n,long long x,vector<long long> w,vector<long long> p){
    if(n==0){
        if(x<=0)return 0;
        return 1;
    }
    if(x <= 1+w[n-1])return calP(n-1,x-1,w,p);
    return p[n-1]+1+calP(n-1,x-2-w[n-1],w,p);
}

int main() {
    long long N=0,X=0;
    cin >> N >> X;

    vector<long long> w(N+1),p(N+1);
    w.at(0) = 1;
    p.at(0) = 1;
    for(int i=1; i<=N; i++){
        w.at(i) = w.at(i-1)*2+3;
        p.at(i) = p.at(i-1)*2+1;
    }
    long long ans = calP(N,X,w,p);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define P pair<ll,ll>
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1;cin>>n;
  lvector t(n,0); rep(i,n) cin>>t[i];
  for(ll i=0;i<n;++i) ans=(ans/__gcd(ans,t[i]))*t[i];
  print(ans);
  return 0;
}

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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define RFOR(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const ll INF = 1e15;
const ll MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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; }

vector<ll > divisor(ll n) {
  vector<ll > ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(void){
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  vector<ll> div = divisor(N);

  ll len = div.size();

  ll tmp = INF;
  if (len % 2 == 0){
    REP(i, len/2-1 + 1){
      ll val1 = div[i];
      ll val2 = div[len - i - 1];
      if (val1 + val2 < tmp){
        tmp = val1 + val2;
      }
    }
  }


  else{
    REP(i, len/2 - 1 + 1){
      ll val1 = div[i];
      ll val2 = div[len - i - 1];
      if (val1 + val2 < tmp){
        tmp = val1 + val2;
      }
      ll val3;
      val3 = div[len/2];
      if (val3 * 2 < tmp){
        tmp = val3 * 2;
      }
    }
  }

  cout << tmp-2 << endl;

  return 0;
}



Measured memory_bytes: 384
#include<stack>
#include<cstdio>
using namespace std;

int main(){
	int n;
	int temp;
	stack<int> data;
	
	while(1){
		scanf("%d",&n);
		
		if(n!=0){
			data.push(n);
		}
		else{
			if(data.empty() == true)break;
			else{
				printf("%d\n",data.top());
				data.pop();
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1036
// abc081_b
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,a,cnt,ans=500000000;
  cin>>n;
  rep(i,n) {
    cin>>a;
    cnt=0;
    while(a%2==0){
      a/=2;
      cnt++;
    }
    ans=min(ans,cnt);
    if(ans==0)break;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    if (n == 1 && m == 1) {
      System.out.println(1);
      return;
    }
    if (n == 1) {
      System.out.println(m - 2);
      return;
    }
    if (m == 1) {
      System.out.println(n - 2);
      return;
    }
    System.out.println((long)(n - 2) * (long)(m - 2));
  }
}

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

int main()
{
    int N, K, total;
    cin >> N;
    cin >> K;
    total = 0;
    for (int i = 0; i < N; i++)
    {
        int x, a, b;
        cin >> x;
        a = x;
        b = K - x;
        total += 2 * min(a, b);
    }
    cout << total << endl;
}


Measured memory_bytes: 256
a=input()
if len(a)==1:
    print("-1 -1")
elif (len(a)==2)&(len(list(set(a)))==1):
    print("1 2")
else:
    for i in range(len(a)-2):
        e=list(set(a[i:i+3]))
        if (len(e)==2) or (len(e)==1):
            print("{}".format(i+1)+" "+"{}".format(i+3))
            break
    else:
        print("-1 -1")

Measured memory_bytes: 3188
from itertools import product

N, D1, D2 = map(int, input().split())

# Dが「奇数」or「D%4=2」になるまで、4で割る
Ds = []
Ms = []
for D in [D1, D2]:
    M = 1
    while D % 4 == 0:
        D //= 4
        M *= 2

    Ds += [D]
    Ms += [M]

# 各点(i,j)に対して、処理を行う
num = 0
for i, j in product(range(2 * N), repeat=2):
    # 1/Mに縮小した平面で(0,0)と同じ色で塗るならば、出力する
    for D, M in zip(Ds, Ms):
        if D % 2:
            # Dが奇数→(x+y)の偶奇で塗り分ける
            if (i // M + j // M) % 2: break
        else:
            # D%4=2→xの偶奇で塗り分ける
            if (i // M) % 2: break
    else:
        print(i, j)
        num += 1
        if num == N * N: break


Measured memory_bytes: 4280
num = 3.times.map { gets.to_i }
total = gets.to_i
sum = 0
cnt = 0


for i in 0..num[0]
  for j in 0..num[1]
    for k in 0..num[2]
      sum = (500 * i) + (100 * j) + (50 * k)
      if sum == total
        cnt += 1
      end
    end
  end
end
    
puts cnt

Measured memory_bytes: 14244
import itertools

n,m,r = map(int,input().split())
R = list(map(int,input().split()))
V = [[] for i in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    V[a].append([b,c])
    V[b].append([a,c])
    
cost = [[float("Inf") for j in range(n+1)] for i in range(n+1)]
for i in range(1,n+1):
    for j in range(1,n+1):
        for v,d in V[i]:
            if v == j:
                cost[i][j] = d

for k in range(1,n+1):
    for i in range(1,n+1):
        for j in range(1,n+1):
            if cost[i][j] > cost[i][k] + cost[k][j]:
                cost[i][j] = cost[i][k] + cost[k][j]

L = list(itertools.permutations(R, r))
ans = float("Inf")

for x in L:
    p = 0
    for i in range(len(x)-1):
        p += cost[x[i]][x[i+1]]
        
    ans = min(ans, p)
print(ans)

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

int main(){
    string s, t;
    cin >> s >> t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    //cout << s <<" "<< t << endl;
    
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

D = int(readline())
C = list(map(int,readline().split()))
S = [list(map(int,readline().split())) for i in range(D)]

past = -1
for s in S:
    ansidx = 0
    anssum = 0
    for i,si in enumerate(s,start=1):
        if anssum < si and past != i:
            ansidx = i
            anssum = si
    print(ansidx)
    past = ansidx


Measured memory_bytes: 9616
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
typedef long long ll;
using namespace std;
const int N = 1e5+5;

int n, m;
vector<int> E[N];
int A[N], B[N], pos[N], vis[N], fa[N];
long long sum[N], add[N];
inline bool cmp(int x, int y) { return A[x] < A[y]; }
inline int find(int x) { return (x == fa[x]) ? x : (fa[x] = find(fa[x])); }
int main() {
    while(~scanf("%d %d", &n, &m)) {
        for(int i = 1; i <= n; ++i) E[i].clear();
        for(int i = 1; i <= n; ++i) {
            pos[i] = i; vis[i] = 0; fa[i] = i;
            scanf("%d %d", &A[i], &B[i]);
            A[i] = max(0, A[i] - B[i]);
            add[i] = A[i];
            sum[i] = B[i];
        }

        sort(pos+1, pos+n+1, cmp);
        for(int i = 0; i < m; ++i) {
            int a, b; scanf("%d %d", &a, &b);
            E[a].push_back(b);
            E[b].push_back(a);
        }

        for(int i = 1; i <= n; ++i) {
            vis[pos[i]] = 1;
            for(int j = 0; j < E[pos[i]].size(); ++j) {
                int tt = E[pos[i]][j];
                if(vis[tt]) {
                    int f1 = find(pos[i]); int f2 = find(tt);
                    if(f1 != f2) {
                        sum[f1] += sum[f2];
                        fa[f2] = f1; 
                        add[f1] = min(add[f1], add[f2] + max(0ll, A[f1] - add[f2] - sum[f2])); 
                    }
                }
            }
        }
        printf("%lld\n", sum[pos[n]] + add[pos[n]]);
    }
    return 0;
}

Measured memory_bytes: 9468
using System;

namespace A___Pair
{
    class Program
    {
        static void Main(string[] args)
        {
            var k = int.Parse(Console.ReadLine());
            if (k % 2 == 0)
            {
                Console.WriteLine(k / 2 * k / 2);
            }
            else
            {
                Console.WriteLine(k / 2 * (k / 2 + 1));
            }
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  string s;cin>>s;
  ll k;cin>>k;
  ll num1=0;
  char ans;
  rep(i,s.size()){
  	if(s[i]!='1'){
  		ans=s[i];
  		break;
  	}
  	num1++;
  }
  if(num1<k){
  	cout<<ans<<endl;
  }else{
  	cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

int A, B;

int main() {
    cin >> A;
    cin >> B;
    if ((A+B)%2==1){
        cout << "IMPOSSIBLE";
    } else {
        int c = (A+B)/2;
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int TestCases = 1; // cin >> TestCases;
    while(TestCases--){
       int n; cin >> n;
       std::vector<int> v;
       for(int i = 1; i <= n; i++){
            int x; cin >> x;
            v.push_back(x);
       }
       sort(all(v));
       int ans = 1000000000;
       for(int i = 1; i <= 100; i++){
          int val = 0;
          for(auto j : v){
             val += ((j - i) * (j - i));
          }
          ans = min(ans, val);
       }
       cout << ans << '\n';
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3632
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
using graph = vector<vector<ll>>;

ll taosu(ll x) {
	if (x > 1) {
		return 2 * taosu(x / 2) + 1;
	}
	else if (x == 1) {
		return 1;
	}
}

int main() {
	ll h,mem,count=0;
	cin >> h;
	cout << taosu(h) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
const int N=2005;
int n;
int b[N];
int ans[N];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=n;i>=1;i--){
        int p=-1;
        for(int j=1;j<=i;j++)
			if(b[j]==j)
				p=j;
		ans[i]=p;
        if(p==-1){
			puts("-1");
			return 0;
        }
        for(int j=p;j<=i;j++)
			b[j]=b[j+1];
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",ans[i]);
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,Q;
int A[101010];
int did[101010];
int ind[101010];
vector<int> V;
int num[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>Q;
	FOR(i,Q) cin>>A[i];
	for(i=Q-1;i>=0;i--) {
		did[A[i]]++;
		if(did[A[i]]==1) {
			ind[A[i]]=V.size();
			V.push_back(A[i]);
		}
	}
	FOR(i,M) if(did[i+1]==0) {
		ind[i+1]=V.size();
		V.push_back(i+1);
	}
	
	while(V.size()>=2 && V[V.size()-2]<V[V.size()-1]) V.pop_back();
	V.pop_back();
	
	num[0]=N;
	for(i=Q-1;i>=0;i--) {
		if(num[ind[A[i]]]) {
			num[ind[A[i]]]--;
			num[ind[A[i]]+1]++;
		}
	}
	
	FOR(i,V.size()) if(num[i]) return _P("No\n");
	_P("Yes\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 2296
/*
	watch me go
*/

#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;*/

//#define d long double
#define pii pair<int,int>
#define pb push_back
#define inf (int)1e18
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
int const mod=998244353;
int const mod1=1000000007;
int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
 #define haha ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// ******** Using PBDS ********
 /*typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
                os; */

int modexp(int x, int n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}
 
int modinv(int n)
{
	return modexp(n,mod-2);
}

signed main()
{
    haha
    string s,t;
    cin>>s>>t;
    int n=t.size();
    if(s+t[n-1]==t)
    cout<<"Yes";
    else
    cout<<"No";
    
    
    
    
    
    
    
    
   
     
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(t)            int t; cin>>t; while(t--)
#define IOS             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int myStoi(string s) {
	stringstream geek(s);
	int x = 0;
	geek >> x;
	return x;

}
int32_t main()

{
	IOS;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n;
	cin >> n;
	/////int x = 1000;

	while (n - 1000 > 0) {
		n -= 1000;
	}
	cout <<  (1000 - n) << "\n";

	return 0;
}

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

#define MAX_N 200000

using namespace std;

typedef long long lint;

int rez;

int n;
int a[MAX_N + 1];

map <int, int> aps;

map <int, bool> doi;

map <int, int> cati;

vector <int> g[MAX_N + 1];
vector <int> g2[MAX_N + 1];

void readFile()
{
    cin >> n;

    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        aps[a[i]] ++;
    }
}

void solve()
{
    for(lint p = 1; p <= (1LL << 30); p <<= 1)
        doi[p] = 1;

    sort(a + 1, a + n + 1);

    for(int i = n; i >= 1; i --)
    {
        if(aps[a[i]] > 0)
        for(lint p2 = (1LL << 30); p2 >= 1; p2 >>= 1)
        {
            if(a[i] <= p2 && aps[p2 - a[i]] > 0 && ((p2 - a[i] != a[i]) || (p2 - a[i] == a[i] && aps[p2 - a[i]] >= 2)))
            {
                rez ++;

                aps[a[i]] --;
                aps[p2 - a[i]] --;

                break;
            }
        }
    }
}

void printFile()
{
    cout << rez << "\n";
}

int main()
{
    readFile();

    solve();

    printFile();

    return 0;
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    const int N=1e5+5;
    vector<pair<pair<ll,ll>,ll> >v;
    vector<pair<ll,pair<int,int> > >edg;
    ll ans;
    int sz[N],arr[N];
    void init(){
    	for(int i=0;i<N;i++){
    		sz[i]=1;
    		arr[i]=i;
    	}
    	return ;
    }
    int root(int a){
    	if(arr[a]!=a){
    		return arr[a]=root(arr[a]);
    	}else{
    		return a;
    	}
    }
    void un(int a,int b,ll cost){
    	int root_a=root(a),root_b=root(b);
    	if(root_a==root_b){
    		return ;
    	}else{
    		ans+=cost;
    		if(sz[root_a]>=sz[root_b]){
    			sz[root_a]+=sz[root_b];
    			arr[root_b]=root_a;
    		}else{
    			sz[root_b]+=sz[root_a];
    			arr[root_a]=root_b;
    		}
    	}
    	return;
    }
     
    int main(){
    	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    	init();
    	int n;cin>>n;
    	for(int i=1;i<=n;i++){
    		ll a,b;cin>>a>>b;
    		v.push_back({{a,b},i});
    	}
    	sort(v.begin(),v.end());
    	for(int i=0;i<n-1;i++){
    		edg.push_back({v[i+1].first.first-v[i].first.first,{v[i].second,v[i+1].second}});
    		edg.push_back({v[i+1].first.first-v[i].first.first,{v[i+1].second,v[i].second}});
    	}
    	for(int i=0;i<v.size();i++){
    		swap(v[i].first.first,v[i].first.second);
    	}
    	sort(v.begin(),v.end());
    	for(int i=0;i<n-1;i++){
    		edg.push_back({v[i+1].first.first-v[i].first.first,{v[i].second,v[i+1].second}});
    		edg.push_back({v[i+1].first.first-v[i].first.first,{v[i+1].second,v[i].second}});
    	}
    	sort(edg.begin(),edg.end());
    	for(auto u:edg){
    		un(u.second.first,u.second.second,u.first);
    	}
    	cout<<ans;
    	return 0;
    }

Measured memory_bytes: 15596
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <cassert>
#include <queue>
#include <ctime>
#include <string>
#include <cstring>
#define mp make_pair
#define pb push_back
#define NAME ""
#define y1 y1_423
#define list lista

using namespace std;

typedef long long ll;
typedef long double ld;

template<typename T>
ostream& operator << (ostream& cout, const vector<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "()");
	}
	cout << "(" << a[0];
	for (int i = 1; i < (int)a.size(); i++) {
		cout << "; " << a[i];
	}
	return (cout << ")");
}

template<typename T>
ostream& operator << (ostream& cout, const set<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T>
ostream& operator << (ostream& cout, const multiset<T> &a) {
	if ((int)a.size() == 0) {
		return (cout << "{}");
	}
	auto it = a.begin();
	cout << "{" << *it;
	++it;
	for (; it != a.end(); ++it) {
		cout << "; " << *it;
	}
	return (cout << "}");
}

template<typename T1, typename T2>
ostream& operator << (ostream& cout, const pair<T1, T2> &a) {
	return cout << "(" << a.first << "; " << a.second << ")";
}

const int nmax = 2000 * 1000;
const int inf = 2000 * 1000 * 1000;
const ll infl = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 1000ll;
const int mod = 1000 * 1000 * 1000 + 7;
const ld pi = acos(-1.0);

int n;
ll e, t, x[nmax], dp[nmax], ans[nmax];
multiset<ll> now, now1;
vector<ll> dela[nmax];

int main() {
	//freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
	//freopen(NAME".in", "r", stdin);freopen(NAME".out", "w", stdout);
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &x[i]);
	}
	x[0] = 0;
	for (int i = 0; i <= n; i++) {
		dp[i] = infl;
		ans[i] = infl;
	}
	dp[0] = 0;
	now.insert(infl);
	now1.insert(infl);
	for (int i = 0; i <= n; i++) {
		for (auto it : dela[i]) {
			now1.erase(now1.find(it));
		}
		now.insert(ans[i]);
		int id = lower_bound(x, x + n + 1, t / 2 + t % 2 + x[i + 1]) - x;
		dp[i] = min(dp[i], *now.begin() + 3 * x[i]);
		dp[i] = min(dp[i], *now1.begin() + x[i]);
		ans[id] = min(ans[id], dp[i] - 2 * x[i + 1] - x[i]);
		dela[id].pb(dp[i] + t - x[i]);
		now1.insert(dp[i] + t - x[i]);
	}
	cout << dp[n] + e - x[n];
}


Measured memory_bytes: 57464
import sys
sys.setrecursionlimit(10 ** 6)


def solve():
    S = input()
    # print(S, len(S))

    words = {0: "dream", 1: "dreamer", 2: "erase", 3: "eraser"}

    TABLE = [[-1 for x in range(len(S) + 1)] for y in range(len(words) + 1)]

    def recur(i, w):
        if not TABLE[w][i] == -1:
            return TABLE[w][i]

        if i >= len(S):
            # print("jey", log)
            return True

        r1, r2, r3, r4 = False, False, False, False
        if S[i:i + 5] == words[0]:
            r1 = recur(i + 5, 0)
        if S[i:i + 7] == words[1]:
            r2 = recur(i + 7, 1)
        if S[i:i + 5] == words[2]:
            r3 = recur(i + 5, 2)
        if S[i:i + 6] == words[3]:
            r4 = recur(i + 6, 3)

        TABLE[w][i] = r1 or r2 or r3 or r4 or False

        return TABLE[w][i]

    ans = recur(0, 0)

    return ans


if __name__ == '__main__':
    res = solve()
    if res:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 79600
#include <iostream>

using namespace std;


const int MAXN = 310;

const int INF = MAXN * MAXN * MAXN * 10;

int cst[MAXN][MAXN];
int ps[MAXN];

string s[MAXN];
int res[MAXN][MAXN];

int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	int tot = 0;
	for (int i = 1; i < m; i++)
	{
		for (int k = 0; k <= n; k++)
		{
			cst[0][k] = cst[k][0] = 0;
			for (int p = k; p < n; p++)
			{
				if (s[p][i] == s[p - k][i - 1])
					cst[0][k]++;
				if (s[p - k][i] == s[p][i - 1] && k != 0)
					cst[k][0]++;
			}
		}
		for (int j = 1; j <= n; j++)
			for (int k = 1; k <= n; k++)
				cst[j][k] = cst[j - 1][k - 1] - (s[n - j][i] == s[n - k][i - 1]);
		for (int k = 1; k <= n; k++)
		{
			res[0][k] = res[0][k - 1] + cst[0][k - 1];
			//cerr << 0 << " " << k << " " << res[0][k] << endl;
		}
		for (int j = 1; j <= n; j++)
		{
			for (int k = 0; k <= n; k++)
				ps[k + 1] = ps[k] + cst[j][k];
			int mn = INF;
			for (int k = 0; k <= n; k++)
			{
				mn = min(mn, res[j - 1][k] + cst[j - 1][k] - ps[k]);
				res[j][k] = mn + ps[k];
				//cerr << j << " " << k << " " << res[j][k] << endl;
			}
		}
		int ans = INF;
		for (int j = 0; j <= n; j++)
			ans = min(ans, res[n][j]);
		//cerr << ans << endl;
		tot += ans;
	}
	cout << tot << endl;
				
				
	
		
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int ans, mem;
string s;

int main(){
    cin >> s;
    for(int i = 0; i < (int)pow(2, s.length()-1); i++){
        mem = (int)(s[0]-'1')+1;
        for(int j = s.length()-2; j >= 0; j--){
            if(i & (1<<j)){
                mem += (int)(s[s.length()-j-1] - '1')+1;
            }
            else{
                mem -= (int)(s[s.length()-j-1] - '1')+1;
            }
        }
        if(mem == 7){
            cout << s[0];
            for(int j = s.length()-2; j >= 0; j--){
                if(i & (1<<j)){
                    cout << '+';
                }
                else{
                    cout << '-';
                }
                cout << s[s.length()-1-j];
            }
            cout << "=7\n";
            return 0;
        }
    }
}

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

using namespace std;


int main()
{
  string S;

  cin >> S;

  map<char, int64_t> mp;

  for(int64_t i = 0;
      i < S.length();
      ++i)
    {
      if(mp.find(S[i]) == mp.end())
        {
          mp.insert(make_pair(S[i],1));
        }
      else
        {
          ++mp[S[i]];
        }
    }

  bool ans = true;

  for(auto it : mp)
    {
      if(it.second != 2)
        {
          ans = false;
          break;
        }
    }
  if(ans)
    {
      cout << "Yes" << endl;
    }
  else
    {
      cout << "No" << endl;
    }

  return 0;
}


Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
	    java.util.Scanner scanner = new java.util.Scanner(System.in);
	    int n = scanner.nextInt();
	    int a = n / 1000;
	    int b = (n - a * 1000) / 100;
	    int c = (n - a * 1000 - b * 100) / 10;
	    int d = n - a * 1000 - b * 100 - c * 10;
	    
	    if (a+b+c+d == 7) {
	    	System.out.println(a + "+" + b + "+" + c + "+" + d + "=7");
	    } else if (a+b+c-d == 7) {
	    	System.out.println(a + "+" + b + "+" + c + "-" + d + "=7");
	    } else if (a+b-c+d == 7) {
	    	System.out.println(a + "+" + b + "-" + c + "+" + d + "=7");
	    } else if (a-b-c+d == 7) {
	    	System.out.println(a + "-" + b + "-" + c + "+" + d + "=7");
	    } else if (a+b-c-d == 7) {
	    	System.out.println(a + "+" + b + "-" + c + "-" + d + "=7");
	    } else if (a-b+c-d == 7) {
	    	System.out.println(a + "-" + b + "+" + c + "-" + d + "=7");
	    } else if (a-b+c+d == 7) {
	    	System.out.println(a + "-" + b + "+" + c + "+" + d + "=7");
	    } else if (a-b-c-d == 7) {
	    	System.out.println(a + "-" + b + "-" + c + "-" + d + "=7");
	    } 
	}

}


Measured memory_bytes: 21972
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=1e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
  LL res=1;
  for(;b;b>>=1,a=a*a%_MOD){
    if(b&1)res=res*a%_MOD;
  }
  return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << "=" << a << " # ";
  err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
  ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
  Solve();
  return 0;
}

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

char s[N],t[N];
void Solve(){
  cin>>s>>t;
  int len=strlen(s),ans=0;
  rep(i,0,len-1)ans+=s[i]!=t[i];
  cout<<ans<<endl;
}



Measured memory_bytes: 3920