akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

ll e( int n ){
    ll s = 0; Rep(i,n) s=s*10+1;
    return s;
}

ll rev( ll n ){
    ll ret = 0;
    while(n) ret = ret*10 + n%10, n/=10;
    return ret;
}

ll dfs( ll n, int d ){
    // printf ("%d,%d\n", n, d );
    if( d <= 0 && n == 0 ) return d==0?10:1;
    if( d <= 0 ) return 0;
    ll top = 0;
    ll tmp = e(d);
    if( n > 0 ){
        top = n%10;
    }else{
        top = -((-n)%10);
    }
    tmp *= top;
    top = abs(top);
    return dfs((n-tmp)/10,d-2)*(10-top);
}

ll search( int n ){
    ll top = n%10;
    ll tmp = top;
    ll ans = 0;
    Repe(i,18,1){
        tmp = e(i)*top;
        // printf ("%d\n", tmp );
        ans += dfs((n-tmp)/10,i-2)*(9-top);
    }
    return ans;
}

int main() {

    int N;
    Scd(N);

    if( N%9 ) {
        printf ("%d\n", 0 );
        return 0;
    }

    ll ans = search(N/9);

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

    ans = 0;

    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;
const ll mod = 1000 * 1000 * 1000 + 7;

ll Pow(ll x, ll n) {
  ll result = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      n--;
      result = result * x % mod;
    } else {
      n /= 2;
      x = x * x % mod;
    }
  }
  return result;
}

ll Inv(ll x) {
  return Pow(x, mod - 2);
}

const int maxn = 1000 * 1000 + 2;
ll fact[maxn], inv[maxn];

ll C(int n, int k) {
  if (n < k) return 0;
  ll result = fact[n];
  result = result * inv[k] % mod;
  result = result * inv[n - k] % mod;
  return result;
}

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

  fact[0] = 1;
  inv[0] = 1;
  for (ll i = 1; i < maxn; ++i) {
    fact[i] = fact[i - 1] * i % mod;
    inv[i] = Inv(fact[i]);
  }

  vector<ll> A(n);
  for (int k = 1; k < n; ++k) {
    A[k] = C(k - 1, n - 1 - k) * fact[k] % mod * fact[n - 1 - k] % mod;
  }

  ll result = 0;
  for (ll k = 1; k < n; ++k) {
    result += k * (A[k] - A[k - 1] + mod) % mod;
    result %= mod;
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 23680
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
l, r, d = M()
ans = 0
for i in range(l, r+1):
    if i % d == 0:
        ans += 1
print(ans)

Measured memory_bytes: 68124
#include <iostream>

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a > b)
	{
		int t = a; a = b; b = t;
	}
	if (b > c)
	{
		int t = b; b = c; c = t;
	}
	cout << a+b << endl;

	return 0;
}

Measured memory_bytes: 384
import Control.Applicative
import Data.Fixed

main = do
  [a,b] <- map (read :: String -> Integer) . words <$> getLine
  putStrLn $ show ( a `div` b ) ++ " " ++ show ( a `mod` b ) ++ " " ++ show  (fromIntegral a / fromIntegral b :: Micro)

Measured memory_bytes: 4040
#include <iostream>
#include <string.h>

using namespace std;

