akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
ll ans = 0;
int N, M, Q;
vll a(51), b(51), c(51), d(51);
vll v = {1};
void dfs(int idx)
{
    if (idx == N + 1)
    {
        ll now = 0;
        for (size_t i = 0; i < Q; i++)
        {
            if (v[b[i]] - v[a[i]] == c[i])
                now += d[i];
        }
        chmax(ans, now);
        return;
    }
    for (size_t i = v.back(); i <= M; i++)
    {
        v.push_back(i);
        dfs(idx + 1);
        v.pop_back();
    }
}
int main()
{

    cin >> N >> M >> Q;

    vint emp(0);
    for (size_t i = 0; i < Q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        b[i]--;
        a[i]--;
    }
    dfs(0);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3644
int main(void) {

	int a = 0 ;
	int b = 0 ;
	int c = 0 ;
	int i = 0 ;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a > b){
		i = b ;
		b = a ;
		a = i ;
	}
	
	if(b > c){
		i = c ;
		c = b ;
		b = i ;
	}
	
	if(a > b){
		i = b ;
		b = a ;
		a = i ;
	}
	
	printf("%d %d %d\n",a,b,c);
		
		
	


	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	vector<int> x(5), v(5);
	int sum = 0;
	
	for(int i = 0; i < 5; ++i) {
		cin >> x[i];
		
		if( x[i] % 10 > 0 ) v[i] = x[i] + 10 - (x[i] % 10);
		else v[i] = x[i];
		
		sum += v[i];
	}
	
	int ans = MOD;
	
	for(int i = 0; i < 5; ++i) {
		sum -= v[i] - x[i];
		ans = min(ans, sum);
		sum += v[i] - x[i];
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    ll sm = 0;
    ll first;
    cin >> first;
    sm += (first-1);
    ll ba = 1;
    for (int i = 1; i < n; i++) {
        ll a;
        cin >> a;
        if (a <= ba) continue;
        if (a == ba+1) {
            ba++;
            continue;
        }
        sm += (a-1)/(ba+1);
    }
    cout << sm << endl;
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, temp;
    cin >> n;
    map<int, int> m;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        m.insert({temp, i+1});
    }
    for(auto it = m.begin(); it != m.end(); it++) {
        cout << it->second << " ";
    }
    return 0;
}


Measured memory_bytes: 5504
S = input()
S_length = len(S)
if S_length == 1:
  Ans = 1
else:
  Ans = S_length
  past = S[0]
  i = 1
  while i < S_length - 1:
    if S[i] != past:
      past = S[i]
      i = i + 1
    else:
      past = S[i]+S[i+1]
      i = i + 2
      Ans = Ans - 1
  
  if S[S_length - 1] == past:
    Ans = Ans - 1

print(Ans)

Measured memory_bytes: 3500
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N;
	scanf("%d", &N);
	int A[N];
	for(int i=0;i<N;i++){
		scanf("%d", &A[i]);
	}
	
	int max=0, tmp;
	for(int i=0;i<N-1;i++){
		for(int j=i+1;j<N;j++){
			tmp = abs(A[i] - A[j]);
			max = (tmp>max) ? tmp:max;
		}
	}
	printf("%d", max);
	
	return 0;
}

Measured memory_bytes: 128
// ITP1_3_B Print Test Cases
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  // 初期値
  int i = 0, data;
  
  // Main loop
  while(1){
    cin >> data;
    if (data == 0){
      break;
    }
    i++;
    cout << "Case " << i << ": " << data << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3032
///         Saniuzzaman Robin
///      CSE,Comilla University

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

typedef     long long int                ll;
typedef     unsigned long long int       ull;
typedef     vector< int >                vint;
typedef     vector< ll >                 vlong;
typedef     vector< vint >               vvint;
typedef     pair< int,int >              pint;
typedef     pair< ll, ll >               plong;
typedef     vector< pint >               vpi;
typedef     vector< plong >              vpli;

#define     dbl                 double
#define     pf                  printf
#define     sc                  scanf
#define     MAX                 1000007
#define     MOD                 1000000007
#define     PI                  2*acos(0.0)
#define     fast                ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define     all(a)              (a).begin(),(a).end()
#define     sz(x)               (int)x.size()
#define     pb                  push_back
#define     mp                  make_pair
#define     mem(a,b)            memset(a, b, sizeof(a) )
#define     gcd(a,b)            __gcd(a,b)
#define     lcm(a,b)            (a*(b/gcd(a,b)))
#define     ifor(x,n)           for( int i=x ; i<n ;i++)
#define     lfor(x,n)           for( long long int i=x; i<n; i++)

int main()
{

    ull n,k,cnt=0,one,two;
    cin>>n>>k;
    ll a[n+3];
    one=(k*(k+1))/2;
    two=(k*(k-1))/2;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }

    for(int i=0; i<n; i++)
    {
        int tmp=0,tmp2=0;
        for(int j=i+1; j<n; j++)
        {
            if(a[i]>a[j])
                tmp++;
        }
        for(int j=i-1; j>=0; j--)
        {
            if(a[i]>a[j])
                tmp2++;
        }
        cnt+=(((one)%MOD)*tmp);
        cnt%=MOD;
        cnt+=(((two)%MOD)*tmp2);
        cnt%=MOD;
    }
    cout<<cnt%MOD<<endl;

    return 0;
}


