akhauriyash/Code-Regression huggingface dataset:
import numpy as np

num_of_books, num_of_algorithm, understanding = map(int, input().split())

books = []
for _ in range(num_of_books):
    books.append(list(map(int, input().split())))

mincost = -1
# 本1冊に対して買う買わないの2値があるため、2の冊数乗回ループ(bit全探索)
for i in range(2 ** num_of_books):

    # 購入する本のリスト
    bag = []
    totalcost = 0

    # 10進数iを購入のbitパターンとしたときのループ
    for j in range(num_of_books):
        # ビットを指定桁だけ右にシフトし、最下位ビット（購入の有無）をチェック
        # 1(0…1)と論理積を取ることで最下位ビットを確認できる
        if((i >> j) & 1):
            bag.append(books[j][1:])
            totalcost = totalcost + books[j][0]
        
    # すべての理解度が基準を超えているか
    # 購入した本の理解度の合計を算出し、すべて基準値以上か
    # (np.allで要素がすべてtrueか)
    if np.all(np.sum(np.array(bag), axis=0) >= understanding):
        if mincost == -1 or totalcost < mincost:
            mincost = totalcost 

print(mincost)

Measured memory_bytes: 27356
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fr(i,j,p)   for(int i=j; i<p ;i++)
#define frr(i,j,p)  for(int i=j; i>=p ;i--)
#define PI          3.14159265358979323846
#define pb          push_back
#define mkp         make_pair
#define print(m)    std::cout << std::fixed << std::setprecision(11) << m <<endl;
#define ff          first
#define ss          second
#define mod         1000000007

int main() {
    string s,t;	cin>>s>>t;
	lli m=s.size(),n=t.size();
  	lli dp[m+1][n+1];
  	fr(i,0,m+1) {
  	    fr(j,0,n+1) {
  	        if(i==0 || j==0) dp[i][j]=0;
  	        else {
  	            if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
  	            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
  	        }
  	    }
  	}
  	lli index=dp[m][n];
  	char lcs[index+1];
  	lcs[index]='\0';
  	lli i=m,j=n;
  	while(i>0 && j>0) {
  	    if(s[i-1]==t[j-1]) {
  	        lcs[index-1]=s[i-1];
  	        i--;
  	        j--;
  	        index--;
  	    }
  	    else if(dp[i-1][j] > dp[i][j-1]) i--;
  	    else j--;
  	}
//   	fr(i,0,dp[m][n]) cout<<lcs[i];
    cout<<lcs;
  	
  	
	return 0;
}

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

using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
//#define REP(i,a,b) for(int i=a;i<=b;i++)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
long long MOD=1e9+7;

int main()
{	
	ios_base:: sync_with_stdio(0);
	cin.tie(0);
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	 int x,y,z;
	 cin>>x>>y>>z;
	 cout<<z<<" "<<x<<" "<<y;
}


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

a = {}
for i in range(0, len(v), 2):
    a[v[i]] = a.get(v[i], 0) + 1

b = {}
for i in range(1, len(v), 2):
    b[v[i]] = b.get(v[i], 0) + 1

sorted_a = sorted(a.items(), reverse=True, key=lambda x: x[1])
sorted_b = sorted(b.items(), reverse=True, key=lambda x: x[1])

res = 0
if sorted_a[0][0] == sorted_b[0][0]:
    if sorted_a[0][1] > sorted_b[0][1]:
        sorted_b[0], sorted_b[1] = sorted_b[1], sorted_b[0]
    elif sorted_a[0][1] < sorted_b[0][1]:
        sorted_a[0], sorted_a[1] = sorted_a[1], sorted_a[0]
    else:
        if len(sorted_b) == 1:
            res += sorted_b[0][1]
        elif sorted_a[1][1] > sorted_b[1][1]:
            sorted_a[0], sorted_a[1] = sorted_a[1], sorted_a[0]
        else:
            sorted_b[0], sorted_b[1] = sorted_b[1], sorted_b[0]

res += len(v) - sorted_a[0][1] - sorted_b[0][1]

print(res)

Measured memory_bytes: 22752
/*
██████╗  ███████╗  
██╔══██╗ ██╔════╝ 
██████╔╝ ███████╗ 
██╔══██╗ ╚════██║  
██║  ██║ ███████║      
╚═╝  ╚═╝ ╚══════╝                                                                                                             
*/

#include<bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define haha(j,a,n) for(int j=a;j<n;j++)
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define endl "\n"
#define bc(v) v.begin(),v.end()
#define vl vector<ll>
#define vi vector<int>
#define why 1000000007
#define NUM 100005
#define F first
#define S second
#define bhar(a) rep(i,a.size()) cin>>a[i];
#define show(a) rep(i,a.size()) cout<<a[i]<<" ";
#define sott(a) sort(bc(a))
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define mapp map<ll,ll>
#define dkac cout<<fixed<<setprecision(15);
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define yeah(n) while(n--)
ll gcd(int a, int b){if(b==0) return a; else return gcd(b,a%b);}
ll bitfun(ll x){
  return (x&(-x));
}
void solve(){
  ll n; cin>>n;
  vl h(n); bhar(h);
  vl dp(n,0);
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
  cout<<dp[n-1];
}
int main(){
    ios
    int t=1; 
    //cin>>t;
    yeah(t){
      solve();
    }
}

