akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; j < (n); k++)
#define rep(i, n) for (int i = 0; (i) < (n); i++)
#define repr(i, a, b) for (auto i = (a); i < (b); i++)
#define repv(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = max((t), (v)))
#define updatemin(t, v) (t = min((t), (v)))
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
template <typename T>
class segtree {
 private:
  int n;
  vector<T> data, lazy;

 public:
  segtree(int n_) {
    n = pow(2, ceil(log2(n_)));
    data.resize(n);
    lazy.resize(n);
    auto __x = data[0];
    repi(n) {
      data[i] = __vmin(__x);
      lazy[i] = 0;
    }
  }
};

int main() {
  int a;
  string s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
sp = []
1.step(n, 1) do |i|
  k = gets.chomp.split
  sp.push({s: k[0].to_s, p: k[1].to_i, i: i})
end
sp = sp.group_by {|sps| sps[:s]}.sort_by {|k,_v_as_array| k}

sp.each do |k,v|
  v.sort_by {|vv| - 1 * vv[:p]}.each {|vvv| puts vvv[:i]}
end

Measured memory_bytes: 1788
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (w, a, b) = (v[0], v[1], v[2]);
    if b > a + w {
        println!("{}", b - a - w);
    } else if b + w < a {
        println!("{}", a - b - w);
    } else {
        println!("0");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long int llint;

int main(){
	int N;
	cin >> N;
	llint caseCnt=1;

	for(int i=0;i<N;i++){
		int a;
		cin >> a;
		if(a%2==0){
			caseCnt*=2;
		}else{
			caseCnt*=1;
		}
	}

	cout << (pow(3,N)-caseCnt) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, N) for(int i = 0; i < N; ++i)
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        swap(a,b);
    }

    auto r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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

    ll sum = 0;
    for(ll a = 1; a <= k; a++)
    {
        for (ll b = 1; b <= k; b++)
        {
            for (ll c = 1; c <= k; c++)
            {
                ll gcdVal = gcd(a,b);
                gcdVal = gcd(gcdVal, c);
                sum += gcdVal;
            }
        }            
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int64_t> data(n + 1);
  for(int i = 0; i < n + 1; i++){
    if(i == 0){
      data.at(0) = 2;
      continue;
    }
    if(i == 1){
      data.at(1) = 1;
      continue;
    }
    data.at(i) = data.at(i - 1) + data.at(i - 2);
  }
  cout << data.at(n) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> N_factor2(N); //0~N-1の2の素因数の数が入る
    vector<int> factorialN_factor2(N); //0!~(N-1)!の2の素因数の数が入る
    vector<int> nCi(N); //パスカルの三角形の偶奇が入る
    rep(i,N){
        int cnt = 0;
        int num = i;
        while(num>0) {
            if(num%2==0) {
                cnt++;
                num/=2;
            } else {
                break;
            }
        }
        N_factor2.at(i) = cnt;
    }
    factorialN_factor2.at(0) = 0;
    rep(i,N-1) {
        factorialN_factor2.at(i+1) = factorialN_factor2.at(i) + N_factor2.at(i+1);
        // cout << factorialN_factor2.at(i);
    }
    // cout << factorialN_factor2.at(N-1) << endl;
    rep(i,N) {
        int NumOfPow2 = 0;
        NumOfPow2 = factorialN_factor2.at(N-1)-factorialN_factor2.at(i)-factorialN_factor2.at(N-i-1);
        if (NumOfPow2>0) {
            nCi.at(i) = 0;
        } else {
            nCi.at(i) = 1;
        }
        // cout << nCi.at(i);
    }
    // cout << endl;
    int num1 = 0, num2 = 0, num3 = 0;
    ll preAns = 0;
    int ans = 0;
    string str;
    cin >> str;
    int charcnt = 0;
    for(char ch: str) {
        a.at(charcnt) = ch - '0';
        charcnt++;
    }
    rep(i,N) {
        int prea = a.at(i);
        if (prea == 1) num1++;
        if (prea == 2) num2++;
        if (prea == 3) num3++;
        // cout << a.at(i);
    }
    if (num2 == 0) {
        rep(i,N) {
            int booly;
            booly = (a.at(i)-1)/2;
            preAns+=nCi.at(i)*booly;
        }
        ans = preAns%2;
        ans *= 2;
    } else if (num1 == 0) {
        rep(i,N) {
            int booly;
            booly = a.at(i)-2;
            preAns+=nCi.at(i)*booly;
        }
        ans = preAns%2;
    } else if (num3 == 0) {
        rep(i,N) {
            int booly;
            booly = a.at(i)-1;
            preAns+=nCi.at(i)*booly;
        }
        ans = preAns%2;
    } else {
        rep(i,N) {
            int booly;
            booly = 1-a.at(i)%2;
            preAns+=nCi.at(i)*booly;
        }
        ans = preAns%2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17564
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

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

bitset<20000> dp[2];
constexpr int X = 10000;
constexpr int Y = 10000;

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

    string s;
    int x, y;
    cin >> s >> x >> y;
    x += X, y += Y;
    int n = s.length();
    dp[0].set(X);
    dp[1].set(Y);
    bool update = false;
    int c = 0;
    int idx = 0;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'F') ++c;
        else{
            if(!update){
                dp[idx] <<= c;
                update = true;
            }
            else{
                dp[idx] = (dp[idx] << c) | (dp[idx] >> c);
            }
            idx ^= 1;
            c = 0;
        }
    }
    if(c > 0){
        if(!update) dp[idx] <<= c;
        else    dp[idx] = (dp[idx] << c) | (dp[idx] >> c);
    }
    if(dp[0][x] && dp[1][y])    cout << "Yes\n";
    else    cout << "No\n";
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
const int N=1000005;
char s[N];
int a[N],b[N],n;
int sol()
{
	int r=0;
	for(int i=0;i<n;i++)
		r=r^((((n-1)&i)==i)&a[i]);
	return r;
}
int main()
{
	scanf("%d%s",&n,s);
	for(int i=0;i<n;i++)
		b[i]=s[i]-'1';
	int fl=0;
	for(int i=0;i<n;i++)
		if(b[i]==1)
			fl=1;
	for(int i=0;i<n;i++)
		a[i]=b[i]&1;
	if(sol())
		puts("1");
	else
	{
		if(fl)
			puts("0");
		else
		{
			for(int i=0;i<n;i++)
				a[i]=b[i]/2;
			if(sol())
				puts("2");
			else
				puts("0");
		}
	}
	return 0;
}

Measured memory_bytes: 9088
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
char a[3][3];
int n, i;

int main()
{
	for(i = 0; i < 3; i++)
	{
		scanf("%s",a[i]);
		getchar();
	}
	printf("%c%c%c\n",a[0][0],a[1][1],a[2][2]);
}

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

using namespace std;

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

int main(){
    long long n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n)cin >> a[i];

    sort(a.begin(), a.end(), greater<long long>());

    long long w =0, h=0;
    bool flag = false; 
    rep(i, n-1){
        if(a[i] == a[i+1]){
            if(flag){
                h = a[i];
                cout << w*h;
                return 0;
            }
            w = a[i];
            flag = true;
            i++;
        }
    }
    cout << 0;
}

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

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;

