akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,a[maxn],dp[maxn];

int main()
{
	int n=read(); dp[0]=1; int f=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		if(dp[a[i]-1]) dp[a[i]]=1;
	}
	for(int i=n;i>=1;i--) if(dp[i]) {cout<<n-i; f=1; break;}
	if(f==0) puts("-1");
	return 0;
}

Measured memory_bytes: 1792
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


N, M = map(int,input().split())
A = [int(input()) for i in range(M)]

for i in range(M-1):
    if A[i+1] - A[i] == 1:
        print(0)
        exit()

d = [1] * (N+1)
for i in range(len(A)):
    d[A[i]] = 0

for i in range(2, N+1):
    if d[i] != 0:
        d[i] = (d[i-1] + d[i-2]) % (mod)
print(d[N])


Measured memory_bytes: 9380
#include <bits/stdc++.h>
using namespace std;
long long n, a, b;
int main() {
	cin >> n >> a >> b;
	if (abs(a - b) % 2 == 0) {
		cout << abs(a - b) / 2 << '\n';
	} else {
		cout << min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2) << '\n';
	}
}

Measured memory_bytes: 256
price = [int(input()) for _ in range(5)]
min_sum = float('inf')
for i in range(5):
    sum = 0
    for j in range(5):
        if j == i:
            sum += price[i]
        else:
            if price[j] % 10 == 0:
                sum += price[j]
            else:
                sum += price[j] + 10 - (price[j] % 10)
    if sum <  min_sum:
        min_sum = sum
