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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

const int BUCKET = 400,SIZE = 300;
int N,Q;
ll bucketAdd [BUCKET];
ll bucketSum [BUCKET];
ll A [100000];

void update(int l,int r,ll val)
{
	FOR(i,0,BUCKET){
		int bucketL = i * SIZE,bucketR = (i + 1) * SIZE;
		if(r <= bucketL || bucketR <= l) continue;
		if(l <= bucketL && bucketR <= r){
			bucketAdd [i] += val;
			bucketSum [i] += val * SIZE;
			continue;
		}
		FOR(j,bucketL,bucketR){
			if(l <= j && j < r){
				bucketSum [i] += val;
				A [j] += val;
			}
		}
	}
}

ll getSum(int l,int r)
{
	ll res = 0;
	FOR(i,0,BUCKET){
		int bucketL = i * SIZE,bucketR = (i + 1) * SIZE;
		if(r <= bucketL || bucketR <= l) continue;
		if(l <= bucketL && bucketR <= r){
			res += bucketSum [i];
			continue;
		}
		FOR(j,bucketL,bucketR){
			if(l <= j && j < r){
				res += bucketAdd [i] + A [j];
			}
		}
	}
	return res;
}

int main()
{
	scanf("%d%d",&N,&Q);
	vector<ll> ans;
	FOR(i,0,Q){
		int com;
		scanf("%d",&com);
		if(com == 0){
			int s,t,x;
			scanf("%d%d%d",&s,&t,&x);
			update(s - 1,t,x);
		}
		else{
			int s,t;
			scanf("%d%d",&s,&t);
			ans.push_back(getSum(s - 1,t));
		}
	}

	FOR(i,0,ans.size()){
		printf("%lld\n",ans [i]);
	}

	return 0;
}

Measured memory_bytes: 4244
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

ll N;
vector<ll> As;

struct Two {
    unordered_set<ll> elems;
    void add(ll k) {
        if (elems.size() < 2) {
            elems.insert(k);
        } else if (elems.find(k) != elems.end()) {
            return;
        } else {
            ll i = *elems.begin();
            ll j = *next(elems.begin());
            if (As[j] < As[i]) {
                swap(i, j);
            }
            if (As[i] < As[k]) {
                elems.clear();
                elems = {k, j};
            }
        }
    }
    void add(const Two& x) {
        for (ll elem : x.elems) {
            add(elem);
        }
    }
};

vector<Two> twoes;
vector<ll> two_sums;

