akhauriyash/Code-Regression huggingface dataset:
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#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;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pll>
#define vpii vector<pii>
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define MP make_pair
#define fs first
#define sc second
#define F first
#define S second
#define nl "\n"
#define asche cerr<<"Ekhane asche\n";
#define pf printf
#define sf scanf
#define mem(a,x) memset(a,x,sizeof(a))
#define SZ(v) (int)v.size()
#define all(v) v.begin(),v.end()
#define one(x) __builtin_popcount(x)
#define fout(x) fixed<<setprecision(x)
#define BeatMeScanf ios_base::sync_with_stdio(false)
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}
//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
namespace IO
{
    #define in() ( { int a ; scanf("%d",&a); a; } )
    #define LL() ( { ll a ; scanf("%lld",&a); a; } )
       #define ULL() ( { ull a ; scanf("%llu",&a); a; } )
    #define DD() ({ double a; scanf("%lf", &a); a;})
    #define CC() ( { char a ; scanf("%c",&a); a; } )
    #define pf1(a) printf("%d\n",a)
    #define pf1ll(a) printf("%lld\n",a)
}
using namespace IO;

const int mod=1e9+7;
const int N=3e5+9;
const double eps=1e-9;
const double PI=acos(-1.0);
ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

char s[N];
int32_t main()
{
    int n=in();
    sf("%s",s);
    int ans=0;
    for(int i=0,j;i<n;i=j){
        for(j=i+1;j<n&&s[i]==s[j];j++);
        ans++;
    }
    pf1(ans);
    return 0;
}
///Before submit=>
///    *check for integer overflow,array bounds
///    *check for n=1



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=998244353;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

int main(void){
    string s,t;
    cin>>s>>t;
    int ls=s.size(),lt=t.size();
    int ans=1000000;
    rep(i,ls-lt+1){
        int diff=0;
        rep(j,lt){
            if(s[i+j]!=t[j]) diff++;
        }
        chmin(ans,diff);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 2e18;


ll dist[55][55];
void solve() {
	int N; cin >> N;
	vector<int>A(N), B(N);
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];

	REP(i, 51)REP(j, 51)dist[i][j] = (1LL << 55);
	REP(i, 51) {
		FOR(j, 1, 51) {
			dist[i][i%j] = min(dist[i][i%j], (1LL << j));
		}
	}
	REP(i, 51) {
		dist[i][0] = min(dist[i][0], (ll)2);
		dist[i][i] = 0;
	}
	REP(k, 51) {	//kが中継点
		REP(i, 51) {
			REP(j, 51) {
				dist[i][j] = min(dist[i][j], (dist[i][k] | dist[k][j]));
			}
		}
	}
	REP(i, N) {
		if (dist[A[i]][B[i]] >= (1LL << 55)) {
			print("-1"); return;
		}
	}

	set<int>use;
	for (int k = 50; k >= 1; k--) {
		REP(i, 51)REP(j, 51)dist[i][j] = (1LL << 55);
		REP(i, 51) {
			dist[i][i] = 0;
		}
		for (auto r : use) {
			REP(i, 51) {
				dist[i][i%r] = min(dist[i][i%r], 1LL << (r));
			}
		}
		FOR(r, 1, k) {
			REP(i, 51) {
				dist[i][i%r] = min(dist[i][i%r], 1LL << i);
			}
		}
		bool need = false;
		REP(k2, 51) {	//kが中継点
			REP(i, 51) {
				REP(j, 51) {
					dist[i][j] = min(dist[i][j], (dist[i][k2] | dist[k2][j]));
				}
			}
		}
		REP(i, N) {
			if (dist[A[i]][B[i]] >= (1LL << 55)) {
				need = true; break;
			}
		}
		if (need) {
			//print(k);
			use.insert(k);
		}
	}
	ll ans = 0;
	for (auto k : use) {
		ans |= (1LL<<k);
	}
	print(ans);
}

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

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

using namespace std;

string sa, sb;
int inf = 1e8, n;

int solve() {
	int last = inf, ans = inf;
	vector<int> a(n), b(n);
	deque<int> ad(n);
	for (int i = 0; i < n; i++) {
		a[i] = sa[i] - '0';
		ad[i] = a[i];
		b[i] = sb[i] - '0';
	}
	vector<int> sl(n, inf), sr(n, inf);
	for (int i = 0; i < 2 * n; i++) {
		if (b[i % n] == 1)
			last = 0;
		else
			last++;
		sl[i % n] = last;
	}
	last = inf;
	for (int i = 2 * n - 1; i >= 0; i--) {
		if (b[i % n] == 1)
			last = 0;
		else
			last++;
		sr[i % n] = last;
	}
	for (int i = 0; i <= n; i++) {
		int msl, msr, cans = 0;
		vector<pair<int, int>> sls;
		for (int j = 0; j < n; j++) {
			if (ad[j] == b[j])
				continue;
			cans++;
			if (sl[j] > i) {
				msl = sl[(j + n - i) % n];
				msr = sr[j];
				sls.push_back({msl, msr});
			}
		}
		sort(sls.begin(), sls.end());
		int cmx = 0, best = inf;
		if (sls.empty())
			best = 0;
		for (int j = sls.size() - 1; j >= 0; j--) {
			//cout<<i<<' '<<j<<' '<<sls[j].first<<' '<<sls[j].second<<endl;
			best = min(best, sls[j].first + cmx);
			cmx = max(cmx, sls[j].second);
		}
		best = min(best, cmx);
		ans = min(ans, cans + i + best * 2);
		ad.push_front(ad.back());
		ad.pop_back();
	}
	return ans;
}


int main() {
	cin >> sa >> sb;
	n = sa.size();
	int ans = solve();
	reverse(sa.begin(), sa.end());
	reverse(sb.begin(), sb.end());
	ans = min(ans, solve());
	if (ans == inf)
		printf("-1\n");
	else
		printf("%d\n", ans);
}

Measured memory_bytes: 384
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
    public static void Main()
    {
        var xy = Console.ReadLine().Split()
            .Select(x => long.Parse(x))
            .ToArray();

        Console.WriteLine(Math.Abs(xy[0] - xy[1]) > 1 ? "Alice" : "Brown");
    }
}


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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;
pii arr[MAXN];

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> N;
    for(int i=1; i<=N; i++)
    {
        cin >> arr[i].f;
        arr[i].s = i;
    }
    sort(arr+1, arr+N+1);
    for(int i=1; i<N; i++)
    {
        cout << arr[i].s << " ";
    }
    cout << arr[N].s;
    return 0;
}


