akhauriyash/Code-Regression huggingface dataset:
use proconio::*;
use proconio::marker::{Bytes, Chars};
use std::*;

#[warn(unused_imports)]
const MOD: i128 = 100_000_007;

#[fastout]
fn main() {
    input!{
        num_list : [i32;5]
    };
    for i in 0..5{
        if num_list[i] == 0 {
            println!("{}", i+1);
            break;
        }
    }
}


Measured memory_bytes: 2124
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int n;
  scanf("%d",&n);
  vi a(n), b(n);
  rep(i,n) {
    scanf("%d%d",&a[i],&b[i]);
  }
  ll ans = 0;
  drep(i,n) {
    ll x = (b[i]-(ans+a[i])%b[i])%b[i];
    ans += x; 
  }
  cout<<ans<<endl;
  return 0;
}































Measured memory_bytes: 1024
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s1, s2, s3 string
	fmt.Scan(&s1, &s2, &s3)
	ans := strings.ToUpper(s1[0:1] + s2[0:1] + s3[0:1])
	fmt.Println(ans)
}


Measured memory_bytes: 640
d = int(input())
clst = list(map(int, input().split()))
slst = []
lastday = [0] * 26
for i in range(d):
  slst.append(list(map(int, input().split())))
res = 0
for i in range(1, d + 1):
  t = int(input())
  lastday[t - 1] = i
  res += slst[i - 1][t - 1]
  c = 0
  for j in range(26):
    c += clst[j] * (i - lastday[j])
  res -= c
  print(res)

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int INF = 2e9 + 7;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    int mn = INF;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (arr[i] < mn) {
            ans++;
        }
        mn = min(mn, arr[i]);
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;
ll n , m , a[maxn] , b[maxn] , c[maxn] ; 
pair<ll , ll> p[maxn] ; 
int main()
{
	migmig ;
	cin>>n>>m ; 
	for(int i = 0 ; i < n ; i++) cin>>a[i] ; 
//	for(int i = 0 ; i < m ; i ++) cin>>b[i]>>c[i] ; 
for(int i = 0 ; i < m ; i++)
{
	cin>>p[i].second>>p[i].first ; 
	}	
	sort(a , a+n) ; 
	sort(p , p+m  ,  greater<pair<ll , ll>>()) ; 
	
	int j = 0 ;
	for(int i = 0 ; i < n ; i ++)
	{
		if(p[j].X > a[i]) 
		{
			a[i]= p[j].X ; 
			p[j].Y -- ; 
			if(p[j].Y == 0) j++ ; 
			if(j >= m ) break ; 
		}
	//	cout<<a[i]<<" " ; 
	}
	
//a	cout<<endl ; 
	
	ll sum = 0  ; 
	 for(int i = 0 ; i < n ; i++) sum+= a[i] ; 
	 cout<<sum ; 
	

}
//////
////////
///////////



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll N) {
  N--;
  const char table[] = "abcdefghijklmnopqrstuvwxyz";

  string name;
  while (N >= 26) {
    // printf("N=%lld N\%26=%lld %c\n", N, N % 26, table[N % 26]);
    name += table[N % 26];
    N /= 26;
    N--;
  }
  name += table[N];
  // printf("N=%lld %c\n", N, table[N]);
  reverse(name.begin(), name.end());
  cout << name << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;

  solve(N);

  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

vector<vector<int>> g;

void dfs(vector<int> &v,const int par,const int cnt) {
    for(auto x:g[cnt]) {
        if (x == par) continue;
        v[x] = v[cnt] + 1;
        dfs(v,cnt,x);
    }
}

int main(void)
{
    IOS
    int N, T, A;
    cin >> N >> T >> A;
    T--; A--;
    g.resize(N);
    REP(i,N-1) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> vt(N), va(N);
    dfs(vt,-1,T);
    dfs(va,-1,A);
    int ans = 0;
    REP(i,N) {
        if (vt[i] <= va[i]) ans = max(ans,va[i]-1);
        //cerr << vt[i] << " " << va[i] << endl;
    }

    cout << ans << '\n';

    return 0;
}

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

#define MOD 1000000007
#define f first
#define s second
#define es " "
#define pb push_back
#define endl "\n"
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define ll long long int
#define fastio ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int matriz[305][305], dist[305][305];

int main(){
    fastio;
    int n, m, q, l;
    cin >> n >> m >> l;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            matriz[i][j]=INF, dist[i][j]=INF;
        }
        matriz[i][i]=0, dist[i][i]=l;
    }
    for(int i=0, a, b, c; i<m; i++){
        cin >> a >> b >> c;
        matriz[a][b]=c;
        matriz[b][a]=c;
    }
    cin >> q;
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                matriz[i][j]=min(matriz[i][j], matriz[i][k]+matriz[k][j]);
            }
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(matriz[i][j]<=l){
                dist[i][j]=1;
            }
        }
    }
    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                dist[i][j]=min(dist[i][j], dist[i][k]+dist[k][j]);
            }
        }
    }
    //cout << dist[2][4] << endl;
    for(int i=0, a, b; i<q; i++){
        cin >> a >> b;
        if(dist[a][b]==INF) cout << -1 << endl;
        else cout << dist[a][b]-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4304
#[allow(unused_macros)]
macro_rules! input {
    ($x:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        $x = buf.trim().parse().unwrap();
    };

    ($x:expr, $($y:expr), +) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        input_iter!(buf.split_whitespace(), $x, $($y), +);
    };

    ($v:expr; $size:expr) => {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).ok();
        for v in buf.split_whitespace() {
            $v.push(v.parse().unwrap());
        }
    };

    ($v:expr; $h_size:expr, $w_size:expr) => {
        for _ in 0..$h_size {
            let mut part_vec = Vec::new();
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).ok();
            for v in buf.split_whitespace() {
                part_vec.push(v.parse().unwrap());
            }
            $v.push(part_vec);
        }
    };
}