int main() {
    cin >> N;
    As.resize(1 << N);
    rep(i,0,1 << N) {
        cin >> As[i];
    }
    twoes.resize(1 << N);
    rep(i,0,1<<N) {
        twoes[i].add(i);
        rep(bit,0,N) {
            if (i & (1 << bit)) {
                ll j = i & ~(1 << bit);
                twoes[i].add(twoes[j]);
            }
        }
    }
    two_sums.resize(1 << N);
    rep(i,0,1<<N) {
        for (ll elem : twoes[i].elems) {
            two_sums[i] += As[elem];
        }
    }
    rep(K,1,1<<N) {
        ll ans = numeric_limits<ll>::min();
        ans = max(ans, two_sums[K]);
        rep(bit,0,N) {
            if (K & (1 << bit)) {
                ll L = K;
                L &= ~(1 << bit);
                L |= ((1 << bit) - 1);
                ans = max(ans, two_sums[L]);
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define in(x, a, b) a <= x && x < b
const int inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
//const ll mod = 1000000009;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p <<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	ll n, c;
	cin >> n >> c;
	vl x(n + 1), v(n + 1);
	rep1(i, n) {
		cin >> x[i] >> v[i];
	}
	x.push_back(c);
	vl migi(n), hidari(n), migima(n), hidarima(n);
	ll now = 0, ma = 0;
	rep(i, n) {
		now = now - (x[i + 1] - x[i]) + v[i + 1];
		migi[i] = now;
		ma = max(ma, now);
		migima[i] = ma;
	}
	now = 0; ma = 0;
	for (int i = n; i > 0; i--) {
		now = now - (x[i + 1] - x[i]) + v[i];
		hidari[i - 1] = now;
		ma = max(ma, now);
		hidarima[i - 1] = ma;
	}
	/*
	DEBUG_VEC(migi);
	DEBUG_VEC(migima);
	DEBUG_VEC(hidari);
	DEBUG_VEC(hidarima);
	//*/
	ll ans = max(migima[n - 1], hidarima[0]);
	rep(i, n - 1) {
		ll add = migima[i];
		add -= x[i + 1];
		add += hidarima[i + 1];
		ans = max(ans, add);
	}
	for (int i = n - 1; i > 0; i--) {
		ll add = hidarima[i];
		add -= x.back() - x[i + 1];
		add += migima[i - 1];
		ans = max(ans, add);
	}
	cout << ans << endl;

}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
int ok[MAX];
vector<int> ans[MAX];
int main(){
    int n; cin >> n;
    int s = 1;
    while(1){
        int m = s * (s + 1) / 2;
        if(m >= MAX) break;
        ok[m] = s;
        s++;
    }

    int j = ok[n];
    if(!j){
        out("No"); return 0;
    }

    out("Yes");
    if(j == 1){
        out("2"); out("1 1"); out("1 1"); return 0;
    }
    
    out(j + 1);
    ans[0].push_back(1); ans[0].push_back(2);
    ans[1].push_back(2); ans[1].push_back(3);
    ans[2].push_back(3); ans[2].push_back(1);

    int now = 3;
    for(int k = 3; k <= j; k++){
        rep(i, k){
            ans[i].push_back(now + i + 1);
            ans[k].push_back(now + i + 1);
        }
        now += k;
    }

    rep(i, j+1){
        outs(ans[i].size());
        for(int& k : ans[i]) outs(k);
        out("");
    }
    
}

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

int main(){
	long long int n,x;
	cin>>n>>x;
	vector<long long int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	
	long long int ans=1e18;
	vector<long long int> ma(n,1e9);
	
	for(int i=0;i<n;i++){
		long long int tmp=x*i;
		for(int j=0;j<n;j++){
			ma[j]=min(ma[j],a[(j+i)%n]);
			tmp+=ma[j];
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
s=gets.chomp
a="ACGT"
count=0
can=false
s.length.downto(1) do |i|
  can=false
  0.upto(s.length-i) do |j|
    if s[j, i].count("^#{a}")==0
      count=i
      can=true
      break
    end
  end
  if can
    break
  end
end
puts count


Measured memory_bytes: 14300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=366,INF=1<<30;
int dp[MAX][MAX],to[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<pair<pair<int,int>,int>> S(N);
        for(int i=0;i<N;i++){
            cin>>S[i].fi.fi>>S[i].fi.se>>S[i].se;
        }
        sort(all(S),[](auto a,auto b){
            return a.fi.se<b.fi.se;
        });
        
        memset(dp,0,sizeof(dp));
        memset(to,0,sizeof(to));
        
        for(int i=0;i<N;i++){
            memset(to,0,sizeof(to));
            
            for(int j=0;j<MAX;j++){
                for(int k=0;k<MAX;k++){
                    if(j<S[i].fi.fi){
                        chmax(to[S[i].fi.se][k],dp[j][k]+S[i].se);
                    }
                    if(k<S[i].fi.fi){
                        chmax(to[j][S[i].fi.se],dp[j][k]+S[i].se);
                    }
                    chmax(to[j][k],dp[j][k]);
                }
            }
            
            for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) dp[j][k]=to[j][k];
        }
        
        int ans=0;
        
        for(int j=0;j<MAX;j++) for(int k=0;k<MAX;k++) chmax(ans,dp[j][k]);
        
        cout<<ans<<"\n";
    }
}




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

using namespace std;

const int N = 1e7 + 1000;
long long int a[N], b[N] , c[N] , ansa , ans;
pair <long long int , long long int> p[N];
long long int aa , bb , cc;
long double f;

int main () {
    ios::sync_with_stdio(false);
    long long int n , p;
    cin >> n >> p;
    if(n == 1) return cout << p , 0;
    long long int p1 = p;
    for(long long int i = 2 ; i * i <= p ; i++ ) {
        while(p % i == 0) {
            a[i]++;
            p /= i;
        }
        //cout << n << '\n';
    }
    ans = 1;
    for(long long int i = 2 ; i < sqrt(p1) ; i++ ) {
        for(long long int j = 1 ; j <= a[i] / n ; j++ ) {
            ans *= i;
        }
    }
    cout << ans;
}


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

int main() {
	int n, m;
	cin >> n >> m;
	int a[m], b[m - 1];
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a, a + m);
	for (int i = 0; i < m - 1; i++) {
		b[i] = a[i + 1] - a[i];
	}
	sort(b, b + m - 1, greater<int>());
	long ans = 0;
	for (int i = n - 1; i < m - 1; i++) {
		ans += b[i];
	}
	cout << ans << endl;
	return 0;
}

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

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n :i64= read();
    for j in 0..n{
        for k in 0..n{
            if  4 * j + 7*k > n {
                break;
            }
            if 4 * j + 7*k == n{
                println!("Yes");
                return;
            }
        }
    }
    println!("No")
}

Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long n = scanner.nextLong();
        final int x = scanner.nextInt();
        final int m = scanner.nextInt();

        if (n < 10_000_000) {
            long tmp = x;
            long sum = 0;
            for (int i = 0; i < n; i++) {
                sum += tmp;
                tmp = tmp * tmp % m;
            }

            System.out.println(sum);
            return;
        }

        final int[] modIndices = new int[m + 1];
        Arrays.fill(modIndices, -1);
        long prev = x;
        int loopStart = -1;
        int loopEnd = -1;
        final List<Long> list = new ArrayList<>();
        for (int i = 0; i <= m; i++) {
            if (modIndices[(int) prev] != -1) {
                loopStart = modIndices[(int) prev];
                loopEnd = i;
                break;
            }

            modIndices[(int) prev] = i;
            list.add(prev);
            prev = prev * prev % m;
        }

        final long startSum = IntStream.range(0, loopStart)
            .mapToLong(list::get)
            .sum();
        final long oneLoopSum = IntStream.range(loopStart, loopEnd)
            .mapToLong(list::get)
            .sum();
        final long loopCount = (n - loopStart) / (loopEnd - loopStart);
        final long endLoop = (n - loopStart) % (loopEnd - loopStart);
        final long endSum = IntStream.range(loopStart, loopStart + (int) endLoop)
            .mapToLong(list::get)
            .sum();
        System.out.println(startSum + oneLoopSum * loopCount + endSum);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}
    

Measured memory_bytes: 36960
#include<bits/stdc++.h>
#define boom {puts("Possible"); return 0;}
#define foom {puts("Impossible"); return 0;}
using namespace std;
int n, c[105], mx;

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		int T;
		scanf("%d",&T);
		c[T]++;
		mx = max(mx, T);
	}
	for(int i=mx;i>mx/2;i--) {
		if(c[i] < 2) foom;
		c[i] -= 2;
	}
	if(mx % 2 == 0) {
		if(c[mx/2] < 1) foom;
		c[mx/2] -= 1;
	}
	for(int i=1;i<=(mx+1)/2;i++) {
		if(c[i]) foom;
	}
	boom;
}


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

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

