akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;

/*
奇数個登場する頂点があると駄目？

1 2
1 3
奇数個の頂点があって木になる場合を生み出したい
なさそう

用いられてる頂点
*/

void solve(){
    int n,m;
    cin >> n >> m;
    int c[n+10];
    rep(i,n){
        c[i]=0;
    }
    rep(i,2*m){
        int tmp;
        cin >> tmp;
        c[tmp-1]++;
    }
    rep(i,n){
        if(c[i]%2!=0){
            cout << "NO" << endl;
            return;
        }
    }
    cout << "YES" << endl;
}

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



Measured memory_bytes: 640
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
s=list(input())

x=0
mx=0

for si in s:
    if si=='I':
        x+=1
    else:
        x-=1
    mx=max(x,mx)
print(mx)

Measured memory_bytes: 9132
#include<stdio.h>

int main(){
  int r,c,i,j,k,sum,sum2;
  scanf("%d %d",&r,&c);
  int H[r+2][c+2];

  for(i=0; i<=r; i++){
    for(j=0; j<=c; j++){
      H[i+1][j+1] = 0;
    }
  }

  for(i=1; i<=r; i++){
    for(j=1; j<=c; j++){
      scanf("%d",&H[i][j]);
    }
  }

  for(i=1; i<=r+1; i++){

    sum = 0;

    for(j=1; j<=c+1; j++){
      
      if(i!=r+1 && j==c+1){
	H[i][c+1] = sum;
	H[r+1][c+1] += sum;
      }

      else if(i==r+1 && j!=c+1){

	sum2 = 0;

	for(k=1; k<=r; k++) sum2 += H[k][j];

	H[i][j] = sum2;

      }

      else if(j<c+1) sum += H[i][j];
    }
  }


  for(i=1; i<=r+1; i++){
    for(j=1; j<=c+1; j++){

      if(j<c+1) printf("%d ",H[i][j]);
      else printf("%d",H[i][j]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll A,B,M;
    cin >> A >> B >> M;
    ll a[A],b[B];
    ll i;
    ll ami=100000000;
    ll bmi=100000000;
    for(i=0;i<A;i++){
        cin >> a[i];
        ami=min(ami,a[i]);
    }
    for(i=0;i<B;i++){
        cin >> b[i];
        bmi=min(bmi,b[i]);
    }
    ll ans=1000000000;
    ll x,y,c;
    for(i=0;i<M;i++){
        cin >> x >> y >> c;
        ans=min(ans,a[x-1]+b[y-1]-c);

    }
    ans=min(ans,ami+bmi);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
/**
*    author:  boutarou
*    created: 27.06.2020 21:00:51
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

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

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int cnt = 0;
    string s, t;
    cin >> s >> t;
    rep(i,s.size()) {
        if (s[i] != t[i]) cnt++;
    }
    cout << cnt << endl;
    
    return 0;
}

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

ll calc(ll x){
    ll ans = 0;
    while (x){
        ans += (x/5LL);
        x /= 5;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    if (n & 1) cout << 0;
    else cout << (ll)(n/10LL + calc(n/10));
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define MAXN 200001

int max(int a, int b) { return a > b ? a : b; }

int n, m, fa[MAXN], size[MAXN];

int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }

void Union(int x, int y) {
	int rootx = find(x), rooty = find(y);
	if (rootx == rooty) return;
	if (size[rootx] > size[rooty]) {
		fa[rooty] = rootx;
		size[rootx] += size[rooty];
	}
	else {
		fa[rootx] = rooty;
		size[rooty] += size[rootx];
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; ++i) fa[i] = i, size[i] = 1;
	for (int i = 1, u, v; i <= m; ++i) {
		scanf("%d %d", &u, &v);
		Union(u, v);
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (fa[i] == i) ans = max(ans, size[i]);
	}
	std::cout << ans << '\n';
	return 0;
}

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

int main(int argc, char const *argv[]) {
	string s;
	int ans;
	cin >> s;
	ans = s.size();

	for (size_t i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			break;
		}
		ans--;
	}

	for (size_t i = 0; i < s.size(); i++) {
		if (s[s.size() - i - 1] == 'Z') {
			break;
		}
		ans--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <queue>

#define INF (10000000)
#define MAX (100)

using namespace std;

struct edge { int to, cost; };
typedef pair<int, int> P;

vector<edge> T[MAX+1],C[MAX+1];
int dist[MAX+1];


int dijkstra_c(int s, int g)
{
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dist, dist + MAX + 1, INF);
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < C[v].size(); i++) {
            edge e = C[v][i];
            if(dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
    return dist[g];
}

int dijkstra_t(int s, int g)
{
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dist, dist + MAX + 1, INF);
    dist[s] = 0;
    que.push(P(0, s));

    while(!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        for(int i = 0; i < T[v].size(); i++) {
            edge e = T[v][i];
            if(dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                que.push(P(dist[e.to], e.to));
            }
        }
    }
    return dist[g];
}


int main()
{
    int n, m;
    while(cin >> n >> m && n) {
        for(int i = 0; i <= MAX; i++) {
            C[i].clear(); T[i].clear();
        }

        int a,b,c,t;
        for(int i = 0; i < n; i++) {
            cin >> a >> b >> c >> t;
            C[a].push_back((edge){b, c});
            C[b].push_back((edge){a, c});
            T[a].push_back((edge){b, t});
            T[b].push_back((edge){a, t});
        }
        
        int k,p,q,r;
        cin >> k;
        for(int i = 0; i < k; i++) {
            cin >> p >> q >> r;
            if(r == 0) cout << dijkstra_c(p, q) << endl;
            else       cout << dijkstra_t(p, q) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <cstdio>

using namespace std;

int n,i;

int main()
{
	scanf("%d %d",&n,&i);
	printf("%d\n",n-i+1);

	return 0;
}

/**                                                                          
 *          .,:,,,                                        .::,,,::.          
 *        .::::,,;;,                                  .,;;:,,....:i:         
 *        :i,.::::,;i:.      ....,,:::::::::,....   .;i:,.  ......;i.        
 *        :;..:::;::::i;,,:::;:,,,,,,,,,,..,.,,:::iri:. .,:irsr:,.;i.        
 *        ;;..,::::;;;;ri,,,.                    ..,,:;s1s1ssrr;,.;r,        
 *        :;. ,::;ii;:,     . ...................     .;iirri;;;,,;i,        
 *        ,i. .;ri:.   ... ............................  .,,:;:,,,;i:        
 *        :s,.;r:... ....................................... .::;::s;        
 *        ,1r::. .............,,,.,,:,,........................,;iir;        
 *        ,s;...........     ..::.,;:,,.          ...............,;1s        
 *       :i,..,.              .,:,,::,.          .......... .......;1,       
 *      ir,....:rrssr;:,       ,,.,::.     .r5S9989398G95hr;. ....,.:s,      
 *     ;r,..,s9855513XHAG3i   .,,,,,,,.  ,S931,.,,.;s;s&BHHA8s.,..,..:r:     
 *    :r;..rGGh,  :SAG;;G@BS:.,,,,,,,,,.r83:      hHH1sXMBHHHM3..,,,,.ir.    
 *   ,si,.1GS,   sBMAAX&MBMB5,,,,,,:,,.:&8       3@HXHBMBHBBH#X,.,,,,,,rr    
 *   ;1:,,SH:   .A@&&B#&8H#BS,,,,,,,,,.,5XS,     3@MHABM&59M#As..,,,,:,is,   
 *  .rr,,,;9&1   hBHHBB&8AMGr,,,,,,,,,,,:h&&9s;   r9&BMHBHMB9:  . .,,,,;ri.  
 *  :1:....:5&XSi;r8BMBHHA9r:,......,,,,:ii19GG88899XHHH&GSr.      ...,:rs.  
 *  ;s.     .:sS8G8GG889hi.        ....,,:;:,.:irssrriii:,.        ...,,i1,  
 *  ;1,         ..,....,,isssi;,        .,,.                      ....,.i1,  
 *  ;h:               i9HHBMBBHAX9:         .                     ...,,,rs,  
 *  ,1i..            :A#MBBBBMHB##s                             ....,,,;si.  
 *  .r1,..        ,..;3BMBBBHBB#Bh.     ..                    ....,,,,,i1;   
 *   :h;..       .,..;,1XBMMMMBXs,.,, .. :: ,.               ....,,,,,,ss.   
 *    ih: ..    .;;;, ;;:s58A3i,..    ,. ,.:,,.             ...,,,,,:,s1,    
 *    .s1,....   .,;sh,  ,iSAXs;.    ,.  ,,.i85            ...,,,,,,:i1;     
 *     .rh: ...     rXG9XBBM#M#MHAX3hss13&&HHXr         .....,,,,,,,ih;      
 *      .s5: .....    i598X&&A&AAAAAA&XG851r:       ........,,,,:,,sh;       
 *      . ihr, ...  .         ..                    ........,,,,,;11:.       
 *         ,s1i. ...  ..,,,..,,,.,,.,,.,..       ........,,.,,.;s5i.         
 *          .:s1r,......................       ..............;shs,           
 *          . .:shr:.  ....                 ..............,ishs.             
 *              .,issr;,... ...........................,is1s;.               
 *                 .,is1si;:,....................,:;ir1sr;,                  
 *                    ..:isssssrrii;::::::;;iirsssssr;:..                    
 *                         .,::iiirsssssssssrri;;:.                      
 */

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n, N) for(ll i=(n);i<(N);i++)
#define RREP(i, n, N) for(ll i=(N-1);i>=(n);i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(), (v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N, X;
ll s[55], p[55];

ll f(ll n, ll x){   //レベルn, 下からx
    if(x == 1){
        return n == 0 ? 1 : 0;
    }else if(1 < x && x <= s[n-1] + 1){
        return f(n-1, x-1);
    }else if(x == s[n-1] + 2){
        return p[n-1] + 1;
    }else if(s[n-1] + 2 < x && x <= 2*s[n-1] + 2){
        return p[n-1] + 1 + f(n-1, x-(s[n-1]+2));
    }else{  //x == 2*s[n-1] + 3
        //return p[n];
        return 2*p[n-1] + 1;
    }
}

int main() {
    cin>>N>>X;

    s[0] = 1;
    p[0] = 1;
    REP(i,1,N+1) s[i] = 2*s[i-1] + 3;
    REP(i,1,N+1) p[i] = 2*p[i-1] + 1;

    cout<<f(N, X)<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque
import sys

input = lambda: sys.stdin.readline().rstrip()

s = deque(list(input()))
q = int(input())

is_reverse = False
for i in range(q):
    query = input().split()
    if query[0] == '2':
        if (query[1] == '1' and not is_reverse) or (query[1] == '2' and is_reverse):
            s.appendleft(query[2])
        else:
            s.append(query[2])
    else:
        is_reverse = not is_reverse

result = ''.join(s)
if is_reverse:
    print(result[::-1])
else:
    print(result)


Measured memory_bytes: 8676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc011.contest.atcoder.jp/tasks/agc011_b>
問題文============================================================
 すぬけ君は，N 匹の変わった生き物を見つけました．
 それぞれの生き物には色と大きさが定まっており，i 番目の生き物の色は i，大きさは Ai で表されます．
 
 どの生き物も，大きさが自分の 2 倍以下であるような他の生き物を吸収することができます．
 大きさ A，色 B の生き物が大きさ C，色 D の生き物を吸収すると (C≤2×A)，合体して大きさ A+C，
 色 B の生き物になります．
 ここで，2 匹の生き物の大きさによっては，どちらも他方を吸収することが可能な場合があります．
 
 すぬけ君がこの生き物たちを観察していると，合体を繰り返して，最終的に 1 匹になりました．
 このとき，残った生き物の色として考えられるものは何種類あるかを求めてください．
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N);
    for(auto &in:A) cin >> in;
    sort(A.begin(),A.end());
    vector<ll> cusum(N+1,0);
    for(int i = 0; i < N;i++) cusum[i+1] = cusum[i] + A[i];
    ll ans = 0;
    A[0] = LINF;
    for(ll i = N - 1; i >= 0; i--){
       if(A[i] <= 2*cusum[i]) continue;
        ans = N - i;
        break;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
  string divide[4] = {"dream","dreamer","erase","eraser"};
int main(){
  
  
  string S;
  cin >> S;
  
  reverse(S.begin(),S.end());
  for(int i=0;i<4;++i)
    reverse(divide[i].begin(),divide[i].end());
  
  bool can = true;
  for (int i=0;i<S.size();){
    bool can2 = false;
    for (int j=0;j<4;++j){
      string d=divide[j];
      if (S.substr(i,d.size()) == d){
        can2 =true;
        i += d.size();
      }
    }
    if (can2==false){
      can =false;
      break;
    }
  }
  if (can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <stdio.h>
int main(void)
{
    int N;
    int a[1001];
    int flag = 0;
    scanf("%d ", &N);
    for (int i = 0; i < N; i++)
    {
        scanf("%d ", &a[i]);
    }
    for (int i = 0; i < N; i++)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 3 != 0 && a[i] % 5 != 0)
            {
                flag = 1;
            }
        }
    }
    if (flag == 0)
    {
        printf("APPROVED");
    }
    if (flag == 1)
    {
        printf("DENIED");
    }
    return 0;
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::collections::*;
use std::cmp::{min, max};

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let (N, A, B) = read!(i64, i64, i64);
	let mut a = A;
	a.setmin(B);
	let mut b = 0;
	b.setmax(A + B - N);
	println!("{} {}", a, b);
}


Measured memory_bytes: 8572
#include <iostream>
using namespace std;
int main()
{
  int x,y;
  while(cin >> x >> y){
    if(x < y){
      int t = x;
      x = y;
      y = t;
    }
    for(;;){
      int d = x % y;
      if(d == 0){
        cout << y << endl;
        break;
      }
      x = y;
      y = d;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int L, R;
    cin >> L >> R;
    int ans = 2018;
    ll value;
    for (ll i = L; i < R; i++)
    {
        for (ll j = i + 1; j <= R; j++)
        {
            value = (i * j) % 2019;
            if (value < ans)
            {
                ans = value;
                if (ans == 0)
                {
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int gcd(int a,int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}

int main() {
    int K;
    scanf("%d", &K);
    if(K % 7 == 0)
        K /= 7;
    if(gcd(10,K) != 1) {
        printf("-1\n");
        return 0;
    }
    int v = 1%K;
    int ans = 1;
    while(v != 0) {
        v = (10*v + 1)%K;
        ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 3788
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
int eq(char a,char b,char c){
    vector<char> k{a,b,c};
    sort(ALL(k));
    return distance(k.begin(),unique(ALL(k)))-1;
}

int n;
string a,b,c;
void input(){
    cin>>n>>a>>b>>c;
}
void src(){
    int ans=0;
    rep(i,n){
        ans+=eq(a[i],b[i],c[i]);
    }
    cout<<ans;
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
   // ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    cin >> a >> b;
    if(a < b){
        for(int i = 0; i < b; i++){
            cout << a;
        }
    }
  	else{
        for(int i = 0; i < a; i++){
            cout << b;
        }
    }
  	return 0;
}


Measured memory_bytes: 256
N = int(input())

mod = 10**9 + 7

A = [int(i)%mod for i in input().split()]

S = [0]*N

ans = 0
for i in range(N-1):
    if i == 0:
        S[i] = sum(A) - A[i]
    else:
        S[i] = (S[i-1] - A[i])
    ans +=  (A[i]*S[i])%mod

print(ans%mod)


Measured memory_bytes: 31756
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b=MI()
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a // gcd(a, b) * b
x=gcd(a,b)
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
y=prime_factorize(x)
print(len(set(y))+1)


   

Measured memory_bytes: 38512
num = int(input())
lines = input().split(" ")
int_lines = [int(i) for i in lines]
int_lines.sort()
count = 1
 
if num == 2:
  result = (int_lines[0] + int_lines[1]) / 2
  print(result)
else:
  itr = iter([j for j in int_lines])
  for j in itr:
    if count == 1:
        x = j
        count += 1
    elif count == 2:
        y = j
        count += 1
    else:
        x = (x + y) / 2
        y = j
        count += 1
  x = (x + y) / 2
    
  print(x)

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

typedef long long ll;

#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back

const long double PI = acos(-1);

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll GetDigit(ll num) {return log10(num)+1;}

bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2){
    if (num % i == 0){
      return false;
    }
  }
  return true;
}

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    for(ll i = 0; i < n; i++) cin >> s[i];
    sort(all(s));

    vector<pair<ll, string>> p(n);
    ll cnt = 0;
    for(ll i = 0; i < n; i++){
        if(i > 0 && s[i] == s[i-1]){
            cnt++;
        }else{
            cnt = 0;
        }
        p[i].first = cnt, p[i].second = s[i];
    }

    sort(p.begin(), p.end(), greater<pair<ll, string>>());

    vector<string> ans(n);
    for(ll i = 0; i < n; i++){
        ans[i] = p[i].second;
        if(p[i].first == p[i+1].first){
            continue;
        }else{
            break;
        }
    }

    sort(all(ans));
    for(ll i = 0; i < ans.size(); i++){
      if(ans[i] == "") continue;
      cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}




int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int t=a;
  while(1) {
    if(t%b==c) {
      cout << "YES" << endl;
      return 0;
    }
    t+=a;
    if(t>a*b) {
      cout << "NO" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3616
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    x:i16,}
    println!("{}", 8 - (x - 400) / 200);
}


Measured memory_bytes: 2164
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] a = new int[6] ;
		double x=0,y=0;
		while(scan.hasNext()){
			for(int i = 0; i < 6;i++){
				a[i] = scan.nextInt();
			}
			double d = a[0]*a[4] - a[1]*a[3];
			x = (double)(a[4]*a[2] - a[1]*a[5]);
			y = (double)(-a[3]*a[2] + a[0]*a[5]);
			if(x != 0){
				x /= d;
			}
			if(y != 0){
				y /= d;
			}
			System.out.printf("%.3f %.3f\n",x,y);

		}
		
	}
}

Measured memory_bytes: 11000
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

int cnt;
string S;
int another;

int main(){

	cin >> S;

	for (int i = 0; i < S.size(); i++){
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
			cnt++;
			if (another < cnt) another = cnt;
		}
		else{
			cnt = 0;
		}
	}

	cout << another << endl;
	

	return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;

const ll LMAX = (1LL<<61);
const int IMAX = (1<<29);
const int BIG = 104206970;
const int PRIME = 104206969;

const int N = 501;
const ll MOD = 1e9+7;

int n, c[N], s[N], f[N];

int main () {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// cout.precision(9); cout << fixed;
	cin >> n;
	for (int i = 0; i < n-1; i++)
		cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n; i++) {
		int t = 0;
		for (int j = i; j < n-1; j++) {
			if (t < s[j])
				t = s[j];
			else if (not (t%f[j] == 0))
				t += f[j]-t%f[j];
			t += c[j];
		}
		cout << t << endl;
	}

	return 0;
}


Measured memory_bytes: 256
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  X_L = [list(map(int, input().split())) for _ in range(N)]
  # print(N)

  X_L.sort(key=lambda x: x[0]+x[1])
  # print(X_L)

  def min_robots(X_L):
    # print(X_L)
    N = len(X_L)
    added = [0]
    for i in range(1, N):
      pre = added[-1]
      if X_L[pre][0] + X_L[pre][1] <= X_L[i][0] - X_L[i][1]:
        added.append(i)
    return len(added)

  print(min_robots(X_L))


if(__name__ == '__main__'):
  main()

Measured memory_bytes: 31804
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


N, A, B = map(int, input().split())
X = list(map(int, input().split()))


hirou = 0
for i in range(N-1):
    dist = X[i+1] - X[i]
    hirou +=  min(dist*A, B)


print(hirou)


Measured memory_bytes: 63472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    int cnt = 0, bcnt = 0;
    rep(i, S.size()) {
        if (S[i] == 'a') {
            if (cnt < A + B) {
                cout << "Yes";
                cnt++;
            } else
                cout << "No";
        } else if (S[i] == 'b') {
            if (cnt < A + B && bcnt < B) {
                cout << "Yes";
                cnt++, bcnt++;
            } else
                cout << "No";
        } else
            cout << "No";
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
int main()
{
    string s;
    string t;
    cin >> s;
    cin >> t;
    int n= s.length();
    int k = t.length();
    for(int i = 0;i<n;i++)
    {
        if(s[i] != t[i])
        {
            printf("No\n");
            return 0;
        }
    }
    if(k > n)
    {
        printf("Yes\n");
    }else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
template <class T1, class T2> void vadd(vector<T1> &v, T2 x);

#define int long long int

void solve(long long N, std::vector<long long> A, std::vector<long long> B) {
  auto f = [=](vector<lli> C) {
    sort(C.begin(), C.end());
    if (N % 2 == 1)
      return C[N / 2];
    else {
      return (C[N / 2] + C[N / 2 - 1]);
    }
  };
  auto left = f(A);
  auto right = f(B);
  cout << lli(right - left + 1) << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
  }
  solve(N, std::move(A), std::move(B));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


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

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

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

  int n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());

  string ans = "No";
  if(n%3 == 0) {
    // X,X, ... ,X | Y,Y, ... ,Y | X^Y,X^Y, ... ,X^Y
    if(a[0] == a[n/3-1] && a[n/3] == a[2*n/3-1] && a[2*n/3] == a[n-1] && (a[0]^a[n/3]) == a[2*n/3]) {
      ans = "Yes";
    }
    /*
    // 0,0, ... ,0 | x,x, ... ,x
    if(a[0] == 0 && a[0] == a[n/3-1] && a[n/3] == a[n-1]) {
      ans = "Yes";
    }
    */
  } else {
    // 0,0, ... ,0
    if(a[n-1] == 0) {
      ans = "Yes";
    }
  }

  cout << ans << '\n';
  return 0;
}


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

ll mod = 998244353;
int n, a[300000];
ll s[2000000], sdi[2000000], inv[2000000];

void sieve(int n) {
	inv[1]=1;
	for (int i=2; i<=n; i++)
		inv[i] = (mod - (mod/i)*inv[mod%i] % mod) % mod;
  for (int i = 1; i <= n; i++) {
    sdi[i] += inv[i];
    sdi[i] %= mod;
    for (int j = 2; i * j <= n; j++)
      sdi[i * j] = (sdi[i * j] - sdi[i] + mod) % mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  sieve(1000100);
  cin >> n;
  ll r = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (int x = 1; x * x <= a[i]; x++)
      if (a[i] % x == 0) {
        int y = x;
        r += ((a[i] * s[y]) % mod) * sdi[y];
        r %= mod;
        s[y] += a[i];
        s[y] %= mod;
        if (x * x != a[i]) {
          int y = a[i] / x;
          r += ((a[i] * s[y]) % mod) * sdi[y];
          r %= mod;
          s[y] += a[i];
          s[y] %= mod;
        }
      }
  }
  cout << r << "\n";
}


Measured memory_bytes: 31616
sx, sy, tx, ty = [int(x) for x in raw_input().strip().split(" ")]
a = tx - sx
b = ty - sy
c = a + 1
d = b + 1
print('U'*b+'R'*a+'D'*b+'L'*c+'U'*d+'R'*c+'DR'+'D'*d+'L'*c+'U')

Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N, M; cin >> N >> M;
	Graph G(N);
	rep(i, 0, M) {
		int a, b; cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i, 0, N) {
		cout << G[i].size() << "\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r <= x && x <= (W-r) && r <=y && y <= (H-r)){
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
S = input()
 
if S == "SUN":
    print("7")
elif S == "MON":
    print("6")
elif S == "TUE":
    print("5")
elif S == "WED":
    print("4")
elif S == "THU":
    print("3")
elif S == "FRI":
    print("2")
elif S == "SAT":
    print("1")

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>

using namespace std;

const int MAXN=2e5;
const int INF=1e9;
struct node
{
	int x,y,l,r;
	friend bool operator <(const node a,const node b)
	{
		return a.x>b.x;
	}
};
priority_queue <node> ans;
int f[4*MAXN][2];
int a[MAXN],id[MAXN];
void build(int root,int left,int right)
{
	if (left==right)
	{
		if (left&1)
		{
			f[root][1]=a[left],f[root][0]=INF;
		}
		else
		{
			f[root][0]=a[left],f[root][1]=INF;
		}
		return ;
	}
	int mid=(left+right)>>1;
	build(2*root,left,mid);
	build(2*root+1,mid+1,right);
	f[root][1]=min(f[2*root][1],f[2*root+1][1]);
	f[root][0]=min(f[2*root][0],f[2*root+1][0]);
}
int query(int root,int left,int right,int qleft,int qright,bool p)
{
	if (left>=qleft && right<=qright)
	{
		if (p)
		{
			return f[root][1];
		}
		else
		{
			return f[root][0];
		}
	}
	int mid=(left+right)>>1;
	if (qright<=mid)
	{
		return query(2*root,left,mid,qleft,qright,p);
	}
	else if (qleft>mid)
	{
		return query(2*root+1,mid+1,right,qleft,qright,p);
	}
	else
	{
		int ans1,ans2;
		ans1=query(2*root,left,mid,qleft,mid,p);
		ans2=query(2*root+1,mid+1,right,mid+1,qright,p);
		return min(ans1,ans2);
	}
}

int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1; i<=n; i++)
	{
		scanf("%d",&a[i]);
		id[a[i]]=i;
	}
	build(1,1,n);
	int x=query(1,1,n,1,n,1);
	int y=query(1,1,n,id[x]+1,n,0);
	node q;
	q.l=1,q.r=n,q.x=x,q.y=y;
	ans.push(q);
	for (int i=2; i<=n/2; i++)
	{
		q=ans.top();
		ans.pop();
		int nx=id[q.x];
		int ny=id[q.y];
		node now;
		if (q.l<nx)
		{
			bool p=q.l&1;
			int x=query(1,1,n,q.l,nx-1,p);
			int y=query(1,1,n,id[x]+1,nx-1,p^1);
			now.l=q.l;
			now.r=nx-1;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		if (nx+1<ny)
		{
			bool p=(nx+1)&1;
			int x=query(1,1,n,nx+1,ny-1,p);
			int y=query(1,1,n,id[x]+1,ny-1,p^1);
			now.l=nx+1;
			now.r=ny-1;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		if (ny<q.r)
		{
			bool p=(ny+1)&1;
			int x=query(1,1,n,ny+1,q.r,p);
			int y=query(1,1,n,id[x]+1,q.r,p^1);
			now.l=ny+1;
			now.r=q.r;
			now.x=x;
			now.y=y;
			ans.push(now);
		}
		printf("%d %d ",q.x,q.y);
	}
	while (!ans.empty())
	{
		node now=ans.top();
		ans.pop();
		printf("%d %d ",now.x,now.y);
	}
	return 0;
}


Measured memory_bytes: 8436
#include <iostream>
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;

typedef long long ll;
ll a, b, q, x, s[N], t[N];

ll f(ll p, ll q) {
	return min(p, q) * 2 + max(p, q);
}

int main()
{
	ll i, t1, t2, ls, rs, lt, rt;
	cin >> a >> b >> q;
	s[0] = -1e18; s[a + 1] = 1e18;
	for (i = 1; i <= a; i++) scanf("%lld", &s[i]);
	t[0] = -1e18; t[b + 1] = 1e18;
	for (i = 1; i <= b; i++) scanf("%lld", &t[i]);
	while (q--) {
		scanf("%lld", &x);
		t1 = lower_bound(s + 1, s + a + 1, x) - s;
		t2 = lower_bound(t + 1, t + b + 1, x) - t;
		ls = x - s[t1 - 1];
		rs = s[t1] - x;
		lt = x - t[t2 - 1];
		rt = t[t2] - x;
		printf("%lld\n", min(min(max(ls, lt), max(rs, rt)), min(f(ls, rt), f(rs, lt))));
	}
    return 0;
}

Measured memory_bytes: 2816
import math

A, B = map(int, input().split())

x = (A * 100 + 7) // 8
y = (B * 100 + 9) // 10
ans = max(x, y)

if (ans * 8) // 100 != A or (ans * 10) // 100 != B:
    ans = -1

print(ans)


Measured memory_bytes: 3060
<?php

while(1){
    fscanf(STDIN,"%d\n",$n);
    if($n==0)
        break;
    $line = trim(fgets(STDIN));
    $a = explode(" ",$line);
    $flag=0;//# of up foot
    $s=0;//start
    $sum=0;
    for($i=0;$i<sizeof($a);$i++){
        if($flag==0){
                $flag=1;
        }
        else if($flag==1){
            if($a[$i]=="lu"||$a[$i]=="ru"){
                $flag=2;
                if($s==0){
                    $s=1;
                    $sum++;
                }
            }
            else{
                $flag=0;
                if($s==1){
                    $s=0;
                    $sum++;
                }
            }
        }
        else if($flag==2){
            $flag=1;
        }
    }
    echo $sum."\n";
}



?>

Measured memory_bytes: 6652
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;


int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) * (m - 1) << endl;
}

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

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

int check(int _in){
    if(_in < 0) return 0;
    else return _in;
}

int main(){
    int a, b, ab, A, B;
    cin >> a >> b >> ab >> A >> B;
    
    int m = min(A,B);
    int case1 = A*a + B*b;
    
    int case2 = 2*A*ab + (check(B-A))*b;
    int case3 = 2*B*ab + (check(A-B))*a;
    cout << min(min(case1,case2), min(case2,case3)) <<endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int n;
vector<lli> a;

int main(void){
  cin>>n;

  lli t;
  for(int i=1;i<=n;i++){
    cin>>t;
    a.pb(t-i);
  }
  sort(a.begin(),a.end());

  //if(a.size()%2==1){
    t=a[n/2];
    lli res=0;
    for(int i=0;i<n;i++){
      res+=abs(a[i]-t);
    }
    cout<<res<<endl;

  /*
  else{
    t=a[n/2]+a[n/2 -1];
    t/=2;
    lli res1,res2,res3;
    res1=res2=res3=0;
    for(int i=0;i<n;i++){
      res1+=abs(a[i]-t);
      res2+=abs(a[i]-t-1);
      res3+=abs(a[i]-t+1);
    }
    cout<<min(res1,min(res2,res3))<<endl;
    }*/
  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int main(){
  ll A,B,C; cin>>A>>B>>C;
  if(A+B>=C){
    cout<<B+C<<endl;
  }else{
    cout<<B+A+B+1<<endl;
  }
  return 0;
}


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

int main() {
  string s;
  int i;
  for (i = 0; i < 3; i++) {
    cin >> s;
    s.at(0) += 'A' - 'a';
    cout << s.at(0);
  }
  cout << endl;
  return 0;
}


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


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

  ll ans =0;
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a, a+n);
  ll ub=a[n-1]+a[n-1]+100;
  ll lb=0;
  ll tar_p=0;
  while((ub-lb)>1){
    ll mid=(ub+lb)/2;
    //人の数
    ll sum=0;
    ll smid=0;
    rep(i,n){
      ll tar=mid-a[i];      
      sum += (a+n) - lower_bound(a,a+n,tar);
      smid += upper_bound(a,a+n,tar) - lower_bound(a,a+n,tar);
    }
    //    cout << "lb ub " << lb << " " << ub << endl;
    if(sum<m) ub=mid;
    else if(sum-smid > m) lb=mid;
    else{
      tar_p=mid;
      break;
    }
  }
  //  cout << "tar point " << tar_p << endl;
  ll sum[n+1];
  sum[0]=0;
  ll num=0;
  rep1(i,n) sum[i] = sum[i-1]+a[i-1];
  rep(i,n){
    ll tar=tar_p-a[i];
    ll ind = upper_bound(a,a+n,tar)-a;
    if(ind==n) continue;
    else {
      num+=n-ind;
      ans += a[i] * (n-ind) + sum[n]- sum[ind];
    }
    //    cout << ans << endl;
  }
  ans += (m-num)*tar_p;
  cout << ans << endl;


  
  return 0;
    

}


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

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

    if(S<1e9){
        for (int i = 0; i < N; i++){
            if (i < K)
                cout << S;
            else
                cout << S + 1;
            if (i < N - 1)
                cout << ' ';
        }
    }else{
        for (int i = 0; i < N; i++)
        {
            if (i < K)
                cout << S;
            else
                cout << S - 1;
            if (i < N - 1)
                cout << ' ';
        }
    }
}

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

int main(){
  int N, A, sum;
  int ans = 0;
  cin >> N;//N(代入)
  cin >> A;//A(代入)
  while(A % 2 == 0){
    A /= 2;
    ans++;//ans++
  }
  for(int i = 1; i < N; i++){//i = 1
    sum = 0;
    cin >> A;//A(代入2)(ループ)
    while(A % 2 == 0){
      A /= 2;
      sum++;//sum++
    }
    if(sum <= ans){//sum <= ans
      ans = sum;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string t;
	cin >> t;
	for (int i = 0; i < (int)t.size(); ++i) {
		if (t.at(i) == '?') {
			t.at(i) = 'D';
		}
	}
	cout << t << endl;
}

Measured memory_bytes: 3752
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;

int main() {
    int N, K;
    while (~scanf("%d %d", &N, &K)) {
          int tg = 0;
          for (int i = 1; i <= N; i++) {
              int tmp;
              scanf("%d", &tmp);
              if (tmp == 1) tg = i;
          }
          int ans = 2;
          int fl = 1, fr = K;
          while (fl < tg && fr < tg) {
                ans++;
                fl = fr;
                fr += (K - 1);
          }
          int sl = N - (K - 1), sr = N;
          while (sl > tg && sr > tg) {
                ans++;
                sr = sl;
                sl -= (K - 1);
          }
          if (fr - sl >= (K - 1)) ans--;
          // if (fl == sl && fr == sr) ans--;
          printf("%d\n", ans);
    }
    return 0;
}


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


#define mems(arr,VAL)           memset(arr,VAL,sizeof(arr))
#define pii                     pair<int,int>
#define mk                      make_pair
#define pb                      push_back
#define ff                      first
#define ss                      second
#define PI                      acos(-1.0)

#define pf                      printf
#define sc                      scanf
//#define Mod                     1000000007
#define hiii                    1e9//1000000000
#define looo                   -1e9//-1000000000
#define NMAX                    1003

ll H , N , A[NMAX] , B[NMAX] ;
ll dp[1003][10004] ;

ll fun(ll pos , ll curr)
{
    if(curr <= 0)return 0 ;
    if(curr > 0 && pos > N)return 999999999999 ;

    if(dp[pos][curr] != -1)return dp[pos][curr] ;

    ll p1 = 0 , p2 = 0 , p3 = 0 ;

    p1+=B[pos] + fun(pos , curr - A[pos]) ;
    p2+=B[pos] + fun(pos+1 , curr - A[pos]) ;
    p3+= fun(pos+1 , curr) ;

    return dp[pos][curr] = min(p1 , min(p2 , p3)) ;
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    mems(dp , -1 ) ;

    cin >> H >> N ;
    for(ll i = 1 ; i<=N ; i++)
        cin >> A[i] >> B[i] ;

    cout << fun(1 , H) << endl ;

//cout << double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;
return 0;
}




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

using namespace std;

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

  std::vector<int> v;
  string s;cin>>s;
  for(int i=0;i<(int)s.length();i++){
      if(s[i]=='0') v.push_back(0);
      else if(s[i]=='1') v.push_back(1);
      else if(v.size()>0) v.pop_back();
  }
  for(int i=0;i<(int)v.size();i++) cout<<v[i];
  cout<<endl;
}


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

#define int long long
#define pb  push_back
#define eb  emplace_back
#define scan(a,n)  for(int i = 0; i < n;i++)cin >> a[i];
#define print(a,n)  for(int i = 0;i < n;i++)cout <<a[i] <<' ';cout<<endl;
#define w(x)  int x; cin>>x; while(x--)
#define endl  '\n'
#define vi  vector<int>
#define rng(x) x.begin(),x.end()


#define db(...) 		__f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
// Tushar Goyal : Chalie Shuru karte hai

void solve()
{
	int n, m, k, tempa, tempb, cnt = 0, ans = 0;
	cin >> n >> m >> k;

	vi a(n);
	scan(a, n);

	vi b(m);
	scan(b, m);

	vi prefa(n, 0), prefb(m, 0);

	prefa[0] = a[0];
	prefb[0] = b[0];

	for (int i = 1 ; i < n ; i++)
	{
		prefa[i] = prefa[i - 1] + a[i];
	}

	for (int i = 1 ; i < m ; i++)
	{
		prefb[i] = prefb[i - 1] + b[i];
	}

	tempa = lower_bound(rng(prefa), k) - prefa.begin();
	if (tempa != n)
	{
		if (prefa[tempa] == k)ans = max(ans, tempa + 1);
		else ans = max(ans, tempa);
	}


	// db(tempa);

	tempb = lower_bound(rng(prefb), k) - prefb.begin();
	if (tempb != m)
	{
		if (prefb[tempb] == k)ans = max(ans, tempb + 1);
		else ans = max(ans, tempb);
	}

	// db(tempb);


	for (int i = 0 ; i < n ; i++)
	{
		int val = k - prefa[i];
		if (val <= 0)continue;
		int idx = lower_bound(rng(prefb), val) - prefb.begin();
		// db(i, prefa[i], val, idx);
		if (idx != m)
		{
			if (prefb[idx] == val)ans = max(ans, i + 1 + idx + 1);
			else ans = max(ans, i + 1 + idx);
		}
	}

	cout << ans << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	solve();
	return 0;
}

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

int StoI(string a){
  int res=0;
  for(int i=a.size()-1;i>=0;i--)res=res*10+a[i];
  return res;
}

int main(){
  string a,b;
  int k;
  cin>>a>>b>>k;
  reverse(a.begin(),a.end()),reverse(b.begin(),b.end());
  int n=a.size();
  for(int i=b.size();i<n;i++) b+='0';
  
  int ans=-1;
  for(int bit=0;bit<(1<<n);bit++){
    string num;
    int borrow=0;
    if(__builtin_popcount(bit)<=k)
      for(int i=0;i<n;i++){
	if(a[i]-borrow>=b[i]) num+=(a[i]-borrow-b[i]),borrow=0;
	else num+=(a[i]-borrow+10-b[i]),borrow=1;
	if((bit>>i)%2)borrow=0;
      }
    ans=max(ans,StoI(num));
  }
  cout <<ans<<endl;
  return 0; 
}

Measured memory_bytes: 1216