akhauriyash/Code-Regression huggingface dataset:
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second

template <typename T>
struct modint {
    static_assert(std::is_integral<T>::value, "T must be integral");
    modint(T value = 0, T mod = (T)1e9 + 7) : value(value % mod), mod(mod) {}
    modint operator +(const modint& rhs) const {
        return modint(*this) += rhs;
    }
    modint operator -(const modint& rhs) const {
        return modint(*this) -= rhs;
    }
    modint operator *(const modint& rhs) const {
        return modint(*this) *= rhs;
    }
    modint operator /(const modint& rhs) const {
        return modint(*this) /= rhs;
    }
    modint& operator +=(const modint& rhs) {
        value += rhs.value;
        if (value >= mod) {
            value -= mod;
        }
        return *this;
    }
    modint& operator -=(const modint& rhs) {
        if (value < rhs.value) {
            value += mod;
        }
        value -= rhs.value;
        return *this;
    }
    modint& operator *=(const modint& rhs) {
        value = value * rhs.value % mod;
        return *this;
    }
    modint& operator /=(const modint& rhs) {
        modint tmp = rhs;
        T exp = mod - 2;
        while (exp) {
            if (exp % 2) {
                *this *= tmp;
            }
            tmp *= tmp;
            exp /= 2;
        }
        return *this;
    }
    friend ostream& operator <<(ostream &out, const modint& m) {
        out << m.value;
        return out;
    }
    friend istream& operator >>(istream &in,  modint& m) {
        in >> m.value;
        m.value %= m.mod;
        return in;
    }
    T value;
    T mod;
};

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    if (abs(M - N) > 1) {
        cout << 0 << endl;
        return 0;
    }
    if (M == N) {
        modint<ll> ans = 2;
        rep (i, N) {
            ans *= (i + 1);
            ans *= (i + 1);
        }
        cout << ans << endl;
        return 0;
    }
    modint<ll> ans = 1;
    rep (i, N) {
        ans *= (i + 1);
    }
    rep (i, M) {
        ans *= (i + 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
a = ["R","U","D"]
b = ["L","U","D"]
s = input()
cnt = 0
for i in range(len(s)):
    if i%2==0:
        if s[i] in a:
            pass
        else:
            cnt = 1
            break
    else:
        if s[i] in b:
            pass
        else:
            cnt = 1
            break
if cnt == 0:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  vector<vector<vector<long long>>> dp(2, vector<vector<long long>>(n, vector<long long>(16)));
  for (int i = 0; i < 16; i++) {
    dp[0][n - 1][i] = i;
    dp[1][n - 1][i] = i;
  }

  for (int i = 0; i < 2; i++) {
    for (int j = n - 2; j >= 0; j--) {
      int j1 = 0;
      int j2 = 0;
      long long c1 = a[j];
      long long c2 = a[j + 1];
      while (c1 <= c2 && j1 < 16) {
        dp[i][j][j1] = dp[i][j + 1][0] + j1;
        c1 *= 4;
        j1++;
      }
      while (j2 < 16 && c2 < c1) {
        c2 *= 4;
        j2++;
      }
      while (j1 < 16) {
        if (j2 > 15) {
          dp[i][j][j1] = dp[i][j + 1][15] + (j2 - 15) * (n - 1 - j) + j1;
        }
        else {
          dp[i][j][j1] = dp[i][j + 1][j2] + j1;
        }
        j1++;
        j2++;
      }
    }
    reverse(a.begin(), a.end());
  }

  long long ans = 2 * dp[0][0][0];
  for (int i = 1; i < n; i++) {
    long long steps = dp[0][i][0] * 2 + dp[1][n - i][0] * 2 + i;
    ans = min(ans, steps);
  }
  cout << ans;
}


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



signed main() {
    vector<string> dice(7);

    dice[1] = "##3524#";
    dice[2] = "#4#16#3";
    dice[3] = "#26##15";
    dice[4] = "#51##62";
    dice[5] = "#3#61#4";
    dice[6] = "##4253#";
    
	vector<int> s(7);
	map<int, int> a;
	for (int i = 1; i < 7; ++i) {
		cin >> s[i];
		a[s[i]] = i;
	}
	
	
	
	int N;
	cin >> N;
	
	for (int i = 0; i < N; ++i) {
	    int n, m;
	    cin >> n >> m;
	    cout << s[int(dice[a[n]][a[m]] - '0')] << endl;
	}

}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll) n;i++)
const ll mod = 1e9+7;
ll dp[100000]; 

