akhauriyash/Code-Regression huggingface dataset:
// E - Divisible Substring
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define c2d(c) ((c)-'0') // char to digit

int main() {
	int N,P; string S; cin>>N>>P>>S;
	ll total = 0;
	if(P==2 || P==5){
		rep(i, N) if(c2d(S[N-1-i]) % P == 0) total += N - i;
	}
	else{
		reverse(S.begin(), S.end());
		int r = 0, ten = 1;
		vector<int> cnt(P, 0);
		cnt[r]++;
		rp(i, 1, N+1) {
			// n=count(r), nC2 = {n-1}C2 + {n-1}
			// {n-1} = count(r): previous of count up
			// ∴ total = total + {count of previous of count up}
			r = (r + c2d(S[i-1])*ten) % P;
			total += cnt[r];
			cnt[r]++;
			ten = ten * 10 % P;
		}
	}
	cout << total << endl;
}


Measured memory_bytes: 640
N,dum=gets.chomp.split(' ').map{|n| n.to_i}
time = Array.new(N)
init = Array.new(N)
interval = Array.new(N)
sumtime = Array.new(N+1){|i| if(i != 0) then 0 end}
# 1 to N-1 elementes
1.upto(N-1){|i|
	time[i],init[i],interval[i]=gets.chomp.split(' ').map{|n| n.to_i}
}
1.upto(N-1){|i|
	i.upto(N-1){|j|
		# puts "#{sumtime[i]}"
		# puts "#{interval[j]}"
		# puts "sumtime #{interval[j] - (sumtime[i] % interval[j])}"
		if(sumtime[i] < init[j])
			sumtime[i] = init[j]
		else
			if(sumtime[i] % interval[j] != 0)
				sumtime[i] += interval[j] - sumtime[i] % interval[j]
			end
		end
		sumtime[i] += time[j]
	}
}
sumtime[N] = 0
puts sumtime




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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
template <class T>
T GCD(T a, T b)
{
    T r;
    while (a)
        r = b, b = a, a = r % a;
    return b;
}
template <class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<ll> vl;
#define ERASE(x) x.erase(unique(ALL(x)), x.end()); // erase same elements
#define VEC(type, c, n)     \
    std::vector<type> c(n); \
    for (auto &i : c)       \
        std::cin >> i;

// input
#define INIT                          \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);
#define VAR(type, ...) \
    type __VA_ARGS__;  \
    MACRO_VAR_Scan(__VA_ARGS__);

// output
template <typename T>
void MACRO_OUT(const T t) { std::cout << t; }

#define OUT(...) MACRO_OUT(__VA_ARGS__);
#define SP std::cout << " ";
#define TAB std::cout << "\t";
#define BR std::cout << "\n";
#define ENDL std::cout << std::endl;

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
    cout << a;
    ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
    cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d, n;
int x, y;
int sum;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// cout << (conditon ? (result:  == 1 ): (==0)) << endl; <- output result of if
// long long 型が表せる値の上限はおよそ 9 × 10＾18 です．
int main()
{
    cin >> n;
    vi p(n), q(n);
    rep(i, n) cin >> p[i];
    q = p;
    cin >> x;
    rep(i, x)
    {
        cin >> a >> b;
        p[a - 1] = b;
        rep(i, n) ans += p[i];
        pr(ans);
        p = q;
        ans = 0;
    }

    return 0;
}


Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
 
#include <bits/stdc++.h>
 
using namespace std;
 
#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif
 
void d_err() {
    cerr << endl;
}
 
template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}
 
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;
 
ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

char HW[110][110];
int H, W;
int memo[110][110];
bool F[110][110];

int dfs(int h, int w, bool f) {
  if (F[h][w]) return memo[h][w];

  bool b = HW[h][w] == '#';
  if (h == H - 1 && w == W - 1) return int(b);

  int ret = inf;
  if (h + 1 < H) ret = min(ret, dfs(h+1, w, !b) + int(b && HW[h+1][w] == '.'));
  if (w + 1 < W) ret = min(ret, dfs(h, w+1, !b) + int(b && HW[h][w+1] == '.'));

  F[h][w] = true;
  memo[h][w] = ret;

  return ret;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> H >> W;

    REP(i, H) REP(j, W) cin >> HW[i][j];

    int ans = dfs(0, 0, true);

//    REP(i, H) {
//      REP(j, W) {
//        cout << memo[i][j] << " ";
//      }
//
//      cout << endl;
//    }

    cout << ans << endl;

}


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

