akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define str string
#define vint vector<int>
#define vchar vector<char>
#define vool vector<bool>
#define pb() pushback
#define elif else if

main(){
    int b,c,count=1,count2=0;
    double a=0.000000;
    str SA,SB;
    cin>>a;
    for(int i=a;i>0;i--){
        count*=i;
        count%=(1000000000+7);
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX_N 200000
#define sum(l,r) (s[r]-s[l])
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n; lnt m, s[MAX_N+5];
int main() {
	read(n), read(m);
	for (int i = 1; i <= n; i++)
		read(s[i]), s[i] += s[i-1];
	lnt mi = s[n]*5+m*n*2, tot;
	for (int i = 1; i <= (n+1)/2; mi = min(mi, tot), i++) {
		tot = m*(n+i)+sum(max(0, n-2*i), n)*5; lnt c = 7;
		for (int j = n-2*i; tot < mi && j > 0; j -= i, c += 2)
			tot += sum(max(0, j-i), j)*c;
	}
	return printf("%lld\n", mi), 0;
}

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

#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define laglo cerr << "Ti : " << clock() * 1.0 / CLOCKS_PER_SEC  << endl;
#define endl '\n';
#define ll long long
ll a[2000007];
int main() {
	ioso;// kholo;
	long long n,k; cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> a[i];
	}
	sort(a,a+n);
	ll sum = 0;
	for(int i=0;i<n-k;i++) {
		sum+=a[i];
	}
	cout << sum << endl;
	//laglo;
}

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

#define MAX 1000000000

int main(void){
    long long N, K;
    vector<long long> A;
    int a;

    cin >> N >> K;
    for(int i = 0; i < N; ++i){
        cin >> a;
        A.push_back(a);
    }

    /*
    これがダメな理由どなたか教えてください。
    long long max = *max_element(A.begin(), A.end()) + 1;
    long long min = *min_element(A.begin(), A.end());
    */
    long long max = MAX + 1;
    long long min = 0;
    long long mid;
    int d, CountCut;
    while(max - min > 1){
        CountCut = 0;
        mid = (max + min) / 2;
        for(int i = 0; i < N; ++i){
            d = (A[i] +mid - 1) / mid - 1;
            if(d > 0) CountCut += d;
        }
        if (CountCut <= K) max = mid;
        else min = mid;
    }

    cout << max << endl;
}


Measured memory_bytes: 5372
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string s;
	scan(s);
	int sum=0;
	rep(i,s.size()){
		if(s[i]=='o') sum++;
	}
	sum+=15-s.size();
	if(sum>=8) prin("YES");
	else prin("NO");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll b = 0;
  rep(i,n) {
    cin >> a[i];
    b += a[i];
  }
  ll s = n * (n + 1) / 2;
  if (b % s != 0) {
    cout << "NO" << endl;
    return(0);
  }
  ll x = b / s;
  vector<ll> d(n);
  rep(i,n) {
    d[i] = a[i] - a[(i+1)%n];
    d[i] += x;
  }
  bool ok = true;
  rep(i,n) {
    if (d[i] < 0 || d[i] % n != 0) ok = false;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return(0);
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                string card = Console.ReadLine();
                if (card.CompareTo("-") == 0)
                    break;

                int shuffle_count = int.Parse(Console.ReadLine());
                for (int i = 0; i < shuffle_count; i++)
                {
                    int h = int.Parse(Console.ReadLine());
                    string s1 = card.Substring(0, h);
                    string s2 = card.Substring(h, card.Length - h);
                    card = s2 + s1;
                }
                Console.WriteLine(card);
            }
        }
    }
}

Measured memory_bytes: 9888
s = input()
mod = 10**9 + 7
dp = [[0]*13 for i in range(len(s)+1)]
dp[0][0] = 1
for i in range(len(s)):
    for j in range(13):
        if s[i] != '?':
            dp[i + 1][(j*10 + int(s[i]))%13] += dp[i][j]
            dp[i + 1][(j*10 +int(s[i]))%13] %= mod
        else:
            for k in range(10):
                dp[i + 1][(j*10 + k) % 13] += dp[i][j]
                dp[i + 1][(j*10 + k) % 13] %= mod
print(dp[len(s)][5]%mod)



Measured memory_bytes: 63892
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vi adj[123456];
vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

int dp[111111][2];

