akhauriyash/Code-Regression huggingface dataset:
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 ans = -1;

    for(int i = 1 ; i <= 1000 ; ++i){
      if((int)(i*0.08) == a && (int)(i*0.1) == b){
        ans = i;
        break;
      }
    }

    System.out.println(ans);
    
  }
}

Measured memory_bytes: 35660
mod = 1000000007
def choose(n, a):
    x = 1
    y = 1
    if n/2 < a:
        a = n - a
    for i in range(a):
        x *= n - i
        if x > mod:
            x %= mod
        y *= a - i
        if y > mod:
            y %= mod
    val = x * pow(y, mod-2, mod) % mod
    return val

n, a, b = map(int, input().split(" "))

ans = int(pow(2, n, mod) - 1 - choose(n, a) - choose(n, b))
print(ans % mod)


Measured memory_bytes: 3064
// 2011/03/01 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		double b22_min = 2000000.0;
		int    num_min = 0;
		for(int i=0; i<n; i++){
			int num, h, w;
			cin >> num >> h >> w;

			double bmi = (double)(w*10000)/(double)(h*h);
			double b22 = bmi-22.0;
			if(b22<0.0)
				b22 = -b22;

			if(b22<b22_min||(b22==b22_min&&num<num_min)){
				b22_min = b22;
				num_min = num;
			}
		}

		cout << num_min << endl;
	}

	return 0;
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	m := make(map[rune]int)
	for _, r := range s {
		m[r]++
		if m[r] >= 3 {
			fmt.Println("No")
			return
		}
	}
	if len(m) == 2 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  vll a(n+1);
  rep(i,n) cin>>a[i];
  while(k){
    k--;
    vll b(n+1);
    rep(i,n){
      b[max(0LL,i-a[i])]++;
      b[min(n,i+a[i]+1)]--;
    }
    rep(i,n+1){
      if(i==0) continue;
      b[i]+=b[i-1];
    }
    if(a==b) break;
    a=b;
  }
  rep(i,n){
    cout<<a[i]<<" ";
  }
}

Measured memory_bytes: 6408
#include <stdio.h>

