akhauriyash/Code-Regression huggingface dataset:
def main():
    try:
        n, c = [int(i) for i in raw_input().strip().split()]
    except ValueError:
        return True
    except EOFError:
        return False
    d = [0 for i in xrange(n)]
    w = [0 for i in xrange(n)]
    for i in xrange(n):
        d[i], w[i] = [int(j) for j in raw_input().strip().split()]
    tot = sum(w)
    foo = 0
    foo = max(foo, tot-d[-1])
    foo = max(foo, tot-c+d[0])
    # <>>
    presum = 0
    suffix = tot
    prefer = 0
    for k in xrange(n-1):
        presum += w[k]
        prefer = max(prefer, presum - d[k])
        suffix -= w[k]
        foo = max(foo, prefer)
        tmp = c - d[k+1]
        foo = max(foo, prefer + suffix - tmp - tmp)
    # ><<
    presum = 0
    suffix = tot
    prefer = 0
    for k in xrange(n-1, 0, -1):
        presum += w[k]
        prefer = max(prefer, presum - (c - d[k]))
        suffix -= w[k]
        foo = max(foo, prefer)
        tmp = d[k-1]
        foo = max(foo, prefer + suffix - tmp - tmp)
    print foo
    return True
    
if __name__ == '__main__':
    while True:
        if not main():
            break


Measured memory_bytes: 11112
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
int main() {
    cin >> N;
    vl P_inv(N + 1);
    for (i = 1; i <= N; i++) {
        ll tmp;
        cin >> tmp;
        P_inv[tmp] = i;
    }
    set<ll> indices;
    indices.insert(0);
    indices.insert(N + 1);
    for (i = N; i >= 1; i--) {
        //cout << P_inv[i] << endl;
        auto larger1 = indices.lower_bound(P_inv[i]);
        auto smaller1 = prev(larger1);
        if ((*larger1) != N + 1) {
            auto larger2 = next(larger1);
            ans += i * (P_inv[i] - *smaller1) * (*larger2 - *larger1);
        }
        if ((*smaller1) != 0) {
            auto smaller2 = prev(smaller1);
            ans += i * (*smaller1 - *smaller2) * (*larger1 - P_inv[i]);
        }
        indices.insert(P_inv[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  string result = "";
  rep(i, s.length()) if (i%2==0) result += s[i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans = 0;
        for (int x = 1; x * x <= i; x++)
        {
            for (int y = x; y + y <= i; y++)
            {
                for (int z = y; z * z <= i; z++)
                {
                    if (x * x + y * y + z * z + x * y + y * z + z * x == i)
                    {
                        if(x == y && y == z) {
                          ans++;
                        } else if(x == y || y == z || z == x && (x != y && y != x )) {
                            ans += 3;
                        } else {
                            ans += 6;
                        }
                    }
                }
            }
        }

        cout << ans << "\n";
    }
}


Measured memory_bytes: 3580
n=int(input())
A=input()
B=input()
ans=1
i=0
while i<n:
  if A[i]==B[i]:
    if i==0:
      ans=ans*3
    elif a==1:
      ans=ans*2
    else:
      ans=ans
    i=i+1
    a=1
  else:
    if i==0:
      ans=ans*6
    elif a==1:
      ans=ans*2
    else:
      ans=ans*3
    i=i+2
    a=2
print(ans%(10**9+7))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pi pair<int, int>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
ll n, a[1010], k;
bool DP[100100];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

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

    for (int i=0; i<=k; i++)
        for (int j=0; j<n; j++)
            if (i >= a[j] && !DP[ i -  a[j] ])
                DP[i] = true;

    cout << (DP[k] ? "First" : "Second") << '\n';
    return 0;
}


Measured memory_bytes: 384
fn main() {
    let n = getnum::<i32>();
    let n = n as usize;
    let a = {
        let mut _a = vec![0; n];
        for x in &mut _a {
            *x = getnum::<i32>();
        }
        _a
    };
    let mut b = a.iter().zip(0..).collect::<Vec<_>>();
    b.sort();
    let mut sum = 0;
    let mut i = 0;
    for (_, num) in b {
        if i % 2 != num % 2 {sum += 1;}
        i += 1;
    }
    println!("{}", sum / 2);
}

fn next_line() -> String {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    input
}

#[allow(dead_code)]
fn getnum<T : std::str::FromStr>() -> T {
    let res = next_line();
    let res = res.trim().parse::<T>().ok().unwrap();
    res
}

#[allow(dead_code)]
fn getvec<T : std::str::FromStr>() -> Vec<T> {
    let res = next_line();
    let res : Vec<T> = res.split_whitespace().map(|x| x.parse::<T>().ok().unwrap()).collect();
    return res;
}

Measured memory_bytes: 6524
import sys
sys.setrecursionlimit(200000)
def doritto(vrijednost):
    global kameni
    global memo
    if memo[vrijednost] != -1:
        return memo[vrijednost]
    if vrijednost == len(kameni) -2:
        return abs(kameni[vrijednost] - kameni[vrijednost+1])
    elif vrijednost == len(kameni) -1:
        return 0
    a = abs(kameni[vrijednost] - kameni[vrijednost+1]) + doritto(vrijednost+1)
    b = abs(kameni[vrijednost] - kameni[vrijednost+2]) + doritto(vrijednost+2)
    memo[vrijednost] = min(a,b)
    return memo[vrijednost]
N = int(input())
kameni = list(map(int,input().split()))
memo = []
for i in range(N):
    memo.append(-1)
print(doritto(0))

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

int main(void){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0] == a[1])cout << a[2] << endl;
    else cout << a[0] << endl;
}

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

