akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

int main() {
    lint I, O, T, J, L, S, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    lint ans = I / 2 * 2 + O + J / 2 * 2 + L / 2 * 2;
    if (I > 0 && J > 0 && L > 0) ans = max(ans, 3 + (I - 1) / 2 * 2 + O + (J - 1) / 2 * 2 + (L - 1) / 2 * 2);
    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++)

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    rep(i, n) {
        scanf("%d", &h[i]);
    }
    bool yes = true;
    rep(i, n) {
        if (i == 0) {
            h[i]--;
            continue;
        }
        if (h[i] < h[i-1]) {
            yes = false;
            break;
        } else if (h[i] > h[i-1]) {
            h[i]--;
        }
    }
    if (yes) printf("Yes\n");
    else printf("No\n");
}

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int par[100010];
int fin[100010];
int root(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = root(par[x]);
	}
}
int main() {
	int n, q, p, a, b;
	int x, y;
	cin >> n >> q;
	for (int i = 0; i < n; i++) {
		cin >> p;
		fin[p - 1] = i;
		par[i] = i;
	}
	for (int j = 0; j < q; j++) {
		cin >> a >> b;
		x = root(a - 1);
		y = root(b - 1);
		if (x != y) {
			par[x] = y;
		}
	}
	int ans = 0;
	for (int j = 0; j < n; j++) {
		if (root(par[j]) == root(fin[j])) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>


int main() {
	int n; std::cin >> n;
	std::vector<long long int> leaves(n); for (auto& l : leaves) std::cin >> l;
	long long int result{ 0 };
	for (auto diff = 1; diff < n; ++diff) {
		long long int left{ 0 }, right{ 0 };
		for (auto m = 1; m * diff < n - 1; ++m) {
			if ((n - 1 - m * diff) % diff == 0 && (n - 1 - m * diff) / diff <= m) break;
			if (n - 1 - m * diff < diff) break;
		 	left += leaves[m * diff];
			right += leaves[n - 1 - m * diff];
			result = std::max(result, left + right);
		}
	}
	std::cout << result << std::endl;
}


Measured memory_bytes: 1152
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  string s;cin>>s;
  ll r=0,b=0;
  rep(i,n){
    if(s[i]=='R')r++;
    else b++;
  }
  if(r>b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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


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

    vector< int >p(n);
    for (int &x : p) cin >> x;

    sort(p.begin(), p.end());

    int ans = 0;
    for (int i = 0; i < k; i++) ans += p[i];

    cout << ans << endl;

    return 0;
}



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

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

using namespace std;



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


    ll res = 0;
    rep(i, n-1){
        ll costa = a * (x[i+1] - x[i]);
        if(costa < b)    res += costa;
        else             res += b;
    }

    cout << res << endl;


    return 0;
}


Measured memory_bytes: 1024
'use strict'
const main = (input) => {
  const arr = input.split(' ').map(m => Number(m))
  const sum = arr.reduce((p, c) => p * c)
  console.log((sum === 175) ? 'YES' : 'NO')
}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 21064
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 2e5+9;
vector<int> adj[N];
int vis[N];


int dfs(int x) {
    int cnt = 1;
    vis[x] = 1;
    for(int y: adj[x]) {
        if(!vis[y]) {
            cnt += dfs(y);
        }
    }
    return cnt;
}
int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n,m;
    cin>>n>>m;
    for(int i=0;i<m;++i) {
        cin>>a>>b;
        a--, b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int mx = 0;
    for(int i=0;i<n;++i) {
        int p = 0;
        if(!vis[i]) p = dfs(i);
        // cout<<p<<endl;
        mx = max(mx, p);
    }
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 24680
def main():
    from collections import Counter
    from itertools import combinations

    n, *s = map(lambda x: str(x)[0], open(0).read().split())
    c = Counter(s)

    m = [v for k, v in c.items() if k in ["M", "A", "R", "C", "H"]]
    ans = 0
    if len(m) >= 3:
        for (i, j, k) in combinations(m, 3):
            ans += i * j * k

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11412
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int r;
	cin >> r;
	float area = 2.0 * (22.0/7.0) * (r * 1.0);
	cout << fixed << setprecision(5) << area;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
double fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
int main(){
    ll n, ans; cin >> n;
    ans = fib(n);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3264
#include<stdio.h>
int main(void)
{
	int sh,sm,ss;
	int th,tm,ts;
	int zh,zm,zs;
	int gs,gs2,gs3;
	
	while(scanf("%d %d %d %d %d %d",&sh,&sm,&ss,&th,&tm,&ts)!=EOF){
		
		gs=sh*3600+sm*60+ss;
		gs2=th*3600+tm*60+ts;
		gs3=gs2-gs;
		zh=gs3/3600;
		gs3=gs3%3600;
		zm=gs3/60;
		zs=gs3%60;
		
		printf("%d %d %d\n",zh,zm,zs);
	}
	return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
typedef long long ll;
#define X first
#define Y second
#define dbl double
#define forn(i,n,k) for(int i=0;i<n;i=i+k)
#define forpn(p,n,k) for(int i=p;i<n;i+=k)

using namespace std;
long long gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++)
    {  if(i%k==0)
      {cout<<"OK";return 0;}}
  	cout<<"NG";return 0;

        
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>

using namespace std;

int main(void){

  // Input
  int N;
  cin >> N;
  vector<long long> A;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    A.push_back(x);
  }

  // Check
  long long money = 1000;
  long long stock = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] < A[i+1] && stock == 0) {
      stock = money / A[i];
      money = money % A[i];
    }
    else if (A[i] > A[i+1]) {
      money += stock * A[i];
      stock = 0;
    }
  }
  cout << money << endl;

}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    ll sol = n;
    for (int i = 1; i <= sqrt(n); ++i)
        if (n % i == 0)
            sol = min(sol, i + n / i - 2);
    cout << sol;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c;
	long d=1000000,e=-1000000,f=0;
	scanf("%d",&a);
	for(b=0;b<a;b++){
		scanf("%d",&c);
		if(d>c){
			d=c;
		}
		if(e<c){
			e=c;
		}
		f+=c;
	}
	printf("%ld %ld %ld\n",d,e,f);
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>

