akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
using namespace std;
int main() {
	int n = 0;
	unsigned long long int  a, b, x[100000], ans = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n - 1; i++) {
		if ((x[i + 1] - x[i])*a < b)
			ans += (x[i + 1] - x[i])*a;
		else
			ans += b;
	}
	cout << ans << endl;

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[201][201];
LL dp2[201][201][201];
LL f(LL a, LL b, LL c){
  LL& res = dp2[a][b][c];
  if(res >= 0) return res;
  
  if(a < 0 || b < 0 || c < 0 || a+b < c) return res = 0;
  if(a == 0)
	return res = (b == c? 1: 0);
  if(b == 0)
	return res = (a == c? 1: 0);
  if(c == 0)
	return res = (a+b == 0? 1: 0);

  res = (f(a-1, b, c-1) + f(a, b-1, c-1) + f(a-1, b-1, c-1)) % MOD;
  return res;
}

int sz[201];
void dfs(int u, VVI& G){
  if(G[u].empty()){
	sz[u] = 1;
	dp[u][1] = 1;
	return;
  }

  dfs(G[u][0], G);
  sz[u] = sz[G[u][0]];
  REP(i,sz[u]+1)
	dp[u][i] = dp[G[u][0]][i];

  FOR(i,1,SZ(G[u])){
	int to = G[u][i];
	dfs(to, G);
	VL tmp(sz[u]+sz[to]+1);
	FOR(c,1,sz[u]+sz[to]+1){
	  FOR(a,max(1,c-sz[to]),sz[u]+1){
		FOR(b,max(1,c-a),sz[to]+1)
		  (tmp[c] += dp[u][a] * dp[to][b] % MOD * f(a, b, c) % MOD) %= MOD;
	  }
	}
	sz[u] += sz[to];
	REP(i,sz[u]+1)
	  dp[u][i] = tmp[i];
  }
  ++sz[u];
  for(int i=sz[u];i>0;--i)
	dp[u][i] = dp[u][i-1];
}

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

  fill((LL*)dp2, (LL*)dp2+201*201*201, -1);

  int N;
  cin >> N;
  VVI G(N);
  VI in(N);
  REP(i,N-1){
	int u, v;
	cin >> u >> v;
	G[u].PB(v);
	in[v]++;
  }
  int rt = -1;
  REP(i,N) if(in[i] == 0) rt = i;
  dfs(rt, G);
  LL ans = 0;
  REP(i,N+1) (ans += dp[rt][i]) %= MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 66928
const main = function(arg) {
    var input = arg.trim().split(" ");
    var a = parseInt(input[0])
    var b = parseInt(input[1])
    
    if((a * b)%2 == 0){
        console.log("Even")
    }else {
        console.log("Odd")
    }
}

main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod;return *this;}
mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod;return *this;}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

ll h,w;
int seen[55][55];
vec<string> f;
bool ok = true;

