akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void slove() {
	ll a,b;
	cin >> a >> b;
	cout << a*b << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	slove();

	return 0;
}

Measured memory_bytes: 3648
fun main(args:Array<String>):Unit {
    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val nums = readLine()!!.trim().split(' ').map(String::toInt)
    val pos = nums.indexOf(1)
    println((n + k - 3) / (k - 1))
}

Measured memory_bytes: 47736
#include <bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  string s,t;
  lol n,ans=1000000,x[1000],co,ma=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i];
    if(ma<x[i]) ma=x[i];
  }
  for(int i=0;i<=ma;i++){
    co=0;
    for(int j=0;j<n;j++){
      co+=(x[j]-i)*(x[j]-i);
    }
    if(co<ans) ans=co;
  }
  cout<<ans<<"\n";
  return(0);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;


int dig(int n){
    int cnt = 0;
    while(n > 0){
        cnt++;
        n /= 10;
    }

    return cnt;
}

int32_t main(){
    FAST;

    int n;  cin >> n;
    int ans =0;

    for(int x=1;x<=n;x++){
        if(dig(x) & 1) ans++;
    }

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


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

typedef long long ll;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    
    if (B > N) {
        cout << (A*N)/B - A * (N/B) << endl;
    } else {
        cout << (A*(B-1))/B - A * ((B-1)/B) << endl;
    }
}


Measured memory_bytes: 3628
import sys
import math
input = sys.stdin.readline

N = int(input())

#a, b, c = (int(i) for i in input().split())  
P = [int(i) for i in input().split()] 
#e = [[int(i) for i in input().split()] for i in range(n)] 

minnum = P[0]
count = 1
for i in range(1, N):
    if minnum >= P[i]:
        count+=1
        minnum = P[i]
    else:
        pass

print(count)


Measured memory_bytes: 70992
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    rep(i, 1, 50001) {
        if(i * 108 / 100 == N) {
            output(i);
            return 0;
        }
    }
    output(":(");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using static System.Math;
using Debug = System.Diagnostics.Debug;

