akhauriyash/Code-Regression huggingface dataset:
// B - Ordinary Number

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int p[20];

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

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

	int ans = 0;
	for (int i=0; i+2<n; i++) {
		if (p[i] < p[i+1] && p[i+1] < p[i+2]) ans ++;
		if (p[i] > p[i+1] && p[i+1] > p[i+2]) ans ++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <iterator>
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <regex>
#include <stdexcept>
#include <unordered_set>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <cassert>
#include <time.h>
#include <numeric>
#include <complex>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using D = double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define fill(x, y) memset(x, y, sizeof(x))
#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define rep(i, x)  for(int i = 0; i < (x); i++)
#define rrep(i, x) for(int i = (x - 1); i >= 0; i--)
#define y1 y1_1234413
#define j1 j1_235
#define y0 y0_235
#define j0 j0_256
#define fi first
#define se second
#define itn int
#define re return
#define prev PREV
#define next NEXT

#define sz(x) ((int)x.size())

const int inf = 2e9;
const ld st = 0.000001;
const ld pi = acos((ld)-1);
const int MAXN = 1e5 + 10;
#define FILENAME ""

const ll maxn = 500000 + 10;

bool f(string s, string s1) {
    if (s.size() > s1.size()) {
        return true;
    }
    else if (s.size() < s1.size()) {
        re false;
    }
    else {
        for (int i = 0; i < s.size(); i++) {
            if (s[i] > s1[i]) {
                re true;
            }
            else if (s1[i] > s[i]) {
                re false;
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, s1;
    cin >> s >> s1;
    if (s == s1) {
        cout << "EQUAL";
        re 0;
    }
    if (!f(s, s1)) {
        cout << "LESS";
    }
    else if (f(s, s1)) {
        cout << "GREATER";
    }
    return 0;
}

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

int c[10][10];

// 深さ優先探索
// i -> 1 に必要な最小のMP
int minMP( int i, vector<bool> isVisited )
{
    if( i == 1 ) return 0;
    
    isVisited[i] = true;
    int minimum = INT_MAX;
    for( int j = 0; j < 10; ++j ){
        if( !isVisited[j] ){
            minimum = min( minimum, minMP(j, isVisited) + c[i][j] );
        }
    }
    return minimum;
}

// ワーシャルフロイド法
void WarshallFloyd(  )
{
    for( int k = 0; k < 10; ++k ){
        for( int i = 0; i < 10; ++i ){
            for( int j = 0; j < 10; ++j ){
                c[i][j] = min( c[i][j], c[i][k] + c[k][j] );
            }
        }    
    }
}


int main()
{
    int H, W;
    int A[201][201];

    cin >> H >> W;
    for( int i = 0; i < 10; ++i ){
        for( int j = 0; j < 10; ++j ) cin >> c[i][j];
    }
    for( int i = 0; i < H; ++i ){
        for( int j = 0; j < W; ++j ) cin >> A[i][j];
    }

    /*
    vector<int> cost(10);  // 0~9 -> 1 と書き換えるために必要な最小のMP
    for( int i = 0; i < 10; ++i ){
        vector<bool> isVisited(10, false);
        cost[i] = minMP( i, isVisited );
    }
    
    int ans = 0;
    for( int i = 0; i < H; i++ ){
        for( int j = 0; j < W; j++ ){
            if( A[i][j] != -1 ) ans += cost[A[i][j]];
        }
    }*/

    int ans = 0;
    WarshallFloyd();
    for( int i = 0; i < H; i++ ){
        for( int j = 0; j < W; j++ ){
            if( A[i][j] != -1 ) ans += c[A[i][j]][1];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fi first
#define se second
#define endl '\n'

const int N = 1e5;

multiset<ll> aux;
pll days[N+5];

int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, m; cin >>n >>m;
    for(int i = 0; i<n; i++){
        cin >>days[i].fi >>days[i].se;
    }

    sort(days, days+n);

    ll ans = 0, p = 0;
    for(int i = 1; i<=m; i++){
        while(p < n && days[p].fi <= i){
            aux.insert(-days[p++].se);
        }
        if(!aux.empty()){
            ans += abs(*aux.begin());
            aux.erase(aux.begin());
        }
    }

    cout <<ans <<endl;

    return 0;
}


Measured memory_bytes: 6400
def main():
  n,k=input().split()
  a=set(input().split())
  while True:
      n1=set(n)
      if n1 & a == set():
          print(n)
          break
      else:
          n=int(n)
          n+=1
          n=str(n)
  
  
if __name__=="__main__":
  main()


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

int main() {
    int64_t N, K;
    cin >> N >> K;
    int64_t s = N % K;
    if (N == 0) {
        cout << 0;
    } else if (s < K - s) {
        cout << s;
    } else {
        cout << K - s;
    }
}

Measured memory_bytes: 384
import sys, math

N = int(input())
low = 0
high = N - 1

print(0)
start = input()
tmp = math.ceil((high + low) / 2)
print(tmp)

while True:
    s = input()
    if s == 'Vacant':
        break
    else:
        if (tmp % 2 == 0) ^ (s == start):
            high = tmp
        else:
            low = tmp
        tmp = math.ceil((high + low) / 2)
        print(tmp)

sys.stdout.flush()

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  if(s[0]=='S') cout << "Cloudy" << endl;
  else if(s[0]=='C') cout << "Rainy" << endl;
  else cout << "Sunny" << endl;

  
  return 0;
    

}


Measured memory_bytes: 256
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
int n,a[N],f[N],d[N];
int cnt,head[N],nxt[N+N],to[N+N];
void dp(int u,int fa)
{
	if(d[u]==1)
	{
		f[u]=a[u];
		return;
	}
	int sum=0,mx=0;
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
		{
			dp(v,u);
			sum+=f[v];
			mx=max(mx,f[v]);
		}
	f[u]=2*a[u]-sum;
	// LOG(u);
	// LOG(f[u]);
	if(a[u]>sum || f[u]<0 || mx-f[u]>sum-mx)
	{
		puts("NO");
		exit(0);
	}
}
/*
x+2*(a[i]-x) = sum
x=2*a[i]-sum
*/
main()
{
	re(n);
	for(int i=1;i<=n;++i)re(a[i]);
	if(n==2)
	{
		puts(a[1]==a[2]?"YES":"NO");
		return 0;
	}
	for(int i=1,u,v;i<n;++i)
	{
		re(u),re(v);
		++d[u],++d[v];
		add_edge(u,v);
		add_edge(v,u);
	}
	int rt;
	for(int i=1;i<=n;++i)
		if(d[i]>=2)
			rt=i;
	// cerr<<rt<<endl;
	dp(rt,0);
	// cerr<<233<<endl;
	puts(f[rt]?"NO":"YES");
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    double t, x;
    cin >> t >> x;
    cout << t / x << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc= new Scanner(System.in);
        int N= sc.nextInt();
        int Q= sc.nextInt();

        String S=sc.next();
        char[] s=S.toCharArray();
        int [] num=new int[N];
        int count=0;
        for(int i=0;i<N-1;i++){
            if(s[i]=='A'&&s[i+1]=='C'){
                count++;    
            }
            num[i+1]=count;
            
        }
        int l=0;
        int r=0;
        for(int i=0;i<Q;i++){
            l=sc.nextInt()-1;
            r=sc.nextInt()-1;
            System.out.println(num[r]-num[l]);
        }
        
        
        
        
        
    }
}


Measured memory_bytes: 67060
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000

ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }

int main() {
	int N, c = 0, ans = 0, sum = 0;
	vector<int> k;
	bool flag = false;
	scanf("%d", &N);
	ans = N;
	char* s = new char[N + 1];
	scanf("%s", s);
	while (*s) {
		if (*s == '#')flag = true;
		if (flag) {
			c++;
			if (*s != *(s + 1)) {
				k.push_back(c);
				if(k.size() % 2 == 0)sum += c;
				c = 0;
			}
		}
		s++;
	}
	ans = sum;
	//printf("%d\n", sum);
	rep(i, 0, k.size() / 2) {
		sum += k[i * 2] - k[i * 2 + 1];
		//printf("%d\n", sum);
		ans = min(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}

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

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ldb long double 
#define db double
#define int long long

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair

#define pi pair<int,int>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >

#define mi map<int,int>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int md = 1e9+7;
const int MX = 2e5+5;
const int INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

int power_md(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res=(res%md*a%md)%md;
  a=(a%md*a%md)%md;
  n/=2;
}
res%=md;
return res;
}

int power(int a,int n)
{
 int res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a=a*a;
  n/=2;
}
return res;
}

int abst(int a)
{
 return ((a<0)?(-1*a):(a));
}

class cmp_set{
public:
	bool operator() (int a, int b){
		return a > b;
	}
};

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

int32_t main()
{
    string s;
    cin>>s;
    int c0=0,c1=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')
         c0++;
         else
          c1++;
    }
    int res=min(c0,c1);
    res*=2;
    cout<<res<<"\n";
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

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

    int count = 0;
    bool flag = true;
    while(flag){
        bool start = false;
        vector<P>lr;
        int l = 0, r = 0;
        for(int i = 0; i < n + 1; ++i){
            if( h[i] != 0 && start == false){
                start = true;
                l = i;
            }
            else if( (h[i] == 0) && (start == true)){
                start = false;
                r = i;
                lr.push_back({l,r});
            }
        }

        for(int t = 0; t < lr.size(); t++){
            int min_ = INF32;
            for(int i = lr[t].first; i < lr[t].second; ++i){
                min_ = min(min_, h[i]);
            }
            for(int i = lr[t].first; i < lr[t].second; ++i){
                h[i] -= min_;
            }
            count += min_;
        }

        flag = false;
        for(int i = 0; i < n; ++i){
            if(h[i] != 0){
                flag = true;
            }
        }
    }
    cout << count << endl;
    return 0;
}


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

int main(void){
    int n, m;
    int k, a;
    cin >> n >> m;
    vector<int> cnt(m, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> k;
        for (int j = 0; j < k;j++){
            cin >> a;
            cnt.at(a - 1)++;    //料理の種類ごとに入力
        }
    }
    int ans = 0;
    for (int i = 0; i < m;i++){//料理の種類分ループ
        if (cnt.at(i) == n) //人数分入っていると答えになる
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

namespace A
{

    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();
            Console.WriteLine(n*2f*Math.PI);
            ReadLine();

        }

        //最大公約数
        static int gcd(int a, int b)
        {
            if (a > b) {
                return gcd(b, a);
            }

            while (b != 0) {
                var remainder = a % b;
                a = b;
                b = remainder;
            }

            return a;
        }

        //最小公倍数
        static int lcm(int a, int b) => a * b / gcd(a, b);

        /// <summary>
        /// コンビネーション
        /// </summary>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        public static string ReadLine() => Console.ReadLine();
        public static int ReadLineInt() => int.Parse(Console.ReadLine());
        public static string[] ReadLineStringSplit(char a = ' ') => ReadLine().Split(a).ToArray();
        public static int[] ReadLineIntSpilit(char a = ' ') => ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        public static long[] ReadLineLongSpilit(char a = ' ') => ReadLine().Split(a).Select(x => long.Parse(x)).ToArray();
        static string[] GetAplhaLowerArray() => new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

Measured memory_bytes: 18640
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;cin>>n;
		vll A(n);
		forn(i,n)
			cin>>A[i];
		sort(all(A));
		ll ans=0;
		ll a=n;
		fornd(i,n)
		{
			if(i==n-1)
			{
				ans+=A[i];
				a--;
			}
			else
			{
				if(a>2)
				{
				ans+=2*A[i];
				a-=2;

				}
				else
				{
					ans+=A[i];
					a--;
				}

			}
			if(a==1)
				break;
		}		
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}


Measured memory_bytes: 4784
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

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

  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  int ans = 1e9;

  for (int i = 0; i < n; i++) {
    int t = sum - a[i];
    if (abs(t - sum) < abs(ans - sum)) {
      ans = t;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
xs = map(int, input().split())
xs = list(xs)
ys = map(int, input().split())
ys = list(ys)
ma = max(xs)
mi = min(ys)
if (mi - ma) > 0 and x < mi and mi <= y :
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(){
  double a,b,C,Cd,c2,c,S,L,h,pi;
  scanf("%lf%lf%lf",&a,&b,&C);
  pi=acos(-1);
  Cd=C*pi/180;
  S=0.5*a*b*sin(Cd);
  c2=a*a+b*b-2*a*b*cos(Cd);
  c=sqrt(c2);
  L=a+b+c;
  h=(2*S)/a;
  printf("%.8f\n",S);
  printf("%.8f\n",L);
  printf("%.8f\n",h);
  return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << x << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ cout << (x[i]) << " ";} cout << endl;

typedef long long ll;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    int n = b - a;
    int sum = n * (n+1) / 2;
    int ans = sum - b;
    print(ans);
}


Measured memory_bytes: 256
import sys
import math 
ni = lambda: int(ns())
na = lambda: list(map(int, input().split()))
ns = lambda: input()
N,M = na()
NN = na()
B = [na() for i in range(M)]

NN.sort()
B.sort(key = lambda x: x[1],reverse=True)
j = 0
dif = 0
for i in NN:
    while j<M and (i >= B[j][1] or B[j][0]==0):
        j+=1
    if j>=M:
        break
    dif += B[j][1] - i
    B[j][0]-=1
print(sum(NN)+dif)

Measured memory_bytes: 32876
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

void show(VEC<VEC<int>> &a) {
  REP(i, 0, a.size()) {
    REP(j, 0, a[i].size()) { cerr << a[i][j] << " "; }
    cerr << endl;
  }
  cerr << endl;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  VEC<int> V(N);
  REP(i, 0, N) { V[i] = S[i] - '0'; }
  // DUMP(V);
  int dig = 10;
  auto cs = VEC<VEC<int>>(N, VEC<int>(dig, 0));

  cs[0][V[0]]++;
  REP(i, 1, N) {
    cs[i][V[i]]++;
    REP(j, 0, dig) { cs[i][j] += cs[i - 1][j]; }
  }
  // DUMP("HI");
  // show(cs);

  set<int> pattern;
  REP(i, 1, N - 1) {
    REP(dl, 0, dig) {
      if (cs[i - 1][dl] > 0) {
        REP(dr, 0, dig) {
          if(cs[N-1][dr]-cs[i][dr]>0){
            pattern.insert(dl*100+V[i]*10+dr);
          }
        }
      }
    }
  }
  cout<<pattern.size()<<endl;

  return 0;
}


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

int main(){
   int n = 0 ;
   int input = 0;
   int min = 0;
   cin>>n;
   
   vector<int> list(n+1);
   vector<int> mlist(n+1);
    cin>>input;
    list[1] = input;
    mlist[1] = input;
    min = input;
    for(int i = 2 ; i <= n ; i++){
       cin>>input;
       list[i] = input;
       min = input < min ? input : min;
       mlist[i] = min;
   }
   
   int count = 0;
   for(int i = 1 ; i <= n; i++ ){
       if(list[i] == mlist[i]){
           count++;
       }
   }

   cout<<count<<endl;
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
const int mod = 1000000007;
string s,ans="";
int main(){
  cin >> s;
  for (size_t i = 0; i < s.size(); i++) {
    ans += "x";
  }
  cout << ans << endl;
}


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

int gcd(int a, int b) {
  for (int i = a; i >= 1; --i) {
    if (a%i == 0 && b%i == 0) {
      return i;
    }
  }
  return 1;
}

int main() {
  int a, b;
  cin >> a >> b;
  ll ans = ll(a)*b/gcd(a,b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね

//ここから編集する

bool can(string s) {
    string s1 = s;
    reverse(s1.begin(), s1.end());
    return s1 == s;
}

int main() {
    string s;
    cin >> s;
    string s2;
    REP(i, 0, s.size()) {
        if (s[i] != 'x') s2 += s[i];
    }

    if (!can(s2)) {
        cout << -1 << endl;
        return 0;
    }



    vector<int> cnts;
    int cnt = 0;

    REP(i, 0, s.size() + 1) {
        if (i == s.size()) {
            cnts.push_back(cnt);
            cnt = 0;
            break;
        }
        if (s[i] == 'x') {
            cnt++;
        } else {
            cnts.push_back(cnt);
            cnt = 0;
        }

    }

    if (cnts.size() % 2 == 0) {
        int ans = 0;
        REP(i, 0, cnts.size()/2){
            int rev = cnts.size() - 1 - i;
            ans += abs(cnts[i] - cnts[rev]);
        }
        cout << ans << endl;
        return 0;
    } else {
        int ans = 0;
        REP(i,0,cnts.size()/2+1){
            int l = cnts.size()/2 - i;
            int r = cnts.size()/2 + i;
            ans += abs(cnts[l] - cnts[r]);
        }
        cout << ans << endl;
        return 0;
    }

    return 0;
}


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


int main(void){
  int k; cin >> k;
  k--;
  if(k == 0 || k == 1 || k == 2 || k == 4|| k == 6 ||
  k == 10 || k == 12 || k == 14 || k == 16 || k == 18 || k == 22 ||
  k == 28 || k == 30){
    cout << 1 << endl;
  }
  else if(k == 3 || k == 5 || k == 8 || k == 9 || k == 13 || k == 20 || 
  k == 21 || k == 24 || k == 25){
     cout << 2 << endl;
  }
  else if(k == 7 || k == 11 || k == 17 || k == 19){
    cout << 5 << endl;
  }
  else if(k == 26){
    cout << 5 << endl;
  }
  else if(k == 27 || k == 29){
    cout << 4 << endl;
  }
  else if(k == 15){
    cout << 14 << endl;
  }
  else if(k == 31 ){
    cout << 51 << endl;
  }
  else{
    cout << 15 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    A,B,C=map(int,input().split())
    M=max(A,B,C)
    A,B,C=M-A,M-B,M-C
    S=sum([A,B,C])
    if S%2==0:
        print(S//2)
    else:
        print(S//2 + 2)

main()

Measured memory_bytes: 2940
<?php


[$N] = fscanf(STDIN, "%d");
$list = fscanf(STDIN, str_repeat("%d", $N));
$ans = 0;
foreach($list as $key => $value){
    if($key % 2 === 0){
        if($value % 2 === 1){
            $ans++;
        }
    }
}
echo $ans;

Measured memory_bytes: 16180
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    vector<int> vec1(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
        vec1[i]=x;
    }
    sort(vec.begin(),vec.end());
    int center_1=vec[n/2-1];
    int center_2=vec[n/2];
    for(int i=0;i<n;i++){
        if(vec1[i]<=vec[n/2-1]){
            cout<<center_2<<endl;
        }else{
            cout<<center_1<<endl;
        }
    }
    
}

Measured memory_bytes: 3712
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

constexpr lli inf = 10000 * 10000;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli n;
	string s;
	cin >> n >> s;

	int count = 0;

	for (int i = 0; i < s.size() - 2; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            Console.WriteLine(a * b / 2);
        }
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  string s;
  cin >> s;
  string u="keyence",ans="NO";
  int l=s.size();
  for(int i=0;i<l;i++){
    for(int j=0;j<=l-i-1;j++){
      string cp=s;
      cp=cp.erase(i,j);
      if(u==cp){
        ans="YES";
      }
    }
  }
  cout << ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    vector<double> p;
    for(int i = 0; i < N; i++){
        double x;
        cin >> x;
        p.push_back((x + 1.) / 2.);
    }
    double m = 0;
    for(int i = 0; i < K; i++){
        m += p[i];
    }
    double m2 = m;
    for(int i = K; i < N; i++){
        m2 += p[i];
        m2 -= p[i-K];
        m = max(m, m2);
    }
    cout << fixed << setprecision(12) <<  m << endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
int n,m,l,q,ans=-100;
void Main(){
    cin>>n>>m>>l;
    ans=n+m+l;
    if(ans>21) cout<<"bust"<<endl;
    else cout<<"win"<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
x_y_h = []
for i in range(N):
    x_y_h.append(list(map(int, input().split())))
x_y_h.sort(key=lambda x: x[2])
a, b, c = x_y_h[-1]
for x in range(101):
    for y in range(101):
        h = abs(x-a) + abs(y-b) + c
        if all(k == max(h-abs(x-i)-abs(y-j), 0) for i, j, k in x_y_h):
            print(x, y, h)
            exit()

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2823&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M;
    while(cin >> N >> M,N){
        map<int,int> mp;
        for(int i = 0; i < N;i++){
            int d,v; cin >> d >> v;
            mp[d] = max(mp[d],v);
        }
        int ans = 0;
        for(auto p:mp){
            ans += p.second;
        }
        cout << ans << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(b);i>=(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
template<class T>
ll sum(const T& a){return accumulate(all(a),0LL);}

void solve(){
    ll a,b,c,x,y;cin>>a>>b>>c>>x>>y;
    ll ans=0;
    if(a+b>2*c){
        ll mi=min(x,y);
        ans+=2*mi*c;
        x-=mi;
        y-=mi;
    }
    ans+=min(a,2*c)*x+min(b,2*c)*y;
    cout<<ans<<endl;
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C076
    {
        static void Main(string[] args)
        {
            string S0 = Console.ReadLine();
            string T = Console.ReadLine();

            string S = "";
            if (T.Length > S0.Length) S = "UNRESTORABLE";
            if (S == "")
            {
                for (int i = 0; i <= S0.Length - T.Length; i++)
                {
                    bool match = true;
                    for (int j = 0; j < T.Length; j++)
                    {
                        if (!(S0[i + j] == T[j] || S0[i + j] == '?'))
                        {
                            match = false;
                            break;
                        }
                    }
                    if (match)
                    {
                        S = S0.Substring(0, i) + T + S0.Substring(i + T.Length);
                        S = S.Replace('?', 'a');
                    }
                }
            }
            if (S == "") S = "UNRESTORABLE";
            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>

#define NODE_MAX 500000
#define KEY_MAX 2000000000
#define KEY_MIN -KEY_MAX
#define NIL KEY_MIN-10000

using namespace std;

int left(int n, int i) {
  int l = i*2;
  if(l > n) return 0;
  return l;
}

int right(int n, int i) {
  int r = i*2+1;
  if(r > n) return 0;
  return r;
}

void maxHeapify(int a[], int n, int i) {
  int l = left(n, i);
  int r = right(n, i);
  int largest = i;
  if(l != 0 && a[l] > a[largest]) largest = l;
  if(r != 0 && a[r] > a[largest]) largest = r;

  if(largest != i) {
    int tmp = a[i];
    a[i] = a[largest];
    a[largest] = tmp;
    maxHeapify(a, n, largest);
  }
}

int max(int x, int y) {
  if(x>y) return x;
  return y;
}

int _height(int a[], int n, int i, int h) {
  int l = left(n, i);
  int lh = 0;
  if(l != 0 && a[l] != NIL) {
    lh = _height(a, n, l, h+1);
  }

  int r = right(n, i);
  int rh = 0;
  if(r != 0 && a[r] != NIL) {
    rh = _height(a, n, r, h+1);
  }

  return max(max(h, lh), rh);
}

int height(int a[], int n) {
  return _height(a, n, 1, 1);
}

void buildMaxHeap(int a[], int n) {
  for(int i=n/2; i>=1; i--) {
    maxHeapify(a, n, i);
  }
}

int main() {
  int a[NODE_MAX];
  for(int i=1; i<=NODE_MAX; i++) {
    a[i] = NIL;
  }

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

  buildMaxHeap(a, n);

  for(int i=1; i<=n; i++) {
    cout << " " << a[i];
  }
  cout << endl;
}

Measured memory_bytes: 5008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int N=1e5+10;
int n,X;
int a[N];
int dp[2][N];
ll ans;
int main(){
	scanf("%d%d",&n,&X);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);reverse(a+1,a+n+1);
	int now=0,lst=1;
	dp[lst][X]=1;
	for(int i=1;i<=n;i++,now^=1,lst^=1){
		memset(dp[now],0,sizeof(dp[now]));
		if(i!=n)for(int j=0;j<=X;j++)dp[now][j]=(dp[now][j]+(ll)(n-i)*dp[lst][j]%mod)%mod;
		for(int j=0;j<=X;j++)dp[now][j%a[i]]=(dp[now][j%a[i]]+dp[lst][j])%mod;
	}
	for(int i=1;i<=X;i++)ans=(ans+(ll)i*dp[lst][i]%mod)%mod;
	ans=(ans%mod+mod)%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	char latest = sa[0];
	sa.erase(sa.begin());
	while (true) {
		if (latest == 'a') {
			if (sa.empty()) {
				cout << 'A';
				return 0;
			}
			latest = sa[0];
			sa.erase(sa.begin());
		}
		if (latest == 'b') {
			if (sb.empty()) {
				cout << 'B'; 
				return 0;
			}
			latest = sb[0];
			sb.erase(sb.begin());
		}
		if (latest == 'c') {
			if (sc.empty()) {
				cout << 'C';
				return 0;
			}
			latest = sc[0];
			sc.erase(sc.begin());
		}
	}
}

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

ll max(ll a, ll b){ 
	if(a >= b) return a;
	else if(a < b) return b;
}
ll min(ll a, ll b){ 
	if(a <= b) return a;
	else if(a > b) return b;
}
ll gcd(ll a, ll b){
	if(b == 0) return a;
	return gcd(b, a%b);
}
ll fact(ll n){
	ll res = 1;
	rep(i, n){
		res *= i + 1;
		res =  res%((ll)(1e9 + 7));
	}
	return res;
}
ll digit(const ll n){
	ll res = 0;
	ll i = 1;
	while(n % i != n){
		res += 1;
		i *= 10;
	}
	return res;
}

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

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  string s;
  cin >> s;
  int ans = INT_MAX;
  rep(i, s.size() - 2){
    string s_tmp = s.substr(i, 3);
    // cout << s_tmp << endl;
    ans = min(ans, abs(stoi(s_tmp) - 753));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll l,r; cin>>l>>r;
    ll mn=2050;
    if(r-l+1>=2019){
        cout<<0<<endl;
    }
    else {
        for(ll i=l;i<=r-1;i++){
            for(ll j=i+1;j<=r;j++){
                mn=min((i*j)%2019,mn);
            }
        }
        cout<<mn<<endl;
    }
}


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

ans = 0
for i in range(N):
    if A[i] >= B[i]:
        A[i] -= B[i]
        ans += B[i]
        B[i] = 0 
    else:
        ans += A[i]
        B[i] -= A[i]
        ans += min(B[i], A[i+1])
        A[i+1] = max(0, A[i+1]-B[i])

print(ans)

Measured memory_bytes: 18476
#include <iostream>

using namespace std;

int main(void)
{
	int h, w;

	while (cin >> h >> w, h != 0 || w != 0) {
		for (int i = 0; i < h; i++) {
			char a, b;
			a = i % 2 ? '#' : '.';
			b = '#' + '.' - a;

			for (int i = 0; i < w; i++)
				i % 2 ? cout << a : cout << b;
			cout << endl;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

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

  ll ans = max(0LL, (4 - X) * 100000) + max(0LL, (4 - Y) * 100000);
  if (X == 1 && Y == 1)
    ans += 400000;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
int N, M, K, H, W, L, R;

inline int converter(int x, int y, int h, int w) {
	if (!x || !y || !h || !w)return 120000000;
	x--;
	y--;
	h--;
	w--;
	return (x * 1157625) + (y * 11025) + (h * 105) + w;
}

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

	cin >> H >> W;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	int sy, sx;
	vector<vector<char>>hv(H + 1, vector<char>(W + 1));
	vector<vector<char>>wv(H + 1, vector<char>(W + 1));
	for (char i = 0; i < H; i++) {
		for (char j = 0; j < W; j++) {
			if (s[i][j] == 'E')sy = i, sx = j;
			hv[i + 1][j + 1] = (s[i][j] == 'o');
			wv[i + 1][j + 1] = (s[i][j] == 'o');
		}
	}
	for (char i = 1; i <= H; i++) {
		for (char j = 2; j <= W; j++) {
			hv[i][j] += hv[i][j - 1];
		}
	}
	for (char i = 2; i <= H; i++) {
		for (char j = 1; j <= W; j++) {
			wv[i][j] += wv[i - 1][j];
		}
	}
	short dp[120000001] = {};
	dp[120000000] = -1000;
	for (char i = 1; i <= H; i++) {
		for (char j = 1; j <= W; j++) {
			for (char y = max(1, sy + 2 - i); y <= min(sy + 1, H - i + 1); y++) {
				for (char x = max(1, sx + 2 - j); x <= min(sx + 1, W - j + 1); x++) {
					int box = converter(x, y, i, j);
					int bag = 0;
					if (H - (sy - y + 1) >= y + i - 1) {
						bag = converter(x, y, i - 1, j);
						char rx = min(x + j - 1, W - (sx +1- x));
						char lx = max(x - 1, x+j-1 - sx-1);
						dp[box] = max(dp[box], short(dp[bag] + hv[y + i - 1][rx] - hv[y + i - 1][lx]));
					}
					if (y + i - 1 - sy - 1 < y) {
						bag = converter(x, y + 1, i - 1, j);
						char rx = min(x + j - 1, W - (sx+1 - x));
						char lx = max(x - 1, x +j-1- sx-1);
						dp[box] = max(dp[box], short(dp[bag] + hv[y][rx] - hv[y][lx]));
					}
					if (W - (sx - x + 1) >= (x + j - 1)) {
						bag = converter(x, y, i, j - 1);
						char ry = min(y + i - 1, H - (sy+1 - y));
						char ly = max(y - 1, y +i-1- sy-1);
						dp[box] = max(dp[box], short(dp[bag] + wv[ry][x + j - 1] - wv[ly][x + j - 1]));
					}
					if (x + j - 1 - sx - 1 < x) {
						bag = converter(x + 1, y, i, j - 1);
						char ry = min(y + i - 1, H - (sy+1 - y));
						char ly = max(y - 1, y +i-1- sy-1);
						dp[box] = max(dp[box], short(dp[bag] + wv[ry][x] - wv[ly][x]));
					}
					if (dp[box]) {
						//cout << (int)i << " " << (int)j << " " << (int)y << " " << (int)x << " " << dp[box] << endl;
					}
				}
			}
		}
	}
	short ans = 0;
	for (auto i : dp)ans = max(ans, i);
	cout << ans << endl;
}


Measured memory_bytes: 234624
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

int a0;
int b[3], c[3][3];
bool ans;

int main() {
	repi(i, 0, 3)repi(j, 0, 3) rd(c[i][j]);
	repi(i, -100, 101) {
		a0 = i;
		repi(j, 0, 3) b[j] = c[0][j] - a0;
		bool A = (c[1][0] - b[0]) == (c[1][1] - b[1]) && (c[1][1] - b[1]) == (c[1][2] - b[2]);
		bool B = (c[2][0] - b[0]) == (c[2][1] - b[1]) && (c[2][1] - b[1]) == (c[2][2] - b[2]);
		ans = A && B;
		if (ans) {
			wrln("Yes");
			return 0;
		}
	}
	wrln("No");
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s)
	fmt.Scan(&t)

	ans := 0
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

const int Max = 1e6;
vector<int> mps(Max+1);

void mpsinit(){//O(NloglogN)
    for(int i = 0; i <= Max; i++) mps[i] = i;
    for(ll i = 2; i*i <= Max; i++){
        if(mps[i] == i){
            for(ll j = i*i; j <= Max; j += i){
                if(mps[j] == j) mps[j] = i;
            }
        }
    }
}
template<typename T>
vector<T> prime_factorization(T n){//O(logN)
    vector<T> ret;
    while(mps[n] != n){
        if(ret.size() != 0 && ret.back() == mps[n]){
            n /= mps[n];
        } else {
            ret.push_back(mps[n]);
            n /= mps[n];
        }
    }
    if(ret.size() == 0 || ret.back() != mps[n]) ret.push_back(mps[n]);
    return ret;
}

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

    mpsinit();
    vector<int> seen(Max,0);
    bool pc = true;

    for(int i = 0; i < n; i++){
        if(a[i] == 1) continue;
        vector<int> fp = prime_factorization(a[i]);
        for(auto p:fp){
            if(seen[p]) pc = false;
            seen[p] = true;
        }
    }

    int g = __gcd(a[0],a[1]);
    for(int i = 0; i < n; i++) g = __gcd(g,a[i]);

    if(pc) cout << "pairwise coprime" << endl;
    else if(g == 1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

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

using namespace std;

int cnt[105];

int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	
	for (int i = 0; i < k; i++) {
		int d;
		scanf("%d", &d);
		for (int j = 0; j < d; j++) {
			int x;
			scanf("%d", &x);
			cnt[x]++;
		}
	}
	
	int res = 0;
	for (int i = 1; i <= n; i++) res += (cnt[i] == 0);
	printf("%d\n", res);
}


Measured memory_bytes: 3832
N,x = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
for i in range(N):
  if i == 0:
    cnt += max(0,a[0] - x)
    a[0] -= max(0,a[0] - x)
  else:
    cnt += max(0,a[i] + a[i-1] - x)
    a[i] -= max(0,a[i] + a[i-1] - x)
print(cnt)

Measured memory_bytes: 85076
#include <iostream>

using namespace std;

int main()
{
  int a,b,c;
  int cnt = 0;

  cin >> a >> b >> c;

  for(int i = a;i <= b;i++)
    {
      if(c % i == 0)
	{
	  cnt++;
	}
    }
  cout << cnt << endl;
}



Measured memory_bytes: 3088
import bisect
s = input()
t = input()
N = len(s)

next_map = sorted(zip(s*2,range(N*2)))
br = bisect.bisect_right
ans = 0
i = -1
for c in t:
    map_idx = br(next_map,(c,i))
    if map_idx == N*2:
        ans = -1
        break
    a,j = next_map[map_idx]
    if a != c :
        ans = -1
        break
    ans += j - i
    i = j%N
print(ans)

Measured memory_bytes: 70136