print(min_sum)


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){
    int n;
    scanf("%d",&n);
    int mochi[n];
    for (int l = 0; l < n; ++l) {
        scanf("%d",&mochi[l]);
    }

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(i == j)continue;
            if (mochi[i] > mochi[j]){
                int temp;
                temp = mochi[j];
                mochi[j] = mochi[i];
                mochi[i] = temp;
            }
        }
    }

    int count = 1;
    for (int k = 1; k < n; ++k) {
        if (mochi[k - 1] == mochi[k])continue;
        count++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1700
N,M=map(int,input().split())
s=[]
c=[]
x=dict()
for i in range(M):
    a,b=map(int,input().split())
    s.append(a)
    c.append(b)

for i in range(M):
    if s[i] in x:
        if c[i]!=x[s[i]]:
            print(-1)
            exit()
    else:
        x[s[i]]=c[i]

if M==0:
    ans=""
    for i in range(N):
        if i==0:
            ans="1"
        else:
            ans=ans+"0"
    if N==1:
        print(0)
        exit()
    print(ans)
    exit()
l=[]
if N!=1:
    for i in range(M):
        if s[i]==1:
            if c[i]==0:
                print(-1)
                exit()


for i in range(N):
    if i==0:
        l.append(1)
    else:
        l.append(0)
if N==1:
    l=[]
    l.append(0)
for i in range(M):
    l[s[i]-1]=c[i]
ans=""
#print(l)

for i in range(N):
    ans=ans+str(l[i])
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <map>
#include <stack>
#include <string.h>
#include <array>
#include <bitset>

using namespace std;

typedef long long ll;

map < ll, bool > bio;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin >> n >> k;
	n-=n/k*k;
	cout << min(n, abs(n-k)) << '\n';
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    for(int i = x-k+1; i <= x+k-1; i++) {
        cout << i;
        if(i != x+k-1) {
            cout << " ";
        }
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long k[21][101],n,q[100],sum;
main(){cin>>n;
for(int i=0;i<n;i++){cin>>q[i];}
k[q[0]][0]=1;
for(int i=1;i<n-1;i++){for(int j=0;j<21;j++){
if(j+q[i]<21){k[j+q[i]][i]+=k[j][i-1];}
if(j-q[i]>=0){k[j-q[i]][i]+=k[j][i-1];}
}}
cout<<k[q[n-1]][n-2]<<endl;}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  ll n,k;
  string s;
  cin >>n>>k;
  cin >>s;
  vector <ll> ee;//firstに何個か、secondにその数字
  ll c=1;
 if(s[0]=='0') ee.push_back(0);
 for(ll i=0;i<n;i++){//配列の中身がそれぞれ何個あるかのカウント
  if(s[i]==s[i+1]){
    c++;
    if(i==n-2){//122333みたいなときは3のところがansに入らないので
      ee.push_back(c);
      break;
    }
  }
  else{
    ee.push_back(c);
    if(i==n-2) {
        ee.push_back(1);//112223とかのときにansに3の分を足すため
        break;
    }
    c=1;
  }
}
ll es=ee.size();
ll sum[es+1],ans=0;
for(ll i=0;i<=es;i++) sum[i]=0;
for(ll i=0;i<es;i++) sum[i+1]+=(sum[i]+ee[i]);
for(ll i=0;i<=es;i+=2){
  ll r=i+k*2+1;
  if(r>=(es+1)) r=es;
  ans=max(ans,sum[r]-sum[i]);
}
cout <<ans<<endl;
}


Measured memory_bytes: 2164
n = int(input())

def f(x):
    count = 0
    for i in range(1,x+1):
        if x % i == 0:
            count += 1
    return count

ans = 0

for i in range(1,n+1):
    if f(i) == 8 and i % 2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void doIt() {
		sC();
	}
	
	void sC() {
		int K = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		long num = A;
		K -= A - 1;
		if(K % 2 != 0) {
			K--;
			num++;
		}
		if(B - A < 2) {
			num += K;
		}
		else {
			num += (long)(B - A) * (K / 2);
		}
		System.out.println(num);
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
X,K,D = map(int,input().split())

X = abs(X)
s = X // D
if s < K:
    if (K-s) % 2 == 0:
        print(X-s*D)
    else:
        print(abs(X-s*D-D))
else:
    print(X-K*D)


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

using ll = long long;

constexpr ll base = 211;
constexpr ll M = 1000000000000037LL;

ll get_hash(vector<string> const& v) {
    hash<string> hash_fn;
    ll res = 0;
    for(int i=0; i<v.size(); ++i) {
        res = (hash_fn(v[i]) + res * base) % M;
    }
    return res;
}

int main() {
    vector<string> panels(8);
    while(cin >> panels[0]) {
        for(int i=1; i<8; ++i) {
            cin >> panels[i];
        }
        sort(panels.begin(), panels.end());

        set<ll> s;
        vector<int> rot1 = {2, 3, 4, 5, 6, 7, 0, 1};
        vector<int> rot2 = {5, 4, 3, 2, 1, 0, 7, 6};
        vector<int> rot3 = {0, 6, 1, 7, 3, 5, 2, 4};
        int res = 0;
        do {
            vector<string> v = panels;
            set<ll> ss;
            for(int i=0; i<2; ++i) {
                for(int j=0; j<2; ++j) {
                    for(int k=0; k<4; ++k) {
                        ss.insert(get_hash(v));
                        vector<string> next(8);
                        for(int l=0; l<8; ++l) {
                            next[l] = move(v[rot1[l]]);
                        }
                        v = move(next);
                    }
                    vector<string> next(8);
                    for(int l=0; l<8; ++l) {
                        next[l] = move(v[rot2[l]]);
                    }
                    v = move(next);
                }
                vector<string> next(8);
                for(int l=0; l<8; ++l) {
                    next[l] = move(v[rot3[l]]);
                }
                v = move(next);
            }
            bool f = false;
            for(auto hs : ss) {
                f |= s.count(hs);
            }
            res += !f;
            s.insert(ss.begin(), ss.end());
        } while(next_permutation(panels.begin(), panels.end()));
        cout << res << endl;
    }
}


Measured memory_bytes: 5004
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int a, b, v, w, t;
    std::cin >> a >> v >> b >> w >> t;
    int s = std::abs(a - b);
    if (v <= w) {
        std::cout << "NO" << std::endl;
    } else {
        int d = v - w;
        if (1ll * d * t >= s) {
            std::cout << "YES" << std::endl;
        } else {
            std::cout << "NO" << std::endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();

		int result = 0;

		if (op.equals("+")) {
			result = a + b;
		} else if (op.equals("-")) {
			result = a - b;
		}

		System.out.println(result);

		sc.close();

	}

}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> X(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++) {
      int x, y;
      cin >> x >> y;
      x--;
      X[i].emplace_back(make_pair(x, y));
    }
  }
  int res = 0;
  for (int b = 0; b < (1 << N); b++) {
    bool ok = true;
    for (int i = 0; i < N; i++) {
      if (!((b >> i) & 1)) continue;
      if ((b >> i) & 1) {
        for (int j = 0; j < (int)X[i].size(); j++) {
          if (X[i][j].second != ((b >> X[i][j].first) & 1)) ok = false;
        }
      }
    }
    if (ok) res = max(res, __builtin_popcount(b));
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, M;
char mat[25][25];
ll dx[4] = {-1, 1, 0, 0};
ll dy[4] = {0, 0, -1, 1};
ll ans;
ll dist[25][25];
ll vis[25][25];

bool isValid(int X, int Y) {
	if(X < N && Y < M && mat[X][Y] == '.') {
		return 1;
	}
	return 0;
}
ll bfs(ll indX, ll indY) {
	// cout << "this\n";
	queue<pair<ll, ll>> q;
	q.push({indX, indY});
	dist[indX][indY] = 0;
	while(!q.empty()) {
		indX = q.front().first;
		indY = q.front().second;
		q.pop();
		for(int i = 0; i < 4; i++) {
			if(isValid(indX + dx[i], indY + dy[i]) && !vis[indX + dx[i]][indY + dy[i]]) {
				vis[indX + dx[i]][indY + dy[i]] = 1;
				dist[indX + dx[i]][indY + dy[i]] = min(dist[indX + dx[i]][indY + dy[i]], 1 + dist[indX][indY]);
				q.push({indX + dx[i], indY + dy[i]});
			}
		}
	}
	ll ans1 = -1e18;
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			// cout << dist[i][j] << " ";
			if(dist[i][j] == 1e18) {
				continue;
			}
			ans1 = max(ans1, dist[i][j]);
		}
		// cout <<"\n";
	}
	return ans1;
} 