Measured memory_bytes: 1664
def P(s):
 i,R,P,*L=[0]*29
 while i<D:t=I[i+D][0]-1;P+=s+(~i+L[t])*C[t];R+=I[i][t]-P;i+=1;L[t]=i
 return R
(D,),C,*I=[[*map(int,t.split())]for t in open(0)]
for d,q in I[D-~D:]:I[d-1+D][0]=q;print(P(sum(C)))

Measured memory_bytes: 90356
s = list(input())
def month(i):
  if 1 <= int(i) <=12:
    return True
  else:
    return False
a = month("".join(s[0:2]))
b = month("".join(s[2:4]))
if a and b:
  print('AMBIGUOUS')
elif not a and b:
  print('YYMM')
elif a and not b:
  print('MMYY')
else:
  print('NA')
  
  
  

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int W, H; cin >> W >> H;
	int N; cin >> N;
	vector<int> x(N), y(N), a(N);
	for(int i = 0; i < N; i++) cin >> x[i] >> y[i] >> a[i];
	int left = 0, right = W, up = H, down = 0;
	for(int i = 0; i < N; i++) {
		if(a[i] == 1) left = max(left, x[i]);
		else if(a[i] == 2) right = min(right, x[i]);
		else if(a[i] == 3) down = max(down, y[i]);
		else up = min(up, y[i]);
	}
	int ans = max(0,(right - left)) * max(0,(up - down));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3616
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 3e3 + 10, mod = 1e9 + 7;

ll a[N], p2[N], c[N][N];
int x[N], y[N], debt[N][N], pend = 0;

void f(int i, int j);

