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

int main()
{
	int64_t a, b, k;
	cin >> a >> b >> k;

	{
		int64_t t = min(a, k);
		a -= t;
		k -= t;
	}
	{
		int64_t t = min(b, k);
		b -= t;
		k -= t;
	}

	cout << a << ' ' << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

using ll = long long;
const int Wmax = 1e5 + 5;
int N,Weight;
ll w[101],v[101];
ll dp[101][Wmax];

int main() {
    cin >> N >> Weight;
    for(int i = 1; i <= N; ++i)
        cin >> w[i] >> v[i];
    for(int i = 1; i <= N; ++i)
        for(int j = 1; j <= Weight; ++j)
            if(j >= w[i])
                dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i]] + v[i]);
            else
                dp[i][j] = max(dp[i][j - 1],dp[i - 1][j]);
    cout << dp[N][Weight];
    return 0;
}


Measured memory_bytes: 78336
#include<stdio.h>
int main(void)
{
	int  a, b, i ,c;

	scanf("%d", &a);
	scanf("%d", &b);

for(i=0;i<a;i++){
	c = i;
}

if(b>=a)
{
	c++;

}
printf("%d", c);




return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007

ll dp[105][(int)1e5+5];
pair<ll,ll> arr[105];

ll func(ll idx, ll wt)
{
    if(wt==0 || idx==-1)
        return 0;
    if(dp[idx][wt]!=-1)
        return dp[idx][wt];
    if(wt<arr[idx].first)
        return dp[idx][wt]=func(idx-1,wt);
    return dp[idx][wt]=max(func(idx-1,wt),arr[idx].second+func(idx-1,wt-arr[idx].first));    
}

int main()
{
    fast;
    ll n,wt,x,y;
    cin>>n>>wt;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        arr[i]=pii(x,y);
    }
    memset(dp,-1,sizeof(dp));
    cout<<func(n-1,wt);
    return 0;
}

Measured memory_bytes: 82304
S = input()
T = input()
cnt_list = []

for i in range(len(S)-len(T)+1):
  sub_S = S[i:i+len(T)]
  cnt = 0
  for j in range(len(T)):
    if sub_S[j] != T[j]:
      cnt += 1
  cnt_list.append(cnt)
print(min(cnt_list))

Measured memory_bytes: 9004
#include <bits/stdc++.h>
#define loop(n) for(ll i=0;i<n;i++)
#define loop4(i,n) for(ll i=0;i<n;i++)
#define rng(i,a,b,c) for(ll i = a; i<b;i+=c)
#define loop2(i,a,b) for(long long i = a; i>=b;i--)
#define loop3(j,a,b) for(int j = a; j<b;j++)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long   
#define ld long double
#define SET set<ll>
#define pb push_back
#define mp make_pair
#define gc getchar_unlocked

using namespace std; 

//cout<<setprecision(4) << fixed;
/*int compare(string str1, string str2){
   if(str1.length() < str2.length())
   return 1;
   return 0;
}*/
/* int to string-
int c=0;
stringstream ss;
ss<<c;
string str=ss.str();*/
/* STRING TO INT
string s;
	cin>>s;
	reverse(s.begin(),s.end());
	stringstream ss(s);
	ll a=0;
	ss>>a;*/
//about maps
/*unordered_map <int,int> g;
loop(n)
{
	g.insert(make_pair(b[i],i));
}
 int* i1; 
    i1 = std::min_element(v + 2, v + 5); 
    cout<<*i1;
 
//getline

cin.ignore();
getline(cin,s);    

*/
// no getchar_unlocked on Windows so call _getchar_nolock
/*

 ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 }  

inline int getchar_unlocked() { return _getchar_nolock(); }
inline ll read() {  
 ll n=0;  
 char p=getchar_unlocked();  
 while((p<'0'||p>'9')&&p!=EOF)  
 p=getchar_unlocked();  
 while(p>='0'&&p<='9')  
 {  
 n = (n<< 3) + (n<< 1) + (p - '0');  
 p=getchar_unlocked();}  
 return n;
}

void dfs(vector<ll> adj[],ll vis[],ll u)
{

	if(vis[u]==0)
	{
		cout<<u<<' ';
		vis[u]=1;
		for(auto x:adj[u])
		{
			if(vis[x]==0 )
			{
			dfs(adj,vis,x);
		    }
		}
	}
}
*/

