akhauriyash/Code-Regression huggingface dataset:
# tree[i] += 1 O(logN)
def BIT_add(i):
    while i <= N:
        tree[i] += 1
        i += i&(-i)

# sum(tree[1:i+1]) O(logN)
def BIT_sum(i):
    s = 0
    while i:
        s += tree[i]
        i -= i&(-i)
    return s

# 二分探索 O(logN)
# 和がx以上となる最小のインデックス(>= 1)を返す
def BIT_search(x):
    # 求めるインデックス
    i = 0
    # 和
    s = 0
    # step = 2^i  (2^i <= N)
    step = 1<<(N.bit_length()-1)
    while step:
        if i+step <= N and s + tree[i+step] < x:
            i += step
            s += tree[i]
        step >>= 1
    # 1-indexed
    return i+1


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())

# 1-indexed
P = [None] + [int(x) for x in input().split()]

# p_to_i[i] = P.index(i)
# 1-indexed
p_to_i = [None] * (N+1)
for i,x in enumerate(P[1:],1):
    p_to_i[x] = i

"""
大きい数から挿入していく
左隣にあるインデックスを取得できるようにしておく
そのために、[1,i]内で書き込んだ数の個数を獲得できるBITを持つ
"""

# BIT (1-indexed)
tree = [0] * (N+1)
answer = 0
for x in range(N,0,-1):
    c = p_to_i[x]
    # 左にある既に書き込んだ数の個数
    L = BIT_sum(c)
    # 右にある既に書き込んだ数の個数
    R = BIT_sum(N) - L
    # tree[c] += 1 
    BIT_add(c)
    # 左側
    a = BIT_search(L-1) if L > 1 else 0
    b = BIT_search(L) if L > 0 else 0
    # 右側
    d = BIT_search(L+2) if R > 0 else N+1
    e = BIT_search(L+3) if R > 1 else N+1

    # xとなる個数
    coef = 0
    if b != 0:
        # [b,c]を含むようにする。
        coef += (b-a) * (d-c)
    if d != 0:
        # [c,d]を含むようにする。
        coef += (e-d) * (c-b)
    answer += x * coef

print(answer)

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

string s;

int x[] = {-1, 0, 1, 2, 0, -1, 2, 0, 1, 2};

int solve(int i, int foot)
{
	int px = x[s[i - 1] - '0'];
	int cx = x[s[i] - '0'];
	if (i == s.size()) return 0;
	if (foot == 0){
		if (px <= cx) return solve(i + 1, 1);
		return 1 + solve(i + 1, 0);
	}
	else {
		if (cx <= px) return solve(i + 1, 0);
		return 1 + solve(i + 1, 1);
	}
}

int main()
{
	while (cin >> s, s != "#"){
		cout << min(solve(1, 0), solve(1, 1)) << endl;
	}
}

Measured memory_bytes: 1316
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto d = RDA;
	long ans;
	foreach (i; 0..N)
	{
		foreach (j; i+1..N)
		{
			ans += d[i]*d[j];
		}
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

using namespace std;

int n, w;
long long weight[101];
long long value[101];
long long dp[100001][101];

int main()
{
    cin >> n >> w;
    long long lval = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> weight[i] >> value[i];
        lval += value[i];
    }

    for(int i = 0; i <= lval; i++)
    {
        dp[i][0] = 1e18;
    }

    dp[0][0] = 0;

    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= lval; j++)
        {
            if(j - value[i] >= 0) dp[j][i] = min(dp[j][i-1], dp[j - value[i]][i-1] + weight[i]);
            else dp[j][i] = dp[j][i-1];
        }
    }

    long long mx = 0;
    for(int i = 1; i <= lval; i++)
    {
        if(dp[i][n] <= w) mx = i;
    }

    cout << mx << endl;

}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  if(K == 0){
    cout << N*N << endl;
    return 0;
  }

  ll cnt = 0;

  rep2(b, K + 1, N + 1) cnt += N / b * (b - K) + max((N % b) - (K - 1), (ll)0);

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