using ll=long long;

int main(){
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   int ta=a;
   int ao=c;
   while(ao>0 && ta>0){
      ao-=b;
      if(ao<=0)break;
      ta-=d;
   }
   if(ao<=0)cout<<"Yes";
   else cout<<"No";
   cout<<endl;
   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans=0;
  for(int i=0;i<3;i++){
    if(s[i]=='1'){
      ans++;
    }
  }
  cout << ans << endl;    
  return 0;
}

Measured memory_bytes: 3620
<?php
[$X] = ints();
$A = 100;
for($i = 0; $i < 1000000; $i++){
    $A*=1.01;
    $A=floor($A);
    if($A>=$X){
        echo $i+1;
        exit;
    }
}

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$M = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

int main() {
	string  st;
	bool flag = true;
	cin >> st;

	if (st.at(0) == st.at(1)) {
		if (st.at(0) == st.at(2)) flag = false;
		else if (st.at(0) == st.at(3)) flag = false;
		else if (st.at(1) == st.at(2)) flag = false;
		else if (st.at(1) == st.at(3)) flag = false;
		else if (!(st.at(2) == st.at(3))) flag = false;
	}

	else if (st.at(0) == st.at(2)) {
		if (st.at(0) == st.at(1)) flag = false;
		else if (st.at(0) == st.at(3)) flag = false;
		else if (st.at(2) == st.at(1)) flag = false;
		else if (st.at(2) == st.at(3)) flag = false;
		else if (!(st.at(1) == st.at(3))) flag = false;
	}

	else if (st.at(0) == st.at(3)) {
		if (st.at(0) == st.at(1)) flag = false;
		else if (st.at(0) == st.at(2)) flag = false;
		else if (st.at(3) == st.at(1)) flag = false;
		else if (st.at(3) == st.at(2)) flag = false;
		else if (!(st.at(1) == st.at(2))) flag = false;
	}

	else if(st.at(1)==st.at(2)){
		if (st.at(1) == st.at(0)) flag = false;
		else if (st.at(1) == st.at(3)) flag = false;
		else if (st.at(2) == st.at(0)) flag = false;
		else if (st.at(2) == st.at(3)) flag = false;
		else if (!(st.at(0) == st.at(3))) flag = false;
	}

	else if (st.at(1) == st.at(3)) {
		if (st.at(1) == st.at(0)) flag = false;
		else if (st.at(1) == st.at(2)) flag = false;
		else if (st.at(3) == st.at(0)) flag = false;
		else if (st.at(3) == st.at(2)) flag = false;
		else if (!(st.at(0) == st.at(2))) flag = false;
	}

	else if (st.at(2) == st.at(3)) {
		if (st.at(2) == st.at(0)) flag = false;
		else if (st.at(2) == st.at(1)) flag = false;
		else if (st.at(3) == st.at(0)) flag = false;
		else if (st.at(3) == st.at(1)) flag = false;
		else if (!(st.at(0) == st.at(1))) flag = false;
	}
  	else flag = false;
  
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <stack>
#include <iostream>

using namespace std;

void calc(int n){
    int in,l,c,s,ans=0;
    stack<int> st;

    scanf("%d",&s);
    l=s;
    st.push(1);

    for(int i=1;i<n;i++){
        scanf("%d",&in);
        if(i%2==1){
            if(in!=l){
                c=0;
                c+=st.top();
                st.pop();
            
                if(st.size()>=1)st.top()+=c+1;
                else st.push(c+1);
                
            }else{
                st.top()++;
            }
        }else{
            if(in!=l){
                st.push(1);
            }else{
                st.top()++;
            }
        }
        l=in;
    }

    for(int i=0;!st.empty();i++){
        if((l+i)%2==0){
            ans+=st.top();
        }
        st.pop();
    }

    printf("%d\n",ans);

    return;
}

int main(){
    int n;
    
    while(1){
        scanf("%d",&n);
        
        if(n==0) break;
        
        calc(n);
    }
    
    return 0;
}
    

Measured memory_bytes: 1192
# 入力
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

l = ni()
n = len(bin(l)[2:])

graph = []

# 頂点iからi+1に長さ0,2**(i-1)の辺を張る
for i in range(1,n):
    graph.append((i, i+1, 0))
    graph.append((i, i+1, 2**(i-1)))
    
# 頂点n-1から順に、バイパスを追加
res = l
for j in range(n-1, 0, -1):
    if res - 2**(j-1) >= 2**(n-1):
        graph.append((j, n, res-2**(j-1)))
        res -= 2**(j-1)
        
# 出力
print(n, len(graph))
for edge in graph:
    print(*edge)

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

int main() {
    map<string, int> blood_t;
    int n;
    char comma;
    string blood;
    while (cin >> n >> comma >> blood) {
        blood_t[blood]++;
    }
    cout << blood_t["A"] << endl;
    cout << blood_t["B"] << endl;
    cout << blood_t["AB"] << endl;
    cout << blood_t["O"] << endl;
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 K;
  std::cin >> K;
  std::cout << std::array<i64, 32>({1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51})[K - 1] << std::endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func maxInt(a ...int) int {m := a[0]; for _, x := range a {if x > m {m = x}}; return m}
func minInt(a ...int) int {m := a[0]; for _, x := range a {if x < m {m = x}}; return m}

func main() {
  var a, b, c, d int
  fmt.Scan(&a, &b, &c, &d)
  fmt.Println(minInt(a, b) + minInt(c, d))
}

Measured memory_bytes: 512
K = int(input())

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    float data[10];
    float ans[5];
    cin>>n;
    while( n != 0 ){
        for(int i=0;i<n;i++){
            for(int j=0;j<8;j++){
                cin>>data[j];
            }
            ans[0]=data[0]*data[4]-data[1]*data[5]-data[2]*data[6]-data[3]*data[7];
            ans[1]=data[0]*data[5]+data[1]*data[4]+data[2]*data[7]-data[3]*data[6];
            ans[2]=data[0]*data[6]-data[1]*data[7]+data[2]*data[4]+data[3]*data[5];
            ans[3]=data[0]*data[7]+data[1]*data[6]-data[2]*data[5]+data[3]*data[4];
            for(int j=0;j<4;j++){
                cout<<ans[j];
                if(j+1 != 4){
                    cout<<" ";
                }
            }
            cout<<"\n";
        }
        cin>>n;
    }
    return 0;
}




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

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

	bool finished = false;


	while (!finished) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			finished = true;
		}
		else {
			a -= d;
			if (a <= 0) {
				cout << "No" << endl;
				finished = true;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? ((x) : -(x)))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;
string A[7] = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
string str;
int main()
{
	int i, j;
	cin >> str;
	int cur = 0;
	for (i = 0; i < 7; ++i) {
		if (str == A[i]) cur = i + 1;
	}
	if (7 - cur == 0) printf("7");
	else printf("%d", 7 - cur);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>

namespace bf
{
	typedef long long ll;
	const int N=8010,M=203,MOD=998244353;
	inline void inc(int a,int &b){b=(a+b)%MOD;}
	ll inv(int x){return x==1?1:(-(MOD/x)*inv(MOD%x)%MOD);}
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}

	int dec[N*4];
	void getdec(int n){for(int i=1;i<n;i++)dec[i]=(dec[i>>1]>>1)+(i&1?n>>1:0);}
	void ntt(int *y,int n,int rag)
	{
		for(int i=0;i<n;i++)
			if(i<dec[i])std::swap(y[i],y[dec[i]]);

		int *y0,*y1,ny0,ny1;
		for(int len=2;len<=n;len<<=1)
		{
			int delta=qpow(3,(MOD-1)/len),h=len>>1,x;
			if(rag<0)delta=inv(delta);

			for(int p=0;p<n;p+=len)
			{
				y0=y+p,y1=y0+h,x=1;
				for(int i=0;i<h;i++)
				{
					ny0=(y0[i]+(ll)x*y1[i])%MOD;
					ny1=(y0[i]-(ll)x*y1[i])%MOD;
					y0[i]=ny0,y1[i]=ny1;
					x=(ll)x*delta%MOD;
				}
			}
		}
	}
	void mul(int *A,int *B,int n)
	{
		getdec(n);
		ntt(A,n,1),ntt(B,n,1);
		for(int i=0;i<n;i++)A[i]=(ll)A[i]*B[i]%MOD;
		ntt(A,n,-1);
		int x=inv(n);
		for(int i=0;i<n;i++)A[i]=(ll)A[i]*x%MOD;
	}

	int fact[N],ifact[N];
	int C(int n,int m){if(n<m)return 0;return (ll)fact[n]*ifact[m]%MOD*ifact[n-m]%MOD;}

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

		fact[0]=1;
		for(int i=1;i<N;i++)fact[i]=(ll)fact[i-1]*i%MOD;
		ifact[N-1]=inv(fact[N-1]);
		for(int i=N-1;i;i--)ifact[i-1]=(ll)ifact[i]*i%MOD;
	}

	int f[M][N];
	void dp()
	{
		static int A[N*4],B[N*4];
		f[0][0]=1;
		for(int i=1;i<=m;i++)
		{
			int tot;
			for(tot=1;tot<=n+n+2;tot<<=1);
			memset(A,0,tot*4),memset(B,0,tot*4);
			for(int j=0;j<=n;j++)A[j]=(ll)f[i-1][j]*ifact[j]%MOD;
			for(int j=3;j<=n+2;j++)B[j]=ifact[j];

			mul(A,B,tot);

			for(int j=0;j<=n;j++)f[i][j]=(ll)fact[j+2]*A[j+2]%MOD;

			for(int j=0;j<=n;j++)
			{
//				for(int l=0;l<j;l++)
//					inc((ll)f[i-1][l]*C(j+2,l)%MOD,f[i][j]);
				inc((ll)f[i-1][j]*(1+C(j+1,2))%MOD,f[i][j]);
			}
		}
	}

	int getans()
	{
		int ret=0;
		for(int i=0;i<=n;i++)
			inc((ll)f[m][i]*C(n,i)%MOD,ret);
		return (ret+MOD)%MOD;
	}

	void solve()
	{
		initialize();
		dp();
		printf("%d\n",getans());
	}
}

