akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n);
  rep(i, n) cin >> A[i];
  sort(all(A));
  if(n%2) {
    ll ans = 0;
    {
      ll tmp = 0;
      rep(i, n) {
        if(i < n/2) tmp -= 2*A[i];
        else if(i < n/2+2) tmp += A[i];
        else tmp += 2*A[i];
      }
      chmax(ans, tmp);
    }
    {
      ll tmp = 0;
      rep(i, n) {
        if(i < n/2-1) tmp -= 2*A[i];
        else if(i < n/2+1) tmp -= A[i];
        else tmp += 2*A[i];
      }
      chmax(ans, tmp);
    }
    cout << ans << endk;
  } else {
    ll ans = 0;
    rep(i, n) {
      if(i < n/2-1) ans -= 2*A[i];
      else if(i == n/2-1) ans -= A[i];
      else if(i == n/2) ans += A[i];
      else ans += 2*A[i];
    }
    cout << ans << endk;
  }
  return 0;
}


Measured memory_bytes: 3924
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <map>
#include <array>

using namespace std;

vector<int> table;
vector<bool> a;

int PRIME = 1000000007;


int main(int argc, char* argv[]){
    int N, M;

    cin >> N >> M;
    a.resize(N, true);
    for(int i = 0; i < M; ++i){
        int n;
        cin >> n;
        a[n] = false;
    }

    table.resize(N + 1, 0);
    table[N] = 1;

    if(a[N-1]){
        table[N-1] = 1;
    }

    for(int i = N-2; i >= 0; --i){
        if(a[i]){
            table[i] = table[i + 1] + table[i + 2];
            table[i] %= PRIME;
        }
    }

    cout << table[0];

}


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
const int N=101101;
int n,x,t;
int main(){
	scanf("%d%d%d",&n,&x,&t);
	printf("%d",((n-1)/x+1)*t);
	return 0;
}

Measured memory_bytes: 1732
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int A = int.Parse(input[0]);
        int B = int.Parse(input[1]);
        int C = int.Parse(input[2]);
        
        if ((A * C) <= B)
        {
            Console.WriteLine(C);
        }
        else
        {
            Console.WriteLine(B / A);
        }
    }
}


Measured memory_bytes: 13140
// Target Expert 

/*
 * Author    : raj1307 - Raj Singh
 * Institute : Jalpaiguri Government Engineering College
 * Date      : 8.08.19
 */

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <iomanip>
#include <memory.h>
#include <assert.h>
using namespace std;


//#define DEBUG
#ifdef DEBUG
#define deb(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
#define debarr(a,n) cerr<<#a<<" : ";for(int i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(int i=0;i<row;i++) {for(int j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma=strchr(names+1,',');
	cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}

#else
#define deb(...) {}
#define debarr(a,n) {}
#define debmat(mat,row,col) {}
#define endl "\n"
#endif

#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fr(i, a, b) for(int i = (a); i < (b); ++i)
#define fb(i, b, a) for(int i = (b); i > (a); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define rr return 
#define int long long
#define pb push_back
#define sz(x) ((int)x.size())
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a>b) return b; else return a;}

const int mod = 1000*1000*1000+7;
const int INF = 1e18 +5;

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}


const int N = 1e5 + 5;
int n;
int a[302];
double cache[302][302][302];
bool vis[302][302][302];
int f[4];
 


double dp(int a,int b,int c){


 
	if(a<0 || b<0 || c<0) return 0;
	if(a==0 && b==0 && c==0) return 0;

	double &ans=cache[a][b][c];

	if(vis[a][b][c]) return ans;


	vis[a][b][c]=1;
	ans=n+a*dp(a-1,b,c)+b*dp(a+1,b-1,c)+c*dp(a,b+1,c-1);
	ans/=(a+b+c);

	return ans;



}



 
void solve(){
 
 
	cin>>n;
	fr(i,0,n){ 
		cin>>a[i];
		f[a[i]]+=1;
	}


	memset(cache,-1,sizeof(cache));



	cout<<dp(f[1],f[2],f[3]);




	
	

 
}
 



signed main() {
	fio;
	
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}

	
	return 0;
}


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

    # 要素の絶対値
B = list(map(abs, A))

    # 負の要素の個数
C = [a for a in A if a < 0]
if len(C) % 2 == 0:
  print(sum(B))
else:
        # 最小値を負として計算する
  print(sum(B) - min(B)*2)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int num = n / 2;
  bool flag = true;
  
  if (n % 2 == 0) {
    rep(i, num) {
      if (s[i] != s[i + num]) flag = false;
    }
  } else {
    flag = false;
  }
  
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl; 
}


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