Measured memory_bytes: 256
my ($a, $b) = map {$_ + 0} split(/\s+/o, <>);
my $A = '';
foreach my $i (1..$b) {
  $A .= $a;
}
my $B = '';
foreach my $i (1..$a) {
  $B .= $b;
}
if ( $A le $B  ) {
  print $A;
} else {
  print $B;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    
    long long n,m,fac1=1,fac2=1;
    cin >> n >> m;
    if(abs(n-m) > 1) {cout<<0; return 0;}
    for(long long i=2;i<=n;i++){ fac1 = fac1*i%1000000007;}
    for(long long i=2;i<=m;i++) fac2 = fac2*i%1000000007;
    if(n != m) cout<<(fac1*fac2)%1000000007;
    else cout << (fac1*fac2*2)%1000000007;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

vector<int> edge[MAX_N];
bool reach[MAX_N];
//int ans[MAX_N];

void dfs(int now){
    if(reach[now]) return;
    reach[now]=true;
}

lint d[300][300]; // MAX_V
void warshallfloyd(int v){ // N
  rep(i,v) rep(j,v) rep(k,v) d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
  return;
}


int main(void){
    int N,M,R;
    cin >> N >> M >> R;
    int r[R];
    rep(i,R) cin >> r[i],r[i]--;
    sort(r,r+R);
    rep(i,N) rep(j,N) if(i!=j) d[i][j]=INF;
    rep(i,M){
        int u,v,w;
        cin >> u >> v >> w;
        u--,v--;
        d[u][v]=w;
        d[v][u]=w;
    }
    warshallfloyd(N);
    lint ans=INF;
    do{
        lint dis=0;
        rep(i,R-1) dis+=d[r[i]][r[i+1]];
        ans=min(ans,dis);
    }while(next_permutation(r,r+R));
    cout << ans << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> t(n);
    vector<int> x(n);
    vector<int> y(n);
    for (int i=0;i<n;i++){cin >> t[i] >> x[i] >> y[i];}

    int prev_x = 0;
    int prev_y = 0;
    int prev_t = 0;
    string s = "Yes";
    int distance;
    int time_interval;
    for (int i=0;i<n;i++){
        distance = abs(x[i] - prev_x) + abs(y[i] - prev_y);
        time_interval = t[i] - prev_t;
        if (distance > time_interval){
            s = "No";
            break;
        } else {
            if (abs((distance - time_interval) % 2) == 1){
                s = "No";
                break;
            }
        }
        prev_x = x[i];
        prev_y = y[i];
        prev_t = t[i];
    }
    cout << s <<  endl;


}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  s[0]++;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int count = 0;
		for(char c : s.toCharArray()) {
			if(c=='1') count++;
		}
		System.out.println(count);
	}
}

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

int main(){
  long long n, a, b; cin >> n >> a >> b;
  long long x[n];
  for(int i = 0; i < n; ++i) cin >> x[i];
  long long dp[n+1];
  dp[0] = 0;
  dp[1] = 0;
  for(int i =2; i <= n; ++i){
    dp[i] = min(a*(x[i-1]-x[i-2]), b) + dp[i-1];
  }
  cout << dp[n] << endl;
  return 0; 
}

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

using namespace std;

