akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;

long long h[30008] = { 0 };
long le[15] = { 0 };
long cnt[15] = { 0 };
long ri[15] = { 0 };
int main()
{
	long long n;
	cin >> n;
	if (n < 2|| n % 2 == 1) {
		cout << 0 << endl; 
		return 0;
	}
	else{
		long long ans = 0;
		ans += n / 10;
		long long k = n / 10;
		while (k >= 5) {
			k = k / 5;
			ans += k;
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 256
import re
s = input()
t = input()
 
s = s.replace("?", ".")[::-1]
t = t[::-1]
 
for i in range(len(s) - len(t) + 1):
  if re.match(s[i:i+len(t)], t):
    s = s[:i].replace(".","a") + t + s[i+len(t):].replace(".","a")
    print(s[::-1])
    break
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3188
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String S = sc.next();

        final int N = sc.nextInt();
        final int A = sc.nextInt();
        // final long B = sc.nextLong();
        // final String s = sc.next();
        // final String b = sc.next();

        int oddNum = 0;
        int evenNum = 0;
        for (int i = N - 1; i > 0; i--) {
            oddNum += i;
        }
        for (int i = A - 1; i > 0; i--) {
            evenNum += i;
        }
        System.out.println(oddNum + evenNum);

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

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

using namespace std;
typedef long long ll;
const int MAXN=2e5+10,MAXM=4010<<1,MOD=1e9+7;
ll res,fac[MAXM],inv[MAXM],dp[MAXM][MAXM],ret;
int n,a[MAXN],b[MAXN],mx,mx_sum;

ll quick_pow(ll a,ll b)
{
	for(ret=1;b;b>>=1,(a*=a)%=MOD)
		if(b&1) (ret*=a)%=MOD;
	return ret;
}
ll C(ll a,ll b)
{return fac[a]*inv[a-b]%MOD*inv[b]%MOD;}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&a[i],&b[i]),
		mx=max(mx,max(a[i],b[i])),mx_sum=max(mx_sum,a[i]+b[i]);
	
	for(int i=1;i<=n;i++)
		dp[-a[i]+mx][-b[i]+mx]++;
	for(int i=0;i<=(mx<<1);i++)
		for(int j=0;j<=(mx<<1);j++)
			if(dp[i][j]) (dp[i+1][j]+=dp[i][j])%=MOD,(dp[i][j+1]+=dp[i][j])%=MOD;
	for(int i=1;i<=n;i++) (res+=dp[a[i]+mx][b[i]+mx])%=MOD;
	
	mx_sum<<=1;fac[0]=1;
	for(int i=1;i<=mx_sum;i++) fac[i]=fac[i-1]*i%MOD;
	inv[mx_sum]=quick_pow(fac[mx_sum],MOD-2);
	for(int i=mx_sum;i;i--) inv[i-1]=inv[i]*i%MOD;
	
	for(int i=1;i<=n;i++)
		res=(res-C((a[i]+b[i])<<1,a[i]<<1)+MOD)%MOD;
	res=(res*(MOD+1)>>1)%MOD;
	printf("%lld",res);
	return 0;
}
//×éºÏÊýÇóºÍ->Ó³ÉäÖÁÂ·¾¶ÌõÊý 

Measured memory_bytes: 254080
#include <bits/stdc++.h>
#include <unordered_set>
#include <stdio.h>

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define f first
//#define s second
#define ll long long
#define ull unsigned long long
#define endl "\n"
#define PI 3.141592653589793
#define vi vector<int>
#define vll vector<long long>
//#define p pair<int,int>
const ll MOD = 1000000007;
inline double degcos(double ang) {return cos(ang*PI/180);}
inline double degsin(double ang) {return sin(ang*PI/180);}
#define rep(i,j,k,in) for (int i = j; i < k; i += in)
#define repr(i,j,k,in) for (int i = j; i > k; i -= in)
#define repll(i,j,k,in) for (ll i = j; i < k; i += in)
#define repllr(i,j,k,in) for (ll i = j; i > k; i -= in)

/*---END OF TEMPLATE---*/

int N;
const int MAXN = 25,MAXSZ = 1 << 21 + 1;
int arr[MAXN][MAXN];
int dp[MAXSZ];


int main() {
    scan(N);
    int powN = 1 << N; 
    rep(i,0,N,1) {
        rep(j,0,N,1) {
            scan(arr[i][j]);    
        }
    }
    dp[0] = 1;
    rep(powNum,0,powN-1,1) {
        int m = __builtin_popcount(powNum);
        rep(i,0,N,1) {
            if (arr[m][i] && !(powNum & (1 << i))) {
                dp[powNum | (1 << i)] = (dp[powNum | (1 << i)] + dp[powNum]) % MOD; 
            }
        }
        
    }
    cout << dp[powN-1];


}

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

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long long ,long long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin()
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin()
#define ct(i) cout<< i << "\n"
#define sv(v) sort(v.begin(),v.end())
#define mod 1000000007
#define M 100005
#define endl "\n"

void solve(){
    ll n,x,y,ans=999999,m;
    string s,t;
    cin>>t>>s;
    n = s.size();
    m = t.size();
    for(int i=0;i<=m-n;i++){
        int c=0;
        for(int j=0;j<n;j++){
            if(s[j]!=t[i+j]) c++;
        }
        ans = min(ans,(ll)c);
    }
    cout<<ans<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int q;
    //cin>>q; while(q--)
        solve();
    return 0;
}


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

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

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

	int k;
	cin >> k;
	int ans = 0;
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			for(int p=1; p<=k; p++){
				ans += gcd(i,gcd(j,p));
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int a,b;
  cin >> a >> b;
  cout << a + b / 2 << endl;;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// vector -> min/max({vector}) 
// 配列   -> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(S.begin(),S.end())
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならv.begin(),v.end()
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
typedef pair<int,int> P;
const int inf = 10e7;
#define Maxw 1000
#define Maxh 1000
int h,w;


bool flag=0;
int dx[2]={0,1};
int dy[2]={1,0};

int main(){
  int step[Maxh][Maxw];char maze[Maxh][Maxw];
  cin>>h>>w;
  string s;
for (int i=0;i<h+2;i++){
    for (int j=0;j<w+2;j++){
    step[i][j]=inf;}
  }step[1][1]=0;
  for (int i=0;i<w+2;i++){maze[0][i]='!';maze[h+1][i]='!';}
  for (int i=0;i<h+2;i++){maze[i][0]='!';maze[i][w+1]='!';}
  for (int H=1;H<h+1;H++){cin>>s;rep(j,w){maze[H][j+1]=s[j];}maze[H][0]='!';maze[H][w+1]='!';}
rep(i,h){
  rep(j,w){
    rep(k,2){if (maze[i+1+dx[k]][j+1+dy[k]]!='!'){
      step[i+1+dx[k]][j+1+dy[k]]=min(step[i+1+dx[k]][j+1+dy[k]],step[i+1][j+1]+(maze[i+1+dx[k]][j+1+dy[k]]=='#'&&maze[i+1][j+1]=='.'? 1:0));}}}}
int ans=0;if (maze[1][1]=='#')ans++;

  cout<<step[h][w]+ans<<endl;
}


Measured memory_bytes: 2560
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  ll ch[26];
  fill(ch,ch+26,400000);
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
    ll tp[26];
    fill(tp,tp+26,0);
    for(char c:s[i]){
      tp[c-'a']++;
    }
    for(int i=0;i<26;i++){
      ch[i] = min(ch[i],tp[i]);
    }
  }
  for(int i=0;i<26;i++){
    for(int j=0;j<ch[i];j++){
      cout << (char)('a'+i);
    }
  }
  cout << endl;
}