using namespace std;

class Solution {
public:
	/* time: O(n + q), space: O(n), where n = # of players, q = # of questions */
	vector<bool> attackSurvival(int n, int k, const vector<int>& questions) {
		const int q = questions.size();
		vector<int> nCorrect(n);
		for (int player : questions)
			++nCorrect[player - 1];

		vector<bool> ans(n);
		for (int i = 0; i < n; ++i)
			ans[i] = (k - (q - nCorrect[i])) > 0;
		return ans;
	}
};

int main() {
	int n, k, q;
	cin >> n >> k >> q;

	vector<int> questions(q);
	for (int i = 0; i < q; ++i)
		cin >> questions[i];

	Solution sol;
	vector<bool> ans = sol.attackSurvival(n, k, questions);
	for (int i = 0; i < n; ++i)
		cout << (ans[i] ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(s[i+1]==s[i]){
            s[i]='0';
        }
        
    }
    int count=0;
    for(int j=0;j<n;j++){
        if(s[j]!='0'){
            count++;
        }
    }
    printf("%d",count);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a = str(input())
b = "AC"
if (a[0:1] != 'A'): b = 'WA'
if (not a[1:2].islower()): b = 'WA'
if (a[2:-1].count('C') != 1): b = 'WA'
if (not a[2:-1].replace('C', 'c').islower()): b = 'WA'
if (not a[-1].islower()): b = 'WA'

print(b)

Measured memory_bytes: 3060
// Author -- xyr2005

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed+=0x71dad4bfu,seed^=seed>>5,seed+=0xc6f74d88u,seed^=seed<<17,seed+=0x25e6561u,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=3005;
const int mod=1000000007;
template<typename _Tp1,typename _Tp2>Finline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>Finline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int dp[N<<1][N][2];
int sum[N];
int main()
{
	int n,m,k;read(n,m,k);
	int limit=max(n,m)*2;
	dp[0][0][0]=1;
	int ans=0;
	for(int i=1;i<=limit;++i)
	{
		for(int j=0;j<=n;++j)
		{
			sum[j]=dp[i-1][j][0],add(sum[j],dp[i-1][j][1]);
			add(sum[j],sum[j-1]);
		}
		for(int j=0;j<=n;++j)
		{
			dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
			if(j) dp[i][j][1]=(sum[j-1]-(j>=k?sum[j-k]:0)+mod)%mod;
		}
		for(int j=0;j<=n;++j) if(j%(k-1)==n%(k-1)&&(i*(k-1)-j+1)%(k-1)==m%(k-1)&&i*(k-1)-j+1<=m) add(ans,dp[i][j][1]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 82228
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Edge{
	Edge(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};

enum Type{
	from_S,
	from_G,
};

struct Info{
	Info(int arg_node_id,int arg_sum_cost){
		node_id = arg_node_id;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{ //総コストの昇順(PQ)
		return sum_cost > arg.sum_cost;
	}
	int node_id,sum_cost;
};

int N,M,P;
int C[100001];
int min_dist[100][2];
bool calculated[100][2];
double path_num[100][2],ans[100];
vector<Edge> G[100];
vector<int> DAG_G[100],rev_DAG_G[100];

void dijkstra(Type type,int start){

	for(int i = 0; i < N; i++)min_dist[i][type] = BIG_NUM;
	min_dist[start][type] = 0;

	priority_queue<Info> Q;
	Q.push(Info(start,0));

	int next_node,next_cost;

	while(!Q.empty()){

		if(Q.top().sum_cost > min_dist[Q.top().node_id][type]){
			Q.pop();
		}else{

			for(int i = 0; i < G[Q.top().node_id].size(); i++){
				next_node = G[Q.top().node_id][i].to;
				next_cost = Q.top().sum_cost+G[Q.top().node_id][i].cost;

				if(min_dist[next_node][type] > next_cost){
					min_dist[next_node][type] = next_cost;
					Q.push(Info(next_node,next_cost));
				}
			}

			Q.pop();
		}
	}
}

//from_S:あるノードからゴール方向への経路数、from_G:あるノードからスタート方向への経路数
double recursive(Type type,int node_id,int goal){

	if(calculated[node_id][type])return path_num[node_id][type];

	if(node_id == goal)return 1.0;

	if(type == from_S){

		for(int i = 0; i < DAG_G[node_id].size(); i++){
			path_num[node_id][type] += recursive(type,DAG_G[node_id][i],goal);
		}

	}else{ //type == from_G

		for(int i = 0; i < rev_DAG_G[node_id].size(); i++){
			path_num[node_id][type] += recursive(type,rev_DAG_G[node_id][i],goal);
		}
	}
	calculated[node_id][type] = true;

	return path_num[node_id][type];
}

void func(){

	for(int i = 0; i < N; i++){
		G[i].clear();
		DAG_G[i].clear();
		rev_DAG_G[i].clear();
	}

	int from,to,cost;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d %d",&from,&to,&cost);
		G[from].push_back(Edge(to,cost));
		G[to].push_back(Edge(from,cost));
	}

	for(int i = 0; i < P; i++)scanf("%d",&C[i]);

	dijkstra(from_S,0);
	dijkstra(from_G,N-1);

	int next_node;
	//最短経路DAGを作る
	for(int i = 0; i < N; i++){
		for(int k = 0; k < G[i].size(); k++){
			next_node = G[i][k].to;
			if(min_dist[i][from_S]+G[i][k].cost+min_dist[next_node][from_G] == min_dist[N-1][from_S]){ //最短経路上の辺
				DAG_G[i].push_back(next_node);
				rev_DAG_G[next_node].push_back(i);
			}
		}
	}

	for(int i = 0; i < N; i++){
		for(int k = 0; k < 2; k++){
			calculated[i][k] = false;
			path_num[i][k] = 0;
		}
	}

	//再帰的に、そのノードを経由する経路数を計算する
	recursive(from_S,0,N-1);
	recursive(from_G,N-1,0);

	for(int i = 0; i < N; i++){
		ans[i] = path_num[i][from_G]*path_num[i][from_S]/path_num[0][from_S];
	}

	for(int i = 0; i < P; i++){
		printf("%.10lf\n",ans[C[i]]);
	}
	printf("\n");
}

int main(){

	while(true){
		scanf("%d %d %d",&N,&M,&P);
		if(N == 0 && M == 0 && P == 0)break;

		func();
	}

	return 0;
}



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

double	calc_root_dist(int N, const vector<pair<double, double>> &dist,
			const vector<int> &root)
{
	double x1, y1, x2, y2;
	tie(x1, y1) = dist.at(root.at(0));
	double r_dist = 0;
	for (int i = 1; i < N; ++i) {
		tie(x2, y2) = dist.at(root.at(i));
		r_dist += hypot(x2 - x1, y2 - y1);
		x1 = x2;
		y1 = y2;
	}
	return r_dist;
}

int	main()
{
	int	N;
	cin >> N;
	double x, y;
	vector<pair<double, double>> dist(N);
	for (int i = 0; i < N; ++i) {
		cin >> x >> y;
		dist.at(i) = make_pair(x, y);
	}
	vector<int> root(N);
	iota(root.begin(), root.end(), 0);
	double ave = 0, tmp;
	int	cnt = 0;
	do {
		tmp = calc_root_dist(N, dist, root);
		ave = (ave * cnt + tmp) / (cnt + 1);
		++cnt;
	} while (next_permutation(root.begin(), root.end()));
	cout << setprecision(8) << ave << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#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--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    ll a = A;

    map<int,bool>mpa;

    for(int i = 0;i < a;i++)
        mpa[i] = false;

    bool fla = false;

    while(true){
        if(a % B == C){
            fla = true;
            break;
        }else if(mpa[a%B] == true){
            break;
        }else{
            mpa[a%B] = true;
            a += A;    
        }
    }

    if(fla)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int num[1000000] = { 0 };
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int i = 1;
	while (true) {
		if (num[A * i % B] != 0) {
			cout << "NO";
			return 0;
		}
		if (A * i % B == C) {
			cout << "YES";
			return 0;
		}
		else {
			num[A * i % B]++;
		}
		i++;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<int, int> par;

ll sol,Dp[maxn],ant[maxn];
char s[maxn];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> s;

    int N=strlen(s) , M=2019;

    ant[0]=1;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++)
           Dp[ (j*10+ s[i]-'0') % M ]+=ant[j];
        sol+=Dp[0];
        for(int j=0;j<M;j++)
            ant[j] = Dp[j] ,Dp[j]=0;
        ant[0]++;
    }
    cout << sol;


}


Measured memory_bytes: 3876
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
# from collections import Counter

import numpy as np
# import scipy as scp

# 入力の受け取り
n,k = map(int,input().split())
# 配列入力の受け取り
arrh = np.array(input().split(),dtype=np.int64)

filter = arrh >= k
ans = len(arrh[filter])

print(ans)

Measured memory_bytes: 21172
b=input()
l=[]
i=0
num=0
while i<len(b):
    if b[i]=="A" or b[i]=="C" or b[i]=="G" or b[i]=="T":
        num+=1
    else:
        l.append(num)
        num=0
    i+=1
    l.append(num)
print(max(l))

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
    char s[4];
    char t;
    int ct = 0;


    scanf("%s", s);

    for (int k = 0; k < 3; k++) {
        t = s[k];
        for (int i = k+1; i < 4; i++) {
            if (t == s[i]) {
                ct++;
            }
        }
    }
    if (ct == 2) {
        puts("Yes");
    } else {
        puts("No");
    }

    return 0;

}

Measured memory_bytes: 128
def solve(a, b, c):
    # 方針
    # 1. 2番目に大きな数字が1番大きな数字と一致するまで、1×2の操作をする
    # 2. 3番目に大きな数字が1番大きな数字以上になるまで、2×1の操作をする
    # 3. 数字のずれが生じるなら1×2の操作で調整する
    l = sorted((a, b, c))
    d1, d2 = l[2] - l[0], l[2] - l[1]
    return d2 + (d1 - d2 + 1) // 2 + (0 if (d1 - d2) % 2 == 0 else 1)

_a, _b, _c = list(map(int, input().split()))
print(solve(_a, _b, _c))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  string a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  int ans=0;
  for(int i=0;i<n;i++)
    {
      if(a[i]==b[i]&& b[i]==c[i])
	{
	  continue;
	}
      else if(a[i]!=b[i] && b[i]!=c[i] && c[i]!=a[i])
	{
	  ans+=2;
	}
      else
	{
	  ans+=1;
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var takoyakis = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();

            var result = 0;
            for (var i = 0; i < n; i++)
            {
                for (var j = i + 1; j < n; j++)
                {
                    result += takoyakis[i] * takoyakis[j];
                }
            }

            Console.WriteLine(result);
        }

    }
}

Measured memory_bytes: 28252
#include<bits/stdc++.h>
#define ll long long 
#define ld long double 
using namespace std ;
 int main(){
	ld a ; 
	cin>> a ;
	 ld l = a/3 ; 
	 cout<<fixed<<setprecision(15)<<(l * l *l )<<endl;
	 
	 
	 
	 
 }




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;

    ll ans = n;
    ll flag = 0;
    for(ll i=1;i<n;++i){
        if(s[i-1] == s[i]){
            flag++;
        }else{
            ans -= flag;
            flag = 0;
        }
    }
    ans -= flag;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    mapOf(
        1 to 1,
        2 to 1,
        3 to 1,
        4 to 1,
        5 to 1,
        6 to 1,
        7 to 1,
        8 to 1,
        9 to 1,
        10 to 1,
        12 to 1,
        14 to 1,
        16 to 1,
        18 to 1,
        15 to 1,
        21 to 1,
        24 to 1,
        27 to 1,
        20 to 1,
        28 to 1,
        32 to 1,
        36 to 1,
        25 to 1,
        30 to 1,
        35 to 1,
        40 to 1,
        45 to 1,
        42 to 1,
        48 to 1,
        54 to 1,
        49 to 1,
        56 to 1,
        63 to 1,
        64 to 1,
        72 to 1,
        81 to 1
    )[n]?.let {
        println("Yes")
    } ?: println("No")
}

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

using namespace std;

const int mod = 1e9 + 7;

int main()
{
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
    {
        cin>>v[i];
    }

    vector<int> suffix(n);
    suffix[n-1] = v[n-1];
    for(int i = n-2;i>=0;i--)
    {
        suffix[i] = (v[i] + suffix[i+1]) % mod;
    }

    int total = 0;
    for(int i = 0;i<n-1;i++)
    {
        int t = (long long) suffix[i+1] * v[i] % mod;
        total = (total + t) % mod;
    }

    cout<<total<<"\n";

    return 0;
}


Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;

int main(){
	int a,b;cin>>a>>b;
	if(a+b==3){
		cout<<3<<endl;
	}else if(a+b==5){
		cout<<1<<endl;
	}else{
		cout<<2<<endl;
	}
	return 0;
}

Measured memory_bytes: 3564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        int[] counts = new int[26];
        foreach (var c in s)
        {
            int index = c - 'a';
            counts[index]++;
        }

        for (int i = 0; i < 26; i++)
        {
            if (counts[i] == 0)
            {
                Console.WriteLine((char)('a' + i));
                return;
            }
        }

        Console.WriteLine("None");
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 11616
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	ll cnt = 0;
	string last;
	string cur;
	for (auto ite = begin(s); ite != end(s); ite++) {
		cur += *ite;
		if (cur != last) {
			last = cur;
			cur = "";
			cnt++;
		}
	}
	std::cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 720
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,M,K = inputIL()

friend = [[] for _ in range(N)]
friend_edges = []
for _ in range(M):
  a, b = inputIL()
  friend_edges.append((a-1, b-1))
for a, b in friend_edges:
  friend[a].append(b)
  friend[b].append(a)
  
block = [[] for _ in range(N)]
block_edges = []
for _ in range(K):
  a, b = inputIL()
  block_edges.append((a-1, b-1))
for a, b in block_edges:
  block[a].append(b)
  block[b].append(a)

  
cluster = [None for i in range(N)]
count = []

n = -1
for v in range(N):
  if cluster[v] == None:
    n += 1
    q = deque([v])
    cluster[v] = n
    c = 1
    while q:
      i = q.popleft()
      for j in friend[i]:
        if cluster[j] == None:
          cluster[j] = n
          c += 1
          q.append(j)
    count.append(c)

ans = [count[cluster[i]]-1 for i in range(N)]

for a, b in friend_edges:
  if cluster[a]==cluster[b]:
    ans[a] -= 1
    ans[b] -= 1

for a, b in block_edges:
  if cluster[a]==cluster[b]:
    ans[a] -= 1
    ans[b] -= 1
  

print(*ans,sep=" ")

Measured memory_bytes: 117548
def factorize(n):
    res = []
    i = 2
    while i * i <= n:
        cnt = 0
        while n % i == 0:
            cnt += 1
            n //= i
        if cnt > 0:
            res.append([i, cnt])
        i += 1
    if n != 1:
        res.append([n, 1])
    return res

n = int(input())
nlist = factorize(n)
ans = 0
for k, v in nlist:
    i = 1
    while v >= i:
        v -= i
        i += 1
    ans += i-1
print(ans)

Measured memory_bytes: 9212
N = int(input())
A = list(map(int,input().split()))

c = 0
l = 0
ans = 0

for r in range(N):
    a = A[r]
    if c&a:
        while c&a:
            c = c^A[l]
            l += 1
    c = c^a
    ans += r-l+1

print(ans)


Measured memory_bytes: 24712
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;


const ll mod = 1000000007;
ll sumbefcol[200500];
ll c[200500];
ll dp[200500];

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ptr = 0;
    for (int i = 0; i < n; ++i) {
        cin >> c[ptr];
        if (ptr > 0 && c[ptr] == c[ptr - 1]) {
            continue;
        }
        ++ptr;
    }
    n = ptr;
    dp[0] = 1;
    for (int i = 1; i <= n; ++i) {
        dp[i] = (sumbefcol[c[i - 1]] + dp[i - 1]) % mod;
        sumbefcol[c[i - 1]] = (sumbefcol[c[i - 1]] + dp[i - 1]) % mod;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4992
a, b = gets.split.map(&:to_i)
s = gets.chomp.split("")

flag = 1
s.each_with_index { |value, index|
  if index < a || index > a
    unless value =~ /^[0-9]+$/
      flag = 0
      break
    end
  end

  if index == a
    unless value == "-"
      flag = 0
      break
    end
  end
}

puts flag == 1 ? "Yes" : "No"

Measured memory_bytes: 1788
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18

void calcPoint(pair<double, double> &P, double r, double theta) {
    P.first = r * cos(theta);
    P.second = r * sin(theta);
    return;
}

int main(){

    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double thetaA = 2. * M_PI * (H / 12. + (M / 60.) / 12.);
    double thetaB = 2. * M_PI * (M / 60.);
    pair<double, double> PA;
    pair<double, double> PB;
    calcPoint(PA, A, thetaA);
    calcPoint(PB, B, thetaB);

    double dx = (PA.first - PB.first) * (PA.first - PB.first);
    double dy = (PA.second - PB.second) * (PA.second - PB.second);
    double ans = sqrt(dx + dy);

    cout << fixed << setprecision(20);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4100
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] num = new int[N];
		int add=0;
		for (int i=0;i<N ;i++ ) {
			num[i]=scan.nextInt();
			add+=num[i];
		}

		double hei = (double)add/N;

		double min = 200;
		int mem = 0;
		double mai = 0;
		for (int i=0;i<N ;i++ ) {
			mai = hei-num[i];
			if(mai<0){mai*=-1;}
			if(mai<min){
				min=mai;
				mem=i;
			}
		}
		System.out.println(mem);

	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1000000007;
ll dp[101][100003];
int w[101];
ll v[101];
int N,W;
ll dpf(int N,int W)
{
  if      (dp[N][W]!=-1) {return dp[N][W];                                      }
  if      (N==0||W==0  ) {return dp[N][W]=0;                                    }
  else if (w[N]<=W     ) {return dp[N][W]=max(dpf(N-1,W),v[N]+dpf(N-1,W-w[N])); }
  else if (w[N]>W      ) {return dp[N][W]=dpf(N-1,W);                           }
  return 0;
}
int main()
{
 memset(dp,-1,sizeof(dp));
 cin>>N>>W;
 for(int i=1;i<=N;i++)
 {
     cin>>w[i]>>v[i];
 }
 cout<<dpf(N,W);
return 0;
}


Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n==25)
    cout<<"Christmas";
  else if(n==24)
    cout<<"Christmas Eve";
  else if(n==23)
    cout<<"Christmas Eve Eve";
  else
    cout<<"Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a>b){
		a+=b;
		b=a-b;
		a=a-b;
	}
	if(b>c){
		b+=c;
		c=b-c;
		b=b-c;
	}
	if(a>b){
		a+=b;
		b=a-b;
		a=a-b;
	}
	cout<<a<<' '<<b<<' '<<c<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>