int main(){
    int n;
    cin >> n;

    vector<vector< int > >dyce(n, vector<int>(2));

    for(int i = 0 ; i < n ; i++){
        for(int j = 0; j < 2 ; j++){
            cin >> dyce[i][j];
        }
    }

    for(int i = 0 ; i < n-2 ; i++){
        int j = 0;
        if(dyce[i][j] == dyce[i][j+1]){
            if(dyce[i+1][j] == dyce[i+1][j+1]){
                if(dyce[i+2][j] == dyce[i+2][j+1]){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  string S;
  cin >> S;
  if (len(S) == 2) {
    cout << S << "\n";
  } else {
    reverse(all(S));
    cout << S << "\n";
  }
}

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

int main() {

  int64_t N, K;
  cin >> N >> K;

  vector<int> H(N);

  for (int64_t i = 0; i < N; i++) {
    int64_t j;
    cin >> j;
    H.at(i) = j;
  }

  sort(H.begin(),H.end());

  for (int64_t i = 0; i < K; i++) {
    H.pop_back();
    if (H.size() ==0) {
      break;
    }
  }

  int64_t h_sum = 0;
  for (auto x : H) {
    h_sum += x;
  }

  cout << h_sum << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
#include <cstdlib>
#define INT_MAX 2147483647
#define INT_MIN -2147483646
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

static const int N = 105;

struct vertex {
	int id;
	int p;
	int d;
	bool operator<(const vertex & another) const {
		return (d != another.d ? d>another.d : id>another.id);
	}
};

int main() {
	vvi mx(N, vi(N, -1));
	int n;
	cin >> n;
	Loop(i, n) {
		Loop(j, n) {
			int a;
			cin >> a;
			mx[i][j] = a;
		}
	}
	//
	vi color(N, 0); //0,1,2
	priority_queue<vertex> q;
	q.push({ 0,-1,0});
	int ret = 0;
	while(q.size() > 0) {//?
		vertex v = q.top();
		q.pop();
		if (color[v.id] == 2) continue;
		color[v.id] = 2;
		ret += v.d;
		Loop(j, n) {
			if (mx[v.id][j] != -1 && color[j] != 2){
					q.push({ j, v.id,mx[v.id][j] });
					color[j] = 1;
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3216
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if(n>=m){
            System.out.println(0);
        }else{
            int[] x = new int[m];
            for(int i=0;i<m;i++)x[i] = Integer.parseInt(sc.next());
            Arrays.sort(x);
            int[] diff = new int[m-1];
            for(int i=0;i<m-1;i++)diff[i] = -(x[i+1] - x[i]);

            Arrays.sort(diff);
            int dist = x[m-1] - x[0];
            for(int i=0;i<n-1;i++)dist+=diff[i];
            System.out.println(dist);
        }
        sc.close();
    }
}

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

using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  int x[100];
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }

  int min = INT_MAX;
  for (int p = 1; p <= 100; ++p) {
    int sum = 0;
    for (int j = 0; j < n; ++j) {
      sum += (x[j] - p) * (x[j] - p);
    }
    if (sum < min) {
      min = sum;
    }
  }

  cout << min;

  return 0;
}


Measured memory_bytes: 256
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
INF = 10**10
MOD = 10**9 + 7

H = [0] * N
_H = [INF] * N
pre_h = 0
for i, h in enumerate(T):
  if h != pre_h:
    H[i] = h
    pre_h = h
  else:
    _H[i] = min(_H[i], h)

pre_h = 0
for i, h in enumerate(A[::-1], 1):
  if h != pre_h:
    if (H[-i] > 0 and H[-i] != h) or _H[-i] < h:
      print(0)
      quit()
    H[-i] = h
    pre_h = h
  else:
    _H[-i] = min(_H[-i], h)

ans = 1
for h, _h in zip(H, _H):
  if h == 0:
    ans *= _h
    ans %= MOD

print(ans)

Measured memory_bytes: 18500
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int H, W;
    cin>>H>>W;
    vector<string> S(H);
    for(int i=0;i<H;++i){
        cin>>S[i];
    }
    int full = 0;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(S[i][j]=='.') full++;
        }
    }
    queue<pair<int, int> > que;
    queue<int> numque;
    pair<int, int> state;
    int num;
    que.push(mp(0, 0));
    numque.push(1);
    bool can = false;
    int ans;
    while(!que.empty()){
        state = que.front();que.pop();
        num = numque.front();numque.pop();
        if((state.fi==H-1) && (state.se==W-1)){
            can = true;
            ans = num;
        }
        if(S[state.fi][state.se]=='#') continue;
        S[state.fi][state.se] = '#';
        if((state.fi>0) && (S[state.fi-1][state.se]=='.')){
            que.push(mp(state.fi-1, state.se));
            numque.push(num+1);
        }
        if((state.fi<H-1) && (S[state.fi+1][state.se]=='.')){
            que.push(mp(state.fi+1, state.se));
            numque.push(num+1);
        }
        if((state.se>0) && (S[state.fi][state.se-1]=='.')){
            que.push(mp(state.fi, state.se-1));
            numque.push(num+1);
        }
        if((state.se<W-1) && (S[state.fi][state.se+1]=='.')){
            que.push(mp(state.fi, state.se+1));
            numque.push(num+1);
        }
    }
    if(can) cout<<full-ans<<endl;
    else cout<<-1<<endl;
}



Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)

	writer := bufio.NewWriter(os.Stdout)

	l := getNextInt(scanner)
	r := getNextInt(scanner)

	fmt.Fprintln(writer, solve(l, r))
	writer.Flush()
}