#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))

int F()
{
	char ch;
	int x, a;
	while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
	if (ch == '-') ch = getchar(), a = -1;
	else a = 1;
	x = ch - '0';
	while (ch = getchar(), ch >= '0' && ch <= '9')
		x = (x << 1) + (x << 3) + ch - '0';
	return a * x;
}

const int N = 1 << 20;

const int mod = 924844033;

const int g = 5;

int fpow(int a, int x)
{
	int ret = 1;
	for (; x; x >>= 1)
	{
		if (x & 1) ret = 1LL * ret * a % mod;
		a = 1LL * a * a % mod;
	}
	return ret;
}

int n;

vector<int> edge[N];

int cnt[N], siz[N], fac[N], ifac[N];

int C(int n, int m)
{
	if (n < m || m < 0) return 0;
	return 1LL * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}

void dfs(int u, int fa)
{
	siz[u] = 1;
	for (auto v : edge[u])
	{
		if (v == fa) continue;
		dfs(v, u);
		siz[u] += siz[v];
	}
	for (auto v : edge[u])
	{
		if (v == fa)
		{
			++cnt[n - siz[u]];
			continue;
		}
		++cnt[siz[v]];
	}
}

void dft(int *a, int n, int sig)
{
	for (int i = 0, j = 0; i < n; ++i)
	{
		if (i > j) swap(a[i], a[j]);
		for (int l = n >> 1; (j ^= l) < l; l >>= 1);
	}
	for (int i = 1; i < n; i <<= 1)
	{
		int m = i << 1;
		int w = fpow(g, (mod - 1) / m);
		if (sig == -1) w = fpow(w, mod - 2);
		for (int j = 0; j < n; j += m)
		{
			int v = 1;
			for (int k = j; k < j + i; ++k, v = 1LL * v * w % mod)
			{
				int x = a[k], y = 1LL * a[k + i] * v % mod;
				a[k] = (x + y) % mod;
				a[k + i] = (x - y + mod) % mod;
			}
		}
	}
	if (sig == -1)
	{
		int invn = fpow(n, mod - 2);
		for (int i = 0; i < n; ++i) a[i] = 1LL * a[i] * invn % mod;
	}
}