#[allow(unused_macros)]
macro_rules! input_iter {
    ($iter:expr, $x:expr) => {
        $x = $iter.next().unwrap().parse().unwrap();
    };

    ($iter:expr, $x:expr, $($y:expr), +) => {
        let mut iter = $iter;
        $x = iter.next().unwrap().parse().unwrap();
        input_iter!(iter, $($y), *);
    };
}

#[allow(unused_imports)]
use std::collections::*;
use std::collections::hash_map::Entry::*;

fn main() {
    let s: String;
    let t: String;
    input! { s };
    input! { t };
    let mut hm: HashMap<char, Vec<usize>> = HashMap::new();
    for (i, c) in s.chars().enumerate() {
        hm.entry(c).or_insert(Vec::new()).push(i);
    }
    let mut set_num = 0;
    let mut cur_idx = 0;
    for c in t.chars() {
        if let Vacant(_) = hm.entry(c) {
            print!("-1");
            return;
        }
        let v = hm.get(&c).unwrap();
        let mut idx = match v.binary_search(&cur_idx) {
            Ok(x) => x,
            Err(x) => x,
        };
        if idx >= v.len() {
            set_num += 1;
            idx = 0;
        }
        cur_idx = v[idx] + 1;
    }
    println!("{}", set_num * s.len() + cur_idx);
}


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

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

  ll N; cin >> N;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  vector<ll> S(N + 1, 0); for (ll i = 0; i < N; i++) S[i + 1] = S[i] + A[i];

  vector<ll> L(N, 0);
  ll l, r;
  l = 1;
  for (ll i = 2; i < N - 1; i++) {
    r = i;
    while (true) {
      ll cDiff = max(S[r] - S[l], S[l]) - min(S[r] - S[l], S[l]);
      if (l + 1 == r) {
        L[i] = l;
        break;
      } else {
        l++;
        ll nDiff = max(S[r] - S[l], S[l]) - min(S[r] - S[l], S[l]);
        if (cDiff <= nDiff) {
          l--;
          L[i] = l;
          break;
        }
      }
    }
  }
  // cout << L[0]; for (int i = 1; i < L.size(); i++) { cout << ' ' << L[i]; }

  vector<ll> R(N, 0);
  l, r = N - 1;
  for (ll i = N - 2; i > 1; i--) {
    l = i;
    while (true) {
      ll cDiff = max(S[N] - S[r], S[r] - S[l]) - min(S[N] - S[r], S[r] - S[l]);
      if (l == r - 1) {
        R[i] = r;
        break;
      } else {
        r--;
        ll nDiff = max(S[N] - S[r], S[r] - S[l]) - min(S[N] - S[r], S[r] - S[l]);
        if (cDiff <= nDiff) {
          r++;
          R[i] = r;
          break;
        }
      }
    }
  }
  // cout << R[0]; for (int i = 1; i < R.size(); i++) { cout << ' ' << R[i]; }

  ll ans = 1e15;
  for (ll i = 2; i < N - 1; i++) {
    l = L[i], r = R[i];
    vector<ll> X = {S[l], S[i]- S[l], S[r] - S[i], S[N] - S[r]};
    // cout << X[0]; for (int i = 1; i < X.size(); i++) { cout << ' ' << X[i]; }
    // cout << '\n';
    ans = min(ans, *max_element(X.begin(), X.end()) - *min_element(X.begin(), X.end()));
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 8576
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

int N;
string S;
vi toWhite,toBlack;
int ans=INF;

signed main(){

    in(N,S);
    toWhite.resize(N+1);toBlack.resize(N+1);

    rep(i,N){
        toWhite[i+1]=toWhite[i]+(S[i]=='#');
    }
    REPEAT(i,0,N,false){
        toBlack[i]=toBlack[i+1]+(S[i]=='.');
    }
    show(toWhite,toBlack);
    rep(i,N+1){
        ans=min(ans,toWhite[i]+toBlack[i]);
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 4340
#include <string.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int *)a - *(int *)b; //昇順になる
}
int main(void) //qsort等しないと時間かかりすぎみたいね
{
    int N;
    int a[200000];
    for (int i = 0; i < 200000; i++)
    {
        a[i] = -1;
    }
    int flag = 0;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d", &a[i]);
    }
    qsort(a, N, sizeof(int), compare_int);
    for (int i = 0; i < N - 1; i++)
    {
        if (a[i] == a[i + 1])
        {
            printf("NO");
            flag = 1;
            break;
        }
    }

    if (flag == 0)
    {
        printf("YES");
    }
    return 0;
}


Measured memory_bytes: 1788
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 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, 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_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        K: usize,
        sushi: [(usize1, usize); N],
    }
    sushi.sort_by(|a, b| b.1.cmp(&a.1));

    let mut s: Vec<(usize, usize)> = sushi.iter().rev().skip(N-K).cloned().collect();
    let mut neta_num: Vec<usize> = vec![0; 100000]; 
    let mut min = 0;
    for &(t, d) in s.iter() {
        neta_num[t] += 1;
        min += d;
    }
    let x = neta_num.iter().filter(|num| **num > 0).count();

    let mut iter_sushi = sushi.iter().skip(K);
    let mut iter_s = s.iter();
    let mut max = min + x * x;
    let mut previous = max;

    for t_unique in x+1..K+1 {
        if let Some(&(t, d)) = 
            iter_s.by_ref().skip_while(|&&(t, _d)| neta_num[t] < 2).next() { 
            neta_num[t] -= 1;
            previous -= d;
        } else {
            break;
        }

        if let Some(&(t, d)) = 
            iter_sushi.by_ref().skip_while(|&&(t, _d)| neta_num[t] > 0).next() {
                neta_num[t] += 1;
                previous += d + 2 * t_unique - 1; 
        } else {
            break;
        }

        if max < previous {
            max = previous
        }
    }

    println!("{}", max);
}