int main(void)
{
  int n,i;
  long double x1,y1,x2,y2,x3,y3,x4,y4;
  int ans[100];
  
  scanf("%d", &n);
  for(i = 0;i < n;i++){
    scanf("%Lf %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
  
    if( (y2-y1)*(x4-x3) == (y4-y3)*(x2-x1) ){
      ans[i] = 1;
    }else{
      ans[i] = 0;
    }
  }

  for(i = 0;i < n;i++){
    if(ans[i] == 1){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }
  return 0;
}

Measured memory_bytes: 2608
class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[2], dice[1], dice[3], dice[4] ]
    @bottom = dice[5]
  end

  def roll(action)
    b = @bottom
    u = @top
    case action
    when "N"
      @top   = @side[2]
      @bottom  = @side[0]
      @side[2] = b
      @side[0] = u
    when "E"
      @top   = @side[3]
      @bottom  = @side[1]
      @side[3] = b
      @side[1] = u
    when "S"
      @top   = @side[0]
      @bottom  = @side[2]
      @side[0] = b
      @side[2] = u
    when "W"
      @top   = @side[1]
      @bottom  = @side[3]
      @side[1] = b
      @side[3] = u
    end
  end

  def top
    @top
  end

  def bottom
    @bottom
  end

  def north
    @side[0]
  end

  def east
    @side[1]
  end

  def south
    @side[2]
  end

  def west
    @side[3]
  end

  def all_num
    [@top, @bottom, @side[2], @side[1], @side[3], @side[4]]
  end
end

d = Dice.new(gets.split.map(&:to_i))
sub = Dice.new(gets.split.map(&:to_i))

i = 0
catch(:exit) do
  while true
    if d.south == sub.south
      4.times do
        d.roll("E")
        if d.all_num == sub.all_num
          puts "Yes"
          throw :exit
        end
      end
    end
    if i > 7
      puts "No"
      break
    elsif i == 3
      d.roll("E")
      d.roll("N")
    else
      d.roll("N")
    end
    i += 1
  end
end

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int f[10000005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for (int i=1; i<=n; i++)
        for (int j=i; j<=n; j+=i)
            f[j]++;

    long long ret = 0;
    for (int i=1; i<=n; i++)
        ret += (long long) i * f[i];

    cout << ret << "\n";

    return 0;
}


Measured memory_bytes: 42716
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 200005
#define LOG_MAX 20
#define MOD 998244353
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

LL dp[MAX];
//~LL call(int pos, vector<int> &steps, int n) {
	//~if(pos == n) return 1;
	//~if(dp[pos] != -1) return dp[pos];
	
	//~LL ans = 0;
	//~for(int i=0;i<steps.size();i++) {
		//~if(pos + steps[i] > n) break;
		//~ans = ans + call(pos+steps[i], steps, n);
		//~if(ans >= MOD) ans %= MOD;
	//~}
	
	//~return dp[pos] = ans;
//~}

void solve() {
	int n, k;
	in2(n, k);
	vector<pi> v;
	for(int i=0;i<k;i++) {
		int l, r;
		in2(l, r);
		v.PB(MP(l, r));
	}
	
	sort(v.begin(), v.end());
	
	dp[1] = 1;
	vector<LL> sum(MAX, 0);
	sum[1] = 1;
	for(int i=2;i<=n;i++) {
		LL cnt = 0;
		for(int j=0;j<k;j++) {
			if(i-v[j].X <= 0) break;
			LL temp = sum[i-v[j].X];
			
			int st = max(0, i-v[j].Y-1);
			temp = (temp - sum[st] + MOD) % MOD;
			cnt = (cnt + temp) % MOD;
		}
		dp[i] = cnt;
		sum[i] = (dp[i] + sum[i-1]) % MOD;
	}
	
	cout<<dp[n]<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  map<string, long long> m;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    sort(t.begin(), t.end());
    ans += m[t];
    m[t]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, m;
	cin >> n >> m;
	int ans = 0;
	rep(i, (1 << m)){
		int nm = __builtin_popcount(i);
		ans += ((n - m) * 100) + (1900 * nm) * 2;
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
  	cout << "Yes";
  }
  else {
    cout << "No";
  }


}

int main(){
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 256
from collections import defaultdict


H, W = map(int, input().split())
mass = list()
for i in range(H):
    mass.append(input())

values_col = defaultdict(int)
values_row = defaultdict(int)

ind_row = [[0 for i in range(W)] for j in range(H)]
ind_col = [[0 for i in range(W)] for j in range(H)]

ind = 0
for i, m_row in enumerate(mass):
    ind += 1
    for j, chr in enumerate(mass[i]):
        if chr == '#':
            ind += 1
        else:
            values_row[ind] += 1
            ind_row[i][j] = ind

# print('ROW')
# for i in range(H):
#     for j in range(W):
#         print(values_row[ind_row[i][j]], end=' ')
#     print()

ind = 0
for j in range(W):
    ind += 1
    for i in range(H):
        chr = mass[i][j]
        if chr == '#':
            ind += 1
        else:
            values_col[ind] += 1
            ind_col[i][j] = ind

# print('COL')
# for i in range(H):
#     for j in range(W):
#         print(values_col[ind_col[i][j]], end=' ')
#     print()

ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, values_row[ind_row[i][j]] + values_col[ind_col[i][j]] - 1)
print(ans)


Measured memory_bytes: 281588
#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>

#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 MOD{ (ll)1e9 + 7 };

int main() {
	int n;
	string s;
	cin >> n >> s;
	int left = 0, right = 0;
	int num = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			num++;
		}
		else {
			if (num) {
				num--;
			}
			else {
				left++;
			}
		}
	}
	right = num;
	string first = "", last = "";
	for (int i = 0; i < left; i++) {
		first += '(';
	}
	for (int i = 0; i < right; i++) {
		last += ')';
	}
	cout << first + s + last << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
    int n; cin >> n;
    bool f=0;
    for(int i=1 ; i<10 ; i++){
        if(n%i == 0 && n/i <10){
            f=true;
            cout << "Yes" << endl;
            break;
        }
    }
    if(!f)cout << "No" << endl;
}


    


Measured memory_bytes: 256
object Main extends App {
  val n = scala.io.StdIn.readInt()
  val xInput =  scala.io.StdIn.readLine()
  val xArray = xInput.split(" ").map(_.toInt).toVector