using namespace std;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define bas(x) #x << ": " << x << " "
#define prarr(x, n) cout << #x << ": "; for (int qsd = 0; qsd < n; qsd++) cout << x[qsd] << " "; cout << endl;
#define prarrv(x) cout << #x << ": "; for (int qsd = 0; qsd < (int)x.size(); qsd++) cout << x[qsd] << " "; cout << endl;
#define inside sl<=l&&r<=sr
#define outside sr<l||r<sl

typedef long long ll;

int n;
int arr[200005];
int yer[200005];

int get(int i){
	return yer[i] < yer[i+1];
}

int main(){
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i];
	}
	
	if (arr[0] != 0){
		cout << -1 << endl;
		return 0;
	}
	for (int i = 1; i < n; i++){
		if (arr[i] > arr[i-1]+1){
			cout << -1 << endl;
			exit(0);
		}
	}
	
	ll ans = 0;
	for (int i = 1; i < n; i++){
		if (arr[i] == arr[i-1]+1) ans++;
		else ans += arr[i];
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define  pb push_back
#define  xx first
#define  yy second
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;
int h,n;
int dp[1001];
int v[4000],cost[4000];
int ans = 1e-9;
/*
int go(int i,int sum){

        if(dp[i][sum]!=-1) return dp[i][sum];

       dp[i][sum] =min(val[i]+go(i+1,W-a[i]),go(i+1,W));
       return dp[i][sum];
}
*/
void go(int i,int x, int y ){

     ans = max(ans,x-y);
    if(i>n){
      return ;
    }
    go(i+1,v[i]+x,cost[i]+y);
    go(i+1,x,y);
    return;
}
 int main()
{
   // fast;

    int n,k,q;

    string s;
     cin >> n >> q >> s;
     int cul[n+10];
     memset(cul,0,sizeof cul);

   for(int i = 0; i < n; i++){
      if(s[i]=='A' && s[i+1]=='C'){
        cul[i+1] = 1;
      }
   }

   for(int i = 1; i<=n; i++) cul[i] =cul[i-1]+cul[i];

   while(q--){
     int r,l;
    cin >> l >> r;
   int ans = cul[r]-cul[l-1];
     if(s[r-1]=='A' && s[r]=='C') ans--;
     cout << ans << '\n';
   }

   return 0;
}


Measured memory_bytes: 1408
from itertools import product

S = input()
N = len(S)

l = [0 for i in range(13)]
l[0] = 1

x = 1
mod = 10**9 + 7

for i in range(N):
    tmp = [0 for i in range(13)]
    if S[-i-1] == '?':
        for i,j in product(range(13), range(10)):
            tmp[(i + x*j) % 13] += l[i] % mod
    else:
        num = int(S[-i-1])
        for i in range(13):
            tmp[(i + x*num) % 13] += l[i] % mod
    l = tmp
    x = 10 * x % 13

print(l[5] % mod)


Measured memory_bytes: 43740
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n;
  int i;
  int *ai;

  scanf("%d",&n);
  ai=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    scanf("%d",&ai[i]);
  }

  for(i=0;i<n;i++){
    printf("%d",ai[n-i-1]);
    if(i==n-1) printf("\n");
    else printf(" ");
  }

  return 0;
}


Measured memory_bytes: 2032
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <climits>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
#ifdef RUN_LOCAL
  ifstream in("../input.txt");
  cin.rdbuf(in.rdbuf());
#endif

  cin.tie(0);
  ios::sync_with_stdio(false);

  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h, vector<char>(w));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }
  vector<vector<int>> dp(h, vector<int>(w));
  dp[0][0] = 1;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#') continue;
      if (i - 1 >= 0 && a[i - 1][j] != '#') {
        long long tmp = (long long)dp[i][j] + dp[i - 1][j];
        dp[i][j] = tmp % 1000000007;
      }
      if (j - 1 >= 0 && a[i][j - 1] != '#') {
        long long tmp = (long long)dp[i][j] + dp[i][j - 1];
        dp[i][j] = tmp % 1000000007;
      }
    }
  }
  cout << dp[h - 1][w - 1] << endl;


  return 0;
}


Measured memory_bytes: 5248
/*
Anki:未済
作成日:
*/

#include <stdio.h>

int main()
{
    int n, i, result = 0;

    scanf( "%d", &n );

    for( i = 1; i < n+1; i++ )
    {
        result += i;
    }
    printf( "%d\n", result );
    
    return 0;
}

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

typedef long long ll;
#define ALL(x) (x).begin(), (x).end()

