akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using  namespace std;

class UnionFind {
  public:

  //par[i]:parent of i. rank[i]:rank(depth) of the group with i.
  vector<int> par, rank; 

  UnionFind(int n) {
    par = vector<int>(n, -1);
    rank = vector<int>(n, 0);
  }

  int root(int x) {               //root(x):root of x
    return (par[x] < 0) ? x : par[x] = root(par[x]);
  }

  int size(int x) {               //the number of edge of the group with x
    return -par[root(x)];
  }

  bool same(int x, int y) {       //judge whether x & y is in the same group.
    return root(x) == root(y);
  }

  void unite(int x, int y) {      //unite group with x & group with y.
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank[x] < rank[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    if (rank[x] == rank[y]) rank[x]++;
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    --x; --y;
    uf.unite(x, y);
  }
  int ans = 0;
  rep(i, n) if (uf.root(i) == i) ++ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
li = [list(map(int, input().split())) for i in range(n)]
foods = [1] * m
for person in li:
    for i in range(m):
        if i + 1 not in person[1:]:
            foods[i] = 0
            
print(foods.count(1))

Measured memory_bytes: 3060
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        var dic = new HashSet<char>();
        foreach(char c in s) {
            if(!dic.Contains(c)) dic.Add(c);
        }

        if(dic.Count == 1) return 0;

        int min = int.MaxValue;
        for(char i='a'; i<='z'; i++) {
            if(!dic.Contains(i)) continue;
            min = Math.Min(f(s, i), min);
        }

        return min;
    }