  val min = xArray.min
  val max = xArray.max

  var result = -1

  (min to max).foreach { i =>
    val tempSum = xArray.map(x => (x - i) * (x - i)).sum
    if(result < 0 || tempSum < result) {
      result = tempSum
    }
  }
  println(result)
}

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

int main(){
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	int ans = (n-1+k-2)/(k-1);
	cout << ans << endl;
    return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    ll ans = 0;
    ll u = 0;
    ll R = 0;
    rep(L, n) {
        while(R < n) {
            bool dame = false;
            rep(i, 30) {
                if((u & 1<<i) && (a[R] & 1<<i)) {
                    dame = true;
                }
            }
            if(dame) {
                break;
            }
            u += a[R];
            R++;
        }
        ans += R-L;
        u -= a[L];
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1792
# include <bits/stdc++.h>
using namespace std;
 
bool v[100010];
int main() {
	int n, m, x, y;
	scanf("%d%d", &n,&m);
	while(m--) { scanf("%d%d", &x, &y); v[x]^=1, v[y]^=1; }
	for(int i=1;i<=n;++i)if(v[i]) { puts("NO"); return 0;}
	puts("YES"); return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define all(x) x.begin(), x.end()
#define watch(x) cout<<#x<<" : "<<x<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define testCases int tt;cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef vector<string> vs;

int main() {
    fastio;
    string str;
    cin >> str;
    int answer = 0;
    int n = str.size();
    for (int i = 0; i < n; i++) {
        int temp = str[i]-'0';
        answer+=temp;
    }   
    if (answer%9) {
        cout << "No";
    } else {
        cout << "Yes";
    }
    return 0;
}

Measured memory_bytes: 3756
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
  
  // }
  ll n,d;
  vector<long double>v;
  cin>>n>>d;
  rep(i,0,n-1)
  {
    long double x,y;
    cin>>x>>y;
    v.pb(sqrt(x*x+y*y));
  }
  // for(double i:v)
  // cout<<i<<" ";;
  sort(al(v));
  // for(double i:v)
  // cout<<i<<" ";;
  int itr=upper_bound(al(v),d)-v.begin();
  cout<<itr;

  
}


Measured memory_bytes: 7564
#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+10;
struct node{
	int step,x,y;
};
int s[N][N],vis[N][N];
char mp[N][N];
int sx,sy,ex,ey,n,m;
int dir[4][2]={0,1,1,0,0,-1,-1,0};

priority_queue<node>q;
bool operator < (node a,node b){
	return b.step<a.step;
}
int main(){
	memset(s,0x3f,sizeof(s));
	cin>>n>>m>>sx>>sy>>ex>>ey;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>mp[i][j];
		}
	}
	q.push((node){0,sx,sy});
	s[sx][sy]=0;
	while(q.size()){
		node now=q.top();
		q.pop();
	//	printf("%d %d %d\n",now.x,now.y,s[now.x][now.y]);
		if(now.x==ex&&now.y==ey){
			printf("%d\n",s[now.x][now.y]);
			return 0;
		}
		for(int i=0;i<4;i++){
			int xx=now.x+dir[i][0];
			int yy=now.y+dir[i][1];
			if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&mp[xx][yy]=='.'&&s[xx][yy]>now.step){
				q.push((node){now.step,xx,yy});
				vis[xx][yy]=1;
				s[xx][yy]=now.step;
			} 
		}
		for(int xx=now.x-2;xx<=now.x+2;xx++){
			for(int yy=now.y-2;yy<=now.y+2;yy++){
				if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&mp[xx][yy]=='.'&&s[xx][yy]>now.step+1){
					q.push((node){now.step+1,xx,yy});
					vis[xx][yy]=1;
					s[xx][yy]=now.step+1;
				} 
			}
		}
		
	}

	printf("-1\n");
}

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