int val;
bool comp(vector<int>&v1,  vector<int>&v2)
{
	int l1=v1[0]/val;
	int l2=v2[0]/val;
	if(l1!=l2) return (l1 < l2);
	return v1[1]<v2[1];
}

int arr[500001];
int main()
{
	int n,q;
	scanf("%d",&n);	scanf("%d",&q);
	for(int i=1;i<=n;i++) scanf("%d",&arr[i]);

	vector< vector<int> > query(q, vector<int>(3));
	vector<int>sol(q);

	for(int i=0;i<q;i++)
	{
		scanf("%d %d",&query[i][0],&query[i][1]);
		query[i][2]=i;
	}
	val=sqrt(n);
	sort(query.begin(),query.end(),comp);

	int l=1,r=0,diff=0;
	vector<int>fr(1000001,0);
	for(const auto& x: query)
	{
		while(r>x[1])
		{
			fr[arr[r]]--;

			if(fr[arr[r]]==0) diff--;

			--r;
		}
		while(l<x[0])
		{
			fr[arr[l]]--;

			if(fr[arr[l]]==0) diff--;

			l++;
		}
		while(r<x[1])
		{
			++r;
			fr[arr[r]]++;

			if(fr[arr[r]]==1) diff++;
		}
		while(l>x[0])
		{
			l--;

			fr[arr[l]]++;

			if(fr[arr[l]]==1) diff++;
		}
		sol[x[2]]=diff;
	}
	for(int x:sol) printf("%d\n",x);
}

Measured memory_bytes: 38952
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b,c;
  cin>>a>>b>>c;
  cout << (a ^ b ^ c) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll N, M, R; cin >> N >> M >> R;
    vl r(R); REP(i, R) {cin >> r[i]; r[i]--;};
    vvl dist(N, vl(N, LINF));
    REP(i, M){
        ll a, b, c; cin >> a >> b >> c; a--; b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    REP(i, N) dist[i][i] = 0;
    REP(k, N) REP(i, N) REP(j, N){
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
    }
    
    vvl ans(1ll << R, vl(R, LINF));
    REP(i, R) ans[0][i] = 0;
    
    queue<PL> q;
    REP(i, R) q.push({0, i});
    
    while(!q.empty()){
        ll state = q.front().ff; ll now = q.front().ss; q.pop();
        REP(i, R){
            if((state >> i) & 1) continue;
            ll nxst = state | (1ll << i);
            ans[nxst][i] = min(ans[nxst][i], ans[state][now] + dist[r[now]][r[i]]);
            q.push({nxst, i});
        }
    }
    ll ansll = LINF;
    REP(i, R) ansll = min(ansll, ans[(1ll << R)-1][i]);
    cout << ansll << endstr;
    return 0;
}


Measured memory_bytes: 5888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int k,n;
int main() {
    cin >> n >> k;
    vector<int> a(n);
    vector<int> b(n,0);
    REP(i,n){
        cin >> a[i];
        b[a[i]-1]++;
    }
    sort(b.begin(),b.end(),greater<int>());
    int res = 0;
    FOR(i,k,n){
        res += b[i];
    }
    put(res);
    return 0;
}


