akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N;
    vector<string> s(N);
    cin >> s;
    map<string, int> mp;
    REP(i, N) {
        mp[s[i]]++;
    }
    cout << mp.size() << endl;
}

Measured memory_bytes: 25108
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
long long a,b,c,d,e;
int main() {
	cin>>a>>b>>c;
	if((a*b*c)%2==0){cout<<"0"<<endl;}else{
		d=max({a,b,c});
			if(d==a){cout<<c*b;}else
			if(d==b){cout<<c*a;}else{cout<<a*b;}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<ll> dp0(n+1);  /* dp0[i+1] :  aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点ではまだa+bがs未満になるかわかっていない
                                         (a, b)の組の個数 */
    
    vector<ll> dp1(n+1);  /* dp1[i+1] :  aおよびbの上からi桁目(iは0-index)までを確定させ、
                                         その時点で既にa+bがs未満であることがわかっている
                                         (a, b)の組の個数 */

    dp0[0] = 1;
    rep(i, n) {

        // (a_i, b_i) = (0, 0) のとき
        if(s[i] == '0') {
            dp0[i+1] += dp0[i];
            dp1[i+1] += dp1[i];
        } 
        else if(s[i] == '1') {
            dp1[i+1] += dp0[i] + dp1[i];
        }

        // (a_i, b_i) = (1, 0), (0, 1) のとき
        if(s[i] == '0') {
            dp1[i+1] += 2*dp1[i];
        } 
        else if(s[i] == '1') {
            dp0[i+1] += 2*dp0[i];
            dp1[i+1] += 2*dp1[i];
        }

        dp0[i+1] %= mod;
        dp1[i+1] %= mod;
    }

    cout << (dp0[n] + dp1[n])%mod << endl;
    return 0;
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

ull gcd(ull x, ull y)
{
    if(!y) return x;
	else return gcd(y,(ull)x%y);
}


int main(){
	int n;
  	cin >> n;
  	int a[n+1] = {0},cnt = 0,memo = 0,memo_n = 0;
  	a[n] = -1;
  	rep(i,0,n){
      cin >> a[i];
    }
  	sort(a,a+n);
  
  	rep(i,1,n+1){
      memo_n = a[i-1];
      memo++;
      if(a[i-1] != a[i]){
        if(memo < memo_n){
          cnt += memo;
        }
        else if(memo > memo_n){
          cnt += memo - memo_n;
        }
        memo = 0;
      }
    }
  
  	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
bool NA(string s) {
	if (s == "1111" || s == "2222" || s == "3333" || s == "4444" || s == "5555" || s == "6666" || s == "7777" || s == "8888" || s == "9999")return true;
	else return false;
}
signed main() {
	string s;
	while (cin >> s, s != "0000") {
		int ans(0);
		while (s != "6174") {
			if (NA(s)) {
				cout << "NA" << endl;
				goto here;
			}
			string big(s), small(s);
			sort(all(small));
			sort(all(big), greater<char>());
			s = to_string(stoi(big) - stoi(small));
			while (s.size() < 4)s = "0" + s;
			ans++;
		}
		cout << ans << endl;
	here:;

	}
	return 0;
}

Measured memory_bytes: 3248
k = gets.chomp.to_i
a,b = gets.chomp.split.map &:to_i

a.upto(b).each do |i|
#  p "i: #{i}, k: #{k}, i%k: #{i%k}"
  if i%k == 0
    print 'OK' 
    exit
  end
end
print 'NG'

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename M>
struct SegmentTree{
    using T = typename M::type;

    int numLeaves;
    std::vector<T> data;
    
    SegmentTree(int n){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }
        
        data.resize(numLeaves * 2);
        std::fill(data.begin() + numLeaves, data.end(), M::identity());
        
        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    template <typename F>
    SegmentTree(int n, F f){
        numLeaves = 1;
        while(numLeaves < n){
            numLeaves *= 2;
        }

        data.resize(numLeaves * 2);
        for(int i=0;i<n;++i){
            data[i + numLeaves] = std::move(f(i));
        }
        std::fill(data.begin() + numLeaves + n, data.end(), M::identity());

        for(int i=numLeaves-1;i>0;--i){
            data[i] = M::bop(data[i*2], data[i*2+1]);
        }
    }

    void set(int k, T v){
        k += numLeaves;
        data[k] = v;
        
        while(k > 1){
            k /= 2;
            data[k] = M::bop(data[k*2], data[k*2+1]);
        }
    }
    
    T product(int l, int r){
        l += numLeaves;
        r += numLeaves;
        
        T pl = M::identity(), pr = M::identity();
        for(;l<r;l/=2,r/=2){
            if(l & 1){
                pl = M::bop(pl, data[l]);
                l += 1;
            }
            if(r & 1){
                r -= 1;
                pr = M::bop(data[r], pr);
            }
        }
        
        return M::bop(pl, pr);
    }
    
    T at(int i){
        return data[i + numLeaves];
    }
};

struct M{
    using type = int;
    static type identity(){
        return 0;
    }
    static type bop(type &m1, type &m2){
        return std::max(m1, m2);
    }
};

int N, K, C;
std::string S;
int A[200100], B[200100];
SegmentTree<M> seg(200100);

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

    std::cin >> N >> K >> C;
    std::cin >> S;

    for(int i=1;i<=N;++i){
        A[i] = A[i-1];

        if(S[i-1] == 'x'){continue;}

        A[i] = std::max(A[i], A[std::max(i-C-1, 0)] + 1);
    }

    if(C == 0){
        if(A[N] == K){
            for(int i=1;i<=N;++i){
                if(S[i-1] == 'o'){
                    std::cout << i << std::endl;
                }
            }
        }
        
        return 0;
    }

    for(int i=N;i>=1;--i){
        B[i] = B[i+1];

        if(S[i-1] == 'x'){continue;}

        B[i] = std::max(B[i], B[std::min(i+C+1, N+1)] + 1);
    }

    for(int i=1;i<N;++i){
        seg.set(i, A[i] + B[std::min(i+C+1, N+1)]);
    }

    for(int i=1;i<=N;++i){
        int x = seg.product(std::max(i-C, 1), i);

        if(i-C <= 0){
            x = std::max(x, B[i+1]);
        }

        if(x < K){
            std::cout << i << std::endl;
        }
    }
}


Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
long long a[5],n,t,x,y,p;
int main(){
	scanf("%llu%llu",&n,&p);
	a[0]=1;
	a[1]=0;
	for(int i=1;i<=n;i++){
		scanf("%llu",&t);
		x=a[0];
		y=a[1];
		if(t%2==1){
			a[0]+=y;
			a[1]+=x;
		}else{
			a[0]+=x;
			a[1]+=y;
		}
	}
	printf("%llu",a[p]);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct edge {
  ll to, a, b, lim;
};

ll N, M, S, G;
vector<edge> E[200000];

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

double fd(double a, double b, double x) {
  return x + b / (x + a);
}

ll limit(ll a, ll b) {
  double l = 0, h = 1e20;
  REP(i, 0, 200) {
    double m1 = l + (h - l) / 3, m2 = l + (h - l) / 3 * 2;
    double f1 = fd(a, b, m1), f2 = fd(a, b, m2);
    if (f1 > f2) l = m1; else h = m2;
  }
  return f(a, b, (ll) l) < f(a, b, (ll) l + 1) ? l : l + 1;
}

int main(void) {
  cin >> N >> M >> S >> G, S--, G--;
  REP(i, 0, M) {
    ll U, V, A, B;
    cin >> U >> V >> A >> B; U--; V--;
    ll lim = limit(A, B);
    E[U].push_back((edge) { V, A, B, lim });
    E[V].push_back((edge) { U, A, B, lim });
  }

  vector<ll> dp(N, 1LL << 60);
  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.push(pll(0, S));

  while (q.size()) {
    ll t = q.top().first, v = q.top().second;
    q.pop();

    if (dp[v] <= t) continue;
    dp[v] = t;

    if (v == G) {
      cout << t << endl;
      return 0;
    }

    for (edge e : E[v]) {
      ll nv = e.to, a = e.a, b = e.b, lim = e.lim;
      ll nt = t < lim ? f(a, b, lim) : f(a, b, t);
      q.push(pll(nt, nv));
    }
  }

  cout << -1 << endl;
}


Measured memory_bytes: 31872
n, result = map(int, input().split())

for x in range(n + 1):
  for y in range(n - x + 1):
    if 10000 * x + 5000 * y + 1000 * (n - x - y) == result:
      print(x, y, n - x - y)
      exit()

print("-1 -1 -1")

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

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

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  V<int> a(n);
  V<char> op(n);
  op[0] = '+'; cin >> a[0];
  FOR(i, 1, n) cin >> op[i] >> a[i];

  V<int> b(n); b[0] = a[0];
  FOR(i, 1, n) b[i] = b[i-1] + a[i];

  V<int> v;
  REP(i, n) if(op[i] == '-') v.PB(i);
  v.PB(n);
  V<int> nxt(n);
  REP(i, v.size()-1) nxt[v[i]] = v[i+1];

  int ret = -INF, now = 0;
  REP(i, n) {
    if(op[i]=='+') {
      now += a[i];
    } else {
      chmax(ret, now - (b[nxt[i]-1]-b[i-1]) + (b[n-1]-b[nxt[i]-1]));
      now -= a[i];
    }
  }
  chmax(ret, now);

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  string s, t;
  std::cin >> s;
  std::cin >> t;
  string k = t + s;
  std::cout << k << '\n';
  return 0;
}


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

#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
 
const int Maxn = 4e2 + 10;
const ll Inf = LONG_LONG_MAX >> 2;
const int Log = 20;
const ll Mod = 1e9 + 7;

ll mul(ll a, ll b){
	return (a * b) % Mod;
}

int a[Maxn], b[Maxn];
ll dp[Maxn][Maxn];
ll pw[Maxn][Maxn];
ll ps[Maxn][Maxn];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, c;
	cin >> n >> c;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= n; i++) cin >> b[i];
	for(int i = 0; i < Maxn; i++){
		pw[i][0] = 1;
		for(int j = 1; j < Maxn; j++){
			pw[i][j] = mul(pw[i][j - 1], i);
		}
	}
	for(int i = 0; i < Maxn; i++) ps[0][i] = pw[0][i];
	for(int i = 1; i < Maxn; i++){
		for(int j = 0; j < Maxn; j++){
			ps[i][j] = (pw[i][j] + ps[i - 1][j]) % Mod;
		}
	}
	
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= c; j++){
			//for(int x = a[i]; x <= b[i]; x++){
				for(int k = 0; k <= j; k++){
					dp[i][j] += mul(dp[i - 1][j - k], ps[b[i]][k] - ps[a[i] - 1][k]);
					//C = mul(C, x);
				}
				dp[i][j] %= Mod;
			//}
		}
	}
	
	cout << (dp[n][c] + Mod) % Mod << '\n';
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll f(ll n){
	return n*n*n*n*n;
}
void solve(){
	ll x;
	cin>>x;
	rep(i, -2000,2000){
		rep(j,-2000,2000){
			if(f(i)-f(j)==x){
				cout<<i<<" "<<j<<endl;
				return ;
			}
		}
	} 
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}






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