Measured memory_bytes: 1792
import java.io.*
import java.util.*

val pw = PrintWriter(System.out)
const val MOD = 1000000007L
const val INF = 2147483647
const val LINF = 9223372036854775807L

fun main(args: Array<String>) {
    solve()
    pw.flush()
}

fun solve() {
    val (n, m) = nextIntList()
    val s = next()
    var ng = StringBuilder("")
    repeat(m){
        ng.append("1")
    }
    if(s.contains(ng)){
        println(-1)
        return
    }

    var now = n
    val ans:Deque<Int> = ArrayDeque()
    while(now != 0){

        if(now <= m){
            ans.push(now)
            break
        }
        for(i in m downTo 1){
            val next = now - i
            if(s[next] == '0'){
                ans.push(i)
                now = next
                break
            }
        }
    }

    println(ans.joinToString(" "))

}


fun println(v: String) {
    pw.println(v)
}

fun print(v: String) {
    pw.print(v)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ").toMutableList()
fun nextIntList(index: Int = 0) = next().split(" ").map { it.toInt() + index }.toMutableList()
fun nextLongList(index: Long = 0L) = next().split(" ").map { it.toLong() + index }.toMutableList()
fun nextDoubleList() = next().split(" ").map { it.toDouble() }.toMutableList()

fun ary(n: Int, init: String = "") = Array(n) { init }
fun intAry(n: Int, init: Int = 0) = IntArray(n) { init }
fun longAry(n: Int, init: Long = 0L) = LongArray(n) { init }
fun doubleAry(n: Int, init: Double = 0.0) = DoubleArray(n) { init }
fun ary2(n: Int, m: Int, init: String = "") = Array(n) { Array(m) { init } }
fun intAry2(n: Int, m: Int, init: Int = 0) = Array(n) { IntArray(m) { init } }
fun longAry2(n: Int, m: Int, init: Long = 0) = Array(n) { LongArray(m) { init } }
fun doubleAry2(n: Int, m: Int, init: Double = 0.0) = Array(n) { DoubleArray(m) { init } }
fun ary3(n: Int, m: Int, k: Int, init: String = "") = Array(n) { Array(m) { Array(k) { init } } }
fun intAry3(n: Int, m: Int, k: Int, init: Int = 0) = Array(n) { Array(m) { IntArray(k) { init } } }
fun longAry3(n: Int, m: Int, k: Int, init: Long = 0L) = Array(n) { Array(m) { LongArray(k) { init } } }
fun doubleAry3(n: Int, m: Int, k: Int, init: Double = 0.0) = Array(n) { Array(m) { DoubleArray(k) { init } } }

fun abs(n: Int): Int = Math.abs(n)
fun abs(n: Long): Long = Math.abs(n)
fun abs(n: Double): Double = Math.abs(n)
fun max(a: Int = -INF, b: Int = -INF, c: Int = -INF, d: Int = -INF, e: Int = -INF): Int = listOf(a, b, c, d, e).max()!!
fun max(a: Long = -LINF, b: Long = -LINF, c: Long = -LINF, d: Long = -LINF, e: Long = -LINF): Long =
    listOf(a, b, c, d, e).max()!!.toLong()

fun min(a: Int = INF, b: Int = INF, c: Int = INF, d: Int = INF, e: Int = INF): Int = listOf(a, b, c, d, e).min()!!
fun min(a: Long = LINF, b: Long = LINF, c: Long = LINF, d: Long = LINF, e: Long = LINF): Long =
    listOf(a, b, c, d, e).min()!!.toLong()


Measured memory_bytes: 41184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    // ?¨??????\???????????????????????????????????????
        Scanner sc= new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int tmp;
        int[] values = new int[w];
        for(int i= 0; i< values.length; i++) {
            values[i] = i + 1;
        }
        for(int i= 0; i< n; i++) {
            String str= sc.next();
            String[] ab = str.split(",");
            int a = Integer.parseInt(ab[0]) -1;
            int b = Integer.parseInt(ab[1]) -1;
            tmp = values[a];
            values[a] = values[b];
            values[b] = tmp;
        }
        for(int i = 0; i < w; i++){
            System.out.println(values[i]);
        }
    }
}

Measured memory_bytes: 17392
#include<stdio.h>

