akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	A, B, C, X, Y := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	mn := -1
	for i := 0; i <= X; i++ {
		c := 2 * (X - i)

		remain := Y - c/2
		bplus := 0
		if c%2 == 1 {
			if C < B {
				bplus += C
				remain--
			}
		}
		if remain < 0 {
			remain = 0
		}
		plus := 2 * remain * C
		if c%2 == 1 {
			plus += C
		}
		sum := A * i
		sum += C * c

		sum += min(remain*B, plus)
		if mn == -1 || mn > sum {
			mn = sum
		}
	}
	fmt.Println(mn)

}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main(){
	ios::sync_with_stdio(0);
	int D,N;
	cin>>D>>N;
	int S=1;
	for(int i=0;i<D;++i)S*=100;
	if(N<=99){
		cout<<S*N<<"\n";
	}else{
		cout<<S*101<<"\n";
	}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  int a=0;
  int b=0;
  rep(i,0,n){
    if(s[i]=='0') a++;
    else b++;
  }
  cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  int Q;
  while (cin >> N >> S >> Q) {
    vector<int> X(N);
    for (int i = 0; i < N; i++) X[i] = S[i] - 'a';
    vector<set<int>> sets(26);
    for (int i = 0; i < N; i++) {
      sets[X[i]].insert(i);
    }
    for (int c = 0; c < 26; c++) sets[c].insert(N);
    for (int q = 0; q < Q; q++) {
      int type;
      cin >> type;
      if (type == 1) {
        int i;
        char c;
        cin >> i >> c;
        --i;
        sets[X[i]].erase(i);
        X[i] = c - 'a';
        sets[X[i]].insert(i);
      } else {
        int l, r;
        cin >> l >> r;
        --l;
        --r;
        int sum = 0;
        for (int c = 0; c < 26; c++) sum += (*sets[c].lower_bound(l)) <= r;
        cout << sum << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 28164
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7,N=53;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int dp[N][3][3],n;
string s1,s2;
int fun(int ind,int c1,int c2)
{
  if(ind==n) return 1;
  if(c1!=-1 && c2!=-1 && dp[ind][c1][c2]!=-1) return dp[ind][c1][c2];
  int ans=0;
  if(s1[ind]==s2[ind])
    {
      set<int> s;
      if(c1!=-1) s.insert(c1);
      if(c2!=-1) s.insert(c2);
      vi rem;
      rep(i,0,3) if(!s.count(i)) rem.pb(i);
      for(int x:rem)
	ans=add(ans,fun(ind+1,x,x));
    }
  else
    {
      rep(i,0,3)
	rep(j,0,3)
	if(i!=j && i!=c1 && j!=c2)
	  ans=add(ans,fun(ind+2,i,j));
    }
  return dp[ind][c1][c2]=ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>n;
  cin>>s1>>s2;
  memset(dp,-1,sizeof(dp));
  cout<<fun(0,-1,-1)<<endl;
  return 0 ;
}


Measured memory_bytes: 256
iN ,iX  = [int(x) for x in input().split()]
aX = [int(x) for x in input().split()]

aCum = [0]*iN
aCum[0] = aX[0]
for i in range(1,iN):
    aCum[i]=aCum[i-1]+aX[i]

def fCeil(iT,iR):
    return -1 * iT // iR * -1

def fCalcCost(iN,iX,aCum,iK):
    iCost = (iN + iK ) * iX + 5 * aCum[-1]
    for i in range(2,fCeil(iN,iK) ):
        iCost += 2 * aCum[-1 * i * iK -1]
    return iCost

#枝刈りのテスト
#これ通用するのかな
iTotalCost = fCalcCost(iN,iX,aCum,1)
for iK in range(2,fCeil(iN,2) + 1):
    iThisCost = fCalcCost(iN,iX,aCum,iK)
    if iThisCost > iTotalCost:
        break
    else:
        iTotalCost = iThisCost
print(iTotalCost)


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


int main(){
    int N; cin >> N;
    vector<int> A(N+2);
    A[0]=A[N+1]=0;
    for(int i=1; i<=N; i++) cin >> A[i];
    
    int S=0;
    for(int i=0; i<=N; i++){
        S += abs(A[i]-A[i+1]);
    }
    
    int Si=0;
    for(int i=1; i<=N; i++){
        Si=0;
        Si = S + abs(A[i-1]-A[i+1]) - (abs(A[i-1]-A[i])+abs(A[i]-A[i+1]));
        cout << Si << endl;
    }
}


Measured memory_bytes: 1664
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, X = MAP()
C = [0] * N
A = [[]] * N
for i in range(N):
    C[i], *A[i] = MAP()

ans = INF
for bit in range(1<<N):
    skills = [0] * M
    cost = 0
    for i in range(N):
        if bit>>i & 1:
            cost += C[i]
            for j in range(M):
                skills[j] += A[i][j]
    if min(skills) >= X:
        ans = min(ans, cost)
if ans == INF:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 68828
//q
#include<stdio.h>

int cnt[26]={0}, ok=0;
char s[100005];

int main()
{
	//freopen("in.txt", "r", stdin);
	scanf("%s", s);
	for(int i=0; s[i]; i++) cnt[s[i]-'a']++;
	for(int i=0; i<26; i++)
	{
		if(!cnt[i])
		{
			ok++;
			putchar(i+'a');
			break;
		}
	}
	if(!ok) printf("None");
	puts("");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;
    return 0;
}

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

int main(){

        int n;
        cin>>n;

        int arr[n];

        long long ans=0;


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

            if(i>=1){
                if(arr[i]>=arr[i-1])
                    continue;

                else{
                    ans+=(arr[i-1]-arr[i]);
                    arr[i]=arr[i-1];
                }
            }
        }

        cout<<ans<<endl;





}


Measured memory_bytes: 4388
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
#include <numeric>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

long long gcd(long long m, long long n)
{
    if(m < n) return gcd(n,m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
long long lcm(long long m, long long n)
{
    return m * n / gcd(m,n);
}

int main(void)
{
    int n;
    cin >> n;
    vector<long long> a;
    long long ans = 0;
    REP(i,n)
    {
        long long temp;
        cin >> temp;
        //a.push_back(temp);
        ans += temp - 1;
    }
    cout << ans << endl;
    /*
    long long lcdnum = a[0];
    REP(i,n)
    {
        lcdnum = lcm(lcdnum, a[i]);
    }
    */
}




Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati aka (PARTH_4399, hungry_chef)
 *  Institute : Pandit Deendayal Petroleum University
 **/
#include <bits/stdc++.h>

using namespace std;

void solve()
{
    long long n, d;
    cin >> n >> d;
    int cnt = 0;
    while (n--)
    {
        long long x, y;
        cin >> x >> y;
        if (pow(x, 2) + pow(y, 2) <= pow(d, 2))
            ++cnt;
    }
    cout << cnt;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <numeric>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    i64 h, w;

    scanf("%lld %lld", &h, &w);

    i64 ans = h * w;

    //i지점에서 자른다
    for (int t = 0; t < 2; t++)
    {
        for (i64 i = 1; i < h; i++)
        {
            i64 maxh = max(i, h - i);

            //maxh를 반으로 나눈다

            i64 size1 = min(i, h - i) * w;

            i64 sizeh1 = (maxh / 2) * w;
            i64 sizeh2 = ((maxh + 1) / 2) * w;

            i64 sizew1 = maxh * (w / 2);
            i64 sizew2 = maxh * ((w + 1) / 2);

            i64 sh = max({ size1, sizeh1, sizeh2 }) - min({ size1, sizeh1, sizeh2 });
            i64 sw = max({ size1, sizew1, sizew2 }) - min({ size1, sizew1, sizew2 });

            ans = min({ ans,sh,sw });
        }

        swap(h, w);
    }

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

    return 0;
}

Measured memory_bytes: 256
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var s = o.a(1);
  var ans = 0;
  var l = s.length
  for(var i = 0; i < l >> 1; i++){
    if(s[i] !== s[l-1-i])ans++;
  }
  return ans;
}

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	string a;
	cin >> a;
	if(a[0]>='a'&&a[0]<='z') cout << 'a';
	else cout << 'A';
}


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

int data[100005];

int main(){
	int ban;
	scanf("%d",&ban);
	int mx=0;
	for(int i=0;i<ban;i++){
		scanf("%d",&data[i]);
		if(mx<data[i])mx=data[i];
	}
	int med1=ceil(mx/2),med2=mx/2;
	int sel=1000000000,mn;
	for(int i=0;i<ban;i++){
		if(abs(med1-data[i])<sel && data[i]!=mx){
			sel=abs(med1-data[i]);
			mn=data[i];
		}
		if(abs(med2-data[i])<sel && data[i]!=mx){
			sel=abs(med2-data[i]);
			mn=data[i];
		}
	}
	printf("%d %d\n",mx,mn);
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    
    int ans  = 0;
    rep(i, n){
        if(a[i]==b[i]){
            if(a[i]!=c[i])ans++;
        }
        else if(a[i]==c[i]||b[i]==c[i])ans++;
        else ans+=2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def insertionSort(a, n):
    for i in range(1,n):
        v = a[i]
        j = i-1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        print(' '.join(list(map(str, a))))
n = int(input())
a = list(map(int, input().split()))
print(' '.join(list(map(str, a))))
insertionSort(a, n)


Measured memory_bytes: 5600
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N = int(sys.stdin.buffer.readline())
AB = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N - 1)]
# AB = generate_tree(N)


graph = [[] for _ in range(N)]
for a, b in AB:
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

bp = [-1] * N
stack = [(0, None, 0)]
while stack:
    v, p, b = stack.pop()
    bp[v] = b
    b += 1
    b &= 1
    for u in graph[v]:
        if u == p:
            continue
        stack.append((u, v, b))

cnt0 = N // 3
cnt1 = (N + 2) // 3
cnt2 = (N + 1) // 3
vs0 = [i for i, b in enumerate(bp) if b == 0]
vs1 = [i for i, b in enumerate(bp) if b == 1]
ans_mod3 = [-1] * N
if bp.count(0) <= N // 3:
    for i in range(len(vs0)):
        ans_mod3[vs0.pop()] = 0
        cnt0 -= 1
elif bp.count(1) <= N // 3:
    for i in range(len(vs1)):
        ans_mod3[vs1.pop()] = 0
        cnt0 -= 1
else:
    for i in range(cnt1):
        ans_mod3[vs0.pop()] = 1
        cnt1 -= 1
    for i in range(cnt2):
        ans_mod3[vs1.pop()] = 2
        cnt2 -= 1

for _ in range(cnt0):
    if vs0:
        ans_mod3[vs0.pop()] = 0
    elif vs1:
        ans_mod3[vs1.pop()] = 0
for _ in range(cnt1):
    if vs0:
        ans_mod3[vs0.pop()] = 1
    elif vs1:
        ans_mod3[vs1.pop()] = 1
for _ in range(cnt2):
    if vs0:
        ans_mod3[vs0.pop()] = 2
    elif vs1:
        ans_mod3[vs1.pop()] = 2

st = [3, 1, 2]
ans = []
for a in ans_mod3:
    ans.append(st[a])
    st[a] += 3
print(*ans)


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

#define pp push_back
#define pf push_front
#define mp make_pair
#define fs first
#define sc second
#define sf scanf

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

const int N = (int) 1e5;
const int INF = (int) 1e9 + 7;

int main(int argc, char *argv[])
{
	// ios_base::sync_with_stdio(false);
	// cin.tie(NULL);

	int a, b, c, k;
	sf("%d %d %d %d", &a, &b, &c, &k);
	int ans = 0;
	ans += min(a, k);
	k -= ans;
	if (k > 0) {
		k -= b;
	}
	if (k > 0) {
		ans -= k;
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool prime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}
bool comp(pair<ll,ll>a,pair<ll,ll>b)
{
    if(a.fi==b.fi)return a.se>b.se;
    return a.fi>b.fi;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string a,b; cin>>a>>b;
ll n = a.size();
if(b.size()>n&&b.substr(0,n)==a)cout<<"Yes\n";
else cout<<"No\n";
return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<map>
#include<vector>
#include<set>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#define Max zhi5968
typedef long long ll;
using namespace std;
 
int main ()
{
	int i,t[5];
	for(i=0;i<4;i++)
		scanf("%1d",&t[i]);
	if(t[0]+t[1]+t[2]+t[3]==7)
	{
		printf("%d+%d+%d+%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]+t[1]+t[2]-t[3]==7)
	{
		printf("%d+%d+%d-%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]+t[1]-t[2]+t[3]==7)
	{
		printf("%d+%d-%d+%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]+t[1]-t[2]-t[3]==7)
	{
		printf("%d+%d-%d-%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]-t[1]+t[2]+t[3]==7)
	{
		printf("%d-%d+%d+%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]-t[1]+t[2]-t[3]==7)
	{
		printf("%d-%d+%d-%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]-t[1]-t[2]+t[3]==7)
	{
		printf("%d-%d-%d+%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	if(t[0]-t[1]-t[2]-t[3]==7)
	{
		printf("%d-%d-%d-%d=7",t[0],t[1],t[2],t[3]);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int sum = 0;
        for (int a = 1; a <= k; a++) {
            for (int b = 1; b <= k; b++) {
                for (int c = 1; c <= k; c++) {
                    sum += gcd(gcd(a, b), c);
                }
            }    
        }
        System.out.println(sum);
        sc.close();
    }

    static int gcd(int a, int b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}

Measured memory_bytes: 35704
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <functional>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言

int main() {
  string s;
  cin >> s;
  int a[26] = {};

  int n = (int)(s.length());

  rep(i, n) {
    a['z'-s[i]] += 1;
  }

  rep(i, 26) {
    if(a[i]>1) {
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 200010;
inline int read()
{
	register char cc = getchar(); register int cn(0), flus(1);
	while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
struct node
{
	int x,h;
} b[N];
inline bool cmp(node i,node j)
{
	return i.x < j.x;
}
int n, d, a, qn[N], qx[N], q1, q2, qs, ans;
signed main()
{
	n = read();
	d = read();
	a = read();
	rep(i, 1, n)
	{
		b[i].x = read();
		b[i].h = read();
		b[i].h=(b[i].h - 1) / a + 1;
	}
	sort(b+1,b+n+1,cmp);
	rep(i, 1, n)
	{
		while(qx[q1] < b[i].x && q1 < q2)
		{
			qs -= qn[q1++];
		}
		if(b[i].h > qs)
		{
			ans+=(qn[q2]=b[i].h-qs);
			qx[q2++]=b[i].x+ (d << 1);
			qs=b[i].h;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

int main(){
    int W,H,x,y,r = 0;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  vector<int> from, to;
  REP(i, M) {
    int a, b; cin >> a >> b;
    if (b < a) swap(a, b);
    if (a == 1) {
      from.push_back(b);
    }
    if (b == N) {
      to.push_back(a);
    }
  }
  sort(to.begin(), to.end());
  bool ok = false;
  for (int x : from) {
    if(binary_search(to.begin(), to.end(), x)) ok = true;
  }
  cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}


Measured memory_bytes: 1276
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N;

    cin >> N;

    vector<long> A(N);

    long min = 1000000000;
    long count = 0;
    long ret = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(abs(A[i]) < min){
            min = abs(A[i]);
        }
        if(A[i] < 0){
            count++;
        }
        ret += abs(A[i]);
    }

    if(count %2 != 0){
        ret -= abs(min)*2;
    }

    cout << ret << endl;


    return 0;
}


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

const int INF = 1e9+5;

int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    for(int& x : h)
    {
        cin>>x;
    }
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        {
            if(j<n)
            {
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#define inf -2147483647
using namespace std;
struct info
{
    int l,r,d;
}s[400005];
int n,m;
int flag = 1;
int dis[100005],visited[100005];
int first[400005],nexti[400005];
void dfs(int t)
{
    if(!flag)return;
    int k = first[t];
    while(k != -1)
    {
        if(!flag)return;
        if(!visited[s[k].r])
        {
            dis[s[k].r] = dis[s[k].l] + s[k].d;
            visited[s[k].r] = 1;
            dfs(s[k].r);
        }
        else if(s[k].d + dis[s[k].l] != dis[s[k].r])
        {
            flag = 0;
            return;
        }
        k = nexti[k];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 0;i < m;i ++)
    {
        scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
        nexti[i] = first[s[i].l];
        first[s[i].l] = i;
        s[i + m].r = s[i].l;
        s[i + m].l = s[i].r;
        s[i + m].d = - s[i].d;
        nexti[i + m] = first[s[i + m].l];
        first[s[i + m].l] = i + m;
    }
    for(int i = 1;i <= n;i ++)
    {
        if(!visited[i])
        {
            visited[i] = 1;
            dfs(i);
        }
    }
    if(flag)printf("Yes");
    else printf("No");
}


Measured memory_bytes: 9728
#include<bits/stdc++.h>
#define IMAX -1000000000

#define ll long long

using namespace std;
int main()
{
  ll n;
  cin>>n;
  
  ll a[n][3];


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

  ll b[n][3];

  for(ll i=0;i<n;i++)
  {
      b[i][0]=IMAX;
      b[i][1]=IMAX;
      b[i][2]=IMAX;
  }
  
  b[0][0]=a[0][0];
  b[0][1]=a[0][1];
  b[0][2]=a[0][2];



  for(ll i=0;i<n-1;i++)
  {
    for(ll j=0;j<3;j++)
    {
        for(ll k=0;k<3;k++)
        {
          if(j!=k)
          {
            b[i+1][k]=max(b[i][j]+a[i+1][k],b[i+1][k]);
          }
        }
    }
  }

  // for(ll i=0;i<n;i++)
  // {
  //     cout<<a[i][0]<<" ";
  //     cout<<a[i][1]<<" ";
  //     cout<<a[i][2]<<"\n";
  // }

  
  cout<<max(b[n-1][0],max(b[n-1][1],b[n-1][2]));


}

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

const int limit = 100010;
using edge = struct {int to; long long cost;};
vector<edge> tree[limit];
long long depth[limit];

void dfs(int v, int p, long long d){
    depth[v] = d;
    for(auto &e : tree[v]) {
        if(e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

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

    int n;
    cin >> n;

    for(int i = 0; i < n-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);

    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }

    return 0;
}

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

bool palindrome(int n) { // all numbers are 5-digit
    int x=0, y=n;
    while (n) {
        x*=10;
        x += n%10;
        n/=10;
    }
    //cout << x << " " << y << '\n';
    if (x==y) return true;
    return false;
}


int main() {
    int A, B, cnt=0;
    cin >> A >> B;
    for (int i=A;i<=B;i++) {
        if (palindrome(i)) cnt++;
    }
    cout << cnt << '\n';
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n, m, l;
    int i, j, k;
    long int A[100][100], B[100][100], C[100][100];
    long int sum = 0;
    cin >> n >> m >> l;

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >>A[i][j];
        }
    }

    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            cin >> B[i][j];
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            sum = 0;
            for(k = 0; k < m; k++){
                sum += A[i][k]*B[k][j];
            }
            C[i][j] = sum;
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            if(j) cout << " ";
            cout << C[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3320
#include<iostream>
#include<string>
using namespace std;
int main(void){
	string s;
	cin>>s;
	if(s[0]=='a'&&s[1]=='b'&&s[2]=='c')
	cout<<"Yes"<<endl;
	else  if(s[0]=='a'&&s[2]=='b'&&s[1]=='c')
	cout<<"Yes"<<endl;
	else if(s[1]=='a'&&s[0]=='b'&&s[2]=='c')
	cout<<"Yes"<<endl;
	else if(s[2]=='a'&&s[0]=='b'&&s[1]=='c')
	cout<<"Yes"<<endl;
    else if(s[1]=='a'&&s[2]=='b'&&s[0]=='c')
	cout<<"Yes"<<endl;
	else if(s[2]=='a'&&s[1]=='b'&&s[0]=='c')
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}



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

using namespace std;



int main(int argc, const char * argv[]) {

 
    

       
   int n;
   cin >> n;
   int a,b;
   cin >> a >> b;
   
   for(int i=a; i<=b; i++){
       if(i%n==0){
           cout << "OK" << endl;
           return 0;
       }
           
   }

   cout << "NG";
   

    return 0;
}


Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		
		int r = s.nextInt();
		int c = s.nextInt();
		int[][] yousoA = new int[r][c];
		int[] yousoB = new int[r];
		int[] yousoB2 = new int[c];
		int sum = 0;
		
		for(int i = 0; i < r; i++){
			for(int j = 0; j < c; j++){
				int x = s.nextInt();
				yousoA[i][j] = x;
				yousoB[i] += x;
				yousoB2[j] += x;
				sum += x;
			}
		}
		for(int i=0; i < r+1; i++){
			if(i < r)
				for(int j =0; j < c+1; j++){
					if(j < c) System.out.print(yousoA[i][j] + " ");
					else System.out.println(yousoB[i]);
				}
			else
				for(int k = 0; k < c; k++){
					System.out.print(yousoB2[k] + " ");
				}
		}
		System.out.println(sum);
		s.close();
	}
}


Measured memory_bytes: 42128
from math import factorial

def comb(m, n):
    return factorial(m) // factorial(n) // factorial(m-n)

def solve(n, p, a):
    n_odd = len(list(filter(lambda _:_%2, a)))
    n_even = n - n_odd
    v = 2**n_even
    w = sum([comb(n_odd, k) for k in range(p, n_odd+1, 2)])
    return v * w

n, p = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, p, a))


Measured memory_bytes: 3064
L,R = map(int,input().split())
L_mod = L % 2019
A = 2019 - L_mod
if A <= R-L:
  print(0)
else:
  ans = 2018
  for i in range(R-L+1):
    for j in range(i+1,R-L+1):
      temp = (L_mod + i) * (L_mod + j) % 2019
      if temp <= ans:
        ans = temp
  print(ans)
  

Measured memory_bytes: 2940
#include<iostream>

#include<stdio.h>
#include<vector>
#include<math.h>
#include<unordered_map>
#include<queue>

#define inf 0x3f3f3f3f
#define vai freopen("in","r",stdin);
#define ii pair<int,int> 
#define iii pair<int, ii>
#define pb push_back

const int maxn = 5010;


using namespace std;
typedef vector<int> vi;
 

void faz ( int * a, int * b, int * c ){
	if (* a>  *b ) swap (*a, *b);
	if (* b >  *c ) swap (*b, *c);
	if (* a>  *b ) swap (*a, *b);
}


 
 

int main () {
	
	
	
 
	
	int a, b, c;
	
	
	cin >> a >> b >> c;
	faz(&a, &b,&c);
	
	int t = ( b - a );
	if ( t%2 ){
		 int k = ( (b + 1) - a )/2;
		cout << ( ( c + 1 ) - (b + 1) ) + 1  + k  <<'\n';
	}else {
		 cout << (c - b + t/2 )<<'\n';
	}
	

}
	
	 


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N, M;
	cin >> N >> M;
	vector<pair<ll, int>> C(N);
	REP(i, N) cin >> C[i].first >> C[i].second;
	sort(C.begin(), C.end());
	int i = 0;
	ll res = 0;
	while (C[i].second < M) {
		res += C[i].first * C[i].second;
		M -= C[i].second;
		i++;
	}
	res += C[i].first * M;
	cout << res << "\n";

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n,m; cin >> n >> m;
	int x[100005];

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

	sort(x,x+m);

	int dif[100005];

	for (int i = 0;i < m-1;i++){
		dif[i] = x[i+1] - x[i];
	}

	sort(dif,dif+m-1);

	ll ans = 0;

	for (int i = 0;i < m-n;i++){
		ans += dif[i];
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 1024
a, b, c, k = map(int, input().split())

total = 0

if a > 0:
    if a < k:
        total += a
        k -= a
    else:
        total += k
        print(total)
        k = 0

if b > 0 and k > 0:
    if b < k:
        k -= b
    else:
        print(total)
        k = 0

if c > 0 and k > 0:
    if c < k:
        total -= c
        print(total)
    else:
        total -= k
        print(total)


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> r(n,0), g(n,0), b(n,0);
  rep(i,n) {
    if(i > 0) {
      r[i] += r[i-1];
      g[i] += g[i-1];
      b[i] += b[i-1];
    }
    if(s[i] == 'R') r[i]++;
    if(s[i] == 'G') g[i]++;
    if(s[i] == 'B') b[i]++;
  }
  ll ans = 0;
  for(int i = 1; i < n; i++) {
    for(int j = i+1; j < n; j++) {
      if(s[i] == 'G' && s[j] == 'B') {
        ans += r[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'R') ans--; 
      }
       if(s[i] == 'B' && s[j] == 'G') {
        ans += r[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'R') ans--; 
      } 
      if(s[i] == 'R' && s[j] == 'G') {
        ans += b[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'B') ans--; 
      } 
      if(s[i] == 'G' && s[j] == 'R') {
        ans += b[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'B') ans--; 
      } 
      if(s[i] == 'B' && s[j] == 'R') {
        ans += g[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'G') ans--; 
      }
       if(s[i] == 'R' && s[j] == 'B') {
        ans += g[i-1];
        if(2*i-j >= 0 && s[2*i-j] == 'G') ans--; 
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3692
#include<stdio.h>
#include<stdlib.h>

#define ll long long int

int main() {
  int n;
  scanf("%d", &n);
  ll *a, *m;
  a = (ll *)malloc(sizeof(ll) * n);
  m = (ll *)malloc(sizeof(ll) * (n + 1));
  int i, j;
  for(i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
    m[i] = 0;
  }
  for(i = 0; i < n; i++) m[0] += a[i];
  for(i = 1; i < n; i += 2) m[0] -= 2 * a[i];
  for(i = 1; i < n; i++) m[i] = 2 * a[i - 1] - m[i - 1];
  for(i = 0; i < n; i++) printf("%lld ", m[i]);
  printf("\n");
  return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z,m;
    cin>>x>>y>>z;
    int a[x];
    for(int i=0; i<x; i++)
    {
        a[i]=y;
    }
    for(int j=0; j<z; j++)
    {
        cin>>m;
        a[m-1]++;
    }
    for(int i=0; i<x; i++)
    {
        if(a[i]-z>0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
const long long inf = 1e17;
const int mod = 1000000007;

signed main() {
	int a, v, b, w, t; cin >> a >> v >> b >> w >> t;
	v -= w;
	int d = abs(a - b);
	if (v > 0 && t*v >= d)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 3636
N, X = map(int, input().split())

x = [int(i) for i in input().split()]

x.append(X)
x.sort()

def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

now = x[1] - x[0]

for i in range(1, N):
    distance = x[i+1] - x[i]
    now = gcd(now, distance)
    if now == 1:
        break
print(now)


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

int main(void) {
    int n, k, t[6] = {1, 10, 100, 1000, 10000, 100000};
    bool bad[10] = {};
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int d;
        cin >> d;
        bad[d] = true;
    }
    for (int i = n; ; i++) {
        bool flag = true;
        for (int j = 0; i / t[j]; j++) {
            if (bad[i % t[j + 1] / t[j]]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i << endl;
            break;
        }
        else continue;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){ 
    string a,b;
    cin>>a>>b;

    int ans=0;

    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i])ans++;
    }

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

Measured memory_bytes: 3920
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

signed main() {
    int L, R;
    cin >> L >> R;
    
    if (R - L > 2019) R = L + 2018;
    int ans = 1000000000;
    for (int i = L; i < R; ++i) for (int j = i + 1; j <= R; ++j) {
        ans = min(ans, i % 2019 * j % 2019);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <utility>
#include <algorithm>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <numeric>
#include <list>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
using namespace std;

int main(void) {
    int N;
    cin >> N;
    vi h(N);
    vi ans(100 + 10);
    
    rep(i, N) {
        cin >> h[i];
    }
    
    REP(i, 1, 100) {
        bool left=false;
        int cnt=0;
        rep(j, N) {
            if (h[j] >= i && left==false) {
                cnt++;
                left=true;
            } else if (h[j] < i) {
                left=false;
            }
        }
        ans[i] = cnt;
    }
    
    int res=0;
    REP(i, 1, 100) {
        res += ans[i];
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}
bool isPrime(ll num)
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

void solve(long long X)
{
    while (!isPrime(X))
    {
        X++;
    }

    cout << X << endl;
}

int main()
{
    long long X;
    scanf("%lld", &X);
    solve(X);
    return 0;
}


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

using namespace std;

#define ll long long




void solve() {

	int n;
	cin >> n;
	double sum = 0;
	while(n--) {
		int x;
		cin >> x;
		sum += 1 / (double)x;
	}
	cout << fixed;
	setprecision(10);
	cout << 1 / (double)sum << "\n";

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	solve();

	return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<27;

typedef vector<int> Array;
typedef vector<Array> Matrix;

void shortestPath(const Matrix &g, Matrix &dist) {
  int n = g.size();
  dist = g;
  REP(k, n) REP(i, n) REP(j, n)
    dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
}

int main() {
  int n,m;
  while(cin>>n>>m,n) {
    Matrix gl(n,Array(n,INF));
    Matrix gs(n,Array(n,INF));
    REP(i,n) {
      gl[i][i] = 0;
      gs[i][i] = 0;
    }
    REP(i,m) {
      int a,b,c;
      cin >> a>>b>>c;
      a--;b--;
      char ch;
      cin >> ch;
      if (ch=='L') {
        gl[a][b] = c;
        gl[b][a] = c;
      }else {
        gs[a][b] = c;
        gs[b][a] = c;
      }
    }
    int t;
    cin >> t;
    int z[t];
    REP(i,t) {
      cin >> z[i];
      z[i]--;
    }
    Matrix distl, dists;
    shortestPath(gl, distl);
    shortestPath(gs, dists);

    int dp[t][n];
    REP(i,t)REP(j,n)dp[i][j] = INF;
    dp[0][z[0]] = 0;
    int cnt = 0;
    REP(i,t-1) {
      REP(j, n) {
        REP(k, n) {
          int tmp;
          if (j==k) tmp = distl[z[i]][z[i+1]];
          else tmp = distl[z[i]][j] + dists[j][k] + distl[k][z[i+1]];
          dp[i+1][k] = min(dp[i+1][k], dp[i][j] + tmp);
        }
      }
    }
    cout << *min_element(dp[t-1], dp[t-1]+n) << endl;
  }
}

Measured memory_bytes: 2336
#include<iostream>                
using namespace std;
int main(){
   
   int a,b,c,r=0,i;
   
   cin>>a>>b>>c;

   for(i=a;i<=b;i++){

	   if(c%i==0){
		   r++;
	   }
   }
   cout<<r<<endl;

   return 0;
   }


Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}

int main(){
    int x;cin>>x;
    int c=0;
    int n=x%100;
    for(int i=5;i>=1;i--){
        c+=n/i;
        n%=i;
    }
    if(x/100>=c){
        cout<<1<<endl;
    }else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  ll n,a,b;
  cin >> n >> a >> b;
  mint res(2);
  res = res.pow(n)-(mint)1;

  mint aa(1);
  rep1(i,a){
    aa *= (mint)(n-i+1)/(mint)i;
  }
  res -= aa;

  mint bb(1);
  rep1(i,b){
    bb *= (mint)(n-i+1)/(mint)i;
  }
  res -= bb;  

  cout << res.x << "\n";
  return 0;
}


Measured memory_bytes: 256
class Dice
  attr_reader :u, :f, :r, :l, :b, :d
  def initialize(line)
    @u, @f, @r, @l, @b, @d = line.split.map(&:to_i)
  end
  def rot(direc)
    case direc
    when "E";
      @u, @l, @d, @r = @l, @d, @r, @u
    when "N";
      @u, @f, @d, @b = @f, @d, @b, @u
    when "S";
      @u, @f, @d, @b = @b, @u, @f, @d
    when "W";
      @u, @l, @d, @r = @r, @u, @l, @d
    when "Z";
      @f, @r, @b, @l = @r, @b, @l, @f
    end
  end
  def dispUp
    printf "%d\n", @u
  end
  def arr
    {:u=>u, :f =>f, :r=>r, :l=>l, :b=>b, :d=>d}
  end
  def out
    return sprintf "%d %d %d %d %d %d", u, f, r, l, b, d
  end
end

dice1 = Dice.new(gets.chomp)
dice2 = Dice.new(gets.chomp)

dice2.arr.each{|key, val|
  if dice1.u == val then
    d2 = dice2.clone
    k = sprintf "%s", key
    case k
    when "d"; d2.rot("N"); d2.rot("N");
    when "f"; d2.rot("N");
    when "b"; d2.rot("S");
    when "l"; d2.rot("E");
    when "r"; d2.rot("W");
    end
    
    4.times do
      if dice1.out == d2.out then
        printf "Yes\n"
        exit
      end
      d2.rot("Z")
    end
  end
}

printf "No\n"

Measured memory_bytes: 8680