akhauriyash/Code-Regression huggingface dataset:
#pragma warning(disable:4996)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;

#define INF 0x3fffffff
typedef long long ll;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define pb push_back

const int maxn = 400 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }

int n, c;
int a[maxn], b[maxn];
int dp[maxn][maxn], res[maxn][maxn];

void solve()
{
	scanf("%d%d", &n, &c);

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

	for (int i = 1; i <= 400; i++)
	{
		for (int j = 0; j <= 400; j++)
		{
			dp[i][j] = (j == 0 ? 1 : 1LL*dp[i][j - 1] * i%mod);
			dp[i][j] %= mod;
		}
	}
	for (int i = 1; i <= 400; i++)
	{
		for (int j = 1; j <= 400; j++)
		{
			dp[i][j] += dp[i - 1][j];
			if (dp[i][j] >= mod)
			{
				dp[i][j] -= mod;
			}
		}
	}
	memset(res, 0, sizeof(res));
	res[0][0] = 1;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= c; j++)
		{
			for (int k = 0; k <= j; k++)
			{
				if (!res[i - 1][j - k])continue;
				int t = 0;
				if (k == 0)
				{
					t = (b[i] - (a[i] - 1) + mod) % mod;
				}
				else
				{
					t = (dp[b[i]][k] - dp[a[i] - 1][k] + mod) % mod;
				}
				res[i][j] += 1LL*res[i - 1][j - k] * t%mod;
				res[i][j] = (res[i][j] + mod) % mod;
			}
		}
	}
	printf("%d\n", res[n][c]);
}

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


Measured memory_bytes: 1536
loop do
	s = gets.chomp
	break if s == ?#
	cand = [s]
	('a'..'z').to_a.reverse.each_cons(2) do |from, to|
		next_cand = []
		cand.each do |s|
			if s =~ /#{to}/
				flag = true
				s.each_char.with_index do |c, i|
					if flag && c == to
						copy = s.dup
						copy[i] = from
						next_cand << copy
					elsif c == from
						flag = false	
						break
					end
				end
				next_cand << s if flag
			else
				next_cand << s if s !~ /#{from}/
			end
		end
		cand= next_cand
	end	
	cand.sort!
	p n = cand.size
	if n <= 10
		puts cand
	else
		puts cand[0..4]
		puts cand[-5..-1]
	end
end

Measured memory_bytes: 14712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (int)1.01e9;
const int N = 1 << 19;
const int MOD = (int)1e9 + 7;


int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    int n, m;
    while (cin >> n >> m) {
        vector<string> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];

        vector<int> cnt(26);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                cnt[a[i][j] - 'a']++;
            }
        }

        vector<int> need;
        for (int i = 0; i * 2 < n; i++) {
            for (int j = 0; j * 2 < m; j++) {
                set<pair<int, int> > st;
                st.insert({i, j});
                st.insert({n - 1 - i, j});
                st.insert({i, m - 1 - j});
                st.insert({n - 1 - i, m - 1 - j});
                need.push_back(st.size());
            }
        }
        sort(need.begin(), need.end());
        reverse(need.begin(), need.end());

        bool ok = 1;
        for (int x : need) {
            int j = 0;
            for (int i = 1; i < 26; i++) if (cnt[i] > cnt[j]) {
                    j = i;
                }
            ok &= cnt[j] >= x;
            cnt[j] -= x;
        }
        string ans = ok ? "Yes" : "No";
        cout << ans << endl;
    }

