akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (size_t i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  size_t N;
  cin >> N;
  vector<int> L(N);
  rep(i, N) { cin >> L[i]; }
  sort(L.begin(), L.end());

  ll Ans = 0;
  for (size_t a = 0; a < N - 1; a++) {
    for (size_t b = a + 1; b < N; b++) {
      int c_min0 = L[a] - L[b];
      int c_min1 = L[b] - L[a];
      int c_min = max(c_min0, c_min1);
      int c_max = L[a] + L[b];
      // cout << "c_min=" << c_min << " c_max=" << c_max << endl;
      auto it_min = upper_bound(L.begin(), L.end(), c_min);
      if (it_min == L.end()) continue;
      size_t pos_min = distance(L.begin(), it_min);

      auto it_max = lower_bound(L.begin(), L.end(), c_max);
      size_t pos_max = distance(L.begin(), it_max);
      // if (it_max == L.end()) pos_max = N-1;

      // cout << "a=" << a << " b=" << b;
      // cout << " pos_min=" << pos_min << " pos_max=" << pos_max << endl;
      int num = pos_max - pos_min;
      if (pos_min <= a && a <= pos_max) num--;
      if (pos_min <= b && b <= pos_max) num--;
      Ans += (num < 0) ? 0 : num;
      // cout << "Ans=" << Ans << " num=" << num << endl;
    }
  }
  Ans /= 3;
  cout << Ans << endl;
  return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    double l;
    cin >> l;

    double ans = l/3 * l/3 * l/3;
    printf("%lf", ans);
}

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

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

using ll = long long;
constexpr ll INF = 1000000000;
constexpr ll mod = 1e9 + 7;

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

using namespace std;

//fixed << setprecision(10)

/////////////////////////////////////////////////////////////////////////////////////////////////////////

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

	int n = s.length();

	int cnt = 0;
	for(int i=1;i<n;i++){
		if (s[i] == '9')cnt++;
	}

	char a = s[0];
	int c = a - '0';

	if (cnt == n - 1) {	
		cout << c + (n - 1) * 9 << endl;
		return 0;
	}
	else {
		cout << (c - 1) + (n - 1) * 9 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

    int a, b, c;
    cin >> a >> b >> c;

    cout << min({a + b, b + c, c + a}) << endl;

    return 0;
}

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

int main() {
  int H, W;
  char x;
  cin >> H >> W;
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cout << '#';
    for (int j = 0; j < W; j++) {
      cin >> x;
      cout << x;
    }
    cout << '#';
    cout << endl;
  }
  for (int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    double ans;
    cin>>n;
    ans = 2.0*2.0*acos(0.0)*(n*1.0);
    cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3788
#include<stdio.h>

int main(void) {
	int H, W;
	while (1) {
		scanf("%d %d", &H, &W);
		if (H == 0 && W == 0)break;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				if ((i + j) % 2 == 0) {
					printf("#");
				}
				else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
const int maxn = 2e5 + 10;
int n;
typedef pair<ll, ll> pll;
ll A[maxn], B[maxn];
map<pll, int> M, M2;
const ll mod = 1000000007;
ll bin[maxn];
ll ans = 1, cnt;
int main()
{
	scanf("%d", &n);
	bin[0] = 1;
	for(int i = 1; i < maxn; ++i) bin[i] = bin[i - 1] * 2 % mod;
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld%lld", &A[i], &B[i]);
		if(A[i] == 0 && B[i] == 0)
		{
			--i; --n; ++cnt; continue;
		}
		if(B[i] == 0) A[i] = 1;
		else
		{
			if(B[i] < 0) A[i] = -A[i], B[i] = -B[i];
			ll d = __gcd(abs(A[i]), abs(B[i]));
			A[i] /= d, B[i] /= d;
		}
		M[mp(A[i], B[i])]++;
	}
	M2 = M;
	for(auto v : M)
	{
		auto val = v.first;
		auto rev = mp(-val.second, val.first);
		if(val.first > 0 && M.count(rev))
		{
			ans = ans * (bin[v.second] + bin[M[rev]] - 1) % mod;
			M2.erase(val);
			M2.erase(rev);
		}
	}\
	for(auto v : M2)
		ans = ans * bin[v.second] % mod;
	cout << (ans + cnt + mod - 1) % mod << endl;
	return 0;
}
	

Measured memory_bytes: 33232
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	
	long gcd(long a,long b) {
		return a==0?b:gcd(b%a,a);
	}

	void run() {
		Scanner sc=new Scanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int K=sc.nextInt();
		long ans=0;
		for (int i=1;i<=K;++i) {
			for (int j=1;j<=K;++j) {
				for (int k=1;k<=K;++k) {
					ans+=gcd(i,gcd(j,k));
				}
			}
		}
		pw.println(ans);
		pw.close();
	} 
	
	void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
	
    public static void main(String[] args) {
    	new Main().run();
    }
}


Measured memory_bytes: 35968
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    a.append(list(list(map(int,input().split())) for i in range(m)))

ans=0
for i in range(2**n):
    r=1
    ib=list(format(i,"b").zfill(n))
    for j in range(n):
        if ib[j]=="1":
            for k in range(len(a[j])):
                if int(ib[a[j][k][0]-1])!=a[j][k][1]:
                    r=0
    if r==1:
        ans=max(ans,ib.count("1"))
print(ans)


Measured memory_bytes: 44764
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 1e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;


vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
//const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int sub(int a, int b)
{
	a += MOD ; b += MOD ;
	a-=b;
	if(a < 0) a += MOD ;
	return a;
}

int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}


