akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [u64; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1

fn main() {
    input! { s: chars }
    let mut s = s;
    for t in s.iter_mut() {
        if *t == 'A' || *t == 'G' || *t == 'C' || *t == 'T' {
        } else {
            *t = ' ';
        }
    }
    let s: String = s.into_iter().collect();
    let mut ans = 0;
    for t in s.split_whitespace() {
        let l = t.len();
        if l > ans { ans = l; }
    }
    println!("{}", ans);
}

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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int selectionSort(int a[], int n) {
  ll result = 0, minj = 0, i, j;
  for (i = 0; i < n - 1; i++) {
    minj = i;
    for(j = i; j < n; j++) {
      if (a[j] < a[minj]) minj = j;
    }
    swap(a[i], a[minj]);
    if (i != minj) result++;
  }
  return result;
}

signed main() {
	ll n, a[100], result;
  cin >> n;
  rep(i, n) cin >> a[i];

  result = selectionSort(a, n);

  rep(i, n) {
    if (i == n - 1) {
      cout << a[i] << endl;
      break;
    }
    cout << a[i] << " ";
  }
  cout << result << endl;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

ll euclidean_gcd(ll a, ll b)
{
    if(a<b) swap(a, b);
    ll r;
    while((r=a%b)!=0){
        a=b;
        b=r;
    }

    return b;
}

int main()
{
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    ll gcd=euclidean_gcd(C,D);
    ll cd=C*D/gcd;
    cout << B-A+1-(B/C-(A-1)/C)-(B/D-(A-1)/D)+(B/cd-(A-1)/cd) << endl;

    return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N, M; cin >> N >> M;
    vi count(M+1);
    REP(i, N)
    {
        int K; cin >> K;
        REP(j, K)
        {
            int A; cin >> A;
            count[A]++;
        }
    }
    int ans = 0;
    REP1(i, M) if(count[i] == N) ans++;
    cout << ans << endl;
}
    
int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<int> a;

int main(void){
  int k,t;
  cin >> k >> t;
  rep(i,t){
    cin >> k;
    a.pb(k);
  }
  sort(all(a));
  int ans = 0;
  rep(i,a.size()) ans+= a[i];
  ans -= a[a.size()-1];
  ans -= a[a.size()-1];
  ans++;
  if(ans >= 0){
    cout << 0 << endl;
  }else{
    cout << -ans << endl;
  }
    
  return 0;
}


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

#define int long long

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

int N;
int x[200000], y[200000];
int idx[200000];

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        if (x[i] > y[i])
            swap(x[i], y[i]);
    }
    int ans;
    int R_max, B_max, R_min, B_min;
    R_max = B_max = 0, R_min = B_min = LLONG_MAX;
    for (int i = 0; i < N; i++) {
        R_max = max(R_max, x[i]), R_min = min(R_min, x[i]);
        B_max = max(B_max, y[i]), B_min = min(B_min, y[i]);
    }
    ans = (R_max - R_min) * (B_max - B_min);

    R_max = B_max = 0, R_min = B_min = LLONG_MAX;
    for (int i = 0; i < N; i++) {
        idx[i] = i;
        R_max = max(R_max, y[i]), R_min = min(R_min, x[i]);
        B_max = max(B_max, x[i]);
    }

    sort(idx, idx + N, [](int l, int r) { return y[l] < y[r]; });
    stable_sort(idx, idx + N, [](int l, int r) { return x[l] < x[r]; });
    int y_min = LLONG_MAX;
    for (int i = 0; i < N - 1; i++) {
        B_max = max(B_max, y[idx[i]]);
        y_min = min(y_min, y[idx[i]]);
        B_min = min(y_min, x[idx[i + 1]]);
        ans = min(ans, (R_max - R_min) * (B_max - B_min));
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "numeric"
using namespace std;

long long nzyou(int a,int b) {
	long long c = 1;
	for (int i = 1; i <= b; i++) {
		c *= a;
	}
	return c;
}

int main() {
	long long n;
	cin >> n;
	long long ans = 0;
	if (n % 2 != 0) {
		ans = 0;
	}
	else {
		for(int i=1;nzyou(5,i)<=n/2;i++){
			ans += (n/2) / nzyou(5, i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
I = [tuple(map(int, input().split())) for _ in range(N)]
As = []
Bs = []
for a, b in I:
	As.append(a)
	Bs.append(b)
As.sort()
Bs.sort()

if N % 2 == 0:
	lows = As[N//2] + As[N//2-1]
	his = Bs[N//2] + Bs[N//2-1]
else:
	lows = As[N//2]
	his = Bs[N//2]

print(his - lows + 1)


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

using namespace std;

typedef unsigned long long ull;

ull A[2000000],N,sum,maks;


int main()
{
    maks = 0;
    
    cin>>N;
    
    for(ull i = 0; i<N; i++){
        cin>>A[i];
    }
    
    for(ull i = 0; i<N; i++){
        if(A[i] < maks){
            sum += maks - A[i];
        } else if(A[i] > maks){
            maks = A[i];
        }
    }
    
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 5132
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
*/public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}
static class TaskC   {
public void solve(int testNumber, Scanner in, PrintWriter out) {
        int D = in.nextInt();
        int G = in.nextInt();
        int p[] = new int[D];
        int c[] = new int[D];
        for (int i = 0; i < D; i++) {
            p[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        int ans = 1<<30;
        int[] magic = {0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4, 13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14};
        for (int bit = 0; bit < 1 << D; bit++) {
            int sum = 0;
            int tans = 0;
            HashSet<Integer> hs = new HashSet<>();
            for (int cbit = bit; cbit != 0; cbit &= (cbit - 1)) {
                int next1bit = cbit & -cbit;
                int i = magic[next1bit * 0x076be629 >>> 27];
                sum += 100 * (i + 1) * p[i] + c[i];
                tans += p[i];
                hs.add(i);
            }
            a:if (sum < G) {
                for (int i = D - 1; i >= 0; i--) {
                    if (hs.contains(i)) continue;
                    for (int j = 0; j < p[i]; j++) {
                        sum += 100 * (i+1);
                        tans++;
                        if(sum >= G) break a;
                    }
                }
            }
            ans = Math.min(ans, tans);
        }
        out.println(ans);
    }
}
}



Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll N,A,B;
vector<pll> ranges;
void solve() {
    cin >> A >> B;
    ll ans = 0;
    if(A>=B){
        ans += A--;
    }else{
        ans += B--;
    }
    if(A>=B){
        ans += A--;
    }else{
        ans += B--;
    }
    print(ans);
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3636
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long ans;
    foreach (i; 0 .. 61)
    {
        long[2] cnt;
        foreach (a; A)
            cnt[(a & (1L << i)) != 0]++;
        long x = cnt[0] * cnt[1] % MOD;
        foreach (_; 0 .. i)
            x = (x << 1) % MOD;
        ans = (ans + x) % MOD;
    }
    writeln(ans);
}


Measured memory_bytes: 18104
#include <cstdio>

int main(void)
{
    int A,B,N;
    scanf("%d%d%d",&N,&A,&B);
    if(N==1)
    {
        if(A==B)
            printf("1\n");
        else
            printf("0\n");
    }
    else 
    {
        if(A>B)
            printf("0\n");
        else
            printf("%lld\n",(long long )(B-A)*(N-2)+1);
    }
    return 0;
}
    

Measured memory_bytes: 128
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    /////////////////////
    // Write code below /
    /////////////////////
    int numberOfButtons;
    cin >> numberOfButtons;
    vector<int> buttons(numberOfButtons);
    
    for (int button_i = 0; button_i < numberOfButtons; button_i++) {
        int nextButtonIndex;
        cin >> nextButtonIndex;
        nextButtonIndex--;
        buttons.at(button_i) = nextButtonIndex;
    }
    
    int currentButtonIndex = 0;
    for (int count = 0;; count++) {
        if (currentButtonIndex == 1) {  // ボタン2が光っている場合
            cout << count << endl;
            break;
        }
        
        // ボタンの数以上にループをしている場合 = ボタン2が押せない場合
        if (count >= numberOfButtons) {
            cout << -1 << endl;
            break;
        }
        
        currentButtonIndex = buttons.at(currentButtonIndex);
    }
    
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <map>

using namespace std;

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

int main() {
  int N; cin>>N;
  ll ans = 0;
  vector<string> a(N);
  REP(i,N) {
    cin>>a[i];
  }
  REP(k,N) {
    bool ok = true;
    REP(row,N) {
      int r1 = row;
      REP(col,N) {
	int c1 = col;
	int r2 = (col-k+N)%N;
	int c2 = (r1+k)%N;
        //      cout << k << r1 << c1 << r2 << c2 << endl;                              
        if(a[r1][c1] != a[r2][c2]) {
          ok = false;
          break;
        }
      }
      if(!ok) break;
    }
    if(ok) ans += (ll)N;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main() {
	int a,b,c,d,e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if (a==0)
		printf("1\n");
	else if (b==0)
		printf("2\n");
	else if (c==0)
		printf("3\n");
	else if (d==0)
		printf("4\n");
	else if (e==0)
		printf("5\n");
	return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <cmath>
#include <vector>
#include <string>


using namespace std;


int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    
    string S;
    cin >> S;
    
    
    int cnt = 0, sea = 0;
    for( int i = 0; i < N; ++i ){
        int flag = 0;
        switch( S.c_str()[i] ){
            case 'a':
                if( cnt < A+B ){ flag = 1; ++cnt; } break;
            case 'b': ++sea; if( cnt < A+B && sea <= B ){ flag = 1; ++cnt; } break;
        }
        if( flag ) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 896
import math

def myfactorial(n):
  return math.factorial(n)

def combinations_count(n, r):
  return (myfactorial(n) // (myfactorial(n - r) * myfactorial(r))) % 1000000007

n, k = map(int, input().split())
for i in range(1, k+1):
  if n-k+1 < i:
    print(0)
  else:
    print(combinations_count(k-1, i-1) * combinations_count(n-k+1, i) % 1000000007) 

Measured memory_bytes: 3316
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    var N = scn.nextInt()
    var list = arrayListOf("a","b","c","d","e","f","g","h","i","j")

    var ans0 = arrayListOf<String>("a")
    var ans1 = arrayListOf<String>()

    for (i in 2..N) {
        for (e in ans0) {
            var atOnce = false
            for (j in 1..i) {
                if (e.indexOf(list[j - 1]) == -1 && atOnce == false) {
                    atOnce = true
                    ans1.add(e + list[j - 1])
                }
                if (e.indexOf(list[j - 1]) != -1) {
                    ans1.add(e + list[j - 1])
                }
            }
        }
        ans0.clear()
        ans0 = ans1.clone() as ArrayList<String>
        ans1.clear()
    }

    ans0.sort()
    for(i in ans0)
        println(i)
}

Measured memory_bytes: 53104
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	var ans int64 = 0

	a := make([]int64, N, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}

	maxi := a[0]

	for i := 1; i < N; i++ {
		if a[i] < maxi {
			ans += maxi - a[i]
		} else {
			maxi = a[i]
		}
	}

	fmt.Println(ans)

}


Measured memory_bytes: 6484
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 500010


int main(){
  int n;
  ll a[SIZE], b[SIZE];
  pair<ll,ll> p[SIZE];
  
  scanf("%d",&n);

  for(int i=0;i<n;i++){
    scanf("%lld%lld",a+i, b+i);
    p[i] = {a[i], b[i]};
  }

  sort(p,p+n);

  ll ans = 0, sum = 0;
  
  for(int i=0;i<n;i++){
    ll a = p[i].first;
    ll b = p[i].second;
    sum = max(sum + b, a + b);

    ans = max(ans, sum - a);
  }

  printf("%lld\n",ans);
  
  
  return 0;
}



Measured memory_bytes: 18852
read
s=(`sort -n`)
total=$((`echo ${s[@]} | tr ' ' +`))
if((total%10==0))
then
    min=`echo ${s[@]} | tr ' ' '\n' | grep -v "0$" | head -1`
    total=$((total-min))
fi
((total%10==0)) && echo 0 || echo $total


Measured memory_bytes: 936
import sys 

inp=sys.stdin.readline()


def coffeeLike(inp):
	
	li=list(inp)
	if(len(li)>=6):
		if (li[2]==li[3]) and (li[4]==li[5]):
			print("Yes")
		else:
			print("No")
	else:
		print("No")
		
	
coffeeLike(inp)	

Measured memory_bytes: 3060
/****************************
 * 作者：zxf
 * 日期：2017/8/8
 * 标题：こだわり者いろはちゃん / Iroha's Obsession
 * 题号：ARC058C
 * 做题方法：...
 * 结果：
 * Time used：
 * Memory used：
 ****************************/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define LL long long
#define pb push_back
#define pob pop_back
#define mp make_pair
#define FILL(a,v) memset((void*)a,v,sizeof(a))
#define FILL0(a) FILL(a,0)
#define FILL1(a) FILL(a,-1)
#define ALL(a) (a).begin(),(a).end()
#define Inf 1e9
#define Mod 1000000007
#define foreach(it,x) for(typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define FOR(i,x) for(int i=0;i<x;i++)
#define RFOR(i,x) for(int i=x-1;i>=0;i--)
#define FFOR(i,a,b) for(int i=a;i<b;i++)
#define FRFOR(i,a,b) for(int i=a-1;i>=b;i--)
#define SZ(a) ((int)(a).size())
#define FI first
#define SE second
#define OVER(a) return puts(a),0
#define fastio ios::sync_with_stdio(0)
#define filei(f) freopen(f,"r",stdin)
#define fileo(f) freopen(f,"w",stdout)
using namespace std;
typedef pair<int,int> pii;
typedef unsigned long long UINT;
typedef unsigned int Uint;
typedef long long INT;
typedef pair<INT,INT> PII;
typedef stringstream sst;
typedef istringstream iss;
typedef vector<int> vint;
typedef vector<INT> VINT;
typedef vector<pii> vpii;
typedef vector<PII> VPII;
typedef priority_queue<int> pqi;
typedef priority_queue<INT> PQI;
typedef priority_queue<pii> pqp;
typedef priority_queue<PII> PQP;
typedef priority_queue<int,vint,greater<int> > xqi;
typedef priority_queue<INT,VINT,greater<INT> > XQI;
typedef priority_queue<pii,vpii,greater<pii> > xqp;
typedef priority_queue<PII,VPII,greater<PII> > XQP;

int n,m;
char s[10];
set<char> cant;

int main()
{
	scanf("%d%d",&n,&m);
	int c;
	for(int i=0;i<m;i++)
	{
		scanf("%d",&c);
		cant.insert(c+'0');
	}
	while(1)
	{
		sprintf(s,"%d",n);
		int can=1;
		for(int i=0;i<strlen(s);i++)
			if(cant.count(s[i]))
				can=0;
		if(can==1)return printf("%d\n",n),0;
		n++;
	}
}

Measured memory_bytes: 256
import java.lang.Math.*

const val MOD = 1000000007L

fun main(args: Array<String>) {
    val n = readInt()
    val h = readLongList().reversed().toMutableList()

    n.rep { index ->
        if (index < h.size - 1) {
            if (h[index] < h[index + 1] - 1) {
                println("No")
                return
            } else if (h[index] == h[index + 1] - 1) {
                h[index + 1] = h[index + 1] - 1
            }
        }
    }

    println("Yes")
}


fun readList() = readLine()!!.split(' ')
fun readInt() = readLine()!!.split(' ').map(String::toInt).first()
fun readIntList() = readList().map(String::toInt)
fun readLongList() = readList().map(String::toLong)
fun readDoubleList() = readList().map(String::toDouble)

fun readPair(): Pair<String, String> {
    val splite = readLine()!!.split(' ')
    return Pair(splite[0], splite[1])
}

fun <T> List<T>.copy() = this.map { it }

// 速度のためforEachは避ける
inline fun Int.rep(start: Int = 0, body: (Int) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

inline fun Long.rep(start: Long = 0, body: (Long) -> Unit) {
    for (i in start until this + start) {
        body(i)
    }
}

// 約数のList
fun divisor(value: Long): List<Long> {
    val max = sqrt(value.toDouble()).toLong()
    return (1..max)
        .filter { value % it == 0L }
        .map { listOf(it, value / it) }
        .flatten()
        .sorted()
}

// 範囲内の素数を取得
// fromだけ指定すると戻り値の個数で素数判定ができる
fun prime(from: Long, to: Long = from): List<Long> {
    return (from..to).filter { i ->
        val max = Math.sqrt(i.toDouble()).toLong()
        (2..max).all { j -> i % j != 0L }
    }
}

// 素因数分解
fun decom(value: Long): List<Long> {
    if (value == 1L) return listOf(1)
    val max = Math.sqrt(value.toDouble()).toLong()
    return prime(2, max).filter { value % it == 0L }
}

// 最大公約数
fun gcd(a: Long, b: Long): Long {
    return if (a % b == 0L) b else gcd(b, a % b)
}

// 文字列を入れ替え
fun swap(base: String, a: String, b: String): String {
    return base.map {
        when (it) {
            a.toCharArray()[0] -> b
            b.toCharArray()[0] -> a
            else -> it.toString()
        }
    }.joinToString()
}

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void pout(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void pout(const T &value, const Args&... args){std::cout << value << " ";pout(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  i64 N, K;

  while(cin >> N >> K){
    i64 ans;

    N %= K;
    
    ans = min(N, K-N);

    pout(ans);
  }


  return 0;
}


Measured memory_bytes: 256
/**
*    author:  Dooloper
*    created: 17.09.2020 23:33:25
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  vector<int> c(n);
  rep(i,n) cin >> p[i], --p[i];
  rep(i,n) cin >> c[i];
  ll ans = (-1) * 1e9;
  for(int i = 0; i < n; i++){
    int v = i;
    ll cycle_sum = 0;
    int cycle_cnt = 0;
    while(1){
      cycle_cnt++;
      cycle_sum += c[v];
      v = p[v];
      if(v == i) break;
    }

    ll path = 0;
    int cnt = 0;

    while(1){
      cnt++;
      path += c[v];
      if(cnt > k) break;
      int num = (k-cnt)/cycle_cnt;
      ll score = path + max(0ll, cycle_sum) * num;
      ans = max(ans, score);
      v = p[v];
      if(v == i) break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3692
M, D = map(int, input().split())
c = 0
for m in range(1, M + 1):
    for d in range(1, D + 1):
        d1 = d % 10
        d10 = int(d / 10)
        if d1 > 1 and d10 > 1 and d1 * d10 == m:
            c += 1
print(c)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll i,a[10];
	for(i=0;i<5;i++) {
		cin>>a[i];
	}
	for(i=0;i<5;i++) {
		if(a[i]==0) {
			cout<<i+1;
			break;
		}
	}
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
    ll n,k;
    cin>>n>>k;
    string t="rsp";
    map<char,char> win;
    win['r']='p';
    win['s']='r';
    win['p']='s'; 
    map<char,ll> mp;
    for(int i=0;i<3;i++){
        ll d;cin>>d;
        mp[t[i]]=d;
    }
    string s;
    cin>>s;
    V<bool> vis(s.size(),true);
    ll ans=0;
    int m=s.size();
    V<bool> same(m,true);
    for(int i=0;i<m;i++){
        if(!vis[i])break;
        for(int j=i;j<m-k;j+=k){
            vis[j]=false;
            if(same[j]&&same[j+k]&&s[j]==s[j+k])same[j+k]=false;
        }
    }
    for(int i=0;i<m;i++){
        if(!same[i])continue;
        else ans+=mp[win[s[i]]];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vi L(N);
  rep(i,N) cin >> L[i];
  
  int ans=0;
  rep(i,N-2) {
    rep2(j,i+1,N-1) {
      rep2(k,j+1,N) {
        vi a={L[i],L[j],L[k]};
        sort(a.begin(),a.end());
        if(a[0]!=a[1]&&a[1]!=a[2]&&a[0]+a[1]>a[2]) ans++;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>

int main(void){
    long long x, y, q, r;
    
    scanf("%lld", &x);
    q = x / 11;
    r = x % 11;
    
    y = q*2;
    if (r>6) y+=2;
    else if (r>0) y+=1;
    printf("%lld", y);
  
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int n, m, A[100][100];
	static int sum, total;

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

	for (int i = 0; i < n; i++) {
		sum = 0;
		for (int j = 0;j < m;j++) {
			printf("%d ", A[i][j]);
			sum += A[i][j];
			total += A[i][j];
		}
		printf("%d\n", sum);
	}
	for (int j = 0; j < m; j++) {
		sum = 0;
		for (int i = 0; i < n; i++) {
			sum += A[i][j];
		}
		printf("%d ", sum);
	}

	printf("%d\n", total);
	return 0;
}

Measured memory_bytes: 2692
#include <stdio.h>
int main(){
int a,b,c,d,e,max;
scanf("%d",&a);
scanf("%d",&b);

c=a+b;
d=a-b;
e=a*b;
max = c;
  if( max < d ) {
    max = d;
  }
  if( max < e ) {
    max = e;
  }
  
  printf("%d\n",max);
  
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
const int Mod = 1e9+7;

long long a[N], cnt[N];

int main ()
{
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin >> n;
	for (int i = 0 ; i < n ;  i++) {
		cin >> a[i];
		cnt[a[i]]++;
		if ((a[i]%2 == n%2)) {
			cout << 0 << endl;
			return 0;
		}
	}
	if ((cnt[0] && n%2==0) || cnt[0] > 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (cnt[i] && cnt[i]!=2) {
			cout << 0 << endl;
			return 0;
		}
	}
	
	long long res = 1;
	for (int i = 0 ;  i< n/2 ; i++) {
		res *= 2;
		res %= Mod;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
  int n;
  cin >> n;
  
  int as[n+1];
  for (int i = 1; i <= n; i++) {
    cin >> as[i];
  }
  
  int bs[n+1];
  int m = 0;
  for (int i = n; i > 0; i--) {
    int b = as[i];
    for (int j = 2*i; j <= n; j+=i) {
      b = b ^ bs[j];
    }
    bs[i] = b;
    if (bs[i] == 1) {
      m += 1;
    }
  }
  
  cout << m << endl;
  bool is_first = true;
  for (int i = 1; i < n+1; i++) { 
    if (bs[i] == 1) {
      cout << (is_first ? "" : " ") << i;
      is_first = false;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2432
import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

s = load(str)    


if len(s) % 2 == 1:
    print('No')
    sys.exit(0)

n = int(len(s) / 2)

target = 'hi' * n

if target == s:
    print('Yes')
    sys.exit(0)
print('No')

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

int a[1000005],n,k,dp[1000004][2],dp1[1000004][2];
int f(int m) {
	for(int i=0;i<n;i++) dp[i][0] = 0,dp[i][1] = 0, dp1[i][0] = 0,dp1[i][1] = 0;
	if(k%2) {
		int c = 0;
		if(a[0]<=m) c++;
		for(int i=2;i<n;i++) {
			if(a[i]<=m) {
				if(i==0) {
					dp1[i][0] = 0;
					dp1[i][1] = 1;
				} else {
					dp1[i][0] = max(dp1[i-1][0],dp1[i-1][1]);
					dp1[i][1] = dp1[i-1][0]+1;
				}
			} else {
				if(i==0) {
					dp1[i][0] = 0;
					dp1[i][1] = 0;
				} else {
					dp1[i][0] = max(dp1[i-1][0],dp1[i-1][1]);
					dp1[i][1] = 0;
				}
			}
		}
		if(c+max(dp1[n-1][0],dp1[n-1][1])>=(k+1)/2) return 1;
	}
	//if(m==1) printf("yo");
	int i = 0;
	if(k%2) i++;
	for(;i<n;i++) {
		if(a[i]<=m) {
			if(i==0) {
				dp[i][0] = 0;
				dp[i][1] = 1;
			} else {
				dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
				dp[i][1] = dp[i-1][0]+1;
			}
		} else {
			if(i==0) {
				dp[i][0] = 0;
				dp[i][1] = 0;
			} else {
				dp[i][0] = max(dp[i-1][0],dp[i-1][1]);
				dp[i][1] = 0;
			}
		}
	}
	//printf("%d %d\n",dp[n-1][1],dp[n-1][0]);
	return max(dp[n-1][1],dp[n-1][0]) >= k/2;
}
int main() {
	char ch;
	int n,k,a[100005],sum=0;;
	scanf("%d %d",&n,&k);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	for(int i=0;i<k;i++) sum+=a[i];
	printf("%d\n",sum);
}

Measured memory_bytes: 3836
// AtCoder Beginner Contest 088 D - Grid Repainting
// https://abc088.contest.atcoder.jp/tasks/abc088_d
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for(int i = 0; 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;}

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

    int H, W; cin >> H >> W;
    vector<string> grid(H);
    int c_white = 0;
    rep(i, H) {
        cin >> grid[i];
        c_white += count(all(grid[i]), '.');
    }

    int ans = 0;

    int dw[4] = { 0, 0,-1, 1 };
    int dh[4] = {-1, 1, 0, 0 };

    vector<vector<int>> d(H, vector<int>(W, -1));
    queue<pair<int, int>> q;

    d[0][0] = 0;
    q.push(make_pair(0, 0));
    
    while (!q.empty()) {
        pair<int, int> hw = q.front(); q.pop();
        rep(j, 4) {
            int h = hw.first + dh[j];
            int w = hw.second + dw[j];
            if (0 <= h && h < H && 0 <= w && w < W && grid[h][w] != '#' && d[h][w] == -1) {
                d[h][w] = d[hw.first][hw.second]+1;
                if (h == H-1 && w == W-1) {
                    while (!q.empty()) q.pop();
                    break;
                }
                q.push(make_pair(h, w));
            }
        }
    }

    ans = d[H-1][W-1]==-1 ? -1 : c_white - (d[H-1][W-1]+1);

    cout << ans << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

line = input().split(" ")
n = int(line[0])
c = int(line[1])

sushi = []
for _ in range(n):
    line = input().split(" ")
    sushi.append([int(line[0]), int(line[1])]) #[x,v]

r = []
state = 0
rmax = -9999999999
for i in range(n):
    s = sushi[i]
    state += s[1]

    if state-s[0]>rmax:
        rmax = state-s[0]
    r.append(rmax)

state = 0
ret1 = r[-1]
for i in range(n-1,0,-1):
    s = sushi[i]
    state += s[1]

    s = state-2*(c-s[0]) + r[i-1]
    if s>ret1:
        ret1 = s




l = [0 for _ in range(n)]
state = 0
lmax = -9999999999999
for i in range(n-1,-1,-1):
    s = sushi[i]
    state += s[1]

    if state-(c-s[0])>lmax:
        lmax = state-(c-s[0])
    l[i] = lmax

state = 0
ret2 = l[0]
for i in range(n-1):
    s = sushi[i]
    state += s[1]

    s = state-2*s[0] + l[i+1]
    if s>ret2:
        ret2 = s

print(max(ret1,ret2,0))


Measured memory_bytes: 27596
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

a,b = na()

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
        
f = gcd(a,b)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
    
d = factorization(f)
k = 1 if len(d) == 1 and d[0][0] == 1 else len(d)+1
print(k)

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  vector<string> s(3);
  vi sz(3);
  rep(i, 0, 3) {
    cin >> s[i];
    sz[i] = s[i].size();
  }

  vi p(3, 0);
  int nxt = 0;
  while(1) {
    if(sz[nxt] == 0) {
      cout << (char)('A' + nxt) << endl;
      return 0;
    }

    int n = s[nxt][p[nxt]] - 'a';
    sz[nxt]--;
    p[nxt]++;
    nxt = n;
  }
}


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

int main() {
    int D, N;
    cin >> D >> N;
    int ans = 1;
    for (int i = 0; i < D; i++) {
        ans *= 100;
    }
    if (N != 100) {
        cout << ans * N << endl;
    }
    else {
        cout << ans * 101 << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
  	cin>>m>>n;
  	int a,sum=0;
  	for(int i=0;i<n;i++){
        cin>>a;
        sum+=a;
  	}
  	printf("%d\n",(m-sum)<0?-1:(m-sum));
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
    string s;
	int sum = 0;
    cin >> s;
    for(int i = 0;i<6;i++){
        if(s[i] == '1'){
            sum ++;
        }
    }
    cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  int A[N];
  rep(i,N){
    cin >> A[i];
    A[i] -= i+1;
  }
  sort(A,A+N);
  ll ans1 = 0, ans2 = 0;
  rep(i,N) ans1 += abs(A[N/2]-A[i]);
  if (N>1) {
    rep(i,N) ans2 += abs(A[N/2-1]-A[i]);
    chmin(ans1,ans2);
  }
  cout << ans1 << endl;
  
  //rep(i,N) cout << A[i] << endl;
  
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4364
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>
#include <math.h>       /* pow */

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
    ll A;
    float B;
    cin>>A>>B;
    ll C = (ll)(B*100+0.5);
    ll ans = A*C/100; 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	A
# CreatedDate:  2020-08-15 20:38:43 +0900
# LastModified: 2020-08-15 21:01:55 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    if S == 'RRS' or S == 'SRR':
        print(2)
    elif S == 'RRR':
        print(3)
    elif S == 'SSS':
        print(0)
    else:
        print(1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9028
#include <iostream>
#include <string>
#include <fstream>

int main(){

    int data_set_num;
    std::string str;
    std::string from = "Hoshino";
    std::string to = "Hoshina";
    std::cin >> data_set_num;
    std::cin.ignore();
    //std::getline(std::cin,str);
    //sscanf(str.c_str(),"%d ",&data_set_num);

    while(data_set_num--){
        std::getline(std::cin,str);
        std::string::size_type pos = str.find(from);
        while(pos != std::string::npos){
            str.replace(pos, from.size(), to);
            pos = str.find(from, pos + to.size());
        }
        std::cout << str << std::endl;
    }

    return 0;
}

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

int main()
{
    int N, A, B, C, D, penX = 0, penY = 0, rateX = 0, rateY = 0;
    cin >> N >> A >> B >> C >> D;

    while (penX < N)
    {
        penX += A;
        rateX += B;
    }

    while (penY < N)
    {
        penY += C;
        rateY += D;
    }
    
    
    if (rateX > rateY)
    {
        cout << rateY <<endl;
    }else{
        cout << rateX <<endl;
    }
    

    return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cctype>
#include <stack>
#include <map>
#include <cstring>
#include <sstream>
#include <set>
#include <list>
#include <fstream>
#include <iomanip>
#include <assert.h>

#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define op                            \
    std::ios::sync_with_stdio(false); \
    std::cin.tie(0);

const int INF = 0x3f3f3f3f;
const int maxn = (100000 + 10);
const int mod = (1e9 + 7);

int main()
{
    int k,x;
    scanf("%d %d",&k,&x);
    if(k*500>=x) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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



int main() {
string S, T;
cin >> S >> T;
string Si = S;
string ans = "No";
if(S == T)ans = "Yes";
for(int i = 0; i < 115; i++){
char a = Si[0];
Si.erase(Si.begin());
Si += a;
if(Si == T)ans = "Yes";
}
cout << ans << endl;


}


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

int main(){
	

	int t = 1;
	//cin >> t;
	while(t--){
		int n= 0;
		string s, t;
		cin >> s >> t;
		for(int i = 0; i < s.length();++i){
			if(s[i]!=t[i]) n = 1;
		}
		if(n){
			cout << "No";
		}
		else cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  
  while (0 <= K) {
    if (B <= A) {
      B <<= 1;
    } else if (C <= B) {
      C <<= 1;
    } else {
      break;
    }
    --K;
  }
  if (0 <= K) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

//LP SEIVE
const int N = 1e5+2;
int lp[N+1];
vector<int> pr;
void LPS(){
  for (int i=2; i<=N; ++i) {
    if (lp[i] == 0){
      lp[i] = i;
      pr.push_back (i);
    }
    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
      lp[i * pr[j]] = pr[j];
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  LPS();
  int n,k;cin >> n >> k;
  LL ans = 0;
  LL cnt[k+1];
  for(int i=k;i>0;i--){
    cnt[i] = POW(k/i,n,MOD);
    for(int j=2;j<=k/i;j++) {cnt[i] = cnt[i] - cnt[j*i] + MOD;cnt[i] %= MOD;}
    ans += cnt[i]*i;
    ans %= MOD;
  }
  cout << ans << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 5000
gets.split.map(&:to_i).tap do |x, y|
  [
    [1, 3, 5, 7, 8, 10, 12],
    [4, 6, 9, 11],
    [2]
  ].each do |group|
    if group.include?(x) && group.include?(y)
      puts('Yes')
      exit
    end
  end
end
puts('No')

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n, i;
  cin >> n >> i;
  dump(n-i+1);
  return 0;
}


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

ll a[100111][3],dp[100111][3],n,ans = 0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j==k)continue;
				dp[i][j] = max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	for(int i=0; i<3; i++)ans = max(ans,dp[n][i]);
	cout << ans << endl;
}


Measured memory_bytes: 4992
#include<stdio.h>
    int main(){
        int r, g, b, S;
            scanf("%d%d%d", &r, &g, &b);
                S = 100 * r + 10 * g + b;
                    if(S % 4 == 0){
                        printf("YES");
                    }else{
                        printf("NO");
                    }
    }

Measured memory_bytes: 128
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline

def solve(x):
    if x == 1:
        print(0)
    else:
        print(1)

            

def main():
    x = int(input())
    solve(x)


if __name__ == "__main__":
    main()

Measured memory_bytes: 64852
data = input().split()
 
n = int(data[0])
k = int(data[1])
 
hpstr = input().split()
hp = []
 
for i in range(n):
  hp.append(int(hpstr[i]))
 
hp.sort()
 
ans = 0
for i in range(n - k):
  ans += hp[i]
 
print(ans)


Measured memory_bytes: 26556
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int a[5],_2,_3,minn=111;
int main()
{
    cin>>a[0]>>a[1]>>a[2];
    do
    {
        _2=abs(a[1]-a[2]);
        _3=abs(a[0]-a[1]);
        if(minn>_2+_3)
            minn=_2+_3;
    }while(next_permutation(a,a+3));
    cout<<minn;
}


Measured memory_bytes: 256