int main(){
	unsigned long n, a, b;
	unsigned long cnt, mod;

	scanf("%lu %lu %lu", &n, &a, &b);

	cnt = n /(a+b);
	mod = n % (a+b);

	printf("%lu", cnt*a + ((mod < a) ? mod : a));

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a.back()-a.front()<<endl;
  return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
Sum = 0
lists = []
for i in range(N):
    s = str(input())
    s_list = list(s)
    s_list.sort()
    m = "".join(s_list)
    lists.append(m)
c = collections.Counter(lists)
for i in set(lists):
    n = c[i]
    Sum += n * (n - 1) // 2
lists.sort()
print(Sum)
    

Measured memory_bytes: 23408
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll A, B;
  cin >> A >> B;
  ll acount = 0, bcount = 0;
  cout << 100 << ' ' << 100 << endl;;
  for(int i = 0; i < 100; i++){
    for(int j = 0; j < 100; j++){
      if(i < 50){
        if(j % 2 == 0) cout << '#';
        else{
          if(i % 2 == 0 && acount < A - 1){
            cout << '.';
            acount++;
          }
          else{
            cout << '#';
          }
        }
      }
      else{
        if(j % 2 == 0) cout << '.';
        else{
          if(i > 50 && i % 2 == 1 && bcount < B - 1){
            cout << '#';
            bcount++;
          }
          else{
            cout << '.';
          }
        }
      }

      if(j == 99) cout << endl;
    }
  }
}


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

int main(){
    int a,b,c;
    int ans=0;
    cin >> a >> b >> c ;
    if(b/a >= c){
        ans = c;
    }else{
        ans = b/a;
    }
    cout << ans;
    return 0;
}

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

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b){
    return b <= 0 ? a :gcd( b, a%b);
}

int main(){
    unsigned long long int n; cin >> n;
    vector<unsigned long long int> t(n);
    unsigned long long int time = 1;
    for(unsigned long long int i = 0; i < n; i++){
        unsigned long long int t; cin >> t;
        unsigned long long int g = gcd(time, t);
        time = (time/g)*t;
    }
    cout << time << endl;


	return 0;
}



Measured memory_bytes: 256
#include "stdio.h"

int main(){

int A;
int B;
int sum;
int cal;
int desum;
scanf("%d%d\n",&A,&B );
sum=A+B;
cal=A*B;
desum=A-B;
int max=sum;

if(max<cal){
  max=cal;
}
if(max<desum){
  max=desum;
}
printf("%d\n", max);


return 0;




}


Measured memory_bytes: 128
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>

#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
//#define for(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define print(x) std::cout << x << std::endl;

using namespace std;

typedef long long ll;

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first = 0, bool replace_empty = 0);
bool isContain(int value, int under, int top);
vector<int> range(int x);

int main(void) {
	//Program Start
	
	int A, B, T;
	cin >> A >> B >> T;

	cout << (T / A) * B << endl;


ProgramEndPointLabel:;


	//Program End
	system("pause");

	return 0;
}


vector<int> range(int y) {
	vector<int> result(y);
	for (int i = 0; i < y; i++)
		result[i] = i;
	return result;
}

bool isContain(int value, int under, int top) {
	if (under <= value && value <= top) return true;
	return false;
}

template<class T, class U> std::string replace(std::string s, const T& target, const U& replacement, bool replace_first, bool replace_empty) {
	using S = std::string;
	using C = std::string::value_type;
	using N = std::string::size_type;
	struct {
		auto len(const S& s) { return s.size(); }
		auto len(const C* p) { return std::char_traits<C>::length(p); }
		auto len(const C  c) { return 1; }
		auto sub(S* s, const S& t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C* t, N pos, N len) { s->replace(pos, len, t); }
		auto sub(S* s, const C  t, N pos, N len) { s->replace(pos, len, 1, t); }
		auto ins(S* s, const S& t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C* t, N pos) { s->insert(pos, t); }
		auto ins(S* s, const C  t, N pos) { s->insert(pos, 1, t); }
	} util;

	N target_length = util.len(target);
	N replacement_length = util.len(replacement);
	if (target_length == 0) {
		if (!replace_empty || replacement_length == 0) return s;
		N n = s.size() + replacement_length * (1 + s.size());
		s.reserve(!replace_first ? n : s.size() + replacement_length);
		for (N i = 0; i < n; i += 1 + replacement_length) {
			util.ins(&s, replacement, i);
			if (replace_first) break;
		}
		return s;
	}

	N pos = 0;
	while ((pos = s.find(target, pos)) != std::string::npos) {
		util.sub(&s, replacement, pos, target_length);
		if (replace_first) return s;
		pos += replacement_length;
	}
	return s;
}


Measured memory_bytes: 504
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h,w,k = LI()
    aa = [[int(c) for c in S()] for _ in range(h)]

    def f(hs):
        l = len(hs)
        c = [0] * l
        r = l - 1
        for i in range(w):
            nc = [0] * l
            bf = False
            for j in range(l):
                for h in hs[j]:
                    nc[j] += aa[h][i]
                if nc[j] > k:
                    return -1
                if nc[j] + c[j] > k:
                    bf = True
            if bf:
                r += 1
                c = nc
            else:
                for j in range(l):
                    c[j] += nc[j]
        return r

    r = inf
    for bi in range(2**(h-1)):
        hs = [[0]]
        for i in range(h-1):
            if 2**i & bi > 0:
                hs.append([])
            hs[-1].append(i+1)
        t = f(hs)
        if t >= 0 and r > t:
            r = t

    return r


