akhauriyash/Code-Regression huggingface dataset:
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] result = new string[] { "AC", "WA", "TLE", "RE" };
        int[] count = new int[4];

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

        for (int i = 0; i < n; i++)
        {
            string input = Console.ReadLine();

            if (input.Equals(result[0]))
            {
                count[0]++;
            }
            else if (input.Equals(result[1]))
            {
                count[1]++;
            }
            else if (input.Equals(result[2]))
            {
                count[2]++;
            }
            else if (input.Equals(result[3]))
            {
                count[3]++;
            }
        }

        for (int i = 0; i < result.Length; i++)
        {
            //出力
            Console.WriteLine(result[i] + " x " + count[i]);
        }
    }
}

Measured memory_bytes: 30692
n, k = gets.split(" ").map(&:to_i)
p = gets.split(" ").map(&:to_i) + [0]

sum = p[0...k].inject(0, :+)
max = -Float::INFINITY
(0..n-k).each do |i|
  max = [max, sum].max
  sum -= p[i]
  sum += p[i+k]
end
puts (max + k) / 2.0


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

using namespace std;

typedef long long ll;

struct Monster {
	ll x;
	ll health;

	bool operator<(const Monster other) {
		return this->x < other.x;
	}
};

ll n, d, dmg;
vector<Monster> v;
vector<ll> bombs;

int main() {
	ios::sync_with_stdio(false);
	cin >> n >> d >> dmg;
	v.resize(n);
	bombs.resize(n, 0);
	for (Monster& monster : v) cin >> monster.x >> monster.health;
	sort(begin(v), end(v));
	ll ans = 0;
	ll acc = 0;
	for (int i = 0; i < n; i++) {
		acc += bombs[i];
		v[i].health -= acc * dmg;
		if (v[i].health > 0) {
			ll rem = (v[i].health + dmg - 1) / dmg;
			ll b = 0, e = n, target = v[i].x + 2 * d;
			while (b < e) {
				ll mid = (b + e) / 2;
				if (v[mid].x > target) {
					e = mid;
				} else {
					b = mid + 1;
				}
			}
			if (b < n) bombs[b] -= rem;
			acc += rem;
			ans += rem;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < n-1; i++){
      a[sc.nextInt()-1]++;
    }
    for(int i = 0; i < n; i++){
      System.out.println(a[i]);
    }
  }
}

Measured memory_bytes: 61564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int h=scn.nextInt();
		int w=scn.nextInt();
		System.out.println((n-h+1)*(n-w+1));
	}

}


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

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

using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  string S; cin >> S;
  const int N = S.size();
  vector<vector<int>> next(N * 2, vector<int>(26, -1));
  repr(i, N * 2 - 1) {
    rep(j, 26) {
      if (S[(i + 1) % N] - 'a' == j) {
        next[i][j] = i + 1;
      } else {
        next[i][j] = next[i + 1][j];
      }
    }
  }
  ll ans = 0;
  string T; cin >> T;
  int i = 0;
  if (S[0] == T[0]) T.erase(0, 1);
  for (char c : T) {
    if (next[i][c - 'a'] == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans += next[i][c - 'a'] - i;
    i = next[i][c - 'a'] % N;
  }
  cout << ans+1 << endl;
}


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

int main() {
  int N, M;

  cin >> N;
  vector<string> s(N);
  for(int i=0; i<N; i++){
    cin >> s.at(i);
  }

  cin >> M;
  vector<string> t(M);
  for(int i=0; i<M; i++){
    cin >> t.at(i);
  }

  int sum=0;
  for(int i=0; i<N; i++){
    int count=0;
    for(int j=0; j<N-i; j++){
      if(s.at(i)==s.at(i+j)){
        count++;
      }
    }
    for(int j=0; j<M; j++){
      if(s.at(i)==t.at(j)){
        count--;
      }
    }
    sum = max(sum, count);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)c==d[k]?k++,c=r[i++]:(putchar(c),c=g[j++]);exit(0);}

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  double h,w; cin >> h >> w;
  if(h == 1 || w == 1){
    cout << 1 << endl;
  } else {
    cout << (ll) ((h*w)/2 + 0.9) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
    char str[100000];
    gets(str);
    
    int len=0;
    while(str[len]) len++;

    for (int i=0; i < len; i++){
        if (i%2 == 0) printf("%c", str[i]);
    }
    printf("\n");
    


    return 0;
} 



Measured memory_bytes: 256
# B - Balance

n = int(input())
w = list(int(x) for x in input().split())

wsum = [0]
for i in range(n):
    wsum.append(wsum[i] + w[i])

ans = 10**6
for i in range(1, n):
    ans = min(ans, abs(wsum[n]-wsum[i]-wsum[i]))

print(ans)


Measured memory_bytes: 3060
N, M = map(int, input().split())
a, b, c = [0] * M, [0] * M, [0] * M
INF = int(1e13) + 1
for i in range(M):
    a[i], b[i], c[i] = map(int, input().split())
    a[i] -= 1
    b[i] -= 1

