akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

#define int long long

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = 1e18;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();



int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  
  int a,b;
  cin >> a >> b;
  int g = __gcd(a,b);
  set<int>primes;  
  for(int i = 2; i*i <= g; i++) {
    if(g % i == 0) {
      primes.insert(i);
      while(g % i == 0 and g  > 1)g/=i;
    }
  }
  if(g != 1)primes.insert(g);
  cout << sz(primes) + 1;
  
  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
  
  return 0;
}

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


int main(void){
	ll w, h, x, y;
  cin >> w >> h >> x >> y;
  double s = (double)((w * h)/ 2.0);
  cout << fixed << setprecision(10) << s<< " ";
  int a = 0;
  if(2*x == w && 2*y == h) a = 1;
  cout << a;
  
}


Measured memory_bytes: 3780
#include <iostream>
#include <string>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	string s; cin >> s;

	rep(i, 0, s.size() - 1) {
		if (s[i] == s[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
		else if (i != s.size() - 1 && s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ti = tuple<int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl;


int main() {
    IN(int, n);
    vector<tuple<string, int,int>> a(n);
    string k;
    int l,m;
    REP(i, n){
        cin >> k >> l;
        a[i] = make_tuple(k,-1*l,i);
    }
    sort(ALL(a));
    REP(i, n){
        tie(ignore,ignore,m) = a[i];
        COUT(m+1);
        
    }
    return 0;
}


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

using namespace std;

int main()
{
  string sd, t;
  cin >> sd >> t;
  
  if(count(sd.begin(), sd.end(), '?')==sd.length()){
    if(sd.length() >= t.length()){
	    for(int i=0; i<sd.length() - t.length(); i++)
          sd[i] = 'a';
        for(int i=0; i<t.length(); i++)
          sd[sd.length() - t.length() + i] = t[i];
        cout << sd << endl;
 	}
    else
	  cout << "UNRESTORABLE" << endl;
    return 0;
  }
  
  int sd1=-1;
  int tlen = t.length();
  for(int j=sd.length() - tlen; j>=0; j--){
    int i;
  	for(i=0; i<tlen; i++){
      //cout << t[i] << " " << sd[j+i] << endl;
      if(t[i]!=sd[j+i] && '?'!=sd[j+i]){
        break;
      }
    }
    if(i==tlen){
      sd1=j;
      break;
    }
  }
  if(sd1!=-1){
    for(int i=0; i< sd1; i++){
      if(sd[i]=='?') sd[i] = 'a';
    }
  	for(int i=0; i<t.length(); i++)
      sd[sd1+i] = t[i];
    for(int i=sd1+t.length(); i<sd.length(); i++){
      if(sd[i]=='?') sd[i] = 'a';
    }
    cout << sd << endl;
  }
  else
	  cout << "UNRESTORABLE" << endl;
  
  return 0;
}

Measured memory_bytes: 256
X, K, D = map(int, input().split())
if D>= max(X, -X):
    if K%2 == 0:
        ans = max(X, -X)
    else:
        ans = max(X-D, D-X)
elif K<((max(X, -X))//D):
    ans = max(X, -X)-(D * K)
else:
    N = (max(X, -X))//D
    if (K-N)%2 == 0:
        ans = max(X, -X)-(D * N)
    else:
        ans = -(max(X, -X)-(D * (N+1)))
print(ans)

Measured memory_bytes: 61616
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		scanner.nextLine();
		long[] As = Arrays.stream(scanner.nextLine().split(" ")).mapToLong(Long::parseLong).toArray();
		Arrays.sort(As);
		if(As[0] == 0) {
			System.out.println(0);
			return;
		}
		long result = 1L;
		long threshold = (long)Math.pow(10, 18);
		for(int i = As.length - 1; i >= 0; i--) {
			if(threshold / As[i] < result ) {
				System.out.println(-1);
				return;
			}
			result *= As[i];
		}
		System.out.println(result);
	}
}


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

int main() {
    int count = 0;
    int N = 0;
    int* A;
    int evenflag = 1;
    
    cin >> N;
    A = new int[N]; //キーボードから入力したN個分のメモリを確保

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

    while(evenflag == 1){
        for (int j = 0; j < N; j++) {
            if ((A[j] % 2) == 0) {
                A[j] /= 2;
            }
            else {
                evenflag = 0;
                break;
            }
            if (j == N - 1) {
                ++count;
            }
        }
    }

    delete[] A;
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

bool check(ll n){
  bool no3,no5,no7;
  no3 = no5 = no7 = false;
  while(n){
    if(n%10 == 3)no3 = true;
    if(n%10 == 5)no5 = true;
    if(n%10 == 7)no7 = true;
    n/=10;
  }
  return no3&&no5&&no7;
}

void dfs(ll &m,ll n,int &ans){
  if(n > m)return;
  if(check(n))ans++;
  dfs(m,n*10+3ll,ans);
  dfs(m,n*10+5ll,ans);
  dfs(m,n*10+7ll,ans);
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n;cin>>n;
  int ans = 0;
  dfs(n,0,ans);
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <stack>
#include <sstream>
#include <string>
#include <list>

typedef std::list<std::string> TList;
TList SplitString(std::string S)
{
    TList List;
    std::istringstream Input(S);
    std::string s;
    while(getline(Input, s, ' ')){
        List.push_back(s);
    }
    return List;
}
TList GetInputStrings(std::istream& Input)
{
    TList List;
    std::string Line;
    std::getline(Input, Line);
    return SplitString(Line);
}
int Rpn(const TList& List)
{
    std::stack<int> Stack;
    for(TList::const_iterator It = List.begin();
        It != List.end();
        ++It)
    {
        switch((*It)[0]){
        case '+':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b + a);
            break;
        }
        case '-':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b - a);
            break;
        }
        case '*':{
            int a = Stack.top(); Stack.pop();
            int b = Stack.top(); Stack.pop();
            Stack.push(b * a);
            break;
        }
        default:{
            Stack.push(std::atoi(It->c_str()));
            break;
        }
    }
    }
    return Stack.top();
}
int main()
{
    TList List = GetInputStrings(std::cin);
    std::cout << Rpn(List) << std::endl;
    return 0;
}

Measured memory_bytes: 1220
<?php

fscanf(STDIN, "%d", $n);

$arr = [];
for ($i = 0; $i < $n; ++$i) {
    $input = trim(fgets(STDIN));

    if (!isset($arr[$input])) {
        $arr[$input] = 1;
    } else {
        ++$arr[$input];
    }
}

$max = max($arr);

$arr2 = [];
foreach ($arr as $input => $count) {
    $arr2[$count][] = $input;
}

$res = $arr2[$max];
sort($res);
foreach ($res as $str) {
    echo $str, PHP_EOL;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  for(int i = 0; i < 3*N; i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int64_t sum = 0;
  for(int i = 0; i < 2*N; i++){
    if(i % 2 == 1) sum+= a.at(i);
  }
  cout << sum << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
struct UnionFind {
    int *par;
    int *rank;
    UnionFind(int n) {
        par=new int[n];
        rank=new int[n];
        for(int i=0;i<n;i++) {
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x) {
        if(par[x]==x) {
            return x;
        }else {
            return par[x]=find(par[x]);
        }
    }
    void unite(int x,int y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) {
            par[x]=y;
        }else {
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x,int y) {
        return find(x)==find(y);
    }
};
int ans[100000];
int main() {
    int n,q;
    scanf("%d %d",&n,&q);
    UnionFind U(n);
    int k=0;
    for(int i=0;i<q;i++) {
        int com,x,y;
        scanf("%d %d %d",&com,&x,&y);
        if(com==0) {
            U.unite(x,y);
        }else {
            ans[k++]=U.same(x,y);
        }
    }
    for(int i=0;i<k;i++) {
        printf("%d\n",ans[i]);
    }
}

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

using namespace std;
typedef long long ll;


int main()
{
    int x, n;
    cin >> x >> n;
    set<int> st;
    for (int i = 0, p; i < n; i++) {
        cin >> p;
        st.insert(p);
    }

    int l = x, h = x;
    for (int i = 0; ; i++) {
        if (!st.count(l-i)) {
            cout << l-i;
            break;
        }
        else if (!st.count(h+i)) {
            cout << h+i;
            break;
        }
    }

    return 0;
}


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

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

int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = 0;
        for(int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return;
}

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


Measured memory_bytes: 3712
#include <iostream>
#include<vector>
#define mod 1000000007
using namespace std;
int helper(vector<vector<int>> &arr,vector<vector<int>> &dp,int i,int j,int n,int m)
{
    if(i>=n||j>=m||arr[i][j]==0)
     return 0;

    if(i==n-1&&j==m-1)
     return 1; 

    if(dp[i][j]!=-1)
     return dp[i][j];

    int ans1=0,ans2=0;

    ans1=helper(arr,dp,i,j+1,n,m)%mod;
    ans2=helper(arr,dp,i+1,j,n,m)%mod;
    dp[i][j]=ans1+ans2;
    return dp[i][j]%mod;
}
int main() {
    
    int n,m;
    cin>>n>>m;

    vector<vector<int>> arr(n,vector<int>(m,0)), dp(n,vector<int>(m,-1));

    for(int i=0;i<n;i++)
     {
         for(int j=0;j<m;j++)
            {
                char ch;
                cin>>ch;
                if(ch=='.')
                 arr[i][j]=1;
            }
     }
    int ans=helper(arr,dp,0,0,n,m)%mod;  
    cout<<ans%mod;
}


Measured memory_bytes: 8320
n = int(input())
inputlist = list(map(int, input().split()))
count = 0
isZero = 0
minabs = float("inf")
abslist = []

for i in range(n):
  ith = inputlist[i]
  if ith == 0:
    isZero = 1
  if ith < 0:
    count += 1
  if abs(ith) < minabs:
    minabs = abs(ith)
  abslist.append(abs(ith))
  
ans = 0
if count % 2 == 0 or isZero == 1:
  for j in range(n):
    ans += abslist[j]
  print(ans)
else:
  for k in range(n):
    ans += abslist[k]
  ans -= 2 * minabs
  print(ans)

Measured memory_bytes: 14496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
using namespace std;
int dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num[5], k;
    rep(i, 5) { cin >> num[i]; }
    cin >> k;
    rep(i, 5) {
        rep(j, 5) {
        if (num[i] - num[j] > k) {
            puts(":(");
            return 0;
        }
        }
    }

    puts("Yay!");
    return 0;
}

Measured memory_bytes: 256
# 20/05/10 cost:20min

def is_valid(num):
    if 1 <= num < 10:
        return True
    ns = map(int, str(num))
    n = len(ns)
    for i in xrange(n - 1):
        if abs(ns[i] - ns[i + 1]) > 1:
            return False
    return True

lunluns = []
for i in xrange(1, 10):
    if is_valid(i):
        lunluns.append(i)

d = {}

def dfs2(rem, pre, lt):
    if rem == 0:
        return 1
    key = (rem, pre, lt)
    if key in d:
        return d[key]

    res = 0
    if lt:
        for i in xrange(10):
            res += dfs2(rem - 1, i, lt and i == 0)
    else:
        for i in xrange(10):
            if abs(i - pre) <= 1:
                res += dfs2(rem - 1, i, False)
    d[key] = res
    return res

assert dfs2(1, -1, True) == 10
assert dfs2(1, 1, False) == 3

def dfs(cur, n, k, pre, lt, buf):
    if cur == n:
        return k == 1

    for i in xrange(10):
        if lt or abs(i - pre) <= 1:
            u = dfs2(n - cur - 1, i, lt and i == 0)
            if u < k:
                k -= u
            else:
                buf.append(i)
                assert dfs(cur + 1, n, k, i, lt and i == 0, buf)
                break
    return True

def solve(k):
    N = 500
    res = []
    assert dfs(0, N, k, -1, True, res)
    res = res[::-1]
    while res and res[-1] == 0:
        res.pop()
    if not res:
        res = [0]
    return ''.join(map(str, res[::-1]))

assert solve(3) == '2'
assert solve(1) == '0'
assert solve(2) == '1'
assert solve(4) == '3'

for i, num in enumerate(lunluns):
    assert solve(i + 2) == str(num)

if __name__ == '__main__':
    k = int(raw_input())
    k += 1
    print solve(k)


Measured memory_bytes: 4868
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
//#include <unordered_set>

using namespace std;

#define int long long

//sqrtN -> 最大値のみに対応できればいいので，それを使う
const int sqrtN = 512;
struct SqrtDecomposition {
  int N, K;
  vector<int> data;
  vector<int> bucketData;
  vector<int> bucketMin;
  const int INIT_VALUE = 2147483647;
  
  SqrtDecomposition(int n) : N(n) {
    //分割数
    K = (N + sqrtN - 1) / sqrtN;
    data.assign(K * sqrtN, INIT_VALUE);
    bucketData.assign(K, -1);
    bucketMin.assign(K, INIT_VALUE);
  }
  //ここまで共通
  
  void eval(int k) {
    //バケツを分配
    int l = k * sqrtN;
    int r = (k + 1) * sqrtN;
    if(bucketData[k] != -1) {
      for(int i = l; i < r; ++i) {
        data[i] = bucketData[k];
      }
      bucketData[k] = -1;
    }
  }
  void update(int s, int t, int x) {
    for(int k = 0; k < K; ++k) {
      //各バケツをループ
      int l = k * sqrtN;
      int r = (k + 1) * sqrtN;
      if(s >= r || t <= l) continue;
      if(l >= s && t >= r) {
        //完全に区間内
        bucketData[k] = x;
        bucketMin[k] = x;
      } else {
        eval(k);
        
        for(int i = max(s, l); i < min(t, r); ++i) {
          data[i] = x;
        }
        
        int smin = INIT_VALUE;
        for(int i = l; i < r; ++i) {
          smin = min(smin, data[i]);
        }
        bucketMin[k] = smin;
      }
    }
  }
  
  int find(int s, int t) {
    int minval = INIT_VALUE;
    for(int k = 0; k < K; ++k) {
      int l = k * sqrtN;
      int r = (k + 1) * sqrtN;
      if(r <= s || l >= t) continue;
      if(r <= t && l >= s) {
        minval = min(minval, bucketMin[k]);
      } else {
        eval(k);
        for(int i = max(s, l); i < min(t, r); ++i) {
          minval = min(minval, data[i]);
        }
      }
    }
    return minval;
  }
};

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int n, q;
  cin >> n >> q;
  
  SqrtDecomposition sq(n);
  
  for(int i = 0; i < q; i++) {
    int qtype;
    cin >> qtype;
    if(qtype == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      ++t;
      sq.update(s, t, x);
    } else {
      int s, t;
      cin >> s >> t;
      ++t;
      cout << sq.find(s, t) << endl;
    }
  }  

}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
      Scanner scan = new Scanner(System.in);
      int inputStr = scan.nextInt();//ここでコンソールに入力したものを取得
      // System.out.println("Hello World!");
      int money = 0;
      int otsuri = 0;
      for(int i=1; i<=10; i++){
        money = 1000*i;
        if(money-inputStr >= 0){
           otsuri = money-inputStr;
           break;
        }
      }
      System.out.println(otsuri);
    }
  
}