using namespace std;
int main (){
    int n;
    cin >> n;
    string stmp;
    map<string,int> sapper;
    for (int i = 0; i < n; i++){
        cin >> stmp;
        sapper[stmp]++;
    }
    vector<pair<int,string>> vote(sapper.size());
    int idx=0;
    for (auto itr = sapper.begin(); itr != sapper.end(); itr++){
//        cout << itr->first << " " << itr->second << "\n";
        vote[idx].first=itr->second*-1;
        vote[idx].second=itr->first;
        idx++;
    }
    sort(vote.begin(),vote.end());
    idx=0;
    int ref=vote[idx].first;
    while (vote[idx].first==ref){
        cout << vote[idx].second << "\n";
        idx++;
    }

}

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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k<<endl;
	else if(k<=a+b) cout<<a<<endl;
	else cout<<a-(k-a-b)<<endl;
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3652
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))
#define each(itr,v) for(auto (itr):(v))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	for (auto vv : v)
		os << vv << ",";
	return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
	return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
	return a * a;
}

template <typename T>
T gcd(T a, T b) {
	if (a > b) return gcd(b, a);
	return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
	if (n == 0) return 1;
	if (n == 1) return b /* % MOD */;
	if (n % 2 == 0) {
		return mypow(b * b /* % MOD */, n / 2);
	}
	else {
		return mypow(b, n - 1) * b /* % MOD */;
	}
}

