akhauriyash/Code-Regression huggingface dataset:
require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
w,h,x,y = gets.chomp.split.map(&:to_i)

puts w.to_f*h/2

if (x*2 == w && y*2 == h) || h==0 || w == 0
  puts 1
else
  puts 0
end


Measured memory_bytes: 2172
#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 lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }

    lli ans = 0;

    for (lli i = 0; i < n; i++) {
        for (lli j = i + 1; j < n; j++) {
            if (v[i] == v[j]) {
                continue;
            }
            for (lli k = j + 1; k < n; k++) {
                if (v[k] == v[j] || v[k] == v[i]) {
                    continue;
                }
                vector<lli> tmp;
                tmp.pb(v[i]);
                tmp.pb(v[j]);
                tmp.pb(v[k]);
                sort(all(tmp));
                if (tmp[0] + tmp[1] > tmp[2]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>

#define MOD 1000000007

using namespace std;
 
int a[100005];
int main(){
    int n;
    int b;
    long long ans=1;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>b;
        a[b]++;
    }

    for(int i=1;i<100005;i++){
        if(a[i]==2){
            ans*=2;
            ans%=MOD;
        }
    }
    if(n%2==1){
        if(a[0]!=1)ans=0;
        for(int i=1;i<100005;i++){
            if(a[i]!=0&&a[i]!=2)ans=0;
        }
    }
    if(n%2==0){
        for(int i=0;i<100005;i++){
            if(a[i]!=0&&a[i]!=2)ans=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#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 N;
  string S;
  cin >> N >> S;
  int ans = 0;
  rep(i, N - 2){
    if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[2000005],n;
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n;i++){
		cout<<a[i];
		if(i!=n-1) cout<<" ";
		else cout<<endl;
	}
	return 0;
} 


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

using namespace std;

bool check(vector<int> &a, vector<int> &b) {
    int sum = 0;
    for(int i = 0; i < a.size(); i++) {
        sum += abs(a[i] - b[i]) * abs(a[i] - b[i]);
    }
    return (int)sqrt(sum) * (int)sqrt(sum) == sum;
}

int main() {
    int N, D;
    cin >> N >> D;
    vector<vector<int>> pts(N, vector<int>(D));
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> pts[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if(check(pts[i], pts[j])) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*****Here we go again!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 3e5 + 10;

int main()
{
    fast;
    int n;
    cin >> n;
    ll dp[n][3] = {0,0}, a[n][3];
    f(i,0,n)
        f(j,0,3)
            cin >> a[i][j];

    f(i,0,3)
        dp[0][i] = a[0][i];

    f(i,1,n)
    {
        f(j,0,3)
        {
            f(k,0,3)
            {
                if(j == k)
                    continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);
            }
        }
    }

    ll ans = 0;
    f(i,0,3)
        ans = max(ans, dp[n-1][i]);
    cout << ans;
}


Measured memory_bytes: 8308
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int a, b, h; cin >> a >> b >> h;
    cout << (a+b)*h/2 << endl;
}


Measured memory_bytes: 256
def main():
    s = list(input())
    s_d = list(set(s))
    a = [chr(i) for i in range(ord('a'), ord('z')+1)]
    set_diff = sorted(list(set(s_d) ^ set(a)))
    if len(set_diff) > 0:
        print(set_diff[0])
    else:
        print('None')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3956
N = int(input())
A = input()
B = input()
C = input()

count = 0

for i in range(N) :
    if A[i] == B[i] and C[i] != A[i] :
        count = count + 1
    elif A[i] == C[i] and B[i] != C[i] :
        count = count + 1
    elif B[i] == C[i] and C[i] != A[i]:
        count = count + 1
    elif A[i] != B[i] and B[i] != C[i] and C[i] != A[i] :
        count = count + 2

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int INF=INT_MAX;
const long long LLINF=LONG_MAX;
typedef long long ll;
const ll mod=998244353;
const int MX=2e5+7;
ll qpow(ll a ,ll b,int MOD=mod)
{
    ll ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=ans*a%MOD;
        }
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
bool cmp(int a ,int b)
{
    return a>b;
}
int a[MX];
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll ans=0;
    ll h,k;
    cin>>h;
    ll m=1;
    while(h>=1)
    {
        ans+=m;
        m*=2;
        h/=2;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	int t1 = a + b, t2 = a - b, t3 = a * b;
	if (t2 > t1) t1 = t2;
	if (t3 > t1) t1 = t3;
	printf("%d\n", t1);
	return 0;
}

Measured memory_bytes: 128
def solve():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())

    if abs(a-e) <= k:
        print('Yay!')
    else:
        print(':(')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll MOD=1000000007;
mat mul(mat A, mat B){
    mat C(A.size(), vec(B[0].size()));
    rep(i,0,A.size()){
        rep(k,0,B.size()){
            rep(j,0,B[0].size()){
                C[i][j]+=A[i][k]*B[k][j]%MOD;
                C[i][j]%=MOD;
            }
        }
    }
    return C;
}
mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    rep(i,0,A.size()){
        B[i][i]=1;
    }
    while(n>0){
        if(n&1) B=mul(B,A);
        A=mul(A,A);
        n>>=1;
    }
    return B;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll K;
    cin>>N>>K;
    mat A(N,vec(N));
    rep(i,0,N){
        rep(j,0,N){
            cin>>A[i][j];
        }
    }
    A=pow(A,K);
    ll ans=0;
    rep(i,0,N){
        rep(j,0,N){
            ans+=A[i][j];
            ans%=MOD;
        }
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 384
inpl = lambda: list(map(int,input().split()))
MOD = 10**9+7

def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return factorial_mod[n]*factorial_inv_mod[k]*factorial_inv_mod[n-k] % MOD

N, K = inpl()
factorial_mod = [1]*(N+1)
factorial_inv_mod = [1]*(N+1)
for n in range(1,N+1):
    factorial_mod[n] = factorial_mod[n-1]*n % MOD
    factorial_inv_mod[n] = factorial_inv_mod[n-1]*inv_mod(n) % MOD

for i in range(1,K+1):
    print((comb_mod(K-1,i-1)*comb_mod(N-K+1,i)) % MOD)

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    int ans=0;
    if(a>=b)
    {
        ans+=a;
        a--;
        if(a>=b)
        {
          ans+=a;
        }
        else
        {
            ans+=b;
        }

    }
    else
    {
        ans+=b;
        b--;
        if(a>=b)
        {
          ans+=a;
        }
        else
        {
            ans+=b;
        }

    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, p; cin >> n >> p;
    string s; cin >> s;

    ll ans = 0;
    if(p == 2 || p == 5){
        zep(i, 0, n){
            if((s[i]-'0')%p == 0){
                ans += i+1;
            }
        }
    }
    else{
        ll a[n];
        a[0] = 1;
        zep(i, 1, n){
            a[i] = 10*a[i-1]%p;
        }

        zep(i, 0, n){
            a[i] *= s[n-1-i]-'0';
            a[i] %= p;
        }

        zep(i, 1, n){
            a[i] += a[i-1];
            a[i] %= p;
        }

        //zep(i, 0, n){print(a[i])}

        ll cnt[p]; memset(cnt, 0, sizeof(cnt));
        rrep(i, n-1, 0){
            ans += cnt[a[i]];
            cnt[a[i]]++;
        }
        ans += cnt[0];
    }
    print(ans)
    return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <math.h>
int main(){
	int N;
	std::cin>>N;
	int t[N+1],x[N+1],y[N+1];
	t[0]=0;x[0]=0;y[0]=0;
	for(int i=0;i<N;i++){
		std::cin>>t[i+1]>>x[i+1]>>y[i+1];
	}
	for(int i=1;i<N+1;i++){
		int work=abs(x[i]-x[i-1])+abs(y[i-1]-y[i]);
		if(((t[i]-t[i-1])-work)%2 == 1 || work > t[i]-t[i-1]){
			std::cout<<"No"<<std::endl;
			return 0;
		}
	}
	std::cout<<"Yes"<<std::endl;
	return 0;
}


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

int dp[100005][3];

typedef struct Happiness {
    int a,b,c;
} happiness;

int main()
{

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

    int n, i;
    cin >> n;

    happiness arr[n];

    for(i=0;i<n;i++)
    {
        cin >> arr[i].a;
        cin >> arr[i].b;
        cin >> arr[i].c;
    }

    dp[0][0]=arr[0].a;
    dp[0][1]=arr[0].b;
    dp[0][2]=arr[0].c;

    for(i=1;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(j==0)
            {
                dp[i][j]=arr[i].a+max(dp[i-1][1],dp[i-1][2]);
            }

            if(j==1)
            {
                dp[i][j]=arr[i].b+max(dp[i-1][2],dp[i-1][0]);
            }

            if(j==2)
            {
                dp[i][j]=arr[i].c+max(dp[i-1][1],dp[i-1][0]);
            }
        }
    }

    cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << '\n';

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
    using namespace std;
    int dp[100001][4];
    int minCost(vector<vector<int>>&v,int n,int expt){
        if(n==0) return 0;
        if(dp[n][expt]!=-1) return dp[n][expt];
        int a,b,c;
        a=b=c=INT_MIN;
        if(expt!=1) a=v[n-1][0]+minCost(v,n-1,1);
        if(expt!=2) b=v[n-1][1]+minCost(v,n-1,2);
        if(expt!=3) c=v[n-1][2]+minCost(v,n-1,3);
        return dp[n][expt]=max(a,max(b,c));
    }
    int main(){
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
     int t=1;
    //  cin>>t;
     while(t--){
         int n;
         cin>>n;
         vector<vector<int>>v(n,vector<int>(3));
         for(int i=0;i<n;i++) cin>>v[i][0]>>v[i][1]>>v[i][2];
         for(int i=0;i<=n;i++){
             dp[i][0]=dp[i][1]=dp[i][2]=dp[i][3]=-1;
         }
         cout<<minCost(v,n,0)<<'\n';
     }
        return 0;
    }

Measured memory_bytes: 17968
#include <bits/stdc++.h>
using namespace std;
int main() {
int a;
int cnt=0;cin>>a;
if(a/1000==2)cnt++;
if(a%1000/100==2)cnt++;
if(a%100/10==2)cnt++;
if(a%10==2)cnt++;cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans = 0, c0, c1;
	string s;

	cin >> s;
	n = s.length();
	c0 = 0;
	for (i = 0; i < n; i++) {
		if (s[i] == 'A') c0++;
		else {
			c1 = 0;
			j = i;
			while ((j + 1 < n) && (s[j] == 'B') && (s[j + 1] == 'C')) {
				c1++;
				j += 2;
			}
			if (j == i) {
				c0 = 0;
				i = j;
			}
			else {
				ans += c0 * c1;
				i = j - 1;
			}
		}
	}
	cout << ans << "\n";
		
	return 0;
}


Measured memory_bytes: 832
n = int(input())
nums = [int(num) for num in input().split(" ")]
flag = 1
exchange_num = 0
result_string = ""        

while flag:
    flag = 0
    for j in range(n-1, 0, -1):
        if nums[j] < nums[j-1]:
            tmp = nums[j]
            nums[j] = nums[j-1]
            nums[j-1] = tmp
            flag = 1
            exchange_num += 1

for i in range(n):
    if result_string == "":
        result_string += str(nums[i])
    else:
        result_string += " "
        result_string += str(nums[i])

print(result_string)
print(exchange_num)


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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))

int main(){
    int D, N;
    cin >> D >> N;
    int counter = 0;
    for(int i = 1; true; i++){
        int this_count = 0, this_N = i;
        while(this_N % 100 == 0){
            this_count++;
            this_N /= 100;
        }
        if(this_count == D){
            counter++;
        }
        if(counter == N){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll a[100010], b[100010];
    cin >> N;
    rep(i,0,N) cin >> a[i];
    rep(i,0,N) cin >> b[i];
    sort(a,a+N);
    sort(b,b+N);
    vector<lpair> lp;
    rep(i,0,N) lp.push_back(make_pair(a[i], 0));
    rep(i,0,N) lp.push_back(make_pair(b[i], 1));
    sort(lp.begin(), lp.end());
    ll ans = 1;
    ll v1 = 0, v2 = 0;
    rep(i,0,N*2){
        if(lp[i].second == 0){
            if(v2 == 0){
                v1++;
            }else{
                ans *= v2 % MOD;
                ans %= MOD;
                v2--;
            }
        }else{
            if(v1 == 0){
                v2++;
            }else{
                ans *= v1 % MOD;
                ans %= MOD;
                v1--;
            }
        }
        // print2(v1,v2);
    }
    print(ans);
}


Measured memory_bytes: 7664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef set <int> :: iterator sitr;
typedef set <ll> :: iterator sltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef mset <int> :: iterator msitr;
typedef mset <ll> :: iterator msltr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
int n;
int main(){
    cin>>n;
    if(n==1){cout<<"Hello World\n";}
    else{
        int a,b;
        cin>>a;
        cin>>b;
        cout<<a+b<<endl;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#define EPS 1e-10
#define EQ(a, b) (abs((a) - (b)) < EPS)
using namespace std;

typedef complex<double> P;

double cross(P a, P b) {
    return(a.real() * b.imag() - a.imag() * b.real());
}

int isPalallel(P a,P a2, P b, P b2) {
    return(EQ(cross(a-a2, b-b2), 0.0));
}

int main(void) {
    int num; cin >> num;
    
    for(int r = 0; r < num; r++) {
        double x1, y1, x2, y2, x3, y3, x4, y4; cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
        P a(x1, y1), b(x2, y2), c(x3, y3), d(x4, y4);
        if(isPalallel(a, b, c, d)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return(0);
}

Measured memory_bytes: 1224
#include <iostream>
#include <queue>
#include <tr1/unordered_map>
#include <map>
using namespace std;

struct NODE{
	int x,bit;
	NODE(int x,int bit) : x(x) , bit(bit) {}
};

int n;
vector<int> dd[25];

int mask[25];

int sim(int bit){
	int nextbit = 0;
	for(int i = 0 ; i < n*n ; i++){
		int c = __builtin_popcount(bit&mask[i]);
		if( (bit >> i & 1) && (c == 2) ){
			nextbit |= (1<<i);
		}else if( c == 3 ){
			nextbit |= (1<<i);
		}
	} 
	return nextbit;
}

string view(int bit){
		string s;
	for(int i = 0 ; i < n * n ; i++) s += string(1,(bit>>i&1) + '0') + ((i+1)%n==0?"\n":""); 
	return s;
}
int main(){
	while(cin >> n && n){
		int bit = 0;
		int st = 0;
		int weight = 1;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				char c;
				cin >> c;
				if( c == '#' ) bit += weight;
				weight *= 2;
				if( c == '@' ) st = n * i + j;
			}
		}
		
		
		
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				dd[i*n+j].clear();
				mask[i*n+j] = 0;
				for(int k = 0 ; k < 8 ; k++){
					int dx[] =  {0, 1,0,-1,1,1,-1,-1};
					int dy[] =  {-1,0,1,0,1,-1,1,-1};
					int y = i + dy[k];
					int x = j + dx[k];
					if( y >= n || x >= n || x < 0 || y < 0 ) continue;
					dd[i*n+j].push_back(n*y+x);
					mask[i*n+j] |= (1<<(n*y+x));
					//cout << i << "," << j << " : " << dd[i*n+j].back() << endl;
				}
				//dd[i*n+j].push_back(i*n+j);
			}
		}
		
		queue<NODE> Q;
		Q.push(NODE(st,bit));
		tr1::unordered_map<int,int> done[25];
		done[st][bit] = 0;
		while(Q.size()){
			NODE q = Q.front(); Q.pop();
			//cout << view(q.bit) << q.x << " " << (q.bit >> q.x & 1 ) << "[" << done[q.x][q.bit] << "]" << endl;
			
			if( q.bit == 0 ){
				cout << done[q.x][q.bit] << endl;
				goto exit;
			}
			
			for(int i = 0 ; i < dd[q.x].size() ; i++){
				if( !(q.bit >> (dd[q.x][i]) & 1) ){
					int tnext = sim(q.bit|(1<<dd[q.x][i])) &~ (1<<dd[q.x][i]);
					if( !done[dd[q.x][i]].count(tnext) ){
						done[dd[q.x][i]][tnext] = done[q.x][q.bit] + 1;
						Q.push(NODE(dd[q.x][i],tnext));
					}
				}
			}
		}
		cout << -1 << endl;
		exit:;
	}
}

Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define pii pair<ll,ll>
#define pi pair<int ,int> 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i,a,n) for(int i=a;i>=n;i-- )
ll gcd(ll x,ll y)
{
    if(y==0){return x;}
    return gcd(y,x%y);
}

ll lcm(ll x,ll y)
{
    
    return (x*y)/gcd(x,y);
}
int main() {
          
         
        ll n,m;
        cin>>n>>m;
        vector<ll>A(n);
        REP(i,0,n)
        {ll x;cin>>x;A[i]=x/2;}
        
        ll lcmi=A[0];
        REP(i,1,n)
        {
           lcmi=lcm(lcmi,A[i]);
        }
        
        REP(i,0,n)
        {
              ll temp=lcmi/A[i];
             
            if(temp%2==0)
            {
                cout<<0;return 0;
            }
           
        }
        if(lcmi>m){cout<<0;return 0;}
        ll ans1=0;
        ans1=m/lcmi;
        ll ans2=0;
        ans2=(ans1)-(ans1/2);
       cout<<ans2; 
    return 0;
}

Measured memory_bytes: 1024
import sys
readline = sys.stdin.readline

def main():
    N, A = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))
    lim = max(X) * N
    X = [x-A for x in X]
    dp = [[0]*(2*lim) for _ in range(N+1)]
    dp[0][lim] = 1
    for i in range(1, N+1):
        x = X[i-1]
        for j in range(2*lim):
            if 0 <= j - x < 2 * lim:
                dp[i][j] = dp[i-1][j] + dp[i-1][j-x]
            else:
                dp[i][j] = dp[i-1][j]
    
    print(dp[N][lim] - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;



int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll x[n];
  REP(i,n) cin >> x[i];

  ll ans = 0;

  REP(i,n-1){
    ans += min((x[i+1] - x[i]) * a, b);
  }

  cout << ans << endl;

  return 0;
}


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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
#define INF 1000000000

void ch(int &x, int &y){
    if(y < x){
        int tmp = y;
        y = x;
        x = tmp;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int>D(N+1);
    vector<P>DS(N);
    for (int i = 1; i <= N; ++i) {
        cin >> D[i];
        DS[i-1] = P(D[i], i);
    }
    sort(DS.begin(), DS.end());
    Graph graph(N+1);
    map<P, int>mp;
    vector<int>U(M);
    vector<int>V(M);
    for (int i = 0; i < M; ++i) {
        cin >> U[i] >> V[i];
        ch(U[i], V[i]);
        mp[P(U[i], V[i])] = INF;
        graph[U[i]].push_back(V[i]);
        graph[V[i]].push_back(U[i]);
    }

    vector<int>ans(N+1, 0);
    for (int i = 0; i < N; ++i) {
        int v = DS[i].second;
        int cs = DS[i].first;
        if (ans[v]) continue;
        int flag = 0;
        for (int x: graph[v]) {
            if (ans[x] != 0) {
                int t1 = v;
                int t2 = x;
                ch(t1, t2);
                mp[P(t1, t2)] = cs;
                flag = 1;
                if (ans[x] == 1) ans[v] = 2;
                else ans[v] = 1;
                break;
            }
        }
        if (flag) continue;
        for (int x: graph[v]) {
            if (D[x] == cs) {
                flag = 1;
                ans[v] = 1;
                ans[x] = 2;
                int t1 = v;
                int t2 = x;
                ch(t1, t2);
                mp[P(t1, t2)] = cs;
                break;
            }
        }
        if (flag) continue;

        cout << -1 << "\n";
        return 0;
    }

    for (int i = 1; i <= N; ++i) {
        if (ans[i] == 1) {
            cout << "W";
        } else {
            cout << "B";
        }
    }
    cout << "\n";
    for (int i = 0; i < M; ++i) {
        cout << mp[P(U[i], V[i])] << "\n";
    }
    return 0;
}

Measured memory_bytes: 24192
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int a,b,t;
    scanf("%d%d%d",&a,&b,&t);
    int i=1,ans=0;
    while(i*a<=t)
    {
        ans=i*b;
        i++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,k;
  scanf("%d%d", &n, &k);
  double ans=0,div;
  int score,i;
  for(i=1;i<=n;i++){
    score=i;
    div=1/(double)n;
    while(score<k){
      score*=2;
      div/=2;
    }
    ans+=div;
  }
  printf("%.12lf", ans);
  return 0;
}

Measured memory_bytes: 128
N = int(input())
a = list(map(int, input().split()))
sorted_a = list(reversed(sorted(a)))
alice = 0
bob = 0
for i in range(N):
    if i % 2 == 0:
        alice += sorted_a[i]
    else:
        bob += sorted_a[i]
print(alice - bob)

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

int main(){
  int a, countF,countS;
  countF=countS=0;
  for(int i=0;i<3;i++){
    cin>>a;
    if(a==5){
      countF++;
    }
    else if(a==7){
      countS++;
    }
  }
  if(countF==2&&countS==1){
    cout<<"YES"<<endl;
   }
  else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

class Edge {
    int from, to, cap;
    Edge rev;
    this(int from, int to, int cap) {
        this.from = from;
        this.to = to;
        this.cap = cap;
    }
}
class Graph {
    int V; // ?¬????????¬¨??°
    Edge[][] G;
    this(int V) {
        this.V = V;
        this.G = new Edge[][V];
    }
    void addEdge(int from, int to, int cap) {
        auto e = new Edge(from ,to, cap);
        auto r = new Edge(to, from, 0);
        e.rev = r; r.rev = e;
        G[from] ~= e; G[to] ~= r;
    }
    int maxFlow(int s, int t) {
        auto used = new bool[V];
        int dfs(int v, int t, int f) {
            if (v == t) return f;
            used[v] = true;
            foreach (e; G[v]) {
                if (!used[e.to] && e.cap > 0) {
                    int d = dfs(e.to, t, min(f, e.cap));
                    if (d > 0) {
                        e.cap -= d;
                        e.rev.cap += d;
                        return d;
                    }
                }
            }
            return 0;
        }
        int flow = 0;
        while (true) {
            used[0 .. $] = false;
            int f = dfs(s, t, cast(int)1e9);
            if (f == 0) return flow;
            flow += f;
        }
    }
}

void main() {
    int V, E; readf("%d %d\n", &V, &E);
    auto g = new Graph(V);
    foreach (_; 0 .. E) {
        int s, t, c; readf("%d %d %d\n", &s, &t, &c);
        g.addEdge(s, t, c);
    }
    writeln(g.maxFlow(0, V - 1));
}

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

int main(){
    int n,ans = 0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n-2; i++){
        if (s.substr(i,3) == "ABC") ans++;
    }
    cout << ans << "\n";
}

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


int main (){


  int m,nmin,nmax,ans,diff;
  int point[200];
  while(1){
    scanf("%d %d %d",&m,&nmin,&nmax);
    if(m == 0 && nmin == 0 && nmax == 0) break;
    for(int i = 0;i < m;i++){
      scanf("%d",&point[i]);
    }
    //std::sort(point,point+m,std::greater<int>());
    //ans = nmin;
    ans = 0;
    diff = 0;
    for(int ss = nmin;ss <= nmax;ss++){
      if(point[ss-1] - point[ss] >= diff){
        diff = point[ss-1] - point[ss];
        ans = ss;
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 2728
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let n: usize = input();
    let (d, x) = input_tuple();
    let mut a_vec: Vec<u64> = Vec::new();
    for _ in 0..n {
        let a: u64 = input();
        a_vec.push(a);
    }
    let mut sum = 0;
    for i in 0..d {
        for a in &a_vec {
            if i % a == 0 {
                sum += 1;
            }
        }
    }
    println!("{}", x + sum);
}


Measured memory_bytes: 2132
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a)%mod;
        }
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2);
}

void solve()
{
	int n , k;
	
	cin >> n >> k;
	
	int a[n];
	
	for(int i= 0; i < n; ++i) {
		cin >> a[i];
	}
	
	sort(a,a+n);
	
	int sm = 0;
	
	for(int i = 0; i < k; ++i) {
		sm += a[i];
	}
	
	cout << sm;
}

signed main() {
    fast;
    
    int t = 1;
    
    //cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


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

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


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


int main() {
	
	int n;
	cin >> n;
	
	vector<pair<int, int>> a(n);
	
	rep(i, n){
		int x;
		cin >> x;
		a[i] = make_pair(x, i+1);
	}
	sort(a.begin(), a.end());
	
	rep(i, n){
		cout << a[i].second << endl;
	}
	
	
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, T;
  cin >> N >> T;
  vector<int> A;
  int flag = 0;
  for(int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if(t > T) {
      continue;
    }
    A.push_back(c);
    flag = 1;
  }
  if(flag) {
    sort(A.begin(), A.end());
    cout << A[0] << endl;
  } else {
    cout << "TLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	int H;
	long long int A[255];
	cin >> H;

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

	for (int i = 0; i < H; i++)
	{
		printf("node %d: key = %lld, ", i + 1, A[i]);
		if (i != 0)
		{
			printf("parent key = %lld, ", A[((i + 1) / 2) - 1]);
		}
		if ((i + 1) * 2 <= H)
		{
			printf("left key = %lld, ", A[((i + 1) * 2) - 1]);
		}
		if ((i + 1) * 2+1 <= H)
		{
			printf("right key = %lld, ", A[((i + 1) * 2 + 1) - 1]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    cout<<setprecision(16);
    ll n,k;
    cin>>n>>k;
    vector<double> v(n,0);
    rep(i,n){
        cin>>v[i];
    }
    ll l = 1;
    ll r = 1e9;

    rep(ii,1000){
        ll mid = (l+r)/2.0;
        ll sum = 0;

        rep(i,n){
            ll c = v[i];
            if(mid!=0) {
                sum += (c / mid);
                if (c % mid == 0)sum--;
            }
        }
        if(sum>k){
            l=mid;
        }else{
            r=mid;
        }



    }



    cout<<r<<endl;






    return 0;
}


Measured memory_bytes: 4860
num=[]
while a=gets
  num=a.split(nil)
  num.map!{|n| n.to_f}
  x=(num[2]*num[4]-num[1]*num[5])/(num[0]*num[4]-num[1]*num[3])
  y=(num[2]*num[3]-num[0]*num[5])/(num[1]*num[3]-num[0]*num[4])
  puts printf("%.3f %.3f",x+0,y+0)#+0は-0.000になることを防いでいる
end

Measured memory_bytes: 6140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>	// upper_bound(A, A+N, num), lower_bound(A, A+N, num)
#include <functional>
#include <string>
#include <sstream>
#include <complex>
#include <vector>		// V[i],  push_back(x), pop_back(), insert(index, x), erase(index), sort(v.begin(), v.end(), greater<int>())
#include <list>			// push_front(x), push_back(x), pop_front(), pop_back(), insert(index, x)
#include <queue>		// push(x), front(), pop()
#include <deque>
#include <stack>		// push(x), top(), pop()
#include <map>			// M[key],  insert(key, val), erase(key), find(key), 
#include <set>			// insert(key), erase(key), find(key)

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

#define PI 3.141592653589793
#define MOD 1000000007
#define REP(i, n) for(int i = 0; i < n; i++)



void solve() {
	int a, b;
	cin >> a >> b;
	int ans = max(a + b, max(a - b, a*b));
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;

int dy[4]={0,0,1,-1};
int dx[4]={1,-1,0,0};

int main(){
	int A,B;
	cin>>A>>B;
	if(A%3==0||B%3==0||(A+B)%3==0)cout<<"Possible";
	else cout<<"Impossible";
}

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

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  int H;
  cin >> H;

  int ans = 0;
  int cnt = 1;

  while(H > 0){
    H /= 2;
    ans += cnt;
    cnt *= 2;
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

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)

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
ll modpow(ll a,ll b){
  ll r=1;
  while(b){
    if(b&1)r=r*a%MOD;
    a=a*a%MOD;
    b>>=1;
  }
  return r;
}

const int MX = 10002521;
int ifact[MX];

int h,w,k;

int main(){
  scanf("%d%d%d",&h,&w,&k);
  
  ifact[MX-1] = 586218400;
  FORR(i,1,MX)ifact[i-1] = 1ll*ifact[i]*i%MOD;
  
  ll hw = modpow(1ll * ifact[h] * ifact[w] % MOD, MOD-2);
  ll factk = 1;
  FOR(i,1,k+1)factk = factk*i%MOD;

  ll ans = 0;
  ll k16 = 1ll * (k+1) * ifact[3] % MOD;
  FOR(p,max(0,k-w),min(h,k)+1){
    ll X = p;
    ll Y = k-X;
    ll val = k16 * (2*X*Y%MOD + 3*k + 6) % MOD + MOD - 1;
    ans += val * ifact[h-X] % MOD * ifact[w-Y] % MOD * ifact[X] % MOD * ifact[Y] % MOD;
  }
  ans %= MOD;
  ans = ans * hw % MOD * factk % MOD;
  
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, S;
  cin >> N >> K;
  S = 1;

  for(int i=0; i<N; i++){
    if(S < K){
      S *= 2; 
    }
    else {
      S += K;
    }
  }
  cout << S << endl;
}

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

int main(){
  string S,T;
  cin >> S >> T;
  bool ans=false;
  int size=S.size();
  for(int i=0;i<size;++i){
    if(S==T) ans=true;
    string a="";
    a+=S.at(size-1);
    for(int j=0;j<size-1;++j){
      a+=S.at(j);
    }
    S=a;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
import scala.io.Source

object Main extends App {
  val lines = Source.stdin.getLines()
  val n = lines.next().toInt
  val list = lines.take(n)
  println(solve(list))


  def solve(list: Iterator[String]): String = {
    list.toStream
      .take(n)
      .map(_.toInt)
      .foldLeft((Int.MinValue.toInt, Int.MaxValue.toInt)) { case ((temporaryMax, temporaryMin), current) =>
        (temporaryMax max current - temporaryMin, temporaryMin min current)
      }._1.toString
  }
}




Measured memory_bytes: 110300
#include <stdio.h>

int main(void)
{
	int W,H,i,j;
	
	scanf("%d %d",&H,&W);
	while(H != 0 && W != 0)
	{
		for(i=0;i<H;i++)
		{
			for(j=0;j<W;j++)
			{
				if(i%2==0)
				{
					if(j%2==0)
						printf("#");
					else
						printf(".");
				}
				else
				{
					if(j%2==0)
						printf(".");
					else
						printf("#");
				}
			}
			printf("\n");
		}
		scanf("%d %d",&H,&W);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; 
  while ( cin >> n ) {
    int cnt = 0;
    for ( int i = 0; i < 10; i++ ) {
      for ( int j = 0; j < 10; j++ ) {
    for ( int k = 0; k < 10; k++ ) {
      int l = n - i - j - k;
      if ( l >= 0 && l < 10 && i + j + k + l == n ) cnt++;
    }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

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

int main()
{
  long N;
  cin >> N;

  long m = 0;

  for (long i = 1; i < sqrt(N) + 1; i++)
  {
    if (N % i == 0)
    {
      m = i;
    }
  }

  cout << (m - 1) + (N / m - 1) << endl;
}


Measured memory_bytes: 256
n=int(input())

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

ans=0
rem=0
for i in range(n):
    if A[i]>B[i]:
        ans+=B[i]
    else:
        ans+=A[i]
        rem=B[i]-A[i]
        if A[i+1]>rem:
            ans+=rem
            A[i+1]-=rem
        else:
            ans+=A[i+1]
            A[i+1]=0

print(ans)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n;string s;
	cin >> n >> s;

	int cnt = 0;

	loop(i,0,n)if(s[i] == 'R')cnt++;

	int ans= 0;

	loop(i,0,cnt)if(s[i] != 'R')ans++;

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 3772
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
m = [[0] * w for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if m[i][j] == 1:
            continue
        m[i][j] = 1
        qs = [[i, j]]
        white = 0
        black = 0
        while len(qs) != 0:
            q = qs.pop(0)
            if s[q[0]][q[1]] == '.':
                white += 1
            else:
                black += 1
            m[q[0]][q[1]] = 1
            for k in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
                if not (0 <= q[0] + k[0] <= h - 1) or not (0 <= q[1] + k[1] <= w - 1):
                    continue
                if m[q[0] + k[0]][q[1] + k[1]] == 0 and s[q[0]][q[1]] != s[q[0] + k[0]][q[1] + k[1]]:
                    m[q[0] + k[0]][q[1] + k[1]] = 1
                    qs.append([q[0] + k[0], q[1] + k[1]])
        ans += black * white
print(ans)

Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int n;
vector<int> node;
void resize(int x){
	n = 1;
	while(x > n){
		n *= 2;
	}
	node.resize(2 * n - 1,0);
}
void update(int x,char c){
	x += (n - 1);
	node[x] = 1 << (c - 'a');

	while(x > 0){
		x = (x - 1) / 2;
		node[x] = node[2 * x + 1] | node[2 * x + 2];
	}
}

int getsize(int a,int b,int k = 0,int l = 0,int r = -1){
	if (r < 0){
		r = n;
	}
	if (r <= a || b <= l){
		return 0;
	}
	if (a <= l && r <= b){
		return node[k];
	}
	int vl = getsize(a,b,2 * k + 1,l, (l + r) / 2);
	int vr = getsize(a,b,2 * k + 2,(l + r) / 2, r);
	return vl | vr;
}





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

	for(int i = 0; i < size; i++) {
		update(i,s[i]);
	}

	// for(int i = 0; i < 2 * n - 1; i++) {
	// 	cout << i << node[i].size() << endl;
	// }
	int q;cin>>q;
	for(int i = 0; i < q; i++) {
		int q1;cin>>q1;
		if(q1 == 1){
			int iq;char cq;cin>>iq>>cq;
			iq--;
			update(iq,cq);
		}
		else{
			int l,r;cin>>l>>r;
			l--;
			int ans = getsize(l,r);
			cout << __builtin_popcount(ans) << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4996
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq # priolity-queue
# import time
# import itertools
# import collections # queue
# from operator import itemgetter
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    a,b,c,d = map(int,input().split())
    ans = 0
    if a<=c:
        if b<=c: pass
        elif b>=d: ans = d - c
        else: ans = b - c
    else:
        if a>=d: pass
        elif b<=d: ans = b - a
        else: ans = d - a
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 3064