int main()
{

    int n, m, o=0;
    char a[101], b[101];
    cin>>a>>b;
    n=strlen(a);
    for(int i=0; i<n; i++){
        m=0; o=0;
        for(int k=i; k<n ;k++){
            if(b[m]!=a[k]){
                o=1;
               break;
            }
            m++;
        }
        if(o==0)
            for(int j=0; j<i; j++){
                if(b[m]!=a[j]){
                    o=1;
                    break;
                }
                m++;
            }
        if(o==0){
            break;
        }
    }
    if(o==1)
    cout<<"No";
    else
        cout<<"Yes";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

int n;

int binary_search(vector<int>&a, int key){
    int left = 0;
    int right = n;
    while (left<right)
    {
      int mid = (right+left)/2;
      if(a[mid]==key){
          return mid;
      }else if(key<a[mid]){
          right = mid ;
      }else{
          left = mid+1;
      }
    }
    
    return -1 ;
}


int main() {

    cin >> n ;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin >> a[i] ;

    int q ;
    cin >> q;
    int ans = 0;
    for(int i=0;i<q;++i){
        int target;
        cin >> target ;
        int idx = binary_search(a,target);
        if(idx>=0) ans++;
    }
    cout << ans << endl; 

    return 0 ;
}


Measured memory_bytes: 3104
// ---------------------------------------------
/*
1. 广告位招租ing!
2. 广告位招租ing!
*/
// ---------------------------------------------
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cstring>
#include <set>
#include <map>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define rep(i, a, b) for (int i=(a);i<=(b);i++)
#define dd(x) cout << #x << " = " << x << endl;
typedef pair<int, int> pii;
typedef long long LL;

const LL MOD = 1000000007;
const int N = 500000+10;
char s[12];
int main() {
    scanf("%s", s+1);
    s[4] = '8';
    printf("%s\n", s+1);
}














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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}


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


	int N = getint();

	int A[301][301];
	
	int kazu = 0;
	int onaji = 1;
	rep1(i, N) {
		rep1(j, N) {
			A[i][j] = getint();
			if (onaji && i != j) {
				if (!kazu) kazu = A[i][j];
				else if (kazu != A[i][j]) onaji = 0;			
			}
		}
	}
	if (onaji) {
		ll kotae = 0;
		rep1(i, N) rep1(j, i - 1) kotae += A[i][j];
		printf("%lld", kotae);
		return 0;
	}

	//int shouryaku[301][301] = {};
	//rep1(k, N) {
	//	rep1(i, N) {
	//		if (k == i) continue;
	//		rep1(j, i - 1) {
	//			if (k == j) continue;
	//			if (A[i][j] > A[i][k] + A[k][j]) {
	//				printf("-1");
	//				return 0;
	//			}
	//			else if (A[i][j] == A[i][k] + A[k][j]) {
	//				shouryaku[i][j] = 1;
	//			}
	//		}
	//	}
	//}

	//ll goukei = 0;
	//rep1(i, N) {
	//	rep1(ii, i - 1) {
	//		if (shouryaku[i][ii] == 0) goukei += A[i][ii];
	//	}
	//}

	ll goukei = 0;
	rep1(i, N) {
		rep1(j, i - 1) {
			bool OK = 1;
			rep1(k, N) {
				if (k == j || k == i) continue;
				if (A[i][j] > A[i][k] + A[k][j]) {
					printf("-1");
					return 0;
				}
				else if (A[i][j] == A[i][k] + A[k][j]) {
					OK = 0;
					break;
				}
			}
			if (OK) goukei += A[i][j];
		}
	}

	printf("%lld", goukei);

	Would you please return 0;
}

