akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;

inline char b36(int i)
{
	return (i < 10) ? ('0' + i) : ('A' + (i - 10));
}

int main(void)
{
	for (;;)
	{
		int n, m, q;
		cin >> n >> m >> q;
		if (!n)break;
		vector<ULL>hash1(n), hash2(m);
		vector<bool>flag(n);
		for (int k = 0; k < q; ++k)
		{
			string s, t;
			cin >> s >> t;
			for (int i = 0; i < n; ++i)
			{
				flag[i] = flag[i] ^ (s[i] == '1');
				hash1[i] *= 2;
				hash1[i] += flag[i];
			}
			for (int j = 0; j < m; ++j)
			{
				hash2[j] *= 2;
				hash2[j] += (t[j] == '1');
			}
		}
		map<ULL, int>dic;
		for (int i = 0; i < n; ++i)
		{
			if (dic.count(hash1[i]))
			{
				dic[hash1[i]] = -1;
			}
			else
			{
				dic[hash1[i]] = i;
			}
		}
		for (int j = 0; j < m; ++j)
		{
			int val = dic[hash2[j]];
			if (val < 0)
			{
				cout << '?';
			}
			else
			{
				cout << b36(val);
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int  ans=0;
		int  X= sc.nextInt();
		int  A= sc.nextInt();
		if(X<A){
			System.out.println(ans);}
		else{ans=10;	
			System.out.println(ans);}
		}
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	long long n, ans = 0; cin >> n; n *= 4;
	b = min(b, 2 * a);
	c = min(c, 2 * b);
	d = min(d, 2 * c);
	ans += (n / 8) * d; n %= 8;
	ans += (n / 4) * c; n %= 4;
	ans += (n / 2) * b; n %= 2;
	ans += n * a; 
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
read A
read B
read C
read X

count=0

for (( a = 0; a <= A; a++ )); do
    for (( b = 0; b <= B; b++ )); do
        for (( c = 0; c <= C; c++ )); do
            ((a * 500 + b * 100 + c * 50 == X)) && : $((++count))
        done
    done
done

echo ${count}


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

using namespace std;
#define pb push_back
const int mn=2e5+5;

int n,m;

char s[mn];

int a[mn],b[mn];
bool vis[mn];
vector<int> g[mn];

int main(){
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=m;i++) {
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].pb(v);
		g[v].pb(u);
		if (s[u]=='A') a[v]++;
		else b[v]++;
		if (s[v]=='A') a[u]++;
		else b[u]++;
	}

	queue<int> q;
	for(int i=1;i<=n;i++){
        if (a[i]==0||b[i]==0) q.push(i),vis[i]=1;
	}
    while(!q.empty()){
		int u=q.front();q.pop();
		for(auto &i:g[u]){
			if (s[u]=='A'){
				a[i]--;
				if (!vis[i]&&a[i]==0) q.push(i),vis[i]=1;
			}
			else{
				b[i]--;
				if (!vis[i]&&b[i]==0) q.push(i),vis[i]=1;
			}
		}
    }
    int ans=0;
    for(int i=1;i<=n;i++) if (!vis[i]) ans=1;
    if (ans) puts("Yes");
    else puts("No");

    return 0;
}


Measured memory_bytes: 12672
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

int n,m;
pair<int,int> p[1005];
int c[1005];

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

  int dist[104][104];

  for(int i=0;i<104;i++)for(int j=0;j<104;j++)dist[i][j] = -1;

  for(int i=0;i<m;i++){
    int xx,yy;cin>>xx>>yy;
    int cc;cin>>cc;
    xx--;
    yy--;
    p[i] = make_pair(xx,yy);
    c[i] = cc;
    dist[xx][yy] = cc;
    dist[yy][xx] = cc;
  }

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(dist[i][k] == -1) continue;
        if(dist[k][j] == -1) continue;
        if(dist[i][j] == -1){
          dist[i][j] = dist[i][k] + dist[k][j];
        } else {
          dist[i][j] = min(dist[i][j],dist[i][k] + dist[k][j]);
        }
      }
    }
  }
  int ans = 0;
  for(int i=0;i<m;i++){
    if(c[i] > dist[p[i].first][p[i].second]) ans++;
  }
  cout<<ans<<endl;

  return 0;
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   Int dist[300][300];
   void solve() {
      Int inf = 1LL << 53;
      for(Int i = 0; i < 300; ++i) {
         for(Int k = 0; k < 300; ++k) {
            dist[i][k] = inf;
         }
         dist[i][i] = 0;
      }
      Int n, m, r; scan(n, m, r);
      LI rs(r); scan(rs);
      for(Int i = 0; i < m; ++i) {
         Int a, b, c; scan(a, b, c);
         dist[a][b] = dist[b][a] = c;
      }
      for(Int k = 1; k <= n; ++k) {
         for(Int i = 1; i <= n; ++i) {
            for(Int j = 1; j <= n; ++j) {
               dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
            }
         }
      }
      std::sort(rs.begin(), rs.end());
      Int res = inf;
      do {
         Int t = 0;
         for(Int i = 1; i < r; ++i) {
            t += dist[rs[i-1]][rs[i]];
         }
         res = std::min(res, t);
      } while( next_permutation(rs.begin(), rs.end()) );
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 960
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 x, k, d, t;
int main() {
    scanf("%lld%lld%lld", &x, &k, &d);
    x = abs(x);
    t = x / d;
    if (t >= k) {
        printf("%lld", x - k * d);
        return 0;
    }
    k -= t;
    x %= d;
    printf("%lld", k & 1 ? d - x : x);
}

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

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

  while(true) {
    for (int i=0; i<n; i++) {
      if (array[i] % 2 != 0)
        goto OUT;
      else
        array[i] = array[i] / 2;
    }
    counter++;
  }
OUT:
  cout << counter << endl;
  return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	long long k;
	cin>>n>>k;
	vector<long long> p,m;
	long long z=0LL,a;
	for (int i = 0; i < n; ++i)
	{
		cin>>a;
		if (a<0)
		{
			m.push_back(a);
		}
		else if (a>0)
		{
			p.push_back(a);
		}
		else
		{
			++z;
		}
	}
	sort(p.begin(), p.end());
	sort(m.begin(), m.end());
	if (k<=(long long)p.size()*m.size())
	{
		long long ng=-1e18-5,ok=-1;
		while (ok-ng>1)
		{
			long long mid=(ok+ng)/2,cnt=0,b;
			for (int i = 0; i < p.size(); ++i)
			{
				b=(mid-p[i]+1)/p[i];
				cnt+=upper_bound(m.begin(), m.end(),b)-m.begin();
			}
			if (cnt>=k)
			{
				ok=mid;
			}
			else
			{
				ng=mid;
			}
		}
		cout<<ok<<endl;
		return 0;
	}
	k-=(long long)p.size()*m.size();
	if (z>0)
	{
		if (k<=(z*(n-z)+z*(z-1)/2))
		{
			cout<<"0\n";
			return 0;
		}
		k-=z*(n-z)+z*(z-1)/2;
	}
	for (int i = 0; i < m.size(); ++i)
	{
		m[i]*=-1;
	}
	reverse(m.begin(), m.end());
	long long ng=0,ok=1e18+5;
	while (ok-ng>1)
	{
		long long mid=(ok+ng)/2,cnt=0,b;
		for (int i = 0; i < p.size(); ++i)
		{
			b=mid/p[i];
			long long tmp=upper_bound(p.begin(), p.end(),b)-p.begin();
			if (i<tmp)
			{
				--tmp;
			}
			cnt+=tmp;
		}
		for (int i = 0; i < m.size(); ++i)
		{
			b=mid/m[i];
			long long tmp=upper_bound(m.begin(), m.end(),b)-m.begin();
			if (i<tmp)
			{
				--tmp;
			}
			cnt+=tmp;
		}
		cnt/=2;
		if (cnt>=k)
		{
			ok=mid;
		}
		else
		{
			ng=mid;
		}
	}
	cout<<ok<<endl;
	return 0;
}


