akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define int long long

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int H, W, K; cin >> H >> W >> K;
    int cnt[10];
    rep(i, W) {
        int n = 1 << i;
        for(int j = 0; j < n; j++) {
            bool flag = true;
            rep(k, i) {
                if(j & (1<<k)) {
                    if(j & (1<<(k - 1))) flag = false;
                    if(j & (1<<(k + 1))) flag = false; 
                }
            }
            if(flag) cnt[i] ++;
        }
    }
    ll dp[120][10];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1LL;
    rep(i, H) {
        rep(j, W) {
            dp[i + 1][j] += dp[i][j - 1] * (j - 2 >= 0 ? cnt[j - 2] : 1) * (W - 1 - j - 1 >= 0 ? cnt[W - j - 2] : 1);
            dp[i + 1][j] += dp[i][j] * (j - 1 >= 0 ? cnt[j - 1] : 1) * (W - 1 - j - 1 >= 0 ? cnt[W - j - 2] : 1);
            dp[i + 1][j] += dp[i][j + 1] * (j - 1 >= 0 ? cnt[j - 1] : 1) * (W - 1 - j - 2 >= 0 ? cnt[W - j - 3] : 1);
            dp[i + 1][j] %= mod;
        }
    }
    cout << dp[H][K - 1] << endl;
	return 0;
}

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

int main() {
  long N,A,B,C,D,E,ti;
  cin >> N >> A >> B >> C >> D >> E;
  ti=min({A,B,C,D,E});
  if(N%ti==0)N--;
  cout << 5+N/ti;
}


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

using namespace std;

#define int long long

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;


typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef unordered_map<int,int> mii;
typedef unordered_map<char,int> mci;
typedef unordered_map<string,int> msi;

#define pb push_back
#define f first
#define s second 
 

void solve() {
    int h,w; cin>>h>>w;
    vvc grid(h,vc(w));
    for(int i=0;i<h;i++) {
        for(int j=0;j<w;j++) {
            cin>>grid[i][j];
        }
    }
    vvi dp(h,vi(w));
    dp[0][0] = 1;
    for(int i=1;i<h;i++) {
        dp[i][0] = dp[i-1][0];
        if(grid[i][0]=='#') dp[i][0] = 0;
    }
    for(int i=1;i<w;i++) {
        dp[0][i] = dp[0][i-1];
        if(grid[0][i]=='#') dp[0][i] = 0;
    }
    for(int i=1;i<h;i++) {
        for(int j=1;j<w;j++) {
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
            if(grid[i][j]=='#') dp[i][j] = 0;
        }
    }
    cout<<dp[h-1][w-1]<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //#ifdef LOCAL
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif

    int tc; tc=1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}

Measured memory_bytes: 12176
#include <iostream>
#include <string>

using namespace std;


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

	if (S == "Sunny")
	{
		cout << "Cloudy" << endl;
		return 0;
	}
	else if (S == "Cloudy")
	{
		cout << "Rainy" << endl;
		return 0;
	}
	else
	{
		cout << "Sunny" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n = int(input())
p_n = list(map(int, input().split()))
ans = 1
p_i_1 = [p_n[0]]
m = p_n[0]
for i in range(1, n):
    if m > p_n[i]:
        ans += 1
    m = min(m, p_n[i])
    p_i_1.append(p_n[i])
    if m == 1:
        break
print(ans)

Measured memory_bytes: 26012
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()
lenC = len(C)

# Bを止めて,条件を満たすA,Cを数える。足し合わせる。
ans = 0
for b in B:
  idxA = bisect.bisect_left(A, b)
  idxC = lenC - bisect.bisect_right(C, b)
  ans += idxA * idxC
print(ans)

Measured memory_bytes: 23328
from sys import stdin, setrecursionlimit


def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x % y)


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True