Measured memory_bytes: 10620
object Main extends App {
  def isNoDown(hs: List[Int]): String = {
    @annotation.tailrec
    def f(l: List[(Int, Int)], before: Int, isDown: Boolean = false): String = l match {
      case h :: t =>
        val diff = h._2 - h._1
        if (diff < 0 && isDown) "No"
        else if (diff < -1) "No"
        else if (before < 0 && diff < 0) "No"
        else f(t, diff, ((before < 0 || isDown) && diff == 0))
      case _ => "Yes"
    }

    f(hs.zip(hs.tail), 0, false)
  }
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val hs = List.fill(n)(sc.nextInt)

  println(isNoDown(hs))
}

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

static class Program
{
    const int INF = int.MaxValue / 2;

    static int BitCount(int n)
    {
        int count = 0;
        while (n > 0)
        {
            if ((n & 1) != 0) { ++count; }
            n >>= 1;
        }
        return count;
    }

    static int Count(int W, int K, List<List<string>> rows)
    {
        int H = rows.Count;
        int ans = 0;
        var sum1 = new int[H];
        for (int i = 0; i < W; ++i)
        {
            var sum2 = new int[H];
            for (int j = 0; j < H; ++j)
            {
                foreach (string row in rows[j])
                {
                    if (row[i] == '1') { ++sum2[j]; }
                }
            }
            if (sum2.Any(sum => sum > K)) { return INF; }
            if (Enumerable.Range(0, H).Any(j => sum1[j] + sum2[j] > K))
            {
                sum1 = new int[H];
                ++ans;
            }
            for (int j = 0; j < H; ++j) { sum1[j] += sum2[j]; }
        }
        return ans;
    }

