akhauriyash/Code-Regression huggingface dataset:
import std.algorithm;
import std.range;
import std.ascii;
import std.array;
import std.container;
import std.conv;
import std.numeric;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

long modPow(long mod)(long x, long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) return modPow!mod(x * x % mod, n / 2);
    return x * modPow!mod(x % mod, n - 1) % mod;
}

class RollingHash(long[] Ps, long mod) {
    string s;
    int N;
    long[][] H;
    this(in string s) { 
        this.s = s; 
        this.N = s.size;
        this.H = new long[][](Ps.length, N + 1); // H[k]: s[0]*Ps[k]^(n-1) + s[1]*Ps[k]^(n-2) + ... + s[n-1]*Ps[k]^0
        foreach (k, P; Ps) {
            foreach (int i, c; s) {
                H[k][i + 1] = (H[k][i] * P + cast(int)(c - 'a' + 1)) % mod;
            }
        }
    }
    long[] hash(int l, int r) { // [l, r)
        auto hs = iota(0, Ps.length, 1).map!(delegate(k) {
                      return (H[k][r] - H[k][l] * modPow!mod(Ps[k], r - l) % mod + mod) % mod;
                  });
        return hs.array;
    }
}

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    auto s = readln.chomp;
    auto hasher = new RollingHash!([991, 9999991], cast(long)(1e9+7))(s);
    int l = 0, r = 1;
    bool[long[]] appeared;
    foreach (_; 0 .. M) {
        auto q = readln.chomp;
        switch (q) {
            case "L++": l++; break;
            case "L--": l--; break;
            case "R++": r++; break;
            case "R--": r--; break;
            default: assert(false);
        }
        appeared[hasher.hash(l, r).idup] = true;
    }
    writeln(appeared.keys.size);
}

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

