akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    
    int n = 0;
    for(int i = a; i <= b; i++) {
        if(c % i == 0) {
            n++;
        }
    }
    
    cout << n << endl;;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void) {

    int n;
    cin>>n;
    vi v(n);
    ll ans=0;
    vector<pair<int,int> > log;
    bool isneg=false,ispos=false;
    rep(i,n){
        cin>>v[i];
        if(v[i]>=0)ispos=true;
        else isneg=true;
    }
    Sort(v);

    if(ispos&&isneg){
        for(int i=v.size()-2;i>0;i--){
            if(v[i]<0)break;
            log.push_back(mp(v[0],v[i]));
            v[0]-=v[i];
            v[i]=INF;
        }
        for(int i=0;i<v.size()-1;i++){
            if(v[i]==INF)continue;
            else {
                log.push_back(mp(v[v.size()-1],v[i]));
                v[v.size()-1]-=v[i];
            }
        }
        ans=v[v.size()-1];
    }
    else if(ispos){
        for(int i=1;i<v.size()-1;i++){
            log.push_back(mp(v[0],v[i]));
            v[0]-=v[i];
        }
        log.push_back(mp(v[v.size()-1],v[0]));
        v[v.size()-1]-=v[0];
        ans=v[v.size()-1];
    }
    else if(isneg){
        Rort(v);
        log.push_back(mp(v[0],v[1]));
        v[0]-=v[1];
        for(int i=2;i<v.size();i++){
            log.push_back(mp(v[0],v[i]));
            v[0]-=v[i];
        }
        ans=v[0];
    }
    
    cout<<ans<<endl;
    for(int i=0;i<log.size();i++){
        cout<<log[i].first<<" "<<log[i].second<<endl;
    }

}



Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

/**
 * Segment Tree (0-indexed)
 */
template<class Monoid> struct SegmentTree {
    using func = function<Monoid(Monoid, Monoid)>;
    int n;
    Monoid ie;
    func f;
    vector<Monoid> node;

    SegmentTree(){};
    SegmentTree(int n, Monoid ie, func f) : n(n), ie(ie), f(f) {
        const int cn = n;
        n = 1; while(n < cn)  n *= 2;
        node.assign(2*n, ie);
    }

    void update(int i, Monoid x) {
        i += n;
        node[i] = x;
        while(i /= 2)  node[i] = f(node[2*i], node[2*i+1]);
    }

    // [l, r)
    Monoid query(int l, int r) {
        l = max(l, 0);  r = min(n, r);
        if(l >= r)  return ie;

        Monoid res = ie;
        for(l += n, r += n; l != r; l /= 2, r /= 2) {
            if(l % 2)  res = f(res, node[l++]);
            if(r % 2)  res = f(res, node[--r]);
        }
        return res;
    }

    Monoid operator[](int i) {
        assert(0 <= i && i < n);
        return node[i+n];
    }
};

int main() {
    lint n, m;
    cin >> n >> m;

    using T = tuple<lint, lint, lint>;
    vector<T> query(m);
    for(auto& e : query) {
        lint l, r, c;
        cin >> l >> r >> c;
        e = T(--l, --r, c);
    }

    sort(begin(query), end(query));
    SegmentTree<lint> sg(n, 1e18, [](lint a, lint b){return min(a, b);});
    sg.update(0, 0);

    for(auto q : query) {
        lint l, r, c;
        tie(l, r, c) = q;
        lint mi = sg.query(l, r+1);
        sg.update(r, min(sg[r], mi+c));
    }

    cout << (sg[n-1] == 1e18 ? -1 : sg[n-1]) << endl;
}

Measured memory_bytes: 4608
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List
import qualified Data.Vector.Unboxed as VU
-- import qualified Data.Vector.Unboxed.Mutable as VUM
-- import Control.Monad
-- import Control.Monad.ST
import Debug.Trace
-- trace _ = id

solve :: Int -> Int -> [Int] -> Int
solve bN bK as = lastVec VU.! bK
  where
  lastVec = foldl princF initVec as
  initVec = VU.cons 1 (VU.replicate bK 0)
  princF prev a = VU.postscanl' secondF 0 (VU.fromListN (bK+1) [0..bK])
    where secondF acc k
            | k-(a+1) < 0   = x
            | otherwise     = x `mSub` (prev VU.! (k-(a+1)))
            where x = acc `mAdd` (prev VU.! k)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_bN,bs_bK]:remLines1 = remLines0
      bN = readBInt bs_bN
      bK = readBInt bs_bK
      line2:remLines2 = remLines1
      as = map readBInt line2
  in solve bN bK as

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents

-------------------------------------------------------------------------------

prime :: Int
prime = 10 ^ 9 + 7

mAdd x y | s < prime = s
         | otherwise = s - prime
  where s = x + y

mSub x y = mAdd (prime + x) (-y)


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

int main(){
    cout << fixed << setprecision(20);
    ll x; cin >> x;
    int ans = 0;
    double num = 100;
    while(num < x){
        num *= 1.01;
        num = floor(num);
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
int n;
vector<vector<int> > v(100000);
ll dp[100000][2];//0白1黒
vector<bool> used(100000,false);
void dfs(int n){
    used[n]=true;
    if(v[n].size()==1&&used[v[n][0]]){
        dp[n][0]=1;
        dp[n][1]=1;
        return;
    }
    for(int i=0;i<v[n].size();i++){
        if(used[v[n][i]])continue;
        dfs(v[n][i]);
        dp[n][0]*=dp[v[n][i]][0]+dp[v[n][i]][1];
        dp[n][1]*=dp[v[n][i]][0];
        dp[n][0]%=MOD;
        dp[n][1]%=MOD;
    }
    return;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    if(n==1){
        cout <<2<< "\n";
        return 0;
    }
    for (int i = 0; i < n-1; i++)
    {
        int tempx, tempy;
        cin >> tempx>>tempy;
        tempx--;
        tempy--;
        v[tempx].push_back(tempy);
        v[tempy].push_back(tempx);
    }
    for(int i=0;i<n;i++){
        dp[i][0]=1;
        dp[i][1]=1;
    }
    //memset(dp,1,sizeof dp);
    dfs(0);
    cout <<(dp[0][0]+dp[0][1])%MOD<< "\n";
}



Measured memory_bytes: 11520
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        k: i64,
        n: usize,
        a: [i64; n],
    }

    let mut d = vec![0; n];
    d[0] = k + a[0] - a[n - 1];
    for i in 1..n {
        d[i] = a[i] - a[i - 1];
    }
    println!("{}", d.iter().sum::<i64>() - d.iter().max().unwrap());
}


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

int main(void){
    int n;
    cin >> n;
    int p[n],num = 0;
    for(int i = 0;i < n;i++){
        cin >> p[i];
    }
    int sum = 0;
    for(int i = 0;i < n;i++){
        if(n-num >= p[i])sum++;
        num = max(num,n-p[i]);
    }
    cout << sum;
    
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if(A > 8 || B > 8) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
    }
  return 0;
}


Measured memory_bytes: 256
using System;

class program
{

    public static void Main()
    {

        var n = int.Parse(Console.ReadLine());

        var p = Console.ReadLine().Split(' ');
        double[] p1 = new double[n];

        for (int i = 0; i < n; i++)
        {
            p1[i] = double.Parse(p[i]);
        }

        p = Console.ReadLine().Split(' ');
        double[] p2 = new double[n];

        for (int i = 0; i < n; i++)
        {
            p2[i] = double.Parse(p[i]);
        }

        double[] D = new double[4];

        for (int i = 0; i < 3; i++)
        {
            D[i] = 0.0;
            for (int j = 0; j < n; j++)
            {
                D[i] += Math.Pow(Math.Abs(p2[j] - p1[j]), i + 1);
            }
            D[i] = Math.Pow(D[i], (1.0 / (i + 1)));
        }

        double max = 0.0;
        for (int i = 0; i < n; i++)
        {
            double abs = Math.Abs(p2[i] - p1[i]);
            max = max > abs ? max : abs;
        }
        D[3] = max;

        foreach (double val in D)
        {
            Console.WriteLine("{0:f6}", val);
        }
    }
}

Measured memory_bytes: 5800
n,m=map(int,input().split())

ans=0
success_probability=1
failure_probability=1
for i in range(1,1000):
    time=(1900*m + 100*(n-m))*i
    success_probability=failure_probability * (1/2**m)
    failure_probability=failure_probability * (1-(1/2**m))
    ans+= time * success_probability