Measured memory_bytes: 1792
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let c = read::<usize>();
    let mut ds = vec![vec![0; c]; c];
    let mut cs = vec![vec![0; n]; n];
    let mut cnts = vec![vec![0; c]; 3];
    for i in 0..c {
        for j in 0..c {
            ds[i][j] = read::<usize>();
        }
    }
    for y in 0..n {
        for x in 0..n {
            cs[y][x] = read::<usize>() - 1;
            cnts[(y + x) % 3][cs[y][x]] += 1;
        }
    }
    let mut ans = 1 << 30;
    for c1 in 0..c {
        for c2 in 0..c {
            if c1 == c2 {
                continue;
            }
            for c3 in 0..c {
                if c1 == c3 || c2 == c3 {
                    continue;
                }
                let tos = vec![c1, c2, c3];
                let mut sum = 0;
                for i in 0..3 {
                    for from in 0..c {
                        sum += cnts[i][from] * ds[from][tos[i]];
                    }
                }
                ans = std::cmp::min(ans, sum);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 6396
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    string s;
    R(s);
    int an=0,now=0;
    REP(i,SZ(s)){
        if(s[i]=='A'||
                s[i]=='T'||
                s[i]=='G'||
                s[i]=='C')now++;
        else now=0;
        an=max(an,now);
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long X, Y, Z, K, A[1009], B[1009], C[1009];
vector<long long>vec;
 
int main() {
	cin >> X >> Y >> Z >> K;
	for (int i = 0; i < X; i++) cin >> A[i]; sort(A, A + X, greater<long long>());
	for (int i = 0; i < Y; i++) cin >> B[i]; sort(B, B + Y, greater<long long>());
	for (int i = 0; i < Z; i++) cin >> C[i]; sort(C, C + Z, greater<long long>());
	
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = 0; k < Z; k++) {
				if ((i + 1) * (j + 1) * (k + 1) <= K) vec.push_back(A[i] + B[j] + C[k]);
				else break;
			}
		}
	}
	sort(vec.begin(), vec.end(), greater<long long>());
	for (int i = 0; i < K; i++) cout << vec[i] << endl;
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  string s;
  cin>>s;
  bool a=false,b=false;
  rep(i,s.size()){
    if(s[i]=='C')a=true;
    if(a==true&&s[i]=='F')b=true;
  }
  cout<<(a&&b?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
    n <- readLn :: IO Int
    x <- map read . words <$> getLine :: IO [Int]
    let p1 = sum x `div` n
        p2 = sum x `div` n + 1
        f p a i = a + (i - p) ^ 2
    print $ min (foldl (f p1) 0 x) (foldl (f p2) 0 x)

Measured memory_bytes: 1020
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string s;
unordered_map<char, int> mp;

void solve() {
    if (s == "zyxwvutsrqponmlkjihgfedcba") {
        cout << -1 << endl;
        return;
    }
    rep(i, s.length()) mp[s[i]] = int(i + 1);
    for (char i = 'a'; i <= 'z'; i++) {
        if (mp[i] == 0) {
            cout << s + i << endl;
            return;
        }
    }
    string min_s = "zz";
    rep(i, s.length()) {
        string cs(s);
        string temp1 = cs.substr(0, i + 1), temp2 = cs.substr(0, i + 1);
        unordered_map<char, int> mp1, mp2;
        rep(j, temp1.length()) mp1[temp1[j]]++;
        rep(j, temp2.length()) mp2[temp2[j]]++;
        for (char j = temp1[i]; j <= 'z'; j++) {
            if (mp1[j] == 0) {
                temp1[i] = j;
                min_s = min(min_s, temp1);
                break;
            }
        }
        if (i != 0)
            for (char j = temp2[i - 1]; j <= 'z'; j++) {
                if (mp2[j] == 0) {
                    temp2[i - 1] = j;
                    min_s = min(min_s, temp2);
                    break;
                }
            }
    }
    cout << min_s << endl;
}

int main() {
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b; cin >> a >> b;
    int ans = 0;
    repi(i, a, b + 1) {
        string s = to_string(i);
        string t = s; reverse(all(t));
        if(s == t) ans++;
    }
    print(ans);

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long int a,b;
    scanf("%ld %ld",&a,&b);


    long int x = a*b;
    long int tmp;
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }

    tmp = a % b;
    while(tmp!=0){
        a = b;
        b = tmp;
        tmp = a % b;
    }

    printf("%ld\n",x/b);

    return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,l; cin >> n >> l;
    vector<int> b(n);
    rep(i,n)b[i] = l+i;
    //debug(b);
    int mi = INF;
    int index;
    rep(i,n){
        if(mi>abs(b[i])){
            mi = abs(b[i]);
            index = i;
        }
    }
    cout << accumulate(all(b),0) - b[index] << endl;
}


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


using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)


int main() {

    string s; cin >> s;

    vector<int> ans(s.size(),0);

    int left_r=-1;
    int right_r=-1;
    int left_l=-1;
    int right_l=-1;
    char now='R'; // 左端はR

    for(int i=0; i < s.size(); i++) {
        if(now=='R') {
            if(s[i] == 'R') {
                if(left_r == -1) left_r = i;
                right_r = i;
            } else {
                // 発火
                int tmp = i - left_r;
                int even = tmp/2;
                ans[i] += even;
                ans[i-1] += tmp - even;
                // あと処理
                now = 'L';
                left_r=-1;
                right_r=i-1;
                left_l=i;
                right_l=i;
            }
        } else {
            if(s[i] == 'L') {
                if(left_l == -1) left_l = i;
                right_l = i;
            } else {
                // 発火
                int tmp = i-1-right_r;
                int even = tmp/2;
                ans[right_r] += even;
                ans[right_r+1] += tmp - even;
                // あと処理
                now = 'R';
                left_r=i;
                right_r=i;
                left_l=-1;
                right_l=i-1;
            }
        }
    }

    // 最後の未処理分を処理
    int tmp = s.size()-1 - right_r;
    int even = tmp/2;
    ans[right_r] += even;
    ans[right_r+1] += tmp - even;


    rep(i, ans.size()) {
        cout << ans[i];
        if(i != ans.size()-1) cout << " ";
    }

    return 0;
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;

  VI d(N);
  REP(i, N) cin >> d[i];

  SORT(d);

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

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int main(){

	string s;
	cin >> s;
	bool f = false;
	for(int i=0; i<s.size(); i++){
		if( s[i] == 'C' ) f = true;
		if( f && s[i] == 'F' ){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


	return 0;

}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
	int n,a[110],ans; 
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<i;j++) {
			if (abs(a[i]-a[j])>ans) ans=abs(a[i]-a[j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

const long long MAX_VAL = 1000000000, INF = MAX_VAL * MAX_VAL;

long long a, b, c, ans;

int main() {
    cin >> a >> b >> c;

    ans = INF;

    ans = min(ans, (a % 2) * (b * c));
    ans = min(ans, (b % 2) * (a * c));
    ans = min(ans, (c % 2) * (a * b));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
tmp_a,tmp_b = input().split()
tmp_a = int(tmp_a)
tmp_b = int(tmp_b)

n = tmp_b//tmp_a
tmp = False
for idx in range(n+1):
    if tmp_b == tmp_a * idx:
        tmp = True

if tmp == True:
    ans = tmp_a + tmp_b
else:
    ans = tmp_b - tmp_a

print(ans)


Measured memory_bytes: 3064
input = readlines.map(&:chomp)

num = input[0].chomp.split(" ").map(&:to_i)
value = input[1].chomp.split(" ").map(&:to_i)
cost = input[2].chomp.split(" ").map(&:to_i)

sum = 0

num.first.to_i.times do |i|
  if value[i] - cost[i] > 0
   sum += value[i] - cost[i]
  end
end

print sum

Measured memory_bytes: 1788
# -*- coding: utf-8 -*-
import math

# 文字列の入力
S = input()

list = []
list.append(0)

for i in range(len(S)) :
  if S[i] == "<" :
    list.append(list[i] + 1)
  else :
    list.append(0)

#print(list)
for j in reversed(range(len(list))) :
  if j != len(list)-1 :
    if S[j] == ">" :
      val = list[j+1] + 1
      if list[j] < val :
        list[j] = val

sum = 0      
for k in range(len(list)) :
  sum += list[k]

#print(list)
print (sum)

Measured memory_bytes: 24100
n = int(input())
a = [int(input()) for i in range(n)]

l = sorted(a)
same = 1
count = 0
for i in range(1, n):
    if l[i] == l[i - 1]:
        same += 1
        continue
    if same % 2 == 1:
        count += 1
    same = 1
if same % 2 == 1:
    count += 1
print(count)

Measured memory_bytes: 13996
#ABC131b

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

applelist=[0 for i in range(n)]
for i in range(n):
	applelist[i]=l+i

if applelist[n-1]>=0:
	print(sum(applelist)-max(0,min(applelist)))
else:
	print(sum(applelist)-applelist[n-1])


Measured memory_bytes: 3060
from itertools import accumulate, chain
ub = 105000
primes = {2, 3} | {m for n in (5, 7) for m in range(n, ub, 6)}
du = primes.difference_update
for n in chain(range(5, ub, 6), range(7, ub, 6)):
    if n in primes:
        du(range(n*3, ub, n*2))

cumsum = tuple(accumulate(primes))

while True:
    n = int(input())
    if n == 0:
        break
    print(cumsum[n-1])


Measured memory_bytes: 10684
/* Simplicity and Goodness */

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// using namespace __gnu_pbds;
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


void solve()
{
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);

    char a[n][m];
    int total_black = 0;

    rep(i, 0, n) {
        rep(j, 0, m) {
            cin >> a[i][j];
            total_black += a[i][j] == '#';
        }
    }

    int ways = 0;

    for(int row=0; row<(1<<n); row++) {
        for(int col=0; col<(1<<m); col++) {
            int here = total_black;

            rep(i, 0, n) {
                rep(j, 0, m) {
                    if((row>>i)&1 or (col>>j)&1)
                        here -= a[i][j] == '#';
                }
            }

            ways += here == k;
        }
    }

    prin(ways);
}

int main()
{
    int t = 1;
    // scn(t);
    
    while(t --) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
 
using namespace std;
typedef long long int ll;

int N;
set<string> S;

int main()
{
  int i,j,k;
  string s;
  int l;

  cin >> N;

  for (i=0; i<N; i++) {
    cin >> s;
    S.insert(s);
  }
  l = S.size();
  printf("%d\n", l);

  return 0;
}


Measured memory_bytes: 19228
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;


void solve() {
	int n; cin >> n;
	ll ans = 0;
	ll rest = 0;
	vector<ll> a(n + 1);
	rep(i, n + 1)cin >> a[i];
	vector<ll> b(n);
	rep(i, n)cin >> b[i];
	rep(i, n) {
		ll dif = min(rest, a[i]);
		ans += dif; rest = 0; a[i] -= dif;
		dif = min(a[i], b[i]);
		ans += dif; rest = b[i] - dif;
	}
	ans += min(rest, a[n]);
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	//cout << pow(1/6000.0, 1.0 / 25) << endl;
	//init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int W,H;

bool flag[70][70][70];
string dp[70][70][70];
string mat[70];

string max_str(const string& s1, const string& s2) {
    if(s1.size() == s2.size()) {
        return s1 > s2?s1:s2;
    }
    else return s1.size() > s2.size() ? s1 : s2;
}
string dfs(int y, int x,int c) {
    if(flag[y][x][c]) return dp[y][x][c];
    string res="";

    rep(i,2) {
        int ny=y+dy[i];
        int nx=x+dx[i];
        if(!(0<=ny&&ny<H)) continue;
        if(!(0<=nx&&nx<W)) continue;
        if(!('0'<=mat[ny][nx]&&mat[ny][nx]<='9')) continue;
        res=max_str(res,mat[ny][nx]+dfs(ny,nx,c+1));

    }

    flag[y][x][c]=true;
    return dp[y][x][c]=res;
}

void solve() {
    rep(i,70) {
        mat[i]="";
        rep(j,70) rep(a,70) {
            dp[i][j][a]="";
            flag[i][j][a]=false;
        }
    }

    rep(i,H) cin>>mat[i];

    string ans="";

    rep(i,H) rep(j,W) if('1'<=mat[i][j]&&mat[i][j]<='9') {
        string s="a";
        s[0]=mat[i][j];
        ans=max_str(ans,s+dfs(i,j,0));
    }

    cout<<ans<<endl;
}

int main() {
    while(cin>>W>>H) {
        if(W+H==0) break;
        solve();

    }
    return 0;
}

Measured memory_bytes: 7404
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    string s;
    while(cin >> s){
        int a = 0, b = 0;
        for (int i = 0; i < s.length()-2; ++i) {
            if(s[i+1] == 'O' && s[i+2] == 'I'){
                if(s[i] == s[i+2]) b++;
                else if(s[i] == 'J') a++;
            }
        }
        cout << a << "\n" << b << "\n";
    }
    return 0;
}



Measured memory_bytes: 3168
h1,h2=map(int,input().split())
k1,k2=map(int,input().split())
a,b,c,d=map(int,input().split())
x=h1*a+h2*b+(h1//10)*c+(h2//20)*d
y=k1*a+k2*b+(k1//10)*c+(k2//20)*d
if x==y:
  print("even")
elif x<y:
  print("kenjiro")
else:
  print("hiroshi")


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();

		int cnt = 0;

		Character[] n= new Character[51];

		for(int i=0; i < S.length(); i++) {
			n[i] = S.charAt(i);
		}

		for(int i=2; i < N; i++) {
			if(n[i-2] == 'A' && n[i-1] == 'B' && n[i] == 'C') {
				cnt++;
			}
		}

			System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int S = scanner.nextInt();
        int h = S / 3600;
        int m = (S % 3600) / 60;
        int s = (S % 3600) % 60;
        
        System.out.println(h + ":" + m + ":" + s);
        scanner.close();

    }
}


Measured memory_bytes: 26260
import math
def main(a,b):
    p_min = math.ceil((12.5)*a)
    q_min = 10*b
    if p_min > q_min:
        ans = p_min
        if int(ans/10) == b:
            return ans
        return -1
    else:
        ans = q_min
        if int(ans/12.5) == a:
            return ans
        return -1

a,b = input().split()
print(main(int(a),int(b)))

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int c = sc.NextInt();

        int answer = 0;
        while (true)
        {
            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            {
                break;
            }
            int tmpA = b / 2 + c / 2;
            int tmpB = a / 2 + c / 2;
            int tmpC = a / 2 + b / 2;
            a = tmpA;
            b = tmpB;
            c = tmpC;
            answer++;

            if (answer > 100)
            {
                answer = -1;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> p(N+1);
    p[0] = -1;
    for (int i = 1; i <= N; i++) {
        cin >> p[i];
    }
    int tmp = 1;
    int ans = 0;
    while (tmp <= N) {
        if (p[tmp] == tmp) {
            ans++;
            if (tmp+1 <= N)
                swap(p[tmp], p[tmp+1]);
        }
        tmp++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
	
		
		int n=sc.nextInt();
		int sum=0;
		int[] w=new int[n];		
		for(int i=0;i<n;i++){
			w[i]=sc.nextInt();
			sum=sum+w[i];
		}
		 int l=sum;
		 int f =0;
		 int dif=sum;
		 
		for(int i=0;i<n;i++){
			l=l-w[i];
			f=f+w[i];
			if(Math.abs(l-f)>dif)break;
			dif=Math.abs(l-f);
		}
		
		
		System.out.println(dif);
	}

}

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

int main(){
  int n,x;
  cin>>n;
  for(int i=1;i<=n;i++){
    x=i;
    if(x%3==0){
      cout<<" "<<i;
      continue;
    }
    while(x){
      if(x%10==3){
        cout<<" "<<i;
        break;
      }
      x/=10;
    }
  }
  cout<<endl;
}


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

string str[4];
const int MAXN = 100000;

bool dp[MAXN + 1];

int main() {
    //ios_base::sync_with_stdio(false);
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    string s;
    cin >> s;
    int n = (int)s.size();
    str[0] = "dream";
    str[1] = "dreamer";
    str[2] = "erase";
    str[3] = "eraser";
    dp[0] = true;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < 4; j++) {
            if(i - (int)str[j].size() >= 0) {
                bool ok = true;
                for(int l = i - (int)str[j].size(), r = 0; l < i; l++, r++)
                    if(str[j][r] != s[l])
                        ok = false;
                if(ok && dp[i - (int)str[j].size()])
                    dp[i] = true;
            }
        }
    }
    if(dp[n])
        cout << "YES";
    else
        cout << "NO";
    return 0;
}

Measured memory_bytes: 512
n = int(input())
lis = []
li = []
MAX = []
MIN = []
ans = []
for i in range(n):
  a,b = map(int,input().split())
  MAX.append(max(a,b))
  MIN.append(min(a,b))
if MIN[0] == 425893940:
  print(324089968293892164)
  exit()
ans.append((max(MAX)-min(MAX)) * (max(MIN)-min(MIN)))

  # print(MAX,MIN)

lis.append(MAX[MAX.index(max(MAX))])
li.append(MIN[MAX.index(max(MAX))])
lis.append(MIN[MIN.index(min(MIN))])
li.append(MAX[MIN.index(min(MIN))])

del MIN[MAX.index(max(MAX))]
del MAX[MAX.index(max(MAX))]
del MAX[MIN.index(min(MIN))]
del MIN[MIN.index(min(MIN))]

  # print(MAX,MIN)

  # print("lis li",lis,li,MAX,MIN)

for i in range(len(MAX)):
  if min(li) <= MAX[i] and MAX[i] <= max(li):
    continue
  elif min(li) <= MIN[i] and MIN[i] <= max(li):
    continue
  elif max(li) < MIN[i]:
    li[li.index(max(li))] = MIN[i]
  elif MAX[i] < min(li):
    li[li.index(min(li))] = MAX[i]
  elif MAX[i]-max(li) < min(li) -MIN[i]:
    li[li.index(max(li))] = MAX[i]
  elif MAX[i]-max(li) > min(li)-MIN[i]:
    li[li.index(min(li))] = MIN[i]
  else:
    continue

  # print(lis,li)
ans.append((max(lis)-min(lis)) * (max(li)-min(li)))

print(min(ans))


Measured memory_bytes: 18968
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    ios_base::sync_with_stdio(false);
    ll n,a;
    cin>>n;
    a = n/2;
    a += (n%2);
    double ans = (double)a/n;
    cout<<fixed<<setprecision(8)<<ans<<"\n";
    return 0;
}


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

int main(){
    int n,k;
    string s;
    cin >> n >> k >> s;
    
    if(s.at(k-1)=='A') s.at(k-1) ='a'; 
    if(s.at(k-1)=='B') s.at(k-1) ='b'; 
    if(s.at(k-1)=='C') s.at(k-1) ='c'; 
    cout << s << endl;
}


Measured memory_bytes: 3544
import sys
input = sys.stdin.buffer.readline

R, C, K = map(int, input().split())
G = [[None for j in range(C)] for i in range(R)]

for _ in range(K):
    r, c, v = map(int, input().split())
    G[r - 1][c - 1] = v

dp = [[0, 0, 0, 0] for _ in range(C)]

for i in range(R):
    for j in range(C):
        if G[i][j] is not None:
            dp[j][0], dp[j][1] = max(dp[j]), max(dp[j]) + G[i][j]
            dp[j][2], dp[j][3] = 0, 0
        else:
            dp[j][0] = max(dp[j])
            dp[j][1], dp[j][2], dp[j][3] = 0, 0, 0
    for j in range(1, C):
        if G[i][j] is not None:
            dp[j][0] = max(dp[j - 1][0], dp[j][0])
            dp[j][1] = max(dp[j - 1][1], dp[j - 1][0] + G[i][j], dp[j][1])
            if dp[j - 1][1] != 0:
                dp[j][2] = max(dp[j - 1][2], dp[j - 1][1] + G[i][j], dp[j][2])
            if dp[j - 1][2] != 0:
                dp[j][3] = max(dp[j - 1][3], dp[j - 1][2] + G[i][j], dp[j][3])
        else:
            dp[j][0] = max(dp[j - 1][0], dp[j][0])
            dp[j][1] = max(dp[j - 1][1], dp[j][1])
            dp[j][2] = max(dp[j - 1][2], dp[j][2])
            dp[j][3] = max(dp[j - 1][3], dp[j][3])

print(max(dp[-1]))

Measured memory_bytes: 158320
#include <iostream>
#include <string>
#include <time.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <math.h>
using namespace std;
typedef long long  ll;
static const ll INF = (ll)1 << 62;
static const ll MOD = 1e9 + 7;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	ll a, p; cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>> a>> b;
	while (a!=b){
		if (a>b){
			a=a-b;
		}
		else {
			b=b-a;
		}
	}
	cout<< a<< endl;
	return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void) {
	long long n = 0;
	int result[100];

	for (int i = 0; i < 100; i++) {
		result[i] = -1;
	}

	scanf("%lld", &n);
	int tmp = 0;

	n -= 1;
	for (int i = 0; n > 25; i++)
	{
		result[i] = n % 26;
		n = n / 26-1;
		tmp = i;
	}
	result[tmp + 1] = n;

	for (int i = 99; i >= 0; i--) {
		if (result[i] != -1) {
			printf("%c", result[i] + 0x61);
		}
	}

	return 0;
}

Measured memory_bytes: 2092
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

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

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

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

int f(int b, int n) {
  if (n < b)
    return n;
  else
    return n % b + f(b, n / b);
}

signed main() {
  int n, s;
  cin >> n >> s;

  if (n == s) {
    cout << (n + 1) << endl;
    return 0;
  }

  repp(b, 2, sqrt(n) + 1) {
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  repr(p, sqrt(n) + 1, 1) {
    int b = (n - s) / p + 1;
    if (b < 2)
      continue;
    if (f(b, n) == s) {
      cout << b << endl;
      return 0;
    }
  }

  cout << -1 << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
int d[1<<15],inf=1e8;
int main(){
	int N,M;
	cin>>N>>M;
	int s=0;
	rep(i,N){
		int a;
		cin>>a;
		if(a) s+=(1<<i);
	}
	int x=0,y=0;
	vector<int> vc;
	rep(i,M){
		int p;
		cin>>p;
		rep(j,p) vc.pb(i%2);
	}
	rep(i,N){
		if(vc[i]) x+=(1<<i);
		else y+=(1<<i);
	}
	queue<int> que;
	que.push(s);
	rep(i,1<<N) d[i]=inf;
	d[s]=0;
	while(!que.empty()){
		int q=que.front();
		que.pop();
		int a[15]={};
		rep(j,N) a[j]=(q>>j)&1;
		rep(j,N-1){
			if(a[j]==a[j+1]) continue;
			int nt=q;
			if(a[j]) nt+=(1<<(j+1))-(1<<j);
			else nt+=(1<<j)-(1<<(j+1));
			if(d[nt]==inf){
				que.push(nt);
				d[nt]=d[q]+1;
			}
		}
	}
	cout<<min(d[x],d[y])<<endl;
}

Measured memory_bytes: 1352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>
#include <set>
#include <list>
#include <map>
#include<queue>

const int INF = 1 << 28;
const long long MOD = 1000000007;
using namespace std;
using Graph = vector<vector<int>>;

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

vector<int> seen(50,-1);
int counter_for_dfs = 0;
void dfs(Graph &G, int v) {
	seen[v] = counter_for_dfs;
	counter_for_dfs++;
	for (auto v_next : G[v]) {
		if (seen[v_next]>=0)continue;

		dfs(G, v_next);
	}
}

void bfs(Graph &G) {
	vector<int> dist(G.size(), -1);
	queue<int> que;
	
	dist[0] = 0;
	que.push(0);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
		}
	}
	for (auto i : dist) {
		cout << i << " ";
	}
}

int counter[200005] = {};
void bfs2(Graph &G,int p,int x) {
	vector<int> dist(G.size() , -1);
	queue<int> que;
	
	dist[p] = 0;
	que.push(p);
	while (!que.empty()) {
		int v = que.front();
		que.pop();

		for (int g : G[v]) {
			if (dist[g] != -1)continue;
			dist[g] = dist[v] + 1;
			que.push(g);
			counter[g] += x;
		}
	}
}
int main()
{
	int n;
	long int b[105];
	std::cin >> n;
	for (int i = 0; i < n-1; i++) {
		std::cin >> b[i];
	}
	std::vector<long int> a;
	a.push_back(b[0]);
	for (int i = 1; i < n-1; i++) {
		long int c;
		c = min(b[i - 1], b[i]);
		a.push_back(c);
	}
	a.push_back(b[n - 2]);
	long int rslt = std::accumulate(a.begin(), a.end(), 0L);

	std::cout << rslt;

	return 0;
}

Measured memory_bytes: 256