akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<set>
using namespace std;
long long int tep[100000], a[100000], b[100000];
int main()
{
	int n;
	while (~scanf("%d", &n))
	{
		memset(tep, 0, sizeof(tep));
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		for (int i = 0; i < n; i++)
			scanf("%lld", &a[i]);
		for (int i = 0; i < n; i++)
		{
			scanf("%lld", &b[i]);
			tep[i] = b[i] - a[i];
		}
		sort(tep, tep + n);
		int i = 0, j = n - 1;
		long long int ans = 0;
		while (tep[i] < 0)
		{
			ans += tep[i];
			i++;
		}
		while (tep[j] > 1)
		{
			ans += tep[j] / 2;
			j--;
		}
		if (ans>=0)
			printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 2560
#include<cstdio>
#define MAX 50
int Pre[MAX];
int In[MAX];
int Post[MAX];
int pos = 0;
int p = 0;
int n;
void reconstruction(int l, int r)
{
	if(l >= r)
		return;
	int root = Pre[pos++];
	int m;
	for(int i=0; i<n; i++)
	{
		if(In[i] == root)
		{
			m = i;
			break;
		}
	}
	reconstruction(l,m);
	reconstruction(m+1,r);
	Post[p++] = root;
}

int main()
{
	//int n;
	scanf("%d", &n);
	for(int i=0; i<n; i++)
		scanf("%d", &Pre[i]);
	for(int i=0; i<n; i++)
		scanf("%d", &In[i]);

	reconstruction(0,n);

	for(int i=0; i<p; i++)
	{
		if(i) printf(" ");
		printf("%d",Post[i]);
	}
	printf("\n");

	return 0;
}


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

bool isACGT(char c) {
    if ( c == 'A' || c == 'C' || c == 'G' || c == 'T') {
        return true;
    }
    return false;
}

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

    int longest = 0;
    int cnt = 0;
    for (int i = 0; i < s.length(); i++) {
        if(isACGT(s[i])) {
            cnt++;
        } else {
            cnt = 0;
        }
        longest = max(longest, cnt);
    }
    cout << longest << endl;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	string str;
	cin >> str;
	int size = str.size();
	if( (str[0]==str[size-1])^(size%2) ){
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M, C;
    cin >> N >> M >> C;
    vec B(M);
    mat A(N, vec(M));
    REP(i,0,M) cin >> B[i];
    REP(i,0,N) REP(j,0,M) cin >> A[i][j];

    ll cnt = 0;
    REP(i,0,N) {
        ll sum = C;
        REP(j,0,M) sum += A[i][j] * B[j];
        if(sum > 0) ++cnt;
    }
    PR(cnt);


    return 0;
}

/*



*/

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    int64_t n;
    cin >> n;

    vector<int64_t> a(n);
    for (auto&& aa : a) {
        cin >> aa;
    }

    vector<vector<int64_t>> ans(h, vector<int64_t>(w));
    int64_t y = 0, x = 0, dir = 1;
    for (auto i : irange(0L, n)) {
        for (auto _ : irange(0L, a[i])) {
            ans[y][x] = i + 1;
            x += dir;
            if (x == w) {
                --x;
                ++y;
                dir = -1;
            } else if (x == -1) {
                ++x;
                ++y;
                dir = 1;
            }
        }
    }

    for (auto i : irange(0L, h)) {
        cout << ans[i][0];
        for (auto j : irange(1L, w)) {
            cout << " " << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}
template <class T>
void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
const int INF = 1001001001;



int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int cnt = 0;
    xrep(n, L, R+1) {
        if(n%d==0) {
            cnt++;
        }
    }
    print(cnt);
    
    return 0;
}

Measured memory_bytes: 3632
// small and large integers
#include <stdio.h>
#define MAXSIZE 200

int find_num(int target, int ub, int kishutsu[MAXSIZE]){
    for(int i = 0; i < ub; i++){
        if(kishutsu[i] == target) return 1;
    }
    return 0;
}

int main(void){
    int a, b, k;
    scanf("%d %d %d", &a, &b, &k);
    
    if(k > (b - a + 1) / 2){
        for(int i = a; i <= b; i++) printf("%d\n", i);
    }else{
        int kishutsu[MAXSIZE];
        int ub = 1;
        for(int i = 0; i < k; i++){
            kishutsu[i] = a + i;
            ub++;
            printf("%d\n", a + i);
        }

        for(int i = b - (k - 1); i <= b; i++){
            if(!find_num(i, ub, kishutsu)) printf("%d\n", i);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define MAXN 120
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    string word[4] = {"esare", "maerd", "remaerd", "resare"}, s;
    int a=0, n;
    bool possible = true;

    cin >> s;
    n = s.size();
    reverse(s.begin(), s.end());

    while (s.size() >= 5){
        possible = false;
        for (int i=0; i<4; i++){
            if (s.substr(0, (int)word[i].size()) == word[i]){
                s.erase(0, (int)word[i].size());
                possible = true;
                break;
            }
        }
        if (!possible){
            cout << "NO" << endl;
            return 0;
        }
    }

    if (s.size() == 0){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

const ll MODULO = 998244353L;
ll mod_minus(ll x, ll modval) {
    if (x >= 0) {
        return x % modval;
    } else {
        ll mm = ((-x) % modval);
        if (mm == 0) {
            return 0;
        } else {
            return modval - mm;
        }
    }
}
ll mod(ll x) {
    return mod_minus(x, MODULO);
}

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> dp(200003, 0);
    vector<ll> left(K + 1);
    vector<ll> right(K + 1);
    ll minl = INF;
    for (ll i = 0; i < K; i++) {
        cin >> left[i] >> right[i];
        minl = min(minl, left[i]);
    }

    dp[1] = 1;
    dp[minl + 1] = 1;
    for (ll i = minl + 2; i <= N; i++) {
        dp[i] = dp[i - 1];
        for (ll j = 0; j < K; j++) {
            ll l = left[j];
            ll r = right[j];
            if (i - r - 1 >= 0) {
                dp[i] = mod(dp[i] - dp[i - r - 1]);
            }
            if (i - l >= 0) {
                dp[i] = mod(dp[i] + dp[i - l]);
            }
        }
    }
    print(dp[N]);
}


Measured memory_bytes: 4828
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int main(){
	int X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;
	vector<ll> p(A), q(B), r(C);
	for(int i=0; i<A; i++) cin >> p[i];	
	for(int i=0; i<B; i++) cin >> q[i];
	for(int i=0; i<C; i++) cin >> r[i];
	sort(p.rbegin(), p.rend());
	sort(q.rbegin(), q.rend());
	sort(r.rbegin(), r.rend());

	//解法みちゃいました．
	vector<ll> d;
	for(int i=0; i<X; i++) d.push_back(p[i]);
	for(int i=0; i<Y; i++) d.push_back(q[i]);
	for(int i=0; i<C; i++)  d.push_back(r[i]);
	sort(d.rbegin(), d.rend());
	
	ll ans = 0;
	for(int i=0; i<X+Y; i++) ans += d[i];
	cout << ans << endl;




	//以下　累積和とか考えて　最適を探そうとして　ハマってしまった.
	// vector<ll> a_wa(A+1), b_wa(B+1), c_wa(C+1);//累積和
	// a_wa[0] = 0; b_wa[0] = 0; c_wa[0] = 0;
	// for(int i=0; i<A; i++) a_wa[i+1] = a_wa[i] + p[i];
	// for(int i=0; i<B; i++) b_wa[i+1] = b_wa[i] + q[i];
	// for(int i=0; i<C; i++) c_wa[i+1] = c_wa[i] + r[i];
	
	// tasty[i][j]: p,qから合計i個食べる時， 
	//pからj個,qからi-j個食べた時の合計のおいしさ
	// vector<vector<ll>> tasty(X+Y+1, vector<ll>(X, 0));
	// for(int i=0; i<X+Y+1; i++){
	// 	tasty[i][]
	// }

	// ll ans = 0;
	// for(int a_num=0; a_num<=X; a_num++){
	// 	ans = max(ans, a_wa[a_num] + b_wa[X+Y-a_num] + c_wa[])
	// }

	// // tasty[i]: p,qから合計i個食べた時の，おいしさの最大値
	// vector<ll> tasty(X+Y+1, 0);
	// for(int i=0; i=X+Y+1; i++){


	// }
	// for(int c_num=0; c_num<=X+Y; c_num++){

	// }


	// ll ans = 0;
	// // tasty[i]: Aからi個食べて,CからX-i個食べたおいしさ
	// vector<ll> a_tasty(X, 0);
	// for(int a_num=0; a_num<=X; a_num++){
	//     a_tasty[a_num] += a_wa[a_num];// Aからa_num個食べる
	// 	a_tasty[a_num] += c_wa[X-a_num]; //CからX-a_num個食べる
	// }


}


Measured memory_bytes: 9760
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=7;

int main(){
    fast_io
    
    ll k;
    cin>>k;
    ll cnt=1;
    if(k==2){
        cout<<-1<<endl;
        return 0;
    }
    ll num=0;
    for(int i=1;i<2e6;i++){
        num *= 10;
        num += 7;
        num %= k;
        if(num==0){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n = 5;
    int mi = 10, ans = 0;
    REP(i,n){
        int x = in();
        if (x % 10) mi = min(mi, x % 10);
        x = 10 * ((x + 9) / 10);
        ans += x;
    }
    cout << ans - 10 + mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    if(a>b){
      cout<<0<<endl;
      return 0;
    }
    if(n==1){
      if(a!=b) cout<<0<<endl;
      else cout<<1<<endl;
    }else{
      ll cnt1=a+b+a*(n-2);
      ll cnt2=a+b+b*(n-2);
      cout<<cnt2-cnt1+1<<endl;
    }
}

Measured memory_bytes: 256
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( [ $ t : ty ] ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( [ $ t : ty ] ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( [ $ t ] ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let n = get!(usize);
    let v = get!([usize]);
    let c = get!([usize]);

    let ans = (0..n)
        .filter(|&i| v[i] > c[i])
        .map(|i| v[i] - c[i])
        .sum::<usize>();

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


Measured memory_bytes: 8572
#include <stdio.h>

int main(void)
{
        int W,H,x,y,r;

        scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);


        if((r > x || r > y)||(r > (W - x) || r > (H - y)))
        {
                printf("No\n");
        }
        else
        {
                printf("Yes\n");
        }
        return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#define pi 3.141592653897932384626
#define abs(x) ((x)>0?(x):(-(x)))
#define eps (double)(0.0000001)
//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
using namespace std;
long a[105];
int main()
{
    long n,m;
    cin>>n>>m;
    long x=LONG_MAX;
    for(long i=0;i<n;++i){scanf("%ld",&a[i]);x=min(x,a[i]);m-=a[i];}
    cout<<n+m/x<<endl;
    return 0;
}


Measured memory_bytes: 256
while(1):
    x,op,y=input().split()
    X=int(x)
    Y=int(y)
    if(op=='+'):
      print(X+Y)
    elif(op=='-'):
      print(X-Y)
    elif(op=='*'):
      print(X*Y)
    elif(op=='/'):
      print(X//Y)
    else:
        break


Measured memory_bytes: 5596
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<unordered_map>
#include<stack>
#include<vector>
using namespace std;
int main(){
    int A;
    cin >> A;
    int B;
    cin >> B;
    
    if(B * 2 < A)cout << A - B * 2;
    else cout << 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [INT() for _ in range(N)]	

dic = defaultdict(int)

for a in A:
	dic[a] += 1

#print(dic)
print(len([1 for x in dic if dic[x]%2 == 1]))
	


Measured memory_bytes: 18364
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var nums = chunk.split(" ");
    for(var i = 0; i < nums.length; i ++){
        nums[i] = Number(nums[i]);
    }
    var output = "a == b";
    if (nums[0] > nums[1]){
        output = "a > b";
    }else if(nums[0] < nums[1]){
       output = "a < b"; 
    }
    console.log(output);
});

Measured memory_bytes: 7644
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by hikigineer on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception
    {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        String O = in.next();
        String E = in.next();

        int i;
        String result = "";
        for(i = 0; i < E.length(); i++)
            result += String.valueOf(O.charAt(i)) + String.valueOf(E.charAt(i));
        if(O.length() - E.length() == 1)
            result += String.valueOf(O.charAt(i));
        out.println(result);
        out.flush();
    }

}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) freopen(name, "r", stdin)
#define fout(name) freopen(name, "w", stdout)
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i < r; ++i)
#define E(i, l, r) for(auto i = l; i <= r; ++i)
#define DF(i, l, r) for(auto i = l; i >= r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define sz(a) ((int)(a).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)1e9 + 7;
const dbl eps = (dbl)1e-8;
const int maxn = (int)2e5 + 5;
const dbl pi = acos(-1);

int n;
ll a[maxn];

int main() {
//	fin("t.in");
	sync;
	cin >> n;
	F(i, 0, n) {
		cin >> a[i];
	}
	int fl_can = 1;
	F(i, 1, n) {
		if (a[i] - 1 > a[i - 1])
			fl_can = 0;
	}
	if (!fl_can || a[0] != 0) {
		cout << -1 << endl;
		exit(0);
	}
	ll ans = 0;
	F(i, 1, n) {
		if (a[i] == a[i - 1] + 1) {
			++ans;
		} else {
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
import numpy as np
x1, y1, x2, y2 = list(map(int, input().split()))
z1 = [
    [x1],
    [y1]
]
z1 = np.matrix(z1)
z2 = [
    [x2],
    [y2]
]
z2 = np.matrix(z2)
v1 = z2 - z1
R = [
    [0, -1],
    [1, 0]
]
v2 = np.dot(R, v1)
z3 = z2 + v2
v3 = np.dot(R, v2)
z4 = z3 + v3
ans = [str(z3[0, 0]), str(z3[1, 0]), str(z4[0, 0]), str(z4[1, 0])]
print(" ".join(ans))

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

int main()
{
    int N;
    string ans = "APPROVED";

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int num = 0;
        cin >> num;

        if (num % 2 == 0)
        {
            if (!(num % 3 == 0 || num % 5 == 0))
            {
                ans = "DENIED";
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace MinPro2019B
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] one = Console.ReadLine().Split(' ').Select(a1 => int.Parse(a1)).ToArray();
            int[] two = Console.ReadLine().Split(' ').Select(a1 => int.Parse(a1)).ToArray();
            int[] three = Console.ReadLine().Split(' ').Select(a1 => int.Parse(a1)).ToArray();

            int[] flags = new int[5];

            flags[one[0]]++;
            flags[one[1]]++;
            flags[two[0]]++;
            flags[two[1]]++;
            flags[three[0]]++;
            flags[three[1]]++;

            if (flags.Max() > 2)
            {
                Console.WriteLine("NO");
                return;
            }
            Console.WriteLine("YES");
        }
    }
}

Measured memory_bytes: 13396
from heapq import heapify,heappop,heappush
n,m=map(int,input().split())
l=[[]for i in range(10**5)]
ans=0
for i in range(n):a,b=map(int,input().split());l[a-1].append(-b)
for i in range(10**5):heapify(l[i])
p = []
heapify(p)
for i in range(m):
 if len(l[i])!=0:heappush(p,[heappop(l[i]),i])
 if len(p)!=0:
  x=heappop(p)
  ans+=-x[0]
  if len(l[x[1]])!=0:heappush(p,[heappop(l[x[1]]),x[1]])            
print(ans)

Measured memory_bytes: 22332
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

def main():
    N = readline()[:-1]
    n = int(N[-1])
    if n in [2,4,5,7,9]:
        print('hon')
    elif n == 3:
        print('bon')
    else:
        print('pon')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
import sys

sys.setrecursionlimit(10000)

from collections import Counter
 
def parse_line(line, type=int):
    return [type(x) for x in line.split(' ')]
 
 
#              1, 2, 3, 4, 5, 6, 7, 8, 9
weight = ['x', 2, 5, 5, 4, 5, 6, 3, 7, 6]
 

def run(k, weight_to_num, cache):
    if k not in cache:
        if k <= 1:
            res = 0
        else:
            res = 0
            for w, num in weight_to_num.items():
                res = max(res, run(k - w, weight_to_num, cache))
            if res > 0:
                res += 1
            if k in weight_to_num:
                res = max(1, res)
        cache[k] = res
    return cache[k]
 
 
def main():
    n, m = parse_line(input())
    numbers = set(parse_line(input()))
    #numbers = [6, 8, 9]
 
    #for n in range(2, 60):
 
    if 6 in numbers and 9 in numbers:
        numbers.remove(6)
    if 2 in numbers and 3 in numbers:
        numbers.remove(2)
    if 2 in numbers and 5 in numbers:
        numbers.remove(2)
    if 3 in numbers and 5 in numbers:
        numbers.remove(3)
 
    weight_to_num = {weight[v]: v for v in numbers}
    cache = {}
    run(n, weight_to_num, cache)
    #print(cache)
    #return
 
    ws = list(weight_to_num.keys())
    ws.sort(reverse=True, key=lambda w: weight_to_num[w])
    res = []
    cache = {k:v for k,v in cache.items() if v > 0}
    cache[0] = 0
 
    if n not in cache:
        return
 
    l = cache[n]
    while l:
        for w in ws:
            if cache.get(n - w, 'False') == l - 1:
                res.append(weight_to_num[w])
                n = n - w
                l -= 1
                break
    print(''.join((str(x) for x in res)))
 
 
if __name__ == '__main__':
    main()

# 20 4
# 3 7 8 4

Measured memory_bytes: 9844
def main():
    balls = int(input())
    coordinates = []
    answer = 1
    count_delta = {}
    for _ in range(balls):
        coordinates.append(list(map(int, input().split())))
    coordinates.sort()
    if balls > 1:
        for i in range(balls):
            for j in range(i + 1, balls):
                d = (coordinates[j][0] - coordinates[i][0], coordinates[j][1] - coordinates[i][1])
                if d in count_delta:
                    count_delta[d] += 1
                else:
                    count_delta[d] = 1
        answer = balls - max(count_delta.values())
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
// B - Tag
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,v,b,w,t; cin>>a>>v>>b>>w>>t;
	int dl = abs(a - b);
	int dv = v - w;
	if(dv > 0 && (dl+dv-1) / dv <=t) puts("YES");
	else puts("NO");
}


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

int main(){
    int a, b; cin >> a >> b;
    int y = (b - 2 * a) / 2;
    int x = a - y;
    if(x < 0 || y < 0 || (x * 2 + y * 4) != b) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

const int maxn(1e5 + 5);

int n, m, d[maxn], vis[maxn];
multiset <int> edge[maxn];
multiset <int> :: iterator it, ot;

int main() {
	int i, a, b, ret = 0, sum = 0, mx = 0, x, y, u, v;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; ++i) {
		scanf("%d%d", &a, &b), ++d[a], ++d[b];
		edge[a].insert(b), edge[b].insert(a);
	}
	for (i = 1; i <= n; ++i) if (d[i] & 1) return puts("No"), 0;
	for (i = 1; i <= n; ++i) {
		if (vis[i]) continue;
		u = i;
		if (edge[u].size() == 2) {
			vis[u] = 1, x = *edge[u].begin(), y = *edge[u].rbegin();
			edge[x].erase(edge[x].find(u)), edge[y].erase(edge[y].find(u));
			if (x == y) ++sum;
			else edge[x].insert(y), edge[y].insert(x);
			edge[u].clear();
		}
	}
	for (i = 1; i <= n; ++i)
		if (!vis[i]) ++ret, mx = max(mx, (int)edge[i].size());
	sum += mx / 2;
	if (ret >= 3 || sum >= 3) return puts("Yes"), 0;
	return puts("No"), 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

int N,M;
int A[100],B[100];
vector<int> V[10];
bool used[10];
int ans = 0;

void dfs(int X){
    bool end = 1;
    if(used[X]) return;
    else used[X] = 1;
    REP(i,N) if(!used[i]) end = 0;
    if(end){
        ans++;used[X] = 0;
        return;
    }
    REP(i,V[X].size()){
        dfs(V[X][i]);
    }
    used[X] = 0;
}

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);cin >> N >> M;
    REP(i,M){
        cin >> A[i] >> B[i];--A[i];--B[i];
        V[A[i]].pb(B[i]);V[B[i]].pb(A[i]);
    }
	dfs(0);
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,3) h.push_back(INF);
    int dp[MX];
    rep(i, n) dp[i] = INF;
    dp[0] = 0;
    dp[1] = dp[0]+abs(h[0]-h[1]);
    for(int i=2;i<n;++i){
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

int main() {
    int l; cin >> l;
    double ans = l*l*l/27.0;
    cout << fixed << setprecision(10);
    cout << ans << endl;
}


Measured memory_bytes: 256
def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A, L=60, MOD=10**9+7):
    modsum = 0
    for j in range(L):
        count_ones = sum([1 for a in A if (a >> j) & 1])
        # count_ones = sum([(A[i] >> j) & 1 for i in range(N)])
        count_zeros = N - count_ones
        # MODは一度にとる
        modsum +=  (1<<j) * count_zeros * count_ones
        modsum %= MOD
    return modsum


if __name__ == '__main__':
    inputs = read()
    print("%d" % solve(*inputs))


Measured memory_bytes: 42156
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double ans = 0;
    for (int i = 0; i < N; i++) ans += 1d / sc.nextInt();
    System.out.println(1 / ans);
  }
}

Measured memory_bytes: 21716
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    a = sorted(nl(), reverse=True)
    print(sum(a[:n//2]) + sum(a[1:(n+1)//2]))
    return

solve()


Measured memory_bytes: 31428
L = [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 = int(input())
print(L[K-1])

Measured memory_bytes: 61684
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/



void Calc() {

  const int INF = 1e9 - 1;

  int sa = INF;

  int n, t;
  in, n, t;

  auto a = in.Array(n);
  a.push_back(0);
  map<int, int> m;

  int mini = INF;
  int maxi = 0;
  rep(i, n + 1) {
    if (a[i] < mini) {
      m[maxi - mini]++;
      err(i, a[i], maxi, mini);
      mini = a[i];
      maxi = 0;
    }
    amax(maxi, a[i]);
  }
  cout << (m.rbegin())->second << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
struct qwq{
	int id;
	int have;
}a[100005];
	int n;
	inline bool cmp(qwq x,qwq y){
	return x.have<y.have;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		a[i].id=i;
		scanf("%d",&a[i].have);
	}
	stable_sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		printf("%d ",a[i].id);
	}
	return 0;
}

Measured memory_bytes: 4472
#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main() {
	int n,x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		x+=i;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
int a=0,b=0,x=0;
scanf("%d%d%d",&a,&b,&x);

for(int i = 0;i<x;i+=2)
{
if(a % 2 != 0)
{
a -= 1;
}
b += a / 2;
a = a / 2;
if(i == x-1){break;}
if(b % 2 != 0)
{
b -= 1;
}
a += b / 2;
b = b / 2;
}

printf("%d %d",a,b);

return 0;
}

Measured memory_bytes: 128
def solve():
    N,C,K = map(int, input().split())
    T = [int(input()) for _ in range(N)]
    T.sort()
    
    num = 1
    bus_pos = T[0]
    ret = 1
    for t in T[1:]:
        # print(t,ret,num,bus_pos)
        if num < C and t <= bus_pos+K:
            num += 1
        else:
            ret += 1
            num = 1
            bus_pos = t
            
    print(ret)
    
solve()

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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool o= false;
    for(int i= a;i<b+1;i++){
        int d=i%k;
        if(d==0){
            o = true;
        }

    }
    if(o){
        cout << "OK" <<endl;
    }
    else{
        cout <<"NG"<<endl;
    }
}

Measured memory_bytes: 3624
s = gets.chomp
flg = true
target = "keyence"
cntf,cntl = 0,0
7.times do |i|
  if s[i] == target[i]
    cntf += 1 if flg
  else 
    flg = false
  end
end
flg = true
7.times do |i|
  if s[-i-1] == target[-i-1]
    cntl += 1 if flg
  else 
    flg = false
  end
end
puts cntf + cntl >= 7 ? "YES" : "NO"

Measured memory_bytes: 1788
#include <stdio.h>
#define MAX (int)1e5+1
#define SENTINEL (int)1e9+1

typedef struct {
    char mark;
    int value;
} Card;

Card L[MAX/2+2], R[MAX/2+2];

void merge(Card A[], int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;

    for (i = 0; i < n1; i++) { L[i] = A[left + i]; }
    for (i = 0; i < n2; i++) { R[i] = A[mid + i]; }

    L[n1].value = R[n2].value = SENTINEL;

    i = 0; j = 0;

    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void merge_sort(Card A[], int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        merge_sort(A, left, mid);
        merge_sort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int partition(Card A[], int p, int r) {
    int i, j;
    i = p - 1;
    for (j = p; j <= r; j++) {
        if (A[j].value <= A[r].value) {
            i++;
            Card tmp = A[i]; A[i] = A[j]; A[j] = tmp;
        }
    }
    return i;
}

void quick_sort(Card A[], int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        quick_sort(A, p, q-1);
        quick_sort(A, q+1, r);
    }
}

int main() {
    Card A[MAX], B[MAX];
    int i, n, v;
    int stable = 1;
    char s[10];

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s %d", s, &v);
        A[i].mark = B[i].mark = s[0];
        A[i].value = B[i].value = v;
    }

    quick_sort(A, 0, n - 1);
    merge_sort(B, 0, n);

    for (i = 0; i < n; i++) {
        if (A[i].mark != B[i].mark) {
            stable = 0;
            break;
        }
    }

    printf( (stable) ? "Stable\n" : "Not stable\n");

    for (i = 0; i < n; i++) {
        printf("%c %d\n", A[i].mark, A[i].value);
    }

    return 0;
}



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

long long n, tab[200010], ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
    
    for (int a = 1; a <= n; a++) {
        cin >> tab[a];
    }
    if (tab[1]) {
        cout << -1;
        return 0;
    }
    tab[n+1] = 1e9 + 10;
    for (int a = 2; a <= n; a++) {
        if (tab[a] - tab[a-1] >= 2) {
            cout << -1;
            return 0;
        } 
    }
    //dp[0] = 0;
    for (int a = 1; a < n; a++) {
        if (tab[a+1] != tab[a] + 1) {
            ans += tab[a];
        }      
    }
    ans += tab[n];
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        boolean b = false;
        outside: for (int i = 0; i <= y / 10000; i++) {
            for (int j = 0; j <= (y - 10000 * i) / 5000; j++) {
                int x = y - 10000 * i - 5000 * j;
                if (x >= 0 && x / 1000 == n - i - j) {
                    b = true;
                    System.out.println(i + " " + j + " " + (n - i - j));
                    break outside;
                }
            }
        }
        if (!b)
            System.out.println("-1 -1 -1");
        sc.close();
    }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))
s = " ".join(map(str, a))
print(s)
for i in range(1, n):
    v = a[i]
    j = i-1
    while j >= 0 and a[j] > v:
        a[j+1] = a[j]
        j -= 1
    a[j+1] = v
    s = " ".join(map(str, a))
    print(s)



Measured memory_bytes: 5596
#include <iostream>
#include <string>


using namespace std; 

int main(){
	int N, x, y;
	cin >> N;
	x = 800 * N;
	if (N < 15){ y = 0; }
	else{ y = 200*(N - (N % 15)) / 15; }
	cout << x - y << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
string s;
int ans=INT_MAX; 
int main()
{
    cin>>s;
    int len=s.length();
    for(int i=1;i<len;i++){
    	if(s[i]!=s[i-1])ans=min(ans,max(i,len-i)); 
	}
    cout<<min(ans,len)<<'\n';
    return 0;
}

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

// global variables
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<ll, int> P;
// sort by P.first (asd)
bool comPair(const P &firstElof, const P &secondElof) {
    return firstElof.first < secondElof.first;
}

// moving 4-direction
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int n;
    int i, k;
    int cnt = 0;
    cin >> n;
    set<int> s;
    for (i = 0; i < n; i++) {
        cin >> k;
        s.emplace(k);
    }
    auto it = s.begin();
    do {
        it++;
        cnt++;
    } while (it != s.end());
    cout << cnt << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b, c = zip(*[list(map(int, input().split())) for i in range(q)])

cnt = [0] * (10**5+10)

for i in range(n):
    cnt[a[i]] += 1

s = 0
for i, x in enumerate(cnt):
    s += i * x

for i in range(q):
    s -= cnt[b[i]] * b[i]
    s += cnt[b[i]] * c[i]
    cnt[c[i]] += cnt[b[i]]
    cnt[b[i]] = 0
    print(s)

Measured memory_bytes: 100008
#input
N, K = map(int, input().split())
h = list(map(int, input().split()))

#output
dp = [0] * N
dp[1] = abs(h[1]-h[0])

for i in range(2, N):
    temp = abs(h[i]-h[i-1]) + dp[i-1]
    for j in range(2, K+1):
        if 0<= i-j <= N-1:
            temp = min(temp, dp[i-j]+abs(h[i]-h[i-j]))
    dp[i] = temp

print(dp[N-1])


Measured memory_bytes: 52576
n, k = map(int, input().split())
s = list(input())

if s[k-1] == "A":
    s[k-1] = "a"
elif s[k-1] == "B":
    s[k-1] = "b"
else:
    s[k-1] = "c"

print(''.join(str(ans) for ans in s))


Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))
base = [0]*n

for i in range(n):
  base[i] = a[i] - (i+1)
  
judge = n%2
temp_1 = 0
temp_2 = 0
ans = 0
base.sort()

if judge == 0:
  for i in range(n):
    temp_1 = temp_1 + abs(base[i] - base[n//2 - 1])
    temp_2 = temp_2 + abs(base[i] - base[n//2])
    
  if temp_1 <= temp_2:
    ans = temp_1
  elif temp_2 < temp_1:
    ans = temp_2
    
elif judge == 1:
  for i in range(n):
    ans = ans + abs(base[i] - base[(n-1)//2])
    
print(ans)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();

    if(n == 1) {
        // cerr << s << " " << k << endl;
        cout << k/2 << endl;
        return 0;
    }

    bool flag = true;
    FOR(i, 1, n) if(s[i] != s[0]) flag = false;
    if(flag) {
        cout << n*k/2 << endl;
        return 0;
    }

    s += s;
    ll con = 1, ret1 = 0, ret2 = 0;
    FOR(i, 1, 2*n) {
        if(s[i-1]==s[i]) con++;
        else con = 1;
        
        if(con>0 && con%2==0) {
            if(i<n) ret1++;
            else ret2++;
        }
    }

    cout << ret1 + (k-1)*ret2 << endl;

    return 0;
}


Measured memory_bytes: 256
#Sを取得
s = input()

#1文字目を取り出す
s1 = s[0]

#3文字目と末尾から2文字目の間の文字列を取り出す。
s2 = s[2:-1]

#AとCを元の文字列から消しちゃう。
s = s.replace('A','')
s = s.replace('C','')

#sを全て小文字に変換した文字列を用意する。
#これとsが一致したら、sはもともと全部小文字だったことになる。
t = s.lower()

if(s1 == 'A' and s2.count('C') == 1 and t == s):    #1文字目がAで、Cの数が1個だけで、それ以外の文字が全て小文字なら
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include <sstream>
#include <iomanip>


using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 int n, f=0;
 string s;
 cin >> n >> s;
 for(int i=0;i<1000;i++){
   ostringstream sout;
    sout << std::setfill('0') << std::setw(3) << i;
    string c = sout.str();
   int j=0;
   while(j<n){
     if(s[j]==c[0]){
       j++;
       break;
     }
     j++;
   }
   while(j<n){
     if(s[j]==c[1]){
       j++;
       break;
     }
     j++;
   }   
    while(j<n){
     if(s[j]==c[2]){
       j++;
//       cout << c << endl;
       f++;
       break;
     }
     j++;
   }
 }
  cout << f << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	string yaki = "YAKI";
	string S;
	cin >> S;

	if (S.size() < 4) {
		cout << "No" << endl;
		return 0;
	}

	rep(i, 4) {
		if (S[i] != yaki[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, char>> p(m);

  for (int i = 0; i < m; i++) cin >> p.at(i).first >> p.at(i).second;

  for (int i = 0; i <= 1000; i++) {
    string s = to_string(i);
    if (s.size() != n) continue;
    bool ok = true;
    for (int j = 0; j < m; j++) {
      if (s.at(p.at(j).first - 1) != (p.at(j).second)) ok = false;
    }
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

struct pair_ii_hash {
    inline size_t operator()(const pair<int,int> & p) const{
        const auto a = hash<int>()(p.first);
        const auto b = hash<int>()(p.second);
        return a ^ (b << 1);
    }
};

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

    int N, M; cin >>N >>M;
    vector<pair<int, int>> PY(M);
    vector<int> PY_sorted_i(M);
    rep(i, M) {
        cin >> PY[i].first >> PY[i].second;
    }
    iota(all(PY_sorted_i), 0);
    sort(all(PY_sorted_i), [&](int a, int b) { return PY[a] < PY[b]; });

    unordered_map<pair<int, int>, int, pair_ii_hash> x_map;
    int P_prev = -1;
    int x;
    rep(i, M) {
        const pair<int, int>& py = PY[PY_sorted_i[i]];
        if (py.first != P_prev) {
            x = 1;
        } else {
            x++;
        }
        x_map.emplace(py, x);
        P_prev = py.first;
    }

    rep(i, M) {
        printf("%06d%06d\n", PY[i].first, x_map[PY[i]]);
    }
}


Measured memory_bytes: 8356