akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define SZ(X) ((int)X.size() )
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef pair<int, int> PII; 
const double eps = 1e-12;
const double PI = acos(-1);
const LL INFF = (LL)1e18;
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)1e5+7;
int val(int v){
	int res = 0;
	while(v){
		res += v % 10;
		v /= 10;
	}
	return res;
}
int main(void){
	DRI(n);
	int ans = INF;
	rep1(i, 1, n){
		ans = min(ans, val(i) + val(n-i) );
	}
	printf("%d\n", ans);
	return 0;
}


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

int main(){
    ll i,j,k,flag=0,t,m,n,b,c,x,y,u,v,trc=0,row,col,l=0,lst;
    double sum=0;
 // string s1,s2,s;
   cin>>n>>k;
   t=n%k;
   cout<<min(t,k-t)<<endl;
       
    
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define popcnt(x) __builtin_popcount(x)
#define popcntll(x) __builtin_popcountll(x)
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

vc<int> init(vc<int>& a){
    int n = LEN(a), j = -1;
    vc<int> f(n+1, -1);
    REP(i, n){
        while(j>=0 and a[j]!=a[i]) j = f[j];
        f[i+1] = ++j;
    }
    return f;
}

vc<int> search(vc<int>& s, vc<int>& t, vc<int>& f){
    int n = LEN(s), m = LEN(t), j = 0;
    vc<int> res;
    for(int i=0;i+j<n;){
        while(i+j<n and j<m and s[i+j]==t[j]) ++j;
        if(j==m) res.pb(i);
        i = i + j - f[j];
        if(j) j -= j - f[j];
    }
    return res;
}

class FXorShift {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N), B(N), AA(N), BB(N);
        for(auto& a : A) in>>a;
        for(auto& b : B) in>>b;
        REP(i, N){
            AA[i] = A[i] ^ A[(i+1)%N];
            BB[i] = B[i] ^ B[(i+1)%N];
        }
        vc<int> f = init(BB), C(2*N-1);
        REP(i, N){
            C[i] = AA[i];
            if(i<N-1) C[i+N] = AA[i];
        }
        vc<int> ans = search(C, BB, f);
        for(auto& k : ans) out<<k<<' '<<(A[k]^B[0])<<'\n';
    }
};


int main() {
	FXorShift solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

// const int MAX = 1010;

ll COM(int n, int r)
{
    ll semi = 1;
    ll denomi = 1;
    for (int i = 0; i < r; i++)
    {
        semi *= n - i;
        if (semi % (i + 1) == 0)
        {
            semi /= (i + 1);
        }
        else
        {
            denomi *= (i + 1);
        }
    }
    return semi / denomi;
}

int main()
{
    int n, p;
    cin >> n >> p;
    int odd = 0, even = 0;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        if (a % 2 == 0)
        {
            ++even;
        }
        else
        {
            ++odd;
        }
    }
    ll ans = 0;
    for (int i = 0; i <= odd; i++)
    {
        if (i % 2 == p)
        {
            ans += COM(odd, i);
        }
    }
    ll tmp = 0;
    for (int i = 0; i <= even; i++)
    {
        tmp += COM(even, i);
    }
    ans *= tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3572
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    n,m = map(int, input().split())
    print(((n-m)*100+m*1900)*2**m)
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		int n;
		double a, m, b;

		Scanner stdIn = new Scanner(System.in);

		while (true) {
			b = 0.0;
			n = stdIn.nextInt();
			if(n == 0) {
				break;
			}
			int[] s = new int[n];

			for (int i = 0; i < n; i++) {
				s[i] = stdIn.nextInt();
			}

			double temp = 0.0;
			for (Integer j : s) {
				temp += j;
			}
			m = (temp / n);

			int i = 0;
			for (Integer j : s) {
				b += Math.pow((j - m), 2);
				i++;
			}
			a = b / n;
			System.out.format("%.8f\n", Math.sqrt(a));
		}
		stdIn.close();
	}
}

Measured memory_bytes: 31420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

long long extgcd(long long a, long long b ,long long &x, long long&y){
  long long d = a;
  if( b != 0 ){
    d = extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1,y=0;
  }
  return d;
}
long long mod_inverse( long long a, long long m ){
  long long x, y ;
  extgcd( a, m , x, y);
  return (m+x%m)%m;
}