#ifdef HOME
    cerr << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 998244353;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    char c;
    cin >> c;
    cout << (('A' <= c && c <= 'Z') ? 'A' : 'a') << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	if (S[0] == 'A')
	{
		int cnt2 = 0;
		int idx2 = 2;
		for (int i = 2; i < S.size() - 1; i++)
		{
			if (S[i] == 'C')
			{
				cnt2++;
				idx2 = i;
			}
		}

		if (cnt2 == 1)
		{
			for (int i = 1; i < S.size(); i++)
			{
				if (i == idx2) continue;
				if (S[i] >= 'A' && S[i] <= 'Z')
				{
					cout << "WA";
					return 0;
				}
			}

			cout << "AC";
			return 0;
		}
	}

	cout << "WA";
	
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector <int> p(n);
  for (int i = 0; i < n; i++) {
	  cin >> p[i];
	}
  int ans = 0;
  for (int i = 1; i < n - 1; i++) {
	  if ((p[i] - p[i - 1]) * (p[i + 1] - p[i]) > 0) {
		  ans++;
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import Control.Applicative

ans :: [Integer] -> Bool
ans lst =
    let count :: [Integer] -> (Int, Int, Int)
        count [] = (0, 0, 0)
        count (first:rest)
            | (mod first 4) == 0 =
                let (x, y, z) = count rest
                    in (x, y, z + 1)
            | (mod first 2) == 0 =
                let (x, y, z) = count rest
                    in (x, y + 1, z)
            | otherwise = 
                let (x, y, z) = count rest
                    in (x + 1, y, z)
        (odds, evens, fours) = count lst
        in if evens < 1 then (odds - 1 <= fours) else (odds <= fours)

out :: Bool -> String
out a = if a then "Yes" else "No"

main = do
    getLine
    putStrLn =<< out . ans . (map (\a -> read a :: Integer)) . words <$> getLine


Measured memory_bytes: 36220
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int N, W;
int v[100], w[100];
int dp[101][10001];

void solve(){
    Rep(i, 0, N + 1) dp[i][0] = 0;
    Rep(j, 0, W + 1) dp[0][j] = 0;
    Rep(i, 1, N + 1){
        Rep(j, 1, W + 1){
            if(j < w[i - 1]) dp[i][j] = dp[i - 1][j];
            else dp[i][j] = Max2(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
        }
    }
}

int main(){
    cin >> N >> W;
    Rep(i, 0, N){
        cin >> v[i] >> w[i];
    }
    solve();
    Print(dp[N][W]);
    return 0;
}


Measured memory_bytes: 7028
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        WriteLine(Math.Min(cin.nextint * cin.nextint, cin.nextint));
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int32_t main(){
    fast_io;
    int a,b;
    cin>>a>>b;
    show(a*b);
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
using namespace std;
string s;long k,n,i;
int main(){
  cin>>s>>k;
  n=s.size();
  for(i=0;i<n;i++)if(s[i]!='a'&&123-s[i]<=k){k-=123-s[i];s[i]='a';}
  s[n-1]+=k%26;if(s[n-1]>122)s[n-1]-=26;
  cout<<s<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

long long int mod=1e9+9;
const int N=100000;
int t=3,i,j,cs=0,n,a,b;
string s;

int main()
{
    cin>>s;
   for(auto it:s)
    if(it=='7'){
        cout<<"Yes"<<endl;
        return 0;
    }
        cout<<"No"<<endl;
}





Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int N;
    char c;
    cin >> N;

    vs32 L(N + 1, 0);
    L[0] = 0;
    rep (i, N)
    {
        cin >> c;
        L[i + 1] = L[i];
        if (c == 'W') ++L[i + 1];
    }

    int ans = N;
    rep (i, N)
    {
        ans = MIN(N - i - 1 - L[N] + L[i + 1] + L[i], ans);
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  int N; cin >> N;
  vector<LL> S(N + 1); S[0] = 0;
  for (int i = 0; i < N; ++i) {
    LL a; cin >> a;
    S[i + 1] = S[i] + a;
  }

  vector<vector<LL>> dp(N + 1, vector<LL>(N + 1, 1e18));
  for (int i = 0; i <= N; ++i) dp[i][i] = 0;

  for (int j = 1; j <= N; ++j) {
    for (int i = 0; i + j <= N; ++i) {
      int l = i, r = i + j;
      LL merge_cost = S[r] - S[l - 1];
      for (int k = l; k < r; ++k) {  // dp[i][k] + dp[k+1][i+j]
        dp[l][r] = min(dp[l][r], dp[l][k] + dp[k+1][r] + merge_cost);
      }
    }
  }
  cout << dp[1][N] << endl;
}


Measured memory_bytes: 4856
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . ( * 3 ) . ( ^ 2 )

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

#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;

int main(){
   int n;cin >> n;
   vector<double> a(n);
   rep{
           cin >> a[i];
   }
   sort(a.begin(),a.end());
   while(a.size()>1){
           double x = (a[0]+a[1])/2.0;
           a.erase(a.begin(),a.begin()+2);
           a.push_back(x);
           sort(a.begin(),a.end());
           //cout << a.size() << endl;
   }
   printf("%.6f\n",a[0]);
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace diverta2019ProgrammingContest
{
    class Program
    {
        static void Main(string[] args)
        {
            var RGBN = Console.ReadLine().Split().Select(int.Parse).ToList();
            long R = RGBN[0];
            long G = RGBN[1];
            long B = RGBN[2];
            long N = RGBN[3];
            long cnt = 0;
            for (int r = 0; R * r <= N; ++r)
            {
                for (int g = 0; R * r + G * g <= N; ++g)
                {
                    var bb = N - (R * r + G * g);
                    if (0 == bb % B)
                    { ++cnt; }
                }
            }
            Console.WriteLine($"{cnt}");
        }
    }
}

Measured memory_bytes: 13396
h,w = list(map(int,input().strip().split()))

result =""
for i in range(w+2):
  result += "#"
print(result)

for j in range(h):
  result = "#"
  s = input()
  result += s
  result += "#"
  print(result)
result =""
for i in range(w+2):
  result += "#"
print(result)




Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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 VRSORT(v) sort(v.rbegin(), v.rend());//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,w;
  int dp[110][10010];
  cin >> n >> w;
  int value[110],weight[110];
  REP(i,n) cin >> value[i] >> weight[i];
  memset(dp,-1,sizeof(dp));
  REP(j,10010) dp[0][j] = 0;

  REP(i,n){
    for(int j=0;j<=w;++j){
      if(j<weight[i]) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = max(dp[i][j],dp[i+1][j-weight[i]]+value[i]);
    }
  }

  cout << dp[n][w] << endl;
}


Measured memory_bytes: 7480
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> L;
int main(){
    int n, m, a;
    L l[1050];
    while(true){
	cin >> n >> m >> a;
	if(n == 0 && m == 0 && a == 0)return 0;
	for(int i = 0;i < m;i++){
	    cin >> l[i].first >> l[i].second.first >> l[i].second.second;
	}
	sort(l, l + m, greater<L>());
	for(int i = 0;i < m;i++){
	    P tmp = l[i].second;
	    if(tmp.first == a)a = tmp.second;
	    else if(tmp.second == a)a = tmp.first;
	}
	cout << a << endl;
    }
}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	vector<int> b(N);
	for (int i = 0; i < N; i++) {
		cin >> b[i];
		b[i]--;
	}
	vector<int> ans;
	while (b.size() > 0) {
		int j = b.size() - 1;
		while (j >= 0) {
			if (b[j] == j) break;
			j--;
		}
		if (j == -1) {
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(j + 1);
		b.erase(b.begin() + j);
	}
	for (int i = ans.size() - 1; i >= 0; i--) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto s = readStr;
  bool dif;

  foreach(i; 0 .. 3){
    if(s[i] == s[i+1]) dif = true;
  }

  writeln(dif ? "Bad" : "Good");
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

// 貰うDP(動的計画法)

func main() {

	var n int
	fmt.Scan(&n)

	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	dp := make([]int, 100010)
	dp[1] = abs(h[1] - h[0])
	// 初期化(最小化問題なのでINF尼初期化)
	for i := 2; i < n; i++ {
		dp[i] = abs(h[1] - h[0])

		b1:= dp[i-1] + abs(h[i] - h[i-1])
		b2 := dp[i-2] + abs(h[i] - h[i-2])
		if b1 < b2 {
			dp[i] = b1
		} else {
			dp[i] = b2
		}
	}
	fmt.Println(dp[n-1])
}

func abs(n int) int {
	y := n >> 63
	return (n ^ y) - y
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 6312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <map>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll maxn = 1e6 + 5;

int main(){
	int n,m,a[10],s,c;
	map<int,int>mp;
	cin>>n>>m;
	bool flag=false;
	memset(a,-1,sizeof(a));
	while(m--){
		cin>>s>>c;
		if(a[s]==-1){
			mp[s]=c;
			a[s]=c;
		}else{
			if(mp[s]!=c) flag=true;
		}
	}
	if(a[1]==0 && n>1) flag=true;
	if(flag) cout<<-1;
	else{
		if(n>1){
			for(int i=1;i<=n;i++){
				if(a[i]==-1 && i==1) cout<<1;
				else if(a[i]==-1 && i>1) cout<<0;
				else cout<<a[i];
			}
		}else{
			if(a[1]==-1) cout<<0;
			else cout<<a[1];
		}
	}
	return 0;
}

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

typedef long long  ll;

ll dp[51][50*50];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    dp[0][0] = 1;
    
    int N,A,temp;
    cin>>N>>A;
    for (int i = 0; i<N; i++) {
        cin>>temp;
        for(int j = i; j>=0; j--)
            for(int k = 0; k<=i*50 ; k++){
                dp[j+1][k+temp] += dp[j][k];
            }
    }
    
    ll ans = 0;
    for(int i = 1; i<=N; i++){
        ans += dp[i][i*A];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1280
import numpy as np
import itertools


hwk = input().split(' ')

h = int(hwk[0])
w = int(hwk[1])
k = int(hwk[2])

mat = np.zeros([h, w])

for i in range(h):
  tmp_row_str = input()
  tmp_row = np.array([1 if tmp_row_str[j] == '#' else 0 for j in range(w)])
  mat[i] = tmp_row

count = 0

sum_rows = mat.sum(axis=0)
sum_cols = mat.sum(axis=1)

sum_total = mat.sum()

row_combs = itertools.product([0, 1], repeat=h)
col_combs = list(itertools.product([0, 1], repeat=w))

count = 0


for row_comb in row_combs:
  #col_combs = itertools.product([0, 1], repeat=w)
  for col_comb in col_combs:
    tmp_mat = mat.copy()
    tmp_mat[np.array(row_comb).astype('bool')] = 0
    tmp_mat[:, np.array(col_comb).astype('bool')] = 0

    
    if tmp_mat.sum() == k:
      count += 1

print(count)

"""
while True:
  if sum_total == k:
    print(1)
    break
  #まず列から
"""
  

Measured memory_bytes: 27128
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int[] A = new int [N];
      	for(int i = 0; i < N; i++){
        	A[i] = sc.nextInt();
        }
      	boolean isTrue = true;
      	for(int i = 0; i < N; i++){
        	if(A[i] % 2 == 0){
            	if(A[i]%3==0 || A[i]%5==0){
                	
                }else{
                	isTrue = false;
                }
            }
        }
      	if(isTrue) System.out.println("APPROVED");
      	else System.out.println("DENIED");
    }
}

Measured memory_bytes: 35964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  string s;
  PP t=PP(31,P(4,30));
  while(cin>>s,s!="#"){
	int a,b,c;
	cin>>a>>b>>c;
	if(PP(a,P(b,c))>t){
	  cout<<"? ";
	  a-=30;
	}else cout<<s<<" ";
	cout<<a<<" "<<b<<" "<<c<<endl;
  }
  return 0;
}



Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	int N, M; cin >> N >> M;
	int a[100100];
	ll dp[100100];
	for (int i = 0; i < 100100; ++i) {
		dp[i] = 0;
	}
	for (int i = 0; i < M; ++i) {
		cin >> a[i];
		dp[a[i]] = -1;
	}
	dp[0] = 1;
	if (dp[1] != -1) {
		dp[1] = 1;
	}
	for (int i = 2; i < 100100; ++i) {
		if (dp[i] == -1) {
			continue;
		}
		if (dp[i - 2] != -1) {
			dp[i] += dp[i - 2];
		}
		if (dp[i - 1] != -1) {
			dp[i] += dp[i - 1];
		}
		dp[i] %= INF;
	}
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    int h,w;cin>>h>>w;
    vector<string>s(h);
    rep(i,h)cin>>s[i];
    vector<bool>f(h);
    vector<bool>g(w);
    rep(i,h){
        rep(j,w){
            if(s[i][j]!='.')break;
            if(j==w-1){
                f[i] = true;
            }
        }
    }
    rep(i,w){
        rep(j,h){
            if(s[j][i]!='.')break;
            if(j==h-1){
                g[i] = true;
            }
        }
    }
    rep(i,h){
        if(f[i])continue;
        rep(j,w){
            if(g[j])continue;
            cout<<s[i][j];
        }
        cout<<endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P; 

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, init, n) for(ll i = init; i <(ll)(n); i++)

int main() {

    string s;
    cin >> s;
    s += "TTT";
    int x, y;
    cin >> x >> y;

    vector<int> v, u;
    bool up = false;
    int tmp = 0;

    int us = 0, vs = 0;
    REP(i, s.size()){
        if (s[i] == 'F') tmp++;
        else{
            if (up) {u.push_back(tmp); us += tmp;}
            else {v.push_back(tmp); vs += tmp;}
            tmp = 0;
            up ^= true;
        }
    }
    vector<vector<bool>> v1(u.size(), vector<bool>(2 * us + 5, false));
    vector<vector<bool>> v2(v.size(), vector<bool>(2 * vs + 5, false));

    REP(i, v.size()){
        if (i == 0){
            v2[i][v[0] + vs] = true;
        }
        else REP(j, 2 * vs + 4){
            if (v2[i-1][j]){
                v2[i][j - v[i]] = true;
                v2[i][j + v[i]] = true;
            }
        }
    }

    REP(i, u.size()){
        if (i == 0){
            v1[i][u[0] + us] = true;
            v1[i][-u[0] + us] = true;
        }
        else REP(j, 2 * us + 4){
            if (v1[i-1][j]){
                v1[i][j - u[i]] = true;
                v1[i][j + u[i]] = true;
            }
        }
    }

    if (x + vs >= 0 && y + us >= 0  && v2[v.size()-1][x + vs] && v1[u.size()-1][y + us]) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
using namespace std;

int main(){
  int K,A,B,ans=0;
  cin>>K>>A>>B;
  bool CAN=false;
  
  for(int i=A; i<=B; ++i){
    if(i%K==0) CAN=true;
  }
  
  if(CAN) cout<<"OK"<<endl;
  else cout<<"NG"<<endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


vector <pair <int, int> > v;
const int N = 5005;
int dp[N];
const int INF = (int) 2e9 + 100;

int main(int,  char **)
{
#ifdef LOCAL
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        int h, p;
        scanf("%d%d", &h, &p);
        v.emplace_back(h + p, p);
    }
    sort(v.begin(), v.end() );
    sort(v.begin(), v.end() );

    for (int i = 1; i < N; i++)
            dp[i] = INF;

    for (int i = 0; i < n; i++)
    {
        for (int j = i; j >= 0; j--)
        {
            int cur = dp[j];
            if (cur <= v[i].first - v[i].second)
                dp[j + 1] = min(dp[j + 1], cur + v[i].second);
        }
    }
    int ans = 0;
    while (dp[ans + 1] < INF)
        ans++;
    printf("%d\n", ans);

	return 0;
}



Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 100100100100100;

int main() {
	string S;
	cin >> S;
	ll size = S.size();
	cout << S[0] << size - 2 << S[size - 1] << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()){
            int in = s.nextInt();
            int count = 0;
            for(int a=0; a<10; a++){
                for(int b=0; b<10; b++){
                    for(int c=0; c<10; c++){
                        for(int d=0; d<10; d++){
                            if((a+b+c+d)==in)
                                count++;
                        }
                    }
                }
            }
            System.out.println(count); 
        }
    }
}

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

int main() {
  int n,k,x,y;
  cin>>n>>k>>x>>y;
  int ans=0;
  if(n<=k){
  ans+=x*n;
  }else{
  ans+=k*x;
    ans+=(n-k)*y;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n, k, h[112345];

    cin >> n >> k;
    REP(i, n)
    cin >> h[i + 1];

    ll dp[112345];

    fill(dp, dp + n + 1, INF);

    dp[1] = 0;

    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            if (i + j > n)
                break;

            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }

    cout << dp[n] << endl;

    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    int n,m;cin >> n >> m;
    if(n == m)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

double deg_to_rad(double deg) {
	return deg*pi/180;
}

int main(){
    int A,B,H,M;
    cin>>A>>B>>H>>M;
    double angle=(H%12)*30+(double)0.5*M-M*6;
    
    cout<<fixed<<setprecision(10)<<sqrt((double)(A*A+B*B)-2*A*B*cos(deg_to_rad(angle)))<<endl;
    //cout<<sqrt((double)(A*A+B*B)-2*A*B*0.17364817766)<<endl;
    return 0;
}

Measured memory_bytes: 4132
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


def dfs(n):
    if n not in memo:
        ans = min(n*d, min(dfs(n//2),dfs((n+1)//2)) + a + d*(n % 2))
        if n % 3 <= 1:
            ans = min(ans, dfs(n//3) + b + d*(n % 3))
        else:
            ans = min(ans, dfs((n+2)//3) + b + d*(3 - n % 3))
        if n % 5 <= 2:
            ans = min(ans, dfs(n//5) + c + d*(n % 5))
        else:
            ans = min(ans, dfs((n+4)//5) + c + d*(5 - n % 5))
        memo[n] = ans
    return memo[n]


t = int(input())

for _ in range(t):
    n, a, b, c, d = map(int, input().split())
    memo = {0: 0, 1: d}
    print(dfs(n))


Measured memory_bytes: 98612
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	static String reverce(String str) {
		String strr="";
		for(int i=str.length()-1;i>=0;i--) {
			strr+=str.charAt(i);
		}
		return strr;
	}
	public static void main(String[] args) {
		String str=scan.next();
		int c1=0;
		int c2=0;
		for(int i=0;i<str.length();i++) {
			if(i%2==0) {
				if(str.charAt(i)=='0') {
					c1++;
				}
				else {
					c2++;
				}
			}
			if(i%2==1) {
				if(str.charAt(i)=='1') {
					c1++;
				}
				else {
				c2++;
				}
			}
		}
		System.out.println(Math.min(c1, c2));
	}
}


Measured memory_bytes: 39340
#include <iostream>

using namespace std;
#include <cmath>
#include <cstring>
#include <algorithm>

int main()
{
    int a,b;double c;
    cin>>a>>b;
    if(b<10)
        c=a*10+b;
    else if(b==100)
        c=a*1000+b;
    else
        c=a*100+b;
    if((sqrt(c)-int(sqrt(c)))==0)
        cout <<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Created by hikigineer on 2017/03/04.
 */
public class Main {
    static Scanner in;
    static PrintWriter out;
    static String INPUT = "";

    public static void main(String[] args) throws Exception
    {
        in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
        out = new PrintWriter(System.out);
        int N = ni();
        int M = ni();

        Long combi = N == M ? 2L: 1L;

        if(N - M > 1 || N - M < -1)
            combi = 0L;
        else
        {
            int i;
            for (i = N; i >= 1; i--)
            {
                combi *= i;
                combi = combi % 1000000007;
            }
            for (i =M; i >= 1; i--)
            {
                combi *= i;
                combi = combi % 1000000007;
            }
        }
        out.println(combi);
        out.flush();
    }

    static int ni() {
        return Integer.parseInt(in.next());
    }
}

Measured memory_bytes: 30292
#include <stdio.h>
#include <string.h>

int main(void){
	int n, i, j, flag[86400], time[3] = {3600,60,1}, sum1, sum2, max;
	char str[9], c;
	while(1){
		scanf("%d%*c",&n);
		if(!n)
			break;
		memset(flag,0,sizeof(flag));
		for(i = 0;i < n;i++){
			j = 0;
			while((c = getchar()) != ' ')
				str[j++] = c;
			str[j] = '\0';
			sum1 = 0;
			for(j = 0;j < strlen(str);j+=3)
				sum1 += time[j / 3] * ((str[j] - '0') * 10 + str[j + 1] - '0');
			j = 0;
			while((c = getchar()) != '\n')
				str[j++] = c;
			str[j] = '\0';
			sum2 = 0;
			for(j = 0;j < strlen(str);j+=3)
				sum2 += time[j / 3] * ((str[j] - '0') * 10 + str[j + 1] - '0');
			for(j = sum1;j < sum2;j++)
				flag[j]++;
		}
		max = -1;
		for(i = 0;i < 86400;i++){
			if(max < flag[i])
				max = flag[i];
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 1376
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n;
ll a[N], s, x;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) cin >> a[i], s += a[i];
   x = max (0ll, s - n * (n - 1));
   ll D = n + 1;
   ll have = x;
   for (int i = 1; i <= n; i ++) {
      a[i] += x;
      ll will = a[i] / D;
      if (have >= will) a[i] -= will * D, have -= will;
      else a[i] -= have * D, have = 0;
   }
   sort (a + 1, a + n + 1);
   while (a[n] >= n) {
      x ++;
      for (int i = 1; i < n; i ++) a[i] ++;
      a[n] -= n;
      sort (a + 1, a + n + 1);
   }
   cout << x;
}               
 
signed main () {                                       
  // #ifdef QWERTY
  //    freopen("input", "r", stdin);
  // #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3576
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
    }
    ll ans=0;
    ll maxi=0;
    for(int i=0;i<n;i++)
    {
        ans+=(max((ll)0,maxi-v[i]));
        maxi=max(v[i],maxi);
    }
    cout<<ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

int main(){
	int a, b; cin >> a >> b;
	string s; cin >> s;
	bool isPostalcode = true;
	for(int i = 0; i < a + b + 1; ++i){
		if(i == a){
			if(s[i] == '-') continue;
			else{
				isPostalcode = false;
				break;
			}
		}
		if(!isdigit(s[i])){
			isPostalcode = false;
			break;
		}
	}
	if(isPostalcode) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
// Binary indexed tree supporting binary search.
 
 
#define x first
#define y second
 
#define forn(i, n) for(int i = 0; i < int(n); ++i)
 
typedef pair<int, int> pii;
//#define forn(i, a,b) for (int i = (int) a; i <= (int) b; ++i)
struct query{
	int a,b,c,d;
};
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    long long A;
	long long B,N;
    cin>>A>>B>>N;
    cout<< (A*min(N,B-1))/B<<endl;
	return 0;	
}

Measured memory_bytes: 3640
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b & 1)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfb = b / 2;
		ll half = modpow(a, halfb) % MOD;
		return half * half % MOD;
	}

}

ll calcComb(ll a, ll b)
{
	if (b > a-b)
	{
		return calcComb(a, a-b);
	}

	ll ansMul = 1;
	ll ansDiv = 1;
	for (ll i = 0; i < b; i++)
	{
		ansMul *= (a-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

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

	int n;
	
	cin >> n;

	ll a[n];
	rep(i, n)
	{
		cin >> a[i];
	}

	sort(a, a+n);

	ll l = a[n-1];

	int idx = 0;
	ll mid = a[n-1] / 2;

	rep(i, n - 1)
	{
		//cout << calcComb(l, i+1) << " " << calcComb(l, i) << endl;
		/*
		if (calcComb(l, a[i+1]) < calcComb(l, a[i]))
		{
			idx = i;
			break;
		}
		*/
		if (abs(a[i+1] - mid) > abs(a[i] - mid))
		{
			idx = i;
			break;
		}
	}

	cout << a[n-1] << " " << a[idx] << endl;
	return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    fib = [0] * (n + 1)
    fib[0], fib[1] = 1, 1
    for i in range(2, n + 1):
        fib[i] = fib[i - 1] + fib[i - 2]
    print(fib[-1])


if __name__ == '__main__':
    resolve()



Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int H, W;
	cin >> H >> W;
	int A[1001][1001] = {};
	rep1(i, H) {
		string a;
		cin >> a;
		rep(j, W) if (a[j] == '#') A[i][j + 1] = 1;
	}

	ll mod = 1e9 + 7;
	ll dp[1001][1001] = {};
	dp[1][0] = 1;
	rep1(i, H) {
		rep1(j, W) {
			if (A[i][j] == 0) dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
		}
	}

	co(dp[H][W]);

	Would you please return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    long long ans = 0;
    FOR(i, 1, N+1){
        if(i%3 == 0 and i%5 == 0) continue;
        else if(i%3 == 0) continue;
        else if(i%5 == 0) continue;
        else ans += i;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

const int N = 2e5 + 5;

#define pii pair<int, int>

int n, m;
pii seg[N];
int uf[N];
priority_queue<int, vector<int>, greater<int>> Q;
int find(int x) {
	return uf[x] == x ? x : (uf[x] = find(uf[x]));	
}
void unit(int x, int y) {
	x = find(x), y = find(y);
	if (x > y)
		swap(x, y);
	if (x ^ y)
		uf[x] = y;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1, l, r; i <= n; i++) {
		scanf("%d%d", &l, &r);
		seg[i] = pii(l, r);
	}
	sort(seg + 1, seg + n + 1);
	uf[0] = 1;
	for (int i = 1; i <= m + 1; i++) {
		uf[i] = i;
	}
	pii *p = seg + 1, *_p = seg + n + 1;
	int ans = 0;
	for (int i = 0; i <= m; i++) {
		if (i && find(i) == i) {
			Q.push(0);
		} else if (i) {
			Q.push(i);
		}
		while (p != _p && p->first == i) {
			int R = p->second;
			boolean suc = false;
			if (!Q.empty()) {
				int tp = Q.top();
				if (tp < R) {
					int p = find(tp);
					if (p <= m) {
						unit(p, p + 1);
						Q.pop();
						Q.push(R);
						ans++;
						suc = true;
					}
				}
			}
			if (!suc) {
				int p = find(R);
				if (p <= m) {
					unit(p, p + 1);
					ans++;
					suc = true;
				}
			}
			p++;
		}
	}
	printf("%d\n", n - ans);
	return 0;
}


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

using namespace std;
constexpr uint64_t mod = 1e9 + 7;

int64_t calc(const vector<int> &x) {
  int64_t ans = 0;
  for (size_t i = 0; i < x.size() - 1; ++i) {
    int w = x[i + 1] - x[i];
    ans = (ans + w * (i + 1) * (x.size() - 1 - i)) % mod;
  }
  return ans;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  vector<int> x(n), y(m);
  for (auto &e : x)
    cin >> e;
  for (auto &e : y)
    cin >> e;
  int64_t ansx = calc(x), ansy = calc(y);
  cout << (ansx * ansy) % mod << "\n";
}


Measured memory_bytes: 1024