int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			cin >> mat[i][j];
		}
	}
	for(int i = 0; i < N; i++) {
		for(int j = 0; j < M; j++) {
			if(mat[i][j] == '.') {
				for(int k = 0; k < N; k++) {
					for(int l = 0; l < M; l++) {
						dist[k][l] = 1e18;
						vis[k][l] = 0;
					}
				}
				ans = max(ans, bfs(i, j));
			}
		}
	}
	cout << ans << " ";
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,k;
    cin>>a>>b>>c>>d;
    for(int i=1;;i++){
        c=c-b;
        a=a-d;
        if(c<=0){
            k=1;
            break;
        }
        if(a<=0){
            k=0;
            break;
        }
    }
    if(k==1)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3560
#include <stdio.h>
#define N 10000000
#define Q 10000000
int binarySearch(int);
int i,j,n,q,S[N],T[Q],c=0;
int main(){
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);
  for(i=0;i<q;i++) c+=binarySearch(T[i]);
  printf("%d\n",c);
  return 0;
}
int binarySearch(int key){
  int left,right,mid;
  left=0;
  right=n;
  while(left<right){
    mid=(left+right)/2;
    if(S[mid]==key) return 1;
    else if(key<S[mid]) right=mid;
    else left=mid+1;
  }
  return 0;
}

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

int solvePlus(vector<int> v) {
  int cnt = 0, sum = 0;

  for (int i = 0; i < v.size(); i++) {
    sum += v[i];
    if (i % 2 == 1) {
      cnt = (sum < 0) ? cnt : (cnt + abs(sum) + 1);
      sum = (sum < 0) ? sum : -1;
    } else if (i % 2 == 0) {
      cnt = (sum > 0) ? cnt : (cnt + abs(sum) + 1);
      sum = (sum > 0) ? sum : 1;
    }
  }
  return cnt;
}

signed main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto&& w : a) cin >> w;
  copy(begin(a), end(a), begin(b));
  for (auto&& w : b) w *= -1;

  int ans = min(solvePlus(a), solvePlus(b));

  cout << ans << endl;
}

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

using namespace std;

#define pb push_back

typedef long long ll;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k, s;
    cin >> k >> s;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            if(s - i - j <= k && 0 <= s - i - j){
                ans++;
            }
        }
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

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

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

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

    int r = 0;
    int b = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'R') {
            r++;
        } else {
            b++;
        }
    }

    string ans = "No";
    if (r > b) ans = "Yes";

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

    int main(){
        int A,B;
        scanf("%d", &A);
        scanf("%d", &B);
        if ( 2 <= A && A <= 100 && 2 <= B && B <= 100 ) {
            printf("%d", (A-1)*(B-1) );
        } else {
        }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<double> x(N);
  vector<double> y(N);
  for(int i = 0; i < N; i++){
    cin >> x.at(i);
    cin >> y.at(i);
  }
  double ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = i; j < N; j++){
      ans += sqrt((x.at(i) - x.at(j))*(x.at(i) - x.at(j)) + (y.at(i) - y.at(j))*(y.at(i) - y.at(j)));
    }
  }
  ans = ans * 2 / N;
  printf("%.10lf", ans);
}

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