const ll INF = 1001001001;
const int MOD = 1000000007;
const int MAX_N = 101010;

// A:array of pair, N:size of array
void sort_second(vector<pair<ll, ll>> &A, int N);
// a^n
ll a_n(ll a, ll n);
// make vector of (n!)%MOD, (n!)^(-1)%MOD to calculate nCk
void factorial_map(vector<ll> &n, vector<ll> &ninv);
// a^(-1) % MOD 
ll inv(ll a);
// map of prime factorization
void prime_map(map<ll, ll> &a, ll n);
//list of prime (is_prime.size() = n + 1, primes.size() = 0)
void prime_list(ll n, vector<ll> &primes, vector<bool> &is_prime);
// get gcd from prime map
ll gcd_map(map<ll, ll> a, map<ll, ll> b);
// get lcm from prime map
ll lcm_map(map<ll, ll> a, map<ll, ll> b);
// get gcd
ll my_gcd(ll a, ll b);
// calculate nCk
ll nCk(ll n, ll k);
// get abs
ll my_abs(ll a);
// z-algorithm (s.size() == a.size())
void z_algorithm(string s, vector<int> &a);

class Unionfind {
    public:
        vector<ll> par, siz, rank;
        Unionfind();
        ll root(ll x);
        void merge(ll x, ll y);
        bool issame(ll x, ll y);
        ll size(ll x);
};

int main() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;
    for(ll i=0; i <n; i++) {
        ll tmp;
        cin >> tmp;
        a.push_back(make_pair(tmp, i+1));
    }
    sort(ALL(a), greater<pair<ll, ll>>());

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, -1*INF));
    dp[0][0] = 0;

    for(ll i=1; i<=n; i++) {
        for(ll x = 0; x <= i; x++) {
            ll y = i-x, left = -1*INF, right = -1*INF;
            if(x>0) {
                left = dp[x-1][y] + a[i-1].first*my_abs(a[i-1].second-x);
            }
            if(y>0) {
                right = dp[x][y-1] + a[i-1].first*my_abs(a[i-1].second-(n-(y-1)));
            }
            dp[x][y] = max(left, right);
        }
    }

    ll ans = -1*INF;
    for(ll i=0; i<=n; i++) {
        if(ans < dp[i][n-i]) ans = dp[i][n-i];
    }

    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