int main() {
    int temp = 0, ans = 0;
    string str;
    cin >> str;
    rep(i, str.length()) {
        if(str.at(i) == 'A' || str.at(i) == 'C' || str.at(i) == 'G' || str.at(i) == 'T') {
            temp++;
            ans = max(ans, temp);
        } else {
            temp = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

using namespace std;

const int N = 3e3 + 5;

int S[N][N], fac[N], ifac[N], inv[N];

inline int ksm(int a, int b, const int& mod) {
	int ans = 1; 
	for (; b; b >>= 1, a = 1ll * a * a % mod) 
		if (b & 1) ans = 1ll * ans * a % mod;
	return ans;
}

inline int binom(int n, int m, const int& mod) {
	if (n < m || n < 0 || m < 0) return 0;
	if (n == 0 || m == 0) return 1; 
	return 1ll * fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}

int add(int a, int b, const int& mod) {return a += b, a >= mod ? a - mod : a;}
int sub(int a, int b, const int& mod) {return a -= b, a < 0 ? a + mod : a;}

int main() {
	S[0][0] = 1; int n, mod; scanf("%d%d", &n, &mod);
	inv[0] = ifac[0] = fac[0] = inv[1] = fac[1] = ifac[1] = 1;
	for (int i = 2; i < N; ++i) {
		inv[i] = 1ll * inv[mod % i] * (mod - mod / i) % mod;
		fac[i] = 1ll * fac[i - 1] * i % mod;
		ifac[i] = 1ll * ifac[i - 1] * inv[i] % mod;
	}
	for (int i = 1; i < N; ++i) 
		for (int j = 1; j <= i; ++j) 
			S[i][j] = (1ll * S[i - 1][j] * j % mod + S[i - 1][j - 1]) % mod;
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		 int sum = 0;
		 for (int j = 0; j <= i; ++j) {
		 	int val = ksm(2, 1ll * j * (n - i) % (mod - 1), mod);
		 	val = 1ll * val * S[i + 1][j + 1] % mod;
			sum = (sum + val) % mod;
		}
		if (i & 1) ans = sub(ans, 1ll * sum * ksm(2, ksm(2, n - i, mod - 1), mod) % mod * binom(n, i, mod) % mod, mod); 
		else ans = add(ans, 1ll * sum * ksm(2, ksm(2, n - i, mod - 1), mod) % mod * binom(n, i, mod) % mod, mod);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 29372
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;

bool state[10001][1261];
int pc[10001];

main()
{
  int N, M;
  while( cin >> N >> M, !(N == 0 && M == 0) ) {
    int r, q;

    fill_n(*state, 10001*1261, false);

    cin >> r;
    Rep(i, r) {
      int t, n, m, s;
      cin >> t >> n >> m >> s;
      if( s ) pc[n] = t;
      else {
	for(int j=pc[n]; j<t; j++) {
	  state[m][j] = 1;
	}
      }
    }

    cin >> q;
    Rep(i, q) {
      int ts, te, m;
      cin >> ts >> te >> m;
      
      int sum = 0;
      for(int j=ts; j<te; j++) sum += state[m][j];
      
      cout << sum << endl;
    }
    
  }

}

Measured memory_bytes: 15296
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

int b[22];
int v,l;

int main() 
{ 

   ll ans=0;

    int n;
    scf(n);

    rep(i,1,n+1)
    {
        scf(v);

        rep(k,0,21)
        if(1<<k&v)
        {
          l=max(l,b[k]);
          b[k]=i;
        }

        ans+=(i-l);
    }

    lprin(ans);
  
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define ll long long int
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define pb push_back
using namespace std;

int main() {
	IOS;
	ll n,k,ans;
	cin>>n>>k;
	ll arr[n+1];
	ll dif[n+1];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		if(i==0){
			dif[i]=0;
			ans=dif[i];
		} else if(i==1){
			dif[i]=abs(arr[i]-arr[i-1]);
			ans=dif[i];
		}else{
			ll temp=dif[i-1]+abs(arr[i]-arr[i-1]);
			for(ll j=i-1;j>=max(0,(int)(i-k));j--){
				temp=min(temp,dif[j]+abs(arr[i]-arr[j]));
			}
			dif[i]=temp;
			ans=dif[i];
		}
	}
	cout<<ans;

}


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

class Program
{        
    static bool LinerSearch(int[] s, int key, int n)
    {
        int i = 0;
        s[n] = key;
        while(s[i] != key)
        {
            i++;
        }
        return i != n;
    }

    static void Main(string[] args)
    {
        int count = 0;        

        int n = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int[] s = new int[n + 1];
        for(int i = 0; i < n; i++)
        {
            s[i] = int.Parse(str[i]);
        }

        int q = int.Parse(Console.ReadLine());
        string[] strer = Console.ReadLine().Split(' ');
        int key = 0;
        for(int i = 0; i < q; i++)
        {
            key = int.Parse(strer[i]);
            if(LinerSearch(s, key, n))
            {
                count++;
            }
        }
       
        Console.WriteLine(count);

    }
}


Measured memory_bytes: 18004
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

int main(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans=0;
    for(int i=l;i<=r;++i){
        if(i%d==0)ans++;
    }
    cout<<ans<<endl;





}

Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
l = [0] * (n-1)
for _ in range(n-1):
  a,b = map(int,input().split())
  a,b = a-1,b-1
  l[_] = (min(a,b),max(a,b))
  g[a].append(b)
  g[b].append(a)
m = 0
for _ in range(n):
  if len(g[_]) > m:
    m = len(g[_])
    mi = _
print(m)
g2 = [[] for i in range(n)]
stack = [(mi,-1)]
vi = [0] * n
vi[mi] = 1
d = dict()
while stack:
  pre,prei = stack.pop()
  c = 0
  for i in g[pre]:
    if vi[i] == 1:
      continue
    else:
      vi[i] = 1
      c += 1
      if c == prei:
        c += 1
      d[(min(pre,i),max(pre,i))] = c
      stack.append((i,c))
for i in l:
  print(d[i])


Measured memory_bytes: 86544
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<int,int> mp;
bool flag=1;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(mp[a]!=0)
		{
			cout<<"NO"<<endl;
			flag=0;
			break;
		}
		else mp[a]=i;
	}
	if(flag) cout<<"YES"<<endl;
	return 0;
}

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

int main()
{
  long long a,b,k=0;
  cin >>a>>b>>k;
  
  if(a+b+k==22 || a+b+k>22)
  {
    cout <<"bust"<<endl;
    
  }
  else {cout <<"win"<<endl;}
}

Measured memory_bytes: 256
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n;
	cin>>n;
	
	ll ans=0;
	rep(x,1,n+1){
		ans+=(ll)(x)*(x+1)/2;
	}
	
	ll a,b;
	rep(x,1,n){
		cin>>a>>b;
		if (a>b) swap(a,b);
		
		ans-=a*(n+1-b);
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int stricmp(char* str, char* str1){
	int i;
	if(strlen(str) == strlen(str1)){
		for(i = 0; strlen(str) > i; i++)
			if(tolower(str[i]) != tolower(str1[i])) return -1;
		return 0;
	}
	return -1;
}

int main(void) {
	char cmp[11], str[1001];
	int cou = 0;
	scanf("%s", cmp);
	while(scanf("%s", str)){
		if(strcmp(str, "END_OF_TEXT") == 0) break;
		if(stricmp(str, cmp) == 0) cou++;
	}
	printf("%d\n", cou);
	return 0;
}

Measured memory_bytes: 552
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
// #define int long long
#define P pair<int, int>
typedef long long ll;

vector<bool> seen;

const long long int MOD = 1e9+7;
const int INF = -1;

struct _chunk {
	int connect;
	int dist;
	int color;
};

long long int dfs(int color, vector<vector<int> > &graph, int now, int parent){
	seen[now] = true;
	int num = graph[now].size();
	int use_color = color;

	if (parent == -1) {
		use_color--;
	} else {
		use_color-=2;
	}
	if (color < num) {
		return 0;
	} else {
		ll case_num = 1;
		for(int e : graph[now]) {
			if (seen[e]) continue;
			case_num*=use_color;
			case_num%=MOD;
			use_color--;
		}

		for(int e : graph[now]) {
			if (seen[e]) continue;
			case_num*=dfs(color, graph, e, now);
			case_num%=MOD;
		}

		return case_num%MOD;
	}
}

signed main(void) {
  	int N, K;
  	cin >> N >> K;
  	// 0 is the root

  	vector<vector<int> > graph(N);
  	rep(i, N) {
  		seen.pb(false);
  	}
  	for (int i=0; i<N-1; ++i) {
  		int a, b;
  		cin >> a >> b;
  		a--; b--;

  		graph[a].pb(b);
  		graph[b].pb(a);
  	}

  	cout << K*dfs(K, graph, 0, -1)%MOD << endl;
 
	return 0;
}


Measured memory_bytes: 11648
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] nums = new int[(int) Math.ceil(Math.log(n) / Math.log(2))+1][n+1];
        int[] lengths=new int[nums.length];
        lengths[0]=n;
        for(int i=0;i<n;i++){
            nums[0][i]=sc.nextInt();
        }
        for(int i=1;i<nums.length;i++){
            lengths[i]=lengths[i-1]%2==0?lengths[i-1]/2:lengths[i-1]/2+1;
            for(int j=0;j<lengths[i-1]/2;j++){
                nums[i][j]=Euclid(nums[i-1][j*2],nums[i-1][j*2+1]);
            }
            if(lengths[i-1]%2==1){
                nums[i][lengths[i-1]/2]=nums[i-1][lengths[i-1]-1];
            }
        }
        int output=1;
        int tmp;
        int now;
        for(int i=0;i<n;i++){
            now=i;
            tmp=0;
            for(int j=0;j<nums.length;j++){
                tmp=Euclid(tmp,nums[j][now%2==0?now+1:now-1]);
                now=now/2;
            }
            output=Math.max(tmp,output);
        }
        System.out.println(output);
    }

    private static int Euclid(int n, int m) {
        int tmp;
        if(n==0||m==0){
            return Math.max(n,m);
        }
        while (true) {
            if (n == 0) {
                return m;
            } else if (m == 0) {
                return n;
            }
            tmp = n;
            n = m;
            m = tmp;
            n = n % m;

        }
    }
}