int main() {
    int i, N, *h, *height, cnt = 0, isend = 0;
    if (scanf("%d%*c", &N) == -1) return -1;
    h = (int *)malloc(sizeof(int) * N);
    height = (int *)malloc(sizeof(int) * N);
    if (!h) return -1;
    for (i = 0; i < N; i++) {
        if (scanf("%d%*c", &h[i]) == -1) return -1;
        height[i] = 0;
    }
    while (isend == 0) {
        isend = 1;
        for (i = 0; i < N; i++) {
            if (height[i] < h[i]) {
                height[i]++;
                if (i == 0 || (i != 0 && height[i] != height[i-1])) cnt++;
            }
        }
        for (i = 0; i < N; i++) if (height[i] != h[i]) isend = 0;
    }
    printf("%d\n", cnt);
    free(h); free(height);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0

 int main()
 {
 	int a;
 	cin >> a;
 	if(a%111==0){
 		cout << a << endl;
 	}else{
 		cout << (a/111+1)*111 << endl;
 	}
 }

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        S: String,
        T: String,
    };
    println!("{}", T + &S);
}


Measured memory_bytes: 4352
n = int(input())
arr = [x for x in list(map(int, input().split()))]

count = 0
for i in range(len(arr)):
  mini = i
  for j in range(i, len(arr)):
    if arr[j] < arr[mini]:
      mini = j
  if mini != i:
    arr[mini], arr[i] = arr[i], arr[mini]
    count += 1