int main()
{
	int n; cin >> n;
	string s, t; cin >> s >> t;
	int cnt = 2*n;
	for (int i = 0; i<n; i++) {
		if (s[i] == t[0]) {
			for (int j = 0; i + j < n; j++) {
				if (s[i + j] != t[j])break;
				if (i + j == n - 1) {
					cnt -= j + 1;
					cout<<cnt << endl;
					return 0;
				}
			}
		}
	}

	cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MaxN 250005
#define INF 2140000000
#define eps 1e-9
#define MOD 1000000007

using namespace std;

int N,X,last[MaxN],P,Q,Fact[MaxN],InvFact[MaxN];
int LogPow(int base,int exp)
{
    int ans=1;
    for(int i=0;i<30;i++)
    {
        if(exp&(1<<i))
            ans=(1LL*ans*base)%MOD;
        base=(1LL*base*base)%MOD;
    }
    return ans;
}
int Comb(int k,int n)
{
    if(k>n)
        return 0;
    return ((1LL*Fact[n]*InvFact[k])%MOD*InvFact[n-k])%MOD;
}
int main()
{
    cin>>N;
    for(int i=1;i<=N+1;i++)
    {
        cin>>X;
        if(last[X]!=0)
        {
            P=last[X];
            Q=i;
        }
        last[X]=i;
    }
    Fact[0]=InvFact[0]=1;
    for(int i=1;i<=N+1;i++)
    {
        Fact[i]=(1LL*Fact[i-1]*i)%MOD;
        InvFact[i]=LogPow(Fact[i],MOD-2);
    }
    for(int i=1;i<=N+1;i++)
	{
        int x=(Comb(i,N+1)-Comb(i-1,P+N-Q))%MOD;
		if(x<0)
			x+=MOD;
		cout<<x<<'\n';
	}
    return 0;
}


Measured memory_bytes: 2432
// #pragma GCC optimize(2)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <sstream>
#include <cstring>
#include <set>
#include <cctype>
#include <bitset>
#define IO                       \
    ios::sync_with_stdio(false); \
    // cin.tie(0);                  \
    // cout.tie(0);
using namespace std;
int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};
typedef unsigned long long ULL;
typedef long long LL;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 100003;
const double pi = acos(-1);
int f[maxn];
int size[maxn];
bool vis[maxn];
int ans[maxn];
int find(int v)
{
    if (f[v] == v)
        return v;
    else
        return f[v] = find(f[v]);
}

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    IO;
    int n;
    cin >> n;
    if (n == 1)
        cout << 0;
    else
        cout << 1;
    return 0;
}

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll sx, sy, tx, ty;

	cin>>sx>>sy>>tx>>ty;

	rep(i, tx-sx) cout<<'R';

	rep(i, ty-sy) cout<<'U';

	rep(i, tx-sx) cout<<'L';

	rep(i, ty-sy) cout<<'D';

	cout<<'D';

	rep(i, tx-sx+1) cout<<'R';

	rep(i, ty-sy+1) cout<<'U';

	cout<<"LU";

	rep(i, tx-sx+1) cout<<'L';

	rep(i, ty-sy+1) cout<<'D';

	cout<<'R'<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n[10],i,j,temp;
    for(i=0;i<10;i++)
    {
        scanf("%d",&n[i]);
    }
    for(i=0;i<10;i++)
    {
        for(j=0;j<9;j++)
        {
            if(n[j]<n[j+1])
            {
                temp=n[j];
                n[j]=n[j+1];
                n[j+1]=temp;
            }

        }

    }
    for(j=0;j<3;j++)
    printf("%d\n",n[j]);
    return 0;
}