int main()
{
	gi(n);
	for (int i = 1; i < n; ++i)
	{
		int u, v;
		gii(u, v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs(1, 0);
	fac[0] = 1;
	for (int i = 1; i <= n; ++i) fac[i] = 1LL * fac[i - 1] * i % mod;
	ifac[n] = fpow(fac[n], mod - 2);
	for (int i = n; i; --i) ifac[i - 1] = 1LL * ifac[i] * i % mod;
	static int f[N], g[N];
	for (int i = 0; i <= n; ++i) g[i] = ifac[n - i];
	for (int i = 0; i <= n; ++i) f[i] = 1LL * cnt[i] * fac[i] % mod;
	int m = 1;
	for (; m <= (n << 1); m <<= 1);
	dft(f, m, 1), dft(g, m, 1);
	for (int i = 0; i < m; ++i) f[i] = 1LL * f[i] * g[i] % mod;
	dft(f, m, -1);
	for (int k = 1; k <= n; ++k)
	{
		int ans = n;
		ans = 1LL * ans * C(n, k) % mod;
		ans = (ans - 1LL * ifac[k] * f[n + k]) % mod;
		if (ans < 0) ans += mod;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 61440
#include"iostream"
#include"cstdio"

#define MAXN
using namespace std;
typedef long long LL;
#define INF 0x7fffffff

char S[300050];

int main()
{
	int N;
	scanf("%d", &N);
	scanf("%s", S + 1);
	int cnt = 0;
	int ans = 0;
	for(int i = 1; i < N; i++)
		if(S[i] == 'W') cnt++;
	ans = cnt;
	for(int i = N - 1; i >= 1; i--)
	{
		if(S[i + 1] == 'E') cnt++;
		if(S[i] == 'W') cnt--;
		ans = min(ans, cnt);
	}
	cout<< ans<< endl;
	return 0;
}


Measured memory_bytes: 640
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
from collections import deque
#======================================================#
def main():
    h, w = MII()
    ch, cw = MII()
    dh, dw = MII()
    maze = [IS() for _ in range(h)]
    check = [[-1]*w for i in range(h)]
    dq = deque([(ch-1, cw-1)])
    check[ch-1][cw-1] = 0
    count = 0

    inMaze = lambda x,y: 0 <= y < h and 0 <= x < w
    isWall = lambda x,y: maze[y][x] == '#'
    isChecked = lambda x,y: check[y][x] != -1

    while True:
        tmp = []
        while dq:
            y, x = dq.popleft()
            tmp.append((y, x))
            for dy, dx in ((0,1), (0,-1), (1,0), (-1,0)):
                ny = y+dy
                nx = x+dx
                if not inMaze(nx, ny):
                    continue
                if isWall(nx, ny):
                    continue
                if isChecked(nx, ny):
                    continue
                check[ny][nx] = count
                dq.appendleft((ny, nx))

        count += 1
        for y, x in tmp:
            for i in range(-2,3):
                for j in range(-2,3):
                    ny = y+i
                    nx = x+j
                    if not inMaze(nx, ny):
                        continue
                    if isWall(nx, ny):
                        continue
                    if isChecked(nx, ny):
                        continue
                    check[ny][nx] = count
                    dq.append((ny, nx))
        if not dq:
            break

    print(check[dh-1][dw-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 95008
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_HW = 110;
int H, W;
int N;
vector<int> A;
int board[MAX_HW][MAX_HW];
int main() {
  cin >> H >> W;
  cin >> N;
  A.resize(N);
  for (auto &val : A) {
    cin >> val;
  }
  int y = 0;
  int x = 0;
  int dir = 1;
  for (int i = 0; i < N; i++) {
    int deg = A[i];
    int node = i + 1;
    while (deg > 0) {
      board[y][x] = node;
      x += dir;
      if (x < 0) {
        x = 0;
        y++;
        dir = 1;
      } else if (x >= W) {
          x = W - 1;
          y++;
          dir = -1;
      }
      deg--;
    }
  }
  for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
          cout << board[i][j] << " ";
      }
      cout << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int h,n; cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    rep(i,n) cin >> a[i], sum += a[i];
    h > sum ? cout << "No" << endl : cout << "Yes" << endl;
}

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

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

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((100*a + 10*b + c)%4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
queue<int> que;
int main() {
	int n, x;
	cin >> n >> x;
	for (int i = 1; i < 2 * n; i++) {
		que.push(i);
	}
	if (x != 1 && x != 2 * n - 1) {
		cout << "Yes" << endl;
		int co = x - n;
		if (co < 0) {
			co += 2 * n - 1;
		}
		for (int i = 0; i < co; i++) {
			int y = que.front();
			que.pop();
			que.push(y);
		}
		for (int i = 0; i < 2 * n - 1; i++) {
			cout << que.front() << endl;
			que.pop();
		}
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <numeric>
using namespace std;


//I hate Factorization
//*
int main() {
	int x;
	cin >>x;
	for (int i = 0; i < 800;i++) {
		for (int j = -i; j < i; j++) {
			if (x == (i * i * i * i * i) - j * j * j * j * j) {
				cout << i << " " << j;
				return 0;
			}
		}
	}

	return 0;
}
//*/

Measured memory_bytes: 3636
s=input()
l=[]
alf=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z"]
for x in alf:
    if str(x) in s:
        pass
    else:
        l.append(x)
if l==[]:
    print("None")
else:
    print(min(l))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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 RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N;
    cin >> N;
    VI A(N);
    REP(i, N) cin >> A[i];

    map<int, int> mp;
    REP(i, N) {
        mp[A[i]] = i;
    }

    REP(i, N) {
        cout << (mp[i + 1] + 1) << (i + 1 == N ? '\n' : ' ');
    }
}


Measured memory_bytes: 5888
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm>
#define MAXN 250010
using namespace std;

int n;
pair<int,int> a[MAXN];
stack<pair<int,int> > S;
int b[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].first);
		a[i].second=i;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		int cnt=1;
		int x=1;
		b[a[i].first]=a[i].second;
		while(x<a[i].first && cnt<a[i].second){
			if(!b[x]){
				b[x]=a[i].second;
				cnt++;
			}
			x++;
		}
		if(cnt<a[i].second){
			puts("No");
			return 0;
		}
		for(int j=1;j<=n-a[i].second;j++)
			S.push(make_pair(a[i].first,a[i].second));
	}
	for(int i=n*n;i>=1;i--)
		if(!b[i]){
			if(S.top().first>=i){
				puts("No");
				return 0;
			}
			b[i]=S.top().second;
			S.pop();
		}
	puts("Yes");
	for(int i=1;i<=n*n;i++) printf("%d ",b[i]);
}


Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

const ll M = 1000000007;

int main(){
	static ll n,m;
	static ll a[5002];
	static ll b[5002][202];
	scanf("%lld%lld",&n,&m);
	a[1] = 0;
	for(int i = 2 ; i <= n ; i ++){
		scanf("%lld",&a[i]);
		a[i] += a[i-1];
	}
	for(int i = 1 ; i <= n ; i ++){
		rep(j,m){
			scanf("%lld",&b[i][j]);
		}
	}
	
	static ll c[5002][5002] = {};
	
	rep(i,m){
		vector<P> vec;
		rep1(j,n)vec.pb(P(b[j][i],j));
		sor(vec);
		rev(vec);
		set<ll> S;
		S.insert(0);
		S.insert(n+1);
		for(int j = 0 ; j < vec.size() ; j ++){
			P p = vec[j];
			int l = *--S.lower_bound(p.sc);
			int r = *S.lower_bound(p.sc);
			c[l+1][p.sc] += p.fr;
			c[l+1][r] -= p.fr;
			c[p.sc+1][p.sc] -= p.fr;
			c[p.sc+1][r] += p.fr;
			S.insert(p.sc);
		}
	}
	rep(i,5002)rep1(j,5001)c[i][j] += c[i][j-1];
	rep1(i,5001)rep(j,5002)c[i][j] += c[i-1][j];
	
	ll ret = 0;
	for(int x = 1 ; x <= n ; x ++){
		for(int y = x ; y <= n ; y ++){
			ret = max ( ret , c[x][y]+a[x]-a[y] );
		}
	}
	cout << ret << endl;
}
	


Measured memory_bytes: 203732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9;
ll s;
int main(){

    cin>>s;
    if(s%mod==0){
        cout<<"0 0 0 "<<s/mod<<" "<<mod<<" 0";
    }else{
        ll p=s/mod*mod+mod;
        ll res=p-s;
        cout<<"0 0 "<<p/mod<<' '<<1<<' '<<res<<' '<<mod<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=110000;
const ll P=1e9+7;
ll x[N], xa[N], xb[N], la[N], lb[N];

int main() {
    ll n, a, b, i, ia, ib;
    scanf("%lld%lld%lld", &n, &a, &b);
    for(i=1; i<=n; i++) scanf("%lld", &x[i]);

    for(i=1; i<n; i++) {
        if(x[i+1]-x[i]<a) la[i]=i;
        else la[i]=la[i-1];
        if(x[i+1]-x[i]<b) lb[i]=i;
        else lb[i]=lb[i-1];
    }

    ia=ib=1;
    xa[1]=xb[1]=1;
    for(i=2; i<=n; i++) {
        while(ia+1<=i && x[i]-x[ia]>=a) ia++;
        while(ib+1<=i && x[i]-x[ib]>=b) ib++;

        if(ia==i) xa[i]=(xa[i-1]+xb[i-1])%P;
        else xa[i]=(lb[i-2]<ia? xb[ia] : 0);

        if(ib==i) xb[i]=(xa[i-1]+xb[i-1])%P;
        else xb[i]=(la[i-2]<ib? xa[ib] : 0);
    }
    printf("%lld\n", (xa[n]+xb[n])%P);
    return 0;
}

Measured memory_bytes: 4352
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main()
{
  long N;
  cin >> N;

  string S;

  while( true )
  {
    if( N == 0 || N == 1 )
    {
      S += '0' + N;
      break;
    }

    if( N >= 0 )
    {
      int mod = N % 2;
      S += '0' + mod;
      N = - N / 2;
    }
    else
    {
      int mod = - N % 2;
      S += '0' + mod;
      N = ( - N + 1 ) / 2;
    }
  }

  reverse( S.begin(), S.end() );

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;

int main()
{
  string n;
  bool ok = false;
  cin >> n;
  rep(i, n.size()) {
    if (n[i] == '7') {
      ok = true;
      break;
    }
  }
  if (ok)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(int n, int m) {
    int rinv = 1 << m;
    int ms = 1900 * m + 100 * (n-m);
    std::cout << rinv * ms << std::endl;
}

int main() {
    struct timeval start,end;
    long long span;
    int n, m;

    gettimeofday(&start,NULL);

    std::cin >> n >> m;
    solve(n, m);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 888
import itertools
import math

n = int(input())
x_y = [list(map(int, input().split())) for _ in range(n)]
dist = 0
town = [i for i in range(n)]
root_lis = itertools.permutations(town)# 全ての場合のリストを生成
for one_case in root_lis:
    x_prev, y_prev = x_y[one_case[0]][0], x_y[one_case[0]][1]
    for num in one_case:
        dist += math.sqrt((x_y[num][0] - x_prev)**2 + (x_y[num][1] - y_prev)**2)
        x_prev, y_prev = x_y[num][0], x_y[num][1]
print(dist / math.factorial(n))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
  
        ll n,m;
        cin>>n>>m;
        for(int i=0;i<max(n,m);i++)
        {
            cout<<min(n,m);
        }
        
    
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <queue>
#include <random>
#include <cstdint>
#include <bitset>
#include <iomanip>
#include <utility>
#include<map>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

ll n, m, a[100000], b[100000], siz[100000];

ll par[100000], ran[100000];
void init(int p);
ll find(int x);
void unit(int x, int y);
bool same(int x, int y);
ll fsize(int x);


int main() {
	ll ans[100000];
	cin >> n >> m;
	fill(siz, siz + n, 1);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
	}
	ans[m - 1] = n * (n - 1) / 2;
	init(n);
	for (int i = m - 2; i >= 0; i--) {
		if (same(a[i+1], b[i+1])) {
			ans[i] = ans[i + 1];
		}
		else {
			ans[i] = ans[i + 1] - (fsize(a[i+1])*fsize(b[i+1]));
		}
		unit(a[i+1], b[i+1]);
	}
	for (int i = 0; i < m; i++) cout << ans[i] << endl;
}

void init(int p) {
	for (int i = 0; i < p; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}
ll find(int x) {
	if (par[x] == x) return x;
	else {
		par[x] = find(par[x]);
		return par[x];
	}
}

void unit(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		siz[find(y)] += siz[find(x)];
		par[x] = y;
	}
	else {
		siz[find(x)] += siz[find(y)];
		par[y] = x;
	}
	if (ran[x] == ran[y])ran[x]++;
}
bool same(int x, int y) { return find(x) == find(y);}

ll fsize(int x) {
	if (par[x] == x) return siz[x];
	else {
		siz[x] = fsize(par[x]);
		return siz[x];
	}
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする　大きい値にする
template<class T> bool chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

// 最大公約数を求める GCD
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


// 素因数分解 pair
vector<pair<ll, ll> > prime_factorize(ll n) {
    vector<pair<ll, ll> > res;
    for (ll p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

const int MAX = 210000;
const int MOD = 1000000007;

//  二項係数の計算nCk セット
//  https://drken1215.hatenablog.com/entry/2018/06/08/210000
//  使い方としては、最初に一度前処理として COMinit() をしておけば、あとは COM(n, k) 関数を呼べばよい
//  前処理 COMinit(): O(n)
//　クエリ処理 COM(n, k): O(1)
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


/*

 *
 * */

int main() {

    string a;
    
    cin >> a;
    
    string ans;
    if(a == "ARC"){
        ans = "ABC";
    }else{
        ans = "ARC";
    }

    cout << ans << endl;
}

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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<set<ll>> v(n);
        for(ll i=0; i<n; i++) {
            ll m;
            cin >> m;
            while(m--) {
                ll p;
                cin >> p;
                p--;
                v[i].insert(p);
            }
        }

        set<ll> w;
        {
            ll k;
            cin >> k;
            while(k--) {
                ll p;
                cin >> p;
                p--;
                w.insert(p);
            }
        }

        ll res = -2;
        for(ll i=0; i<n; i++) {
            bool pass = true;
            for(auto &e: w) {
                pass &= v[i].count(e);
            }
            if(pass)
                if(res == -2)
                    res = i;
                else {
                    cout << -1 << endl;
                    goto a;
                }

        }
        cout << res+1 << endl;
a:
        ;
    }
}



Measured memory_bytes: 3568
# get input parameter
step_list = list(input())

# continue flag
isEasy = True

# loop operation
for index in range(len(step_list)):
    num = index + 1
    item = step_list[index]
    
    if (item == 'R'):
        if (num % 2 == 0):
            isEasy = False
    elif (item == 'L'):
        if (num % 2 == 1):
            isEasy = False
    
    if not isEasy:
        break

if isEasy:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	int a, b, c;
	string  ans;
	cin >> a >> b >> c;
	if (a*b*c == 5 * 5 * 7) {
		ans = "YES";
	}
	else {
		ans = "NO";
	}
	std::cout << ans << std::endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,j,c,r,tmp1,tmp2;
	i=j=r=c=tmp1=tmp2;
	int city[52]={0};
	scanf("%d %d",&c,&r);
	for(i=0;i<r;i++){
		scanf("%d %d",&tmp1,&tmp2);
		city[tmp1]++;
		city[tmp2]++;
	}
	for(j=1;j<=c;j++){
		printf("%d\n",city[j]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
const int N=3e5+1;
int n, a[N], s[N];
int main() {
	int sum[2]={};
	assert(scanf("%d", &n)==1);
	for(int i=1; i<=n; ++i) {
		assert(scanf("%d", a+i)==1);
		sum[i%2]+=a[i];
		s[i]=s[i-1]+(i%2==1?a[i]:-a[i]);
	}
	if(n%2==0) {
		std::sort(sum, sum+2);
		printf("%d %d\n", sum[1], sum[0]);
		return 0;
	}
	int l=0, r=sum[1];
	while(l<r) {
		int x=(l+r+1)/2, min=0;
		for(int i=2; i<n; i+=2) if(s[i-1]-min>=x&&s[i]<min) min=s[i];
		if(s[n]-min>=x) l=x; else r=x-1;
	}
	printf("%d %d\n", sum[0]+l, sum[1]-l);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int cnt[6];
int main() {
	int n; cin >> n;
	rep(i, n) {
		double d; cin >> d;
		if (d >= 185.)cnt[5]++;
		else if (d >= 180.0)cnt[4]++;
		else if (d >= 175.)cnt[3]++;
		else if (d >= 170.)cnt[2]++;
		else if (d >= 165.)cnt[1]++;
		else cnt[0]++;
	}
	rep(i, 6) {
		cout << i + 1 << ':';
		rep(j, cnt[i])cout << '*';
		cout << endl;
	}
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int n, lim = 10000001, pm[2000007], l[107], r[107], cntl, cntr, cnt;
int h[207], cur[207], num[207], to[200007], w[200007], nxt[200007], tot, s, t, ans, res;
bool is[10000007],ck[10000007];
queue<int>q;
int read()
{
	int num = 0;
	char c = getchar();
	while (c < '0' || c>'9')c = getchar();
	while (c >= '0' && c <= '9')num = num * 10 + c - '0', c = getchar();
	return num;
}
int add(int a, int b, int c)
{
	to[tot] = b;
	w[tot] = c;
	nxt[tot] = h[a];
	h[a] = tot;
	tot++;
	to[tot] = a;
	nxt[tot] = h[b];
	h[b] = tot;
	tot++;
	return 0;
}
int bfs()
{
	memcpy(cur, h, sizeof cur);
	memset(num, 0, sizeof num);
	q.push(s);
	num[s] = 1;
	while (!q.empty())
	{
		int x = q.front();
		q.pop();
		for (int i = h[x]; i != -1; i = nxt[i])
			if (w[i] && !num[to[i]])
			{
				num[to[i]] = num[x] + 1;
				q.push(to[i]);
			}
	}
	return num[t];
}
int dfs(int x, int l)
{
	if (x == t)return l;
	int used = 0;
	for (int& i = cur[x]; i != -1; i = nxt[i])
		if (w[i] && num[to[i]] == num[x] + 1)
		{
			int d = dfs(to[i], min(w[i], l - used));
			if (d)
			{
				w[i] -= d;
				w[i ^ 1] += d;
				used += d;
				if (l == used)break;
			}
		}
	return used;
}
int main()
{
	for (int i = 2; i <= lim; i++)
	{
		if (!ck[i])pm[++cnt] = i;
		for (int j = 1; j <= cnt && i * pm[j] <= lim; j++)
		{
			ck[i * pm[j]] = 1;
			if (i % pm[j] == 0)break;
		}
	}
	ck[0] = ck[1] = ck[2] = 1;
	n = read();
	for (int i = 1; i <= n; i++)
		is[read()] = 1;
	for (int i = 1; i <= lim; i++)
		if (is[i] != is[i - 1])
			if (i & 1)l[++cntl] = i;
			else r[++cntr] = i;
	t = cntl + cntr + 1;
	memset(h, -1, sizeof h);
	for (int i = 1; i <= cntl; i++)
		add(s, i, 1);
	for (int i = 1; i <= cntr; i++)
		add(cntl + i, t, 1);
	for (int i = 1; i <= cntl; i++)
		for (int j = 1; j <= cntr; j++)
			if (!ck[abs(l[i] - r[j])])
				add(i, cntl + j, 1);
	while(bfs())
		ans += dfs(s, 1e9);
	res = ans;
	res += (cntl - ans) / 2 * 2 + (cntr - ans) / 2 * 2;
	res += ((cntl - ans) & 1) * 3;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 24832
package main

import (
	"fmt"
	"math"
)

func main(){
	var X int
	fmt.Scan(&X)
	var res float64
	res = 1.0
	for i := 2; i < X; i++ {
		//for文
		n := 2.0
		for int(math.Pow(float64(i),n)) <= X {
			tmp := math.Pow(float64(i),n)
			n++
			if tmp > res && tmp <= float64(X) {
				res = tmp
			}
		}
	}
	fmt.Println(res)
}

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<int> V;
bool check(string s,char c){
    for(auto &x:s)if(x!=c)return false;
    return true;
}
int main(){
    string s;
    cin>>s;
    int n=s.size();
    int res=114514;
    REP(x,26){
        char c='a'+x;
        string t = s;
        int m=n;
        while(check(t,c)==false){
            string u(m-1,'-');
            REP(i,m-1){
                if(t[i]==c||t[i+1]==c)u[i]=c;
                else u[i]='-';
            }
            t=u;
            m--;
        }
        chmin(res,n-m);
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int a, b;
   cin >> a >> b;
   if((a+b)%2!=0)
      cout << "IMPOSSIBLE" << endl;
   else
      cout << (a+b)/2 << endl;
   return 0;
}


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

string s;

int main() {
	int num = 0;
	cin >> s;
	
	int i;
	for (i = 0; i < s.length(); i++) {
		if (s[i] == '+') num++;
		else num--;
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int mod = 1e9 + 7;

int sum(int a, int b) {
    a += b;
    if (a >= mod)
        a -= mod;
    return a;
}

int sub(int a, int b) {
    return sum(a, mod - b);
}

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

int binpow(int x, int deg) {
    int res = 1;
    while (deg) {
        if (deg % 2)
            res = mul(res, x);
        deg /= 2;
        x = mul(x, x);
    }
    return res;
}

int rev(int x) {
    return binpow(x, mod - 2);
}

const int maxn = 200100;
int fact[maxn], ifact[maxn];

int ch(int x, int y) {
    return mul(mul(ifact[x], ifact[y]), fact[x + y]);
}

int main() {
    #ifdef LOCAL
    assert(freopen("d.in", "r", stdin));
    #else
    #endif
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < maxn; ++i) {
        fact[i] = mul(fact[i - 1], i);
        ifact[i] = mul(ifact[i - 1], rev(i));
    }
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int res = ch(h - 1, w - 1);
    forn (i, b) {
        res = sub(res, mul(ch(h - a - 1, i), ch(a - 1, w - i - 1)));
    }
    cout << res << '\n';
}


Measured memory_bytes: 1792
n = int(input())
a = list(map(int,input().split()))

l = sum(a)
half = 0
tmp=a[0]
while tmp<l/2:
    half+=1
    tmp+=a[half]
    
    
print(int(min(tmp-l/2,abs(tmp-a[half]-l/2))*2))

Measured memory_bytes: 31412
def calcs(a, b)
	calc1 = a / b
	calc2 = a % b
	calc3 = a.to_f / b.to_f
	return sprintf('%d %d %.5f', calc1, calc2, calc3)
end

input = gets
a, b = input.split(' ').map(&:to_i)
puts calcs(a, b)

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

int main() {
	long long N, COUNT = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N - 2; i++) {
		if (S.substr(i, 3) == "ABC") COUNT++;
	}
	cout << COUNT << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

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

    vector<int> B(N);
    for (int i = 0; i < N; ++i) {
        cin >> B[i];
    }

    vector<int> C(N-1);
    for (int i = 0; i < N-1; ++i) {
        cin >> C[i];
    }

    int ans = B[A[0]];
    for (int i = 1; i < N; ++i) {
        ans += B[A[i]];
        if (A[i] == A[i-1] + 1) {
            ans += C[A[i-1]];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
def solve():
    if '##' in s[a:c + 1] or '##' in s[b:d + 1]:
        return False
    if b < c < d:
        return True  # sfsf
    if c < b < d:
        return True  # ssff
    return '...' in s[b - 1:d + 2]  # sffs


n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1

s = input()

print('Yes' if solve() else 'No')


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
vector<pair<ll,ll>> ans;
vector<pair<ll,ll>> primefactarization(ll GC){
  for(ll i=2;i<sqrt(GC);i++){
    ll cnt=0;
    //cout<<i<<endl;
    while(true){
      if(GC%i==0){
        GC=GC/i;
        //cout<<GC<<endl;
        cnt++;
      }else{
        if(cnt>=1)
        ans.push_back(make_pair(i,cnt));
        break;
      }
    }
  }
  if(GC>1)ans.push_back(make_pair(GC,1));
  return ans;
}

int main(){
  ll a,b;
  cin>>a>>b;
  ll GC=__gcd(a,b);
  primefactarization(GC);
  // for(auto a:ans){
  //   cout<<a.first<<" "<<a.second<<endl;
  // }
  ll tmp=ans.size();
  cout<<tmp+1<<endl;
  }

Measured memory_bytes: 256
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int N = sc.nextInt();
		int K = sc.nextInt();
		int R = sc.nextInt();
		int S = sc.nextInt();
		int P = sc.nextInt();
		String T = sc.next();

		char[] pred = T.toCharArray();
		char[] player = new char[N];
		long score = 0;
		for (int i = 0; i < K; i++) {
			if (pred[i] == 'r'){
				score += P;
				player[i] = 'p';
			}else if (pred[i] == 's'){
				score += R;
				player[i] = 'r';
			}else {
				score += S;
				player[i] = 's';
			}
		}
		for (int i = K; i < pred.length; i++) {
			int s;
			if (pred[i] == 'r'){
				s =  P;
				player[i] = 'p';
			}else if (pred[i] == 's'){
				s =  R;
				player[i] = 'r';
			}else {
				s =  S;
				player[i] = 's';
			}
			if (player[i] == player[i - K]) {
				player[i] = 0;
			} else {
				score += s;
			}
		}
		System.out.println(score);
	}
}

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

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 27884
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		int[] dx = {-1, -1, -1,  0, 0,  1, 1, 1};
		int[] dy = {-1,  0,  1, -1, 1, -1, 0, 1};
		
		char[][] s = new char[h][w];
		for (int i = 0; i < h; i++) {
			s[i] = sc.next().toCharArray();
		}
		
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '#') {
					System.out.print('#');
				} else {
					int cnt = 0;
					for (int idx = 0; idx < dx.length; idx++) {
						int x = j + dx[idx];
						int y = i + dy[idx];
						
						if (0 <= x && x < w && 0 <= y && y < h && s[y][x] == '#') {
							cnt++;
						}
					}
					
					System.out.print(cnt);
				}
				
			}
			System.out.println();
		}
		
		sc.close();
	}
}




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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define PI M_PI
#define endl "\n"
#define sc scanf
#define pf printf
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     string s;
     cin>>s;
     
     if(s[1]=='R')
          cout<<"ABC\n";
     else
          cout<<"ARC\n";

     return 0;
}



Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
typedef long long int llint;

int main(void){
  int n, m;
  std::cin >> n >> m;

  if(n==m) std::cout << "Yes" << std::endl;
  else     std::cout << "No" << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[]
for i in range(H):
   s.append(input())

dis=[[-1,0],[1,0],[0,-1],[0,1]]

for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            isfound=False
            for k in dis:
                if  0<=i+k[0]<H and 0<=j+k[1]<W:
                    if s[i+k[0]][j+k[1]]=='#' :
                        isfound=True


            if not isfound:
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 3064