print(round(ans))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, W;
	cin >> N >> W;
	int w[100000], v[100000];
	rep(i, N) cin >> w[i] >> v[i];

	ll dp[101][100001] = {};
	rep(i, N) {
		rep1(j, W) {
			dp[i + 1][w[i]] = v[i];
			if (dp[i][j]) {
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				if(j + w[i] <= W) dp[i + 1][j + w[i]] = max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
			}
		}
	}

	ll kotae = 0;
	rep1(i, W) {
		kotae = max(kotae, dp[N][i]);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 79744
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long q = sc.nextLong();
        long h = sc.nextLong();
        long s = sc.nextLong();
        long d = sc.nextLong();
        long n = sc.nextLong();
        long x = Math.min(d, Math.min(s * 2, Math.min(h * 4, q * 8)));
        long y = Math.min(s, Math.min(h * 2, q * 4));
        long amari = n % 2;
        //System.out.printf("x %d,y %d,amari %d%n", x, y, amari);
        if (amari == 0) {
            System.out.println(n / 2 * x);
            return;
        }
        System.out.println(n / 2 * x + amari * y);
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

string field[50];


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

int seedfill(int x, int y){
	queue<P> q;
	q.push(MP(x,y));
	set<char> s;
	int cnt = 0;

	while(!q.empty()){
		P p = q.front();
		q.pop();

		if(field[p.Y][p.X] != '.'){
			s.insert(field[p.Y][p.X]);
			continue;
		}
		field[p.Y][p.X] = '#';
		cnt++;

		rep(i, 4){
			int nx = p.X+dx[i];
			int ny = p.Y+dy[i];
			if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
			q.push(MP(nx, ny));
		}
	}
	bool white = (s.find('W') != s.end());
	bool black = (s.find('B') != s.end());
	if(white && black) return 0;
	if(black) return -cnt;
	if(white) return  cnt;
	return 0;
}

int main(){
	while(1){
		cin >> w >> h;
		if(!w && !h)break;
		rep(i, h){
			cin >> field[i];
		}
		int br = 0;
		int wh = 0;
		rep(i, h){
			rep(j, w){
				if(field[i][j] == '.'){
					int ret = seedfill(j, i);
					if(ret < 0) br += -ret;
					else wh += ret;
				}
			}
		}
		cout << br << ' ' << wh << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
n = int(input())
#a,b = map(int,input().split())
x_L = list(map(int,input().split()))

def destance(a,b):
    return (a-b)**2

x_L = list(sorted(x_L))
start = x_L[0]
end = x_L[-1]

ans = 10**20
for i in range(start,end+1):
    tmp = 0
    for k,val in enumerate(x_L):
        tmp += destance(x_L[k],i)
    ans = min(ans,tmp)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define N 100

void push(int);
int pop();

int top, calc[10000];

int main(){

  top=0;
  int x, y, result;
  char str[N];

  while( scanf("%s", str) != EOF){

    if(str[0]=='+'){

      x=pop();
      y=pop();

      push(x+y);
    }else if(str[0]=='-'){
      x=pop();
      y=pop();

      push(y-x);
    }else if(str[0]=='*'){
      x=pop();
      y=pop();

      push(x*y);
    }else push(atoi(str));
  }


  result=pop();
  printf("%d\n", result);
 return 0;
  
}

void push(int a){


  calc[++top]=a;

}
int pop(){

  top--;

  return calc[top+1];
}
  
  
    
    

  



Measured memory_bytes: 2100
import java.util.Scanner;
import java.util.*;

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

                int sum = 0;
                int in = 0;
                int min = 0;
                int oldIn = scan.nextInt();
                min = oldIn;
                sum = min;
                for(int i = 0; i < h - 2; i++){
                  in = scan.nextInt();
                  min = Math.min(oldIn, in);
                  sum += min;
                  oldIn = in;

                }
                sum += oldIn;
                System.out.println(sum);
    }
}


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

using namespace std;

int main(){
    string words;
    cin >> words;
    int len = words.size();
    for (int i = 1; i < len; ++i)
    {
        if(words[i-1] == 'S' && words[i] == 'T'){
            words.erase(words.begin() + i);
            words.erase(words.begin() + i - 1);
            i -= 2;
            len -= 2;
        }
    }
    cout << words.size() << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> v1(n); 
  for(int i=0;i<n;i++) {
    cin >> v1.at(i);
  }
  
  int m;
  cin >> m;
  vector<string> v2(m);
  for(int j=0;j<m;j++) {
    cin >> v2.at(j);
  }
  
  vector<int> x(n);
  for(int i=0;i<n;i++) {
    int z=0;
    for(int j=0;j<n;j++) {
      if(v1.at(i)==v1.at(j)) {
        z++;
      }
    }
    x.at(i)=z;
  }
  
  vector<int> y(n);
  for(int i=0;i<n;i++) {
    int w=0;
    for(int j=0;j<m;j++) {
      if(v1.at(i)==v2.at(j)) {
        w++;
      }
    }
    y.at(i)=w;
  }
  
  int nn=x.at(0)-y.at(0);
  for(int i=0;i<n;i++) {
    if(x.at(i)-y.at(i)>nn) {
      nn=x.at(i)-y.at(i);
    }
  }
  if(nn<0) {
    cout << 0 << endl;
  }
  else {
    cout << nn << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String a = sc.next();
if(a.equals("a") || a.equals("e") || a.equals("i") || a.equals("o") || a.equals("u")){
System.out.println("vowel");
}else{
System.out.println("consonant");
}

}
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	if (N == 1 && A != B){
		cout << 0 << endl;
	}
	else if (A > B){
		cout << 0 << endl;
	}
	else{
		ll sum_min = A*(N - 1) + B;
		ll sum_max = A + B*(N - 1);
		cout << sum_max - sum_min + 1 << endl;
	}
	return 0;
}



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

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

ll l , r ;

int main() {
  fast
  cin >> l >> r ;
  ll mn = Int_max ;
    forn( ll , i , l , min( l + 2020 , r ) ){
       forn( ll , j , l + 1 , min( l + 2020 , r + 1 ) ){
            mn = min( mn , ( i * j ) % 2019 ) ;
       }
    }
  cout << mn ;

  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//using ll = long long;
#define ll long long
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 (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll tmp1,tmp2,tmp3;
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
void swap(ll *x,ll *y){
  ll z = *x;
  *x = *y;
  *y = z;
}
void print(vector<ll> vec){
  ll length = (ll)vec.size();
  rep(i,length){
    if(i != 0){cout << " ";}
    cout << vec[i];
  }
  cout << endl;
}
int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> vec(n);
  rep(i,n){
    cin >> vec[i];
  }
  ll ans = 0;
  rep(i,n){
    if(vec[i] >= k){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 1024
//NAME-ADITYYA OJHA
                                               /*
                                                      GURU(MENTOR)-AARADHYA
                                               */
/*
 *     Heart beats fast
 *         Colors and promises
 *             How to be brave
 *                 How can I love when I am afraid to fall...
                                             (courtesy-amnesiac_dusk)
 */

#include <bits/stdc++.h>
#define ll long long int
#define forin for(int i=0;i<n;i++)
#define pb push_back
#define vx vector<ll> x
#define vy  vector<ll> y
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  f   first
#define  s   second
#define mod 1000000007
using namespace std;

/*
check for corner cases(for n==1)
 check for int overflow
 run on some sample cases before submitting
*/

/*FERMAT THEOREM

       pow(x,m-1)%m=1 (x and m are co-prime)
*/
/*MODULAR INVERSE

        pow(x,-1)=pow(x,m-2) (x and m are co-prime)
*/

/*
ll  mode(ll x,ll n,ll mod)
{
    if(n==0)return 1%mod;

    ll u=mode(x,n/2,mod);
    u=(u*u)%mod;
    if(n & 1)u=(u*x)%mod;
}
*/

 const ll N=1e5+ 5;
 ll dp[N];

int main()
{
   fast;
   memset(dp,0,sizeof(dp));
   ll n;
   cin>>n;
   ll a[n+1];
   for(int  i=1;i<=n;i++)
   {
       cin>>a[i];
   }
   dp[1]=0;
   dp[2]=abs(a[2]-a[1]);
   for(int i=3;i<=n;i++)
   {
       dp[i]=min(dp[i-2]+ abs(a[i]-a[i-2]), dp[i-1]+ abs(a[i]-a[i-1]));
   }
   cout<<dp[n]<<endl;



}


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

#define INF 9999999999
#define MAXN 51111
using namespace std;

struct A{
    int u,v,w;
    int next;
    int id;
    bool operator < (const A & b) const{
        return w > b.w;
    }
}star[MAXN], pre[MAXN];

int t,n;
int u,v,w;
int dis[MAXN], vis[MAXN], head[MAXN], eg;
bool svis[MAXN];

void Init(){
    memset(vis, 0, sizeof vis);
    memset(pre, 0, sizeof pre);
    for(int i=0; i<MAXN; i++)
        dis[i] = INF;
}

void AddEdge(int u, int v, int w, int id){
    ++eg;
    star[eg] = (A){u,v,w,head[u]};
    star[eg].id = id;
    head[u] = eg;
}

void Dijkstra(int s){
    priority_queue<A>P;
    A t1, t2;
    t1.v = s;
    P.push(t1);
    dis[s] = 0;
    while(!P.empty()){
        t1 = P.top();
        P.pop();
        int u = t1.v;
        if(vis[u]) continue;
        vis[u] = 1;
        for(int i=head[u]; ~i; i=star[i].next){
            int v = star[i].v;
            if(!vis[v] && dis[v] > dis[u] + star[i].w){
                dis[v] = star[i].w + dis[u];
                t2.u = u;
                t2.v = v;
                t2.w = dis[v];
                pre[v] = star[i];
                P.push(t2);
            }
        }
    }
}

int main() {
    memset(head, -1, sizeof head);eg = 0;
    int n, m;
    int u, v, w;
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++) {
        scanf("%d%d%d", &u, &v, &w);
        AddEdge(u, v, w, i);
        AddEdge(v, u, w, i);
    }
    for(int i = 1; i <= n; i++) {
        Init();
        Dijkstra(i);
        for(int j = 1; j <= n; j++) {
            if(i != j) {
                A tmp = pre[j];
                svis[tmp.id] = 1;
                while(tmp.u != i) {
                    svis[tmp.id] = 1;
                    tmp = pre[tmp.u];
                }
            }
        }
    }
    int cnt = 0;
    for(int i = 0; i < m; i++) {
        if(!svis[i]) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 1920
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val ab = (1..n).map { Pair(sc.nextInt(), sc.nextInt()) }
  val cd = (1..m).map { Pair(sc.nextInt(), sc.nextInt()) }

  val array = IntArray(n) { 0 }

  for (i in 0 until n) {
    val a = ab[i].first
    val b = ab[i].second
    var min = Int.MAX_VALUE
    var tmpj = 0
    for (j in 0 until m) {
      val c = cd[j].first
      val d = cd[j].second
      val dist = Math.abs(a - c) + Math.abs(b - d)
      if (dist < min) {
        tmpj = j
        min = dist
      }
    }
    array[i] = tmpj + 1
  }


  println(array.joinToString("\n"))

}


Measured memory_bytes: 41380
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {a:usize,b:[u128;a]}
    let mut ans: u128 = 1;
    let max = 10_u128.pow(18);
    for i in &b {
        if i == &0 {
            println!("0");
            return;
        }
    }

    for i in &b {
        ans *= i;
        if ans > max {
            println!("-1");
            return;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 5344
import java.util.Scanner;

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

    long n = sc.nextLong();
    long k = sc.nextLong();

    long rest = n % k;
    long abs = Math.abs(rest - k);
    System.out.println(Math.min(rest, abs));
  }
}

Measured memory_bytes: 21716
#include<iostream>
using namespace std;
int n,cnt;
int a[100];
main(){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n-1;i++){
        if(a[i]==a[i+1])cnt++,a[i+1]=-1000+i;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	float d, t, s;
	cin >> d >> t >> s;
	float time;
	time = d / s;
	if (time <= t)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll N=1e5+8;
const ll MOD=1e9+7;
const ll inf=1e18+6;
const ll M=2000;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(20);
    cout << fixed;
    ll n;
    cin>>n;
    ll x=n,c=0;
    while(x>0)
    {
        c+=x%10;x=x/10;
    }
    if(n%c==0) cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
import math
a, b, C = map(int, input().split())
S = a * b * math.sin(math.pi * C / 180) / 2
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.pi * C / 180))
L = a + b + c
h = 2 * S / a
print('{:.4f}'.format(S))
print('{:.4f}'.format(L))
print('{:.4f}'.format(h))



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

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define int long long
using ll = long long;
int N, M, L, K, A, H;
ll dp[101][101];  // dp[i][j]=街iに、残り時間jで来るときの最短時間
bool canfri[101];
struct edge {
    int to, cost;
};
vector<edge> G[101];
void init() {
    REP(i, N) {
        REP(j, M + 1) { dp[i][j] = 1e18; }
    }
    dp[A][M] = 0;
    REP(i, N) {
        canfri[i] = false;
        G[i].clear();
    }
}

using arr3 = array<int, 3>;
bool solve() {
    cin >> N >> M >> L >> K >> A >> H;
    if (N == 0) return false;
    init();
    REP(i, L) {
        int x;
        cin >> x;
        canfri[x] = true;
    }
    REP(i, K) {
        int u, v, c;
        cin >> u >> v >> c;
        G[u].push_back({v, c});
        G[v].push_back({u, c});
    }
    priority_queue<arr3, vector<arr3>, greater<arr3>> que;
    que.push({0, A, M});
    while (!que.empty()) {
        arr3 ar = que.top();
        que.pop();
        int c = ar[0], now = ar[1], rem = ar[2];
        if (c > dp[now][rem]) continue;
        if (canfri[now] && rem < M) {
            if (dp[now][rem] + 1 < dp[now][rem + 1]) {
                dp[now][rem + 1] = dp[now][rem] + 1;
                que.push({dp[now][rem + 1], now, rem + 1});
            }
        }
        for (auto e : G[now]) {
            int nxt = e.to;
            if (rem < e.cost) continue;
            if (dp[now][rem] + e.cost < dp[nxt][rem - e.cost]) {
                dp[nxt][rem - e.cost] = dp[now][rem] + e.cost;
                que.push({dp[nxt][rem - e.cost], nxt, rem - e.cost});
            }
        }
    }
    ll ans = 1e18;
    REP(j, M + 1) { ans = min(ans, dp[H][j]); }
    if (ans < 1e18)
        cout << ans << endl;
    else
        cout << "Help!" << endl;
    return true;
}
signed main() {
    while (solve())
        ;
    return 0;
}



Measured memory_bytes: 3456
//coded by dsingh_24
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	ios
    ll n,m,i,j=1,k,ii;
    cin>>n>>m>>k;
    ll a[k+1],ans[n+2][m+2];
    for(i=1;i<=k;i++)cin>>a[i];
    for(i=1;i<=n;i++)
    {
    	if(i%2)
    	{
    		for(ii=1;ii<=m;ii++)
        {
        	if(a[j]==0)j++;
        	ans[i][ii]=j;
        	a[j]--;
    	}
		}else
		{
			for(ii=m;ii>=1;ii--)
        {
        	if(a[j]==0)j++;
        	ans[i][ii]=j;
        	a[j]--;
    	}
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		cout<<ans[i][j]<<" ";
		cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm> 
using namespace std; 
int main(){ int n,max_num = -1000001,min_num = 1000001,tmp;
long long int sum = 0; 
scanf("%d",&n);
for(int i = 0;
i < n; i++){ scanf("%d",&tmp); 
sum += tmp;
max_num = max(max_num,tmp); 
min_num = min(min_num,tmp);
} 
printf("%d %d %lld\n",min_num,max_num,sum);

    
} 


Measured memory_bytes: 2756
#include<iostream>
using namespace std;
int main(){
    int a, b;
    char op;
    
    while(true){
        
        cin >> a >> op >> b;
        
        if(op == '?') {
            break;
        } else if (op == '+'){
            cout << a + b << endl;
        } else if (op == '-'){
            cout << a - b << endl;
        } else if (op == '*'){
            cout << a * b << endl;
        } else if (op == '/'){
            cout << a / b << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3080
N = int(input())
S = input()
r1 = [0] * N
r2 = [0] * (N+1)
r1[0] = 1 * (S[0] == '#')
for i in range(1, N):
    if S[i] == "#":
        r1[i] = r1[i - 1] + 1
    else:
        r1[i] = r1[i - 1]
#print(r1)
r2[N - 1] = 1 * (S[N - 1] == ".")
r2[N] = r2[N-1]
for i in range(N - 2, -1, -1):
    if S[i] == ".":
        r2[i] = r2[i + 1] + 1
    else:
        r2[i] = r2[i + 1]
#print(r2)
c1 = S.count("#")
c2 = S.count(".")
ans = N
for i in range(N):
    ans = min(ans, r1[i] + r2[i + 1])
print(min(ans, c1, c2))

Measured memory_bytes: 44512
#include<stdio.h>
#define MAX 100000
#define NIL -1
 
struct Node{ int p, l, r;};
 
struct Node T[MAX];
 
int n;
int a, D[MAX];
 
int getDepth(int);
void print(int);
 
 
 
int main(){
   
  int i, j;
  int d, v;
  int c, l;
 
   
  scanf("%d", &n);
 
   
  for ( i = 0; i < n; i++ ) {
     
    T[i].p = NIL;
    T[i].l = NIL;
    T[i].r = NIL;
     
  }
 
  for ( i = 0; i < n; i++ ){
     
    scanf("%d %d", &v, &d);
 
    for ( j = 0; j < d; j++ ){
       
      scanf("%d", &c);
       
      if ( j == 0 ) {
    T[v].l = c;
      }
      else{
    T[l].r = c;
      }
       
      l = c;
      T[c].p = v;
       
    }
  }
   
  a = 0;
   
  for ( i = 0; i < n; i++ ){
     
    D[i] = getDepth(i);
     
    if ( D[i] > a) {
      a= D[i];
    }
     
  }
 
  for ( i = 0; i < n; i++ ) {
    print(i);
  }
   
  return 0;
}
 
 
 
 
 
int getDepth(int u){
   
  int d = 0;
 
  for(d=0; T[u].p != NIL ;d++) {
    u = T[u].p;
  }
   
  return d;
}
 
void print(int u){
   
  int i, c;
   
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("depth = %d, ", D[u]);
 
  if ( T[u].p == NIL ) {
    printf("root, ");
  }
  else if ( T[u].l == NIL ) {
    printf("leaf, ");
  }
  else{
    printf("internal node, ");
  }
   
  printf("[");
   
  for(i = 0, c = T[u].l; c != NIL; i++, c = T[c].r){
 
    if (i) printf(", ");
 
    printf("%d", c);
 
  }
   
  printf("]\n");
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; ++i){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long sum = 0;
  int end = n-k;
  for(int i = 0; i < end; ++i){
    sum += a[i];
  }    
  cout << sum << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
using namespace std;
using ll = long long;
typedef pair <int, int> pii;
string s;
ll sum = 0;
int len = 0;
//void kansuu(int n, string t)
//{
//	if (n == len)
//	{
//		cout << stoll(t) << endl;
//
//		sum += stoll(t);
//		return;
//	}
//	sum += stoll(t);
//	cout << stoll(t) << endl;
//
//	kansuu(n + 1, t + s[n]);
//	sum += stoll(t);
//	cout << stoll(t) << endl;
//
//	t = s[n];
//	kansuu(n + 1, t);
//	return;
//}
void kansuu(int n, string t)
{
	if (n == len)
	{
		

		int z = 0;
		string u,v;
		//cout << stoll(t) << endl;
		while (1)
		{
			if (z==t.length()-1)
			{
				u += t[z];
				//cout << "last sum+=" << stoll(u) << endl;

				sum += stoll(u);
				return;
			}
			else if (t[z] == 'a')
			{
				//cout <<"sum+="<< stoll(u) << endl;

				sum += stoll(u);
				z++;
				u = v;
				/*u = t[z];
				z++;*/
			}
			else
			{
				u += t[z];
			z++;
			}
		}

		return;
	}
	/*sum += stoll(t);
	cout << stoll(t) << endl;
*/
	t += s[n];
	//t = "aaaaaaa";
	/*sum += stoll(t);
	cout << stoll(t) << endl;

	t = s[n];*/
	kansuu(n + 1, t);
	//t += "a";
	if (n!=s.length()-1)
	{

	t += "a";
	kansuu(n + 1, t);
	}
	return;
}
int main()
{

	//int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0, k = 0, l = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	ll n, m, q;
	//int   y[100001], z[100001], x[10001] = {};
	//pii y[100001];
	//pair<int, float> pii[100001];
	string x;
	cin >> s;
	//x = s[0];
	//x = '0';
	len = s.length();
	kansuu(0, x);






	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
//typedef long long int;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int main()
{
    string s;
    string ss[30];
    cin >> s;
    int k=0;

    for(int i=0;i < s.size();i++){
        if(s.size()-i >= 3){
            ss[k++] = s.substr(i,3);
            //cout << ss[k-1] << endl;
        }
    }
    int mini=9999;
    int kazu;
    for(int i=0;i < k;i++){
        kazu=0;
        for(int j=0;j < 3;j++){
            kazu += ss[i][j]-'0';
            if(j == 2) break;
            kazu *= 10;
        }
        mini = min(abs(753-kazu), mini);
    }
    cout << mini << endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = Array.new(N).map{Array.new(3)}
res = 0
N.times do |i|
    B[i]=[A[i]-1,A[i],A[i]+1]
end
[0,1,2].repeated_permutation(N).to_a.each do |z|
    z.each_with_index do |j,i|
        if B[i][j].even?
            res+=1
            break
        end
    end
end
puts res

Measured memory_bytes: 11516
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

char S[MAXN];
char T[MAXN];
int last[MAXN];
int nxt[MAXN][30];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;

    cin>>S;
    cin>>T;

    n = strlen(S);

    for(int i=0;i<n;i++)
        S[i+n] = S[i];

    for(int i=0;i<26;i++)last[i] = INF;

    for(int i=2*n-1;i>=n;i--){
        cur = S[i]-'a';
        last[cur] = i;
    }

    for(int i=n-1;i>=0;i--){
        cur = S[i]-'a';
        for(int j=0;j<26;j++){
            nxt[i][j] = last[j]-i;
        }
        last[cur] = i;
    }

    m = strlen(T);

    for(int i=0;i<n;i++){
        if(S[i]==T[0]){idx = i; break;}
    }

    if(idx==-1){
        cout<<"-1\n"; return 0;
    }

    ll res = idx+1;
    ll dis;
    int nt;

    for(int i=0;i<m-1;i++){
        nt = T[i+1]-'a';
        dis = nxt[idx][nt];
        if(dis>n){
            cout<<"-1\n"; return 0;
        }
        res+=(ll)dis;
        idx+=nxt[idx][nt];
        idx%=n;
    }

    cout<<res<<"\n";

    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
bool compare_by(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second > b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    COMint();
    int P;
    int Q;
    int a=0;
    int b=0;
    bool p[N]={};
    bool q[N]={};
    int cnt;
    REP(i,N){
        cin>>P;
        p[P-1]=true;
        cnt=0;
        REP(j,P-1){
            if(!p[j])cnt++;
        }
        a+=cnt*fac[N-i-1];
    }
    
    REP(i,N){
        cin>>Q;
        q[Q-1]=true;
        cnt=0;
        REP(j,Q-1){
            if(!q[j])cnt++;
        }
        b+=cnt*fac[N-i-1];
    }
    cout<<abs(a-b)<<endl;
    return 0;
}


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

bool canMake(int a, int b, int c){
	int sentence[] = {a,b,c};
	int five = 0, seven = 0;
	for (size_t i = 0; i < 3; i++) {
		if (sentence[i] == 5)
			five++;
		else if (sentence[i] == 7)
			seven++;
	}
	return five == 2 && seven == 1;
}
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (canMake(a,b,c))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))

D = defaultdict(int)
for a in A:
    D[a] += 1

ans_base = 0
for v in D.values():
    ans_base += v * (v - 1) // 2

for a in A:
    print(ans_base - (D[a] * (D[a] - 1) // 2) + ((D[a] - 1) * (D[a] - 2) // 2))


Measured memory_bytes: 26772
import java.util.*;
import java.io.*;
public class Main {
    public static long dp[][][];
    public static long solve(long arr[] , int i , int j , int turn){
        if(i > j){
            return 0;
        }
        if(dp[i][j][turn] != -1){
            return dp[i][j][turn];
        }

        if(turn == 1){
            long ans = arr[i] + solve(arr , i+1 , j , 2);
            ans = Math.max(ans , arr[j] + solve(arr , i , j-1 , 2));
            return dp[i][j][turn] = ans;
        }else {
            long ans = solve(arr , i+1 , j , 1);
            ans = Math.min(ans , solve(arr , i , j-1 , 1));
            return dp[i][j][turn] = ans;
        }
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        long arr[] = new long[n+1];
        dp = new long[n+1][n+1][3];
        for(int i = 0 ; i <= n ; i++){
            for(int j = 0 ; j <= n ; j++){
                for(int k = 0 ; k <= 2 ; k++){
                    dp[i][j][k] = -1;
                }
            }
        }
        long sum = 0;
        for(int i = 1 ; i <= n ; i++){
            arr[i] = s.nextLong();
            sum += arr[i];
        }
        long first = solve(arr , 1 , n , 1);
        long second = sum - first;
        System.out.println(first - second);
    }
}

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

void testcase(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cout << "ACL";
}


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int q=1;
   // cin >> q;
    while(q--){
    testcase();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    ll N,M,K;
    cin >> N >> M >> K;
    if(M - N + 1 <= K * 2){
        for(ll i = N;i<=M;i++)cout << i << endl;
    }
    else {
        rep(i,K){
        cout << i + N << endl;
    }
    rep(i,K){
        cout << M - K + 1 + i << endl;
    }
    }
}


Measured memory_bytes: 256
require 'pp'
s = gets.chomp
c = s.chars
all = "abcdefghijklmnopqrstuvwxyz".chars
rest = all - c


if rest.size > 0
  puts s + rest[0]
else
  buf = []
  loop do
    d = c.pop
    buf << d
    buf.sort!

    break if c.size == 0

    if c.last < buf.last
      t = buf[0]
      buf.each do |e|
        if c.last < e
          t = e
          break
        end
      end
      c[-1] = t
      break
    end
  end
  if c.size == 0
    puts -1
  else
    puts c.join
  end
end


Measured memory_bytes: 2172
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int X;

void check(int s,int num){
	if(s<=X&&X<=s+199){
		cout<<num<<endl;
		exit(0);
	}
}

signed main(){
	cin>>X;
	check(400,8);
	check(600,7);
	check(800,6);
	check(1000,5);
	check(1200,4);
	check(1400,3);
	check(1600,2);
	check(1800,1);
	return 0;
}


Measured memory_bytes: 3620