akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

template<typename T>
struct BIT{
    int n;
    vector<T> dat;
    BIT(int n) : n(n), dat(n+1,0){}
    void add(int x, T val){
        for(int i = x+1; i <= n; i += (i & -i)) dat[i] += val;
    }
    T sum(int x){
        T ret = 0;
        for(int i = x+1; i > 0; i -= (i & -i)) ret += dat[i];
        return ret;
    }
    T sum(int a, int b){
        return sum(b) - sum(a-1);
    }
};


int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n,k; cin >> n >> k;
    vi p(n+1);
    rep(i,n) cin >> p[i];
    p[n] = n;

    vi s(n);
    ll mx = -1, cnt = 0;
    rep(i,n){
        if(mx < p[i]){
            cnt++;
            mx = p[i];
        }else{
            cnt = 1;
            mx = p[i];
        }
        if(cnt >= k) s[i-k+1] = 1;
    }
    REP(i,1,n) s[i] += s[i-1];
    // debug(s)

    multiset<ll> st;
    ll ans = n-k+1;
    REP(i,1,k) st.insert(p[i]);
    REP(i,1,n-k+1){
        // debug(i,p[i-1], *st.begin(), *st.rbegin(), p[k+i-1]);
        if((p[i-1] < *st.begin() && *st.rbegin() < p[k+i-1]) ||
           (s[i-1] < s[i] && s[i] >= 2)){
            ans--;
        }
        st.erase(p[i]);
        st.insert(p[k+i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    string s;
    cin >> s;
    
    bool oneC = false;
    if(s[0] != 'A') {
        cout << "WA";
        return 0;
    } 
    
    int cnt = 0;
    for(int i = 1; i < s.size(); ++i){
        if(isupper(s[i])){
            if(i == 1 || i == s.size() - 1 || s[i] != 'C'){
            cout << "WA";
            return 0;
            }
        ++cnt;
        }
    
    }
    
    if (cnt != 1) {
        cout << "WA";
        return 0;
    }
    
    cout << "AC";
    return 0;

}
    
    

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n, 0);
    ll ans = 0;
    map<int, int> tmp;
    for(int i = 0; i< n; i++){
        cin >> a[i];
        tmp[a[i]]++;
        ans += a[i];
    }
    int q;
    cin >> q;
    for(int i = 0; i< q; i++){
        int b, c;
        cin >> b >> c;

            ans += (c-b)*tmp[b];
            tmp[c] += tmp[b];
            tmp[b] = 0;
            cout << ans << endl;
    }
    
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=201234;

int n,nw,nw2,a2;
ll k,res,a[64][51][51],b[64][51];

int main()
{
    scanf("%d %lld",&n,&k);
    for(int i=1; i<=n; ++i)
    {
        for(int j=1; j<=n; ++j){
            scanf("%d",&a2);
            a[nw][i][j]=a2;
        }
        b[nw2][i]=1;
    }
    while(k)
    {
        if(k&1)
        {
            ++nw2;
            for(int i=1; i<=n; ++i)
            {
                for(int k=1; k<=n; ++k)
                {
                    b[nw2][i]+=b[nw2-1][k]*a[nw][k][i];
                    b[nw2][i]%=MOD;
                }
            }
        }
        k>>=1;
        ++nw;
        for(int i=1; i<=n; ++i)
        {
            for(int j=1; j<=n; ++j)
            {
                for(int k=1; k<=n; ++k)
                {
                    a[nw][i][j]+=a[nw-1][i][k]*a[nw-1][k][j];
                    a[nw][i][j]%=MOD;
                }
            }
        }
    }
    for(int i=1; i<=n; ++i)
        res=(res+b[nw2][i])%MOD;
    printf("%lld",res);
    return 0;
}


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

using namespace std;

vector<vector<int>> G;

int main() {
  int N, Q;
  cin >> N >> Q;
  G.resize(N);

  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  vector<int64_t> score(N, 0);

  for (int i = 0; i < Q; i++) {
    int64_t p, x;
    cin >> p >> x;
    p--;
    score[p] += x;
  }

  struct Node {
    int v;
    int parent;
    int64_t score;
    Node(int v, int p, int64_t s) : v(v), parent(p), score(s) {}
  };

  vector<int64_t> results(N, 0);
  queue<Node> q;
  q.push(Node(0, 0, 0));

  while (!q.empty()) {
    Node node = q.front();
    q.pop();
    node.score += score[node.v];
    results[node.v] = node.score;

    for (int v2 : G[node.v]) {
      if (v2 == node.parent) continue;
      Node next(v2, node.v, node.score);
      q.push(next);
    }
  }

  for (int i = 0; i < N; i++) {
    cout << results[i];
    if (i + 1 < N) {
      cout << " ";
    } else {
      cout << endl;
    }
  }


  return 0;
}


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

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    for (int i=0; i<n; ++i) {
        int a, b; cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

adj = [[] for i in range(n)]

for i in range(m):
    s, t = map(int, input().split())
    adj[s].append(t)
    adj[t].append(s)

isVisited = [False] * n

CC = [None] * n


def dfs(u, group):
    path = []
    path.append(u)
    isVisited[u] = True
    CC[u] = group
    while path:
        u = path[-1]
        if adj[u]:
            v = adj[u].pop(0)
            if not isVisited[v]:
                isVisited[v] = True
                CC[v] = group
                path.append(v)
        else:
            path.pop()

def makeCC(group):
    for i in range(n):
        if not isVisited[i]:
            dfs(i, group)
            group += 1

def isConnected(v1, v2):
    if CC[v1] == CC[v2]:
        print('yes')
    else:
        print('no')


makeCC(0)


q = int(input())

for i in range(q):
    s, t = map(int, input().split())
    isConnected(s, t)

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

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

  c = a * b % 2 ;
 
  if (c == 0 ) {
    cout << " Even " << endl;
  }
  else {
      cout << " Odd " << endl;
    }
  }

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long long ll;

void solve()
{
	char ch;
	cin>>ch;
	if (ch>='a' && ch<='z') {
		cout << "a\n";
	}
	else {
		cout << "A\n";
	}
}

int main()
{
	int t=1;
	// cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll n;
ll L[N+5];

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

  n*=2;
  afor(i,1,n)cin>>L[i];

  sort(L+1,L+n+1);

  ll ans = 0;
  for(int i=1;i<=n;i+=2)ans+=L[i];

    cout<<ans;




  
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s,t;
long long int mem[3005][3005];
long long int  dp(long long int  i,long long int  j){
	if(i>=s.size())
	return 0;
	if(j>=t.size())
	return 0;
	if(mem[i][j]!=-1)
	return mem[i][j];
	long long int  x = dp(i+1,j);
	x = max(x,dp(i,j+1));
	if(s[i]==t[j])
	x = max(x,1+dp(i+1,j+1));
	mem[i][j]=x;
	return x;
}
string ans="";
void lcs(long long int  i,long long int  j){
	//cout<<" at i: "<<i<<" j: "<<j<<endl;
	if(i>=s.size() || j>=t.size()){
		return;
	}
	if(s[i]==t[j]){
		ans = ans+s[i];
		lcs(i+1,j+1);
	}
	else{
		if(mem[i+1][j]>mem[i][j+1]){
			lcs(i+1,j);
		}
		else{
			lcs(i,j+1);
		}
	}
	return;
}

int  main(){
	cin>>s>>t;
	memset(mem,-1,sizeof(mem));
	long long int  x=dp(0,0);
	lcs(0,0);
	/*for(long long int  i=0;i<s.size();i++)
	{
		for(long long int  j=0;j<t.size();j++)
		{
			print f("%3d ",mem[i][j]);
		}
		cout<<endl;
	}*/
	cout<<ans;
	return 0;
}

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

struct num {
	int sum;
	int id;
} odd[100010],even[100010];

int n;
int v[100010];
int ans1,ans2;
int maxn;

bool cmp(num a,num b) {
	if(a.sum!=b.sum)
		return a.sum>b.sum;
	return a.id<b.id;
}

int main() {
	cin>>n;
	for(int i=1; i<=100001; i++) {
		odd[i].id=i;
		even[i].id=i;
		odd[i].sum=0;
		even[i].sum=0;
	}
	for(int i=1; i<=n; i++) {
		cin>>v[i];
		maxn=max(v[i],maxn);
		if(i%2==1) odd[v[i]].sum++;
		else even[v[i]].sum++;
	}
	maxn++;
	sort(odd+1,odd+maxn,cmp);
	sort(even+1,even+maxn,cmp);
//	cout<<odd[1].sum<<" ----> "<<odd[1].id<<endl<<even[1].sum<<" ----> "<<even[1].id<<endl;
	ans1=(n%2==0?n:n+1)/2-odd[1].sum;
	ans2=(n%2==0?n:n-1)/2-even[1].sum;
	if(even[1].id==odd[1].id) {
		ans1+=(n%2==0?n:n-1)/2-even[2].sum;
		ans2+=(n%2==0?n:n+1)/2-odd[2].sum;
	} else {
		ans1+=(n%2==0?n:n-1)/2-even[1].sum;
		ans2+=(n%2==0?n:n+1)/2-odd[1].sum;
	}
	cout<<min(ans1,ans2)<<endl;
	return 0;
}
 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt();

    vector <vector<ll>> dp(n, vector<ll>(3,0));

    for(ll i=0; i<n; i++)
    {
        ll a, b, c;
        cin >> a >> b >> c;

        if(!i)
        {
            dp[i][0] = a;
            dp[i][1] = b;
            dp[i][2] = c;
        }

        else
        {
            dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
            dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
            dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
        }
    }

    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;
import java.math.*;
public class Main{
        public static void main(String[] args){
                final Scanner cin=new Scanner(System.in);
                long a=cin.nextLong();
                double b=cin.nextDouble();
                long k=(long)Math.round(b*100);
                long mul=(a*k);
                System.out.print(mul/100);
        }   
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  int m = 10000000, t;
  for(int i = -100; i <= 100; i++) {
    t = 0;
    for(auto x : a)
      t += (x - i) * (x - i);
    m = min(m, t);
  }
  cout << m << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y) {
  ll tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}
int main(){
  ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll n;
  cin >> n;
  cout << a[n-1] << endl;
}

Measured memory_bytes: 256
A, B, K = map(int, raw_input().split())
numberlst = []
for i in range(0, K):
	if A+i > B: break
	numberlst.append(A+i)
for i in range(0, K):
	if A > B-i or B-i in numberlst: break
	numberlst.append(B-i)
numberlst.sort()
for i in range(0, len(numberlst)):
	print numberlst[i]

Measured memory_bytes: 28652
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	cin >> a;
	int ans = 0;
	for (int i = 1; i <= a; i += 2) {
		int cnt = 0;
		rep(j, 1, i + 1) {
			if (i % j == 0)cnt++;


		}
		if (cnt == 8)ans++;
	}

	cout << ans << endl;

}
	

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

int main() {
	int r, g, b;
	cin >> r >> g >> b;

	int result = r * 100 + g * 10 + b;

	if (!(result % 4))
		cout << "YES";
	else
		cout << "NO";

	return 0;
}

Measured memory_bytes: 256
from itertools import product
D, G = map(int, input().split())
P, C = zip(*[map(int, input().split()) for _ in range(D)])
INF = 10**18
ans = INF
for bit in product((0, 1), repeat=D):
    p = list(P)
    cnt = 0
    score = 0
    for i in range(D):
        if bit[i]:
            score += C[i]
            score += P[i]*100*(i+1)
            cnt += P[i]
            p[i] = 0

    if score+sum(p[i]*100*(i+1) for i in range(D)) < G:
        continue

    idx = D-1
    while score < G:
        while not p[idx]:
            idx -= 1
        score += 100*(idx+1)
        p[idx] -= 1
        cnt += 1
    if cnt < ans:
        ans = cnt
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    ll count=0;
    for(int i=0;i<n;i++){
        count+=2*min(k-x[i],x[i]);
    }
    cout<<count<<endl;

}