d = [-INF] * N
d[0] = 0
for __x in range(N-1):
    for i in range(M):
        if d[b[i]] < d[a[i]] + c[i]:
            d[b[i]] = d[a[i]] + c[i]

isCycle = False
for __x in range(N-1):
    if isCycle:
        break
    for i in range(M):
        if d[b[i]] < d[a[i]] + c[i]:
            d[b[i]] = d[a[i]] + c[i]
            if b[i] == N-1:
                isCycle = True
                break

if isCycle:
    print('inf')
else:
    print(d[N-1])


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

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            
            if(a == b&&a == c)
            {
                Console.WriteLine(1);
            }else if(a == b && b != c || b == c && a != b || a == c && b != c)
            {
                Console.WriteLine(2);
            }
            else
            {
                Console.WriteLine(3);
            }
        }
    }
}

Measured memory_bytes: 11092
import numpy as np
import math

N = int(input())


lim = math.ceil(np.sqrt(N))

ans = 0

for i in range(lim):
    rem = i+1
    if N <= rem**2 + rem:
        break
    if (N-rem) % rem == 0:
        ans += (N-rem)/rem

print(int(ans))


Measured memory_bytes: 13776
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll N = 2e5 + 10, inf = 1e18 + 10, mod = 1e9 + 7;
ll t[4 * N], c[4 * N], x[N], d[N], L[N], R[N], ans;
vector <int> a[N];
void push(int v, int tl, int tr)
{
    if(c[v])
    {
        t[v] += c[v];
        if (tl != tr){
            c[v + v] += c[v];
            c[v + v + 1] += c[v];
        }
        c[v] = 0;
    }
}
ll ma(int v, int tl, int tr, int l, int r)
{
    push(v, tl, tr);
    if(l <= tl && tr <= r)return t[v];
    else if(tr < l || r < tl)return -inf;
    else
    {
        int mid = (tl + tr) / 2;
        return max(ma(v + v, tl, mid, l, r), ma(v + v + 1, mid + 1, tr, l, r));
    }
}
void up(int v, int tl, int tr, int l, int r, ll val)
{
    push(v, tl, tr);
    if(l <= tl && tr <= r)
    {
        c[v] += val;
        push(v, tl, tr);
    }
    else if(tr < l || r < tl)return;
    else
    {
        int mid = (tl + tr) / 2;
        up(v + v, tl, mid, l, r, val);
        up(v + v + 1, mid + 1, tr, l, r, val);
        t[v] = max(t[v + v], t[v + v + 1]);
    }
}
main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> L[i] >> R[i] >> x[i];
        a[L[i]].pb(i);
        a[R[i]].pb(-i);
    }
    for(int i = 1; i <= n; i++)
    {
        for(auto j : a[i])
        {
            if(j > 0)up(1, 0, n, 0, i - 1, x[j]);
        }
        d[i] = ma(1, 0, n, 0, i - 1);
        up(1, 0, n, i, i, d[i]);
        for(auto j : a[i])
        {
            if(j < 0)
            {
                up(1, 0, n, 0, L[-j] - 1, -x[-j]);
            }
        }
        ans = max(ans , d[i]);
    }
    cout << ans;
}


Measured memory_bytes: 29056
N, x = map(int, input().split())
a = list(map(int, input().split()))
cost = [ai for ai in a]
res = sum(cost)
for i in range(1, N):
    for j in range(N):
        cost[(j+i)%N] = min(cost[(j+i)%N], a[j])
    res = min(res, sum(cost)+x*i)
print(res)

Measured memory_bytes: 42604
#include <stdio.h>

#define SIZE 128

int N;
int selectionSort(int *A);

int main(void){
  int i, A[SIZE] ={0};
  scanf("%d", &N);
  for (i = 0; i < N; i++)
    scanf("%d", &A[i]);
  int cnt = selectionSort(A);

  for (i = 0; i < N; i++) {
    printf("%d", A[i]);
    if (i < N - 1)
      printf(" ");
  }
  printf("\n%d\n", cnt);
  return 0;
}

int selectionSort(int *A){
  int i, j, minj, tmp, cnt = 0;
  for (i = 0; i < N; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[minj])
	minj = j;
    }
    if (A[i] != A[minj]) {
      tmp = A[i];
      A[i] = A[minj];
      A[minj] = tmp;
      cnt++;
    }
  }
  return cnt;
}

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

vector<int> g[200005];
int n, m, cc[200005], mx, number[200005], currComp;

void dfs(int x) {
    cc[x] = currComp;
    number[currComp]++;
    for(auto next: g[x])
        if(!cc[next])
            dfs(next);
}

