akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
 
int main(){
    lint N;
    cin >> N;
    lint ans = 1e18;
    for(lint i = 1; i * i <= N; i++){
        if(N % i == 0){
            ans = min(ans, i + (N / i));
        }
    }
    cout << ans - 2 << endl;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner s=new Scanner(System.in);
		long n=s.nextLong();
		int p=(int)(Math.log(n)/Math.log(2));
		p++;
		System.out.println((long)(Math.pow(2,p)-1));
		
	}
}

Measured memory_bytes: 23124
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>
 
using namespace std;
typedef long long LL;
 
int a[60];
LL ans , sum;
 
long long C[300][300];
 
void get_C(int maxn)
{
    C[0][0] = 1;
    for(int i=1;i<=maxn;i++)
    {
        C[i][0] = 1;
        for(int j=1;j<=i;j++)
            C[i][j] = C[i-1][j]+C[i-1][j-1];
        //C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;
    }
} 
 
int main()
{
	get_C(50);
	int n , p , ca = 0 , cb = 0;
	scanf("%d %d",&n , &p);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d",&a[i]);
		if(a[i] % 2) ca++;
		else cb++;
	}
	if(p == 0){
		for(int i = 0 ; i <= ca ; i += 2) ans += C[ca][i];
		for(int i = 0 ; i <= cb ; i++)    sum += C[cb][i];
	}
	else{
		for(int i = 1 ; i <= ca ; i += 2) ans += C[ca][i];
		for(int i = 0 ; i <= cb ; i++)    sum += C[cb][i];
	}
	if(p == 1 && ca == 0) printf("0\n");
	else if(sum == ans && sum == 0) printf("0\n");
	else if(sum == 0 || ans == 0) printf("%lld\n",max(sum,ans));
	else printf("%lld\n",sum*ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	deque<int> dq;
	string s;
	while(cin >> s) {
		if(isdigit(s[0])) dq.eb(stoi(s));
		else {
			int b = dq.back(); dq.pop_back();
			int a = dq.back(); dq.pop_back();
			if(s == "+") dq.eb(a + b);
			if(s == "-") dq.eb(a - b);
			if(s == "*") dq.eb(a * b);
		}
	}
	P(dq.back());
	return 0;
}

Measured memory_bytes: 3240
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec a(N+1);
  rep(i, N)cin >> a[i+1];
  ll inc = 0;
  llvec v(N+1, -1);
  llvec cnt(N+1, -1);
  ll ci = 1;
  while(cnt[ci]==-1){
    //cerr << ci <<" "<< a[ci]<<" "<<inc<<endl;
    v[inc]=ci;
    cnt[ci]=inc;
    ci = a[ci];
    inc++;
  }
  
  ll T = inc - cnt[ci];
  if(K<cnt[ci]){
    cout << v[K];
  }else{
    //cerr << cnt[ci] << endl;
    cout << v[mod((K - cnt[ci]),T)+cnt[ci]];
  }

  return 0;
}


Measured memory_bytes: 8012
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
#define par pair<pair<int,int>, int>
#define f first
#define s second
    
int n,m,s[N], mem[N],x;

int dp(int idx=0)
{
    if(s[idx] || idx > n) return 0;
    if(idx == n) return 1;
    int &ret = mem[idx];
    if(~ret) return ret;
    return ret = (dp(idx+1) + dp(idx+2)) % oo;
}

int main()
{
    memset(mem, -1, sizeof mem);
    scanf("%d%d",&n,&m);
    for(int i=0; i<m ;i++)
    {
        scanf("%d",&x);
        s[x] = 1;
    }printf("%d",dp());
    return 0;
}

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

using namespace std;