void go()
{
	ll n,x,t;
	
	cin>>n>>x>>t;
	
	if(n%x==0)
	cout<<t*(n/x)<<'\n';
	else
	cout<<t*((n/x) + 1)<<'\n';
	
//
}

int main() 
{
ll t;

fast;

//cin>>t; 

//while(t--)
go();
}


Measured memory_bytes: 3644
while True:
    n = int(input())
    if n == 0:
        break
    L=[]
    for _ in range(n):
        L.append(int(input()))

    cnt = 0
    for k in range(1,len(L))[::-1]:
        for i in range(k):
            if L[i+1] < L[i]:
                cnt += 1
                L[i+1], L[i] = L[i], L[i+1]
    print(cnt)




Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    vector<int> ans;
    for(int i=0;i<n;i++){
        if((n-i-1)%2==1) ans.pb(a[n-1-i]);
    }
    for(int i=0;i<n;i+=2){
        ans.pb(a[i]);
    }
    if(n%2==0){
        rep(i,n) cout << ans[i] << " ";
    }else{
        rep(i,n) cout << ans[n-1-i] << " ";
    }
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

#define MAX 100005

bitset<MAX> prime;
vector<int> primeList;

void sieve() {
    prime.set();
    prime[0] = prime[1] = 0;
    for (int i=4; i<MAX; i+=2)
        prime[i] = 0;
    for (int p=3; p<MAX; p+=2)
        if (prime[p])
            for (int i=p; i<=(MAX-1)/p; i+=2)
                prime[i*p] = 0;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    sieve();

    int x;
    cin >> x;
    while (!prime[x]) x++;
    cout << x << "\n";

    return 0;
}


Measured memory_bytes: 3632
l, r = list(map(int, input().split()))


if (r-l)//2019 >= 1 :
    d = 0
else :
    ll = l%2019
    rr = r%2019
    if rr > ll :
        d = 2019
        for i in range(ll, rr) :
            for j in range(i+1, rr+1) :
                d = min(d, i*j%2019)
    else :
        d = 2019
        for i in range(ll, rr+2019) :
            for j in range(i+1, rr+2020) :
                d = min(d, i*j%2019)