const int inf = 1000000;
typedef pair<int, int> P;
char field[60][60];
int d[60][60];
int h,w;
int ok = 0;
int k = 0;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int bfs(){
  queue<P> que;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      d[j][i] = inf;
    }
  }
  que.push(P(0,0));
  d[0][0] = 0;
  
  while(que.size()){
    P p = que.front(); que.pop();
    if(p.first == w-1 && p.second == h-1){
      ok++;
      break;
    }
    for(int i = 0;i < 4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      
      if(nx >= 0 && nx < w && ny >= 0 && ny < h && field[nx][ny] == '.' && d[nx][ny] == inf){
        d[nx][ny] = d[p.first][p.second] + 1;
        que.push(P(nx,ny));
      }
    }
  }
  if(ok == 1){
    return d[w-1][h-1];
  }else{
    return -1;
  }
}

int main(){
  
  cin >> h >> w;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> field[j][i];
      if(field[j][i] == '.'){
        k++;
      }
    }
  }
  int res = bfs();
  int kekka;
  if(ok == 1){
    kekka = k - res - 1;
    cout << kekka << endl;
  }else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <set>

using namespace std;

const long long INF = 1LL << 61;

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

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

    // binary seach : 長さx以下にできるか？を計算
    long long ok = INF;
    long long ng = 0;

    while(ok - ng > 1){
        long long tmpK = K;
        long long mid = (ok + ng)/2;

        for(int i=0; i<N; ++i){
            if(mid < A[i]){
                tmpK -= A[i]/mid;
            }
        }

        if(tmpK <0 ){
            ng = mid;
        }else{
            ok = mid;
        }
    }

    cout << ok << endl;

    // multiset<long long, greater<long long>> s;

    // for(int i=0; i<N; ++i){
    //     long long A;
    //     cin >> A;
    //     s.insert(A);
    // }

    // for(int i=0; i<K; ++i){
    //     auto it = s.begin();
    //     long long first = *it;
    //     auto ni = next(it);
    //     long long second = *ni;
        
    // cout << "test" << endl;

    // }

}

Measured memory_bytes: 4816
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
const ll mod=1e9+7;

ll dp[100010][13];

int main(){
    string s;cin>>s;
    dp[0][0]=1;
    rep(i,1,s.size()+1){
        if(s[i-1]=='?'){
            rep(j,0,10){
                rep(k,0,13){
                    dp[i][(k*10+j)%13]+=dp[i-1][k];
                    dp[i][(k*10+j)%13]%=mod;
                }
            }
        }
        else{
            int num=s[i-1]-'0';
            rep(j,0,13){
                dp[i][(j*10+num)%13]+=dp[i-1][j];
                dp[i][(j*10+num)%13]%=mod;
            }
        }
    }
    cout<<dp[s.size()][5]<<endl;
    
    

}
    









Measured memory_bytes: 10624
def gcd(x,y):
    x,y=max(abs(x),abs(y)),min(abs(x),abs(y))
    if x%y==0:
        return y
    while x%y==0:
        x,y=y,x%y
    return y

h,w=map(int,input().split())
a=[]
for i in range(h):
    b=[int(j) for j in input().split()]
    if i%2==0:
        b=b
    else:
        b=b[::-1]
    a+=b
ans=[]
def rs1(x):
    j,k=1+x//w,1+x-w*(x//w)
    if j%2==0:
        k=w-k+1
    return j,k
for i in range(h*w-1):
    if a[i]%2==1:
        ans.append((rs1(i)+rs1(i+1)))
        a[i+1]+=1
print(len(ans))
for i in ans:
    print(*i)

Measured memory_bytes: 82184
#include<bits/stdc++.h>
using namespace std;
int n,ans,x;
map<int,int>m;
vector<int>v;
int main()
{
  scanf("%d",&n);
  for(int i=1;i<=n;++i)
  {
    scanf("%d",&x);
    if(m[x]==0) 
	  v.push_back(x);
    m[x]++;
  }
  for(int i=0;i<v.size();++i) 
  {
    if(m[v[i]]>=v[i]) 
      ans+=m[v[i]]-v[i]; 
    else  ans+=m[v[i]];
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 5112
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
    

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

  bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
  {

    if(a.s==b.s)
    {
      return a.f<b.f;
    }
    return a.s<b.s;
  }
  int32_t main()
  {         
 
      IOS

        
        string a,b;
        cin>>a>>b;

        sort(all(a));
        sort(all(b),greater<int>());

        if(a<b)
        {
          cout<<"Yes";
        }
        else
        {
          cout<<"No";
        }


      return 0;
  }           

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int d[50][50], color[505][505], n, c, value[50][5] = {},res=999999999999999;
	cin >> n >> c;
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			cin >> d[i][j];
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> color[i][j];
			value[color[i][j]][(i + j)%3]++;
		}
	}
	for (int i = 1; i <= c; i++) {
		for (int j = 1; j <= c; j++) {
			for (int k = 1; k <= c; k++) {
				if (i == j || j == k || k == i) { continue; }
				long long int tmp=0;
				for (int q = 1; q <= c; q++) {
					tmp += value[q][0] * d[q][i];
				}
				for (int q = 1; q <= c; q++) {
					tmp += value[q][1] * d[q][j];
				}
				for (int q = 1; q <= c; q++) {
					tmp += value[q][2] * d[q][k];
				}
				res = min(res, tmp);
			}
		}
	}
	cout << res;
}

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