int main()
{
	bf::solve();
	return 0;
}


Measured memory_bytes: 6784
//何も分からないので実験した。最初A≠Bのときを考える。
//・最後に正の値が残るとしたら、それは1箇所。A_i > B_iだった所になるようだ。
//・A_i > B_iを満たすiの元, B_iの最小値を求めると、それが最終的な数列A, Bの和と一致するようだ。
//証明はしていない。
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n;
int a, b;

signed main() {
	int i;
	int s = 0, minB = 1e+10;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a >> b;
		s += a + b;
		if (a > b) minB = min(minB, b);
	}
	if (minB == 1e+10) cout << 0 << endl;
	else cout << (s - 2 * minB) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int h1, h2, k1, k2, a, b, c, d, hsum, ksum;
    
    scanf("%d %d", &h1, &h2);
    scanf("%d %d", &k1, &k2);
    scanf("%d %d %d %d", &a, &b, &c, &d);
    
    hsum = h1 * a + h2 * b + (h1 / 10 * c) + (h2 / 20 * d);
    ksum = k1 * a + k2 * b + (k1 / 10 * c) + (k2 / 20 * d);
    
    if (ksum == hsum) {
        printf("even\n");
    } else if (ksum > hsum)
    {
        printf("kenjiro\n");
    } else if (ksum < hsum)
    {
        printf("hiroshi\n");
    }
    
    return 0;
}

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