long long MOD = 1e9+7;
int main() {
  // S: just seems like a standard DP where you keep track of the
  // residues
  // |K|D states, 10 transitions?
  // 10^7 should totally be fine
  // oh wait, the fact that it has to be less than K (which isn't
  // just 10^x)
  // more annoying, but _should_ be fine
  // like split it up into cases?

  cin.tie(0);
  cin.sync_with_stdio(0);
  string k; cin >> k;
  int d; cin >> d;
  long long nomatch[k.length()][d], match[k.length()][d];
  for(int i = 0; i<k.length(); ++i) {
    for(int j = 0; j<d; ++j) {
      nomatch[i][j] = 0;
      match[i][j] = 0;
    }
  }

  for(int i = 0; i<(k[0]-'0'); ++i) {
    // Very important to take the mod in here!
    nomatch[0][i%d]++;
  }
  match[0][(k[0]-'0')%d]++;

  for(int i = 1; i<k.length(); ++i) {
    for(int j = 0; j<d; ++j) {
      for(int l = 0; l<=9; ++l) {
        // Don't forget to mod the result as you go
        nomatch[i][(j+l)%d] = (nomatch[i][(j+l)%d] + nomatch[i-1][j])%MOD;
        if(l < (k[i]-'0'))
          nomatch[i][(j+l)%d] = (nomatch[i][(j+l)%d] + match[i-1][j])%MOD;
      }
      match[i][(j+k[i]-'0')%d] = (match[i][(j+k[i]-'0')%d] + match[i-1][j])%MOD;
    }
  }
  // off by 1 because it includes 0, so add MOD-1
  cout << (match[k.length()-1][0] + nomatch[k.length()-1][0]+MOD-1)%MOD << endl;
}


Measured memory_bytes: 15872
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]>x:
        ans+=a[i]-x
        a[i]=x
    if a[i]+a[i+1]>x:
        ans+=a[i]+a[i+1]-x
        a[i+1]-=a[i]+a[i+1]-x
print(ans)


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N,K; cin >> N >> K;
    VVI A(K);
    REP(i,K){
        int d; cin >> d;
        A[i].resize(d); REP(j,d) cin >> A[i][j];
    }

    VI s(N,0);
    REP(i,K)REP(j,A[i].size()){
        s[A[i][j]-1]++;
    }

    int ans = 0;
    REP(i,N) if(s[i] == 0) ans++;
    cout << ans << en;
    return 0;
}

