akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {

  int N, M;
  cin >> N >> M;

  int sum = 0;
  for (int i = 0; i < M; i++) {
    int A;
    cin >> A;
    sum += A;
  }

  if (N < sum) {
    cout << -1 << endl;
  } else {
    cout << N - sum << endl;
  }

  return 0;

}

Measured memory_bytes: 3636
n = int(input())
h = list(map(int, input().split()))

cost = [1001001001] * n
cost[0] = 0
cost[1] = abs(h[1] - h[0])

for i in range(2, n):
    cost[i] = min((cost[i-2] + abs(h[i] - h[i-2])),
                  cost[i-1] + abs(h[i] - h[i-1]))

print(cost[-1])

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

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

	bool flag = true;
	bool preD = false;
	for (int i = 0; flag && i < s.size();) {
		if (s[i] == 'd') {
			string sub = s.substr(i, 5);
			if (sub == "dream")i += 5;
			else flag = false;
			preD = true;
		}
		else if (s[i] == 'e') {
			string sub = s.substr(i, 6);
			if (sub == "eraser") {
				i += 6;
				preD = false;
				continue;
			}
			sub = s.substr(i, 5);
			if (sub == "erase") {
				i += 5;
				preD = false;
				continue;
			}
			sub = s.substr(i, 2);
			if (sub == "er" && preD) {
				i += 2;
				preD = false;
				continue;
			}
			flag = false;
		}
		else flag = false;
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    std::deque<char> deq;
    cin>>s;
    for (int i=0;i<s.size();i++) {
        deq.emplace_back(s.at(i));
    }
    int q,t,f;
    char c;
    cin>>q;
    int flag=0;
    for (int i=0;i<q;i++) {
        cin>>t;
        if (t==1) {
            if (flag==0) {
                flag=1;
            } else {
                flag=0;
            }
        } else if (t==2) {
            cin>>f>>c;
            if (f==1) {
                if (flag==0) {
                    deq.emplace_front(c);
                } else {
                    deq.emplace_back(c);
                }
            } else if (f==2) {
                if (flag==0) {
                    deq.emplace_back(c);
                } else {
                    deq.emplace_front(c);
                }
            }
        }
    }
    if (flag==0) {
        for (int j=0;j<deq.size();j++) {
            cout<<deq[j];
        }
    } else {
        for (int k=deq.size()-1;k>=0;k--) {
            cout<<deq[k];
        }
    }
    cout<<endl;
}