int main(){
	ll A, B;
	cin >> A >> B;
	ll ans = 0;
	if(A % 2 == 0){
		if((B - A + 1) % 4 >= 2){
			ans++;
		}
	}else{
		if((B - A + 1) % 4 == 1 || (B - A + 1) % 4 == 2){
			ans++;
		}
	}
	for(int i=1; i<40; i++){
		if(A & (1ll<<i)){
			if(B & (1ll<<i)){
				if((A+B) % 2 == 0){
					ans |= (1ll<<i);
				}
			}else{
				if(A % 2 == 1){
					ans |= (1ll<<i);
				}
			}
		}else{
			if(B & (1ll<<i)){
				if(B % 2 == 0){
					ans |= (1ll<<i);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

map<string,int> mp[5];
int main(){
    int n,m,sz;
    string s;
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>s>>m;
        sz=s.size();
        if(mp[sz-1].find(s)==mp[sz-1].end()) mp[sz-1][s]=m;
        else mp[sz-1][s] +=m;
    }
    for(int i=0;i<5;++i){
        for(map<string,int>::iterator it=mp[i].begin();it!=mp[i].end();++it) cout<<it->first<<" "<<it->second<<endl;
    }
    return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;

int main(){
	int r;
	cin>>r;
	 long double pi=2*acos(-1);
	 long double res=pi*r;
	cout<<fixed<<setprecision(20)<<res;
	
	
	
	
	
	
	
}

Measured memory_bytes: 3792
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
	priority_queue<pair<int, int> > PQ;
	int color[MAX];
	int d[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = GRAY;

	while (!PQ.empty()) {
		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;
		color[u] = BLACK;

		if (d[u] < (f.first * (-1))) continue;

		for (unsigned int j = 0; j < adj[u].size(); j++) {
			int v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				// priority queue order is converted from descending to ascending with -1.
				PQ.push(make_pair(d[v] * (-1), v));
				color[v] = GRAY;
			}
		}
	}
	
	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	int k, u, v, c;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			adj[u].push_back(make_pair(v, c));
		}
	}

	/*
	for (int i = 0; i < n; i++) {
		vector<pair<int, int> >::iterator begin = adj[i].begin();
		vector<pair<int, int> >::iterator end = adj[i].end();
		cout << i << " ";
		for (; begin != end; begin++) {
			cout << (*begin).first << " " << (*begin).second << " ";
		}
		cout << endl;
	}
	*/

	dijkstra();

	return 0;
}


Measured memory_bytes: 8032
#include <bits/stdc++.h>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define a(x) x.begin(), x.end()
using namespace std;

int n, res = 0;

int check (int x) {
  int cnt = 0;
  while (x > 0) {
    x/=10;
    cnt++;
  }
  return (cnt & 1);
}

signed main () {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (check (i)) res ++;
  }
  cout << res;
  return 0;
}

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

const int INF = 1 << 24;
int q_chicken, b, p_chicken, p_aizu, q_aizu;

bool C(int x){//x: 買う会津鶏肉の量
	if(x * p_aizu > b || x > q_aizu){//資金超えるか用意された量より多い
		return false;
	}
	return x + (b-x*p_aizu) / p_chicken >= q_chicken;
}

int main(){
	while(std::cin >> q_chicken >> b >> p_aizu >> p_chicken >> q_aizu, !std::cin.eof()){
		int ub = INF, lb = 0;
		for(int i=0;i<100;i++){
			int mid = (lb + ub) / 2;
			if(C(mid))lb = mid;
			else ub = mid;
		}

		if(lb == 0){//会津鶏肉が買えない，残念
			puts("NA");
		}else{
			printf("%d %d\n", lb, (b-lb*p_aizu)/p_chicken);
		}
	}
}

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

int N, M;
vector<set<int>> path;

int visit(set<int> visited, int now) {
  visited.insert(now);
  if (visited.size() == (unsigned) N) return 1;
  int ways = 0;
  for(auto i : path[now]) {
    if (visited.find(i) != visited.end()) continue;
    ways += visit(visited, i);
  }
  return ways;
}

signed main() {
  cin >> N >> M;
  rep(i, N) path.push_back({});
  rep(i, M) {
    int a, b;
    cin >> a >> b;
    path[a-1].insert(b-1);
    path[b-1].insert(a-1);
  }
  cout << visit({}, 0) << endl;
}


Measured memory_bytes: 256
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m


def lcm(x, y):
        return (x*y) // gcd(x, y)


N = int(input())
A = list(map(int, input().split()))
A.sort()
lcm_value = A[0]
for i in range(1, N):
    lcm_value = lcm(lcm_value, A[i])

# print(lcm_value)
mod = 10**9+7
ans = 0
for i in range(N):
    ans += (lcm_value // A[i])

print(ans % mod)


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

int main(){
    int n, h, w, x, l;
    cin >> n >> h >> w;
    int imos[11000] = {}, b = 100;
    for(int i = 0; i < n; i++){
        cin >> x;
        if(i%2) l = i*w-x;
        else    l = i*w+x;
        imos[b+l]++;
        imos[b+l+w]--;
    }
    for(int i = 1; i < 11000; i++)  imos[i] += imos[i-1];
    int ans = 0;
    for(int i = b; i < b+n*w; i++)  ans += (imos[i] <= 0);
    cout << ans*h << endl;
    return 0;
}


Measured memory_bytes: 3152
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
#import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""


def main():
    X, Y, Z = map(int, input().split())
    print(Z, X, Y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;


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

  int x;
  cin >> x;
  
  int t = x, cnt = 1;
  while(1) {
   if (t == 0) {
     cout << cnt << endl;
     return 0;
   }
   t += x;
   t %= 360;
   cnt++;
  }
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int bil[4][3][10];
    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int u=0;u<10;u++)
                bil[i][j][u]=0;
        }
    }
    int a,b,c,d,n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a >> b >> c >> d;
        bil[a-1][b-1][c-1]+=d;
    }
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            for(int u=0;u<10;u++){
                cout << " " << bil[i][j][u];
            }
            cout << endl;
        }
        for(int p=0;p<20;p++)
        cout << "#";
        cout << endl;
    }
    for(int j=0;j<3;j++){
        for(int u=0;u<10;u++){
            cout << " " << bil[3][j][u];
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

long long int i,j;

int main(){
	long long int x;
	cin >>x;
	long long int ans = 0;
	ans += (x/11)*2;
	x=x%11;
	if(x>=7)ans+=2;
	else if(x>0)ans+=1;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}


int main() {
	int N, D;
	cin >> N >> D;
	int x[N][D];
	int ans = 0;
	REP(i, 0, N){
		REP(j, 0, D) cin >> x[i][j];
	}
	
	int distance = 0;
	REP(i, 0, N){
		REP(j, i+1, N){
			distance = 0;
			REP(k, 0, D){
				distance += pow(x[i][k] - x[j][k], 2);
				/*if(x[i][k]  != x[j][k]) distance += pow(x[i][k] - x[j][k], 2);
				else{
					/7distance = -1;
					break;
				}*/
			}
			//cout << i << " " << j << " " << distance << endl;
			if(distance != -1){
				int res  = sqrt(distance);
				if(pow(res, 2) == distance) ++ans;
			}
		
		}
	}
		cout << ans;	

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF=1000000000;
signed main(){
  int H,W,h,w;
  cin>>H>>W>>h>>w;
  if(H%h==0 && W%w==0){
    puts("No");
    return 0;
  }
  puts("Yes");
  if(W%w!=0){
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(j%w==0)cout<<INF-1;
        else if(j%w==w-1)cout<<-INF;
        else cout<<0;
        cout<<(j==W-1?'\n':' ');
      }
    }
  }else{
    for(int i=0;i<H;i++){
      int n;
      if(i%h==0)n=INF-1;
      else if(i%h==h-1)n=-INF;
      else n=0;
      for(int j=0;j<W;j++)cout<<n<<(j==W-1?'\n':' ');
    }
  }
}

Measured memory_bytes: 3640
import scala.io.StdIn

object Main extends App {

  val s = StdIn.readLine()
  val K = StdIn.readLine().toInt
  
  val m = scala.collection.mutable.Set.empty[String]
  //val m = scala.collection.mutable.SortedSet.empty[String]
  
  // i <- 0 until s.size
  //   j <- 1 until s.size - i
  for(i <- 0 until s.size;
      j <- 1 to s.size - i; if j <= K){
    //println(s"$i $j")
    val temp = s.substring(i, i + j)
    if(!m.contains(temp)){
      m add temp
    }
  }
  
  //println(m.mkString(" "))
  def getK(t: List[String], index: Int): String = {
    if(K == index) t.head
    else getK(t.tail, index + 1)
  }
  println(getK(m.toList.sorted, 1))
}


Measured memory_bytes: 75928
#include<cstdio>
#include<string.h>
#include<math.h>
using namespace std;
void move(int d, char ch)
{
    while(d)
    {
        printf("%c",ch);
        d--;
    }
}
int main()
{
    int x1,x2,y1,y2,x,y,i;
    while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2)!=EOF)
    {
        int x=x2-x1;
        int y=y2-y1;
        for(i=1;i<=4;i++)
        {
            if(i==1)
            {
                move(y,'U');
                move(x,'R');
            }
            else if(i==2)
            {
                move(y,'D');
                move(x,'L');
            }
            else if(i==3)
            {
                printf("L");
                move(y+1,'U');
                move(x+1,'R');
                printf("D");
            }
            else
            {
                printf("R");
                move(y+1,'D');
                move(x+1,'L');
                printf("U");
            }
        }
        printf("\n");
    }
    return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