    static int Solve(int H, int W, int K, string[] S)
    {
        int min = INF;
        for (int i = 0; i < 1 << (H - 1); ++i)
        {
            var rows = new List<List<string>>();
            rows.Add(new List<string>());
            for (int j = 0; j < H; ++j)
            {
                rows.Last().Add(S[j]);
                if ((i & (1 << j)) != 0)
                {
                    rows.Add(new List<string>());
                }
            }
            min = Math.Min(Count(W, K, rows) + BitCount(i), min);
        }
        return min;
    }

    static void Main(string[] args)
    {
        int[] V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int H = V[0], W = V[1], K = V[2];
        var S = new string[H];
        for (int i = 0; i < H; ++i) { S[i] = Console.ReadLine(); }
        Console.WriteLine(Solve(H, W, K, S));
    }
}


Measured memory_bytes: 22984
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<lli>/*------------------*/vlli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()
#define makepair/*---------------------*/make_pair

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli a,b;
	string s;
    cin >> a >> b;
    cin >> s;
    if(s.length() < a+b+1)
    {
        cout << "No";
    }
    else
    {
        if(s[a] != '-')
        {
            cout << "No";
        }
        else
        {
            bool check = true;
            lli i;
            rep(i,s.length())
            {
                if(i == a) continue;
                if(s[i] >= '0' and s[i] <= '9')
                    ;
                else
                {
                    check = false;
                    break;
                }
            }

                if(check)
                    cout << "Yes";
                else
                    cout << "No";
        }
    }
	return 0;
}










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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

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

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 N, M;
  cin >> N >> M;
  if (N == M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
n, x, y = gets.chomp.split.map(&:to_i)

ans = Array.new(n, 0)
(1..n).to_a.combination(2) do |a|
  s, e = a
  tmp = (s-x).abs + (e-y).abs + 1
  l = [e-s, tmp].min
  ans[l] += 1
end
n.times do |i|
  next if i == 0
  p ans[i]
end


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vvi c(n);
	vvi g(n);
	function<void(int)> dfs = [&](int v) {
		c[v].push_back(v);
		int l = v * 2 + 1, r = v * 2 + 2;
		if (l < n) {
			dfs(l);
			REP(i, c[l].size())c[v].push_back(c[l][i]);
		}
		if (r < n) {
			dfs(r);
			REP(i, c[r].size())c[v].push_back(c[r][i]);
		}
	};

	dfs(0);
	REP(i, n) {
		int l = i * 2 + 1, r = i * 2 + 2;
		if (l < n) {
			REP(j, c[l].size()) {
				g[i].push_back(c[l][j]);
			}
		}
	}
	int cnt = 0;
	REP(i, n)cnt += g[i].size();
	cout << cnt << endl;
	REP(i, n)REP(j, g[i].size())cout << i + 1 << " " << g[i][j] + 1 << endl;
	int v = 0;
	REP(aaa, k) {
		int v = 0;
		while (1) {
			cout << v + 1 << endl;
			string s; cin >> s;
			if (s == "No") {
				v = 2 * v + 2;
			}
			else if (s == "Near") {
				v = 2 * v + 1;
			}
			else {
				break;
			}
		}
	}

}


