akhauriyash/Code-Regression huggingface dataset:
use proconio::*;
use proconio::marker::*;
use std::cmp::*;

pub trait MoOperator {
    type Value;
    type Query;
    type Answer;
    fn init(&mut self);
    fn insert(&mut self, v: &Self::Value);
    fn delete(&mut self, v: &Self::Value);
    fn answer(&mut self, q: Self::Query) -> Self::Answer;
    fn solve(&mut self, array: &[Self::Value], mut query: Vec<(usize, usize, Self::Query)>, answer: &mut [Self::Answer]) {
        let state = self;
        let size = array.len();
        assert!(query.len() <= answer.len());
        assert!(query.iter().all(|p| p.0 < p.1 && p.1 <= size));
        if query.is_empty() {
            return;
        }
        let batch = (size as f64 / (query.len() as f64).sqrt()).ceil() as usize;
        let mut q = vec![];
        std::mem::swap(&mut q, &mut query);
        let mut query = (0..(size / batch + 1)).map(|_| vec![]).collect::<Vec<_>>();
        for (i, (l, r, op)) in q.into_iter().enumerate() {
            query[l / batch].push((r, l, i, op));
        }
        state.init();
        let mut x = 0;
        let mut y = 0;
        for (i, mut query) in query.into_iter().enumerate() {
            query.sort_unstable_by_key(|p| p.0);
            if i & 1 == 1 {
                query.reverse();
            }
            for (r, l, k, op) in query.into_iter() {
                for v in array[min(x, l)..x].iter().rev() {
                    state.insert(v);
                    x = l;
                }
                for v in array[min(y, r)..r].iter() {
                    state.insert(v);
                    y = r;
                }
                for v in array[min(x, l)..l].iter() {
                    state.delete(v);
                    x = l;
                }
                for v in array[min(y, r)..y].iter().rev() {
                    state.delete(v);
                    y = r;
                }
                answer[k] = state.answer(op);
            }
        }
    }
}

struct State {
    cnt: Vec<u32>,
    ans: usize,
}

impl MoOperator for State {
    type Value = usize;
    type Query = ();
    type Answer = usize;
    fn init(&mut self) {
        for c in self.cnt.iter_mut() {
            *c = 0;
        }
        self.ans = 0;
    }
    fn insert(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 0 {
            self.ans += 1;
        }
        *c += 1;
    }
    fn delete(&mut self, x: &Self::Value) {
        let c = &mut self.cnt[*x];
        if *c == 1 {
            self.ans -= 1;
        }
        *c -= 1;
    }
    fn answer(&mut self, _q: Self::Query) -> usize {
        self.ans
    }
}