Measured memory_bytes: 896
#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>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int h;
        cin >> h;
        if (h>=k) ans++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		String ans = "Yes";
		for (int i = 0; i < s.length; i++) {
			boolean e = (i + 1) % 2 == 0;
			if (e && !"LUD".contains(s[i])) {
				ans = "No";
				break;
			} else if (!e && !"RUD".contains(s[i])) {
				ans = "No";
				break;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23252
INF = 10 ** 14
N, M, L = map(int,input().split())

MAP1 = [[INF for i in range(N)] for j in range(N)]

for _ in range(M):
    A, B, C = map(int,input().split())
    MAP1[A-1][B-1] = C
    MAP1[B-1][A-1] = C

for k in range(N):
    for i in range(N):
        for j in range(N):
            MAP1[i][j] = min(MAP1[i][j], MAP1[i][k] + MAP1[k][j])

MAP2 = [[INF for i in range(N)] for j in range(N)]

for i in range(N):
    for j in range(N):
        if MAP1[i][j] <= L:
            MAP2[i][j] = 1

for k in range(N):
    for i in range(N):
        for j in range(N):
            MAP2[i][j] = min(MAP2[i][j], MAP2[i][k] + MAP2[k][j])

Q = int(input())

for _ in range(Q):
    s, t = map(int,input().split())
    if MAP2[s-1][t-1] == INF:
        print(-1)
    else:
        print(MAP2[s-1][t-1] - 1)

Measured memory_bytes: 60504
#include <iostream>
#include <math.h>
#include <string>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;

int main(){
	int a, b, x;
	cin >> a >> b >> x;
	
	if(a <= x && x <= a + b){
		cout << "YES" << endl;
	} else{
		cout << "NO" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define length(X) (int)X.size()
using namespace std;
typedef pair <int, int> ii;

const ll siz = 10 + 5;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9;
const ll maxx = 2e9;
const ll MAXX = 1e18;



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    char c;
    cin >> c;
    if (c >= 'a' && c <= 'z')
        cout << 'a';
    else
        cout << 'A';
    return 0;
}


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

int main(){
	priority_queue < int , vector < int > , greater < int > > q;
	int N , sum , cnt = 0; long long all = 0;
	cin >> N >> sum; for(int i = 1 , x ; i <= N ; ++i){cin >> x; q.push(x); all += x;}
	if(sum == all){cout << N; return 0;}
	while(!q.empty() && q.top() <= sum){sum -= q.top(); ++cnt; q.pop();}
	cout << cnt - (cnt == N); return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void solve()
{
  ll n,m; cin>>n>>m;
  if (n>1) n-=2;
  if (m>1) m-=2;
  cout << n*m << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
h, w, d = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
Q = int(input())
lis = [0] * (h * w)
for i in range(h):
    for j in range(w):
        lis[a[i][j] - 1] = (i, j)
cum = [0] * d
for i in range(d, h * w):
    cum.append(cum[i - d] + abs(lis[i][0] - lis[i - d][0]) + abs(lis[i][1] - lis[i - d][1]))
for i in range(Q):
    l, r = map(int, input().split())
    print(cum[r - 1] - cum[l - 1])

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

double density(int a,int b) {
    double dens;
    dens = (double)(b)*100/(a+b);
    if (b==0) dens = 0;
    return dens;
}

int main (void) {
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    A *= 100;
    B *= 100;

    pair<int,int> ans = make_pair(A,0);

    for (int x=0;x<=F;x+=100) {
        bool wok = false;
        for (int i=0;A*i<=x;i++) {
            if ((x-A*i)%B == 0) {
                wok = true;
                break;
            }
        }
        if (!wok) continue;
        for (int y=0;y<=F-x;y++) {
            bool sok = false;
            for (int i=0;i*C<=y;i++) {
                if ((y-C*i)%D == 0) {
                    sok = true;
                    break;
                }
            }
            if (!sok) continue;
            if (x/100*E < y) continue;
            //cout<<density(x,y)<<" "<<x<<" "<<y<<endl;
            if (density(x,y)>density(ans.fi,ans.se)) {
                ans.fi = x;
                ans.se = y;
            }
        }
    }

    cout<<ans.fi + ans.se<<" "<<ans.se<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()

def resolve():
    def check(arr):
        height = 0
        for b, h in arr:
            if height+b < 0:
                return False
            height += h
        return True

    N = int(inp())
    plus = []
    minus = []
    total = 0
    for _ in range(N):
        # 1つのパーツを処理
        S = inpS()
        cum = 0 # 累積和(最高地点)
        bottom = 0 # 最下地点
        for s in S:
            if s == "(":
                cum += 1
            else:
                cum -= 1
                bottom = min(bottom, cum)

        total += cum
        if cum > 0:
            plus.append((bottom, cum))
        else:
            minus.append((bottom-cum, -cum))

    plus.sort(reverse=True)
    minus.sort(reverse=True)

    if check(plus) and check(minus) and total == 0:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    resolve()


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

int main(){
  int n,k,x,y;
  int ans = 0;
  cin >> n >> k >> x >> y;
  if(n > k){
    ans = x * k + y * (n - k);
    cout << ans << endl;
  }
  else{
    ans  = x * n;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, j, x;
    int a = 1;
    int counter = 0;
    int array[9] = {0};
    while (scanf("%d",&x)!=EOF) {
        counter = 0;
        for (i = 9; i >= 0; i--) {
            a = 1;
            for (j = 0; j < i; j++) {
                a = a * 2;
            }
            if (x >= a) {
                x = x - a;
                counter++;
                array[counter] = a;
            }
        }
        for (i = counter; i >= 1; i--) {
            if (i != 1) {
                printf("%d ",array[i]);
            }
            else {
                printf("%d\n",array[i]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    string org, rev;

    cin >> org;

    rev = org;
    reverse(rev.begin(), rev.end());

    if (rev == org) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;
typedef long long ll;

int main()
{
  ll h, m, h2, m2, k;
  cin >> h >> m >> h2 >> m2 >> k;

  cout << (h2 * 60 + m2) - (h * 60 + m) - k << endl;

  return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

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

    vector<int> data(N);
    vector<int> out(N,0);

    N--;

    for(int i=1; i<N; i++){
        cin >> data[i];
    }

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

    for(int i=0; i<=N; i++){
        out[data[i]]++;
    }
    
    for(int i=1; i<=N; i++){
        cout << out[i] << endl;
    }
}

Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
 
ll X[100100]; ll Y[100100]; ll Z[100100];
ll pow3(int a);
int main(){
  string T; cin >> T;
  
  for(int i = 0; i < 100100; i++){ X[i] = 0LL; Y[i] = 0LL; Z[i] = 0LL;}
  if(T[0] == 'A' || T[0] == '?'){ X[0] = 1LL;}
  int cnt=0; if(T[0] == '?')cnt++;
  for(int i = 0; i < (int) T.size()-1; i++){
    int flag;
    if(T[i+1] == 'A'){ flag = 1;} 
    if(T[i+1] == 'B'){ flag = 2;}
    if(T[i+1] == 'C'){ flag = 3;}
    if(T[i+1] == '?'){ flag = 4;}
    
    if( flag == 1 || flag == 4 ){ X[i+1]+=X[i]+pow3(cnt);Y[i+1]+=Y[i];Z[i+1]+=Z[i];}
    if( flag == 2 || flag == 4){ X[i+1]+=X[i]; Y[i+1]+=Y[i]+X[i];Z[i+1]+=Z[i];}
    if( flag == 3 || flag == 4){ X[i+1]+=X[i]; Y[i+1]+=Y[i];Z[i+1]+=Z[i]+Y[i];}
    X[i+1] %= MOD; Y[i+1] %= MOD; Z[i+1] %= MOD;
    if(flag == 4)cnt++;
  }
  
  cout << Z[(int)T.size()-1] << endl; return 0;}
      
ll pow3(int a){
  ll s=1,b=3;
  while(a){
    if(a%2){s*=b; s%=MOD;}
    b*=b; b%=MOD;
    a/=2;
  }
  return s;
}      
    


Measured memory_bytes: 2816
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val k = sc.nextInt()
  val res = Array.fill(k)(false)

  var i = 0
  var r = 7 % k
  res(r) = true
  var continue = true
  while (continue) {
    r = (((r * 10) % k) + 7 % k) % k
    if (res(r)) {
      continue = false
    } else {
      res(r) = true
    }
    i += 1
  }

  println(if (res(0)) i else -1)
}


Measured memory_bytes: 55452
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    counter = Counter()
    for _ in range(N):
        counter[input().strip()] += 1
    for verdict in ['AC', 'WA', 'TLE', 'RE']:
        print(f'{verdict} x {counter[verdict]}')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 69888
def password():
    for i in range(10):
        for j in range(10):
            for k in range(10):
                yield [str(i), str(j), str(k)]


n = int(input())
s = input()

ans = 0
for perm in password():
    if perm[0] in s:
        a = s.find(perm[0])
        if perm[1] in s[a + 1 :]:
            b = s[a + 1 :].find(perm[1])
            if perm[2] in s[a + 1 :][b + 1 :]:
                ans += 1

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
#define ull unsigned long long int
#define ll long long int
#define vll vector<ll>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define itr vll::iterator
#define all(c) c.begin(),c.end()
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define inf 1000000000000000001
 
#define rep(i, n)      for(ll i = 0; i <  n; ++i)
#define repA(i, a, n)  for(ll i = a; i <= n; ++i)
#define repD(i, a, n)  for(ll i = a; i >= n; --i)
 
using namespace std;
 
bool func(const pll &a, const pll &b){
    return a.s < b.s;
}
 
ll power(ll x, ll y) 
{ 
    if (y == 0) 
        return 1; 
    else if (y % 2 == 0) 
        return ((power(x, y / 2)%mod) * (power(x, y / 2)%mod)%mod); 
    else
        return (x * ((power(x, y / 2)%mod) * (power(x, y / 2)%mod)%mod))%mod; 
}
 
ll modInverse(ll a, ll m){
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1) return 0;
    while (a > 1){
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0) x += m0;
    return x;
} 

void solve(int t){
    ll n,k,  m;
    cin >> n >> m;
    vll cc(n+1, 0);
    vll cnt(n+1, 0);
    ll penal = 0, cr = 0;
    rep(i, m){
        ll tmp;
        string s;
        cin >> tmp >> s;
        if(cc[tmp] == 0){
            // penal++;
            if(s == "AC"){
                // cr++;
                cc[tmp] = 1;
            }
            else cnt[tmp]++;
        }
    }
    repA(i, 1, n){
        if(cc[i]){
            cr++;
            penal += cnt[i];
        }
    }
    cout << cr << " " << penal;
}
 
int main(){
 
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t, tmp = 0;
    // cin >> t;
    t = 1;
    while(tmp++ < t){
        // cout << "Case #" << tmp << ": ";
        solve(tmp-1);
        if(t-tmp) cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define d_5 100000
#define d9_7 1000000007
#define vll vector<vector<long long>>
#define vl vector<long long>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define pf push_front
#define ld long double
#define ll long long

int main(void){
  string s;
  cin>>s;
  if(s=="SUN"){
  	cout<<7;
  }else if(s=="MON"){
  	cout<<6;
  }else if(s=="TUE"){
  	cout<<5;
  }else if(s=="WED"){
  	cout<<4;
  }else if(s=="THU"){
  	cout<<3;
  }else if(s=="FRI"){
  	cout<<2;
  }else if(s=="SAT"){
  	cout<<1;
  }
  return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll x, y; cin >> x >> y;
    cout << (abs(x - y) > 1 ? "Alice" : "Brown") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  cin >> a;
  b=a/1000;
  c=(a/100)%10;
  d=(a/10)%10;
  e=a%10;
  
  if (((b==c)&&(c==d)) || ((c== d)&&(d==e)) ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

int main() {
    int i = 1;
    while(i <= 5) {
        int tmp;
        cin >> tmp;
        if(tmp == 0) {
            cout << i << endl;
            return 0;
        } else {
            i++;
        }
    }
}

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

int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  if (K <= 2) {
    if (K == 2) S = S + S;
    int ans = 0;
    for (int i = 1; i < S.size(); i++) {
      if (S[i] == S[i - 1]) {
        ans++, i++;
      }
    }
    cout << ans << endl;
    return 0;
  }

  int N = S.size();
  S = S + S + S;
  ll ans = 0, ans1 = 0, ans2 = 0;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == S[i - 1]) {
      ans++;
      if (N <= i && i <= 2 * N - 1) {
        ans1++;
      } else if (2 * N <= i) {
        ans2++;
      }
      i++;
    }
  }
  // cout << ans << ans1 << ans2 << K / 2 << (K - 1) / 2 << endl;
  cout << (ans - ans1 - ans2) + ans1 * (K / 2) + ans2 * ((K - 1) / 2) << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        HashSet<String> set = new HashSet<>();
        int n = sc.nextInt();
        for(int i=0; i<n; i++){
            String com = sc.next();
            String str = sc.next();
            if(com.charAt(0) == 'i'){
                // insert
                set.add(str);
            }else{
                // find
                if(set.contains(str)) System.out.println("yes");
                else System.out.println("no");
            }

        }

    }


    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}


Measured memory_bytes: 144948
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

static const double pi = 3.141592653589793;
int main(){
    long double a,b;
    cin>>a>>b;
    int h,m;
    cin>>h>>m;
    double hrad,mrad,rad;
    hrad=h*30+0.5*m;
    mrad=m*6;
    if(hrad>=mrad){
        rad=hrad-mrad;
    }
    else{
        rad=mrad-hrad;
    }
    double trad;
    trad=rad*pi/180;
    //cout<<rad<<endl;
    if(rad==0){
        cout<<abs(a-b)<<endl;
    }
    if(rad==180){
        cout<<a+b<<endl;
    }
    if(rad!=0&&rad!=180){
        cout<<setprecision(10)<<sqrt(a*a+b*b-2*a*b*cos(trad))<<endl;
    }
}



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

int main() {
	
	string S, T;
	cin >> S >> T;
	vector<int> start(26, -1);
	vector<int> goal(26, -1);
	for (int i = 0; i < S.size(); i++)
	{
		int a = S[i] - 'a';
		int b = T[i] - 'a';

		if (start[a] != -1 || goal[b] != -1) {
			if (start[a] != b || goal[b] != a) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {

			start[a] = b;
			goal[b] = a;
		}
	}

	cout << "Yes" << endl;
	
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <utility>

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

    auto vec = std::vector<std::pair<int, bool>>(n + 1);
    for (int i = 1; i < n + 1; ++i) {
        int tmp;
        std::cin >> tmp;

        vec[i] = std::make_pair(tmp, false);
    }

    int current_pos = 1;
    int result = 0;
    while(true)
    {
        /* std::cout << result << ": " << current_pos << std::endl; */
        if(current_pos == 2)
        {
            std::cout << result << std::endl;
            return 0;
        }

        auto next_pos = vec[current_pos].first;
        if(vec[current_pos].second)
        {
            break;
        }

        vec[current_pos] = std::make_pair(next_pos, true);

        current_pos = next_pos;

        result++;
    }

    std::cout << "-1" << std::endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
using ll = long long;
using P = pair<ll,ll>;
 
int main (){
  ll n,k; 
  cin>>n>>k;
  vector<double> v(n);
  rep(i,n){
    double num;cin>>num;
    double a = num*(num+1)/2;
    v.at(i) = a/num;
  }
  double sum;
  rep(i,k){
    sum+=v.at(i);
  }
  double maxsum = sum;
  rep(i,n-k){
    sum-=v.at(i);
    sum+=v.at(i+k);
    maxsum = max(sum,maxsum);
  }
  cout << fixed << setprecision(10) << maxsum << endl;
}

Measured memory_bytes: 1792
// copied
#include<cstdio>
#include<queue>
using namespace std;
inline int read() {
	int x;
	char c;
	while ((c = getchar()) < '0' || c > '9')
		;
	for (x = c - '0'; (c = getchar()) >= '0' && c <= '9';)
		x = x * 10 + c - '0';
	return x;
}
#define N 262144
#define INF 0x3FFFFFFF
#define mp make_pair
#define tp pq.top()
#define F first
#define S second
int t1[N * 2 + 5], t2[N * 2 + 5], p[N];
priority_queue<pair<pair<int, int>, pair<int, int> > > pq;
void build(int*t) {
	for (int i = N; --i;)
		t[i] = min(t[i << 1], t[i << 1 | 1]);
}
int query(int*t, int l, int r) {
	int res = INF;
	for (l += N - 1, r += N + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
		if (~l & 1)
			res = min(res, t[l + 1]);
		if (r & 1)
			res = min(res, t[r - 1]);
	}
	return res;
}
void push(int l, int r) {
	if (l > r)
		return;
	int x = query(l & 1 ? t1 : t2, l, r);
	pq.push(mp(mp(-x, query(l & 1 ? t2 : t1, p[x] + 1, r)), mp(l, r)));
}
int main() {
	int n = read(), i, x, y, l, r;
	for (i = 1; i <= n; ++i)
		p[x = read()] = i,  t1[i + N] = i & 1 ? x : INF, t2[i + N] =
				i & 1 ? INF : x;
	build(t1);
	build(t2);
	for (push(1, n); !pq.empty();) {
		x = -tp.F.F;
		y = tp.F.S;
		l = tp.S.F;
		r = tp.S.S;
		printf("%d %d ", x, y);
		pq.pop();
		push(l, p[x] - 1);
		push(p[x] + 1, p[y] - 1);
		push(p[y] + 1, r);
	}
}


Measured memory_bytes: 8084
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    println!("{}", a * b - a - b + 1);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vec x(n),y(n);
  for(ll i=0;i<n;i++) cin >> x[i] >> y[i];
  for(ll i=0;i<n;i++) {
    vector<double> d;
    for(ll j=0;j<n;j++) {
      if(i==j) continue;
      d.push_back(atan2(y[j]-y[i],x[j]-x[i]));
    }
    sort(d.begin(),d.end());
    double r=0;
    ll k=d.size();
    for(ll j=0;j<k;j++) {
      d.push_back(d[j]+2*M_PI);
    }
    for(ll j=0;j<k;j++) {
      r=max(r,M_PI-(d[j+k]-d[j+1]));
    }
    cout << fixed << setprecision(10) << r/(2*M_PI) << endl;
  }
}

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

#define ll int long long
#define dll double long long
#define forei(i,n,x) for(int i=n;i<=x;i++)
#define fored(i,n,x) for(int i=n;i>=x;i--)
#define forni(i,n,x) for(int i=n;i<x;i++)
#define fornd(i,n,x) for(int i=n;i>x;i--)
#define SQ(a) (a)*(a)
#define MOD 1000000007
#define sortvi(v) sort(v.begin(),v.end())
#define sortvd(v) sort(v.rbegin(),v.rend())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pv(v) for(auto it: v) cout<<it
#define endl '\n'   //Take care in case of interactive problems
#define MAX1 100005
#define MAX2 200005
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

typedef pair<ll,ll> pl;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;


int main() 
{ 
   ll n;cin>>n;
   ll sum=0;
   for(ll i=1;i<=n;i++)
   {
       if(i%3&&i%5)
       sum+=i;
   }
   cout<<sum<<endl;
   
    return 0; 
} 


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i,n,init) for(ll i=init;i<(n);i++)
#define repd(i,n,init) for(ll i=(n);i>=init;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define repb(bit,n,init) for(ll bit=init;bit<(1<<n);++bit)

int main()
{
    int n;
    cin >> n;
    map<string,int> mp;
    repi(i,n,0){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
    return 0;
}

Measured memory_bytes: 19256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

ll A[3010][3010];
ll dp[3010][3010][4];

int main(){
  ll r,c,k;
  cin>>r>>c>>k;
  

  rep(i,3010){
    rep(j,3010) A[i][j]=0;
  }
  
  ll x,y,z;
  rep(i,k){
    cin>>x>>y>>z;
    A[x][y]=z;
  }
  
  rep(i,3010){
    rep(j,3010){
      rep(k,4) dp[i][j][k]=0;
    }
  }
  
  for(int i=1;i<=r;i++){
    for(int j=1;j<=c;j++){
      for(int k=0;k<=3;k++){
        if(A[i][j]==0){
          if(k==0) dp[i][j][k]=max(max(max(dp[i-1][j][0],dp[i][j-1][k]),
                                   max(dp[i-1][j][1],dp[i-1][j][2])),dp[i-1][j][3]);
          else dp[i][j][k]=dp[i][j-1][k];
        }
        else{
          if(k==0) dp[i][j][k]=max(max(max(dp[i-1][j][0],dp[i][j-1][k]),
                                   max(dp[i-1][j][1],dp[i-1][j][2])),dp[i-1][j][3]);
          else if(k==1) dp[i][j][k]=max(max(max(dp[i][j-1][k],dp[i][j-1][k-1]+A[i][j]),
                                        max(dp[i-1][j][0],dp[i-1][j][1])+A[i][j]),
                                        max(dp[i-1][j][2],dp[i-1][j][3])+A[i][j]);
          else dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+A[i][j]);
        }
      }
    }
  }
  ll ans=0;
  rep(i,4){
    ans=max(ans,dp[r][c][i]);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 357540
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n + 1), b(n);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    lint ret = 0;
    for (int i = 0; i < n; ++i) {
        ret += min(a[i], b[i]);
        b[i] -= min(a[i], b[i]);
        ret += min(a[i + 1], b[i]);
        a[i + 1] -= min(a[i + 1], b[i]);
    }
    cout << ret << "\n";
    return 0;
}

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

#define ll long long int
#define str string
#define sec .second

ll MOD = 1000000007,INFL = 1ll << 60,INF = 1 << 30;
ll A[10000000] = {};
ll X[1000000] = {};
ll aiti[10000];
int dy[]={0, 0, 1, -1},dx[]={1, -1, 0, 0};
vector <ll> v;
ll a = 0,b = 0,c = 0,n = 0,sum = 0, max = INF;
str S;
int ans = 0;

int findDigits(int n) {
        int i = 0;
        while (n > 0) {

                sum += n%10;
                n /= 10;
                i++;
        }
        return i;
}


int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        //Code Line
  for(int i = 0;i < 1000000;i++)A[i] = 1;
cin >> n;
for(int i = 0;i < n;i++)cin >> A[i];
for(int i = 0;i < n;i++){
  if(A[i] < 0){
    //判定
    if(A[i] <= 0 && A[i+1] >= 0 && A[i+2] <= 0){
      A[i] *= -1;A[i+2] *= -1;
 
    }
    else if(A[i] <= 0 && A[i+1] <= 0){
      A[i] *= -1;A[i+1] *= -1;
   
    }  
   else {
     A[i] *= -1;
     a++;
   }
  }

}
for(int i = 0;i < n;i++)b += A[i];
sort(A,A + n);
a %= 2;
for(int i = 0;i < a;i++){
  b -= A[i] + A[i];
}
cout << b << endl;
  //Code Line
        return 0;
}


Measured memory_bytes: 10496
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string S;
ll K;

int main()
{
    cin >> S;
    cin >> K;
    if (K == 1)
    {
        cout << S[0] << endl;
        return 0;
    }

    for (int i = 0; i < K; i++)
    {
        if (S[i] != '1')
        {
            cout << S[i] << endl;
            return 0;
        }
    }

    cout << '1' << endl;
}


Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	n := len(s)
	dp := make([][13]int, n+1)

	dp[0][0] = 1

	mod := int(1e9 + 7)
	mm := [6]int{
		1, 10, 9, 12, 3, 4,
	}

	di := n - 1

	for i := 0; i < n; i++ {
		d := mm[di%6]
		for iii := 0; iii < 13; iii++ {
			if s[i] == '?' {
				for iiii := 0; iiii <= 9; iiii++ {
					m := (d*iiii + iii) % 13
					dp[i+1][m] += dp[i][iii]
					dp[i+1][m] %= mod
				}

				continue
			}
			m := (d*(int(s[i]-'0')) + iii) % 13
			dp[i+1][m] += dp[i][iii]
			dp[i+1][m] %= mod
		}
		di--
	}
	fmt.Fprintln(writer, dp[n][5])
	writer.Flush()
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)

template <typename T>
T pow_mod(T x, T n, T mod)
{
	T res = 1;
	while (n > 0)
	{
		if (n & 1)
			res = (res * x) % mod;
		x = (x * x) % mod;
		n >>= 1;
	}
	return res;
}

int main()
{
	ull n = 0;
	cin >> n;
	ll a,b,c;cin>>a>>b>>c;

	const ll maxN = 200000;
	vector<ll> inv( maxN, 1 );
	for( ll i = 2; i < maxN; ++i )
		inv[i] = cMOD - inv[cMOD % i] * ( cMOD / i ) % cMOD;
	auto add = []( ll a, ll b) { return ( a + b ) % cMOD; };
	auto sub = []( ll a, ll b) { return ( a + cMOD -b ) % cMOD; };
	auto mul = []( ll a, ll b) { return a * b % cMOD; };
	auto div = [&inv]( ll a, ll b) { return a * inv[b] % cMOD; };
	
	ll prev = 1;
	ll prevc = 1;
	ll ans = 0;
	ll abn = div(div(mul(add(a,b),100),100-c),100-c);
	REP(i,n)
	{
		if(i==0) { prev = mul(abn,n); prevc = pow_mod(div(a,add(a,b)),n,cMOD); }
		else{ prev = add(prev,abn); prevc = div(mul(div(mul(prevc,b),a+b),n-1+i),i); }
		ans = add(ans,mul(prev,prevc));
	}
	REP(i,n)
	{
		if(i==0) { prev = mul(abn,n); prevc = pow_mod(div(b,add(a,b)),n,cMOD); }
		else{ prev = add(prev,abn); prevc = div(mul(div(mul(prevc,a),a+b),n-1+i),i); }
		ans = add(ans,mul(prev,prevc));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

    int N, i;
    scanf("%d", &N);
    //printf("N:%d", N);

    const int MAX = N+1;
    int ti[MAX], xi[MAX], yi[MAX]; // i=0にt=0の条件:(x,y)=(0,0)を格納しないとN=1の処理が出来ない
    char dammy;

    // 配列初期化, t=0の条件を追加
    for (i = 0; i < N;i++){
        ti[i] = xi[i] = yi[i] = 0;
    }

    for (i = 1; i < MAX; i++)
    {
        scanf("%c", &dammy);
        scanf("%d %d %d", &ti[i], &xi[i], &yi[i]);
        
    }

/*
    for (i = 0; i < N; i++)
    {
        printf("%d %d %d", ti[i], xi[i], yi[i]);
    }

*/

    int distance = 0;
    int judge = 1;
    /*
    for (i = 0; i < MAX-1; i++){
        distance = abs((xi[i + 1] - xi[i]) + (yi[i + 1] - yi[i]));
        if((distance <= abs((ti[i+1]-ti[i]))&&(distance%2 == abs((ti[i+1]-ti[i]))%2))){
            printf("Yes");
        }else{
            printf("No");
        }
    }
    */
    for (i = 0; i < MAX-1; i++){
        distance = abs((xi[i + 1] - xi[i]) + (yi[i + 1] - yi[i]));
        if((distance <= abs((ti[i+1]-ti[i]))&&(distance%2 == abs((ti[i+1]-ti[i]))%2))){
            judge *= 1;
        }else{
            judge *= 0;
        }
    }

    if(judge == 1){
        printf("Yes");
    }else{
        printf("No");
    }

        return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using P = pair<int, int>;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<int> y(m);

    for(int i = 0; i < m; i++) cin >> p[i] >> y[i];
    vector<vector <P> > data(n);
    for(int i = 0; i < m; i++){
        data[p[i]-1].push_back(make_pair(y[i], i));
    }
    for(int i = 0; i < n; i++){
        if(data[i].size()){
            sort(data[i].begin(), data[i].end());
        }
    }

    vector<P> ans(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j < data[i].size(); j++){
            ans[data[i][j].second] = make_pair(i+1, j+1);
        }
    }

    for(int i = 0; i < m; i++){
        printf("%06d%06d\n", ans[i].first, ans[i].second);
    }
    return 0;
}

Measured memory_bytes: 8576
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;

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

    if(T.size() > S.size()){
        cout << "UNRESTORABLE";
        return 0;
    }

    for(int i = S.size()- 1; i >= 0; --i){
        if(i < T.size() - 1){
            cout << "UNRESTORABLE";
            return 0;
        }

        int start = i - T.size() + 1;
        bool check = true;
        for(int j = 0; j < T.size(); ++j){
            if(S[start + j] == '?'){
                continue;
            }
            else if(S[start + j] != T[j]){
                check = false;
                break;
            }
        }

        if(check){
            for(int j = 0; j < start; ++j){
                if(S[j] == '?'){
                    S[j] = 'a';
                }
            }
            for(int j = 0; j < T.size(); ++j){
                S[start + j] = T[j];
            }
            for(int j = i * 1; j < S.size(); ++j){
                if(S[j] == '?'){
                    S[j] = 'a';
                }
            }

            cout << S;
            return 0;
        }
    }

}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
  int n;
  int a, b, c, d;
  int com;

  while(cin >> n)
    {
      com = 0;
      if(n == EOF) break;
      
      for(a = 0 ; a < 10 ; a++)
	{
	  for(b = 0 ; b < 10 ; b++)
	    {
	      for(c = 0 ; c < 10 ; c++)
		{
		  for(d = 0 ; d < 10 ; d++)
		    {
		      if(a + b + c + d == n) com++;
		    }
		}
	    }
	}
      cout << com << endl;
    }
  return 0;
}

Measured memory_bytes: 0
using System;

class Program
{
    static void Main(string[] args)
    {
        char[] o = Console.ReadLine().ToCharArray();
        char[] e = Console.ReadLine().ToCharArray();
        char[] ans = new char[o.Length + e.Length];
        int count = 0;
        for (int i = 0; i < o.Length + e.Length; i++)
        {
            if (i % 2 == 0)
                Console.Write(o[count]);
            else
            {
                Console.Write(e[count]);
                count++;
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()


void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

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

int main() {
    fastik();
    ll n;cin>>n;
    vll a(n);
    vll l(n);
    vll r(n);
    forn(i,n){
        cin >> a[i];
    }
    l[0] = a[0];
    fore(i,1,n-1){
        l[i] = gcd(l[i-1],a[i]);
    }
    r[n-1] = a[n-1];
    for(int i = n-2; i>=0; i--){
        r[i] = gcd(r[i+1],a[i]);
    }
    vll m(n,0);
    fore(i,1,n-2){
        m[i] = gcd(l[i-1],r[i+1]);
    }
    m[0] = r[1];
    m[n-1] = l[n-2];
    ll mx = -1;
    forn(i,n){
        mx = max(mx,m[i]);
    }
    cout << mx;
}

Measured memory_bytes: 3456
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<ctime>
#include<cmath>
#include<cstdlib>
#include<utility>
#include<bitset>
using namespace std;
const int maxn=(1e5+10);
int n,a[maxn],ans=0;
map<int,int> mp; 
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
	map<int,int>::iterator it;
	for(it=mp.begin();it!=mp.end();it++)
	{
		if(it->first>it->second)
		{
			ans+=it->second;
			continue;
		}
		if(it->first==it->second)
		{
			continue;
		}
		ans+=it->second-it->first;
	}
	cout<<ans<<endl;
	return 0;
}


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


// 関数
long long attack(long long n) {
  // 処理内容 : 
 
  // ベースケース
  if (n == 1) {
    return 1;  // モンスターを倒して終了
  }
 
  // 再帰ステップ
  long long num = attack(n/2);  // 0 ~ (n-1) の総和
  return 1+num*2;  // 自分の下のブランチは２つ
}

int main() {
  
  long long H;
  cin >> H;

  long long res =0;
  
  res = attack(H);
  cout << res << endl;
}





Measured memory_bytes: 256
program struck_out
  implicit none
  integer :: n, m, k, i, j, l, s, t
  integer(8) :: a(100000), dp(0:100000,300), deq(100000), nxt
  a = 0_8
  dp = 0_8
  deq = 0_8
  read(*,*) n, m, k
  read(*,*) a(1:n)
  dp(1:n,1) = a(1:n)
  do j = 2, k
    s = 1
    t = 1
    do i = 1, n
      if (s.eq.t) then
        dp(i,j) = -1_8
      else
        dp(i,j) = int(j,8)*a(i)+dp(deq(s),j-1)
        if (i+1-deq(s).gt.m) s = s+1
      end if
      nxt = dp(i,j-1)
      if (nxt.ne.-1_8) then
        do while (s.ne.t.and.dp(deq(t-1),j-1).lt.nxt)
          t = t-1
        end do
        deq(t) = i
        t = t+1
      end if
    end do
  end do
  write(*,'(i0)') maxval(dp(1:n,k))
  stop
end program struck_out

Measured memory_bytes: 236800
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;


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

  int ans = 0, cnt = 0;
  for (int i = 0; i < N - 1; i++){
    if (H[i] >= H[i + 1]){
      cnt++;
    }else{
      if (ans < cnt) ans = cnt;
      cnt = 0;
    }
  }
  if (cnt > ans) ans = cnt;
  
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    if a[i]<400:
        l.append("hai")
    elif a[i]<800:
        l.append("cha")
    elif a[i]<1200:
        l.append("midori")
    elif a[i]<1600:
        l.append("mizu")
    elif a[i]<2000:
        l.append("ao")
    elif a[i]<2400:
        l.append("ki")
    elif a[i]<2800:
        l.append("orange")
    elif a[i]<3200:
        l.append("red")
    else:
        l.append("free")
ls=set(l)
if "free" not in ls:
    print(len(ls),len(ls))
else:
    x=len(ls)-1#free以外の色の数
    y=x+l.count("free")
    #if y>8:
        #y=8
    
    if x==0:
        x=1
    print(x,y)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  char c;
  cin >> c;
  c++;
  cout << c << endl;
return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader((new InputStreamReader(System.in)));
        int N = Integer.parseInt(reader.readLine());
        long res = 0;
        int[][] a = new int[10][10];
        for(int i=1;i<=N;i++){
            String s = Integer.toString(i);
            a[Character.getNumericValue(s.charAt(0))][i%10]+=1;
        }
        for(int u=0;u<10;u++){
            res+=a[u][u]*a[u][u];
            for(int i=u+1;i<10;i++){
                res+=2*a[u][i]*a[i][u];
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 32340
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };
const string nr[10] = { "0","1","2","3","4","5","6","7","8","9" };


bool larger(string a, string b) {
	int i;
	if (a.size() > b.size()) {
		return true;
	}
	if (a.size() < b.size()) {
		return false;
	}
	for (i = 0; i < a.size(); i++) {
		if (a[i] > b[i]) {
			return true;
		}
		if (a[i] < b[i]) {
			return false;
		}
	}
	return false;
}

int main(void) {
	int n, m, i, j, ain;
	const int nus[10] = { 0,2,5,5,4,5,6,3,7,6 };
	vector<int> a;
	string dp[10003], lk;
	
	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		scanf("%d", &ain);
		a.push_back(ain);
	}

	for (i = 0; i <= n; i++) {
		dp[i] = "0";
	}
	
	for (i = 2; i <= n; i++) {
		for (j = 0; j < m; j++) {
			if (i < nus[a[j]] || (i - nus[a[j]] > 0 && dp[i - nus[a[j]]] == "0")) {
				continue;
			}
			lk = dp[i - nus[a[j]]] + nr[a[j]];
			if (larger(lk, dp[i])) {
				dp[i] = lk;
			}
		}
	}

	cout << dp[n].substr(1, dp[n].size() - 1) << '\n';

	return 0;
}

Measured memory_bytes: 43520
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
#include <queue>
#include <iomanip>
#include <vector>
#include <numeric>
//#include <bits/stdc++.h>

using namespace std;
const int INF = 1 << 30 ;
queue<int> Q;


bool BFS()
{
    while(!Q.empty())
    {
        int x;
        x = Q.front();
        Q.pop();
        if(x==0)
        {
            return true;
        } 
        else 
        {
            if(x-4>=0)
                Q.push(x-4);
            if(x-7>=0)
                Q.push(x-7);
        }
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    Q.push(n);
    if(BFS())
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define N 100000

int a[N];

int partition(int p,int r){
  int x=a[r],i=p-1,j,n;

  for(j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      n=a[i]; a[i]=a[j]; a[j]=n;
    }
  }
    n=a[i+1]; a[i+1]=a[r]; a[r]=n;

    return i+1;
}

int main(){
  int n,i,di;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);
  di=partition(0,n-1);

  for(i=0;i<di;i++) printf("%d ",a[i]);
  printf("[%d] ",a[i++]);
  for(;i<n-1;i++) printf("%d ",a[i]);
  printf("%d\n",a[i]);

  return 0;
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	string s;cin >> s;
	string ans = "";
	rep(i,s.size()){
		if(s[i]=='0') ans.push_back('0');
		else if(s[i]=='1') ans.push_back('1');
		else if(ans.size()>0) ans = ans.substr(0,ans.size()-1);
	}
	cout << ans << endl;
	
} 
 

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

int main() {
    int N;
    cin >> N;
    map<string, int> S;
    int max_count = 0;
    for(int i=0; i<N; i++){
        string s;
        cin >> s;
        S[s]++;
        max_count = max(max_count, S[s]);
    }

    vector<string> maxes;
    for(pair<string, int> freq : S){
        if(freq.second == max_count){
            maxes.push_back(freq.first);
        }
    }

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

    for(string s : maxes){
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 26868