Measured memory_bytes: 256
import math
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i < K:
        r = -(-(math.log2(K) - math.log2(i))//1)
        ans += 0.5**r*(1/N)
    else:
        ans += 1/N
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(8);

    ll n;
    cin>>n;
    double ans=0.000000000;
    rep(i,n){
        double x;
        string s;
        cin>>x>>s;
        if(s=="BTC"){
            x *= 380000;
        }
        ans += x;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
s = gets.chomp
a = s.slice(0,2).to_i
b = s.slice(2,2).to_i
if (0<a && a<=12) && (0<b && b<=12)
  puts "AMBIGUOUS"
elsif (0<a && a<=12) && !(0<b && b<=12)
  puts "MMYY"
elsif !(0<a && a<=12) && (0<b && b<=12)
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)    (x).begin(),(x).end()
# define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
# define mp        make_pair
# define eb        emplace_back
# define REP       (i, a) for (int i = 0; i < (a); i++)
# define INIT      std::ios::sync_with_stdio(false);std::cin.tie(0);

int n, x;

int main() {
	INIT;
	cin >> n >> x;
	if (x == 1 || x == 2 * n - 1) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	int d = n - x;
	n += n - 1;
	for (int i = 0; i < n; i++) {
		cout << (i - d + n) % n + 1 << endl;
	}

}

Measured memory_bytes: 1536
//#pragma GCC optimize ("O3")
//#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

constexpr int bm = 2500;
ll BIT[50][bm];
int zero[50];
//priority_queue<ll> PQ;
const int AS = 5000;
class saidai_tekitou_heap {
public:
	int HS = 0;
	const ll IM = -8e18;
	ll dat[AS * 2 + 2];
	saidai_tekitou_heap() : dat() {
		dat[0] = -IM;
		rep1(i, AS * 2 + 1) dat[i] = IM;
	}
	void push(ll v) {
		int p = ++HS;
		while (v > dat[p >> 1]) dat[p] = dat[p >> 1], p >>= 1;
		dat[p] = v;
	}
	ll pop() {
		if (HS == 1) {
			HS = 0;
			return dat[1];
		}
		ll ret = dat[1];
		ll v = dat[HS];
		dat[HS--] = IM;
		int j = 2 + (dat[2] < dat[3]);
		while (v < dat[j]) {
			dat[j >> 1] = dat[j];
			j <<= 1;
			j += dat[j] < dat[j + 1];
		}
		dat[j >> 1] = v;
		return ret;
	}
} PQ;
inline ll query(int A, int gin) {
	ll kotae = 0;
	while (gin < bm) {
		kotae = max(BIT[A][gin], kotae);
		gin += gin & -gin;
	}
	return kotae;
}
inline void query2(int A, int gin, ll ti) {
	int tmp = gin;
	while (gin < bm) {
		if (BIT[A][gin] >= ti) return;
		gin += gin & -gin;
	}
	gin = tmp;
	while (gin > 0) {
		if (BIT[A][gin] >= ti) break;
		BIT[A][gin] = ti;
		gin -= gin & -gin;
	}
	PQ.push(ti << 18 | A << 12 | tmp);
}

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


	int N, M, S;
	cin >> N >> M >> S;
	if (S >= 2460) S = 2460;

	vector<ll> E[50];
	rep(i, M) {
		int u, v, a;
		ll b;
		cin >> u >> v >> a >> b;
		u--;
		v--;
		b = a << 8 | b << 16;
		E[u].pb(v | b);
		E[v].pb(u | b);
	}
	int C[50], D[50];
	rep(i, N) {
		cin >> C[i] >> D[i];
	}

	query2(0, S + 1, 4e12);
	ll zenbu = 0;
	ll owari = (1ll << N) - 1;

	while (PQ.HS) {
		auto p = PQ.pop();
		ll ti = p >> 18;
		int i = p >> 12 & 63;
		int gin = p & 4095;
		if (ti < query(i, gin)) continue;

		ll ti2 = ti - D[i];
		int gin2 = gin + C[i];
		if (gin2 > 2460) gin2 = 2460;
		query2(i, gin2, ti2);

		for (auto pp : E[i]) {
			int to = pp & 255;
			ti2 = ti - (pp >> 16);
			gin2 = gin - (pp >> 8 & 255);
			if (gin2 > 0) query2(to, gin2, ti2);
		}
		zenbu |= 1ll << i;
		if (zenbu == owari) break;
	}

	for (int i = 1; i < N; i++) {
		co(ll(4e12 - query(i, 1)));
	}



	Would you please return 0;
}