Measured memory_bytes: 256
N=int(input())
S=input()
L=[0]*N
R=[0]*N
Lcnt=0
Rcnt=0
for i in range(1,N):
    if(S[i-1]=='W'):
        Lcnt+=1
    L[i]=Lcnt
for i in reversed(range(0,N-1)):
    if(S[i+1]=='E'):
        Rcnt+=1
    R[i]=Rcnt
        
ans=10e+9
for i in range(N):
    ans=min(ans,(L[i]+R[i]))
    
print(ans)

Measured memory_bytes: 17596
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int n;
    cin >> n;
    vector<char> v(n);
    rep(i, n) cin >> v[i];

    priority_queue<ll> red;
    PQ_ASK white;

    if (*max_element(v.begin(), v.end()) == *min_element(v.begin(), v.end())) {
        cout << 0 << endl;
        ret();
    }

    rep(i, n) {
        if (v[i] == 'R') red.push(i);
        else white.push(i);
    }

    int ans = 0;
    while (white.top() < red.top()) {
        ans++;
        int r = red.top();
        int w = white.top();

        red.pop();
        white.pop();
        white.push(r);
        red.push(w);
    }

    cout << ans << endl;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
bool is_prime[1300000];

int main(){
	cin.sync_with_stdio(false);
	rep(i,1300000)is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	repl(i,2,1300000){
		if(is_prime[i]){
			for(int j=i*2;j<1300000;j+=i)is_prime[j]=false;
		}
	}
	while(1){
		cin>>n;
		if(n==0)break;
		if(is_prime[n])cout<<0<<endl;
		else{
			int l=n,r=n;
			while(!is_prime[l])l--;
			while(!is_prime[r])r++;
			cout<<r-l<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007

vll adj[100003]; ll n;
ll dp[100003][3];

ll solve(ll i , ll j)
{
	if(i==n)return 0;
	
	if(dp[i][j]!=-1)return dp[i][j];
	
	ll maxans=-1;
	forA(k,0,3,1)
	{
		if(j==k)continue;
		maxans = max(solve(i+1,k),maxans);
	}
	return dp[i][j]=adj[i][j]+maxans;
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll a,b,c; cin>>n;
	memset(dp,-1,sizeof(dp));
	forA(i,0,n,1){cin>>a>>b>>c; adj[i].pb(a); adj[i].pb(b) ; adj[i].pb(c); }
	ll ans=0;
	forA(i,0,3,1)ans=max(solve(0,i),ans);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 17604
// 
#include <bits/stdc++.h>
using namespace std;
#define int 	long long int
#define pii 	pair<int,int>
#define vi 		vector<int>
#define vii		vector<pii>
#define mii 	map<int,int>
#define pb 		push_back
#define mp 		make_pair
#define ff 		first
#define ss 		second
#define MOD 	1000000007

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int N,W,i;
	cin>>N>>W;
	int v[N],w[N];
	for(i=0;i<N;i++)
	{
		cin>>w[i]>>v[i];
	}

	// for(i=0;i<N;i++)
		// cout<<w[i]<<" "<<v[i];

	int dp[N][W+1];
	for(int wt=0;wt<=W;wt++)
		dp[0][wt]=0;

	dp[0][w[0]]=v[0];
	for(i=1;i<N;i++)
	{
		for(int wt=0;wt<=W;wt++)
		{
			dp[i][wt]=dp[i-1][wt];
			if(w[i]<=wt)
				dp[i][wt]=max(dp[i][wt],v[i]+dp[i-1][wt-w[i]]);
		}
	}

	cout<<*max_element(dp[N-1],dp[N-1]+W+1);
	// int ans=0;

	// for(int wt=0;wt<=W;wt++)
	// 	cout<<dp[i][wt]<<" ";

    return 0;
}

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

int h, w;
char S[60][60]; //[r][c]

int main(){
  //定数倍高速化
  cin >> h >> w;
  for(int i = 1; i <= h; i++){
    for(int  j = 1; j <= w; j++){
      cin >> S[i][j];
    }
    //cout << S[i] << endl;
  }
  for(int i = 1; i <= h; i++){ // row
    for(int j = 1; j <= w; j++){ // colum
      if(S[i][j] != '.'){
        continue;
      }
      int cnt = 0;
      for(int d1 = -1; d1 <= 1; d1++){
        for(int d2 = -1; d2 <= 1; d2++){
          if(d1 == 0 && d2 == 0){
            continue;
          }
          if(S[i + d1][j + d2] == '#'){
            cnt++;
          }
        }
      }
      char tmp = '0' + cnt;
      S[i][j] = tmp;
    }
  }
  //output
  for(int i = 1; i <= h; i++){ // row
    for(int j = 1; j <= w; j++){ // colum
      cout << S[i][j];
    }
    cout << endl;
  }
  return 0;
}

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

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main() {
    ll N, X, Y;
    cin >> N >> X >> Y;
    map<ll, ll> m;
    for (ll i = 1; i < N; i++) {
        for (ll j = i + 1; j <= N; j++) {
            ll tmp = min(j - i, abs(Y - j) + abs(X - i) + 1);
            m[tmp]++;
        }
    }
    for (ll i = 1; i <= N - 1; i++) {
        cout << m[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main() {
    int a,b;

    scanf("%d %d",&a,&b);

    if (a > b) {
        printf("a > b\n");
    } else if (a < b) {
        printf("a < b\n");
    } else {
        printf("a == b\n");
    }
    return 0;
}


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

using lint = long long;

template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	double dist() const { return sqrt((double)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	double angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(double a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

typedef Point<double> P;
double ccRadius(const P& A, const P& B, const P& C) {
	return (B-A).dist()*(C-B).dist()*(A-C).dist()/
			abs((B-A).cross(C-A))/2;
}
P ccCenter(const P& A, const P& B, const P& C) {
	P b = C-A, c = B-A;
	return A + (b*c.dist2()-c*b.dist2()).perp()/b.cross(c)/2;
}

pair<P, double> mec(vector<P> ps) {
	shuffle(ps.begin(),ps.end(), mt19937(time(0)));
	P o = ps[0];
	double r = 0, EPS = 1 + 1e-8;
	for(int i = 0; i < ps.size(); ++i) 
	    if ((o - ps[i]).dist() > r * EPS) {
		    o = ps[i], r = 0;
		    for(int j = 0; j < i; ++j) if ((o - ps[j]).dist() > r * EPS) {
			    o = (ps[i] + ps[j]) / 2;
			    r = (o - ps[i]).dist();
			    for(int k = 0; k < j; ++k) 
			        if ((o - ps[k]).dist() > r * EPS) {
				        o = ccCenter(ps[i], ps[j], ps[k]);
				        r = (o - ps[i]).dist();
			        }
		    }
	    }
	return {o, r};
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    cout << fixed << setprecision(19);
    vector<P> points(n);
    for (int i = 0; i < n; ++i) {
    	cin >> points[i].x >> points[i].y;
    }

    auto ret = mec(points);
    cout << ret.second << '\n';
}

Measured memory_bytes: 256
<?php

$cnt = 0;
while (($line = trim(fgets(STDIN))) !== '') {
    $len = strlen($line);
    if ($len === 1) {
        $cnt++;
        continue;
    }

    $mid = (int)($len / 2);
    $str = substr($line, 0, $mid);
    $str = implode('', array_reverse(str_split($str)));
    $i = $len % 2 === 0 ? $mid : $mid + 1;
    $str === substr($line, $i) && $cnt++;
}
echo $cnt, PHP_EOL;

Measured memory_bytes: 6620
//============================================================================
// Name        : test.cpp
// Author      : tree
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
typedef long long int LLI;
const int mol = 1000000007;
const int maxn = 1000000 + 10;

LLI inv[maxn * 2];
LLI x[maxn];
LLI y[maxn];

int main() {
	int w, h, a, b;
	LLI ans = 0;
	scanf("%d%d%d%d", &h, &w, &a, &b);
	inv[1] = 1;
	for(int i = 2;i <= 2000000;i ++){
		inv[i] = (mol - mol / i) * inv[mol % i] % mol;
	}
	x[b - 1] = 1;
	for(int i = b;i <= 1000000;i ++){
		x[i] = x[i - 1] * i % mol * inv[i - b + 1] % mol;
	}
	y[w - b - 1] = 1;
	for (int i = w - b; i <= 1000000; i++) {
		y[i] = y[i - 1] * i % mol * inv[i - w + b + 1] % mol;

	}
	for(int i = 1;i <= h - a;i ++){
		ans = (ans + x[i + b - 2] * y[w + h - b - i - 1] % mol) % mol;
	}
	printf("%lld\n",ans);
	return 0;
}

// LLI temp = Lucas(i + b - 2, b - 1, mol);
// LLI temp1 = Lucas(w + h - b - i - 1, h - i, mol);


Measured memory_bytes: 31488
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <iomanip>
#include <limits>
#include <cstring>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<string, string> sP;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

ll h, w, d[11][11], a, ans = 0;
struct edge { ll to, cost; };
vector<edge>v[100010];


int main() {
	cin >> h >> w;
	for (int i = 0;i <= 9;i++) {
		for (int j = 0;j <= 9;j++) {
			cin >> d[i][j];
		}
	}
	for (int k = 0;k <= 9;k++) {
		for (int i = 0;i <= 9;i++) {
			for (int j = 0;j <= 9;j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	for (int i = 0;i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> a;
			if (a != -1)ans += d[a][1];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;

  int cnt = 0;
  for (int i = A; i <= B; i++) {
    string n_str = to_string(i);
    if (n_str[0] == n_str[4] && n_str[1] == n_str[3]) {
      cnt ++;
    }
  }

  cout << cnt << endl;
}

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

int main()
{
	int n;
	cin >> n;
	for(int x=0;x<n;x++){
		bool flag=true;
		int a,b=0,c=0;
		for(int i=0;i<10;i++){
			cin >> a;
			for(int j=a-1;j>=0;j--){
				if(b==j){
					b=a;
					break;
				}
				if(c==j){
					c=a;
					break;
				}
				if(j==0){
					flag = false;
					break;
				}
			}
		}
		if(flag)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,j,h,w;
	cin>>h>>w;
	char a[h+1][w+1];
	for(i=1;i<h+1;i++){
		for(j=1;j<w+1;j++){
			cin>>a[i][j];
			if(a[i][j]=='#'){
				a[0][j]='#';
				a[i][0]='#';
			}
		}
	}
	bool aa;
	for(i=1;i<h+1;i++){
		aa=false;
		for(j=1;j<w+1;j++){
			if(a[i][0]=='#'&&a[0][j]=='#'){
				cout<<a[i][j];
				aa=true;
			}
		}
		if(aa)cout<<endl;
	}
	
	
	
	
	
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    map<ll, ll, greater<ll>> m;
    for(int i = 0; i < n; i++){
        ll a; cin >> a;
        m[a]++;
    }
    ll l1 = 0, l2 = 0;
    for(auto p : m){
        if(4 <= p.second && l1 == 0){
            l1 = p.first;
            l2 = p.first;
            break;
        }else if(2 <= p.second){
            if(l1 == 0){
                l1 = p.first;
            }else{
                l2 = p.first;
                break;
            }
        }
    }
    ll ans = l1 * l2;
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n,m;
	cin >> n >> m;
	vector<vector<char>> a(n+2, vector<char>(m+2));
	REPS(i, n) { REPS(j, m) { cin >> a[i][j]; } }
	REP(i, n+2) {
		REP(j, m+2) {
			if (i == 0 || i==(n+1)) {
				cout << "#";
			}
			else {
				if(j==0||j==(m+1))
					cout << "#";
				else {
					cout << a[i][j];
				}
			}
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll INF=(9e18);
const int maxn=(2e5)+10;
int n,a[maxn];
ll dp[maxn][5],ans=INF;
int op(int i,int j) {
	if (j==1||j==3) {
		if (a[i]==0) return 2;
		return a[i]&1;
	}
	if (j==2) return a[i]&1^1;
	return a[i];
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (int i=1;i<=n;i++)
	for (int j=0;j<=4;j++) {
		dp[i][j]=INF;
		for (int k=0;k<=j;k++)
			dp[i][j]=min(dp[i][j],dp[i-1][k]);
		dp[i][j]+=op(i,j);
		if (i==n) ans=min(ans,dp[i][j]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8832
/**
 *   created: 04 July 2019  20:06:43
**/
#include<bits/stdc++.h>
using namespace std;

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef vector< pair<int , int> > vii;
typedef long long ll;
typedef vector<long long> vl;
typedef pair<long long , long long> pll;
typedef vector< pair<long long , long long> > vll;

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

//=========================================================================================================

int main()
{
	optimizeIO();
	int tt=1;
	// cin>>tt;
	while(tt--){
		ll l,r;
		cin>>l>>r;
		if(r-l+1>2019){
			cout<<0;
			return 0;
		}
		set<ll> s;
		rep(i,l,r+1){
			rep(j,i+1,r+1){
				s.insert(((i%2019)*(j%2019))%2019);
			}
		}
		cout<<*s.begin();
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <ext/numeric>
#define oo 0x3f3f3f3f
#define long long long

using namespace std;
//using namespace __gnu_cxx;


int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int h, w, n;
    cin >> h >> w >> n;
    vector<pair<int, int>> arr(n);
    set<pair<int, int>> isBlack;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first >> arr[i].second;
        isBlack.insert({arr[i].first, arr[i].second});
    }

    map<int, long> ans;
    ans[0] = 1ll * (h - 2) * (w - 2);
    set<pair<int, int>> vis[3][3];
    for (int i = 0; i < n; ++i) {
        for (int x = max(1, arr[i].first - 2); x <= arr[i].first; ++x) {
            for (int y = max(1, arr[i].second - 2); y <= arr[i].second; ++y) {
                if (x + 2 > h || y + 2 > w)
                    continue;
                bool ok = true;
                int cnt = 0;
                for (int a = x; a <= x + 2; ++a) {
                    for (int b = y; b <= y + 2; ++b) {
                        if (isBlack.count({a, b})) {
                            ++cnt;
                            ok &= vis[a - x][b - y].insert({a, b}).second;
                        }
                    }
                }
//                cout << x << ' ' << y << ' ' << cnt << '\n';
                if (ok) {
                    ++ans[cnt];
                    --ans[0];
                }
            }
        }
    }

    for (int i = 0; i < 10; ++i) {
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 50956
#include <stdio.h>
int main(void){
    char S[5]={'A','C','G','T'},b;
    scanf("%c",&b);
    int i;
    for (i=0; i<4; i++) {
        if(b==S[i]){
            printf("%c\n",S[3-i]);
            return 0;
        }
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <queue>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"

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

  priority_queue<pii> q;
  REP(i, N) {
    IN(a);
    q.push(make_pair(a, 1));
  }

  REP(i, M) {
    IN(b); IN(c);
    q.push(make_pair(c, b));
  }
  ll sum = 0;
  int n = 0;
  while (n < N) {
    pii p = q.top(); q.pop();
    sum += (ll)p.first * min(p.second, N - n);
    n += p.second;
  }
  OUT(sum);

  return 0;
}


Measured memory_bytes: 2420
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline 

#n = int(input())
#s = input()
#a = [int(i) for i in readline().split()]
#m = [[int(i) for i in readline().split()] for _ in range(n)]

t1,t2 = [int(i) for i in readline().split()]
a1,a2 = [int(i) for i in readline().split()]
b1,b2 = [int(i) for i in readline().split()]


if a1*t1 + a2*t2 == b1*t1 + b2*t2:
    print("infinity")
else:
    d = a1*t1 + a2*t2 - (b1*t1 + b2*t2)
    if d < 0:
        a1,b1 = b1,a1
        a2,b2 = b2,a2
        d = -d
    
    if a1 == b1:
        print("infinity")
    elif a1 > b1:
        print(0)
    else:
        c = (b1-a1)*t1
        r = c//d
        #print(r,c,d)
        if c%d == 0:
           print(2*r)
        else:
            print(2*r+1)
           


        
        
        
        
        
        

Measured memory_bytes: 3188
#include<stdio.h>
int main(){
	int a,b,c,k;
	scanf("%d%d%d%d",&a,&b,&c,&k);
	int ans;
	if(a>=k) ans=k,k-=a;
	else if(a<k) ans=a,k-=a;
	if(k>0) k-=b;
	if(k>0) ans-=k,k-=c;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

int main(){cout<<fixed<<setprecision(10);
           //bit全探索2^10=1024通り
		   int n;
           cin>>n;
           vector<vin> a(n,vin(10)),b(n,vin(11));
           rep(i,0,n){
            rep(j,0,10)cin>>a[i][j]; 
           }
           rep(i,0,n){
            rep(j,0,11)cin>>b[i][j]; 
           }
           ll ans=-INF;
           for(int bit=1;bit<(1<<10);bit++){
             ll cnt=0;
             rep(j,0,n){
             int c=0;
             
                 for(int i=0;i<10;i++){//時間i
                   if(bit &(1<<i)&&a[j][i]){//店が開いている
                         c++;
                   }
                 }//for i
               cnt+=b[j][c];
             }
             chmax(ans,cnt);
           }//for bit
           cout<<ans<<endl;
}

Measured memory_bytes: 3724
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

mod = 10**9 + 7

N = int(raw_input())
T = map(int, raw_input().split())
A = map(int, raw_input().split())

hmin = [1]*N
hmax = [1]*N
hmin[0] = hmax[0] = T[0]
hmin[N - 1] = hmax[N - 1] = A[N - 1]

if T[N - 1] != A[0]:
    print 0
    exit()

for i in xrange(1, N - 1):
    if T[i] > T[i - 1]:
        hmin[i] = hmax[i] = T[i]
    else:
        hmax[i] = T[i]
for i in xrange(N - 2, 0, -1):
    if A[i] > A[i + 1]:
        if A[i] > hmax[i]:
            print 0
            exit()
        hmax[i] = hmin[i] = A[i]
    else:
        hmax[i] = min(hmax[i], A[i])

ans = 1
for i in xrange(N):
    ans = ans*(hmax[i] - hmin[i] + 1)%mod

print ans


Measured memory_bytes: 15888
x,y=map(int,input().split())
if x<y:
	x,y=y,x
naname = x-y
if y-naname<0 or (y-naname)%3!=0:
	print(0)
	exit()

numna=(y-naname)//3
numyo=naname

mod=10**9+7

fac = [0]*1000000
inv = [0]*1000000
fac[0]=1
fac[1]=1
inv[0]=1
inv[1]=1



for i in range(2,10**6-5):
	fac[i] = fac[i-1]*i%mod
	inv[i] = pow(fac[i],mod-2,mod)

def nCr(n,r):
	return fac[n]*inv[r]%mod*inv[n-r]%mod

print(nCr(numna*2+numyo,numna))


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

    Scanner sc = new Scanner(System.in);
    String S = sc.next();

    String S1 = S.substring(0,1);
    String S2 = S.substring(1,2);
    String S3 = S.substring(2,3);
    String S4 = S.substring(3,4);

    int count = 0;

    if (S1.equals("+")) {
      count++; 
    } else {
      count--; 
    }

    if (S2.equals("+")) {
      count++; 
    } else {
      count--; 
    }

    if (S3.equals("+")) {
      count++; 
    } else {
      count--; 
    }

    if (S4.equals("+")) {
      count++; 
    } else {
      count--; 
    }

    System.out.println(count);

  }
}

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

int main(){
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int a=1;
  for(int i=1;i<N;i++){
    a=vec.at(a-1);
    if(a==2){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3768
a = [int(x) for x in input().split()]

ans = 2*(a[0]//2 + a[3]//2 + a[4]//2) + 3*(1 & a[0] & a[3] & a[4])
if a[0] and a[3] and a[4]:
    ans = max(ans, 2*((a[0]-1)//2 + (a[3]-1)//2 + (a[4]-1)//2) + 3)

print(int(ans + a[1]))


Measured memory_bytes: 9048
n,m = map(int, input().split())
a = [str(input()) for i in range(n)]
b = [str(input()) for i in range(m)]
for i in range(0,n-m+1):
    for j in range(0,n-m+1):
        ans = 1
        for k in range(0,m):
            for l in range(0,m):
                if a[i+k][j+l] != b[k][l]:
                    ans = 0
                    break
        if ans == 1:
            print('Yes')
            exit()
print('No')


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    bool f = true;
    f = f && (s[0] == 'A');

    int cnt = 0;
    for (int i = 2; i < int(s.size())- 1; ++i) {
      cnt += (s[i] == 'C');
    }
    f = f && (cnt == 1);

    each (c, s) {
      if (c == 'A' || c == 'C') continue;
      f = f && ('a' <= c && c <= 'z');
    }
    
    cout << (f ? "AC" : "WA") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256