akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}

int n, m, k;
ll dp[(1 << 20)];
int go[20][20];
int lst[(1 << 20)];
int gg[20][(1 << 20)];
const ll MOD = 1e9 + 7;

void add(ll &a, ll b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

int main() {
    cin >> n >> m >> k;
    --n;
    for (int i = 0; i < (1 << n); ++i) {
        lst[i] = -1;
        for (int j = 0; j < n; ++j)
            gg[j][i] = -1;
        int cc = 0;
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                if (j != 0 && !((i >> (j - 1)) & 1)) {
                    gg[cc][i] = i - (1 << j) + (1 << (j - 1));
                }
                lst[i] = j;
                ++cc;
            }
        }
    }
    for (int i = 0; i < k; ++i) { 
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        go[a][b] |= (1 << c);
    }
    for (int i = 0; i < m; ++i) 
        for (int j = 0; j < n; ++j)
            if (go[i][j] == 3) {
                cout << 0 << "\n";
                return 0;
            }
    dp[0] = 1;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = (1 << n) - 1; k >= 0; --k) {
                if (dp[k] && gg[j][k] != -1)
                    add(dp[gg[j][k]], dp[k]);
            }
        }
        for (int j = 0; j < n; ++j)
            for (int k = 0; k < (1 << n); ++k) { 
                if (lst[k] < j)
                    add(dp[k + (1 << j)], dp[k]);
            }
        for (int k = 0; k < (1 << n); ++k) {
            for (int j = 0; j < n; ++j) {
                if (go[i][j] == 1 && ((k >> j) & 1))
                    dp[k] = 0;
                else if (go[i][j] == 2 && !((k >> j) & 1))
                    dp[k] = 0;
            }
        }
    }
    ll ans = 0;
    for (int j = 0; j < (1 << n); ++j)
        add(ans, dp[j]);
    cout << ans << "\n";
    return 0;
}




Measured memory_bytes: 88320
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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


int mod=1000000000+7;
int modu=998244353;

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

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

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

std::vector<pair<int,int > > v;

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


//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	god;
	//rko;
	fun();
	int tt=1; //cin>>tt;
	while(tt--)
	{
		int n; cin>>n;
		int h[n+1]; h[0]=0;
		for(int i=1;i<=n;i++) cin>>h[i];
		int dp[n+1];
		dp[0]=0; dp[1]=0;
		dp[2]=abs(h[1]-h[2]);
		for(int i=3;i<=n;i++) dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
		cout<<dp[n];
	}
	return 0;
}

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

string s;
vector<char> ch;

int main() {
	megaRandom();
	cin >> s;
	for(int i = 0; i < sz(s); i ++) {
	  if(s[i] == 'T') {
			if(sz(ch) > 0 && ch.back() == 'S')
				ch.pp();
			else
				ch.pb(s[i]);
		} else ch.pb(s[i]);
	}
	cout << sz(ch);
	return 0;  
}


Measured memory_bytes: 772
s=input()
if s.count("N")>0 and s.count("S")==0:
    print("No")
elif s.count("W")>0 and s.count("E")==0:
    print("No")
elif s.count("N")==0 and s.count("S")>0:
    print("No")
elif s.count("W")==0 and s.count("E")>0:
    print("No")
else:print("Yes")

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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ct(i) cout<< i << "\n"
#define sv(v) sort(v.begin(),v.end())
#define mod 1000000007
#define M 100005
#define endl "\n"