func solve(l, r int) int {
	if r-l >= 2019 {
		return 0
	}
	ml := l % 2019
	mr := r % 2019

	if mr <= ml {
		return 0
	}

	ans := 2019

	for i := ml; i < mr; i++ {
		for j := i + 1; j <= mr; j++ {
			if (i*j)%2019 < ans {
				ans = (i * j) % 2019
			}
		}
	}
	return ans
}


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

const int N = 2e6 + 100, M = 6, MOD = 1000 * 1000 * 1000 + 7;

int sum(int a, int b) {a += b;return (a < 0? a + MOD: a >= MOD? a - MOD: a);}
void _sum(int &a, int b) {a = sum(a, b);}
int mul(int a, int b) {return 1LL * a * b % MOD;}
void _mul(int &a, int b) {a = mul(a, b);}

int power(int a, int b) {
	int res = 1;
	while(b) {
		if(b & 1)
			_mul(res, a);
		_mul(a, a);
		b >>= 1;
	}
	return res;
}

int n, ans, X[M], Y[M], fac[N], pow_fac[N];

int choose(int a, int b) {
	return a > b? 0: mul(fac[b], mul(pow_fac[a], pow_fac[b - a]));
}

void pre_pro() {
	fac[0] = 1;
	for (int i = 1; i < N; i++)
		fac[i] = mul(fac[i - 1], i);
	for (int i = 0; i < N; i++)
		pow_fac[i] = power(fac[i], MOD - 2);
}

int g(int x, int y, int X, int Y) {
	return sum(sum(choose(y + Y + 1, x + X + y + Y + 2), -choose(y + Y + 1, x + 1 + y + Y)), sum(-choose(y, x + X + y + 1), choose(y, x + y)));
}

