akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

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; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    map<char, ll> mp;
    ll N;
    string S;
    cin >> N >> S;

    ll ans = 0;
    rep(i,N){
        char c = S[i];
        ll d = 1;
        rep(j,26){
            if ('a' + j == c) continue;
            (d *= (mp['a' + j] + 1)) %= MOD;
        }
        mp[c]++;
        (ans += d) %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <numeric>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

/*
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1
 < > > > < < > < < < < < > > > <
 x o o o x x o x x x x x o o o x
*/
int main() {
  init();

  string S;
  cin >> S;
  ll n = S.size() + 1;
  vll a(n);

  REP(i, 1, n) {
    if (S[i - 1] == '<') {
      a[i] = max(a[i], a[i - 1] + 1);
    }
  }

  for (ll i = n - 2; i >= 0; i--) {
    if (S[i] == '>') {
      a[i] = max(a[i], a[i + 1] + 1);
    }
  }

  cout << accumulate(a.begin(), a.end(), ll(0)) << endl;

  return 0;
}



Measured memory_bytes: 4764
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

/*bool operator<(const pair<int, int> &a, const pair<int, int> &b)
{
    if (a.first == b.first)
    {
        return a.second < b.second;
    }
    return a.first < b.first;
}*/

ll dp[1010][1010];
int N, M;
vector<string> v;
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;

    for (int i = 0; i < H; ++i)
    {
        string s;
        cin >> s;
        v.push_back(s);
    }
    dp[0][0] = 1;

    for (int i = 0; i < H; ++i)
    {
        for (int j = 0; j < W; ++j)
        {
            if (i == 0 && j == 0)
                continue;
            else if (i == 0)
            {
                if (v[i][j] != '#')
                    dp[i][j] = dp[i][j - 1];
                else
                    dp[i][j] = 0;
            }
            else if (j == 0)
            {
                if (v[i][j] != '#')
                    dp[i][j] = dp[i - 1][j];
                else
                    dp[i][j] = 0;
            }
            else
            {
                if (v[i][j] != '#')
                    dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[H - 1][W - 1] % MOD << endl;
    return 0;
}

Measured memory_bytes: 9216
/**
 * author: nayan_000
**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define vll vector<ll>
#define pll pair<ll,ll>
#define vp vector<pll>
#define pqll priority_queue<ll>
#define test int tcase; cin>>tcase; for(int tc = 1; tc <= tcase; tc++)
#define inp(a,n,f) ll a[n+f];for(ll hh=f;hh<n+f;hh++)cin>>a[hh];
#define prdec(k) cout<<fixed<<setprecision(k);
#define ub upper_bound
#define lb lower_bound
#define mapp map<ll,ll>
#define mem(x) memset(x,0,sizeof(x))
#define all(v) v.begin(),v.end()
#define qll queue<ll>
#define sll set<ll>
#define inf LLONG_MAX


int main ()
{
	fastio;
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

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


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

	map<char, int> mp;

	for (auto c : S)
	{
		if (mp.count(c))
		{
			mp[c]++;
		}
		else
		{
			mp[c] = 1;
		}
	}

	if (mp.size() != 2)
	{
		cout << "No" << endl;
		return 0;
	}

	for (auto & m : mp)
	{
		if (m.second != 2)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
// copy from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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")
    };
}

fn main() {
    input! {
        s: String,
    }
    let f = s[0..2].parse::<usize>().unwrap();
    let b = s[2..4].parse::<usize>().unwrap();
    if can_mm(f) && can_mm(b) {
        println!("AMBIGUOUS");
    } else if can_mm(f) {
        println!("MMYY");
    } else if can_mm(b) {
        println!("YYMM");
    } else {
        println!("NA");
    }
}

fn can_mm(n: usize) -> bool {
    n > 0 && n < 13
}


Measured memory_bytes: 4352
#include <iostream>


using namespace std;


int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s, sr;
    cin >> s;
    int n = s.length();
    sr = s;
    reverse(sr.begin(), sr.end());
    bool ok = true;
    if(s != sr)ok = false;
    if(s.substr(0, (n-1)/2) != sr.substr((n+1)/2))ok = false;
     if(sr.substr(0, (n-1)/2) != s.substr((n+1)/2))ok = false;
 
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
   
 
    return 0;
}

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

int main(){
  char a;cin >> a;
  if ((int)'A' <= (int)a && (int)a <= (int)'Z')
  {
    cout << 'A' << endl;
  }
  else
  {
    cout << 'a' << endl;
  }

}

Measured memory_bytes: 3632
from collections import Counter
import numpy as np


def main():
    n = int(input())
    a = np.array([int(i) for i in input().split()])
    b = np.array([int(i) for i in input().split()])
    ca = Counter(a)
    cb = Counter(b)
    for k in cb.keys():
        if cb[k] > n - ca[k]:
            print("No")
            return
    shift = max(ca[k] for k in cb.keys())
    while any(a == b):
        b = np.roll(b, shift)
    print("Yes")
    print(*b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74212
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

ll A,B;
ll f(ll x){
  return (A*x/B)-A*(x/B);
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  ll N;
  cin >> A >> B >> N;

  ll x=min(B-1,N);
  cout << f(x) << endl;

  return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define fs first
#define sc second
#define pb push_back
#define sz size() 
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<string> vs;

const static int INF = 1e8;
const static D EPS = 1e-8;

int main(){
  int n;
  cin >> n;
  vi l(2*n);
  rep(i,2*n) cin >> l[i];
  sort(all(l));

  int ans = 0;
  rep(i,n) ans += l[2*i];
  cout << ans << endl;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    int h[n];
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    sort(h,h+n);
    int ans=1000000000;
    for(int i=0;i<n-k+1;i++){
        if(h[i+k-1]-h[i]<ans)ans=h[i+k-1]-h[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    
    String[] s = scanner.next().split("");
    ArrayList<String> result = new ArrayList<>();
    
    for(int i = 0; i < s.length; i++) {
      if(s[i].equals("0") || s[i].equals("1")) {
        result.add(s[i]);
      } else if(result.size() >= 1) {
        result.remove(result.size() - 1);
      }
    }
    
    for(String r: result) {
      System.out.print(r);
    }
  }
}

Measured memory_bytes: 35588
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

string a,b,c;
int main(){
  cin>>a>>b>>c;
  if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N = int(sys.stdin.readline())
X = list(map(int, sys.stdin.readline().split()))
X2 = list(sorted(X))
x1 = X2[N // 2 - 1]
x2 = X2[N // 2]


for x in X:
    if x <= x1:
        print(x2)
    else:
        print(x1)


Measured memory_bytes: 36076
#include <iostream>
#include <vector>

using namespace std;

#define MOD 1000000007

long long llpow(long long x, long long n) {
	if (!n) return 1;
	if (n & 1) return llpow(x * x % MOD, n >> 1) * x % MOD;
	return llpow(x * x % MOD, n >> 1);
}

int main() {
	int n, k; cin >> n >> k;
	vector<long long> cnt(k + 1);
	for (int i = 1; i <= k; ++i) cnt[i] = llpow(k / i, n);
	for (int i = k / 2; i > 0; --i)
		for (int j = i * 2; j <= k; j += i)
			cnt[i] = (cnt[i] - cnt[j] + MOD) % MOD;
	long long ans = 0;
	for (int i = 1; i <= k; ++i) (ans += cnt[i] * i % MOD) %= MOD;
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> arr(N);
  for(int i=0;i<N;i++)  cin >> arr[i];
  int cnt=0;
  for(int i=0;i<N;i++){
    if(arr[i]%2==1 && i %2 ==0) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int H, W;

  cin >> H >> W;
  vector<vector<char>> f(H);
  vector<vector<int>> f2(H);

  for(int i = 0; i < H; i++){
    f[i].resize(W);
    f2[i].resize(W, 0);
  }
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      cin >> f[h][w];
    }
  }



  // count
  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      // Bomb
      if(f[h][w] == '#'){
        f2[h][w] = -1;
      }else{
        int c = 0;
        // counting

        // 一つ上
        if(0 < h){
          if(f[h-1][w] == '#'){
            c++;
          }
        }

        // 一つ左上
        if(0 < h && 0 < w){
          if(f[h-1][w-1] == '#'){
            c++;
          }
        }

        // 一つ左
        if(0 < w){
          if(f[h][w-1] == '#'){
            c++;
          }
        }

        // 一つ左下
        if(h < H-1 && 0 < w){
          if(f[h+1][w-1] == '#'){
            c++;
          }
        }

        // 一つ下
        if(h < H-1){
          if(f[h+1][w] == '#'){
            c++;
          }
        }

        // 一つ右下
        if(h < H-1 && w < W-1){
          if(f[h+1][w+1] == '#'){
            c++;
          }
        }

        // 一つ右
        if(w < W-1){
          if(f[h][w+1] == '#'){
            c++;
          }
        }

        // 一つ右上
        if(0 < h && w < W-1){
          if(f[h-1][w+1] == '#'){
            c++;
          }
        }

        f2[h][w] = c;
      }

    }
  }

  for(int h = 0; h < H; h++){
    for(int w = 0; w < W; w++){
      if(f2[h][w] == -1){
        cout << '#';
      }else{
        cout << f2[h][w];
      }

    }
    cout << endl;
  }


  return 0;
}


Measured memory_bytes: 256
n=int(input())
t=[int(i) for i in input().split()]
max=sum(t)
m=int(input())
sum_list=[]
for i in range(m):
    index,value=[int(j) for j in input().split()]
    index-=1
    temp=t[index]
    t[index]=value
    sum_list.append(sum(t))
    t[index]=temp
for i in sum_list:
    print(i)

Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace lineAralgebra
{
	class Program
	{
		public static void Main(String[] args)
		{
			var n = int.Parse(Console.ReadLine());

			var dp = new int[n + 1];

			for (var i = 0; i <= n; i++)
			{
				dp[i] = int.MaxValue;
			}
			dp[0] = 0;

			for (var i = 1; i <= n; i++)
			{
				for (var power9 = 1; power9 <= i; power9 *= 9)
				{
					dp[i] = Math.Min(dp[i], dp[i - power9] + 1);
				}

				for (var power6 = 1; power6 <= i; power6 *= 6)
				{
					dp[i] = Math.Min(dp[i], dp[i - power6] + 1);
				}
			}

			System.Console.WriteLine(dp[n]);
		}
	}
}



Measured memory_bytes: 13108
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll pre[n - 1];
    pre[n - 2] = a[n - 1];
    for (int i = n - 2, k = n - 3; i >= 0 && k >= 0; i--, k--)
    {
        pre[k] = (pre[k + 1]%mod + a[i]%mod)%mod;
    }
    ll prod = 0;
    for (int i = 0, j = 0; i < n - 1 && j < n; i++, j++)
    {
        prod += a[j] * pre[i];
        if(prod<0) prod+=mod;
        prod %= mod;
    }
    cout << prod;
    return 0;
}

Measured memory_bytes: 5996
from collections import Counter
import sys
n = int(input())
a = list(map(int, input().split()))
count_a = list(Counter(a).items())
count_a = sorted(count_a, reverse=True)
result = 1
c = 0
for x, y in count_a:
    if y>=2:
        result *= x
        c += 1
        if c == 1 and y>=4:
            result *= x
            c += 1
        if c == 2:
            print(result)
            sys.exit()
print(0)

Measured memory_bytes: 21412
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  vector<pair<int,int> > red;
  vector<pair<int,int> > blue;
  for(int i = 0; i < n; i++){
    int a,b;
    cin>>a>>b;
    red.push_back(make_pair(a,b));
  }
  
  for(int i = 0; i < n; i++){
    int c,d;
    cin>>c>>d;
    blue.push_back(make_pair(c,d));
  }
  
  sort(red.begin(),red.end());
  sort(blue.begin(),blue.end());
  int ans = 0;
  
  vector<bool> used(n,false);
  
  for(int i = 0; i < n; i++){
    pair<int,int> bb = blue[i];
    int mx = -1;
    int index = -1;
    
    for(int j = 0; j < n; j++){
      
      if(red[j].first<bb.first&&red[j].second<bb.second&&red[j].second>mx&&used[j]==false){
        index = j;
        mx = red[j].second;
      }
    }
    
    if(index!=-1){
        ans++;
        used[index]=true;
      }
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  long long s = 0;
  for(int b = K + 1; b <= N; b++){
    s += (N / b) * (b - K) + max(N - (N / b) * b - K + 1, 0);
    if(K == 0) s -= 1; // a > 0
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
count = 0
list_prob = []
while count < n:
    list_prob.append(int(input()))
    count += 1
maxv = list_prob[1] - list_prob[0]
minv = list_prob[0]
for j in range(1,n):
    maxv = max(maxv, list_prob[j] - minv)
    minv = min(minv, list_prob[j])
print(maxv)



Measured memory_bytes: 13588
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    int N;

    scanf("%d", &N);

    char S[N + 1];

    scanf("%s", &S);

    S[N] = '\0';

    int m = 0;
    int x = 0;
    int i;

    for (i = 0; i < N; i++) {
        if (S[i] == 'I') x++;
        else x--;

        m = max(m, x);
    }

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

    return 0;
}


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


int main()
{
	int n,ans,w[106]={};
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {scanf("%d",w+i);w[i]+=w[i-1];}
	ans=w[n];
	for(int i=1;i<=n;++i) ans=min(ans,abs(w[n]-2*w[i]));
	cout<<ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int N = sc.nextInt();
		int M = sc.nextInt();
		int C = sc.nextInt();
		int B[] = new int[M];
		int A[][] = new int[N][M];
		int cal[] = new int[N];
		int count = 0;

		for (int k = 0; k < M; k++) {
			B[k] = sc.nextInt();
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < M; j++) {
				cal[i] += A[i][j] * B[j] ;
			}
			cal[i] += C;
			
			if(cal[i] > 0) {
				count++;
			}
		}

		System.out.print(count);
		
	}
}


Measured memory_bytes: 22356
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;
//NのM乗を求める(繰り返し二乗法)
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}
long long nCr(long long n, long long r) {
    long long A = 1, B = 1;
    //Aが分子Bが1/r!
    for (long long i = n - r + 1; i <= n; i++) {
        A = A * i % MOD;
    }
    for (long long i = 1; i <= r; i++) {
        B = B * i % MOD;
    }
    B = mod_pow(B, MOD - 2);
    B %= MOD;
    //Bは割るのではなく掛ける
    return (A * B) % MOD;
}

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

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

//long long A,B;
bool ok(long long key,long long index){
    if(index > key) return true;
    else if(index <= key) return false;
}
long long binary_search(long long key,long long size){
    //left,right,midはいずれもindex
    long long left = -1,right = size;
    while(right - left > 1){
        long long mid = left + (right-left)/2;
        long long hantei = ok(key,mid);
        if(hantei) right = mid;
        else left = mid;
    }
    if(left == -1)return 0;
    return left;
}

int main() {
    string S;cin >> S;
    int ans = 0;
    for(int i = 0;i<S.size();i++){
        if(S.at(i) == '1') ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int bit[200005];int n;

int sum(int i)
{
	int s=0;
	while(i){
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}
void add(int i)
{
	while(i<=n){
		bit[i]++;
		i+=i&-i;
	}
}
void sub(int i)
{
	while(i<=n){
		bit[i]--;
		i+=i&-i;
	}
}

char s[200005];
int c['z'+1];

void calc(int ch){
	while(c[ch]<n&&s[c[ch]]!=ch)c[ch]++;
}

int main(void){
	int k,i,j,f;
	char b[15],*p;
	
	fgets(p=s,sizeof(s),stdin);
	while(*p>' ')p++;n=p-s;
	fgets(b,15,stdin),k=atoi(b);
	
	for(i=1;i<=n;i++)add(i);
	for(i='a';i<='z';i++)calc(i);
	for(i=0;i<n;i++)for(j='a';j<='z';j++){
		if(c[j]==n)continue;
		if((f=sum(c[j]))<=k){
			k-=f;
			sub(c[j]+1);
			putchar(j);
			c[j]++;
			calc(j);
			break;
		}
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 4056
import java.util.*;

public class Main {

	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
    int B = sc.nextInt();
      int max = A*B;
      if(A-B>max) max=A-B;
      if(A+B>max) max=A+B;
     System.out.println(max);
	}
}

Measured memory_bytes: 21460
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
inline int read(){
	int f=1,ans=0;char c;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
	return ans*f;
}
int a,b;
signed main(){
	a=read(),b=read();
	if(a==0||b==0){printf("Zero\n");return 0;}
	if(a<0&&b>0){printf("Zero\n");return 0;}
	if(a>0){printf("Positive\n");return 0;}
	if(a<0){int ans=(-a)-(-b);if(ans%2==1)printf("Positive\n");else printf("Negative\n");return 0;}
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W, M;
	cin >> H >> W >> M;
	map<int, int> HM, WM;
	map<pair<int, int>, int> MM;
	for(int i=0; i<M; i++){
		int h, w;
		cin >> h >> w;
		if(HM.count(h) == 0){
			HM[h] = 1;
		}
		else{
			HM[h]++;
		}
		if(WM.count(w) == 0){
			WM[w] = 1;
		}
		else{
			WM[w]++;
		}
		MM[make_pair(h, w)] = 1;
	}
	
	int hmax = 0;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		int k = itr->first;
		int v = itr->second;
		if(hmax < v){
			hmax = v;
		}
	}
	map<int, int> M1;
	for(auto itr = HM.begin(); itr != HM.end(); itr++){
		int k = itr->first;
		int v = itr->second;
		if(v == hmax){
			M1[k] = v;
		}
	}

	int wmax = 0;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		int k = itr->first;
		int v = itr->second;
		if(wmax < v){
			wmax = v;
		}
	}
	map<int, int> M2;
	for(auto itr = WM.begin(); itr != WM.end(); itr++){
		int k = itr->first;
		int v = itr->second;
		if(v == wmax){
			M2[k] = v;
		}
	}
	LL prod = (LL)M1.size() * (LL) M2.size() ;
	if(prod > M){
		printf("%d\n", hmax + wmax);
		return 0;
	}

	int exist = 0;
	for(auto itr1 = M1.begin(); itr1 != M1.end(); itr1++){
		for(auto itr2 = M2.begin(); itr2 != M2.end(); itr2++){
			int a = itr1->first;
			int b = itr2->first;
			if(MM.count(make_pair(a, b)) == 0){
				exist = 1;
				break;
			}
		}
		if(exist == 1){
			break;
		}
	}
	if(exist == 1){
		printf("%d\n", hmax + wmax );
	}
	else{
		printf("%d\n", hmax + wmax - 1);
	}
	return 0;
}


Measured memory_bytes: 78664
#include <iostream>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
typedef int64_t lint;
using namespace std;

int main(){
    lint n, k;
    cin >> n >> k;
    vector<lint> a(n);
    rep0(i, n){
        cin >> a[i];
    }
    boost::multiprecision::cpp_int kk = k * (k - 1) / 2;
    boost::multiprecision::cpp_int ans = 0;
    for (int i = 0; i < n; ++i) {
        lint left = 0;
        lint right = 0;
        for (int j = 0; j < n; ++j) {
            if(a[i] > a[j]){
                if(i > j)left ++ ;
                if(i < j)right ++ ;
            }
        }
        //AC
        // for(int j = 0 ; j < left ; j++)
        // {
        //     ans += kk;
        // }
        //WA
        ans += kk * left;

        rep0(j,right)
        {
            ans += kk;
            ans += k;
        }
        ans %= 1000000007;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int x = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		for (int i = x - k + 1; i <= x + k - 1; i++) {
			ans.append(i);
			ans.append(" ");
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		long[][][] dp = new long[100+2][10][1000+2]; dp[0][0][0] = 1;
		for(int i=0;i<=100;i++) for(int j=0;j<10;j++) for(int k=0;k<=1000;k++) {
			dp[i+1][j][k] += dp[i][j][k];
			if(j==9) continue;
			if(i+k<=1000) dp[i+1][j+1][k+i] += dp[i][j][k];
		}
		for(;;) {
			int n = sc.nextInt(), s = sc.nextInt();
			if((n|s) == 0) break;
			System.out.println(dp[101][n][s]);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 29032
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
char str[N];

int main()
{
    cin>>str;
    int len = strlen(str);
    for(int i=0;i<len-8;i++)
        printf("%c",str[i]);
    cout<<endl;
    return 0;
}


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

int main() {
	ll n;
	cin >> n;
	vector<ll> h(n);
	for (ll i = 0; i < n; ++i)cin >> h[i];
	vector<ll> dp(n);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	for (ll i = 2; i < n; ++i) {
		dp[i] = min(dp[i - 2] + abs(h[i - 2] - h[i]), dp[i - 1] + abs(h[i - 1] - h[i]));
	}
	cout << dp.back() << endl;
}


Measured memory_bytes: 1792
A,B=(map(int,input().split()))
import fractions
c=fractions.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
d=prime_factorize(c)
e=set(d)
print(len(e)+1)


Measured memory_bytes: 5048
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int n = scanner.nextInt();
        int[] a = new int[n];
        int asum = 0;

        for( int i = 0 ; i < n ; i++){
            a[i] = scanner.nextInt();
            asum += a[i];
        }

        String result = h > asum ? "No" : "Yes";
        System.out.println(result);
    }
}

Measured memory_bytes: 49000
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int d, g;
	cin >> d >> g;
	int p[10], c[10];
	rep(i, d) cin >> p[i] >> c[i];

	int ans = 1e9;
	for (int mask = 0; mask < (1 << d); mask++) {
		int s = 0, num = 0, rest_max = -1;
		for (int i = 0; i < d; i++) {
			if ((mask >> i) & 1) {
				s += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else {
				rest_max = i;
			}
		}
		if (s < g) {
			int s1 = 100 * (rest_max + 1);
			int need = (g - s + s1 - 1) / s1;
			if (need >= p[rest_max]) continue;
			num += need;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// AtCoder Grand Contest 012
// C - Tautonym Puzzle

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_C = 100;

ll N;
vector<int> ans;

int main() {

    cin >> N;

    for (int i = 0; ((N + 1) >> i) > 1; i++) {
        if (((N + 1) >> i) & 1) {
            ans.push_back(MAX_C - i);
        }
        ans.push_back(i + 1);
    }

    cout << ans.size() + MAX_C << endl;
    for (int i = 0; i < (int)ans.size(); i++) {
        cout << ans[i] << ' ';
    }
    for (int i = 1; i <= MAX_C; i++) {
        cout << i << (i == MAX_C ? '\n' : ' ');
    }

    return 0;

}


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

using namespace std;
int main()
{
   int n,m,i,j;
   cin>>n>>m;
   int count[50]={0};
   int ans=0;
   for(i=0;i<n;i++)
   {
       int k;
       cin>>k;
      for( j=0;j<k;j++)
       {
           int temp;
           cin>>temp;
           count[temp]++;
       }
   }
   for(i=1;i<m+1;i++)
       {
           
           if(count[i]==n)
           {
               ans++;
           }
       }
       cout<<ans;
       
   return 0;
}

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

const int MAX_N = 501, MAX_M = 2e5+10;
int N, M, Q;
int L[MAX_M], R[MAX_M];
int p[MAX_M], q[MAX_M];
ll ans[MAX_N][MAX_N];

void solve()
{
	for(int i=0;i<M;++i){
		for(int le=1;le<=L[i];++le)ans[le][R[i]]++;
	}
	for(int i=1;i<=N;++i)for(int j=0;j<=N;++j){
		if(i>j)ans[i][j]=0;
		else ans[i][j] += ans[i][j-1];
	}
	for(int i=0;i<Q;++i){
		cout << ans[p[i]][q[i]] << '\n';
	}
}

int main()
{
	cin >> N >> M >> Q;
	for(int i=0;i<M;++i) cin >> L[i] >> R[i];
	for(int i=0;i<Q;++i) cin >> p[i] >> q[i];
	solve();
	return 0;
}

Measured memory_bytes: 7884
#include <bits/stdc++.h>
using namespace std;
int n,m,a[105],tot,cnt;
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){cin>>a[i];tot+=a[i];}
	double fgh=tot;
	fgh/=(m*4);
	for(int i=0;i<n;i++)if(a[i]>=fgh)cnt++;
	if(cnt>=m)cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n)cin>>a[i];
  auto dp=vec(n,n,0LL);
  rep(i,0,n)dp[0][i]=a[i];
  rep(i,1,n)rep(j,0,n-i){
    dp[i][j]=max(a[j]-dp[i-1][j+1],a[j+i]-dp[i-1][j]);
    //cout<<i spa j spa dp[i][j]<<endl;
  }
  cout<<dp[n-1][0]<<endl;
  return 0;
}

Measured memory_bytes: 72832
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int n;

string itos(int x) {
	int xQ = x / 10;
	int xR = x % 10;
	string strcur;
	if (xQ == 0) {
		strcur = "";
		strcur += (char)('0' + x);
	}
	else {
		strcur = itos(xQ);
		strcur += (char)('0' + xR);
	}
	return strcur;
}

void rec(int k,int m,string &str) {//前回の数、残り数、それまでのデータ
	string strcpy(str);
	if (m != n) {
		string nullS = "";
		string addstr = itos(k);
		strcpy += addstr;
		if (m == 0) {
			cout << strcpy << endl;
			return;
		}
		else strcpy += " ";
	}
	repd(i, k, 0) {
		if (i > m)continue;
		rec(i, m - i, strcpy);
	}
	return;
}

int main() {
	while (1) {
		rd(n);
		if (n == 0) break;
		string nullS = "";
		rec(100, n, nullS);
	}
	return 0;
}


Measured memory_bytes: 3176
#include <iostream>

void swap(int& a, int& b)
{
	int tmp = a;
	a = b;
	b = tmp;
}

int main()
{
	int N;
	std::cin >> N;
	
	int *A = new int[N];
	for (int i=0; i<N; i++) std::cin >> A[i];
	
	int swap_count = 0;
	for (int i=0; i<N; i++) {
		int min_i = i;
		for (int j=i; j<N; j++) {
			if (A[j] < A[min_i]) min_i = j;
		}
		if (i < min_i) {
			swap(A[i], A[min_i]); swap_count++;
		}
	}
	
	std::cout << A[0];
	for (int i=1; i<N; i++) std::cout << " " << A[i];
	std::cout << std::endl;
	std::cout << swap_count << std::endl;
	
	delete[] A;
	
	return 0;
}




Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------


//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    rep(i,N) A[i]-=(i+1);
    SORT(A);
    ll b=A[N/2];
    ll ans=0;
    rep(i,N) ans+=abs(A[i]-b);
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main()
{
    string A, B, C;
    cin >> A >> B;
    C = B;
    for (int i = 0; i < A.size(); i++)
    {
        if (A == B)
        {
            cout << "Yes";
            break;
        }

        if (i == A.size() - 1)
            cout << "No";
        

        C.at(0) = B.at(B.size() - 1);
        for (int j = 1; j < A.size(); j++)
        {
            C.at(j) = B.at(j - 1);
        }

        B = C;
    }

}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const ll MOD = 1e9+7;


int S[300];
ll DP[300][100100];
int main(){
    int N, X;
    cin >> N >> X;
    REP(i,N){
        int s;
        cin >> s;
        S[i] = s;
    }

    sort(S, S+N, greater<int>());

    DP[0][X] = 1;
    for(int i = 0; i < N; i++){
        int s = S[i];
        for(int j = 0; j <= 100000; j++){
            if(DP[i][j] == 0) continue;
            //DP[i+1][j%s] = max(DP[i+1][j%s], DP[i][j]);
            //DP[i+1][j] = max(DP[i+1][j], (N-1-i)*DP[i][j]);
            DP[i+1][j%s] += DP[i][j];
            DP[i+1][j%s] %= MOD;
            DP[i+1][j] += (N-1-i)*DP[i][j];
            DP[i+1][j] %= MOD;
        }
    }

    ll ans = 0;
    REP(i,100001){
        int d = DP[N][i];
        ans += (ll)d*i;
        ans %= MOD;
    }

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


Measured memory_bytes: 155904
import kotlin.math.sqrt

fun main() {
    var n = nextLong()
    val primeCounts = mutableMapOf<Long, Int>()
    val sieve = sizedArray(sqrt(n.toDouble()).toInt() + 1, true)
    sieve[0] = false
    sieve[1] = false
    sieve.indices.forEach {
        if (!sieve[it]) return@forEach
        // check gcd
        while (n % it == 0L) {
            n /= it
            primeCounts[it.toLong()] = primeCounts.getOrDefault(it.toLong(), 0) + 1
        }
        // update sieve
        var index = it + it
        while (index <= sieve.lastIndex) {
            sieve[index] = false
            index += it
        }
    }
    if (n >= sieve.size) {
        primeCounts[n] = 1
    }
    var res = 0
    primeCounts.forEach { _, value ->
        var count = value
        var num = 1
        while (num <= count) {
            count -= num
            num++
            res++
        }
    }
    println(res)
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

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

int main(){
    ll N;cin>>N;ll A;cin>>A;
    if(A!=0){
        cout<<0<<endl;
        return 0;
    }
    ll ans=3,B=1,R=0,G=0;
    for(ll i=1;i<N;i++){
        cin>>A;
        if(A==B and A==R and A==G){
            ans*=3;
            ans%=MOD;
            B++;
        }
        else if(A==B and A==R){
            ans*=2;
            ans%=MOD;
            B++;
        }
        else if(A==B and A==G){
            ans*=2;
            ans%=MOD;
            B++;
        }
        else if(A==R and A==G){
            ans*=2;
            ans%=MOD;
            R++;
        }
        else if(A==B)B++;
        else if(A==R)R++;
        else if(A==G)G++;
        else{
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import statistics

n=int(input())
list1 = list(map(int, input().split()))
cnt = 0
ans=[]
av = statistics.median(list1)
for i in range(n):
    ans.append(abs(list1[i]-av))

fir=min(ans) 
sec=sorted(ans)[1]

print(int(fir+sec))

Measured memory_bytes: 16036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define ld long double
#define mod 1000000007
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    ll n;
    cin>>n;
    ll ans=0,a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            ans+=(a[i]*a[j]);
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (ll i = 0; i < (n); ++i)
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;}

int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int ans =0;
    int i = 0;
    while(i<n-1){
        if(a[i]!=a[i+1]&&i==n-2){ans+=2;i++;}
        else if(a[i]!=a[i+1]){ans++;i++;}
        else{
            int l=1;
            while(i<n-1&&a[i]==a[i+1]){
                l++;
                i++;
            }
           // cout<<l<<endl;
            i++;
            if(l%2!=0)ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3952
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a=n/100;
	int b=(n-100*a)/10;
	int c=n-a*100-b*10;
	if(a==7||b==7||c==7)
	{
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
}

Measured memory_bytes: 1660
import Data.Bits
import Data.List
import Data.Foldable(foldlM)
import Data.Maybe(fromJust)
import Control.Monad
import Data.Array as A ((!),accumArray)
import Data.Graph
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM
import Control.Monad.ST
import Data.Maybe (fromMaybe)
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  as <- getLine
  bs <- getLine
  print $ length $ filter id $ zipWith (==) as bs


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int h[N];
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];

    }
    long long INF = 1e+10;
    vector<long long> cost(N+10,INF);
    cost[0] = 0;
    for (int i = 0; i < N; i++)
    {
        cost[i+1] = min(cost[i+1],cost[i]+abs(h[i+1]-h[i]));
        cost[i+2] = min(cost[i+2],cost[i]+abs(h[i+2]-h[i]));
    }
    cout << cost[N-1] << endl;

}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int x=1;
  
  for(int i=0 ; i<N ; i++){
    if(x*2 <= x+K){
      x *= 2;
    }
    else {
      x += K;
    }
  }
  cout << x << endl;
  
} 

Measured memory_bytes: 256