Measured memory_bytes: 640
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    vector<int> ans(n);
    rep(i, n) ans[a.at(i) - 1] = i + 1;
    rep(i, n) {
        cout << ans.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 4028
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ret = max(max(a*c, a*d), max(b*c,b*d));
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
   unsigned long long int n=0,m=0;
    scanf("%llu%llu",&n,&m);
    n*=2;
    if(n<=m)
    {
    printf("%llu",(m+n)/4);
    }
    else{
        printf("%llu",m/2);
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

vector<vector<ll>> tree(200010);
vector<ll> point(200010, 0);

void dfs(ll crr, ll parent){
    rep(i, tree[crr].size()){
        if(tree[crr][i] == parent)continue;

        point[tree[crr][i]] += point[crr];
        dfs(tree[crr][i], crr);
    }
}

int main(){
    ll n, q;
    cin >> n >> q;

    rep(i, n-1){
        ll a, b;
        cin >> a >> b;

        a--, b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    rep(i, q){
        ll p, x;
        cin >> p >> x;

        p--;
        point[p] += x;
    }

    dfs(0, 0);

    rep(i, n)cout << point[i] << " ";
}

Measured memory_bytes: 28152
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    if(a<=5){
      System.out.println(0);
    }else if(a<=12){
      System.out.println(b/2);
    }else{
      System.out.println(b);
    }
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <unordered_set>
#include <map>
using namespace std;

const int MAXN = 19;
const long long INF = 1000000000ll*1000ll;
struct Stat {
	long long pl, pr;
	bool operator==(const Stat &rhs) const {
		return pl == rhs.pl && pr == rhs.pr;
	}
};
struct Stat_hash {
	size_t operator() (const Stat &s) const {
		return s.pl ^ s.pr;
		// return hash<long long>()(s.pl) ^ hash<long long>()(s.pr);
	}
};

unordered_set<Stat, Stat_hash> dp[MAXN][MAXN];
void shrink(int b1, int b2) {
	map<long long, long long> filter;
	for (auto it : dp[b1][b2]) {
		if (filter.find(it.pl) == filter.end())
			filter[it.pl] = it.pr;
		else
			filter[it.pl] = min(filter[it.pl], it.pr);
	}
	dp[b1][b2].clear();
	long long lastsecond = INF;
	for (auto it : filter) { // it.first is from small to big. we need it.second from big to small.
		if (it.second < lastsecond)
			dp[b1][b2].insert( Stat{it.first, it.second} );
		lastsecond = min(lastsecond, it.second);
	}
}
int main() {
	int n;
	long long a[MAXN];
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>a[i];
	for (int i=0; i+1<n; i++)
		dp[i][i+1].insert(Stat{0, 0});
	for (int len = 3; len<=n; len++)
		for (int i=0, j=len-1; j<n; i++, j++)
			for (int k=i+1; k<j; k++) {
				// cout<<"DP["<<i<<", "<<j<<"] k="<<k<<endl;
				//dp[i][j] = min(dp[i,k] + dp[k,j]);
				for (auto s1 : dp[i][k])
					for (auto s2 : dp[k][j]) {
						long long midval = s1.pr + s2.pl + a[k];
						dp[i][j].insert(Stat{s1.pl+midval, s2.pr+midval});
					}
				shrink(i, j);
				// cout<<"\t size="<<dp[i][j].size()<<endl;
				// for (auto it: dp[i][j])
				// 	cout<<"\t ladd="<<it.pl<<" radd="<<it.pr<<endl;
			}
	long long ans = dp[0][n-1].begin()->pl + dp[0][n-1].begin()->pr;
	for (auto it : dp[0][n-1])
		ans = min(ans, it.pl + it.pr);
	cout<<a[0] + a[n-1] + ans<<endl;
	return 0;
}

Measured memory_bytes: 640
// atcoder/abc068/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    int j = 0;
    for (int i = 0; (1 << i) <= n; ++i) {
      j = i;
    }
    cout << (1 << j) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define ll long long
#define ull unsigned long long
#define pb push_back
#define pf push_front
#define mp make_pair
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int isprime(int n){
    int count =0;
    for(int i=2;i<=sqrt(n);i++)
    if(n%i==0)count++;
    if(count)return 0;
    return 1;
}

void dfs(vector<int>adj[],int u,int visited[]) {
       visited[u] = 1;
       for (int i = 0; i < adj[u].size(); i++) {
       int v = adj[u][i];
       if (visited[v]) {
       continue;
       }
      dfs(adj,v,visited);
      }
      }
void bfs(vector<int>adj[],int u,int visited[],int layer[]){
    queue<int> q;
    layer[u]=0;
    visited[u]=1;
    q.push(u);
    while(!q.empty()){
         u = q.front();
         q.pop();
        for(int i=0;i<adj[u].size();i++){
            int v = adj[u][i];
            if(!visited[v]){
                q.push(v);
                layer[v]=layer[u]+1;
                visited[v]=1;
            }
        }
    }
}    
void bfs01(vector<pair<int,int> >adj[],int start,int d[]){
    deque<int> q;
    q.pf(start);
    d[start]=0;
    while(!q.empty()){
         int u = q.front();
         q.pop_front();
        for(int i=0;i<adj[u].size();i++){
           if(d[adj[u][i].first]>d[u]+adj[u][i].second){
               d[adj[u][i].first] = d[u]+adj[u][i].second;
               if(adj[u][i].second==0)
               q.pf(adj[u][i].first);
               else 
               q.pb(adj[u][i].first);
               
           } 
          
        }
    }
   
}
void addedge(vector<int>adj[],int a,int b){
    adj[a].pb(b);
    adj[b].pb(a);
}

int main(){
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes";
    else cout<<"No";
    
    return 0;
}



Measured memory_bytes: 3748
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Jan 27 01:32:31 2019
//
package main

import "fmt"

func main() {
	var N, C int
	fmt.Scan(&N, &C)

	D := make([][]int, C)
	for i := range D {
		D[i] = make([]int, C)
	}

	for i := range D {
		for j := range D[i] {
			fmt.Scan(&D[i][j])
		}
	}

	m := [3]map[int]int{}
	for i := range m {
		m[i] = map[int]int{}
	}

	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			var a int
			fmt.Scan(&a)
			m[(i+j)%3][a-1]++
		}
	}

	ans := 1 << 60
	for i := 0; i < C; i++ {
		for j := 0; j < C; j++ {
			for k := 0; k < C; k++ {
				if i == j || j == k || k == i {
					continue
				}
				total := 0
				for key, v := range m[0] {
					total += D[key][i] * v
				}
				for key, v := range m[1] {
					total += D[key][j] * v
				}
				for key, v := range m[2] {
					total += D[key][k] * v
				}
				if total < ans {
					ans = total
				}
			}
		}
	}
	fmt.Println(ans)
}


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

int main(void) {
    int k;
    string s;
    cin >> k >> s;
    if (k >= s.size())cout << s;
    else {
        s=s.substr(0, k);
        s += "...";
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,k;
vector<int> xid;
vector<int> yid;
int x[51],y[51];
int sum[105][105];

ll maxi(ll a,int i,int j,int l,int m){
	ll xx=xid[i]-xid[l];
	if(xx<0)xx=-xx;
	ll yy=yid[j]-yid[m];
	if(yy<0)yy=-yy;
	if(a==-1)return xx*yy;
	return min(xx*yy,a);
}

bool C(int i,int j,int l,int m){
	int minix=xid[i];
	int maxix=xid[l];
	int miniy=yid[j];
	int maxiy=yid[m];
	int cnt=0;
	for(int a=0;a<n;a++){
		if(x[a]>=minix && x[a]<=maxix){
			if(y[a]>=miniy && y[a]<=maxiy){
				cnt++;
			}
		}
	}
	return cnt>=k;
}

int main(void){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x[i],&y[i]);
		xid.push_back(x[i]);
		yid.push_back(y[i]);
	}
	sort(xid.begin(),xid.end());
	sort(yid.begin(),yid.end());
	ll ans=-1;
	for(int i=0;i<yid.size();i++){
		for(int j=0;j<xid.size();j++){
			for(int l=i;l<yid.size();l++){
				for(int m=j;m<xid.size();m++){
					if(C(i,j,l,m)){
						ans=maxi(ans,i,j,l,m);
					}
				}
			}
			
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
// #define int ll

using namespace std;
typedef long long ll;
typedef long double ld;


signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	int N = n * n;
	vector<vector<int>> dp(n, vector<int> (n, 0));
	vector<vector<bool>> used(n, vector<bool> (n, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			dp[i][j] = min(i, min(j, min(n - 1 - i, n - 1 - j)));
		}
	}
	vector<int> p(n * n);
	for (int i = 0; i < n * n; i++) 
		cin >> p[i], p[i]--;
	int sum = 0;
	for (int i = 0; i < n * n; i++) {
		int x = p[i] / n, y = p[i] % n;
		sum += dp[x][y];
		deque<pair<int, int>> q;
		used[x][y] = 1;
		q.pb({x, y});
		while(len(q) > 0) {
			auto now = q.front();
			q.pop_front();
			for (int dx = -1; dx < 2; dx++) {
				for (int dy = -1; dy < 2; dy++) {
					if(abs(dx) + abs(dy) != 1)
						continue;
					int x2 = now.ft + dx, y2 = now.sc + dy;
					if(x2 < 0 || y2 < 0 || x2 >= n || y2 >= n)
						continue;
					if(used[now.ft][now.sc]) {
						if(dp[x2][y2] > dp[now.ft][now.sc]) {
							dp[x2][y2] = dp[now.ft][now.sc];
							q.push_front({x2, y2});
						}
					}
					else {
						if(dp[x2][y2] > dp[now.ft][now.sc] + 1) {
							dp[x2][y2] = dp[now.ft][now.sc] + 1;
							q.push_front({x2, y2});
						}
					}
				}
			}
		}
	}
	cout << sum;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
    int sum = 0;
  while(1) {
      if(sum % 2 == 0) C -= B;
      else A -= D;
      sum++;
      if(C <= 0) { cout << "Yes"; return 0; }
      else if(A <= 0) { cout << "No"; return 0;}
  }
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

ll f(ll n) {
  if(n%2==0) return n/2;
  return 3*n+1;
}

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

  ll n, h, w;
  cin >> n >> h >> w;
  
  ll ret = 0;
  REP(i, n) {
    ll a, b;
    cin >> a >> b;
    if(a >= h && b >= w) ret++;
  }
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 256
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int n,a,b;
  cin>>n>>a>>b;
  cout<<min(a*n,b);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n, m;
	cin >> n >> m;
	vint a(m, 0);
	int k;
	int x;
	rep(i, n) {
		cin >> k;
		rep(i, k) {
			cin >> x;
			a[x - 1]++;
		}
	}
	int ans = 0;
	rep(i, m) {
		if (a[i] == n) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    unordered_map<ll, ll> cnt;
    rep(i, N) {
        cnt[A[i]]++;
    }
    bool ok = true;
    rep2(i, 2, 1e6 + 5) {
        ll v = i;
        ll c = 0;
        while (v <= 1e6) {
            c += cnt[v];
            v += i;
        }
        if (c >= 2) {
            ok = false;
            break;
        }
    }
    if (ok) {
        cout << "pairwise coprime" << '\n';
        return;
    }
    ll g = 0;
    rep(i, N) {
        g = gcd(g, A[i]);
    }
    if (g == 1) {
        cout << "setwise coprime" << '\n';
    } else {
        cout << "not coprime" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


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

#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	 

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

int N;
int A[N_MAX];

int main(){
	cin>>N;
	REP(i,N)cin>>A[i];
	ll ans=0;
	int bit[21];
	REP(i,21)bit[i]=0;
	int r=0,x=0;
	REP(l,N){
		while(r<N && (x&A[r])==0){
			x|=A[r];
			r++;
		}
		ans+=r-l;
		x&=((1<<22)-1)^A[l];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
s = input()
t = input()

ls = len(s)
lt = len(t)

max_char = lt

for i in range(0, ls - lt+1):
    s2 = s[i:i + lt]
    # print(s2)
    count = 0
    for cs, ct in zip(s2, t):
        if cs != ct:
            count += 1
    max_char = min(count, max_char)
print(max_char)


Measured memory_bytes: 9048
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
#[allow(dead_code)]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
#[allow(dead_code)]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

macro_rules! eprint(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! eprintln(
    ($($arg:tt)*) => { {
        use std::io::Write;
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! dbg {
    ($val:expr) => {
        // Use of `match` here is intentional because it affects the lifetimes
        // of temporaries - https://stackoverflow.com/a/48732525/1063961
        match $val {
            tmp => {
                eprintln!(
                    "[{}:{}] {} = {:#?}",
                    file!(),
                    line!(),
                    stringify!($val),
                    &tmp
                );
                tmp
            }
        }
    };
}

fn main() {
    input! {
        n: usize,
        h: i64,
        w: i64,
        ab_v: [[i64; 2]; n],
    }

    let answer = ab_v.iter().filter(|&ab| ab[0] >= h && ab[1] >= w).count();
    println!("{}", answer);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
priority_queue<int> qe;
vector<int> ve[N]; 
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int a,b;
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&a,&b);
		if(m-a+1<1)continue;
		ve[m-a+1].push_back(b);
	}
	int anx=0;
	for(int i=m;i>=1;--i){
		for(int j=0;j<ve[i].size();++j){
			qe.push(ve[i][j]);
		}
		if(!qe.empty()){
			anx+=qe.top();
			qe.pop();
		}
	}
	printf("%d",anx);
}

Measured memory_bytes: 8948
a, b, c = map(int, input().split())
if a >= b >= c:
    print(c, b, a)
elif a >= c >= b:
    print(b, c, a)
elif b >= a >= c:
    print(c, a, b)
elif b >= c >= a:
    print(a, c, b)
elif c >= b >= a:
    print(a, b, c)
elif c >= a >= b:
    print(b, a, c)
    


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

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

  string ans = "Yes";

  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 1 && S.at(i) == 'R') ans = "No";
    if (i % 2 == 0 && S.at(i) == 'L') ans = "No";
  }

  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<pair<ll, ll>> v1(N), dif(N);
    for(int i=0;i<N;++i){
        cin >> v1[i].first >> v1[i].second;
        dif[i].second = v1[i].first - v1[i].second;
        dif[i].first = v1[i].first + v1[i].second;
    }
    sort(dif.begin(), dif.end());
    int count=0;
    ll x=dif[0].first;
    for(int i=1;i<N;++i){
        if(x <= dif[i].second){
            x = dif[i].first;
        }
        else{
            ++count;
        }
    }
    cout << N - count << endl;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
	char c1, c2, c3;
	cin >> c1 >> c2 >> c3;

	if (c1 == c2 && c1 == c3) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int sum,a;
  sum = 0;
  a = N;
  while (a) {
    int b;
    b = a%10; 
    sum += b;
    a = a/10;
  }
  
  if ( N%sum ==0 ) {
    cout << "Yes" << endl; 
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
  
struct P{
  int team;
  int ans;
  int sum;
  int pro[100];
  static bool less(const P& left,const P& right){
    if(left.ans!=right.ans) return left.ans > right.ans;
    else if(left.sum!=right.sum)return  left.sum < right.sum;
    else return left.team < right.team;
  }
};
  
int main(){
  int t,p,r,tid,pid,time;
  string sta;
  while(cin >> t >> p >> r){
    if(t == 0 && r == 0 && p == 0) break;
    vector <P> data;
    P tmp;
    for(int i=0;i<t;i++){
      tmp.team = i+1;
      tmp.ans = 0;
      tmp.sum = 0;
      for(int j=0;j<=p;j++) tmp.pro[j] = 0;
      data.push_back(tmp);
    }
    while(r--){
      cin >> tid >> pid >> time >> sta;
      if(sta == "CORRECT"){
    for(int i=0;i<t;i++){
      if(data[i].team == tid){
        data[i].sum += data[i].pro[pid]*1200+time;
        data[i].ans += 1;
        break;
      }
    }
      }
      else if(sta == "WRONG"){
    for(int i=0;i<t;i++){
      if(data[i].team == tid) data[i].pro[pid] += 1;
    }
      }
    }
    sort(data.begin(),data.end(),P::less);
    for(int i=0;i<t;i++) cout << data[i].team << " " << data[i].ans << " " << data[i].sum << endl;
  }
}


Measured memory_bytes: 3244
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};



int main(){
    lint x;
    cin>>x;
    lint n=100;
    irep(i){
        if(n>=x){
            cout<<i<<endl;
            return 0;
        }
        n*=1.01;
    }
}

Measured memory_bytes: 3656
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 200100
#define mdn 1000000007
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int f[N],n,m,pre[2][N]; char ch[N];
void upd(int &x,int y){x+=x+y>=mdn?y-mdn:y;}
int query(int l,int r,int w){return !l?pre[w][r]:(pre[w][r]-pre[w][l-1]+mdn)%mdn;}
int main()
{
	n=read(),m=read(); scanf("%s",ch+1);
	char w=ch[1]; int s=0,mn=inf,fs=0;
	for(int i=1;i<=m;i++)
		if(ch[i]==w)	s++;
		else	mn=s&1?min(s,mn):mn,fs=!fs?s:fs,s=0;
	mn=min(fs+!(fs&1),mn); f[0]=1,pre[0][1]=pre[0][0]=1;
	int ans=0;
	if(s==m)
	{
		f[0]=1; pre[0][0]=1;
		for(int i=2;i<=n;i++)
			f[i]=query(0,i-2,0),pre[0][i]=(pre[0][i-1]+f[i])%mdn;
		for(int i=1;i<=n;i++)	upd(ans,1ll*(i+1)*f[n-i-1]%mdn);
		printf("%d\n",ans+1);
		return 0;
	}
	for(int i=2;i<=n;i++)
		f[i]=query(max(0,i-mn-1),i-2,i&1),
		pre[i&1][i]=(pre[i&1][i-1]+f[i])%mdn,
		pre[!(i&1)][i]=pre[!(i&1)][i-1];
	for(int i=1;i<=mn;i+=2)	upd(ans,1ll*(i+1)*f[n-i-1]%mdn);
	printf("%d\n",ans);
	return 0;
}

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

int main()
{
	string s,t;
	cin>>s>>t;
	int dp[s.length()+3][t.length()+3];
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=s.length();i++)
	{
		for(int j=0;j<=t.length();j++)
		{
			if(i==0 || j==0)
					dp[i][j]=0;
			else if(s[i-1]==t[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string ans="";
	int m=s.length();
	int n=t.length();
	while(m>0 && n>0)
	{
		if(s[m-1]==t[n-1])
			{ans+=s[m-1];m--;n--;}
		else
		{
			if(dp[m-1][n]>dp[m][n-1])
				m--;
			else
				n--;
		}

	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}

Measured memory_bytes: 38864
map_height,map_width=map(int,input().split())
d={'.':0,'#':-1}
map_data= [list(map(lambda x: d[x],list(input()))) for _ in range(map_height)]

import itertools
Z= map_width*map_height

#m = np.ones((map_width*map_height,map_width*map_height))*float("inf")
m = [[401 for _ in range(Z)] for _ in range(Z)]
for i,j in itertools.product(range(map_height),range(map_width)):
    if map_data[i][j] == 0:
        for i_n, j_n in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:
            if 0 <= i_n < map_height and 0 <= j_n < map_width:
                if map_data[i_n][j_n] == 0:
                    m[map_width*i+j][map_width*i_n+j_n] = 1
for i in range(Z):
    m[i][i]=0
for k in range(Z):
    for i in range(Z):
        for j in range(Z):
            temp = min(m[i][j],m[i][k] + m[k][j])
            m[i][j] = temp
                
ans = 0
for i in range(Z):
    for j in range(Z):
        temp = m[i][j]
        if temp != 401:
            if ans < m[i][j]:
                ans = m[i][j]
print(ans)

Measured memory_bytes: 44540
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g,h,i,x,j;
    cin>>a>>b>>c>>d>>e;
    x=0;
    if(a<0){
        x=-a;
    }
    f=b-a;
    g=f*e;
    h=x*c;
    j=b*e;
    if(a<0){
        i=j+d+h;
        cout<<i<<endl;
    }
    else if(a>0){
        cout<<g<<endl;
    }
    
}


Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;


int main(void){
    vector<int> table;
    int n = 0;
    cin >> n;
    int f = 0;
    for(int i =0; i < n; i++){
        f = f ^ 0xFF;
        int tmp;
        cin >> tmp;

        if(f){
            table.push_back(tmp);
        }else{
            table.insert(table.begin(), tmp);
        }
    }
    if(n%2){
        reverse(table.begin(), table.end());
    }
    for(int i =0; i < n; i++){
        if(i != 0) cout << " ";
        cout << table[i];
    }
    cout << endl;
    return 0;
}   

Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
int main(){
   string s,t;
   cin >> s >> t;
   int n=s.size();
   for(int i=0;i<n;i++){
       if(s[i] == t[i])continue;
       else {
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

// rejudge

// from: https://atcoder.jp/contests/abc137/submissions/6831647
template<typename T>
struct BellmanFord{
	struct edge{
		int u,v;
		T w;
		edge(){}
		edge(int u,int v,T w):u(u),v(v),w(w){}
	};

	int n;
	vector< vector<int> > G,Ginv;
	vector<int> reach;
	BellmanFord(int n):n(n),G(n),Ginv(n),reach(n,0){}

	vector<edge> es;
	void add_edge(int u,int v,T c){
		es.emplace_back(u,v,c);
		G[u].emplace_back(v);
		Ginv[v].emplace_back(u);
	}

	void dfs(int v){
		if(reach[v]) return;
		reach[v]=1;
		for(int u:Ginv[v]) dfs(u);
	}

	T build(int from,int to,int &neg_loop){
		dfs(n-1);
		const T INF = numeric_limits<T>::max();
		vector<T> ds(n,INF);
		ds[from]=0;
		for(int j=0;j<n;j++){
			bool update=0;
			for(auto e:es){
				if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
				if(ds[e.v]>ds[e.u]+e.w){
					ds[e.v]=ds[e.u]+e.w;
					update=1;
				}
			}
			if(!update) break;
			if(j==n-1){
				neg_loop=1;
				return INF;
			}
		}
		neg_loop=0;
		return ds[to];
	}
};

ll n,m,p,ans;

int main(){
	cin>>n>>m>>p;
	BellmanFord<ll> f(n);
	rep(i,m){
		ll a,b,x;
		cin>>a>>b>>x;
		f.add_edge(a-1,b-1,p-x);
	}
	int neg_loop;
	ans = f.build(0,n-1,neg_loop);
	cout<<(neg_loop?-1:max(-ans,0LL))<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
int n;
int main()
{
    cin >> n;
    vector<int> a;
    a.resize(n);
    for (int i = 0; i != n; ++i)
    cin >> a[i];
    sort(a.begin(), a.end());

    if (accumulate(a.begin(), a.end(), 0) <= a.back() * 2)
        cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define mod 1000000007

long long ruijo(long long x,ll n){
	long long p,ans;
	if(n==0)return 1;
	if(n==1)return x;
	if(n%2){
		p = ruijo(x,n/2);
		ans = (x*p)%mod;
		ans = (ans*p)%mod;
		return ans;
	}else{
		p = ruijo(x,n/2);
		ans = (p*p)%mod;
		return ans;
	}
}

int main(){
    ll n;
    cin >> n;
    ll kai = 1;
    for(ll i=2;i<=n;i++){
        kai *= i;
        kai %= mod;
    }
    vector<ll>a(n);
    rep(i,n)cin >> a[i];
    ll sm = 0;
    for(int i=1;i<=n;i++){
        sm += ruijo(i,mod-2);
        sm %= mod;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        //cerr << sm << endl;
        ans += sm*a[i]%mod;
        ans %= mod;
        sm += mod-ruijo(n-i,mod-2);
        sm %= mod;
        sm += ruijo(i+2,mod-2);
        sm %= mod;
    }
    cout << ans*kai %mod << endl;
    return 0;
}

Measured memory_bytes: 1024
import fractions
a,b,c,d = map(int, input().split())

cd_gcd = fractions.gcd(c, d)
cd_lcm = (c*d)//cd_gcd

div_c_min = (a-1) // c
div_c_max = b // c
div_d_min = (a-1) // d
div_d_max = b // d
div_cd_min = (a-1) // (cd_lcm)
div_cd_max = b // (cd_lcm)

total =  b - a +1

diff = (div_c_max-div_c_min) + (div_d_max-div_d_min) - (div_cd_max - div_cd_min)
diff_total = total -diff

print(diff_total)

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string s,t;
    cin>>s>>t;
    ll ans=inf;
    fr(i,0,SZ(s))
    {
        if(i+SZ(t)<=SZ(s))
        {
            ll ct=0;
            fr(j,0,SZ(t))
            {
                if(s[i+j]!=t[j])
                {
                    ct++;
                }
            }
            ans=min(ans,ct);
        }
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 2050


#define PI 3.14159265358979323846264338327950

#define ll   long long int
ll mod = 1000000007;
ll a[MAXX], b[MAXX];

int main()
{
	FAST;
	ll n, t , h = 1, ans= 0;;
	cin >> n >> t;
	for(ll i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	for(ll i = 0; i < t; i++){
		ans += a[i];
	}
	cout <<ans;
	
}

Measured memory_bytes: 3656
#include<iostream>
using namespace std;
int main() {
	double l,r;
	int la,lb,lc,ld,ra,rb,rc,rd;
	la = 0;
	lb = 0;
	lc = 0;
	ld = 0;
	ra = 0;
	rb = 0;
	rc = 0;
	rd = 0;
	while (cin >> l >> r) {
		if (l >= 1.1)la += 1;
		else if (l >= 0.6)lb += 1;
		else if (l >= 0.2)lc += 1;
		else ld += 1;
		if (r >= 1.1)ra += 1;
		else if (r >= 0.6)rb += 1;
		else if (r >= 0.2)rc += 1;
		else rd += 1;
	}
	cout << la << ' ' << ra << endl;
	cout << lb << ' ' << rb << endl;
	cout << lc << ' ' << rc << endl;
	cout << ld << ' ' << rd << endl;

}

Measured memory_bytes: 3200