int main() {
	fast_cin();
	int n, q;
	cin >> n >> q;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 1; i <= q; ++i) {
		cin >> x[i] >> y[i];
	}
	p2[0] = 1;
	for (int i = 1; i < N; ++i) {
		p2[i] = (2 * p2[i - 1]) % mod;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			c[i][j] = 1;
		}
	}
	for (int t = q; t >= 1; --t) {
		++pend;
		for (int i = 1; i <= n; ++i) {
			if (i == x[t] or i == y[t]) {
				continue;
			}
			f(i, x[t]); f(x[t], i);
			f(i, y[t]); f(y[t], i);
			c[i][x[t]] = c[i][y[t]] = (c[i][x[t]] + c[i][y[t]]) % mod;
			c[x[t]][i] = c[y[t]][i] = (c[x[t]][i] + c[y[t]][i]) % mod;
		}
		f(x[t], y[t]); f(y[t], x[t]);
		c[x[t]][y[t]] = c[y[t]][x[t]] = (c[x[t]][y[t]] + c[y[t]][x[t]]) % mod;
		// tot = (2 * tot) % mod;
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			--debt[i][j]; --debt[j][i];
			f(i, j); f(j, i);
			// cout << i << ' ' << j << ' ' << c[i][j] << endl;
			if (a[i] < a[j]) {
				ans += c[j][i];
				ans %= mod;
			} else if (a[i] > a[j]) {
				ans += c[i][j];
				ans %= mod;
			}
		}
	}
	cout << ans << endl;
}

void f(int i, int j) {
	++debt[i][j];
	c[i][j] *= p2[pend - debt[i][j]];
	c[i][j] %= mod;
	debt[i][j] = pend;
}

Measured memory_bytes: 106368
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int dp[2010][2010], pos[2][2010];

const int SIZE = 1 << 15;
struct segtree {
    int node[2*SIZE];
    segtree() {
        memset(node, 0, sizeof(node));
    }
    void init() {
        memset(node, 0, sizeof(node));
    }
    void update(int x, int val) {
        x += SIZE - 1;
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};
 
segtree seg;
signed main() {
    fill(dp[0], dp[2010], INF);
    dp[0][0] = 0;
    int N; cin >> N;

    for(int i=0; i<2*N; i++) {
        char c; int val; cin >> c >> val; val--;
        int col = (c == 'B' ? 1 : 0);
        pos[col][val] = i;
    }

    // black, white
    for(int i=0; i<=N; i++) {
        seg.init();
        for(int k=0; k<i; k++) seg.update(pos[1][k], 1);
        for(int j=0; j<=N; j++) {
            int target = i + j;
            if(i != N) {
                int inv1 = seg.query(pos[1][i], 2*N);
                chmin(dp[i+1][j], dp[i][j] + (pos[1][i] + inv1 - target));
            }

            if(j != N) {
                int inv2 = seg.query(pos[0][j], 2*N);
                chmin(dp[i][j+1], dp[i][j] + (pos[0][j] + inv2 - target));
                seg.update(pos[0][j], 1);
            }
        }
    }
    cout << dp[N][N] << endl;
    return 0;
}

Measured memory_bytes: 32512
#include <vector>
#include <iostream>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge> >;

Graph G;
vector<int> d; // d[i]根から頂点iまでの距離
void Dfs(int v, int parent)
{ 
    for (auto e : G[v])
    {
        if (e.first == parent) continue; // 逆流を防ぐ(探索の肝！)
        d[e.first] = d[v] + e.second;
        Dfs(e.first, v);
    }
}

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

    int u, v, w;
 
    G.assign(N, vector<Edge>());
    for (int i = 0; i < N - 1; ++i)
    {
        cin >> u >> v >> w;
        --u; --v;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    d.assign(N, 0);
    Dfs(0, -1);

    for (auto ans : d) cout <<(ans & 1)<< endl; // [ans % 2]だと時間がかかるので1とのビット積を用いている

    return 0;
};


Measured memory_bytes: 8192
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(2, n+1):
        idx = k * (j + 1) - 1
        if  idx > n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) % 2


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")