int main(){
   long long N,A,B,C;
   cin >> N >> A >> B >> C;
   int mod = 1000000007;
   long long AN=1;
   long long BN=1;
   long long V=mod_inverse(100-C,mod);
   long long K=1;
   for(int i=0;i<N;i++){
      AN*=A;
      AN%=mod;
      BN*=B;
      BN%=mod;
      K*=V;
      K%=mod;
   }
   long long ans = 0;
   //cout << N<<"* ("<< AN<<"+"<<BN<<") *"<<K << endl;
   ans += ((N*(AN+BN))%mod)*K;
   ans %=mod;
   //cout << ans << endl;
   long long comb = 1;
   for(int i = 1; i<= N-1; i++){
      AN*=B;AN%=mod;
      BN*=A;BN%=mod;
      K*=V; K%=mod;
      comb *= N+i-1;
      comb %= mod;
      comb *= mod_inverse(i, mod);
      comb %= mod;

      //cout << N+i<<"* " << comb << " * ("<< AN<<"+"<<BN<<") *"<<K << endl;
      long long tmp = (N+i)*comb;
      tmp %= mod;
      tmp *= (AN+BN);
      tmp %= mod;
      tmp *= K;
      tmp %= mod;
      //cout << ans <<"+" << tmp << endl;
      ans += tmp;
      ans %= mod;
   }

   //cout << ans << endl;
   ans *= 100;
   ans %= mod;
   ans *= mod_inverse(100-C,mod);
   ans %= mod;
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  int ans = 0;
  if (x == 3)
    ans += 100000;
  else if (x == 2)
    ans += 200000;
  else if (x == 1)
    ans += 300000;
  if (y == 3)
    ans += 100000;
  else if (y == 2)
    ans += 200000;
  else if (y == 1)
    ans += 300000;
  if (x == 1 && y == 1)
    ans += 400000;
  cout << ans << endl;
  return 0;
}

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