Measured memory_bytes: 3308
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,k,l,o;
char c[6666666];
int main(){
    scanf("%d%d",&n,&k);
    if(k>n*2+2){
        if(k&1)k=n*2+3;
        else k=n*2+2;
    }
    for(int i=1;i<=n;++i)scanf(" %c",c+i);
    l=1;
    for(int i=1;i<=k;++i){
        if(o&&c[l]=='B')c[l]='A';
        else if(!o&&c[l]=='A')c[l]='B';
        else{
            o^=1,++l;
            if(o)c[l+n-1]='B';
            else c[l+n-1]='A';
        }
    }
    if(o){
        for(int i=l;i<l+n;++i){
            if(c[i]=='A')c[i]='B';
            else c[i]='A';
        }
    }
    for(int i=l;i<l+n;++i)printf("%c",c[i]);
    printf("\n");
    //system("pause");
    return 0;
}


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

int main() {
  string s1, s2;
  cin >> s1;
  cin >> s2;

  reverse(s1.begin(), s1.end());
  if (s1 == s2) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}



Measured memory_bytes: 256
d=int(input())
c=list(map(int,input().split()))
s=[]
for _ in range(d):
    s_i=list(map(int,input().split()))
    s.append(s_i)

dp=[0]*26

def score_ans(s,c,now):
    tmp=0
    for i in range(26):
        tmp+=c[i]*(now - dp[i])
    
    return s-tmp

for i in range(d):

    score=0
    ans=1
    for j in range(26):
        s_i=s[i][j]
        if score<score_ans(s_i,c,i):
            ans=j+1

        dp[ans-1]=i    
    

    print(ans)