    static int f(string s, char c) {
        char[] y = s.ToCharArray();
        int co = 0;
        while (true) {
            char[] y2 = new char[y.Length-1];
            bool all = true;
            for(int i=0; i<y2.Length; i++) {
                if(y[i] == c || y[i+1] == c){
                    y2[i] = c;
                } else {
                    y2[i] = y[i];
                    all = false;
                }
            }
            co++;
            y = y2;
            if(all) return co;
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11348
#include <functional>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    sort(H.begin(), H.end(), greater<ll>());
    if (N <= K) {
        cout << 0 << endl;
        return 0;
    }
    ll sum = 0;
    for (int i = K; i < N; i++) {
        sum += H[i];
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 4764
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int H, W;
	std::vector<std::string> A;
	std::cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		std::string a;
		std::cin >> a;
		if (std::find(a.begin(), a.end(), '#') == a.end())
			continue;
		A.push_back(std::move(a));
	}

	std::deque<bool> B;
	B.resize(A[0].size());
	for (int x = 0; x < A[0].size(); ++x) {
		int y = 0;
		for (; y < A.size(); ++y) {
			if (A[y][x] == '#')
				break;
		}
		if (y == A.size()) {
			B[x] = true;
		}
	}
	
	for (auto& a : A) {
		for (int x = 0; x < a.size(); ++x) {
			if (!B[x])
				std::cout << a[x];
		}
		std::cout << "\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> A >> B;

	string ab = "";
	rep(i, 0, B) ab += char('0' + A);

	string ba = "";
	rep(i, 0, A) ba += char('0' + B);

	string ans = min(ab, ba);
	cout << ans << endl;
}







Measured memory_bytes: 256
def split_returner(chardata):
        chardata = str(chardata).split(" ")
        for i in range(0,len(chardata)):
            chardata[i] = int(chardata[i])
        return chardata

a = split_returner(input())
result = int((a[2]+0.5)/a[0]) * a[1]
print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>c){
    swap(a,c);
    swap(b,d);
  }
  int ans=max(0LL,min(b,d)-c);
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    int n,k;
    cin>>n>>k;
    int ans=k;
    for(int i=0;i<n-1;i++) ans*=k-1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cmath>
using namespace std;
int main(){
  double r, pi_value;
  pi_value = 3.141592653589793238;
  cin >> r;
  printf("%.6f %.6f\n", pow(r, 2)*pi_value, r*2*pi_value);
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
#include <stdio.h>
using namespace std; 
int main()
{
    int c=1000000007;
    unsigned long long int n;
    cin>>n;
    unsigned long long int a[n];int rag=0;int count=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        if(a[i]==0)
            rag=1;
        if(a[i]>c)count++;
    }
    if(rag==1)
    {
        cout<<0;
    }
    else
        if(count>=2)
        {
            cout<<-1;
        }
        else
    {

        unsigned long long int p=1;int flag=0;
        for (int i = 0; i < n; ++i)
        {
            p=p*a[i];
            if(p>1000000000000000000 || p<0)
                {cout<<-1;flag=1;break;}
        }
         if (flag==0)
        {
            cout<<p;
        }
    }
} 

Measured memory_bytes: 4376
N, M, *I = map(int, open(0).read().split())
H, AB = [0] + I[:N], I[N:]

memo = [False] + [True] * N
for a, b in zip(*[iter(AB)] * 2):
    if H[a] < H[b]:
        memo[a] = False
    elif H[b] < H[a]:
        memo[b] = False
    else:
        memo[a] = memo[b] = False

print(sum(memo))

Measured memory_bytes: 43952
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

int n;
vi d;

int m;
vi t;

bool read() {
	if  (scanf("%d", &n) < 1) {
		return 0;
	}
	d.resize(n);
	forn(i, n) {
		scanf("%d", &d[i]);
	}

	scanf("%d", &m);

	t.resize(m);
	forn(i, m) {
		scanf("%d", &t[i]);
	}

	swap(n, m);
	swap(d, t);
	
	return 1;
}

bool solve() {
	multiset<int> D;
	forn(i, n) {
		D.insert(d[i]);
	}

	for (int x : t) {
		if  (D.count(x)) {
			D.erase(D.find(x));
		}
	}

	return D.empty();
}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	while (read()) {
		puts(solve() ? "YES" : "NO");
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


Measured memory_bytes: 11136
#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
#define readint read<int>()
#define readlint read<lint>()

const int inf=1e9+1e7;

lint ans=0,x,n;

lint Eclid(lint N,lint X)
{
	if(!(N%X)) return (N/X)*X*2-X;
	else return Eclid(X,N%X)+(N/X)*X*2;
}

int main(void)
{
	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);
	scanf("%lld%lld",&n,&x);
	ans=n+Eclid(x,n-x);
	printf("%lld\n",ans);
	return 0;
}

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

// one-based numbering
struct UnionFind {
    vector<int> data;
    // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
    UnionFind(int n) {
        data.resize(n+1, -1);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    int size(int x) {
        return -data[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    vector<long long> x(n+1, 0);
    for (int i = 0; i < n; i++) cin >> x[i+1];
    using edge = pair<long long, array<int, 2>>;
    vector<edge> v;
    vector<array<int, 3>> p(m);
    vector<array<long long, 2>> px(m);
    for (int i = 0; i < m; i++) {
        int a, b; long long y; cin >> a >> b >> y;
        v.push_back({y, {a, b}});
    }
    sort(v.begin(), v.end());
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a = v[i].second[0], b = v[i].second[1];
        p[i][0] = uf.find(a), p[i][1] = uf.find(b);
        px[i][0] = x[p[i][0]], px[i][1] = x[p[i][1]];
        if (!uf.same(a, b)) {
            uf.unite(a, b);
            x[uf.find(a)] = x[p[i][0]] + x[p[i][1]];
        }
        p[i][2] = uf.find(a);
    }
    long long all = x[uf.find(1)];
    for (int i = 0; i < n; i++) x[i] = all;
    int ans = 0;
    for (int i = m-1; i >= 0; i--) {
        if (x[p[i][2]] < v[i].first) {
            ans++;
            x[p[i][0]] = px[i][0];
            x[p[i][1]] = px[i][1];
        }
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  long long n,m;
  cin >>n>>m;
  if(n*2>=m)cout<<m/2<<endl;
  else {
    long long kotae=n;
    m-=2*n;
    kotae+=m/4;
    cout<<kotae<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define mp make_pair
#define pb push_back
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define sz(a) int((a).size())
#define endl '\n'
#define INF 1000000007 

signed main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);

	string s,t;
	cin>>s>>t;

	int sl = s.length();
	int tl = t.length();

	vvi dp(sl+1,vi(tl+1));
	//vector<string>v(tl+1);

	for(int i=0;i<sl;i++){
		for(int j=0;j<tl;j++){
			if(s[i]==t[j]){
				dp[i+1][j+1] = dp[i][j]+1;
				//v[j]+=s[i-1];
			}else{
				dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
				/*if(dp[i][j]==dp[i][j-1]){
					v[j]=v[j-1];
				}*/
			}
		}
	}
	string res="";
    int i=(int)s.size(), j=(int)t.size();
    while(i>0 && j>0){
        if(dp[i][j]==dp[i][j-1]){
            --j;
        } 
        else if(dp[i][j]==dp[i-1][j]){
            --i;
        }else {
            res=s[i-1]+res;
             --i; --j;
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    sort(begin(s),end(s));
    if(s[0]==s[1] && s[2]==s[3] && s[1]!=s[2]){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
}

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

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

int main(void){
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = b-a+1;
	ans -= b/c - (a-1)/c;
	ans -= b/d - (a-1)/d;
	ll l = c / myGcd(c, d) * d;
	ans += b/l - (a-1)/l;
	cout <<  ans << endl;
	return 0;
}

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;//use A C G T ' ' as 5 jinzhi data.
}

long long getKey(char str[])
{
  long long sum = 0, p = 1, i;
  for(i=0; i<strlen(str); i++)
  {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M-1));} // h2 should be prime with M, so that index can go through whole array.

int find(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for(i=0; i<M ; i++)
  {
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[])
{
  long long key, i, h;
  key = getKey(str);
  for(i=0; i<M; i++)
  {
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0)
    {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main()
{
  int i, n, h;
  char str[L], com[9];
  for(i=0; i<M; i++)
  {
    H[i][0] = '\0';
  }
  scanf("%d", &n);
  for(i=0; i<n; i++)
  {
    scanf("%s %s", com, str);
    if(com[0] == 'i')
    {
      insert(str);
    }
    else
    {
      if(find(str))
        printf("yes\n");
      else
        printf("no\n");
    }
  }
}



Measured memory_bytes: 16036
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 171, task c, 2020/06/21
//ms,
/*
*/

int main(void){
  int64_t N;
  vector<int64_t> dogs_num;//index群の犬の数
  int64_t counted=0;
  int name_size=1;
  string ans="";

  cin >>N;
  N--;
  dogs_num.push_back(0);
  dogs_num.push_back(26);

  while(counted<=N){
    counted += dogs_num[name_size];
    dogs_num.push_back(dogs_num[name_size]*26);
    name_size++;
  }
  name_size--;

  for(int i=0;i<name_size;i++){
    N -= dogs_num[i];
  }


  for(int i=1;i<=name_size;i++){
    //cout <<N<<endl;
    //cout <<N%26<<endl;
    char tmp = 'a';
    tmp += N%26;
    ans += tmp;
    N /= 26;
  }

  reverse(ans.begin(), ans.end());
  cout <<ans <<endl;

  return 0;
}
/*
1,000,000,000,000,001
26をかければ桁は少なくとも１つ増える。ので、犬の名前の文字数は定数オーダー。
文字数さえ求まればあとは余りで適当に出力できるね。
*/


Measured memory_bytes: 3612
H, W, h, w = map(int, input().split())
if H % h == 0 and W % w == 0:
    print("No")
else:
    print("Yes")
    ans = [[None] * W for i in range(H)]
    for i in range(H):
        for j in range(W):
            if i % h == h - 1 and j % w == w - 1:
                ans[i][j] = -1 * 1000 * (h * w - 1) - 1
            else:
                ans[i][j] = 1000
    for i in ans:
        print(*i)

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



int main() {
   int a, b, c, d;
   cin >> a >> b >> c >> d;
   for (int i=0; i<101; i++) {
      c = c - b;
      if (c <= 0) {
         cout << "Yes" << endl;
         return 0;
      }
      a = a - d;
      if (a <= 0) {
         cout << "No" << endl;
         return 0;
      }
   }
   return 0;
}

Measured memory_bytes: 3632
lis=[];

for i in range(10):
    h=int(input());
    lis.append(h);
    
for i in range(10):
    for j in range(i+1,10):
        if lis[i]<lis[j]:
            a=lis[i];
            lis[i]=lis[j];
            lis[j]=a;
            
for i in range(3):
    print(lis[i]);

Measured memory_bytes: 7616
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cerr << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF=1e9;
string a,b;
int L[2005],R[2005];
vector<int> car[2005];

int main()
{jizz
	int ans=INF,flag=0,n;
	cin >> a >> b,n=a.size();
	for(int i=0;i<n;++i)
		if(b[i]=='1') flag=1;
	if(!flag)
		return cout << ((a==b)?"0\n":"-1\n"),0;
	for(int i=0;i<n;++i)
		for(int j=L[i]=i;b[(j+n)%n]!='1';L[i]=--j);
	for(int i=0;i<n;++i)
		for(int j=R[i]=i;b[j%n]!='1';R[i]=++j);
	for(int i=-n+1;i<n;++i)
	{
		int tmp=-abs(i),r=0,mi=INF,lt=0,rt=0;
		if(i>0) rt=r=i;
		else if(i<0) lt=-i;
		for(int j=0;j<n;++j) car[j].clear();
		for(int j=0;j<n;++j)
			if(b[(j+i+n)%n]!=a[j])
				++tmp,car[j-L[j]].pb(R[j]-j);
		for(int j=n-1;j>=lt;mi=min(2*(r+j),mi),--j)
			for(int k:car[j+1])
				r=max(r,k);
		ans=min(ans,tmp+mi);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 384
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int H, W; std::cin >> H >> W;
	Int h, w; std::cin >> h >> w;

	std::cout << H * W - (h * W + w * H - h * w);

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'
#define INF 1000000007

const int maxn=2e6+5;
ll f[maxn];

ll pow(ll val, ll exp, ll MOD)
{
    ll x=1,y=val; 
    while(exp > 0)
    {
        if(exp%2 == 1)
        {
            x=(x*y);
            if(x>MOD) x%=MOD;
        }
        y = (y*y);
        if(y>MOD) y%=MOD; 
        exp /= 2;
    }
    return x;
}
ll InverseEuler(ll n, ll MOD)
{
    return pow(n,MOD-2,MOD);
}
 
ll C(ll n, ll r, ll MOD)
{
    return (f[n]*((InverseEuler(f[r], MOD) * InverseEuler(f[n-r], MOD)) % MOD)) % MOD;
}

void compute(int mod)
{
    f[0] = 1;
	for(int i = 1 ; i < maxn ; i++)
		f[i] = (f[i-1]*i)%mod;
}

int mul(int x, int y)
{
    return (x * 1ll * y) % INF;
}

int main()
{
    IOS;
    compute(INF);
    string s;
    ll k;
    cin>>k;
    cin>>s;
    ll n=s.size();

    ll ans=0;

    for (int i = 0; i <= k; i++)
        ans=(ans+mul(pow(25,k-i,INF),mul(pow(26,i,INF),C(n-1+k-i,k-i,INF))))%INF;
    
    cout<<ans;
}

Measured memory_bytes: 19884
# import pandas as pd
# import numpy as np

# d = pd.read_csv("useful.csv", usecols = ["Q133", "Q134", "Q146"])

# #l = d["Q133"]
# l = d["Q146"]
# bad = []
# good = [] 
# for i in range(1, 56):
# 	if int(l[i][0]) >= 4:
# 		good.append(i)
# 	else:
# 		bad.append(i)
# print(bad, good)

import sys
input = sys.stdin.readline

n, k = list(map(int, input().split()))
l = input().strip()
ans = 0
for i in range(n - 1):
	if l[i] == l[i+1]:
		ans += 1
print(min(ans + 2 * k, n - 1))




Measured memory_bytes: 39408
using System;

namespace _176_b
{
    internal class MultipleOf9
    {
        private static void Main(string[] args)
        {
            long sum = 0;
            while (true)
            {
                var n = Console.Read() - '0';
                if (n < 0 || n > 9) break;
                sum += n;
            }

            Console.WriteLine(sum % 9 == 0 ? "Yes" : "No");
        }
    }
}

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

using namespace std;

void solve()
{
    int n, m;
    cin >> n >> m;
    int ans = 0;
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int x;
        cin >> x;
        mp[x]++;
    }
    vector<int> mods(m), used(m), pairs(m);
    for (auto &p : mp)
    {
        if (p.second)
        {
            mods[p.first % m] += p.second;
            pairs[p.first % m] += p.second / 2;
        }
    }
    ans += mods[0] / 2;
    for (int i = 1; i <= m / 2; i++)
    {
        if (i * 2 == m)
        {
            ans += mods[i] / 2;
            used[i] = mods[i];
        }
        else
        {
            int y = min(mods[i], mods[m - i]);
            ans += y;
            used[i] = used[m - i] = y;
        }
    }
    for (int i = 1; i < m; i++)
    {
        int z = (mods[i] - used[i]) / 2;
        ans += min(z, pairs[i]);
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n,res=0;
	cin>>n;
	vector<int> a(n);
	for(int& x:a) cin>>x;
	for(int i=0;i<n;++i){
		if(i+1==a[i]) res++,i++;
	}
	cout<<res<<'\n';
}




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

using namespace std;

template <typename T> void debug(T v) { cout << v << endl; } /* {{{ */
template <typename T, typename... Rest> void debug(T v, Rest... r) {
  cout << v << " ";
  debug(r...);
}
template <typename T> void debug(const vector<T> &v) {
  for (const auto &e : v) {
    cout << e << " ";
  }
  cout << endl;
}
template <typename T> void debug(const vector<vector<T>> &vv) {
  for (const auto &v : vv) {
    debug(v);
  }
} /* }}} */

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<int>> A(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A[i][j];
    }
  }
  int i = 0, j = 0;
  int carry = 0;
  vector<vector<int>> ans;
  while (true) {
    A[i][j] += carry;

    int ni = i, nj = j;
    if (i % 2 == 0) {
      if (j == W - 1) {
        if (i == H - 1) break;
        ni++;
      } else {
        nj++;
      }
    } else {
      if (j == 0) {
        if (i == H - 1) break;
        ni++;
      } else {
        nj--;
      }
    }

    if (A[i][j] % 2) {
      ans.push_back({i, j, ni, nj});
      carry = 1;
    } else {
      carry = 0;
    }
    i = ni;
    j = nj;
  }
  cout << ans.size() << endl;
  for (auto a : ans) {
    for (int i = 0; i < 4; i++) {
      if (i > 0) cout << " ";
      cout << a[i] + 1;
    }
    cout << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 9904
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    string input;
    string ans;
    cin >> input;
    ans = input;
    int right = 0;
    for(int i = n - 1; i >= 0; --i){
        if(input[i] == ')'){
            right++;
        }
        else{
            if(right == 0){
                ans += ")";
            }
            else{
                right--;
            }
        }
    }
    for(int i = 0; i < right; ++i){
        ans = "(" + ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

int main()
{
    int n;
    int tmp1;
    int maxv=-2000000000;
    scanf("%d",&n);
    int R[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&R[i]);
    }
    int minv=R[0];
    for(int i=1;i<n;i++)
    {
        maxv=max(maxv,R[i]-minv);
        minv=min(minv,R[i]);
    }
    printf("%d\n",maxv);
    return 0;
}



Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> s(m);
    rep(i,m){
        int k; cin >> k;
        rep(j,k) {
            int a; cin >> a;
            --a;
            s[i].pb(a);
        }
    }
    vector<int> p(m);
    rep(i,m) cin >> p[i];
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        bool all = true;
        for(int j = 0; j < m; j++){
            int sum = 0;
            for(int k : s[j]){
                if((i>>k) & 1) sum++;
            }
            if(sum%2 != p[j]) all = false;
        }
        if(all) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  int n;
  cin>>n>>s;
  for(int i=0;i<s.size();i++){
    s[i]+=n;
    if(s[i]>'Z'){
      s[i]=s[i]-'Z'+'A'-1;
    }
    cout<<s[i];
  }
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>

int a[100][50];
int dp[100][50];

int main()
{
	int n, l = 0;
	while( std::cin >> n )
	{
		static int j;

		a[l][j++] = n;
		char c = std::cin.get();

		if( c == '\n' )
		{
			++l;
			j = 0;
		}
	}

	dp[0][0] = a[0][0];

	for( int i = 0; i != l; ++i )
	{
		for( int j = 0; j <= std::min( i, l - 1 - i ); ++j )
		{
			if( i <= l / 2 )
			{
				if( j )
					dp[i][j] = dp[i-1][j-1] + a[i][j];

				if( j <= std::min( i - 1, l - 1 - i + 1 ) + 1 )
					dp[i][j] = std::max( dp[i][j], dp[i-1][j] + a[i][j] );
			}
			else
				dp[i][j] = std::max( dp[i-1][j], dp[i-1][j+1] ) + a[i][j];
		}
	}

	std::cout << dp[l-1][0] << std::endl;

	return 0;
}

Measured memory_bytes: 1200
A, B = map(int, input().split())
#f(0,N)
def f(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 3:
        return 0
    elif n % 4 == 0:
        return 1 ^ (n + 1)
    elif n % 4 == 2:
        return 0 ^ (n + 1)

print(f(A - 1) ^ f(B))

Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 size_t strlen(const char *s);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=100010;
const int P=1000000007;
int compare_int(const void *a, const void *b)
{
    return *(long long int*)a - *(long long int*)b;//a-b昇順
}
//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ
//	cout<<(n-2)*180<<endl;
//	string s="hoge";
//	cout<<ans<<endl;
//	int  n  ,a  ,b  ,c  ,d  ,e  ,f  ;
//	cin  >>n  >>a  >>b  >>c  >>d  >>e  >>f  ;

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	len = strlen(s);
文字列長さ*/


/*
	string s;
	s.size()
*/


/*ソート
	qsort(b, 10, sizeof(int), compare_int);
*/


/*
	char s[N];
	strlen(s)
/*
	if(  <  )puts("Yes");
	else puts("No");
*/
/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/

int main(){
	int n, k, q;
	cin>>n>>k>>q;
	int sc[100010];
	int j;
	rep(i, 100010){
		sc[i]=0;
	}

	rep(i, q){
		cin>>j;
		sc[j-1]++;
	}
	rep(i, n){
		if(sc[i]>q-k)puts("Yes");
	else puts("No");
	}
}

/*int main()
{
    char str1[] = "Kyoto";
    char str2[] = "Sangyo";
	char str3[22] "aaa";
	if(1){
	 str3 = "University";
	}
    printf("%s %s %s\n", str1, str2, str3);
    return 0;
}*/

Measured memory_bytes: 1280
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let (n, k, c): (usize, usize, usize) = (sc.read(), sc.read(), sc.read());
    let s = sc.chars();

    let mut pos: usize = 0;
    let l: Vec<usize> = (0..k)
        .map(|_| {
            while s[pos] == 'x' {
                pos += 1;
            }
            pos += c + 1;
            pos - c - 1
        })
        .collect();

    let mut pos: usize = n - 1;
    let r: Vec<usize> = (0..k)
        .map(|i| {
            while s[pos] == 'x' {
                pos -= 1;
            }
            if i + 1 < k {
                pos -= c + 1;
                pos + c + 1
            } else {
                pos
            }
        })
        .collect();

    for (x, y) in l.iter().zip(r.iter().rev()) {
        if x == y {
            let _ = write!(out, "{}\n", x + 1);
        }
    }
}


Measured memory_bytes: 5960
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
//自作関数
template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
ll solve(ll h){
    if(h==1)return 1;
    else {
        return 2*solve(h/2)+1;
    }
}
int main(){
    ll h;
    cin>>h;
    ll ans=solve(h);
    cout<<ans<<endl;
    return 0;
}




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

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<ll> vec(5);
    string str;
    rep(i,n){
        cin >> str;
        if(str[0] == 'M') vec[0]++;
        if(str[0] == 'A') vec[1]++;
        if(str[0] == 'R') vec[2]++;
        if(str[0] == 'C') vec[3]++;
        if(str[0] == 'H') vec[4]++;
    }
ll ans = 0;
    rep(i,5){
        reps(j,i+1,5){
            reps(k,j+1,5){
                ans += (vec[i] * vec[j] * vec[k]);
                //cout << i << " " << j << " " << k << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
int binary_search(int num)
{
	int low=0,high=n-1;
	while(low<high-1)
	{
		int mid=(low+high)>>1;
		if(a[mid]<num)
			low=mid;
		else
			high=mid;
	}
	if(high==n-1)return a[low];
	if(low==n-1)return a[high];
	if(abs(a[low]-num)<abs(a[high]-num))
		return a[low];
	else
		return a[high];
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]<<' '<<binary_search(a[n-1]/2);
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;

  put(T + S);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

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

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) {
  T c = min(a, b), d = max(a, b);
  return c * (d / gcd(c, d));
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register
#define int long long
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
int a,b,c,d;
signed main(){
a=read();
b=read();
c=read();
if(c<=a){
	printf("%lld %lld",a-c,b);
}
else if(b-c+a>=0)printf("%lld %lld",0,b-c+a);
else puts("0 0");
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll l, r;
  cin >> l >> r;
  if (r - l >= 2019) {
    cout << 0 << endl;
  } else {
    ll ans = 1000000000000;
    for(ll i = l; i <= r; i++) {
      for(ll k = i + 1; k <= r; k++) {
        ans = min(ans, (i%2019)*(k%2019)%2019);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),max=0,total=0;
		for(int i=0; i<N; i++) {
			int l = sc.nextInt();
			if(max < l) {
				total+=max;
				max=l;
			}else {
				total+=l;
			}
		}
		System.out.println(max<total?"Yes":"No");
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define INF 1e9
#define MOD 1000000007
using namespace std;
using ll = long long;

int main(void) {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll allSum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        allSum += A[i];
    }
    
    ll ans = 0;
    for (int i = 0; i < N-1; i++)
    {
        allSum-=A[i];
        ans += ((allSum % MOD) * A[i])%MOD;
        ans %= MOD;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#include <sys/time.h>

#define mp       make_pair
#define mt  make_tuple
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF=1<<29;
const double EPS=1e-9;
const ll MOD = 1000000007;

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

const int MAX_NM = 100100;
int N,M;

vector<int> learn_person[MAX_NM];
vector<int> edges[MAX_NM];

bool visited[MAX_NM];
class Timer {
public:
  Timer() {}
  void start() { start_time = get_mill_sec(); }
  double get_mill_duration() { return get_mill_sec() - start_time; }

private:
  double start_time;
  double get_mill_sec() {
    struct timeval res;
    gettimeofday(&res, NULL);
    return res.tv_sec * 1000 + res.tv_usec / 1000;
  }
};
int cnt_N;
Timer timer;
bool timeout;
void dfs(int pos){
  visited[pos] = true;
  if (timeout)return ;
  if (timer.get_mill_duration() >= 150){
    timeout = true;
    return ;
  }
  for (const auto &lang : edges[pos]){
    if (timeout)return ;
    for (const auto &next : learn_person[lang]){

      if (visited[next])continue;
      dfs(next);
    }
  }
}


int main(){
  timer.start();
  timeout = false;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  cnt_N = N;
  set<int> learn_lang;
  for (int i = 0; i < N; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int l;
      cin >> l;
      l--;
      learn_person[l].emplace_back(i);
      edges[i].emplace_back(l);
    }
  }
  dfs(0);
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (not visited[i]){
      ok = false;
    }
  }
  if (ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
  
}


Measured memory_bytes: 12160
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 105;
int p[maxn],N,A,B;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    

    cin>>N>>A>>B;
    int lesA = 0,bAB = 0, gb = 0;
    for(int i = 0; i< N; i++){
        cin>>p[i];
        if(p[i]<=A) lesA++;
        if(p[i]>A&&p[i]<=B) bAB++;
        if(p[i]>B) gb++;
    }
    cout<<min(lesA,min(bAB, gb))<<endl;
    
    
    
    
    return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

  int64_t ans = 0;
  for (auto i : irange(1L, n + 1)) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }

    ans += i;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

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

	cout << (a-1)*(b-1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
  int A,B ;
  cin>>A>>B ;
  if (A>=13){
    cout<<B<<endl;
   
  }
  else if (A>=6 && A<=12){
    cout<<B/2<<endl;
  }
  else if(A<=5) {
    cout<<0<<endl;
   
  }
    return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


void solve(ll N, vector<string> S) {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool f = true;
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                if (S[j][k] != S[k][j]) f = false;
            }
        }
        if (f) ans += N;
        for (int j = 0; j < N; j++)
            rotate(S[j].begin(), S[j].begin() + 1, S[j].end());
    }
    cout << ans << endl;
}


void main_(istream &cin) {
    ll N;
    cin >> N;
    vector<string> S(N - 1 + 1);
    for (int i = 0; i <= N - 1; i++) {
        cin >> S[i];
    }
    solve(N, S);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





Measured memory_bytes: 640
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
	auto _n = readln;
	string[] n, d = [];
	foreach (string l; lines(stdin)) n ~= l.chomp;
	foreach (_s; ["S", "H", "C", "D"])
		foreach (_i; 1..14) {
			auto t = "%s %d".format(_s, _i);
			if (!n.canFind(t)) t.writeln;
		}
}

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

int main(void) {
    int N;cin>>N;
    int ma1 = 0;
    bool flg = false;
    int cur = 0;
    for (int i = 0; i < N; i++) {
        int A;cin>>A;
        if (!flg) {
            if (A == 1) {
                flg = true;
                cur++;
            }
        } else {
            if (A == 1) {
                cur++;
            } else {
                flg = false;
                if (ma1 < cur) ma1 = cur;
                cur = 0;
            }
        }   
    }
    if (ma1 < cur) ma1 = cur;
    cout << ma1 + 1 << endl;
    return 0;
}


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

int main() {
   long long N;
   cin >> N;
   long long  m=0;
  for(long long i=1;i*i<=N;i++){
    if(N%i==0)m=i;
  }  
  long long  r=N/m;
  int res=0;
  while (r>0){
    r/=10;
    res++;
  }  
   cout <<res <<endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

        double w = stdIn.nextInt();
        double h = stdIn.nextInt();
        double x = stdIn.nextInt();
        double y = stdIn.nextInt();

        double ans = w * h / 2;
        System.out.println(ans);
        if (x == w / 2 && y == h / 2)
            System.out.println('1');
        else
            System.out.println('0');
    }
}


Measured memory_bytes: 21844