print(main())





Measured memory_bytes: 6284
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        mut a:i64,
        b:i64,
        c:i64,
        d:i64,
    }

    a = a - 1;
    let cd = lcm(c, d);

    let all = b - a;
    let divc = b / c - a / c;
    let divd = b / d - a / d;
    let divcd = b / cd - a / cd;

    println!("{}", all - divc - divd + divcd);
}

fn gcd(x: i64, y: i64) -> i64 {
    if x % y == 0 {
        return y;
    }
    gcd(y, x % y)
}

fn lcm(x: i64, y: i64) -> i64 {
    x / gcd(x, y) * y
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;







ll fac[maxn], ifac[maxn], inv[maxn];

ll nck(ll n, ll k) {
    if (n<k) return 0;
    return fac[n]*ifac[k]%mod*ifac[n-k]%mod;
}


int n;
int a[maxn];

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

    fac[0]=inv[0]=ifac[0]=1;
    fac[1]=inv[1]=ifac[1]=1;

    for (int i=2; i<maxn; i++) {
	fac[i]=fac[i-1]*i%mod;
	inv[i]= (((-1LL*((mod/i)*inv[mod%i]))%mod)+mod)%mod;
	ifac[i]=ifac[i-1]*inv[i]%mod;
    }

    assert(nck(4,2)==6);


    cin>>n;
    set<int> s;
    int x=-1;
    for (int i=0; i<n+1; i++) {
	cin>>a[i];
	if (s.count(a[i])) {
	    x=a[i];
	}
	s.insert(a[i]);
    }
    assert(x!=-1);
    int l=-1,r=-1;
    for (int i=0; i<n+1; i++) {
	if (x==a[i]) {
	    if (l==-1) {
		l=i;
	    } else {
		r=i;
	    }
	}
    }

    assert(l!=-1 && r!=-1 && l<r);

    for (int k=1; k<=n+1; k++) {

	if (k==1) {
	    cout<<n<<"\n";
	    continue;
	}


	int left = l;
	int right = n+1-r-1;

	ll ans = nck(n+1,k) - nck(left+right,k-1);
	ans %= mod;
	ans += mod;
	ans %= mod;
	cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll N=S.size();
    vector<ll> counts(26,0);
    vector<ll> countt(26,0);
    char C='a';
    for(ll i=0;i<26;i++){
        for(ll j=0;j<N;j++){
            if(S.at(j)==C){counts[i]++;}
            if(T.at(j)==C){countt[i]++;}
        ;}
        C++;
    ;}
    sort(counts.begin(), counts.end());
    sort(countt.begin(), countt.end());
    if(counts==countt){cout<<"Yes"<<endl;}
    else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 900
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define INF 999999999
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define LL long long

int main(void)
{
    int n; // 1-base
    scanf("%d", &n);
    int c[n], s[n], f[n];
    FOR(i, 1, n)
    {
        scanf(" %d %d %d", &c[i], &s[i], &f[i]);
    }

    FOR(i, 1, n + 1)
    {
        int r = 0;

        FOR(j, i, n)
        {
            int cj = c[j];
            int sj = s[j];
            int fj = f[j];

            if (r < sj)
            {
                r = sj;
            }
            else
            {
                r = ((r - 1) / fj + 1) * fj;
            }

            r += cj;
        }

        printf("%d", r);
        printf("\n");
    }

    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;

    int res = 0;
    for (int i = 0; i < n; ++i){
        int x;
        cin >> x;

        res += min(x, k-x) * 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
using namespace std;

int h, w, n, c[100000][5][5], s[10];
pair<int, int> a[100000];

int main()
{
    cin >> h >> w >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i].second >> a[i].first, --a[i].first, --a[i].second;
    sort(a, a + n);
    set<pair<int, int>> s[11];
    for (int i = 0; i < n; ++i)
    {
        for (int x = -2; x <= 2; ++x)
            for (int y = -2; y <= 2; ++y)
                if (a[i].first + x >= 0 && a[i].second + y >= 0 &&
                    a[i].first + x < w && a[i].second + y < h)
                    c[i][y + 2][x + 2] = binary_search(a, a + n, make_pair(a[i].first + x, a[i].second + y));
        //cout << i << ": \n";
        //for (int y = 0; y < 5; ++y)
        //{
        //    for (int x = 0; x < 5; ++x)
        //        cout << c[i][y][x] << " ";
        //    cout << endl;
        //}
        for (int y = 0; y < 5; ++y)
            for (int x = 0; x < 5; ++x)
            {
                if (y != 0)
                    c[i][y][x] += c[i][y - 1][x];
                if (x != 0)
                    c[i][y][x] += c[i][y][x - 1];
                if (y != 0 && x != 0)
                    c[i][y][x] -= c[i][y - 1][x - 1];
            }
        //cout << "\n";
        //for (int y = 0; y < 5; ++y)
        //{
        //    for (int x = 0; x < 5; ++x)
        //        cout << c[i][y][x] << " ";
        //    cout << endl;
        //}

        for (int y = 0; y <= 2; ++y)
            for (int x = 0; x <= 2; ++x)
            {
                if (!(0 <= a[i].first + (x - 2) && a[i].first + x < w &&
                      0 <= a[i].second + (y - 2) && a[i].second + y < h))
                    continue;
                int sum = c[i][y + 2][x + 2];
                if (y != 0)
                    sum -= c[i][y - 1][x + 2];
                if (x != 0)
                    sum -= c[i][y + 2][x - 1];
                if (y != 0 && x != 0)
                    sum += c[i][y - 1][x - 1];
                //cout << sum << ":: " << x << " " << y << endl;
                if (sum != 0)
                    s[sum].insert(make_pair(a[i].first + (x - 2), a[i].second + (y - 2)));
            }
    }
    long long int nu = 1ll * (w - 2) * (h - 2);
    for (int i = 1; i < 10; ++i)
        nu -= s[i].size();
    cout << nu << endl;
    for (int i = 1; i < 10; ++i)
    {
        /* 
        cout << i << ": \n";
        for (auto j : s[i])
            cout << j.first << " " << j.second << " ";
        cout << endl;
        */
        cout << s[i].size() << endl;
    }
    return 0;
}


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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  for (int i = 3; i < n + 1; i++) {
    if (i % 3 == 0) cout << ' ' << i;
    else {
      int a = i;
      while (a > 0) {
        if (a % 10 == 3) {
          cout << ' ' << i;
          break;
        }
        a /= 10;
      }
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3060
from collections import deque

R = lambda: map(int, input().split())

n, m = R()
g = [None] + [set() for _ in range(n)]

for _ in range(m):
  u, v = R()
  g[u].add(v)
  g[v].add(u)

V = [None] + [False] * n
q = deque()

def bfs(u):
  r = 0
  V[u] = True
  q.append(u)
  while(q):
    u = q.popleft()
    r += 1
    for v in g[u]:
      if not V[v]:
        V[v] = True
        q.append(v)
  return r

print(max(bfs(u) for u in range(1, n + 1) if not V[u]))


Measured memory_bytes: 74808
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n=int(input())
    res = 0
    for i in range(n+1):
        if i%3!=0 and i%5!=0:
            res+=i
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 67124
#pragma GCC optimize("Ofast,O3,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

#define endl '\n'
#define hoise cerr<<"hoise - "<<__LINE__<<"\n";
#define tham getchar();
#define FASTIO ios::sync_with_stdio(false);cin.tie(nullptr);

using ll = long long;
using ii = pair <int, int>;
using vi = vector <int>;
using vl = vector <ll>;

const int MXN = (int)2e5+6;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(ll N, ll pos){return (bool)(N & (1LL<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }


template <typename T> using orderedSet = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using orderedSet1 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*--------------------------------------------------------------------------------------------------------------------------*/




int main(){
	FASTIO
	
	int n, k;
	cin >> n >> k;
	
	ll sum[MXN + 4];
	
	for (int i = 1; i < MXN; ++i) {
		sum[i] = sum[i - 1] + i;
	}
	ll ans = 0;
	for (int i = k; i <= n + 1; ++i) {
		ll mnsum = sum[i];
		ll mxsum = sum[n + 1] - sum[n - i + 1];
		ans = ans + (mxsum - mnsum + 1) % mod;
		ans %= mod;
	}
	
	cout << ans % mod << endl;
	
    return 0;
}

/*

*/


Measured memory_bytes: 5220
s = int(input())
sl = [s]
count = 2
for i in range(10**6):
  s_next = 0
  if sl[i]%2 == 0:
    s_next = sl[i]//2
    sl.append(s_next)
  else:
    s_next = 3*sl[i]+1
    sl.append(s_next)
  if sl.count(s_next) > 1:
    print(count)
    break
  count += 1

Measured memory_bytes: 3064
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a=0;
    int b=0;
    int ap=0;
    int bp=0;

    cin >> a;

    int *ii = new int[a];

    for(int i =0; i < a ; i++){
        cin>>b;
        ii[i]=b;
    }

    do { ap++;
    } while ( std::next_permutation(ii,ii+a) );

    for(int i =0; i < a ; i++){
        cin>>b;
        ii[i]=b;
    }

    do { bp++;
    } while ( std::next_permutation(ii,ii+a) );

   cout<<abs(bp-ap);

    return 0;
}

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

typedef long long int LL;
typedef pair <int,int> pii;
typedef pair <long long,long long> pll;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const int N = 1e5 + 5;
const int inf = 1e9;
const long long INF = 1e18;

int len;
string s;
int cnt[ 30 ];
LL dp[ 30 ];

LL solve( int idx ) {
        if( idx == 27 ) return 1;
        if( dp[idx] != -1 ) return dp[idx];
        LL ret = 0;
        if( cnt[idx] == 0 ) ret += solve( idx + 1 ) , ret %= MOD;
        else ret += 1LL * ( cnt[idx] + 1 ) * ( solve( idx + 1 ) ), ret %= MOD;
        return dp[idx] = ret%MOD;
}
int main( int argc , char const *argv[] ) {
        ios_base::sync_with_stdio( false ); cin.tie( nullptr );
        cin >> len >> s;
        for( int i = 0; i < len; i++ ) cnt[ s[i]-'a'+1 ]++;
        memset( dp , -1 , sizeof( dp ) );
        cout << ( solve( 1 ) - 1 + MOD ) % MOD << endl;
        return 0;
}







Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long x; std::cin >> x;
    std::cout << x / 500 * 1000 + (x % 500) / 5 * 5 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <queue>
using namespace std;

const int Max = 100005;
int color[Max], nt[Max];
vector<int> G[Max];
int n;
/*
int next(int u)
{
    nt[u]++;
    if(nt[u]<G[u].size())
        return G[u][nt[u]];
    else
        return -1;
}
*/
void dfs(int s, int t)
{

     //memset(nt, -1, sizeof(nt));
     stack<int> S;
     S.push(s);
     color[s] = t;
     while(!S.empty())
     {
         int u = S.top(); S.pop();
         for(int i=0; i<G[u].size(); i++)
         {
             int v = G[u][i];
             if(color[v]==-1)
             {
                 color[v] = t;
                 S.push(v);
             }
         }
     }
     /*
     while(!S.empty())
     {
         int u = S.top();
         int v = next(u);
         if(v!=-1)
         {
             if(v==t) return 1;
             if(color[v]==-1)
             {
                 color[v] = 0;
                 S.push(v);
             }
         }
         else
         {
             S.pop();
         }
     }
     */
     //return 0;
}

void assignColor()
{
    int id = 1;
    memset(color, -1, sizeof(color));
    for(int i=0; i<n; i++)
    {
        if(color[i]==-1)
            dfs(i, id++);
    }
}

int main()
{
    int m, q, s, t;
    scanf("%d %d", &n, &m);
    for(int i=0; i<m; i++)
    {
        scanf("%d %d", &s, &t);
        G[s].push_back(t);//邻接表
        G[t].push_back(s);
    }
    scanf("%d", &q);
    assignColor();
    for(int i=0; i<q; i++)
    {
        scanf("%d %d", &s, &t);
        if(color[s]==color[t])
            printf("yes\n");
        else
            printf("no\n");
        /*
        if(dfs(s, t))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
            */
    }

    return 0;
}



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

#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
int main()
{
    string S[2], S2;
    int A[2];
    cin >> S[0] >> S[1];
    cin >> A[0] >> A[1];
    cin >> S2;
    if (S[0] == S2){
        A[0]--;
    } else {
        A[1]--;
    }
    cout << A[0] << " " << A[1];
    return 0;
}


Measured memory_bytes: 256
a = STDIN.read.split("\n")
b_len = Integer(a[0])
r_len = Integer(a[b_len+1])
b = a[1, b_len]
r = a[b_len + 2, r_len]
hb = {}
b.each do |s|
  next if hb.has_key?(s)
  hb[s] = b.select{|e|e===s}.length
end
hr = {}
r.each do |s|
  next if hr.has_key?(s)
  hr[s] = r.select{|e|e===s}.length
end
res = hb.map do |k,pos|
  neg = hr[k] || 0
  pos - neg
end
puts res.max < 0 ? 0 : res.max


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

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

const int lim = 1000000007;

int main(){
    int N, K;
    cin >> N >> K;
    //Kで割ってi余る数が、1以上N以下に何個あるかを、num[i]に格納する
    vector<ll> num(K, 0);
    for(int i = 1; i <= N; i++) num[i%K]++;
    ll val = 0;
    //a%Kの値をaとして扱い、その時のb%K, c%Kを求める。
    //b%K, c%Kの値は、(a+b)%K == (a+c)%K == 0が成立している前提で決定している
    //(b+c)%K == 0となれば、その組み合わせの個数を答えに追加する
    for(int a = 0; a < K; a++){
        //ここでのb, cは、b%K, c%Kである。
        int b = (K-a) % K;
        int c = (K-a) % K;
        //
        if((b+c) % K != 0) continue;
        //num[i]には、Kで割った余りがiになる1以上N以下の整数の個数が格納されているため、それを掛け合わせた
        //分だけ、組み合わせが存在する。
        val += num[a] * num[b] * num[c];
    }
    cout << val << endl;
    return 0;
}

Measured memory_bytes: 4740
#include<cstdio>

int main() {
	int n;
	scanf("%d", &n);
	int count = 0;
	int last = 0;
	for(int i=0;i<n;i++) {
		int a;
		scanf("%d", &a);
		if(last == a) {
			last = 0;
			count++;
		} else {
			last = a;
		}
	}
	printf("%d\n", count);
	return 0;
}


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

double dp[3010][3010];
double p[3010];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while(t != 0) {
        int n;
        cin >> n;
        for(int i = 0; i < n; i++) {
            cin >> p[i];
        }
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++) {
            dp[i][0] = (1-p[i-1])*dp[i-1][0];
        }
        for(int i = 1; i <= n; i++) {
            for(int j = 1; j <= n; j++) {
                dp[i][j] = dp[i-1][j]*(1-p[i-1]) + dp[i-1][j-1]*p[i-1];
            }
        }
        double ans = 0;
        for(int j = n/2+1; j <= n; j++) {
            ans += dp[n][j];
        }
        printf("%.10f\n", ans);
	    t--;
	}
	return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>

int main(void)
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a <= b && b <= c) printf("%d %d %d\n", a, b, c);
	else if (a <= c && c <= b) printf("%d %d %d\n", a, c, b);
	else if (b <= a && a <= c) printf("%d %d %d\n", b, a, c);
	else if (b <= c && c <= a) printf("%d %d %d\n", b, c, a);
	else if (c <= a && a <= b) printf("%d %d %d\n", c, a, b);
	else if (c <= b && b <= a) printf("%d %d %d\n", c, b, a);

	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main(void){
    int n,min;
    int count = 1;
    cin >> n;
    int x[n];
    for(int t=0;t<n;t++){
        cin >> x[t];
    }

    min = x[0];
    for(int i=0;i<n;i++){
        if(min > x[i]){
            min = x[i];
            count++;
        }
        
    }
    
    cout << count << endl;

    return 0;
}

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

int main() {
    long long n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    for (int i = 0; i <= n - 1; i++) {
        long long minimum = c * i - d * (n - 1 - i), maximum = d * i - c * (n - 1 - i);
        if (minimum <= b - a && b - a <= maximum) {
            cout << "YES" << endl;
            return 0;
        } 
    }
    cout << "NO" << endl;
}

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

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

pair < long long, long long > cut(long long a, long long b){
    return { (a / 2) * b, (a / 2 + a % 2) * b };
}

int main(int argc, char **argv){
    long long x, y;
    cin >> x >> y;
    long long area = 0;
    long long ans = 1ll << 60;
    for(long long i = 1;i < x;i++){
        area += y;
        pair < long long, long long > a = cut(x - i, y);
        pair < long long, long long > b = cut(y, x - i);
        ans = min(ans, max({area, a.first, a.second}) - min({ area, a.first, a.second }));
        ans = min(ans, max({area, b.first, b.second}) - min({ area, b.first, b.second }));
    }
    area = 0;
    swap(x, y);
    for(long long i = 1;i < x;i++){
        area += y;
        pair < long long, long long > a = cut(x - i, y);
        pair < long long, long long > b = cut(y, x - i);
        ans = min(ans, max({area, a.first, a.second}) - min({ area, a.first, a.second }));
        ans = min(ans, max({area, b.first, b.second}) - min({ area, b.first, b.second }));
    }
    cout << ans;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

pub struct UnionFind {
    pub parents: Vec<usize>,
}
impl UnionFind {
    pub fn new(n: usize) -> Self {
        let parents = (0..n).collect();
        UnionFind { parents }
    }
    pub fn root(&mut self, x: usize) -> usize {
        if self.parents[x] == x {
            return x;
        }
        let par = self.parents[x];
        self.parents[x] = self.root(par);
        self.parents[x]
    }
    pub fn union(&mut self, x: usize, y: usize) {
        let rx = self.root(x);
        let ry = self.root(y);
        if rx == ry {
            return;
        }
        self.parents[rx] = ry;
    }
    pub fn is_same(&mut self, x: usize, y: usize) -> bool {
        let rx = self.root(x);
        let ry = self.root(y);
        rx == ry
    }
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, m: usize);
    let mut uf = UnionFind::new(n);
    for _ in 0..m {
        parse!(it, x: u1, y: u1, z: usize);
        uf.union(x, y);
    }
    let ps: HashSet<usize> = (0..n).map(|i| uf.root(i)).collect();
    println!("{}", ps.len());
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 5368
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

int h, w, n;
const int MAX_N = 1005;
char map[MAX_N][MAX_N];
int visit[MAX_N][MAX_N];
struct point{
	int x, y;
	int step;
	point(){
		x = 0; y = 0; step = 0;
	}
	point(int xx, int yy, int ss){
		x = xx;
		y = yy;
		step = ss;
	}
};
struct point p[16];

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

int ok(int x, int y){
	if (x >= 0 && x<h && y >= 0 && y<w) return 1;
	return 0;
}

int bfs(int next){
	for (int i = 0; i<MAX_N; i++){
		for (int j = 0; j < MAX_N; j++){
			visit[i][j] = 0;
		}
	}
	int nextcheese = next + 1;

	queue<point> q;
	point cur(p[next].x, p[next].y, 0);
	q.push(cur);
	while (q.size()){
		cur = q.front(); q.pop();
		int x = cur.x, y = cur.y;
		int nx, ny;
		for (int i = 0; i<4; i++){
			nx = x + dx[i]; ny = y + dy[i];
			if (ok(nx, ny)){
				if ((map[nx][ny] - '0') == nextcheese) return ++cur.step;
				if ((map[nx][ny] != 'X') && visit[nx][ny] == 0){
					q.push(point(nx, ny, cur.step + 1));
					visit[nx][ny] = 1;
				}
			}
		}
	}
}

void solve(){
	cin >> h >> w >> n;
	for (int i = 0; i<h; i++){
		for (int j = 0; j<w; j++){
			cin >> map[i][j];
		}
	}
	for (int i = 0; i<h; i++){
		for (int j = 0; j<w; j++){
			char ch = map[i][j];
			switch (ch){
			case '.': break;
			case 'X': break;
			case 'S': p[0].x = i; p[0].y = j; map[i][j] = '.'; break;
			default:
				int t = (ch - '0');
				p[t].x = i; p[t].y = j;
			}
			/* if(map[i][j]=='S'){
			p[0].x=i; p[0].y = j;
			map[i][j]='.';
			}
			else if(isdigit(map[i][j])){
			int index=map[i][j]-'0';
			p[index].x=i; p[index].y=j;
			}*/
		}
	}
	int step = 0;
	for (int i = 0; i<n; i++){
		step += bfs(i);
	}
	printf("%d\n", step);
}


int main(){
	solve();
}


Measured memory_bytes: 8084
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        int len = S.length();
        StringBuilder bld = new StringBuilder();
        for(int i=0;i<len;i++){
            bld.append("x");
        }
        System.out.println(bld.toString());
    }
}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (!map.containsKey(x))
				map.put(x, 1);
			else
				map.put(x, map.get(x) + 1);
		}

		for (Entry<Integer, Integer> entry : map.entrySet()) {
			int key = entry.getKey();
			int val = entry.getValue();
			if (val >= key)
				ans += val - key;
			else
				ans += val;
		}
		System.out.println(ans);

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}
	}
}