int main(){
    int a[3];
    cin>> a[0]>>a[1]>>a[2];
    int temp;
    if(a[0]==a[1]&&a[1]==a[2]){
        cout<<"Yes"<<"\n";
    }else{
        cout<<"No"<<"\n";
    }
    return(0);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int n,m,fa[200005],num;
long long ans,d[200005];
long long min(long long a,long long b){return a<b?a:b;}
struct node{int u,v;long long w;}e[400005];
int find(int u)
{
	if(fa[u]==u)return u;
	return fa[u]=find(fa[u]);
}
bool comp(node a,node b){return a.w<b.w;}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)d[i]=1e18;
	for(int i=1;i<=m;i++)
	{
		int x,y;long long z;
		scanf("%d%d%lld",&x,&y,&z);
		e[++num]=(node){x,y,z};
		d[x]=min(d[x],z+1);
		d[y]=min(d[y],z+2);
	}
	for(int t=0;t<2;t++)
	 for(int i=0;i<n;i++)
	  d[(i+1)%n]=min(d[i]+2,d[(i+1)%n]); 
	for(int i=0;i<n;i++)e[++num]=(node){i,(i+1)%n,d[i]},fa[i]=i;
	std::sort(e+1,e+1+num,comp);
	int t=0;
	for(int i=1;i<=num;i++)
	 if(find(e[i].u)!=find(e[i].v))
	 {
	 	fa[fa[e[i].u]]=fa[e[i].v];
	 	t++;ans+=e[i].w;if(t==n-1)break;
	 }
	printf("%lld\n",ans);
}

Measured memory_bytes: 9088
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char cn[200010];
	fread(cn, 1, 200010, stdin);

	int L = 0, R = 200000;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (cn[M] >= '?') L = M;
		else R = M;
	}
	for (char* i = cn; i < cn + R; i++) {
		if (*i == '?') *i = 'D';
	}
	fwrite(cn, 1, R, stdout);

	Would you please return 0;
}

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

int main()
{
	ll int n;
	cin>>n;
	set< string > a;
	while(n--)
	{
		string s;
		cin>>s;
		a.insert(s);
	}
	
	cout<<a.size()<<endl;
}



Measured memory_bytes: 19232
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N,ok1=0,ok2=0;
  cin>>N;
  vector<int> num(N,0);
  bool ans=false;
  for(int i=0;i<N;i++){
    cin>>num[i];
    if(num[i]%4==0) ok2++;
    else if(num[i]%2==0) ok1++;
  }
  if(ok2>=N/2) ans=true;
  if(ok2*2+ok1>=N) ans=true;
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <stack>
#include <deque>
#include <iostream>
using namespace std;


