akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        // 文字列の入力
        String s = sc.next();
        String[] comp = s.split("");

        // バス運行判定
        if (comp[0].equals(comp[1]) && comp[1].equals(comp[2])) {

            // バスの運航無(No出力)
		    System.out.println("No");
        } else {

            // バスの運航無(Yes出力)
		    System.out.println("Yes");
        }
	}
}

Measured memory_bytes: 21588
#include <iostream>

using namespace std;

int factorial(int X) {
  int ans = 0;
  for (int x=1; x<=X; ++x)
    ans += x;
  return ans;
}

int main()
{
  int a, b;

  cin >> a >> b;

  cout << factorial((b-a)) - b << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstdio>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll f[MN+5];
int n,a[MN+5],head[MN+5],cnt=0,d[MN+5];
struct edge{int to,next;}e[MN*2+5];
void No(){puts("NO");exit(0);} 
inline void ins(int f,int t)
{
	e[++cnt]=(edge){t,head[f]};head[f]=cnt;++d[f];
	e[++cnt]=(edge){f,head[t]};head[t]=cnt;++d[t];
}
ll dfs(int x,int fa)
{
	if(d[x]==1) return a[x];
	ll tot=0,mx=0;
	for(int i=head[x];i;i=e[i].next)
		if(e[i].to!=fa)
		{
			f[e[i].to]=dfs(e[i].to,x);
			tot+=f[e[i].to];
			mx=max(mx,f[e[i].to]);
		}
	ll maxmatch=mx<=tot/2?tot/2:tot-mx;
	if(tot<a[x]||tot-maxmatch>a[x]) No();
	return tot-2*(tot-a[x]);
}
int main()
{
	n=read();
	for(int i=1;i<=n;++i) a[i]=read();
	if(n==2) return 0*puts(a[1]==a[2]?"YES":"NO");
	for(int i=1;i<n;++i) ins(read(),read());
	int rt=1;
	for(;d[rt]==1;++rt);
	if(dfs(rt,0)) puts("NO"); else puts("YES");
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes\n";
    else
        cout << "No\n";
}

Measured memory_bytes: 256
#入力
n, u, v = map(int, input().split())
mapdata = [list(map(int,input().split())) for _ in range(n-1)]

#グラフ作成
graph = [[] for _ in range(n+1)]
for i, j in mapdata:
  graph[i].append(j)
  graph[j].append(i)

#探索
def dfs(v):
  dist = [-1] * (n + 1)
  stack = [v]
  dist[v] = 0
  while stack:
    v = stack.pop()
    dw = dist[v] + 1
    for w in graph[v]:
      if dist[w] >= 0:
        continue
      dist[w] = dw
      stack.append(w)
  return dist

du, dv = dfs(u), dfs(v)
ans = 0

for u, v in zip(du[1:], dv[1:]):
  if u < v:
    x = v-1
    if ans < x:
      ans = x

print(ans)

Measured memory_bytes: 43488
import itertools
import numpy as np
N,M,X = map(int, input().split())
CA = np.zeros((N,M+1))
for i in range(N):
    CA[i] = np.array(list(map(int, input().split())))

nums = [0,1]
bools = np.array(list(itertools.product(nums, repeat=N)))
ans = 10000000
for i in range(len(bools)):
    sumCA = sum(bools[i].reshape((N,1))*CA)
    flag = 1
    for j in range(1,M+1):
        if sumCA[j] < X:
            flag = 0
    if flag and sumCA[0] < ans:
        ans = sumCA[0]
        
if ans == 10000000:
    print(-1)
else:
    print(int(ans))

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

int main() {
  int N;
  cin >> N;
  int j =0;

  // ここにプログラムを追記
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if (s=="Y"){
      j++;
      break;
    }
  }
  if (j == 0){
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }
}


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


#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define lmax1 9223372036854775807
#define max1 2147483647
#define lmin1 -9223372036854775808
#define pi 3.141592653589793116
#define mod 1e9+7

long long res(long long a)
{
    long long w[]={a,1,a+1,0};
    return w[a%4];
}