void solve(){
	int n , k ;
	cin >> n >> k ;
	vi a(n) ;
	init(N) ;
	for(auto& x : a) cin >> x ;
	sort(all(a)) ;
	int plus = 0 ;
	for(int i = k-1 ; i < n ; i++){
		plus = add(plus+MOD, mult(a[i]+MOD , choose(i,k-1))) ;
	}
	int minus = 0 ;
	for(int i = 0 ; i < (n-k+1) ; i++){
		minus = add(minus+MOD, mult(a[i]+MOD, choose(n-(i+1), k-1))) ;
	}
	int ans = sub(plus , minus) ;
	cout << ans << endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 4224
from sys import stdin, exit

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

num = []
count = []
for k in a:
    if k not in num:
        num.append(k)
        count.append(1)
    else:
        count[num.index(k)] += 1
    if len(num) > 3:
        print('No')
        exit()
if len(num) == 1 and num[0] == 0:
    print('Yes')
    exit()
if len(num) == 2 and num[0] ^ num[1] == num[1] and N % 3 == 0 and count[1] == 2 * count[0]:
    print('Yes')
    exit()
if len(num) == 2 and num[0] ^ num[1] == num[0] and N % 3 == 0 and count[0] == 2 * count[1]:
    print('Yes')
    exit()
if len(num) <= 2:
    print('No')
    exit()
if num[0] ^ num[1] ^ num[2] == 0 and N % 3 == 0 and count[0] == count[1] == count[2] == int(N / 3):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 60784
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,ans,tmp,hoge,fuga,piyo,sum;
ll A[200100],B[200100],C[200100],D[200100];
string st,str;
char ch;
int main(){
  cin>>a>>b;
  cout<<a*b;
  return 0;
}

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

int main(void){
    int N; cin >> N;
    int C[N-1], S[N-1], F[N-1];
    int time=0;
    for(int i=0; i<N-1; i++){
        cin >> C[i] >> S[i] >> F[i];
    }

    for(int i=0; i<N; i++){
        time=0;
        for(int j=i; j<N-1; j++){
            if(time%F[j]!=0) time+=F[j]-(time%F[j]);
            while(time<S[j]) time+=F[j];

            time+=C[j];
        }
        cout << time << endl;
    }


}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 long long a,b,c,s,t,x,y,z;
 long long A,B,C,S,T,X,Y,Z;

 long long cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

//long long mam(long long a, long long b){}

int main(){

	cin>>a;

	cnt=a-1;

	for(ll i=2;i<a;i++){
		cnt+=a/i;
		if(a%i==0) cnt--;
	}
	
	cout<<cnt;
	return 0;

}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <limits.h>
#include <stack>

using namespace std;

#define rip(i, n, s) for (int i = (s);i < ( int )( n ); i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef pair<int, ll> P;

int main(){
    int n,m;
    ll l;
    cin >> n >> m >>l;
    vector<vector<ll>> da(n,vector<ll>(n,INT_MAX/2));
    int a,b;
    ll c;
    rip(i,m,0){
        cin >> a >> b >> c;
        a--;b--;
        da[a][b]=c;
        da[b][a]=c;
    }
    vector<vector<ll>> dp(n,vector<ll>(n));
    rip(i,n,0){
        rip(j,n,0){
            dp[i][j]=da[i][j];
            if(i==j){
            dp[i][j]=0;
            }
        }
    }
    rip(i,n,0){
        rip(j,n,0){
            rip(k,n,0){
                dp[j][k]=min(dp[j][k],dp[j][i]+dp[i][k]);
            }
        }
    }
    vector<vector<int>> dpp(n,vector<int>(n,INT_MAX/2));
    rip(i,n,0){
        rip(j,n,0){
            if(i==j){
                dp[i][j]=0;
                continue;
            }
            if(dp[i][j]<=l){
                dpp[i][j]=1;
            }
        }
    }
    rip(i,n,0){
        rip(j,n,0){
            rip(k,n,0){
                dpp[j][k]=min(dpp[j][k],dpp[j][i]+dpp[i][k]);
            }
        }
    }
    int q;
    cin >> q;
    vector<int> ans(q);
    rip(i,q,0){
        int s,t;
        cin >> s >> t;
        ans[i]=dpp[s-1][t-1];
        if(ans[i]==INT_MAX/2){
            ans[i]=0;
        }
    }
    rip(i,q,0){
        printf("%d\n",ans[i]-1);
    }
}

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

#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define MOD 1000000007

const int MAX_M = 100000;


int main(){
  ll n, m, x;    //n枚,y円
  //string s, t;
  cin >> n >> m >> x;

  vector<ll> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  //queue<ll> q;
  //map<string,ll> m;

  rep(i,0,n){
    cin >> c.at(i);
    rep(j,0,m){
      cin >> a.at(i).at(j);
    }
  }

  ll ans = INT_MAX;

  for(int bit = 0; bit<(1<<n); ++bit){
    vector<ll> sum(m);
    ll y = 0;
    rep(i,0,n){
      if(bit & (1<<i)){
        y += c.at(i);
        rep(j,0,m){
          sum.at(j) += a.at(i).at(j);
        }
      }
    }
    bool ok = true;
    rep(i,0,m){
      if(sum.at(i) < x){
        ok = false;
      }
    }
    if(ok){
      ans = min(ans,y);
    }
  }

  //cout << fixed << setprecision(10);
  //cout << ans << endl;
  cout << ((ans == INT_MAX)? -1 : ans) << endl;

}


Measured memory_bytes: 3640
n, m = [int(x) for x in input().split()]
a_list = [int(x) for x in input().split()]

a_sum = sum(a_list)
a_list.sort()
a_list.reverse()
for i in range(m):
    a = a_list[i]
    if a < a_sum / (4 * m):
        print('No')
        exit()
else:
    print('Yes')


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

using namespace std;

#define ll long long
#define pb push_back
#define bug cout << "bug" << endl
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const ll N = 1e3 + 5, M = 1e4 + 5, INF = 1e9;

int main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(k > 0){
		if(b <= a){
			b *= 2;
			k--;
			continue;
		}
		if(c <= b){
			c *= 2;
			k--;
			continue;
		}
		break;
	}
	if(a < b && b < c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
n = int(input())
max = 100000
#dp[n] = min(1+dp[n-1], 1+dp[n-6], 1+dp[n-6**2],....1+dp[n-9],1+dp[n-9**2]...)
dp = [float("INF")] * (max+1)
dp[0] = 0
for i in range(1,max+1):
  power = 1
  while power <= i:
    dp[i] = min(dp[i], dp[i-power]+1)
    power *= 6
  power = 9
  while power <= i:
    dp[i] = min(dp[i], dp[i-power]+1)
    power *= 9
print(dp[n])

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

char a[100010];

int main() {
    scanf("%s", a + 1);
    int n = strlen(a + 1), l = -1, r = -1;
    for (int i = 1; i <= n; i++) {
        if (i + 1 <= n && a[i] == a[i + 1]) {
            l = i, r = i + 1; break;
        } else if (i + 2 <= n && a[i] == a[i + 2]) {
            l = i, r = i + 2; break;
        }
    }
    printf("%d %d\n", l, r);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> s(n+2,0);
    for(int i = 1; i < n+2; i++){
        s[i] = s[i-1] + i;
    }

    ll ans = 0;
    ll mod = 1000000007;
    for(int i = k; i <= n+1; i++){
        ll x = s[n+1] - s[n+1-i] - s[i] + 1;
        ans += x;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4752
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#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 = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
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;}
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...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll k;cin>>k;
  queue<string>que;
  rep(i,0,9)que.push(string(1,i+'1'));
  k--;
  while(k){
    auto p=que.front();
    //cout<<p<<endl;
    que.pop();
    auto s=p.back()-'0';
    rep(i,-1,2){
      if(s+i<0||s+i>=10)continue;
      que.push(p+char(s+i+'0'));
    }
    k--;
  }
  cout<<que.front()<<endl;
  return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> v(105104);
  for(int i = 0;i < a;i++){
    int m;
   cin >> m;
    v.at(m) += 1;
  }
  int e = 1;
  for(int i = 1;i < 104105;i++){
    int f = 0;
    f = v.at(i-1) +v.at(i) + v.at(i+1);
    e = max(e,f);}
  cout << e << endl;
    
}

Measured memory_bytes: 640
implicit none

integer(8) :: n,m
integer(8), allocatable :: a(:), dp(:)
integer(8) :: i

read *,n,m
allocate(a(m))
do i = 1, m
   read *, a(i)
enddo

allocate(dp(0:n))

dp(0:n) = 1
do i = 1, m
   dp(a(i)) = 0
enddo

do i = n-2, 0, -1
   if (dp(i) == 0) then
      cycle
   endif
   dp(i) = mod(dp(i+1) + dp(i+2), 1000000007)
enddo

write(6,'(i0)') dp(0)

stop
end

Measured memory_bytes: 1792
n,a,b=map(int,input().split())
x=list(map(int,input().split()))
ans=0
if a>=b:
  print(b*(n-1))
else:
  d=b//a
  
  for i in range(n-1):
    if x[i+1]-x[i]>d:
      ans+=b
    else:
      ans+=(x[i+1]-x[i])*a
  print(ans)


Measured memory_bytes: 14224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<ctime>
#include<bitset>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 1e9+7;

inline ll max(ll a,ll b) { return a>b?a:b; }
inline ll min(ll a,ll b) { return a<b?a:b; }
inline ll abs1(ll a) { return a>0?a:-a; }

//const int maxn=


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	
	vector<ll>v1,v2;
	v1.resize(n),v2.resize(n);
	
	for(ll i=0,x,y;i<n;i++)
	{
		cin>>x>>y;
		v1[i]=x+y;
		v2[i]=x-y;
	}
	
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	
	cout<<max(v1[n-1]-v1[0],v2[n-1]-v2[0])<<endl;
	
	return 0;
}

Measured memory_bytes: 6344
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		for(int i=0; i<n; i++){
			double x1=sc.nextDouble();
			double y1=sc.nextDouble();
			double x2=sc.nextDouble();
			double y2=sc.nextDouble();
			double x3=sc.nextDouble();
			double y3=sc.nextDouble();
			double x4=sc.nextDouble();
			double y4=sc.nextDouble();

			P v1=new P(x2-x1, y2-y1);
			P v2=new P(x4-x3, y4-y3);

			println(abs(v1.det(v2))<EPS?"YES"
					:"NO");
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

class P{
	double x, y;

	P(){
		this(0, 0);
	}

	P(double x, double y){
		this.x=x;
		this.y=y;
	}

	P add(P p){
		return new P(x+p.x, y+p.y);
	}

	P sub(P p){
		return new P(x-p.x, y-p.y);
	}

	P mul(double m){
		return new P(x*m, y*m);
	}

	P div(double d){
		return new P(x/d, y/d);
	}

	double abs(){
		return Math.sqrt(abs2());
	}

	double abs2(){
		return x*x+y*y;
	}

	double dot(P p){
		return x*p.x+y*p.y;
	}

	double det(P p){
		return x*p.y-p.x*y;
	}

	P rot90(){
		return new P(-y, x);
	}
}

Measured memory_bytes: 12000
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
    
def main():
    N,K=map(int,input().split())
    print(len(Base_10_to_n(N,K)))
main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,l[87];
  c(a);
  l[0]=2;
  l[1]=1;
  rep(i,2,87){
    l[i]=l[i-1]+l[i-2];
  }
  co(l[a]);
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(x) cout << x << endl
#define PI acos(-1)
const int INF = 1e9;
const LL INF64 = 1e18;

const int NMAX = 1e5 + 5;

vector<LL> precomp;
bool arr[1005];
int main() {
	memset(arr, 0, sizeof arr);
	LL cnt = 0;
	precomp.pb(1);
	for(int i = 2; i <= sqrt(1000); i++){
		LL tmp = i * i;
		while(tmp <= 1000){
			cnt++;
			if(arr[tmp] == 0) {
				precomp.pb(tmp);
				arr[tmp] = 1;
			}
			//debug(tmp);
			tmp *= i;
		}
	}
	sort(precomp.begin(), precomp.end());
	LL x;
	cin >> x;
	LL lb = upper_bound(precomp.begin(), precomp.end(), x) - precomp.begin();
	cout << precomp[lb - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}

func Perm(arr []int) [][]int {
	ret := make([][]int, 0)
	perm(arr, &ret, 0)
	return ret
}

func perm(arr []int, ret *[][]int, i int) {
	if i > len(arr) {
		*ret = append(*ret, append([]int{}, arr...))
		return
	}
	perm(arr, ret, i+1)
	for j := i + 1; j < len(arr); j++ {
		arr[i], arr[j] = arr[j], arr[i]
		perm(arr, ret, i+1)
		arr[i], arr[j] = arr[j], arr[i]
	}
}

func index(a []int, t [][]int) int {
	i := 0
	for _, arr := range t {
		for j, e := range a {
			if e == arr[j] {
				continue
			} else {
				if e > arr[j] {
					i++
				}
				break
			}
		}
	}
	return i
}

func main() {
	n := scanInt()
	arr := make([]int, n)
	for i := range arr {
		arr[i] = i + 1
	}

	p := make([]int, n)
	for i := range p {
		p[i] = scanInt()
	}

	q := make([]int, n)
	for i := range q {
		q[i] = scanInt()
	}

	permutations := Perm(arr)
	indexP := index(p, permutations) + 1
	indexQ := index(q, permutations) + 1

	fmt.Println(abs(indexP - indexQ))
}


Measured memory_bytes: 8064
def my_match s,t
  
  sl = s.length
  sl.times do |i|
    return false if s[i] != ?? and s[i] != t[i]
  end
  return true
end

def solve sp,t
  
  s = sp
  
  sl = s.length
  tl = t.length
  
  no = "UNRESTORABLE"
  
  i = sl - 1
  j = tl - 1
  
  return no if sl < tl
  
  if sp.include?(t)
    
    k = sp.index(t)
    s[k, tl] = t
    return s.gsub(??, ?a)
  end
  
  k = sl - tl
  k.downto(0) do |kk|
    if my_match(sp[kk,tl],t)
      s[kk,tl] = t
      return s.gsub(??, ?a)
    end
  end
  
  return no
end

sp = gets.chomp
t = gets.chomp

puts solve sp,t

Measured memory_bytes: 1788
from itertools import product
x, y, z, k = map(int, input().split())
A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())
AB = [sum(ab) for ab in product(A, B)]
AB.sort(reverse=True)
AB = AB[:k]
ABC = [sum(abc) for abc in product(AB, C)]
ABC.sort(reverse=True)
for i in range(k):
    print(ABC[i])


Measured memory_bytes: 144240
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    ll ans = 0;
    for (int R = 0; R <= n; R+=r) {
        for (int G = 0; G <= n; G+=g) {
            if (R+G > n) break;
            ll B = n-R-G;
            if (B%b == 0) ans ++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M, K;
bool vsd[1010][1010];
char S[1010][1010];

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

void solve() {
	cin >> N >> M >> K;
	int sx, sy;
	rep(i, 0, N) {
		rep(j, 0, M) {
			cin >> S[i][j];
			if(S[i][j] == 'S') {
				sx = i; sy = j;
			}
		}
	}
	queue<pi> que;
	vsd[sx][sy] = true;
	que.push(pi(sx, sy));
	rep(q, 0, K) {
		int qs = sz(que);
		while(qs--) {
			pi p = que.front(); que.pop();
			int x = p.fst, y = p.sec;
			rep(i, 0, 4) {
				int nx = x + dx[i], ny = y + dy[i];
				if(0 <= nx && nx < N && 0 <= ny && ny < M) {
					if(S[nx][ny] != '#' && !vsd[nx][ny]) {
						vsd[nx][ny] = true;
						que.push(pi(nx, ny));
					}
				}
			}
		}
	}
	int ans = inf;
	rep(i, 0, N) {
		rep(j, 0, M) {
			if(vsd[i][j]) {
				// debug(i, j);
				MIN(ans, 1 + (min(min(i, j), min(N - 1 - i, M - 1 - j)) + K - 1) / K);
			}
		}
	}
	cout << ans << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define MOD 1000000007
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b==1)return a%MOD;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
int n,m;
map<int,int>mp;
signed main(){
	int ans=1;
	cin>>n>>m;
	for(int i=2;i*i<=m;i++){
		while(m%i==0){
			m/=i;
			mp[i]++;
		}
		if(m==1)break;
	}
	if(m!=1)mp[m]++;
	for(auto p:mp){
		ans*=comb(n+p.second-1,p.second);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <set>
#include <tuple>
#include <stdbool.h>
#include <bitset>
#include <string>

using namespace std;

int main(void) {
    string str;
    cin >> str;
    
    int c0 = count(str.cbegin(), str.cend(), '0');
    int c1 = count(str.cbegin(), str.cend(), '1');
    cout << (2 * (c0 < c1 ? c0 : c1)) << endl;
    return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    n = II()
    A = LI()
    for i in range(n):
        A[i] = A[i] - i - 1
    import statistics
    a = round(statistics.median(A))
    ans = 0
    for i in range(n):
        ans += abs(A[i] - a)
    print(ans)
#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 27284
#include <iostream>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a + b >= 10)
    cout << "error\n";
  else
    cout << a + b << "\n";
  return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define Edge pair< i_i, int>
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; scanf("%lld", &x);
#define int2(x, y) int x, y; scanf("%lld %lld", &x, &y);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// assign

signed main()
{
    int2(h, w);

    int ans = INF;
    if (!(h % 3) || !(w % 3)) {
        cout << 0 << endl;
        return 0;
    } else if (h == 1 || w == 1) {
        cout << 1 << endl;
    }
    ans = (w / 3 + 1) * h - (w / 3) * h;
    ans = min(ans, (h / 3 + 1) * w - (h / 3) * w);
    Rep(i, h) {
        int tmp1 = i * w, tmp2 = (h - i) * (w / 2), 
            tmp3 = (h - i) * (w / 2 + (w % 2));
        ans = min(ans, max(tmp1, max(tmp2, tmp3)) - 
                min(tmp1, min(tmp2, tmp3)));
    }
    Rep(i, w) {
        int tmp1 = i * h, tmp2 = (w - i) * (h / 2), 
            tmp3 = (w - i) * (h / 2 + (h % 2));
        ans = min(ans, max(tmp1, max(tmp2, tmp3)) - 
                min(tmp1, min(tmp2, tmp3)));
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
#define SUB(X,Y) ((X) = ((X) + MOD - (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

i64 H, W, T;

i64 gcd(i64 a, i64 b)
{
	while (b) {
		i64 tmp = a % b;
		a = b;
		b = tmp;
	}
	return a;
}
i64 modpow(i64 a, i64 p)
{
	if (p == 0) return 1;
	i64 x = modpow(a, p / 2);
	x = x * x % MOD;
	if (p % 2 == 1) x = x * a % MOD;
	return x;
}
int main()
{
	scanf("%lld%lld%lld", &H, &W, &T);

	i64 mult = 1;
	{
		i64 g = gcd(H, T);
		mult *= g;
		H /= g;
	}
	{
		i64 g = gcd(W, T);
		mult *= g;
		W /= g;
	}

	i64 ret = 0;

	// . only
	ADD(ret, 1);

	// >, v only
	ADD(ret, modpow(2, H)); SUB(ret, 1);
	ADD(ret, modpow(2, W)); SUB(ret, 1);

	// diagonal
	i64 g = gcd(H, W);
	ADD(ret, modpow(2, g)); SUB(ret, 2);

	ret = modpow(ret, mult);
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
    int a,b;
    int c;
    char op;
    cin >> a >> op >> b;
    while(op!='?'){
        int c;
        if(op=='+'){
            c = a + b;
        }
        if(op=='-'){
            c = a - b;
        }
        if(op=='*'){
            c = a * b;
        }
        if(op=='/'){
            c = a / b;
        }
        cout << c << endl;
        cin >> a >> op >> b;
    }
    return 0;
}



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

typedef long long ll;
typedef pair<ll, ll> P;
#define MOD 1000000007
#define INF (1 << 30)
#define REP(i, m, n) for(int i = (int)m; i < (int)n; ++i)
#define rep(i, n) REP(i, 0, n)


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

    ll n; cin >> n;
    vector<P> vec;
    for(ll i = 1; i*i <= n; i++) {
        if(n%i == 0) vec.push_back(P(i, n/i));
    }
    ll ans = 1e13;
    for(auto e : vec) {
        ll tmp = 0;
        if(e.first == 0 && e.second == 0) continue;
        tmp += e.first-1;
        tmp += e.second-1;
        if(ans > tmp) ans = tmp;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

class Main{
    public Main(){
        Scanner SC = new Scanner(System.in);
        int N = Integer.parseInt(SC.next());
        int[] A = new int[N];
        for(int i=0;i<N-1;i++){
            A[Integer.parseInt(SC.next())-1] += 1;
        }
        for(int i=0;i<N;i++){
            System.out.println(A[i]);
        }
    }

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


Measured memory_bytes: 59768
<?php

class Answer
{
    private $lists;

    public function __construct()
    {
        $list = fgets(STDIN);
        if (isset($list)) {
            $this->lists = explode(' ', trim($list));
        }
    }

    public function calc($num1, $num2, $operator)
    {
        switch ($operator) {
            case '+':
                return $num1 + $num2;
                break;
            case '-':
                return $num1 - $num2;
                break;
            case '*':
                return $num1 * $num2;
                break;
        }
    }

    public function getAnswer(){
        $arr = array();
        while ($tmp = array_shift($this->lists)) {
            if (ctype_digit($tmp)) {
                $arr[] = intval($tmp);
            } else {
                    $num = array_pop($arr);
                    $arr[] = $this->calc(array_pop($arr), $num, $tmp);
            }
        }
        echo $arr[0] . PHP_EOL;
    }
}
$answer = new Answer;
$answer->getAnswer();


Measured memory_bytes: 9376
/*
    Print a rectangle ITP1_5_A
*/

#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0)
            break;

        for (i=0; i < H; i++) {
            for (j=0; j < W; j++)
                putchar('#');
            putchar('\n');
        }
        putchar('\n');
    }
    return (0);
}


Measured memory_bytes: 2040
number = gets.split(' ')
k = number[0].to_i
s = number[1].to_i
count = 0

for x in 0..k do
  for y in 0..k do
    z = s-x-y
    if z <= k and z >= 0 then
      count = count+1
    end
  end
end
puts count

Measured memory_bytes: 14128
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    int N;
    SCD(N);
    ll ans = 0;
    ll ncount = 0;
    REP(i,N){
        ll x;
        cin >> x;
        if (x == 0){
            ans = ans + (ncount / 2);
            ncount = 0;
            continue;
        }
        ncount += x;
    }
    ans = ans + (ncount / 2);
    cout << ans << "\n";
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**7)

def dfs(node,prenode,black):
  if black and B[node]!= -1: return B[node]
  elif not black and W[node]!= -1: return W[node]
  res = 1
  for vi in G[node]:
    if vi == prenode: continue
    tmp = 0
    tmp += dfs(vi,node,False)
    if not black:
      tmp += dfs(vi,node,True)
    res = res * tmp % mod
  if black:
    B[node] = res
  else:
    W[node] = res
  return res

n = int(input())
B = [-1]*n
W = [-1]*n
G=[[] for i in range(n)]
for i in range(n-1):
  x,y = map(int,input().split())
  x-=1;y-=1
  G[x].append(y)
  G[y].append(x)
dfs(0,-1,True)
dfs(0,-1,False)
print((B[0]+W[0])%mod)
# print(B)
# print(W)

Measured memory_bytes: 101740
n = int(input())
list = [[]]
for i in range(n-1):
  list.append([])
for i in range(n):
    a, b = (map(int,input().split()))
    list[i].append(a)
    list[i].append(b)
sum_length = 0
for i in range(n):
    for j in range(n):
      sum_length = sum_length + ((list[i][0]-list[j][0])**2 + (list[i][1]-list[j][1])**2)**0.5
average = sum_length / n
print(average)

Measured memory_bytes: 3064
const val VACANT = "Vacant"

fun main(args: Array<String>) {


    val n = readLine()!!.toInt()

    var l = 0
    var lType = query(0)
    if (lType == VACANT) return

    var u = n
    var uType = lType
    while (true) {
        val m = (l + u) / 2
        var mType = query(m)
        if (mType == VACANT) return
        if (lType == mType) {
            if ((m - l) % 2 == 1) {
                u = m
                uType = mType
            } else {
                l = m
                lType = mType
            }
        } else {
            if ((m - l) % 2 == 0) {
                u = m
                uType = mType
            } else {
                l = m
                lType = mType
            }
        }
    }
}

fun query(position: Int): String {
    println(position)
    return readLine()!!
}


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 1e5+69;
int cnt[MAXN];
int n;
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        cnt[x]++;
    }
    int ans = 0;
    for(int i=1;i<=100000;i++)ans+=i*cnt[i];
    int q;
    cin>>q;
    while(q--){
        int x,y;
        cin>>x>>y;
        ans-=x*cnt[x];
        ans+=y*cnt[x];
        cnt[y]+=cnt[x];
        cnt[x]=0;
        cout<<ans<<'\n';
    }
}


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

int main() {
  ll k; 
  cin >> k;
  
  if(k<=9){
    cout << k << endl;
    return 0;
  }
  
  queue<ll>a;
  for(int i=1; i<=9; i++){
    a.push(i);
  }
  
  ll x=0;
  while(k>0){
    x=a.front();
    a.pop();
    
    for(int i=-1; i<=1; i++){
      if(x%10<=0 && i==-1) continue;
      if(x%10>=9 && i==1) continue;
      
      ll nx = x*10+x%10+i;
      a.push(nx);
      
    }
    
    k--;
    
  }
  
  cout << x << endl;
  
}


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

const int nax = 55;
int d[nax];

int main() {
	int n, sum = 0; 
	scanf("%d", &n);

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

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			sum += d[i] * d[j];
		}
	}

	cout << sum << "\n";
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

//const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ijt n, l;
int r[100010];
ijt a[100010];
int cut[100010];
int main(void) {
	cin >> n >> l;
	rep(i, n) {
		cin >> a[i];
		if (a[i] >= l)r[i] = 4;
	}
	for (int i = 0; i < n-1; i++)
	{
		if (a[i] + a[i + 1] >= l) {
			cout << "Possible" << endl;
			for (int j = 0; j < i; j++)
			{
				cout << j + 1 << endl;
			}
			for (int j = n - 2; j > i; j--) {
				cout << j + 1 << endl;
			}
			cout << i + 1 << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

class Point {
public:
	double x, y;
	Point(double x = 0, double y = 0) :x(x), y(y) { };
	Point operator + (Point& p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point& p) { return Point(x - p.x, y - p.y); }
	Point operator * (double k) { return Point(x * k, y * k); }
	Point operator / (double k) { return Point(x / k, y / k); }
	double Abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }
};
typedef Point Vector;
struct Segment {
	Point p1, p2;
};

double dot(Vector& a, Vector& b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector& a, Vector& b) {
	return a.x * b.y - a.y * b.x;
}

static const int COUNTER_CLOCKWISE = -1;
static const int CLOCKWISE = 1;
static const int ON_SEGMENT = 0;
static const int ONLINE_BACK = -2;
static const int ONLINE_FRONT = 2;

Segment s1, s2;
int T;

int Position(Vector a, Vector b) {
	if (cross(a, b) > 0) return COUNTER_CLOCKWISE;
	if (cross(a, b) < 0) return CLOCKWISE;
	if (dot(a, b) < 0) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	return ON_SEGMENT;
}

bool intersect(Segment s1, Segment s2) {
	int a = Position(s1.p2 - s1.p1, s2.p1 - s1.p1) * Position(s1.p2 - s1.p1, s2.p2 - s1.p1);
	int b = Position(s2.p2 - s2.p1, s1.p1 - s2.p1) * Position(s2.p2 - s2.p1, s1.p2 - s2.p1);
	if (a <= 0 && b <= 0) return true;
	else return false;
}

int main() {
	cin >> T;
	while (T--) {
		cin >> s1.p1.x >> s1.p1.y >> s1.p2.x >> s1.p2.y >> s2.p1.x >> s2.p1.y >> s2.p2.x >> s2.p2.y;
		if (intersect(s1, s2)) cout << "1" << endl;
		else cout << "0" << endl;
	}
	return 0;
}


Measured memory_bytes: 3236
import java.util.*;

public class Main {
	private static Scanner sc=new Scanner(System.in);;

	public static void main(String args[]) {
		char []a=sc.nextLine().toCharArray();
		for(int i=0;i<a.length;i++){
			if(a[i]>=97&&a[i]<=122){
				a[i]-=32;
			}else if(65<=a[i]&&a[i]<=90){
				a[i]+=32;
			}
		}
		for(int i=0;i<a.length;i++){
			System.out.print(a[i]);
		}
		System.out.println();
		/*System.out.println((int )'a'+" "+(int)'z');
		System.out.println((int)'A'+" "+(int)'Z');
		System.out.println((int)'a'-'A');
		System.out.println((int)'z'-'Z');
		 */
	}
}

Measured memory_bytes: 17128