deque<char> s;
string ss;
int main() {
    
    cin >> ss;
    for(int i = 0; i < ss.length(); i++) {
        if (ss[i]  == 'B' && !s.empty())
            s.pop_back();
        else if (ss[i] != 'B')
            s.push_back(ss[i]);
    }
    
    while (!s.empty()) {
        printf("%c", s.front());
        s.pop_front();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef unsigned long long int ull;

int main() {
  ios::sync_with_stdio(false); cin.tie(); cout.tie();
  ull start = 100, count = 0, X;
  cin >> X;


  while (true) {
    if (start >= X) {
      cout << count << endl;
      break;
    }
    count++;
    start += (ull)(start / 100);
  }
  
  return 0;
}


Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <cmath>

#define int long long

using namespace std;

typedef long long ll;

map <ll, bool> hsh;

ll X[555][555];

bool vis[55555555];

int gcd(int a, int b) {
    return !b ? a : gcd(b, a % b);
}

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

bool v[5555555];

int Pr[5555555], cnt = 0;

signed main() {
    int n;
    scanf("%lld", &n);
    for(int i = 2; i < 555555; i++) {
        if(!v[i]) {
            Pr[++cnt] = i;
            for(int j = 1; i * j < 555555; j++) v[i * j] = 1;
        }
    }
    for(int i = 0; i <= n + 1; i++)
        for(int j = 0; j <= n + 1; j++)
            X[i][j] = 1;
    int c = 0;
    for(int i = 1; i <= n; i += 2) {
        int s = Pr[++c];
        for(int j = 1; i + j - 1 <= n; j++) {
            X[j][i + j - 1] *= s;
        }
    }
    for(int j = 3; j <= n; j += 2) {
        int s = Pr[++c];
        for(int i = 1; i + j - 1 <= n; i++) {
            X[i + j - 1][i] *= s;
        }
    }
    for(int i = 2; i <= n + n; i += 2) {
        int s = Pr[++c];
        for(int j = 1; j <= n; j++) if(i - j <= n && i - j > 0) {
            X[j][i - j] *= s;
        }
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++)
            if((i + j) % 2) {
                X[i][j] = lcm(lcm(X[i + 1][j], X[i][j + 1]), lcm(X[i - 1][j], X[i][j - 1]));
                for(int k = 1; ; k++) if(!hsh[X[i][j] * k]) {
                    X[i][j] *= k;
                    hsh[X[i][j]] = 1;
                    X[i][j]++;
                    break;
                }
            }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            printf("%lld ", X[i][j]);
            if(X[i][j] > 1e15) {
                puts("----------------");
                printf("%lld %lld\n", i, j);
                exit(0);
            }
        }
        putchar('\n');
    }
}

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

int main() {
	
	int n;
	string s;
	cin >> n >> s;
	string ans = "Yes";
	if(n%2 != 0){
		ans = "No";
	}else{
		string a;
		for(int i = 0; i < n/2; i++){
			a[i] = s[i];
		}
		for(int i = n/2; i < n; i++){
			if(a[i-n/2] != s[i]) ans = "No";
		}
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n],b[n];
  for(ll i=0;i<n;i++)cin>>a[i]>>b[i];
  ll ans=0;
  for(ll i=n-1;i>=0;i--){
    ll c=a[i]+ans;
    ans+=(b[i]-c%b[i])%b[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	vector<bool>b;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int o[10];
		for (int i = 0; i < 10; i++){
			cin >> o[i];
		}
		bool bo = true;
		int l = o[0], r = 0;
		for (int i = 1; i < 10; i++){
			if (l >= r){
				if (o[i] >= l) {
					l = o[i];
					goto cont;
				}
				else{
					goto L;
				}
			}
			else{
			L:
				if (o[i] >= r){
					r = o[i];
					goto cont;
				}
				else{
					bo = false;
				}
			}
		cont:;
		}
		b.push_back(bo);
	}
	for (bool i : b) {
		if (i)cout << "YES"; else cout << "NO";
		cout << endl;
	}
	char ch;
	cin >> ch;
}

Measured memory_bytes: 3024
use std::io;
use std::f64;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let (a, b, x): (usize, usize, usize) = {
        let mut i = r.read_line().split_whitespace().map(|s| s.parse().unwrap());
        (i.next().unwrap(), i.next().unwrap(), i.next().unwrap())
    };
    // let (a, b, x) = (2, 2, 4);
    let (a, b, x) = (a as f64, b as f64, x as f64);

    let tant: f64;
    if x < a * a * b * 0.5 {
        tant = a * b * b * 0.5 / x;
    } else {
        tant = 2.0 * b / a - 2.0 * x / (a * a * a);
    }
    let t = tant.atan();
    let t = t / f64::consts::PI * 180.0;
    println!("{}", t);
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 4352
let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m

let perm n k =
  Array.fold_left ( *^ ) 1 @@
  Array.init k @@ ( + ) (n - k + 1)
let comb n k = power ( *^ ) (perm n k) (perm k k) (m - 2)
let hcomb n k = comb (n + k - 1) k

let () =
  let s = read_int () in
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) 0 @@
  Array.init (s / 3) @@ fun n -> hcomb (n + 1) (s - 3 * (n + 1))

Measured memory_bytes: 12144
import itertools

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	P = tuple(map(int, input().split()))
	Q = tuple(map(int, input().split()))
	a = None
	b = None
	seq = [i for i in range(1, N + 1)]
	L = list(itertools.permutations(seq))
	M = len(L)
	for i in range(M):
		if P == L[i]:
			a = i
		if Q == L[i]:
			b = i

	print(abs(a - b))

if __name__ == '__main__':
	main()

Measured memory_bytes: 44784
#include<iostream>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  // ここでストリームに obj を書き込みます。
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}