#[fastout]
fn run() {
    input! {
        n: usize,
        q: usize,
        c: [Usize1; n],
        ask: [(Usize1, usize); q],
    }
    let ask: Vec<_> = ask.into_iter().map(|(l, r)| (l, r, ())).collect();
    let mut ans = vec![0; q];
    State {
        cnt: vec![0; n],
        ans: 0,
    }.solve(&c, ask, &mut ans);
    for a in ans {
        println!("{}", a);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 41640
# -*- coding:utf-8 -*-
N = int(input())
ans = 0
before = 1
factor = 0
for tmp in range(1,N+1):
    ans += tmp
    factor = tmp
    if before < N and N <= ans:
        break
    before = ans
difference = ans - N
if difference != 0:
    for tmp in range(1,factor+1):
        if difference != tmp:
            print(tmp)
        else:
            pass
else:
    for tmp in range(1,factor+1):
        print(tmp)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  string s; cin >> s;
  int n = s.size();
  int ans = n;
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, n - (i + 1)));
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
ll a, b, x;
ll c(ll l){
  if(l < 0) return 0;
  return l/x+1;
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> x;
  cout << c(b)-c(a-1) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long

int main() {
	int H, W;
	string s[30][30];

	cin >> H >> W;

	REP(i, H) {
		REP(j, W) {
			cin >> s[i][j];
		}
	}
	
	REP(i, H) {
		REP(j, W) {
			if (s[i][j] == "snuke") {
				cout << (char)('A' + j) << i + 1 << endl;
				return 0;
			}
		}
	}

	
	return 0;
}

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

typedef long long LL;
const LL mod = 1e9 + 7;

inline LL pow(LL x, LL exp) {
  LL res = 1;
  for (; exp; exp >>= 1, x = x * x % mod)
    if (exp & 1) res = res * x % mod;
  return res;
}

LL dp[5005], arr[5005];

int main() {
  LL n, k, m = 0;
  scanf("%lld%lld", &n, &k);
  for (LL i = 1; i * i <= n; i ++)
    if (n % i == 0) {
      arr[++ m] = i;
      if (i * i != n) arr[++ m] = n / i;
    }
  sort(arr + 1, arr + m + 1);
  LL ans = 0;
  for (int i = 1; i <= m; i ++) {
    dp[i] = pow(k, (arr[i] + 1) / 2);
    for (int j = 1; j < i; j ++)
      if (arr[i] % arr[j] == 0) {
	dp[i] -= dp[j];
	if (dp[i] < 0) dp[i] += mod;
      }
    if (arr[i] & 1) ans += arr[i] * dp[i] % mod;
    else ans += (arr[i] / 2) * dp[i] % mod;
    if (ans >= mod) ans -= mod;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
int a,d=0;
scanf("%d",&a);
if ((a-a%10)%111==0){
d=d+1;
	}
else if((a%1000)%111==0){
d=d+1;
	}
	if(d==1)
	{
		printf ("Yes");
	}
	else{
	printf ("No");
		}
return 0;
	}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#define ll long long
#define F first
#define FF first.first
#define FS first.second
#define S second
#define pb push_back
using namespace std;
const int N=1000006, INF=1e16;
 
ll n, q=1, m, a[N], b[N], f[N], o, k, t, x, y, z, u, h, mx, mn, ans, Ans;
pair<ll,ll> p[N];
string s, S;
vector<int> v[N], V;
 
main(){ios_base::sync_with_stdio(false), cin.tie(0);
   	
//	cin>>q;
   	
   	while(q--){ans=o=0;
   		cin>>x>>y>>z>>n;
   		if((x+y)>=n){
   			cout<<min(x, n);
		}else{
			cout<<x-(n-x-y);
		}
	}
	
}

Measured memory_bytes: 27096
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int MAX = 510000;
const int MOD = 1000000007;

long long 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() {
    // 前処理
    COMinit();
    int n,k;cin>>n>>k;
    for(int i=1;i<=k;i++){
      cout<<(COM(n-k+1,i)*COM(k-1,i-1))%MOD<<endl;
    }
}


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

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

  vector<pair<int, int>> vy(h), vx(w);
  for (int i = 0; i < h; i++) vy[i].second = i;
  for (int i = 0; i < w; i++) vx[i].second = i;

  set<pair<int, int>> s;
  for (int i = 0; i < n; i++) {
    int y, x;
    cin >> y >> x;
    y--, x--;
    vy[y].first++;
    vx[x].first++;
    s.insert({y, x});
  }

  sort(vy.rbegin(), vy.rend());
  sort(vx.rbegin(), vx.rend());

  int r = min(2, n);
  for (auto ey : vy) {
    if (ey.first + vx.front().first <= r) break;
    for (auto ex : vx) {
      if (ey.first + ex.first <= r) break;
      r = max(r, ey.first + ex.first - (int)s.count({ey.second, ex.second}));
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 21976
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
    ll n, d;
    cin >> n >> d;
    vector<ll> x(n);
    vector<ll> y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (x[i] * x[i] + y[i] * y[i] <= d * d)
        {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6420
S=input()

reverse_S=S[::-1]

while True:
    if (reverse_S.find('maerd')==0 or
        reverse_S.find('esare')==0
        ):
        reverse_S=reverse_S[5:]

    elif reverse_S.find('remaerd')==0:
        reverse_S=reverse_S[7:]
        
    elif reverse_S.find('resare')==0:
        reverse_S=reverse_S[6:]

    else:
        break

if len(reverse_S)==0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define N 15
using namespace std;
typedef pair<int,int> P;
int n;
vector<P> G[N];
int g[N][N];
int Min(int &a,int b){return a=min(a,b);}

void WF(){
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++) Min(g[i][j],g[i][k]+g[k][j]);
}

int mem[1<<N],used[1<<N];
int dfs(int bit){
  if(bit==(1<<n)-1) return 0;
  if(used[bit]++) return mem[bit];

  int res = 1e9;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if((bit>>i&1) || (bit>>j&1)) continue;
      int nbit = bit | (1<<i) | (1<<j);
      Min(res,g[i][j]+dfs(nbit));
    }
  }
  return mem[bit] = res;
}

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

  for(int i=0;i<N;i++)
    for(int j=0;j<N;j++) g[i][j] = 1e9;

  int sum = 0;  
  for(int i=0,a,b,d;i<m;i++){
    cin>>a>>b>>d;
    G[a].push_back(P(b,d));
    G[b].push_back(P(a,d));
    Min(g[a][b],d);
    Min(g[b][a],d);
    sum += d;
  } 
  
  int start = 0;
  for(int i=0;i<n;i++)
    if(G[i].size()%2==0) start |= 1<<i;
  WF();

  cout<<sum+dfs(start)<<endl;
  
  
  return 0;
}

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

int main(){
    int a , b;
    cin >> a >> b;
    if(a+b >= 10){
        cout << "error" << endl;
    }
    else{
        cout << a + b << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        SetOut(new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(int.Parse).ToArray();
        var st = new DisjointSparseTable<int>(A, GCD);
        var ans = 0;
        for (int i = 0; i < N; i++)
        {
            ans = Max(ans, GCD(st.Query(0, i), st.Query(i + 1, N)));
        }
        WriteLine(ans);
        Out.Flush();
    }

    static int GCD(int a, int b)
    {
        while (b != 0)
        {
            var c = a;
            a = b;
            b = c % b;
        }
        return a;
    }
}

public class DisjointSparseTable<T> // 半群
{
    T[,] buffer;
    Func<T, T, T> F;
    int[] log2;

    public DisjointSparseTable(T[] init, Func<T, T, T> f)
    {
        F = f;

        var n = init.Length;

        //Query[l, r) で log2[l ^ (r - 1)]を計算するため 1 << log2(r - 1) + 1 = 1 << log2(n - 1) + 1
        var log = 0;
        while ((1 << log) <= n - 1) log++;
        log2 = new int[1 << log + 1];
        for (int i = 2; i < log2.Length; i++) log2[i] = log2[i >> 1] + 1;
        log2[0] = -1;
        //log2[1] = -1;

        var h = log2[n - 1] + 1;//ceil(log2(n))
        buffer = new T[h, n];

        for (int j = 0; j < n; j++) buffer[0, j] = init[j];
        for (int i = 1; i < h; i++)
        {
            int s = 1 << i;
            for (int j = 0; j < n; j += s << 1)
            {
                if (j + s >= n) break;//左半分がいらない条件

                int t = j + s - 1;
                buffer[i, t] = init[t];
                for (int k = t - 1; k >= j; k--) buffer[i, k] = f(init[k], buffer[i, k + 1]);//非可換
                t++;
                buffer[i, t] = init[t];
                int r = Math.Min(t + s, n);
                for (int k = t + 1; k < r; k++) buffer[i, k] = f(buffer[i, k - 1], init[k]);//非可換
            }
        }
    }

    public T Query(int l, int r)
    {
        if (l == r) return default(T);
        if (r - l == 1) return buffer[0, l];
        r--;//閉区間
        var h = log2[l ^ r];
        return F(buffer[h, l], buffer[h, r]);
    }
}


Measured memory_bytes: 34012
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> R(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        R[i] = P(b, a);
    }
    priority_queue<P, vector<P>, greater<P>> B;
    for (int i = 0; i < N; i++) {
        int c, d;
        cin >> c >> d;
        B.push(P(c, d));
    }
    sort(R.begin(), R.end(), greater<P>());

    int res = 0;
    vector<bool> used(N);
    while (!B.empty()) {
        P b_p = B.top(); B.pop();
        int c = b_p.first, d = b_p.second;
        for (int i = 0; i < N; i++) {
            P r_p = R[i];
            int a = r_p.second, b = r_p.first;
            if (a < c && b < d && !used[i]) {
                res++;
                used[i] = true;
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,alphabet[26]={0};
    char moji[1201];
    while(scanf("%s",moji)!=EOF)
    {
        for(i=0;moji[i]!='\0';i++)
        {
            if(moji[i]>='A'&&moji[i]<='Z')
            {
                alphabet[moji[i]-'A']++;
            }
            if(moji[i]>='a'&&moji[i]<='z')
            {
                alphabet[moji[i]-'a']++;
            }
        }
    }
    for(i=0;i<26;i++)
    {
        printf("%c : %d\n",'a'+i,alphabet[i]);
    }
    return 0;
}


Measured memory_bytes: 2044
import Data.Array

type Z_2 = Bool

addz2::Z_2 -> Z_2 -> Z_2
addz2 True True = False
addz2 False False = False
addz2 True False = True
addz2 False True = True

addz2_3::Z_2 -> Z_2 -> Z_2 -> Z_2
addz2_3 x y z = addz2 (addz2 x y) z

convert::String->[Z_2]
convert []    = []
convert (x:xs)= (if x=='o' then False else True):(convert xs)

deconv::[Z_2]->String
deconv []     = []
deconv (x:xs) = (if x then 'W' else 'S'):(deconv xs)

genline::Array Int Z_2-> Int -> (Z_2,Z_2)->Array Int Z_2
genline b n (init_1,init_2) = let a = listArray (0,n+1) (init_1:init_2:[addz2_3 (a!(i-1)) (a!(i-2)) (b!(mod (i-1) n)) |i<-[2..(n+1)]])  in a

{--
check::Int -> Array Int Z_2 -> Bool
check n a = ((a!0) == (a!n))&&((a!1) == (a!(n+1)))
--}

check2::Array Int Z_2 -> Int -> Array Int Z_2 -> Bool
check2 b n a = let bb = listArray (0,n-1) [addz2_3 (a!(mod (i-1) n)) (a!i) (a!(mod (i+1) n)) |i <-[0..n-1]] in bb==b

solver::Array Int Z_2 -> Int ->String
solver b n = let pat = map (genline b n) [(True,True),(False,True),(True,False),(False,False)] in
              let ok = filter (check2 b n) pat in
              if ok==[] then "-1" else deconv ( take n (elems (head ok)))

main::IO()
main= do
  nc<-getLine
  let n = read nc::Int
  dat<-getLine
  let b = listArray (0,n-1) (convert dat)
  putStr ((solver b n)++"\n")

Measured memory_bytes: 37372
#include <stdio.h>

int main(){
  int S[10000], count = 0, s, t, t0, i, j;
  scanf("%d",&s);
  for(i = 0; i < s; i++) scanf("%d",&S[i]);
  scanf("%d",&t);
  for(i = 0; i < t; i++){
    scanf("%d",&t0);
    for(j=0; j < s; j++){
      if(S[j] == t0){
	count++;
	break;
	  }
	}
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define mp(a, b) make_pair(a, b)
#pragma GCC optimize("O3")
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;

void dfs(ll N, ll x, ll y, vvll &cost, const vvb &m){
    ll t = cost[x][y];
    if(m[x][y]){t++;}
    if(0<=x-1){
        if(cost[x-1][y] > t){
            cost[x-1][y] = t;
            dfs(N, x-1, y, cost, m);
        }
    }
    if(0<=y-1){
        if(cost[x][y-1] > t){
            cost[x][y-1] = t;
            dfs(N, x, y-1, cost, m);
        }
    }
    if(x+1<N){
        if(cost[x+1][y] > t){
            cost[x+1][y] = t;
            dfs(N, x+1, y, cost, m);
        }
    }
    if(y+1<N){
        if(cost[x][y+1] > t){
            cost[x][y+1] = t;
            dfs(N, x, y+1, cost, m);
        }
    }
}

int main(){
    ll N; cin >> N;
    vll p(N*N);
    rep(i, 0, N*N){
        cin >> p[i];
    }
    vvb map(N, vb(N, true));
    vvll cost(N, vll(N));
    rep(i, 0, N){
        rep(j, 0, N){
            cost[i][j] = min(min(i,j), min(N-1-i, N-1-j));
        }
    }
    ll c = 0;
    rep(i, 0, N*N){
        ll k = p[i];
        ll m = k % N;
        ll x, y;
        if(m == 0){
            x = N - 1; y = k/N- 1;
        }else{
            x = k%N - 1; y = k/N;
        }
        c += cost[x][y];
        map[x][y] = false;
        ll p = 1000000;
        p = min(p, cost[x][y]);
        if(0<=x-1){
            ll d = cost[x-1][y];
            if(map[x-1][y]){d++;}
            p = min(p, d);
        }
        if(0<=y-1){
            ll e = cost[x][y-1];
            if(map[x][y-1]){e++;}
            p = min(p, e);
        }
        if(x+1<N){
            ll f = cost[x+1][y];
            if(map[x+1][y]){f++;}
            p = min(p, f);
        }
        if(y+1<N){
            ll l = cost[x][y+1];
            if(map[x][y+1]){l++;}
            p = min(p, l);
        }
        bool s=false, g=false, r=false, n=false;
        if(0<=x-1){
            if(cost[x-1][y] > p){
                s=true;
                cost[x-1][y] = p;
            }
        }
        if(0<=y-1){
            if(cost[x][y-1] > p){
                g=true;
                cost[x][y-1] = p;
            }
        }
        if(x+1<N){
            if(cost[x+1][y] > p){
                r=true;
                cost[x+1][y] = p;
            }
        }
        if(y+1<N){
            if(cost[x][y+1] > p){
                n=true;
                cost[x][y+1] = p;
            }
        }
        if(s){
            dfs(N, x-1, y, cost, map);
        }
        if(g){
            dfs(N, x, y-1, cost, map);
        }
        if(r){
            dfs(N, x+1, y, cost, map);
        }
        if(n){
            dfs(N, x, y+1, cost, map);
        }
    }
    prt(c);
}


Measured memory_bytes: 38116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int l = 0, r = 0;
  bool flag = false;
  for (int i = 0; i < s.size(); ++i) {
    if (!flag and s[i] == 'A') {
      l = i;
      flag = true;
    }

    if (s[i] == 'Z') r = i;
  }

  cout << r - l + 1<< endl;
}


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

int main(){
	ll x,y;
	cin >> x >> y;
	cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
}


Measured memory_bytes: 256
//1.read question_2.read I/O_3.read test cases_4.read constraints(to decide TC of solution)_5.decide method_6.dry run_
//7.code_8.test_9.submit
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define mod 1000000007
#define F first
#define S second
#define _READ freopen("input.txt","r", stdin);
#define pb push_back
#define MP make_pair
#define _FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{

    _FAST
    lli n,t,i,j,k,ans=0,flag=0,a,b,m;
    cin>>n;vector<lli> ar(n);
    for(auto &i:ar)
        cin>>i;
    vector<lli> dp(n,0);
    for(i=1;i<n;i++)
        dp[i]=min(abs(ar[i-1]-ar[i])+dp[i-1]
                  ,i-2<0?INT_MAX:abs(ar[i-2]-ar[i])+dp[i-2]
                  );
    cout<<dp[n-1];
    return 0;
}


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

int main(){
    int H,W,cnt=0;
    cin >> H >> W;
    vector<vector<char>> vec(H+2,vector<char>(W+2,0));
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> vec[i+1][j+1];
        }
    }
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            if(vec[i][j]=='.'){
                for(int k=i-1;k<i+2;k++){
                    for(int l=j-1;l<j+2;l++){
                        if(vec[k][l]=='#'){
                            cnt++;
                        }
                    }
                }
                vec[i][j]='0'+cnt;
                cnt=0;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << vec[i+1][j+1];
            if(j==W-1)
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
end

N = gets.chomp.to_i

def power(n)
  return 1 if n == 1
  (n * power(n-1)) % (10 ** 9 + 7)
end

puts power(N)


Measured memory_bytes: 18256
#include <iostream>
using namespace std;
int A[1000][1000]={{}};
int b[1000]={};
int main(){
  int n, m, i, j;
  int sum;
  cin >> n >> m;
  for(i=0; i<n; i++){
      for(j=0;j<m;j++){
          cin >> A[i][j];
      }
  }
  for(i=0; i<m; i++){
      cin >>b[i];
  }
  for(i=0; i<n; i++){
      sum = 0;
      for(j=0; j<m; j++){
          sum += A[i][j] * b[j];
      }
      cout << sum << endl;
  }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  string ans;
  for(int i=0;i<2;i++) {
    for(int j=0;j<2;j++) {
      for(int k=0;k<2;k++) {
        bool f[3];
        if(i%2) f[0] = true;
        else f[0] = false;
        if(j%2) f[1] = true;
        else f[1] = false;
        if(k%2) f[2] = true;
        else f[2] = false;

        int a = s[0] - '0';
        for(int x=0;x<3;x++) {
          if(f[x]) a += s[x+1]-'0';
          else a -= s[x+1]-'0';
        }
        ans = "";
        if(a == 7) {
          ans += s[0];
          for(int x=0;x<3;x++) {
            if(f[x]) ans += "+";
            else ans += "-";
            ans += s[x+1];
          }
          ans += "=7";
          cout << ans << endl;
          return 0;
        }
      }
    }
  }


}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    int n,x,y;
    public void solve(){
        Scanner sc = new Scanner(System.in);
        sc.useDelimiter("\\s");
        n = sc.nextInt();
        int a[][] = new int [14][4];
        for(x = 0; x < 13; x++){
            for(y = 0; y < 4; y++){
                a[x][y] = 0;
            }
        }
        for(x = 0; x < n; x++){
            String b = sc.next();
            int c = sc.nextInt();
            if(b.equals("S")){
                a[c][0] = c;
            }else if(b.equals("H")){
                a[c][1] = c;
            }else if(b.equals("C")){
                a[c][2] = c;
            }else if(b.equals("D")){
                a[c][3] = c;
            }
        }
        for(y = 0; y < 4; y++){
            for(x = 1; x < 14; x++){
                if(a[x][y] == 0 && y == 0){
                    System.out.println("S " + x);
                }else if(a[x][y] == 0 && y == 1){
                    System.out.println("H " + x);
                }else if(a[x][y] == 0 && y == 2){
                    System.out.println("C " + x);
                }else if(a[x][y] == 0 && y == 3){
                    System.out.println("D " + x);
                }else{
                    continue;
                }
            }
         }
    }
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 18100
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    int cnt=0;
    bool ok=false;
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        if(x==y) cnt++;
        else cnt=0;
        if(cnt>2) ok=true;
    }
    cout<<(ok?"Yes":"No")<<'\n';
    return 0;
}

Measured memory_bytes: 3648
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
   ll n;
   ll k;
    cin>>n>>k;
    ll a[n];
    f(i,n)
        cin>>a[i];
    sort(a,a+n);
    ll sum=0;
    f(i,k)
        sum+=a[i];
    cout<<sum;
        
    return 0;
}


Measured memory_bytes: 3648
using System;

namespace ABC_070_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int a = N.Length;
            string x = N.Substring(0, 1);
            string y = N.Substring(a-1, 1);
            if (x == y)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
n = gets.chomp.to_i
a = gets.chomp.split().map(&:to_i)

ave = a.inject(:+).to_f / n

minlen = 10000
minpos = 0
n.times do |i|
  if minlen > (ave - a[i]).abs
    minlen = (ave - a[i]).abs
    minpos = i
  end
end

puts minpos


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

int main() {
  char a, b;
  cin >> a >> b;
  
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
    cout << "H" << endl;
  }
  else{
    cout << "D" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){

    Scanner scan = new Scanner(System.in);
    Integer n = scan.nextInt();

    if(n%10==3){
        System.out.println("bon");
    } else if(n%10==0 || n%10==1 || n%10==6 || n%10==8 ){
        System.out.println("pon");     
    } else {
        System.out.println("hon");     
    }  

    scan.close();
    }    
}