print (" ".join([str(x) for x in arr]))
print (count)


Measured memory_bytes: 5608
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF /*1000000007*/ 1000000000000000003
#define MOD 1000000007

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };

vector<edge>tree[100010];
vector<P> connect[100005];
long long cost[100005];

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

int main() {

	ll N;
	cin >> N;

	ll m = (ll)(sqrt(N));
	vector<ll>waru;
	for (ll i = 1; i <= m;++i) {
		if (N%i == 0) {
			waru.push_back(i);
		}
	}
	ll ans = INF;
	for (int i = 0; i < waru.size();++i) {
		ll target = waru[i];
		ans = min(ans, (target-1)+((N/target)-1));
	}
	cout << ans << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

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 * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, x;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  mii m;
  fi(0, n) {
    cin >> x;
    m[x]++;
  }
  for(pii x: m) {
    // cout << x.first << "," << x.second << endl;
    int num = x.first;
    int cnt = x.second;
    if(cnt > num)
      ans += cnt - num;
    else if(cnt < num)
      ans += cnt;
  }
  cout << ans << endl;
  return 0;
}



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

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int ans = 0;

    // aとbを直接買ったときのお金
    int abpizza = (a * x) + (b * y);

    // cだけを買った時の金額
    int cpizza = c * std::max(x, y) * 2;

    int xymin = std::min(x, y);
    int x2 = x - xymin;
    int y2 = y - xymin;
    int abcpizza = a * x2 + b * y2 + c * (xymin * 2);
    
    ans = std::min(abpizza, std::min(cpizza, abcpizza));

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500005];
ll x[800005],y[800005],z[900005];
bool animal[500005];