Measured memory_bytes: 7276
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        HashMap<String, Integer> b = new HashMap<>();
        HashMap<String, Integer> r = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String s = scan.next();
            if (!b.containsKey(s)) {
                b.put(s, 0);
            }
            int c = b.get(s);
            b.put(s,c+1);
        }
        int M = scan.nextInt();
        for (int i = 0; i < M; i++) {
            String s = scan.next();
            if (!r.containsKey(s)) {
                r.put(s, 0);
            }
            int c = r.get(s);
            r.put(s,c+1);
        }
        int answer = 0;
        for (String s : b.keySet()) {
            int count1 = b.get(s);
            int count2 = r.containsKey(s) ? r.get(s) : 0;
            answer = Math.max(count1 - count2, answer);
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21716
#include <string>
#include <map>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    int p[n];
    int x = 0;
    int y = 0;
    int z = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (p[i] <= a) {
            x++;
        } else if (p[i] > b) {
            z++;
        } else {
            y++;
        }
    }
    int ans = x;
    if (ans > y) {
        ans = y;
    }
    if (ans > z) {
        ans = z;
    }
    cout << ans;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
ll MOD=1000000007;
const ll INF=ll(1e15), sINF = ll(1e9);


vector<ll> v[MAXn];
ll pk[MAXn], dp[MAXn];

void dfs1(ll now,ll f)
{
    pk[now] = 1;
    for(ll k:v[now])if(k != f)
    {
        dfs1(k, now);
        pk[now] = pk[now]* (1+pk[k]) % MOD;
    }
}
void dfs2(ll now,ll f,ll tp)
{
    dp[now] = pk[now] * (tp+1) % MOD;
    vector<ll> t, pre, suf;
    pre.pb(1);
    suf.pb(1);
    t.pb(-1);
    for(ll k:v[now])if(k != f)t.pb(k), pre.pb(pk[k] + 1), suf.pb(pk[k] + 1);
    pre.pb(1);
    suf.pb(1);
    t.pb(-1);
    REP1(i, SZ(pre) - 2)pre[i] = pre[i] * pre[i-1] % MOD;
    for(int i = SZ(suf) - 2;i > 0;i --)suf[i] = suf[i] * suf[i+1] % MOD;
    REP1(i, SZ(t) - 2)
    {
        dfs2(t[i], now, (tp+1) * pre[i-1] % MOD * suf[i+1] % MOD);
    }
    
}