Measured memory_bytes: 9516
int main() {
    int t;
    __builtin_scanf("%d", &t);

    int h = t / 3600;
    int r = (t % 3600) / 60;
    int m = (t % 3600 ) % 60;
    
    __builtin_printf("%d:%d:%d\n", h, r, m);
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<P>>;
 
int main() {
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back(P(b, c));
        G[b].push_back(P(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    K--;
    vector<int> x(Q), y(Q);
    rep(i, Q) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
 
    vector<ll> dist(N, -1);
    queue<int> que;
    dist[K] = 0;
    que.push(K);
 
    while (!que.empty()) {
        int v = que.front(); que.pop();
 
        for (P nv: G[v]) {
            if (dist[nv.first] != -1) continue;
            dist[nv.first] = dist[v] + nv.second;
            que.push(nv.first);
        }
    }
    
    rep(i, Q) {
        cout << dist[x[i]] + dist[y[i]] << endl;
    }
    return 0;
}

Measured memory_bytes: 9588
#include <iostream>

using namespace std;

int main()
{
    long long int n = 0;
    cin >> n;
    long long int minv, maxv;

    cin >> minv;
    maxv = -2000000000;
    long long int temp;
    for(long long int i = 1; i < n; i++) {
        cin >> temp;
        maxv = (temp - minv) > maxv ? (temp - minv) : maxv;
        minv = temp < minv ? temp : minv;
    }

    cout << maxv << endl;


	return 0;
}



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

using namespace std;

#define LL long long
#define ULL unsigned LL
#define LD long double

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int x;
	cin>>x;
	LL a = x / 500;
	LL b = (x%500) / 5;
	LL w = a * 1000 + 5 * b;
	cout<<w;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int A[1];
int size=1;
int m=2;
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
/*
bool prime(ll n){if(n==1)return false;for(ll i=2;i*i<=n;i++)if(n%i==0){return false;}return true;}
void prime_fact(int n){for(int i=2;i*i<=n;i++){int count=0;if(n%i==0){while(n%i==0)n/=i,count++;cout<<i<<"^"<<count<<" ";}}if(n>1)cout<<n<<"^1";}
ll power(ll base ,ll pow){ll res=1;while(pow>0){if(pow&1)res*=base,pow-=1;else base*=base,pow/=2;}return res;}
void prime_fact_seieve(int n){for(int i=2;i<=size;i++){if(A[i]==0)for(ll j=i;j<=size;j+=i)if(A[i]==0)A[j]=i;}while(n>2){cout<<A[n]<<"*";n/=A[n];}}
template <class X> X gcd(X a , X b) { return b==0?a: gcd( b, a%b); }
template <class X> X lcm(X a , X b) { return a/gcd(a,b) * b ; }
ll Ab[N][N],I[N][N];  // identity matrix and a matrix to store result
void multiply(ll I[][N],ll A[][N],int dim)
{   int res[dim+1][dim+1];
    for(int i=0;i<dim;i++)
    {  for(int j=0;j<dim;j++)
        {
           res[i][j]=0;
           for(int k=0;k<dim;k++)
           {  res[i][j]+=((I[i][k]%mod)*(A[k][j])%mod)%mod;}}}

        for(int i=0;i<dim;i++)
            for(int j=0;j<dim;j++)
                I[i][j]=res[i][j];}
void powerMat(ll A[][N],int dim,int n)
{   for(int i=0;i<dim;i++)
    for(int j=0;j<dim;j++)
    {if(i==j) I[i][j]=1;
     else     I[i][j]=0;}
     while(n>0)
     {
         if(n%2)
         multiply(I,A,dim),n--;
         else
         multiply(A,A,dim),n/=2;
     }
     for(int i=0;i<dim;i++)
         for(int j=0;j<dim;j++)
             A[i][j]=I[i][j];
}
void printMat(ll A[][N],int dim)
{
    for(int i=0;i<dim;i++)
    {for(int j=0;j<dim;j++)
        {
            cout<<A[i][j]<<" ";
        }cout<<"\n";}
}
// REMEMBER PREFIX SUM SUFFIX SUM OR GCD VERY INTERESTING QUESTIONS
ll power(ll base ,ll pow,ll mo){ll res=1;while(pow>0){if(pow&1)res=(res%mo*base%mo)%mo,pow-=1;else base=(base%mo*base%mo)%mo,pow/=2;}return res;}*/
bool Binary(vector<int> arr,int n,int ele,int b)
{  int l=0,r=n-1,m;
   while(l<=r)
   {
       m=l+(r-l)/2;
       if(arr[m]==ele)
       {arr[m]=b;return true;}
       else if(arr[m]>ele)
           r=m-1;
       else
           l=r+1;
   }
    return false;

}

int main() {
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    if(c<=a)cout<<a-c<<" "<<b;
    else if(c>a&&c-a<=b){cout<<0<<" "<<b-c+a;}
    else cout<<0<<" "<<0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 100000000000
#define BLK 555
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
const int mod = 1000000007;
const int N = 2e5+5, M = N;
//=========================================

bool check(string s){
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] != s[n-1-i])
            return false;
    }

    return true;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    string s;
    cin >> s;
    int n = s.size();
    string a = s.substr(0,n/2);
    string b = s.substr(n/2 + 1, n/2);

    //cout << a << " " << b;

    if(check(s) && check(a) && check(b)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;

}


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

int main()
{
    int n,a,b;
    cin >> n >> a >> b;

    int x,sum,ans = 0;
    for(int i = 1; i <= n; i++){
        x = i;
        sum = 0;
        while(x){
            sum += x % 10;
            x /= 10;
        }
        if(sum >= a && sum <= b) ans += i;
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int N = 2010;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a, b;
    cin >> a >> b;
    int n = a.length();
    vector<int> p;
    for (int i = 0; i < n; ++i) {
        if (b[i] == '1') {
            p.push_back(i);
        }
    }
    if (p.empty()) {
        if (a.find('1') == string::npos) {
            cout << 0;
        } else {
            cout << -1;
        }
        return 0;
    }
    p.insert(p.begin(), p.back() - n);
    p.push_back(p[1] + n);
    int ans = 100000;
    vector<int> l(n), r(n);
    for (int i = 0; i < n; ++i) {
        int pos = lower_bound(p.begin(), p.end(), i) - p.begin();
        r[i] = p[pos];
        if (p[pos] > i) {
            l[i] = p[pos - 1];
        } else {
            l[i] = i;
        }
    }
    //right
    for (int shift = 0; shift <= n; ++shift) {
        int ch = 0;
        multiset<int, greater<int>> s;
        vector<int> e[N];
        s.insert(0);
        for (int j = 0; j < n; ++j) {
            if (a[j] != b[(j + shift) % n]) {
                ++ch;
                s.insert(j - l[j]);
                e[r[j] - j].push_back(j - l[j]);
            }
        }
        ans = min(ans, shift + ch + *s.begin() * 2);
        for (int j = 1; j <= n; ++j) {
            for (int k : e[j]) {
                s.erase(s.find(k));
            }
            ans = min(ans, j + min(abs(shift - j) % n, n - abs(shift - j)) + ch + *s.begin() * 2);
            ans = min(ans, j * 2 + *s.begin() + min(abs(*s.begin() - shift) % n, n - abs(*s.begin() - shift)) + ch);
        }
    }
    //left
    for (int shift = 0; shift <= n; ++shift) {
        int ch = 0;
        multiset<int, greater<int>> s;
        vector<int> e[N];
        s.insert(0);
        for (int j = 0; j < n; ++j) {
            if (a[j] != b[(j - shift + n) % n]) {
                ++ch;
                s.insert(r[j] - j);
                e[j - l[j]].push_back(r[j] - j);
            }
        }
        ans = min(ans, shift + ch + *s.begin() * 2);
        for (int j = 1; j <= n; ++j) {
            for (int k : e[j]) {
                s.erase(s.find(k));
            }
            ans = min(ans, j + min(abs(shift - j) % n, n - abs(shift - j)) + ch + *s.begin() * 2);
            ans = min(ans, j * 2 + *s.begin() + min(abs(*s.begin() - shift) % n, n - abs(*s.begin() - shift)) + ch);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(auto &x : A) cin >> x;
    sort(WHOLE(A));
    vector<int> P;
    P.push_back( (N - 1) / 2);
    int r = N - 1, l = 0;
    while(P.size() < N) {
        P.push_back(r);
        r--;
        if (P.size() < N) {
            P.push_back(l);
            l++;
        }
    }
    i64 cand0 = 0, cand1 = 0;
    for(int i = 0; i < N - 1; i++) {
        cand0 += abs(A[P[i]] - A[P[i + 1]]);
        cand1 += abs(A[N - 1 - P[i]] - A[N - 1 - P[i + 1]]);
    }
    i64 ans = max(cand0, cand1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1276
#pragma GCC optimize("O3,inline,unroll-loops")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 200020
using namespace std;

long long a[N], b[N];

int main(void)
{
    int n, m, k;
    int i, o;

    scanf("%d %d %d", &n, &m, &k);
    for(i = 1; i <= n; i ++)
    {
        scanf("%lld", &a[i]);
        a[i] += a[i - 1];
    }
    for(i = 1; i <= m; i ++)
    {
        scanf("%lld", &b[i]);
        b[i] += b[i - 1];
    }

    for(i = o = 0; i <= n; i ++)
        if(k >= a[i])
            o = max(o, i + (int)(upper_bound(b, b + m + 1, k - a[i]) - b - 1));
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 6948
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
const ll INF = 1e15;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    int k[3] = {a,b,c};
    sort(k,k+3);
    PRINT(k[2]*10+k[1]+k[0]);
}


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

int main() {
  int n, cnt = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    if ((i + 1) % 2 == 1 && a.at(i) % 2 == 1) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>

int main(){
  int A[1000],i,v,j,N,f;

  scanf("%d\n",&N);
 
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  
  for(i=1;i<=N-1;i++){
    v = A[i];
    j = i - 1;

    while(j >=0 && A[j]>v){
      A[j+1] = A[j];
      j = j - 1;
      A[j+1]=v;
    }
    for(f=0;f<N-1;f++){
      printf("%d ",A[f]);
    }
    printf("%d\n",A[N-1]);
  }
  return 0;
}

Measured memory_bytes: 604
import math
N = int(input())
P = [tuple(map(int, input().split())) for _ in range(N)]
DONE = (1 << N) - 1

ds = []
todo = [(0, i, (1 << i)) for i in range(N)]
while todo:
    d, i, state = todo.pop()
    x, y = P[i]
    for ni in range(N):
        if state & (1 << ni):
            continue
        nx, ny = P[ni]
        nd = d + math.sqrt((x - nx) ** 2 + (y - ny) ** 2)
        nstate = state | (1 << ni)
        if nstate == DONE:
            ds.append(nd)
        else:
            todo.append((nd, ni, nstate))
ans = math.fsum(ds) / len(ds)
print(ans)

Measured memory_bytes: 10664
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int cnt(int,int);

int main(void){
        int i,j;
        int ans = 0;
        int n;
        int a[10][10];
        int b,c;
        for(i=1;i<=9;i++){
                for(j=1;j<=9;j++){
                        a[i][j]=0;
                }
        }


        scanf("%d",&n);

        for(i=1;i<=n;i++){
                c = i%10;
                b = i;
                while(b>=10){b=b/10;};
                a[c][b] ++;
        }

        for(i=1;i<=9;i++){
                for(j=1;j<=9;j++){
                        ans += a[i][j] * a[j][i];
                }
        }
        printf("%d\n",ans);
        return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstring>
 
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<29;

int w, h;
int field[110][110];
int visit[110][110];
int dx[][6] = {
	{-1, -1, -1, 0, 0, 1},
	{-1, 0, 0, 1, 1, 1},
};
int dy[][6] = {
	{-1, 0, 1, -1, 1, 0},
	{0, -1, 1, -1, 0, 1},
};

int main(){
	cin >> w >> h;
	FOR(i, 1, h+1) FOR(j, 1, w+1) cin >> field[i][j];

	queue<P> q;
	q.push(MP(0, 0));

	int ans = 0;
	while(!q.empty()){
		P p = q.front();
		q.pop();

		if(field[p.Y][p.X]){
			ans++;
			continue;
		}
		if(visit[p.Y][p.X]) continue;
		visit[p.Y][p.X] = 1;

		int k = p.Y&1;
		rep(i, 6){
			int nx = p.X + dx[k][i], ny = p.Y + dy[k][i];
			if(nx < 0 || nx > w+1 || ny < 0 || ny > h+1) continue;
			q.push(MP(nx, ny));
		}
	}

	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
	string a,b;
	cin>>a>>b;
	int sum=0;
	for(int i=0;i<a.size();i++){
		if(a[i]!=b[i]){
			sum++;
		}
	}
	cout<<sum;

	return 0;
}


Measured memory_bytes: 3824