signed main() {
  	int n; cin >> n;
  	vector<int> h(n);
  	for(int& i: h) cin >> i;
  	int dp[n];
  	memset(dp, 0, sizeof dp);
  	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; ++i) {
    	dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

long long p10[19];

long long search(long long D, int len, bool first = false){
    if(abs(D) >= p10[len]) return 0;
    if(len <= 1) return D == 0 ? p10[len] : 0;
    long long res = 0;
    for(int dif=-9;dif<=9;dif++){
        long long add = dif * p10[len-1] - dif;
        long long newD = D + add;
        if(abs(newD) % 10 != 0) continue;
        long long mul = 10 - abs(dif) - (first && dif <= 0 ? 1 : 0);
        res += mul * search(newD/10, len-2);
    }
    return res;
}

int main(){
    p10[0] = 1;
    for(int i=1;i<19;i++) p10[i] = 10 * p10[i-1];
    long long D;
    while(cin >> D){
        long long res = 0;
        for(int i=1;i<=18;i++) res += search(D, i, true);
        cout << res << endl;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
char od[6];
int f[30];
int main(){
	scanf("%s",od);
	for(int i=0;i<4;i++){
		f[od[i]-'A']++;
	}
	int fg=1;
	for(int i=0;i<26;i++){
		if(f[i]!=0&&f[i]!=2)fg=0;
//		printf("%d ",f[i]);
	}
	if(fg)puts("Yes");
	else puts("No");
}

Measured memory_bytes: 256
for _ in [None] * 50:
    m, f, r = map(int, input().split())
    result = ""
    if m == f == r == -1:
        break
    if m == -1 or f == -1 or m + f < 30:
        result = "F"
    elif m + f >= 80:
        result = "A"
    elif 80 > m + f >= 65:
        result = "B"
    elif 65 > m + f >= 50:
        result = "C"
    else:
        result = "C" if r >= 50 else "D"
    print(result)



Measured memory_bytes: 5600
N, C, K = gets.split.map(&:to_i)
T = Array.new(N)
N.times do |i|
  T[i] = gets.to_i
end
T.sort!
count = 0

while !T.length.zero? do
  buss = []
  buss << T.shift
  limit = buss[0] + K
  while buss.length < C do
    #p "T[0]は#{T[0]}"
    #p "bussは#{buss}"
    if T.size.zero?
      break
    end
    if T[0] > limit
      break
    else
      buss << T.shift
    end
  end
  count += 1
end

p count

Measured memory_bytes: 4328
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final String S = sc.nextLine();
        if (S.equals("RRR")) {
            System.out.println(3);
        } else if (S.contains("RR")) {
            System.out.println(2);
        } else if (S.contains("R")) {
            System.out.println(1);
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 35668
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define reach(i,a)	for(auto i:a)
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
int bitcnt(ll x) {
	x = ((x & 0xAAAAAAAAAAAAAAAA) >> 1) + (x & 0x5555555555555555);
	x = ((x & 0xCCCCCCCCCCCCCCCC) >> 2) + (x & 0x3333333333333333);
	x = ((x & 0xF0F0F0F0F0F0F0F0) >> 4) + (x & 0x0F0F0F0F0F0F0F0F);
	x = ((x & 0xFF00FF00FF00FF00) >> 8) + (x & 0x00FF00FF00FF00FF);
	x = ((x & 0xFFFF0000FFFF0000) >> 16) + (x & 0x0000FFFF0000FFFF);
	x = ((x & 0xFFFFFFFF00000000) >> 32) + (x & 0x00000000FFFFFFFF);
	return x;
}
int bitcnt(int x) {
	x = ((x & 0xAAAAAAAA) >> 1) + (x & 0x55555555);
	x = ((x & 0xCCCCCCCC) >> 2) + (x & 0x33333333);
	x = ((x & 0xF0F0F0F0) >> 4) + (x & 0x0F0F0F0F);
	x = ((x & 0xFF00FF00) >> 8) + (x & 0x00FF00FF);
	x = ((x & 0xFFFF0000) >> 16) + (x & 0x0000FFFF);
	return x;
}
ll gcd(ll a, ll b) {
	return a%b == 0 ? b : gcd(b, a%b);
}
#define debug(x)	cout<<"case #" << x << ": " << endl
#define DEBUG 0
const int inf = 1e9;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };

deque<int> pos[26];

int bit[200010];
int N = 1;

void init(int n) {
	N = n;
	REP(i, N)	bit[i] = 0;
}

void add(int k, int a) {
	while (k <= N) {
		bit[k] += a;
		k += k&-k;
	}
}

int sum(int k) {
	int ret = 0;
	while (k>0) {
		ret += bit[k];
		k &= k - 1;
	}
	return ret;
}

int main() {
	string s;	cin >> s;
	int n = s.size();
	rep(i, n)	pos[s[i] - 'a'].push_back(i + 1);
	int cntodd = 0;
	rep(i, 26)	cntodd += pos[i].size() & 1;
	if (cntodd > 1) {
		cout << -1 << endl;
		return 0;
	}
	ll ret = 0;
	init(n);
	while (n > 2) {
		int del = -1;
		int mov = inf;
		rep(i, 26) {
			if (pos[i].size() > 1) {
				int l = pos[i].front(), r = pos[i].back();
				//適当に正しい位置へもっていき、
				l -= sum(l);	r -= sum(r);
				//両端への移動距離を計算する
				if (mov > (l - 1) + (n - r)) {
					mov = l + n - r - 1;
					del = i;
				}
			}
		}
		ret += mov;
		add(pos[del].front(), 1);
		add(pos[del].back(), 1);
		pos[del].pop_front();
		pos[del].pop_back();
		n -= 2;
	}
	cout << ret << endl;
	return 0;
}

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

using namespace std;
#define         MAX         1000000
#define         input       freopen("input.txt","r",stdin)
#define         output      freopen("output.txt","w",stdout)

queue<long long>q;

int main() {

    for(int i=1;i<=9;i++) q.push(i);

    int k;
    cin>>k;
    int cnt = 0;
    long long f;
    while(cnt<k){

        f =  q.front(); q.pop();

        int tmp = f%10;
        if(tmp != 0) q.push((f*10)+(tmp-1));
        q.push((f*10)+tmp);
        if(tmp != 9) q.push((f*10)+(tmp+1));

        cnt++;

    }

    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
list = []
for i in range(3, n + 1):
    if i % 3 == 0:
        list.append(i)
    else:
        x = i
        while x:
            if x % 10 == 3:
                list.append(i)
                break
            else:
                x = x // 10
print("", *list)


Measured memory_bytes: 5980
H, W = map(int, input().split())
S = [list(map(int, input().split())) for _ in range(10)]

for k in range(10):
  for i in range(10):
    for j in range(10):
      if S[i][j] > S[i][k] + S[k][j]:
        S[i][j] = S[i][k] + S[k][j]
        
D = {}
for i in range(H):
  line = list(map(int, input().split()))
  for j in line:
    if j in D:
      D[j] += 1
    else:
      D[j] = 1
magic = 0
for k in D:
  if k != -1:
    magic += S[k][1] * D[k]
print(magic)

Measured memory_bytes: 3064
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll x , a;

int main() {
    fast_io;

    cin >> x >> a;
    cout << (x >= a ? 10 : 0) << endl;

    return 0;
}
/*
todo :
    1- set constants
    2- check TimeLimit and MemoryLimit
    3- check special test cases
    4- don't forget BS can help you that is good idea(use for loop for floats)
    5- don't forget printf and scanf can help you in your code speed
*/


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {

            String s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; i--)
#define all(vec) vec.begin(), vec.end()
#define rever(vec) reverse(all(vec));
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
const int mod2 = 998244353;
const int mod = (int)1e9 + 7, inf = (int)1e16;

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] *= fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int perm(int n, int r) {
	if (n < r) return 0;
	if (n - r < r) r = n - r;
	int ans= fact[n] * modpow(fact[n - r], mod - 2) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int>factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

P operator+(const P& a, const P& b) {
	return P(a.first + b.first, a.second + b.second);
}
P operator-(const P& a, const P& b) {
	return P(a.first - b.first, a.second - b.second);
}

int n;
int b[101];
int a[101];
int ans;
signed main() {
	cin >> n;
	rep(i, n - 1) cin >> b[i];
	rep(i, n) a[i] = inf;
	rep(i, n - 1) {
		a[i] = min(a[i], b[i]);
		a[i + 1] = min(a[i + 1], b[i]);
	}
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

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





int main(){
   
    int N;
    cin >> N;
    vector<pair<int,int>> p(N);
    for(int i=0;i<N;i++) {
        cin >> p[i].first >> p[i].second;
    }
    vector<pair<int, int>> v(N*N);
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            v[N*i+j] = pair<int, int> ( p[i].first-p[j].first, p[i].second-p[j].second );
        }
    }
    
    sort(v.begin(),v.end());
    int cnt=1;
    int maxcnt=1;
    for(int i=1;i<N*N;i++){
        // cout << v[i].first << " " << v[i].second << " " << cnt << endl;
        if( v[i-1]==pair<int,int>(0,0) || v[i]==pair<int,int>(0,0) ) {
            cnt = 1;
            continue;
        }
        
        if(v[i]==v[i-1]) cnt++;
        else {
            maxcnt = max(maxcnt,cnt);
            cnt = 1;
        }
    }
    
    cout << max(1,N-maxcnt) << endl;
    // cout << maxcnt << endl;
    
    return 0;
}




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

using namespace std;

#define all(c)	(c).begin(),(c).end()
#define rall(c)	(c).rbegin(),(c).rend()
#define rep(i,N)	for(int i=0;i<N;++i)

typedef long long ll;

constexpr ll INF = 0x3fffffffffffffff;
constexpr int inf = 0x1fffffff;
constexpr double inf_l = 1e18;
constexpr ll MOD = 1000000007LL;
constexpr int mod = 1000000007;

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

	string s; cin >> s;
	int idx = 0, K; cin >> K;

	while (K--) {
		if (idx == s.size() - 1) {
			s[idx] = 'a' + (s[idx] - 'a' + K + 1) % 26;
			break;
		}

		if (s[idx] == 'a') {
			idx++;
			K++;
			continue;
		}
		else {
			if ('z' - s[idx] <= K) {
				K -= 'z' - s[idx];
				s[idx] = 'a';
				++idx;
			}
			else {
				++idx;
				K++;
				continue;
			}
		}
	}
	cout << s << endl;
	return 0;
}

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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool f = true;

  rep(i, n) {
    if (s[i] != s[n-1-i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  if (n == 3) {
    cout << "Yes" << endl;
    return 0; 
  }
  rep(i, (n-1)/4) {
   if (s[i] != s[n-1/2-1-i]) {
      cout << "No" << endl;
      return 0;
   }
  }
  rep(i, (n-1)/4) {
   if (s[(n+3)/2 + i - 1] != s[n-1 - i]) {
     //cout << i << endl;
    //cout << (n+3)/2 + i - 1<< " " << n-1 -i << endl; 
    //cout << s[(n+3)/2 + i - 1] << " " << s[n-1 -i] << endl; 
      cout << "No" << endl;
      return 0;
   }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

struct _map {
  int  nDepth;
  char chMap;
} stMap[20000];

int chLake(int staMap, const int finMap, const struct _map* stMap, const int nDepth);

int main(){
  int maxH=0,minH=0,endMap=0;
  int A=0,L[10000],k=0;

  if (1) {
    char theMap; int m=0;
    int curH=0;
    while(scanf("%c",&theMap) !=EOF){
      stMap[m].chMap = theMap;
      if(theMap=='\\'){
	stMap[m].nDepth = --curH;
	if(curH<minH) minH=curH;
      }
      else if(theMap=='/'){
	stMap[m].nDepth = curH++;
	if(curH>maxH) maxH=curH;
      }
      else
	stMap[m].nDepth = curH;
      m++;
    }
    endMap=m;
  }

  if (1) {
    int m;
    for(m=0; m<endMap; m++) {
      if(stMap[m].chMap=='\\') {
	int n;
	for (n=m; n<endMap; n++) {
	  if ((stMap[n].chMap=='/')&&(stMap[n].nDepth==stMap[m].nDepth)) {
	    int a = chLake(m, n, stMap, stMap[m].nDepth);
	    L[k] = a/2;
	    A = A + L[k];
	    k++;
	    m = n;
	    break;
	  }
	}
      }	
    }
  }

  printf("%d\n",A);
  if (k==0)
    printf("%d\n",0);
  else {
    int l;
    printf("%d ",k);
    for(l=0; l<k-1; l++)
      printf("%d ",L[l]);
    printf("%d\n",L[k-1]);
  }
  return 0;
}

int chLake(int staMap, int endMap, const struct _map* stMap, int nDepth){
  int a=0;
  int m;
  for(m=staMap;m<=endMap;m++){
    if(stMap[m].chMap=='\\'){
      a = a + 1 + (nDepth - stMap[m].nDepth) * 2;
    }
    else if(stMap[m].chMap=='_'){
      a = a + 2 + (nDepth - stMap[m].nDepth) * 2;
    }
    else if(stMap[m].chMap=='/'){
      a = a + 1 + (nDepth - stMap[m].nDepth) * 2;
    }
  }
  return (a);
}

Measured memory_bytes: 712
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<utility>
#include<string>
#include<iomanip>
#include<queue>
#include<cmath>
#include<utility>
#include<set>
#include<cmath>
#define MOD 998244353
using namespace std;
long long mi(long long x, long long y)
{
    if(x < y)
        return x;
    return y;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    if((b-a-1)%2==1)
    {
        long long r=(b-a)/2;
        cout << r << '\n';
    }
    else
    {
        long long r=mi(a-1, n-b)+1;
        if(b-a > 1)
            r+=(b-a-1)/2;
        cout << r << '\n';
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    int n,x,temp=0,l,ans=1;
    cin >> n >> x;
    for(int i=0;i<n;i++){
        cin >> l;
        temp+=l;
        if(temp<=x) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

typedef unsigned long long ull;

ull mult(ull a, ull b, ull mod) {
  static const ull MASK = (1ULL << 25) - 1;
  ull res = 0;
  for (; a > 0; a >>= 25) {
    res = (res + b * (a & MASK)) % mod;
    b = (b << 25) % mod;
  }
  return res;
}

ull power(ull base, ull exp, ull mod) {
  ull ans = 1;
  while (exp) {
    if (exp & 1)
      ans = mult(ans, base, mod);
    base = mult(base, base, mod);
    exp >>= 1;
  }
  return ans;
}

bool millerRabin(ull num) {
  //static const ull witnesses[] = { 2, 325, 9375, 28178, 450775, 9780504, 1795265022 };
  static const ull witnesses[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37};
  if (num <= 1)
    return false;
  if (num <= 3)
    return true;
  if ((num & 1) == 0)
    return false;
  ull d = num - 1;
  int s = 0;
  for (; ~d & 1; s++)
    d >>= 1;
  for (int i = 0; i < 12; i++) {
    if (witnesses[i] > num - 2)
      break;
    ull x = power(witnesses[i], d, num);
    if (x == 1 || x == num - 1)
      continue;
    bool flag = false;
    for (int j = 0; j < s; j++) {
      x = power(x, 2, num);
      if (x == 1)
        return false;
      if (x == num - 1) {
        flag = true;
        break;
      }
    }
    if (!flag)
      return false;
  }
  return true;
}
typedef unsigned long long ll;

const int MAX = 100000;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> primes;
  vector<bool> sieve(MAX, false);
  for(int i=2;i<MAX;++i) {
    if(!sieve[i]) {
      primes.push_back(i);
      for(int j=2*i;j<MAX;j+=i)
        sieve[j]=true;
    }
  }
  int N;
  cin >> N;
  vector<ll> arr(N);
  for(ll& a : arr)
    cin >> a;
  unordered_map<ll,int> cnt;
  unordered_map<ll,ll> oth;
  int good=0;
  for(ll a : arr) {
    ll x = 1, o = 1;
    if (!millerRabin((ull)a)) {
      //cerr << a << " " << millerRabin(a) << endl;
    for(int p : primes) {
      if (a == 1 || ll(p)*p > a) break;
      int ex = 0;
      while (a % p == 0) {
        ++ex;
        a /= p;
      }
      if(ex==0)continue;
      ex%=3;
      if(ex==1) {
        x*=p;
        o*=p;
        o*=p;
      } else if(ex==2) {
        o*=p;
        x*=p;
        x*=p;
      }
    }
    }
    if (a>1) {
      if (a < MAX) {
        x *= a;
        o *= a;
        o *= a;
      } else {
        ++good;
        continue;
      }
    }
    //cerr << x << " " << o << endl;
    ++cnt[x];
    oth[x]=o;
    oth[o]=x;
    if(!cnt.count(o))
      cnt[o]=0;
  }
  int res=0;
  for(const auto& e : cnt) {
    if(e.first == 1) {
      continue;
    } else {
      const ll o = oth[e.first];
  //    cerr << e.first << " max:" << max(cnt[o],e.second)  << endl;
      res += max(cnt[o], e.second);
    }
  }
  res >>= 1;
  if(cnt.count(1))
    ++res;
  res+=good;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 15376
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define lef(x) (x<<1)
#define rig(x) (lef(x)+1)
#define int long long
const ll MOD=1e9+7LL;
const int N=100100;
ll md(ll x){
	return ((x%MOD)+MOD)%MOD;
}
ll fastexpo(ll x, ll n)
{
	ll b=1LL;
	while(n)
	{
		if(n&1LL)
			b=md(b*x);
		x=md(x*x);
		n>>=1LL;
	}
	return b;
}
ll invfat[N],fat[N],a[N];
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    fat[0]=1;
    invfat[0]=1;
    for (int i = 1; i < N; ++i)
    {
    	fat[i]=md(fat[i-1]*i);
    	invfat[i]=fastexpo(fat[i],MOD-2);
    }
    int n;
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
    	cin>>a[i];
    }
    ll tot=0LL;
    ll rs=0LL;
    for (int i = 1; i <n; ++i)
    {
    	tot=md(tot+fastexpo(i,MOD-2));
    	// cout<<tot<<" "<<(a[i+1]-a[i])<<"\n";
    	rs=md(rs+(a[i+1]-a[i])*tot);
    }
    // cout<<rs<<"\n";
    rs=md(rs*fat[n-1]);
    cout<<rs<<"\n";
    return 0;   
}

Measured memory_bytes: 2560
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,r = LI()
    v = [[] for i in range(n)]
    for i in range(m):
        a,b,c = LI()
        v[a].append((b,c))
    d = [float("inf")]*n
    d[r] = 0
    q = [(0,r)]
    while q:
        dx,x = heappop(q)
        for y,c in v[x]:
            nd = dx+c
            if nd < d[y]:
                d[y] = nd
                heappush(q,(nd,y))
    for i in d:
        if i == float("inf"):
            print("INF")
        else:
            print(i)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 89680
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
INF = 10**9

def ok(l):
    cnt = 0
    for L in a:
        cnt += L//l
        if L%l != 0:
            cnt+=1
        cnt-=1
    return cnt <= k

if __name__ == "__main__":
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    left = 0
    right = max(a)
    #最大値の最小値は二分探索
    while right - left > 1:
        mid = (right+left)//2
        if ok(mid):
            right = mid
        else:
            left = mid
    print(right)

Measured memory_bytes: 103976
N = int(input())
a = list(map(int,input().split()))

m = 10**6+1
M = -10**6-1
j = -1
k = -1
for i in range(N):
    if M < a[i]:
        M = a[i]
        j = i
    if m > a[i]:
        m = a[i]
        k = i

print(2*N-2)
if -m < M:
    for i in range(N):
        if i != j:
            print('{} {}'.format(j+1,i+1))
    for i in range(N-1):
        print('{} {}'.format(i+1,i+2))
else:
    for i in range(N):
        if i != k:
            print('{} {}'.format(k+1,i+1))
    for i in range(N-1,0,-1):
        print('{} {}'.format(i+1,i))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int h, w;
string s[100];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> h >> w;
  FOR(i, 0, h) cin >> s[i];
  FOR(i, 0, h+2){
    FOR(j, 0, w+2){
      if(i==0||i>h||j==0||j>w){
        cout << '#';
      }else{
        cout << s[i-1][j-1];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
ll A;
  ll B;
   ll C;
  ll X;
   ll Y;
  cin >>A>>B>>C>>X>>Y;
  C=2*C;
  //cout<<C<<endl;
  ll z=max(X,Y);
  ll w=min(X,Y);
  vl c(z+1);
  rep(i,z+1) {
    if(i<w) {
      c.at(i)+=C*i;
      c.at(i)+=A*(X-i)+B*(Y-i);
    }
    
    else if ((i<z)&&(i>=w)) {
      if(X<=i) {
        c.at(i)+=C*i;
        c.at(i)+=(Y-i)*B;
      }
      if(Y<=i) {
c.at(i)+=C*i;
        c.at(i)+=(X-i)*A;
      }
    }
    if(i==z) {
      c.at(i)+=C*i;
    }
  }
  
  sort(all(c));
  cout<<c.at(0)<<endl;
  
}
      
      


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

using namespace std;

#define ll long long
#define ld long double

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

signed main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d));
}

Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	N := ReadInt()
	A := ReadInts(N)
	all := 1
	ex := 1
	for i := 0; i < N; i++ {
		all *= 3
		if A[i]%2 == 0 {
			ex *= 2
		}
	}
	fmt.Println(all - ex)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    
    int ans = 1;
    lli diff = 0;
    for(int i=1; i<n; i++){
        if(diff *(a[i] -a[i-1]) < 0){
            ans++;
            diff = 0;
        }else if(a[i] -a[i-1] != 0){
            diff = a[i] -a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, m;
vector<int> a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    if(abs(n-m)<=1)cout<<"Brown"<<"\n";
    else cout<<"Alice"<<"\n";
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = (int)1e9 + 7;

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

    map<int, int> mp;
    int n;
    cin >> n;
    REP(i, n){
        int x;
        cin >> x;
        mp[x]++;
    }
    int ans = 0;
    for(auto x : mp){
        if(x.first < x.second) ans += x.second - x.first;
        else if(x.first > x.second) ans += x.second;
    }
    cout << ans << endl;
}

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

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

	int ans = 10000;
	for (int i = 1;i <= n / 2;i++) {
		int sum = 0;
		int j = i;
		while (j != 0) {
			sum += j % 10;
			j /= 10;
		}
		j = n - i;
		while (j != 0) {
			sum += j % 10;
			j /= 10;
		}
		ans = min(ans, sum);
	}

	cout << ans << endl;


	return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

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

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

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

template<uint32_t mod>
struct ModInt{
    uint32_t a;
    ModInt& s(uint32_t vv){
        a=vv<mod?vv:vv-mod;
        return *this;
    }

    ModInt(int64_t x=0){s(x%mod+mod);}

    ModInt& operator+=(const ModInt &x){return s(a+x.a);}
    ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
    ModInt& operator*=(const ModInt &x){
        a=uint64_t(a)*x.a%mod;
        return *this;
    }
    ModInt& operator/=(const ModInt &x){
        *this*=x.inv();
        return *this;
    }

    ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
    ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
    ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
    ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
    bool operator==(const ModInt &x)const{return a==x.a;}
    bool operator!=(const ModInt &x)const{return a!=x.a;}
    bool operator<(const ModInt &x)const{return a<x.a;}

    ModInt operator-()const{return ModInt()-*this;}
    ModInt pow(int64_t n)const{
        ModInt res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }

    ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
    return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
    return (out<<a.a);
}
using mint=ModInt<1000000007>;

mint po[222222];
int N;
vint G[222222];

mint ans;
int sz[222222];
void dfs(int v,int p){
    sz[v]=1;
    vint lis;
    for(auto u:G[v]){
        if(u==p)continue;
        dfs(u,v);
        sz[v]+=sz[u];
        lis.pb(sz[u]);
    }

    if(p!=-1)lis.pb(N-sz[v]);
    mint tmp=po[N-1];
    tmp-=1;
    for(auto s:lis){
        tmp-=po[s];
        tmp+=1;
    }
    ans+=tmp;
}
signed main(){
    po[0]=1;
    for(int i=1;i<222222;i++)po[i]=po[i-1]*2;
    cin>>N;
    rep(i,N-1){
        int a,b;
        cin>>a>>b;
        a--;b--;G[a].pb(b);G[b].pb(a);
    }

    dfs(0,-1);
    ans*=po[N].inv();
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

typedef long long int64;

string S;
vector< int64 > vs;

void rec(int idx, int64 sum)
{
  if(idx == S.size()) {
    vs.emplace_back(sum);
    return;
  }
  int64 ret = 0;
  for(int i = idx; i < S.size(); i++) {
    ret *= 10;
    ret += S[i] - '0';
    rec(i + 1, ret + sum);
  }
}

int main()
{
  cin >> S;
  rec(0, 0);
  int64 ret = 0;
  for(auto &s : vs) ret += s;
  cout << ret << endl;
}

Measured memory_bytes: 256
import math
a,b = input().split()

# int*floatは誤差が出る
# bは今回少数第2位なので100倍(b[0]+b[2:])した
# ものでint同士の計算を行い、100で割る
print((int(a)*int(b[0]+b[2:]))//100)

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a;
            vec[a - 1] = 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(vec[i] == 0) ans++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3604
num = int(input())
x = []
x.append(num//1000)
num = num % 1000
x.append(num//100)
num = num % 100
x.append(num//10)
num = num % 10
x.append(num)
if((x[0] == x[1] and x[1] == x[2]) or (x[1] == x[2] and x[2] == x[3])):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
S = [1 if _ == 'p' else 0 for _ in input()]
N = len(S)
count_g = 0
count_p = 0
score = 0
for hand_t in S:
    if count_p < count_g:
        count_p += 1
        hand_a = 1
    else:
        count_g += 1
        hand_a = 0
    score += hand_a - hand_t

print(score)


Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

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

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,ll b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

void solve() {
	int h1, h2, m1, m2, k;
    sc(h1, m1, h2, m2, k);
    int l = 0;
    while(h1 != h2 || m1 != m2) {
        h1 += (m1 + 1) / 60;
        m1 = (m1 + 1) % 60;
        l++;
    }
    cout << max(0, (l - k)) << endl;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3656