int f(int x, int y, int xx, int yy) {
	return mul(g(x - X[1], y - Y[1], X[1] - X[0], Y[1] - Y[0]), g(X[4] - xx, Y[4] - yy, X[5] - X[4], Y[5] - Y[4]));
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	pre_pro();
	for (int i = 0; i < M; i++)
		cin >> X[i];
	for (int i = 0; i < M; i++)
		cin >> Y[i];
	
	for (int x = X[2]; x <= X[3]; x++)
		_sum(ans, mul(f(x, Y[2] - 1, x, Y[2]), -(x + Y[2] - 1)));
	for (int y = Y[2]; y <= Y[3]; y++)
		_sum(ans, mul(f(X[2] - 1, y, X[2], y), -(X[2] - 1 + y)));
	
	for (int x = X[2]; x <= X[3]; x++)
		_sum(ans, mul(f(x, Y[3], x, Y[3] + 1), x + Y[3]));
	for (int y = Y[2]; y <= Y[3]; y++)
		_sum(ans, mul(f(X[3], y, X[3] + 1, y), X[3] + y));
	
	cout << ans;
	return 0;
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

const lli MOD = 1000000007LL;

lli modpow(lli a, lli n){
    lli res = 1;

    for(lli ai = a; n; n>>=1){
        if(1&n) res = (res*ai)%MOD;
        ai=(ai*ai)%MOD;
    }
    return res;
}

lli inv(lli n){
    return modpow(n, MOD-2);
}

lli modperm(lli n, lli k){
    lli res = 1;
    rep(i, k){
        res = (res*(n-i))%MOD;
    }
    return res;
}

lli modcomb(lli n, lli k){
    return (modperm(n, k)*inv(modperm(k, k)))%MOD;
}

lli posmod(lli n){
    lli res = n;
    res %= MOD;
    if(res < 0) res += MOD;
    return res;
}
int a, b;

int main(void){
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}



Measured memory_bytes: 3624
n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
	sum_ = 0
	m = i

	while True:
		sum_ += m % 10
		m //= 10
		if not m:
			break
	if a <= sum_ <= b:
		ans += i

print(ans)

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

int main(){
    string s;
    cin >> s;
    char a, b;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
        if(i == 0) a = s[i];
        else if(i == s.size()-1) b = s[i];
        else cnt++;
    }
    cout << a << cnt << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;

#define ll long long
#define ull unsigned long long

int main()
{
	char c;
	cin >> c;
	printf("%c", ++c);

	return 0;
}


Measured memory_bytes: 888
#include <iostream>

int main() {
    std::string S;
    std::cin >> S;
    int max_size = S.size() - 1;
    max_size = max_size % 2 == 0 ? max_size : max_size - 1;

    for (int i = max_size; i >= 0; i -= 2) {
        if (S.substr(0, i / 2) == S.substr(i / 2, i / 2)) {
            std::cout << i << std::endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    int input;
    std::cin >> input;
    int hour = input / 3600;
    int min = (input % 3600) / 60;
    int sec = input - hour * 3600 - min * 60;

    std::printf("%d:%d:%d\n", hour, min, sec);
    return 0;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;


	ll n;
	cin >> n;
	vector<ll> a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	ll ans = 0, sum = a[0];
	if (sum == 0) {
		ans++;
		sum++;
	}
	for (ll i = 1; i < n; i++) {
		sum += a[i];
		if (sum * (sum - a[i]) < 0) continue;
		if (sum > 0) {
			ans += sum + 1;
			sum = -1;
		}
		else {
			ans += 1 - sum;
			sum = 1;
		}
	}
	ll subans = 0;
	sum = a[0];
	if (sum == 0) {
		subans++;
		sum--;
	}
	else if (sum > 0) {
		subans += sum + 1;
		sum = -1;
	}
	else {
		subans += 1 - sum;
		sum = 1;
	}
	for (ll i = 1; i < n; i++) {
		sum += a[i];
		if (sum * (sum - a[i]) < 0) continue;
		if (sum > 0) {
			subans += sum + 1;
			sum = -1;
		}
		else {
			subans += 1 - sum;
			sum = 1;
		}
	}
	cout << min(ans, subans) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main (void) {
    string S;
    cin >> S;
    char blinker = '0';
    int temp = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == blinker) {
            temp++;
        }
        if (blinker == '0') {
            blinker = '1';
        }
        else {
            blinker = '0';
        }
    }
    int ans;
    int diff = S.length() - temp;
    ans = min(diff, temp); 
    cout << ans << endl;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(auto& x : a) cin >> x;
  map<int, int> cnts;
  ll ans = 0;
  for(int i = 0; i < n; i++) {
    int need = i-a[i];
    ans += cnts[need];
    cnts[i+a[i]]++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 21212
package main

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

var sc = bufio.NewScanner(os.Stdin)

func inputInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func splitInt(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = inputInt()
	}
	return arr
}

type sortable [][]int

func (s sortable) Len() int { return len(s) }

func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }

func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	sc.Buffer([]byte{}, 100000000)
	sc.Split(bufio.ScanWords)
	n := inputInt()
	as := splitInt(n)
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		ans[as[i]-1] = i + 1
	}

	first := true
	for _, x := range ans {
		if !first {
			fmt.Print(" ")
		}
		fmt.Printf("%d", x)
		first = false
	}
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int INF = 1145; 
	int A[20], B[20]; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	for(int i = 0; i < N; i++) cin >> B[i]; 
	int dp[262150][55] = {}; // dp[ここまでに使った数の集合][max] = 回数min
	for(int i = 0; i < (1 << N); i++){
		for(int j = 0; j <= 50; j++){
			dp[i][j] = INF; 
		}
	}
	dp[0][0] = 0; 
	int used[20] = {}; 
	for(int i = 0; i < (1 << N); i++){
		int cnt = 0; fill(used, used+20, 0); 
		for(int k = 0; k < N; k++){
			if((i >> k) & 1){
				used[k] = -1; cnt ++; 
			}
		}
		int pop = cnt; 
		for(int k = 0; k < N; k++){
			if(used[k] != -1){
				used[k] = cnt; cnt ++; 
			}
		}
		for(int j = 0; j <= 50; j++){
			if(dp[i][j] == INF) continue; 
			for(int k = 0; k < N; k++){
				if(used[k] == -1) continue; 
				int last; 
				if(pop % 2 == k % 2) last = A[k]; 
				else last = B[k]; 
				if(last >= j) dp[i + (1 << k)][last] = min(dp[i + (1 << k)][last], dp[i][j] + used[k] - pop); 
			}			
		}
	}
	int ans = INF; 
	for(int k = 0; k <= 50; k++){
		ans = min(ans, dp[(1 << N) - 1][k]); 
	}
	if(ans == INF) cout << -1 << endl; 
	else cout << ans << endl;
	/*for(int i = 0; i < 8; i++){
	    for(int j = 0; j <= 5; j++){
	        cout << dp[i][j] << " "; 
	    }
	    cout << endl; 
	}*/
}

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