int main(){
  ll n,m,k,tmp=-1,ans=1;
  cin>>n>>m;
  vector<ll> a(n);
  rep(i,n){
    cin>>m;
    a[m]=1;
  }
  
  
  dp[1]=1;
  dp[2]=(a[1]==0?1:0)+1;
  
  for(ll i=1;i<n;i++){
    dp[i+2]=(a[i+1]==0?dp[i+1]:(ll)0)+(a[i]==0?dp[i]:(ll)0);
    dp[i+2]%=mod;
  }
  
  cout<<dp[n]<<endl;
 
}


Measured memory_bytes: 1792
from collections import deque
n, k, c = map(int, input().split())
s = str(input())

# 前後
i = 0
l1 = []
while i <= n-1:
    if s[i] == 'o':
        l1.append(i+1)
        i += c + 1
    else:
        i += 1
    if len(l1) >= k:
        break
i = n-1
l2 = []
while i >= 0:
    if s[i] == 'o':
        l2.append(i+1)
        i -= (c + 1)
    else:
        i -= 1
    if len(l2) >= k:
        break
ans = []
for i, j in zip(l1, l2[::-1]):
    if i == j:
        ans.append(i)
print("\n".join(list(map(str, ans))))


Measured memory_bytes: 70728
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x <<": "<<x<<"\n"
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template <class T> using vec = std::vector<T>;
template <class T = int> T in(){T x; cin>>x;return(x);}
template <class T > void print(T& x){cout<<x<<"\n";}
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
map<string,int> dic;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N=in<int>();
  string s,tmps;
  bool flg = true;
	REP(i,N){
		tmps=s;
		s = in<string>();
		if (dic[s]==0)dic[s]++;
		else {
			flg = false;
			break;
		}
		if (i>0&&tmps[tmps.size()-1]!=s[0]){
			flg = false;
			break;
		}
	}
	cout <<(flg?"Yes":"No")<<"\n";
}

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

int main(void)
{
   int n, i=0, f=0;
   char s[100];

   scanf("%s",s);

   n=strlen(s);

   while((s[i]==s[n-i-1])&&(i<n))
      i++;

   while((s[f]==s[(n-1)/2-f-1])&&(s[(n+3)/2+f-1]==s[n-f-1])&&(f<(n-1)/2))
      f++;

   if((i==n)&&(f==(n-1)/2))
      printf("Yes\n");

   else
      printf("No\n");

   return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;


int main()
{
	ll a;
	cin >> a;
	cout << a / 500 * 1000 + (a % 500) / 5 * 5 << endl;

	

	return 0;
}


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

using namespace std;

typedef long long ll;

int N;
ll K;
pair<ll, ll> AB[100000 + 10];

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++)cin >> AB[i].first >> AB[i].second;

	int msb = 0;
	while (K >= (1 << msb))msb++;
	msb--;

	ll ans = 0;
	for (int i = 0; i < N; i++)if ((K | AB[i].first) == K)ans += AB[i].second;
	for (int i = msb; i >= 0; i--) {
		ll jougen = 0;
		//最初の(msb - i)桁はKと同じ。
		for (int j = i + 1; j <= msb; j++)jougen += ((K >> j) & 1) << j;
		//上からmsb - i + 1桁目は、0固定して、それより下の桁はすべて(1 << i) - 1になる。(2進数で全部1)
		if (!((K >> i) & 1))continue;
		jougen += 0;
		jougen += (1 << i) - 1;
		
		ll tmp = 0;
		for (int j = 0; j < N; j++)if ((jougen | AB[j].first) == jougen)tmp += AB[j].second;
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)
#define INF 1e9+7