int main(){
  int n; cin >>n;
  map<int,int> mp;
  rep(i,n){
    int a; cin >>a;
    mp[a]^=1;
  }
  int cnt=0;
  for(pair<int,int> x:mp){
    cnt+=x.second;
  }
  print(cnt);
}



Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }

void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, n) cout << s[i] << t[i];
  cout << endl;
}


Measured memory_bytes: 256
import copy
y,x = map(int,input().split())
maps = []


def f(i,x,maps): # i>0 x >0 
    l = []
    if i > 0  and x > 0:
        try:
            l.append(maps[i-1][x-1])
        except:
            pass
        try:
            l.append(maps[i-1][x])
        except:
            pass
        try:
            l.append(maps[i-1][x+1])
        except:
            pass
        try:
            l.append(maps[i][x-1])        
        except:
            pass
        try:
            l.append(maps[i][x+1])        
        except:
            pass
        try:
            l.append(maps[i+1][x-1])        
        except:
            pass
        try:
            l.append(maps[i+1][x])   
        except:
            pass
        try:
            l.append(maps[i+1][x+1])        
        except:
            pass
    elif i > 0 and x == 0:
        try:
            l.append(maps[i-1][x])
        except:
            pass
        try:
            l.append(maps[i-1][x+1])    
        except:
            pass
        try:
            l.append(maps[i][x+1])        
        except:
            pass
        try:
            l.append(maps[i+1][x])   
        except:
            pass
        try:
            l.append(maps[i+1][x+1])
        except:
            pass
    elif i == 0 and x > 0:
        try:
            l.append(maps[i][x-1])       
        except:
            pass
        try:
            l.append(maps[i][x+1])
        except:
            pass
        try:
            l.append(maps[i+1][x-1])
        except:
            pass
        try:
            l.append(maps[i+1][x])   
        except:
            pass
        try:
            l.append(maps[i+1][x+1])
        except:
            pass
    elif i == 0 and x == 0:
        try:
            l.append(maps[i][x+1])    
        except:
            pass
        try:
            l.append(maps[i+1][x])           
        except:
            pass
        try:
            l.append(maps[i+1][x+1])        
        except:
            pass

    return l


for i in range(y):
    s = str(input())
    maps.append([s[i] for i in range(x)])
maps2 = copy.deepcopy(maps)
for i in range(y):
    for j in range(x):
        r = maps[i][j]
        ll = f(i,j,maps)

        if r == ".":
            k = ll.count("#")
            maps2[i][j] = str(k)

for i in range(y):
    print(''.join(maps2[i]))


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

const double PI = acos(-1);
const double EPS = 1e-15;
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

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

int main(){
  string a,b,c,s;
  cin >>a>>b>>c;
  s = toupper(a[0]);
  s += toupper(b[0]);
  s += toupper(c[0]);
  cout << s << endl;
  return 0;
}


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

int fp(int a,int b)
{
    if(b==0)
    return 1;
    int x=fp(a,b/2);
    x=(x*x)%mod;
    if(b&1)
    x=(x*a)%mod;
    return x;
}
int fact(int n,int r)
{
   // cout<<n<<" "<<r<<" ";
    int num=1,den=1;
    for(int i=r;i>=1;i--)
    {
        den=(den*i)%mod;
        num=(num*n)%mod;
        n--;
    }
    int x=(num*fp(den,mod-2))%mod;
   
    return x;
}



signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    int ans=(fp(2,n)-1+mod)%mod;
    ans=((ans-fact(n,a)-fact(n,b))%mod+mod)%mod;
    cout<<ans;
	return 0;
}


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

void main_()
{
    ll L, R;
    cin >> L >> R;

    ll ans = numeric_limits<ll>::max();
    if (R - L > 2018) {
        ans = 0;
    } else {
        for (ll i = L; i <= R - 1; ++i) {
            for (ll j = L + 1; j <= R; ++j) {
                if (i < j) {
                    ans = min(ans, i * j % 2019);
                }
            }
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger m = BigInteger.ONE;
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			m = m.multiply(BigInteger.valueOf(a[i]));
		}
		BigInteger de = BigInteger.ZERO;
		for (int i = 0; i < n; i++) {
			de = de.add(m.divide(BigInteger.valueOf(a[i])));
		}
		System.out.println(new BigDecimal(m).divide(new BigDecimal(de), 10, BigDecimal.ROUND_HALF_UP));
	}
}


Measured memory_bytes: 21844
#include<stdio.h>