using namespace std;
string s,t;

int main()
{
	ios::sync_with_stdio(false);
	cin>>s>>t;
	int ans=0;
	int x=s.size(),y=t.size();
	if(s[0]==t[0]) ans++;
	if(s[1]==t[1]) ans++;
	if(s[2]==t[2]) ans++;
	cout<<ans<<endl;
	
	
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,ans=0;
  cin >> n;
  ll d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      ans += d[i]*d[j];
    }
  }
  cout <<ans <<endl;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

ll keta(ll m) {
    return 81LL * ((1LL << (m-1)) - 1);
}

string solve(ll n, ll m, ll num1) {
    rep(num2, 10) {
        ll tmp;
        if (num1 == num2) tmp = ((1LL << (m-1))-1LL) * 9LL;
        else tmp = (1LL << (m-1));
        if (n >= tmp) {
            n -= tmp;
        }
        else {
            string ans = to_string(num2);
            if (num1 == num2) {
                ans += solve(n, m-1, num1);
            }
            else {
                if (num1 < num2) swap(num1, num2);
                for (int k=m-2; k>=0; --k) {
                    ans += to_string((n&(1LL<<k) ? num1 : num2));
                }
            }
            return ans;
        }
    }
    return "";
}

int main() {
    ll n;
    while (cin >> n, n) {
        n--;
        ll m = 2;
        while (n >= keta(m)) {
            n -= keta(m);
            m++;
        }
        ll block = keta(m) / 9;
        ll num1 = 1 + n / block;
        n %= block;
        cout << num1 << solve(n, m-1, num1) << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000007
ll fact[50];
#define eps 1e-9
#define INF 1e18
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=ans*a%c;
    }
    a=a*a%c;
    b=b/2;
  }
  return ans;
}
ll ncr(ll n,ll r){
    if(r>n)return 0;
    if(r==n)return 1;
    ll z=fact[n];
    z=z*power(fact[r],mod-2,mod)%mod;
    z=z*power(fact[n-r],mod-2,mod)%mod;
    return z;
}
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
       
            int r; cin>>r;
            double res=2*22*r/7.0;
            printf("%.18lf\n",res );
        
        return 0;
}


Measured memory_bytes: 3768
# ABC111

N = int(input())

zorome_contest = [111*i for i in range(1, 10)]
diff_min = 10**10
ans = 0

for contest in zorome_contest:
    if contest - N >= 0 and contest - N < diff_min:
        diff_min = contest - N
        ans = contest
print(ans)


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

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"

#define DEBUG(x) cout << "> " << #x << ": " << x << endl;

typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
const int inf = 1e9+7;
const ll longinf = 1LL<<60;

// Start Coding...

void solve() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int x,a,b;
  cin>>x;
  for (int i=0;i<1000;i++){
    for(int j=0;j<2000;j++){
      //long long int aa,bb;
      //aa=i*i*i*i*i;
      //bb=j*j*j*j*j;
    
      long long int num,aa,bb;
      aa=i-j+100;
      bb=i*(j-100);
      num=aa*((aa*aa+2*bb)*(aa*aa+2*bb)-2*bb*bb+bb*(aa*aa+3*bb));
      
      if(num==x){
        a=i;
        b=j-100;
        cout<<a<<" "<<b<<endl;
        return 0;
     
        
      }
    }
  }
}

Measured memory_bytes: 3604
from itertools import accumulate

n, q = map(int, input().split())

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i:i+2] == 'AC' else total


cumsum = list(accumulate([0] + list(range(n)), count))

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])



Measured memory_bytes: 33824
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