class Player{
private:
    bool played_;
    queue<int> games_;
    int id_;
public:
    void SetId(int i);
    int GetId();
    void NewDay(vector<Player*>& active_players);
    bool CanPlay();
    int NextGame();
    void Play();
    void Input(int i);
};

void Player::SetId(int i) {
  id_ = i;
}

int Player::GetId() {
  return id_;
}

void Player::NewDay(vector<Player*>& active_players){
  if (played_) active_players.push_back(this);
  played_ = false;
}

bool Player::CanPlay(){
  return !(played_ or games_.empty());
}

int Player::NextGame() {
  return games_.front();
}

void Player::Play() {
  games_.pop();
  played_ = true;
}

void Player::Input(int i) {
  games_.push(i);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<Player> players(n);
  vector<Player*> active_players(n);
  for (int i = 0; i < n; ++i) {
    players[i].SetId(i);
    active_players[i] = &players[i];
    for (int j = 0; j < n - 1; ++j) {
      int a;
      cin >> a;
      players[i].Input(a - 1);
    }
  }

  int game = 0;
  int day = 0;
  int prev_game = 0;

  while (game < n * (n - 1) / 2) {
    for (Player* player : active_players) {
      if (not player->CanPlay()) continue;
      Player* opponent = &players[player->NextGame()];
      if (not opponent->CanPlay()) continue;
      if (player->GetId() == opponent->NextGame()) {
        player->Play();
        opponent->Play();
        ++game;
      }
    }
    if (game == prev_game) {
      cout << -1 << endl;
      return 0;
    }
    prev_game = game;
    ++day;
    active_players.clear();
    for (Player& player: players) {
      player.NewDay(active_players);
    }
  }
  cout << day << endl;
  return 0;
}


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