int main() {
    off;
   
    long long a,b;
    cin>>a>>b;
    if(a-1>0)
     cout<<(res(b)^res(a-1))<<"\n";
    else
      cout<<res(b)<<'\n';
      return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

int main(){
	map<char, bool[13]> trump;
	int n;

	cin >> n;
	for(int i = 0; i < n; i++){
		char d;
		int r;

		cin >> d >> r;
		trump[d][r-1] = true;
	}

	for(auto d : {'S', 'H', 'C', 'D'})
		for(int i = 0; i < sizeof(trump[d]); i++)
			if(!trump[d][i])
				cout << d << " " << i+1 << endl;
}



Measured memory_bytes: 3116
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n, m, x;
	cin >> n >> m >> x;
	int ans = 1 << 30;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	for (int t = 1; t < (1 << n); ++t) {
		int cost = 0;
		vector<int> u(m);
		for (int i = 0; i < n; ++i) {
			if (t & (1 << i)) {
				cost += c[i];
				for (int j = 0; j < m; ++j) {
					u[j] += a[i][j];
				}
			}
		}
		bool ok = true;
		for (int j = 0; j < m; ++j) {
			if (u[j] < x) {
				ok = false;
				break;
			}
		}
		if (ok) {
			ans = min(ans, cost);
		}
	}
	cout << (ans < (1 << 30) ? ans : -1) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(){
  int N,a[100];
  cin>>N;
  for(int i=0;i<N;i++)
  cin>>a[i];
  int ans=0;
  for(int i=0;i+1<N;i++){
    if(a[i]==a[i+1]){
      ans++;
      i++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
/*
Wai u read my code xD
*/
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    int n, m; cin >> n >> m;
    nout((n*(n-1) + m*(m-1))/2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N; cin >> N;
  bool ans = false;
  int counter = 0;
  for (int i = 0; i < N; i++) {
    int D1, D2; cin >> D1 >> D2;
    if (D1 == D2) counter++;
    else counter = 0;

    if (counter == 3) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using VVI = vector<vector<int>>;
using VI  = vector<int>;
const static string el = "\n";

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

  VI p = VI(n);
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    p[i] = tmp;
  }
  
  sort(p.begin(), p.end());
  
  int result = 0;

  for (int i = 0;i < k;i++) 
  {
    result += p[i];
  }
  cout << result << el;
  return 0;
}

Measured memory_bytes: 3600
def solve(string):
    n, *h = map(int, string.split())
    count = 0
    current = 0
    for _h in h:
        count += max(0, _h - current)
        current = _h
    return str(count)


if __name__ == '__main__':
    print(solve("\n".join([input(), input()])))


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

using namespace std;

void Main() {
    int N;
    cin >> N;

    vector<int> rep;
    if (N == 0) {
        cout << 0 << endl;
        return;
    }
    while (N != 0) {
        int residual = N % (-2);
        if (residual == 0) {
            rep.push_back(0);
        }
        else {
            rep.push_back(1);
            N -= 1;
        }
        N /= (-2);
    }
    reverse(rep.begin(), rep.end());
    for (int i = 0; i < rep.size(); ++i) {
        cout << rep[i];
    }
    cout << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

#define int long long

using namespace std;

signed main()
{
    int x=0,y=0,z=0;
    std::vector<int> Size(2);
    cin>>Size[0]>>Size[1];
    rep(z,2){

    if(Size[0]>Size[1]){
            x+=Size[0];

            Size[0]--;
    }
    else{
            x+=Size[1];
            Size[1]--;
    }
    }
     cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 764
#!/usr/bin/env python3
import sys


def solve(S: str):
    if(S=='Sunny'):
        print('Cloudy')
    elif(S=='Cloudy'):
        print('Rainy')
    else:
        print('Sunny')
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}
  int find(int x) {
    if (d[x] < 0) {
      return x;
    }
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      return false;
    }
    if (d[y] < d[x]) {
      swap(x, y);
    }
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return -d[find(x)]; }
};

using namespace std;
using ll = long long;

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    uf.unite(a, b);
  }
  int ans = 0;
  rep(i, n) { ans = max(ans, uf.size(i)); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3988
N, L = map(int, input().split())
S = {int(x) for x in input().split()}
flag = False
while flag == False:
    if N%10 in S:
        N += 1
        continue
    if int((N%100-N%10)/10) in S and N >= 10:
        N += 1
        continue
    if int((N%1000-N%100)/100) in S and N >= 100:
        N += 1
        continue
    if int((N%10000-N%1000)/1000) in S and N >= 1000:
        N += 1
        continue
    if int((N%100000-N%10000)/10000) in S and N >= 10000:
        N += 1
        continue
    flag = True
print(N)


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

int main()
{
  int N;
  cin >> N;
  string S;
  bool tf = false;
  for (int i = 0; i < N; i++)
  {
    cin >> S;
    if (S == "Y")
    {
      tf = true;
    }
  }
  if (tf)
  {
    cout << "Four" << endl;
  }
  else
  {
    cout << "Three" << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

int main()
{
	int n;
	while (cin >> n, n) {
		ll num = n, sum = 0;
		ll ans;
		vector<int> p(n), j(n);
		rep(i, n) { cin >> p[i];  sum += p[i]; }
		rep(i, n - 1)cin >> j[i];

		sort(j.begin(),j.end(),greater<int>());
		ans = n * sum;

		rep(i, n-1) {
			sum += j[i];
			num--;
			ans = max(ans,num*sum);
		}
		cout << ans << endl;
	}
	return	0;
}

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

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main(){
	char b;
	cin >> b;
	if('A' == b){
		cout << 'T' << endl;
	}else if('T' == b){
		cout << 'A' << endl;
	}else if('C' == b){
		cout << 'G' << endl;
	}else if('G' == b){
		cout << 'C' << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
#define MOD 1000000007
#define INF 1000000
#define MAX_N 100010



int main()
{
  int N;cin>>N;
  vector<int> h(N+2,0);
  for (int i=1;i<=N;i++)
    cin>>h[i];
  
  h[0]=pow(10,5);
  //dp[i]=i番目にいるときのコストの最小値
  vector<int> dp(N+1,0);
  dp[1]=0;
  for (int i=2;i<=N;i++)
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  
  cout<<dp[N]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    if(X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,(e))
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define irpz(i,s) irp(i,(s),-1)
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;}
string S, T;

string solve(){
	string ans="UNRESTORABLE";
	int sn = S.size();
	int tn = T.size();
	for(int i=sn-tn; i>=0; --i){
		bool exist = true;
		for(int j=0; j<tn; ++j){
			// cout<<T[j]<<" "<<S[i+j]<<"\n";///
			if(S[i+j] != '?' && S[i+j] != T[j]){
				exist  = false;
				break;
			}
		}
		if(exist){
			ans="";
			for(int j=0; j<i; ++j){
				if(S[j] == '?') ans+='a';
				else ans+=S[j];
			}
			ans += T;
			for(int j=i+tn; j<sn; ++j){
				if(S[j] == '?') ans+='a';
				else ans+=S[j];
			}
			return ans;
		}
	}
	return ans;
}

int main(){
	cin>>S>>T;
	cout<< solve() <<endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

int x[MAXN];

ll swap(ll a, ll b) {
    ll tmp;
    tmp = a;
    a = b;
    b = tmp;
}
ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);
    if (b==0) return a;
    return gcd(b, a%b);
}

int main() {
    int N, X;
    cin >> N >> X;
    rep(i, N) {
        cin >> x[i];
    }
    x[N] = X;

    sort(x, x+N+1);


    ll ans = x[1] - x[0];
    for(int i=2; i<N+1; ++i) {
        ans = gcd(ans, x[i]-x[i-1]);
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	string s; cin >> s;
	int n=s.length();
	int ans = 0;
	int ri = 0;
	for(int i=0; i<n; i++){
		while(s[ri]=='A'||s[ri]=='C'||s[ri]=='G'||s[ri]=='T'){
			ri++;
			if(ri==n)break;
		}
		ans = max(ans, ri-i);
		i = ri; ri++;
	}
	cout << ans << endl;
}	


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
    ll n,ans=0; cin>>n;
    vector<ll> a(n+1,0);
    rep(i,n+1) cin>>a[i];
    rep(i,n){
        ll b; cin>>b;
        if(a[i]<b){
            ans+=a[i];
            b-=a[i];
            a[i]=0;
            if(a[i+1]<b){
                ans+=a[i+1];
                a[i+1]=0;
            }
            else{
                ans+=b;
                a[i+1]-=b;
            }
        }
        else{
            ans+=b;
            a[i]-=b;
        }
    }
    cout<<ans<<endl;
}

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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

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

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 3E5 + 10;

int n;
char s[N];

int main(){
	scanf("%d%s", &n, s);
	int sum = count(s + 1, s + n, 'E');
	int ans = sum;
	for (int i = 1; i < n; ++i){
		sum += s[i - 1] == 'W';
		sum -= s[i] == 'E';
		mini(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;

  Int M;
  cin>>M;

  vector<Int> A(M);
  vector<Int> key(M);
  for(Int i=0;i<M;i++){
    Int a, b;
    cin>>a>>b;
    A[i] = a;
    for(Int j=0;j<b;j++){
      Int c;
      cin>>c; c--;
      key[i] |= (1LL<<c);
    }
  }

  vector<vector<Int> > dp(1010, vector<Int>(1<<12, INF));
  dp[0][0] = 0;
  for(Int i=0;i<M;i++)
    for(Int j=0;j<(1<<N);j++){
      Min(dp[i+1][j], dp[i][j]);
      Min(dp[i+1][j | (key[i])], dp[i][j] + A[i]);
    }

  Int ans = dp[M][(1LL<<N)-1];
  if(ans == INF) ans = -1;
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 32768
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll di[2222][2222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,x,y;cin>>n>>x>>y;
  vi ans(2222);x--;y--;
  for(int i=0;i<2222;i++)
    for(int j=0;j<2222;j++)
      di[i][j] = llINF;

  for(int i=0;i<n-1;i++){
    queue<pair<ll,ll>>que;
    que.push(mp(i,1));
    di[i][i] = 0;
    //  cout<<i<<endl;
    while(!que.empty()){
      ll now = que.front().F;
      ll co = que.front().S; 
      que.pop();
      if(now == x){
	if(di[i][y] > co){
	  di[i][y] = min(di[i][y],co);
	  que.push(mp(y,co+1));
	}
      }
      if(now == y){
	if(di[i][x] > co){
	  di[i][x] = min(di[i][x],co);
	  que.push(mp(x,co+1));
	}
      }
      
      if(now+1 < n && di[i][now+1] > co){
	di[i][now+1] = min(di[i][now+1],co);
	que.push(mp(now+1,co+1));
      }
           
      if(now-1 >= 0 && di[i][now-1] > co){
	di[i][now-1] = min(di[i][now-1],co);
	que.push(mp(now-1,co+1));
      }
    }
  }
  /* for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      cout<<di[i][j]<<" ";
    cout<<endl;
    }*/
  for(int i=0;i<2222;i++)
    for(int j=i+1;j<2222;j++)
      if(di[i][j]!=llINF)
	ans[di[i][j]]++;
  for(int i=1;i<=n-1;i++)
    cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 38912
#include <bits/stdc++.h>
using namespace std;
inline void chmax (int& a, int b) {
  if (a < b) a = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    b[--tmp] = i;
  }
  int tmp = 1;
  int maxv = 0;
  for (int i = 1; i < n; i++) {
    if (b[i - 1] < b[i]) {
      tmp++;
    } else {
      chmax(maxv, tmp);
      tmp = 1;
    }
  }
  chmax(maxv, tmp);
  int ret = n - maxv;
  cout << ret << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
	char a;
	cin >> a;
	if (isupper(a)) {
		cout << "A" << endl;
	}
	else {
		cout << "a" << endl;
	}

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define lint long long
//#define P pair<int, int>

lint MOD = 1e9 + 7;


int main()
{
    int N, M;
    cin >> N >> M;
    
    vector<lint> a(M);
    for(int i = 0; i < M; ++i){
        cin >> a[i];
    }
    
    if(M == 0) a.push_back(1e8);
    
    lint sum[N + 1];
    
    int pos = 0;
    
    sum[0] = 1;
    
    if(a[0] == 1){
        sum[1] = 0;
        pos++;
    } else {
        sum[1] = 1;
    }
    
    for(int i = 2; i <= N; ++i){
        if(a[pos] == i){
            sum[i] = 0;
            if(pos < M - 1) pos++;
        } else {
            sum[i] = (sum[i - 1] + sum[i - 2]) % MOD;
        }
    }
    

    cout << sum[N] << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
    double x; cin >> x;
    long long int c = 100;
    int ans(0);
    do{
        c = (long long int)(c*1.01);
        ++ans;
    }while(c < x);
    cout << ans << endl;
    return 0;    
}


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

int main(){
    int r,g,b; cin>>r>>g>>b;
    if((g*10+b)%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
c=[list(map(int,input().split())) for i in range(3)]
d1=[]
d2=[]
for i in range(3):
  d1.append(c[1][i]-c[0][i])
  d2.append(c[2][i]-c[0][i])
print('Yes' if (d1[0]==d1[1]==d1[2] and d2[0]==d2[1]==d2[2]) else 'No')

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

using namespace std;

const int N = 2000000;
const int MOD = 1000000007;
typedef long long ll;



ll fact[N+1],inv[N+1];



ll adl(ll a , ll b){
	return (a+b)%MOD;
}
ll mul(ll a, ll b){
	return (a*b)%MOD;
}
ll nCk(ll n , ll k){
	if(k > n)return 0;
	return mul(fact[n],mul(inv[k],inv[n-k]));
}
ll fast(ll a , ll b){
	if(!b)return 1ll;
	ll res = fast(a,b/2);
	res = mul(res,res);
	if(b&1)return mul(res,a);
	return res;
}
int k , n;
string s;
int main(){
	fact[0] = 1;
	inv[0] = fast(fact[0],MOD-2);
	for(int i = 1 ; i <= N;++i){
		fact[i] = mul(i,fact[i-1]);
		inv[i] = fast(fact[i],MOD-2);
	}
	cin >> k;
	cin >> s;
	n = s.size();
	ll answer = 0;
	for(int suf = 0 ; suf <= k;++suf){
		int rem = k-suf;
		ll numberOfWays = nCk(s.size()-1+rem,s.size()-1);
		answer = adl(answer,mul(fast(26,suf),mul(fast(25,rem),numberOfWays)));
	}
	// s1 + s2 + s3 +s4 + s5 .... + s[s.size()] = k-suf 
	// s[something] could be zero
	cout << answer << endl;

}

Measured memory_bytes: 36532
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

int main(){
    int N;
    cin >> N;
    int P[N];
    rep(i, N){
        cin >> P[i];
    }

    vector<int> dp(N+1, 0);
    int ans = 0;
    rep(i, N){
        int p = P[i];
        dp[p] = dp[p-1] + 1;
        chmax(ans, dp[p]);
    }

    cout << N - ans << endl;
}


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

int n=1,p,q;
int main(){
	cin>>p>>q;
	for(int i=1;i<=p;i++){
		if((n*2)-n<q){
			n=n*2;
		}else if(n>=q){
			n=n+q;
		}
	}
	cout<<n;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;


int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	int n;
	cin >> n;

	int flag = 0;
	for(int i = 1; i <=9; i++){
		for(int j = 1; j<=9; j++){
			if (i*j == n)
				flag = 1;
		}
	}
	if (flag == 1)
		cout << "Yes\n";
	else
		cout << "No\n";

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(20);
    ll n,k; cin >> n >> k;
    vc<ll> list(1e5+7);
    rep(i,n){
        int x,y; cin >> x >> y;
        list[x] += y;
    }
    ll cnt = 0;
    rng(i,1,1e5+1){
        cnt += list[i];
        if(cnt >= k){
            cout << i << endl;
            return 0;
        }
    }
}

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

int main() {
  int N,M,i,j,cou,max=0;
  cin >> N;
  vector<string> a(N);
  for(i=0;i<N;i++){
    cin >> a[i];
  }
  cin >> M;
  vector<string> b(M);
  for(i=0;i<M;i++){
    cin >> b[i];
  }
  for(i=0;i<M;i++){
    for(j=0;j<N;j++){
      if(b[i]==a[j]){
        a[j]="";
        break;
      }
    }
  }
  for(i=0;i<N;i++){
    if(a[i]=="")cou=0;
    else{cou=1;
         for(j=i+1;j<N;j++){
           if(a[i]==a[j]){
             cou++;
             a[j]="";
           }
         }
        }
    if(max<cou)max=cou;
  }
  cout << max << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
using namespace std;

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



    ll n,i,j,k,t;


    cin>>n;

    ll ma=0,mi=1001;
    fo(i,n)
    {
        cin>>j;
        ma=max(ma,j);
        mi=min(mi,j);
    }

    cout<<ma-mi;
    return 0;
}


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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

struct Node {
	Node* parent = nullptr;
	LL size = 1;
};

Node nodes[100001];

Node* UpdateRoot(LL a, Node* root) {
	Node* node = &nodes[a];
	while (node->parent) {
		Node* parent = node->parent;
		node->parent = root;
		node = parent;
	}
	return node;
}

Node* Root(LL a) {
	Node* node = &nodes[a];
	while (node->parent) {
		node = node->parent;
	}
	return node;
}

void Join(LL a, LL b) {
	Node* rootA = Root(a);
	Node* rootB = Root(b);
	rootA->size += rootB->size;
	rootB->parent = rootA;
	rootB->size = -99999;

	UpdateRoot(b, rootA);
}

bool IsSame(LL a, LL b) {
	return Root(a) == Root(b);
}

LL Size(LL a) {
	return Root(a)->size;
}


int main()
{
	LL N, M;
	cin >> N >> M;
	vector<pair<int, int>> order(M);
	REP(i, M) {
		LL a, b;
		cin >> a >> b;

		order[i].first = a;
		order[i].second = b;
	}

	LL value = (N * (N - 1)) / 2;

	vector<LL> results;
	results.reserve(M + 1);

	results.push_back(value);

	for (auto it = order.rbegin(); it != order.rend(); ++it) {
		LL a = it->first;
		LL b = it->second;

		if (IsSame(a, b)) {
			nodes->parent;
		}
		else {
			value -= Size(a) * Size(b);
			Join(a, b);
		}

		results.push_back(value);
	}

	REP(i, M) {
		cout << results[M - i - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(void){
  	
  string s, t;
  cin>>s>>t;
  
  int flag=0;
  for(int i=0;i<s.size();i++){
  	if(s[i]!=t[i]){
    	flag=1;
        break;
    }
  }
  
  if(flag==0){
  	cout<<"Yes"<<endl;
  }else{
  	cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3592
#include<stdio.h>

int main()
{
	int i=1,j=1;
	while(i<=9)
	{
		j=1;
		while(j<=9)
		{
			printf("%dx%d=%d\n",i,j,i*j);
			j++;
		}
		i++;
	}
	return 0;
}

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

typedef long long LL;

const int N=200;

int mod;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m;

void into(){
  scanf("%d%d%d",&n,&m,&mod);
}

int inv[N+9],fac[N+9],ifac[N+9];

void Get_inv(){
  inv[1]=1;
  fac[0]=fac[1]=1;
  ifac[0]=ifac[1]=1;
  for (int i=2;i<=n;++i){
	inv[i]=mul(mod-mod/i,inv[mod%i]);
	fac[i]=mul(fac[i-1],i);
	ifac[i]=mul(ifac[i-1],inv[i]);
  }
}

int dp[N+9][N+9];

int Get_dp(int a,int b,int m){
  for (int i=1;i<=a;++i){
	int sum=0;
	for (int j=b;j>=0;--j){
	  sum=i>1?add(sum,dp[i-1][j]):1;
	  dp[i][j]=i-1+j<=m&&a-i+b-j<=m?sum:0;
	}
	dp[1][0]=0;
  }
  return dp[a][0];
}

int Get_ans(int n,int m){
  if (n==1) return 1;
  int res=0;
  for (int i=2;i<n;++i) sadd(res,Get_dp(i,n-i,m));
  return mul(res,fac[n-1]);
}

int ans;

void Get_ans(){
  for (int i=0;i<=m;++i) sadd(ans,mul(mul(fac[n],ifac[n-i]),Get_ans(n-i,m-i)));
}

void work(){
  Get_inv();
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N, A, B;
   cin >> N >> A >> B;
   
   if ( N * A < B) {
       cout << N * A << endl;
   }
   
   else if ( N * A >= B) {
       cout << B << endl;
   }
}


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


using namespace std;


using ll = long long;


template<long long M>
class modint {
    public:
        long long a;
        modint(const long long x = 0LL) : a((x % M + M) % M) {}
        long long &value() { return a; }
        modint operator+(const modint rhs) const {
            return modint(*this) += rhs;
        }
        modint operator-(const modint rhs) const {
            return modint(*this) -= rhs;
        }
        modint operator*(const modint rhs) const {
            return modint(*this) *= rhs;
        }
        modint operator/(const modint rhs) const {
            return modint(*this) /= rhs;
        }
        modint &operator+=(const modint rhs) {
            a += rhs.a;
            if (a >= M) {
                a -= M;
            }
            return *this;
        }
        modint &operator-=(const modint rhs) {
            if (a < rhs.a) {
                a += M;
            }
            a -= rhs.a;
            return *this;
        }
        modint &operator*=(const modint rhs) {
            a = a * rhs.a % M;
            return *this;
        }
        modint pow(long long n) const {
            modint ret(1);
            modint x = *this;
            while (n) {
                if ((n & 1) == 1) {
                    ret *= x;
                }
                n >>= 1;
                x *= x;
            }
            return ret;
        }
        modint inv() const {
            return pow(M - 2);
        }
        modint &operator/=(const modint rhs) {
            return *this *= rhs.inv();
        }
};


const long long M = 1000000007;


using mint = modint<M>;


mint fact(ll n) {
    mint ret(1);
    for (ll i = 1; i <= n; i++) {
        ret *= mint(i);
    }
    return ret;
}


mint comb(ll n, ll k) {
    return mint(fact(n).a) * mint(fact(k).a).inv() * mint(fact(n - k).a).inv();
}


int main() {
    ll X, Y;
    cin >> X >> Y;

    if ((2 * X - Y) % 3 != 0 || (2 * Y - X) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll n, m;
    m = (2 * X - Y) / 3;
    n = (2 * Y - X) / 3;

    if (m < 0 || n < 0) {
        cout << 0 << endl;
        return 0;
    }

    mint ans = comb(n + m, n);
    cout << ans.a % M << endl;
}


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

int main()
{
  int N, l, r, total;
  cin >> N;
  
  for(int i = 0; i < N; i++)
  {
    cin >> l >> r;
    total += (r - l) + 1;
  }
  
  cout << total << endl;
}

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

int main()
{
    int n,m,s,t;
    cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i,m) {
        int u,v;
        cin >> u >> v;
        g[u-1].push_back(v-1);
    }
    cin >> s >> t;
    --s; --t;

    queue<pair<int,int>> que;    
    vector<vector<bool>> seen(n,vector<bool>(3,false));

    que.push({s,0});
    seen[s][0] = true;

    while(!que.empty()) {
        int cv = que.front().first;
        int cd = que.front().second;
        que.pop();
        if(cv == t && cd%3 == 0) {
            cout << cd/3 << endl;
            return 0;
        }
                
        for(auto nv:g[cv]) {
            if(seen[nv][(cd+1)%3]) continue;
            que.push({nv,cd+1});
            seen[nv][(cd+1)%3] = true;
        }
    }

    cout << -1 << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vint A(N);
  rep(i, N) cin >> A[i];
  vint B = A;
  sort(all(B));
  map<int, int> mp;
  rep(i, N) mp[A[i]] = i%2;
  int ans = 0;
  rep(i, N) {
    if(mp[B[i]] != i%2) ans++;
  }
  cout << ans/2 << endl;

  return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    uint64_t l, r;
    cin >> l >> r;

    if (l + 2019 < r) {
	cout << 0 << endl;
	return 0;
    }

    l = l % 2019;
    r = r % 2019;
    if (l >= r) {
	cout << 0 << endl;
	return 0;
    }
    uint64_t ans = 2019;
    for (uint64_t i = l; i < r; ++i) {
	for (uint64_t j = i + 1; j <= r; ++j) {
	    auto tmp = (i * j) % 2019;
	    if (tmp < ans) {
		ans = tmp;
	    }
	}
    }
    cout << ans << endl;
    return 0;
}
 


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

#define ll long long

#define rep(i, a, b) for (int i = a; i < b; i++)
#define For(i, a, b) for (int i = a; i <= b; i++)

using namespace std;

const int mod = 1000000000 + 7;
const int MAXN = 100000 + 5;

char s[MAXN];
int acOcc[MAXN];

int main() {
    int n, q;
    scanf("%d%d", &n, &q);
    scanf("%s", s);
    for (int i = 1; i < n; i++) {
        acOcc[i] = acOcc[i - 1];
        if (s[i] == 'C' && s[i - 1] == 'A')
            acOcc[i]++;
    }
    while (q-- > 0) {
        int l, r;
        scanf("%d%d", &l, &r);
        printf("%d\n", acOcc[r - 1] - acOcc[l - 1]);
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long W, a, b, tmp, dist; cin >> W >> a >> b;
    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }
    dist = (a+W) - b; 
    if (dist < 0) cout << abs(dist) << endl;
    if (dist >= 0) cout << 0 << endl;
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

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

    vs s(n);
    NREP() {
        cin >> s.at(i);
    }
    sort(ALL(s));

    REP(i, s.size()) {
        cout << s.at(i);
    }

    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
long long n,ans,i,j,k;
long long a[305][305];
bool p[305][305];
int main() {
	cin>>n;
	for(i=1; i<=n; i++) {
		for(j=1; j<=n; j++) {
			cin>>a[i][j];
		}
	}
	for(k=1; k<=n; k++) {
		for(i=1; i<=n; i++) {
			for(j=1; j<=n; j++) {
				if(k!=j&&k!=i&&i!=j) {
					if(a[i][j]==a[i][k]+a[k][j]) {
						p[i][j]=1;
					}
					if(a[i][j]>a[i][k]+a[k][j]) {
						puts("-1");
						return 0;
					}
				}
			}
		}
	}
	for(i=1; i<=n; i++) {
		for(j=1; j<=n; j++) {
			if(p[i][j]==0) {
				ans+=a[i][j];
			}
		}
	}
	printf("%lld\n",ans>>1);
	return 0;
}

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

string s,t,u="";
int n,m,d[3002][3000];

int main(void){
    cin>>s>>t;
    n=s.length();
    m=t.length();
    for(int i=0;i<3002;i++){
        d[0][i]=d[i][0]=0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                d[i][j]=d[i-1][j-1]+1;
            }else{
                d[i][j]=max(d[i][j-1], d[i-1][j]);
            }
            //cout<<d[i][j]<<" ";
        }
        //cout<<endl;
    }
    int x=m,y=n;
    while(x*y>0){
        //cout<<"-- "<<y<<" ,"<<x<<endl;
        if(d[y][x]>d[y][x-1]&&d[y][x]>d[y-1][x]){
            u+=s[y-1];
            x--;
            y--;
        }else if(d[y][x-1]>d[y-1][x]){
            x--;
        }else{
            y--;
        }
    }
    for(int i=u.length()-1;i>=0;i--){
        cout<<u[i];
    }
    cout<<endl;
}


Measured memory_bytes: 35456
n,m =map(int,input().split())
 
H=[]
H=list(map(int,input().split()))
C=[]
for i in range(n):
    C.append(1)
 
for i in range(m):
    a,b = map(int,input().split())
    if H[a-1]==H[b-1] :
        C[a-1] = 0
        C[b-1] = 0
    elif H[a-1]<H[b-1] :
        C[a-1] = 0
    else:
        C[b-1] = 0
 
print( C.count(1))      


Measured memory_bytes: 20112
#include<bits/stdc++.h>
using namespace std;
int main()
{ 
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]==',')
    { 
      s[i]=' ';
    }
  }
  cout<<s<<endl;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string s;
	cin >> s;

	int n = s.size();
	for (int i = 0; i < n; i += 2) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int eo[2] = {};
  int i;
  for (i = 0; i < s.length(); i++) {
    eo[i % 2] += s.at(i) - '0';
  }
  int result;
  if (s.length() % 2 == 0) {
    result = min(eo[0], eo[1]) + s.length() / 2 - max(eo[0], eo[1]);
  } else {
    if (eo[0] < eo[1] + 1) {
      result = eo[0] + (s.length()) / 2 - eo[1];
    } else {
      result = eo[1] + (s.length() + 1) / 2 - eo[0];
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;


struct payment_item {
    int day;
    int payment;
};

bool operator>(const payment_item& pa, const payment_item& pb) {
    return pa.day > pb.day;
}

bool operator<(const payment_item& pa, const payment_item& pb) {
    return pa.day < pb.day;
}

int main() {

    int n,m;
    cin >> n >> m;

    priority_queue<payment_item, vector<payment_item>, greater<payment_item>> dtbl;

    rep(i,n) {
        payment_item p;
        cin >> p.day >> p.payment;
        dtbl.push(p);   // 日付の小さい順にソートされる
    }

    int total = 0;
    priority_queue<int, vector<int>, less<int>> pay_tbl; // 給料の大きい順にソートされる
    rep(i,m + 1) {
        while(!dtbl.empty() && dtbl.top().day <= i) {
            pay_tbl.push(dtbl.top().payment);
            dtbl.pop();
        }
        if (!pay_tbl.empty()) {
            total += pay_tbl.top();
            pay_tbl.pop();
        }
    }

    cout << total << endl;

    return 0;
}


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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()  
#define sz(x) int(x.size()) 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=63;
const int mxn=0;
bool DEBUG=0;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    vi a(n);
    int mx = 0; ll ans=0;
    for(int i=0; i<n; i++){
		cin>>a[i];
		ans += (mx>a[i]?1ll*(mx-a[i]):0);
		mx=max(mx,a[i]);
	}
	cout<<ans<<"\n";
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += min(v[i], abs(K - v[i])) * 2;
  }
  cout << ans << endl;
}


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,n,k;


int main(){
  int ans=0;
  string s;cin>>s;

  int ren=0;
  REP(i,s.length()) {
    if ((s[i]==65+0)|(s[i]==65+2)|(s[i]==65+6)|(s[i]==65+19)){
      ren++;
      ans=max(ren,ans);
    }else{
    	ren=0;
    }
  };

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

Measured memory_bytes: 256