void answer(){
	int n,m;
	cin>>n;
	int a1=0,a2=0,a3=0,a4=0;
    string c;
	while(n--){
	    cin>>c;
	    if(c=="AC") a1++;
	    if(c=="WA") a2++;
	    if(c=="TLE") a3++;
	    if(c=="RE") a4++;
	    
	}
	cout<<"AC x "<<a1<<endl;
	cout<<"WA x "<<a2<<endl;
	cout<<"TLE x "<<a3<<endl;
	cout<<"RE x "<<a4<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>

/*
0 1 2 3 4 ... N-4 N-3 N-2 N-1 N
0～Kまでの数の総和 = 
N-K～Nまでの数の総和 = NK - (K-1)K/2
0～NでK個を選んだ場合の和としてありうるものの数は NK - K(K-1) + 1
0～NでK個以上を選んだ場合の和としてありうるものの数は Σ[i=K→N+1](NK - K(K-1) + 1)
 */
int main(){
    long long int N_input;
    long long int K_input;
    long long int kosu=0;

    scanf("%lld %lld", &N_input, &K_input);
    // printf("%lld %lldn", N_input, K_input);

    for(auto m=K_input; m<=N_input+1; m++){
        kosu += (m*N_input - (m-1)*m + 1);
        // printf("%lld %lld %lld %lld\n", N_input, K_input, m, kosu);
    }

    printf("%lld", kosu%1000000007);
}

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

using namespace std;

#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define pb			    push_back

typedef long long ll;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    string s;
    cin >> s;
    int len = SZ(s);
    if (len % 2 == 0)
    	cout << "No";
    else {
    	for (int i = 0; i < len / 2; ++i) {
    		if (s[i] != s[len - i - 1]) {
    			cout << "No";
    			return 0;
    		}
    	}
    	int first = (len - 1) >> 1;
    	for (int i = 0; i < first; ++i) {
    		if (s[i] != s[first - i - 1]) {
    			cout << "No";
    			return 0;
    		}
    	}
    	int sec = (len + 3) >> 1;
    	for (int i = sec; i < len; ++i) {
    		if (s[i] != s[len - i - 1]) {
    			cout << "No";
    			return 0;
    		}
    	}
    	cout << "Yes";
    }

    return 0;
}


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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;

// stores all divisors of x excluding 1 and x
void computeAllDivisors(int x, vi& divisors) {
      divisors.clear();
      int i;
      for(i = 2; i*i < x; i++) {
            if(x % i == 0)  {
                  divisors.pb(i);
                  divisors.pb(x / i);
            }
      }
      if(i *i == x) 
            divisors.pb(i);
}