void dfs(int u, int p=-1)
{
	int prod=1; int prod2=1;
	for(int v:adj[u])
	{
		if(v==p) continue;
		dfs(v,u);
		prod=mult(prod,add(dp[v][0],dp[v][1]));
		prod2=mult(prod2,dp[v][0]);
	}
	dp[u][0]=prod; dp[u][1]=prod2;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int u,v; cin>>u>>v; u--; v--; adj[u].pb(v); adj[v].pb(u);
	}
	dfs(0);
	int ans=0;
	ans=add(ans,dp[0][0]);
	ans=add(ans,dp[0][1]);
	cout<<ans<<'\n';
}


Measured memory_bytes: 14080
using System;

namespace Hoge
{
    class Program
    {
        static void Main()
        {
            string s = Console.ReadLine();
            int count = 0;
            foreach (var i in s)
            {
                if (i == 'o') count++;
            }
            Console.Write(700 + count * 100);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

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

    rep(i,S.length()) {
        if (i % 2 == 0 && S[i] == 'L' || i % 2 == 1 && S[i] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main() {

  int num;
  cin >> num;

  for (int i=0; i<num; i++) {
    int k, p;
    cin >> k >> p;
    int ans = k % p;
    if (ans == 0) cout << p << endl;
    else cout << ans << endl;
  }


	return 0;
}

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

#define mod 10e9+7
#define ll long long int

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int k[m];
    int s[m][10];
    for(int i = 0;i < m;i++){
        for(int j = 0;j < 10;j++){
            s[i][j] = 0;
        }
    }
    int p[m];
    for(int i = 0;i < m;i++){
        scanf("%d", &k[i]);
        for(int j = 0;j < k[i];j++){
            int a;
            scanf("%d", &a);
            s[i][a-1] = 1;
        }
    }
    
    for(int i = 0;i < m;i++){
        scanf("%d", &p[i]);
    }
    int ans = 0;
    for(int s1 = 0;s1 <= 1;s1++){
    for(int s2 = 0;s2 <= 1;s2++){
    for(int s3 = 0;s3 <= 1;s3++){
    for(int s4 = 0;s4 <= 1;s4++){
    for(int s5 = 0;s5 <= 1;s5++){
    for(int s6 = 0;s6 <= 1;s6++){
    for(int s7 = 0;s7 <= 1;s7++){
    for(int s8 = 0;s8 <= 1;s8++){
    for(int s9 = 0;s9 <= 1;s9++){
    for(int s10 = 0;s10 <= 1;s10++){
        int count = 0;
        for(int i = 0;i < m;i++){
            if((s1*s[i][0]+s2*s[i][1]+s3*s[i][2]+s4*s[i][3]+s5*s[i][4]+s6*s[i][5]+s7*s[i][6]+s8*s[i][7]+s9*s[i][8]+s10*s[i][9])%2 == p[i])count++;
        }
        if(count == m)ans++;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    int div = (int)pow(2, 10-n);
    printf("%d\n", ans/div);
    return 0;
}

Measured memory_bytes: 384
s = input()

keta = int(len(s))
cases = 2 ** (keta - 1)

lst = []
for i in range(cases):
    sushiki_moji = s[0]
    adjust = format(i, 'b').zfill(keta - 1)
    for j in range(keta - 1):
        if adjust[j] == '1':
            sushiki_moji += '+'
        sushiki_moji += s[j+1]
    lst.append(sushiki_moji)

eval_number = [eval(i) for i in lst]
print(sum(eval_number))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if(
		(b-a) > k
		||
		(c-a) > k
		||
		(d-a) > k
		||
		(e-a) > k
		||
		(c-b) > k
		||
		(d-b) > k
		||
		(e-b) > k
		||
		(d-c) > k
		||
		(e-c) > k
		||
		(e-d) > k
	){
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [int(x) for x in input().split()]
 
for i in range(n):
    a = l[i]
    j = i - 1
 
    while j >= 0 and l[j] > a:
        l[j+1] = l[j]
        j = j - 1
 
    l[j+1] = a
    print(*l)

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

int main(void)
{
    int count, a[100], i, N;

    cin >> N;
    for (i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    count = a[0];
    for (i = 0; i < N - 1; i++)
    {
        if (a[i] < a[i + 1])
        {
            count = count + a[i + 1] - a[i];
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
    ll x,y;
    cin >> x >> y;
    ll cnt=0, num=x;
    while(num <= y){
        cnt++;
        num *= 2;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

k=0
for i in range(len(S)):
    if S[i].islower():
        S = S.replace(S[i],A[k])
        k=k+1


k=0
for i in range(len(T)):
    if T[i].islower():
        T = T.replace(T[i],A[k])
        k=k+1

print('Yes' if S==T else 'No')

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main()
{
    int N;
    while(~scanf("%d",&N))
    {
        int T,A,logo=0;
        scanf("%d %d ",&T,&A);
        int a[1000],i;
        for(i=0; i<N; i++)
            scanf("%d",&a[i]);
        float c[1000],min;
        for(i=0; i<N; i++)
            c[i]=fabs(T-a[i]*6.0/1000-A);
        min=c[0];
        for(i=0; i<N; i++)
        {
            if(min>c[i])
            {
                min=c[i];
                logo=i;
            }
        }
        printf("%d\n",logo+1);
    }
}


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


namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {

            string A = Console.ReadLine();
            string B = Console.ReadLine();
            string C = Console.ReadLine();

            int countA = 0;//
            int countB = -1;
            int countC = -1;
            var flagA = true;
            var flagB = false;
            var flagC = false;


            while (A.Length > countA && B.Length > countB && C.Length > countC)
            {


                if (flagA == true)
                {
                    flagA = false;
                    if (A[countA] == 'a')
                    {
                        countA++;
                        flagA = true;
                    }
                    else if (A[countA] == 'b')
                    {
                        countB++;
                        flagB = true;
                    }
                    else if (A[countA] == 'c')
                    {
                        countC++;
                        flagC = true;
                    }
                }
                else if (flagB == true)
                {
                    flagB = false;
                    if (B[countB] == 'a')
                    {
                        countA++;
                        flagA = true;
                    }
                    else if (B[countB] == 'b')
                    {
                        countB++;
                        flagB = true;
                    }
                    else if (B[countB] == 'c')
                    {
                        countC++;
                        flagC = true;
                    }
                }
                else if (flagC == true)
                {
                    flagC = false;
                    if (C[countC] == 'a')
                    {
                        countA++;
                        flagA = true;
                    }
                    else if (C[countC] == 'b')
                    {
                        countB++;
                        flagB = true;
                    }
                    else if (C[countC] == 'c')
                    {
                        countC++;
                        flagC = true;
                    }
                }
            }

            if (flagA == true)
            {
                Console.WriteLine('A');
            }
            else if(flagB == true)
            {
                Console.WriteLine('B');
            }
            else
            {
                Console.WriteLine('C');
            }


        }

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int l ,r,  d;
    cin >> l >> r >> d;
    int ans = 0;
    srep(i,l,r+1){
        if(i % d == 0)ans++;
    }
    cout << ans << endl;
    return 0;
}




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

using namespace std;

int n;
double ta;
long double r[505], x[505], ans;

long double sq(long double a) {
	return a * a;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%lf", &ta);
		x[i] = r[i] = ta;
		for (int j = 0; j < i; j++)
			x[i] = max(x[i], x[j] + sqrt(sq(r[i] + r[j]) - sq(r[i] - r[j])));
		ans = max(ans, x[i] + r[i]);
	}
	printf("%.10lf\n", (double)ans);
	return 0;
}

Measured memory_bytes: 3204
// #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solve(MuMIS &result){
	foreach_it(MuMIS, it, result){
		cout << (*it).second << "," << (*it).first << endl;
	}
}

int main(){
	fastIO;
	int n, a = 0, b = 0, c = 0;
	string teamName;
	cin >> n;
	while (n){
		MuMIS result;
		while (n--){
			cin >> teamName >> a >> b >> c;
			result.insert(MP(a * 3 + c, teamName));
		}
		solve(result);
		cin >> n;
		if (n)
			cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa;cin>>nyaa;

typedef pair<ll, ll> LP;
int max_n;
const int mn = 100000;
struct edge {
	int to, cap;ll cost; int rev;
};
vector<edge> G[mn];
LP par[mn];
ll dist[mn];
void add_edge(int from, int to, int cap, ll cost) {
	G[from].push_back({ to,cap,cost,(int)G[to].size() });
	G[to].push_back({ from,0,-cost,(int)G[from].size() - 1 });
	max_n = max({ max_n,from + 1,to + 1 });
}
LP minimum_road(int s, int t) {
	fill(par, par + max_n, LP{ -1,-1 });
	fill(dist, dist + max_n, INF);
	dist[s] = 0;
	priority_queue<LP, vector<LP>, greater<LP>> q; q.push({ 0,s });
	while (!q.empty()) {
		LP p = q.top(); q.pop();
		int id = p.second;
		if (id == t)continue;
		if (p.first > dist[id])continue;
		rep(j, G[id].size()) {
			if (G[id][j].cap > 0) {
				int to = G[id][j].to;
				ll nd = p.first + G[id][j].cost;
				if (nd < dist[to]) {
					dist[to] = nd;
					par[to] = { id,j };
					q.push({ dist[to],to });
				}
			}
		}
	}
	int cur = t;
	int f = mod;
	while (cur != s) {
		int p = par[cur].first, j = par[cur].second;
		if (p < 0)return { -1,-1 };
		f = min(f, G[p][j].cap);
		cur = p;
	}
	cur = t;
	while(cur!=s){
		int p = par[cur].first, j = par[cur].second;
		if (p < 0)return { -1,-1 };
		G[p][j].cap -= f;
		if (G[p][j].rev >= 0) {
			G[cur][G[p][j].rev].cap += f;
		}
		cur = p;
	}
	return { dist[t],f };
}
ll minimum_cost_flow(int s, int t, int k) {
	ll ret = 0;
	rep(i, k) {
		LP z = minimum_road(s, t);
		if (z.first < 0)return -1;
		if (k - i <= z.second) {
			ret += z.first*(k - i); break;
		}
		i += z.second - 1;
		//cout << z.first*z.second << endl;
		ret += z.first*z.second;
	}
	return ret;
}

void Z_algorithm(const string &s,vector<int> &a) {
	int sz = s.size();
	a.resize(sz);
	a[0] = sz;
	int i = 1, j = 0;
	while (i < sz) {
		while (i + j < sz&&s[j] == s[i + j])++j;
		a[i] = j;
		if (j == 0) {
			++i; continue;
		}
		int k = 1;
		while (i + k < sz&&k + a[k] < j)a[i + k] = a[k], ++k;
		i += k; j -= k;
	}
}


void solve() {
	int n; cin >> n;
	vector<string> s(n);
	rep(i, n)cin >> s[i];
	int sta = 2 * n; int goal = sta + 1;
	rep(i, n) {
		add_edge(sta, i, 1, 0);
		add_edge(i + n, goal, 1, 0);
	}
	rep(i, n) {
		rep(j, n) {
			string u = s[j] + "#" + s[i];
			vector<int> ra;
			Z_algorithm(u, ra);
			int cost = 0;
			Rep(k, s[j].size() + 2, u.size()) {
				if (k + ra[k] == u.size()) {
					cost = ra[k]; break;
				}
			}
			add_edge(i, j + n, 1, mod - cost);
			//cout << i << " " << j << " " << cost << endl;
		}
	}
	ll f = minimum_cost_flow(sta, goal, n);
	f -= mod * n;
	//cout << f << endl;
	rep(i, n) {
		f += s[i].size();
	}
	cout << f << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 6092
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <set>
#include <map>
#include <deque>
#include <cmath>
#include <queue>
#include <random>
#include <bitset>
#include <time.h>
#include <string>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
//#define endl '\n'
#define mp make_pair
#define pbc push_back
#define pob pop_back()
#define empb emplace_back
#define sp system("pause")
#define queuel queue<long long>
#define all(x) (x).begin(),(x).end()
#define matrix vector<vector<ll>>
#define pin(p) cin >> p.first >> p.second;
#define rev(v) reverse(v.begin(),v.end());
#define mx(v) max_element(v.begin(), v.end());
#define mn(v) min_element(v.begin(), v.end());
#define sout(s, c) for(auto i : s) cout << i << c;
#define pout(p) cout << p.first << " " << p.second;
#define er(v, l, r) erase(v.begin() + l, v.begin() + r);
#define vin(v) for(ll i = 0; i < v.size(); ++i) cin >> v[i];
#define vout(v, c) for(int i = 0; i < v.size(); ++i) cout << v[i] << c;
#define pushi(v, a) for(int i = 0; i < a.size(); ++i) v.push_back(a[i]);
#define sin(s, n) for(int i = 0; i < n; ++i){int a; cin >> a; s.insert(a);}
#define fastio() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
using namespace std;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++--++
const ll INF = 1000LL * 1000 * 1000 * 1000 * 1000 * 1000;
const int inf = 1000 * 1000 * 1000;
const ld PI = acos(-1.0);
const ll mod1 = inf + 7;
const ll mod2 = inf + 9;
const int MAXN = 500001;
const ld EPS = 1e-9;
int hp = 179;

signed main()
{
	fastio();
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for (int a = 1; a <= n; ++a)
	{
		int l = a % k;
		int ned = k - l;
		int cned = n / k;
		if (n%k >= ned)
		{
			cned++;
		}
		if ((2 * ned) %k == 0)
		{
			ans += 1LL * cned *cned;
		}
	}
	cout << ans;
	system("pause");
}

Measured memory_bytes: 504
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    ll n,k;
    cin >> n >> k;
    ll h[n];
    rep(i, n) {
        cin >> h[i];
    }

    ll dp[n+1];
    dp[0] = 0;
    for(ll i= 1; i<n; i++) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        ll leng = min(k, i)+1;
        FOR(j, 1, leng) {
            chmin(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    } 

    print(dp[n-1]);
    return 0;
}


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

#define MOD 1000000007
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
LL fact[1100000];
LL invfact[1100000];

LL ncr(LL n, LL r){
    if(r < 0 || n < 0) return 0;
    if(n < r) return 0;
    LL a = fact[n];
    a = (a * invfact[r]) % MOD;
    a = (a * invfact[n-r]) % MOD;
    return a;
}
void init(){
    fact[0] = 1;
    invfact[0] = 1;
    LL inv2 = inv(2);
    for(LL i = 1; i < 1100000; i++){
        fact[i] = (i*fact[i-1]) % MOD;
        invfact[i] = inv(fact[i]);
    }
}

int main(){
    init();
    LL A, B;
    cin >> A >> B;
    LL ans = 0;
    for(LL b = 1; b <= B; b++){
        // number of B's
        if(b == B){
            ans += (A+1);
            continue;
        }
        LL B2 = B - b;
        for(LL b2 = 1; b2 <= B2; b2++){
            LL num = ncr(B-1, b-1);
            num *= ncr(B2-1, b2-1);
            num %= MOD;

            LL B3 = B2 - b2;

            LL aleft = A+B - B - B2 - B3;
            if(aleft < 0) continue;
            num = num * ncr(aleft + 2, 2);
            num %= MOD;
            ans += num;
            ans %= MOD;
            //cout << b << " " << b2 << " " << num << endl;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
#define lowbit(x) (x&(-x))
#define CSE(x,y) memset(x,y,sizeof(x))
#define INF 0x3f3f3f3f
#define Abs(x) (x>=0?x:(-x))
#define FAST ios::sync_with_stdio(false);cin.tie(0);
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int maxn = 111;

int main()
{
	int n, a[maxn], ans = 0;
	CSE(a, 0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] & 1 && i & 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3632
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
couA = 0
couB = 0
for i in range(0,len(a),2):
    couA +=a[i]
for j in range(1,len(a),2):
    couB +=a[j]
print(couA-couB)

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


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    long long int n;
    cin >> n;
    long long int remainder = n%500;
    long long int coin = n/500;
    remainder = remainder/5;
    unsigned long long int ans = coin*1000 + remainder*5;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    for(int i = 0;i < n;i++){
        for(int j = 0;j < d;j++){
            cin >> x[i][j];
        }
    }
    int ans = 0;
    double dist;
    for(int i = 1;i < n;i++){
        for(int j = 0;j < i;j++){
            dist = 0;
            for(int k = 0;k < d;k++){
                dist += pow((x[i][k] - x[j][k]),2);
            }
            dist = pow(dist,0.500000);
            if(ceil(dist) == floor(dist))ans++;
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import sys

if sys.getrecursionlimit()<10**7:
    sys.setrecursionlimit(10**7)

N=int(input())
ver=[[] for _ in range(N)]
for _ in range(N-1):
    u,v,W=map(int,input().split())
    ver[u-1].append((v-1,W))
    ver[v-1].append((u-1,W))
his=[-1 for _ in range(N)]

def dfs(i,col):
    his[i]=col
    for j,w in ver[i]:
        if his[j]==-1:
            if w%2==0:
                dfs(j,col)
            else:
                dfs(j,(col+1)%2)

dfs(0,0)            
for i in range(N):
    print(his[i])


Measured memory_bytes: 79488
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

int main(){
	// sankou http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=546884#1
	string in_line, in;

	while (getline(cin, in_line)){
		stack<double> sta;
		istringstream stream(in_line);
		while (stream >> in){
			if (isdigit(in[0]) || in.length() >= 2){
				// 文字列inは数値なのでpushする.
				// string -> char -> double
				sta.push(atof(in.c_str()));
			}
			else{
				// a+b a-b a*b a/b
				double b = sta.top(); sta.pop();
				double a = sta.top(); sta.pop();

				double temp = 0.0;
				if (in[0] == '+')			temp = a + b;
				else if (in[0] == '-')		temp = a - b;
				else if (in[0] == '*')		temp = a * b;
				else						temp = a / b;
				sta.push(temp);
			}
		}
		printf("%.7lf\n", sta.top());
	}
	return 0;
}

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

int main() {
    int X;
    cin >> X;
    int a = X/500;
    int r = X%500;
    int b = r/5;
    int ans = a*1000+b*5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_ord(int ary[], int length) {
	int max;
	max = max_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_num(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_ord(int ary[], int length) {
	int min;
	min = min_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int main() {
	int n, cnt = 0, max = 0, x, num = 0;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	int i = 1;
	for(; i <= n; i++) {
		cnt = 0;
		x = i;
		while (x % 2 == 0) {
			x /= 2;
			cnt++;
		}
		if (max < cnt) {
			max = cnt;
			num = i;
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
s = []
for _ in range(m):
    _, *args = map(int, input().split())
    s.append(args)
p = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
    for j in range(m):
        sw = 0
        for k in range(n):
            if (i >> k) & 1 and k + 1 in s[j]:
                sw += 1
        if sw % 2 != p[j]:
            break
    else:
        ans += 1
print(ans)


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

using namespace std;

//FILE *fi=freopen("1.txt","r",stdin);

int n,a[100001][100],d[100001][100];

void nhap()
{
    scanf("%d",&n);
    for (int i=1;i<=n;++i)
    {
        for (int j=1;j<=3;++j)
        {
            scanf("%d",&a[i][j]);
        }
    }
}

void process()
{
    for (int j=1;j<=3;++j)
        d[1][j]=a[1][j];
    for (int i=2;i<=n;++i)
    {
        for (int j=1;j<=3;++j)
        {
            for (int x=1;x<=3;++x)
            {
                if (x!=j)
                {
                    d[i][j]=max(d[i][j],d[i-1][x]);
                }
            }
            d[i][j]+=a[i][j];
        }
    }
    cout<<max(d[n][1],max(d[n][2],d[n][3]));
}

int main()
{
    nhap();
    process();
    return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

ll p5(ll a) {
    return a * a * a * a * a;
}

int main() {
    ll X;
    cin >> X;
    vector<ll> v(1, 0);
    for (ll i=1; ; ++i) {
        if (p5(i) - p5(v.back()) > X) break;
        v.push_back(i);
    }

    vector<ll> v2;
    for (int i=0; i<(int)v.size(); ++i) {
        v2.push_back(v[i]);
        v2.push_back(-v[i]);
    }

    for (int i=0; i<(int)v2.size(); ++i) {
        for (int j=0; j<(int)v2.size(); ++j) {
            if (p5(v2[i]) - p5(v2[j]) == X) {
                cout << v2[i] << " " << v2[j] << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3640
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[] args)throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int t=Integer.parseInt(st.nextToken());
      	if(t%2==0)
          System.out.println(t);
      	else
          System.out.println(2*t);
    }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<string.h>
using namespace std;

#define LIM 48828125
#define LEN 13

char H[LIM][LEN];


int toInt(char str) {
  if ( str == 'A' ) return 1;
  else if ( str == 'C' ) return 2;
  else if ( str == 'G' ) return 3;
  else if ( str == 'T' ) return 4;
  else return 0;
}

long long getKey(char str[]) {
  int i, m, p = 1, sum = 0;
  for ( i = 0; i < strlen(str); i++ ) {
    m = toInt(str[i]);
    sum += m * p;
    p *= 5;
  }
  return sum;
}

int h1(long long key) { return key % LIM; }
int h2(long long key) { return 1 + (key % (LIM - 1)); }
long long hashValue(long long key, int i) { return h1(key) + i * h2(key); }

int insert(char str[]) {
  long long key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    long long h = hashValue(key, i);
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 1;
    }
  }
  return 0;
}
int find(char str[]) {
  long long key = getKey(str);
  for ( int i = 0; i < LIM; i++ ) {
    long long h = hashValue(key, i);
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int main() {
  int n;
  char com[6], str[12];
  scanf("%d", &n);

  while( scanf("%s %s", com, str) != EOF ) {
    if ( com[0] == 'i' ) {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 48432
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

typedef unsigned long long ull;

const ull INF = ULLONG_MAX/3;

void add(int s, int t, ull x, vector<ull> &xList, vector<ull> &sxList){
    int nn = xList.size();
    int sn = sxList.size();
    int ss = s/sn;
    int tt = t/sn;
    if(ss == tt){
        for (int i=0;i<t-s+1;i++){
            xList[s+i] += x;
        }
    }else{
        for(int i=s;i<(ss+1)*sn;i++){
            xList[i] += x;
        }

        for(int i=tt*sn;i<t+1;i++){
            xList[i] += x;
        }

        for(int i=ss+1;i<tt;i++){
            sxList[i] += x;
        }
    }
}

void get(int ind, vector<ull> &xList, vector<ull> &sxList){
    int nn = xList.size();
    int sn = sxList.size();
    cout << xList[ind] + sxList[ind/sn]<< endl;
}

int main(){
    int n, q, qType, s, t,ind;
    ull x;
    cin >> n >> q;
    int sn = sqrt(n)+1;

    vector<ull> xList(sn*sn, 0);

    vector<ull> sxList(sn, 0);

    for (int i=0;i<q;i++){
        cin >> qType;
        if (qType == 0){
            cin >> s >> t >> x;
            add(s,t,x,xList,sxList);
        }else{
            cin >> ind;
            get(ind, xList, sxList);
        }
        /*
        for (int i=0;i<sn*sn;i++){
            cout << xList[i]  << " ";
        }
        cout << endl;
        for (int i=0;i<sn;i++){
            cout << sxList[i] << " ";
        }
        cout << endl;
        */
    }
    return 0;
}

Measured memory_bytes: 3612
#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 mod = 10000;

	int n,k; cin >> n >> k;

	int s[101]; memset(s,0,sizeof(s));

	for (int i = 0;i < k;i++){
		int a,b; cin >> a >> b;
		s[a-1] = b;
	}

	int dp[200][4][2]; memset(dp,0,sizeof(dp));

	if(s[0] > 0) dp[0][s[0]][0] = 1;
	else{ dp[0][1][0] = 1; dp[0][2][0] = 1; dp[0][3][0] = 1;}

	for (int i = 0;i < n;i++){
		for (int j = 1;j <= 3;j++){
			for (int k = 0;k < 2;k++){
				if(dp[i][j][k] == 0) continue;
				//cout << dp[i][j][k] << endl;
				int ni = i+1;
				dp[i][j][k] %= mod;
				if(s[ni] > 0){
					if(j == s[ni]){
						if(k == 0) dp[i+1][j][1] += dp[i][j][k];
					}else{
						dp[i+1][s[ni]][0] += dp[i][j][k];
					}
				}else{
					if(k == 0){
						for (int l = 1;l <= 3;l++){
							if(l == j) dp[i+1][l][1] += dp[i][j][k];
							else dp[i+1][l][0] += dp[i][j][k];
						}
					}else{
						for (int l = 1;l <= 3;l++){
							if(l == j) continue;
							dp[i+1][l][0] += dp[i][j][k];
						}
					}
				}
			}
		}
	}

	int ans = 0;

	for (int i = 1;i <= 3;i++){
		for (int j = 0;j < 2;j++){
			//cout << dp[n][i][j] << endl;
			ans += dp[n-1][i][j];
			ans %= mod;
		}
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3148
#include <stdio.h>
#include <stdlib.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;

int main(void)
{
    int n;
    char s[4001];
    ll del = 0, r = 0, g = 0, b = 0, ans;
    char pre[2][2], cnt = 0;
    scanf("%d%s", &n, s);
    rep(i, n)
    {
        switch (s[i])
        {
        case 'R':
            r++;
            break;
        case 'G':
            g++;
            break;
        case 'B':
            b++;
            break;
        }
    }
    for (int i = 1; i < n; i++)
    {
        if (1 + i * 2 > n)
            break;
        rep(j, n - i * 2)
        {
            if (j + i * 2 > n)
                break;
            if (s[j] != s[j + i] && s[j] != s[j + i * 2] && s[j + i] != s[j + i * 2])
                del++;
        }
    }

    ans = r * g * b - del;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b, s;
  cin >> a >> b;
  
  s = 0;
  
  s += max(a, b);
  if(a > b)
    a--;
  else
    b--;
  s += max(a, b);
  
  cout << s << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,arr[300005];
     cin>>t;
     t*=3;
     for(int i=1;i<=t;i++)
     {
         cin>>arr[i];
     }
     sort(arr+1,arr+(t+1));
     ll cnt=0,sum=0;
     for(int i=t;i>t/3;i--)
     {
         if(cnt%2==1)
            sum+=arr[i];
         cnt++;
     }
     cout<<sum<<endl;
}


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

#define ull unsigned long long
#define ul unsigned long
#define ll long long
#define size_t long long
// std::sort(&a[0], &a[4], [](auto& x, auto& y){return x[0] < y[0];});
//accumulate(&arr2[n], &arr2[m-1], 0);
using namespace std;

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

  ll L,R;
  std::cin >> L >> R;
  int ans = 2020;
  for (int i = (int)L%2019; i <= (int)L%2019 + min((int)(R-L),2019) - 1; i++) {
    for (int j = i+1; j <= (int)L%2019 + min((int)(R-L),2019) ; j++) {
      ans = min(ans,(i*j)%2019);
    }
    if(ans == 0) break;
  }

  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 100000 + 5;

struct process {
  string name;
  int time;
};

process Q[MAXN];
int head, tail;
int n, q, total_time = 0;

void enqueue(process x) {
  Q[tail] = x;
  tail++;
  tail %= MAXN;
}

process dequeue() {
  process x = Q[head];
  head++;
  head %= MAXN;
  return x;
}

bool isEmpty() {
  return head == tail;
}

int main() {
  cin >> n >> q;
  for (int i = 0; i < n; i++) {
    cin >> Q[i].name >> Q[i].time;
  }
  head = 0, tail = n;
  while (!isEmpty()) {
    process crt = dequeue();
    int need = min(crt.time, q);
    crt.time -= need;
    total_time += need;
    if (crt.time == 0) {
      cout << crt.name << " " << total_time << endl;
    } else {
      enqueue(crt);
    }
  }
  return 0;
}

Measured memory_bytes: 7076
N,M=(int(i) for i in input().split())
denkyu=[]
for i in range(M):
    denkyu.append([int(i) for i in input().split()])
p=[int(i) for i in input().split()]
import copy
swi=[[0],[1]]
for _ in range(N-1):
    swi1=copy.deepcopy(swi)
    swi2=copy.deepcopy(swi)
    for i in range(len(swi)):
        swi1[i].append(0)
        swi2[i].append(1)
    swi=swi1
    swi.extend(swi2)


answer=0
for s in swi:
    allon=1
    for i in range(M):
        on=0
        for j in range(1,denkyu[i][0]+1):
            if s[denkyu[i][j]-1]==1:
                on+=1
        if on%2!=p[i]:
            allon=0
            break
    if allon==1:
        answer+=1      
print(answer)
        

Measured memory_bytes: 43120
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a,c));
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(n<6){
        cout<<n<<endl;
        return 0;
    }

    int q=0,r=0;//9,6
    int ans = IINF;

    while((9*q)<=n){
        r=0;
        while((9*q)+(6*r)<=n){
            int m = 0;

            if(q+r > 0)
                m = n % (9*q+6*r);

            if(m < 6 && (9*q)+(6*r)+m==n){
                int cnt9 = 0;
                int cnt6 = 0;

                int tmp = q;
                FORR(i,1,6){ //9^5 = 59049
                    cnt9 += tmp / (int)pow(9,i);
                    tmp %= (int)pow(9,i);
                }
                cnt9 += tmp;

                tmp = r;
                FORR(i,1,7){ //6^6 = 46656
                    cnt6 += tmp / (int)pow(6,i);
                    tmp %= (int)pow(6,i);
                }
                cnt6 += tmp;

                ans = min(ans, cnt9+cnt6+m);
            }
            r++;
        }
        q++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    for line in stdin.lock().lines() {
        let mut v: Vec<_> = line.unwrap()
            .split_whitespace()
            .map(|s| s.parse::<i32>().unwrap())
            .collect();
        if v == [0, 0] {
            return;
        }
        v.sort();
        println!("{} {}", v[0], v[1]);
    }
}



Measured memory_bytes: 5072
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = N.iota.map!(_ => readln.chomp.to!long).array;
    auto B = N.iota.map!(_ => readln.chomp.to!long).array;

    A.sort();
    B.sort();

    long a = 0;
    long b = 0;
    long ans = 1;

    for (int i = 0, j = 0; i < N || j < N; ) {
        if (j == N || (i != N && A[i] < B[j])) {
            if (b == 0) {
                a += 1;
            } else {
                ans = ans * b % MOD;
                b -= 1;
            }
            ++i;
        } else {
            if (a == 0) {
                b += 1;
            } else {
                ans = ans * a % MOD;
                a -= 1;
            }
            ++j;
        }
    }

    ans.writeln;
}


Measured memory_bytes: 4476