ll a[maxn],b[maxn];

int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;

    f1(i,n+1){
        cin >> a[i];
    }

    f1(i,n){
        cin >> b[i];
    }

    ll sum=0LL;
    f1(i,n){
        int have= b[i];
        if(have>a[i]){
            int tot=a[i]+a[i+1];
            if(have>=tot){
                sum+=tot;
                a[i+1]=0;
            }else {
                tot -= have;
                sum+=have;
                a[i+1]=tot;
            }
        }else {
            sum+=have;
        }
    }

    cout << sum << endl;

    return 0;
}



Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> list = new ArrayList<String>();

		while (true) {
			String line = sc.nextLine();
			if (line.equals("0 0")) {
				break;
			}
			list.add(line);
		}

		for (String line : list) {

			String[] string = line.split(" ");

			int[] is = new int[2];
			is[0] = Integer.parseInt(string[0]);
			is[1] = Integer.parseInt(string[1]);

			if (is[0] <= is[1]) {
				System.out.println(is[0] + " " + is[1]);
			} else {
				System.out.println(is[1] + " " + is[0]);
			}

			if (is[0] == 0 && is[1] == 0) {
				break;
			}
		}

	}

}

Measured memory_bytes: 34896
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = I.nextInt();
		int C = I.nextInt();
		int K = I.nextInt();
		int Bl = 0;
		int ans = 0;
		char[][] grid = new char[R][C];
		for (int r = 0; r < R; r++) {
			grid[r] = I.next().toCharArray();
			for (int i = 0; i < C; i++) if (grid[r][i]=='#') Bl++;
		}
		for (int rnum = 0; rnum < (1<<R); rnum++) {
			int curK = Bl;
			boolean[]vis = new boolean[R];
			for (int row = 0; row < R; row++) {
				if ((rnum>>row)%2==1) {
					for (int c = 0; c < C; c++) {
						vis[row]=true;
						if (grid[row][c]=='#') curK--;
					}
				}
			}
			if (curK>=K) {
				int temp = curK;
				for (int cnum = 0; cnum < (1<<C); cnum++) {
					for (int col = 0; col < C; col++) {
						if ((cnum>>col)%2==1) {
							for (int r = 0; r < R; r++) {
								if (!vis[r]&&grid[r][col]=='#') temp--;
							}
						}
					}
					if (temp==K) ans++;
					temp=curK;
				}
			}	
		}
		O.pln(ans);
	}
	public static ArrayList<String> recur(int N){
		ArrayList<String> ret = new ArrayList<String>();
		if (N==1) {
			for (int i = 0; i <= N; i++) {
				ret.add(Integer.toString(i)+" ");
			}
			return ret;
		}
		ArrayList<String> prev = recur(N-1);
		for (int i = 0; i < prev.size(); i++) {
			String S = prev.get(i);
			String[] cur = prev.get(i).split(" ");
			int cmp = Integer.parseInt(cur[cur.length-1]);
			for (int j = cmp; j <= N; j++) {
				ret.add(S+Integer.toString(j)+" ");
			}
		}
		return ret;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
	}
}