ll pcnt(ll b) {
	return __builtin_popcountll(b);
}



// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int ans = 0;
	REP(i, S.size() - 1) {
		if (S[i] != S[i + 1]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

bool ab[200000],cd[200000];

int main(){
  int n,m,i;
  cin >> n >> m;
  vector<int> a(m),b(m);
  for(i=0;i<m;++i){
    cin >> a[i] >> b[i];
    if(a[i]==1){
      ab[b[i]]=true;
    }else if(b[i]==n){
      cd[a[i]]=true;
    }
  }
  i=0;
  int ha=0;
  for(i=0;i<n;++i){
    if(ab[i]==true && cd[i]==true){
      ha=1;
    }
  }

  if(ha==1){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String in = sc.next();
    int out = 0;
    for(int i = 0; i < 3; i++){
      if(in.charAt(i) == 'o')out++;
    }
    System.out.println(700 + 100 * out);
  }
}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
long double a,b,c;
int main(){
	cin>>a>>b;
	a*=b;
	cout<<(ll)(a)<<endl;
	return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#define N 1050
//LCS

using namespace std;

int LCS (string x, string y) {
    
    int maxl = 0;
    int str[N+1][N+1]; 
    int m = x.size();
    int n = y.size();
    x = ' ' + x;
    y = ' ' + y;

    //初期化
    for (int i = 0; i <= m; i++) {
        str[i][0] = 0;
    }
    for (int i = 1; i <= n; i++) {
        str[0][i] = 0;
    }


    for (int i = 1; i <= m; i++) {
        for (int j = 1; j <= n; j++){
        	if(x[i] == y[j]){
        	    str[i][j] = str[i - 1][j - 1] + 1;
        	}else{
        	    str[i][j] = max(str[i][j - 1], str[i - 1][j]);
        	}
        	maxl = max(maxl, str[i][j]);
        }
    }
    return maxl;
}

int main() {
    int q;
    cin >> q;
    string X, Y;
    for(int i = 0;i < q; i++) {
        cin >> X >> Y;
        cout << LCS(X,Y) << endl;
    }
    return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

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

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


int main(){
    CIN(N,k);
    int h;
    int ans=0;
    rep(i,N){
        scanf("%d",&h);
        if(h>=k)ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


S, W = MI()
print('unsafe' if W >= S else 'safe')

Measured memory_bytes: 61620
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

K = int(input())

cnt = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(j+1, K+1):
            cnt += 2 * gcd(i, gcd(j, k))
    for j in range(1, K+1):
        cnt += gcd(i, gcd(j, j))
print(cnt)




Measured memory_bytes: 9484
from collections import Counter

n=int(input())
C=[Counter() for i in range(n)]
for i in range(n):
    C[i]=Counter(input())

abc=[chr(i) for i in range(ord('a'),ord('a')+26)]
ans=''
for ch in abc:
    ans+=ch * min([C[i][ch] for i in range(n)])
print(ans)

Measured memory_bytes: 39152
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define N_MAX (1<<17)

int nn_sum;
long long dat_sum1[(2 * N_MAX) - 1];
long long dat_sum2[(2 * N_MAX) - 1];

void init_sum(int n1) {
  nn_sum = 1;

  while (nn_sum < n1)nn_sum *= 2;

  for (int i = 0; i < 2 * nn_sum - 1; i++) {
    dat_sum1[i] = 0;
    dat_sum2[i] = 0;
  }
}

void add_sum(int a, int b, long long x, int k, int l, int r) {
  if (a <= l && r <= b) {
    dat_sum1[k] += x;
  }
  else if (l < b && a < r) {
    dat_sum2[k] += (min(b, r) - max(a, l)) * x;
    add_sum(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add_sum(a, b, x, k * 2 + 2, (l + r) / 2, r);
  }
}

long long sum_sum(int a, int b, int k, int l, int r) {
  if (b <= l || r <= a)return 0LL;
  else if (a <= l && r <= b) {
    return (dat_sum1[k] * (r - l) + dat_sum2[k]);
  }
  else {
    long long ret;
    ret = (min(b, r) - max(a, l)) * dat_sum1[k];
    ret += sum_sum(a, b, k * 2 + 1, l, (l + r) / 2);
    ret += sum_sum(a, b, k * 2 + 2, (l + r) / 2, r);
    return ret;
  }
}

ll d[100100];

int main() {
  ll n,m;
  cin>>n>>m;
  vector<pair<ll,pair<ll,ll> > > v;
  rep(i,0,n){
    ll a,b;
    cin>>a>>b;
    v.pb(mp(b-a+1,mp(a,b)));
  }
  sort(all(v));
  init_sum(m+1);
  int index = 0;
  rep(i,1,m+1){
    ll c = 0;
    while(index<n&&v[index].fi<i){
      ll a = v[index].se.fi;
      ll b = v[index].se.se;
      c++;
      add_sum(a,b+1,1,0,0,nn_sum);
      index++;
    }
    d[1]+=c;
    d[i]-=c;
    ll e = 0;
    for(int j = i; j <= m; j += i){
      e += sum_sum(j,j+1,0,0,nn_sum);
    }
    d[i]+=e;
    d[i+1]-=e;
  }
  ll h = n - index;
  rep(i,0,100005){
    d[i+1]+=d[i];
  }
  rep(i,1,m+1){
    cout << d[i]+h << endl;
  }
  return 0;
}





Measured memory_bytes: 13032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

vector<pint> dist;
int N;

int main()
{
    cin >> N;
    dist.resize(N);
    rep(i, N)
    {
        cin >> dist[i].first >> dist[i].second;
    }
    vector<int> P(N);
    rep(i, N)
    {
        P[i] = i;
    }
    ld ans = 0;
    do
    {
        ld con = 0;
        rep(i, N - 1)
        {
            int to = P[i];
            int from = P[i + 1];
            int x = dist[to].first - dist[from].first;
            int y = dist[to].second - dist[from].second;
            con += sqrt((ld)(x * x + y * y));
        }
        ans += con;
    } while (next_permutation(P.begin(), P.end()));
    int fact = 1;
    rep2(i, 1, N + 1)
    {
        fact *= i;
    }
    cout << setprecision(10) << (ld)(ans / fact) << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(input())
B = list(input())
C = list(input())

ans = 0
for i in range(N):
  if A[i] == B[i] == C[i]: continue
  elif A[i] == B[i] or A[i] == C[i] or B[i] == C[i]:
    ans += 1
  else:
    ans += 2
print(ans)

Measured memory_bytes: 3060
fn main() {
  let s = get::chars();

  let mut freq = vec![0; 3];
  for c in s {
    match c {
      'a' => {freq[0] += 1},
      'b' => {freq[1] += 1},
      'c' => {freq[2] += 1},
      _ => unreachable!()
    }
  }

  let fmax = freq.iter().max().unwrap();
  let fmin = freq.iter().min().unwrap();
  let ans = if fmax-fmin <= 1 {"YES"} else {"NO"};

  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}

Measured memory_bytes: 4352
#include <iostream>

using namespace std;

int main (void){
    unsigned long int n;
    unsigned int a[200002] = {0};
    unsigned int box[200002] = {0};
    int ansflag = 0;
    int ansvalue = 0;
    unsigned int no[200002] = {0};

    // 0はダミーとして用いる

    //input
    cin >> n;
    for(unsigned long int i=1;i<(n+1);i++){
        cin >> a[i];
    }

    //半分以上
    for(unsigned long int i=n; i > (n/2) ; i-- ){
        if(a[i] ==1){
            box[i] = 1;
            no[ansvalue] = i;
            ansvalue++;
        }else{
            box[i] = 0;
        }
        //debug
    }

    //半分以下
    for( unsigned long i=(n/2) ; i>0; i--){
        unsigned long value = 2 * i;
        unsigned long sum = 0;

        while(value <= n){
            sum += box[value];
            value += i;
        }

        if( (sum+1)%2 == a[i] ){
            box[i] =1;
            no[ansvalue] = i;
            ansvalue++;
        }else if( sum%2 == a[i]){
            box[i] = 0;
        }else{
            ansflag = -1;
            break;
        }
    }

    if(ansflag == -1){
        cout << "-1" << endl;
    }else{
        cout << ansvalue << endl;
        for(int i=0;i<ansvalue; i++){
            cout << no[i] << " " ;
        }
    }




    return 0;
}

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


int n,m;
bool a[510][510],bl[510][510];
char ch[510][510];

int main(){
	cin>>n>>m;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>ch[i][j];
			
			if(ch[i][j]=='#'){
				a[i][j]=bl[i][j]=1;
			}
		}
	}
	
	
	for(int i=1;i<=m;i++){
		a[i][1]=1;
		bl[i][m]=1;
	}
	
	
	for(int i=1;i<=n;i++){
		for(int j=2;j<m;j++){
			if(i%2) a[i][j]=1;
			else bl[i][j]=1;
		}
	} 
	
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]) cout<<'#';
			else cout<<'.';
		}
		
		cout<<endl;
	}
	
	cout<<endl;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(bl[i][j]) cout<<'#';
			else cout<<'.';
		}
		
		cout<<endl;
	}
	
	return 0;
} 

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

	vector<int> a(n);
	for (auto& v : a) {
		cin >> v;
	}

	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (a[i] != a[i + 1]) {
			continue;
		}

		a[i + 1] = INF;
		ans++;
	}

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


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