Measured memory_bytes: 3636
/*
　　　∫ ∫ ∫
　　　ノヽ
　　（＿　 ）
　（＿　　　 ）
（＿＿＿＿＿＿ ）
　ヽ(´･ω･)ﾉ　
　　 |　 /
　　 UU
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using P = pair<ll, ll>;
const int MOD = (int)1e9 + 7;
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = s; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x << ": " << x << "\n";
#define mp make_pair
template <typename T>
ostream& operator<<(ostream& os, vector<T> &V){
    int N = V.size();
    REP(i,N){
        os << V[i];
        if (i!=N-1) os << " ";
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, pair<T,T> const&P){
    os << P.first;
    os << " ";
    os << P.second;
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T> &S){
    auto it=S.begin();
    while(it!=S.end()){
        os << *it;
        os << " ";
        it++;
    }
    os << "\n";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, deque<T> &q){
    for(auto it=q.begin();it<q.end();it++){
        os<<*it;
        os<<" ";
    }
     os<<endl;
    return os;
}
//fixed<<setprecision(10)<<ans<<endl;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];

    int ans=0;
    int max_bit = 1<<N;
    unordered_map<int, int> M;
    REP(bit ,max_bit){
        int sum = 0;
        REP(j,N){
            if(bit & (1<<j)) sum+=A[j];
        }
        M[sum]++;  
    }
    int Q,query;
    cin >> Q;
    REP(i,Q){
        cin >> query;
        if(M[query]) cout << "yes\n";
        else cout << "no\n";
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  double L; cin>>L;
  double side=L/3;
  double ans=pow(side,3);
  cout<<fixed<<setprecision(12)<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <regex>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include<tuple>

using namespace std;

int main() {
	int A, B;

	cin >> A >> B;

	cout << A * B - (A + B - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <vector>
static const int MAXN = 104;
static const int ALPHA = 26;

int h, w;
int ct[ALPHA] = { 0 };
std::vector<std::vector<std::pair<int, int>>> groups[5];
char s[MAXN][MAXN];

int main()
{
    scanf("%d%d", &h, &w); getchar();
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            ++ct[getchar() - 'a'];
        getchar();
    }

    for (int i = 0; i < (h + 1) / 2; ++i)
        for (int j = 0; j < (w + 1) / 2; ++j) {
            std::vector<std::pair<int, int>> g;
            g.push_back({ i, j });
            if (i * 2 != h - 1) {
                g.push_back({ h - 1 - i, j });
                if (j * 2 != w - 1) {
                    g.push_back({ i, w - 1 - j });
                    g.push_back({ h - 1 - i, w - 1 - j });
                }
            } else {
                if (j * 2 != w - 1)
                    g.push_back({ i, w - 1 - j });
            }
            //for (auto pos : g) printf(" (%d %d)", pos.first, pos.second); putchar('\n');
            groups[g.size()].push_back(g);
        }

    for (int i = 0; i < ALPHA; ++i) {
        for (int j = 4; j >= 1; --j)
            while (ct[i] >= j && !groups[j].empty()) {
                ct[i] -= j;
                for (auto pos : groups[j].back())
                    s[pos.first][pos.second] = i + 'a';
                groups[j].pop_back();
            }
    }

    for (int i = 1; i <= 4; ++i) if (!groups[i].empty()) { puts("No"); return 0; }

    /*for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) putchar(s[i][j]);
        putchar('\n');
    }*/
    puts("Yes");

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		long sum = 0, cost = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			if (i % 2 == 0) {
				if (sum >= 0) {
					cost += sum + 1;
					sum = -1;
				}
			} else {
				if (sum <= 0) {
					cost += -sum + 1;
					sum = 1;
				}
			}
		}

		sum = 0;
		long cost1 = 0;
		for (int i = 0; i < n; i++) {
			sum += a[i];
			if (i % 2 == 0) {
				if (sum <= 0) {
					cost1 += -sum + 1;
					sum = 1;
				}
			} else {
				if (sum >= 0) {
					cost1 += sum + 1;
					sum = -1;
				}
			}
		}

		System.out.println((cost >= cost1) ? cost1 : cost);
	}
}

Measured memory_bytes: 50844
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N;
	cin >> N;
	int n = int(sqrt(N));
	cout << n * n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<pii> X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x,y; cin >> x >> y;
        x--,y--;
        X.emplace_back(x,y);
    }
    
}