Measured memory_bytes: 256
#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 <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL INF = 1e12;

VL to[2505];
VL rto[2505];
bool visited[2505]={0};
set<LL> to_set;
set<LL> rto_set;

void dfs(LL x) {
    if(visited[x])return;
    visited[x] = true;
    to_set.insert(x);
    EACH(itr, to[x]) {
        dfs(*itr);
    }
}

void rdfs(LL x) {
    if(visited[x])return;
    visited[x] = true;
    rto_set.insert(x);
    EACH(itr, rto[x]) {
        rdfs(*itr);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,m,p;
    cin>>n>>m>>p;
    vector<tuple<LL,LL,LL>> link(m);
    REP(i,m){
        LL a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        link[i] = make_tuple(a, b, -c + p);
        to[a].PB(b);
        rto[b].PB(a);
    }

    VL d(n, INF);
    d[0] = 0;
    REP(i,n-1){
        REP(j,m){
            LL u,v,c;
            tie(u,v,c) = link[j];
            d[v] = min(d[v], d[u] + c);
        }
    }

    dfs(0);
    REP(i,2505)visited[i]=false;
    rdfs(n-1);
    set<LL> product;
    EACH(itr, to_set){
        if(EXIST(rto_set, *itr)){
            product.insert(*itr);
        }
    }


    bool solved = true;
    REP(i,m){
        LL u,v,c;
        tie(u,v,c) = link[i];
        if(!EXIST(product, u))continue;
        if(!EXIST(product, v))continue;
        if(d[v] > d[u] + c) {
            solved = false;
            break;
        }
    }

    if(solved) {
        PUTS(max((LL)0, -d[n-1]));
    }
    else{
        PUTS(-1);
    }
}


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

using namespace std;

int H, W;
string s[101];

int main() {

        cin >> H >> W;

        for(int i = 0; i < H; i++)
            cin >> s[i];

        bool white[100][100] = {false};
    
        for(int i = 0; i < H; i++){
            
            bool can = true;

            for(int j = 0; j < W; j++){

                if(s[i][j] == '#'){
                    can = false;
                    break;
                }
            }

            if(can){
                for(int k = 0; k < W; k++){
                    white[i][k] = true;
                }
            }
        }

    
        for(int i = 0; i < W; i++){
            
            bool can = true;

            for(int j = 0; j < H; j++){

                if(s[j][i] == '#'){
                    can = false;
                    break;
                }
            }

            if(can){
                for(int k = 0; k < H; k++){
                    white[k][i] = true;
                }
            }
        }

       

        for(int i = 0; i < H; i++){
            int out = 0;
            for(int j = 0; j < W; j++){
                if(!white[i][j]){
                    cout << s[i][j];
                    out++;
                }
            }
            if(out)
                cout << '\n';
        }

}



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

#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int a, b;
    cin >> a >> b;
    if (max(a,b) <= 8) cout << "Yay!";
    else cout << ":(";
}