def main():
    input = stdin.buffer.readline
    a, b = map(int, input().split())

    g = gcd(a, b)

    ans = 0

    for i in range(1, int(g ** 0.5) + 1):
        if g % i == 0:
            if is_prime(i) or i == 1:
                ans += 1
            if is_prime(g // i) and i != g // i:
                ans += 1

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


Measured memory_bytes: 41580
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    as <- replicateM n getInt
    print . length . filter odd . map length . group $ sort as

Measured memory_bytes: 30972
import sys

str_a, str_b =input().split()
a=int(str_a)
b=int(str_b)
if not (a >=1 and a<=100):
    sys.exit()
b=int(str_b)
if not (b >=1 and b<=100):
    sys.exit()
print(str(a*b) + " " + str(a*2+b*2))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
typedef vector<vector<int> > mat;
const int mod = 1000000007;
const int INF = 1e18;

mat mul(mat &A, mat &B){
    mat C(A.size(), vector<int>(B[0].size()));
    for(int i = 0; i < A.size(); i++){
        for(int k = 0; k < B.size(); k++){
            for(int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, int n){
    mat B(A.size(), vector<int>(A.size()));
    for(int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

int n, k;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    vector<vector<int> > a(n, vector<int>(n));
    rep(i, 0, n){
        rep(j, 0, n){
            cin >> a[i][j];
        }
    }
    a = pow(a, k);
    int ans = 0;
    rep(i, 0, n){
        rep(j, 0, n){
            ans += a[i][j];
            ans %= mod;
        }
    }
    cout << ans << endl;
}

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

using ll = long long;
using vll = vector<ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define INF (ll)(1e18 + 1)

// Ford-Fulkerson
class MaxFlow {
  struct edge {
    int to;
    ll cap;
    int rev; // 逆辺のindex(G[to][rev]が逆辺)
  };

 private:
  vector<vector<edge>> G;
  vector<bool> used;
  int sink;

  // f: 頂点vに流れてきている量
  ll dfs(int v, ll f) {
    if (v == sink) {
      return f;
    }

    used[v] = true;
    for (auto e = G[v].begin(); e != G[v].end(); e++) {
      if (used[e->to] || e->cap <= 0) {
        continue;
      }

      ll d = dfs(e->to, min(f, e->cap));
      if (d > 0) {
        e->cap -= d;
        G[e->to][e->rev].cap += d;
        return d;
      }
    }

    return 0;
  }

 public:
  MaxFlow(int max_v) : G(max_v), used(max_v) {
  }

  void add_edge(int from, int to, ll cap) {
    G[from].push_back((edge){to, cap, (int)G[to].size()});
    G[to].push_back((edge){from, 0, (int)G[from].size() - 1});
  }

  // source: Start
  // sink: Goal
  ll max_flow(int source, int sink) {
    this->sink = sink;

    ll flow = 0;
    for (;;) {
      fill(used.begin(), used.end(), false);

      ll f = dfs(source, INF);
      if (f == 0) {
        return flow;
      }
      flow += f;
    }
  }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;
  vll a(n), b(n), c(n), d(n);

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

  rep(i, n) {
    cin >> c[i] >> d[i];
  }

  MaxFlow mf(202);
#define SOURCE_INDEX 200
#define SINK_INDEX 201

  rep(i, n) {
    rep(j, n) {
      if (a[i] < c[j] && b[i] < d[j]) {
        mf.add_edge(i, 100 + j, 1);
      }
    }
  }

  rep(i, n) {
    mf.add_edge(SOURCE_INDEX, i, 1);
  }

  rep(i, n) {
    mf.add_edge(100 + i, SINK_INDEX, 1);
  }

  cout << mf.max_flow(SOURCE_INDEX, SINK_INDEX) << endl;
  return 0;
}


Measured memory_bytes: 512
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                if(N<1200){
                        System.out.println("ABC");
                }else if(N<2800){
                        System.out.println("ARC");
                }else{
                        System.out.println("AGC");
                }

                
                
                
                


                
        }
        
        
        

		
	
}


Measured memory_bytes: 22228
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=50;
//↑templete
//立っているbitの数を数える（32bit限定）
int bitcount32(int dw32){
	dw32 = ((dw32 & 0xAAAAAAAA) >>  1) + (dw32 & 0x55555555);
	dw32 = ((dw32 & 0xCCCCCCCC) >>  2) + (dw32 & 0x33333333);
	dw32 = ((dw32 & 0xF0F0F0F0) >>  4) + (dw32 & 0x0F0F0F0F);
	dw32 = ((dw32 & 0xFF00FF00) >>  8) + (dw32 & 0x00FF00FF);
	dw32 = ((dw32 & 0xFFFF0000) >> 16) + (dw32 & 0x0000FFFF);
	return dw32;
}
signed main(){
	int N;
	cin>>N;
	vpint A[SIZE];
	for(int i=0;i<N;i++){
		int M;
		cin>>M;
		for(int j=0;j<M;j++){
			int a, b;
			cin>>a>>b;
			a--;
			A[i].eb(a, b);
		}
	}
	int maxi=0;
	for(int state=0;state<(1<<N);state++){
		bool kind[SIZE]={};
		for(int i=0;i<N;i++){
			if(state&(1<<i))
				kind[i]=1;
		}
		for(int i=0;i<N;i++){
			if(!kind[i])
				continue;
			for(int j=0;j<A[i].size();j++){
				int a, b;
				tie(a, b)=A[i][j];
				if((!b && kind[a]) || (b && !kind[a])){
					goto skip;
				}
			}
		}

		maxi=max(maxi, bitcount32(state));
		skip:;
	}
	cout<<maxi<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import copy
input = sys.stdin.readline

def main():
    N, x = map(int, input().split())
    a = list(map(int, input().split()))

    min_ = copy.deepcopy(a)

    ans = int(1e15)
    # 魔法を唱える回数 k
    for k in range(N):
        tmp = k * x
        for i in range(N):
            min_[i] = min(min_[i], a[(i-k)%N])
            tmp += min_[i]
        # print(min_)
        ans = min(ans, tmp)
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int K, T,ma,all;
	all = 0;
	ma = 0;
	cin >> K >> T;
	vint a(T);
	for (int i = 0; i < T; i++) {
		cin >> a[i];
		ma = max(ma, a[i]);
		all += a[i];
	}
	
	if (all - ma >= ma)cout << "0" << endl;
	else cout << ma - (all-ma) - 1 << endl;

	
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    S = input()
    K = int(input())
    A = set()
    L = len(S)
    for i in range(L):
        for k in range(K):
            if i+k<=L:
                A.add(S[i:i+k+1])
    A = list(A)
    A.sort()
    print(A[K-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 10528
M=998244353
N,*A=open(0)
d=[0]*90301
d[0]=1
e=[0]*90301
e[0]=1
z=1
s=0
for a in A:
	a=int(a);s+=a;i=s;z*=3
	while~i:d[i]+=d[i]+d[i-a]%M;e[i]+=e[i-a]%M;i-=1
i=s
while i*2>=s:z=(z-d[i]*3)%M;i-=1
z+=~s%2*e[s//2]*3
print(z%M)

Measured memory_bytes: 144900
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,k,l,r,a,b;
    cin>>a>>b>>n;
    r=min(b-1,n);
    cout<<(a*r)/b<<"\n";
    return 0;
}



Measured memory_bytes: 3652
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846
#ifdef LOCAL
#include <sys/types.h>
#include <sys/timeb.h>
#include <intrin.h> 
#include <thread>
#else
#include <sys/time.h>
#endif

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main(){
	int d;
	cin >> d;
	cout << "Christmas";
	REP(i, 25 - d)cout << " Eve";
	cout << endl;
	return 0;
}

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

string S;
int N;

ll rec(int count, vector<int> &bit){
    
    ll sum = 0;
    
    if(count == N - 1){
        string num;
        for(int i = 0; i < N - 1; ++i){
            num += S[i];
            if(bit[i]) {
                sum += stoll(num);
                num = "";
            }
        }
        num += S[N - 1];
        sum += stoll(num);
        return sum;
    }
    
    bit[count] = 1;
    sum += rec(count + 1, bit);
    bit[count] = 0;
    sum += rec(count + 1, bit);
    
    return sum;
}

int main(void){
    
    cin >> S;
    N = S.length();
    vector<int> bit(N - 1, 0);
    
    cout << rec(0, bit) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <stdbool.h>

bool contain(uint32_t n, const char *d)
{
    char s[6];
    for (; *d != '\0'; ++d) {
        snprintf(s, sizeof(s), "%" PRIu32, n);
        if (strchr(s, *d) != NULL) {
            return true;
        }
    }
    return false;
}

int main(void)
{
    uint32_t n, k;
    char d[10] = "";
    scanf("%" SCNu32 " %" SCNu32, &n, &k);
    for (uint32_t j = 0; j < k; ++j) {
        char s[2];
        scanf("%s", s);
        strcat(d, s);
    }
    while (contain(n, d)) {
        ++n;
    }
    printf("%" PRIu32 "\n", n);

    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, a[100009];
int main() {
	while (scanf("%d%d", &n, &m), n) {
		for (int i = 0; i < n; i++) scanf("%d", &a[i]);
		int sum = 0;
		for (int i = 0; i < m; i++) sum += a[i];
		int ret = sum;
		for (int i = m; i < n; i++) {
			sum += a[i] - a[i - m];
			ret = max(ret, sum);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2948
n,m=map(int, input().split())
sc = []
if m==0:
    if n==1:
        print(0)
    if n==2:
        print(10)
    if n==3:
        print(100)
    exit()
for i in range(m):
    a,b=map(int, input().split())
    sc.append([a, b])
for i in range(0,10**n):
    t = str(i)
    f=True
    for j in sc:
        if len(t)!=n:
            f=False
            break
        if t[j[0]-1]==str(j[1]):
            continue
        else:
            f=False
            break
    if f:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3064
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define int long long

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言




//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int N,M,X;
cin>>N>>M>>X;
int C[N];
int understand[M];
int min_money=INF;
int A[15][15];
Fill(A,0);

REP(i,N){ cin>>C[i];  REP(j,M){cin>>A[i][j];}  }


bool ok=false;
REP(bit,1<<N){//どの参考書を買うか

	ok=true;
	REP(i,M){understand[i]=0;}

	int money=0;
	

	REP(i,N){
		if (bit>>i & 1)
		{
			money+=C[i];
			REP(j,M){understand[j]+=A[i][j];}
		}
	}
	REP(i,M){
		if (understand[i]<X)
		{
			ok=false;
			break;
		}
	}

	if (ok)
	{
		min_money=min(min_money,money);
	}
	
}
if (ok)
{
	cout<<min_money<<endl;
}
else cout<<-1<<endl;





return 0;

}

Measured memory_bytes: 3536
#include <stdio.h>

int main()
{
	int n,k,t=1, ans;
	scanf("%d %d", &n, &k);
	for (int i=1;i<=n;i++)
	{
		if (t<k)
		{
			t=t*2;
		}
		else
		{
			t=t+k;
		}
	}
	printf("%d", t);
	
	
	
	return 0;
}

Measured memory_bytes: 1736
#include <stdio.h> 
int main(void)
{ 
    int a, b; 
    char op; 
    while(1){ 
        scanf("%d %c %d", &a, &op, &b); 
        if(op=='?'){ 
            break; 
     	}else if(op=='+'){ 
     	    printf("%d\n", a+b); 
     	}else if(op=='-'){ 
     	    printf("%d\n", a-b); 
     	}else if(op=='*'){ 
     	    printf("%d\n", a*b); 
     	}else if(op=='/'){ 
     	    printf("%d\n", a/b); 
        } 
    } 
    return 0; 
} 



Measured memory_bytes: 2048
n = input()
A = [int(i) for i in input().split(' ')]

def trace(A):
    for index, v in enumerate(A):
        print(v, end='')
        if index != len(A) - 1:
            print(' ', end='')
    print()

trace(A)
for i in range(1, len(A)):
    v = A[i]
    j = i - 1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    trace(A)

Measured memory_bytes: 8392
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n, p / 2);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	char a;
	std::cin >> a;
	if ('a' <= a && a <= 'z') {
		std::cout << "a" << endl;
	}
	else {
		std::cout << "A" << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<functional>
#include<algorithm>
#include<cctype>
using namespace std;


char str[10002];
int p;

int solve(){
	char c=str[p];
	if(isdigit(c)){
		int res=0;
		do{
			res=res*10+str[p]-'0';
		}while(str[++p]!=']');
		return res/2+1;
	}else if(c=='['){
		p++;
		vector<int> v;
		while(str[p]!=']'){
			v.push_back(solve());
		}
		p++;
		int res=0;
		sort(v.begin(),v.end());
		for(int i=0;i<v.size()/2+1;i++)res+=v[i];
		return res;
	}
	return -1;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		cin>>str;
		p=0;
		cout<<solve()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1264
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
#define MOD 1000000007
long long n,k;
long long p;
long long kosu;
long long del[100006];
long long myPow(long long x, long long n, long long m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
int ima;
long long ans;
int main()
{
    cin>>n>>k;
    rep2(i,1,k+1)//del
    {
        if(i==1)
        {
            del[i]=1;
            continue;
        }
        ima=1;
        for(long long j=2;j*j<=i;j++)
        {
            if(i%j==0)
            {
                ima+=del[j];
                if(j*j!=i)ima+=del[i/j];
            }
        }
        del[i]=i-ima;
        //cout<<"del"<<i<<":"<<del[i]<<endl;
    }
    rep2(i,1,k+1)
    {
        p=k/i;
        kosu=myPow(p,n,MOD);
        ans+=del[i]*kosu;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int xx1, x2, x3, x4, x5, x6, yy1, y2, y3, y4, y5, y6, N, fac[2001017], inv[2001017];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int paths (int dx, int dy) {return comb (dx + dy, dx);}

int first_term[1 << 21], second_term[1 << 21], res[1 << 21];
int solve (int a1, int b1, int a2, int b2)
{
    int ans = 0;
    ans = subtract (ans, mul (x3 + y3, mul (paths (x3 - a1, y3 - b1), paths (a2 - x3, b2 - y3))));
    for (int i=x3 + 1; i<=x4; i++)
        ans = subtract (ans, mul (y3 + i, mul (paths (i - a1, y3 - b1 - 1), paths (a2 - i, b2 - y3))));
    for (int j=y3 + 1; j<=y4; j++)
        ans = subtract (ans, mul (x3 + j, mul (paths (x3 - a1 - 1, j - b1), paths (a2 - x3, b2 - j))));
    adto (ans, mul (x4 + y4 + 1, mul (paths (a2 - x4, b2 - y4), paths (x4 - a1, y4 - b1))));
    for (int i=x3; i<x4; i++)
        adto (ans, mul (y4 + i + 1, mul (paths (a2 - i, b2 - y4 - 1), paths (i - a1, y4 - b1))));
    for (int j=y3; j<y4; j++)
        adto (ans, mul (x4 + j + 1, mul (paths (a2 - x4 - 1, b2 - j), paths (x4 - a1, j - b1))));
    return ans;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

Prec (2001000);
scanf ("%d %d %d %d %d %d", &xx1, &x2, &x3, &x4, &x5, &x6), xx1 --, x2 --, x5 ++, x6 ++;
scanf ("%d %d %d %d %d %d", &yy1, &y2, &y3, &y4, &y5, &y6), yy1 --, y2 --, y5 ++, y6 ++;

vector < pair < pair < int, int >, int > > L, R;
L.push_back ({{xx1, yy1}, +1});
L.push_back ({{xx1, y2 + 1}, -1});
L.push_back ({{x2 + 1, yy1}, -1});
L.push_back ({{x2 + 1, y2 + 1}, +1});

R.push_back ({{x5 - 1, y5 - 1}, +1});
R.push_back ({{x5 - 1, y6}, -1});
R.push_back ({{x6, y5 - 1}, -1});
R.push_back ({{x6, y6}, +1});

int ans = 0;
for (auto stanga_sus : L)
    for (auto dreapta_jos : R)
    {
        int a1 = stanga_sus.first.first, b1 = stanga_sus.first.second, a2 = dreapta_jos.first.first, b2 = dreapta_jos.first.second, sg = stanga_sus.second * dreapta_jos.second;
        int val = solve (a1, b1, a2, b2);
        if (sg < 0) val = subtract (mod, val);
        adto (ans, val);
    }
printf ("%d\n", ans);

return 0;
}


Measured memory_bytes: 15872
import math

values = [float(s) for s in input().split(" ")] # 0 is min price, 1 increment, 2 is max price, 3 is decrement
print(int(1 + math.ceil((values[1]-values[0])/(values[0]-1))))

"""
sockets = values[0]
bars = 1
while sockets < values[1]:
    sockets +=values[0] - 1
    bars +=1
print(bars)
"""


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
#define LL long long
int gcd(int a,int b){return b?gcd(b,a%b):a;}
LL merge(LL l1,LL r1,LL l2,LL r2){
	return max(0ll,min(r1,r2)-max(l1,l2)+1);
}
int main(){
	int n,x,d,g,w,w1,w2;scanf("%d%d%d",&n,&x,&d),g=gcd(x,d);
	LL ans=1,l,r;
	if(1ll*d*g<0)d=-d,x=-x;
	if(!d){
		if(!x)putchar('1');
		else printf("%d",n+1);
		return 0;
	}
	if(!x)w1=1,w2=0;
	else w1=d/g,w2=x/g;
	for(int i=1;i<=n;i++){
		l=1ll*(i-1)*i/2,r=1ll*(n+n-i-1)*i/2;
		ans+=r-l+1;
		if((w=i-w1)>=0)ans-=merge(l+w2,r+w2,1ll*w*(w-1)/2,1ll*(n+n-w-1)*w/2);
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	string s;
	cin>>s;
	int i,ans=0;
	for(i=0;i<s.length()-1;i++)if(s[i]!=s[i+1])ans++;
	cout<<ans<<endl;
	
	
	
	
	
	
//////////////////////////////////////////////////////
	return 0;
}


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

int next_train(int f,int s,int nowt){
	if(s>=nowt)return s;
	int x = (nowt-s+f-1)/f;
	return s+x*f;
}

int main(){
	int N;
	cin >> N;
	vector<int> C(N+1),F(N+1),S(N+1);
	for(int i=1;i<N;i++){
		cin >> C[i] >> S[i] >> F[i];
	}
	for(int i=1;i<N;i++){
		int t = 0;
		for(int j=i;j<N;j++){
			t = next_train(F[j],S[j],t);
			t += C[j];
		}
		cout << t << endl;
	}
	cout << 0 << endl;
}

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

int main() {
	int n;
	long long x;
	long long b[51], p[51],size[51];
	long long answer;

	cin >> n >> x;
		answer = 0;
		p[0] = 1;
		b[0] = 0;
		size[0] = 1;
		for (int i = 1; i <= n; i++) {
			p[i] = 1 + 2 * p[i - 1];
			b[i] = 2 + 2 * b[i - 1];
			size[i] = p[i] + b[i];
		}

		for (int k = n; k >= 0; k--) {
			if (k != 0) {
				if (x == size[k]) {
					answer += p[k];
					break;
				}
				if (x > size[k] / 2) {
					answer += p[k - 1] + 1;
					x -= (size[k] / 2) + 1;
				}
				else if (x == size[k] / 2) {
					answer += p[k - 1];
					break;
				}
				else {
					x -= 1;
				}
			}
			else if (x == 1) {
				answer += 1;
			}
		}

		cout << answer << endl;
}

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

int main(){
  string S, T;
  cin >> S >> T;
  
  vector<int> check((int)S.size(), 0);
  int count = 0;
  
  for (int i=0; i<S.size() - T.size()+1; i++){
    for (int j=0; j<T.size(); j++){
      if (S.at(i+j) == T.at(j)) count++;
    }
    check.at(i) = count;
    count = 0;
  }
  
  sort(check.begin(), check.end(), greater<int>());
  cout << (int)T.size() - check.at(0) << endl;
}

Measured memory_bytes: 3628
N = int( input())
W = [0]*101
for i in range(2,N+1):
    j = i
    for k in range(2,100):
        while j%k == 0:
            W[k] += 1
            j //= k
ans = 0
if N >= 78:
    ans += 1
for i in range(2,N+1):
    if W[i] >= 2:
        for j in range(2,N+1):
            if j == i:
                continue
            if W[j] >= 24:
                ans += 1
for i in range(2,N+1):
    if W[i] >= 4:
        for j in range(2,N+1):
            if j == i:
                continue
            if W[j] >= 14:
                ans += 1

for i in range(2,N+1):
    if W[i] >= 2:
        for j in range(2,N+1):
            if j == i:
                continue
            if W[j] >= 4:
                for k in range(j,N+1):
                    if k == i or k == j:
                        continue
                    if W[k] >= 4:
                        ans += 1

print(ans)

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

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

    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if(i % 2 != 0) cnt++;
    }

    double ans = (double)cnt / n;
    printf("%0.7f", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef pair<ll, ll> P;

const int MAXN = 1e5 + 10;

int main(){
    ll N, C; cin >> N >> C;
    ll ans = 0;
    vector<ll> x(N+2,0), v(N+2,0);
    rep(i, N) cin >> x[i+1] >> v[i+1];
    x[N+1] = C;

    ll dpr1[MAXN], dpl1[MAXN], dpr2[MAXN], dpl2[MAXN];
    //vector<ll> right(N+1,0), left(N+1, 0);
    vector<ll> right1(N+1, 0), left1(N+1, 0), right2(N+1,0), left2(N+1,0);
    rep(i, N){
        right1[i+1] = right1[i] + v[i+1] - (x[i+1] - x[i]);
        right2[i+1] = right2[i] + v[i+1] - 2 * (x[i+1] - x[i]);
        left1[i+1] = left1[i] + v[N - i] - (x[N+1-i] - x[N-i]);
        left2[i+1] = left2[i] + v[N - i] - 2 * (x[N+1-i] - x[N-i]);
    }
    rep(i, N){
        dpr1[i+1] = max(dpr1[i], right1[i+1]);
        dpl1[i+1] = max(dpl1[i], left1[i+1]); 
        dpr2[i+1] = max(dpr2[i], right2[i+1]); 
        dpl2[i+1] = max(dpl2[i], left2[i+1]); 
    }
    for(int i = 0; i <= N; i++){
        ans = max(ans, dpr1[i] + dpl2[N-i]);
        ans = max(ans, dpl1[i] + dpr2[N-i]);
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int a[s.size()+1];
    memset(a,0,sizeof(a));
    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        a[i] = max(a[i],count);
        if (s[i] == '<') {
            count++;
        }
        else {
            count = 0;
        }
    }
    a[s.size()] = max(a[s.size()],count);
    for (int i = s.size()-1; i >= 0; i--) {
        a[i+1] = max(a[i+1],count);
        if (s[i] == '>') {
            count++;
        }
        else {
            count = 0;
        }
    }
    long long sum = 0;
    a[0] = max(a[0],count);
    for (int i = 0; i < s.size()+1; i++) {
//        cout << a[i] << "\n";
        sum += a[i];
    }
    cout << sum << "\n";
    return 0;
}


Measured memory_bytes: 2820
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a) for(i = 0 ; i < a ; i++)
#define whln(t) while(t--)
#define whlp(t) while(t++)
ll i=0,j=0;


int main(void){
	#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	#endif
	ll n;
	cin>>n;
	i =1 ;
	ll cnt = 1;
	while(cnt<10000000){
		if((7*i)%n==0){
			cout<<cnt;
			return 0 ;
		}
		i*=10  ;
		i+=1 ;
		i%=n;
		cnt++;
	}
	cout<<-1;

}
//   *****  *******   !
//   *		     *    !
//   ***       *      !
//   *       *        !
//   *****  *******   !

Measured memory_bytes: 3640
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,l;
            cin>>n>>l;
            int sum=0,sum2=0,ans=1e9,ans2;
            for(i=1;i<=n;++i)
                sum=sum+l+i-1;
            for(i=1;i<=n;++i)
            {
                sum2=0;
                for(j=1;j<=n;++j)
                {
                    if(i==j)
                        continue;
                    sum2=sum2+l+j-1;
                }
                if(abs(sum-sum2)<ans)
                {
                    ans=abs(sum-sum2);
                    ans2=sum2;
                }
            }
            cout<<ans2<<endl;
        }
        return 0;
    }


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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int n;
    cin >> n;
    int a[n];
    for(auto &x: a) cin >> x;
    sort(a, a+n);
    lli ans = 0;
    for(int i=0; i<n; i++){
        for(int *j=a+i+1; j<a+n; j++){
            lli x = (lower_bound(a, a+n, a[i]+*j) - j);
            x--;
            ans += x;
        }
    }
    cout << ans << "\n";

    return 0;
}


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

int main(){
	int a,b,c; cin>>a>>b>>c;
	set<int> st;
	st.insert(a);
	st.insert(b);
	st.insert(c);
	cout<<st.size()<<endl;
}

Measured memory_bytes: 3644
// う　し　た　ぷ　に　き　あ　く　ん　笑
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
const string K = "keyence";

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

    string s;
    cin >> s;

    const int n = s.size();

    bool ans = s == K;

    // sのiからjまでの文字列を取り除いてキーエンス文字列か確認する
    for (int i = 0; i < n && !ans; i++) {
        for (int j = i; j < n - 1 && !ans; j++) {
            const string t = s.substr(0, i) + s.substr(j + 1);
            if (t == K) {
                ans = true;
            }
        }
    }

    cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3580
import math

a,b,h,m = map(int,input().split())

kakudo1 = h * 30 + m / 2
kakudo2 = m * 6

ans = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(kakudo1-kakudo2)))
print(ans)

Measured memory_bytes: 9352
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  unsigned long a[100000]={};
  for(int i=0; i<N; i++){
    cin >> a[i];
  }

  map<int, int> mp;
  for(int i=0; i<N; i++){
    mp[a[i]]++;
  }

  int counter=0;
  for(auto p: mp){
    int key = p.first;
    int value = p.second;
    if(value < key){
      counter += value;
    }else{
      counter += value - key;
    }
  }
  cout << counter << endl;
  return 0;
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll inf = 1e18;

class UnionFind{
private:
    vector<int> p,s;
    int cnt;
public:
    UnionFind(){}
    UnionFind(int N):cnt(N),s(N,1),p(N){
        iota(p.begin(),p.end(),0);
    }
    int find(int x){
        if(p[x]==x) return x;
        else return p[x] = find(p[x]);
    }
    void unite(int x,int y){
        x = find(x); y = find(y);
        if(x==y) return;
        if(s[x]>s[y]) swap(x,y);
        p[x] = y;
        s[y] += s[x];
        cnt--;
    }
    bool is_same_set(int x,int y) {return find(x)==find(y);}
    int size(int x) {return s[find(x)];}
    int compnents_number(){return cnt;}
};

bool chmin(ll &a,ll b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,D;
    cin >> N >> D;
    vec<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    struct edge{
        int a,b;
        ll c;
    };
    vec<edge> E;
    
    auto rec = [&](auto&& self,int l,int r)->void{
        if(r-l<=1) return ;
        int m = (l+r)/2;
        self(self,l,m);
        self(self,m,r);
        ll mil = inf;
        int mlid = -1;
        for(int i=l;i<m;i++){
            if(chmin(mil,(m-i)*D+A[i])){
                mlid = i;
            }
        }
        ll mir = inf;
        int mrid = -1;
        for(int i=m;i<r;i++){
            if(chmin(mir,(i-m)*D+A[i])){
                mrid = i;
            }
        }
        for(int i=l;i<m;i++) E.push_back({i,mrid,(m-i)*D+A[i]+mir});
        for(int i=m;i<r;i++) E.push_back({i,mlid,(i-m)*D+A[i]+mil});
    };
    rec(rec,0,N);

    UnionFind uf(N);
    sort(E.begin(),E.end(),[&](edge &a,edge &b){
        return a.c<b.c;
    });
    ll ans = 0;
    for(auto& e:E){
        if(!uf.is_same_set(e.a,e.b)){
            ans += e.c;
            uf.unite(e.a,e.b);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 69472
let _ = int_of_string (read_line())
let s = read_line()
let vs = Str.split (Str.regexp " ") s |> List.map int_of_string
let rec loop = function
 | [] -> [],[]
 | [a] -> [a],[]
 | a::b::xs ->
   let aa,bb = loop xs in
   a::aa,b::bb

let vs1,vs2=loop vs
module M = Map.Make(struct type t=int let compare=compare end)

let f vs m =
  let (v,c,_) = List.fold_left(fun (mv,mc,m) v ->
        let c = (try M.find v m with _ -> 0)+1 in
        if c > mc then (v,c,M.add  v c m) else
        (mv,mc,M.add  v c m)
  ) (0,0,m) vs in
  (v,c)

let (v1,vm1)=f vs1 M.empty
let (v2,vm2)=f vs2 M.empty
let p vm1 vm2 =
  let n = (List.length vs1-vm1)+(List.length vs2-vm2) in
  Printf.printf "%d\n" n

let p2 vm1 vm2 vm1' vm2' =
  let n1 = (List.length vs1-vm1')+(List.length vs2-vm2) in
  let n2 = (List.length vs1-vm1)+(List.length vs2-vm2') in
  Printf.printf "%d\n" (min n1 n2)
let _ =
  if v1 <> v2 then (p vm1 vm2) else
          let (v2',vm2') = f vs2 (M.singleton v1 (-10000)) in
          let (v1',vm1') = f vs1 (M.singleton v1 (-10000)) in
          p2 vm1 vm2 vm1' vm2'


Measured memory_bytes: 22016
n = int(input())
alph = 'abcdefghij'


def dfs(s, i):
    if len(s) == n:
        return s
    return "\n".join([dfs(s + c, i)for c in alph[:i]] +\
                     [dfs(s + alph[i], i + 1)])


print(dfs("a", 1))


Measured memory_bytes: 6668
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 




bool s[405][405];
bool used[405][405];
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
int main()
{
     string s;
     cin>>s;
     int res=0;
     int ct=0;
     for(int i=0;i<s.length();i++){
          if(i==0&&s[i]=='p'){res-=1;ct++;}
          else if(i==0&&s[i]=='g'){ct++;}
          if(i!=0){
               if(s[i]=='g'){
                    if(ct!=0){ct--;res++;}
                    else{ct++;}
               }
               else if(s[i]=='p'){
                    if(ct!=0){ct--;}
                    else{
                         ct++;res-=1;
                    }
               }
          }
     }
     cout<<res;

}



































Measured memory_bytes: 3752
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(void) {
    int N;cin>>N;
    map<int, int> mp;
    vector<int> vc;
    int ma = -1;
    for (int i = 0; i < N; i++) {
        int A;cin>>A;
        vc.push_back(A);
        // 最大値を更新
        if (ma < A) ma = A;
        if (mp.find(A) != mp.end()) mp[A] += 1;
        else mp[A] = 1;
    }

    // 最大値のポインタ 
    map<int, int>::iterator e = mp.find(ma);

    // 結果出力
    for (int i = 0; i < N; i++) {
        int a = vc.at(i);
        
        if (a == ma) {
            if (e->second > 1) {
                cout << ma << endl;
            } else {
                // 最大値の一つ小さい値を入れておく
                map<int, int>::iterator em = e;
                em--;
                cout << em->first << endl;
            }
        } else cout << ma << endl;
    }
    return 0;
}

Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;
#define li          long
#define ll          long long
#define ull         unsigned long long
#define ff          first
#define ss          second
#define pii         pair<int,int>
#define pli         pair<li,li>
#define pll         pair<ll,ll>
#define pb          push_back
#define fo(i,k,n)   for(int i = k;i<n; i++)
#define ro(i,k,n)   for(int i = k; i>=n; i--)
#define tc          int t;cin>>t;while(t--)
#define all(v)      v.begin(),v.end()
#define inf         INT_MAX
#define ninf        INT_MIN
#define W(x)        cout<<x<<endl
#define WW(x,y)     cout<<x<<' '<<y<<endl;
#define in(x)       cin>>x
#define v(x)        vector<x>
#define int         long long
#define ar(x,y)     array<x,y>
const ll mod1 = 99844353;
const ll mod2 = 1e9+7;
/* template <class T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; */

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

template<class T>
T power(T a,T b){
    T res = (T)1;
    while(b>0){
        if(b&1)res = res*a;
        b>>=1;
        a*=a;
    }
    return res;
}

struct dsu{
  unordered_map<int,int> pr,sz;
  dsu(){
    (this->pr).clear();
    (this->sz).clear();
  }
  void make(int x){
    pr[x] = x;
    sz[x] = 1;
  }
  int getpar(int x){
    if(pr[x] == x)return x;
    return pr[x] = getpar(pr[x]);
  }
  void merge(int x,int y){
    x = getpar(x);
    y = getpar(y);
    if(sz[x]<sz[y])swap(x,y);
    pr[y] = x;
    sz[x]+=sz[y];
    sz[y] = 0;
  }
};


void solve(){
  int n;
  cin>>n;
  vector<int> ans(n+1,0);
  fo(i,1,101){
    fo(j,1,101){
      fo(k,1,101){
        int num= i*i+j*j+k*k+i*j+j*k+k*i;
        if(num<=n)ans[num]++;
      }
    }
  }
  fo(i,1,n+1) cout<<ans[i]<<"\n";
}

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


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>

int main(int argc, char const* argv[])
{
    int n, k;
    std::cin >> n >> k;

    auto result = 0;

    for(int i=0; i<n; ++i)
    {
        int val;
        std::cin >> val;

        auto k_diff = std::abs(k - val);
        auto zero_diff = val;

        result += std::min(k_diff, zero_diff) * 2;
    }

    std::cout << result << std::endl;
}

Measured memory_bytes: 256