Measured memory_bytes: 4680
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";

//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes\n";
    else 
    cout<<"No\n";
}
}


Measured memory_bytes: 3612
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
Vi=[0] * N
for i in range(N):
    if i==0:
        Vi[i]=v[i]
    else:
        Vi[i]=Vi[i-1]+v[i]

# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0

for i in range(N):
    for j in range(Vi[i] + 1):
        # i+1番目を入れる場合vs入れない場合（前の段階から足し合わせることで価値がj以上になる場合）
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = dp[i][j]

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)

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

int main() {
  string s;
  cin >> s;
  if (s.at(0)==s.at(1)||s.at(0)==s.at(2)||s.at(1)==s.at(2))
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int n, x, y;
    int a, b, c;
    int ans;
    while(1){
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0){
            break;
        }
        ans = 0;
        y = x;
        if(y > n){
            y = n;
        }
        for(a = 1; a <= y; a++){
            for(b = a + 1; b <= y; b++){
                c = x - a - b;
                if(c > b && c <= n){
                    ans++;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}


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

const int INF = INT_MAX/3;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
    int n;cin>>n;
    vector<pii> p(n+1);
    for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second;

    vector<vi> mat(n+1,vi(n+1,INF));    //mat[i][j] : Mi*...*Mj???????°??????°
    for(int i=0;i<n;i++) mat[i][i] = 0;

    for(int sz=2;sz<=n;sz++){
        /*
         * mat[i][j] = min( mat[i][k]+mat[k+1][j]+Mi.first*Mk+1.first*Mk+1.second )
         */
        for(int i=0;i<=n-sz;i++){
            int j = i + sz - 1;

            for(int k=i;k<=j-1;k++){
                mat[i][j] = min(mat[i][j] , mat[i][k] + mat[k+1][j] + p[i].first * p[k+1].first * p[j].second);
            }
        }
    }
    cout << mat[0][n-1] << endl;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll a,b,c;
    cin >> a >> b >>c;
    if(c <= a + b + 1){
        cout << b + c << endl;
    }
    else{
        cout << a + 2 * b + 1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int X = Integer.parseInt(sc.next());
    ArrayList<Integer> list = new ArrayList<Integer>();
    list.add(X);
    for(int i=0;i<N;i++){
      list.add(Integer.parseInt(sc.next()));
    }
    list.sort((a,b)->a-b);
    int ans = 0;
    for(int i=0;i<list.size()-1;i++){
      if(ans == 0){
        ans = list.get(i+1)-list.get(i);
      }else{
        ans = gcd(ans,list.get(i+1)-list.get(i));
      }
    }
    System.out.println(ans);

  }
  static int gcd (int a, int b) {
  	int temp;
  	while((temp = a%b)!=0) {
  		a = b;
  		b = temp;
  	}
  	return b;
  }
}


Measured memory_bytes: 47848
x,n=gets.split.map &:to_i
if n == 0
  puts x
  exit 
end
p=gets.split.map &:to_i
zettai=999
ans=999
hash={}
[*(-100..200)].each do |i|
  next if p.include?(i)
  zettai = (x-i).abs
  hash[i]=(zettai)
end
puts hash.key(hash.values.min)


Measured memory_bytes: 14312
while true
    rateA,rateB,s = gets.split(" ").map(&:to_i)
    break if rateA ==0 && rateB == 0 && s == 0
    a=[]
    $roop = 1
    for i in 1..s/2
        sa = i*(100+rateA)/100
        (1..s-sa).to_a.reverse.each do |j|
            sb = j*(100+rateA)/100
            if sa + sb < s
                break
            end
            if sa + sb == s
                a.push([i,j])
                break
            end
        end
        break if $roop == 0
    end
    maximum = 0
    for i in 0..a.length-1
        b = [maximum, a[i][0]*(100+rateB)/100 + a[i][1]*(100+rateB)/100]
        maximum = b.max
    end
    puts(maximum)
end

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

int main() {
  int h, w;
  cin >> h >> w;

  string G[h];
  for (int i = 0; i < h; i++) cin >> G[i];

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

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (G[i][j] == '#') continue;

      int n = 0;
      for (int d = 0; d < 8; d++) {
        if (i + dx[d] < 0 || h < i + dx[d]) continue;
        if (j + dy[d] < 0 || w < j + dy[d]) continue;
        if (G[i + dx[d]][j + dy[d]] == '#') n++;
      }
      G[i][j] = static_cast<char>(n + '0');
    }
  }

  for (int i = 0; i < h; i++) cout << G[i] << endl;
}


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