Measured memory_bytes: 2420
a,b,c = map(int,input().split())

k = int(input())


c = c *(2 ** k)

l = 0
m = k
while not(a < b and b < c) and (l >= 0 and m >= 0):
    l += 1
    m -= 1
    b *= 2
    c /= 2

if l >= 0 and m >= 0 and a < b and b < c:
    print("Yes")
else:
    print("No")


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N),C(N-1);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
    }
    for(int i=0;i<N;i++) cin >> B[i];
    for(int i=0;i<N-1;i++) cin >> C[i];
    int ans = 0;
    for(int i=0;i<N;i++){
        ans += B[A[i]];
        if(i!=N-1 && A[i+1]==A[i]+1) ans += C[A[i]];
        //cerr << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define lli long long
# define mod 1000000007
 
lli noOfPaths(int mat[][1000], int h, int w){
	lli dp[h][w];
	memset(dp, 0, sizeof(dp));

	for(int i = h - 1; i >= 0; i--){
		for(int j = w - 1; j >= 0; j--){
			if(i == h - 1 && j == w - 1){
				dp[i][j] = 1;
			}else if(mat[i][j] == 0){
				if(i + 1 < h){
					dp[i][j] += dp[i + 1][j];
					dp[i][j] %= mod;
				}
				if(j + 1 < w){
					dp[i][j] += dp[i][j + 1];
					dp[i][j] %= mod;
				}
			}
		}
	}
	
	return dp[0][0];
}
 

void solve(){
	int h, w;
	cin >> h >> w;
	int i, j, mat[h][1000];
	for(i = 0; i < h; i++){
		for(j = 0; j < w; j++){
			char c;
			cin >> c;
			if(c == '.') mat[i][j] = 0;
			else mat[i][j] = 1;
		}
	}

	lli x = noOfPaths(mat, h, w);
	cout << x;
}
 
int main(){
	solve();
}


Measured memory_bytes: 11904
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;
  std::vector<std::string> s(n);
  rep(i,0,n){
    std::cin>>s[i];
    std::vector<int> temp(10);
    rep(j,0,10)temp[j]=(s[i][j]-'a');
    sort(all(temp));
    rep(j,0,10)s[i][j]=(char)(temp[j]+'a');
  }

  sort(all(s));

  std::string now="";
  ll ans=0,temp=0;

  rep(i,0,n){
    if(now!=s[i]){
      ans+=temp*(temp-1)/2;
      now=s[i];
      temp=1;
    }else{
      temp++;
    }
  }

  ans+=temp*(temp-1)/2;
  std::cout<<ans;
  return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

int main(){
    int c[3][3];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    bool f=true;
    for(int i=0;i<2;i++){
        for(int k=i+1;k<3;k++){
            for(int j=0;j<2;j++){
                if((c[i][j]-c[i][j+1])!=(c[k][j]-c[k][j+1])){
                    f=false;
                }
            }
        }
    }
    if(f){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    


    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	int n;
	double w, h;
	while (scanf("%d,%lf,%lf\n", &n, &w, &h) != EOF)
	{
		if (w/(h*h) >= 25)
			printf("%d\n", n);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;

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

  int N, M, R;
  cin >> N >> M >> R;
  int W[R];
  rep(i,R){
    cin >> W[i];
    --W[i];
  }
  sort(W,W+R);
  int A[N][N];
  rep(i,N){
    rep(j,N){
      if(i == j) A[i][j] = 0;
      else A[i][j] = INF;
    }
  }
  rep(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    A[a][b] = min(A[a][b], c);
    A[b][a] = min(A[a][b], c);
  }
  rep(i,N){
    rep(j,N){
      rep(k,N){
        A[j][k] = min(A[j][k], A[j][i] + A[i][k]);
      }
    }
  }
  int ans = INF;
  do{
    int ans1 = 0;
    rep(i,R-1){
      ans1 += A[W[i]][W[i+1]];
    }
    ans = min(ans, ans1);
  }while(next_permutation(W,W+R));

  cout << ans << endl;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int X = sc.nextInt();

    if ((X - A) <= B && A <= X) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }
}

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

int main() {
  ll q;
  cin >> q;
  while(q--) {
    ll a,b;
    cin >> a >> b;
    if(b<a) {
      a+=b;
      b=a-b;
      a=a-b;
    }
    ll c=sqrt(a*b);
    if(a!=b) {
      ll ans=2*c-3;
      if(c*c<a*b) ans++;
      if(c*(c+1)<a*b) ans++;
      cout << ans << endl;
    }
    else cout << 2*(c-1) << endl;
  }
}

Measured memory_bytes: 3640
<?php
fscanf(STDIN, "%d%d",$N, $M);
$aArray = $bArray = [];
for($i = 0; $i < $M; $i++){
    fscanf(STDIN, "%d%d",$a, $b);
    if($a == 1){
        $bArray[]=$b;
    }
    if($b == $N){
        $aArray[]=$a;
    }
}
echo count(array_intersect($aArray,$bArray)) ? "POSSIBLE" : "IMPOSSIBLE";

Measured memory_bytes: 24180
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        long dp[][] = new long[n + 1][2];
        dp[1][1] = arr[1];
        for (int i = 2; i <= n; i++) {
            if (i % 2 == 0) {
                if (i > 2) {
                    dp[i][0] = Math.max(dp[i - 3][1], dp[i - 2][0]) + arr[i];
                } else {
                    dp[i][0] = dp[i - 2][0] + arr[i];
                }
            } else {
                dp[i][0] = Math.max(dp[i - 3][0], dp[i - 2][0]) + arr[i];
                dp[i][1] = dp[i - 2][1] + arr[i];
            }
        }
        long total;
        if (n % 2 == 0) {
            total = Math.max(dp[n - 1][1], dp[n][0]);
        } else {
            total = Math.max(Math.max(dp[n][0], dp[n - 1][0]), dp[n - 2][1]);
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 64996
#include "bits/stdc++.h"

using namespace std;
using ll=long long;
using ull=unsigned long long;

typedef pair<int,int>Pi;
typedef pair<long long,long long>P;
typedef pair<long long,P>PP;
typedef pair<P,P>PPP;

const long long MOD=1e9+7;
const long long INF=5e18;
const int di[4]={1,0,-1,0};
const int dj[4]={0,1,0,-1};

#define fr first
#define sc second
#define pb push_back
#define eb emplace_back
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()

struct segtree{
	private:
	int n;
	vector<ll>node;
	public:
	segtree(vector<ll>v){
		int sz=v.size();n=1;
		while(sz>n)n*=2;
		node.resize(2*n+1,0);
		for(int i=0;i<sz;i++)node[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)node[i]=max(node[i*2+1],node[i*2+2]);
	}
	void update(int x,ll val){
		x=x+n-1;
		node[x]=val;
		while(x>0){
			x=(x-1)/2;
			node[x]=max(node[x*2+1],node[x*2+2]);
		}
		return;
	}
	ll getmax(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0)r=n;
		if(r<=a||b<=l)return 0;
		if(a<=l&&r<=b)return node[k];
		ll vl=getmax(a,b,k*2+1,l,(l+r)/2);
		ll vr=getmax(a,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
};

ll n,h[200010];
ll a[200010];
vector<ll>z,H,v;

void input(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>h[i];
		z.eb(h[i]);
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	return;
}

void solve(){
	H.resize(n);
	sort(ALL(z));
	for(int i=0;i<n;i++){
		H[i]=lower_bound(ALL(z),h[i])-z.begin();
	}
	v.resize(n,0);
	segtree seg(v);
	for(int i=0;i<n;i++){
		ll want=seg.getmax(0,H[i]);
		seg.update(H[i],want+a[i]);
	}
	cout<<seg.getmax(0,n)<<endl;
	return;
}

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

Measured memory_bytes: 13808
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int *num;
  int i,j,k,n;
  int flag=1;
  int box,time=0;
  scanf("%d",&n);
  num=(int *)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  /*sort*/
  while(flag){
    flag=0;
    for(j=n-1;j>=1;j--){
      if(num[j]<num[j-1]){
	box=num[j];
	num[j]=num[j-1];
	num[j-1]=box;
	flag=1;
	time++;
      }
    }

  }
  for(k=0;k<n;k++){
	if(k==n-1){
	  printf("%d\n",num[k]);
	}
	else {
	  printf("%d ",num[k]);
	    }
      }
  printf("%d\n",time);

  
  
  free(num);
  
  return 0;
}


Measured memory_bytes: 1968
a1 = int(input())

calRList = []

calRList.append(a1)

i = 0
while True:
  if calRList[i] % 2 == 0:
    calRList.append(calRList[i]//2)
  else:
    calRList.append(3*calRList[i]+1)
  
  if calRList.count(calRList[i+1]) > 1:
    #index合わせ
    print((i+1)+1)
    break
  
  i+=1


Measured memory_bytes: 2940
require 'pp'

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A=gets.chomp.split(' ').map{|n| n.to_i}

A=A.sort{|a,b| b<=>a}

#score
s_a = A.select.with_index{|a, i| i%2 == 0}.inject(0){|sum,n|sum+n}
s_b = A.select.with_index{|a, i| i%2 == 1}.inject(0){|sum,n|sum+n}
puts "#{s_a - s_b}"





Measured memory_bytes: 2044
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a,int b){return a < b ? a : b;} 

int main(){
	int elaps =0, c;
	int i, q;
	P u;
	char str[64];
	
	scanf("%d %d", &n, &q);
	for(i=1;i<=n;i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head =1; tail =n+1;

	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
			if(u.t>0) enqueue(u);
			else{
				printf("%s %d\n",u.name, elaps);
			}
	}
return 0;
}


Measured memory_bytes: 11884
#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int diff = abs('A' - 'a');
    s[k - 1] = s[k - 1] + diff;
    cout << s << '\n';
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, k) = input_tuple();
    let a_vec = input_vec();
    for i in k..n {
        if a_vec[i - k] < a_vec[i] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 5836
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 1000000000000000000
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    int res = 1;
    while(b > 0){
        if(b&1) res = m(m(res)*m(a));
        a = m(m(a)*m(a));
        b >>= 1;
    }
    return res;
}
// vector<int> fac; //precompute fac array
// fac.resize(n+1);
// fac[0] = 1; 
// for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i));
// int modInverse(int n){ 
// return p(n, MOD-2); 
// }  
// int nCrModPFermat(int n, int r){   
//     if(r == 0)  return 1; 
//     return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
// } 
signed main(){
    fast();
    int n;
    cin >> n;
    int ans = 1;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i] == 0)   ans = 0;
    }
    if(!ans){
        cout << ans << endl;
        return 0;
    }
    for(auto i: a){
        if(i <= MOD/ans)    ans *= i;
        else{
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    cerr << "\nTime elapsed : " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
}

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

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    if (A*B < N || A+B >= N+2) {
        cout << -1 << endl;
        return 0;
    }
    int cnt = 0;
    vector<int> ans(N, 0);
    while (true) {
        if (N - (cnt+1)*B + (cnt+1) > A){
            for (int i = 0; i < B; i++) {
                ans[i+cnt*B] = cnt*B+B-i;
            }
            cnt++;
        }else{
            int t = ((N-cnt*B)+cnt)-A+1;
            for (int i = 0; i < t; i++) {
                ans[i+cnt*B] = cnt*B+t-i;
            }
            for (int i = cnt*B+t; i < N; i++) ans[i] = i+1;
            break;
        }
    }
    for (int i = 0; i < N; i++) {
        if (i < N-1) printf("%d ", ans[i]);
        else printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int main() {
	int n, a[100010];
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", a+i);
	map <int, int> M[2];
	for(int i=1;i<=n;i++) {
		M[i&1][a[i]]++;
	}
	int ans = 0;
	vector <pii> V;
	for(pii e : M[0]) V.pb(pii(e.Se, e.Fi));
	sort(all(V)); reverse(all(V));
	rep(i,min(2, szz(V))) {
		pii a = V[i];
		int mx = 0;
		for(pii b : M[1]) if(b.Fi != a.Se) mx = max(mx, b.Se);
		ans = max(ans, a.Fi + mx);
	}
	printf("%d\n", n - ans);
	return 0;
}


Measured memory_bytes: 6012
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  for(int i=0;i<M;i++){
 cin >> L.at(i) >> R.at(i);
  }
  sort(L.begin(), L.end());
  sort(R.begin(), R.end());
  int a,b;
  a=L.at(M-1);
  b=R.at(0);
  if(b<a){
    cout << 0 << endl;
  }
  else{
  cout << b-a+1 << endl;
  }
}

Measured memory_bytes: 1024
# -*- coding:utf-8 -*-
# /usr/bin/python3

from bisect import bisect_left
from collections import deque

def main():
  N = int(input())
  liA = list(map(int, [input() for _ in range(N)]))
  colors = deque([liA[0]])
  for a in liA[1:]:
    if a <= colors[0]:
      colors.appendleft(a)
    else:
      i = bisect_left(colors, a)
      colors[i-1] = a

  print(len(colors))
  pass

if __name__=='__main__':
  main()


Measured memory_bytes: 14508
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, x, t; cin >> n >> x >> t;
    cout << ((int) ceil(n/(x * 1.0))) * t;
    return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, M, c=0, v, ans=0;
	cin>>N>>M;
	A.resize(M);
	for(int i=0;i<M;i++) {
		int k, a;
		for(cin>>k;k;k--) {
			cin>>a;
			A[i]|=1<<(a-1);
		}
	}
	for(int i=0;i<M;i++) {
		int a;
		cin>>a;
		c|=a<<i;
	}
	for(int i=(1<<N)-1;i>=0;i--) {
		v=0;
		for(int j=0;j<M;j++) {
			v+=((c>>j)&1)==(__builtin_popcount(i&A[j])&1);
		}
		ans+=v==M;
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a;
template <class T>
void read(int n, vector<T> &v){
	for(int i=0; i<n; ++i){
		T t;
		cin >> t;
		v.push_back(t);
	}
}
long long ans;
map<int, int> mp;
int main(){
	cin >> n >> m;
	read(n, a);
	for(int i=0; i<n; ++i)
		a[i] %= m;
	for(int i=1; i<n; ++i){
		a[i] += a[i-1];
		a[i] %= m;
	}
	mp[0] = 1;
	for(int i=0; i<n; ++i){
		if(mp.find(a[i]) != mp.end()){
			ans += mp[a[i]];
			mp[a[i]]++;
		}else mp[a[i]] = 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  string s;
  cin >> s;
  cin >> s;
  string p;
  p+='A';
  p+=s[0];
  p+='C';
  cout << p << endl;
}


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

void solve()
{
    string s; cin >> s;
    if (s.back() == 's') {
        s += "es";
    } else s.push_back('s');
    cout << s << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
using namespace std;
string s[8];
void f(int x,int y)
{
    s[x][y]='0';
    for(int i=-3;i<=3;i++)
    {
        if(x+i>=0&&x+i<8&&s[x+i][y]=='1')f(x+i,y);
        if(y+i>=0&&y+i<8&&s[x][y+i]=='1')f(x,y+i);
    }
}
main()
{
    int t;cin>>t;
    for(int count=1;count<=t;count++)
    {
        for(int i=0;i<8;i++)cin>>s[i];
        int x,y;cin>>x>>y;
        f(y-1,x-1);
        cout<<"Data "<<count<<":"<<endl;
        for(int i=0;i<8;i++)cout<<s[i]<<endl;
    }
}


Measured memory_bytes: 3072
use std::io::Read;
use std::cmp;

fn main() {
    let mut buf = String::new();

    // 標準入力から全部bufに読み込む
    std::io::stdin().read_to_string(&mut buf);

    // 読み込んだStringを空白で分解する
    let mut iter = buf.split_whitespace();

    // rの読み込み
    let r: usize = iter.next().unwrap().parse().unwrap();

    println!("{}", 3 * r * r);
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys


def solve(h, w, a):
    ret = []
    for i in range(h):
        ret.append(a[i])
        ret.append(a[i])
    for r in ret:
        print(r)


def main():
    h, w = map(int, input().split())
    a = []
    for i in range(h):
        a.append(input())
    solve(h, w, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
N = int(input())
def fac(N):
    if N == 1:
        return [['a']]
    li = []
    for x in fac(N-1):
        n = len(set(x))
        for i in range(n+1):
            li.append(x+[chr(97+i)])
    return li
for x in fac(N):
    print(''.join(x))

Measured memory_bytes: 80220
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			
			int[][] map = new int[n+1][4];
			for(int i=0;i<=n;i++){
				for(int j=0;j<4;j++){
					map[i][j] = sc.nextInt();
				}
			}
			
			boolean out = true;
			boolean flag = true;
			for(int i=0;i<n;i++){
				flag = true;
				if(map[i][1]>map[n][0]) flag = false; 
				else if(map[i][2]>map[n][1]) flag = false;
				else if(map[i][3]>map[n][2]) flag = false;
				else if(map[i][1]*4+map[i][2]*9+map[i][3]*4>map[n][3]) flag = false;
				if(flag==true){
					System.out.println(map[i][0]);
					out = false;
				}
			}
			if(out==true) System.out.println("NA");
		}
	}	
}

Measured memory_bytes: 64648
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

int tile[20][20];

int func(int n){
	int a = 0;
	REP(i, n + 1){
		a += i;
	}
	return a;
}

int main(){
	int n;
	while (cin >> n){
		if (n == 1)
			cout << 2 << endl;
		else
			cout << func(n - 2) + 2 * n << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int dp[100010];

signed main()
{
    int N; cin>>N;
    REP(i,N+1) dp[i]=1e9;
    dp[0]=0;

    REP(i,N){
        dp[i+1]=min(dp[i+1],dp[i]+1);
        for(int j=6;i+j<=N;j*=6) 
            dp[i+j]=min(dp[i+j],dp[i]+1);
        for(int j=9;i+j<=N;j*=9)
            dp[i+j]=min(dp[i+j],dp[i]+1);
    }
    cout<<dp[N]<<endl;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	vector<int> A;
	A.push_back(a);
	A.push_back(b);
	A.push_back(c);

	sort(A.begin(), A.end());
	
	cout << A[0] + A[1] << endl;
}




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

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
	int n;
	int i, j;
	int cnt = 0;
	scanf("%d",&n);
	int p[n];
	int flag[n];
	int m;
	for(i=0;i<n;i++){
		scanf("%d",&p[i]);
		flag[i] = 0;
	}
	m = p[0];
	for(i=1;i<n;i++){
		for(j=i-1;j>=0;j--){
			if(p[i] > m){
				cnt++;
				break;
			}
			if(p[i] < p[i-1] && flag[i-1]==0){
				m = p[i];
				break;
			}
			if(p[i] > p[j]){
				cnt++;
				flag[i] = 1;
				break;
			}
			if(flag[j] == 0 && p[j] >= p[i]){
				m = p[i];
				break;
			}
		}
	}
	printf("%d\n",n - cnt);
    return 0; 
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
typedef std::map<ll,ll> mll;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll N,P;
mll prime_factor(ll a){
  mll res;
  for(ll i=2;i*i<=a;i++){
    while(a%i==0){
      res[i]++;
      a/=i;
    }
  }
  if(a!=1) res[a]=1;
  return res;
}
int main(){
  cin>>N>>P;
  mll mp=prime_factor(P);
  ll res=1;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ll f=itr->first,s=itr->second;
    while(s>=N){
      res*=f;
      s-=N;
    }
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main() {
    using namespace std;
    long long a,b,c,k;
    cin>>a>>b>>c>>k;
    while (--k>=0){
        if (c<=b)
            c=c*2;
        else if(b<=a)
            b=b*2;
        else 
            break;
    }
    if (b<=a||c<=b||a>=c)
        cout<<"No";
    if (a<b&&b<c)
        cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    string r;
    cin >> r;
    rep(i,r.size()) {
        if (r[i] == '?') r[i] = 'D';
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    ll n, d;
    cin >> n >> d;

    ll ans = 0;
    while(n>0){
        ans++;
        n -= (2*d+1);
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            String n = sc.next();

            String subStr = "";

            if(n.length() == 3){
                subStr = n.substring(2, 3);
            }else if(n.length() == 2){
                subStr = n.substring(1, 2);
            }else if(n.length() == 1){
                subStr = n;
            }

            
            String ans = "";

            if(subStr.equals("2") || subStr.equals("4") || subStr.equals("5") || subStr.equals("7") || subStr.equals("9")){
                ans = "hon";
            } else if(subStr.equals("0") || subStr.equals("1") || subStr.equals("6") || subStr.equals("8")){
                ans = "pon";
            } else if(subStr.equals("3")){
                ans = "bon";
            }

            System.out.println(ans);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

Measured memory_bytes: 35688
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
      cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0&&a[i]%2==1)
           ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()

//-2で割ったときの商とあまり
void Ary(int n, int &r, int &q)
{
  if (n == 0)
  {
    r = 0;
    q = 0;
    return;
  }
  int i = 0;
  if (n > 0)
  {
    while ((-2) * i <= n)
    {
      i--;
    }
    i++;
    q = i;
    r = n - (-2) * i;
  }else{
    while((-2)*i>n){
      i++;
    }
    q = i;
    r = n - (-2) * i;
  }
  return;
}

int main()
{
  int n;
  cin >> n;
  int remainder, quotient;
  string ans;
  do
  {
    Ary(n, remainder, quotient);
    ans.push_back('0' + remainder);
    n = quotient;
  } while (quotient != 0);
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){
    
    int A, B;
    int ans = 0;
    cin >> A >> B;
    if(A > B){
        ans += A;
        A--;
    }
    else{
        ans += B;
        B--;
    }
    if(A > B){
        ans += A;
        A--;
    }
    else{
        ans += B;
        B--;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
function Main(input) {
	input = input.trim();
	//input = input.trim().split(" ");
	//input = input.trim().split("\n");
	input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  	var L = input[0] + input[1];
  var R = input[2] + input[3];
  if(L > R){
     console.log("Left");
     }else if(L < R){
    console.log("Right");
  }else{
    console.log("Balanced");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;
#define LOCAL  1
#define UPLOAD 2
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';

#define ll long long

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  int L = input();
  int R = input();
  
  int min = 2019;
  for(ll i=L;i<=R;i++){
    for(ll j=i+1;j<=R;j++){
      if(i % 2019 == 0 || j % 2019 == 0){
        output(0);
        return 0;
      }
      if((i*j) % 2019 < min){
        min = (i*j) % 2019;
      }
    }
  }

  output(min);

  return 0;
}

Measured memory_bytes: 256
import sys
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
inf=float("inf")
data=[[inf]*n for i in range(n)]
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i==k or j==k:
                continue
            if a[i][j]==a[i][k]+a[k][j]:
                break
            elif a[i][j]>a[i][k]+a[k][j]:
                print(-1)
                sys.exit()
        else:
            data[i][j]=a[i][j]
            ans+=a[i][j]
print(ans//2)

Measured memory_bytes: 46940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;

// -------------------------------------------------------

int a, b, c;

int main() {
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}


Measured memory_bytes: 3576
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  ll a = 0, t = n;
  while(t > 0) {
    a += (t % 10);
    t /= 10;
  }

  if(n % a == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C;
    cin>>A>>B>>C;
    if(C<=A+B) cout << C+B<<"\n";
    else cout << A+2*B+1<<"\n";
}


Measured memory_bytes: 256
def listShow(A):
	for i in range(len(A)):
		if(i<len(A)-1):
			print(A[i],end=' ')
		else:
			print(A[i])

def insertionSort(A,N):
	for i in range(1,N):
		j=i-1
		while(j>=0 and A[j]>A[j+1]):
			A[j],A[j+1]=A[j+1],A[j]
			j-=1
		listShow(A)

n=int(input())
a=list(map(int,input().split()))
listShow(a)
insertionSort(a,n)



Measured memory_bytes: 5980
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


i64 n, a[101010], d[101010];
i64 mod = 998244353;

i64 mod_pow(i64 x, i64 y, i64 mod){
	i64 res = 1;
	while(y > 0){
		if(y & 1) res = res * x % mod;
		x = x*x %mod;
		y >>= 1;
	}
	return res;
}

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	if(a[0] != 0){
		cout << 0 << endl;
		return 0;
	}
	sort(a, a+n);
	i64 ans = 1, now = 1, prev = 1;
	for(int i = 1; i < n; i++){
		i64 cnt = 0, j;
		for(j = i; j < n; j++){
			if(a[j] != now) break;
			cnt++;
		}
		if(cnt == 0){
			ans = 0;
			break;
		}
		ans *= mod_pow(prev, cnt, mod);
		ans %= mod;
		prev = cnt;
		now++;
		i = j-1;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,maxi=0,f=0,mini=INF,sum=0;
    string str,sub;
    ll h,w;
    string str1;
    cin>>n;
    map<ll,ll> m;
    set<ll> s;
    rep(i,n){
        cin>>a;
        m[a]++;
        s.insert(a);
    }

    for(auto itr=s.begin();itr!=s.end();itr++){
        if(m[*itr]%2) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(b-a == c-b)cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

int res[101010];
string s;

int main(){
  cin >> s;
  int n = s.size();
  s.push_back('R');
  
  int left = 0, mid = 0;
  for(int i = 0; i < n; i++){
    if(s[i] == 'R' && s[i + 1] == 'L'){
      mid = i;
      continue;
    }
    if(s[i] == 'L' && s[i + 1] == 'R'){
      res[mid] = (i - mid) / 2 + ((mid - left) / 2) + 1;
      res[mid + 1] = (mid - left + 1) / 2 + (i - mid - 1) / 2 + 1;
      left = i + 1;
    }
  }
  
  rep(i, n) cout << res[i] << ((i == n - 1)? "\n" : " ");
    
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;
const int NMAX = 2*1e5;

bool check(int l, int N, int K, int *A)
{
	ll cnt = 0;
	for (int i = 0; i < N; ++i) {
		int num = A[i] / l;
		num += A[i] % l > 0 ? 1 : 0;
		cnt += num - 1;
	}
	return cnt <= K;
}

int main()
{
	int N, K;
	scanf("%d%d", &N, &K);
	int A[NMAX];
	for (int i = 0; i < N; ++i)
		scanf("%d", &A[i]);

	if (check(1, N, K, A)) {
		printf("1\n");
		return 0;
	}

	int lb = 1, ub = 1e9;
	while (ub - lb > 1) {
		int mb = (ub + lb) / 2;
		if (check(mb, N, K, A)) {
			ub = mb;
		} else {
			lb = mb;
		}
	}

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

	return 0;
}



Measured memory_bytes: 3880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ret = false;
            UInt64 retint = 0;
            string retstr = string.Empty;
            //var num = int.Parse(Console.ReadLine());
            var input = spr(Console.ReadLine());
            var Hi = c2i(input.First());
            var Wi = c2i(input.Last());
            if (Hi > 1 && Wi > 1)
            {
                var Hfirst = GetHlinecount(Hi);
                var Hsecond = GetHlinecount(Hi - 1);
                retint = Hfirst * GetHlinecount(Wi);
                retint += Hsecond * GetHlinecount(Wi - 1);
            }
            else
            {
                retint = 1;
            }
            Console.WriteLine(retint);
            //Console.ReadLine();
        }

        static UInt64 GetHlinecount(int line) { return (UInt64)(line / 2 + line % 2); }

        static bool isEven(int i){return(i%2==0);}    
        static int c2i(string c) { return int.Parse(c); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
    }
}


Measured memory_bytes: 11220
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  char s[SIZE];
  int n = 0;
  scanf("%s", s);

  n = strlen(s);

  ll ans = 0;
  int counter = 0;
  
  for(int i=n-1;i>=0;i--){
    if(s[i] == 'W') counter++;
    if(s[i] == 'B') ans += counter;
  }

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




Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, A, B;
		N = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();

		System.out.println(Math.min(N * A, B));
	}
}

Measured memory_bytes: 21716