mint choose(ll n, ll a) //
{
    n -= 1;
    a -= 1;
    mint x = 1, y = 1;
    rep(i, a)
    {
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

int main()
{
    ll n, k;
    cin >> n >> k;
    ll count = 0;
    for (int i = 1; i < k + 1; i++) //kこを1以上の部分列がiこ存在している。
    //まず、kこの青色をiグループに分ける式を考える。
    {
        mint A = choose(k, i);
        //N-kこをi+1のグループに分ける。
        mint B = choose(n - k, i + 1);
        mint C = choose(n - k, i);
        mint D = choose(n - k, i - 1);
        mint g = A * (B + D + C + C);
        if (i == 1)
        {
            cout << g.x - 1 << endl;
        }
        else
        {
            cout << g.x << endl;
        }
    }
}

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() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<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 = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B, C, D, K;

void solve() {
	cin >> A >> B >> C >> D >> K;
	int E = (C - A) * 60 + D - B;
	cout << max(0, E - K) << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

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



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

using namespace std;

int W,H,x,y;
double s;

int main()
{
	cin>>W>>H>>x>>y;
	s=(double)W*H/2;
	printf("%.12lf",s);
	if(x*2==W&&y*2==H)
		cout<<" 1"<<endl;
	else
		cout<<" 0"<<endl;
	return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
k = []
h_remove = []
w_remove = []
for i in range(h):
    ls = input()
    if ls.count(".") == w:
        h_remove.append(i)
    k.append(ls)
for i in range(w):
    now = ""
    for j in range(h):
        now += k[j][i]
    if now.count(".") == h:
        w_remove.append(i)
h_remove = set(h_remove)
w_remove = set(w_remove)
for i in range(h):
    ans = ""
    if i in  h_remove:
        continue
    else:
        for j in range(w):
            if j in w_remove:
                continue
            else:
                ans += k[i][j]
        print(ans)


Measured memory_bytes: 9148
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

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

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int k=sc.nextInt();
        int r=1;
        while(n>=k) {
        	n/=k;
        	r++;
        }
        
        out.println(r);
     	out.flush();
    }
   
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


class P implements Comparable<P>{
    int p,h,f; long m;
    P(int p,int h, int f, long m) {
    	this.p=p;
    	this.h=h;
    	this.f=f;
    	this.m=m;
    }

    public int compareTo(P p){
    	if(this.p==p.p) {
    		if(this.f==-1) return 1;
    		return -1;
    	}
        return this.p-p.p;
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 24532
#include <bits/stdc++.h>
using namespace std;
int main() {
	set<long long> a0;
	for (long long t = 1; t <= 20000000000000LL; t *= 10) {
		for (int i = 1; i <= 999; ++ i) {
			a0.insert(i * t + t-1);
			a0.insert(i * t + t);
		}
	}
	vector<long long> a(a0.begin(), a0.end());
	int n = a.size();
	vector<int> b(n, 0);
	for (int i = 0; i < n; ++ i) {
		for (long long j = a[i]; j > 0; j /= 10) b[i] += j % 10;
	}
	vector<long long> c;
	for (int i = 0; i < n; ++ i) {
		//cout << a[i] << " " << (double)a[i]/b[i] << endl;
		for (int j = i+1; j < n; ++ j) {
			double s1 = a[i]; s1 *= b[j];
			double s2 = a[j]; s2 *= b[i];
			if (s1 > 9e18 || s2 > 9e18) throw 1;
			if (a[i]*b[j] > a[j]*b[i]) goto next;
		}
		c.push_back(a[i]);
		next:;
	}

	int K;
	cin >> K;
	for (int i = 0; i < K; ++ i) {
		if (i >= (int)c.size()) throw 1;
		cout << c[i] << endl;
	}
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,P> pip;
const int inf=(1<<31)-1;

int a,b;
bool ans=1;

int main(){
	cin>>a>>b;
	if((a<=0&&b>=0)||(a>=0&&b<=0)) cout<<"Zero"<<endl;
	else if(a>0&&b>0) cout<<"Positive"<<endl;
	else if((-a+b)%2) cout<<"Positive"<<endl;
	else cout<<"Negative"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec idy={1,0,-1,0};
vec idx={0,1,0,-1};

const ll N=500;
mat c(N,vec(N));
mat al(N,vec(N,1));
ll n;

void dfs(ll y, ll x, ll v) {
  for(ll i=0;i<4;i++) {
    ll ny=y+idy[i];
    ll nx=x+idx[i];
    c[y][x]=v;
    if(ny>-1&&nx>-1&&ny<n&&nx<n&&v+al[y][x]<c[ny][nx]) {
      dfs(ny,nx,v+al[y][x]);
    }
  }
}

int main() {
  cin >> n;
  vec p(n*n);
  for(ll i=0;i<n*n;i++) {
    ll y=i/n;
    ll x=i%n;
    c[y][x]=min({y,x,n-1-y,n-1-x});
  }
  for(ll i=0;i<n*n;i++) {
    cin >> p[i];
    p[i]--;
  }
  ll ans=0;
  for(ll i=0;i<n*n;i++) {
    ll y=p[i]/n;
    ll x=p[i]%n;
    ans+=c[y][x];
    al[y][x]=0;
    dfs(y,x,c[y][x]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 24420
import java.util.Scanner;

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

		int X=sc.nextInt();


		for(int i=1; i<=45000; i++) {
			if(i*(i+1)/2>=X) {
				System.out.println(i);
				break;
			}
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
 
ll mod_pow(ll x, ll a){
    if(a == 1) return x;
    if(a % 2) return (x * mod_pow(x, a - 1)) % MOD;
    ll t = mod_pow(x, a / 2);
    return (t * t) % MOD;
}
 
int main() {
    ll n; cin >> n;
 
    ll ans = mod_pow(10, n) - 2 * mod_pow(9, n) + mod_pow(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl;
 
 
    return 0;
}

Measured memory_bytes: 3604
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n,k;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>k;
    
    if(k == 1)cout<<0<<endl;
    else cout<<n - (k-1) - 1<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
function Main(input) {
    input = input.split(" ");
    var a = parseInt(input[0], 10);
    var b = parseInt(input[1], 10);
    var first = a > b ? a : b;
    var amari_first = a > b ? b : a;
    var second = (first - 1) > amari_first ? (first - 1) : amari_first;
    console.log('%s', first + second);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60; 
#define 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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a.at(i);
	}
	cout << string(w+2,'#') << endl;
	for (int i = 0; i < h; i++) {
		cout << '#' << a.at(i) << '#' << endl;
	}
	cout << string(w + 2, '#') << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
#define ll long long
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
ll h,n;

ll a[1003],b[1003];

ll dp[10004];



int main(){
	fastio();
	cin>>h>>n;

	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(int i=0;i<=h;i++) dp[i] = INF;

		dp[0]=0;
	for(int i=1;i<=h;i++){
		for(int j=0;j<n;j++){
			//dp[i] = min(dp[i],b[j]+(i-a[j]));
			if(i-a[j]<=0){
				dp[i] = min(dp[i],b[j]);
			}
			else dp[i] = min(dp[i],b[j]+dp[i-a[j]]);
		}
	}
	cout<<dp[h];
}

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

vector<int> yoko[2020];
vector<int> tate[2020];
string S;

int main(){
    int H, W; cin >> H >> W;

    for(int i=0; i<H; i++){
        yoko[i].push_back(-1);
    }
    for(int j=0; j<W; j++){
        tate[j].push_back(-1);
    }

    for(int i=0; i<H; i++){
        cin >> S;
        for(int j=0; j<W; j++){
            if(S.at(j)=='#'){
                yoko[i].push_back(j);
                tate[j].push_back(i);
            }
        }
    }

    for(int i=0; i<H; i++){
        yoko[i].push_back(W);
    }
    for(int j=0; j<W; j++){
        tate[j].push_back(H);
    }



    //ソートは終わっている
    int ans=0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            int b1= *lower_bound(yoko[i].begin(),yoko[i].end(),j) - *(upper_bound(yoko[i].begin(),yoko[i].end(),j)-1);
            int c1= *lower_bound(tate[j].begin(),tate[j].end(),i) - *(upper_bound(tate[j].begin(),tate[j].end(),i)-1);
            if(b1!=0 && c1!=0){
                ans = max(ans,b1-1+c1-1-1);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 34432
#include<stdio.h>
#include<bits/stdc++.h>
int main(void)
{
    int x,y;
    while(1)
    {
        scanf("%d %d",&x,&y);
        if ( x==0 && y==0 )
        {
            break ;
        }
        else
        {
            printf("%d %d\n",std::min(x,y),std::max(x,y));
        }
    }
    return 0;
}

Measured memory_bytes: 3208