using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から
#define REP(i,N) for(int j=i;j<N;j++) //iから

typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

#define MOD ((ll)1e+7 + 9)



//cout<<fixed<<setprecision(10);
int main(){
    ll n,k;
    cin>>n>>k;

    vector<ll> cnt(n,0);
    ll p,m=0;;
    rep(i,n){
        p=i+1;
        while(p<k){
            p*=2;
            cnt[i]++;
        }
        m=max(m,cnt[i]);
    }
    p=0;
    rep(i,n){
        p+=pow(2,m-cnt[i]);
    }
    n*=pow(2,m);
    cout<<fixed<<setprecision(10);
    double ans=(double)p / (double)n;
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 4156
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;

int h,w;
char s[101][101];
int dist[101][101];

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

int bfs(){
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++)dist[i][j] = -1;
    }
    
    queue<P> que;
    que.push(P(0,0));
    dist[0][0] = 1;
    
    
    while(!que.empty()){
        P p = que.front();
        que.pop();
        
        for(int i = 0;i < 4;i++){
            int nx = dx[i]+p.second,ny = dy[i]+p.first;
            
            if(s[ny][nx] == '#')continue;
            if(dist[ny][nx] != -1)continue;
            if(0 > nx || nx >= w || 0 > ny || ny >= h)continue;
            
            dist[ny][nx] = dist[p.first][p.second] + 1;
            
            que.push(P(ny,nx));
        }
    }
    
    return dist[h-1][w-1];
}

int main(void){
    cin >> h >> w;
    for(int i = 0;i < h;i++)cin >> s[i];
    
    int black = 0,white = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(s[i][j] == '#')black++;
            else white++;
        }
    }
    
    int alina = bfs();
    if(alina == -1)cout << -1 << endl;
    else cout << white - alina << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/
int N,D,X;
int A[100];
/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    scanf("%d %d %d",&N,&D,&X);
    for(int i = 0;i < N;i++) scanf("%d",A + i);
    for(int i = 0;i < N;i++) X += 1 + (D - 1)/A[i];
    printf("%d",X);
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> px(n), py(n);
    for (int i = 0; i < n; i++)
        cin >> px[i] >> py[i];

    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i == j)
                continue;
            cnt[{px[j] - px[i], py[j] - py[i]}]++;
        }
    }

    int maxVal = 0;
    for (auto elem: cnt)
        maxVal = max(maxVal, elem.second);

    cout << (1 + (n - 1 - maxVal)) << endl;
}


Measured memory_bytes: 384
A = (1..N=gets.to_i).map {gets.split.map &:to_i}
l=t=s = 0
A.each {|a|
  a[l] += s - d=t
  a.each.with_index {|v,i|
    v += d
    if v > s
      if v > t
        s,t,l = t,v,i
      else
        s = v
      end
    end
  }
}
p t

Measured memory_bytes: 11004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;