int main() {
  int n,ans,max;
  max=0;
  ans=0;
  cin >> n;
  vector<int> h(n);
  for(int i=0;i<n;i++) {
    cin >> h.at(i);
    if(i>0) {
      if(h.at(i)<=h.at(i-1)){
        max++;
        if(ans<max) ans++;
      } else {
        max=0;
      };
    };
  };
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int add_number(long long a)
{
	int t=0;
	while (a!=0)
	{
		t+=a%10;
		a/=10;
	}
	return t;
}
int main()
{
	long long n;
	cin >> n;
	if (n%add_number(n)==0) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long int ll;
const int N = 1000000;
const ll INF = std::numeric_limits<long long>::max();
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define sz size
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
ll a, b, c, d, e,ans=0;
string s, ss, sss;
ll v[100000];
int main() {
	cin >>a ;
	cout<<  a*800-200*(a/15)   <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(void) {
    int n,k,t,u,v,l;
    char d[100000]={};
    scanf("%d%d%d%d%d%d",&n,&k,&t,&u,&v,&l);
    for(int i=0; i<n; i++) {
        int t;
        scanf("%d",&t);
        d[t]=1;
    }

    double res=0.0,rem=0.0;
    int carrot=0;
    for(int i=0; i<l; i++) {
        if(d[i]) carrot++;
        if(carrot>k) carrot=k, rem = 1.0*t;

        double now=0.0;
        while(now<1.0) {
            if(rem==0.0) {
                if(carrot) {
                    carrot--;
                    rem = 1.0*t;
                } else {
                    res+= (1.0-now)/u;
                    now = 1.0;
                }
            }

            if(rem > (1.0-now)/v) {
                res+= (1.0-now)/v;
                rem-= (1.0-now)/v;
                now = 1.0;
            } else {
                res+= rem;
                now+= rem*v;
                rem = 0.0;
            }
        }
    }
    printf("%f\n",res);

    return 0;
}

Measured memory_bytes: 2860
#include <bits/stdc++.h>
//#include "atcoder/all"
typedef long long int ll;
using namespace std;
// using namespace atcoder;
int main() {
    int n;
    cin >> n;
    ll ret = 0;
    for (int i = 1; i < n; i++) {
        ret += n / i;
        if (n % i == 0) {
            ret --;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>

bool judge(int x) {
    for (int i = 2; i < x; ++i) {
        if (x % i == 0) return false;
    }
    return true;
}

int main() {
    int A, B;
    std::cin >> A >> B;
    if (A < 10 && B < 10) {
        std::cout << A * B << '\n';
    } else {
        std::cout << -1 << '\n';
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int read() {
	int x=0, f=1; char ch=' ';
	while(!isdigit(ch)) {ch=getchar(); if(ch=='-') f=-1;}
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48), ch=getchar();
	return x*f;
}
int a, b;
int main() {
	cin>>a>>b;
	if(b-2*a<0) cout<<"No";
	else if((b-a*2)%2!=0) cout<<"No";
	else if(a-(b-a*2)/2<0) cout<<"No";
	else cout<<"Yes";
}


Measured memory_bytes: 3632
loop do
	h, w = gets.split.map{ |s| s.to_i }
	break if h == 0 && w == 0
	h.times do |y|
		w.times do |x|
			if x == 0 || y == 0 || w-x == 1 || h-y == 1
				print "#"
			else
				print "."
			end
		end
		puts
	end
	puts
end

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,k=0,count=0;

    cin>>n;
    vector<int> v(n),c(n);
    for(i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        v[i]=a;
        c[i]=b;

    }
    for(i=0;i<n;i++)
    {
        if(v[i]==c[i])
        {
            k++;
            if(k==3)
            {
                cout<<"Yes";
                count++;
                break;
            }
        }
        else
        {
            k=0;
        }
        
    }
    if(count==0)
    cout<<"No";

    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <vector>
#include <bitset>
using namespace std;
#define f(i, x, y) for (int i = x; i <= y; ++i)
#define fd(i, x, y) for (int i = x; i >= y; --i)
#define rep(i, x, y) for (int i = x; i <= y; ++i)
#define repd(i, x, y) for (int i = x; i >= y; --i)

const int INF = 1e9 + 7;
const int N = 50008;
int n, m, q;

int tb[10][10];
int x[6], y[6];
int calc(const int x[], int len)
{
	int tmp = 0;
	for (int i = 1; i <= len; ++i)
		tmp = tb[tmp][x[i]];
	return tmp;
}
bool check(const int x[6])
{	
	for (int i = 1; i <= 5; ++i) y[i] = x[i];
	for (int i = 1; i <= 5; ++i)
	{
		for (int j = 0; j <= 9; ++j)
			if (x[i] != j)
			{
				y[i] = j;
				if (calc(y, 5) == 0) return false;
			}
		y[i] = x[i];
	}
	for (int i = 1; i <= 4; ++i)
		if (y[i] != y[i + 1])
	{
		swap(y[i], y[i + 1]);
		if (calc(y, 5) == 0) return false;
		swap(y[i], y[i + 1]);
	}
	return true;
}

void init()
{
	for (int i = 0; i < 10; ++i)
		for (int j = 0; j < 10; ++j)
			cin >> tb[i][j];
	int ans = 0;
	for (x[1] = 0; x[1] <= 9; ++x[1])
		for (x[2] = 0; x[2] <= 9; ++x[2])
			for (x[3] = 0; x[3] <= 9; ++x[3])
				for (x[4] = 0; x[4] <= 9; ++x[4])
				{
					x[5] = calc(x, 4);
					if (!check(x)) ans++; 
				}
	cout << ans << endl;
}
void solve()
{

}
int main()
{	
	cin.sync_with_stdio(0);
	init();
	solve();
}

Measured memory_bytes: 3224
import numpy as np

def getNearestValue(list, num):
    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
else:
  l = list(range(102))
  for i in p:
    l.remove(i)
  print(getNearestValue(l, x))

Measured memory_bytes: 27188
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		System.out.println((b <= a) ? "delicious" : (b <= a + x) ? "safe" : "dangerous");

	}

}

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

int main() {
string a,b;
cin >> a >> b;
if(a.size() > b.size()) cout << "GREATER" << endl;
else if(a.size() < b.size()) cout << "LESS" << endl;
else{
  rep(i,a.size()){
    if('0'+a.at(i) > '0'+b.at(i)){
      cout << "GREATER" << endl;
      return 0;
    }
    else if('0'+a.at(i) < '0'+b.at(i)){
      cout << "LESS" << endl;
      return 0;      
    }
    
  }
  cout << "EQUAL" << endl;
}
  }


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define endl "\n";
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n,k,ans=0;
	cin>>n>>k;
	while(n>0){
		n/=k;
		ans++;
	}
   cout<<ans;
   return 0;
}


Measured memory_bytes: 3556
use std::io;
use std::collections::HashMap;
use std::ops::{Deref, DerefMut};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let mut xs: CountedData = CountedData(
        buffer
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
    );
    
    xs.sort();
    let mut counter = HashMap::new();
    while !xs.is_empty() {
        let (key, c) = xs.count_and_drain();
        counter.insert(key, c);
    }

    let m: i32 = counter.keys().map(
        |key| {
            [-1, 0, 1]
                .iter()
                .map(|x| {
                    match counter.get(&(key + x)) {
                        None => 0,
                        Some(i) => *i,
                    }
                })
                .sum()
        }).max().unwrap();
    
    println!("{}", m);
}

struct CountedData(Vec<i32>);

impl CountedData {
    fn count_and_drain(&mut self) -> (i32, i32) {
        let key = self[0].clone();
        let cnt = self.iter()
            .take_while(|&&x| x == key)
            .count();
        self.drain(..cnt);
        (key, cnt as i32)        
    }
}

impl Deref for CountedData {
    type Target = Vec<i32>;

    fn deref(&self) -> &Vec<i32> {
        &self.0
    }
}

impl DerefMut for CountedData {
    fn deref_mut(&mut self) -> &mut Vec<i32> {
        &mut self.0
    }
}

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

m = n-k
if m>0:
  if m%(k-1)==0:
    print(m//(k-1) + 1)
  else:
    print(m//(k-1) + 2)
else:
  print(m//(k-1) + 1)

Measured memory_bytes: 20496
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long 
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		ll a, b;
		cin >> a >> b;
		if(1<=a && a<=9){
			if(1<=b && b<=9)
				cout << a*b << endl;
			else
				cout << "-1" << endl;
		}
		else
			cout << "-1" << endl;
		return 0;
	}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
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 divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++) cin >> X.at(i);
  
  sort(X.begin(), X.end());
  
  vector<int> Y(M - 1);
  for (int i = 0; i < M - 1; i++) Y.at(i) = X.at(i + 1) - X.at(i); 
  
  sort(Y.begin(), Y.end(), greater<int>());
  
  int ans = 0;
  for (int i = N - 1; i < M - 1; i++) ans += Y.at(i);
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
#define rep(i,N) for(int i = 0; i<N,i++)
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

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

	int nas = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'x') {
			nas++;
		}
	}

	if (nas >= 8)cout << "NO";
	else cout << "YES";
}

Measured memory_bytes: 256
import java.util.Scanner;


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

    while(true){
      int N = sc.nextInt();

      if(N == 0){
	break;
      }

      char replaces[] = new char[256];
      
      for(int i = 0; i < N; i++){
	replaces[sc.next().toCharArray()[0]] = sc.next().toCharArray()[0];
      }

      long M = sc.nextLong();

      for(long i = 0; i < M; i++){
	char c = sc.next().toCharArray()[0];
	System.out.print(replaces[c] != 0 ? replaces[c] : c);
      }
      System.out.println();
    } 
  }
}