Measured memory_bytes: 35864
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,k,j,l,n;
	cin>>n;
	string s;
	cin>>s;
	
	for(i=0;i<s.length();i++){
		k=(s[i]-'A'+n)%26;
		s[i]='A'+k;
	}
	cout<<s;
	return 0;
}

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

using namespace std;
const int N = 105;
int a[N];
int res = 0;
int n;
void bubbleSort()
{
	int l = n;
	for(int i = 0;i < n;++i)
	{
		for(int j = 0;j < n-1;++j)
		{
			if(a[j] > a[j+1])
			{
				++res;
				swap(a[j],a[j+1]);
			}
		}
	}
}
int main()
{
	cin >> n;
	for(int i = 0;i < n;++i)
		cin >> a[i];
	bubbleSort();
	for(int i = 0;i < n;++i)
	{
		cout << a[i];
		if(i != n-1)
			cout << " ";
	}
	cout << endl;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }

//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<char> res;
    while(n > 0){
        --n;
        res.push_back( (char)('a' + n%26));
        n /=26;
    }
    reverse(res.begin(),res.end());
    for(auto a : res)cout << a;
    cout << endl;
    return 0;
}

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

typedef long long ll;
typedef double ld;

#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int > 
#define pii pair< ll, ll > 
#define len length 
#define fi first
#define se second
#define dt cout<<"HEre\n";
#define sz size
const ll inf=1e18+1e17;
const ll mod = 1e9+7;


ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}
const ll N=4e5+5;