int main(){	
	cin>>n;
	cin>>s;
	while(b<4){
		b++;
		//deba(b);
		animal[0]=b%2;
		animal[1]=(b/2)%2;
		for(i=1;i<n;i++){
			if(animal[i] && s[i]=='o'){
				animal[i+1] = animal[i-1];
			}else if(animal[i] && s[i]=='x'){
				animal[i+1] = !animal[i-1];
			}else if(!animal[i] && s[i]=='o'){
				animal[i+1] = !animal[i-1];
			}else{
				animal[i+1] = animal[i-1];
			}
		}
		//for(i=0;i<=n;i++){
		//	if(animal[i])pu('S');
		//	if(!animal[i])pu('W');
		//}
		//el;
		a=0;
		if(animal[0] == animal[n])a++;
		if(s[0]=='o' && animal[1]==animal[n-1] && animal[0])a++;
		if(s[0]=='x' && animal[1]!=animal[n-1] && animal[0])a++;
		if(s[0]=='o' && animal[1]!=animal[n-1] && !animal[0])a++;
		if(s[0]=='x' && animal[1]==animal[n-1] && !animal[0])a++;
		//deba(a);
		if(a<=1){
			continue;
		}else{
			for(i=0;i<n;i++){
				if(animal[i]){
					pu("S");
				}else{
					pu("W");
				}
			}
		}
		el;
		return 0;
	}
	p(-1);
	
	//p(ans);
	return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>

long long min(long long x, long long y)
{
  return x < y ? x : y;
}

int main(void)
{
  long long n, a, b;
  
  scanf("%lld%lld%lld", &n, &a, &b);
  
  printf("%lld\n", n / (a+b) * a + min(a, n % (a+b)));
  
  return 0;
}


Measured memory_bytes: 128
N = int(input())
H = tuple(map(int, input().split()))

maximum = 0
counter = 0

for i in range(N-1):
    if H[i] >= H[i+1]:
        counter += 1
        if counter > maximum:
            maximum = counter
    else:
        if counter > maximum:
            maximum = counter
        counter = 0

print(maximum)


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;
  vector<int> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  sort(va.begin(), va.end(), greater<int>());
  int cnt1 = 0, cnt2 = 0;
  for (int i = 0; i < va.size(); ++i) {
    if (i % 2 == 0) {
      cnt1 += va[i];
    } else {
      cnt2 += va[i];
    }
  }

  cout << cnt1 - cnt2 << '\n';
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        m: usize,
        aaa: [String; n],
        bbb: [String; m],
    };
    for ai in 0usize..=(n - m) {
        for aj in 0usize..=(n - m) {
            let tf = bbb
                .iter()
                .enumerate()
                .all(|(bi, bb)| bb == &aaa[ai + bi][aj..(aj + m)]);
            if tf {
                println!("Yes");
                return;
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 2116
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
for(var i=0;i<Arr.length;i++){
   var L=Arr[i]-0;
   if(L==0)break;
   var sum=0;
   for(var j=1;j<=12;j++){
      var arr=Arr[i+j].split(" ").map(Number);
      sum+=arr[0]-arr[1];
      if(sum>=L)break;
   }
   (sum>=L)?console.log(j):console.log("NA");
   i=i+12;
}

Measured memory_bytes: 11336
import java.util.*;
import java.math.BigDecimal;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        BigDecimal b1 = new BigDecimal(a);
        BigDecimal b2  = new BigDecimal(b);
         BigDecimal c = b1.multiply(b2);
         BigDecimal d = c.setScale(0,BigDecimal.ROUND_DOWN);
        System.out.println(d);
    }
}


Measured memory_bytes: 35912