akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int n, A[4][3][10] = {0};
  cin >> n;
  for (int i=0;i<n;i++) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    A[b - 1][f - 1][r - 1] += v;
  }

  for (int i=0;i<4;i++) {
    for (int j=0;j<3;j++) {
      for (int k=0;k<10;k++)
        cout << " " << A[i][j][k];
      cout << endl;
    }
    if (i < 3) {
      for (int j=0;j<20;j++)
        cout << "#";
      cout << endl;
    }
  }
}



Measured memory_bytes: 3088
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 d = a/b;
		int r = a%b;
		double f = (double)a/(double)b;
		System.out.printf("%d %d %.5f\n",d,r,f);
	}
}

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

int main()
{
  int m;
  int s=0;
  cin >> m;
  int n=m;
  while (n>0)
  {
    s+=n%10;
    n/=10;
  }
  if (m%s==0) cout<<"Yes"<<endl;
  else cout <<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
# D - equeue

# 何個取るか決める→左からいくつか取る→残りを右から取る→残りの操作回数だけ負の宝石を捨てる
# 何個取るか、左からいくつ取るか、でループ

from collections import deque
import heapq

N, K = map(int, input().split())
original_V = list(map(int, input().split()))

ans = []

for n_take in range(K+1):
    for n_take_from_left in range(n_take+1):
        have = []
        V = deque(original_V)
        
        for _ in range(n_take_from_left):
            if V:
                heapq.heappush(have, V.popleft())
            else:
                break
        
        for _ in range(n_take - n_take_from_left):
            if V:
                heapq.heappush(have, V.pop())
            else:
                break
    
        for _ in range(K - n_take):
            if have and have[0] < 0:
                heapq.heappop(have)
            else:
                break
                
        ans.append(sum(have))
    
print(max(ans))

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

using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int s;
deque<ll> x, p;

ll go() {
    ll res;
    if (x.front() > s) {
        res = x.back() - s;
        s = x.back();
        return res;
    }
    if (x.back() < s) {
        res = s - x.front();
        s = x.front();
        return res;
    }
    int to;
    if (p.front() >= p.back()) {
        p.front() += p.back();
        p.pop_back();
        to = x.back();
        x.pop_back();
    } else {
        p.back() += p.front();
        p.pop_front();
        to = x.front();
        x.pop_front();
    }
    res = go();
    res += abs(s - to);
    s = to;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(cout.fixed);
    cout.precision(20);
    int n;
    cin >> n >> s;
    x.resize(n);
    p.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> p[i];
    }
    cout << go() << "\n";
}


Measured memory_bytes: 2688
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort!
c = Array.new(n, 0)

n.times do |i|
  if i == 0
    c[i] = a[i]
  else
    c[i] = c[i - 1] + a[i]
  end
end
s = c[n - 1]

res = 0
n.times do |i|
  if i == 0 || c[n - 1 - i] * 3 >= c[n - i]
    res += 1
  else
    break
  end
end
puts res