Measured memory_bytes: 34584
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	k := nextInt64()
	s := strconv.FormatInt(k, 10)
	l := len(s)
	var ans int64
	a, _ := strconv.Atoi(s[l-1 : l])
	if a%2 != 0 {
		fmt.Println(0)
		return
	}
	var n int64
	for i := 1; n < k; i++ {
		n = 2 * int64(math.Pow(5, float64(i)))
		ans += k / n
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

int main()
{
        ll N, M;
        cin >> N >> M;
        vector<bool> A(N, false);
        vector<bool> B(N, false);
        for (int i = 0; i < M; ++i) {
                ll a, b; cin >> a >> b;
                if (a == 1) {
                        A[b-1] = true;
                }
                if (b == N) {
                        B[a-1] = true;
                }
        }
        for (int i = 0; i < N; ++i) {
                if (A[i] == true && B[i] == true) {
                        cout << "POSSIBLE" << endl;
                        exit(0);
                }
        }
        cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
left = S[:N // 2]
right = S[N // 2 + 1:]
last = S[(N+3)//2-1:]

print('Yes') if S == S[::-1] and left == left[::-1] and right == right[::-1] and last == last[::-1] else print('No')

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

int main() {
    int n, m;
    cin >> n >> m;
    int a[m];
    int sum = 0;
    for(int i=0; i<m; i++) {
        cin >> a[i];
        sum += a[i];
    }

    if(n-sum < 0)
        cout << -1 << "\n";
    else
        cout << n-sum << "\n";
}

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

int main() {
  string N;
  cin >> N;
  
  int count=0;
  
  for(int i=0; i<4; i++) {
    if (N.at(i) == '2') {
      count++;
    }
  }
  
  cout << count << endl;
  
  
}

Measured memory_bytes: 256
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);

     ll int i,n,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     p=n%10;
     if(p==0 || p==1 ||p==6 || p==8){
        cout<<"pon"<<endl;
     }
     else if(p==3){
        cout<<"bon"<<endl;
     }
     else{
        cout<<"hon"<<endl;
     }



     return EXIT_SUCCESS;
}




Measured memory_bytes: 3608
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  string s;
  int n;
  cin>>s;
  n=s.size();
  ll a[n+1]={};
  ll b[n+1]={};
  ll c[n+1]={};
  ll q[n+1]={};
  if(s[0]=='A') a[0]=1;
  if(s[0]=='B') b[0]=1;
  if(s[0]=='C') c[0]=1;
  if(s[0]=='?') q[0]=1;
  for(int i=1;i<n;i++){
    a[i]=a[i-1];
    b[i]=b[i-1];
    c[i]=c[i-1];
    q[i]=q[i-1];
    if(s[i]=='A') a[i]++;
    if(s[i]=='B') b[i]++;
    if(s[i]=='C') c[i]++;
    if(s[i]=='?') q[i]++;
  }
  ll A=a[n-1];
  ll B=b[n-1];
  ll C=c[n-1];
  ll Q=q[n-1];
//cout<<A<<B<<C<<Q<<endl;
  ll ans=0;

  ll three[n+1]={};
  three[0]=1;
  for(int i=1;i<=n;i++){
    three[i]=three[i-1]*3%MOD;
  }

  for(int i=1;i<n;i++){
    if(s[i]=='B'||s[i]=='?'){
      if(q[i-1]==0&&Q-q[i]==0){
        ans=ans+(a[i]*(C-c[i])%MOD)%MOD;
      }else if(q[i-1]==0){
        ans=ans+(a[i]*((3*(C-c[i])%MOD+Q-q[i])%MOD)%MOD*three[Q-q[i]-1])%MOD;
      }else if(Q-q[i]==0){
        ans=ans+(3*a[i]%MOD+q[i-1])%MOD*three[q[i-1]-1]%MOD*(C-c[i]);
      }else{
        ans=ans+(3*a[i]%MOD+q[i-1])%MOD*three[q[i-1]-1]%MOD*(3*(C-c[i])%MOD+Q-q[i])%MOD*three[Q-q[i]-1]%MOD;
      }
      ans%=MOD;
    }
  }

  cout<<(ans+MOD)%MOD<<endl;




  return 0;
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static String solve(int[] A) {
        long M1 = 0;
        for (int i = 0; i < A.length; ++i) {
            M1 += ((i % 2 == 0) ? 1 : -1) * A[i];
        }

        int[] result = new int[A.length];
        result[0] = (int) M1;
        for (int i = 1; i < result.length; ++i) {
            result[i] = 2 * A[i - 1] - result[i - 1];
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining(" "));
    }
}

Measured memory_bytes: 62328
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const int MOD = 1000000007;
//const int MOD = 998244353;
template<class T> inline int add(T& a, T b, T M = MOD){a=(a+M)%M;b=(b+M)%M;a=(a+b)%M;return a;};
template<class T> inline int mul(T& a, T b, T M = MOD){if(a>=M)a%=M;if(b>=M)b%=M;a*=b;if(a>=M)a%=M;return a;};
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
const string abc="abcdefghijklmnopqrstuvwxyz";
const string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

////////////////////////////////////////////////////////////////////
///////////////////////___modpow___////////////////////
ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
///////////////////////___modinv___////////////////////
ll modinv(ll d, const ll &MOD = MOD){
  return modpow(d, MOD-2, MOD);
}
////////////////////////////////////////////////////////////////////

signed main(){
  int n,m;cin>>n>>m;
  int ans = n;
  rep(i,m){
    int a;cin>>a;ans -= a;
  }
  cout << max(-1LL, ans ) << endl;
}


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

signed main(){
	int n,m;cin>>n>>m;
	vector<int>v;

	for(int i=1;i*i<=m;i++){
		if(m%i==0){v.push_back(i);v.push_back(m/i);}
	}
//	sort(begin(v),end(v));
	int x=m/n,ret=1;
	for(auto&& u:v)if(u<=x)ret=max(ret,u); 
	cout<<ret<<endl;
}

Measured memory_bytes: 256
import collections
 
#文字列を一文字ずつ取得したいとき
def inputStrOnebyOne():
    s = list(input())
    return s
 
#整数を一つずつリストに入れる
def inputOnebyOne_Int():
    a = list(int(x) for x in input().split())
    return a
 
def main():
    n = int(input())
    tlist = inputOnebyOne_Int()
    m = int(input())

    ret=0
    for i in range(m):
        p,x = map(int, input().split())
        ret = sum(tlist) - tlist[p-1] + x
        print(ret)
 
if __name__=='__main__':
    main()

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

int main() {
  int a, b;
  cin >> a >> b;
  int x = a + b;
  int y = a - b;
  int z = a * b;
  if(x >= y && x >= z) {
    cout << x << endl;
  } else if(y >= z && y >= x) {
    cout << y << endl;
  } else{
  	cout << z << endl;
  }
}

Measured memory_bytes: 3608
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;

public class Main {
    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextStr() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            StringBuffer str = new StringBuffer();
            do {
                str.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return str.toString();
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String[] args) throws IOException {

        InputReader sc = new InputReader(System.in);
        int n1 = sc.nextInt();
        int sp1[] = new int[n1];
        for (int i = 0; i < n1; i++) {
            sp1[i] = sc.nextInt();
        }
        int n2 = sc.nextInt();
        int sp2[] = new int[n1];
        for (int i = 0; i < n2; i++) {
            sp2[i] = sc.nextInt();
        }
        int sum = 0;
        for (int j = 0; j < n2; j++) {
            if (Arrays.binarySearch(sp1, sp2[j]) > 0) {
                sum++;
            }
        }
        System.out.println(sum);
    }
}


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

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

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector<int> a(n + 1);
    rep(i, 0, n){
        cin >> a[i];
    }
    a[n] = x;
    sort(a.begin(), a.end());
    int ans = a[1] - a[0];
    rep(i, 1, n){
        ans = gcd(ans, a[i + 1] - a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int s_dsort(const void* a, const void* b);

int main(void) {
	int N,K,i;
	int A[100000];
	
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) 
		scanf("%d", &A[i]);
	qsort((void*)A, N, sizeof(int), s_dsort);
	for (i = 0; i < N; i++) {
		if (A[i] < K) break;
	}

	printf("%d", i);
	return 0;
}
//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b-*(int*)a);
}



Measured memory_bytes: 892
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			int[] a=new int[n];
			for(int i=0;i<n;i++) a[i]=sc.nextInt()-1;
			int ans=0;
			for(int i=0;i<n;i++){
				if(a[a[i]]==i) ans++;
			}
			System.out.println(ans/2);
		}
	}
}

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

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