Measured memory_bytes: 256
from math import sqrt
while True:
      n = int(input())
      if n == 0:
          break
      else:
          scores = list(map(int, input().split()))
          ave = float(sum(scores)) / n
          numerator = 0
          for s in scores:
              numerator += (s - ave)**2
          alpha = numerator / n
          print(sqrt(alpha))

Measured memory_bytes: 5700
x, y= list(input().split())

if x=='A':
    x = int(10)
elif x=='B':
    x = int(11)
elif x=='C':
    x = int(12)
elif x=='D':
    x = int(13)
elif x=="E":
     x = int(14)
else:
    x = int(15)

if y=='A':
    y = int(10)
elif y=='B':
    y = int(11)
elif y=='C':
    y = int(12)
elif y=='D':
    y = int(13)
elif y=="E":
     y = int(14)
else:
    y = int(15)

if x > y:
    print('>')
elif x < y:
    print("<")
else:
    print('=')   

Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <stdio.h>
//#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))

using namespace std;


int main(void)
{
	int A, B, C; cin >> A >> B >> C;
	int ans = B + min(A + B + 1, C);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

n = I()
P = LI()
p = int("".join(str(i) for i in P))
Q = LI()
q = int("".join(str(i) for i in Q))
T = []
for x in permutations(range(1, n+1), n):
    T.append(int("".join(str(i) for i in x)))

a = bisect_left(T, p)
b = bisect_left(T, q)
print(abs(a-b))

Measured memory_bytes: 68440
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> d(10,1);
    for(int i = 0; i < k; i++)
    {
        int num;
        cin>>num;
        d[num] = 0;
    }

    while(1)
    {
        // int temp = n;
        string s = to_string(n);
        int p = s.size();
        bool ok = true;
        for(int i = 0; i < p; i++)
            if(!d[s[i]-'0'])
                ok =false;
        if(ok)
        {
            cout<<n<<"\n";
            break;
        }
        n++;
    }
    cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ans=0;
  while(n!=0){
    ans+=n%10;
    n=n/10;
  }
  return ans;
}
int main(){
  int n;
  cin >> n;
  if(n % digit(n)==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

int main() {

    int x, y;

    cin >> x >> y;

    if ((x*2 > y)||(x*4 < y)) {
        cout << "No" << endl;
        return 0;
    }

    if (y%2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    if ((4*x - y)/2 < 0) {
        cout << "No" << endl;
        return 0;
    } else {
        cout << "Yes" << endl;
        return 0;
    }

}

Measured memory_bytes: 3632
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<int>;

ll MOD = 1000000007;
ll N, K;
vec fac(1000000);
vec finv(1000000);
vec inv(1000000);
vector<lst> edge;
ll ans = 1;


void solve(int v, int parent)
{
	int cldN = edge[v].size() - 1;
	if (cldN + 2 > K)
	{
		ans = 0;
		return;
	}

	ans *= fac[K - 2];
	ans %= MOD;
	ans *= finv[K - 2 - cldN];
	ans %= MOD;

	//cout << v << " " << ans << endl;

	for (auto u : edge[v])
	{
		if (parent == u)continue;
		solve(u, v);
	}
}


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

	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 1000000; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}

	edge = vector<lst>(N);

	for (int i = 0; i < N - 1; ++i)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		edge[a].emplace_back(b);
		edge[b].emplace_back(a);
	}

	if (edge[0].size() + 1 > K)
	{
		cout << 0 << endl;
		return 0;
	}

	ans = K;

	for (int i = 0; i < edge[0].size(); ++i)
	{
		ans *= K - 1 - i;
		ans %= MOD;
	}

	for (auto u : edge[0])
	{
		solve(u, 0);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 35072
list = [input().split()]
r = int(list[0][0])
c = int(list[0][1])
i = 0
k = 0
sum2 = 0
list3 = [0] * c
while i < r:
    sum = 0
    list2 = [input().split()]
    for j in list2[0]:
        print(j, end=' '),
        sum += int(j)
    for k in range(c):
        list3[k] += int(list2[0][k])
    print(sum)
    sum2 += sum
    i += 1
for l in list3:
    print(l, end=' ')
print(sum2)

Measured memory_bytes: 7716
#include<bits/stdc++.h>
using namespace std;
int ans,N;
void dfs(long long n,bool a,bool b,bool c){
    if(a&&b&&c&&n<=N)
    ans++;
    if(n>N)
    return;
    dfs(n*10+3,1,b,c);
    dfs(n*10+5,a,1,c);
    dfs(n*10+7,a,b,1);
}

int main(){
    cin>>N;
    ans=0;
    dfs(3,1,0,0);dfs(5,0,1,0);dfs(7,0,0,1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll cnt = 0, a;
    REP(i, n){
        cin >> a;
        if(a != i + 1) cnt++;
    }
    if(cnt <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define pb push_back
#define all(x) x.begin(),x.end()
#define asort(x) sort(all(x));
#define dsort(x) sort(all(x), greater<int>())
#define unq(x) x.erase(unique(x.begin(),x.end()),x.end())
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

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 bigmod(LL base, LL power, LL mod)
{
    if(power==0) return 1;
    else if(power%2==1)
    {
        LL value1 = base % mod; LL value2 = (bigmod(base,power-1,mod))%mod;
        return (value1*value2)%mod;
    }
    else
    {
        LL value1 = (bigmod(base,power/2,mod))%mod;
        return (value1*value1)%mod;
    }
}



int main()
{
    int n,a;
    sfi2(n,a);

    int x;
    int sum=0;
    for(int i=0; i<a; i++)
    {
        sfi(x);
        sum+= x;
    }
    if(sum>n) cout<<-1;
    else cout<<n-sum;
}


Measured memory_bytes: 3760
#include <stdio.h>

double kill(int x);

double debt(int n){

  int i = 0;
  double D = 100000;

  for(i=0;i<n;i++){
    D = D * 1.05;

    D = kill(D);

  }

  return D;

}

double kill(int x){

  if(x % 1000 != 0){
    x = x + 1000 - (x % 1000);
  }

  return x;
}

int main(){

  int n;

  scanf("%d", &n);

  printf("%d\n", (int)debt(n));

  return 0;

}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int64_t,int64_t>> ab;
    rep(i,n){
        int64_t a;
        int64_t b;
        cin>>a>>b;
        ab.push_back(make_pair(a,b));
    }
    sort(ab.begin(),ab.end());
    int64_t Sum=0;
    for(pair<int64_t,int64_t> t:ab){
        int64_t x,y;
        tie(x,y)=t;
        if(y<m){
            Sum+=(x*y);
            m-=y;
        }
        else{
            Sum+=(x*m);
            break;
        }
    }
    cout<<Sum<<endl;
}

Measured memory_bytes: 2420
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
signed main(){
  ll a,b,min_n,tmp=0,ans=1;
  cin >> a >> b;
  min_n = min(a,b);
  for(auto p:prime_factor(min_n)){
    if(a%p.first==0&&b%p.first==0){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

ll A[200010], F[200010];

int main() {
	int N;
	ll K;
	cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> A[i];
	for(int i=0; i<N; ++i) cin >> F[i];
	sort(A, A+N);
	sort(F, F+N, greater<ll>());
	ll ok=1e12, ng=-1;
	while(ng+1<ok){
		ll mid=(ok+ng)/2, sum=0;
		for(int i=0; i<N; ++i){
			if(A[i]*F[i]>mid){
				sum += A[i]-mid/F[i];
			}
		}
		if(sum<=K) ok=mid;
		else ng=mid;
	}
	cout << ok << endl;
	return 0;
}

Measured memory_bytes: 3456
#include <cmath>

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define MOD 1000000007

typedef long long ll;
typedef std::pair< int, int > P;

int  count[4];
bool flag = true;

std::string s;
int main() {
    for (int i=0; i<3; ++i) {
        int a, b;
        std::cin >> a >> b;
        --a; --b;
        ++count[a];
        ++count[b];
    }
    for (int i=0; i<4; ++i) {
        if (count[i] == 0 || count[i] >  2) flag = false;
    }
    if (flag) s = "YES";
    else s = "NO";

    std::cout << s << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int a[3] = {},k;


int main(){
    
    IN a[0] >> a[1] >> a[2] >> k;

    sort(a,a+3);
    rep(i,0,k)a[2] *= 2;

    P(a[0] + a[1] + a[2]);
	return  0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  int n, k;
  cin>>n>>k;
  int arr[n];
  rep(i, 0, n)
    cin>>arr[i];
  sort(arr, arr+n);
  int sm = 0;
  int res = n;
  repb(i, n-1, 0)
    if(sm + arr[i] < k) sm += arr[i];
    else res = min(res, i);
  cout<<res<<endl;
  return 0;
}


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

int main() {
    int dataSet;
    std::cin >> dataSet;

    for(int count = 0; count < dataSet; count++) {
        std::string x, y;
        std::cin >> x;
        std::cin >> y;

        std::vector< std::vector<int> > dp;
        dp.resize(x.length());
        for(auto itr = dp.begin(); itr < dp.end(); itr++) {
            itr->resize(y.length());
        }

        for(int xIndex = 0; xIndex < x.length(); xIndex++) {
            for(int yIndex = 0; yIndex < y.length(); yIndex++) {
                int top, topleft, left;
                top = 0; topleft = 0; left = 0;
                if(xIndex != 0) {
                    top = dp[xIndex - 1][yIndex];
                }
                if(yIndex != 0){
                    left = dp[xIndex][yIndex - 1];
                }
                if(xIndex != 0 && yIndex != 0) {
                    topleft = dp[xIndex - 1][yIndex - 1];
                }

                if(x[xIndex] == y[yIndex]) {
                    dp[xIndex][yIndex] = topleft + 1;
                } else {
                    dp[xIndex][yIndex] = top < left ? left : top;
                }
            }
        }

        std::cout << dp.back().back() << std::endl;
    }

    return 0;
}

Measured memory_bytes: 5024
#include <stdio.h>
 
int main(){
 
  int i,j,n,S[10000],q,T[500],count=0;
 
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
 
  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
 
  for(j=0;j<q;j++){
    i=0;
    S[n] = T[j];
    while(S[i]!=T[j]){
      i++;
    }
    if(i!=n){
      count++;
    }
  }
 
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){long long x,y,a,b,c,d=0; cin>>x>>y>>a>>b>>c; vector<int> p(a),q(b),r(c); rep(i,a) cin>>p[i]; rep(i,b) cin>>q[i]; rep(i,c) cin>>r[i]; sort(p.rbegin(),p.rend()); sort(q.rbegin(),q.rend()); rep(i,x) r.push_back(p[i]); rep(i,y) r.push_back(q[i]); sort(r.rbegin(),r.rend()); rep(i,x+y) d+=r[i]; cout<<d;}

Measured memory_bytes: 5536
#include <stdio.h>
#include <math.h>

int main() {
    int t, max, cont = 0;
    scanf("%d %d", &t, &max);
    
    for (int j = 0; j < t; ++j){
        double x, y;
        scanf("%lf %lf", &x, &y);
        
        unsigned long long a = x*x, b = y*y;

        double dis = sqrt(a+b);
        //printf("---%lf\n", dis);
        
        if (dis <= max)
            cont += 1;
    }
    printf("%d\n", cont);

    return 0;
}


Measured memory_bytes: 2216
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
int main(){
  int a,b;
  cin >> a>>b;
  cout << (a + b)%24 << endl;
}


Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = input()
count1 = 0
count2 = 0
if C>D:
    for i in range(B-2,D+1):
        if S[i] == ".":
            count1 += 1
            if count1 ==3:
                break
        else:
            count1 = 0
    for i in range(A-1,C):
        if S[i] == '#':
            count2 +=1
            if count2 == 2:
                break
        else:
            count2 =0
    if count1 == 3 and count2 !=2:
        print("Yes")
    else:
        print("No")
else:
    for i in range(A-1,D):
        if S[i] == "#":
            count2 += 1
            if count2 == 2:
                break
        else:
            count2 = 0
    if count2 != 2:
        print("Yes")
    else:
        print("No")


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


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<long long> cnt;
    for(long long n = 1; n <= N; n++){
        cout << count(a.begin(), a.end(), n) + count(b.begin(), b.end(), n) << endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H, vector<char>(W, ' '));
  vector<vector<char>> ans(H, vector<char>(W, ' '));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a.at(i).at(j);
      ans.at(i).at(j) = a.at(i).at(j);
    }
  }

  vector<int> h_flag(W);
  vector<int> w_flag(H);

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        w_flag.at(i) = 0;
        break;
      } else {
        w_flag.at(i)++;
      }
    }
  }

  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (a.at(i).at(j) == '#') {
        h_flag.at(j) = 0;
        break;
      } else {
        h_flag.at(j)++;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (w_flag.at(i) == W) {
        ans.at(i).at(j) = 'x';
      }
      if (h_flag.at(j) == H) {
        ans.at(i).at(j) = 'x';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (ans.at(i).at(j) != 'x') {
        cout << ans.at(i).at(j);
      }
    }
    if (w_flag.at(i) != W) {
      cout << endl;
    }
  }
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li l[1010];

int main() {
	map<li, li> a;
	rep(i, 3) {
		li x;
		cin >> x;
		a[x]++;
	}

	cout << (a[5] == 2 && a[7] == 1 ? "YES" : "NO") << endl;



	return 0;
}

Measured memory_bytes: 256
import sys
N,Y=map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k= N-i-j
        t=10000*i+5000*j+1000*k
        if Y==t:
            print(i,j,k)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
import numpy as np
N=int(input())
B=list(map(int,input().split()))
A=np.zeros(N)
A[0]=B[0]
i=0
while i<=len(B)-1:
    if i==len(B)-1:
        A[i+1]=B[i]
        i+=1
    else:
        if B[i]<=B[i+1]:
            A[i+1]=B[i]
            i+=1
        else:
            A[i+1]=B[i+1]
            i+=1
print(int(sum(A)))

Measured memory_bytes: 20644
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;
 
int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}
 
ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

bool is_prime(long long N){
    if (N == 1) return false;
    for (long long i = 2;i * i <= N;i++){
        if (N % i == 0) return false;
    }
    return true;
}
 
ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}
 
double DegreeToRadian(double degree){
    return degree * M_PI / 180.0;
}
 
 
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
 
 
///////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    int ans = 0;
    for (int i = 0;i < n;i++){
        cin >> a[i];
        if (cnt[a[i]] >= a[i]){
            ans++;
        }
        else {
            cnt[a[i]]++;
        }
    }
    for (auto nx : cnt){
        if (nx.first > nx.second){
            ans += nx.second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8232
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    ll a,b,c,d;
    cin >>a >>b>>c>>d;
    ll ans = max({a*d,a*c,b*c,b*d});
    cout<<ans<<endl;
}
    



Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   map<int, int> mp;
   int n;
   cin >> n;
   rep(i, 0, n) {
      int a;
      cin >> a;
      mp[a]++;
   }
   for (auto p : mp) {
      if (p.second > 1) {
         cout << "NO" << endl;
         return 0;
      }
   }
   cout << "YES" << endl;
   return 0;
}

Measured memory_bytes: 9600
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll a, b, c;
    cin >> a >> b >> c;

    ll n = b/a;
    ll m = min(n, c);

    p(m);
    
    return 0;
}

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