Measured memory_bytes: 26964
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long ll;
struct to{
	ll l,t;
};
vector<to> mp[N];
ll dis[N];
void dfs(ll u,ll fa){
	for(ll i=0; i<mp[u].size(); i++){
		ll v=mp[u][i].t;
		if(v==fa) continue;
		dis[v]=dis[u]+mp[u][i].l;
		dfs(v,u);
	}
	return;
}
int main(){
	ll n,a,b,c,q,k,x,y;
	cin>>n;
	for(ll i=1; i<n; i++){
		cin>>a>>b>>c;
		mp[a].push_back((to){c,b});
		mp[b].push_back((to){c,a});
	}
	cin>>q>>k;
	dfs(k,0);
	for(ll i=0; i<q; i++){
		cin>>x>>y;
		cout<<dis[x]+dis[y]<<endl;
	}
	return 0;
}


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

using namespace std;

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

    int ans = 0;
    for(int i = 0; i < N; ++i){
        bool is_candidate = true;
        for(int j = 0; j < i; ++j){
            if(H[j] > H[i]){
                is_candidate = false;
                break;
            }
        }
        if(is_candidate){
        ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
struct BinaryIndexedTree {
  BinaryIndexedTree(int n) : n(n + 1), v(n + 2, 0), r(1 << (31 - __builtin_clz(n + 1))) {}

  vector<int> v;
  int n, r;

  int sum(int i) {
    ++i;
    int ret = 0;
    while (i) {
      ret += v[i];
      i -= i & -i;
    }
    return ret;
  }

  void add(int i, int x) {
    ++i;
    while (i <= n) {
      v[i] += x;
      i += i & -i;
    }
  }

  int lower_bound(int w) {
    int idx = 0;
    for (int k = r; k > 0; k /= 2) {
      if (idx + k <= n && v[idx + k] < w) {
        w -= v[idx + k];
        idx += k;
      }
    }

    return idx;
  }
};


struct segtree {
  segtree() {}
  segtree(int n, vector<char> v) : n(n) { init(v); }
 
  pair<char, int> id = make_pair('{', -1);
  int n;
  vector<pair<char, int>> node;
 
  void init(vector<char> v) {
    int n_ = n;
    n = 1;
    while (n < n_)
      n *= 2;
 
    node.assign(2 * n - 1, id);
    for (int i = 0; i < v.size(); ++i) {
      int idx = i + n - 1;
      node[idx] = make_pair(v[i], i);
    }
    for (int i = n - 2; i >= 0; --i) {
      node[i] = min(node[2 * i + 1], node[2 * i + 2]);
    }
  }
 
  pair<char, int> find(int a, int b, int k, int l, int r) {
    if (b <= l || r <= a)
      return id;
    if (a <= l && r <= b)
      return node[k];
 
    return min(find(a, b, 2 * k + 1, l, (l + r) / 2),
               find(a, b, 2 * k + 2, (l + r) / 2, r));
  }
 
  pair<char, int> find(int a, int b) { return find(a, b, 0, 0, n); }
 
  void update(int k) {
    k += n - 1;
    node[k] = id;
    while (k) {
      k = (k - 1) / 2;
      node[k] = min(node[2 * k + 1], node[2 * k + 2]);
    }
  }
};
 
int main() {
  string s;
  int k;
 
  cin >> s >> k;
  vector<char> v(s.size());
  for (int i = 0; i < s.size(); ++i)
    v[i] = s[i];
 
  BinaryIndexedTree bit(s.size());
  segtree seg(s.size(), v);
 
  for (int i = 0; i < s.size(); ++i)
    bit.add(i, 1);
 
  string ans;
  for (int i = 0; i < s.size(); ++i) {
    int r = bit.lower_bound(k + 1);
    pair<char, int> c = seg.find(0, r + 1);
    seg.update(c.second);
    bit.add(c.second, -1);
    k -= bit.sum(c.second);
 
    ans.push_back(c.first);
  }
 
  cout << ans << endl;
}

Measured memory_bytes: 8736
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

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

    if(s.size()==1){
        cout << 0 << endl;
        return 0;
    }

    int cnt = 0;
    rep(i, s.size()-1){
        if(s.at(i)!=s.at(i+1)){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
int i=1,x=0,n;
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		if(i%3==0){
			printf(" %d", i);
		}
		else{
			if(i%10==3){
				printf(" %d", i);
			}
			else{
				x=i;
				while(x!=0){
					if(x%10!=3){
						x/=10;
					}
					else{
						printf(" %d", i);
						break;
					}
				}
			}
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 2148
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;
using std::abs;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& vec) {
	os << '[';
	int fst = 1;

	for(auto& elem: vec) {
		if(fst == 0) {
			os << ' ';
		}

		os << elem;
		fst = 0;
	}

	os << ']';
	return os;
}

const int MAX_N = 577;

int cnt[MAX_N][MAX_N], n, m, q;

void solve() {
	cin >> n >> m >> q;

	while(m--) {
		int l, r;
		cin >> l >> r;

		++cnt[l][r];
	}

	for(int l = 1; l <= n; ++l) {
		for(int r = l; r <= n; ++r) {
			cnt[l][r] += cnt[l][r - 1];
		}
	}

	while(q--) {
		int a, b, answ = 0;
		cin >> a >> b;

		for(int l = a; l <= b; ++l) {
			answ += cnt[l][b];
		}

		cout << answ << '\n';
	}
}

int main() {
	init_IO();
	solve();

	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#include<numeric>
//#include <boost/math/common_factor.hpp> 
#define int long long
#define ld long double
#define all(x) x.begin(),x.end()
const int maxn=1000000;
#define what_is(x) cerr << #x << " is " << x << endl;
const int MOD = 1e9 + 7;
using namespace std;
string abc="abcdefghijklmnopqrstuvwxyz";
int powmod(int a, int b, int MOD = MOD){
    if(!a and !b)    return 1ll;
    if(!a)    return a;
    int res = 1ll;
    b %= (MOD - 1ll), a %= MOD;
    while(b){
        if(b%2 == 1)    res = (res * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }
    return res;
}
int popcount(uint32_t n)
{
    n = n - ((n >> 1) & 0x55555555);
    n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
    return ((n + (n >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}
bool check(int n) {return (((double)sqrt(n)-floor((double)sqrt(n)))==0);}
vector<bool> sieve(maxn + 1, true);
void fillprime() {
    sieve[0] = sieve[1] = false;
    for (int i = 2; i <= maxn; ++i) {
        if (sieve[i] && (int) i * i <= maxn) {
            for (int j = i * i; j <= maxn; j += i) {
                sieve[j] = false;
            }
        }
    }
}
const int nn=1e5+5;
void solve() {
     int n;
     cin>>n;
     int arr[n];
     for(int i=0;i<n;++i) cin>>arr[i];
     int cnt=0;
     int k=1;
     bool flag=false;
     for(int i=0;i<n;++i){
         if(arr[i]==k) {
             k++;
             flag=true;
         }
         else cnt++;
     }
     if(flag) cout<<cnt;
     else cout<<-1;

    
}
int32_t main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    //fillprime();
    //int t;cin>>t;while(t--)
    solve();
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    double n;
    while(cin>>n){
    double ans=n;
    rep(i,0,9){
        if(i%2==0)n*=2;
        else n/=3;
        ans+=n;
    }
    printf("%.10f\n",ans);
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3216
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main() {
    string a;
    cin >> a;
    LLI k;
    cin >> k;
    for(LLI i = 0 ; i < a.length() ; i++) {
        if(a[i] == '1') {
            if(k == 1) {
                cout << 1;
                return 0;
            } else {
                k--;
            }
        } else {
            cout << a[i];
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 888
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const long double pi=acos(-1);
const long double eps=1e-12;
double a,b,x;
bool calc(long double mid)
{
	long double res=0.0;
	if(tan(mid)>b/a) res=a*b*b/(2*tan(mid));
	else res=a*a*b-a*a*a*tan(mid)/2;
	
	return (res-x>eps);
}
int main()
{
	cin>>a>>b>>x;
	long double l=0.0,r=pi/2;
	while(r-l>eps)
	{
		long double mid=(l+r)/2;
		if(calc(mid)) l=mid;
		else r=mid;
	}
	printf("%.10Lf\n",(l/pi)*180);
	return 0;
}

Measured memory_bytes: 256
using System;

class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine());

            var area_1r = 1 * 1 * Math.PI;
            var area_r = r * r * Math.PI;

            Console.WriteLine((area_r / area_1r));
        }
    }

Measured memory_bytes: 13140