void solve() {
	int a,b,c;
	cin>>a>>b>>c;
	int cnt=0;
	while ( b<=a){
		cnt++;
		b<<=1;
	}
	while ( c<= b){
		cnt++;
		c<<=1;
	}
	int k;
	cin>>k;
	if ( cnt<= k)
		cout<<"Yes\n";
	else
		cout<<"No\n";


  
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	ll t=1;
//	cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
    //	cout << clock() / double(CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    long long num_people;
    long long capa[5];
    long long time=0;
    long long mincapa=1000000000000000;
    long long i;

    scanf("%lld ",&num_people);
    for(i=0;i<5;i++){
        scanf("%lld",&capa[i]);
        if(capa[i]<mincapa){
            mincapa=capa[i];
        }
    }
    if(num_people%mincapa==0){
        time=(num_people/mincapa)+4;
    }
    else{
        time=(num_people/mincapa)+5;
    }
    printf("%lld",time);
    return 0;

}

Measured memory_bytes: 128
n=input()
m=input()
x=len(n)
 
y=len(m)
 
dp=[[0 for i in range(y+1)] for j in range(x+1)]
#print(len(dp),len(dp[0]))
for i in range(0,x+1):
  for j in range(0,y+1):
    if(i==0 or j==0):
      dp[i][j]=0
    elif n[i-1]==m[j-1]:
      dp[i][j]=1+dp[i-1][j-1]
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j-1])
 