Measured memory_bytes: 2100
from random import randint

D = int(input())
C = [int(i) for i in input().split()]
S = [[int(i) for i in input().split()] for j in range(D)]

def score_calc(T):
    total = 0
    last = [0] * 26
    for i in range(1, D+1):
        t = T[i-1]
        total += S[i-1][t-1]
        last[t-1] = i
        for j in range(26):
            total -= C[j] * (i - last[j])
    return total

total = 0
last = [0] * 26
ans = []
for i in range(1, D+1):
    score = [0] * 26
    for t in range(26):
        score[t] += S[i-1][t]
        for j in range(26):
            if j != t:
                score[t] -= C[j] * (i - last[j])
    total += max(score)
    last[score.index(max(score))] = i
    ans.append(score.index(max(score))+1)

N = 1000
Q = [[randint(0, (D-1)), randint(0, 25)] for i in range(N)]
for d, q in Q:
    old = ans[d]
    ans[d] = q + 1
    if score_calc(ans) > total:
        total = score_calc(ans)
    else:
        ans[d] = old

for i in range(D):
    print(ans[i])

Measured memory_bytes: 9888
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int h, w;
  cin >> h >> w;
  vector<vector<string>> a(h + 2, vector<string>(w + 2));
  for (int i = 0; i < h + 2; i++) {
	for (int j = 0; j < w + 2; j++) {
	  a[i][j] = '#';
	}
  }
  vector<vector<string>> b(h, vector<string>(w));
  for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {
	  char t;
	  cin >> t;
	  a[i+1][j+1] = t;
	}
  }
  for (int i = 0; i < h + 2; i++) {
	for (int j = 0; j < w + 2; j++) {
	  cout << a[i][j];
	}
	cout << endl;
  }
  return 0;
}



Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int INF = 1000;
int main() {
  string s;
  std::cin >> s;
  int ans = INF;
    for (int i =0;i<s.size()-2;i++ ){
      ans = min(ans,abs(753-stoi(s.substr(i,3))));
    }
    std::cout << ans << '\n';
  return 0;
}


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9 + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, l;
  cin >> n >> l;

  int minv = INF;
  int tas, sumtas = 0;
  for (int i = 1; i <= n; ++i) {
    tas = l + i - 1;
    sumtas += tas;
    chmin(minv, abs(tas));
  }

  cout << (sumtas >= 0 ? sumtas - minv : sumtas + minv) << "\n";

  return 0;
}

Measured memory_bytes: 256
#define _CRT_NO_SECURE_WARNINGS
#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <string>
#include <iomanip>
#include <set>
#include <random>
#include <queue>
#include <map>
#include <ctime>
#include <sstream>
#include <cstdlib>
using namespace std;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std; int INF = 1e6; typedef long long ll; typedef double d; typedef unsigned long long ull;


void solve() {
	string s;
	cin >> s;
	if (s == "ABC") {
		cout << "ARC" << endl;
		return;
	}
	cout << "ABC" << endl;
}

int main() {
	//cout << fixed << setprecision(10);
	ios_base::sync_with_stdio(false);
	//freopen("solver.txt", "r", stdin);
	cin.tie(0);
	solve();
	return 0;
}

Measured memory_bytes: 3112
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
vector<int> e[200005];
int n;
pair<int,int> last(int u){
  queue<pair<int,int>> que;
  que.push(make_pair(u, 1));
  vector<int> vis(n);
  pair<int,int> p;
  vis[u] = true;
  while(!que.empty()){
    p = que.front();
    que.pop();
    //cout << p.first << " ";
    for(auto s:e[p.first]){
      if(vis[s]) continue;
      que.push(make_pair(s, p.second+1));
      vis[s] = true;
    }
  }
  //cout << endl;
  return p;
}
void solve(long long N, std::vector<long long> a, std::vector<long long> b) {
  n = N;
  rep(i, N-1) a[i]--,b[i]--, e[a[i]].push_back(b[i]), e[b[i]].push_back(a[i]);
  auto f = last(0);
  auto g = last(f.first);
  if(g.second % 3 == 2){
    cout << "Second"<<endl;
  }else {
    cout << "First"<<endl;
  }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N - 1);
  std::vector<long long> b(N - 1);
  for (int i = 0; i < N - 1; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(N, std::move(a), std::move(b));
  return 0;
}