Measured memory_bytes: 35528
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;

ll N;
map<ll,int>mp;
int res;
int main(){
	cin>>N;
	for(ll i=2;i*i<=N;i++){
		while(N%i==0){
			N/=i;
			mp[i]++;
		}
	}
	if(N!=1)mp[N]++;
	for(pair<ll,int>p:mp){
		for(int i=1;i<=p.second;i++){
			res++;
			p.second-=i;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define LL long long
using namespace std;
inline int read()
{
	int ret = 0; char ch = getchar();
	while(ch < '0' || ch > '9')
		ch = getchar();
	do {
		ret = ret * 10 + ch - '0';
		ch = getchar();
	} while('0' <= ch && ch <= '9');
	return ret;
}
inline void write(int x) // x > 0 (x != 0) ***
{
	if(!x)
		return ;
	write(x / 10);
	putchar(x % 10 + '0');
}
#define maxn 100100
int n;
int a[maxn];
int b[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; i ++)
		cin >> a[i];
	sort(a, a + n);
	int d = (n - 1) / 2;
	b[0] = a[d];
	for(int i = 1; i < n; i ++)
	{
		if(i & 1)
			b[i] = a[n - i / 2 - 1];
		else
			b[i] = a[i / 2 - 1];
	}
//	for(int i = 0; i < n; i ++)
//		cout << b[i] << ' ';
//	cout << endl;
	LL Ans = 0;
	for(int i = 1; i < n; i ++)
		Ans += fabs(b[i] - b[i - 1]);
	if(n & 1)
	{
		LL res = 0;
		for(int i = 1; i < n; i ++)
		{
			if(i & 1)
				b[i] = a[i / 2];
			else
				b[i] = a[n - i / 2];
		}
		for(int i = 1; i < n; i ++)
			res += fabs(b[i] - b[i - 1]);
		Ans = max(Ans, res);
	}
	cout << Ans << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static void Main()
    {
        String[] temp =Console.ReadLine().Split();
        int N = int.Parse(temp[0]);
        int M = int.Parse(temp[1]);
        Console.WriteLine(N * (N - 1)/2 + M * (M - 1)/2);
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
int main()
{
    ll m=0,n,c=0,x,t;
    string s;
    cin>>s;
    for(int i = 0;i < s.size();i++)
    {
        c += s[i]-'0';
    }

        //c += (((s[t-3]-'0')*10)+s[t-2]-'0')*10+s[t-1]-'0';
        if(c%9==0)
        {
            cout<<"Yes\n";
        }
        else
        {
            cout<<"No\n";
        }

}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  string S,T;
  int A,B;
  string U;
  cin>>S>>T>>A>>B>>U;
  if(U==S)A--;
  if(U==T)B--;
  cout<<A<<" "<<B<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long int
int main() {

    ll x,y,z,c=0;
    cin>>x>>y>>z;
    x-=z;
    while(x>=y+z)
    {
        x=x-y-z;
        c++;
    }
    cout<<c;
	return 0;
}

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

int main(){
int n,m,a[100][100],b[100],c[100];

cin >>n >>m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin >>a[i][j];
}
}
for (int j=0;j<m;j++){
cin >>b[j];
}
for(int i=0;i<n;i++){
c[i]=0;
for(int j=0;j<m;j++){
c[i]+=a[i][j]*b[j];
}
}
for(int i=0;i<n;i++){
cout <<c[i] <<endl;
}
return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    if(S.at(K - 1) == 'A') S.at(K - 1) = 'a';
    else if(S.at(K - 1) == 'B') S.at(K - 1) = 'b';
    else if(S.at(K - 1) == 'C') S.at(K - 1) = 'c';

    cout << S << endl; 
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

LL N;
LL ans;

void solve(LL i) {
    if (i == 1) return;
    LL m = N;
    while (m % i == 0) m /= i;
    if (m % i == 1) {
	ans++;
    }
}

void MAIN() {
    scanf("%lld", &N);

    for (LL i=1; i*i<=N-1; i++) if ((N-1) % i == 0) {
	if (i != 1) {
	    ans++;
	}
	if (i*i < N-1) {
	    ans++;
	}
    }

    for (LL i=1; i*i<=N; i++) if (N%i == 0) {
	solve(i);
	if (i*i < N) solve(N/i);
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
void game(int cont,int life,int attack,int partidas)
{
  if(cont >= life)
  {
    printf("%d",partidas);
    return;
  }
  else if(cont < life)
  {
    cont = cont + attack;
    partidas = partidas + 1;
    game(cont,life,attack,partidas);
  }
}
int main(void)
{
  int life,attack;
  scanf("%d %d",&life,&attack);
  game(0,life,attack,0);
}


Measured memory_bytes: 128
import sys
from collections import deque


def main():
    n, m, k = map(int, input().split(" "))
    friends = [set() for _ in range(n)]
    blocks = [set() for _ in range(n)]
    count = [0] * n
    for _ in range(m):
        i, j = map(int, sys.stdin.readline().strip().split(" "))
        friends[i - 1].add(j)
        friends[j - 1].add(i)
        count[i - 1] += 1
        count[j - 1] += 1
    for _ in range(k):
        i, j = map(int, sys.stdin.readline().strip().split(" "))
        blocks[i - 1].add(j)
        blocks[j - 1].add(i)
    cluster_size = [-1] * n
    for i in range(n):
        if cluster_size[i] != -1:
            continue
        stack = deque()
        stack.append(friends[i])
        space = {i + 1}
        while len(stack) > 0:
            s = stack.pop()
            for v in s:
                if v not in space:
                    space.add(v)
                    stack.append(friends[v - 1])
        size = len(space)
        for v in space:
            block_in_cluster = len(space & blocks[v - 1])
            cluster_size[v - 1] = size - block_in_cluster
    ans = []
    for i in range(n):
        ans.append(str(cluster_size[i] - 1 - count[i]))
    print(" ".join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 81764
// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_5-C: Koch Curve

#include <cstdio>
#include <cmath>

struct point {
  const double x_, y_;
  point(double x, double y) : x_(x), y_(y) { }
  static double sin60, cos60;
  point rotate_m60() const;
};
point operator +(const point& p, const point& q) { return point(p.x_+q.x_, p.y_+q.y_); }
point operator -(const point& p, const point& q) { return point(p.x_-q.x_, p.y_-q.y_); }
point operator /(const point& p, const double d) { return point(p.x_/d, p.y_/d); }
point operator *(const point& p, const double m) { return point(p.x_*m, p.y_*m); }
point operator *(const double m, const point& p) { return operator*(p, m); }
double point::sin60 = std::sin(M_PI*60.0/180.0);
double point::cos60 = std::cos(M_PI*60.0/180.0);
point point::rotate_m60() const {
  return point(x_*cos60 - y_*sin60,
               x_*sin60 + y_*cos60);
}
void print_point(const point& p) { std::printf("%.8f %.8f\n", p.x_, p.y_); }

void print_koch(unsigned int n, const point& p1, const point& p2) {
  if (n == 0) return;
  point s = (2*p1 + p2)/3;
  point t = (p1 + 2*p2)/3;
  point u = (t-s).rotate_m60() + s;

  print_koch(n-1, p1, s);
  print_point(s);
  print_koch(n-1, s, u);
  print_point(u);
  print_koch(n-1, u, t);
  print_point(t);
  print_koch(n-1, t, p2);
}

int main(void) {
  unsigned int n;
  std::scanf("%d", &n);

  point p1 = point(0.0, 0.0);
  point p2 = point(100.0, 0.0);

  print_point(p1);
  print_koch(n, p1, p2);
  print_point(p2);

  return 0;
}

// end

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> a(3 * n);
  for(int i = 0; i < 3 * n; i++) cin >> a[i];
  long long ans = -(1ll<<60);
  vector<long long> ma(3 * n);
  vector<long long> mi(2 * n + 1);
  {
    multiset<int> inb;
    long long sum = 0;
    for(int i = 2 * n; i < 3 * n; i++){
      inb.insert(a[i]);
      sum += a[i];
    }
    mi[2 * n] = sum;
    for(int i = 2 * n - 1; i >= 0; i--){
      inb.insert(a[i]); sum += a[i];
      sum -= *(--inb.end()); inb.erase(--inb.end());
      mi[i] = min(mi[i + 1], sum);
    }
    long long rsum = 0;
    multiset<pair<int,int> > by_v, by_p;
    for(int i = 2 * n - 1; i >= 0; i--){
      by_v.insert({a[i], i});
      by_p.insert({i, a[i]});
      rsum += a[i];
      if(i < n){
        auto worst = *by_v.begin(); by_v.erase(by_v.begin());
        rsum -= worst.first;
        by_p.erase({worst.second, worst.first});
      }
      if(i <= n){
        auto it = *(--by_p.end());
        ans = max(ans, rsum - mi[it.first + 1]);
      }
    }
  }
  {
    multiset<int> ina;
    long long sum = 0;
    for(int i = 0; i < n; i++){
      sum += a[i];
      ina.insert(a[i]);
    }
    ma[n - 1] = sum;
    for(int i = n; i < 3 * n; i++){
      ina.insert(a[i]); sum += a[i];
      sum -= *ina.begin(); ina.erase(ina.begin());
      ma[i] = max(sum, ma[i - 1]);
    }
    long long rsum = 0;
    multiset<pair<int,int> > by_p, by_v;
    for(int i = n; i < 3 * n; i++){
      by_v.insert({a[i], i});
      by_p.insert({i, a[i]});
      rsum += a[i];
      if(i >= 2 * n){
      	auto worst = *(--by_v.end()); by_v.erase(--by_v.end());
        rsum -= worst.first;
        by_p.erase({worst.second, worst.first});
      }
      if(i >= 2 * n - 1){
      	auto it = *by_p.begin();
        ans = max(ans, ma[it.first - 1] - rsum);
      }
    }
  }
  for(int i = n - 1; i < 2 * n; i++) ans = max(ans, ma[i] - mi[i + 1]);
  cout << ans << endl;
  return 0;
}
    


Measured memory_bytes: 19328
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
using namespace std;

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;}


const long long INF = 1LL << 60;
long long c[30][10010];
long long dp[30][10010];


//bucket1
// bool ch[10] = {0};
// bool check(int n){
//     while(n!=0){
//         if(ch[n%10]) return false;
//         n /= 10;
//     }
//     return true;
// }



// --------write my code!!!!!----------//

int main(){
    int begin = -1;
    int en = -1;
    string s; cin >> s;
    for(int i=0; i<s.length(); ++i){
        if(s[i]==s[i+1]){
            begin = i+1;
            en = i+2;
        }
        if(s[i]==s[i+2]){
            begin = i+1;
            en = i+3;
        }
    }
    cout << begin << " " << en << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b;
    cin>>a>>b;
    int i=0,j=0;
    int n=a.length();
    int m=b.length();
    while(i<n && j<m)
    {
        if(a[i]!=b[j])
        {
            cout<<"No";
            return 0;
        }
        i++;
        j++;
    }
     if(m==n+1)
        cout<<"Yes";
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll n;
    cin >> n;
    vector<ll> p(n);
    REP(i, n) cin >> p[i];
    ll res = 0;
    REP(i, n-2){
    	if(p[i] < p[i+1] && p[i+1] < p[i+2]) res++;
    	if(p[i] > p[i+1] && p[i+1] > p[i+2]) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll N, K; cin >> N >> K;
    ll ans = N / K;
    ans = ans * ans * ans;
    if(K % 2 == 1) {
        cout << ans << endl;
    } else {
        ll res = (N + K / 2) / K;
        res = res * res * res;
        cout << ans + res << endl;
    }                                                                                                             
	return 0;
}

Measured memory_bytes: 256
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
ans_1=0
ans_2=0
for i in range(x):
    if i in a:
        ans_1+=1
for i in range(x,n):
    if i in a:
        ans_2+=1
print(min(ans_1,ans_2))

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

/*int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    while (n >= 3) {
        n -= 3;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}*/

/*int main() {
    int n;
    scanf("%d", &n);
    bool three = 1;
    for (int i = 0 ; i < n; i++) {
        char c;
        scanf("%*c%c", &c);
        if (c == 'Y') three = 0;
    }
    if (three) printf("Three\n");
    else printf("Four\n");
}*/

/*typedef pair<int, int> ii;

int sq[305][305], ii pos[305 * 305];

int main() {
    int h, w, d;
    scanf("%d %d %d", &h, &w, &d);
    for (int i = 0; i < h; i++ ){
        for (int j = 0; j < w; j++) {
            int val;
            scanf("%d", &val);
            sq[i][j] = val;
        }
    }
}*/

long long memo[100005][3][1 << 4];

int charmap[255];

vector<char> v;

int n, s = 0;
long long solve(int i, int taken, int mask) {
    if (taken == 3) return 1;
    if (i == s) return 0;
    if (memo[i][taken][mask] != -1) return memo[i][taken][mask];
    long long ans = 0;
    if (!(mask & (1 << charmap[v[i]]))) {
        ans += solve(i + 1, taken + 1, mask | (1 << charmap[v[i]]));
    }
    ans += solve(i + 1, taken, mask);
    return memo[i][taken][mask] = ans;
}

int main() {
    charmap['M'] = 0;
    charmap['A'] = 1;
    charmap['R'] = 2;
    charmap['C'] = 3;
    charmap['H'] = 4;
    scanf("%d", &n);
    char name[15];
    memset(memo, -1LL, sizeof memo);
    fgets(name, 15, stdin);
    for (int i = 0; i < n; i++) {
        char name[15];
        fgets(name, 15, stdin);
        if (name[0] == 'M' || name[0] == 'A' || name[0] == 'R' || name[0] == 'C' || name[0] == 'H') {
            s++;
            v.push_back(name[0]);
        }
    }
    //printf("%d", s);
    long long ans = solve(0, 0, 0);
    printf("%lld\n", s == 0 ? 0 : ans);
}

Measured memory_bytes: 42624
def fill(X, c, start):
    for i in range(X):
        q, r = divmod(i, 49)
        i = q * 2 + start
        j = r * 2 + 1 if q % 2 else r * 2 + 2
        ans[i][j] = c


A, B = map(int, input().split())
H, W = 100, 100
ans = [list("#" * W) if i < W // 2 else list("." * W) for i in range(H)]
fill(A - 1, ".", 1)
fill(B - 1, "#", H // 2 + 1)
print(H, W)
[print("".join(row)) for row in ans]


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

ll X,Y,A,B,C;
vector<ll> p;
vector<ll> q;
vector<ll> r;

int main(){
    p.resize(100010);
    q.resize(100010);
    r.resize(100010);
    cin >> X >> Y >> A >> B >> C;
    for(int i=0;i<A;i++) cin >> p[i];
    for(int i=0;i<B;i++) cin >> q[i];
    for(int i=0;i<C;i++) cin >> r[i];
    sort(p.begin(),p.end(),greater<ll>());
    sort(q.begin(),q.end(),greater<ll>());
    sort(r.begin(),r.end(),greater<ll>());
    int ap = X-1;
    int bp = Y-1;
    int cp = 0;
    while(true){
        if(ap < 0 && bp < 0) break;
        if(cp >= C) break;
        if(ap < 0){
            if(q[bp] >= r[cp]) break;
            bp--;
            cp++;
            continue;
        }
        if(bp < 0){
            if(p[ap] >= r[cp]) break;
            ap--;
            cp++;
            continue;
        }
        if(p[ap] < q[bp]){
            if(p[ap] >= r[cp]) break;
            ap--;
            cp++;
        }else{
            if(q[bp] >= r[cp]) break;
            bp--;
            cp++;
        }
    }
    ll sum = 0;
    for(int i=0;i<=ap;i++) sum += p[i];
    for(int i=0;i<=bp;i++) sum += q[i];
    for(int i=0;i<cp;i++) sum += r[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
ll kai[2000001];
ll gyaku[2000001];
ll kuri2(ll x,ll a)
{
	ll ret=1;
	ll tmp=x;
	while(a>0)
	{
		if(a&1)
		{
			ret*=tmp;
			ret%=MOD;
		}
		a>>=1;
		tmp*=tmp;
		tmp%=MOD;
	}
	if(ret<0)
		ret+=MOD;
	return ret;
}
int main()
{
	int x,y;
	int p,m,a,b;
	ll ans=0;
	cin>>x>>y;
	kai[0]=1;
	gyaku[0]=kuri2(kai[0],MOD-2);
	for(ll i=1;i<2000001;i++)
	{
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		if(kai[i]<0)
			kai[i]+=MOD;
		gyaku[i]=kuri2(kai[i],MOD-2);
	}
	if((x+y)%3!=0)
	{
		cout<<0<<endl;
		return 0;
	}
	p=(x+y)/3;
	m=x-y;
	a=(p+m)/2;
	b=(p-m)/2;
	if(!(a+b==p && a>=0 && b>=0))
	{
		cout<<0<<endl;
		return 0;
	}
	ans=kai[p]*gyaku[a];
	ans%=MOD;
	ans*=gyaku[p-a];
	ans%=MOD;
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

bool check_digit(int n)
{
    while(n)
    {
	int digit=n%10;
	if(digit==7)
	 return true;
	n=n/10;
    }
    return false;
}

int main()
{
    int n;
    cin>>n;
    (check_digit(n))?cout<<"Yes\n":cout<<"No\n";
}


Measured memory_bytes: 3596
#include <list>
#include <algorithm>
#include <iostream>
 
using namespace std;
 
int main(){
    int n;
    list<int> data;
    string word;
    int suu;
    list<int>::iterator p;
 
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>word;
        if(word=="deleteFirst"){
            data.pop_front();
        }else if(word=="deleteLast"){
            data.pop_back();
        }else{
            cin>>suu;
            if(word=="insert"){
                data.push_front(suu);
            }else{
                p=find(data.begin(),data.end(),suu);
                if(p!=data.end()){
                    data.erase(p);
                }
            }
        }
    }
    p=data.begin();
    while(p!=data.end()){
        cout<<*p++;
        if(p!=data.end()){
            cout<<" ";
        }
    }
    cout<<endl;
    return 0;
}


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

int main(){
    ll l, r; cin >> l >> r;

    ll ans = 1e18;

    if(r - l >= 2019){
        put(0);
        return 0;
    }

    l %= 2019;
    r %= 2019;
    if(r <= l){
        ans = 0;
    }

    for(int i = l; i < r; i++){
        for(int j = i+1; j <= r; j++){
            ans = min(ans, (i * j) % 2019LL);
        }
    }
    //cout << "min1:" << min1 << " min2:" << min2 << endl;;
    put(ans);
}

Measured memory_bytes: 3532
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var n = new string[s.Length];
            for(var i = s.Length - 1; i >= 0; i--){
                n[s.Length - 1 - i] = s[i].ToString();
            }

            if(int.Parse(s) == int.Parse(string.Join("",n))){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11092
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.nextLine();
		int[] array = Arrays.stream(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		Arrays.sort(array);
		System.out.println(array[array.length - 1] - array[0]);
	}
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template <typename T, typename U>
istream &operator>>(istream &in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD=1e9+7;
	int n;
	cin>>n;
	set<int> st;
	int ans=0;
	rep(i,n){
	    int in;
	    cin>>in;
	    if(st.lower_bound(in)==st.begin())ans++;
	    st.insert(in);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9600
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;


void solution();

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
    string s;
    cin >> s;
    int a = 0, b = 0;
    from(i, 3){
        if(s[i] == 'A') a++;
        else b++;
    }

    if(a > 0 && b > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, long long M){
  vector<pll> ans;
  if(N%2==1){
    ll l=1,r=N;
    REP(M){
      ans.push_back(pll(l,r));
      ++l;--r;
    }
  }else{
    ll l=1,r=N;
    REP(M/2+M%2){
      ans.push_back(pll(l,r));
      ++l,--r;
    }
    --r;
    REP(M/2){
      ans.push_back(pll(l,r));
      ++l,--r;
    }
  }
  REP(M){
    printf("%lld %lld\n",ans[i].first,ans[i].second);
  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 5256