void solve() {
	int i = 0, j = 0, k = 0, n = 0, ans = 0;
	cin >> n;
      if(n == 2) {
            cout << "1\n";
            return;
      }
      vi d_0, d_1;
      computeAllDivisors(n, d_0);
      computeAllDivisors(n - 1, d_1);
      for(int val : d_0) {
            k = n;
            while(k > 1 and k % val == 0) {
                  k /= val;
            }
            if(k % val == 1) ans++;
      }

      ans += sz(d_1) + 2;     // +n-1, +n
      cout << ans << el;
}

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
	// cin >> T;
	for(int tc = 1; tc <= T; tc++) {
		solve();
	}
	return 0;
}

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

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c), d(0);
  rep(i, a) cin >> p[i];
  rep(i, b) cin >> q[i];
  rep(i, c) cin >> r[i];
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  rep(i, x) d.emplace_back(p[i]);
  rep(i, y) d.emplace_back(q[i]);
  rep(i, c) d.emplace_back(r[i]);
  sort(d.begin(), d.end(), greater<int>());
  ll ans = 0;
  rep(i, x + y) ans += d[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

struct P{
    int x,y;
};

int main (){
    ll x,sum=0;cin>>x;
    int index;
    rep(i,1,x+1){
        sum+=i;
        if(sum>=x){
            index=i;
            break;
        }
    }
    rep(i,1,index+1){
        if(i==sum-x)continue;
        cout<<i<<endl;
    }
    
}


/*

*/


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine().Select(c => c - 'a');
        var T = ReadLine().Select(c => c - 'a');

        var ans = "Yes";
        var STMapper = Enumerable.Repeat(-1, 26).ToArray();
        var TSMapper = Enumerable.Repeat(-1, 26).ToArray();
        foreach (var (s, t) in S.Zip(T))
        {
            if(STMapper[s] == -1)
                STMapper[s] = t;
            else if(STMapper[s] != t)
            {
                ans = "No";
                break;
            }

            if (TSMapper[t] == -1)
                TSMapper[t] = s;
            else if (TSMapper[t] != s)
            {
                ans = "No";
                break;
            }
        }

        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


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

int main() {
  ll h, w;
  cin >> h >> w;
  ll ans = (h*w+1)/2;
  if (h == 1 || w == 1) ans = 1;
  cout << ans << endl;
  return 0;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
#define COUT(x) cout<<(x)<<"\n"

int main(){
    string s,t;
    cin >> s >> t;
    if(t.substr(0,s.size())==s)COUT("Yes");
    else COUT("No");
    return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

#define FOR(i,a,b) for (int i=a;i<b;i++)
#define fi first
#define se second
#define pb push_back

int n;
string s;
vi adj[100005];

vector<pii> edges;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    cin >> s;
    n = s.length();
    if (s[n-1] == '1') {
        puts("-1");return 0;
    }
    FOR(i,1,n){
        if (s[i-1] != s[n-i-1]){
            puts("-1");
            return 0;
        }
    }
    if (n > 1 && s[0] == '0'){
        puts("-1");
        return 0;
    }
    int now, nxt;
    now = 1;
    nxt = 2;
    for (int i = 0; i < n/2; i++){
	if (s[i] == '1'){
	    adj[now].pb(nxt);
	    adj[nxt].pb(now);
	    now = nxt;
	    nxt++;
	} else {
	    adj[now].pb(nxt);
	    adj[nxt].pb(now);
	    nxt++;
	}
    }
    for (int i = n/2; i < n-1; i++){
	adj[now].pb(nxt);
	adj[nxt++].pb(now);
    }

    for (int i = 1; i <= n; i++){
        for (int j = 0; j < adj[i].size(); j++){
            edges.push_back(make_pair(min(i,adj[i][j]), max(i,adj[i][j])));
        }
    }
    sort(edges.begin(), edges.end());
    edges.erase(unique(edges.begin(), edges.end()), edges.end());
    for (auto i : edges){
	cout << i.fi << ' ' << i.se << '\n';
    }
    return 0;
}


Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt;

int main(){
	ll a,b,c;
	cin >> a >> b >> c;
	ll k;
	cin >> k;
	while(a>=b){
		cnt++;
		b*=2;
		if(cnt>k){
			cout << "No" << endl;
			return 0;
		}
	}
	while(b>=c){
		cnt++;
		c*=2;
		if(cnt>k){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <random>
#include <chrono>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 100010

void solve(){
    string s;
    
    cin >> s;
    
    if(s == "SSS") cout << 0 << endl;
    else if(s == "RRS" || s == "SRR") cout << 2 << endl;
    else if(s == "RRR") cout << 3 << endl;
    else cout << 1 << endl;
}

int main(){
    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}




Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>

using namespace std;
//DP用
template<class T> inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

//a^n mod を計算する関数
long long modpow(long long a,long long n,long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n % 2 == 1) {
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//a^(-1) mod すなわちaの逆元を返す関数
long long modinv(long long a,long long mod) {
    return modpow(a,mod-2,mod);
}

//最大公約数をを返す関数
long long gcd (long long a,long long b) {
    if(a % b == 0) {
        return b;
    }else {
        return (gcd(b,a%b));
    }
}

const long long INF = 1LL << 60;
const long long P = 1000000007;

//nCkを求める関数
long long conbi (long long n,long long k) {
    long long res = 1;
    long long inv;
    for(long long i = n-k+1; i <= n; i++) {
        res *= i;
        res %= P;
    }
    for(long long i = 1; i <= k; i++) {
        inv = modinv(i,P);
        res *= inv;
        res %= P;
    }
    return res;
}

int main() {
    int h,w;
    cin >> h >> w;
    string s[h];
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }
    
    int a[h][w];
    for(int i = 0; i < h; i++) {
        string t = s[i];
        for(int j = 0; j < w; j++) {
            if(t[j] == '.') {
                a[i][j] = 0;
            }
            if(t[j] == '#') {
                a[i][j] = 3000;
            }
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] >= 3000) {
                if(i > 0 && j > 0) {
                    a[i-1][j-1] += 1;
                }
                if(i > 0) {
                    a[i-1][j] += 1;
                }
                if(i > 0 && j < w-1) {
                    a[i-1][j+1] += 1;
                }
                if(j > 0) {
                    a[i][j-1] += 1;
                }
                if(j < w-1) {
                    a[i][j+1] += 1;
                }
                if(i < h-1 && j > 0) {
                    a[i+1][j-1] += 1;
                }
                if(i < h-1) {
                    a[i+1][j] += 1;
                }
                if(i < h-1 && j < w-1) {
                    a[i+1][j+1] += 1;
                }
            }
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(a[i][j] >= 3000) {
                cout << '#';
            }else {
                cout << a[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}



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

int main(){
    //残りの石がKこの時の勝敗を考える
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    bool dp[100100] = {};
    // taroが勝てるかどうか
    dp[0] = false;
    for(int k=0;k<=K;k++){
        for(int i=0;i<N;i++){
            if(k + A[i] > K) continue;
            dp[k + A[i]] |= !dp[k];
        }
    }
    if(dp[K] == true) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 384
import sys
f = sys.stdin

import string

OFFSET = ord('a')

def to_gamma(c):
    return ord(c) - OFFSET

def from_gamma(gamma, alpha, beta):
    return chr((alpha * gamma + beta) % 26 + OFFSET) 

def affine(c, alpha, beta):
    return from_gamma(to_gamma(c), alpha, beta)


# g[0]==g[3]である前提
def search_that(w):
    b = to_gamma(w[2])
    for a in range(26):
        if w[0] == affine('t',a,b) and w[1] == affine('h',a,b):
            return a, b
    return -1, -1

def search_this(w):
    a = (to_gamma(w[0]) - to_gamma(w[3]) + 26) % 26
    for b in range(26):
        if w[0] == affine('t',a,b) and w[1] == affine('h',a,b) and w[2] == affine('i',a,b) and w[3] == affine('s',a,b):
            return a, b
    return -1, -1

def search(w):
    if w[0] == w[3]:
        return search_that(w)
    else:
        return search_this(w)

n = int(f.readline())
for i in range(n):
    line = f.readline().strip()
    words = [word for word in line.split() if len(word) == 4]
    for word in words:
        a, b = search(word)
        if a != -1:
            print(line.translate(str.maketrans(''.join([affine(c, a, b) for c in string.ascii_lowercase]), string.ascii_lowercase)))
            break    
    

Measured memory_bytes: 6776
use proconio::*;
use proconio::marker::*;
use std::collections::*;

fn run() {
    input! {
        n: usize,
        mut s: [Bytes; n],
    }
    s.iter_mut().for_each(|s| s.reverse());
    s.sort_by_key(|s| s.len());
    let mut map = BTreeMap::<usize, BTreeMap<&[u8], usize>>::new();
    let mut ans = 0;
    for s in s.iter() {
        let mut bit = 0;
        let mut pos = s.len();
        for (&len, map) in map.iter().rev() {
            while pos > len {
                pos -= 1;
                bit |= 1 << (s[pos] - b'a') as usize;
            }
            let pre = &s[..pos];
            ans += map.get(pre).map_or(0, |p| (bit & *p).count_ones());
        }
        let len = s.len();
        let pre = &s[..(len - 1)];
        let k = (s[len - 1] - b'a') as usize;
        *map.entry(len - 1).or_insert(BTreeMap::new()).entry(pre).or_insert(0) |= 1 << k;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 19420
/******techknight@3******/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1000000000000000000
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
          lld n; cin>>n;
          pls(n,a);
          lld ans=1; lld flag=1;
          iot(n)   if(a[i]==0){flag=2; break;}
          if(flag==2) {cout<<0<<nl; return 0;}
          iot(n){
              lld f=ans*a[i];//cout<<f<<nl;
              if(f<ans||f>tod){flag=-1; break;}
              if(f/a[i]!=ans){flag=-1; break;}
              ans=f;
          }
          
        if(flag==-1)  cout<<-1<<nl;
          else
          cout<<ans<<nl;
}



Measured memory_bytes: 4428
n,m=map(int,input().split())
ac=0
wa=0
ans=[True]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)-1
    if s=="AC" and ans[p]:
        ans[p]=False
        ac+=1
    elif s=="WA" and ans[p]:
        wa[p]+=1
cnt=0
for i in range(n):
    if not ans[i]:
        cnt+=wa[i]
print(ac,cnt)


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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

int N;
string S;

int main(void) {
    cin >> N >> S;

    int ans = 0;
    for (char x = '0'; x < ('9' + 1); ++x) {
        auto p = S.find(x, 0);
        if (p == string::npos) continue;
        for (char y = '0'; y < ('9' + 1); ++y) {
            auto p2 = S.find(y, p + 1);
            if (p2 == string::npos) continue;
            for (char z = '0'; z < ('9' + 1); ++z) {
                auto p3 = S.find(z, p2 + 1);
                if (p3 == string::npos) continue;

                ans++;
            }
        }
    }

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

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np
input = sys.stdin.readline

N, Q = [int(i) for i in input().split()]
S = input()
is_AC = [False] * N
AC_csum = [0] * N
for i in range(N):
  is_AC[i] = S[i:i+2] == "AC"
  AC_csum[i] = AC_csum[i-1] + is_AC[i]

for i in range(Q):
  l, r = [int(i) for i in input().split()]
  ans = AC_csum[r-1] - AC_csum[l-1] - is_AC[r-1] + is_AC[l-1]
  print(ans)


Measured memory_bytes: 17712
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; ++i)
    cin >> X[i];
  int min_X = 1000000001, max_X = -1;
  for (int i = 0; i < N; ++i)
    min_X = min(X[i], min_X), max_X = max(X[i], max_X);
  int ans = 1000000001;
  for (int P = min_X; P <= max_X; ++P) {
    int sum = 0;
    for (int i = 0; i < N; ++i)
      sum += (X[i] - P) * (X[i] - P);
    ans = min(sum, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
import math
import fractions
import functools
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

maximum = max(a)

count_m = a.count(maximum)

co = copy.deepcopy(a)
for i in range(n):
    if co[i] == maximum:
        co[i] = 0
maximum2 = max(co)

for i in range(n):
    if count_m == 1 and a[i] == maximum:
        print(maximum2)
    else: print(maximum)

Measured memory_bytes: 120916
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  string s,t;
  cin>>s>>t;
  if(s==t.substr(0,int(t.length())-1)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


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

using namespace std;

#define MAX 50

long long dp[MAX + 1][MAX + 1][MAX * MAX + 1];

int main()
{
	int N, A, max_v = 0;
	long long ans = 0;
	cin >> N >> A;

	vector<int> X(N);

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

		if (max_v < X[i])
			max_v = X[i];
	}

	for (int i = 0; i <= N; i++)
	{
		for (int j = 0; j <= N; j++)
		{
			for (int k = 0; k <= N * max_v; k++)
			{
				long long v;
				if (i == 0 && j == 0 && k == 0)
					v = 1;
				else if (i > 0)
				{
					v = dp[i - 1][j][k];

					if (j > 0 && k >= X[i - 1])
						v += dp[i - 1][j - 1][k - X[i - 1]];
				}
				else
					v = 0;

				dp[i][j][k] = v;
			}
		}
	}

	for (int i = 1; i <= N; i++)
	{
		ans += dp[N][i][A * i];
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 51072
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		x = x * x * x;
		System.out.println(x);
	}
}

Measured memory_bytes: 26272
#include <stdio.h>
#include <stdint.h>
typedef int64_t i64;
#define SIZE 100001

int main(void){
    int n, i, a, count[SIZE] = {0}, q, b, c, j;
    i64 sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a);
        sum += a;
        count[a]++;
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d %d", &b, &c);
        sum += (c - b) * count[b];
        count[c] += count[b];
        count[b] = 0;
        printf("%ld\n", sum);
    }
}

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

signed main()
{   
    int N; cin>>N;
    vector<int> a(N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());

    vector<int> b(N+1);
    b[0]=0;
    for(int i=0;i<N;i++){
        b[i+1]=__gcd(b[i],a[i]);
    }
    vector<int> c(N+1);
    c[N]=0;
    for(int i=N-1;i>=0;i--){
        c[i]=__gcd(c[i+1],a[i]);
    }

    int ans=0;
    for(int i=0;i<N;i++){
        int g=__gcd(b[i],c[i+1]);
        ans=max(ans,g);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  int n;
  while(scanf("%d", &n) && n){
    int lmin = 9999, lmax = 0, sum = 0, s;
    rep(i, n){
      scanf("%d", &s);
      lmin = min(lmin, s); lmax = max(lmax, s);
      sum += s;
    }

    printf("%d\n", (sum - lmin - lmax) / (n-2));
  }
  return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	string s;
	cin >> s;
	if((s[0]==s[1] && s[1]==s[2]) || (s[1]==s[2] && s[2]==s[3])) cout << "Yes" << endl;
	else cout << "No" << endl;

}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int[] ans = new int[10005];
		int v=0;
		for (int x = 1; x < 100; ++x) {
			for (int y = 1; y < 100; ++y) {
				for (int z = 1; z < 100; ++z) {
						v = x*x+y*y+z*z+x*y+y*z+z*x;
						if(v<10005) ans[v]++;
				}
			}
		}
			//System.out.println("["+i+"]"+ans);
			for(int i=0;i<N;++i){
				System.out.println(ans[i+1]);
			}
	}
}


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

#define ALL(a) (a).begin(), (a).end()
#define ll long long

const ll INF = (ll)1e10;

using namespace std;

signed main(){
	int n; cin >> n;
	vector<ll> a(n,0);
	for(auto &e : a)cin >> e;
	vector<ll> dp(n,INF);
	for(auto e : a){
		auto lb = lower_bound(ALL(dp), e);
		*lb = e;
	}
	cout << distance(dp.begin(), lower_bound(ALL(dp),INF)) << endl;

	return 0;
}




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

int main(){
  int N;
  cin >> N;
  int maxL = 0;
  int sum = 0;
  for(int i= 0; i<N; i++){
    int L;
    cin >> L;
    sum += L;
    maxL = max(maxL, L);
  }
  int x = 0;
  x = sum - maxL;
  if(maxL < x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
    

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

int m;

double calc(int n, int s)
{
	if (n == 0) return max(1, s);
	double res = 0.0;
	for (int i = 1; i <= m; i++){
		res += calc(n - 1, s + i);
	}
	return res;
}

int main()
{
	int n, k;
	while (cin >> n >> m >> k, n){
		double res = calc(n, -k) / pow(m, n);
		printf("%.20f\n", res);
	}
}

Measured memory_bytes: 1248
#!/usr/bin/env ruby

N = gets.chomp.to_i

count = 0

1.upto(N) do |a|
  bmax = N / a + 1

  a.upto(bmax) do |b|
    ab = a * b
    break if ab >= N

    count += a == b ? 1 : 2
  end
end

puts count


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

using ll = long long;

int main() {
    ll N, ans = 1e18;
    cin >> N;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i != 0) continue;
        ans = min(ans, i + N / i - 2);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

createList ks i n
  | i > n = []
  | i `elem` ks = 1 : createList ks (i + 1) n
  | otherwise = 0 : createList ks (i + 1) n

calc :: [Int] -> [Int] -> Int -> Bool
calc ks xs p = ((foldr (+) 0 $ zipWith (*) ks xs) `mod` 2) == p

calcAll :: [[Int]] -> [Int] -> [Int] -> Bool
calcAll [] xs [] = True
calcAll (ks : kss) xs (p : ps)
  | (calc ks xs p) == True = calcAll kss xs ps
  | otherwise = False

judge :: [[Int]] -> [[Int]] -> [Int] -> Int -> Int
judge kss [] ps n = n
judge kss (xs : xss) ps n
  | (calcAll kss xs ps) == True = judge kss xss ps (n + 1)
  | otherwise = judge kss xss ps n

main = do
  [n, m] <- getIntList
  kss <- getIntNList m
  ps <- getIntList
  let kss' = map tail kss
  let kss'' = map (\ks -> createList ks 0 n) kss'
  let xss = replicateM n [0, 1]
  let xss' = map (\xs -> 0 : xs) xss
  print $ judge kss'' xss' ps 0


Measured memory_bytes: 4104
#include <bits/stdc++.h>
#define rep(k,i,n) for(long long i=k;i<n;++i)
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll N,X,sum=0;
    cin>>N>>X;
    ll l[N];
    rep(0,i,N)cin>>l[i];
    rep(0,i,N){
        sum+=l[i];
        if(X<sum){
            cout<<i+1<<endl;
            return 0;
        }
    }
    cout<<N+1<<endl;
}


Measured memory_bytes: 256
K = gets.to_i
gcd = Array.new(K + 1){Array.new(K + 1, 0) }
ans = 0
(1 .. K).each do |a|
  (1 .. K).each do |b|
    gcd[a][b] = a.gcd(b)
  end
end
(1 .. K).each do |a|
  (1 .. K).each do |b|
    (1 .. K).each do |c|
      ans += gcd[gcd[a][b]][c]
    end
  end
end
puts ans


Measured memory_bytes: 14448
import sys
sys.setrecursionlimit(100005)
mod=1000000007
# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2

def dfs(v,a):
    w=b=1
    for u in links[v]:
        if u==a:
            continue
        cw,cb=dfs(u,v)
        w*=cw+cb
        b*=cw
        w%=mod
        b%=mod
    return w,b


n=int(input())
links=[set() for i in range(n)]

for line in sys.stdin.readlines():
    x,y=map(int, line.split())
    x-=1
    y-=1
    links[x].add(y)
    links[y].add(x)

print(sum(dfs(0,None))%mod)

Measured memory_bytes: 112464
using System; 
using System.Text;
using System.Collections.Generic; 
using System.Linq; 
using E = System.Linq.Enumerable; 


class Program {
    //最短ステップ記録用
   
    static void Main(string[] args) {
        //入力を受け取る
        var NM = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
        var N  = NM[0];
        var M  = NM[1];
        
        //県ごとに市の情報を管理する
        var city = new List<long>[N+1];
        var ww = new long[M][];
        for(int i = 0;i <= N ;i++){
            city[i] = new List<long>();
        }
        for(int i = 0;i < M ;i++){
            var PY = Console.ReadLine().Split().Select(a => int.Parse(a)).ToArray();
            var P  = PY[0];
            var Y  = PY[1];
            city[P].Add(Y);
            ww[i]  = new long[2]{P,Y};
        }

        var dic = new Dictionary<long,int>[N+1];
        //県ごとに市の順位を求めていく
        var rank = new long[N+1][];
        for(int i = 1;i <= N ;i++){
            rank[i] = city[i].ToArray();
            Array.Sort(rank[i]);
　　　　　　dic[i] = new Dictionary<long,int>();
            for(int j = 0;j < rank[i].Length;j++){
		dic[i].Add(rank[i][j],j);
            }
        }
        

        
        //市ごとに順位情報を出力
        for(int i = 0;i < M ;i++){
            var PR = ww[i][0];
            var RA = dic[PR][ww[i][1]]+1;
           var tmp = string.Format($"{PR:000000}"); Console.WriteLine(tmp+string.Format($"{RA:000000}")); 
            
        }
      
     }
}
     
     
                   


Measured memory_bytes: 64788
import numpy as np

H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

ret = []
for r in grid:
    if any(x == '#' for x in r):
        ret.append(r)
grid = np.array(ret).T.tolist()

ret = []
for r in grid:
    if any(x == '#' for x in r):
        ret.append(r)

grid = np.array(ret).T.tolist()

for r in grid:
    print(*r, sep='')


Measured memory_bytes: 13928
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
ll binpow(ll a,ll b) {
if (b == 0)return 1;ll res = binpow(a, b / 2);
if (b % 2)return res * res * a;else return res * res;}

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll x;
 	cin>>x;
 	for(ll i=-1e3;i<=1e3;i++)
 	{
 		for(ll j=-1e3;j<=1e3;j++)
 		{
 			ll a = binpow(i,5);
 			ll b = binpow(j,5);
 			if(a-b==x)
 			{
 				cout<<i<<" "<<j<<endl;
 				return 0;
 			}
 		}
 	}
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  string a,b;
  cin>>a>>b;
  string ans="NO";
  if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])ans="YES";
  cout(ans);
  return 0;
}

Measured memory_bytes: 125568
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
//int dy[] = {0, 0, -1, 1};
//int dx[] = {1, -1, 0, 0};

int main() {
    string s;
    getline(cin, s);
    istringstream ss(s + "\n");
    map<string, int> mp;
    string longer;
    while (1) {
        string t; ss >> t;
        if (!ss.good()) break;
        mp[t]++;
        if (t.size() > longer.size()) longer = t;
    }
    string freq;
    int lerger = 0;
    for (auto it : mp) {
        if (it.second > lerger) {
            lerger = it.second;
            freq = it.first;
        }
    }
    cout << freq << " " << longer << endl;
}



Measured memory_bytes: 3164
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll a, b;
    cin >> a >> b;
    if (a < b) {
        for (ll i = 0; i < b; ++i) cout << a;
    } else {
        for (ll i = 0; i < a; ++i) cout << b;
    }
    cout << endl;
}


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

using namespace std;

#define ll long long

void solve() {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	if (s[a] != '-') {
		cout << "No\n";
	} else {
		for (int i = 0; i < s.length(); i++) {
			if (!isdigit(s[i]) && i != a) {
				cout << "No\n";
				return;
			}
		}
		cout << "Yes\n";
	}
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 #define rep(i , n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  long long int N, kekka;
  kekka = 0;
  cin >> N;
  vector<long long int> A(N + 1);
  vector<long long int> B(N);
  rep(i , N+1)
    cin >> A[i];
  rep(i , N)
    cin >> B[i];
  rep(i , N){
    if(A[i] >= B[i])
      kekka += B[i];
    else{
      if(A[i] + A[i + 1] >= B[i]){
        kekka += B[i];
      A[i + 1] += A[i] - B[i];
      }
      else{
        kekka += A[i] + A[i + 1];
      A[i + 1] = 0;
      }
  }
  }
    cout << kekka << endl;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)

using namespace std;

const int N = 2e5 + 10;

int n, m;
int A[N], B[N];

struct Num {
	int o, ty, w;

	bool operator < (const Num& y) const { return w < y.w; }
}num[N];

int deg[N];

int main() {

	scanf("%d", &n);
	For(i, 1, n) {
		scanf("%d%d", &A[i], &B[i]);
		num[++m] = (Num){i, 0, A[i]}, num[++m] = (Num){i, 1, B[i]};
	}
	sort(num + 1, num + m + 1);

	long long ans = 0;
	int c[2] = {0};
	For(i, 1, n) {
		++deg[num[i].o], ++c[num[i].ty];
		ans += num[i].w;
	}
	For(i, 1, n) if (!deg[i]) {
		printf("%lld\n", ans);
		return 0;
	}
	if (!c[0] || !c[1]) { printf("%lld\n", ans); return 0; }
	
	if (num[n].o == num[n + 1].o && c[num[n].ty] > 1) ans += min(num[n + 1].w - num[n - 1].w, num[n + 2].w - num[n].w);
	else ans += num[n + 1].w - num[n].w;

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

	return 0;
}

Measured memory_bytes: 4096