int main(void){
  long long int N,A,B,C,D,E,F,G,H;
  cin >> A >> B >> C >> D;
  
  //cout << B/C << ' ' <<  (A-1)/C << endl;
  F = B/C - (A-1)/C;
  //cout << B/D << ' ' <<  (A-1)/D << endl;
  G = B/D - (A-1)/D;
  
  E=lcm(C,D);
  //cout << B/E << ' ' <<  (A-1)/E << endl;  
  H = B/E - (A-1)/E;

  cout << (B-A+1) - (F+G-H);
}

Measured memory_bytes: 256
from sys import stdin
import heapq

N = int(input())
As = [int(x) for x in stdin.readline().rstrip().split()]
ans = [0] * N

for i in range(N):
    x = As[i]
    ans[x-1] = i + 1

ans = ' '.join(map(str, ans))
print(ans)


Measured memory_bytes: 18496
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define N 200100
#define pii pair<int,int>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define vi vector<int>
#define inf 1e9
void solve(){
	int n;
	cin>>n;
	bool app=true;
	while(n--){
		int temp;
		cin>>temp;
		if(temp%2==0 && temp%3!=0 && temp%5!=0){
			app=false;
		}
	}
	if(app){
		cout<<"APPROVED"<<endl;
	} else{
		cout<<"DENIED"<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  int n, T;
  cin >> n >> T;
  vector<pair<int, int>> p(n);
  rep(i, n) {
    cin >> p[i].first;
    cin >> p[i].second;
  }

  vector<int> aa;

  rep(i, n) {
    int c = p[i].first;
    int t =  p[i].second; 
    if(t<=T) aa.push_back(c);
  }

  sort(aa.begin(), aa.end());
  if(aa.empty()) cout << "TLE" << endl;
  else cout << aa[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

struct edge {
	int from;
	int to;
	long long int cost;
};

struct aa {
	int now;
	long long int time;
	int nowv;
	bool comen;
};
class Compare {
public:
	bool operator()(const aa&l, const aa&r) {
		return l.time> r.time;
	}
};	//aa?????????????????¶

int v0, A, B, C;
long long int solve(const vector<vector<edge>>&edges,const int start,const int goal) {
	priority_queue<aa, vector<aa>, Compare>que;
	vector<vector<vector<long long int>>>memo(edges.size(), vector<vector<long long int>>(C,vector<long long int>(2,1e18)));
	memo[0][v0][0] = 0;
	que.push(aa{ start,0,v0,false });
	while (!que.empty()) {
		auto atop(que.top());
		que.pop();
		const int now = atop.now;
		const long long int nowtime = atop.time;
		const int nowv = atop.nowv;
		const int nowcomen = atop.comen;
		if (now == goal&&nowcomen)return nowtime;
		for (auto e : edges[atop.now]) {
			const int next = e.to;
			const long long  int nexttime = nowtime + e.cost*nowv;
			const int nextv = (A*nowv + B) % C;
			const bool nextcomen = nowcomen | (next == edges.size() - 1);
			if (nexttime < memo[next][nextv][nextcomen]) {
				que.push(aa{ next,nexttime,nextv,nextcomen });
				memo[next][nextv][nextcomen] = nexttime;
			}
		}
	}
	return -1;
}

int main() {
	int N, M; cin >> N >> M;
	vector<vector<edge>>edges(N);
	for (int i = 0; i < M; ++i) {
		int x, y, t; cin >> x >> y >> t;
		if (x > y)swap(x, y);
		x--; y--;
		edges[x].push_back(edge{ x,y,t });
		edges[y].push_back(edge{ y,x,t });
	}
	cin >> v0 >> A >> B >> C;
	long long int ans(solve(edges, 0, 0));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9732
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printv(x) for(int i = 0; i < x.size(); i++){ cout << (x[i]) << " "; } cout << endl; 
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printaa(x) for(int i = 0; i < (sizeof(x)/sizeof(x[0])); i++){ for(int j = 0; j < (sizeof(x[0])/sizeof(x[0][0])); j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    ll A[100010];
    cin >> N >> M;
    rep(i,0,N){
        cin >> A[i];
    }
    ll sum[100010] = {};
    rep(i,1,N+1){
        sum[i] = sum[i-1] + A[i-1];
    }
    rep(i,0,N+1){
        sum[i] %= M;
    }
    sort(sum, sum+N+1);
    ll ans = 0;
    ll now_val = 0;
    ll cnt = 0;
    rep(i,1,N+1){
        if(now_val == sum[i]){
            cnt++;
        }else{
            if(now_val == 0){
                ans += cnt;
            }
            ans += (cnt * (cnt-1))/2;
            now_val = sum[i];
            cnt = 1;
        }
    }
    if(now_val == 0){
        ans += cnt;
    }
    ans += (cnt * (cnt-1))/2;

    print(ans);



}


Measured memory_bytes: 1792
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

int a , b;

int main(){
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    } else if(a <= 12 && 6 <= a){
        cout << b / 2 << endl;
    } else {
        cout << 0 << endl;
    }
}


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


int main()
{
	int a, b;
	char c;
	cin >> a >> c >> b;
	if (c == '+') {
		cout << a + b << endl;
	}
	else
		cout << a - b << endl;
	return 0;
}

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

int calc(int a){
    if (1 <= a && 10 >= a){
        int result = a + pow(a,2)+ pow(a,3);
        return result;
    }
    else {
        return 1;
    }
}


int main(void){
    int a;
    scanf("%d",&a);
    printf("%d", calc(a));
    return 0;

}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
 int a,b,c,d;
 scanf("%d %d %d %d",&a,&b,&c,&d);
 int e = a*b;
 int f = c*d;
 if(e>f) printf("%d",e);
 else printf("%d",f);
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)

int INF = 100100100;
const int MAX = 110000;
const int MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    ll ans = N*(N*N+N*3+2)/6;
    rep(i, 0, N-1){
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u*(N-v+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N, l, r, X;
  cin >> N;

X=0;

  for( int i=0; i<N; i++){
    cin >> l >> r;
    X+= r-l+1;
  }
  cout << X << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1L<<61);
const string ACGT = "ACGT";

bool hasAGC(string s) {
  return s.substr(0,3)=="AGC" || s.substr(1,3)=="AGC";
}

bool isOk(string s) {
  if (hasAGC(s)) return false;

  rep(i,3) {
    string d = s;
    swap(d[i], d[i+1]);
    if (hasAGC(d)) return false;
  }
  return true;
}

int main() {
  int n; cin >> n;
  map<string, ll> dp;
  dp["TTTT"] = 1;

  rep(i,n) {
    map<string, ll> ndp;
    for (auto it : dp) {
      rep(j,4) {
        string s = it.first.substr(1,3) + ACGT[j];
        if (isOk(s)) {
          ndp[s] += it.second;
          ndp[s] %= MOD;
        }
      }
    }
    dp = ndp;
  }
  ll ans = 0;
  for (auto it : dp) {
    ans += it.second;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll x,k,d,l;
    double s1,s2;
    double plus, minus;
    cin >> x >> k >> d;
    if(k % 2 == 0){
        l = k/2;
        s1 = -x/(2.0*d);
        s2 = x/(2.0*d);
        if(x == 0){
            cout << 0 << endl;
            return 0;
        }
        if(s1 < 0){
            plus = x;
        }else if(s1 > 0){
            ll round_s1 = round(s1);
            if(round_s1 > l) round_s1 = l;
            plus = x + 2*round_s1*d;
        }

        if(s2 < 0){
            minus = x;
        }else if(s2 > 0){
            ll round_s2 = round(s2);
            if(round_s2 > l) round_s2 = l;
            minus = x - 2*round_s2*d;
        }
    }else{
        l = (k-1)/2;
        s1 = -((double)x/d + 1)/2.0;
        s2 = ((double)x/d - 1)/2.0;
        if(s1 < 0){
            plus = x+d;
        }else if(s1 > 0){
            ll round_s1 = round(s1);
            if(round_s1 > l) round_s1 = l;
            plus = x + (2*round_s1+1)*d;
        }

        if(s2 < 0){
            minus = x-d;
        }else if(s2 > 0){
            ll round_s2 = round(s2);
            if(round_s2 > l) round_s2 = l;
            minus = x - (2*round_s2+1)*d;
        }
    }
    double ans = min(abs(plus), abs(minus));
    printf("%.0lf\n", ans);
    return 0;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> X(N), Y(N);
    rep(i, N){
        int tmp;
        cin >> tmp;
        X.at(i) = tmp;
        Y.at(i) = tmp;
    }

    sort(all(Y));
    int m1 = Y.at(N/2 - 1), m2 = Y.at(N/2);

    rep(i, N){
        if(X.at(i) <= m1) cout << m2 << endl;
        else cout << m1 << endl;
    }

}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int a, b ; 
  cin >> a >> b ;
  
  if( a * b == 15 ) {
    cout <<'*' <<endl ;
    return 0 ;
  }
  if( a+b == 15 ) {
    cout << '+' <<endl ;
    return 0 ;
  }
  
  cout << 'x' <<endl ;


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    int d[n];
    rep(i, n) cin >> d[i];
    int ans = 0;
    for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) {
        ans += d[i]*d[j];
    } 
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>


int main(void){
	const int n = 3;

	int value[n];

	for(int i=0;i<n;i++){
		std::cin >> value[i];
	}
	int min;
	for(int i=0;i<n;i++){
		min = value[i];
		for(int j=i;j<n;j++){
			 if(min > value[j]){
				int v;
				v = value[j];
				value[j] = min;
				min = v;
			 }
		}
		value[i] = min;
	}

	for(int i=0;i<n;i++){
		if(i==n-1){

				std::cout << value[i];
		}else{

				std::cout << value[i] << " ";
		}
	}
	std::cout << std::endl;

}

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

int arr[3][3];
int v[3][3];

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

int main(){
    for(int i=0; i<3; i++) for(int j=0; j<3; j++) cin >> arr[i][j];
    int n; cin >> n;
    for(int k=1; k<=n; k++){
        int t; cin >> t;
        for(int i=0; i<3; i++) for(int j=0; j<3; j++) if(arr[i][j] == t) v[i][j] = 1;
    }

    for(int i=0; i<3; i++){
        int cnt = 0;
        for(int j=0; j<3; j++) cnt += v[i][j];
        if(cnt == 3) f();
    }
    for(int i=0; i<3; i++){
        int cnt = 0;
        for(int j=0; j<3; j++) cnt += v[j][i];
        if(cnt == 3) f();
    }
    if(v[0][0] && v[1][1] && v[2][2]) f();
    if(v[0][2] && v[1][1] && v[2][0]) f();
    cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>

using namespace std;
int main(){

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

	priority_queue<int>que;
	int ans = 0;
	for (int i = 0; i < N; i++){
		que.push(H[i]);
		if (que.top() <= H[i])
			ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#define int long long
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int korattu(int i) {
	int count = 0;
	int k = i;
	while (k != 1) {
		if (k % 2 == 0)k /= 2;
		else k = k * 3 + 1;
		count++;
	}
	return(count);
}
signed main() {
	int n; cin >> n;
	vector<int>sosuu(1000, 0);
	Rip(i, n) {
		int k = i;
		while (k%2==0) {
			k /= 2;
			sosuu[2]++;
		}
		int sosu = 3;
		while (k != 1) {
			if (k % sosu == 0)sosuu[sosu]++, k /= sosu;
			else sosu += 2;
		}
	}
	int ans = 1;
	rip(i, 1000) {
		ans *= sosuu[i] + 1;
		ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>

#define SIZE 51
typedef long long ll;
 
using namespace std;
 

 int main(){
     int N,M,Q;
     int a[SIZE],b[SIZE],c[SIZE],d[SIZE];
     int max = 0;
     cin >> N >> M >> Q;
     for(int i = 1 ; i <= Q ; i++){
         cin >> a[i] >> b[i] >> c[i] >> d[i] ;
     }
     int a_line[11];
     for(a_line[1] = 1 ; a_line[1] <= M ; a_line[1]++){
         for(a_line[2] = a_line[1] ; a_line[2] <= M ; a_line[2]++){
            for(a_line[3] = a_line[2] ; a_line[3] <= M ; a_line[3]++){
                for(a_line[4] = a_line[3] ; a_line[4] <= M ; a_line[4]++){
                    for(a_line[5] = a_line[4] ; a_line[5] <= M ; a_line[5]++){
                        for(a_line[6] = a_line[5] ; a_line[6] <= M ; a_line[6]++){
                            for(a_line[7] = a_line[6] ; a_line[7] <= M ; a_line[7]++){
                                for(a_line[8] = a_line[7] ; a_line[8] <= M ; a_line[8]++){
                                    for(a_line[9] = a_line[8] ; a_line[9] <= M ; a_line[9]++){
                                        for(a_line[10] = a_line[9] ; a_line[10] <= M ; a_line[10]++){
                                            int tmp = 0;
                                            for(int i = 1 ; i <= Q ; i++){
                                                if(a_line[b[i]] - a_line[a[i]] == c[i]){
                                                    tmp += d[i];
                                                }
                                            }
                                            if(max < tmp){
                                                max = tmp;
                                            }
                                        }
                                    }
                                }
                            }    
                        }
                    }
                }
            }
         }
     }
     cout << max;
     return 0;
 }

Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_set>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if (a == 0 and b == 0) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = n / (a + b) * a;
	n %= a + b;
	ans += min(a, n);
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

typedef pair<int, int> pairint;

int main(void){
    int H, W, Ch, Cw, Dh, Dw;
    char Sbuf;
    cin >> H >> W;
    vector<vector<bool>> Maze(H);
    cin >> Ch >> Cw;
    Ch--;
    Cw--;
    cin >> Dh >> Dw;
    Dh--;
    Dw--;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> Sbuf;
            if(Sbuf == '.'){
                Maze[i].push_back(true);
            }else{
                Maze[i].push_back(false);
            }
        }
    }
    deque<pairint> que;
    set<pairint> visited;
    vector<vector<int>> Warps(H, vector<int>(W, -1));
    que.push_front(pairint(Ch, Cw));
    Warps[Ch][Cw] = 0;
    while(!que.empty()){
        pairint curpoint = que.front();
        que.pop_front();
        if(visited.find(curpoint)!=visited.end())continue;
        visited.insert(curpoint);
        for(int i=-2; i<=2; i++){
            for(int j=-2; j<=2; j++){
                if(curpoint.first+i<0)continue;
                if(curpoint.first+i>=H)continue;
                if(curpoint.second+j<0)continue;
                if(curpoint.second+j>=W)continue;
                if(Maze[curpoint.first+i][curpoint.second+j]){
                    if(abs(i)+abs(j)==1){
                        if((Warps[curpoint.first+i][curpoint.second+j]==-1)||(Warps[curpoint.first+i][curpoint.second+j]>Warps[curpoint.first][curpoint.second])){
                            que.push_front(pairint(curpoint.first+i, curpoint.second+j));
                            Warps[curpoint.first+i][curpoint.second+j]=Warps[curpoint.first][curpoint.second];
                        }
                    }else{
                        if((Warps[curpoint.first+i][curpoint.second+j]==-1)||(Warps[curpoint.first+i][curpoint.second+j]>Warps[curpoint.first][curpoint.second]+1)){
                            que.push_back(pairint(curpoint.first+i, curpoint.second+j));
                            Warps[curpoint.first+i][curpoint.second+j]=Warps[curpoint.first][curpoint.second]+1;
                        }
                    }
                }
            }
        }
    }
    cout << Warps[Dh][Dw] << endl;
    return 0;
}

Measured memory_bytes: 31056
#include <iostream>

using namespace std;

typedef long long int lli;

int main()
{
	lli n, t;
	
	while(cin>>n && n){
		t = 0;
		while(n/5 > 0){
			t += n/5;
			n /= 5;
		}
		
		cout << t << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val array = IntArray(n){sc.nextInt()}
  for (i in 1 until array.size) {
    println(array.joinToString(" "))
    val v = array[i]
    var j = i - 1
    while (j >= 0 && array[j] > v) {
      array[j+1] = array[j]
      j--
    }
    array[j+1] = v
  }
  println(array.joinToString(" "))
}


Measured memory_bytes: 30832