akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if ((abs(a - c) <= d) || (abs(a - b) <= d && abs(b - c) <= d))
        cout << "Yes";
    else
        cout << "No";
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i] >> B[i];
    for (int i = 0; i < N-2; i++) {
        if (A[i] == B[i] && A[i+1] == B[i+1] && A[i+2] == B[i+2]) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int mi[514514];
signed main(){
	string s;
	cin>>s;
	int n = s.size()+1;
	mi[1] = 0;
	for(int i=2;i<=n;i++){
		if( s[i-2] == '<' ){
			mi[i] = max(mi[i],mi[i-1] + 1);
		}
	}
	for(int i=n-1;i>=1;i--){
		if( s[i-1] == '>'){
			mi[i] = max(mi[i],mi[i+1]+1);
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		ans += mi[i];
		//cout<<mi[i]<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4740
#include<iostream>
using namespace std;
int main(){
	int n,cnt=0;
	cin >> n;
	bool sw[n];
	int b[n];
	for (int i = 0; i < n; i++){
		sw[i] = false;
		cin >> b[i];
	}
	sw[0] = true;
	int now = 0;
	while (1){
		
			
				cnt++;
				sw[now] = false;
				sw[b[now]-1] = true;
				now = b[now]-1;
				if (cnt>n){
					cout << -1 << endl;
					return 0;
				}
				if (sw[1] == true){
					cout << cnt << endl;
					return 0;
				}
			
		}

		
	}
	

Measured memory_bytes: 768
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    string S, T; cin >> S >> T;
    int N = S.size();

    bool ok = true;
    set<char> from, to;
    set<pair<char, char>> conv;
    REP(i,N) {
        if (conv.count(pair<char, char>(S[i], T[i])) > 0) continue;

        if (from.count(S[i])>0 || to.count(T[i])>0) {
            ok = false;
            break;
        }
        from.insert(S[i]);
        to.insert(T[i]);
        conv.insert(pair<char, char>(S[i], T[i]));
    }

    string ans = ok ? "Yes" : "No";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
ll fexp(ll a, ll b, ll p){ll ans = 1;while(b){if(b&1) ans = ans*a%p; b/=2;a=a*a%p;}return ans;}
const ll mod=1000000007;
const int N=1e5+5;
int main()
{
	fast;ll x,y;cin>>x>>y;
	if(y&1)cout<<"No\n";
	else
	{
		if(y<=4*x&&y>=2*x)cout<<"Yes\n";
		else cout<<"No\n";
	}

}

Measured memory_bytes: 3660
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
		int n = Integer.parseInt(reader.readLine());
		char[] list = reader.readLine().toCharArray(); 
		int i = 0;
		int j = n-1;
		int ans = 0;
		while(i<=j){
			if(list[i]=='R'){
				i++;
				continue;
			}
			if(list[j]=='W'){
				j--;
				continue;
			}
			if(i!=j && list[i]=='W' && list[j]=='R'){
				list[i] = 'R';
				list[j] ='W';
				ans++;
				i++;
				j--;
				continue; 
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36444
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){

    string s;
    cin >> s;

    ll ans =0;

    for (ll i = 0; i < s.size()/2; i++){
        if (s[i] != s[s.size()-1 -i ]  ){
            ans++;
        }
    }

    cout << ans <<endl;


    
    
}


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

int main() {
  size_t N;

  std::cin >> N;

  std::vector<size_t> cnt(27, 1);

  for (size_t i=0; i<N; i++) {
    char c;
    std::cin >> c;
    cnt[c-'a']++;
  }

  size_t ans = 1;

  for (char c='a'; c<='z'; c++) {
    ans *= cnt[c-'a'];
    ans %= 1000000007;
  }
  ans--;

  std::cout << ans << std::endl;

  return 0;
}


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

const int N = 1e5 + 7, INF = 1e9 + 7;

int n, m, s, t;
vector<int> g[N];
int dist[N][3];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    while (m--) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
    }
    cin >> s >> t;
    s--;
    t--;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) dist[i][j] = INF;
    }
    dist[s][0] = 0;
    deque<pair<int, int>> q{{s, 0}};
    while (!q.empty()) {
        int u = q.front().first, kek = q.front().second;
        q.pop_front();
        for (auto v : g[u]) {
            if (dist[u][kek] + 1 < dist[v][(kek + 1) % 3]) {
                dist[v][(kek + 1) % 3] = dist[u][kek] + 1;
                q.emplace_back(v, (kek + 1) % 3);
            }
        }
    }
    cout << (dist[t][0] == INF ? -1 : dist[t][0] / 3);
    return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    map<char,ll> pitsu;
    pitsu['M'] = 0;
    pitsu['A'] = 0;
    pitsu['R'] = 0;
    pitsu['C'] = 0;
    pitsu['H'] = 0;
    ll n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        if(s[0] == 'M' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H'||s[0] == 'A'){
            pitsu[s[0]]++;
        }
    }
    string march = "MARCH";
    ll ans = 0;
    rep(i,5){
        for(ll j = i+1;j<5;j++){
            for(ll k = j+1;k<5;k++){
                ans += pitsu[march[i]]*pitsu[march[j]]*pitsu[march[k]];
            }
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,q,m,a,mx,ans;
  int date[100];
  while(1){
    cin>>n>>q;
    if(n==0 && q==0) break;
    for(int i=0;i<100;i++){
      date[i]=0;
    }
    mx=0;
    ans=0;
     for(int j=0;j<n;j++){
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>a;
      date[a]++;
    }
    }
    for(int i=0;i<100;i++){
      if(date[i]>=q && date[i]>mx){
	mx=date[i];
	ans=i;
      }
    }
      cout<<ans<<endl;
  }
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
string N;
long long dptable[100][4][2];
long long dp(int i, int j, bool adh) {
	if (j == 0) return 1;
	if (i == N.size()) return 0;
	if (dptable[i][j][adh] != -1) return dptable[i][j][adh];
	if (adh) return dptable[i][j][adh] = dp(i + 1, j, N[i] == '0') + (N[i] == '0' ? 0 : ((N[i] - '0' - 1) * dp(i + 1, j - 1, false) + dp(i + 1, j - 1, adh)));
	else return dptable[i][j][adh] = dp(i + 1, j, adh) + 9 * dp(i + 1, j - 1, adh);
}
int main() {
	memset(dptable, -1, sizeof dptable);
	int K;
	cin >> N >> K;
	cout << dp(0, K, true);
	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

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

void Main() {
    ll N;
    cin >> N;
    set<ll> used;
    auto x = divisor(N - 1);
    auto x2 = divisor(N);
    used.insert(x.begin(), x.end());
    for (auto z: x2) {
        ll n = N;
        if (z == 1) continue;
        while (n >= z) {
            if (n % z) {
                n = n % z;
            } else {
                n = n / z;
            }
        }
        if (n == 1) used.insert(z);
    }
    cout << used.size() - 1 << '\n';
}

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


Measured memory_bytes: 384
n=int(input())
dict={}
s='zabcdefghijklmnopqrstuvwxy'
for i in range(len(s)):
    dict[i]=s[i]
cnt=0
ans=""
while True:
    tmp=n%26
    ans=dict[tmp]+ans
    n//=26
    if tmp==0:
        n-=1
    if n<=0 :
        break
print(ans)    

Measured memory_bytes: 61820
N = gets.to_i
Xs, Ys = readlines.map{|l| l.split.map(&:to_i)}.transpose
M = 998244353

p2 = N.times.each_with_object([1]){|_, o| o << o.last * 2 % M}
ys = N.times.sort_by{|n| Ys[n]}.each_with_object([]).with_index{|(n, o), i| o[n] = i}
r, bit = 0, Array.new(N + 1, 0)
ys.sort_by.with_index{|y, i| Xs[i]}.each_with_index do |y, i|
  j = y + 1
  while j <= N
    bit[j] += 1
    j += j & -j
  end
  d, j = 0, y
  while j > 0
    d += bit[j]
    j -= j & -j
  end
  c = i - d
  b = (N - 1) - y - c
  a = (N - 1) - b - c - d
  r = (r + p2[b + c] + p2[c + d] + p2[d + a] + p2[a + b] - p2[a] - p2[b] - p2[c] - p2[d]) % M
end
puts (p2[N]*N - (r + N)) % M

Measured memory_bytes: 50780
#include<iostream>
#include<vector>

using namespace std;

int n;

vector<int> cut(int k,vector<int> cards){
  vector<int>res;
  for(int i=k;i<2*n;i++)res.push_back(cards[i]);
  for(int i=0;i<k;i++)res.push_back(cards[i]);
  return res;
}

vector<int> riffle(vector<int> cards){
  vector<int>res;
  for(int i=0;i<n;i++){
    res.push_back(cards[i]);
    res.push_back(cards[n+i]);
  }
  return res;
}

int main(void){
  int m,k;
  vector<int> cards;

  cin >> n >> m;
  for(int i=1;i<=2*n;i++)cards.push_back(i);
  for(int i=0;i<m;i++){
    cin >> k;
    cards = k ? cut(k,cards) : riffle(cards);
  }
  for(int i=0;i<2*n;i++)cout << cards[i] << endl;

  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
ld dp[3002][3002];
void solve()
{
    ll n;
    cin>>n;
    ld p[n+2];
    for(ll i=1;i<=n;i++)
        cin>>p[i];
    dp[0][0]=1.0;
    for(ll i=1;i<=n;i++){
        for(ll j=0;j<=i;j++){
            if(j == 0){
                dp[i][j] = (dp[i-1][j])*(1.0-p[i]);
            }
            else {
                dp[i][j] = (dp[i-1][j]*(1.0-p[i]))+(dp[i-1][j-1]*p[i]);
            }
        }
    }
    ld ans=0.0;
    for(ll i=(n+1)/2;i<=n;i++)
        ans+=(dp[n][i]);
    cout << setp(10)<<ans <<"\n";


}

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 139136
#include <bits/stdc++.h>
#define rep(i,n) for ( int i = 0; i < (n); ++i )
using namespace std;
using ll = long long int;
const long long int INF = 1001001001001001LL;
const int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;


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

    string s, t;
    cin >> s >> t;

    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
    
    rep( i, s.size() ){
        rep( j, t.size() ) {
            if( s[i] == t[j] )  dp[i+1][j+1] = dp[i][j] + 1;
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
        }
    }
    
    string ans = "";
    int i = s.size(), j = t.size();
    while( i > 0 && j > 0 ) {
        if(dp[i][j] == dp[i][j-1]) j--;
        else if(dp[i][j] == dp[i-1][j] ) i--;
        else {
            ans = s[i-1] + ans;
            i--;
            j--;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

void a()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    a();

    int n;
    double ans = 0, val;
    cin >> n;
    vector<double> dp(n+1);

    dp[0] = 1;
    for(int i = 0; i < n; i++){
       cin >> val;
       for(int j = i + 1; j >= 0; --j){
        dp[j] = (j == 0 ? 0 : dp[j-1]*val) + dp[j] * (1 - val);
       }
    }

    for(int i = n; i > n/2; i--){
        ans += dp[i];
    }

    cout << fixed << setprecision(10);
    cout << ans;
}

Measured memory_bytes: 3864
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;

  int ans=0;
  for(int i=1;i<n;i++)
  {
    int cnt=0;

    for(char c='a';c<='z';c++)
    {
      bool left=false,right=false;

      for(int j=0;j<i;j++)
      {
        if(s[j]==c) left=true;
      }

      for(int j=i;j<n;j++)
      {
        if(s[j]==c) right=true;
      }

      if(left&&right) cnt++;
    }

    if(ans<cnt) ans=cnt;
  }
    cout<<ans<<endl;
}

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

int h,w,k;
int fie[7][7];
int fie2[7][7];

int main(void){
	scanf("%d%d%d",&h,&w,&k);
	for(int i=0;i<h;i++){
		string s;
		cin >> s;
		for(int j=0;j<w;j++){
			if(s[j]=='#'){
				fie[i][j]=-1;
			}else{
				fie[i][j]=0;
			}
		}
	}
	int ans=0;
	for(int i=0;i<(1<<(h+w));i++){
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				fie2[j][k]=fie[j][k];
			}
		}
		for(int j=0;j<h;j++){
			if(!((i>>j)&1))continue;
			for(int k=0;k<w;k++){
				fie2[j][k]=1;
			}
		}
		for(int j=0;j<w;j++){
			if(!((i>>(h+j))&1))continue;
			for(int k=0;k<h;k++){
				fie2[k][j]=1;
			}
		}
		int cnt=0;
		for(int j=0;j<h;j++){
			for(int k=0;k<w;k++){
				if(fie2[j][k]==-1){
					cnt++;
				}
			}
		}
		if(cnt==k){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <string>

using namespace std;

string sort_s_ascending(string s);
string sort_s_descending(string s);

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

	string s,t;
	string ss, tt;
	cin >> s >> t;
	ss = sort_s_ascending(s);
	tt = sort_s_descending(t);
	if(ss<tt) cout << "Yes";
	else cout << "No";
	// int n=s.size(), m=t.size();
	
}

string sort_s_ascending(string s){
	int n = s.size();
	int i_min=0;
	char s_min=s[0];
	char tmp;
	for(int i=0; i<n-1; i++){
		i_min = i;
		s_min = s[i];
		for(int j=i+1; j<n; j++){
			if(s[j]<s_min){
				i_min = j;
				s_min = s[j];
			}
		}
		tmp = s[i];
		s[i] = s[i_min];
		s[i_min] = tmp;
	}
	return s;
}

string sort_s_descending(string s){
	int n = s.size();
	int i_max=0;
	char s_max=s[0];
	char tmp;
	for(int i=0; i<n-1; i++){
		i_max = i;
		s_max = s[i];
		for(int j=i+1; j<n; j++){
			if(s[j]>s_max){
				i_max = j;
				s_max = s[j];
			}
		}
		tmp = s[i];
		s[i] = s[i_max];
		s[i_max] = tmp;
	}
	return s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> c(H);
  for (int i=0; i<H; i++) cin >> c[i];
  // 行と列の選び方を全探索
  int res = 0;
  for (int tmp_line=0; tmp_line<(1<<6); tmp_line++) {
    for (int tmp_column=0; tmp_column<(1<<6); tmp_column++) {
      bitset<6> line(tmp_line), column(tmp_column);
      // 1のビットに対応する行を選んだと考える
      vector<string> c_copy = c;
      for (int i=0; i<H; i++) {
        if (line.test(i)) {
          for (int j=0; j<W; j++) c_copy[i][j] = '.';
        }
      }
      // 列について
      for (int j=0; j<W; j++) {
        if (column.test(j)) {
          for (int i=0; i<H; i++) c_copy[i][j] = '.';
        }
      }
      // 黒のマスを数える
      int num = 0;
      for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
          if (c_copy[i][j]=='#') num++;
        }
      }
      if (num==K) res++;
    }
  }
  // 重複して数えている分を除く
  res /= (int)pow(2, 6-H)*(int)pow(2, 6-W);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4104
#include <iostream>

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i > (b); i--)

using namespace std;

int main(void) {
	int N, L;
    scanf("%d %d", &N, &L);

   int min = L;
   int max = L + N - 1;

   int sum = N * (min + max) / 2;

   int ans = sum;
   if ( min > 0 && max > 0 ) ans -= min;
   else if ( min < 0 && max < 0 ) ans -= max; 
    
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 256
#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 N, A, B;
    cin >> N;
    map<ll, ll> mp;
    rep(i,N) {
        cin >> A >> B;
        mp[B] += A;
    }
    ll sum = 0;
    string ans = "Yes";
    for (auto x : mp) {
        sum += x.second;
        if (sum > x.first) ans = "No";
    }
    cout << ans << endl;
}


Measured memory_bytes: 16108
#include "bits/stdc++.h"
using namespace std;
 
#define mp      make_pair
 
int par[101010];
 
int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
 
int main() {
        int n;
        scanf("%d", &n);
        set<int> g[101010];
        queue<pair<int, int>> both;
        for (int i = 0; i < n; i ++) par[i] = i;
        for (int i = 0; i < 2 * n - 2; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                if (g[a].count(b)) { 
                        both.emplace(a, b);
                        //cout << "both.emplace(" << a << ", " << b << ")" << endl;
                } else { 
                        g[a].insert(b);
                        g[b].insert(a);
                }
        }
        int ans = 0;
        while (!both.empty()) {
                ans ++;
                int a, b;
                tie(a, b) = both.front();
                both.pop();
                a = find(a), b = find(b);
                //if (g[a].size() < g[b].size()) swap(a, b);
                a = par[a], b = par[b];
                if (a == b) continue;
                par[b] = a;
                g[a].erase(b);
                g[b].erase(a);
                for (auto c : g[b]) {
                        g[c].erase(b);
                        if (g[a].count(c)) { 
                                both.emplace(a, c);
                        } else { 
                                g[a].insert(c);
                                g[c].insert(a);
                        }
                }
                g[b].clear();
        }
        puts(ans == n - 1 ? "YES" : "NO");
        return 0;
}
 

Measured memory_bytes: 24192
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl a[n + 1];
    a[0] = 2;
    a[1] = 1;
    repi(i,2,n + 1)a[i] = a[i-1] + a[i-2];
    cout << a[n] << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
  mem = [-1] * 1000000
  a, l = map(int, raw_input().split())
  if not(a or l):
    break
  for i in range(100):
    s = ("%0" + str(l) + "d") % (a)
    if s in mem:
      print "%d %d %d" % (mem.index(s), int(s), i - mem.index(s))
      break
    mem[i] = s
    mx = "".join(sorted(s, reverse=True))
    mi = "".join(sorted(s))
    a = int(mx) - int(mi)

Measured memory_bytes: 19816
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC optimize("Ofast")
//*********************************************DO IT NOW****************************************************************
#include<bits/stdc++.h> 
#include<random>
#define int long long   
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
#define yes cout<< "YES"<<endl
#define no  cout<< "NO"<<endl
#define all(v) (v).begin(),(v).end()
#define s(v)   sort(v,v+n)
#define  mt mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define print(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" "
#define for1(i,a,n)  for(int i=0;i<n;i++)
#define rep(i, c) for(int i = 0; i < (int)c; i++)
using namespace std;
//**********************************************DO IT NOW***************************************************************
void fastio()
{  
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
int dp[101][1001],ans1=1e9,dp1[1000001];
int num[10];
int a[1000000];
signed main()
{   
    fastio();
    int t=1;
  // cin>>t;
    while(t--)
    {    
       string s1;
       cin>>s1;
       for(int i=0;i<s1.length();i++)
       cout<<"x";
       
    }
}
    
// 🍪 🍪 🍪


Measured memory_bytes: 3608
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d %d %d %d", &A,&B,&C,&D);
  
  A = (A+D-1)/D;
  C = (C+B-1)/B;
  if( A >= C ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1660
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

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

    vector<int> cnt(n+1, 0);
    for(int i=2; i<=n; ++i){
        int a = i;
        for(int j=2; j<=n; ++j){
            while(a % j == 0){
                ++ cnt[j];
                a /= j;
            }
        }
    }

    long long ans = 1;
    for(int i=2; i<=n; ++i){
        ans *= cnt[i] + 1;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

    int x = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 1){
            x -= A[i];
        }else{
            x += A[i];
        }
    }
    x /= 2;

    int ans[N];
    ans[0] = x;
    for(int i = 0; i < N-1; i++){
        ans[i+1] = A[i] - ans[i];
    }
    for(int i = 0; i < N; i++){
        ans[i] *= 2;
    }

    for(int i = 0; i < N; i++){
        if(i != N-1){
            cout << ans[i] << " ";
        }else{
            cout << ans[i] << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 2048
public class Hello{
    public static void Main(){
        // Your code here!
        var str = System.Console.ReadLine();
        if(str.Length==3){
            for(int i=2; i>=0; i--){
                System.Console.Write(str[i]);
            }
            System.Console.Write("\n");
        }else{
            System.Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 17148
#include<bits/stdc++.h>
using namespace std;
vector<long long> arr1,arr2;
int n;long long k;
bool ok(long long target){
  long long tmp = k;
  for(int i=0;i<n;++i){
    long long curr = arr1[i] * arr2[i];
    if(curr > target){
      long long mins = (curr - target) / (1ll*arr2[i]);
      if((curr - target)%arr2[i]>0){
        mins++;
      }
      tmp -= mins;
      //cout<<i<<" "<<mins<<" "<<tmp<<endl;
      if(tmp<0){
        return false;
      }
    }
    
  }
  return true;
}
int main(){
  cin>>n>>k;
  arr1 = vector<long long>(n);
  arr2 = vector<long long>(n);
  for(int i=0;i<n;++i)cin>>arr1[i];
  for(int i=0;i<n;++i)cin>>arr2[i];
  sort(arr1.begin(),arr1.end());
  sort(arr2.begin(),arr2.end());
  for(int i=0;i<=n/2;++i){swap(arr2[i],arr2[n-1-i]);}
  
  long long l = 0;
  long long r = 1e18;
  while(l<r){
    long long mid = (l+r)/2;
    if(ok(mid)){
      r = mid;
    }else{
      l = mid+1;
    }
  }
  cout<<l<<endl;
  
  return 0;
}

Measured memory_bytes: 3456
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;
typedef pair<int, int> P;

#define N_MAX	(100000)
#define M_MAX	(1000)
#define H_MAX	(1000)
#define W_MAX	(1000)

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
typedef struct {
	int	val;
	int num;
} OKIKAE_INFO;

bool cmp(OKIKAE_INFO &a, OKIKAE_INFO &b)
{
	return a.val > b.val;
}

int main()
{
	int N, M;
	cin >> N >> M;
	
	vector<int> A(N, 0);
	REP(i, N)	cin >> A[i];
	
	vector<OKIKAE_INFO> okikae;
	REP(i, M) {
		OKIKAE_INFO one;
		cin >> one.num;
		cin >> one.val;
		okikae.push_back(one);
	}

	int okikaeIdx = 0;
	sort(okikae.begin(), okikae.end(), cmp);
	sort(A.begin(), A.end());
	REP(i, M) {
		OKIKAE_INFO one = okikae[i];
		REP(j, one.num) {
			if (A[okikaeIdx] < one.val) {
				A[okikaeIdx] = one.val;
				okikaeIdx++;
			} else {
				if (j == 0) {
					// 置き換え前のと比較してダメ
					goto EXIT;
				}
			}
		}
	}

EXIT:
	QWORD ret = 0;
	REP(i, N)	ret += A[i];
	cout << ret;
	cout << endl;
}


Measured memory_bytes: 1784
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=10050;
//↑templete
#define int long long
signed main(){

	string S;
	cin>>S;
	for(int i=0;i<S.length();i++)
		cout<<'x';
	cout<<endl;

	return 0;
}

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

int main() {
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	a = (a < 40 ? 40 : a);
	b = (b < 40 ? 40 : b);
	c = (c < 40 ? 40 : c);
	d = (d < 40 ? 40 : d);
	e = (e < 40 ? 40 : e);
	cout << (a + b + c + d + e) / 5 << endl;
	return 0;
}


Measured memory_bytes: 3084
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    long long int a;
    long double b;
    cin>>a>>b;
    ll ans = a*ll(b*100+ 0.5)/100;
    // ll ans = a*b/100;
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}


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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main()
{
    int n,m;
    cin >> n >> m;
    ll sum = 0,ans = 0;
    map<int,int> mp;
    mp[0] = 1;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        sum = (sum + a) % m;
        ans += mp[sum]++;
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, a, b) for (int i = a; i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= b; i++)
#define ull unsigned long long

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    ull int H[2 * 100 * 1000];
    REP(i, 0, N)
        cin >> H[i];

    sort(H, H+N);

    ull int sum = 0;
    REP(i, 0, N - K)
        sum += H[i];

    cout << sum << "\n";

    return 0;
}

Measured memory_bytes: 1792
object Main extends App {
    def gcd(n: Int, m: Int): Int = {
        if (n % m == 0) m
        else gcd(m, n % m)
    }
    val Array(w, h, c) = io.StdIn.readLine.split(" ").map(_.toInt)
    println(w * h * c / gcd(w, h) / gcd(w, h))
}

Measured memory_bytes: 43996
fn main() {
    let _n: usize = read();
    let s: String = read();
    let mut count = 0;
    let mut ans = 0;
    for c in s.chars() {
        if c == 'I' {
            count += 1;
        } else if c == 'D' {
            count -= 1;
        }
        ans = std::cmp::max(count, ans)
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}

Measured memory_bytes: 4352
while True:
	e=int(input())
	if e==0:
		exit()
	ans=10**20
	for i in range(int(e**1/3+1)):
		if e-i**3<0:
			break
		ansk=0
		ansk+=i
		ansk+=int((e-i**3)**0.5)
		ansk+=e-i**3-int((e-i**3)**0.5)**2
		ans=min(ans,ansk)
	print(ans)
	


Measured memory_bytes: 5712
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let a: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            (
                itr.next().unwrap().parse().unwrap(),
                itr.next().unwrap().parse().unwrap(),
            )
        })
        .collect();

    let mut ans = n;
    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            let p = a[j].0 - a[i].0;
            let q = a[j].1 - a[i].1;

            let mut cnt = 0;
            for k in 0..n {
                for l in 0..n {
                    if k == l {
                        continue;
                    }
                    let r = a[l].0 - a[k].0;
                    let s = a[l].1 - a[k].1;
                    if p == r && q == s {
                        cnt += 1;
                    }
                }
            }
            ans = min(ans, n - cnt);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>
int main()
{
    int a,b,x;
    int c;
    scanf("%d %d %d", &a,&b,&x);
    if(a+b >= x && x >= a)
    {
        printf("YES");
    }
    else
    {
        printf("NO");
    }
    return 0;
}

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

int main() {
	int D, N;
	cin >> D >> N;

	int base = 1;
	for (int i = 0; i < D; i++) {
		base = base * 100;
	}

	if (N != 100) {
		cout << base*N << endl;
	}
	else {
		cout << base * 101 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define vec vector
#define vi vec<int>
#define vvi vec<vec<int>>
#define ALL(a) begin(a), end(a)
#define RALL(a) rbegin(a), rend(a)
#define SORT(a) stable_sort(ALL(a))
#define RSORT(a) stable_sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNIQUE(a) a.erase(unique(ALL(a)), end(a))
#define lambda(i) [=](auto i)
#define compare(i, j) [=](auto i, auto j)
#define min_of(a) *min_element(ALL(a))
#define max_of(a) *max_element(ALL(a))
#define sum(a) accumulate(ALL(a), 0)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(a) (int)(a).size()
#define REP(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define RREP(i, n) for (auto i = n - 1; i != static_cast<decltype(i)>(-1); i--)
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define RFOR(i, a, b) for (auto i = b - 1; i != a; i--)
#define EACH(i, a) for (auto&& i: (a))
using namespace std;

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

int ceil_div(int X, int Y) {
  return (X - 1) / Y + 1;
}

struct union_find {
  vi data;
  union_find(int size) : data(size, -1) { }
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vi cum(vi V) {
  vi U(SZ(V));
  partial_sum(ALL(V), begin(U));
  return U;
}

void solve() {
  int n;

  cin >> n;
  vvi dp(n, vi(3)); //select i-th and skipped j-times.
  cin >> dp[0][0];
  cin >> dp[1][1];
  FOR(i, 2, n) {
    int a;
    cin >> a;
    if (i % 2 == 0) {
      dp[i][0] = dp[i - 2][0] + a;
      if(n % 2 == 1) {
        dp[i][2] = dp[i - 2][2] + a;
        if(i > 3) {
          dp[i][2] = max(dp[i][2], dp[i - 3][1] + a);
          dp[i][2] = max(dp[i][2], dp[i - 4][0] + a);
        }
      }
    } else {
      dp[i][1] = dp[i - 2][1] + a;
      if(i > 2) dp[i][1] = max(dp[i][1], dp[i - 3][0] + a);
    }
  }
  if (n % 2 == 0) cout << max(dp[n - 1][1], dp[n - 2][0]) << endl;
  else cout << max(dp[n - 1][2], max(dp[n - 2][1], dp[n - 3][0])) << endl;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(15);
  solve();
}


Measured memory_bytes: 14240
#include <stdio.h>

int isPrime ( int a ) {
	// a > bツづつキツづゥ
	int r , i;
	if ( a <= 1 ) return 0;
	if ( a == 2 || a == 3 ) return 1;
	if ( a % 2 == 0 || a % 3 == 0 ) return 0;
	else {
		for ( i = 3; i * i <= a; i+=2 )
			if ( a % i == 0 ) return 0;
		return 1;
	}
}

int main () {
	int i , n;
	while ( scanf("%d",&n) , n ) {
		for ( i = n; ; i-- ) {
			if ( isPrime(i) && isPrime(i-2) ) {
				printf("%d %d\n",i-2,i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main(void)
{
    int h, w;
    std::cin >> h >> w;
    for (int i = 0; i < w + 2; ++i)
    {
        std::cout << '#';
    }
    std::cout << std::endl;
    for (int i = 0; i < h; ++i)
    {
        std::string s;
        std::cin >> s;
        std::cout << '#' << s << '#' << std::endl;
    }
    for (int i = 0; i < w + 2; ++i)
    {
        std::cout << '#';
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

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

using namespace __gnu_pbds;

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

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    ll n, m;
    cin >> n >> m;
    ll res1 = n * (n - 1) / 2LL;
    ll res2 = m * (m - 1) / 2LL;
    cout << res1 + res2 << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int prest = 0, gg_cnt = 0, score = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'g') {
            prest++;
            gg_cnt++;
        } else if (prest > 0) {
            prest--;
        } else {
            score--;
        }
    }
    score += prest / 2;
    cout << score << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<3>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    ll n, k;
    cin >> n >> k;
    if(n > k)n -= (n/k)*k;
    cout << min(abs(n - k), n) << endl;
    return 0;
} 

Measured memory_bytes: 256
# ABC168a


def main():
    import sys
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = input()
    if n[-1] in '24579':
        print('hon')
    elif n[-1] in '0168':
        print('pon')
    else:
        print('bon')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
	int w, h, n;
	cin >> w >> h >> n;
	int l = 0, r = w, b = 0, t = h;
	REP(i,n){
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) l = max(l,x);
		else if (a == 2) r = min(r,x);
		else if (a == 3) b = max(b,y);
		else t = min(t,y);
	}

	int ans = (r-l)*(t-b);

	if (l > r || b > t) ans = 0;

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

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long int lint;

void answer()
{
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x == 0 && y == 0) break;
		if (x < y) printf("%d %d\n", x, y);
		else printf("%d %d\n", y, x);
	}
}

int main()
{
	answer();
	return 0;
}

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

set<int> cnt;

int main(){
    int n; cin >> n;
    for(int i=0;i<n;i++){
        int a; cin >> a;
        
        auto it = cnt.find(a);
        if(it==cnt.end()) cnt.emplace(a);
        else cnt.erase(a);
    }

    cout << cnt.size() << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int count(vector<int> v)
{
    int n = v.size();
    vector<int> init(n);
    for(int i=0;i<n;++i)init[i] = i+1;
    int ans = 1;
    do
    {
        if(init == v){
            return ans; 
        }
        ans++;
        next_permutation(init.begin(),init.end());
    }while(1);
    return ans;
}
int main()
{
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    
    for(int i=0;i<n;++i)cin>>a[i];
    for(int i=0;i<n;++i)cin>>b[i];
    int x = count(a),y = count(b);
    cout<<abs(x-y)<<endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) cin >> L[i];
	sort(L.begin(), L. end());
	ll ans = 0;
	for (int i = 0; i < n-2; i++) {
		for (int j = i + 1; j < n-1; j++) {
			int len = L[i] + L[j];
			int l = j, r = n;
			while (r - l > 1) {
				int c = (l + r) / 2;
				if (L[c] >= len) r = c;
				else l = c;
			}
			ans += l - j;
		}
	}
	cout << ans << endl;
}

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

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

const int mx=1e5+5;

int h[mx];
ll dp[mx];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	for(int i=1;i<n+1;i++) cin>>h[i];
	
	dp[1]=0;
	
	dp[2]=abs(h[1]-h[2]);
	
	for(int i=3;i<n+1;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
		
	cout<<dp[n];
	
	
	
						
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}

Measured memory_bytes: 1536
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
      h -= a[i];
    }
    if(h <= 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 48416
#include <iostream>
#include <string>
#define FOR(i,k,n) for(int(i)=(k);(i)<(n);(i)++)
using namespace std;

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

  int x = 0;
  int x_max = 0;
  FOR(i,0, S.length()) {
    if (S[i] == 'I') ++x;
    else --x;

    // update x_max
    if (x > x_max) x_max = x;
  }

  cout << x_max << endl;

  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    while(cin >> s) {
        int N = 0, S = 0, E = 0, W = 0;
        for(auto c : s) {
            if(c == 'N') {
                N = 1;
            } else if(c == 'S') {
                S = 1;
            } else if(c == 'W') {
                W = 1;
            } else if(c == 'E') {
                E = 1;
            }
        }
        cout << (N != S || E != W? "No" : "Yes") << '\n';
    }
    return 0;
}

Measured memory_bytes: 256