int main()
{
    int N,M;
    cin >> N >> M;
    vi S(N),T(M);
    in(N,S);in(M,T);
    
    ve<vl> dp(N+1,vl(M+1,0));
    
    rep(i,N){
        reps(j,1,M+1){
            
            if(S[i] == T[j-1]){
                dp[i+1][j] = dp[i+1][j-1] + dp[i][j-1] + 1 + (mod+dp[i][j]-dp[i][j-1])%mod;
            }else{
                dp[i+1][j] = dp[i+1][j-1] + (mod+dp[i][j]-dp[i][j-1])%mod;
            }

            dp[i+1][j] %= mod;
        }
    }
    //outmat(dp);
    cout << (dp[N][M]+1)%mod << endl;
    

    
    
    
    

    return 0;
}


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

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int L, R, d; cin >> L >> R >> d;
	int ans = 0;

	for (int i = L; i <= R; i++)if (i % d == 0)ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
	    int input = scanner.nextInt();

	    int odd = 0;
	    for (int i=1; i<=input; i++) {
		    if (i % 2 != 0) odd++;
	    }
	    double answer = (double) odd /input;
	    System.out.println(String.format("%.10f", answer));
	    scanner.close();
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll const mod=1e9+7;
double const pi=acos(-1); 
int main()
{
   	ll sum=100;
   	ll n;
   	cin>>n;
   	ll s=0;
   	while(sum<n)
   	{
   		sum+=sum*0.01;
   		s++;
	}
	cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <iomanip>
#include <map>
#include <cstdio>
#include <sstream>
#define ll long long
#define ld long long double
using namespace std;

int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);   cout.tie(NULL);
   int n,m;
   cin >> n >> m;

   (m>=n) ?
      cout << "Yes\n":cout << "No\n";
}
/* 


*/

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 998244353;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, s; cin >> n >> s;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vvll dp(n + 1, vll(s + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            (dp[i + 1][j] += 2 * dp[i][j] % MOD) %= MOD;
            if (j + a[i] <= s) (dp[i + 1][j + a[i]] += dp[i][j]) %= MOD;
        }
    }
    // for (int i = 0; i <= n; i++) DEBUG_VLL(dp[i])
    cout << dp[n][s] << '\n';
    return 0;
}


Measured memory_bytes: 73668
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
int MOD=1000000007;int inf=MOD*MOD;
int n,k;
int a[20];
int calc(vector<bool> const& status){
    int num=0;
    rep(i,n){
        if(status[i])num++;
    }
    if(num<k)return inf;
    int res=0;
    int last=a[0];
    rep1(i,n-1){
        if(status[i]){
            res+=max((int)0,last-a[i]+1);
            last=max(last+1,a[i]);
        }
        if(last<a[i]){
            last=a[i];
        }
    }
    return res;
}
int solve(vector<bool> status,int cur){
    if(cur==n)return calc(status);
    else{
        int res=solve(status,cur+1);
        status[cur]=true;
        res=min(res,solve(status,cur+1));
        return res;
    }
}
signed main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    vector<bool> status(n,false);
    status[0]=true;
    int res=solve(status,1);
    cout<<res<<endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    if(s == "SAT") cout << 1 << endl;
    else if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    
    return 0;

}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ksm(int a,int b,int mod){
    if(b==0)return 1;
    if(b==1)return a%mod;
    ll ans=ksm(a,b/2,mod);
    ans*=ans;
    ans%=mod;
    if(b%2)ans*=a,ans%=mod;
    return ans;
}
#define mod 1000000007
int n;
bool prime[1000001];
int a[1010];
int f1[1000001];
int main(){
    cin>>n;/*
    for(int i=2;i<=1000000;i++){
        if(!prime[i]){
            for(int j=i+i;j<=1000000;j+=i){
                prime[j]=1;
            }
        }
    }*/
    for(int i=0;i<n;i++){
        cin>>a[i];
        int x=a[i],xx=a[i];
        for(int k=2;k*k<=xx;k++){
            int c=0;
            while(x%k==0){
                c++;
                x/=k;
            }
            f1[k]=max(f1[k],c);
        }
        if(x!=1)f1[x]=max(f1[x],1);
    }
    ll x=1;
    for(int i=2;i<1000000;i++){
        x*=ksm(i,f1[i],mod);
        x%=mod;
    }
    ll s=0;
    for(int i=0;i<n;i++){
        s+=ksm(a[i],mod-2,mod);
        s%=mod;
    }
    ll ans=x*s%mod;
    cout<<ans<<endl;
    return 0;
}

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

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;

