akhauriyash/Code-Regression huggingface dataset:
/**
 *      AGC 20 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-13 17:25:39
**/

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

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

    int N, A, B; cin >> N >> A >> B;
    if (N == 2){
        cout << "Borys" << endl;
    }
    else if (N == 3){
        if (A == 1 && B == 3){
            cout << "Alice" << endl;
        }
        else {
            cout << "Borys" << endl;
        }
    }
    else {
        if ((B - A) % 2 == 1){
            cout << "Borys" << endl;
        }
        else {
            cout << "Alice" << endl;
        }
    }
    return 0;
}

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

int main()
{
	int a,b,ans=-1;
	cin >> a >> b;

	for(int i=0;i<1001;i++){
		if(((int)(i*0.08) == a) && ((int)(i*0.1) == b)){
			ans = i; break;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	vs A(3); FOR(i,0,3) cin >> A[i];

	string ans="";
	FOR(i, 0, 3) ans += A[i][0] - 'a' + 'A';	

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


Measured memory_bytes: 256
//OPTIMIZATONS
#pragma GCC optimize("02")
//CODE
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;
bool check(string s,int st,int fin){
	int limit = (st+fin)/2;
	for(int i=st;i<=limit;i++){
		if(s[i]!=s[fin-i]) return false;
	}
	return true;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string s;
	cin>>s;
	int n = s.length();
	bool full = check(s,0,n-1);
	bool first = check(s,0,(n-1)/2-1);
	bool second = check(s,(n+3)/2-1,n-1);
	//deb(full); deb(first); deb(second);
	if(full&&first&&second) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}



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

int main()
{
  int n, k;
  long long num = 0;
  cin >> n >> k;

  if (k % 2)
    num = pow(n / k, 3);
  else
    num = pow(n / k, 3) + pow(n / (k / 2) - n / k, 3);

  cout << num;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>

#define ll long long
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug(Head head,Tail... tail){
    cerr<<" "<<to_string(head);
    debug(tail...);
}

int main(){
    int N;
    cin>>N;
    int sum=0,min_s=1e9;
    FOR(i,N){
        int s;
        cin>>s;
        sum+=s;
        if(s%10!=0&&min_s>s){
            min_s=s;
        }
    }
    if(sum%10!=0){
        cout<<sum<<endl;
    }else{
        cout<<max(0,min(sum,sum-min_s))<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> st(n),ue(n);
  rep(i,0,n)cin>>st[i]>>ue[i];

  sort(all(st));
  sort(all(ue));

  if(n%2){
    cout<<ue[n/2]-st[n/2]+1<<ENDL;
  }else{
    cout<<(ue[n/2]+ue[n/2 -1])-(st[n/2]+st[n/2 -1])+1<<ENDL;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 6348
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n;
string s[1<<18];
int id[1<<18];
int nxt[1<<20][26];
int cnt[1<<20][26];
int nds=1;
int cs[26];

bool inline Compare(int a,int b){
	return s[a].size()>s[b].size();
}

int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	cont(i,n)cin>>s[i],id[i]=i;
	sort(id+1,id+n+1,Compare);
	ll ans=0;
	cont(I,n){
		int i=id[I];
		reverse(all(s[i]));
		int t=1;
		loop(j,s[i].size()-1){
			t=nxt[t][s[i][j]-'a'];
			cs[s[i][j]-'a']++;
		}
		cs[s[i][s[i].size()-1]-'a']++;
		ans+=cnt[t][s[i][s[i].size()-1]-'a'];
		t=1;
		loop(j,s[i].size()){
			loop(k,26)if(cs[k])cnt[t][k]++;
			if(!nxt[t][s[i][j]-'a'])nxt[t][s[i][j]-'a']=++nds;
			t=nxt[t][s[i][j]-'a'];
			cs[s[i][j]-'a']--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

template <typename T> void s_min(T& a, T b) {
	if (a > b) a = b;
}

template <typename T> void s_max(T& a, T b) {
	if (a < b) a = b;
}

const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(0);

	int N, K;
	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++) cin >> h[i];
	vector<ll> dp(N, INF);
	dp[0] = 0;
	for (int i = 1; i < N; i++) {
		for (int j = 1; j <= min(i, K); j++) {
			s_min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[N - 1];

	return 0;
}

Measured memory_bytes: 4544
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int n=100;
const int m=500;
char c0='.',c1='#';
char s[n|1][n|1];
int a,b;
int main() {
	scanf("%d%d",&a,&b);
	if(a<b)	swap(a,b),swap(c0,c1);
	memset(s,c1,sizeof(s));
	for(int k=1;k<=a;k++) {
		int x=((k-1)/25)*4+1;
		int y=((k-1)%25)*4+1;
		for(int i=x;i<=x+2;i++)
			for(int j=y;j<=y+2;j++)
				s[i][j]=c0;
		if(k<b)	s[x+1][y+1]=c1;
	}
	puts("100 100");
	for(int i=1;i<=100;i++) {
		for(int j=1;j<=100;j++)
			putchar(s[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 256
N = input()
keta = len(N)

ans = 0
keta_half = keta // 2

if keta_half > 0:
    if keta % 2 == 0:
        for i in range(keta_half):
            ans += 9 * 10 ** (2*i)
    else:
        for i in range(keta_half):
            ans += 9 * 10 ** (2*i)
        
        zan = int(N) - 10 ** (keta-1)  + 1
        ans += zan
else:
    ans = int(N)

print(ans)
    


Measured memory_bytes: 3060
n,m = input().split()
n = int(n)
m = int(m)
graph = []
str_list = list(input().split())
str_list = list(map(lambda x:int(x), str_list))
for i in range(n):
  graph.append([])
for i in range(m):
  a,b = input().split()
  a = int(a)
  b = int(b)
  graph[a-1].append(str_list[b-1])
  graph[b-1].append(str_list[a-1])
count = 0
for i in range(n):
  graph[i].sort(reverse=True)
  if len(graph[i])==0:
    count = count + 1
    continue
  if str_list[i] > graph[i][0]:
    count = count + 1
print(count)

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


using namespace std;

typedef long long ll;

double eps = 1e-9;
int change(string a,string b)
{
    int cnt=0;
    for(int i=0; i<a.size(); i++)
    {
        if(a[i]!=b[i])
        {
            cnt++;
        }
    }
    return cnt;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   int n;
   ll m = 1e9 + 7;
   cin>>n;
   ll arr[n];
   for(int i=0;i<n;i++)
   {
       cin>>arr[i];
   }
   ll pref[n];
   pref[0]=arr[0]%m;
   for(int i=1;i<n;i++)
   {
       pref[i] = (arr[i]%m+pref[i-1])%m;
   }
   ll ans=0;
   for(int i=0;i<n-1;i++)
   {
      ans += (arr[i]%m * (pref[n-1]%m-pref[i+1]%m+arr[i+1]%m)%m)%m;
   }
   cout<<ans%m<<endl;




}



Measured memory_bytes: 6760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<class T>
struct Edge {
    int src, to;
    T cost;

    Edge (int to, T cost):
        src(-1), to(to), cost(cost) {};
    Edge (int src, int to, T cost):
        src(src), to(to), cost(cost) {};

    operator int() const {
        return to;
    };
};

template <class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using UnWeightedGraph = vector<vector<int> >;
//===

template<class T>
vector<T> bfs(WeightedGraph<T> &g, int s) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;

    vector<T> min_cost(g.size(), INF);
    queue<P> que;
    que.emplace(0, s);

    while (!que.empty()) {
        T cost = que.front().first;
        int pos = que.front().second;
        que.pop();

        if (min_cost[pos] != INF) continue;
        min_cost[pos] = cost;
        for (Edge<T> e:g[pos]) {
            if (min_cost[e.to] <= cost + e.cost) continue;
            que.emplace(cost + e.cost, e.to);
        }
    }

    return min_cost;
};

template<class T>
vector<T> fukugen(WeightedGraph<T> &g, int s) {
    const T INF = numeric_limits<T>::max();
    using P = pair<T, int>;

    vector<T> min_cost(g.size(), INF);
    vector<T> restore(g.size(), -1);
    queue<P> que;
    min_cost[s] = 0;
    que.emplace(0, s);

    while (!que.empty()) {
        T cost = que.front().first;
        int pos = que.front().second;
        que.pop();

        for (Edge<T> e:g[pos]) {
            if (min_cost[e.to] == INF) {
                min_cost[e.to] = cost + e.cost;
                restore[e.to] = pos;
                que.emplace(cost + e.cost, e.to);
            }
        }
    }

    return restore;
};

llong n, m;
WeightedGraph<llong> g;
vector<vector<llong>> min_cost;

int main() {
    cin >> n >> m;
    g.resize(n + 1);
    min_cost.resize(n + 1);
    for (int i = 0; i < m; i++) {
        llong a, b;
        cin >> a >> b;
        g[a].emplace_back(b, 1);
    }

    for (int i = 1; i <= n; i++) {
        min_cost[i] = bfs(g, i);
    }

    llong k = 1ll << 60ll;
    llong rest_s, rest_t;
    for (int i = 1; i <= n; i++) {
        for (int v:g[i]) {
            if (min_cost[v][i] <= n && k > min_cost[v][i] + 1) {
                k = min_cost[v][i] + 1;
                rest_s = v;
                rest_t = i;
            }
        }
    }

    if (k > n) {
        cout << -1 << endl;
    }
    else {
        auto rest = fukugen(g, rest_s);

        cout << k << endl;

        int idx = rest_t;
        while (idx != -1) {
            cout << idx << endl;
            idx = rest[idx];
        }
    }

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<string> vs;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    int N;
    cin >> N;
    vi A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    sort(all(A), greater<int>());
    rep(i, N - 1){
        ans += A[(i + 1) / 2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4028
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N, A, b, ans = 0, fac[200001] = {}, na = 1, nb = 1;
const ll MOD = (ll)1e9 + 7;

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

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

int main() {
	cin >> N >> A >> b;
	fac[0] = 1;
	rep(i, max(A, b)) {
		fac[i + 1] = (fac[i] * (i + 1)) % MOD;
		if (i < A) {
			na *= i + N - A + 1;
			na %= MOD;
		}
		if (i < b) {
			nb *= i + N - b + 1;
			nb %= MOD;
		}
	}
	cout << (((modpow(2, N, MOD) + MOD - 1) % MOD + MOD - (na * modinv(fac[A], MOD)) % MOD) % MOD + MOD - (nb * modinv(fac[b], MOD)) % MOD) % MOD << endl;
	return 0;
}

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

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(Re int i = a;i <= b;++i)
#define nfor(i,a,b) for(Re int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<((a>=b)?10:0);
	return 0;
}


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

int main() {
	int N,K;
	char s[99];
	cin >> N >> K;
	cin >> s;
	s[K-1] = s[K-1] + 32;
	cout << s << endl ;
	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 < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  int w[n];
  rep(i, n) cin >> w[i];

  int s[n + 1];
  s[0] = 0;
  rep(i, n) s[i + 1] = s[i] + w[i];
  int sum = 0;
  rep(i, n) sum += w[i];

  int ans = 1001001001;
  rep(i, n) {
    int res = sum - s[i];
    int now = abs(s[i] - res);
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;
	
	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i-1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

struct Connection {
	vector<int>friends;
	vector<int>block;
	vector<int>friendable;
	Connection() {};
};

Connection connection[100005];
int target;

void dfs(int from) {
	int c = 1;
	for (auto t : tree[from]) {
		c = c != color[from] ? c : c + 1;
		color[t] = c;
		colorMap[make_pair(from, t)] = c;
		m = max(c, m);
		dfs(t);
		c++;
	}
}

int main() {
	
	ll H,W; 
	std::cin >> W >> H;

	ll kisuu = (W + 1) / 2;
	ll guusuu = W / 2;

	ll kisuuGyo = (H + 1) / 2;
	ll guusuGyo = H / 2;

	ll ans = kisuu * kisuuGyo + guusuu * guusuGyo;

	if (W == 1 || H == 1)ans = 1;

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



Measured memory_bytes: 10880
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

// using ll = long long;
using ll = long long ;

// なぜintじゃだめ?
ll solve(ll h, ll w) {

    ll mw = w/2;
    ll ans = 1 << 30;

    for(int hi = 1; hi <= h; ++hi) {

        ll s1 = hi * w;
        ll mh = (h - hi)/2;

        ll s2, s3;

        for(int f = 0; f<2; ++f) {
            if(f==0) {
                // vertical
                s2 = (h - hi) * mw;
                s3 = (h - hi)  * (w - mw);
            } else {
                // horizontal
                s2 = mh * w;
                s3 = (h- hi - mh) * w;
             }

             ll smax  = std::max({s1, s2, s3});
             ll smin  = std::min({s1, s2, s3});

            ans = std::min({ans, smax-smin});
        }

        // ll tans = std::min({std::max({s1, s2_v, s3_v}) - std::min({s1, s2_v, s3_v}),
                //    std::max({s1, s2_h, s3_h}) - std::min({s1, s2_h, s3_h})});
        
        // if (ans > tans) {
            // ans = tans;
            // if(ans<52000){
                // std::cout<< 
                // std::cout << ans << std::endl;
            // }
        // }        
    }
    return ans;
    // std::cout << ans << std::endl;
}

int main(void) {
    int h,w;
    std::cin >> h >> w;

    std::cout << std::min({solve(h,w), solve(w,h)}) << std::endl;
}

Measured memory_bytes: 256
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)

#入力
x = int(input())
coin = [500,5,100,50,10,1]
#解答
c = [0,0,0,0,0,0]
for i in range(len(coin)):
    c[i] = x//coin[i]
    x -= coin[i]*c[i]
ans = 0
ans += c[0]*1000
ans += c[1]*5
print(ans)
#出力


Measured memory_bytes: 21392
def main():
    #import sys
    #input = sys.stdin.readline
    H,W = map(int,input().split())
    if W == 1:
        print(1)
        exit()
    elif W%2==0:
        W2 = W/2
        W3 = W/2
    elif W%2==1:
        W2 = W//2+1
        W3 = W//2
    if H == 1:
        print(1)
        exit()
    elif H%2==0:
        H2 = H/2
        H3 = H/2
    elif H%2==1:
        H2 = H//2+1
        H3 = H//2
    mas = W2*H2 + W3*H3

    print(int(mas))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int x   , size = 100002 ;
    long long int a , b , sum = 0 ;
    cin >> x >> a >> b ;
    int arr[100002];
    for(int i = 0 ; i < x ; i++){
        cin >> arr[i];
    }
    for(int i = 0 ; i < x-1 ; i++){

        if ( (arr[i+1] - arr[i]) * a < b ){
            sum = sum +(arr[i+1] - arr[i]) * a ;
        }

        else
            sum = sum + b ;



    // cout << sum << endl ;
    }

    cout << sum ;
 return 0 ;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
	int i,j,t,sum=0;
	char a[200000];
	scanf("%s",a);
	t=strlen(a);
	for(i=0;i<t;i++){
		sum+=(a[i]-'0');
	}
	if(sum%9==0){
		printf("Yes");
	}else{
		printf("No");
	}
	return 0;
} 

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    vector<int> v(3);cin>>v[0]>>v[1]>>v[2];
    int cnt=0;
    sort(v.begin(),v.end());
    bool f0=v[0]%2,f1=v[1]%2,f2=v[2]%2;//奇数かどうか
    if(f0 && f1 && f2){
        cnt=(v[2]-v[0])/2+(v[2]-v[1])/2;
    }
    else if(!f0 && !f1 && !f2){
        cnt=(v[2]-v[0])/2+(v[2]-v[1])/2;
    }
    else if(f0 && f1 && !f2){
        cnt++;
        cnt+=(v[2]-v[0]-1)/2+(v[2]-v[1]-1)/2;
    }
    else if(!f0 && f1 && !f2){
        cnt++;
        cnt+=(v[2]-v[0])/2+(v[2]+1-v[1])/2;
    }
    else if(!f0 && !f1 && f2){
        cnt++;
        cnt+=(v[2]-v[0]-1)/2+(v[2]-v[1]-1)/2;
    }
    else if(f0 && !f1 && !f2){
        cnt++;
        cnt+=(v[2]+1-v[0])/2+(v[2]-v[1])/2;
    }
    else if(!f0 && f1 && f2){
        cnt++;
        cnt+=(v[2]+1-v[0])/2+(v[2]-v[1])/2;
    }
    else{
        cnt++;
        cnt+=(v[2]-v[0])/2+(v[2]+1-v[1])/2;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
a_list = list(map(int, input().split()))

def divisors(num):
    """
    約数全列挙
    """
    divisors = []
    for i in range(1, int(num ** 0.5) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num // i)

    return divisors
sum_num = sum(a_list)
a_list.sort()
div = divisors(sum_num)
div.sort(reverse=True)
ans = 1
from itertools import accumulate
for d in div:
    mod = []
    if d == 1:
        break
    for a in a_list:
        mod.append(a % d)
    mod.sort()
    acc_m = list(accumulate(mod))
    modd = []
    for i in range(N):
        modd.append(d-mod[i])
    acc_p = list(accumulate(modd))
    flag = False
    for i in range(N-1):
        p_sum = acc_p[-1] - acc_p[i]
        n_sum = acc_m[i]
        if p_sum == n_sum and p_sum <= K:
            flag = True
    if flag:
        ans = d
        break

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
#define exp pow(10,-9)
#define F first
#define S second
#define PB push_back 
#define MP make_pair
#define time ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define lowercase(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define uppercase(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
main()
{
	int x,y;
	cin>>x>>y;
	
	if(y%2 == 1)
		cout<<"No\n";
	else
	{
		if(y <= 4*x && y >= 2*x)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dp[1001][1001],n,m,mod=1e9+7;
char a[1001][1001];

int call(int i,int j){
    if(i>=n || j>=m || a[i][j]=='#')
        return 0;
    if(i==n-1 && j==m-1)
        return 1;
    if(dp[i][j]!=-1)
        return dp[i][j];
    int res=(call(i+1,j)+call(i,j+1))%mod;
    return dp[i][j]=res;
}


int main(){

    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof(dp));
    cout<<call(0,0)<<endl;



return 0;
}


Measured memory_bytes: 8520
#include <stdio.h>
int main(){
  int year,month,day,data;
  while (scanf("%d %d %d",&year,&month,&day)!=EOF){
    data=year*10000+month*100+day;
    if (data<18680908)
      puts("pre-meiji");
    else if (data<=19120729)
      printf("meiji %d %d %d\n",year-1868+1,month,day);
    else if (data<=19261224)
      printf("taisho %d %d %d\n",year-1912+1,month,day);
    else if (data<=19890107)
      printf("showa %d %d %d\n",year-1926+1,month,day);
    else
      printf("heisei %d %d %d\n",year-1989+1,month,day);
  }
  return 0;
}

Measured memory_bytes: 608
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 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; }
//---------------------------------------------------------------------------------------------------

int A,B;

void _main() {
	cin >> A >> B;

	int count = 0;
	int plag = 1;

	while (plag < B) {
		plag += A - 1;
		count++;
	}

	cout << count << endl;
	
}

Measured memory_bytes: 256
/* ex9_1
    sachiyan*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack
{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk)
{
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem)
{
    if (stk->count >= stk->size)
    {
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else
    {
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk)
{
    char latest;
    if (stk->count <= 0)
    {
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else
    {
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void)
{
    stack stk;
    char string[SIZE], output;
    int i;
    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //与えられた文字列の読み取り
    scanf("%s", string);

    for (i = 0; i < strlen(string); i++)
    {
        //与えられた文字のうち、0か1ならスタックに追加
        if (string[i] == '0' | string[i] == '1')
        {
            push(&stk, string[i]);
            //与えられた文字列がBでスタックの中身があれば消す
        }
        else if (stk.count > 0)
        {
            pop(&stk);
        }
    }

    //スタックからデータを取り出す
    for (i = 1; i <= stk.count; i++)
    {
        printf("%c", stk.data[SIZE - i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 1624
import bisect

n = int(input())
l = list(map(int, input().split()))

l = sorted(l)
ans = 0
for i in range(n):
    a = l[i]
    for j in range(i + 1, n):
        b = l[j]
        shita = max(a - b, b - a)
        ue = a + b
        ans += bisect.bisect_left(l, ue) - bisect.bisect_right(l, shita)
        if shita < a < ue:
            ans -= 1
        if shita < b < ue:
            ans -= 1

print(ans // 3)

Measured memory_bytes: 50384
#include <cstdio>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string s;
ll sum = 0;

void dfs(ll tmp, ll cnt, ll cur) {
  // +が入る場合、入らない場合
  if (cur == s.size()) {
    if (tmp == 0) sum += cnt;
    return;
  }
  dfs(tmp * 10 + s[cur] - '0', cnt, cur + 1);
  dfs(0, tmp * 10 + s[cur] - '0' + cnt, cur + 1);
}

int main() {
  cin >> s;
  dfs(0, 0, 0);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    
    System.out.println(""
      +(char)('A'+a.charAt(0)-'a')
      +(char)('A'+b.charAt(0)-'a')
      +(char)('A'+c.charAt(0)-'a'));
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll INF = 1ll<<40;

struct Rmin {
private:
	int N;
	vector<ll> node;

public:
	Rmin(vector<ll> v) {
		int size = v.size();
		N = 1;
		while (N < size) N <<= 1;
		node.resize(2*N-1, INF);

		for (int i=0; i < size; i++) node[i+N-1] = v[i];
		for (int i=N-2; i>=0; i--) node[i] = min(node[(i<<1)+1], node[(i<<1)+2]);
	}

	Rmin(int size) {
		N = 1;
		while (N < size) N <<= 1;
		node.resize(2*N-1, INF);		
	}

	ll Access(int x) {
		return node[x+N-1];
	}

	void Update(int x, ll val) {
		x += N-1;
		node[x] = val;
		while (x > 0) {
			x = (x-1)>>1;
			node[x] = min(node[(x<<1)+1], node[(x<<1)+2]);
		}
		return;
	}

	//[a, b)
	ll GetValue(int a, int b, int k=0, int l=0, int r=-1) {
		if (r < 0) r = N;
		if (a >= r || b <= l) return INF;
		if (a <= l && r <= b) return node[k];
		ll vl = GetValue(a, b, (k<<1)+1, l, (l+r)>>1);
		ll vr = GetValue(a, b, (k<<1)+2, (l+r)>>1, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q, a, b; cin >> n >> q >> a >> b;
	vector<int> qs(q+1);
	qs[0] = a;
	for (int i = 0; i < q; i++) cin >> qs[i+1];
	Rmin dp_l(n+1), dp_r(n+1);
	dp_l.Update(b, -b);
	dp_r.Update(b, b);

	ll total_diff = 0;
	for (int i = 0; i < q; i++) {
		int x = qs[i]; int y = qs[i+1];
		ll diff = abs(y-x);
		ll res = min(dp_l.GetValue(1, y) + y, dp_r.GetValue(y, n+1) - y);
		dp_l.Update(x, res - diff - x);
		dp_r.Update(x, res - diff + x);
		total_diff += diff;
	}

	ll ans_l = INF; ll ans_r = INF;
	for (int i = 1; i < n+1; i++)
	{
		ans_l = min(ans_l, dp_l.Access(i) + i);
		ans_r = min(ans_r, dp_r.Access(i) - i);
	}
	cout << ans_l + total_diff << endl;
}


Measured memory_bytes: 9216
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    K, N = il()
    A = il()
    A.sort()
    ret = max(A) - min(A)

    for n in range(N - 1):
        ret = min(ret, A[n] + (K - A[n + 1]))

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 20444
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
    long long n,m;
    scanf("%lld%lld",&n,&m);
    if (n == 1 && m == 1) {
        printf("1\n");
        return 0;
    }
    if (n > m)
        swap(n, m);
    if (n == 1) {
        printf("%lld\n", m-2);
    } else if (n == 2) {
        printf("0\n");
    } else {
        long long t = m*2+(n-2)*2;
        printf("%lld\n",n*m-t);
    }
    return 0;
}


Measured memory_bytes: 128
import math
a,b=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

def is_prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if n%i==0:
            return False
    return True

a_l=make_divisors(a)
b_l=make_divisors(b)
koyakusu=set(a_l)&set(b_l)
cnt=0

for k in koyakusu:
    if is_prime(k):
        cnt+=1

print(cnt)


Measured memory_bytes: 5260
#include<bits/stdc++.h>
using namespace std;
#define MN 185
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
char st[MN+5][MN+5];
int f[2][MN+4][MN+4][MN+4],n,m,g[MN+5][MN+5];
int main()
{
    n=read();m=read();
  //  for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) st[i][j]=(i+j)&1;
    for(int i=1;i<=n;++i) scanf("%s",st[i]+1);
    for(int i=1;i<=n;++i) for(int j=1,k;j<=m;j=k+1)
    {
        for(k=j;k<m&&st[i][k+1]==st[i][k];++k);
        for(int q=j;q<=k;++q) f[0][i][i][q]=k;
    }
    for(int i=1;i<=n;++i) for(int j=i+1;j<=n;++j)
        for(int k=1;k<=m;++k) if(st[j][k]==st[j-1][k])
            f[0][i][j][k]=min(f[0][i][j-1][k],f[0][j][j][k]);
    if(f[0][1][n][1]==m) return 0*puts("0");
    for(int r=1;;++r)
    {
        int a=r&1,b=1-a;
        for(int i=1;i<=n;++i) for(int j=i;j<=n;++j) for(int k=1;k<=m;++k) 
        {
            if(f[b][i][j][k]>0&&f[b][i][j][k]<m) f[a][i][j][k]=f[b][i][j][f[b][i][j][k]+1];
            else f[a][i][j][k]=f[b][i][j][k];
        }
        for(int l=1;l<=m;++l) 
        {
            for(int i=1;i<n;++i) 
            {
                int j=i,k=i+1;
                while(j>1&&f[b][j-1][i][l]==f[b][j][i][l]) --j;
                while(k<n&&f[b][i+1][k+1][l]==f[b][i+1][k][l]) ++k;
                g[j][k]=max(g[j][k],min(f[b][j][i][l],f[b][i+1][k][l]));
                for(;j>1||k<n;)
                {
                    int va=f[b][j][i][l],vb=f[b][i+1][k][l];
                    if(k==n||(j>1&&va>=vb))
                        for(--j;j>1&&f[b][j-1][i][l]==f[b][j][i][l];--j);
                    else 
                        for(++k;k<n&&f[b][i+1][k+1][l]==f[b][i+1][k][l];++k);
                    g[j][k]=max(g[j][k],min(f[b][j][i][l],f[b][i+1][k][l]));
                }
            }
            for(int A=1;A<=n;++A) for(int B=n;B>=A;--B)
                g[A][B]=max(g[A][B],max(g[A-1][B],g[A][B+1]));
            for(int A=1;A<=n;++A) for(int B=A;B<=n;++B)
                f[a][A][B][l]=max(f[a][A][B][l],g[A][B]),g[A][B]=0;
        }
        if(f[a][1][n][1]==m) return 0*printf("%d",r);
    }
    return 0;
}

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
using pii = pair<int,int>;

const ll MOD = 1'000'000'007;

ll divs(int num){
    ll ans = 1LL;
    int n = num;
    for(int d = 2; d*d <= n; d++)
    {
        ll cnt = 0LL;
        if(n % d == 0){
            while(n % d == 0){
                n /= d;
                cnt++;
            }
        }
        ans *= (cnt + 1);
    }
    if (n > 1) ans *= 2;
    return ans;
}
// 6=(1,5,1),(5,1,1),(2,2,2),(1,4,2),(4,1,2),(3,1,3),(1,3,3),(1,2,4),(2,1,4),(1,1,5)

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int N;
    cin >> N;



    ll ans = 0;
    for(int C = 1; C < N; C++)
    {
        //DBG1(C); DBG1(divs(N-C));
        ans += divs(N - C);
    }

    cout << ans << endl;   
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PB push_back
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  string n;
  cin>>n;
  ll sum=0;
  int a;
  for (ll i=0;i<n.size();i++)
  {
    a=n[i]-48;
    sum+=a;
  }
  if (sum%9==0)
  {
    cout<<"Yes";
  }
  else
    cout<<"No";
  return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int W,H,N;
    cin >> W >> H >> N;
    int nx,ny,sum = 0;
    cin >> nx >> ny;
    for(int i = 1;i < N;i++){
        int x,y;
        cin >> x >> y;
        if((nx < x && ny < y) || (nx > x && ny > y)){
            sum += max(abs(x-nx),abs(y-ny));
        }else{
            sum += abs(x-nx)+abs(y-ny);
        }
        nx = x,ny = y;
    }
    cout << sum << endl;
}

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

int main(){
    int A, B, C;

    cin >> A >> B >> C;

    int week=0;
    int day=0;

    while(7*A+B<=C){
        C-=7*A+B;
        week++;
    }
    
    while(day<7 && C>0){
        C-=A;
        day++;
    }

    cout << 7*week+day << endl;

    return 0;

}


Measured memory_bytes: 3096
#include <iostream>
using namespace	std;
int main(){

  int h,w,n,a0=0,a1=0,r=0;
  cin>>w>>h>>n;
  int c0=w-2,c1=w-1+h-5+1;
  for(int i=0,b;i<n;i++){
    cin>>b;
    if(b) a1++;
    else a0++;
    if(a1<=c0-1){
      if(a0-a1==0) r++;
    } else if(a1==c0){
      if(a0-a1==0||a0-a1==2) r++;
    } else if(a1<=c1-1){
      if(a0-a1==2) r++;
    } else if(a1==c1){
      if (a0-a1==2||a0-a1==4) r++;
    } else {
      if(a0-a1==4) r++;
    }
  }
  cout<<r<<endl;
  return 0;

}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define int long long
#define double long double
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
typedef pair<P,P> PP;
double eps=1e-8;
int mod=1e9+7;
int inf=1LL<<55;

signed main(){
  int n,m;
  string s;
  vector<int> e[200000],v;
  cin>>n>>m>>s;
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    a--,b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  queue<int> Q;
  int a[200000]={},b[200000]={},c=n;
  bool used[200000]={};

  for(int i=0;i<n;i++){
    for(int j=0;j<e[i].size();j++){
      if(s[e[i][j]]=='A')a[i]++;
      else b[i]++;
    }
    if(!a[i]||!b[i])Q.push(i),used[i]=1;
  }
  while(!Q.empty()){
    int p=Q.front();
    Q.pop();
    c--;
    for(int i=0;i<e[p].size();i++){
      int np=e[p][i];
      if(used[np])continue;
      if(s[p]=='A')a[np]--;
      else b[np]--;
      if(!a[np]||!b[np])Q.push(np),used[np]=1;
    }
  }
  cout<<(c?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 16004
#include<iostream>
using namespace std;
int main()
{
	int a,A=2,B=1;
	for(int i=3;i>0;i--)
	{
		cin>>a;
		if(a==5)
		A--;
		if(a==7)
		B--;
	}
	if(A==0&&B==0)
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long long n,n0,n1,m,M,S,i;
    scanf("%lld",&n);
    scanf("%lld",&n0);
    m=n0;
    M=n0;
    S=n0;
    for(i=1;i<=n-1;i++)
    {
        scanf("%lld",&n1);
        if(n1>M)
        {
            M=n1;
        }
        if(m>n1)
        {
            m=n1;
        }
        S=S+n1;
    }
    printf("%lld %lld %lld\n",m,M,S);
    return 0;
}


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

// 最大公約数〈ユークリッドの互除法〉
long long GCD(long long a, long long b) {
	if(a % b == 0){
		return b;
	} else {
		return GCD(b, a % b);
	}
}

// 最小公倍数
long long LCM(long long a, long long b) {
	return a / GCD(a, b) * b;
}

int main(){
    long long A, B, C, D;
    cin >> A >> B >> C >> D;
    long long E = LCM(C, D);
    long long R = B - A + 1;
    long long b = (B / C) + (B / D);
    long long a = ((A - 1) / C) + ((A - 1) / D);
    long long e = (B / E) - ((A - 1) / E);
    long long ans = R - (b - a) + e;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=5e5+10;
int n,p,f[maxn],c[maxn],a[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
	{
        scanf("%1d",&c[i]);
        if(!c[i])
			p=i;
        a[i]=p;
    }
    for(int i=1;i<=n;i++)
	{
        f[i]=f[i-1];
        if(!c[i])
			continue;
        if(!c[i-1]&&c[i-2])
        {
            f[i]=max(f[i],f[a[i-2]]+i-2-a[i-2]);
        	f[i]=max(f[i],f[a[i-2]+1]+i-2-a[i-2]-1);
        }
        else if(a[i]>1&&c[a[i]-1])
            f[i]=max(f[i],f[a[i]-2]+i-a[i]);
    }
    printf("%d\n",f[n]);
    return 0;
} 

Measured memory_bytes: 6144
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int D;
vector<int> c(26);
int ss[365][26];
vector<int> ans(0);

double powyabai = 1.18;
double cyabaipow = 1.18;

double evaluate(int day, int kind){

    double yabasa = 0;
    int s = ans.size();
    int idx;
    for(idx = s - 1; 0 <= idx; idx--){
        if(ans[idx] == kind) break;
    }
    yabasa = pow(day - idx, powyabai) * pow(c[kind], cyabaipow);
    double uresisa = ss[day][kind];
    return yabasa + uresisa;
}

int main(){
    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D)rep(j, 26) cin >> ss[i][j];
    rep(i, D){
        double max_eva = -inf;
        double choice = 0;
        rep(j, 26){
            if(chmax(max_eva, evaluate(i, j))) choice = j;
        }
        ans.push_back(choice);
    }
    rep(i, D) pt(ans[i] + 1);
    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define REV(x) reverse(ALL((x)))
#define pb push_back

ll ceilll(ll a, ll b) {
    return (a + b - 1) / b;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    vec A(N), F(N);
    REP(i,0,N) cin >> A[i];
    REP(i,0,N) cin >> F[i];

    ASC(A); DESC(F);

    ll ng = -1, ok = INF;
    while(abs(ok - ng) > 1) {
        ll mid = (ng + ok) / 2;
        ll sum = 0;
        REP(i,0,N) {
            sum += MAX(ceilll(A[i]*F[i]-mid,F[i]),0);
        }
        if(sum <= K) ok = mid;
        else ng = mid;
    }

    PR(ok);

    return 0;
}

/*



*/

Measured memory_bytes: 6352
/*まずうちさあ屋上あんだけど、焼いてかない？*/
	#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	ll pas[51][52];
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	int main(){
		IOS;
		ll n, q, k;
		cin >> n;
		vec<vec<P>> g(n + 1);
		REP(i,n-1){
			ll a, b, c;
			cin >> a >> b >> c;
			g[a].push_back(P(b, c));
			g[b].push_back(P(a, c));
		}
		vec<ll> d(n + 1,INF);
		cin >> q >> k;
		d[k] = 0;
		priority_queue<P,vec<P>,greater<P>> que;
		que.push(P(0, k));
		while(!que.empty()){
			P p = que.top();que.pop();
			int v = p.second;
			if(d[v] < p.first)continue;
			for(int i = 0;i < g[v].size();i++){
				P q = g[v][i];
				if(d[q.first] > d[v] + q.second){
					d[q.first] = d[v] + q.second;
					que.push(P(d[q.first],q.first));
				}
			}
		}
		REP(i,q){
			ll x, y;
			cin >> x >> y;
			dump(d[x] + d[y]);
		}
		return 0;
	}

Measured memory_bytes: 11120