Measured memory_bytes: 12000
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
#define ull  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 340000;
int a[N];
string s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> s[i];
        cin >> a[i];
    }
    string x;
    cin >> x;
    int ans = 0;
    int t = 0;
    for (int i = 1; i <= n; i++){
        ans += t * a[i];
        if (s[i] == x) t = 1;
    }
    cout << ans;
}


Measured memory_bytes: 4352
import sys
from fractions import gcd
# from heapq import heapify, heappop, heappush
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

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

g = a[0]
for i in range(1, n):
    g = gcd(g, a[i])
print(g)

# heapify(a)
# while len(a) != 1:
#     f = heappop(a)
#     s = heappop(a)
#     s %= f
#     if s != 0:
#         heappush(a, s)
#     heappush(a, f)
# print(heappop(a))


Measured memory_bytes: 22328
// ABC110_C
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>  // std::copy()
using namespace std;
using ll = long long;

int main() {
    // input
    string S, T;
    cin >> S >> T;
    
    // calculation
    if (S == T) {
        cout << "Yes" << "\n";
    } else {
        // 対応関係を作る
        vector<ll> start(26, -1), goal(26, -1);
        ll sta, go;
        bool flag = true;
        for (ll i = 0; i < S.length(); ++i) {
            sta = S[i] - 'a';
            go = T[i] - 'a';
            if (start[sta] != -1 || goal[go] != -1) {
                // 既に書かれていた場合
                if (start[sta] != go || goal[go] != sta) {
                    // 対応関係が異なっていたら No
                    cout << "No" << "\n";
                    return 0;
                }
            } else {
                start[sta] = go;
                goal[go] = sta;
            }
        }
        cout << "Yes" << "\n";
    }
    return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
typedef long long ll;
const int maxn = 1e5 + 10;
using namespace std;

int n, m, T, kase = 1;
int a[maxn];

int main() {
    while(scanf("%d", &n) != EOF) {
        for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
        int tot = 0; a[n + 1] = 0;
        for(int i = 1; i <= n + 1; i++) {
            tot += abs(a[i] - a[i - 1]);
        }
        for(int i = 1; i <= n; i++) {
            int x = abs(a[i] - a[i - 1]) + abs(a[i] - a[i + 1]);
            int y = abs(a[i - 1] - a[i + 1]);
            printf("%d\n", tot + y - x);
        }
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(b / a, c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int rt[100010];
int find( int x ) { return x == rt[x] ? x : rt[x] = find(rt[x]);}
int main() {
	int n, m;scanf("%d%d", &n, &m);
	for( int i = 1 ; i <= n ; ++i ) rt[i] = i;
	for( int i = 0, u, v, w ;  i<m ; ++i ) scanf("%d%d%d", &u, &v, &w), rt[find(u)] = find(v);
	set<int> c;
	for( int i = 1 ; i <= n ; ++i ) c.insert(find(i));
	printf("%lu\n", c.size());
	return 0;
}


Measured memory_bytes: 5376