int main(){
	int n;
	int max=-99999999;
	int sum=0;
	int i,j;
	int a[5000];
	while(scanf("%d",&n)!=EOF){

		if(n==0)break;



		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		for(i=0;i<n;i++){
			for(j=i;j<n;j++){
				sum+=a[j];
				if(max<sum)max=sum;
			}
			sum=0;
		}
		printf("%d\n",max);
		max=-99999999;
	}
	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,k;
    while(scanf(" %d %d", &n, &k),n)
    {
        vector<int> c(n);
        rep(i,n) scanf(" %d", &c[i]);

        int t=0;
        for(int i=0; i+k-1<n; ++i)
        {
            int tmp=1;
            rep(j,k) tmp*=c[i+j];
            t=max(t,tmp);
        }

        int ans=-1;
        rep(x,n)rep(y,x)
        {
            swap(c[x],c[y]);

            int m=0;
            for(int i=0; i+k-1<n; ++i)
            {
                int tmp=1;
                rep(j,k) tmp*=c[i+j];
                m=max(m,tmp);
            }
            ans=max(ans,m-t);

            swap(c[x],c[y]);
        }

        if(ans<0) printf("NO GAME\n");
        else printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  long long a[n],b[n],c[n];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  for(int i=0;i<n;i++) cin>>c[i];
  long long ans=0;
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  long long o,p;
  for(int i=0;i<n;i++){
      o=lower_bound(a,a+n,b[i])-a;
      p=c+n-upper_bound(c,c+n,b[i]);
      ans+=o*p;
  }
  
  
  cout<<ans<<endl;    
  
}

Measured memory_bytes: 2560
# include <string.h>
# include <iostream>
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    int N = 0;
	int rule = 0;
	cin >> N >> rule;
	int Ans = 0;
	int temp;
	for ( int i = 0; i < N; i++ ) {
		cin >> temp;
		if ( temp >= rule )
			Ans++;
	} // for
  
  	cout << Ans;
} // main()

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);

int main(){
	ll a,b,v,w,t;cin>>a>>v>>b>>w>>t;
    if(v<=w){
        cout<<"NO"<<endl;
        return 0;
    }
    ll s = abs(a-b);
    //ll tt= ceil((double)s/(double)v-(double)w;
    if(s<=t*(v-w))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 3636
import sys

while 1:
    n, r = map(int, sys.stdin.readline().split())

    if (n, r) == (0, 0):
        break

    yama = [int(n - i) for i in range(n)]

    for lp in range(r):
        p, c = map(int, sys.stdin.readline().split())
        p -= 1
        yama = yama[p:p + c] + yama[:p] + yama[p + c:]

    print(yama[0])

Measured memory_bytes: 7652
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> color(9);
  rep(i, N) {
    cin >> a[i];
    color[min(a[i] / 400, 8)]++;
  }

  int Min = 0;
  int Max;
  rep(i, 8) {
    if (color[i] != 0)
      Min++;
  }

  if (Min == 0) {
    Min = 1;
    Max = color[8];
  } else {
    Max = Min + color[8];
  }

  cout << Min << ' ' << Max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define PI (acos(-1))
#define ct cout<<
#define cn cin>>
#define spc <<" "<<
#define nl puts("")
#define _fl(x) puts("FLAG " #x);
#define  _(x)  cout<< #x <<" is "<< x <<endl;
#define fs first
#define sc second
#define pb push_back
#define all(v)  (v).begin(), (v).end()
#define _109 (1000000000)
#define _0(arr) memset(arr,0,sizeof ( arr ) )
#define _1(arr) memset(arr,-1,sizeof ( arr ) )
#define _ninp(n,arr) for(int i=0; i<n;i++)cin>>arr[i];
#define _nout(n,arr) for(int i=0; i<n;i++)cout<<arr[i]<<" \n"[i==n-1];
double _eps=1e-6;
long long gcd(long long a, long long b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main() {

    int h,w,n;
    cn h>>w>>n;


    ct min(n/h+!!(n%h),n/w+!!(n%w));







    return 0;
}


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        
        char ch = (char)('C' + (n / 1000));
        System.out.println("AB" + ch);
    }
}


Measured memory_bytes: 25172
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))

    solve(N)

def solve(N: int):
    for i in range(1, 10):
        for j in range(1, 10):
            if i*j == N:
                print('Yes')
                return
    print('No')
    return

 
if __name__ == "__main__":
    propare()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    string s,dot="...";
    cin>>k>>s;
    if(k>=s.length()){
        cout<<s;
    }
    else{
            s=s.substr(0,k);
            s+=dot;
        cout<<s;
    }
}

Measured memory_bytes: 3628