#define rep(idx, N) for (u64 idx = 0; idx < N; idx++)

int main() {
  i32 k;
  cin >> k;

  u64 ans = 0;
  rep(a, k) {
    rep(b, k) {
      rep(c, k) { ans += gcd(a+1, gcd(b+1, c+1)); }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3616
r,c=map(int,input().split())
tbl=[[0 for i in range(c+1)] for j in range(r+1)]
for i in range(r):
    a = list(map(int,input().split()))
    a_1 = len(a)
    b = 0
    for j in range(a_1):
        tbl[i][j] = a[j]
        b += a[j]
    tbl[i][c] = b
for k in range(c+1):
    d = 0
    for l in range(r):
        d += tbl[l][k]
    tbl[r][k] = d
for m in tbl:
    print(*m)


Measured memory_bytes: 6224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	while(cin >> s){
		bool f = true;
		for(int i = 0; i < s.size(); i++){
			if( i % 2 == 0 ){
//				cout << s[i] << " " << i << endl;
				if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
					f = false;
					break;			
				}				
			}
			else if(i % 2 != 0){
				if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){	
					f = false;
					break;					
				}				
			}		
		}
		if(f) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

map<int, int> getPrimeFactors(int a) {
    map<int, int> s;
    for (int i = 2; i * i <= a; i++) {
        if (a % i != 0) continue;
        while (a % i == 0) {
            s[i]++;
            a /= i;
        }
    }
    if (a > 1) s[a]++;
    return s;
}

class DDivGame {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;

        vector<int> sum(101,  0);
        FOR(i, 1, 100) sum[i] = sum[i-1] + i;

        auto m = getPrimeFactors(N);

        int res = 0;
        for (auto kv : m) {
            int num = kv.second;
            res += upper_bound(sum.begin(), sum.end(), num) - sum.begin() - 1;
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    DDivGame solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
struct node{
	int x;
	int y;
};
bool visit[2001];
int times;
int n;
int k;
node p[2001];
vector<int> can[2001];
int work1(int mp)
{
	int tot=0;
	queue<node> q;
	node start;
	start.x=mp;
	start.y=0;
	q.push(start);
	visit[mp]=0;
	while(!q.empty())
	{
		node now=q.front();
		q.pop();
		for(int i=0;i<can[now.x].size();i++)
		{
			int ok=can[now.x][i];
			if(visit[ok])
			{
				node next;
				next.x=ok;
				next.y=now.y+1;
				q.push(next);
				if(next.y>k/2)
				{
					tot++;
				}
				visit[ok]=0;
			}
		}
	}
	return tot;
}
inline int work2(int mp1,int mp2,int str)
{
	int tot=0;
	queue<node> q;
	node start;
	start.x=mp1;
	start.y=0;
	q.push(start);
	visit[mp1]=0;
	visit[mp2]=0;
	while(!q.empty())
	{
		node now=q.front();
		q.pop();
		for(int i=0;i<can[now.x].size();i++)
		{
			int ok=can[now.x][i];
			if(visit[ok])
			{
				node next;
				next.x=ok;
				next.y=now.y+1;
				q.push(next);
				if(next.y>(k-1)/2)
				{
					tot++;
				}
				visit[ok]=0;
			}
		}
	}
	start.x=mp2;
	start.y=0;
	q.push(start);
	while(!q.empty())
	{
		node now=q.front();
		q.pop();
		for(int i=0;i<can[now.x].size();i++)
		{
			int ok=can[now.x][i];
			if(visit[ok])
			{
				node next;
				next.x=ok;
				next.y=now.y+1;
				q.push(next);
				if(next.y>(k-1)/2)
				{
					tot++;
				}
				visit[ok]=0;
			}
		}
	}
	return tot;
}
int main()
{
//	freopen("some.txt","r",stdin);
	cin>>n>>k;
	for(int i=1;i<=n-1;i++)
	{
		cin>>p[i].x>>p[i].y;
		can[p[i].x].pb(p[i].y);
		can[p[i].y].pb(p[i].x);
	}
	int cnt=1<<30;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			memset(visit,1,sizeof(visit));
			cnt=min(work1(i),cnt);
		}
	}
	else
	{
		for(int i=1;i<=n-1;i++)
		{
//			times++;
			memset(visit,1,sizeof(visit));
			cnt=min(work2(p[i].x,p[i].y,i),cnt);
		}
	}
	cout<<cnt<<endl;
	//cout<<times<<endl;
	return 0;
}

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

int main() {
  int A ,B ,C ,D;
  cin >> A >> B >> C >> D;
  
  if ( A+B > C+D) {
    cout << "Left" << endl;
  }
  else if ( A+B == C+D ){
    cout << "Balanced" << endl;
  }
  else {
  cout << "Right" << endl;
  }
}
 


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

using namespace std;
string e = "E869120";
int main(){
	int i,n,c = 0;
	cin >> n;
	for(i=0;i<n;i++){
		string s; cin >> s;
		if(s==e) c++;
	}
	cout << c << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    int r, g;
    cin >> r >> g;

    cout << g + (g - r) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;
struct union_find{
    vector<int> par; 
    //1からnまで初期化:par[i] = i(1<=i<=n)
    union_find(int n){
        par.push_back(0);
        for(int i = 1;i<=n;i++){
            par.push_back(i);
        }
    }
    int root(int a){
        if (par[a] == a) return a;
        par[a] = root(par[a]);
        return root(par[a]);
    }
    void unite(int a,int b){
        if (root(a) == root(b)) return;
        par[root(a)] = root(b);
    }
    bool same(int a,int b){
        return (root(a) == root(b));
    }
};
int main(){
    long long n,m;
    cin >> n >> m;
    long long a[m],b[m];
    for(int i = 0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    long long ans[m];
    ans[m-1] = n*(n-1)/2;
    union_find tree(n);
    map<long long,long long> mp;
    for(int i = 1;i<=n;i++){
        mp[i] = 1;
    }
    for(int i = m-2;i>=0;i--){
        if(!tree.same(a[i+1],b[i+1])){
            ans[i] = ans[i+1]-(mp[tree.root(a[i+1])]*mp[tree.root(b[i+1])]);
            mp[tree.root(b[i+1])]+=mp[tree.root(a[i+1])];
        }
        else{
            ans[i] = ans[i+1];
        }
        tree.unite(a[i+1],b[i+1]);
    }
    for(int i = 0;i<m;i++){
        cout << ans[i] << endl;
    }
}

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

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

    int64_t result = 0;

    for (int plus = 0; plus < (1 << (N - 1)); plus++) {
        //cout << "case : plus = " << plus << endl;
        vector<int> s_divided(0);
        int prev_i = -1;

        for (int i = 0; i < N; i++) {
            if (plus & (1 << i)) {
                string temp = s.substr(prev_i + 1, i - prev_i);
                prev_i = i;
                s_divided.push_back(stoi(temp));
            }
        }
        
        if (N == 10 && plus == 0) {
            const char *strnum = s.c_str();
            long num = strtol(strnum, NULL, 10); 
            //cout << "   added " << num << " to result" << endl;
            result += num;
        } else {
            string last_num = s.substr(prev_i + 1, N - prev_i - 1);
            s_divided.push_back(stoi(last_num));
        }

        for (int s_nums : s_divided) {
            //cout << "   added " << s_nums << " to result" << endl;
            result += s_nums;
        }
    }

    cout << result << endl;

    return 0;
}

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

using namespace std;

#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).begin(), container.end()
#define sz(container)      (int) (container).size()

using ll = long long;

#ifdef LOCAL_DEFINE
    #include "DEBUG.hpp"
#else
    #define debug(...) 0
#endif
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i + 2 < n; i++) {
        string temp = s.substr(i, 3);
        debug(temp);
        if (temp == "ABC")
            ++ans;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double mi[200001],ma[200001];
int main(){
	int n,i;
	cin>>n;
	for(i=1;i<=n;++i)cin>>mi[i]>>ma[i];
	sort(mi+1,mi+n+1);
	sort(ma+1,ma+n+1);
	if(n&1){
		int a=mi[n+1>>1],b=ma[n+1>>1];
		cout<<b-a+1;
	}else{
		double a=(mi[n>>1]+mi[n+2>>1])/2.0,b=(ma[n>>1]+ma[n+2>>1])/2.0;
		int c=(b-a)*2+1;
		cout<<c;
	}
} 

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

int N;
const int MAX_N = 200 + 100;
int A[MAX_N];

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

    int ans = 1.0e9;
    for (int i = 0; i < N; i++) {
        int cnt = 0;
        while (A[i] % 2 == 0) {
            A[i] /= 2;
            cnt++;
        }

        ans = min(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int digit(int N) {
    if(N == 0) return 1;
    int ans = 0;
    while(N) {
        ans++;
        N /= 10;
    }
    return ans;
}

vector<int> get_vec(int N) {
    if(N == 0) return vector<int>(1, 0);
    vector<int> ans;
    while(N) {
        ans.emplace_back(N % 10);
        N /= 10;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

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

    vector<int> s(M), c(M);
    for(int i=0; i<M; i++) cin >> s[i] >> c[i], s[i]--;

    int ans = -1;
    for(int i=0; i<=100000; i++) {
        int d = digit(i);
        if(d != N) continue;
        vector<int> a = get_vec(i);

        bool ok = true;
        for(int k=0; k<M; k++) {
            ok &= (a[ s[k] ] == c[k]);
        }
        if(ok) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
const int maxn=2010;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
int n,z,w,a[maxn];
template<typename T>
inline ll ab(T x)
{
	if(x<0) x*=-1;
	return x;
}
int main()
{
	n=read(),z=read(),w=read();
	for(int i=1;i<=n;i++) a[i]=read();
	if(n==1) return cout<<ab(a[1]-w)<<endl,0;
	printf("%lld\n",max(1LL*ab((ll)a[n]-w),1LL*ab((ll)a[n-1]-a[n])));
	return 0;
}

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

int main(void)
{
  int a[3];
  int cost, buf ,i;

  scanf("%d %d%d",&a[0],&a[1],&a[2]);

  cost = (abs(a[0]-a[1]) + abs(a[1]-a[2]));

  for(i = 1; i <= 2; i++){
    if(cost > (buf = (abs(a[i]-a[(i+1)%3]) + abs(a[(i+1)%3]-a[(i+2)%3]))))
      cost = buf;
  }

  for(i = 0; i <= 2; i++){
    if(cost > (buf = (abs(a[i]-a[(i+2)%3]) + abs(a[(i+2)%3]-a[(i+1)%3]))))
      cost = buf;
  }

  printf("%d\n", cost);

  return(0);
}


Measured memory_bytes: 128
Q=int(input())

def isprime(x):
    if x == 1:
        return False
    if x == 2:
        return True
    for i in range(2, int(x**0.5) + 1):
        if x % i == 0:
            return False
    return True

nmax = 10**5+1
like = [False]*nmax
for n in range(1,nmax,2):
    if isprime(n) and isprime((n+1)//2):
        like[n]=True

rui = [0]*nmax
rui[0]=int(like[0])
for i in range(1,nmax):
    rui[i] = rui[i-1]+like[i]

for i in range(Q):
    l,r = map(int,input().split())
    print(rui[r]-rui[l-1])

Measured memory_bytes: 79180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
const int MAX=2e5;

int main(){
	int N,M;
	cin>>N>>M;
	int x[MAX],y[MAX];
	rep(j,M) cin>>x[j]>>y[j];
	
	int c[MAX+1];
	bool r[MAX+1];
	rep1(i,N){
		c[i]=1;
		r[i]=false;
	}
	r[1]=true;
	
	rep(j,M){
		c[x[j]]--;
		c[y[j]]++;
		if(r[x[j]]) r[y[j]]=true;
		if(c[x[j]]==0) r[x[j]]=false;
	}
	
	int ans=0;
	rep1(i,N)if(r[i])ans++;
	cout<<ans;
}

Measured memory_bytes: 2432
use std::cmp::min;

fn main() {
    let abck = read_vec::<i64>();
    let mut k = abck[3];
    let mut ret = 0;

    let mi = min(k, abck[0]);
    ret += mi;
    k -= mi;
    let mi = min(k, abck[1]);
    k -= mi;
    let mi = min(k, abck[2]);
    ret -= mi;
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define int long long

int32_t main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	vector<int> v(n+1);
	for(int i=1; i<=n; i++)cin>>v[i];
	vector<int> dp(n+1,INT_MAX);
	dp[1]=0;
	
	for(int i=2; i<=n; i++){
	    for(int j = i-1; j>=1&&(i-j)<=k; j--)
	    dp[i]=min(dp[j]+abs(v[i]-v[j]), dp[i]);
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 1792