Measured memory_bytes: 17532
N, W = gets.split.map(&:to_i)

WV = N.times.map { gets.split.map(&:to_i) }

dp = Hash.new { 0 }
dp[0] = 0
N.times do |i|
  w, v = WV[i]
  new_dp = dp.dup
  dp.each do |cw, cv|
    if cw + w <= W
      to_v = dp[cw + w]
      new_v = cv + v
      new_dp[cw + w] = new_v > to_v ? new_v : to_v
    end
  end
  dp = new_dp
end
ans = dp.values.max
puts ans

Measured memory_bytes: 9340
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef pair<int,ii> iii;
typedef pair<int, iii> iiii;
typedef pair<double, ii> dii;
typedef long long ll;
typedef pair<ll, ii> lii;
const int INF = 1000000000;
const double EPS = 1e-9;
#define LSOne(S) (S & (-S))
int mods(int a, int b) { return (b + (a%b)) % b; }

int n, m, len, idx, dp[3005][3005];
char lcs[3005];
string s, t;

int LCS(int a, int b) {
    if (a == 0 || b == 0) return 0;
    if (dp[a][b] != -1) return dp[a][b];

    if (s[a-1] == t[b-1]) return dp[a][b] = 1 + LCS(a-1, b-1);
    else return dp[a][b] = max(LCS(a-1, b), LCS(a, b-1));
}

void construct(int a, int b) {
    while (a && b) {
        if (s[a-1] == t[b-1]) {
            lcs[--idx] = s[a-1];
            a--; b--;
        }
        else if (dp[a-1][b] > dp[a][b-1]) a--;
        else b--;
    }
}

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

    cin >> s >> t;

    memset(dp, -1, sizeof(dp));
    len = LCS(s.size(), t.size());
    idx = len;
    construct(s.size(), t.size());

    for (int i = 0; i < len; i++)
        cout << lcs[i];
    cout << '\n';
    
    return 0;
}