using namespace std;

using ll   = long long;
using ii   = pair < int , int >;
using i3   = pair < int , ii >;
using li   = pair < ll , int >;
using lii  = pair <  ll,  ii >;
using vi   = vector < int >;
using vl   = vector < ll >;
using vli  = vector < li >;
using vii  = vector < ii >;
using vi3  = vector < i3 >;
using vlii = vector < lii >;

const int N = 2e5 + 5;
const ll INF = 1e17;
const double eps = 1e-12 , PI = acos(-1);

int n;

void solve(int cs){
    scanf("%lld" , &n);
    printf("%lld\n" , n*(n-1ll)/2);

}

main(){
    int t = 1;
    //scanf("%d" , &t);

    for(int cs = 1 ; t -- ; cs ++){
        solve(cs);
    }

    return 0;
}



Measured memory_bytes: 256
K,A,B = map(int,input().split())
if A+1 >= B:
    print(K+1)
else:
    if K < A-2:
        print(K+1)
    else:
        K -= A-1
        chance = K//2
        ans = 0
        ans += chance*(B-A)+A
        spare = K%2
        ans += spare
        print(ans)

Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    set<int> s;
    rep(i,3){
        int a;
        cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない



int main() {
	
	int n, h, w;
	cin >> n >> h >> w;
	cout << (n - h+1)*(n - w+1) << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np
from itertools import product

h, w, k = map(int, input().split())

a = np.array([list(input()) for _ in range(h)])

cnt = 0
for rows in product([False, True], repeat = h):
    for cols in product([False, True], repeat = w):
        if np.count_nonzero(a[np.ix_(rows,cols)]=='#') == k:
           cnt += 1

print(cnt)

Measured memory_bytes: 26996
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  vector<int> A(3 * N);
  for (int i = 0; i < 3 * N; ++i) {
    A[i] = in();
  }

  sort(A.begin(), A.end());
  Int res = 0;
  for (int i = 0; i < N; ++i) {
    res += A[3 * N - 2 * (i + 1)];
  }

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

  return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;


string S;
ll N,K,X,ans;
ll A, B, C;


int main() {

	cin >> K >> X;

	ll left = max(ll(-1000000), X - K + 1);
	ll right = min(ll(1000000), X + K - 1);

	for (int i = left; i <= right; i++) {
		cout << i <<" ";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
import queue
import sys

input = sys.stdin.readline


class Solution:
    def main(self):
        H, W = map(int, input().split())
        S = [list(input().rstrip()) for _ in range(H)]

        for i in range(H):
            S[i] = ["#"] + S[i] + ["#"]
        S = [["#"] * (W + 2)] + S + [["#"] * (W + 2)]

        ans = 0
        for i in range(1, H + 1):
            for j in range(1, W + 1):
                if S[i][j] == "#":
                    continue
                v = self.min_move(S, (i, j))
                ans = max(ans, v)
        print(ans)

    def min_move(self, map, start):
        moving_range = ((1, 0), (-1, 0), (0, 1), (0, -1))

        q = queue.Queue()
        q.put((start, 0))

        already = {start}
        ret = 0
        while not q.empty():
            pos, cnt = q.get()
            ret = max(ret, cnt)
            for move in moving_range:
                i, j = pos[0] + move[0], pos[1] + move[1]
                if (i, j) not in already and map[i][j] == ".":
                    q.put(((i, j), cnt + 1))
                    already.add((i, j))

        return ret


# Run main
if __name__ == '__main__':
    Solution().main()


Measured memory_bytes: 47336
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int len;
    len = s.size();
    int tmp;
    int num;
    num =0;
    if(len%2==1){
        tmp = len/2;
    }else{
        tmp = len/2-1;
    }
    for(int i=0; i<=tmp; i++){
        if(s[i] != s[len-1-i] ){
            num++;
        }
    }
    cout << num << endl;
}




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

typedef long long ll;

int main(){
    ll N,K;
    cin>>N>>K;
    
    ll h[N];
    for(int i=0;i<N;i++) cin>>h[i];
    
    ll c[N];
    c[0]=0;
    
    for(int i=1;i<N;i++){
        ll minv=c[i-1]+abs(h[i]-h[i-1]);
        
        for(int j=1;i-j>=0&&j<=K;j++){
            ll tmp=c[i-j]+abs(h[i]-h[i-j]);
            minv=min(tmp,minv);
        }
        
        c[i]=minv;
    }
    
    cout<<c[N-1]<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999

int f;

int main() {
	cin >> f;
	cout << (f - 30) / 2 << endl;
	

	return 0;
}



Measured memory_bytes: 3096
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n, m;
    
    scanf("%d%d", &n, &m);
    
    if (n==m) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}



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

int main() {
  string s;
  int k;
  cin >> k >> s;

  if (s.size() <= k) {
    cout << s << endl;
  } else {
    string c = s.substr(0, k);
    cout << c << "..." << endl;
  }
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const int N = 1e5 + 10;
const ll INF = 1e18;
int A[N];
ll lo[N], hi[N];
ll suf[N];
inline int ceil(int a, int b) {
  return (a + b - 1) / b;
}

int main() {
#ifdef LOCAL_EXEC
	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n; cin >> n;
  for (int i = 0; i <= n; i++) {
    cin >> A[i];
  }
  if (n == 0) {
    cout << (A[0] == 1 ? 1 : -1) << endl;
    return 0;
  }
  if (n == 1) {
    if (A[0] == 0) {
      cout << (A[1] <= 2 ? A[1] + 1 : -1) << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }
  if (A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  lo[n] = hi[n] = 0;
  for (int i = n - 1; i >= 0; i--) {
    lo[i] = ceil(lo[i + 1] + A[i + 1], 2);
    hi[i] = hi[i + 1] + A[i + 1];
  }


  ll nl = 1;
  ll tot = 1;
  for (int i = 0; i <= n; i++) {
    if (i < 60) {
      if (lo[i] + A[i] > (1ll << i)) {
        cout << -1 << endl;
        return 0;
      }
    }
    if (i == 0) continue;

    nl = max(lo[i], min(hi[i], 2 * nl - A[i]));
    if (i < 60) {
      nl = min(nl, (1ll << i) - A[i]);
    }

    tot += A[i] + nl;
  }
  cout << tot << endl;

  return 0;
}

Measured memory_bytes: 5572
from heapq import heappush, heappop
import numpy as np

N, M = [int(x) for x in input().split()]

price = [int(x) for x in input().split()] 
hq_price = []
for p in price:
  heappush(hq_price, -p)

for m in range(M):
  max_tmp = heappop(hq_price)
  heappush(hq_price, max_tmp/2.)

price = [int(-x) for x in hq_price]
print(sum(price))



Measured memory_bytes: 23924
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramD
    {
        static void Main(string[] args)
        {
            //
            string input = Console.ReadLine();
            int n = int.Parse(input);
            List<Task> task= new List<Task>();

            for(int i = 0; i < n;i ++)
            {
                string[] input_a = Console.ReadLine().Split(' ');
                int a = int.Parse(input_a[0]);
                int b = int.Parse(input_a[1]);
                task.Add(new Task(b,a));
            }

            //ソートする
            IOrderedEnumerable<Task> sorted = task.OrderBy(x => x.b);

            //時間合計
            int sum = 0;
            bool frag = true;
            foreach (Task s in sorted)
            {
                sum += s.a;
                if(sum > s.b)
                {
                    frag = false;
                    break;
                }
            }

            if(frag == true)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }

    public class Task
    {
        public int b;
        public int a;
        public Task(int b, int a)
        {
            this.a = a;
            this.b = b;
        }
    }

Measured memory_bytes: 28836
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=998244353;
inline int ad(int x){return x>=mod?x-mod:x;}
inline int dec(int x){return x<0?x+mod:x;}
inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=1LL*ans*a%mod;
		a=1LL*a*a%mod;
		b>>=1;
	}return ans;
}
int fac[1000010],inv[1000010];
inline int C(int n,int m){return 1LL*fac[n]*inv[m]%mod*inv[n-m]%mod;}
 main()
{
    //freopen("b.in","r",stdin);
	//freopen("b.out","w",stdout);
	fac[0]=1;
	for(int i=1;i<=1000000;i++)fac[i]=1LL*fac[i-1]*i%mod;inv[1000000]=power(fac[1000000],mod-2);
	for(int i=1000000;i>=1;i--)inv[i-1]=1LL*inv[i]*i%mod;
	int n=read(),m=read(),sum=0;if(n<m)swap(n,m);
	for(int i=1;i<=m;i++)sum=ad(sum+1LL*C(2*i,i)*C(n+m-2*i,n-i)%mod);
	sum=1LL*sum*power(ad(2*C(n+m,m)),mod-2)%mod;
	pr2(ad(sum+n));
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define pii pair<int, int>
#define fi first
#define se second
#define mk(x, y) make_pair( x, y )
#define pk push_back
using namespace std;
const int M = 1e5 + 5;
const int N = 1e5 + 5;
const double PI = acos(-1.0);
int m, n;

int main( ){
    ll x, y;
    while( scanf( "%lld %lld", &x, &y ) != EOF ){
        if( x > y )
            printf( "safe\n" );
        else
            printf( "unsafe\n" );
    }
    return 0;
}


Measured memory_bytes: 3656
s = input()
op = ['-', '+']
for i in range(2):
    for j in range(2):
        for k in range(2):
            com = s[0] + op[i] + s[1] + op[j] + s[2] + op[k] + s[3]
            if eval(com) == 7:
                print(com + '=7')
                exit(0)

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

int main(){
    std::string str;
    int count[26]={};
    
    while(std::cin>>str){
        for(int alp=0; alp<26; alp++){
           for(int i=0; i<str.size(); i++){
               if(str[i]=='a'+alp || str[i]=='A'+alp){
                    count[alp]+=1;
                }
            }
        }
    }
    
    for(int alp=0; alp<26; alp++){
        std::cout<< (char)('a'+alp) <<" : "<<count[alp]<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include<iostream>
#include<vector>
#include<bitset>
using namespace std;

int N,M;
vector<int>friends;

int root(int x){
  if(friends.at(x) == x)  return x;
  else  return friends.at(x) = root(friends.at(x));
}

bool same(int x,int y){
  return root(x) == root(y);
}

void unite(int x,int y){
  x = root(x);
  y = root(y);

  if(x == y)  return;

  friends.at(x) = y;
}

int main(){
  cin >> N >> M;
  friends.resize(N);
  for(int i=0;i<N;i++){
    friends.at(i) = i;
  }
  for(int i=0;i<M;i++){
    int a,b;  cin >> a >> b;
    unite(a-1,b-1);
  }
  vector<int>count(N);
  for(int i=0;i<N;i++){
    count.at(root(i))++;
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    if(ans < count.at(i)) ans = count.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 8024