i=x
j=y
ans=""
 
while i>0 and j>0:
    if(n[i-1]==m[j-1]):
        ans=ans+n[i-1]
        #print(n[i-1],1)
        i=i-1
        j=j-1
    else:
        mx=max(dp[i-1][j],dp[i][j-1])
        if mx==dp[i-1][j]:
            i=i-1
        else:
            j=j-1
print(ans[::-1])
        


Measured memory_bytes: 119516
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

llong f(llong x){
	return x*x*x*x*x;
}

int main(){
	llong x;
	cin>>x;
	
	vector<llong> num(201);
	REP(i,201) num[i]=f((llong)i);
	
	REP(i,201)for(int j=i;j<201;++j){
		if(num[i]+num[j]==x){
			cout<<i<<' '<<-j<<endl;
			return 0;
		}
	}
	
	REP(i,201)REP(j,201){
		if(num[i]-num[j]==x){
			cout<<i<<' '<<j<<endl;
			return 0;
		}
	}
}

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

int main() {
  int N, sum ,Alice, Bob;
  sum = 0; 
  cin >> N;
  vector<int> card(N); 
  
  //カードを配列に代入
  for(int i = 0; i < N; i++){
    cin >> card.at(i);
  }
  
  sort(card.begin(), card.end()); // 小さい順に並び替え
  reverse(card.begin(), card.end()); //大きい順に並び替え
 
     for(int j = 0; j < N; j++){
       if(j % 2 == 0){
       Alice += card.at(j);
       }
     }
  
     for(int j = 0; j < N; j++){
       if(j % 2 == 1){
         Bob += card.at(j);
       }
     }
  int dis = Alice - Bob;
  cout << dis << endl;
  
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    static int ans, map[110];
    int x;
    cin >> x;
    map[x] = 1;
    cin >> x;
    map[x] = 1;
    cin >> x;
    map[x] = 1;
    for (int i = 1; i <= 100; ++ i) if (map[i]) ++ ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,r,s,i,j,c,min=10000,k;
    string ch,sh;
    cin>>ch>>sh;
    for(i=0;i<=ch.length()-sh.length();i++){
            c=0;
            k=0;
        for(j=i;j<(i+sh.length());j++){
            if(ch[j]!=sh[k])
                c++;
                k++;
        }
        if(c<min)
            min=c;
    }
    cout<<min<<endl;

}


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