print(d)

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
int main()
{
    int k;read(k);
    int sum=0;
    queue <ll> q;
    for(re int i=1;i<=9;i++) q.push(i);
    while(!q.empty())
    {
        ll x=q.front();
        q.pop();
        sum++;
        if(sum==k)
        {
            printf("%lld\n",x);
            break;
        }
        for(re ll i=-1;i<=1;i++)
        {
            if((x%10)+i>=0&&(x%10)+i<=9)
            {
                q.push(x*10+(x%10)+i);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
    for(int l = 1; l <= n; l++){
        for(int i = 0; i + l <= n; i++){
            if((n - l) % 2 == 0){
                dp[i][i+l] = -INF;
            }else{
                dp[i][i+l] = INF;
            }
        }
    }

    rep(l, n + 1){
        rep(i, n){
            if(i + l > n){
                continue;
            }
            int j = i + l;
            if((n - l) % 2 == 1){
                if(i - 1 >= 0){
                    dp[i-1][j] = max(dp[i-1][j], dp[i][j] + a[i-1]);
                }
                if(j + 1 <= n){
                    dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a[j]);
                }
            }else{
                if(i - 1 >= 0){
                    dp[i-1][j] = min(dp[i-1][j], dp[i][j] - a[i-1]);
                }
                if(j + 1 <= n){
                    dp[i][j+1] = min(dp[i][j+1], dp[i][j] - a[j]);
                }
            }
        }
    }
    cout << dp[0][n] << endl;

    return 0;
}


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

int main() {
    int H1, M1, H2, M2, K; cin >> H1 >> M1 >> H2 >> M2 >> K;
    int e = H2 * 60 + M2;
    int s = H1 * 60 + M1;
    cout << e - s - K << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    ll n,m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1 << endl;
    }else if(n == 2 || m == 2){
        cout << 0 << endl;
    }else if(n == 1 || m == 1){
        cout << n * m - 2 << endl;
    }else{
        cout << (n-2) * (m-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding:utf-8

import sys
from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
a, b = LI()

m = II()
D = defaultdict(int)
for i in range(m):
    x, y, z = LI()
    y -= 1
    z -= 1
    tmp_y = D[y] if y in D.keys() else a + b * y
    tmp_z = D[z] if z in D.keys() else a + b * z
    if x == 0:
        D[z] = tmp_y

    D[y] = tmp_z

k = II()
k -= 1
print(D[k] if k in D.keys() else a + b * k)



Measured memory_bytes: 6024
/*
 * Talk is cheap, show me the code.
 * Author:  JiangDingyuan
 * Created Time:  2017/9/2 20:22:10
 * File Name: 12345.cpp
 */
#include <time.h>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#define PI acos(-1.0)
#define LL long long
#define bug printf("bug!\n");
#define RD freopen("in.txt", "r", stdin);
#define LD freopen("out.txt", "w", stdout);
#define MAXN 200000
using namespace std;
int a[200000];
int main() {
    int n,t;
    cin >> n;
    for(int i = 0; i < n; i++) {
        scanf("%d",&t);
        a[t]++;
    }
    int Max = 0;
    for (int i = 1; i < 150000; i++)
        Max = max(Max,a[i-1]+a[i]+a[i+1]);
    cout << Max <<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ll n , k , s;
	cin >> n >> k >> s;
	//freopen("output.txt" , "w" , stdout);
	while (k--&& n--) cout << s << " ";
	while (n--) cout << (s == 1e9 ? 1 : s+1) << " ";
}


Measured memory_bytes: 3540
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	if (M+2 >= K) {
		cout << N + 1 << endl;
		return 0;
	}
	long long int add = 0;
	if (N <= M) {
		cout << N + 1 << endl;
		return 0;
	}
	if ((N - M + 1) % 2) {
		add++;
		N--;
	}
	cout << M + (K - M)*(N - M+1) / 2 + add << endl;

}

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

int main()
{
   int n, temp, revrs = 0;
   cin >> n;
   temp = n;
   while(temp)
   {
       int digit = temp % 10;
       temp /= 10;
       revrs = digit + (revrs * 10);
   }

   if(n == revrs)cout << "Yes\n";
   else cout << "No\n";

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001

int32_t main()
{
    
    int n;
    cin>>n;

    int sum=0;
    for(int i=1;i<=n;i++){
        int val=(n/i);
        sum+=i*(val*(val+1))/2;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3580
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef int ll;
typedef pair<ll,ll> P;
typedef double db;
struct T{
	ll first,second,third;
	bool operator<(const T& t)const{
		return first!=t.first?(first<t.first):(second!=t.second?second<t.second:third<t.third);
	}
};
ll w,h,g[10][10];
ll cx,cy;
vector<P> doko(ll y,ll x){
	vector<P> v;
	for(ll nx=x+1;nx<w;nx++){
		if(g[y][nx]>0) v.push_back(P(y,nx));
		if(g[y][nx]==1) break;
	}
	for(ll nx=x-1;nx>=0;nx--){
		if(g[y][nx]>0) v.push_back(P(y,nx));
		if(g[y][nx]==1) break;
	}
	for(ll ny=y+1;ny<h;ny++){
		if(g[ny][x]>0) v.push_back(P(ny,x));
		if(g[ny][x]==1) break;
	}
	for(ll ny=y-1;ny>=0;--ny){
		if(g[ny][x]>0) v.push_back(P(ny,x));
		if(g[ny][x]==1) break;
	}
	return v;
}
ll n;
ll id[10][10];
set<T> t;
ll dfs(ll y,ll x,ll s){
	if(t.count((T){y,x,s})) return 0;
	ll res=0;
	vector<P> v=doko(y,x);
	if(s==(1<<n)-1){
		for(ll i=0;i<v.size();i++){
			if(g[v[i].first][v[i].second]==2) return 1;
		}
		t.insert((T){y,x,s});
		return 0;
	}
	if(s) g[y][x]=-1;
	for(ll i=0;i<v.size();i++){
		if(g[v[i].first][v[i].second]==2) continue;
		res+=dfs(v[i].first,v[i].second,s|(1<<id[v[i].first][v[i].second]));
	}
	g[y][x]=1;
	if(res==0) t.insert((T){y,x,s});
	return res;
}

int main()
{while(1){
	scanf("%d%d",&w,&h);
	n=0;
	t.clear();
	memset(id,-1,sizeof(id));
	if(!w) return 0;
	for(ll i=0;i<h;i++) for(ll j=0;j<w;j++){
		scanf("%d",&g[i][j]);
		if(g[i][j]==2){
			cx=j,cy=i;
		}
		else if(g[i][j]){
			id[i][j]=n;
			n++;
		}
	}
	printf("%d\n",dfs(cy,cx,0));
}}

Measured memory_bytes: 49428
N, M = list(map(int, input().split()))
target = [list(map(int, input().split())) for i in range(M)]

'''
4 4
1 3
2 2
1 1
2 4


'''
tmp1 = 0
tmp2 = N + 1
for t in target:
    tmp1 = max(t[0],tmp1)
    tmp2 = min(t[1],tmp2)
    #print(tmp1)
    #print(tmp2)

if  tmp2-tmp1 < 0:
    print(0)
    exit(0)
print(tmp2-tmp1 + 1)

Measured memory_bytes: 27332
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];
    let a = read_as_vec::<usize>();

    let mut i: usize = 0;
    let mut ans = 0;
    while i < n{
        let mut j = 0;
        while i+j < n && a[i] == a[i+j]{
            j += 1;
        }
        ans += j/2;
        i += j;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(all(a));
	int temp = a[2] * 2 - a[1] - a[0];
	if (temp % 2 == 1) {
		cout << (temp + 1) / 2 + 1;
	}
	else {
		cout << temp  / 2;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
    Ball and Boxes 4
    女、男、制限なし(自由分捕り形式)
*/

int main() {
    ll n, k;
    cin >> n >> k;
    COMinit();

    ll ans = COM(n+k-1,k-1);

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



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

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

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

struct PrimalDual{
    using F=long long;
    const F INF=1ll<<50;
    
    struct Edge{
        int to;
        F cap,cost;
        int rev;
        Edge(int to,F cap,F cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}
    };
    
    int n;
    vector<vector<Edge>>G;

    PrimalDual(int n):n(n),G(n){}

    void addEdge(int from,int to,F cap,F cost){
        G[from].push_back(Edge(to,cap,cost,G[to].size()));
        G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
    }


    F minCostFlow(int s,int t,F f){
        F cur=0;

        vector<F>h(n);
        vector<int>prevv(n,-1),preve(n,-1);
        vector<F>dist(n);
        priority_queue<pair<F,int>,vector<pair<F,int>>,greater<pair<F,int>>>que;
            
        while(f>0){
            fill(dist.begin(),dist.end(),INF);
            dist[s]=0;
            que.emplace(0,s); 
            while(que.size()){
                F d;
                int v;
                tie(d,v)=que.top();
                que.pop();
                if(dist[v]<d)continue;
                for(int i=0;i<G[v].size();i++){
                    Edge &e=G[v][i];
                    F nd=dist[v]+e.cost+h[v]-h[e.to];
                    if(e.cap>0&&dist[e.to]>nd){
                        dist[e.to]=nd;
                        prevv[e.to]=v;preve[e.to]=i;
                        que.emplace(nd,e.to);
                    }
                }
            }
            if(dist[t]==INF)return -1;
            for(int v=0;v<n;v++)h[v]+=dist[v];
            F nf=f;
            for(int v=t;v!=s;v=prevv[v]){
                nf=min(nf,G[prevv[v]][preve[v]].cap);
            }
            f-=nf;
            cur+=nf*h[t];
            for(int v=t;v!=s;v=prevv[v]){
                Edge &e=G[prevv[v]][preve[v]];
                e.cap-=nf;
                G[v][e.rev].cap+=nf;
            }
        }
        return cur;
    }
};


signed main(){
    int V,E,F;
    scanf("%d%d%d",&V,&E,&F);
    PrimalDual pd(V);
    rep(i,E){
        int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        pd.addEdge(a,b,c,d);
    }
    printf("%d\n",(int)pd.minCostFlow(0,V-1,F));
    return 0;
}


Measured memory_bytes: 3336
import Foundation

let (a, v) = readInts().mapToTuple()
let (b, w) = readInts().mapToTuple()
let t = Int(readLine()!)!

print(abs(a - b) <= (v - w) * t ? "YES" : "NO")



func readInts() -> [Int] {
    readLine()!.split(separator: " ").map { Int($0)! }
}

extension Collection {
    func mapToTuple() -> (Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!)
    }
    func mapToTuple() -> (Element, Element, Element, Element) {
        var i = makeIterator()
        return (i.next()!, i.next()!, i.next()!, i.next()!)
    }

    subscript(gen: Index) -> Element {
        _modify { yield &self[index(gen, offsetBy: -1)] }
        _read   { yield self[index(gen, offsetBy: -1)] }
    }
}


Measured memory_bytes: 13640
package main

import "fmt"

func main() {
	var times int
	var sum float64
	fmt.Scan(&times)
	for i := 0; i < times; i++ {
		var num float64
		var unit string

		fmt.Scan(&num, &unit)
		if unit == "JPY" {
			sum += num
		} else {
			sum += num * 380000.0
		}
	}

	fmt.Println(sum)
}


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

int n, m;

vector<vector<int> > func1(vector<string> a) {
        vector<vector<int> > ans(n, vector<int>(m, 0));
        for(int i = 0; i < n; i++) {
                int prev = m;
                for(int j = m - 1; j >= 0; j--) {
                        if(a[i][j] == '#') {
                                prev = j;
                                ans[i][j] = 0;
                        } else
                                ans[i][j] = (prev - j);
                }
        }
        return ans;
}

vector<vector<int> > func2(vector<string> a) {
        vector<vector<int> > ans(n, vector<int>(m, 0));
        for(int i = 0; i < n; i++) {
                int prev = -1;
                for(int j = 0; j < m; j++) {
                        if(a[i][j] == '#') {
                                prev = j;
                                ans[i][j] = 0;
                        } else
                                ans[i][j] = (j - prev);
                }
        }
        return ans;
}

vector<vector<int> > func3(vector<string> a) {
        vector<vector<int> > ans(n, vector<int>(m, 0));
        for(int i = 0; i < m; i++) {
                int prev = -1;
                for(int j = 0; j < n; j++) {
                        if(a[j][i] == '#') {
                                prev = j;
                                ans[j][i] = 0;
                        } else
                                ans[j][i] = (j - prev);
                }
        }
        return ans;
}

vector<vector<int> > func4(vector<string> a) {
        vector<vector<int> > ans(n, vector<int>(m, 0));
        for(int i = 0; i < m; i++) {
                int prev = n;
                for(int j = n - 1; j >= 0; j--) {
                        if(a[j][i] == '#') {
                                prev = j;
                                ans[j][i] = 0;
                        } else
                                ans[j][i] = (prev - j);
                }
        }
        return ans;
}

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	vector<string> a(n);
	for(int i = 0; i < n; i++)
                cin >> a[i];
        vector<vector<int> > dist[4];
        dist[0] = func1(a);
        dist[1] = func2(a);
        dist[2] = func3(a);
        dist[3] = func4(a);
        /*for(int i = 0; i < 4; i++) {
                for(int j = 0; j < n; j++) {
                        for(int k = 0; k < m; k++)
                                cout << dist[i][j][k] << ' ';
                        cout << endl;
                }
                cout << endl;
        }*/
        int ans = 0;
        for(int i = 0; i < n; i++) {
                for(int j = 0; j < m; j++) {
                        int lans = 0;
                        for(int k = 0; k < 4; k++)
                                lans += dist[k][i][j];
                        ans = max(ans, lans);
                }
        }
        cout << ans - 3;
	return 0;
}


Measured memory_bytes: 71352
#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;

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 DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];

typedef unsigned int Hash1;
typedef short Hash2;
struct Hash{
  Hash1 first;
  Hash2 second;
  Hash():first(0),second(0){}
  Hash(Hash1 first,Hash2 second):first(first),second(second){}
};
bool operator==(const Hash &a,const Hash &b){
  return a.first==b.first && a.second==b.second;
}
const Hash1 b1 = 29;
const Hash2 b2 = 29;
const Hash2 m2 = 127;
const int MAX = 100001;
Hash hsh[MAX];
Hash bpow[MAX];
Hash2 mdmp[65536];

struct HashHash {
  size_t operator()(const Hash &yey) const {
    hash<int> hasher;
    return hasher((int)yey.first)^hasher((int)yey.second);
  }
};

unordered_set<Hash,HashHash> S;
int calc(int x){
  S.clear();
  REP(i,n-x+1){
    // substr
    int l = i;
    int r = l+x;
    Hash h(0,0);
    h.first += hsh[l].first;
    h.second+= hsh[l].second;
    h.first *= bpow[x].first;
    h.second*= bpow[x].second;
    // mod & negative
    h.first = -h.first;
    // h.second= m2 - mdmp[h.second];
    h.second= m2 - h.second%m2;
    h.first += hsh[r].first;
    h.second+= hsh[r].second;
    // h.second= mdmp[h.second];
    h.second= h.second%m2;
    S.insert(h);
  }
  return S.size();
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,65536)mdmp[i] = i%m2;
  // create hash
  REP(i,n){
    int id = s[i]-'a';
    hsh[i+1].first = hsh[i].first*b1 + (Hash1)id;
    // hsh[i+1].second= mdmp[ hsh[i].second*b2+ (Hash2)id ];
    hsh[i+1].second= (hsh[i].second*b2+ (Hash2)id)%m2;
  }
  // base pow
  bpow[0] = Hash(1,1);
  REP(i,n){
    bpow[i+1].first = bpow[i].first*b1;
    // bpow[i+1].second= mdmp[ bpow[i].second*b2 ];
    bpow[i+1].second= bpow[i].second*b2%m2;
  }
  // go
  int low = 1, high = n;
  while(low+2<high){
    int ml = (low+high)/2;
    int mh = ml+1;
    if(calc(ml)<calc(mh)){
      low = ml;
    }else{
      high = mh;
    }
  }
  int ans = 0;
  FOR(i,low,high+1)CHMAX(ans,calc(i));
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 6180
import math
M,N=map(int,input().split())
if abs(M-N)<=1:
 if (N==M):
  print(math.factorial(N)*math.factorial(M)*2%1000000007)
 else:
  print(math.factorial(N)*math.factorial(M)%1000000007)
else:
 print(0)

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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=0;i<=(n);i++)

int main(){
	in(d);

	if(d == 25)
		cout << "Christmas" << endl;
	else if(d == 24)
		cout << "Christmas Eve" << endl;
	else if(d == 23)
		cout << "Christmas Eve Eve" << endl;
	else if (d == 22)
		cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n,m,a,b,p,q;

int main(){
	cin>>n>>m>>a>>b>>p>>q;
	if(a==1&&b==1){
		ll x=p+q,tmp=min(m/x,n),res=m-x*tmp;
		if(tmp!=n) res=min(res,x*(tmp+1)-m);
		cout<<res<<endl;
		return 0;
	}
	vl x;
	bool B=0;
	int I=0;
	do{
		if(p+q>m) B=1;
		x.push_back(p+q);
		if(INF/p>a) p*=a;
		else break;
		if(INF/q>b) q*=b;
		else break;
		I++;
	}while(I<n&&!B);
	int S=x.size(),S2=S/2,T=S-S2;
	vl c(1<<S2);
	for(int i=0;i<1<<S2;i++){
		for(int j=0;j<S2;j++) if(i&1<<j) c[i]+=x[j];
	}
	sort(c.begin(),c.end());
	ll res=INF;
	for(int i=0;i<1<<T;i++){
		ll tmp=0;
		for(int j=0;j<T;j++) if(i&1<<j) tmp+=x[S2+j];
		auto it=lower_bound(c.begin(),c.end(),m-tmp);
		if(it!=c.end()) res=min(res,abs(m-tmp-*it));
		if(it!=c.begin()) res=min(res,abs(m-tmp-*(it-1)));
	}
	cout<<res<<endl;
}

Measured memory_bytes: 10920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n;
cin >> n;
ll t[n] = {};
rep(i, n){
    cin >> t[i];
}
ll tt[n] = {};
rep(i, n){
    tt[i]=i+1;
}
rep(i,n){
    if(t[i]!=tt[i])ans++;
}
if(ans==0||ans==2){
    cout << "YES" << endl;
}
else cout << "NO" << endl;

return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

while len(a) != 1:
  m=min(a)
  t = [m]
  for i in a:
    if i % m == 0: continue
    t.append(i % m)
  if not t: break
  a = t
  #print(a)
print(m)


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
	char S;
	bool n=false,w=false,s=false,e=false;
	while(cin>>S){
		switch(S){
		case'N':
			n=true;
			break;
		case'W':
			w=true;
			break;
		case'S':
			s=true;
			break;
		case'E':
			e=true;
			break;
		}
	}
	cout<<(n==s&&w==e?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	cout << a*b;
	return 0;
}


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

string str;
int n;
int solve()
{
    int a=0;
    int quantity=0;
    int ans=0;
    if(str[0] == 'I') a=1;
    for(int i=1;i<str.size();i++)
    {
        if(a==0 && str[i]=='I')
        {
            a = 1-a;
            quantity++;
        }else if(a==1 && str[i]=='O') a = 1-a;
        else
        {
            ans += max(0, quantity+1-n);
            quantity=0;
            if(str[i]=='I') a=1;
            else a=2;
        }
    }
    ans += max(0, quantity+1-n);
    return ans;
}
int main()
{
    int m;
    while(cin >> n >> m && (n||m))
    {
    cin >> str;
    cout << solve() << endl;
    str.clear();
    }
}

Measured memory_bytes: 2104
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};




int main(){
    vector<int> flag(100001, false);

    for(int i = 1;i <= 100000;i++){
        set<int> se;
        for(int j = 1;j <= sqrt(i);j++){
            if(i % j == 0){
                se.insert(j);
                se.insert(i/j);
            }
        }
        se.erase(i);
        LL sum = 1;
        for(int q : se){
            sum *= q;
            if(sum >= i*2){
                flag.at(i) = 1;
                break;
            }
        }
    }
    vector<int> ruiseki;
    ruiseki.push_back(0);
    for(int i = 0;i < flag.size();i++){
        ruiseki.push_back(ruiseki.back()+flag.at(i));
    }
    /*
    for(int i = 0;i < 50;i++){
        cout<<i<<":"<<ruiseki.at(i)<<endl;
    }
    */
    ruiseki.erase(ruiseki.begin());
    int Q;cin >> Q;
    for(int i = 0;i < Q;i++){
        int b;cin >> b;
        cout<<ruiseki.at(b)<<endl;
    }
}



Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int R, G, B, n;
  cin >> R >> G >> B >> n;

  int cnt = 0;

  REP(r,3001){
    REP(g,3001){
      int b = n - r*R - g*G;
      if(b < 0) continue;
      if(b%B == 0){
        b /= B;
        if(b <= 3000 && b >= 0) ++cnt;
      }

    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3612
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    auto sa = atcoder::suffix_array(s);
    auto lcp = lcp_array(s, sa);
    debug(sa, lcp);
    ll n = s.size();
    ll ans = (n + 1) * n / 2;
    debug(ans);
    ans -= accumulate(all(lcp), 0LL);
    cout << ans << "\n";
}

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

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
using namespace std;

int main() {
  long long int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  if (A + B <= 2 * C) {
    cout << (A * X) + (B * Y) << endl;
  } else if (X < Y) {
    cout << min(2 * C * Y, (2 * C * X) + (B * (Y - X))) << endl;
  } else {
    cout << min(2 * C * X, (2 * C * Y) + (A * (X - Y))) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#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, Y, Z; cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}

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

typedef long long ll;

main()
{
    string s, sub;
    int a;
    vector<int> v;
    cin >> s;
    for(int i = 0; i < s.size()-2; i++){
        sub = s.substr(i, 3);
        a = stoi(sub);
        v.push_back(abs(753-a));
    }
    sort(v.begin(), v.end());
    cout << v.front();
}





///promy_pompom
//hello world


Measured memory_bytes: 3564
/*
	In the name of ALLAH
	Author : Raashid Anwar
*/

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

#define int int64_t
#define mod 1000000007

int F[100001];

int power(int a,int b) {
	int r=1;
	while(b) {
		if(b&1)
			r=(r*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return r;
}

int C(int a,int b) {
	if(a-b<0||a<0||b<0)
		return 0;
	int ans=(F[a-b]*F[b])%mod;
	ans=(power(ans,mod-2));
	ans=(ans*F[a])%mod;
	return ans;
}


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	F[0]=1;
	for(int i=1;i<=100000;i++)
		F[i]=(F[i-1]*i)%mod;
	int n,k,ans=0;
	cin>>n>>k;
	int A[n+1];
	for(int i=1;i<=n;i++)
		cin>>A[i];
	sort(A+1,A+n+1);
	for(int i=1;i<=n;i++) {
		if(i>=k)
			ans=(ans+((A[i]*C(i-1,k-1))%mod))%mod;
		if(i<=n-k+1)
			ans=(ans+mod-((A[i]*C(n-i,k-1))%mod))%mod;
	}
	cout<<ans<<"\n";
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int h = s / 3600, m = (s % 3600) / 60;
        System.out.println(h+":"+m+":"+(s%60));
    }
}


Measured memory_bytes: 26240
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x;
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll x, a, b, c, d;

int main() {
	rd(x);
	d = (x % 10);
	x /= 10;
	c = (x % 10);
	x /= 10;
	b = (x % 10);
	x /= 10;
	a = x;
	repi(i, 0, 2) repi(j, 0, 2) repi(k, 0, 2) {
		ll temp = a - b - c - d + 2 * (b*i + c*j + d*k);
		if (temp == 7) {
			wr(a);
			if (i)wr('+'); else wr('-');
			wr(b);
			if (j)wr('+'); else wr('-');
			wr(c);
			if (k)wr('+'); else wr('-');
			wr(d);
			wrln("=7");
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
read = sys.stdin.read
readlines = sys.stdin.readlines
from math import ceil, log
def main():
    k = int(input())
    k2 = int(log(ceil(k / 10), 3)) + 1
    def getlun(n, keta, last):
        lunluns.append(n)
        if keta > k2:
            pass
        else:
            l1 = n * 10 + last
            getlun(l1, keta + 1, last)
            if last > 0:
                l2 = n * 10 + last - 1
                getlun(l2, keta + 1, last - 1)
            if last < 9:
                l3 = n * 10 + last + 1
                getlun(l3, keta + 1, last + 1)
    lunluns = []
    for i1 in range(1, 10):
        getlun(i1, 0, i1)
    lunluns.sort()
    print(lunluns[k-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 38380
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    double N,M,tmp(0);
    cin >> N >> M;
    vector <int> a(N);
    int flag = 0;

    for(int i = 0; i < N;i++){
        cin >> a.at(i);
      	tmp += a.at(i);
    }
  
   for(int i = 0;i < N ;i++){
       if(a.at(i) < (tmp/(M*4))){
          
       }else{
			 flag++;
       }
   }
   if(flag >= M){
       cout << "Yes";
   }else{
       cout << "No";
   }

    }
   


Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
//#define for1(i,a) for(i=0;i<a;i++)
//#define for2(i,a) for(i=1;i<=a;i++)
using namespace std;
ll n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    if(n<m)
    {
        ll t=n;
        n=m;
        m=t;
    }
    if(m<=n-2) printf("Alice\n");
    else printf("Brown\n");
    return 0;
}


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

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, m;
	cin >> n >> m;
	vector< pair< ll, pair<int, int> > > edge;
	for(int i = 0, u, v, w; i < m; i++) {
		cin >> u >> v >> w;
		u--, v--;
		edge.push_back({-w, {u, v}});
	}
	
	const ll inf = 1e15;
	vector<ll> d(n, inf);
	d[0] = 0;
	for(int i = 1; i <= n + n; i++) {
		for(auto& e : edge) {
			int u = e.second.first;
			int v = e.second.second;
			ll w = e.first;
			if( d[v] > d[u] + w ) {
				d[v] = d[u] + w;
				if( i >= n and v == n - 1 ) {
					cout << "inf\n";
					exit(0);
				} 
			}
		}
	}
	
	cout << -d[n - 1] << "\n";
}


Measured memory_bytes: 384
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define ll long long int;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main() {
	int x=in();
	if(x==7||x==5||x==3)cout<<"YES";
	else cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    typedef long long int ll;
    typedef long double ld;
    #define rep(i,a,b)  for(ll i=a;i<b;i++)
    #define ml cout<<"\n"
     
    #define pii pair<ll,ll>
    #define vi  vector<ll>
    #define vii vector<pii>
    #define mi  map<ll,ll>
    #define all(a)  (a).begin(),(a).end()
     
    #define pb push_back
    #define in insert
    #define ff first
    #define ss second
    #define mod 1000000007
     
    #define yes cout<<"YES"<<endl;
    #define no cout<<"NO"<<endl;
    #define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
    #define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
    #define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
    #define test1(x) cout<<"x is "<<x<<endl;
     
    int main(){
    	ios_base::sync_with_stdio(false);
         	cin.tie(NULL);
        	cout.tie(NULL);    
        ll n,k;
        cin>>n>>k;
      if(k==1){
       cout<<0<<endl; 
      }else{
        if(n>=k ){
          if(n%k==0)
        	cout<<0<<endl;
          else{
           	cout<<k - n%k<<endl; 
          }
        }else{
         	cout<< min(n , abs(n-k)); 
        }
      }
      
       return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i]!=t[i]) ++ ans;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3856