int main() {
    cin >> n >> m;
    while(m--) {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    for(int i = 1; i <= n; i++)
        if(!cc[i]) {
            currComp++;
            dfs(i);
            mx = max(mx, number[currComp]);
        }
    cout << mx;
}



Measured memory_bytes: 21500
S = [int(i) for i in input()]
n = len(S)
p = int(1e9) + 7

DP = [[0] * 2 for i in range(n + 1)]
DP[0][1] = 1

for i in range(n):
    DP[i + 1][0] += DP[i][0] * 3 % p
    if S[i] == 1:
        DP[i + 1][0] += DP[i][1] % p
        DP[i + 1][1] += DP[i][1] * 2 % p

    else:
        DP[i + 1][1] += DP[i][1] % p

print(sum(DP[n]) % p)

Measured memory_bytes: 56028
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll tmp[101010];
int main() {
	pair<ll,ll> num[101010];
	cin>>N;
	rep(i,0,N){
		cin>>a[i]>>b[i];
		num[i].first=a[i]+b[i];
		num[i].second=i;
	}
	sort(num,num+N,greater<pair<ll,ll>>());
	ll takahashi=0;
	ll aoki=0;
	rep(i,0,N){
		if(i%2==0){
			takahashi+=a[num[i].second];
		}
		else{
			aoki+=b[num[i].second];
		}
	}
	cerr<<takahashi<<" "<<aoki<<endl;
	cout<<takahashi-aoki<<endl;
	return 0;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin >> n;
    ll sum=0;
    ll x=1;
    int t=1;
    n--;
    while(sum+x*26<=n){
        sum+=x*26;
        x*=26;
        t++;
    }
    n-=sum;
    vector<int> ans;
    REP(i,t){
        ans.push_back(n%26);
        n/=26;
    }
    REPR(i,ans.size()){
        cout << char(ans[i]+'a');
    }
    cout << endl;
}

Measured memory_bytes: 3616
#pragma region template

#include <bits/stdc++.h>
using namespace std;

// -type-
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpii = vector<pii>;
using vpll = vector<pll>;


// -const-
const ll MOD = 1000000007;

const ll INF = (ll)0x3f0000003f000000;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1},
          dy[] = {1, 0, -1, 0, 1, -1, -1, 1};


// -define-
#define reps(i, k, n) for (int i = (k), i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) reps(i, 1, n + 1)
#define rep(i, n) reps(i, 0, n)
#define repsr(i, k, n) \
    for (int i = int(n) - 1, i##_len = (k); i >= i##_len; --i)
#define repr(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(o) begin(o), end(o)
#define sz(a) ((int)(a).size())
#define debug(...) debug_args(__LINE__, __VA_ARGS__)


// clang-format off
// -functions-
inline bool in(string s, string c) {return (s.find(c) != string::npos);}
inline bool in(string s,   char c) {return (s.find(c) != string::npos);}

template <class T> T udiv(T a, T b) {return (a + b - 1) / b;}
template <class T> T rdiv(T a, T b) {return (a + b / 2) / b;}

void print_args(ostream&) {}
template <class S, class... T>
void print_args(ostream& out,const S& a,const T&... args) {
    out << ' ' << a;
    print_args(out, args...);
}
template <class S, class... T>
void print(const S& a, const T&... args) {
    std::cout << a;
    print_args(std::cout, args...);
    std::cout << '\n';
}
template <class S, class... T>
void debug_args(const S& a, const T&... args) {
    std::cout << "(L:" << std::setw(3) << a << ")";
    print_args(std::cout, args...);
    std::cout << '\n';
}
// clang-format on

struct setup_main {
    setup_main() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(0);
        std::cout << fixed << setprecision(15);
    }
} setup_main_;

ll ans = 0;
#pragma endregion

struct t {
    int a;
    int b;
    int c;
    t() {
        a = INF, b = INF, c = INF;
    }
    t(int a_, int b_, int c_) {
        a = a_, b = b_, c = c_;
    }
};
void solve(long long N,
           std::vector<long long> a,
           std::vector<long long> b,
           std::vector<long long> c) {
    vector<t> dp(N + 1, t());

    dp[0] = t(a[0], b[0], c[0]);

    reps(i, 1, N) {
        dp[i].a = max(dp[i - 1].b + a[i], dp[i - 1].c + a[i]);
        dp[i].b = max(dp[i - 1].c + b[i], dp[i - 1].a + b[i]);
        dp[i].c = max(dp[i - 1].a + c[i], dp[i - 1].b + c[i]);
    }
    t fo = dp[N - 1];
    print(max({fo.a, fo.b, fo.c}));
}
signed main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
        scanf("%lld", &c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));

    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  ll ans=INF;
  rep(i,2*max(x,y)+1){
    ll yy=y;
    ll xx=x;
    if(i%2==0){
      yy-=i/2;
      xx-=i/2;
    }
    if(yy<0)yy=0;
    if(xx<0)xx=0;
    chmin(ans,i*c+yy*b+xx*a);
  }
  COUT(ans);
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

bool f (ll a, ll b, ll c, ll k) {
    if (k == 0) {
        return (a < b and b < c);
    }

    return f(a*2, b, c, k-1) or f(a, b*2, c, k-1) or f(a, b, c*2, k-1);
}

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

    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    if (f(A, B, C, K)) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <numeric>