Measured memory_bytes: 35968
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i, 0, n){
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 0;
    for(int i = 30; i >= 1; i--){
        for(auto it = mp.begin(); it != mp.end(); it++){
            if(it -> second == 0) continue;
            int op = (1LL << i) - it -> first;
            if(op < it -> first) break;
            if(mp[op] == 0) continue;
            if(op == it -> first){
                ans += mp[op] / 2;
                mp[op] %= 2;
            }else{
                int tmp = min(it -> second, mp[op]);
                ans += tmp;
                it -> second -= tmp;
                mp[op] -= tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 36736
N, Q = map(int, input().split())
S = input()
sum = []
sum.append(0)
for i in range(1, len(S)):
    if S[i-1] == "A" and S[i] == "C":
        sum.append(sum[i-1] + 1)
    else:
        sum.append(sum[i-1])
for j in range(Q):
    l, r = map(int, input().split())
    print(sum[r-1]-sum[l-1])


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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, t, a[N];

int main()
{
    scanf("%d", &n);
    for(int i = 2; i <= n; i++){
        scanf("%d", &t);
        a[t]++;
    }
    for(int i = 1; i <= n; i++)
        printf("%d\n", a[i]);
    return 0;
}


Measured memory_bytes: 4544
a,b = [int(i) for i in input().split()]
N = int(input())

ans = 0

for l in range(N):
    s,f = [int(i) for i in input().split()]
#    if f <= a or b <= s:
    if a < f and s < b:
        ans = 1
        break

print(ans)


Measured memory_bytes: 5604
k, n = map(int, input().split())
cnt = [0] * (n + 1)
cmb = 0
a = list(map(int, input().split()))

ans = 10 ** 6 + 1
for i in range(n):
  r_idx = ((i+1)%n)
  r_ans = a[i]+(k-a[r_idx]) if a[i] < a[r_idx] else abs(a[r_idx]-a[i])
  l_idx = (i-1+n)%n
  l_ans = (k-a[i])+a[l_idx] if a[i] > a[l_idx] else a[l_idx]-a[i]

  ans = min([ans, r_ans, l_ans])

print(ans)


Measured memory_bytes: 33892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  rep(i,n-1){
    if(s[i]!=s[i+1]){
      chmin(ans,max(i+1,n-i-1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3732
#include <iostream>
using namespace std;
int main() {
    int K, X, j = 1;
    cin >> K >> X;
    if(K == 0)
        cout << 0;
    else{
        for(int i = 0; i < K * 2 - 1; i++){
            cout << X - (K - j) << " ";
            j++;
        }
    }
    return 0;
    }

Measured memory_bytes: 256
program count_order
  implicit none
  integer :: n, p(8) = 0, q(8) = 0, i
  integer :: a = 0, b = 0
  integer :: x(8) = (/1,2,3,4,5,6,7,8/)
  read(*,*) n
  read(*,*) p(1:n)
  read(*,*) q(1:n)
  call perm(x(1:n),[integer::])
  write(*,'(i0)') abs(a-b)
contains
  recursive subroutine perm(lin, lout)
    integer, intent(in) :: lin(:), lout(:)
    integer :: i
    if (size(lin) == 0) then
      a = a+cmp(p,lout)
      b = b+cmp(q,lout)
    else
      do i = 1, size(lin)
        call perm(pack(lin, lin /= lin(i)), [lout, lin(i)])
      end do
    end if
  end
  integer function cmp(x,y)
    integer, intent(in) :: x(:), y(:)
    integer :: i
    cmp = 0
    do i = 1, n
      if (x(i) > y(i)) then
        cmp = 1
        return
      else if (x(i) < y(i)) then
        return
      end if
    end do
  end
end program count_order

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

using namespace std;

#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, V, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

ll N, K;

ll mypow(ll x, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) res = res * x;
        x *= x;
        n >>= 1;
    }
    return res;
}

int main() {
    cin >> N >> K;
    if(K % 2) {
        printf("%lld", mypow(N / K, 3));
    } else {
        ll div2 = N / K;
        if(N % K >= K / 2) div2++;
        ll ans = mypow(div2, 3) + mypow(N / K, 3);
        printf("%lld", ans);
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

X = []
for i in range(n):
    X += [i+1]*A[i]

for i in range(h):
    x = X[w*i:w*(i+1)]
    if i%2 == 0:
        print(*x)
    else:
        x.reverse()
        print(*x)


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

int x[110];
int main(){
  int N,K;
  cin >> N >> K;
  
  for (int i=0;i<N;i++) cin >> x[i];
  
  int sum=0;
  for (int i=0;i<N;i++){
     sum+=2*min(x[i],K-x[i]);
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
#define cube(x) (x) * (x) * (x)

const int INF = 1e9;

using namespace std;


int main() {
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    REP(i, n) cin >> a[i];
    REP(i, n)
        for(int j = n - 1; j > i; j--)
            if(a[j] < a[j-1]){
                swap(a[j], a[j-1]);
                count++;
            }

    REP(i, n-1) {
        cout << a[i] << " ";
    }

    cout << a[n-1] << endl << count << endl;

    return 0;
}

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

int f(int n){
  int sum=0;
  while(n>0){
    sum += n % 10;
    n /= 10;
  }
  
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  if(N % f(N)==0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a) ;i < (b) ;i++)
#define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) 
int main(){
	string s ;
	cin>>s ;
	int ans = 0 ;
	string tar = "CODEFESTIVAL2016" ;
	for (int i = 0 ;i < 16; i++)
		if (s[i] != tar[i])ans++ ;
	cout<<ans<<endl ;
	return 0 ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] l = new long[n + 1];
        l[0] = 2;
        l[1] = 1;
        for (int i = 2; i <= n; i++) {
            l[i] = l[i - 1] + l[i - 2];
        }
        System.out.println(l[n]);
    }
}


Measured memory_bytes: 22864
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){
	int n;
	while(cin >> n){
		if(n == 0)break;
		int menu[15];
		fill_n(menu, 15, 0);
		rep(i, n){
			int a;
			cin >> a;
			menu[a]++; 
		}
		rep(i, 10){
			if(menu[i] == 0){
				cout << "-" << endl;
			}else{
				rep(j, menu[i]){
					cout << "*";
				}
				cout << endl;
			}
		}
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >>n;
  int d[n];
  for(int i=0; i<n; i++) cin >>d[i];
  
  int sum=0;
  for(int i=0; i<n; i++){
    for(int j=i+1; j<n; j++){
      sum+=d[i]*d[j];
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#define inf 99999999
using namespace std;
typedef long long ll;
const int MAX=100000+10;
ll s[MAX],dis[MAX];
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    ll n,sum=0,x,flag=1,k=0;
    scanf("%I64d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&s[i]);
        sum+=s[i];
    }
    if(sum%((n*(n+1)/2))!=0){
        cout<<"NO"<<endl;
        return 0;
    }
    x=sum/((n*(n+1))/2);//cout<<x<<endl;
    dis[1]=s[1]-s[n];
    for(int i=2;i<=n;i++)
        dis[i]=s[i]-s[i-1];
    for(int i=1;i<=n;i++){
        if((x-dis[i])<0||(x-dis[i])%n){
            flag=0;break;
        }
        else{
            k+=(x-dis[i])/n;
        }
    }
    if(k!=x)    flag=0;
    if(flag)    cout<<"YES"<<endl;
    else        cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 1792
/**
 * File              : B.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 08.12.2019
 * Last Modified Date: 08.12.2019
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    int res = 0;
    for (int i = 0; i < (int)s.size()>>1; i++) {
        if (s[i] != s[s.size() -1 - i])res++;
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

#define ll long long int

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

    int n,x,y;
    cin>>n>>x>>y;
    int graph[n]={};
    
    for (int i = 1; i < n; ++i)
    {
        for (int j = i+1; j < n+1; ++j)
        {
            graph[min( (j-i), abs(i-x)+abs(j-y)+1 )]++;
        }
    }
    for (int i = 1; i < n; ++i)
    {
        cout<<graph[i]<<endl;
    }
    
    


}



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

int main()
{
    int n, a, b;

    cin >> n >> a >> b;
    int max = a + b;
    string s;
    cin >> s;
    int pass = 0;
    int b_count = 0;
    for (char a : s)
    {
        if (a == 'b')
            b_count++;
        if (a == 'a' && pass < max)
        {
            cout << "Yes" << endl;
            pass++;
            continue;
        }
        if (a == 'b' && pass < max && b_count <= b)
        {
            cout << "Yes" << endl;
            pass++;
            continue;
        }
        cout << "No" << endl;
    }
}


Measured memory_bytes: 896
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  																						   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;	
const int mod = 1e9+7;																							   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS//////////////////////////////////////////////////////

int N, A, B, C;
int tab[100];

///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

int DFS(int n, int a, int b, int c){
	if(n == N){
		if(0 < min({a, b, c})){
			return abs(A-a) + abs(B-b) + abs(C-c) - 30;
		}
		else return 1e8;
	}
	else{
		int ret0 = DFS(n+1, a, b, c);
		int ret1 = DFS(n+1, a+tab[n], b, c) + 10;
		int ret2 = DFS(n+1, a, b+tab[n], c) + 10;
		int ret3 = DFS(n+1, a, b, c+tab[n]) + 10;
		return min({ret0, ret1, ret2, ret3});
	}	
}

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	cin >> N >> A >> B >> C;
	for(int i = 0; i < N; i++){
		cin >> tab[i];
	}
	
	cout << DFS(0, 0, 0, 0) << endl;
	
	
	
	
	
	
	

						
	return 0;
}


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

using namespace std;

int N,Z,W;
int a[2005];

int main() {

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N>>Z>>W;

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

if(N==1){
  cout<<abs(a[0]-W)<<endl;
  return 0;
}

int ans1=abs(a[N-1]-W);
int ans2=abs(a[N-1]-a[N-2]);

cout<<max(ans1,ans2)<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <map>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    int k;
    cin >> n >> k;
    cout << (n - k + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val (D, X) = readLine()!!.split(" ").map { it.toInt() }
    val A = (0 until N).map { readLine()!!.toInt() }

    println((1..N).map { i -> (1..D).map { it * A[i - 1] }.filter { it < D }.map { 1 }.sum() }.sum() + X + N)
}

Measured memory_bytes: 37980
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        
        if (A - 1 > B) {
            
            System.out.println(A + A - 1);
        } else if (B - 1 > A) {
            
            System.out.println(B + B - 1);
        } else {
            
            System.out.println(A + B);
        }
        
        sc.close();
    }
    
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(void){
  char a[100],b[100];
  scanf("%s %s",a,b);
  strcat(a,b);
  int num,hei;
  num=atoi(a);
  hei=sqrt(num);
  if(hei*hei==num){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}
  

Measured memory_bytes: 128
#include <stdio.h>

void func (int, int);
int masu[16+1][16+1];
int cnt;
int w,h;

int main (void)
{
	int i,j;
	int n,y,x;
	
	scanf ("%d %d",&w,&h);
	
	while ( ! (w == 0 && h == 0) ) 	{
		for (i=1; i<=h; i++) {
			for (j=1; j<=w; j++) {
				masu[i][j]=0;
			}
		}
		
		scanf ("%d",&n);
		
		for (i=0; i<n; i++) {
			scanf ("%d %d",&x,&y);
			masu[y][x]=1;
		
		}
		
		cnt=0;
		masu[1][1]=1;
		func (1, 1);
		printf ("%d\n",cnt);
		scanf ("%d %d",&w,&h);
	}
	return 0;
}

void func (int y1, int x1)	{
	if (y1 == h && x1 == w) 	{
		cnt++;
	}
	else {
		if (y1+1 <= h && masu[y1+1][x1] == 0) {
			func (y1+1,x1);
		}
		if (x1+1 <= w && masu[y1][x1+1] == 0) {
			func (y1,x1+1);
		}
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, C;
    int ans = 1e17;
    cin >> N >> C;
    vector<vector<int>> D(C, vector<int>(C));
    REP(i, C){
        REP(j, C){
            cin >> D[i][j];
        }
    }
    vector<map<int, int>> A(3);
    REP(i, N){
        REP(j, N){
            int color;
            cin >> color;
            color--;
            if(A[(i + j) % 3].count(color) != 0){
                A[(i + j) % 3][color] += 1;
            }else{
                A[(i + j) % 3][color] = 1;
            }
        }
    }
    REP(i, C){
        REP(j, C){
            REP(k, C){
                int sum = 0;
                if(i == j || j == k || k == i){
                    continue;
                }
                for(auto x: A[0]){
                    sum += D[x.first][i] * x.second;
                }
                for(auto y: A[1]){
                    sum += D[y.first][j] * y.second;
                }
                for(auto z: A[2]){
                    sum += D[z.first][k] * z.second;
                }
                ans = min(ans, sum);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int cmpfunc (const void * a, const void * b)
{
    if( *(long long int*)a - *(long long int*)b < 0 )
        return 1;
    if( *(long long int*)a - *(long long int*)b > 0 )
        return -1;
    return 0;
}// large from small

int main(){
  long long int n,i,c;
  scanf("%lld",&n);
  long long int a[n],b[n],aminusb[n];
  long long int atotal = 0;
  long long int btotal = 0;
  long long int bminusa = 0;
  for(i=0;i<n;i++) {
    scanf("%lld",&a[i]);
    atotal += a[i];
  }
  for(i=0;i<n;i++) {
    scanf("%lld",&b[i]);
    btotal += b[i];
    if(b[i]>a[i]) {
      bminusa += b[i]-a[i];
      aminusb[i] = 0;
      c++;
    } else {
      aminusb[i] = a[i]-b[i];
    }
  }
  if(btotal > atotal) {
    printf("%d\n",-1);
  } else {
    qsort(aminusb,n,sizeof(long long int),cmpfunc);
    i = 0;
    while(bminusa > 0) {
      bminusa -= aminusb[i];
      i++;
      c++;
    }
    printf("%lld\n",c);
  }
  return 0;
}


Measured memory_bytes: 3068
H, W = list(map(int,input().split()))
s = []
for i in range(H):  s.append(input())
def solve():
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                flg = 1
                if i >= 1:
                    if s[i - 1][j] == "#":
                        flg = 0
                if i < H - 1:
                    if s[i + 1][j] == "#":
                        flg = 0
                if j >= 1:
                    if s[i][j - 1] == "#":
                        flg = 0
                if j < W - 1:
                    if s[i][j + 1] == "#":
                        flg = 0
                if flg:  return "No"
    return "Yes"
ans = solve()
print(ans)

Measured memory_bytes: 65428
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

int l,r,ans=2019;

int read(){
	int t=1,s=0;
	char c=getchar();
	while((c>'9'||c<'0')&&c!='-')c=getchar();
	if(c=='-')t=-1,c=getchar();
	while(c>='0'&&c<='9')
	s=s*10+c-'0',c=getchar();
	return s*t;
}

int main(void){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d %d",&l,&r);
	int l_mod=l%2019;
	int r_mod=r%2019;
	for(int i=0;i<=2019*2;i++){
		if(l+i>r)break;
		for(int j=i+1;j<=2019*2;j++){
			if(l+j>r)break;
			int ll,rr;
			ll=(l+i)%2019;
			rr=(l+j)%2019;
			ans=min(ans,(ll*rr)%2019);
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
bool u1[100], u2[100];
int main(){
	int h, w; cin >> h >> w;
	fill(u1, u1 + h, true);
	fill(u2, u2 + w, true);
	char mp[100][100];
	rep(i, h) {
		string s;
		cin >> s;
		rep(j, w) {
			mp[i][j] = s[j];
			if (s[j] == '#') {
				u1[i] = u2[j] = false;
			}
		}
	}
	rep(i, h) {
		if (u1[i]) {
			continue;
		}
		rep(j, w) {
			if (u2[j])continue;
			cout << mp[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char l;
  cin >> l;
  if (l == 'a'||l == 'i'||l == 'u'||l == 'e'||l == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

const int N=1e5+5;

int t,n,a[N],mem[N],k;

int dp(int pos)
{
    if (pos==n-1)return 0;
    if (mem[pos]!=-1)return mem[pos];
    int ans=1e9+5;
    for (int i=1;i<=k;i++)
    {
        if (pos+i>=n)break;
        ans=min(ans,abs(a[pos]-a[i+pos])+dp(pos+i));
    }
    return mem[pos]=ans;
}

int main()
{
    t=1;
    while(t--)
    {
        memset(mem,-1,sizeof mem);
        cin >> n >> k;
        for (int i=0;i<n;i++)
        {
            cin >> a[i];
        }
        cout << dp(0) << endl;
    }
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
const int inf = 1000000000; // 10^9 Ten to the power of nine.
/**** Type Define ****/
 
   int main(){
       ll a,b,c,k;
       cin>>a>>b>>c>>k;
       if(a>=k){cout<<k<<endl;}
        else if((a+b)>=k){cout<<a<<endl;}
        else{cout<<a-(k-a-b)<<endl;}
   }



Measured memory_bytes: 3604
h, w = map(int, input().split())
ls = [input().strip() for _ in range(h)]
counts = [[[-1] * w for _ in range(h)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        if ls[y][x] == '#':
            counts[0][y][x] = 0
            counts[2][y][x] = 0
        else:
            if x == 0:
                counts[0][y][x] = 1
            else:
                counts[0][y][x] = counts[0][y][x - 1] + 1
            if y == 0:
                counts[2][y][x] = 1
            else:
                counts[2][y][x] = counts[2][y - 1][x] + 1

        yy = h - 1 - y
        xx = w - 1 - x
        if ls[yy][xx] == '#':
            counts[1][yy][xx] = 0
            counts[3][yy][xx] = 0
        else:
            if xx == w - 1:
                counts[1][yy][xx] = 1
            else:
                counts[1][yy][xx] = counts[1][yy][xx + 1] + 1
            if yy == h - 1:
                counts[3][yy][xx] = 1
            else:
                counts[3][yy][xx] = counts[3][yy + 1][xx] + 1

res = 0
for y in range(h):
    for x in range(w):
        val = -3
        for i in range(4):
            val += counts[i][y][x]
        res = max(res, val)
print(res)

Measured memory_bytes: 184024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    char ch;
    cin >> ch;
    if('A'<=ch&&ch<='Z'){
        cout << "A\n";
    }
    else{
        cout << "a\n";
    }
    return 0;
}

Measured memory_bytes: 3652
/*
    _____
  .'|||||'.
 /  >   <  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
    |||||
*/

#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cstdio>
#include<set>
#include<map>
#include<vector>
#include<cstring>
#include<stack>
#include<cmath>
#include<queue>
using namespace std;
#define CL(x,v); memset(x,v,sizeof(x));
#define INF 0x3f3f3f3f
#define LL long long
#define REP(i,r,n) for(int i=r;i<=n;i++)
#define RREP(i,n,r) for(int i=n;i>=r;i--)
int n,v[1100];
int main()
{
    memset(v,0,sizeof(v));
    scanf("%d",&n);
    for (int i=1;i<=9;i++)
        for (int j=1;j<=9;j++)
        v[i*j]=1;
    if (v[n]) printf("Yes\n"); else printf("No\n");
    return(0);
}


Measured memory_bytes: 256