void solve() {
    int n;
    cin >> n;
    vi v;
    FOR(n) {
        int a;
        cin >> a;
        v.push_back(a);
    }
    cout << *max_element(bn(v)) - *min_element(bn(v)) << "\n";
}

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

    int t = 1, i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


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

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

	int first_A = 0;
	for(int i = 0; i < s.length(); i++){
		if(s.at(i) == 'A'){
			first_A = i;
			break;
		}
	}

	int last_Z = 0;
	for(int i = s.length() - 1; i > 0; i--){
		if(s.at(i) == 'Z'){
			last_Z = i;
			break;
		}
	}

	cout << last_Z - first_A + 1 << endl;
}


Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	m1 := nextInt()
	var _ = nextInt()
	m2 := nextInt()
	var _ = nextInt()

	if m1 != m2 {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


Measured memory_bytes: 640
s=str(input())
k=int(input())

lista=[]
for i in range(26):
	lista.append(chr(ord('a') + i))
	
#print(lista)

s_list=list(s)
len_s=len(list(s))
temp1=k
temp2=0
for i in range(len_s):
	if (123-ord(s_list[i])<=temp1)and (s_list[i] != 'a'):
		temp1=temp1-(123-ord(s_list[i]))
		s_list[i]="a"
if temp1!=0:
#	print(temp1)
	temp2=temp1%26+ord(s_list[-1])
	if temp2>122:
		temp2=temp2-122+96
	s_list[-1]=chr(temp2)
#print(temp2)
#print(str(s_list))

for i in range(len(s_list)):
	print(s_list[i],end="")
print()

		
	
	
	


Measured memory_bytes: 56432
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int N,W;
int w1;
vector<int> v[4];

int main(){
    
    scanf("%d%d",&N,&W);
    for(int i=0;i<4;i++){
        v[i].push_back(0);
    }
    for(int i=0,x,y;i<N;i++){
        scanf("%d%d",&x,&y);
        if(i==0)w1 = x;
        v[x-w1].push_back(y);
    }
    for(int i=0;i<4;i++){
        sort(v[i].begin(),v[i].end());
        reverse(v[i].begin()+1,v[i].end());
        for(int j=1;j<v[i].size();j++){
            v[i][j] += v[i][j-1];
        }
    }

    int ans = 0;
    for(int i=0;i<v[0].size();i++){
        for(int j=0;j<v[1].size();j++){
            for(int k=0;k<v[2].size();k++){
                for(int l=0;l<v[3].size();l++){
                    if((long long)w1*(i+j+k+l)+j+2*k+3*l <= W){
                        ans = max(ans, v[0][i]+v[1][j]+v[2][k]+v[3][l]);
                    }
                }
            }
        }
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    set<string> s;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k, z, N;
string s, t, d, c;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n;
	vector<vll> cnt(26,vll(n));
	ll mini;
	for(ll i=0;i<n;i++) {
		cin>>s;
		for(auto ch : s) {
			cnt[ch-'a'][i]++;
		}
	}
	for(ll i=0;i<26;i++) {
		mini = INT_MAX;
		for(ll j=0;j<n;j++) mini = min(mini,cnt[i][j]);
		for(ll j=0;j<mini;j++) cout<<(char)('a'+i);
	}
	newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


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

#define boost ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;
using LL = long long;

constexpr int MAXN = 1e5 + 5;

template <typename T>
inline void read(T &x) {
    int f = 1;
    x = 0;
    char ch = getchar();
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, val[4], u[MAXN], v[MAXN];
string opt[MAXN];
vector<char> choice;

int main() {
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    boost;
    cin >> n;
    cin >> val[1] >> val[2] >> val[3];
    for (int i = 1; i <= n; i++) {
        cin >> opt[i];
        if (opt[i] == "AB") u[i] = 1, v[i] = 2;
        else if (opt[i] == "AC") u[i] = 1, v[i] = 3;
        else u[i] = 2, v[i] = 3;
    }
    for (int i = 1; i < n; i++) {
        if (!val[u[i]] && !val[v[i]]) {
            cout << "No" << endl;
            return 0;
        }
        if (val[u[i]] < val[v[i]]) {
            val[u[i]]++, val[v[i]]--;
            choice.push_back(u[i] - 1 + 'A');
        } else if (val[u[i]] > val[v[i]]) {
            val[u[i]]--, val[v[i]]++;
            choice.push_back(v[i] - 1 + 'A');
        } else {
            val[u[i]]++, val[v[i]]--;
            if (!val[u[i + 1]] && !val[v[i + 1]]) {
                val[u[i]]--, val[v[i]]++;
            } else {
                choice.push_back(u[i] - 1 + 'A');
                continue;
            }
            val[u[i]]--, val[v[i]]++;
            if (!val[u[i + 1]] && !val[v[i + 1]]) {
                val[u[i]]++, val[v[i]]--;
            } else
                choice.push_back(v[i] - 1 + 'A');
        }
    }
    if (!val[u[n]] && !val[v[n]]) {
        cout << "No" << endl;
        return 0;
    }
    if (val[u[n]]) choice.push_back(v[n] - 1 + 'A');
    else choice.push_back(u[n] - 1 + 'A');
    cout << "Yes" << endl;
    for (auto &c : choice) cout << c << endl;
    return 0;
}

Measured memory_bytes: 7652
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	int n = s.size();
	int zero = count(all(s), '0');
	int one = count(all(s), '1');
	int ans = n;
	rep(i, 0, n / 2) {
		if (zero == 0 || one == 0)
			break;
		if (s[i] == '0')
			zero--;
		else
			one--;
		if (s[n - i - 1] == '0')
			zero--;
		else
			one--;
		ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>

using namespace std;


int main() {
	int N, T, A, z;
	double x = 100000,y;
	cin >> N >> T >> A;
	int H[1001];
	for (int i = 1; i <= N; i++)
		cin >> H[i];

	for (int i = 1; i <= N; i++) {
		y = abs(A - (T - (H[i] * 0.006)));
		if (y < x) {
			x = y;
			z = i;
		}
	}

	cout << z << endl;

	return 0;
}

Measured memory_bytes: 256
line = input()
N = int(input())
 
for loop in range(N):
 
    input_str = list(input().split())
 
    if input_str[0] == 'replace':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + input_str[3] + line[right:]
 
    elif input_str[0] == 'reverse':
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        line = line[:left] + line[left:right][::-1] + line[right:]
 
    else: #print
        left = int(input_str[1])
        right = int(input_str[2])
        right += 1
        for i in range(left,right):
            print(line[i],end = "")
        print()


Measured memory_bytes: 5720
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define range(i,l,h) for(int i=l;i<h;i++)
#define endl '\n'
#define I INT_MAX
#define L INT_MIN
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vi vector<int>
using namespace std;
using std::ios;
constexpr int MOD=1e9+7;
constexpr int mod=998244353;

int main()
{
  fastio;
  int n,m;
  cin>>n>>m;
  priority_queue<int> q;
  range(i,0,n)
  {
    int x;
    cin>>x;
    q.push(x);
  }
  while(m>0)
  {
    int t=q.top();
    q.pop();
    t/=2;
    m--;
    q.push(t);
  }
  ll sum=0;
  while(!q.empty())
  {
    sum+=q.top();
    q.pop();
  }
  cout<<sum;
}


Measured memory_bytes: 3840
n = int(input())
s = []
dict = {}
for i in range(n):
    ss = sorted(input())
    st = "".join(map(str,ss))
    if st in dict:
        dict[st]+=1
    else:
        dict[st] = 1
    # print(st)
# print(s)
count = 0
for i in dict:
    if dict[i] > 1:
        count+=(dict[i] * (dict[i] - 1))//2

print(count)

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

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


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d;
map<long long, long long> dp;
long long rec (long long cur) {
  if (cur == 0) return 0;
  if (cur == 1) return d;
  if (dp.count(cur)) return dp[cur];
  long long res = (1. * cur * d > 1e18 ? (long long) 1e18 : cur * d);
  long long to = (cur + 1) / 2 * 2;
  res = min(res, abs(to - cur) * d + a + rec(to / 2));
  to = cur / 2 * 2;
  res = min(res, abs(to - cur) * d + a + rec(to / 2));
  to = (cur + 2) / 3 * 3;
  res = min(res, abs(to - cur) * d + b + rec(to / 3));
  to = cur / 3 * 3;
  res = min(res, abs(to - cur) * d + b + rec(to / 3));
  to = (cur + 4) / 5 * 5;
  res = min(res, abs(to - cur) * d + c + rec(to / 5));
  to = cur / 5 * 5;
  res = min(res, abs(to - cur) * d + c + rec(to / 5));
  return dp[cur] = res;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  auto solve = [] () {
    long long n;
    cin >> n >> a >> b >> c >> d;
    dp.clear();
    return rec(n);
  };
  int t;
  cin >> t;
  while (t--) cout << solve() << endl;
  return 0;
}

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

long long n;

int div_count(long long n)
{
	int ans=0;
	bool prime=true;
	for(int i=1;1ll*i*i<=n;i++)
	{
		if(n%i==0)
		{
			ans+=2;
			if(1ll*i*i==n) ans--;
			prime=false;
		}
	}
	return ans+prime-1;
}

bool ok(long long i)
{
	long long m=n;
	while(m%i==0) m/=i;
	return m%i==1;
}

int main()
{
	cin>>n;

	int ans=div_count(n-1);
	for(int i=2;1ll*i*i<=n;i++)
	{
		if(n%i) continue;
		ans+=ok(i);
		//if(1ll*i*i!=n) ans+=ok(n/i);
	}
	cout<<ans+1;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> V(N), C(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    for(int i = 0; i < N; i++) cin >> C[i];

    int ans = 0;
    for(int i = 0; i < N; i++){
        if(V[i] > C[i]) ans += V[i] - C[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
int N;
ll dp[100010][13];

int main() {
  int ans = 0;
  string s; cin >> s;
  N = s.size();
  dp[0][0] = 1;
  for(int i = 0; i < N; ++i) {
    int c;
    if(s[i] == '?') c = -1;
    else c = s[i] - '0';

    for(int j = 0; j < 10; j++) {
      if(c != -1 && c != j) continue;
      for(int k = 0; k < 13; k++) {
        dp[i+1][(k*10+j)%13] += dp[i][k];
      }
    }
    for(int j = 0; j < 13; ++j) dp[i+1][j] %= mod;
  }
  ans = dp[N][5];

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


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n;
	ll a;
	cin >> n;
	vector<ll>arr(n + 1, 0);
	rep(i, n) {
		cin >> a;
		arr[i + 1] = arr[i] + a;
	}
	map<ll, ll>m;
	for (auto s : arr)m[s]++;
	ll ans = 0;
	for (auto mp : m) {
		if (mp.second >= 2) ans += (mp.second) * (mp.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 17084
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int N; cin >> N;

    vector<double> dp(N + 1, 0);
    dp[0] = 1.0;

    for (int i = 0; i < N; ++i) {
        double heads; cin >> heads;
        double tails = 1 - heads;
        for (int j = N; j > 0; --j)
            dp[j] = dp[j] * tails + dp[j - 1] * heads;
        dp[0] *= tails;
    }

    double answer = accumulate(dp.begin() + N / 2 + 1, dp.end(), 0.0);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(9);
    cout << answer << "\n";
}


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=1e6+1e1;

int a[MAXN];

int n;

int main(void)
{

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

	scanf("%d",&n);

	for(int i=1;i<n;i++) ++a[read<int>()];

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

	return 0;

}


Measured memory_bytes: 4500
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const long long NR=210000;
long long n,k,pl,l,r,mid,a[NR];
long long f(long long x)
{
	long long sum=0,cnt;
	for(long long i=1;i<=n;i++)
	{
		if(a[i]==0)
		{
			if(x<0)
			{
				cnt=0;
			}
			else
			{
				cnt=n;
			}
		}
		if(a[i]>0)
		{
			long long l,r,mid;
			l=1;
			r=n+1;
			while((r-l)>1)
			{
				mid=(l+r)>>1;
				if(a[mid]*a[i]<=x)
				{
					l=mid;
				}
				else
				{
					r=mid;
				}
			}
			if(a[i]*a[l]<=x)
			{
				cnt=l;
			}
			else
			{
				cnt=0;
			}
		}
		if(a[i]<0)
		{
			long long l,r,mid;
			l=1;
			r=n+1;
			while((r-l)>1)
			{
				mid=(l+r)>>1;
				if(a[mid]*a[i]>x)
				{
					l=mid;
				}
				else
				{
					r=mid;
				}
			}
			if(a[i]*a[l]>x)
			{
				cnt=n-l;
			}
			else
			{
				cnt=n;
			}
		}
		sum+=cnt;
	}
	long long ans=sum;
	for(long long i=1;i<=n;i++)
	{
		if(a[i]*a[i]<=x)
		{
			ans--;
		}
	}
	return ans>>1;
}
int main()
{
	scanf("%lld%lld",&n,&k);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	l=-(1ll<<60);
	r=(1ll<<60);
	while((r-l)>1)
	{
		mid=(l+r)>>1;
		if(f(mid)<k)
		{
			l=mid;
		}
		else
		{
			r=mid;
		}
	}
	printf("%lld",r);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
using namespace std;
int main(void){
    int  N, T, t_i, t_til, t_sum;
    cin >> N >> T;
    t_sum = 0, t_til = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> t_i;
        
        if(t_i <= t_til)
        {
            t_sum += t_i + T - t_til;

        }else if(t_i > t_til)
        {
            t_sum += T;
        }
        t_til = t_i + T;
    }
     cout << t_sum << endl;
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
using namespace std;
int main(){
	int N;
	while( cin >> N, N ){
		int i, j, k, l;
		int W, H, S, T;
		cin >> W >> H;
		char field[100][100];
		memset(field, '.', sizeof(field));
		for( i = 0; i < N; i++ ){
			int X, Y;
			cin >> X >> Y;
			field[X-1][Y-1] = '*';
		}
		cin >> S >> T;
		int max = 0;
		for( i = 0; i < W-S+1; i++ ){
			for( j = 0; j < H-T+1; j++ ){
				int sum = 0;
				for( k = 0; k < S; k++ ){
					for( l = 0; l < T; l++ ){
						if( field[i+k][j+l] == '*' ){
							sum++;
						}
					}
				}
				if( max < sum ){ max = sum; }
			}
		}
		cout << max << endl;
	}
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
const int INF = (int)1e9 + 7;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end() //コンテナじゃないと使えない!!
#define debug(x) cerr << #x <<
//cin,coutより遅いので注意
template <class T = int>
void in() //in<string>();とか書く intのときはそのままin();
{
    T x;
    cin >> x;
    return (x);
}
template <class T>
void print(T &x) { cout << x << "\n"; }

int gcd(int n, int m)
{
    int r = n % m;
    if (r == 0)
    {
        return m;
    }
    return gcd(m, r);
}

int lcm(int n, int m)
{
    return n * (m / gcd(n, m));
}

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

    int N;
    vector<int> T;
    cin >> N;
    REP(i, N)
    {
        int temp;
        cin >> temp;
        T.push_back(temp);
    }
    int ans = 1;
    for (auto t : T)
    {
        ans = lcm(ans, t);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
n = int( input() )
bound = [ 26 ]
add = 26
while bound[ -1 ] < 1000000000000001:
    add *= 26
    bound.append( add + bound[ -1 ] )

d = 0
while bound[ d ] < n:
    d += 1

k = n - bound[ d - 1 ] - 1

alphabet = [chr(i) for i in range(97, 97+26)]
conv = []
for _ in range( d + 1 ):
    conv.append( k % 26 )
    k = k // 26

ans = []
for c in conv:
    ans.append( alphabet[ c ] )

print( "".join( reversed( ans[ : d + 1 ] ) ) )

Measured memory_bytes: 9104
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
long long n;
cin >> n;
string s;
while(n > 0) {
    int a = n % 26;
    if(a == 0)
        a = 26;
    s += 'a' + a - 1;
    --n;
    n  /= 26;
}
reverse(s.begin(),s.end());
cout << s << endl;







}



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

int turara[100000];
int dp[100000];
int N, L;
int rec(int idx){
  if(~dp[idx]) return dp[idx];
  int ret = 0;
  if(idx > 0 && turara[idx - 1] > turara[idx]) ret = max( ret, rec(idx - 1));
  if(idx < N - 1 && turara[idx + 1] > turara[idx]) ret = max( ret, rec(idx + 1));
  return dp[idx] = ret + (L - turara[idx]);
}

int main(){
  fill_n( dp, 100000, -1);
  scanf("%d %d", &N, &L);
  for(int i = 0; i < N; i++){
    scanf("%d", &turara[i]);
  }
  int ret = 0;
  for(int i = 0; i < N; i++){
    ret = max( ret, rec(i));
  }
  printf("%d\n", ret);
}

Measured memory_bytes: 3332
S=input()[::-1]
l=len(S)
t=0
p=0
 
ss=[0]*2019
ss[0]=1
d=1
for i in S:
    p=(p+int(i)*d)%2019
    d*=10
    d%=2019
    ss[p]+=1
 
for c in ss:
    t+=c*(c-1)//2
print(t)

Measured memory_bytes: 9264
#include <stdio.h>

int main(void)
{
	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: 1748
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

int h, w;
int a, b, c, d;
vector<string> s;
deque<pair<int,int>> dq;
int ans[1010][1010];
void input() {
	cin >> h >> w >> a >> b >> c >> d;
	s.resize(h);
	for (int i = 0; i < h; i++) cin >> s[i];
	return;
}
void bfs() {
	for (int i = 0; i < 1005; i++)
		for (int j = 0; j < 1005; j++)
			ans[i][j] = mod;
	dq.push_front({ a,b });
	ans[a][b] = 0;
	while (!dq.empty()) {
		auto e = dq.front();
		dq.pop_front();
		for (int i = 0; i < 4; i++) {
			if (e.first + dx[i] < 0 || e.first + dx[i] >= h || e.second + dy[i] < 0 || e.second + dy[i] >= w) continue;
			if (s[e.first + dx[i]][e.second + dy[i]] == '#') continue;
			if (chmin(ans[e.first+dx[i]][e.second + dy[i]], ans[e.first][e.second])) {
				dq.push_front({ e.first + dx[i],e.second + dy[i] });
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				if (e.first + i < 0 || e.first + i >= h || e.second + j < 0 || e.second + j >= w) continue;
				if (s[e.first + i][e.second + j] == '#') continue;
				if (chmin(ans[e.first + i][e.second + j], ans[e.first][e.second] + 1)) dq.push_back({ e.first + i,e.second + j });
			}
		}
	}
}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	input();
	a--; b--; c--; d--;
	bfs();
	if (ans[c][d] == mod) puts("-1");
	else cout << ans[c][d] << endl;

	return 0;
}

Measured memory_bytes: 8748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5+5;
const int mod = 1e9+7;
ll qpow(ll a,ll b){ll res=1;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

int main()
{
    int a[5];
    int ans = -1;
    for(int i = 0;i < 5;++i){
        cin>>a[i];
        if(a[i]==0)ans=i;
    }    
    cout<<ans+1<<endl;
    return 0;
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n;
P a[100],b[100];
vector<int> G[210];
int match[210];
bool used[210];
int S,T;

void add_edge(int u,int v) {
	G[u].pb(v);
	G[v].pb(u);
}

bool dfs(int v) {
	used[v]=true;
	for(auto u:G[v]) {
		int w=match[u];
		if(w<0||(!used[w]&&dfs(w))) {
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bi() {
	int res=0;
	REP(i,210) match[i]=-1;
	REP(v,2*n) {
		if(match[v]<0) {
			REP(i,210) used[i]=false;
			if(dfs(v)) {
				res++;
				//cout<<"V "<<v<<endl;
			}
		}
	}
	//REP(i,2*n) cout<<match[i]<<' ';
	//cout<<endl;
	return res;
}

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

	cin>>n;
	REP(i,n) cin>>a[i].fi>>a[i].se;
	REP(i,n) cin>>b[i].fi>>b[i].se;

	REP(i,n) {
		REP(j,n) {
			if(a[i].fi<b[j].fi&&a[i].se<b[j].se) {
				add_edge(i,j+n);
			}
		}
	}

	S=2*n;
	T=S+1;

	//REP(i,n) add_edge(S,i);
	//REP(i,n) add_edge(n+i,T);

	cout<<bi()<<endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

signed main(){
    int X,Y; cin>>X>>Y;
    int ans = 0;
    while(X<=Y){
        X *= 2;
        ans ++;
    }
    Out(ans);
}





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

using namespace std;

typedef long long ll;
typedef long double ld;

const int maxn = 1e5 + 10;

ld pw[40];

int main(){
	ios_base::sync_with_stdio (false);
	int n, k;
	cin >> n >> k;
	pw[0] = 1;
	for (int i = 1; i <= 30; i++)
		pw[i] = .5 * pw[i - 1];
	ld answer = 0;
	for (int i = 1; i <= n; i++){
		int cnt = 0, t = i;
		while (t < k){
			cnt ++;
			t *= 2;
		}
		answer = (answer + pw[cnt]);
	}
	cout << fixed << setprecision(9) << 1. * answer / n << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String args[]) {
		FastScanner scanner = new FastScanner();
		int n=scanner.nextInt();
		int m=scanner.nextInt();
		int ans=0;
		if(n>m){
			ans+=n;
			n--;
		}else{
			ans+=m;
			m--;
		}
		if(n>m){
			ans+=n;
			n--;
		}else{
			ans+=m;
			m--;
		}
		System.out.println(ans);
	}
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

int main()
{
    ll l, r;
    cin >> l >> r;

    const ll mod = 2019;
    ll ans = mod - 1;

    r = min(r, l + mod * 2);
    for (ll i = l; i <= r; ++i)
    {
        for (ll j = i + 1; j <= r; ++j)
        {
            ll x = i * j % mod;
            ans = min(ans, x);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  vector<int>b(m);
  for(int j=0;j<m;j++){
  cin >> a.at(j) >> b.at(j);
  }
  for(int j=0;j<m;j++){
    for(int i=0;i<m;i++){
      if(a.at(i)==a.at(j) && b.at(i)!=b.at(j)){
      cout << -1 << endl;
      return 0;  
      }
      if(a.at(i)==1 && b.at(i)==0 && n!=1){
      cout << -1 << endl;
      return 0;  
      }
    }
  }
  vector<int>c(n);
  for(int i=0;i<m;i++){
  c.at(a.at(i)-1)=b.at(i);  
  }
  if(c.at(0)==0 && n!=1){
  c.at(0)=1;
  }
  for(int i=0;i<n;i++){
  cout << c.at(i);
  }
}
  

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

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

int main() {
    ll H,W;
    cin >> H >> W;
    vector<vector<int>> num(H,vector<int>(W));
    vector<ll>from_x,from_y,to_x,to_y;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> num[i][j];
        }
    }
    for(int i=0;i<H;i++){
        if(i&1){
            for(int j=W-1;j>=0;j--){
                if(num[i][j]&1){
                    if(num[i][j]&1){
                    if(j==0){
                        if(i==H-1)break;
                        num[i+1][0]++;
                        from_x.push_back(i);
                        from_y.push_back(j);
                        to_x.push_back(i+1);
                        to_y.push_back(0);
                    }
                    else{
                        num[i][j-1]++;
                        from_x.push_back(i);
                        from_y.push_back(j);
                        to_x.push_back(i);
                        to_y.push_back(j-1);
                        //cout << i << " " << j << " " <<i << " " << j-1 << endl;
                    }
                }

                }
            }
        }
        else{
            for(int j=0;j<W;j++){
                if(num[i][j]&1){
                    if(j==W-1){
                        if(i==H-1)break;
                        num[i+1][W-1]++;
                        //cout << i << " "<< j << " " << i+1 <<" "<< W-1 << endl;
                        from_x.push_back(i);
                        from_y.push_back(j);
                        to_x.push_back(i+1);
                        to_y.push_back(W-1);
                    }
                    else{
                        num[i][j+1]++;
                        //cout << i << " " << j << " " <<i << " " << j+1 << endl;
                        from_x.push_back(i);
                        from_y.push_back(j);
                        to_x.push_back(i);
                        to_y.push_back(j+1);
                    }
                }

            }
            
        }
    }
    cout << from_x.size() << endl;
    for(int i=0;i<from_x.size();i++){
        cout << from_x[i]+1 << " " << from_y[i]+1 << " " << to_x[i]+1 << " " << to_y[i]+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 7128
#include <bits/stdc++.h>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

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

//素数判定
ll isprime(ll n){
  bool prime=true;
  for(int i=2;i<n;i++){
    if(n%i==0){
      prime=false; break;
    }
  }
if(prime){cout<<n<<" is prime"<<endl;
         }else{cout<<n<<" is not prime"<<endl;}

}
//階乗　20くらいが限界
ll factorial(ll n){
  ll a=1;ll b=n;
  for(int i=0;i<n;i++){
    a*=b;
    b--;
  }
  return a;
}

//組み合わせ　nCr
ll comb(ll a,ll b){
  ll c;
  c=factorial(a)/(factorial(a-b)*factorial(b));
  return c; 
}




/*10億7。　　　100000007
2*2行列 H*W
vector<vector<int>> vec(H,vector<int>(W));
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
cin>>vec[i][j];
  }
}

文字列→数列
string S;int A=atoi(S.c_str());
数列→文字列
int A;string S=to_string(A);
数字判定　isdigit(a)
pair宣言　pair<int,int> p(5,7);
ソート　sort(vec.begin(),vec.end());
*/

int main(){
cout<<fixed<<setprecision(10);
  
string S;cin>>S;
int counter=0;
  for(int i=0;i<3;i++){
    if(S[i]=='o'){
      counter++;
    }
  }
  
  cout<<700+counter*100<<endl;
}


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

int n, k;
vector<int> h(500000);
vector<int> d(500000);

int main() {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> h.at(i);

    sort(h.begin(), h.begin()+n);

    // for (int i = 0; i < n; ++i) cout << h.at(i) << endl;

    for (int i = 0; i < n-k+1; ++i)
    {
        d.at(i) = h.at(i+k-1) - h.at(i);
    }

    // for (int i = 0; i < n; ++i) cout << d.at(i) << endl;

    int mind = 2000000000;
    for (int i = 0; i < n-k+1; ++i)
    {
        mind = min(mind, d.at(i));
    }

    cout << mind << endl;
}

Measured memory_bytes: 4096
# Author: cr4zjh0bp
# Created: Sat Mar 14 10:49:04 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

x, y = nas()
if ord(x) < ord(y):
    print("<")
elif ord(x) > ord(y):
    print(">")
else:
    print("=")

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int baris, kolom;
	int matrix1[105][105];
	int matrix2[105];
	scanf("%d %d", &baris, &kolom);
	for(int i=0; i<baris; i++){
		for(int j=0; j<kolom; j++){
			scanf("%d", &matrix1[i][j]);
		}
	}
	for(int i=0; i<kolom; i++){
		scanf("%d", &matrix2[i]);
	}
	for(int i=0; i<baris; i++){
		int sum = 0;
		for(int j=0; j<kolom; j++){
			sum += matrix1[i][j]*matrix2[j];
		}
		printf("%d\n", sum);
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,k;
    cin>>n>>k;
    ll ans=n+1-k;
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256