Measured memory_bytes: 22664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//Get the highest value and key from a map.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

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

  int a = atoi(s.substr(0, 2).c_str());
  int b = atoi(s.substr(2, 2).c_str());

  if (a == 0 && b != 0) {
    if (b > 12) {
      cout << "NA" << endl;
      return 0;
    }
    cout << "YYMM" << endl;
  } else if (a != 0 && b == 0) {
    if (a > 12) {
      cout << "NA" << endl;
      return 0;
    }
    cout << "MMYY" << endl;
  } else {
    if (a == 0 && b == 0 || (a > 12 && b > 12)) {
      cout << "NA" << endl;
      return 0;
    }
    if (a <= 12 && b <= 12) {
      cout << "AMBIGUOUS" << endl;
      return 0;
    }
    if (a > b) {
      cout << "YYMM" << endl;
    } else {
      cout << "MMYY" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {

	int a[5];

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

	int sum = min(a[0], min(a[1], a[2])) + min(a[3], a[4]);

	cout << sum - 50 << endl;

	return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> S(N);
    int sum = 0;
    for(int i =0 ;i < N; i++){
        cin >> S[i];
        sum += S[i];
    }
    priority_queue<int, vector<int>, greater<int>> PQ;
    for(int i = 0; i < N; i++){
        if(S[i] % 10 != 0) PQ.push(S[i]);
    }
    if(PQ.empty()) cout << 0 << endl;
    else if(sum % 10 == 0)cout << sum - PQ.top() << endl;
    else cout << sum << endl;
}

Measured memory_bytes: 256
use List::Util 'sum';

chomp($n = <>);
@s = split(/ /, <>);

$r = 100000;
for $i (0 .. $n - 2){
	$dif = abs(sum(@s[0 .. $i]) - sum(@s[$i + 1 .. $n - 1]));
	$r = $dif if($r > $dif);
}

print "$r\n";


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

		System.out.println((x - z) / (y + z));

		sc.close();

	}

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

//const ll INF=(ll)1e18;
const int INF=(1<<30);




int main(){
  int N;
  cin >> N;
  vector<double> t(N+3);
  vector<double> v(N+2);

  t[0]=0; t[1]=0;
  v[0]=0;

  int t_max = 0;
  REP(i,N){
    cin >> t[i+2];
    t[i+2] += t[i+1];
  }
  REP(i,N){
    cin >> v[i+1];
  }

  t[N+2]=t[N+1];
  v[N+1]=0;


  vector<double> v_list;
  for(double i = 0; i <= t[N+2]; i+=0.5){
    double tmp=1000000;

    REP(j,N+2){
      if(i < t[j]){
        tmp = min(tmp,v[j]+(t[j]-i));
      }else if(i >= t[j] && i <= t[j+1]){
        tmp = min(tmp,v[j]);
      }else{
        tmp = min(tmp,v[j] + (i-t[j+1]));
      }
    }
    v_list.push_back(tmp);
  }

  double ans = 0;
  REP(i,v_list.size()-1){
    ans += (v_list[i]+v_list[i+1])*0.25;
  }
  printf("%f\n",ans);
}



Measured memory_bytes: 896
function Main(input) {
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var x = parseInt(input[0].split(" ")[1]);
  tmp = input[1].split(" ");
  a = new Array(n).fill(0);
  for(i=0;i<n;i++){
    a[i]=parseInt(tmp[i]);
  }
  var ans=0;
  for(i=0;i<n;i++){
    if(i==0){
      if(a[i]>x){
        ans+=a[i]-x;
        a[i]=x;
      }
    }else{
      if(a[i]+a[i-1]>x){
        ans+=a[i-1]+a[i]-x;
        a[i]=x-a[i-1];
      }
    }
  }

  console.log('%s', ans);
}

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


Measured memory_bytes: 17804
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[201];
    char p[101];
    
    scanf("%s", s);
    scanf("%s", p);
    
    strncat(s, s, strlen(p));
    
    if((strstr(s, p))!=NULL){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 532
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, inf = 100000000;
    scanf("%d", &n);
    vector<vector<pair<int, int>>> a(n, vector<pair<int, int>>(0));
    for (int i = 0, u, k; i < n; i++)
    {
        scanf("%d %d", &u, &k);
        for (int j = 0, v, c; j < k; j++)
        {
            scanf("%d %d", &v, &c);
            a[i].push_back(make_pair(c, v));
        }
    }
    
    vector<int> cost(n, inf), vis(n, 0);
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > q;
    cost[0] = 0;
    q.push(make_pair(0, 0));
    for (pair<int, int> t; !q.empty(); )
    {
        
        t = q.top();
        q.pop();
        vis[t.second] = true;
        if (cost[t.second] < t.first)
        {
            continue;
        }
        for (int i = 0; i < a[t.second].size(); i++)
        {
            pair<int, int> j = a[t.second][i];
            if (!vis[j.second] && cost[j.second] > cost[t.second] + j.first)
            {
                cost[j.second] = cost[t.second] + j.first;
                q.push(make_pair(cost[j.second], j.second));
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d %d\n", i, cost[i]);
    }
}


Measured memory_bytes: 7848
#include "bits/stdc++.h"
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2601&lang=jp
typedef long long ll;
#define INF 1<<30
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);

	/* input */
	ll W; cin >> W;
	vector<int> a(W);
	for (int i = 0; i < W;i++) cin >> a[i];

	// right direction
	map<int, int> ans1;
	int Exit = -1;
	int limit = INF;
	int limit_at = -1;
	for (int i = 0; i < W;i++) {
		if (a[i] == 0) { 
			Exit = i;
			limit = INF;
			limit_at = -1;
			continue; 
		}
		if (Exit == -1) continue;
		if (a[i] < 0) {
			if (limit < abs(a[i])) continue;
			else {
				int dif = i - limit_at;
				if (limit < abs(a[i]) + dif)continue;
				limit = abs(a[i]);
				limit_at = i;
			}
		}
		else {
			int dif = i - limit_at;
			if (limit - dif <= 0) continue;

			ans1[i] = min(limit - dif, a[i]);
			//cout << i << " : " << ans1[i] << endl;
		}
	}

	// left direction
	map<int, int> ans2;
	Exit = W;
	limit = INF;
	limit_at = W;
	for (int i = W - 1; i >= 0;i--) {
		if (a[i] == 0) {
			Exit = i;
			limit = INF;
			limit_at = W;
			continue;
		}
		if (Exit == W) continue;
		if (a[i] < 0) {
			if (abs(a[i]) > limit)continue;
			else {
				int dif = limit_at - i;
				if (abs(a[i]) + dif > limit)continue;
				limit = abs(a[i]);
				limit_at = i;
			}
		}
		else {
			int dif = limit_at - i;
			if (limit - dif <= 0) continue;
			ans2[i] = min(limit - dif, a[i]);
			//cout << i << " : " << ans2[i] << endl;
		}
	}

	int ans = 0;
	for (int i = 0; i < W;i++) {
		ans += max(ans1[i], ans2[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 12604
#include<stdio.h>

int main(void)
{
    char c;
    int i;
    int count[26] = {0};
    
    while((c = getchar()) != EOF){
        if(c >= 'a' && c <= 'z'){
            count[c-'a']++;
        }
        else if(c >= 'A' && c <= 'Z'){
            count[c-'A']++;
        }
    }
    for(i=0;i<26;i++){
        printf("%c : %d\n", 'a'+i, count[i]);
    }
    return 0;
}

Measured memory_bytes: 524
#define _USE_MATH_DEFINES
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

/*
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

void trace(int a[], int n)
{
    printf("%d", a[0]);
    for (int i = 1; i < n; i++)
    {
        printf(" %d", a[i]);
    }
    printf("\n");
}

int selectionSort(int a[], int n)
{
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        int minj = i;
        for (int j = i; j < n; j++)
            if (a[j] < a[minj])
                minj = j;
        swap(a[i], a[minj]);
        if (i != minj)
            ans++;
    }
    trace(a, n);
    return ans;
}

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

    int a[105];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    cout << selectionSort(a, n) << endl;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	double n,k;cin>>n>>k;
	double ans=0;
	for(int i=1;i<=n;i++){
		int cnt=0,j=i;
		while(j*pow(2,cnt)<k){
			cnt++;
		}
		//int cnt=(ceil)(log2(k/i));
		ans+=1/(n*pow(2,cnt));
	}
	cout<<fixed<<setprecision(15)<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n, count, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i+=2){
    count = 0;
    for (int j = 1; j <= i; j++){
      if (i%j==0) count++;
    }
    if (count==8) {
      ans++;
      // cout << i << endl;
    }
    // cout << i << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n,m,d=[int(s)for s in input().split(" ")]
map_=[input()for i in range(n)]
cnt=0
for i in range(n):
    for j in range(m):
        t='.'*d
        if j<=m-d and map_[i][j:j+d]==t:cnt+=1
        if i<=n-d:
            state_ns=""
            for k in range(d):state_ns+=map_[i+k][j]
            if state_ns==t:cnt+=1
print(cnt)

Measured memory_bytes: 7796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <cstring>

#define LL long long
#define INF 2147483647

using namespace std;

int main(){
	string s;
	cin>>s;
	int ans=0;
	for (int i=0;i<6;i++){
		if (s[i]=='1') ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n;
  cin >> n;
  ll a[200000];
  ll ans = 0;
  rep(i,n) {
    ll t;
    cin >> t;
    a[t-1]++;
    ans += t;
  }
  ll q;
  cin >> q;
  rep(i,q) {
    ll b, c;
    cin >> b >> c;
    ll r = a[b-1];
    a[b-1] = 0;
    a[c-1] += r;
    ans = ans + r*(c-b);
    cout << ans << '\n';
  }
}


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

#define nl '\n'
#define F fisrt
#define S second
#define pb push_back
#define mp make_pair
#define REP(i,a,b) for(int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef stack<int> si;
typedef deque<int> di;
typedef pair<int,int> pi;

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

	//your code here
	int a,b;
	cin >> a >> b;
	a < b ? cout << 0 << endl : cout << 10 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int first(long long x)
{
	int ans=-1;
	while(x)
	{
		x/=2;
		ans++;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long n,i,ans=0;
	cin>>n;
	vector<long long>v(n);
	for(i=0;i<n;i++)
	{
		cin>>v[i];
		ans^=v[i];
	}
	for(i=0;i<n;i++)
		v[i]^=v[i]&ans;
	vector<long long>basis(60,0);
	for(auto x:v)
	{
		while(x && basis[first(x)])
			x^=basis[first(x)];
		if(x)basis[first(x)]=x;
	}
	long long ans2=0;
	for(i=59;i>=0;i--)
		ans2=max(ans2,ans2^basis[i]);
	cout<<ans+ans2*2<<'\n';
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	if((long long)((v-w)*t)>=(long long)(abs(b-a))) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define X first
#define Y second

const int maxn=1e5+10;

int n,f[maxn];
set<int> r[maxn],b[maxn];
queue<pair<int,int> > q;

int find(int x) {return x==f[x]?x:f[x]=find(f[x]);}

int main()
{
#ifdef h10
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
	int i,u,v;
	scanf("%d",&n);
	for (i=1;i<=n;i++) f[i]=i;
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		r[u].insert(v);
		r[v].insert(u);
	}
	for (i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		b[u].insert(v);
		b[v].insert(u);
		if (r[u].count(v))
			q.push(make_pair(u,v));
	}
	while (!q.empty())
	{
		u=find(q.front().X);
		v=find(q.front().Y);
		q.pop();
		if (u==v) continue;
		if (r[u].size()+b[u].size()<r[v].size()+b[v].size()) swap(u,v);
		set<int>::iterator it;
		for (it=r[v].begin();it!=r[v].end();it++)
		{
			int tmp=find(*it);
			r[u].insert(tmp);
			r[tmp].insert(u);
			if (b[u].count(tmp))
				q.push(make_pair(u,tmp));
		}
		for (it=b[v].begin();it!=b[v].end();it++)
		{
			int tmp=find(*it);
			b[u].insert(tmp);
			b[tmp].insert(u);
			if (r[u].count(tmp))
				q.push(make_pair(u,tmp));
		}
		r[v].clear();
		b[v].clear();
		f[v]=u;
	}
	for (i=2;i<=n;i++)
		if (find(i)!=find(1)) {puts("NO"); return 0;}
	puts("YES");
}


Measured memory_bytes: 31232
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	string a, b;
	cin >> a >> b;

	if(a.size() > b.size()) cout << "GREATER" << endl;
	else if(a.size() < b.size()) cout << "LESS" << endl;
	else if(a < b) cout << "LESS" << endl;
	else if(a > b) cout << "GREATER" << endl;
	else cout << "EQUAL" << endl;

	return 0;
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

typedef long long ll;
typedef pair<int,int> pii;

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 1e5, M = 109, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


void go(int tc){
    int n;  cin >> n;

    int ans = 0;
    for(int i = 1;i <= n;i++){
        int x;  cin >> x;
        ans += (i & 1) & (x & 1);
    }

    cout << ans;

}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

    int t = 1, tc = 1;
//    cin >> t;
    while(t--)  go(tc++);
}

Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] a = in.nextIntArray(n);

			boolean isUp = false, isDown = false;
			int count = 0;
			for (int i = 0; i < n-1; i++) {
				if (a[i] == a[i+1]) {
					continue;
				} else if (a[i] < a[i+1]) {
					isUp = true;
					if (isDown) {
						count++;
						isUp = false;
						isDown = false;
					}
				} else if (a[i] > a[i+1]) {
					isDown = true;
					if (isUp) {
						count++;
						isUp = false;
						isDown = false;
					}
				}
			}
			count++;

			out.println(count);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 36460
n,m=map(int,input().split())
a,b,c,d=[],[],[],[]
for i in range(n):
    o = list(map(int, input().split()))
    a.append(o[0])
    b.append(o[1])
for i in range(m):
    o = list(map(int, input().split()))
    c.append(o[0])
    d.append(o[1])
s = []
for i in range(n):
    g = float('inf')
    h = 0
    for j in range(m):
        if g > abs(a[i]-c[j])+abs(b[i]-d[j]):
            g = abs(a[i]-c[j])+abs(b[i]-d[j])
            h = j+1
    s.append(h)
for i in s:
    print(i)

Measured memory_bytes: 3064
def e(a,b):
    x=(a+b)/2
    return x
ans=0
Max=0
n,k=map(int,input().split())
l=list(map(int,input().split()))
tmp=0
for i in range(k):
    Max+=l[i]
tmp=Max
for j in range(k,n):
    tmp+=l[j]
    tmp-=l[j-k]
    Max=max(tmp,Max)
print(e(Max,k))

Measured memory_bytes: 25376
#include<bits/stdc++.h>
#define ll long long

using namespace std;
const int MAXN = 100005;
const int MOD = 1000000007;

int arr[MAXN];
set<int> x,y;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	ll sum = 0;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
		sum += arr[i];
	}
	ll k = 1ll * n * (n+1) / 2;
	if(sum % k != 0){
		cout << "NO\n";
		return 0;
	}
	sum /= k;
	arr[n+1] = arr[1];
	for(int i=1;i<=n;i++){
		int dif = - arr[i+1] + arr[i];
		x.insert((dif+sum)/n);
		y.insert(sum - (dif+sum)/n);
		if((dif + sum) % n != 0){
			cout << "NO\n";
			return 0;
		}
	}
	if(*x.begin() < 0 || *y.begin() < 0) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();

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

		Arrays.sort(a);
		long l = 0;
		long r = 100000 * 2 + 1;
		while (r - l > 1) {
			long mid = (l + r) / 2;
			long count = 0;

			for (int i = a.length - 1; i >= 0; i--) {
				int index = lowerBound(a, mid - a[i]);
				count += (a.length - index);
				if (count > m) break;
			}

			if (count >= m) {
				l = mid;
			} else {
				r = mid;
			}
		}

		long[] s = new long[n + 1];
		s[n - 1] = a[n - 1];
		for (int i = n - 2; i >= 0; i--) {
			s[i] = s[i + 1] + a[i];
		}

		long answer = 0;
		long c = 0;
		for (int i = a.length - 1; i >= 0; i--) {

			int index = lowerBound(a, l - a[i]);
			answer += s[index];
			answer += (n - index) * a[i];
			c += (n - index);
		}

		if (m < c) {
			answer -= (c - m) * l;
		}

		System.out.println(answer);
	}

	private static int lowerBound(long[] a, long x) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int m = (l + r) / 2;
			if (a[m] >= x) {
				r = m;
			} else {
				l = m;
			}
		}
		return r;
	}
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

    //入力高速化
    struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int Q;
  cin >> Q;
  vector<P> input(Q);
  rep(i, Q) {
    cin >> input[i].F >> input[i].S;
  }
  vector<bool> d(1e5 + 5, false);
  vector<int> ans;
  ans.pb(2);
  rep(i,1e5/2+2){
    d[i*2] = true;
  }
  for (int i = 3; i <= (int)(1e5 + 1); i += 2) {
    if (d[i] == false) {
      ans.pb(i);
    }
    else{
      continue;
    }
    for(int j = 1; j * i <= 1e5; j++) {
      d[i*j] = true;
    }
  }

  vector<int> ans2;

  for(auto val : ans){
    if(find(all(ans), (val + 1)/2) != ans.end()){
      ans2.pb(val);
    }
  }

  rep(i, Q) {
    cout << upper_bound(all(ans2), input[i].S) - lower_bound(all(ans2),input[i].F) << endl;
  }

  //for(auto val : ans) PRINT(val)

}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

const int MAXN = 1e5 + 10;

int k, a[MAXN];

void fail() {
	cout << "-1\n";
	exit(0);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> k;
	ll tl = 2, tr = 2;
	for (int i = 0; i < k; i++)	cin >> a[i];
	if (a[k-1] != 2) fail();

	for (int i = k-1; i; i--){
		ll temp, temp2;
		{
			temp = tl;
			if (temp % a[i-1])
				temp += a[i-1] - temp%a[i-1];

		}

		{
			temp2 = tr;
			temp2 += a[i]-1;
			temp2 = temp2/a[i-1] * a[i-1];
		}

		tl = temp, tr = temp2;
		if (tl > tr)
			fail();
	}
	tr += a[0]-1;
	cout << tl << " " << tr << "\n";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>


int main(){
  std::string S;
  std::cin >> S;
  bool ans = true;
  if (S[0] != 'A'){
    ans = false;
  }
  int a = 2;
  int b = S.length() - 1;
  int c = 0;
  for (int i = a;i < b;i++){
    if (S[i] == 'C')c++;
  }
  if (c != 1){
    ans = false;
  }
  int l = 0;
  for (int i = 0;i<S.length();i++){
    if (S[i] < 'a'){
      l++;
    }
  }
  if (l > 2){
    ans = false;
  }

  if (ans)std::cout << "AC" << std::endl;
  else std::cout << "WA" << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	static HashMap<String, Integer> map = new HashMap<String, Integer>();
	static int[] l,r;
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
			
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int m = Integer.parseInt(str[1]);
		
		int[] a = new int[n];
		int[] b = new int[n];
		for(int i = 0; i < n; i++){
			String[] str1 = br.readLine().split(" ");
			a[i] = Integer.parseInt(str1[0]);
			b[i] = Integer.parseInt(str1[1]);
		}
		int[] c = new int[m];
		int[] d = new int[m];
		for(int i = 0; i < m; i++){
			String[] str1 = br.readLine().split(" ");
			c[i] = Integer.parseInt(str1[0]);
			d[i] = Integer.parseInt(str1[1]);
		}

		for(int i = 0; i < n; i++){
			int x = c[0];
			int y = d[0];
			int distx = Math.abs(a[i] - x);
			int disty = Math.abs(b[i] - y);
			int pos = 1;
			for(int j = 1; j < m; j++){
				int tx = Math.abs(a[i] - c[j]);
				int ty = Math.abs(b[i] - d[j]);
				if(distx+disty > tx+ty){
					x = c[j];
					y = d[j];
					distx = tx;
					disty = ty;
					pos = j+1;
				}
			}
			sb.append(pos).append("\n");
		}

		System.out.println(sb);
	}
}


Measured memory_bytes: 21332
n,k = list(map(int, input().split()))
s = input()

t = list(map(int, list(s)))
lt = len(t)
w = []
sumw = []
u = 0
u1 = t[0]
ans1 = []
ans = 0
for i in range(lt):
    if t[i] == u1:
        u += 1
    if t[i] != u1:
        u = u if u1 == 1 else u*-1
        w.append(u)
        ans += abs(u)
        ans1.append(ans if u > 0 else ans*-1)
        u = 1
        u1 = 1 if u1 == 0 else 0

u = u if u1 == 1 else u*-1
w.append(u)
ans += abs(u)
ans1.append(ans if u > 0 else ans*-1)

ans2 = []
for i in range(len(ans1)):
    if i == 0:
        ans2.append(ans1[i])
    elif ans1[i] > 0:
        if i - 2*k - 1 >= 0:
            ans2.append(ans1[i] + ans1[i - 2*k - 1])
        else:
            ans2.append(ans1[i])
    else:
        if i - 2*k >= 0:
            ans2.append(ans1[i]*-1 + ans1[i - 2*k])
        else:
            ans2.append(ans1[i]*-1)

print(abs(max(ans2)))

Measured memory_bytes: 58744
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int h,w,k;cin>>h>>w>>k;
    vvch c(h,vch(w));
    rep(i,h)rep(j,w)cin>>c[i][j];
    int sum;int ans=0;
    rep(i,(1<<h)){
        bitset<7> col(i);
        rep(j,(1<<w)){
            bitset<7> row(j);
            sum=0;
            rep(a,h)rep(b,w){
                if(c[a][b]=='#'&&!col[a]&&!row[b])sum++;
            }
            if(sum==k)ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        for (int i = n[0]; i <= n[1]; i++)
        {
            Console.WriteLine(i);
            if (i - n[0] + 1 == n[2])
            {
                if (n[1] - n[2] + 1 <= i) ;
                else i = n[1] - n[2] ;
            }
            
        }
    }

}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int Cin()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
}


Measured memory_bytes: 13268
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int a = r.i();
        println(3*a*a);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21076
N = int(input())
S = input()
E = [0]
W = [0]
for i in range(N):
    if i == 0:
        if S[i] == 'E':
            E[0] += 1
        else:
            W[0] += 1
    else:
        E.append(E[-1])
        W.append(W[-1])
        if S[i] == 'E':
            E[-1] += 1
        else:
            W[-1] += 1

ans = 10 ** 8

for i in range(N):
    if i == 0:
        ans = min(ans, E[-1] - E[0])
    elif i == N-1:
        ans = min(ans, W[-2])
    else:
        ans = min(ans, W[i-1] + E[-1] - E[i])
print(ans)

Measured memory_bytes: 18084
#include<bits/stdc++.h>
using namespace std;
namespace IO
{
    const int __S=(1<<20)+5;char __buf[__S],*__H,*__T;
    inline char getc()
    {
        if(__H==__T) __T=(__H=__buf)+fread(__buf,1,__S,stdin);
        if(__H==__T) return -1;return *__H++;
    }
    template <class __I>inline void read(__I &__x)
    {
        __x=0;int __fg=1;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1,__c=getc();
        while(isdigit(__c)) __x=__x*10+__c-'0',__c=getc();
        __x*=__fg;
    }
    inline void readd(double &__x)
    {
        __x=0;double __fg=1.0;char __c=getc();
        while(!isdigit(__c)&&__c!='-') __c=getc();
        if(__c=='-') __fg=-1.0,__c=getc();
        while(isdigit(__c)) __x=__x*10.0+__c-'0',__c=getc();
        if(__c!='.'){__x=__x*__fg;return;}else while(!isdigit(__c)) __c=getc();
        double __t=1e-1;while(isdigit(__c)) __x=__x+1.0*(__c-'0')*__t,__t=__t*0.1,__c=getc();
        __x=__x*__fg;
    }
    inline void reads(char *__s,int __x)
    {
        char __c=getc();int __tot=__x-1;
        while(__c<'!'||__c>'~') __c=getc();
        while(__c>='!'&&__c<='~') __s[++__tot]=__c,__c=getc();
        __s[++__tot]='\0';
    }
    char __obuf[__S],*__oS=__obuf,*__oT=__oS+__S-1,__c,__qu[55];int __qr;
    inline void flush(){fwrite(__obuf,1,__oS-__obuf,stdout);__oS=__obuf;}
    inline void putc(char __x){*__oS++ =__x;if(__oS==__oT) flush();}
    template <class __I>inline void print(__I __x)
    {
        if(!__x) putc('0');
        if(__x<0) putc('-'),__x=-__x;
        while(__x) __qu[++__qr]=__x%10+'0',__x/=10;
        while(__qr) putc(__qu[__qr--]);
    }
    inline void prints(const char *__s,const int __x)
    {
        int __len=strlen(__s+__x);
        for(int __i=__x;__i<__len+__x;__i++) putc(__s[__i]);
    }
    inline void printd(double __x,int __d)
    {
        long long __t=(long long)floor(__x);print(__t);putc('.');__x-=(double)__t;
        while(__d--)
        {
            double __y=__x*10.0;__x*=10.0;
            int __c=(int)floor(__y);
            putc(__c+'0');__x-=floor(__y);
        }
    }
    inline void el(){putc('\n');}inline void sp(){putc(' ');}
}using namespace IO;
int a[305][305],n,m,p[305],b[305],vis[305],ans=19260817;
int main()
{
    read(n);read(m);
    for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) read(a[i][j]);
    for(int i=1;i<=n;i++) p[i]=1;
    while(1)
    {
        int mx=0,id=0;memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++)
        {
            while(vis[a[i][p[i]]]) p[i]++;if(!a[i][p[i]]) continue;
            b[a[i][p[i]]]++;if(b[a[i][p[i]]]>mx) id=a[i][p[i]],mx=b[id];
        }
        if(!mx) break;ans=min(ans,mx);vis[id]=1;
        for(int i=1;i<=n;i++) if(a[i][p[i]]==id) p[i]++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 896
fn main() {
    let mut a: Vec<i32> = (0..3).map(|_| read()).collect();

    let mut num_5 = 0;
    let mut num_7 = 0;

    for &val in a.iter(){
        if val == 5{
            num_5 += 1;
        } else if val == 7 {
            num_7 += 1;
        }
    }
    if num_5 == 2 && num_7 == 1{
        println!("YES");
    } else {
        println!("NO");
    }
    
}

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <time.h>
#include <string>
#include <stack>
#include <set>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
#define MP make_pair
#define PB push_back
typedef long long LL;
typedef pair<int, int> Pii;
const int inf = 0x3f3f3f3f;
const LL INF = (1uLL << 63) - 1;
const LL mod = 1000000007;
const int N = 150 + 5;
const double Pi = acos(-1.0);
const int maxn = 1e5 + 5;

int main() {
#ifdef local
    freopen("in", "r", stdin);
    //  freopen("w","w",stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    LL n = 0;
    cin>>n;
    LL ans = n / 11 * 2;
    n %= 11;
    if(n > 6){
        ans += 2;
    }
    else if(n > 0)ans+=1;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main()
{
    int a, b;

    cin >> a >> b;
    cout << a * b << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        String ans = "NO";
        if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1)==c.charAt(0))
            ans = "YES";
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
/* Arthur Conmy / arthurconmy */
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef pair<int,int> pii;
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define REPb(j, d, c) for (int j = int(d); j >= int(c); j--)
#define ff first
#define ss second
#define pb push_back
#define len(x) int((x).size())
#define endl "\n"

int main() // LL OR INT??
{
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int l,r;
	cin>>l>>r;

	if(r-l >= 2019)
	{
		cout << 0 << endl;
		return 0;
	}

	int ans = int(1e9);

	if(l%2019 < r%2019)
	{
		REP(i,l%2019,r%2019)
		{
			REP(j,i+1,r%2019)
			{
				ans=min(ans,(i*j)%2019);
			}
		}

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

	vi possible;

	while(true)
	{
		possible.pb(l%2019);
		if(l==r%2019) break;
		l++;
		l%=2019;

		// cout << l << endl;
	}

	REP(i,0,possible.size()-1)
	{
		REP(j,i+1,possible.size()-1)
		{
			ans=min(ans,(possible[i]*possible[j])%2019);
		}
	}

	cout << ans << endl;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 998244353;

struct FiniteField {
 private:
  int64 x;
 public:
  FiniteField(int64 raw_x) : x(raw_x) {
    if (x >= P || x < 0) {
    x %= P;
    if (x < 0) x += P;
  }
}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};
ostream& operator<<(ostream& s, const FiniteField& x) { s << x.Value(); return s; }

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

  int n, k;
  cin >> n >> k;
  vector<int> ls(k), rs(k);
  for (int i = 0; i < k; i++) {
    cin >> ls[i] >> rs[i];
  }

  vector<FiniteField> xs(n);
  vector<FiniteField> sums(n + 1);
  xs[0] = 1;
  sums[1] = 1;
  auto sum_fn = [&](int l, int r) -> FiniteField {  // [l, r)
    if (r <= 0) return 0;
    if (l < 0) l = 0;
    return sums[r] - sums[l];
  };
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < k; j++) {
      int x1 = i - rs[j];
      int x2 = i - ls[j];
      xs[i] += sum_fn(x1, x2 + 1);
      // cout << xs[i] << endl;
    }
    // cout << i << " " << xs[i] << endl;

    sums[i + 1] = sums[i] + xs[i];
  }
  cout << xs[n - 1] << endl;
}

Measured memory_bytes: 6344
#include <stdio.h>

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

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



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

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

	if (a + b > c + d) cout << "Left" << endl;
	else if (a + b == c + d) cout << "Balanced" << endl;
	else cout << "Right" << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

d = {}
ans = 0

for a in A:
    if a not in d.keys():
        d[a] = 1
    else:
        d[a] += 1

d = sorted(d.items(), key=lambda x:x[1])

if len(d) > K:
    for i in range(len(d) - K):
        ans += d[i][1]

print(ans)


Measured memory_bytes: 38964
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N;
  unordered_set<int> set;

  cin >> N;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    set.insert(d);
  }

  cout << set.size() << endl;

  return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc139/tasks/abc139_d
// ---------------------------------------------
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}
func smallerst(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}
func max(a []int) (idx, val int) {
	if len(a) == 0 {
		panic("func max requires at least one argument")
	}
	val = a[0]
	for i, aa := range a {
		if aa > val {
			idx, val = i, aa
		}
	}
	return
}
func min(a []int) (idx, val int) {
	if len(a) == 0 {
		panic("func min requires at least one argument")
	}
	val = a[0]
	for i, aa := range a {
		if aa < val {
			idx, val = i, aa
		}
	}
	return
}
func sum(a []int) int {
	res := 0
	for _, v := range a {
		res += v
	}
	return res
}
func isEven(n int) bool            { return n&1 == 0 }
func isOdd(n int) bool             { return n&1 == 1 }
func swap(a int, b int) (int, int) { return b, a }
func fill(a []int, val int) {
	for i := 0; i < len(a); i++ {
		a[i] = val
	}
	return
}
func calcMod(n int) int   { return n % mod }
func sigma(x int) int     { return x * (x + 1) / 2 }
func powInt(a, b int) int { return int(math.Pow(float64(a), float64(b))) }

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

func init() {}
func ru() (n int) {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}
func ri() (n int) {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	b := sc.Bytes()
	neg := false
	if b[0] == 45 {
		neg = true
	}
	for _, v := range b {
		n = n*10 + int(v-48)
	}
	if neg {
		n = -n
	}
	return
}
func rs() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}
func rb() []byte {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Bytes()
}
func pf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(bw, format, a...); err != nil {
		panic(err)
	}
}
func pln(a ...interface{}) {
	if _, err := fmt.Fprintln(bw, a...); err != nil {
		panic(err)
	}
}
func pall(a []int) {
	for _, v := range a {
		fmt.Fprintln(bw, v)
	}
}
func pallol(a []int) {
	s := fmt.Sprint(a)
	if _, err := fmt.Fprintln(bw, s[1:len(s)-1]); err != nil {
		panic(err)
	}
}
func debug(a ...interface{}) {
	s := fmt.Sprint(a)
	if _, err := fmt.Fprintln(os.Stderr, s[1:len(s)-1]); err != nil {
		panic(err)
	}
}
func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1e7), 1e7)
	solve()
	bw.Flush()
}

const (
	// maxInt64  = 9223372036854775807  // 9e18
	// maxInt32  = 2147483647           // 2e9
	// maxUint64 = 18446744073709551615 // 1e19
	inf = 1 << 60
	mod = 1e9 + 7
)

type pair struct{ a, b int }
type point struct{ x, y int }

func solve() {
	n := ri()
	pln(sigma(n - 1))
}


Measured memory_bytes: 2944