int main()
{
    IOS();
    ll n;
    cin>>n>>MOD;
    REP(i,n-1)
    {
        ll a, b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs1(1, -1);
    dfs2(1, -1, 0);
    REP1(i,n)cout<<dp[i]<<endl;
    
}


Measured memory_bytes: 34304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  set<int> st;
  rep(i,26) st.insert(i);
  rep(i,s.length())st.erase(s[i]-'a'); 
  rep(i,26){
    if(st.count(i)){
      cout << s;
      cout << (char)('a'+i) << endl;
      return 0;
    }
  }

  string t = s;
  reverse(all(t));
  rep(i,t.length()){
    st.insert(t[i]-'a');
    auto it = st.upper_bound(t[i]-'a');
    if(it != st.end()){
      cout << s.substr(0,s.length()-i-1);
      cout << (char)('a'+*it) << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int a[n+1];
	for(int i=n;i>0;i--){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cout<<a[i];
			if(n<=i){break;}
		cout<<" ";
	}
cout<<endl;
	return 0;
}

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

using namespace std;

using ll = long long;

const int MAX_T = 1e5 + 10;

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

    int n, C;
    cin >> n >> C;

    vector<vector<int>> cnt(C, vector<int>(MAX_T));
    for (int i = 0; i < n; ++i) {
        int s, t, c;
        cin >> s >> t >> c;
        ++cnt[c - 1][s];
        --cnt[c - 1][t + 1];
    }
    for (int i = 0; i < C; ++i)
        for (int j = 0; j < MAX_T; ++j)
            cnt[i][j] += cnt[i][j - 1];

    int ans = 0;
    for (int i = 0; i < MAX_T; ++i) {
        int num = 0;
        for (int j = 0; j < C; ++j)
            num += (0 < cnt[j][i]);
        ans = max(ans, num);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<int> aa(a);
  vector<int> bb(b);
  for (int i = 0; i < a; ++i) cin >> aa[i];
  for (int i = 0; i < b; ++i) cin >> bb[i];

  int mi = 1e9;
  for (int i = 0; i < m; ++i) {
    int x, y, c;
    cin >> x >> y >> c;
    x--; y--;
    int total = aa[x] + bb[y] - c;
    mi = min(mi, total);
  }

  mi = min(mi, *min_element(aa.begin(), aa.end()) + *min_element(bb.begin(), bb.end()));
  cout << mi << '\n';
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
    unsigned long long int a,b,min,max;
    cin>>a>>b;
    if(b%2 == 0){
        min = a*2;
        max = a*4;
        if(b>= min && b <= max){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
    }
    else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3624
A = []
a, op, b = map(str, input().split())
while op != '?':
    A.append([int(a),op,int(b)])
    a, op, b = map(str, input().split())
for i in range(len(A)):
    if A[i][1] == '+':
        print(A[i][0] + A[i][2])
    elif A[i][1] == '-':
        print(A[i][0] - A[i][2])
    elif A[i][1] == '*':
        print(A[i][0] * A[i][2])
    elif A[i][1] == '/':
        print(int(A[i][0] / A[i][2]))


Measured memory_bytes: 5604
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    int val=700;

    for(int i=0; i<3; i++){
        if(S[i]=='o'){
            val+=100;
        }
    }

    cout << val << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
int main(){
	int A,B,X;
	SCD(A); SCD(B); SCD(X);
	
	if((A<=X) and (X<=A+B)){
		printf("YES");
	}else{
		printf("NO");
	}
	
	return 0;
}







Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llu unsigned long long
#define ll long long
#define INF 0x3f3f3f3f
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define to_lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower);
#define to_upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper);
#define Mod 1000000007
using namespace std;

// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// print vector
template <typename T> 
inline ostream &operator<<(ostream &out, vector<T> &a) {
    for(auto &x : a) out << x <<" ";
    // return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

vector<ll> A,B,C;
vector<ll> dp[3];
ll solve(int n, int last)
{
	if(n<0)
		return 0;
	if(dp[last-1][n]!=-1)
		return dp[last-1][n];
	switch(last)
	{
		case 1: dp[last-1][n] = max(B[n]+solve(n-1,2),C[n]+solve(n-1,3));
				break;
		case 2: dp[last-1][n] = max(A[n]+solve(n-1,1),C[n]+solve(n-1,3));
				break;
		case 3: dp[last-1][n] = max(B[n]+solve(n-1,2),A[n]+solve(n-1,1));
				break;
	}
	return dp[last-1][n];
}

int main()	
{
	#ifdef SANS
		freopen("ongoingin.txt","r",stdin);
		freopen("ongoingout.txt","w",stdout);
	#endif
	fast
	int t=1;
	// cin>>t;
	while(t--)
	{
		int n;
		cin>>n;
		A.resize(n);
		B.resize(n);
		C.resize(n);
		for(int i=0; i<3; i++)
		{
			dp[i].resize(n);
			for(int j=0; j<n; j++)
				dp[i][j]=-1;
		}
		for(int i=0; i<n; i++)
			cin>>A[i]>>B[i]>>C[i];
		ll tempa=solve(n-1,1), tempb=solve(n-1,2), tempc=solve(n-1,3);
		cout<<max(tempa,max(tempb, tempc))<<endl;
	}
	#ifdef SANS
		cout<<"\nTime Elapsed:"<<1.0*clock()/CLOCKS_PER_SEC <<"sec\n";
	#endif
}

Measured memory_bytes: 12704
#include <stdio.h>
#include <string>
#include <iostream>

int main()
{
    int n, a, b, c, d;
    std::string s;
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    std::cin >> s;
    bool ok = true;
    for (int i = a-1; i < c-1; i++) {
	if (s[i] == '#' && s[i+1] == '#') {
	    ok = false;
	}
    }
    for (int i = b-1; i < d-1; i++) {
	if (s[i] == '#' && s[i+1] == '#') {
	    ok = false;
	}
    }
    if (c > d) {
	bool space = false;
	for (int i = b-2; i < d-1; i++) {
	    if (s[i] == '.' && s[i+1] == '.' && s[i+2] == '.') {
		space = true;
		break;
	    }
	}
	ok = ok && space;
    }
    printf(ok ? "Yes\n" : "No\n");
    return 0;
}


Measured memory_bytes: 576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VVI x(n), y(n);
    REP(i,n){
        int a = in();
        REP(j,a){
            x[i].push_back(in() - 1);
            y[i].push_back(in());
        }
    }
    int ans = 0;
    REP(mask,1<<n){
        bool f = true;
        int cnt = 0;
        REP(i,n) if ((mask >> i) & 1) cnt++;

        REP(i,n){
            if (((mask >> i) & 1) == 0) continue;
            REP(j,x[i].size()){
                if (((mask >> x[i][j]) & 1) != y[i][j]) f = false;
            }
        }
        if (f) chmax(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
X, Y, C = [], [], []
for _ in range(m):
    x, y, c = map(int, input().split())
    X.append(x)
    Y.append(y)
    C.append(c)

ans = min(A) + min(B)
for i in range(m):
    tot = A[X[i]-1] +B[Y[i]-1] - C[i]
    ans = min(tot, ans)
print(ans) 

Measured memory_bytes: 24704
let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = (x * y) mod m
let ( -^ ) x y = x +^ (m - y)

let () = Scanf.scanf "%d %d" @@ fun n k ->
  let min = ref 0 in
  let max = ref 0 in
  let ans = ref 0 in
  for i = 0 to n do
    min := i +^ !min;
    max := (n - i) +^ !max;
    if k <= i + 1 then ans := !max -^ !min +^ 1 +^ !ans
  done;
  Printf.printf "%d\n" !ans


Measured memory_bytes: 3876
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; ++i) {
        int h;
        cin >> h;
        v.push_back(h);
    }
    
    vector<int> c;
    c.push_back(0);
    for (int i = 1; i < n; ++i) {
        if (i == 1) {
            c.push_back(c[0] + abs(v[i] - v[i - 1])); 
        } else {
            int c1 = abs(v[i] - v[i - 2]);
            int c2 = abs(v[i] - v[i - 1]);
            c.push_back(min(c[i - 2] + c1, c[i - 1] + c2));
        }
    }
    
    cout << c[n - 1] << endl;
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        cout << 2 << " ";  
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            cout << i << " ";  
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        cout << n << " ";  
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
   long long int i,j;
 
   
 //long long int b[1000000];
 //set<long long int >s;
       long long int f=0,p=0,z,o=0;
       double pie=3.141592653589793238;
    long long int n,m,l=0,k,c,min1=100000000000000000,max2=-100;
    cin>>n;
  for(i=1;i*i<=n;i++)
  {
  if(n%i==0)
  {
      if((2*(min(i,n/i)-1)+max(i,n/i)-min(i,n/i))<min1)
      min1=2*(min(i,n/i)-1)+max(i,n/i)-min(i,n/i);
  }
  }
  cout<<min1;
  
 return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
n, m = map(int, input().split())
city_list = [[0] for _ in range(n + 1)]
city = [[]]
for _ in range(m):
    p, y = map(int, input().split())
    city_list[p].append(y)
    city.append([p, y])
for i in range(1, n + 1):
    city_list[i].sort()
for i in range(1, m + 1):
    ID = ''
    p = city[i][0]
    order = str(bisect_left(city_list[p], city[i][1]))
    p = str(p)
    ID = ID + ('0' * (6 - len(p)))
    ID += p
    ID += ('0' * (6 - len(order)))
    ID += order
    print(ID)

Measured memory_bytes: 82080
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
typedef long long int ll;
 
//typedef tree<pp, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
 
const ll N = 400005;
 ll mod = 1000000007;
const long long int inf = INT64_MAX;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	ll a,b,n;
	cin>>n>>a>>b;
	ll k = n/(a+b);
	ll k2 = n%(a+b);
	ll ans = k*a;
	if(k2>=a) ans+=a;
	else ans+=k2;
	cout<<ans<<endl;

	
}


	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 256
// Problem : C - Remainder Minimization 2019
// Contest : AtCoder - AtCoder Beginner Contest 133
// URL : https://atcoder.jp/contests/abc133/tasks/abc133_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
signed main() { 
	ll l,r;
	cin>>l>>r;
	r=min(r,l+2019);
	ll ans=2019;
	for(ll i=l;i<=r;i++)
		for(ll j=i+1;j<=r;j++)
			ans=min(ans,(i*j)%2019);
	cout<<ans<<nl;
}
// read the question correctly (ll vs int)
// template by bqi343

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

ruiA, ruiB = [0], [0]

for i in range(N):
    ruiA.append(ruiA[i] + A[i])

for j in range(M):
    ruiB.append(ruiB[j] + B[j])

t = False
for i in range(N + M + 1):
    if i <= N and ruiA[i] <= K:
        continue
    if i <= M and ruiB[i] <= K:
        continue
    if i > N and ruiA[N] + ruiB[i - N] <= K:
        continue
    if i > M and ruiA[i - M] + ruiB[M] <= K:
        continue

    t = False
    for j in range(0, i + 1):
        if j > M or i - j > N:
            continue
        if ruiA[i - j] + ruiB[j] <= K:
            t = True
            break

    if not t:
        print(i - 1)
        exit()

print(N + M)


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	for(int i=0;i<9;i++){
		char tmp;	
		cin >> tmp;
		if(i==0||i==4||i==8) cout << tmp;
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
import queue

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

for i in range(len(p)):
    p[i] = p[i] + 1

queue = queue.Queue()
currentSum = 0
maxSum = 0
for i in range(len(p)):
    currentSum = currentSum + p[i]
    queue.put(p[i])
    if queue.qsize() > K:
        currentSum = currentSum - queue.get()
    
    if queue.qsize() == K:
        maxSum = max(maxSum, currentSum)

print("{:.12f}".format(maxSum / 2))


Measured memory_bytes: 26328
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll K,N;
ll ans;
string S;
ll a;
vector<ll> so;
ll H,M,HH,MM;
ll now;
ll INF = 1e18;
double b;
 
int main(){
    cin >> N;
    K = N;
    ll i=2;
    while(i*i<=N){
        if(i>K){
            i++;
            continue;
        }
        ll k = 0;
        while(K>=1){
            if(K%i==0){
                K = K/i;
                k++;
            }else{
                break;
            }
        }
        int j = 1;
        while(k-j>=0){
            k -= j;
            ans++;
            j++;
        }
        i++;
    }
    if(K!=1){
        ans+=1;
    }
    cout << ans << endl;
    
    
}


Measured memory_bytes: 3548
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const ll mod = 1000000007;

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

    int n;
    cin >> n;
    ll t[n], a[n];
    bool possible = true;
    bool fixed[n];

    for (int i = 0; i < n; i++) {
        cin >> t[i];
        if (i == 0 || t[i] > t[i - 1]) {
            fixed[i] = true;
        } else {
            fixed[i] = false;
        }
    }

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

    for (int i = n-1; i >= 0; i--) {
        if (i == n-1 || a[i] > a[i+1]) {
            if (fixed[i] && t[i] != a[i]) {
                possible = false;
            }
            if (t[i] < a[i]) {
                possible = false;
            }
            fixed[i] = true;
        }
        t[i] = min(t[i], a[i]);
    }

    ll ans = 1LL;
    for (int i = 0; i < n; i++) {
        if (!(fixed[i])) {
            ans = ans * t[i] % mod;
        }
    }

    if (!(possible)) ans = 0LL;

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

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a == b) {
			System.out.println("a == b");
		}
		sc.close();
	}
}


Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	vi a(106,0);
	rep(i,n){
		int d;cin>>d;
		a[d]++;
	}
	int ans=0;
	rep(i,105)ans+=a[i]>0;
	cout<<ans<<endl;
	

	return 0;
}



Measured memory_bytes: 3632
n, k=map(int, input().split())
# nがkよりも大きい場合毎回kで減っていって、kよりも小さくなってからは２つの値を行ったり来たりするよ
#となると、まず、kで割った場合の余りを出して、

if n>=k:
  print(min(n%k, k-n%k))
else:
  print(min(k-n, n))

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

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

	int i;
	int j = 0,z = 0;

	int k[100];

	for (i = 0; i < 100; i++)
		k[i] = 0;

	for (i = 0; i < 100; i++) {
		if (A % (i+1) == 0) {
		    k[j] = i+1;
			j++;
		}
	}
	for (i = 0; i < j; i++) {
		if (B % k[i] == 0) {
			k[z] = k[i];
			z++;
		}
	}
	
	cout << k[z - K];

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m, t, a[109];
int main() {
	cin >> n >> m >> t; a[0] = -m, a[n+ 1] = t + m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	int ret = 0;
	for(int i = 0; i <= n; i++) ret += max(a[i + 1] - a[i] - 2 * m, 0);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3056
using System;
using System.Linq;
using static System.Console;

class Program
{
    public static void Main()
    {
        var t = ReadLine().Split('/').Select(x => int.Parse(x)).ToArray();
        int y = t[0];
        int m = t[1];
        // int d = t[2];
        if ((y > 2019) || ((y == 2019) && (m > 4)))
        {
            WriteLine("TBD");
        }
        else
        {
            WriteLine("Heisei");
        }
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<double,ll> P;


int main(){
	
	string str;
	cin >> str;
	ll k;cin >> k;
	
	REP(i,str.size()){
		if(str[i] == 'a')continue;
		int tmp = 26 - (str[i] - 'a');
		if(tmp <= k){
			str[i] = 'a';
			k -= tmp;
		}
		if(k == 0)break;
		//cout << i << " " << k << endl;
	}
	
	k %= 26;
	while(k > 0){
		int tmp = str[str.size() - 1] - 'a';
		tmp = (tmp + 1) % 26;
		str[str.size() - 1] = tmp + 'a';
		k--;
	}
	cout << str << endl;
	
	return 0;
}


Measured memory_bytes: 512
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl ;
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 45000 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;


int main() {
    int N ;
    cin >> N ;
    ll x ;
    cin >> x ;
    ll a[N] ;
    for(int i=0;i<N;i++) cin >> a[i] ;
    sort(a,a+N) ;
    int cnt=0 ;
    for(int i=0;i<N;i++)
    {
        if(x-a[i]>=0){
        x-=a[i];
        cnt++ ;
        }
        else x =0 ;
    }
    if(x > 0) {
        cnt--;
    }
    cout<<cnt<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int W = scanner.nextInt();
    int[] w = new int[N + 1];
    int[] v = new int[N + 1];
    for (int i = 1; i <= N; i++) {
      w[i] = scanner.nextInt();
      v[i] = scanner.nextInt();
    }

    long[][] dp = new long[N + 1][W + 1];
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= W; j++) {
        dp[i][j] = dp[i - 1][j];
        if (j >= w[i]) dp[i][j] = Math.max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
      }
    }
    System.out.println(dp[N][W]);
  }
}


Measured memory_bytes: 127316
#include <stdio.h>

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a+b==c||b+c==a||c+a==b){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

#define REP(_i, _cnt) for(int _i=0;_i<_cnt;_i++)

using namespace std;

int main()
{
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int mW = -1, mS = -1;
  for (int a = 0; a <= 30; a++) {
    for (int b = 0; b <= 30; b++) {
      if (100*A*a + 100*B*b > F) continue;
      int W = 100*A*a + 100*B*b;
      int Su = F - W;
      for (int c = 0; C*c <= Su; c++) {
        for (int d = 0; D*d + C*c <= Su; d++) {
          int S = C*c + D*d;
          if (E*W < 100*S || S + W == 0) continue;
          if (mS*(S+W) < S*(mS+mW)) {
            mS = S;
            mW = W;
          }
        }
      }
    }
  }
  cout << (mW + mS) << ' ' << mS << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int S, h, m, s;
  scanf("%d", &S);
  h = S / 60 / 60;
  m = S / 60 % 60;
  s = S % 60;
  printf("%d:%d:%d\n", h, m, s);
  return 0;
}



Measured memory_bytes: 2108