int main() {
  // input
  int N, D, X;
  cin >> N >> D >> X;
  
  // sum
  int A, choco = X;
  for (int i = 0; i < N; i++) {
    cin >> A;
    choco += (D + (A - 1)) / A;
  }
  
  // output
  cout << choco << endl;
  
  return 0;
}

Measured memory_bytes: 256
import math

def f(l):
    mx=max(l)
    flg=True
    for i in range(len(l)):
        if (mx==l[i] and flg==True):
            flg=False
            l[i]-=50
            l[i]=max(0,l[i])
        else:
            l[i]+=1
    return l


def solve(k):
    #k=int(input())
    N=50
    a=k//N+1
    if (k%N==0) :
        a-=1
    l=[a+i for i in range(50)]
    mod=(N-(k%N))%N
    for i in range(mod):
        l=f(l)
    l=sorted(l,reverse=True)
    print(50)
    for i in range(50):
        print(str(l[i])+" ",end="")
    print("")
    ret=0
solve(int(input()))

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int x[] = {a, b, c};
    sort(x, x+3);
    if(x[0] == 5 && x[1] == 5 && x[2] == 7) {
        cout << "YES";
    }
    else {
        cout << "NO";
    }
    
    cout << endl;
    return 0;
}

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

int main() {
	int	N;
	cin >> N;
	vector<int> vec;
	rep(i, N)
	{
		int	a;
		cin >> a;
		vec.push_back(a);
	}
	int M;
	cin >> M;
	rep(i, M)
	{
		int	bg, en;
		cin >> bg >> en;
		vector<int>::iterator itb, ite;
		itb = next(vec.begin(), bg);
		ite = next(vec.begin(), en);
		reverse(itb, ite);
	}
	rep(i, N)
	{
		if (i)
			cout << ' ';
		cout << vec.at(i);
	}
	cout << endl;
}



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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