void solve(ll y,ll x){
    int cnt = 0;
    rep(dir,4){
        ll ny = y + dy[dir];
        ll nx = x + dx[dir];
        if(ny<0||ny>=h||nx<0||nx>=w)continue;
        if(f[ny][nx]=='#') cnt++;
    }
    if(cnt==0) ok=false;
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   
    cin>>h>>w;
    f.resize(h);
    deque<pint> q;
    rep(i,h){
        cin>>f[i];
        rep(j,w){
            if(f[i][j]=='#') q.push_back({i,j});
        }
    }

    for(auto e:q){
        solve(e.fi,e.se);
    }

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

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
   int n;
   string s,t;
   cin >> n >> s>>t;
   rep(i,n) {
       cout << s[i]<<t[i] << flush;
   }
   cout << "" << endl;

  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

string S;
int ans;

int main(){
	cin >> S;
	if (S == "SUN"){
		ans = 7;
	}
	else if (S == "MON"){
		ans = 6;
	}
	else if (S == "TUE"){
		ans = 5;
	}
	else if (S == "WED"){
		ans = 4;
	}
	else if (S == "THU"){
		ans = 3;
	}
	else if (S == "FRI"){
		ans = 2;
	}
	else if (S == "SAT"){
		ans = 1;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int con = 0;
	
	cin>>N;
	
	
	for(int i = 0; i < N; i++){
		string s;
		
		cin>>s;
		
		if( s == "E869120") con++;
	}
	
	cout<<con<<endl;
	
	return 0;
}


Measured memory_bytes: 3228
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse4,avx,avx2")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <chrono>
#include <random>
#include <string>
#include <queue>
#include <tuple>
#include <unordered_map>
#include <sstream>
#include <numeric>
#include <complex>
#include <immintrin.h>
#include <unordered_set>

using namespace std;

using ll = long long;
using ld = long double;
using VectorType = ld;
using ull = unsigned long long;

const ll INF = 1e15;
const ld eps = 1e-7;
const ld pi = atan2(0, -1);
const ll mod = 1e9 + 7;
const ll P = 179, Q = 239;
const ll A = 26;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

ll sign(ll a) {
	if (a < 0) return -1;
	if (a == 0) return 0;
	return 1;
}

bool equal(ld a, ld b) {
	return abs(a - b) < eps;
}

struct query {
	ll l, r, i;

	query(ll l = 0, ll r = 0, ll i = 0) : l(l), r(r), i(i) {};
};

bool mini(ll &a, ll b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

bool maxi(ll &a, ll b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool mini(ld &a, ld b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

ll mmax(ll a, ll b) {
	if (a > b) return a;
	return b;
}

ll mmin(ll a, ll b) {
	if (a < b) return a;
	return b;
}

ld mmax(ld a, ld b) {
	if (a > b) return a;
	return b;
}

ld mmin(ld a, ld b) {
	if (a < b) return a;
	return b;
}

bool maxi(ld &a, ld b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

ll sub(ll a, ll b) {
	a -= b;
	if (a < 0) {
		a += mod;
	}
	return a;
}

ll add(ll a, ll b) {
	a += b;
	if (a > mod) {
		a -= mod;
	}
	return a;
}

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

ll n, m;
ll k;
vector <vector <ll>> vec;
vector <bool> used;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> k >> n;
	vector <ll> a(n);
	for (auto &x : a) {
		cin >> x;
	}
	ll maxdiff = 0;
	for (int i = 1; i < n; ++i) {
		maxi(maxdiff, a[i] - a[i - 1]);
	}
	maxi(maxdiff, a[0] + k - a[n - 1]);
	cout << k - maxdiff;
	return 0;
}

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

int ROW_INDEX = 1;
//[min_range, max_range]からn_ints個の整数の組をすべてとりだしcomb[組][整数]に格納する
void AllCombs_ints(int min_range, int max_range, int depth, int n_ints, int **comb){
	if(depth > 0){
		for(int x = min_range; x <= max_range; x++){
			//comb[0]を一時的な格納場所として使っている。気持ち悪い。
			comb[0][depth-1] = x;
			if(depth == 1){
				for(int num_i = 1; num_i <= n_ints; num_i++)
					comb[ROW_INDEX][num_i-1] = comb[0][n_ints-num_i];
				ROW_INDEX++;
			}
			AllCombs_ints(x + 1, max_range, depth - 1, n_ints, comb);
		}
	}
	if(depth == n_ints)
		ROW_INDEX = 1;
}
long int Factorial(int upto){
	if(upto == 0)
		return 1;
	return upto * Factorial(upto-1);
}
int main(){
	int N, M, X;
	scanf("%d %d %d", &N, &M, &X);
	long int A[N][M], C[N], cost = 0, count = 0, skill[M], total_cost = 0, total_skill[M];
	for(int i = 0; i < N; i++){
		scanf("%ld", &C[i]);
		for(int j = 0; j < M; j++){
			scanf("%ld", &A[i][j]);
			skill[j] = 0;
			total_skill[j] = 0;
		}
	}
	for(int i = 0; i < N; i++){
		total_cost += C[i];
		for(int col_i = 0; col_i < M; col_i++){
			total_skill[col_i] += A[i][col_i];
		}
	}
	for(int col_i = 0; col_i < M; col_i++)
		if(total_skill[col_i] >= X)
			count++;
	if(count < M)
		printf("%d", -1);
	else{
		count = 0;
		int **pt_ints;
		long int ans = total_cost;
		for(int n = 1; n <= N; n++){
			long int n_comb = Factorial(N) / Factorial(n) / Factorial(N - n);
			pt_ints = (int **) malloc(sizeof(int *) * (n_comb+1));
			for(int comb_i = 0; comb_i <= n_comb; comb_i++){
				pt_ints[comb_i] = (int *) malloc(sizeof(int) * n);
			}
			AllCombs_ints(1, N, n, n, pt_ints);
			for(int comb_i = 1; comb_i <= n_comb; comb_i++){
				long int ans_temp = 0;
				for(int num_i = 0; num_i < n; num_i++){
					cost += C[pt_ints[comb_i][num_i]-1];
					for(int col_i = 0; col_i < M; col_i++){
						skill[col_i] += A[pt_ints[comb_i][num_i]-1][col_i];
					} 
				}
				for(int col_i = 0; col_i < M; col_i++)
					if(skill[col_i] >= X)
						count++;
				if(count == M && cost < ans)
					ans = cost;
				cost = 0;
				count = 0;
              for(int col_i = 0; col_i < M; col_i++)
                skill[col_i] = 0;
			}
		}
      printf("%ld", ans);
	}
	return 0;
}

Measured memory_bytes: 1920
// one  element
#include <bits/stdc++.h>

using namespace std;

#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define vb vector<bool>
#define mii map<int,int>
#define swap(a,b) int c=a;a=b;b=c;
// min max heap
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >

#define gcd(x,y) __gcd(x,y)

#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x) // count zeros before first one
#define mod 1000000007
#define inf 1e18
#define fl(i,start,end) for(int i=start;i<=end;i++)
#define input(arr,start,end) for(int i=start;i<=end;i++) cin>>arr[i];
#define printArray(arr,start,last) for(int i=start;i<=last;i++) cout<<arr[i]<<" ";cout<<endl;
// set precesion
#define ps(x,y) fixed<<setprecision(y)<<x

#define mk(arr,n,type) type *arr=new type[n];
#define w(x) int x;cin>>x; while(x--)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long int  N = 1000007;
vector<ll> primes;
const long int modl = 1e9 + 7;
vi graph[1000];

pii ext_eucl(int a, int b) {
	if (b == 0)
		return make_pair(1, b);

	pii pr = ext_eucl(b, a % b);
	return make_pair(pr.ss, pr.ff - (a / b) * pr.ss);
}

ll power(ll x, ll y, ll p = modl) {
	ll res = 1;
	x = x % p;
	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

// shuffle(arr,arr+n,rng)
// shuffler
// w(t) {

// 	mk(arr, 5, int);
// 	for (int i = 0; i < 5; ++i)
// 	{
// 		cin >> arr[i];
// 	}

// 	shuffle(arr, arr + 5, rng);

// 	for (int i = 0; i < 5; ++i)
// 	{
// 		/* code */
// 		cout << arr[i] << " ";
// 	}
// }


void c_p_c() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}


void printAdjacencyList(int n) {
	for (int i = 1; i <= n; i++) {
		cout << i << " : ";
		for (int child : graph[i]) {
			cout << child << " ";
		}
		cout << endl;
	}
}

void solve() {
	long int n, c;
	cin >> n >> c;

	long int w[n], v[n];

	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	long int ans[n + 1][c + 1];

	for (long int i = 0; i <= c; i++) ans[0][i] = 0;
	for (long int i = 0; i <= n; i++) ans[i][0] = 0;

	for (long int i = 1; i <= c; i++) {
		for (long int j = 1; j <= n; j++) {
			ans[j][i] = ans[j - 1][i];
			if ((i >= w[j - 1])) {
				ans[j][i] = max(ans[j][i], ans[j - 1][i - w[j - 1]] + v[j - 1]);
			}
		}
	}

	cout << ans[n][c] << endl;
}

int32_t main() {
	solve();

	return 0;
}

Measured memory_bytes: 82408
from collections import Counter as c
N = int(input())
S = list(input() for _ in range(N))
S.sort()
C, i = c(S).most_common(), 0
l, n = len(C), C[0][1]
while i < l:
  if n == C[i][1]: print(C[i][0])
  else: break
  i += 1

Measured memory_bytes: 49444
sx, sy, tx, ty = map(int, input().split())
ans = ""
for i in range(sx, tx):
    ans += "R"
for i in range(sy, ty):
    ans += "U"
for i in range(sx, tx):
    ans += "L"
for i in range(sy, ty):
    ans += "D"
ans += "L"
for i in range(sy, ty+1):
    ans += "U"
for i in range(sx, tx+1):
    ans += "R"
ans += "D"
ans += "R"
for i in range(sy, ty+1):
    ans += "D"
for i in range(sx, tx+1):
    ans += "L"
ans += "U"
print(ans)


Measured memory_bytes: 3064
import collections as co
if __name__ == '__main__':

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

	S = A[1::2]
	T = A[0::2]

	total_cnt = 0

	#全体をチェック
	U = set(A)
	if len(U) == 1:
		total_cnt = len(A[1::2])
		print(total_cnt)
		exit()

	c1 = []
	c2 = []
	#奇数列をチェック
	s = co.Counter(S)
	c1 = s.most_common()
	#これが秘策
	c1.append((0,0))
	#偶数列をチェック
	t = co.Counter(T)
	c2 = t.most_common()
	#これが秘策
	c2.append((0,0))


	#チェック
	#最頻値が異なるなら
	if c1[0][0] != c2[0][0]:
		#それ以外の数を総カウント-1
		total_cnt = len(S) - c1[0][1] 
		total_cnt += len(T) - c2[0][1]
	else:
		#最頻値が同じならその数が同じか？
		if c1[0][1] > c2[0][1]:
			total_cnt = len(S) - c1[0][1]
			total_cnt += len(T) - c2[1][1]
		elif c1[0][1] < c2[0][1]:
			total_cnt = len(S) - c1[1][1]
			total_cnt += len(T) - c2[0][1]
		else:
			#同じ場合、２番目の数値を比較して取り換え
			if c1[1][1] > c2[0][1]:
				total_cnt = len(S) - c1[1][1]
				total_cnt += len(T) - c2[0][1]
			elif c1[1][1] < c2[1][1]:
				total_cnt = len(T) - c2[1][1]
				total_cnt += len(S) - c1[0][1]
			else:
				#どちらでもよい
				total_cnt = len(S) - c1[1][1]
				total_cnt += len(T) - c2[0][1]
				
	print(total_cnt)



Measured memory_bytes: 32340
n,m = map(int,input().split(" "))
alist = []
blist = []
for _ in range(n):
    anew = list(map(int,input().split(" ")))
    alist.append(anew)
for _ in range(m):
    bnew = int(input())
    blist.append(bnew)
sums = 0
for i in range(n):
    for j in range(m):
        sums += alist[i][j] * blist[j]
    print(sums)
    sums = 0


Measured memory_bytes: 6016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;



int main(){

char s[5];
rep(i,4)cin >> s[i];
if(s[0]==s[1] and s[1]==s[2])cout << "Yes" << endl;
else if(s[1]==s[2] and s[2]==s[3])cout << "Yes" << endl;
else cout << "No" << endl;


return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int LEN = 55556;

int main()
{
    int n;
    cin >> n;
    vector<bool> isPrime(LEN, true);
    vector<int> Prime;
    vector<int> PrimeAndOne;
    for (auto i = 2; i * i <= LEN; i++)
    {
        for (auto j = i + 1; j < LEN; j++)
        {
            if (j % i == 0)
            {
                isPrime[j] = false;
            }
        }
    }

    for (auto i = 2; i < LEN; i++)
    {
        if (isPrime[i])
        {
            Prime.push_back(i);
        }
    }

    for (auto i = 0; i < Prime.size(); i++)
    {
        if (Prime[i] % 5 == 1)
        {
            PrimeAndOne.push_back(Prime[i]);
        }
    }

    for (auto i = 0; i < n; i++)
    {
        cout << PrimeAndOne[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc080/tasks/abc080_b
"use strict";
function Main(input) {
  const X = Number(input);
  const sum = input.split("").reduce((acc, cur) => Number(acc) + Number(cur), 0);

  if (X % sum === 0) {
    console.log("Yes");
  } else {
    console.log("No");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
s = input()
n = len(s)

a = []
cont = 0
c = ''
for ss in s:
    if c != ss:
        a.append(cont)
        c = ss
        cont = 1
    else:
        cont += 1
a.append(cont)

ans = 0
minus_flg = False
for aa in a[1:]:
    if minus_flg:
        aa -= 1
        minus_flg = False
    q, r = divmod(aa, 3)
    # print(aa, ans, q, r)
    if r == 0:
        ans += q * 2
    elif r == 1:
        ans += ((aa - 1) // 3) * 2 + 1
    else:
        ans += ((aa + 1) // 3) * 2
        minus_flg = True
if minus_flg:
    ans -= 1
print(ans)

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> c(26, INT_MAX);
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		int b[26] = {};
		for (auto&& si : s) b[si-'a']++;
		for (int i = 0; i < 26; i++) c[i] = min(c[i], b[i]);
	}
	string r;
	for (int i = 0; i < 26; i++) r += string(c[i], (char)(i+'a'));
	cout << r << endl;
	return 0;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	FOR(i,1,1000){
		int x = a * i;
		if (x % b == c){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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


struct edge { ll t; ll e; };

ll N;

ll a[MAX], b[MAX];

vector<edge> g[MAX];

ll ans[MAX] = {};

bool ch[MAX] = {};

void solve(ll u) {

	ch[u] = 1;

	ll rt = 0;

	rep(i, g[u].size()) {
		ll ed = g[u][i].e;
		if (ans[ed] != 0) {rt=ans[ed]; }

	}


	ll t = 1;

	rep(i, g[u].size()) {
		ll ed = g[u][i].e;
		if (t == rt) { t++; }
		if (ans[ed] == 0) { ans[ed] = t; t++; }
		
	}

	rep(i, g[u].size()) {
		ll ta = g[u][i].t;

		if (ch[ta] == 0) { solve(ta); }
	}

	return;
}


int main() {


	cin >> N;



	repn(i, N - 1) cin >> a[i] >> b[i];

	repn(i, N - 1) {
		edge x;
		x.t = b[i];
		x.e = i;
		g[a[i]].push_back(x);

		x.t = a[i];
		g[b[i]].push_back(x);
	}

	solve(1);

	ll k = 0;

	repn(i, N - 1) {
		k = max(ans[i], k);
	}

	cout << k << endl;

	repn(i, N - 1) {
		cout << ans[i] << endl;
	}






	system("PAUSE");
}


Measured memory_bytes: 35328
# -*- coding: utf-8 -*-

inputAB = [int(e) for e in input().split()]

inputA = int(inputAB[0])
inputB = int(inputAB[1])

# print(inputA, inputB)

if inputA > inputB:
    largeNum = inputA
    smallNum = inputB
else:
    largeNum = inputB
    smallNum = inputA

# print(largeNum, smallNum)

if ((largeNum - smallNum) % 2) == 1:
    print("IMPOSSIBLE")
else:
    answer = smallNum + int((largeNum - smallNum) / 2)
    print(answer)

Measured memory_bytes: 3060
#include <stdio.h>
#define NUMBER 100

void print_array(int array[],int num){
	int i;
	
	for(i = 0; i < num - 1; i++)
		printf("%d ", array[i]);
	
	//スペースを出力したくないので最後の要素だけfor文外で出力
	printf("%d\n", array[i]);
}

int selectionSort(int array[],int num){
	int cnt = 0;
	int i, j , minj, temp;
	for(i = 0; i <= num - 1; i++){
		minj = i;
		for(j = i; j <= num - 1; j++){
			if(array[j] < array[minj])
				minj = j;
		}
		if(minj != i){
			temp = array[i];
			array[i] = array[minj];
			array[minj] = temp;
			cnt++;
		}
	}
	
	return cnt;
}

int main(void){
	int array[NUMBER];
	int num, i, n;
	
	scanf("%d", &num);
	
	for(i = 0; i < num; i++){
		//配列を入力
		scanf("%d", &array[i]);
	}
	//選択ソート
	n = selectionSort(array, num);
	
	print_array(array, num);
	
	//交換回数を出力
	printf("%d\n", n);
	
	return 0;
}


Measured memory_bytes: 2740
t=int(input())
ac=0
wa=0
tle=0
re=0
for _ in range(t):
  s=input()
  if(s=="AC"):
    ac+=1
  elif(s=="WA"):
    wa+=1
  elif(s=="TLE"):
    tle+=1
  else:
    re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;


int main(){
    int n, a, X = 0;
    cin >> n >> a;
    X = a;

    vector<int> x(n);
    REP(i, n) {
        cin >> x[i];
        X = max(X, x[i]);
    }

    ll dp[n+1][n+1][n*X+1]; /* dp[i][j]; i枚目まで見て合計jになるときの通り数 */
    REP(i, n+1) REP(j, n+1) REP(k, n*X+1) dp[i][j][k] = 0;
    dp[0][0][0] = 1;

    REPN(i, 1, n+1) REP(j, n+1) REP(k, n*X+1) {
        if(k >= x[i-1] && j >= 1) {
            dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]];
        } else if (k < x[i-1]) {
            dp[i][j][k] = dp[i-1][j][k];
        }
    }

    ll ans = 0;

    REPN(i, 1, n+1) {
        ans += dp[n][i][i*a];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 51072
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        q[--p[i]] = i;
        if (p[i] % 2 != i % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    int mx[2] = {0, 0};
    for (int i = 0, j = 0; i < n; ++i) {
        if (q[i] >= j) {
            mx[i % 2] = max(mx[i % 2], i);
            for (int k = j; k < q[i]; ++k) {
                if (p[k] < mx[k % 2]) {
                    cout << "No" << endl;
                    return 0;
                }
                mx[k % 2] = p[k];
                if (k % 2 != i % 2 && p[k] != k) {
                    cout << "No" << endl;
                    return 0;
                }
            }
            p[q[i]] = mx[i % 2];
            j = q[i];
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 2688
using System;

public class AtCoderA
{
    static void Main()
    {
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
        }

        if (a >= 13)
        {
            Console.WriteLine(b);
        }
        else if (6 <= a && a <= 12)
        {
            Console.WriteLine(b / 2);
        }
        else
        {
            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13140
N = list(map(int, input()))

if ((N[0]*100+N[1]*10+N[2]) < (N[0]*100+N[0]*10+N[0])):
    print(N[0]*100+N[0]*10+N[0])
elif ((N[0]*100+N[1]*10+N[2]) > (N[0]*100+N[0]*10+N[0])):
    print((N[0]+1)*100+(N[0]+1)*10+(N[0]+1))
else:
    print(N[0]*100+N[1]*10+N[2])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	VI a(n); REP(i, n)cin >> a[i];
	int m[3] = { -1,-1,-1 };
	VI dp(n + 1,0);
	dp[0] = 1;
	REP(i, n) {
		int k = 0,flag = 0;
		REP(j, 3) {
			if (m[j] + 1 == a[i]) {
				if(!flag)
					m[j]++;
				k++;
				flag = 1;
			}
		}
		if (!flag) {
			cout << 0;
			return 0;
		}
		dp[i + 1] = (dp[i] * k) % MOD;
	}
	cout << dp[n];
}

Measured memory_bytes: 1792
//
// Created by 伊東麻沙美 on 2019/10/22.
//

#include<iostream>
#include<algorithm>
#include<stdlib.h>
using namespace std;


int main() {
    int N;
    cin>>N;
    int A[N];
    for(int i = 0;i<N;i++){
        cin>>A[i];
    }
    double kei = 0;
    for(int j = 0;j<N;j++){
        kei = kei+ 1.0/A[j];
    }
    cout<<1.0/kei<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

void solve() {
    int N,M; cin >> N >> M;
    vll H(N);
    rep(i,N) cin >> H[i];
    vector<vi> to(N);
    // vi A(M),B(M);
    int a,b;
    rep(i,M) {
        cin >> a >> b;
        a--;b--;
        to[a].pb(b);
        to[b].pb(a);
    }

    int ans = 0;
    rep(i,N){
        int h = H[i];
        bool good = 1;
        for(auto x:to[i]){
            if(h <= H[x]){
                good = 0;
                break;
            }
        }
        if(good) ans++;
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int x[N],y[N],h[N];

    int i;
    for(i=0;i<N;i++)
    {
        cin >> x[i] >> y[i] >> h[i];
    }

    int j,k,H1,H2,p=0;
    while(h[p]==0) p++;
    for(i=0;i<=100;i++)
    {
        for(j=0;j<=100;j++)
    {
        H1 = abs(x[p]-i) + abs(y[p]-j) + h[p];
        for(k=0;k<N;k++)
        {
            H2 = H1 - abs(x[k]-i) - abs(y[k]-j);
            if(H2 < 0) H2=0;
            if(H2!=h[k]) break;
        }
        if(k==N) {cout << i << ' ' << j << ' ' << H1;return 0;}
    }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        Long K = sc.nextLong();
        sc.nextLine();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }

        List<Integer> l = new ArrayList<>();
        Set<Integer> s = new HashSet<>();

        int n = 1;
        int loop = 0;
        while(true) {
            if(!s.contains(n)) {
                s.add(n);
                l.add(n);
                n = A[n-1];
            } else {
                loop = l.indexOf(n);
                break;
            }
        }

        int ans = 0;
        if(l.size() > K) {
            System.out.println(l.get(Integer.parseInt(Long.toString(K))));
        } else {
            ans = (int) ((K - loop) % (l.size() - loop));
            System.out.println(l.get(ans+loop));
        }
        
        sc.close();
    }
}

Measured memory_bytes: 66036
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<ll, ll> P;
const ll inf = 1e15;
struct edge{
  ll to, cost;
  edge(ll t, ll c) {
    to = t, cost = c;
  }
};
// Kからの距離を求めておく
int N;
vector<edge> G[100005];
ll d[100005];
void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  FOR(i,1,N+1) d[i] = inf;
  d[s] = 0;
  que.push(P(0, s));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto &e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
}
int main()
{
  cin >> N;
  FOR(i,0,N-1) {
    ll a, b, c;
    cin >> a >> b >> c;
    G[a].push_back(edge(b, c));
    G[b].push_back(edge(a, c));
  }
  int Q, K; cin >> Q >> K;
  // Kからの距離
  dijkstra(K);
  FOR(i,0,Q) {
    int x, y; cin >> x >> y;
    cout << d[x] + d[y] << endl;
  }
  return 0;
}


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

int n,nex[501000],f[501000],pos;
char s[1001000];
void U(int &x,int y){
	x=max(x,y);
}
int main(){
	scanf("%d%s",&n,s+1); n=strlen(s+1);
	for (int i=n+1;i>0;i--)
		nex[i]= s[i]=='1'? nex[i+1]: i;
	for (int i=0;i+3<=n;i++){
		if (s[i+1]=='1'&&s[i+2]=='0'&&s[i+3]=='1'){
			pos=nex[i+3];
			for (int j=i+3;j<pos;j++)
				U(f[j],f[i]+j-i-2);
		}
		if (s[i+1]=='1'){
			pos=nex[i+1];
			if (pos+1<=n){
				if (s[pos+1]=='1'){
					U(f[pos+1],f[i]+pos-i-1);
				}
			}
		}
		U(f[i+1],f[i]);
	}
	for (int i=1;i<n;i++) U(f[n],f[i]);
	cout<<f[n];
}

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

using namespace std;
#define rep(i,n) for(int i; i<(int)(n); i++)

int main() {
  int N; cin >> N;
  int ans = 0;
  rep(i,N) {
    int l, r;
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>

class Node {
    public:
        const int value;
        Node* prev;
        Node* next;

        Node(int value): value(value) {}
        ~Node() {
            delete prev;
            delete next;
        }
};

class LinkedList {
    Node* guard;
    int _size;

    public:
        const int id;

        LinkedList(int id, Node* first): id(id) {
            guard = new Node(-1);
            guard->next = first;
            guard->prev = first;
            first->next = guard;
            first->prev = guard;
            _size = 1;
        }

        ~LinkedList() {
            delete guard;
        }

        void append_all(LinkedList* other) {
            last()->next = other->first();
            other->first()->prev = last();

            guard->prev  = other->last();
            other->last()->next  = guard;

            _size += other->size();
        }

        Node* first() {
            return guard->next;
        }

        Node* last() {
            return guard->prev;
        }

        bool is_end(Node* node) {
            return node == guard;
        }

        int size() {
            return _size;
        }
};

LinkedList **SETs;

void unite(int x, int y) {
    if ( SETs[x] == SETs[y] ) return;

    bool is_x_bigger = SETs[x]->size() >= SETs[y]->size();
    LinkedList* main = is_x_bigger ? SETs[x] : SETs[y];
    LinkedList* sub  = is_x_bigger ? SETs[y] : SETs[x];

    Node* node = sub->first();
    while(! sub->is_end(node)) {
        SETs[ node->value ] = main;
        node = node->next;
    }
    main->append_all(sub);
}

bool same(int x, int y) {
    return SETs[x]->id == SETs[y]->id;
}

void create_sets(int n) {
    for (int i = 0; i < n; i++) {
        Node *node = new Node(i);
        LinkedList *set = new LinkedList(i, node);
        SETs[i] = set;
    }
}

int main() {
    int n, q;
    scanf("%d %d\n", &n, &q);

    SETs = new LinkedList*[n];
    create_sets(n);

    int command, x, y;
    for (int i = 0; i < q; i++) {
        scanf("%d %d %d\n", &command, &x, &y);
        switch (command) {
            case 0:
                unite(x, y);
                break;
            case 1:
                printf("%d\n", same(x, y));
                break;
        }
    }
    return 0;
}

Measured memory_bytes: 2204
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::map<P, ll> mp;
ll ans;

int main()
{
  std::cin >> N;

  std::cout << (N-1)/2 << std::endl;

  return 0;
}

Measured memory_bytes: 3624
import sys
input = lambda: sys.stdin.readline().rstrip()
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
edges = [set() for _ in range(N)]
for _ in range(M):
    a, b = inpl()
    a -= 1
    b -= 1
    edges[a].add(b)
    edges[b].add(a)

L = [0] * 2
signs = [None] * N
pool = [(0,0)]
while pool:
    n, s = pool.pop()
    if signs[n] is None:
        signs[n] = s
        L[s] += 1
        for c in edges[n]:
            edges[c].remove(n)
            pool.append((c,1-s))
    elif signs[n] == s:
        continue
    else:
        ans = N*(N-1)//2 - M
        break
else:
    ans = L[0]*L[1] - M

print(ans)

Measured memory_bytes: 77676
import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

dist = defaultdict(lambda: float('inf'))
def dijkstra(start, end):
	dist[start] = 0
	heap = []
	heappush(heap, (0, start))
	while heap:
		d, n = heappop(heap)
		if n == end:
			return d
		if dist[n] != d:
			continue
		edges = get_edges(n)
		for nn, ed in edges:
			nd = d + ed
			if dist[nn] > nd:
				dist[nn] = nd
				heappush(heap, (nd, nn))
	return -1

def get_edges(n):
	i, j = n
	edges = []
	if M[i][j] == '#': return edges
	for di in range(-2, +3):
		for dj in range(-2, +3):
			ni, nj = i+di, j+dj
			if di == 0 and dj == 0: continue
			if not(0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if (di, dj) in [(1,0),(-1,0),(0,1),(0,-1)]:
				edges.append(((ni, nj), 0))
			else:
				edges.append(((ni, nj), 1))
	return edges

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(start, end)
print(d)


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

typedef struct{double x, y;}P;

void koch(int, P,P);

int main(){
  P a, b;
  int n;

  scanf("%d",&n);

  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;

  printf("%.8f %.8f\n",a.x,a.y);
  
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;

}

void koch(int n,P a,P b)
{
  if(n==0)return;
  
  P s, t, u;
  double th = M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n-1,t,b);
}




Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
int main (){
    int N,K;
    cin >> N >> K;
    vector<int> v(N);
    for(int i = 0; i < N; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(),v.end());
    int min = pow(10,9);
    for(int i = 0; i < N-K+1; i++)
    {
        if(min > v[i+K-1] -v[i]){
            min = v[i+K-1] -v[i];
        }
    }
    cout << min << endl;
    
    
}

Measured memory_bytes: 640
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == (500*i+100*j+50*k):
               count+=1
print(count)

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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a;
    int c_0 = 0, c_n = 0;
    for(int i=0;i<m;i++){
        cin >> a;
        if(a>x){
            c_n++;
        }else if(a<x){
            c_0++;
        }
    }
    cout << min(c_0, c_n) << endl;
}

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

using namespace std;

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

    vector<int> d(n);
    for(int i = 0;i < n;i++)    cin >> d[i];

    sort(d.begin(), d.end());


    cout << d[n/2] - d[n/2-1] << endl;

    return 0;
}

Measured memory_bytes: 640
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
	do {\
		std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
		debug_impl(__VA_ARGS__);\
		std::cerr << std::noboolalpha;\
	} while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
	{ for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
	for (auto it = v.begin(); it != v.end(); it++)
		{os << (it != v.begin() ? "," : "") << *it;}
	return os << "}";
}

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	lint n, k; std::cin >> n >> k;
	std::vector<lint> ans;
	if (n == 1) {
		loop((k+1) / 2) ans.emplace_back(1);
	} else if (n % 2 == 0) {
		ans.emplace_back(n/2);
		loop(k-1) ans.emplace_back(n);
	} else {
		std::vector<lint> len = {1};
		lint border_value = 4000000;
		loop(k) {
			lint x = len.back() * n + 1;
			if (border_value <= x) break;
			len.emplace_back(x);
		}
		debug(len);

		assert(2 <= n && n % 2 == 1);
		lint border = len.size();
		lint diff = k % 2 == 0;
		lint k_ = k;
		for (lint i = k_; i >= border; i--) {
			ans.emplace_back((n+1)/2);
			diff++;
			k_--;
		}
		debug(ans.size(),border,ans);
		debug(k,diff,len);
		assert(0 <= k_ && k_ < len.back());

		lint X = (len.back() - diff) / 2;
		assert(2 * X + diff == len.back());
		debug(X);

		auto f = [&] (auto&& f, lint k, lint X) {
			if (k == 0 || X == 0) return ;
			debug(k,X);
			X--;
			lint q = X / len.at(k-1);
			lint r = X % len.at(k-1);
			ans.push_back(q+1);
			f(f,k-1,r);
		};
		f(f, border - 1, X);
		debug(ans.size(), ans);
	}

	lint sz = ans.size();
	assert(sz <= k);
	for (lint x : ans) assert(1 <= x && x <= n);
	rep(i,0,sz) {
		std::cout << (0 < i ? " " : "") << ans.at(i);
	}
	std::cout << std::endl;
	return 0;
}

Measured memory_bytes: 6128
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> h(n+1);
    REP(i,n){
        cin >> h[i];
    }
    h[n] = 0;
    int mh = *max_element(all(h));
    int res = 0;
    FOR(i,1,mh+1){
        int con = 0;
        int temp = 0;
        REP(j,n+1){
            if(i<=h[j]){
                con++;
            }else{
                if(con>0){
                    temp++;
                }
                con = 0;
            }
        }
        res += temp;
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var ans = getAns(a, n);
        Console.WriteLine(ans);
    }
    static long getAns(int[] a, int n)
    {
        var count = 0L;
        var j = 0;
        var s = 0L;
        for (int i = 0; i < n; i++)
        {
            while (j < n && s + a[j] == (s ^ a[j]))
                s += a[j++];
            count += j - i;
            if (i == j) j++;
            else s -= a[i];
        }
        return count;
    }
}

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

int mod=1e9+7;

int mpow(ll a,ll b) {
    ll c=1;
    while (b) {
        if (b%2)
            c=c*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return c;
}

int C(int a,int b) {
    ll c,d;
    c=d=1;
    for (ll i=a,j=1;j<=b;i--,j++)
        c=c*i%mod,d=d*j%mod;
    return c*mpow(d,mod-2)%mod;
}

int main() {
    int n,m;cin>>n>>m;
    map<int,int> pf;
    for (int i=2;i*i<=m;i++)
        while (m%i==0) {
            m/=i;
            pf[i]++;
        }
    if (m>1)
        pf[m]++;
    ll ans=1;
    for (auto p:pf)
        ans=ans*C(n-1+p.second,p.second)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
A = list(map(int,input().split()))
total = sum(A)
ACC = list(itertools.accumulate(A))

ans = 10 ** 10
for i in range(N-1):
  x = ACC[i]
  y = total - x
  ans = min(ans,abs(x - y))

print(ans)



Measured memory_bytes: 30660
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  int N, K; cin >> N >> K;
  vector<double> D(N+1, 0);
  for (int i = 1; i<=N; i++) {
    int p; cin >> p;
    double e = 0;
    rep(j,p) e += j+1;
    e /= p;
    D.at(i) = D.at(i-1) + e;
  }

  double ma = 0;
  for (int i = 0; i + K <= N; i++) {
    if (ma < D[i+K] - D[i]) ma = D[i+K] - D[i];
  }
  cout << fixed << setprecision(12);
  cout << ma << endl;
}


Measured memory_bytes: 4836
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

const inf = 1 << 60
const mod int = 1e9 + 7

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, a, b := ri(), ri(), ri()
	if a > b {
		fmt.Println(0)
		return
	}
	if a == b {
		fmt.Println(1)
		return
	}
	if n == 1 {
		fmt.Println(0)
		return
	}
	if n == 2 {
		fmt.Println(1)
		return
	}
	x := n - 2
	ans := b*x - a*x + 1
	fmt.Println(ans)
}


Measured memory_bytes: 640