Measured memory_bytes: 45428
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;

	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> num(r);
	vector<ll> den(r);

	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}

	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> c(h);
	for (int i = 0; i < h; i++) {
		cin >> c[i];
	}
	int ans = 0;
	for (int maskR = 0; maskR < (1 << h); maskR++) {
		for (int maskC = 0; maskC < (1 << w); maskC++) {
			int black = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (maskR >> i & 1) {
						continue;
					}
					if (maskC >> j & 1) {
						continue;
					}
					
					if (c[i][j] == '#') {
						black++;
					}
				}
			}
			if (black == k) {
				ans++;
			}
		}
	}

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

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
#define int long long
#define inf 1145141919ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d,e,f,g;
int dx[]={0,-1,0,1,0};
struct A{
	A *e;
	int temp;

};
struct B{
	A *src;
	A *dst;
	int cost;
};
struct C{
	int u;
	int v;
	int len;
	C(int x,int y,int z):u(x),v(y),len(z){}
};
int i,j,k,n;
int p[100000],q[100000];
signed main(){
	cin>>a>>b>>c>>d>>e>>f>>g;
	n=b;
	if(a%2+d%2+e%2>=2&&a&&d&&e){
		a--;
		d--;
		e--;
		n+=3;
	}
	n+=(a/2)*2;
	n+=(d/2)*2;
	n+=(e/2)*2;
	cout<<n<<endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] atgs){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		
		try{
			String line = reader.readLine();
			int num = Integer.parseInt(line);
			System.out.println(num * num * num);
		}catch(IOException e){
			System.out.println(e);
		}catch(NumberFormatException e){
			System.out.println("入力できる型はInt型に限ります");
		}
	}
}


Measured memory_bytes: 24308
x, y = map(int, input().split())
cnt = 0
for i in range(x+1):
    for j in range(x+1):
        if (i + j == x) and (2*i + 4*j == y):
            cnt += 1
                
if cnt >= 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 63832
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------

int N;
ll H[100001];

void _main() {
	cin >> N;

	rep(i, 0, N) {
		cin >> H[i];
	}

	int count = 0;
	int cMax = 0;
	rep(j, 0, N) {

		while (H[j] >= H[j + 1] && j < N-1) {
			j++;
			count++;
		}

		chmax(cMax, count);
		count = 0;
	}

	cout << cMax << endl;
	
}

Measured memory_bytes: 1024
n,a,b=map(int,input().split())
mod=10**9+7

def comb(n,r,mod):
    p,q=1,1
    for i in range(min(r,n-r)):
        p=p*(n-i)%mod 
        q=q*(i+1)%mod 
    return p*pow(q,mod-2,mod)%mod

nca=comb(n,a,mod)
ncb=comb(n,b,mod)

ans=pow(2,n,mod)
ans=(ans-((nca+ncb)%mod+1))%mod
print(ans)

Measured memory_bytes: 3064