int solve(){
    // set<int> p;
    // p.insert(0);
    vector<int> cnt(N,1);
    vector<bool> Red(N,false);
    Red[0] = true;
    for (int i = 0; i < M; i++)
    {
        cnt[X[i].first]--;
        cnt[X[i].second]++;
        if(Red[X[i].first]) Red[X[i].second] = true;
        if(cnt[X[i].first]==0) Red[X[i].first] = false;
        // if(p.find(X[i].first)!=p.end(){
        //     p.insert(X[i].second);
        // }
        // if(cnt[X[i].first]==0) p.erase(X[i].first);
    }
    // cout << p.size() << endl;
    int ans = accumulate(Red.begin(),Red.end(),0);
    cout << ans << endl;    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    string S,T; cin>>S>>T;
    sort(ToEnd(S));
    sort(ToEnd(T));
    reverse(ToEnd(T));

    if(S<T) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
template<class T> inline void chmax(T &a,T b){if(a<b)a=b;}
template<class T> inline void chmin(T &a,T b){if(a>b)a=b;}

int main(){
    cin.tie(0); ios_base::sync_with_stdio(false);
    int a,b;cin >> a >> b;
    string s; cin >> s;
    REP(i,s.size()){
        if(s[i]=='-' && i!=a){
            cout << "No" << endl;
            return 0;
        }
        if(i==a && s[i]!='-'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
point_a,point_b = 0,0
for i in range(int(input())):
	k =[]
	a,b = input().split()
	k = [[i,j] for i,j in zip(a,b) if i != j]
	if k == []:
		if len(a) < len(b):
			point_b+=3
		elif len(a) > len(b):
			point_a += 3
		else:
			point_a+=1
			point_b+=1
	elif ord(k[0][0]) < ord(k[0][1]):
		point_b += 3
	else :
		point_a += 3
print(point_a,point_b)

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

int main() {
    int n;
    cin >> n;
  	int h[n],a[n];
  	for(int i=0;i<n;i++){
     	cin>>h[i];
    }
  	
  	a[0]=0;
    a[1] = abs(h[0]-h[1]);
  	for(int i=2;i<n;i++){
    	a[i] = min(a[i-1]+ abs(h[i]-h[i-1]) , a[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<a[n-1]<<endl;                 
	return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
from typing import List
from math import gcd


def get_divisors(n: int) -> List[int]:
    i = 1
    ret = []
    while i * i <= n:
        if n % i == 0:
            ret.append(i)
            x = n // i
            if x != i:
                ret.append(x)
        i += 1
    return ret



def main() -> None:
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a

    divisors = list(filter(lambda x: b % x == 0, get_divisors(a)))
    divisors.sort()
    # print(divisors)
    ret = []

    for div in divisors:
        ok = True
        for i in ret:
            if gcd(i, div) != 1:
                ok = False
                break
        if ok:
            ret.append(div)

    print(len(ret))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, **kwargs):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 70724
#include<bits/stdc++.h>
using namespace std;
bool c[256];
int main(){
  c['a']=c['i']=c['u']=c['e']=c['o']=1;
  int n;
  while(cin>>n,n){
    string res[100],s;
    for(int i=0;i<n;i++){
      cin>>s;
      res[i]+=s[0];
      for(int j=1;j<s.size();j++)
	if(c[s[j-1]])res[i]+=s[j];
    }
    int ans=-1;
    for(int i=1;i<=50;i++){
      set<string> st;
      bool f=1;
      for(int j=0;j<n;j++){
	string sb=res[j].substr(0,i);
	if(st.count(sb))f=0;
	st.insert(sb);
      }
      if(f){ans=i;break;}
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int num[3];
	num[0]=a;
	if(b<num[0]){
		num[1]=num[0];
		num[0]=b;
	}
	else{num[1]=b;}
	
	if(c<num[0]){
		num[2]=num[1];
		num[1]=num[0];
		num[0]=c;
	}
	else if(c<num[1]){
		num[2]=num[1];
		num[1]=c;
	}
	else{num[2]=c;
	}
	
	cout << num[0] << " " << num[1] << " " << num[2] <<endl;
	return 0;
}

Measured memory_bytes: 1168
function Main(input) {
	input = input.split(" ");
	var tHP = parseInt(input[0], 10);
	var tAT = parseInt(input[1], 10);
	var aHP = parseInt(input[2], 10);
	var aAT = parseInt(input[3], 10);


var a =  Math.ceil(aHP  /  tAT )

var t =  Math.ceil(tHP  /  aAT )

if (t >= a){
	console.log('Yes');
}else{
	console.log('No');

}


}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29616
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            int money = N - 500 * (N / 500);
            Console.WriteLine(money <= A ? "Yes" : "No");
        }
    }
}

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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string o = "";
            const string X = "x";

            for (int i = 0; i < input.Length; i++)
            {
                o += X;
            }

            Console.Write(o);
        }
    }
}


Measured memory_bytes: 13140
t,r,g=map(int,input().split())
d=[[float("INF") for ccc in range(t)] for i in range(t)]
for i in range(t):
    d[i][i]=0
gl=list(map(int,input().split()))
for j in range(r):
    x,y,c=map(int,input().split())
    d[x-1][y-1]=c
    d[y-1][x-1]=c
for i in range(t):
    for j in range(t):
        for k in range(t):
            d[k][j]=min(d[k][j],d[k][i]+d[i][j])
from itertools import permutations as pe
ans=float("INF")
for G in pe(gl):
    p=0
    for qw in range(g-1):
        p+=d[G[qw]-1][G[qw+1]-1]
    ans=min(ans,p)
print(ans)

Measured memory_bytes: 65112
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FOR(type,a,b,c,d) for(type i = a;i b c;i += d)
#define QUICK ios_base::sync_with_stdio(0);cout << fixed;
#define MOD 1000000007

string upper(string);
string lower(string);
bool isalup(string);
bool isalow(string);

int main(){

    int a,b,c,d; 
    cin >> a >> b >> c >> d;
    while(b<=a){
        b *= 2;
        d--;
    }
    while(c<=b){
        c *= 2;
        d--;
    }
    if(d<0)
        cout << "No";
    else

        cout << "Yes";




    return 0;
}









            string upper(string a){
                for(char& c:a){
                    if(islower(c))
                        c -= 32;
                   }
                return a;
            }
                string lower(string a){
                    for(char& c : a){
                        if(isupper(c))
                            c += 32;
                    }
                    return a;
                }
                bool isalup(string a){
                    for(char& c: a){
                        if(islower(c))
                            return false;
                    }
                    return true;
                }
                bool isalow(string a){
                    for(char& c:a){
                        if(isupper(c))
                            return false;
                    }
                   return true;
                }


Measured memory_bytes: 3532
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n;
	cin >> n;
	vector<ll> a(n + 1, 0);
	for (int i = 0; i <= n; i++)
	{
		cin >> a[i];
	}
	vector<ll> b(n + 1, 0);
	ll l = 1;
	bool f = true;
	if (a[0] > 1 || (a[0] == 0 && n == 0))
		f = false;
	else
		l -= a[0];
	b[0] = 1;
	for (int i = 1; i <= n; i++)
	{
		if (l > LONG_MAX / 2)
			l = LONG_MAX;
		else
			l *= 2;
		b[i] = l;
		if (a[i] > l)
		{
			f = false;
			break ;
		}
		l -= a[i];
	}
	vector<ll> c(n+1, 0);
	c[n] = a[n];
	ll p = a[n];
	for (int i = n-1; i >= 0; i--)
	{
		c[i] = min(a[i] + c[i+1], b[i]);
		p += c[i];
	}
	if (f)
		cout << p << endl;
	else
		cout << -1 << endl;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, n){
        cin >> a.at(i);
        if(mp.find(a.at(i)) != mp.end())mp.erase(a.at(i));
        else mp[a.at(i)] = 1;
    }
    cout << mp.size();
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
vector<vector<ll>>adj(500000);
ll visited[500000]{0};
int main()
{
    ll n,k;
    cin>>n>>k;
    if(n>k)
        n = n - (n/k)*k;
   while(abs(n-k)<=n)
   {
    if(n==0)
        break;
     n = abs(n-k);
   }
    cout<<n;
}

Measured memory_bytes: 11904
n=int(input())
a=list(map(int,input().split()))
p=[]
cnt=[]
zero=0
for i in range(n):
	if len(p)>=4:
		print("No")
		exit()
	if a[i]==0:
		zero+=1
	elif a[i] not in p:
		p.append(a[i])
		cnt.append(1)
	else:
		for j in range(len(p)):
			if a[i]==p[j]:
				cnt[j]+=1
if n%3!=0 and zero!=n:
	print("No")
	exit()
if len(p)>=4:
	print("No")
	exit()
if len(p)==3:
	if cnt[0]==cnt[1]==cnt[2]==n/3:
		if p[0]^p[1]^p[2]==0:
			print("Yes")
			exit()
	else:
		print("No")
		exit()
elif len(p)==1:
	if cnt[0]==n/3*2:
		print("Yes")
		exit()
elif len(p)==0:
	if sum(a)==0:
		print("Yes")
		exit()
print("No")

Measured memory_bytes: 14704
package main
 
import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "strings"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func main() {
  if sc.Scan() {
    s := strings.Split(sc.Text(), "/")
    y, _ := strconv.Atoi(s[0])
    m, _ := strconv.Atoi(s[1])
    d, _ := strconv.Atoi(s[2])
    
    if y * 10000 + m * 100 + d <= 20190430 {
    	fmt.Printf("Heisei")
    } else {
    	fmt.Printf("TBD")
    }      
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
const int N=1e7+10;
using namespace std;
inline int gi(){
  char ch=getchar();int x=0,q=0;
  while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar();
  while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q?(-x):x;
}
int mark[N],pri[N],tot,P=1e7+1,n,m,g[N];
int c[105][105],bl[105],vis[105],a[105],b[105];
void pre(){
  for (int i=2,s; i<=P; ++i){
    if (!mark[i]) pri[++tot]=i;
    for (int j=1; j<=tot&&(s=i*pri[j])<=P; ++j){
      mark[s]=1;
      if (i%pri[j]==0) break;
    }
  }
  return;
}
int dfs(int x){
  for (int i=1; i<=m; ++i)
    if (c[x][i]&&!vis[i]){
      vis[i]=1;
      if (!bl[i]||dfs(bl[i]))
	return bl[i]=x;
    }
  return 0;
}
int main(){
  int p=gi(),s;
  pre();
  for (int i=1; i<=p; ++i)
    g[gi()]=1;
  for (int i=P; i>=1; --i)
    g[i]^=g[i-1];
  for (int i=1; i<=P; ++i)
    if (g[i]){
      if (i&1) a[++n]=i;
      else b[++m]=i;
    }
  for (int i=1; i<=n; ++i)
    for (int j=1; j<=m; ++j){
      s=abs(a[i]-b[j]);
      if (s!=1&&!mark[s])
	c[i][j]=1;
    }
  int ans=0;
  for (int i=1; i<=n; ++i){
    memset(vis,0,sizeof(vis));
    if (dfs(i)) ++ans;
  }
  cout<<ans+(n-ans)/2*2+(m-ans)/2*2+(((n-ans)&1)||((m-ans)&1))*3;
  return 0;
}


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

int a,b,c,d,e,f;

bool dp[3005];
bool dp2[3005];

int main(){
  
  cin>>a>>b>>c>>d>>e>>f;

  dp[100*a]=true;
  if(100*b<=f)dp[100*b]=true;
  
  for(int i=0;i<f;i++){
    
    if(!dp[i]) continue;

    if(i+100*a<=f) dp[i+100*a]=true;
    
    if(i+100*b<=f) dp[i+100*b]=true;
    
  }
  
  dp2[0]=true;
  
  if(c<=f) dp2[c]=true;
  if(d<=f) dp2[d]=true;

  for(int i=0;i<f;i++){
    
    if(!dp2[i]) continue;

    if(i+c<=f) dp2[i+c]=true;
    
    if(i+d<=f) dp2[i+d]=true;
    
  }

  int ans=0, ans2=0;
  double noudo=-1;
  
  for(int i=0;i<=f;i++){

    if(!dp[i]) continue;
    
    for(int j=f;j>=0;j--){
      
      if(!dp2[j]) continue;

      if(i+j<=f&&i/100*e>=j&&100.0*j/i>noudo){
	
	noudo=100.0*j/i;
	
	ans=i+j;

	ans2=j;
	
      }
      
    }
    
  }
  
  cout<<ans<<' '<<ans2<<endl;
  
  return 0;
}


Measured memory_bytes: 256
000010 IDENTIFICATION                   DIVISION.
000020 PROGRAM-ID.                      MAIN.
000030*
000040 ENVIRONMENT                      DIVISION.
000050*
000060 DATA                             DIVISION.
000070 WORKING-STORAGE                  SECTION.
000080 77 STR                           PIC XXX.
000090*
000100 PROCEDURE                        DIVISION.
000110 MAIN.
000120     ACCEPT STR                   FROM SYSIN.
000130     IF STR(1:1) > STR(3:1) THEN
000140         DISPLAY ">"              UPON SYSOUT
000150     ELSE IF STR(1:1) < STR(3:1) THEN
000160         DISPLAY "<"              UPON SYSOUT
000170     ELSE
000180         DISPLAY "="              UPON SYSOUT
000190     END-IF.
000200     STOP RUN.

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int h, w;
string s[50];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) cin >> s[i];
  FOR(i, 0, h){
    FOR(j, 0, w){
      if(s[i][j]=='#'){
        cout << '#';
        continue;
      }
      int c = 0;
      FOR(k, -1, 2)FOR(l, -1, 2){
        int ii = i+k, jj = j+l;
        if(0<=ii&&ii<h&&0<=jj&&jj<w&&s[ii][jj]=='#') c++;
      }
      cout << c;
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

long long modPow(long long x, long long n, long long mod = MODV){
    if(n == 0) return 1;
    if(n%2 == 0) return modPow(x*x%mod, n/2, mod)%mod;
    return x%mod * modPow(x%mod, n-1, mod)%mod;
}

int main(){
    Init();
    ll x, ans = 1; cin >> x;

    // x=1の時は1を出力
    if(x == 1){
        cout << 1 << endl;
        return 0;
    }

    // 実数部
    for(ll i=2; i*i<=x; i++){
        // 指数部
        for(ll p=2; p<=10; p++){
            ll tmp = modPow(i, p);
            if(tmp > x) break;
            chmax(ans, tmp);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	int ans = 0;
	int cnt = 0;
	for (int i = 0; i + 1 < N; i++) {
		if (H[i] >= H[i + 1]) cnt++;
		else {
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans, cnt);
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;
 
template <typename T>
int bfs(int sx, int sy, int gx, int gy, const T& maze){
    const int INF = 100000000;
    queue<pair<int, int>> que;
    int H = maze.size(), W = maze[0].size();
    vector<vector<int>> d(H, vector<int>(W, INF));
 
    que.push(pair<int, int>(sx, sy));
    d[sx][sy] = 0;
 
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    while (que.size()){
	pair<int, int> p = que.front();
	que.pop();
 
	if ((p.first == gx) && (p.second == gy)) break;
 
	for (int i = 0; i < 4; i++){
	    int nx = p.first+dx[i], ny = p.second+dy[i];
 
	    if ((0 <= nx) && (nx < H) && (0 <= ny) && (ny < W)){
		if ((maze[nx][ny] == '.') && (d[nx][ny] == INF)){
		    que.push(pair<int, int>(nx, ny));
		    d[nx][ny] = d[p.first][p.second]+1;
		}
	    }
	}
    }
 
    if (d[gx][gy] == INF) return -1;
    return d[gx][gy];
}
 
int main(){
    int H, W;
    cin >> H >> W;
    vector<string> s(H);
    for (int i = 0; i < H; i++){
	cin >> s[i];
    }
 
    int res = bfs(0, 0, H-1, W-1, s);
    if (res == -1){
	cout << res << endl;
	return 0;
    }
 
    int cnt = 0;
    for (int i = 0; i < H; i++){
	for (int j = 0; j < W; j++){
	    if (s[i][j] == '.') cnt++;
	}
    }
 
    cout << cnt-res-1 << endl;
 
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>

#define long long long int

using std::vector;
using std::map;
using std::string;
using std::pair;
using std::cin;
using std::cout;

// @author: pashka

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

    long a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;

    b = std::min(b, 2 * a);
    c = std::min(c, 2 * b);
    d = std::min(d, 2 * c);

    long res = d * (n / 2) + c * (n % 2);

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os << "[ "; 
	for(auto v:V)os << v << " "; return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S){ os << "{ "; 
	for(auto s:S) os<<s<<" ";  return os<<"}"; 
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os<<"("<<P.first<<","<< P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
	os<<"{ ";for(auto m:M)os<<"("<<m.F<<":"<<m.S<<")";
	return os<<"}";
}
#define cerr cout
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define For(i,n) for(int i=0;i<(int)n;++i)
#define Rev(i,n) for(int i=(int)n-1;i>=0;--i)
#define Rep(i,n) for(int i=1;i<=(int)n;++i)
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpii;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


int main(){
	fio; cout<<fixed<<setprecision(25);	
	int h , w , n;
	cin >> h >> w >> n;
	int k = max(h , w);
	cout << (n+k-1)/k << endl;









	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int N, A, B, C, D;
char S[271828];

int main(void) {
	int i;
	if (scanf("%d%d%d%d%d", &N, &A, &B, &C, &D) != 5) return 1;
	if (scanf("%271827s", S) != 1) return 1;
	if (A >= B) {
		puts("error!");
		return 2;
	}
	A--; B--; C--; D--;
	if (C == D || S[C] != '.' || S[D] != '.') {
		puts("No");
	} else if (C < D) {
		/* 追い越さなくていいパターン */
		for (i = A; i < C; i++) {
			if (S[i] != '.' && S[i + 1] != '.') {
				puts("No");
				return 0;
			}
		}
		for (i = B; i < D; i++) {
			if (S[i] != '.' && S[i + 1] != '.') {
				puts("No");
				return 0;
			}
		}
	} else {
		/* 追い越すパターン */
		int ok = 0;
		for (i = A; i < C; i++) {
			if (S[i] != '.' && S[i + 1] != '.') {
				puts("No");
				return 0;
			}
		}
		for (i = B - 1; i < D; i++) {
			if (S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.') {
				ok = 1;
				break;
			}
		}
		if (!ok) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 1848
#include <bits/stdc++.h>
using namespace std;
 
int main() {
     int x,a,b;
    cin>>x>>a>>b;
    if(b-a<=0){
      cout<<"delicious"<<endl;
    }
    else if(b-a<=x){
    cout<<"safe"<<endl;
    }else{
      cout<<"dangerous"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
const double EPS=0.00001;

int cnt[51][26];

int main(){
    CLR(cnt);
    int N;cin>>N;
    REP(i,N){
        string s;
        cin>>s;
        REP(j,SZ(s))cnt[i][(int)(s[j]-'a')]++;
    }
    string res="";
    REP(ii,26){
        int tmp=52;
        REP(i,N)tmp=min(tmp,cnt[i][ii]);
        REP(i,tmp)res+=(char)('a'+ii);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main()
    {
      int l, r, d;
      cin >> l >> r >> d;
      int cnt = 0, num , i;
      for(i=l; i<=r; i++)
      {
          if(i%d == 0)
            {
                num = i;
                cnt++;
            }
      }
      while(num >= i && num <= r)
      {
        cnt++;
        num = num + d;     
      }
      cout << cnt << endl;
    }

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    ll n;
    cin >> n;
    vector<ll> p(5);
    for(int i=0; i<5; i++)
        cin >> p[i];
    ll mn = min({p[0], p[1], p[2], p[3], p[4]});
    ll sol = 4 + n/mn;
    if(n%mn != 0)
        sol++;
    cout << sol;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 10010
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int n,q;
int p[MAX];

void init(){
  FOR(i,0,n){ p[i]=i; }
}

int f(int a){
  if(a==p[a])return a;
  int rep=f(p[a]);
  p[a]=rep;
  return rep;
}

void make_link(int a,int b){
  p[a]=b;
}

void unit(int a,int b){
  make_link(f(a),f(b));
}

int same(int a,int b){
  return f(a)==f(b);
}

int main()
{
  cin>>n>>q;
  init();
  FOR(i,0,q){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==0)unit(b,c);
    else cout<<same(b,c)<<endl;
  }
  return 0;
}


Measured memory_bytes: 3216
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

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

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  string c1, c2; cin >> c1 >> c2;
  reverse(ALL(c2));
  cout << (c1 == c2 ? "YES\n" : "NO\n");
  return 0;
}


Measured memory_bytes: 256