static class P
{
    static void Main()
    {
        var r = int.Parse(Console.ReadLine());
        Console.WriteLine(3 * r * r);
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, m;
llong a[100005];
pair<llong, llong> ca[100005];
llong sum;

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

    for (int i = 0; i < m; i++) {
        llong b, c;
        cin >> b >> c;

        ca[i] = {c, b};
    }

    sort(a, a + n);
    sort(ca, ca + m, greater<>());

    int i, j;
    for (i = j = 0; i < n; i++) {
        if (j >= m) {
            sum += a[i];
        }
        else if (ca[j].first > a[i]) {
            sum += ca[j].first;
            ca[j].second--;
            if (ca[j].second == 0) j++;
        }
        else {
            sum += a[i];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 2560
def sunuke_sum(arg):
    sum_digit = 0
    for char in arg:
        sum_digit += int(char)
    return sum_digit


input_num = int(input())

sunuke_dict = {}

min_sunuke_div = 10 ** 20
for d in reversed(range(1, 16)):
    for n in reversed(range(10, 1000)):
        i = n * (10 ** d) + (10 ** d - 1)
        sunuke_div = i / sunuke_sum(str(i))
        sunuke_dict[i] = sunuke_div

for i in reversed(range(1, 110)):
    sunuke_div = i / sunuke_sum(str(i))
    sunuke_dict[i] = sunuke_div

sunuke_sorted = sorted(sunuke_dict.items())
sunuke_list = []

for value, div_value in reversed(sunuke_sorted):
    if min_sunuke_div >= div_value:
        sunuke_list.append(value)
        min_sunuke_div = div_value

sunuke_list.reverse()

for i in range(0, input_num):
    print(str(sunuke_list[i]))

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vi dp;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    cout << fixed << setprecision(15);

    int n; cin >> n;
    dp.resize(n+1, inf);
    dp[0] = 0;
    vi nums;
    nums.push_back(1);
    for(int i = 6; i <= 100000; i *= 6) {
        nums.push_back(i);
    }
    for(int i = 9; i <= 100000; i *= 9) {
        nums.push_back(i);
    }

    for(int i = 0; i < n; ++i) {
        for(auto j : nums) {
            if(i+j>n) continue;
            chmin(dp[i+j], dp[i] + 1);
        }
    }
    cout << dp[n] << '\n';
}

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

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


void solve(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B){
    ll t = 0;
    rep(i,M) t += B[i];
    ll j = M;
    ll ans = 0;

    rep(i,N+1){
        while(0 < j && K < t){
            j--;
            t -= B[j];
        }
        if(K < t) break;
        ans = max(ans, i+j);
        if(i == N+1) break;
        t += A[i];
    }
    cout << ans << endl;
}

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


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

int main() {
  int N;
  cin >> N;
  
  int X[N];
  int sum = 0;
  for(int i=0; i<N; i++) {
    cin >> X[i];
    sum += X[i];
  }
  
  int mean = sum / N;
  int power1 = 0;
  int power2 = 0;
  for(int j=0; j<N; j++) {
    power1 += (X[j] - mean) * (X[j] - mean);
    power2 += (X[j] - mean - 1) * (X[j] - mean - 1);
  }
  if(power1 < power2) {
    cout << power1 << endl;
  } else {
    cout << power2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import sys
from itertools import combinations
n = int(sys.stdin.readline())
lst = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]


def dist(a, b):
  x = a[0] - b[0]
  y = a[1] - b[1]
  dist = (x ** 2 + y ** 2) ** 0.5
  return dist

dist_lst = [dist(i[0], i[1]) for i in combinations(lst, 2)]
print(2 * sum(dist_lst) / n)

  


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int num, j;
    int oishisa[50];
    int sum = 0;

    cin >> num;
    rep(i, num)
    {
        cin >> oishisa[i];
    }

    rep(i, num - 1)
    {
        for (j = i + 1; j < num; j++)
        {
            sum = oishisa[i] * oishisa[j] + sum;
        }
    }

    cout << sum << endl;

    return 0;
}


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

#define INF int(1e9+5)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=1005;
const int maxm=2005;
const int mod=1e9+7;
int n,m,cnt1,cnt2,ans;
ll x,sum;
int u[maxm],v[maxm],w[maxm],ord[maxm],pw2[maxm];
int par[maxn],dep[maxn],pare[maxn];
bool in[maxm];
vector<pii>edge[maxn];
bool cmp(int a,int b){
	return w[a]<w[b];
}

namespace Dsu{
	int f[maxn];
	void init(){
		REP(i,n)f[i]=i;
	}
	int find(int x){
		return f[x]==x?x:f[x]=find(f[x]); 
	}
}
void dfs(int x,int p,int d,int pe){
	par[x]=p;
	dep[x]=d;
	pare[x]=pe;
	rep(i,int(edge[x].size()))
		if(edge[x][i].fst!=p)dfs(edge[x][i].fst,x,d+1,edge[x][i].snd);
}

int main(){
	scanf("%d%d%lld",&n,&m,&x);
	pw2[0]=1;
	REP(i,m)pw2[i]=2LL*pw2[i-1]%mod;
	REP(i,m){
		scanf("%d%d%d",&u[i],&v[i],&w[i]);
		ord[i]=i;
	}
	sort(ord+1,ord+1+m,cmp);
	Dsu::init();
	REP(i,m){
		int uu=Dsu::find(u[ord[i]]),vv=Dsu::find(v[ord[i]]);
		if(uu==vv)continue;
		in[ord[i]]=true;
		sum+=w[ord[i]];
		edge[u[ord[i]]].pb(mp(v[ord[i]],ord[i]));
		edge[v[ord[i]]].pb(mp(u[ord[i]],ord[i]));
		Dsu::f[uu]=vv;
	}
	if(sum==x)ans=1LL*(pw2[n-1]-2+mod)*pw2[m-n+1]%mod;
	dfs(1,0,0,0); 
	REP(i,m)if(!in[i]){
		int xx=u[i],yy=v[i],cur=0;
		if(dep[xx]<dep[yy])swap(xx,yy);
		while(dep[xx]>dep[yy])cur=max(w[pare[xx]],cur),xx=par[xx];
		while(xx!=yy){
			cur=max(w[pare[xx]],max(w[pare[yy]],cur));
			xx=par[xx];yy=par[yy];
		}
		if(sum-cur+w[i]==x)cnt1++;
		else if(sum-cur+w[i]>x)cnt2++; 
	}
	ans+=2LL*(pw2[cnt1]-1+mod)%mod*pw2[cnt2]%mod;
	if(ans>=mod)ans-=mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int a[200000];
int b[200000];
int main(){
	int n,k,c;
	string s;
	cin>>n>>k>>c>>s;
	int now=0;
	for(int i=0;i<k;i++){
		while(s[now]=='x'){
			now++;
		}
		a[i]=now;
		now+=c+1;
	}
	now=n-1;
	for(int i=k-1;i>=0;i--){
		while(s[now]=='x'){
			now--;
		}
		b[i]=now;
		now-=c+1;
	}
	for(int i=0;i<k;i++){
		if(a[i]==b[i]){
			cout<<a[i]+1<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define pi acos(-1)
#define eps 0.000001
#define inf (1e18 + 7)
using namespace std;

long long a, b;

int main()
{
    scanf("%lld%lld", &a, &b);
    long long ans = min(a, b / 2);
    a -= ans;
    b -= ans * 2;
    if(b > 0)
        ans += b / 4;
    printf("%lld\n", ans);
    return 0;
}


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

#define fo(i, n) for(ll i = 0; i < n; i++)
#define of(i, n) for(ll i = n - 1; i >= 0; i--)
#define ll long long
#define vec vector<ll>
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)


ll mod= 1e9+7;

#define umap unordered_map

string t;

ll sub(string s)
{
    ll l=0,h=s.length();
    ll j=0;
    for (int i=0; i<s.length()&&j<t.length(); i++)
       if (t[j] == s[i])
         j++;

    return (j==t.length());
}

ll check(ll n, string s)
{
    ll l,h;
    l=0;h=n-1;
    while(h<s.length()){
        if(sub(s.substr(l,h))) return 1;
        l++;h++;
    }
    return 0;
}

ll ab(ll x)
{
    if(x<0) x*=-1;
    return x;
}
int main()
{
    fio;
    ll n;
    cin>>n;
    vec a(n),b(n),c(n);
    fo(i,n) {cin>>a[i]>>b[i]>>c[i];}
    ll x,y,z,xx,yy,zz;
    x=y=z=0;
    fo(i,n)
    {
        xx = a[i] + max(y,z);
        yy = b[i] + max(x,z);
        zz = c[i] + max(x,y);
        x=xx;y=yy;z=zz;

    }
    cout<<max(z,max(x,y));

}






Measured memory_bytes: 2560
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

const (
	INFTY = 1 << 32
)

type Graph [][]int

func (g *Graph) floyd(n int) {
	for k := 0; k < n; k++ {
		for i := 0; i < n; i++ {
			if (*g)[i][k] == INFTY {
				continue
			}
			for j := 0; j < n; j++ {
				if (*g)[k][j] == INFTY {
					continue
				}
				(*g)[i][j] = min((*g)[i][j], (*g)[i][k]+(*g)[k][j])
			}
		}
	}
}

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func answer(reader io.Reader) string {
	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	e, _ := strconv.Atoi(sc.Text())

	d := make(Graph, n)
	for i := 0; i < n; i++ {
		d[i] = make([]int, n)
		for j := 0; j < n; j++ {
			if i == j {
				d[i][j] = 0
				continue
			}
			d[i][j] = INFTY
		}
	}

	for i := 0; i < e; i++ {
		sc.Scan()
		u, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		v, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		c, _ := strconv.Atoi(sc.Text())
		d[u][v] = c
	}

	d.floyd(n)

	negative := false
	for i := 0; i < n; i++ {
		if d[i][i] < 0 {
			negative = true
		}
	}

	if negative {
		return fmt.Sprint("NEGATIVE CYCLE")
	}

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j != 0 {
				out.WriteString(" ")
			}
			if d[i][j] == INFTY {
				out.WriteString("INF")
				continue
			}
			out.WriteString(fmt.Sprint(d[i][j]))
		}
		out.WriteString("\n")
	}

	return strings.TrimRight(out.String(), "\n")
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 1964
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
 	
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  
  sort(a, a+3);
  
  if(a[0] == a[1] && a[2] > a[0]) cout << "YES\n";
  else cout << "NO\n";
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n>>m;
    cin>>s;
    for(int i=0;i<(int)s.size();i++){
        if(i==n){
            if(s[i]!='-'){cout<<"No"<<endl;return 0;}
        }else{
            if(s[i]>'9' || s[i]<'0'){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    string s;
    cin >> s;
    int ans = 754;
    for (int i = 0; i < s.size() - 2; i++) { 
        int num = 100*(s[i]-'0') + 10*(s[i+1]-'0') + s[i+2]-'0';
        ans = min(ans, abs(753-num));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

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

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,k,a[200010],nxt[100][200010];
	cin >> n >> k;
	for(int i = 0;i < n;i++) cin >> a[i];
	for(int i = 0;i < n;i++) nxt[0][i] = a[i] - 1;
	for(int i = 1;i < 100;i++){
		for(int j = 0;j < n;j++) nxt[i][j] = nxt[i - 1][nxt[i - 1][j]];
	}
	int pos = 0;
	for(int i = 0;i < 62;i++){
		if(k >> i & 1) pos = nxt[i][pos];
	}
	cout << pos + 1 << endl;
}


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


int N;
vector<int> a;


void input() {
    cin >> N;
    a = vector<int>(N);
    rep(i, N) cin >> a[i];
}


int main() {
    input();
    int ans = 0;
    rep(i, N) ans += a[i] - 1;
    cout << ans << endl;
}


Measured memory_bytes: 3628
import java.util.LinkedList;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	static final int INF = 2000000;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		TreeMap<Integer, LinkedList<Point>> map = new TreeMap<Integer, LinkedList<Point>>();
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w == 0 && h == 0){
				break;
			}

			
			
			Point start = null, goal = null;
			int max = 0;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					String s = sc.next();
					if(s.equals("S")){
						start = new Point(0, i, j);
						LinkedList<Point> temp = new LinkedList<Point>();
						temp.add(start);
						map.put(0, temp);
					}else if(s.equals("G")){
						goal = new Point(INF, i, j);
					}else if(s.matches("[0-9]+")){
						int num = Integer.parseInt(s);
						max = max < num ? num : max;
						if(map.containsKey(num)){
							map.get(num).add(new Point(INF, i, j));
						}else{
							LinkedList<Point> temp = new LinkedList<Point>();
							temp.add(new Point(INF, i, j));
							map.put(num, temp);
						}
					}
				}
			}
			LinkedList<Point> temp = new LinkedList<Point>();
			temp.add(goal);
			map.put(max + 1, temp);
			System.out.println(fm(map));
			map.clear();
		}
		sc.close();
	}
	static int fm(TreeMap<Integer, LinkedList<Point>> map){
		int m = 1;
		LinkedList<Point> from = map.get(0);
		LinkedList<Point> to = null;
		while(true){
			if(!map.containsKey(m)){
				break;
			}
			to = map.get(m);
//			System.out.print(m+":");
			for(Point p : to){
				for(Point s : from){
					int temp = Math.abs(p.x - s.x) + Math.abs(p.y - s.y);
					p.c = p.c > temp + s.c ? temp + s.c : p.c;
				}
//				System.out.print("[" + p.c + "]");
			}
//			System.out.println();
			from = to;
			m++;
		}		
		return map.get(m - 1).get(0).c;
	}
}
class Point{
	int c;
	int x;
	int y;
	Point(int c, int y, int x){
		this.c = c;
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 69096
#include <iostream>

using namespace std;

int main() {
   int a[3];
   cin >> a[0] >> a[1] >> a[2];
   int min = 0;
   int x[6] = { a[0] * 10 + a[1] + a[2],
   a[1] * 10 + a[0] + a[2],
   a[2] * 10 + a[0] + a[1],
   a[0] * 10 + a[2] + a[1],
   a[1] * 10 + a[2] + a[0],
   a[2] * 10 + a[1] + a[0] };
   for (int i=0;i<=5;i++) {
      if (x[i] >= min) {
         min = x[i];
      }
   }
   cout << min << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
vector<T> divisor(T x){
	vector<T> res;
	for(T i=1;i*i<=x;i++){
		if(x%i==0){
			res.push_back(i);
			if(i!=x/i){
				res.push_back(x/i);
			}
		}
	}
	return res;
}

template <class T>
bool is_prime(T x){
	for(T i=2;i*i<=x;i++){
		if(x%i==0){
			return false;
		}
	}
	return x!=1;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b;
  cin>>a>>b;
  vector<ll> ret1=divisor(a),ret2=divisor(b);
  set<ll> now;
  for(auto itr:ret1){
    now.insert(itr);
  }
  set<ll> cnt;
  for(auto itr:ret2){
    auto itr2=now.find(itr);
    if(itr2!=now.end()) cnt.insert(*itr2);
  }
  //for(auto itr:cnt) cout<<itr<<endl;
  ll ans=1;
  for(auto itr:cnt){
    if(is_prime(itr)) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a;
	cin>>a;
	cout<<a/3<<endl;
}

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

int a[104];

int main() {
	int n, x;
	scanf("%d%d",&n,&x);
	for (int i = 0; i < n; i++)
		scanf("%d",a+i);
	std::sort(a, a+n);
	for (int i = 0; i < n; i++)
		if ((x -= a[i]) < 0) {
			printf("%d\n",i);
			return 0;
		}
	printf("%d\n",n - (x>0));
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        int d = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        while (0 < a) {
            c -= b;
            if (0 < c) {
                a -= d;
            } else {
                break;
            }
        }
        boolean winTakahashi = c <= 0;
        String result = winTakahashi ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sqr(a) a*a


using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int,int> pi;


int main() {
    //ios::sync_with_stdio(0);
    //cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int h, a;
    cin >> h >> a;
    int res;
    res = h/a;
    if(h % a != 0){
        ++res;
    }
    cout << res;

}

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

int main() {
  int a, b;
  char op;

  while (cin >> a >> op >> b && op != '?') {
    if (op == '+') cout << a + b << endl;
    else if (op == '-') cout << a - b << endl;
    else if (op == '*') cout << a * b << endl;
    else if (op == '/') cout << a / b << endl;
    else if (op == '%') cout << a % b << endl;
  }

  return 0;
}

Measured memory_bytes: 3088
n,m = map(int,input().split())
ans_l,ans_r= map(int,input().split())
for i in range(m-1):
        l,r = map(int,input().split())
        ans_l = max(ans_l,l)
        ans_r = min(ans_r,r)
print(max(0,ans_r-ans_l + 1))

Measured memory_bytes: 3060
#include<cstdio>
#define N 3001
#define p 1000000007
int a[N],b[N],c[N],f[N][N],i,m,n,u,v,x,y;
int main()
{
	scanf("%d%d",&n,&m);
	for(i=x=1;i<=n;i++)scanf("%d",a+i);
	for(u=1;u<=n;u++)for(v=1;v<=n;v++)if(a[u]>a[v])f[u][v]=1;
	while(m--)
	{
		scanf("%d%d",&u,&v),(x<<=1)%=p,y=500000004ll*(f[u][v]+f[v][u])%p;
		for(i=1;i<=n;i++)b[i]=500000004ll*(f[i][u]+f[i][v])%p,c[i]=500000004ll*(f[u][i]+f[v][i])%p;
		for(i=1;i<=n;i++)f[i][u]=i==v?y:i==u?0:b[i],f[i][v]=i==u?y:i==v?0:b[i],f[u][i]=i==v?y:i==u?0:c[i],f[v][i]=i==u?y:i==v?0:c[i];
	}
	for(i=0,u=1;u<=n;u++)for(v=u;v<=n;v++)i=(i+(long long)x*f[u][v])%p;
	return 0*printf("%d\n",i);
}

Measured memory_bytes: 35328
xy = list(map(int, input().split()))
 
if 4*xy[0]-xy[1]<0 or -2*xy[0]+xy[1]<0:
    print('No')
elif 4*xy[0]-xy[1]==0 and -2*xy[0]+xy[1]==0:
    print('No')
elif (1/2*(4*xy[0]-xy[1]))%1!=0 or (1/2*(-2*xy[0]+xy[1])%1)!=0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int n; vector<int>vi;
	cin>>n;  rep(i,3*n){int a;cin>>a;vi.pb(a);}
	SORT(vi);
	ll ans=0,cnt=0;
	for(int i=3*n-2;cnt<n;i-=2){
		ans+=vi[i];
		cnt++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2420
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        double a[] = new double[n];

        for (int i = 0; i < n; i++) {
            a[i] = sc.nextDouble();
        }

        double sum = 0;
        for (int i = 0; i < n; i++) {
            sum += 1/a[i];
        }

        System.out.println(1/sum);
	}
}


Measured memory_bytes: 25172
"""
6 5
4 7 10 6 
"""
x,n = map(int, raw_input().split(' '))

ais = map(int, raw_input().split(' ')) if n else []
ais.sort()


def f(x, u, v):
	#returns the number thats closest to x within range u,v not including u and v
	if u + 1 == v: return (+float('inf'), +float('inf'))
	if u < x < v: return (0,x) 	
	if x >= v: return (abs(x - (v -1)), v-1)
	if x <= u: return (abs(x - (u +1)), u + 1)
res = (+float('inf'), +float('inf'))
ais = [-1] + ais + [102]
for u,v in zip(ais,ais[1:]):
	res = min(res , f(x,u,v))

print res[1]

Measured memory_bytes: 64416
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define df 0
using namespace std;
typedef long int li;

int main(){
  string s,t; cin >> s >> t;
  vector<vector<int>> dict(26);
  int len_s=s.length();
  for(int i=0;i<len_s;i++){
    dict.at(s.at(i)-'a').push_back(i);
  }
  if(df){
    for(int i=0;i<26;i++){
      if(dict.at(i).size()){
	int l=dict.at(i).size();
	printf("%c:",i+'a');
	for(int j=0;j<l;j++){
	  printf("%d ",dict.at(i).at(j));
	}
	cout << endl;
      }
    }
  }
  int len_t=t.length();
  li rep=0,ans=0;
  int temp=-1;
  for(int i=0;i<len_t;i++){
    int c=t.at(i)-'a';
    if(dict.at(c).empty()){
      ans=-1;
      break;
    }
    auto itr=lower_bound(dict.at(c).begin(),dict.at(c).end(),temp+1);
    if(itr==dict.at(c).end()){
      if(df) cout << " rep\n";
      rep++;
      itr=dict.at(c).begin();
    }
    temp=*itr;
    if(df) printf("%d ",temp);
  }
  if(ans>=0) ans=rep*len_s+temp+1;

  cout << ans;
}


Measured memory_bytes: 1216
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        
        for(int i = N-1; i > -1; i--){
            Console.Write(nums[i]);
            if(i != 0){
                Console.Write(' ');
            }
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 18140
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 494
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}
void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n; i>n-r; i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
const int N = 1e6 + 5, inf = 2e9, mod = 1e9 + 7;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}

int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

*/
int main()
{
   bizarre
   int n,mxm=0;
   cin>>n;
   map<string,int>mp;
   while(n--)
   {
       string s; cin>>s;
       mp[s]++;
       mxm=max(mxm,mp[s]);
   }
   for(auto it : mp)
    if(it.second==mxm)
    cout << it.first<<endl;
    return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define pb push_back
#define pp pop_back
#define int num
#pragma GCC optimize("O2")
using namespace std;
typedef long long num;
typedef long double lod;

int n,m,d;

int32_t main(){
    cout<<setprecision(15)<<fixed;
    cin>>n>>m>>d;
    int c=n-d;
    if(d!=0) c*=2;
    c*=m-1;
    cout<<c/lod(n*n)<<endl;
}


Measured memory_bytes: 256
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin[0]);
    const S = stdin[1].split(' ').map(Number);
    const T = stdin[3].split(' ').map(Number);

    const SinT = T.filter(e =>  binarySearch(e, 0, n, S));
    console.log(SinT.length);
}

function binarySearch(target, left, right, array){
    while(left < right){
        const mid = Math.floor((right + left) / 2);

        if(array[mid] === target) {
            return true;
        }
        else if(array[mid] > target) {
            right = mid;
        }
        else {
            left = mid + 1;
        }
    }
    return false;
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 34000
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1000000000
#define  pow(x) pow(10,(x)) 
typedef long long int LL;

typedef pair<pair<int,LL>,int> P;

unsigned GetDigit(unsigned num){
    return log10(num)+1;
}

int main(){
    int N,M; cin >> N >> M;
    vector<P> L(M);
    LL y;

    rep(i,M){
        cin >> L[i].first.first >> L[i].first.second ;
        L[i].second = i ;
    }

    sort(all(L));

    vector<pair <int, pair<int,int> > > L2(M);
    int temp = 1;
    int birth = 1;

    rep(j,M){
        if(L[j].first.first != temp){
            temp = L[j].first.first;
            birth = 1;
        }
        L2[j].first = L[j].second;
        L2[j].second.first = temp;
        L2[j].second.second = birth;
        birth++;
    }

    sort(all(L2));

    rep(k,M){
        /*
        vector<int> res1(6,0);
        vector<int> res2(6,0);
        */

        int num = L2[k].second.first;
        int num2 = L2[k].second.second;

        cout << setfill('0') << right << setw(6) << num ;
        cout << setfill('0') << right << setw(6) << num2 << endl;
        /*
        int keta = GetDigit(num);
        int keta2 = GetDigit(num2);
        int ten = 1;
        rep(l,keta){
            ten = 1;
            rep(x,l){
                ten *= 10;
            }
            res1[l] = num % ten;
        }
        rep(m,keta2){
            ten = 1;
            rep(y,m){
                ten *= 10;
            }
            res2[m] = num2 % ten;
        }

        rep(z,6){
            cout << res1[5-z] ;
        }
        rep(x,6){
            cout << res2[5-x] << endl;
        }
   */

    }
}

Measured memory_bytes: 4992
K = int(input())
A,B = map(int,input().split())

con = 0
ans = 0

for i in range(1,144):
    ans = K * i

    if(A<=ans and ans<=B):
        print("OK")
        break

    else:
        con += 1
        continue


        

if(con==143):
    print("NG")


Measured memory_bytes: 61616
#include<iostream>
using namespace std;
int main()
{
    char X,Y;
    cin>>X>>Y;
    if(X<Y)
    {
        cout<<"<"<<endl;
    }
    if(X>Y)
    {
        cout<<">"<<endl;
    }
    else if(X==Y)
    {
        cout<<"="<<endl;
    }

}


Measured memory_bytes: 3620
X, Y, Z, K = map(int, input().split())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))[::-1]

A_B = []
for a in A:
    for b in B:
        A_B.append(a + b)

A_B = sorted(A_B)[::-1][:K]

ans = []
for a_b in A_B:
    for c in C:
        ans.append(a_b + c)

for a in sorted(ans)[::-1][:K]:
    print(a)

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){


}

void solve(){

    int n;
    cin >> n;
    vector<int> A,B;
    for(int i=1;i<=n;i++){
        int x,y;
        cin >> x >> y;
        A.push_back(x+y);
        B.push_back(x-y);
    }
    sort(all(A));
    sort(all(B));
    cout << max( A[n-1] - A[0] , B[n-1] - B[0] );

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 5108
import heapq

def intoheap(l):
    for i in l:
        heapq.heappush(Q, -i)
        
n,m = map(int,input().split())
P = {i:[] for i in range(1,m+1)}
Q = []
ans = 0
for _ in range(n):
    a,b = map(int, input().split())
    if a > m:
        continue
    P[a].append(b)
        

for i in range(1,m+1):
    if i in P.keys():
        intoheap(P[i])
    if Q == []:
        continue
    ans += -heapq.heappop(Q)
    
print(ans)

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

struct Node {
    int key;
    Node *prev, *next;
};

Node *dllist;

Node * lisSearch(int key) {
    Node *cur = dllist -> next;
    //if (curr == dllist) circle is over without result
    while (cur != dllist && cur -> key != key) {
        cur = cur -> next;
    }
    return cur;
}

void init () {
    dllist = new Node;
    dllist -> next = dllist;
    dllist -> prev = dllist;
}

void printList() {
    Node *cur = dllist -> next;
    int isf = 0;
    while (1) {
        if (cur == dllist) break;
        if (isf++ > 0) (std::printf(" "));
        std::printf("%d", cur -> key);
        cur = cur -> next;
    }
    printf("\n");
}

void insert(int key) {
    Node *x = new Node;
    x -> key = key;
    x -> next = dllist -> next;
    dllist -> next -> prev = x;
    dllist -> next = x;
    x -> prev = dllist;
}

void deleteNode(Node *t) {
    if (t == dllist) return;
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst() {
    deleteNode(dllist -> next);
}

void deleteLast() {
    deleteNode(dllist -> prev);
}

void deleteKey(int key) {
    deleteNode(lisSearch(key));
}


int main()
{
    int key, n;
    char com[20];
    init();
    std::scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        std::scanf("%s", com);
        if (com[0] == 'i') {
            std::scanf("%d", &key);
            insert(key);
        }
        else if (com[0] == 'd') {
            if (strlen(com) > 6) {
                if (com[6] == 'F') {
                    deleteFirst();
                } else if (com[6] == 'L') {
                    deleteLast();
                }
            } else {
                std::scanf("%d", &key);
                deleteKey(key);
            }
        }
    }

    printList();


    return 0;
}



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

const int zo[5]={1,2,12,112,1112};
const int ti[5]={1,11,111,1111,11111};

int main(){
    vector<int> a(200001);

    rep(i,9) a[i+1]=i+1;

    for(int i=10; i<=200000; i++){
        int ma,se,keta;
        rep(j,5){
            if(i<pow(10,j+2)){
                keta=j+2;
                se=i/pow(10,j+1);
                break;
            }
        }
        ma=i%10;
        if(ma==0){
            a[i]=a[i-1];
            continue;
        }
        int cen=(i-(se*pow(10,keta-1))-ma)/10;
        if(ma==se){
            a[i]=a[i-1]+(2*(cen+zo[keta-2])+1);
            continue;
        }
        if(ma<se){
            a[i]=a[i-1]+(2*ti[keta-2]);
            continue;
        }
        if(ma>se){
          if(keta>=3){
          a[i]=a[i-1]+(2*ti[keta-3]);
          }
          else a[i]=a[i-1];
          continue;
        }
    }


   int n; cin >> n;
    cout << a[n] << endl;
return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#define int long long
using namespace std;

int h, w;

signed main() {
	cin >> h >> w;
	
	int ans = 1145141919810;
	
	for (int a = 1; a < w; a++) {
		int b = h / 2;
		int Min = min({a * h, b * (w - a), (h - b) * (w - a)});
		int Max = max({a * h, b * (w - a), (h - b) * (w - a)});
		ans = min(ans, Max - Min);
	}
	
	for (int b = 1; b < h; b++) {
		int a = w / 2;
		int Min = min({b * w, a * (h - b), (w - a) * (h - b)});
		int Max = max({b * w, a * (h - b), (w - a) * (h - b)});
		ans = min(ans, Max - Min);
	}
	
	if (h >= 3) {
		ans = min(ans, w * (h % 3 != 0));
	}
	if (w >= 3) {
		ans = min(ans, h * (w % 3 != 0));
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
object Main extends App {
  @scala.annotation.tailrec
  def loop(a: Int, b: Int, c: Int, count: Int): Boolean =
    if (a < b && b < c) true
    else if (count == 0) false
    else if (b <= a) loop(a, b * 2, c, count - 1)
    else loop(a, b, c * 2, count - 1)

  val sc = new java.util.Scanner(System.in)
  val A, B, C, K = sc.nextInt()
  println(if (loop(A, B, C, K)) "Yes" else "No")
}


Measured memory_bytes: 55360
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] ds = new int[n];
		
		for(int i=0; i<ds.length; i++) {
			ds[i] = sc.nextInt();
		}
		sc.close();
		
		Arrays.sort(ds);
		
		System.out.println(ds[n-1] - ds[0]);

	}

}


Measured memory_bytes: 21716
#include <iostream>
#include <limits>

using namespace std;

int main() {
    int n, p;
    cin >> n;
    int answer = 0;
    int max = numeric_limits<int>::max();
    for (int i = 0; i < n; ++i) {
        cin >> p;
        if (p < max) {
            max = p;
            ++answer;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 256
while True:
   s = input()
   if s == "END OF INPUT": break
   
   s += " " 
   #print(s)
   
   c = 0
   for i in range(len(s)):
      #print(s[i])
      if s[i] == ' ':
         print(c, end = "")
         c = 0
         continue
      c += 1
   print("")


Measured memory_bytes: 5552
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    ll n, m;
    cin >> n >> m;

    vector<vector<int>> adj(n);
    vector<int> h(n);

    for (int &x : h)
        cin >> x;

    for (int i = 0; i < m; i++)
    {
        int p, q;
        cin >> p >> q, --p, --q;

        adj[p].push_back(q);
        adj[q].push_back(p);
    }

    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        int ok = 1;

        for (int x : adj[i])
        {
            ok &= h[x] < h[i];
        }
        ans += ok;
    }
    cout << ans << endl;
}

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

int main(){
  int ans=0;
  int n; cin>> n;
  int a[103];
  for(int i=1; i<=n; i++){
  	cin >> a[i];
    if(i%2==1 && a[i]%2==1) ans++;
  }
  cout << ans;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>

#define INF 200000000

using namespace std;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    if (a <= b)
    {
        if (a + w >= b)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            cout << b - (a + w) << endl;
            return 0;
        }
    }
    else
    {
        if (b + w >= a)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            cout << a - (b + w) << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
/*

We walked with our shoulders in line,
Laughing about things that didn't matter as we looked onward toward the same dream.
If I listen carefully, I can still hear it:
Your voice, staining this city orange.

When you're not around, I'm so bored,
But when I say I'm lonely, you just laugh at me.
I just keep counting up the things I have left,
That shine brightly and never fade away.

Like the sky after the rain lets up... like clearing up one's heart...
I remember your smile; it floats up in my mind and I can't help but smile.
Surely, just as we were that day... like innocent children,
We'll run through the passing seasons, seeing each of our many tomorrows.

Whenever I was alone and started to feel uneasy...
On nights I didn't want to sleep, we'd just go on talking.

I wonder what you'll go on to see from here,
And what I'll see right here.
I'll try to entrust my tears,
To this city where the setting sun stains everything orange.

This single love was born among a million rays of light;
Even if you never change... even if you happen to change... you're you, so I'm not worried.
Someday we'll both become adults and meet wonderful people;
At that time, I hope we can bring along our irreplaceable families and meet here again...

Like the sky after the rain lets up... like clearing up one's heart...
I remember your smile; it floats up in my mind and I can't help but smile.
This single love was born among a million rays of light...
We run through the passing seasons, seeing each of our many tomorrows;
Choosing from each of our many dreams.

*/

#include <bits/stdc++.h>

using namespace std;

int main() {
  long long x, y;
  scanf("%lld %lld", &x, &y);
  int ans = 0;
  while (x <= y) {
    ans++;
    x *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256