Measured memory_bytes: 69228
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAXN = 100000 + 10;

int N;
vector <int> Adj[MAXN];

int DFS(int cur, int fa)
{
	int SG = 0;

	for(const int & x : Adj[cur])
		if(x != fa)
			SG ^= (1 + DFS(x, cur));

	return SG;
}

int main()
{
	cin >> N ;
	for(int i = 1; i < N; i++)
	{
		int u, v;
		cin >> u >> v ;
		Adj[u].push_back(v);
		Adj[v].push_back(u);
	}

	cout << (DFS(1, 0) == 0 ? "Bob" : "Alice") << endl ;

	return 0;
}



Measured memory_bytes: 10368
r,c=map(int,input().split())
tbl=[list(map(int,input().split()))+[0] for _ in range(r)]+[[0]*(c+1)]
for i in range(r):
    tbl[i][c]=sum(tbl[i])
for j in range(c+1):
    tbl[r][j]=sum(tbl[k][j] for k in range(r))
for i in range(r+1):
    print(*tbl[i])


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

int main(){
	int n;
	stack<int> st;
	while(cin >> n){
		if(n == 0){
			cout << st.top() << endl;
			st.pop();
		} else {
			st.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}



///////////////////////////




int main() {

	string S;
	cin >> S;
	ll ans = 700;
	rep(i, 3) if (S[i] == 'o') { ans += 100; }

	cout << ans;
	
		
	system("PAUSE");

}


Measured memory_bytes: 504
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
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 = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    int t;cin >> t;
    for(int i=0;i<t;i++){
	string s1,s2;cin >> s1 >> s2;
	int m=s1.size(),n = s2.size();
	int dp[m+1][n+1];
	rep(i,m+1)rep(j,n+1) dp[i][j] = 0;
	for(int i=1;i<=m;i++){
	    for(int j=1;j<=n;j++){
		if(s1[i-1]==s2[j-1]) dp[i][j] = dp[i-1][j-1]+1;
		else{
		    dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	    }
	}
	cout << dp[m][n] << endl;
    }
    return 0;
}



Measured memory_bytes: 7132
#include <bits/stdc++.h>
using namespace std;
string words[4] = {"dream", "dreamer", "erase", "eraser"};
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for(int i=0; i<4; ++i) reverse(words[i].begin(), words[i].end()); 
    int pos = 0;
    bool ok = true;
    int n = s.length();
    while(pos<n and ok){
        ok = false;
        for(int i=0; i<4; ++i){
            if(s.substr(pos, words[i].length()) == words[i]) {
                ok = true;
                pos += words[i].length();
                break;
            }
        }
    }
    cout << (ok? "YES": "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
while n = gets
  break if n.to_i.zero?
  s = gets.split.map(&:to_i)
  p = nil

  count = 0
  freqency_appearance = Hash.new(0)
  loop do
    freqency_appearance.clear
    s.each { |num| freqency_appearance[num] += 1 }
    p = s.map { |num| freqency_appearance[num] }

    break if s == p

    count += 1
    s = p
  end

  puts count
  puts p.join(' ')
end

Measured memory_bytes: 8844
n, m, x = map(int, input().split())
bs = [list(map(int, input().split())) for _ in range(n)]

from itertools import combinations

combs = list()
for k in range(1, n+1):
    combs.extend(list(combinations(range(0, n), k)))

mn = -1
for comb in combs:
    money = 0
    us = [0] * m
    for i in list(comb):
        b = bs[i]
        money += b[0]
        for j, u in enumerate(b[1:]):
            us[j] += u

    is_ok = True
    for i in range(m):
        if us[i] < x:
            is_ok = False
            break
    if is_ok:
        if mn < 0 or money < mn:
            mn = money

print(mn)

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

#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define sc(a) scanf("%c",&a)
#define ss(a) scanf("%s",a)
#define pi(a) printf("%d\n",a)
#define pl(a) printf("%lld\n",a)
#define pc(a) putchar(a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i, a, b) for(register int i=a;i<=b;++i)
#define repd(i, a, b) for(register int i=a;i>=b;--i)
#define reps(s) for(register int i=head[s];i;i=Next[i])
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define pii pair<int,int>
#define mii unordered_map<int,int>
#define msi unordered_map<string,int>
#define lowbit(x) ((x)&(-(x)))
#define ce(i, r) i==r?'\n':' '
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;

inline int qr() {
    int f = 0, fu = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')fu = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        f = (f << 3) + (f << 1) + c - 48;
        c = getchar();
    }
    return f * fu;
}

ll a[5];

int main() {
    repi(i, 1, 4)a[i] = qr();
    ll ans = -4e18;
    repi(i, 1, 2)repi(j, 3, 4)ans = max(ans, a[i] * a[j]);
    pl(ans);
    return 0;
}

Measured memory_bytes: 3760
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

ll gcd(ll x, ll y) {
	if (y == 0) {
		return x;
	}
	return gcd(y, x % y);
}

int main() {
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3644
import scala.collection.mutable
import scala.io.StdIn
import scala.util.control.Breaks


object Main extends App {
  val maxN = StdIn.readLine().toInt
  def f(x:Int,y:Int,z:Int):Int=x*x + y*y+z*z + x*y+y*z+z*x

  val b1 = new Breaks
  val b2 = new Breaks
  val b3 = new Breaks

  var resultList = mutable.ArrayBuffer.empty[Int]
  for (n <- 1 to maxN) {

    var count = 0


      b1.breakable{for (x1 <- 1 to n) {
        if (f(x1, 1, 1) > n) b1.break()

          b2.breakable {for (x2 <- 1 to x1) {
            if(f(x1,x2,1) > n) b2.break()

              b3.breakable {for (x3 <- 1 to x2) {
                  val value = f(x1,x2,x3)
                  if(value > n) b3.break()
                  if(value == n){

                    val d =Set[Int](x1,x2,x3).size match{
                        case 1 => 1
                        case 2 => 3
                        case 3 => 6
                      }
                    count += d
                  }
                }
              }
            }
          }
        }
      }
    resultList += count
    }

  resultList.foreach(println)


}








Measured memory_bytes: 59692
N = int(input())

A = list(map(int, input().split()))
cnt = 0

for i in range(N):
    minj = i
    for j in range(i, N):
        if A[j] < A[minj]:
            minj = j
    A[i], A[minj] = A[minj], A[i]
    if A[i] != A[minj]:
        cnt += 1

print(' '.join(map(str,A)))
print(cnt)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s1,s2,f;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin>>h[i];
  if(n==1) {cout<<0;return 0;}
  s1=0;
  s2=abs(h[1]-h[0]);
  if(n==2) {cout<<s2;return 0;}
  for(int i=2;i<n;i++){
    f=min(s2+abs(h[i]-h[i-1]),s1+abs(h[i]-h[i-2]));
    s1=s2;
    s2=f;
  }
  cout<<f;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[1000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0;
  string s;
  cin>>a>>b>>c;
  for(int n=0;n<a;n++) cin >>i[n];
  for(int n=1;n<a;n++){
    d+=min((i[n]-i[n-1])*b,c);
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 2304
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, a[20],m[20],ans= 0;
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		if (i == 0) {
			m[i] = a[i];
		}
		else {
			m[i] = max(m[i - 1], a[i]);
		}
	}
	rep(i, n) {
		if (a[i] >= m[i]) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll lcm(ll x, ll y) {
    return x / GCD(x, y) * y;//先に割り算をして掛けられる数を小さくして掛け算を行う
}
int main() {
    string S;
    cin >> S;
    bool hantei = false;
    int n = 0;
    for (int i = S.size() - 1; i >= 0; i--)
    {
        if(i % 2 != 0) { S.erase(i); continue; }
        S.erase(i);
        if (S.substr(0, S.size() / 2) == S.substr(S.size() / 2, S.size() / 2))
        {
            n = S.size();
            break;
        }
            
        
    }
    

    cout << n << endl;
    
    return 0;

}

Measured memory_bytes: 3648
# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_c

# 横で切り分けてから、いちごが無い行は上の行のをコピる


import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range


def read_ints():
    return list(map(int, read().split()))


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from fractions import gcd

c = 0


def ret_row(s: list):
    ret = [-1] * W
    l = 0
    global c
    for r, ss in enumerate(s):
        if ss == 1:
            c += 1
            for j in rr(l, r + 1):
                ret[j] = c
            l = r + 1
    for j in rr(l, W):
        ret[j] = c
    # assert -1 not in ret  # あとで消す
    return ret


H, W, K = read_ints()
S = read_map_as_int(H)

ans = []
for s in S:
    if 1 not in s:
        ans.append([-1] * W)
    else:
        ans.append(ret_row(s))

if ans[0][0] == -1:
    i = 0
    while ans[i][0] == -1:
        i += 1
    for j in rr(W):
        ans[0][j] = ans[i][j]


for i in rr(1, H):
    if ans[i][0] != -1:
        continue
    for j in rr(W):
        ans[i][j] = ans[i - 1][j]


for a in ans:
    print(*a)



Measured memory_bytes: 73304
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String ans = "No";
		boolean[] list = new boolean[101];
		Arrays.fill(list,false);
		for(int i = 1;i < 10;i++){
			for(int j = 1;j < 10;j++){
				list[i * j] = true;
			}
		}
		if(list[N]){
			ans = "Yes";
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) {
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int siraberu=0;
		boolean isp=false;
		int min,max;
		int counter=1;

		try {
			while(true) {
				str=bfr.readLine();
				siraberu=Integer.parseInt(str);
				while(true) {
					siraberu-=counter;
					isp=isPrime(siraberu);
					if(isp==true) {
						min=siraberu;
						break;
					}
				}

				siraberu=Integer.parseInt(str);
				while(true) {
					siraberu+=counter;
					isp=isPrime(siraberu);
					if(isp==true) {
						max=siraberu;
						break;
					}
				}

				System.out.println(min+" "+max);
			}
		}catch(IOException e) {
		}
		catch(NumberFormatException e) {
			System.exit(0);
		}
	}

	static boolean isPrime(int a) {
		int siraberu=a;
		if(a%2==0 && a!=2) {
			return false;
		}
		else if(a==2) {
			return true;
		}
		int max=((int)Math.sqrt(siraberu))+1;
		for(int i=2; i<max; i++) {
			if(siraberu%i==0) {
				return false;
			}
		}
		return true;
	}
}


Measured memory_bytes: 24320
n = int(raw_input())
data = map(int, raw_input().split())
result = []
for i in range(2):
    sum = 0
    count = 0
    for j in range(n):
        sum += data[j]
        if (i+j) % 2 == 0:
            if sum <= 0:
                count += abs(1-sum)
                sum = 1
        else:
            if sum >= 0:
                count += abs(-1-sum)
                sum = -1
    result.append(count)
print min(result) 

Measured memory_bytes: 11272
//Love and Freedom.
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#define ll long long
#define inf 20021225
#define N 1001000
using namespace std;
int read()
{
	int s=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return f*s;
}
char s[N],t[N]; queue<int> q;
int main()
{
	int n=read(),ans=0;
	scanf("%s",s+1);
	scanf("%s",t+1);
	if(strcmp(s+1,t+1)==0)	return printf("0\n"),0;
	int pt=n,ps=n;
	while(pt)
	{
		while(pt && t[pt]==t[pt-1]) pt--;
		while(ps && (ps>pt||s[ps]!=t[pt]))	ps--;
		if(!ps)	return printf("-1\n"),0;
		while(!q.empty() && q.front()-q.size()>=pt)	q.pop();
		if(ps!=pt)	q.push(ps);
		ans=max(ans,(int)q.size()+1);
		pt--;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

//bool flag = __builtin_add_overflow(a , b , &tmp);
//bool flag = __builtin_mul_overflow(a , b , &tmp);
//bool flag3= __builtin_sub_overflow(a , b , &tmp);

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-12;
const long long inf = 2e12 + 12;
const int MAXN = 250005, MAXM = 102, Mod = 1000000007 , MAXLog = 20;

string s;
int memo[MAXN][15];
int solve(int idx, int rem) {
    if (idx == s.size()) {
        return rem == 5;
    }
    int &ret = memo[idx][rem];
    if (~ret)
        return ret;
    ret = 0;
    if (s[idx] != '?') {
        ret = solve(idx + 1, (rem * 10 + (s[idx] - '0')) % 13);
    } else {
        for (int i = 0; i < 10; ++i) {
            ret += solve(idx + 1, ((rem * 10) + i) % 13);
            ret %= Mod;
        }
    }
    return ret;
}


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

    cin >> s;
    memset(memo, -1, sizeof memo);

    cout << solve(0, 0) << '\n';

    return 0;
}

Measured memory_bytes: 21328
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		Array.Sort(I);
		WriteLine(I[0] == I[1] ? I[2] : I[0]);
	}
}


Measured memory_bytes: 13268
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# import numpy as np


mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    # sys.setrecursionlimit(int(pow(10,6)))
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("../output.txt", "w")
except:
    pass


# @lru_cache(None)




K=L()[0]
if K%2==0 or K%5==0:
    print(-1)
    exit()
i=1
s=7
while(s%K!=0 and i<10**8):
    s=(s*10+7)%K
    i+=1
print(i if i<10**8 else -1)

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<vector<int>> a(n, vector<int>(n - 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  int c = 0;
  vector<int> ids(n);
  set<int> look;
  for (int i = 0; i < n; i++) look.insert(i);
  for (int i = 0; i < n * n; i++) {
    set<int> update;
    for (auto it = look.begin(); it != look.end(); it++) {
      int j = *it;
      if (ids[j] >= n - 1) {
        continue;
      }
      int to = a[j][ids[j]];
      if (ids[to] >= n - 1) {
        continue;
      }
      if (a[to][ids[to]] == j) {
        update.insert(to);
        update.insert(j);
      }
    }
    if (update.empty()) {
      cout << -1 << endl;
      return 0;
    }
    look.clear();
    for (auto &j : update) {
      ids[j]++;
      look.insert(j);
      c++;
    }
    if (c == n * (n - 1)) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4352
using namespace std;

#include <iostream>
#include <vector>
#include <cmath>
#include <string>

typedef long long ll;
vector<int> v;


int main() {
  int N; cin >> N;
  string s; cin >> s;
  
  int tf[N], animal[N], prev[N], post[N];
  int f_animal[4] = {1, 1, -1, -1}, s_animal[4] = {1, -1, 1, -1};
  
  for (int i = 0; i < N; i++) {
    if (s[i] == 'o') tf[i] = 1;
    else tf[i] = -1;
    
    if (i == 0) prev[i] = N - 1;
    else prev[i] = i - 1;
    
    if (i == N - 1) post[i] = 0;
    else post[i] = i + 1;
  }
  
  for (int i = 0; i < 4; i++) {
    animal[0] = f_animal[i];
    animal[1] = s_animal[i];
    
    for (int j = 1; j < N; j++) {
      if (j == N - 1) {
        if (tf[N-1]*animal[N-2]*animal[N-1] == animal[0]) {
          if (tf[0]*animal[N-1]*animal[0] == animal[1]){
            for (int k = 0; k < N; k++) {
              if (animal[k] == 1) cout << 'S';
              else cout << 'W';
            }
            cout << endl;
            return 0;
          }
        }
      }
      animal[post[j]] = tf[j] * animal[prev[j]] * animal[j];
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 2112
#include <stdio.h>

int main(void) {                                                                
    int d, area, x;                                                             
                                                                                
    while (scanf("%d", &d) != EOF) {                                            
        area = 0;                                                               
        x=d;                                                                    
        while (x < 600) {                                                       
            area += (d*x*x);                                                    
            x += d;                                                             
        }                                                                       
        printf("%d\n", area);                                                   
    }                                                                           
    return 0;                                                                   
}

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

int main(){
	int x; cin >> x;
	int ans=1;
	if(x<=3) {
		cout << ans << endl;
		return 0;
	}
	for(int i=2;;i++){
		int j=i*i;
		while(j<=x){
			ans=max(ans,j);
			j*=i;
		}
		if(j==i*i) break;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    int A,B;
    cin >> A >> B;
    cout << (3 * A + B)/ 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        var sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int sum = 0;

        for (int i = 0; i < m; i++) {
            sum += sc.nextInt();
        }
        System.out.println(n-sum >= 0 ? n-sum : -1);
    }
}


Measured memory_bytes: 46344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	int gcd = a[0]; reps(i, 1, n) gcd = __gcd(gcd, a[i]);
	printf("%d\n", gcd);
	return 0;
}


Measured memory_bytes: 640
n=int(input())
l=input()
m=l.split(" ")
lst=[]
for i in m:
    lst.append(int(i))
lst.sort(reverse=True)
a=0
b=0
c=0
d=0
for x in lst:
    if d==x and c==0:
        a=x
        c+=1
        d=0
    elif d==x and c==1:
        b=x
        c+=1
        d=0
    else:
        d=x
    if c==2:
        break
print(a*b)

Measured memory_bytes: 15576
#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++)
using ll = long long;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using P = pair<ll, ll>;

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
    int n,k,x,y; cin >> n >> k >> x >> y;
    if(k >= n) cout << n*x << endl;
    else cout << k*x+(n-k)*y << endl;
    return 0;
}

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

int main(){
  int n, w, i,money=0, r=0, l, flag;
  cin>>n;
  vector<int> a(n);

  for(int i=0; i<n; i++){
    cin >> a[i];
  }
 l = n-1;
    for(;;){
      if(w>0){
        w -= a[l];
        l--;

        if(l<r){
          flag = 0;
          break;
        }
      }else{
        w += a[r];
        r++;

        if(l<r){
          flag = 1;
          break;

        }
      }
    }

    if(flag==0) l--;
    else r--;

      i=0;
      for(;;){
        if(w==0){
          break;
        }else if(w>0){
          if(a[i]>2&&i<r){
            w--;
            money++;
          }else
          {
            w--;
            money++;
          }
        }else{
          if(a[n-i]>2&&r>i){
            w++;
            money++;
          }else
          {
            w++;
            money++;
          }
        }

        i++;
      }



    cout << money << endl;



}


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

int main() {
    string a, b, c;
    cin >> a >> b;
    c = a + b;
    int d;
    d = stoi(c);
    int ans = 1;

    while (d > (ans * ans)) {
        ans++;
    }

    cout << (((ans * ans) == d) ? "Yes" : "No") << endl;
}

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

using namespace std;

const int N=1e6+3;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans,sz[N];

char s[N];

pair<int,int> p[N];

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	printf("%lld\n",(ll)a*b/__gcd(a,b));
}


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

using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ s >> p.first >> p.second; return s;}

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

    int ans = (1000 - (N%1000)) % 1000;

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <string>
 
using namespace std;
int main()
{
    int i,n,ans[100000]={0},cnt[2]={0,0},t;
    string s;
    cin >> s;
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='L'){
            t=i;
            while(s[i]=='L'){
                cnt[i%2]++;
                i++;
            }
            ans[t-1]+=cnt[(t-1)%2];
            ans[t]+=cnt[t%2];
            cnt[0]=0;
            cnt[1]=0;
        }
        cnt[i%2]++;
    }
  	n=i-1;
    for(i=0;i<n;i++) cout << ans[i] << ' ';
    return 0;
}

Measured memory_bytes: 4124
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include<set>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
const int mod=1e9+7;
typedef long long ll;
int main()
{
	ll l,r;
	cin>>l>>r;
	ll i,j;
	ll min=100000;
	if(r-l>2019)
		min=0;
	else if(r-l<=2019)
		for(i=l;i<r;i++)
			for(j=i+1;j<=r;j++)
			{
			if(min>(i*j)%2019)
				min=i*j%2019;
			}

			
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    
    cout << a * b - a - b + 1;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,j,ans=0,c[30],p[1010][30],a,b[30]={};
  scanf("%d",&n);
  for(i=0;i<26;i++)scanf("%d",&c[i]);
  for(i=0;i<n;i++){
    for(j=0;j<26;j++)scanf("%d",&p[i][j]);
  }
  for(i=1;i<=n;i++){
    scanf("%d",&a);
    ans+=p[i-1][a-1];
    b[a-1]=i;
    for(j=0;j<26;j++)ans-=c[j]*(i-b[j]);
    printf("%d\n",ans);
  }
  //printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
//struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long N, std::string S, std::string T){
	string res;
	REP(i, N) {
		res += S[i];
		res += T[i];
	}
	cout << res << "\n";
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(N, S, T);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c=0;
    cin>>n;
    string s;
    cin>>s;
    int memo[n];
    for(int i=0;i<n;i++)
    {
    if(s[i]=='I')
    {
        ++c;
    }
    else
    {
        --c;
    }
    memo[i]=c;
    }
    int ans = 0;
    for(int i=0;i<n;i++)
    {
      ans = max(ans,memo[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

main(){
  int n,k,i,j,t;
    int Adj[101][101];
  int g;
  
  scanf("%d",&n);
    for(i=0;i<=n;i++){
      for(j=0;j<=n;j++){
	Adj[i][j]=0;
      }
    } 
    
    for(i=0;i<n;i++){
      scanf("%d",&g);    
      scanf("%d",&k);
      for(j=0;j<k;j++){
	scanf("%d",&t);
	Adj[g][t]=1;      
      }
    }
    
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	if(j==n){
	  if(Adj[i][j]!=0) printf("1");
	  else printf("0");
	  break;	
	}
	
	if(Adj[i][j]!=0) printf("1 ");
	else printf("0 ");
	
      }
      printf("\n");
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &A[i]);
  }
  for (int i = 1; i < N; ++i) {
    A[i] += A[i - 1];
  }
  ll ans = numeric_limits<ll>::max();
  for (int i = 0; i < N - 1; ++i) {
    ans = min(ans, abs(A[i] - (A[N - 1] - A[i])));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int A[20][20];

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i,M) cin >> B[i];
  rep(i,N) rep(j,M) cin >> A[i][j];
  int ans = 0;
  rep(i,N) {
    int temp = 0;
    rep(j,M) temp += A[i][j] * B[j];
    if (temp + C > 0) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()


def resolve():
    s = str(input())
    s = s.replace('BC', 'D')
    ans = a = 0
    for i in s:
        if i == 'A':
            a += 1
        elif i == 'D':
            ans += a
        else:
            a = 0
    print(ans)


resolve()

Measured memory_bytes: 3500
#include<cstdio>
#include<cmath>
int main(){
    double x,h;
    for(;;){
        scanf("%lf%lf",&x,&h);
        if(x==0&&h==0)break;
        printf("%lf\n",x*sqrt((x/2)*(x/2)+h*h)*2+x*x);
    }
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int count_E=0;
  for(int i=1; i<(int)S.size(); i++){
    if(S[i] == 'E'){
      count_E++;
    }
  }
  int count_W=0;
  int ans=count_E;
  for(int i=1; i<(int)S.size(); i++){
    if(S[i-1] == 'W'){
      count_W++;
    }
    if(S[i] == 'E'){
      count_E--;
    }
    ans = min(ans,count_E+count_W);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  string S; cin >> S;
  map< pair<int,string>, int> cnt;
  
  string t = S.substr(0, N);
  string u = S.substr(N, N);

  REP(set, 1 << N) {
    int b = __builtin_popcount(set);
    string v;
    REP(i, N) if (set >> i & 1) v += t[i];
    for (int i = N-1; i >= 0; i--) if (!(set >> i & 1)) v += t[i];
    ++cnt[{b,v}];
  }

  ll ans = 0;

  REP(set, 1 << N) {
    int b = __builtin_popcount(set);
    string v;
    for (int i = N-1; i >= 0; i--)  if (!(set >> i & 1)) v += u[i];
    REP(i, N) if ((set >> i & 1)) v += u[i];
    ans += cnt[{N-b, v}];
  }

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

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 73984