template <typename T>
map<T, int> factorize(T n){
  map<T, int> res;
  T tmp = n;
  for(T i = 2; i * i <= n; i++){
    while(tmp % i == 0){
      ++res[i];
      tmp /= i;
    }
  }
  if(tmp != 1)res[tmp] = 1;
  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto mp = factorize(n);
  cout << n << ": ";
  ll tmp = 1;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    rep(i, itr->second){
      cout << itr->first;
      tmp *= itr->first;
      cout << "\n "[tmp != n];
    }
  }
	return 0;
}



Measured memory_bytes: 3148
import java.util.Scanner;
import java.text.DecimalFormat;
import java.math.RoundingMode;
public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int a = s.nextInt();
    int b = s.nextInt();
    s.close();
    int d = a / b;
    int r = a % b;
    double f = (double) a / b;
    DecimalFormat df = new DecimalFormat("#.00000");
    df.setRoundingMode(RoundingMode.HALF_UP);
    System.out.println(d + " " + r + " " + df.format(f));
  }
}



Measured memory_bytes: 26188
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut v: [usize; 3 * n]
    }
    v.sort_by(|x, y| y.cmp(x));
    let mut ans = 0;
    for i in 0..n {
        ans += v[2 * i + 1];
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
N = int(input())
lis = input().split()
num_lis = [int(x) for x in lis]

def Turn(AB, l):
    m = max(l)
    AB += m
    l.remove(m)

    return (AB, l)

Alice = 0
Bob = 0

while num_lis:
    Alice, num_lis = Turn(Alice, num_lis)
    
    if num_lis:
        Bob, num_lis = Turn(Bob, num_lis)
    
print(Alice - Bob)

Measured memory_bytes: 3064
#encoding: utf-8                                                                                                                                                                 

def main
  while nums = gets
    a, b = nums.chomp.split(/\s/).collect { |x| x.to_i}
    sum = a + b
    puts dig(sum)
  end
end

def dig num
  res = 0
  while num != 0
    res += 1
    num /= 10   
  end
  res
end

main

Measured memory_bytes: 6104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
vector<ll> v;
ll K;

void dfs(int d) {
    if(v.size() == d) {
        K--;
        if(K == 0) {
            for(auto tmp : v) cout << tmp;
            cout << endl;
            exit(0);
        }
        return;
    }
    if(v.empty()) {
        for(int i = 1; i <= 9; i++) {
            v.push_back(i);
            dfs(d);
            v.pop_back();
        }
    } else {
        for(int i = v.back() - 1; i <= v.back() + 1; i++) {
            if(i < 0 or i > 9) continue;
            v.push_back(i);
            dfs(d);
            v.pop_back();
        }
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> K;
    for(ll d = 1; ; d++) {
        dfs(d);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
int main (void) {
    ll N, M;

    cin >> N >> M;

    ll ans;
    ll mi = min(N, M);
    ll ma = max(N, M);
    if (mi == 1 && ma == 1) ans = 1;
    else if (mi == 1) ans = ma - 2;
    else ans = (N - 2) * (M - 2);

    cout << ans << endl;

    return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5])
    cout << "Yes" << endl;
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256