int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
    ll n, sum = 0, last = 2, x;
    cin >> n;
    ll arr[3*n];
    for(int i = 0; i < 3*n; i++) 
    	cin >> arr[i];
    sort(arr, arr+3*n);
    for(int i = 0; i < 3*n; i += 3) {
    	sum += arr[3*n-last];
    	last += 2;
    }
    cout << sum;

}


Measured memory_bytes: 5932
s = int(input())
d = set([s])
i = 1
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    if s in d:
        print(i+1)
        break
    else:
        i += 1
        d.add(s)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
    int a, b, c, tmp;
    scanf("%d %d %d", &a, &b, &c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n", a, b, c);
    return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
  int start=-1,t=0,i;
  string S;
  cin >> S;
  for(i=0;i<S.length();i++){
    if(S.at(i)=='A' || S.at(i)=='T' || S.at(i)=='C' || S.at(i)=='G'){
      if(start==-1)start=i;
    }else{
      if((start !=-1)&&i-start>t)t=i-start;
      start=-1;
    }
  }
  if((start !=-1)&&i-start>t)t=i-start;
  cout << t << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>

int
main(void)
{
	int res = 0;
	int max_p = 0;
	int i;
	for (i = 0; i < 3; i++) {
		int p;
		scanf("%d", &p);
		res += p;
		if (p > max_p)
			max_p = p;
	}
	printf("%d\n", res - max_p);
	return 0;
}

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

def solve():
    R, G, B, N = list(map(int, input().split()))

    ans = 0
    for r in range(N+1):
        if r*R > N: break
        
        for g in range(N+1):
            if r*R+g*G > N: break
            
            if (N - (r*R+g*G))%B == 0:
                ans += 1
    print(ans)

if __name__ == "__main__":
    solve()


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  // int A[M][N];
  // int B[M];
  vector < vector <int >> A (N , vector <int >( M ));
  vector <int > B ( M );

  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < M; j++)
    {
      cin >> A[i][j];
    }
  }

  int count = 0;
  for (int i = 0; i < N; i++)
  {
    int sum = C;
    for (int j = 0; j < M; j++)
    {
      sum += A[i][j] * B[j];
    }
    if (sum > 0) { count++; }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAxn = 1e4 + 5;

int main() {
    string s, s2 = "FESTIVAL";
    int n = 7;
    cin >> s;
    for (int i = 0; i < s.size()-8; i++) cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <ctype.h>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	/*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
	string str;
	cin>>str;
	int l = 0;
	int flag= 0, flag1=0, flag2=0;
	int h = str.length()-1;
	while(h>l)
	{
		if(str[l++]!=str[h--])
		{
			flag = 1;
			break;
		}
	}
	int l1 = 0;
	int h1 = ((str.length()-1)/2)-1;
	int l2 = ((str.length()+3)/2)-1;
	int h2 = str.length()-1;
	if(flag==0)
	{
		while(h1>l1)
		{
			if(str[l1++]!=str[h1--])
			{
				flag1++;
			}
		}
		while(h2>l2)
		{
			if(str[l2++]!=str[h2--])
			{
				flag2++;
			}
		}

	}
	if(flag1==0 && flag2==0 && flag==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;


}

Measured memory_bytes: 256
#include <iostream>
#include <stack>

int car_n;
std::stack<int> st;

bool get_input()
{
	return (std::cin >> car_n);
}

int main()
{
	while (get_input()) {
		if (car_n == 0) {
			std::cout << st.top() << std::endl;
			st.pop();
		} else {
			st.push(car_n);
		}
	}
	return 0;
}

Measured memory_bytes: 0