using namespace std;
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
int main(void){
    int a,b,c,x,y,cnt=0;
    cin>>a>>b>>c>>x>>y;
    c*=2;
    if(a+b>c){
        int mn=min(x,y);
        cnt+=mn*c;
        x-=mn;
        y-=mn;
    }
    if(a>c){
        cnt+=x*c;
        x=0;
    }
    if(b>c){
        cnt+=y*c;
        y=0;
    }
    cnt+=x*a+y*b;
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,k,ans=0,sabun=1,cnt=0,cntt=1;
  cin >> n >> k;
  if(k%2==1){
    cout << (n/k)*(n/k)*(n/k) << endl;
  }else{
    for(int i=1;i<=n;i++){
      cnt++;
      if(cnt*2%k==0){
        ans+=sabun;
      }
      if(i%k==0){
        sabun+=6*cntt;
        cntt++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b){
    cout << c << endl;
  }
  else if (a == c){
    cout << b <<endl;
  }
  else if(b == c){
    cout << a <<endl;
  }
}


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

int main()
{
  int N, K;
  cin >> N;
  cin >> K;
  
  int num = 1;
  
  for(int i = 0; i < N;i++){
    if (num <= K) {
      num *= 2;
    } else {
      num += K;
    }
  }
  cout << num << endl;
}

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

int main(){
    int n,m; //n even , m odd 
    cin >> n >> m;
    if(n<=1){
        if(m<=1){
            cout << 0 << endl;
            return 0;
        }
        cout << m*(m-1)/2 << endl;
        return 0;
    }
    if(m<=1){
        cout << n*(n-1)/2 << endl;
        return 0;
    }
    int ans = n*(n-1)/2 + m*(m-1)/2;
    cout << ans << endl;
    return 0;    
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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 a, b, c; cin >> a >> b >> c;
  ll ans = INF64;
  chmin(ans, b*c*abs(a/2-(a-a/2)));
  chmin(ans, a*c*abs(b/2-(b-b/2)));
  chmin(ans, b*a*abs(c/2-(c-c/2)));

  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#include <stack>

typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,cnt=0ll;
  cin >> n >> k;
  for(i=1;i<=n;i++){
    if(i%2==1)cnt++;
  }
  if(cnt>=k)cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int sb(int num)
{int hh=0;
while(--num!=0){
	hh+=num;
}
  return hh;
}
int main()
{ int n,m;cin>>n>>m;int sum;
if(n!=0&&m!=0)
{sum=sb(n)+sb(m);cout<<sum<<"\n";
}
else if(n==0)cout<<sb(m)<<"\n";
else if(m==0)cout<<sb(n)<<"\n";

}

Measured memory_bytes: 256
// C - Reconciled?
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007

ll factorial_mod(ll n){//階乗％MOD
	ll ans = n;
	while(n>1) ans = ans * --n % MOD;
	return ans;
}

int main(){
	ll small, big; cin>>small>>big;
	if(small>big) swap(small, big);

	if(small != big && small+1 != big){
		cout<< 0 <<endl;
		return 0;
	}

	ll ans =  factorial_mod(big) * factorial_mod(small) % MOD;
	if(small == big) ans = ans * 2 % MOD;
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

vector<int> E[1100];
int parent[1100];
int sib[1100];
int depth[1100];
int height[1100];

void f(int u, int d){
	depth[u] = d;
	for(int i = 0; i < E[u].size(); i++){
		f(E[u][i], d + 1);
	}
}

int g(int u){
	int ret = 0;
	for(int i = 0; i < E[u].size(); i++){
		ret = max(ret, g(E[u][i]) + 1);
	}
	height[u] = ret;
	return ret;
}

int main(){
	
	int n;
	cin >> n;
	
	for(int i = 0; i < n; i++){
		parent[i] = -1;
		sib[i] = -1;
	}
	
	for(int i = 0; i < n; i++){
		int id, c1, c2;
		cin >> id >> c1 >> c2;
		if(c1 != -1){
			parent[c1] = id;
			E[id].push_back(c1);
		}
		if(c2 != -1){
			parent[c2] = id;
			E[id].push_back(c2);
		}
		if(c1 != -1 && c2 != -1){
			sib[c1] = c2;
			sib[c2] = c1;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(parent[i] == -1){
			f(i, 0);
			g(i);
			break;
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << "node " << i << ": parent = " << parent[i];
		cout << ", sibling = " << sib[i] << ", degree = " << E[i].size();
		cout << ", depth = " << depth[i] << ", height = " << height[i] << ", ";
		if(parent[i] == -1){
			cout << "root";
		}else if(E[i].size() == 0){
			cout << "leaf";
		}else{
			cout << "internal node";
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3192
#include <stdio.h>
#define MAX 100005
#define NIL -1
struct Node {
    int p;
    int left;
    int right;
};

struct Node Tree[MAX];
int N,D[MAX],H[MAX];

void findDepth(int,int);
int findHeight(int);
int findSibling(int);
void Print(int);

int main(){
  int v, left, right, root = 0;
  scanf("%d",&N);
  for(int i=0;i<N;i++) Tree[i].p = NIL;
  for(int i=0;i<N;i++) {
    scanf("%d %d %d",&v,&left,&right);
    Tree[v].left  = left; Tree[v].right = right;
    if(left != NIL) Tree[left].p = v; if(right != NIL) Tree[right].p = v;
  }
  
  for(int i=0; i<N; i++)if(Tree[i].p == NIL) root = i;
  
  findDepth(root,0);
  findHeight(root);
  
  for(int i=0;i<N;i++) Print(i);
  
  return 0;
}

void findDepth(int value,int d) {
  if(value == NIL) return;
  D[value] = d;
  findDepth(Tree[value].left, d+1);
  findDepth(Tree[value].right,d+1);
}

void Print(int i){  /*mainでのprintを関数化してみた*/
    int degree = 0;
    printf("node %d: parent = %d, sibling = %d, ", i,Tree[i].p,findSibling(i));
    if(Tree[i].left  != NIL) degree++;
    if(Tree[i].right != NIL) degree++;
    printf("degree = %d, depth = %d, height = %d, ",degree,D[i],H[i]);

    if ( Tree[i].p == NIL ) printf("root\n");
    else if (Tree[i].left == NIL && Tree[i].right == NIL ) printf("leaf\n"); /*A.cの条件式に&&〜を加えた*/
    else printf("internal node\n");
}

int findHeight(int r){
    int height1,height2;
    height1 = height2 = 0;

    if(Tree[r].left != NIL)height1 = findHeight(Tree[r].left) + 1;
    if(Tree[r].right != NIL)height2 = findHeight(Tree[r].right) + 1;

    return H[r] = (height1 > height2 ? height1 : height2);
}

int findSibling(int s) {
  if( Tree[s].p == NIL ) return NIL;
  if(Tree[Tree[s].p].left != s && Tree[Tree[s].p].left != NIL )return Tree[Tree[s].p].left;
  if(Tree[Tree[s].p].right != s && Tree[Tree[s].p].right != NIL )return Tree[Tree[s].p].right;
  
  return NIL;
}


Measured memory_bytes: 2148
import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
	n, w = read(); 
	dp = [[0 for i in range(w+1)] for j in range(3)]
	w_v_list = [read() for i in range(n)]
	# for i in dp:print(*i)
	# print("\n")
	# print(w_v_list)
	for i in range(n):
		for j in range(w+1):
			elem_w, elem_v = w_v_list[i]
			if elem_w <= j:
				dp[i%3][j] = max(elem_v + dp[(i-1)%3][j - elem_w], dp[i%3][j-1], dp[(i-1)%3][j])
				# w_v_list[i][1] = 0
			else:
				dp[i%3][j] = max(dp[i%3][j-1], dp[(i-1)%3][j])
		dp[(i+1)%3] = [0]*(w+1)
		# for i in dp:print(*i)
		# print("\n")
	print(dp[(n-1)%3][w])




if __name__ == "__main__":
	solve()

Measured memory_bytes: 113052
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(x) cerr << #x << ": " << x << endl
#define all(v) ((v).begin()),((v).end()) 
#define dbgxy(x,y) cerr << #x << ": " << x <<", "<<#y<<": "<<y<<endl
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
void solve(){
	lli n;
	cin>>n;
	lli sum = 0;
	for(lli i = 1;i<=n;i++){
		if(i % 3 != 0 and i % 5 != 0){
			sum += i;
		}
	}
	cout<<sum;
}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}


Measured memory_bytes: 3656
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<bits/stdc++.h>
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector> //*max_element(all(変数))で最大値を獲得
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF 1e18
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
  int n;  cin >> n;
  vi a(n);  rep0(i,n) cin >> a[i];
  int odd = 0, x4 = 0;
  rep0(i,n){
    if(a[i] % 2 == 1) odd++;
    if(a[i] % 4 == 0) x4++;
  }
  int x2 = n-odd-x4;
  if(odd+x2%2 <= x4+1) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 640
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N;
long long W, weight[110], value[110];

long long dp[110][100010];

int main()
{
    cin >> N >> W;
    rep(i,N) cin >> weight[i] >> value[i];

    rep(i,N){
        for(int sum_w = 0; sum_w <= W; ++sum_w){

            //i番目の品物を選ぶ場合
            if(sum_w - weight[i] >= 0){
                chmax(dp[i+1][sum_w],dp[i][sum_w - weight[i]] + value[i]);
            }

            //選ばないとき
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

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

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

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 1; k <= n; k++) {
                sum += gcd(i, gcd(j, k));
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll N, M, K;

	cin >> N >> M >> K;

	vector<ll> a(N + 1);
	vector<ll> b(M + 1);
	
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}

	for (int j = 1; j <= M; j++) {
		cin >> b[j];
		b[j] += b[j - 1];
	}

	int t = 0;
	int j = M;	

	for (int i = 0; i <= N; i++) {
		if (K < a[i]) {
			break;
		}

		while (b[j] > K - a[i] && j >= 0) {
			j--;
		}

		t = max(t, i + j);
	}

	
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 6324
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

const int N = 1e6 + 9;

signed main(){
   IOS;
   vector<int> prim, was(N);
   for(int i = 2;i<N;i++){
      if(!was[i]){
         prim.push_back(i);
         for(int j = 1;i*j<N;j++){
            was[i*j] = 1;
         }
      }
   }
   int n, ans = 0; cin >> n;
   for(auto p : prim){
      for(int x = p;x<=n;x*=p){
         if(n%x == 0){
            ans++;
            n/=x;
         }
      }
      while(n%p == 0) n/=p;
   }
   if(n != 1) ans++;
   cout << ans << '\n';
}

Measured memory_bytes: 12036
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
using namespace std;

const double pi = acos(-1);

#define nyan cout<<"(=^•ω•^=)"<<endl;
#define int long long

signed main(){
    string s;cin>>s;
    if(s.length()==3)reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  string a,b;
  cin >> a >> b;
  for(int i=0; i<a.size(); i++) {
   	cout << a[i];
    if(i<b.size())
      cout << b[i];
  }
  cout << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[100005];

ll labs(ll x){
	if(x<0LL)return -x;
	return x;
}

int main(void){
	scanf("%d",&n);
	int cp=0,cm=0;
	ll sum=0;
	for(int i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum+=labs(a[i]);
		if(a[i]>=0)cp++;
		else cm++;
	}
	int posp=-1,posm=-1;
	for(int i=0;i<n;i++){
		if(a[i]>=0){
			posp=i;
		}else{
			posm=i;
		}
	}
	if(cp==0){
		ll maxi=a[0],pos_b=0;
		for(int i=1;i<n;i++){
			if(maxi<a[i]){
				maxi=a[i];
				pos_b=i;
			}
		}
		printf("%lld\n",sum+maxi+maxi);
		for(int i=0;i<n;i++){
			if(i!=pos_b){
				printf("%lld %lld\n",a[pos_b],a[i]);
				a[pos_b]-=a[i];
			}
		}
	}
	if(cm==0){
		ll mini=a[0],pos_b=0;
		for(int i=1;i<n;i++){
			if(mini>a[i]){
				mini=a[i];
				pos_b=i;
			}
		}
		printf("%lld\n",sum-mini-mini);
		int tmp=(pos_b+1)%n;
		for(int i=0;i<n;i++){
			if(i!=tmp && i!=pos_b){
				printf("%lld %lld\n",a[pos_b],a[i]);
				a[pos_b]-=a[i];
			}
		}
		printf("%lld %lld\n",a[tmp],a[pos_b]);
	}
	if(cp>0 && cm>0){
		printf("%lld\n",sum);
		for(int i=0;i<n;i++){
			if(a[i]<0 && posm!=i){
				printf("%lld %lld\n",a[posp],a[i]);
				a[posp]-=a[i];
			}
		}
		for(int i=0;i<n;i++){
			if(a[i]>=0 && posp!=i){
				printf("%lld %lld\n",a[posm],a[i]);
				a[posm]-=a[i];
			}
		}
		printf("%lld %lld\n",a[posp],a[posm]);
	}
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
typedef long long ll;;

#define int long long 
using namespace std;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPR(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size()) 
#define MAX(x) *max_element(ALL(x)) 
#define MIN(x) *min_element(ALL(x)) 
#define INF 1000000000000 
#define MOD 10000007 
#define MAXR 100000 
#define PI 3.14159265358979323846
using namespace std;

signed main(){
 //   cout << "HELLO W" <<endl ;
	
	// ifstream in("input.txt");
	// cin.rdbuf(in.rdbuf());
    int n;
    cin >> n ;
    //vector<int> T(n);
    int S[4][13];
    //vector< vector<int> > S(4,vector<int>(13) ) ;

    REP(i,4){
        REP(j,13){
            S[i][j] = j+1 ;
        }
    }

    REP(i, n){
        char a;
        int b ;
        cin >> a>>b;
        b--;
   //     cout << "a,b:"<<a<<" "<<b <<endl ;

        switch (a)
        {
        case 'S':
            S[0][b] = -1 ;
            break;
        case 'H':
            S[1][b] = -1 ;
            break;
        case 'C':
            S[2][b] = -1 ;
            break;
        case 'D':
            S[3][b] = -1 ;
            break;
        }
    }

    REP(i,4){
        REP(j,13){
            if(S[i][j]> 0){
                
            char c;
            switch(i){
                case 0:c='S' ;break;
                case 1:c='H' ;break;
                case 2:c='C' ;break;
                case 3:c='D' ;break;

            }
            cout << c <<" "<< S[i][j] << endl ;

            }
        }
    }




    return 0 ;
}





Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    string s, p(n, ' '), q(n, ' ');
    fore(i,0,n) cin >> p[i];
    fore(i,0,n) cin >> q[i];
    fore(i,0,n) s.pb(i+'1');
    int a, b, it = 1;
    do {
        if (p == s) a = it;
        if (q == s) b = it;
        it++;
    } while (next_permutation(s.begin(), s.end()));
    cout << abs(a-b) << endl;
}


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

int main() {
    ll MOD = 2019;
    ll L, R;
    cin >> L >> R;
    ll remainderL, remainderR;
    remainderL = L % MOD;
    remainderR = R % MOD;
    ll MIN = 1ll << 40;

    if (R-L >= 2019) {
        MIN = 0;
    }

    else if (remainderL >= remainderR) {
        MIN = 0;
    }

    else {
        for (int i = remainderL; i < remainderR; i++) {
            for (int j = i+1; j <= remainderR; j++) {
                ll product = i*j;
                product %= MOD;
                MIN = min(MIN, product);
            }
        }
    }

    cout << MIN << endl;
    return 0;
}

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

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    lli n, x=0;
    string s;
    cin >> n >> s;
    lli max = x;
    for(lli i=0; i<n; i++)
        if(s[i]=='I'){
            x = x + 1;
            if(max<x) max = x;
        }
        else
            x = x - 1;
    cout << max << endl;
    return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

template <typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) { return b ? gcd(b, a % b) : a; }
template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) { return (a != 0 && b != 0) ? a / gcd(a, b) * b : 0; }

template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
gcd(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = gcd(res, *first);
    return res;
}

template <typename ForwardIt>
constexpr typename iterator_traits<ForwardIt>::value_type
lcm(ForwardIt first, ForwardIt last)
{
    using val_t = typename iterator_traits<ForwardIt>::value_type;
    if (first == last) return static_cast<val_t>(0);
    val_t res = *first;
    while (++first != last) res = lcm(res, *first);
    return res;
}

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

    int x, y; cin >> x >> y;
    cout << gcd(x, y) << endl;
    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <cstring>
#include <string>

using namespace std;

#define MOD 100000007

int main(void){
	int dp1[100001], dp2[100001];
	memset(dp1,0,sizeof(dp1));
	memset(dp2,0,sizeof(dp2));
	dp1[1] = 1; dp1[2] = 2; dp1[3] = 4; dp1[4] = 8; dp1[5] = 16;
	dp2[1] = 1; dp2[2] = 2; dp2[3] = 4;
	
	for(int i=4;i<100001;i++){
		if(i >= 6){
			dp1[i] = 1;
			for(int j=1;j<=5;j++){
				dp1[i] += dp1[i-j] % MOD;
				dp1[i] %= MOD;
			}
		}
		dp2[i] = 1;
		for(int j=1;j<=3;j++){
			dp2[i] += dp2[i-j] % MOD;
			dp2[i] %= MOD;
		}
	}
	
	string str;
	while(cin >> str){
		if(str == "#") break;
		
		char c;
		int num;
		long long ret=1;
		
		c = str[0];
		num = 1;
		if(str.size() == 1){
			cout << 1 << endl;
		}else{
			for(int i=1;i<str.size();i++){
				if(str[i] == c){
					num++;
				}else{
					if(c == '0' || c == '8'){
						ret = ((long long)ret * dp2[num]) % MOD;
					}else{
						ret = ((long long)ret * dp1[num]) % MOD;
					}
					c = str[i];
					num = 1;
				}
			}
			if(c == '0' || c == '8'){
				ret = ((long long)ret * dp2[num]) % MOD;
			}else{
				ret = ((long long)ret * dp1[num]) % MOD;
			}
			cout << ret << endl;
		}
	}
}

Measured memory_bytes: 1932
#include<iostream>
#include<cstdio>
using namespace std;
int n;
char a[1010][1010];
char ans3[101][101]={"aab","b.b","baa"};
char ans4[101][101]={"aaba","ccba","abcc","abaa"};
char ans5[101][101]={"abb.a",
"a.a.a",
"bbabb",
"cacc.",
"ca.aa"};
char ans7[101][101]=
{"aabb..a",
"...ab.a",
"..bab..",
"aab.aa.",
"..ab.bb",
"..aba..",
"aa..abb"};
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	a[i][j]='.';
	if(n==1||n==2) puts("-1");
	else
	{
		if(n%3==0)
		{
			for(int i=1;i<=n;i+=3)
			{
				for(int j=0;j<3;j++)
				for(int k=0;k<3;k++)
				a[i+j][i+k]=ans3[j][k];
			}
		}
		else if(n%4==0)
		{
			for(int i=1;i<=n;i+=4)
			{
				for(int j=0;j<4;j++)
				for(int k=0;k<4;k++)
				a[i+j][i+k]=ans4[j][k];
			}
		}
		else if(n%5==0)
		{
			for(int i=1;i<=n;i+=5)
			{
				for(int j=0;j<5;j++)
				for(int k=0;k<5;k++)
				a[i+j][i+k]=ans5[j][k];
			}
		}
		else if(n%7==0)
		{
			for(int i=1;i<=n;i+=7)
			{
				for(int j=0;j<7;j++)
				for(int k=0;k<7;k++)
				a[i+j][i+k]=ans7[j][k];
			}
		}
		else if(n==11)
		{
			int i=1;
			for(int j=0;j<4;j++)
			for(int k=0;k<4;k++)
			a[i+j][i+k]=ans4[j][k];
			i=5;
			for(int j=0;j<7;j++)
			for(int k=0;k<7;k++)
			a[i+j][i+k]=ans7[j][k];
		}
		else
		{
			for(int k1=0;k1*4<=n;k1++)
			if((n-k1*4)%5==0)
			{
				for(int i=1;i<=k1*4;i+=4)
					for(int j=0;j<4;j++)
					for(int k=0;k<4;k++)
					a[i+j][i+k]=ans4[j][k];
				for(int i=k1*4+1;i<=n;i+=5)
					for(int j=0;j<5;j++)
					for(int k=0;k<5;k++)
					a[i+j][i+k]=ans5[j][k];
				break;
			}
		}
		for(int i=1;i<=n;i++)
		printf("%s\n",a[i]+1);
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
	vector<char> st;
	int n;
	char c;
	scanf("%d", &n);
	scanf(" %c", &c);
	st.push_back(c);
	for(int i = 1; i < n; ++i){
		scanf(" %c", &c);
		if(c != st.back()) st.push_back(c); 
	}
	printf("%lu\n", st.size());
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {

	int n, h[101], answer, highest;

	h[0] = {0};
	cin >> n;
	answer = 0;

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

		if (i == 0)highest = h[i];
		if (highest <= h[i]) {
			answer++;
			highest = h[i];
		}
	}
	cout << answer << endl;

	//cin >> /*変数他*/;
	//cout << /*文字列*/ << endl;
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
ans=[[0]*(3*k+10) for i in range(4*k+10)]
for i in range(n):
    x,y,c=input().split()
    x=int(x)
    y=int(y)
    a=x//k%2
    b=x%k
    d=y//k%2
    e=y%k
    x=b+a*k
    y=e+d*k
    if (a+d)%2==0:
        if c=="B":

            x=k-b
            y=k-e

        else:
            x=2*k-b
            y=k-e
    else:
        if c == "W":
            x = k - b
            y = k - e

        else:
            x = 2 * k - b
            y = k - e

    ans[x][y]+=1
    ans[x][y+k]-=1
    ans[x+k][y]-=1
    ans[x+k][y+k]+=1


for i in range(4*k+9):
    for j in range(3*k+9):
        ans[i][j+1]=ans[i][j]+ans[i][j+1]
for i in range(4*k+9):
    for j in range(3*k+9):
        ans[i+1][j]=ans[i][j]+ans[i+1][j]
anser=0

for x in range(k,2*k):
    for y in range(k,2*k):
        p=ans[x][y]+ans[x-k][y-k]+ans[x-k][y+k]+ans[x+k][y+k]+ans[x+k][y-k]+ans[x+2*k][y]
        anser=max(anser,p)
for x in range(2*k,3*k):
    for y in range(k,2*k):
        p = ans[x][y] + ans[x - k][y - k] + ans[x - k][y + k] + ans[x + k][y + k] + ans[x + k][y - k]+ans[x-2*k][y]
        anser = max(anser, p)
print(anser)









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

tmp = "abcdefghij"

ans = ""

i = 1


def mkstr(ans, i):
    if len(ans) >= N:
        print(ans)
    else:
        for j in range(i):
            if j == i - 1:
                mkstr(ans + tmp[j], i + 1)
            else:
                mkstr(ans + tmp[j], i)


mkstr(ans, i)


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int dpa[n+1],dpb[n+1],dpc[n+1];
    dpa[0]=dpb[0]=dpc[0]=0;
    int prev=0;
    for(int i=1;i<=n;i++){
        dpa[i]=a[i-1]+max(dpb[i-1],dpc[i-1]);
        dpb[i]=b[i-1]+max(dpa[i-1],dpc[i-1]);
        dpc[i]=c[i-1]+max(dpa[i-1],dpb[i-1]);
    }
    cout<<max(max(dpa[n],dpb[n]),dpc[n]);
}

Measured memory_bytes: 2560
from collections import Counter
 
n = int(input())
cnt = Counter(input().split())
c1, c2, c3 = cnt['1'], cnt['2'], cnt['3']
total = c1 + 2 * c2 + 3 * c3
c23 = c2 + c3
dp = [[[0.0] * (c3 + 1) for _ in range(c2 + c3 + 1)] for _ in range(n + 2)]  # ←ここを0で初期化するとTLE
 
for k in range(1, n + 1):
    still = n / k
    for a1 in range(k, max(-1, 2 * k - total - 1, k - c23 - 1), -1):
        dpap, dpac, dpan = dp[a1 - 1], dp[a1], dp[a1 + 1]
        for a2 in range(min(k - a1, c2 + c3), max(-1, 3 * k - 2 * a1 - total - 1, k - a1 - c3 - 1), -1):
            a3 = k - a1 - a2
            tmp = 0
            if a1:
                tmp += dpap[a2][a3] * a1
            if a2:
                tmp += dpan[a2 - 1][a3] * a2
            if a3:
                tmp += dpac[a2 + 1][a3 - 1] * a3
            dpac[a2][a3] = tmp / k + still
print(dp[c1][c2][c3])

Measured memory_bytes: 254856