akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
int indeg[700],outdeg[700],presen[700],par[700];
inline int parent(int pos)
{
	if(par[pos]!=pos)
	{
		par[pos]=parent(par[pos]);
	}
	return par[pos];
}
bool comp[700];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	int h;
	cin>>h;
	int a[n+1],b[n+1],c[n+1],d[n+1];
	for(int i=0;i<=600;i++)
	{
		par[i]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		int ff=-1,ss=-1;
		if(c[i]==0)
		{
			ff=250+a[i];
		}
		else
		{
			ff=c[i];
		}
		if(d[i]==0)
		{
			ss=b[i];
		}
		else
		{
			ss=250+d[i];
		}
		outdeg[ff]++;
		indeg[ss]++;
		presen[ff]=1;
		presen[ss]=1;
		int p1=parent(ff);
		int p2=parent(ss);
		if(p1!=p2)
		{
			par[max(p1,p2)]=min(p1,p2);
		}
	}
	bool flag=true;
	int ans1=0;
	for(int i=1;i<=250;i++)
	{
		if(presen[i])
		{
			if(outdeg[i]!=indeg[i])
			{
				if(outdeg[i]>indeg[i])
				{
					flag=false;
					break;
				}
				else
				{
					ans1+=indeg[i]-outdeg[i];
					comp[parent(i)]=true;
					//cout<<ans1<<"\n";
				}
			}
		}
	}
	int ans2=0;
	for(int i=251;i<=500;i++)
	{
		if(presen[i])
		{
			if(outdeg[i]!=indeg[i])
			{
				if(outdeg[i]<indeg[i])
				{
					flag=false;
					break;
				}
				else
				{
					ans2+=outdeg[i]-indeg[i];
					if(!comp[parent(i)])
					{
						flag=false;
						break;
					}
					//cout<<ans2<<"\n";
				}
			}
		}
	}
	for(int i=0;i<=500;i++)
	{
		if(presen[i])
		{
			if(!comp[parent(i)])
			{
				flag=false;
				break;
			}
		}
	}
	//cout<<ans1<<" "<<ans2<<" "<<flag<<"\n";
	if(ans1!=ans2)
	{
		flag=false;
	}
	if(ans1==0)
	{
		flag=false;
	}
	if(flag)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << " " << x << endl;
typedef long long int ll;

int dp[100002];

int longest_path(vector<int> graph[], int n, int src){

    int cnt = 0;

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

    for (int i=0; i<graph[src].size(); i++){
        cnt = max(cnt, longest_path(graph, n, graph[src][i])+1);
    }    

    dp[src] = cnt;
    return dp[src];

}

int main(){

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m; 
    cin >> n >> m;

    vector<int> graph[n+1];

    int u, v;
    for (int i=0; i<m; i++){
        cin >> u >> v;
        graph[u].push_back(v);
    }

    //printing graph
    /*
    for (int i=1; i<n+1; i++){
        for (int j=0; j<graph[i].size(); j++){
            cout << graph[i][j] << " ";
        }
        cout << endl;
    }
    */

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

    int maxi = 0;
    for (int i=1; i<n+1; i++){
        maxi = max(maxi, longest_path(graph, n, i));
    }

    cout << maxi << endl;

    return 0;
}


Measured memory_bytes: 12116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void)
{
    int N, i, j, f;
    char S[200001][20];
    int count=1;

    scanf("%d",&N);
    for(i=0; i<N; i++){
        for(j=0; j<11; j++) S[i][j] = '\0';//初期化
        scanf("%s",S[i]);
    }

    qsort(S,N,sizeof(char[20]),strcmp);

    for(i=0; i<N-1; i++){
   
        if(strcmp(S[i],S[i+1])!=0) count++;
        //printf("%s\n",S[i]);
    }

    printf("%d\n",count);

    return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  string s; cin >> s;
  string ref="CODEFESTIVAL2016";
  int ans = 0;
  for(int i = 0; i < s.length(); i++) {
    if(s[i] != ref[i]) ans++;
  }
  cout << ans << endl;

  return 0;
}

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

#define rep(i,n) for(ll i=0;(i)<(ll)n;(i)++)
const long long INF = 100000000000;

int main(){
  int n,k; cin >> n >> k;
  int s = 2 * n,t = 2 * n + 1;
  mcf_graph<int,ll> g(2 * n + 2);
  g.add_edge(s,t,n*k,INF);
  rep(i,n){
    g.add_edge(s,i,k,0);
    g.add_edge(n+i,t,k,0);
  }
  rep(i,n){
    rep(j,n){
      ll a; cin >> a;
      g.add_edge(i,n+j,1,INF-a);
    }
  }
  
  auto res = g.flow(s,t,n*k);
  cout << (ll)n * (ll)k * INF - res.second << endl;
  vector<string> grid(n,string(n,'.'));
  auto edges = g.edges();
  for(auto &e : edges){
    if(e.flow == 0 || e.from == s || e.to == t) continue;
    grid[e.from][e.to-n] = 'X';
  }
  
  rep(i,n){
    cout << grid[i] << endl;
  }
    

}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

ll h[100005];

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    rep(i, n) cin >> h[i];

    ll left = 0, right = 1e10, mid;
    while (right - left > 0)
    {
        mid = (left + right) / 2;
        ll sum = 0;
        rep(i, n)
        {
            if (h[i] - mid * b > 0)
                sum += ceil((double)(h[i] - mid * b) / (a - b));
        }

        if (sum <= mid)
            right = mid;
        else
            left = mid + 1;
    }

    OP(right);

    return 0;
}

Measured memory_bytes: 1024
# import itertools
# import math
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

N = int(input())
# S = input()
# n, *a = map(int, open(0))
# N, M = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

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

print((10 ** N - (9 ** N + 9 ** N - 8 ** N)) % (10 ** 9 + 7))

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

int maxn = 10000000;

main(){
  while(1){
    int m,n; cin >> m >> n;
    if(m == 0) break;

    vector<bool> isprime(maxn, false);
    int i = m, c = 0;
    while(1){
      if(isprime[i] == false){
	c++;
	for(int j = i; j < maxn; j += i)
	  isprime[j] = true;
      }
      i++;
      if(i == maxn) break;
      if(c == n) break;
    }
    FOR(j,m,maxn) if(isprime[j] == false){
      cout << j << endl;
      break;
    }
  }
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+7, LINF = 1e18;


int main()
{
    ll a,b;
    cin>>a>>b;

    cout<<(a%b==0?-1:a)<<endl;;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a < b){
            System.out.println("a < b");
        }else if(a > b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26164
import unittest


def solve(n):
    total = 0
    for i in range(1, n+1):
        k = n // i
        total += i * k * (k + 1) // 2

    return total


def main():
    n = int(input())
    print(solve(n))


if __name__ == "__main__":
    main()


class Test(unittest.TestCase):
    def test1(self):
        self.assertEqual(solve(1), 1)
        self.assertEqual(solve(2), 5)
        self.assertEqual(solve(3), 11)
        self.assertEqual(solve(4), 23)

    def test2(self):
        self.assertEqual(solve(100), 26879)

    def test3(self):
        self.assertEqual(solve(10000000), 838627288460105)


Measured memory_bytes: 77492
// IN THE NAME OF GOD
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
using namespace std;
const int MAXN = 1e5 + 15;
int n, a[MAXN], ans;
map <int, int> pos;
vector <int> vect;
int main(){
  //ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i], vect.pb(a[i]);
  sort(vect.begin(), vect.end());
  for(int i = 0; i < vect.size(); i++) pos[vect[i]] = i;
  for(int i = 0; i < n; i++) if(abs(i - pos[a[i]]) % 2) ans++;
  cout << ans / 2 << endl;
}


Measured memory_bytes: 7408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 500500;
int n;
char s[N];
int dp[N][3];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 0; i <= n; i++)
		dp[i][0] = dp[i][1] = dp[i][2] = -N;
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		dp[i][0] = max(dp[i][0], dp[i][1]);
		dp[i + 1][0] = max(dp[i + 1][0], dp[i][0]);
		if (s[i] == '1') {
			dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + 1);
			dp[i + 1][2] = max(dp[i + 1][2], max(dp[i][0], dp[i][2]) + 1);
		}
		if (i == n - 1) continue;
		if (s[i] == '1' && s[i + 1] == '0')
			dp[i + 2][1] = max(dp[i + 2][1], dp[i][0]);
		if (s[i] == '0' && s[i + 1] == '1')
			dp[i + 2][0] = max(dp[i + 2][0], dp[i][2]);
	}
	printf("%d\n", max(dp[n][0], dp[n][1]));

	return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

constexpr int mod = 1e9 + 7;
constexpr int32_t inf = 1001001001;
constexpr int64_t infll = 1001001001001001001ll;
constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const string YES = "YES", NO = "NO", Yes = "Yes", No = "No", yes = "yes", no = "no";

// clang-format off
// ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
// ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
// istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }

template <typename T> void sort(vector<T> &v) { sort(all(v)); }
template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in(), x = in();
  vector<int> a(n);
  cin >> a;

  sort(a);

  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (x >= a[i]) {
      ans++;
      x -= a[i];
    }
  }

  if (ans == n && x) ans--;

  cout << ans << endl;
}


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

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17;

int n, t, s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> t, s += (t & 1);
	if (s & 1) cout << "NO\n";
	else cout << "YES\n";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
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(){
    string s;
    cin >> s;
    int sum = 0;
    rep(i, 4) {
        if (s[i] == '+') ++sum;
        else --sum;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3624
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int a, b, c;
bool visited[105], sol;

int main(){
    ios::sync_with_stdio(0);
    clean(visited,0);
    cin >> a >> b >> c;

    sol = false;

    forr(i,1,100000){
        if(visited[(a*i)%b]) break;

        if( (a*i) % b == c){
            sol = true;
            break;
        }

        visited[(a*i)%b] = 1;
    }

    if(sol){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }

    return 0;
}

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

int main() {
    int n;
    cin>>n;
    bool zoro=false;
    int count=0;
    rep(i,n){
        int d1, d2;
        cin>>d1 >>d2;
        if(d1==d2 && zoro && count==2){
            cout<<"Yes"<<endl;
            return 0;
        }else if(d1==d2 && zoro){
            count++;
        }else if(d1==d2 && !(zoro)){
            zoro=true;
            count=1;
        }else if(d1!=d2){
            zoro=false;
            count=0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 5100;
const int MOD = 1000000007;

vector<vector<ll> > dp(MAX, vector<ll>(MAX, -INF));

int main(){
  ll N;cin>>N;
  vector<P> a(N);
  rep(i,N){
    cin>>a[i].first;
    a[i].second = i+1;
  }
  sort(a.begin(), a.end(), greater<P>());


  // vector<vector<ll> > dp(N+1, vector<ll>(N+1, -INF));


  dp[0][0] = 0;

  //dp[i][j]は左にi,みぎにj移動が決まった場合の最大値
  rep(i,N+1){
    rep(j,N+1){
      if(i == 0){
        dp[i][j+1] = dp[i][j] + a[j].first * abs(a[j].second - (N-j) );
      }
      else{
        if(j == 0){
          dp[i][j] = dp[i-1][j] + a[i-1].first * abs(a[i-1].second - i );
        }
        else{
          // 左側or右側 a[i+j-1]の追加 左側はすでにi-1こ、右側はすでにj-1こ
          dp[i][j] = max(dp[i-1][j] + a[i+j-1].first * abs(a[i+j-1].second - i) ,
              dp[i][j-1] + a[i+j-1].first * abs(a[i+j-1].second - (N-(j-1) ) ) );
        }
      }
    }
  }

  //check
  /*
  rep(i,N+1){
    rep(j,N+1){
      cout<<dp[i][j]<<" ";
    }
    cout<<endl;
  }
  */

  ll ans = 0;
  rep(i,N+1){
    // cout<<dp[i][N-i]<<endl;
    ans = max(ans , dp[i][N-i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 206620
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
	int n, k;
	long long m, m2;
	cin >> n >> k;
	m = m2 = 0;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (k <= i)	m -= p[i - k];
		m += p[i];
		if (m2 < m)	m2 = m;
	}
	m2 += k;
	cout << m2 / 2;
	if (m2 % 2 == 0)	cout << ".0" << endl;
	else {
		cout << ".5" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef vector<LL> VEC;
typedef vector<VEC> VVEC;
typedef  pair<LL,LL> P;


const LL INF=1<<30;
const LL MOD=1000000007;




int main(){
    int x,a,b;
    cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >>n;

    int res=INF;
    for(int i=1; i*i<=n; i++){
        if(n%i!=0) continue;
        string s=to_string(n/i);
        chmin(res,SZ(s));
    }
    cout<<res<<endl;
}

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

void Print(string str) {
  int a,b;
  cin >> a >> b;
  for(int i = a; i <= b; i++) {
    cout << str[i];
  }
  cout << endl;
}

string Reverse(string str) {
  int a,b;
  string copy = str;
  cin >> a >> b;
  for(int i = a; i <= b; i++) {
    copy[i] = str[a + b - i];
  }
  return copy;
}

string Replace(string str) {
  int a,b;
  string p;
  cin >> a >> b >> p;
  for(int i = a; i <= b; i++) {
    str[i] = p[i-a];
  }
  return str;
}

int main() {
  string str;
  int q;
  cin >> str >> q;
  rep(i,q) {
    string order;
    cin >> order;
    if(order=="print") Print(str);
    if(order=="reverse") str = Reverse(str);
    if(order=="replace") str = Replace(str);
  }
  return 0;
}


Measured memory_bytes: 3196
N, Q = gets.split.map(&:to_i)
seq = gets.chomp
lr = Array.new(Q){gets.split.map(&:to_i)}

#0からn文字目まで切り出したときのACの数
cum = Array.new(seq.length,0)
cnt = 0
(seq.length-1).times do |i|
  #p seq.slice(i,2)
  if seq.slice(i,2).include?("AC")
    cnt += 1
  end
  cum[i+1] = cnt
  #p cum
end

Q.times do |i|
  puts cum[lr[i][1]-1] - cum[lr[i][0]-1]
end

Measured memory_bytes: 11132
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int h, w;
int calc(int a, int b) {
    int sp, sq, sr;
    if(a != h) sp = (h-a) * w;
    else sp = (w-b) * h;
    if(!(a%2) || !(b%2)) {
        sq = sr = (a*b/2);
    }
    else {
        int x = min(a, b), y = max(a, b);
        sq = (y/2) * x, sr = (y/2+1) * x;
    }

    // printf("a = %lld, b = %lld, sp = %lld, sq = %lld, sr = %lld\n", a, b, sp, sq, sr);
    int ma = max(sp, max(sq, sr));
    int mi = min(sp, min(sq, sr));
    return ma - mi;
}

signed main() {
    cin >> h >> w;
    int ans = (int)1e16;
    rep(i,1,h) ans = min(ans, calc(h-i, w));
    rep(i,1,w) ans = min(ans, calc(h, w-i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		
		int x = 0;
		int max = 0;
		for(int i = 0; i < n; i++){
			if(s.charAt(i) == 'I' ){
				x++;
			}else{
				x--;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}
 
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <time.h>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}
ll facctorialMethod(ll k){ //階乗
	ll s;
	if(k > 1){
		s = k*facctorialMethod(k-1);
	} else {
		s = 1;
	}
	return s;
}
vl primes(ll n){ //1e6くらいまでしか使えん
	vl x(n);
	REP(i, sqrt(n)+2){
		x[i] = 0;
	}
	for(ll i = 2; i < sqrt(n) + 2; i++){
		while(n % i == 0){
			n /= i;
			x[i-1] += 1;
		}
	}
	if(n > 1){
		x[n-1] += 1;
	}
	return x;
}
const ll mod = 1000000007;
const ll INF = 1e9;

// 変数定義start(vectorはresizeしようね)
ll N, K;
vl h;
// 変数定義end

void solve(){
	cin >> N >> K;
	h.resize(N);
	REP(i, N){
		cin >> h[i];
	}
	ll ans = 0;
	REP(i, N){
		if(h[i] >= K){
			ans++;
		}
	}
	cout << ans << endl;
}

int main(){

    //clock_t start = clock();

    cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve(); clock_t end = clock();

    //const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    //printf("time %lf[ms]\n", time);
}


Measured memory_bytes: 1024
////**********CODED BY :- DURGESH KUMAR***************////

/*
⣿⣿⣿⣿⣿⣿⡷⣯⢿⣿⣷⣻⢯⣿⡽⣻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣇⠸⣿⣿⣆⠹⣿⣿⢾⣟⣯⣿⣿⣿⣿⣿⣿⣽⣻⣿⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣻⣽⡿⣿⣎⠙⣿⣞⣷⡌⢻⣟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⡄⠹⣿⣿⡆⠻⣿⣟⣯⡿⣽⡿⣿⣿⣿⣿⣽⡷⣯⣿⣿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣷⣿⣿⣿⡀⠹⣟⣾⣟⣆⠹⣯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢠⡘⣿⣿⡄⠉⢿⣿⣽⡷⣿⣻⣿⣿⣿⣿⡝⣷⣯⢿⣿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣯⢿⣾⢿⣿⡄⢄⠘⢿⣞⡿⣧⡈⢷⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⢸⣧⠘⣿⣷⠈⣦⠙⢿⣽⣷⣻⣽⣿⣿⣿⣿⣌⢿⣯⢿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⣟⣯⣿⢿⣿⡆⢸⡷⡈⢻⡽⣷⡷⡄⠻⣽⣿⣿⡿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣏⢰⣯⢷⠈⣿⡆⢹⢷⡌⠻⡾⢋⣱⣯⣿⣿⣿⣿⡆⢻⡿⣿⣿⣿
⣿⣿⣿⣿⣿⣿⡎⣿⢾⡿⣿⡆⢸⣽⢻⣄⠹⣷⣟⣿⣄⠹⣟⣿⣿⣟⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⢸⣯⣟⣧⠘⣷⠈⡯⠛⢀⡐⢾⣟⣷⣻⣿⣿⣿⡿⡌⢿⣻⣿⣿
⣿⣿⣿⣿⣿⣿⣧⢸⡿⣟⣿⡇⢸⣯⣟⣮⢧⡈⢿⣞⡿⣦⠘⠏⣹⣿⣽⢿⣿⣿⣿⣿⣯⣿⣿⣿⡇⢸⣿⣿⣾⡆⠹⢀⣠⣾⣟⣷⡈⢿⣞⣯⢿⣿⣿⣿⢷⠘⣯⣿⣿
⣿⣿⣿⣿⣿⣿⣿⡈⣿⢿⣽⡇⠘⠛⠛⠛⠓⠓⠈⠛⠛⠟⠇⢀⢿⣻⣿⣯⢿⣿⣿⣿⣷⢿⣿⣿⠁⣾⣿⣿⣿⣧⡄⠇⣹⣿⣾⣯⣿⡄⠻⣽⣯⢿⣻⣿⣿⡇⢹⣾⣿
⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⡽⡇⢸⣿⣿⣿⣿⣿⣞⣆⠰⣶⣶⡄⢀⢻⡿⣯⣿⡽⣿⣿⣿⢯⣟⡿⢀⣿⣿⣿⣿⣿⣧⠐⣸⣿⣿⣷⣿⣿⣆⠹⣯⣿⣻⣿⣿⣿⢀⣿⢿
⣿⣿⣿⣿⣿⣿⣿⣿⠘⣯⡿⡇⢸⣿⣿⣿⣿⣿⣿⣿⣧⡈⢿⣳⠘⡄⠻⣿⢾⣽⣟⡿⣿⢯⣿⡇⢸⣿⣿⣿⣿⣿⣿⡀⢾⣿⣿⣿⣿⣿⣿⣆⠹⣾⣷⣻⣿⡿⡇⢸⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡇⢹⣿⠇⢸⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠻⡇⢹⣆⠹⣟⣾⣽⣻⣟⣿⣽⠁⣾⣿⣿⣿⣿⣿⣿⣇⣿⣿⠿⠛⠛⠉⠙⠋⢀⠁⢘⣯⣿⣿⣧⠘⣿
⣿⣿⣿⣿⣿⣿⣿⣿⣿⡈⣿⡃⢼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡙⠌⣿⣆⠘⣿⣞⡿⣞⡿⡞⢠⣿⣿⣿⣿⣿⡿⠛⠉⠁⢀⣀⣠⣤⣤⣶⣶⣶⡆⢻⣽⣞⡿⣷⠈⣿
⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠘⠁⠉⠉⠉⠉⠉⠉⠉⠉⠉⠙⠛⠛⢿⣄⢻⣿⣧⠘⢯⣟⡿⣽⠁⣾⣿⣿⣿⣿⣿⡃⢀⢀⠘⠛⠿⢿⣻⣟⣯⣽⣻⣵⡀⢿⣯⣟⣿⢀⣿
⣿⣿⣿⣟⣿⣿⣿⣿⣶⣶⡆⢀⣿⣾⣿⣾⣷⣿⣶⠿⠚⠉⢀⢀⣤⣿⣷⣿⣿⣷⡈⢿⣻⢃⣼⣿⣿⣿⣿⣻⣿⣿⣿⡶⣦⣤⣄⣀⡀⠉⠛⠛⠷⣯⣳⠈⣾⡽⣾⢀⣿
⣿⢿⣿⣿⣻⣿⣿⣿⣿⣿⡿⠐⣿⣿⣿⣿⠿⠋⠁⢀⢀⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣌⣥⣾⡿⣿⣿⣷⣿⣿⢿⣷⣿⣿⣟⣾⣽⣳⢯⣟⣶⣦⣤⡾⣟⣦⠘⣿⢾⡁⢺
⣿⣻⣿⣿⡷⣿⣿⣿⣿⣿⡗⣦⠸⡿⠋⠁⢀⢀⣠⣴⢿⣿⣽⣻⢽⣾⣟⣷⣿⣟⣿⣿⣿⣳⠿⣵⣧⣼⣿⣿⣿⣿⣿⣾⣿⣿⣿⣿⣿⣽⣳⣯⣿⣿⣿⣽⢀⢷⣻⠄⠘
⣿⢷⣻⣿⣿⣷⣻⣿⣿⣿⡷⠛⣁⢀⣀⣤⣶⣿⣛⡿⣿⣮⣽⡻⣿⣮⣽⣻⢯⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣯⢀⢸⣿⢀⡆
⠸⣟⣯⣿⣿⣷⢿⣽⣿⣿⣷⣿⣷⣆⠹⣿⣶⣯⠿⣿⣶⣟⣻⢿⣷⣽⣻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⢀⣯⣟⢀⡇
⣇⠹⣟⣾⣻⣿⣿⢾⡽⣿⣿⣿⣿⣿⣆⢹⣶⣿⣻⣷⣯⣟⣿⣿⣽⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⢀⡿⡇⢸⡇
⣿⣆⠹⣷⡻⣽⣿⣯⢿⣽⣻⣿⣿⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⢸⣿⠇⣼⡇
⡙⠾⣆⠹⣿⣦⠛⣿⢯⣷⢿⡽⣿⣿⣿⣿⣆⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠎⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⢀⣿⣾⣣⡿⡇
⣿⣷⡌⢦⠙⣿⣿⣌⠻⣽⢯⣿⣽⣻⣿⣿⣿⣧⠩⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⢰⢣⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⢀⢀⢿⣞⣷⢿⡇
⣿⣽⣆⠹⣧⠘⣿⣿⡷⣌⠙⢷⣯⡷⣟⣿⣿⣿⣷⡀⡹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣈⠃⣸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⢀⣴⡧⢀⠸⣿⡽⣿⢀
⢻⣽⣿⡄⢻⣷⡈⢿⣿⣿⢧⢀⠙⢿⣻⡾⣽⣻⣿⣿⣄⠌⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⢁⣰⣾⣟⡿⢀⡄⢿⣟⣿⢀
⡄⢿⣿⣷⢀⠹⣟⣆⠻⣿⣿⣆⢀⣀⠉⠻⣿⡽⣯⣿⣿⣷⣈⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⢀⣠⠘⣯⣷⣿⡟⢀⢆⠸⣿⡟⢸
⣷⡈⢿⣿⣇⢱⡘⢿⣷⣬⣙⠿⣧⠘⣆⢀⠈⠻⣷⣟⣾⢿⣿⣆⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⣠⡞⢡⣿⢀⣿⣿⣿⠇⡄⢸⡄⢻⡇⣼
⣿⣷⡈⢿⣿⡆⢣⡀⠙⢾⣟⣿⣿⣷⡈⠂⠘⣦⡈⠿⣯⣿⢾⣿⣆⠙⠻⠿⠿⠿⠿⡿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⢋⣠⣾⡟⢠⣿⣿⢀⣿⣿⡟⢠⣿⢈⣧⠘⢠⣿
⣿⣿⣿⣄⠻⣿⡄⢳⡄⢆⡙⠾⣽⣿⣿⣆⡀⢹⡷⣄⠙⢿⣿⡾⣿⣆⢀⡀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⢀⣀⣠⣴⡿⣯⠏⣠⣿⣿⡏⢸⣿⡿⢁⣿⣿⢀⣿⠆⢸⣿
⣿⣿⣿⣿⣦⡙⣿⣆⢻⡌⢿⣶⢤⣉⣙⣿⣷⡀⠙⠽⠷⠄⠹⣿⣟⣿⣆⢙⣋⣤⣤⣤⣄⣀⢀⢀⢀⢀⣾⣿⣟⡷⣯⡿⢃⣼⣿⣿⣿⠇⣼⡟⣡⣿⣿⣿⢀⡿⢠⠈⣿
⣿⣿⣿⣿⣿⣷⣮⣿⣿⣿⡌⠁⢤⣤⣤⣤⣬⣭⣴⣶⣶⣶⣆⠈⢻⣿⣿⣆⢻⣿⣿⣿⣿⣿⣿⣷⣶⣤⣌⣉⡘⠛⠻⠶⣿⣿⣿⣿⡟⣰⣫⣴⣿⣿⣿⣿⠄⣷⣿⣿⣿
*/
#include<bits/stdc++.h>
#define ll long long
#define ff double
#define endl "\n"
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');

using namespace std;

int main()
{
ll n;
cin>>n;
ff a;
ff sum=0;
REP(i,n)
{
cin>>a;
sum=sum+(double)(1/a);
}
ff ans=(double)(1/sum);
cout<<fixed<<setprecision(5)<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
#define irep(i,n) for(int i = n-1; i > -1; --i )
using namespace std;
using ll = long long;
using P = pair<int,int>;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct Combination {
  vector<mint> fact, ifact;
  Combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  string s;
  cin >> s;
  int n = s.size();

  mint dp[5];
  dp[0]=1;
  rep(i,n){
    if(s[i]=='?'){
      irep(j,4) {
        dp[j+1] += dp[j];
        dp[j] *= 3;
      }
    }else{
      int j = s[i]-'A';
      dp[j+1] += dp[j];
    }
  }
  cout << dp[3] << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
int main(){
    char a,b;
    cin>>a>>b;
    if(a=='H'){
        if(b=='H')cout<<'H'<<endl;
        else cout<<'D'<<endl;
    }else{
        if(b=='H')cout<<'D'<<endl;
        else cout<<'H'<<endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

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

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

int t(string s,char c){
    rep(i,0,sz(s)){
        if(s[i] != c)return 0;
    }
    ret 1;
}

int main(){
	string s;
	cin >> s;
	map<char,int> m;
	rep(i,0,sz(s))m[s[i]]++;

	ll mi = linf;
	
	for(auto it:m){
	   
	    char c = it.ft;
	    ll cnt = 0;
	    string ss = s;
	    while(t(ss,c) == 0){
            rep(i,1,sz(ss)){
                if(ss[i]==c){
                    ss[i-1] = c;
                }
            
            }
            ss.erase(ss.begin()+sz(ss)-1);
            cnt++;
        }
        mi = min(mi,cnt);
       
    }
  
    P(mi);
    
	return  0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int n,i,max,a;
  max=0;
  a=0;
  scanf("%d",&n);
int h[n];
  for(i=0;i<n;++i)
  {
  scanf("%d",&h[i]);
  if(max<h[i]) max=h[i];
  }

  while(max>=0)
  {
    if(h[0]>0) a++;
    for(i=0;i<n-1;++i)
    {
    if(h[i]==0 && h[i+1]>0) a++;
    }
    
    for(i=0;i<n;++i)
    {
    if(h[i]>0) h[i]--;
    }
  max--;
  }
  
  printf("%d",a);
  

return 0;
}

Measured memory_bytes: 128
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn()
  let nr=tnn(n)
  let now=nr[0]
  for(let i=1;i<n;i++){
    if(nr[i]<now){
      to('No')
      return
    }
    now=nr[i]>now?nr[i]-1:nr[i]
  }
  to('Yes')
}
main()


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

int main() {
    int x;
    rep(i,5) {
        cin >> x;
        if (x == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3576
from sys import stdin
def main(le=len):
    n, k = map(int, raw_input().split())
    a = []
    g = [[] for _ in xrange(n)]
    dat = map(int, stdin.read().split(), [10] * 2 * (n - 1))
    for i in xrange(n - 1):
        u, v = dat[i*2] - 1, dat[i*2+1] - 1
        a.append((u, v))
        g[u].append(v)
        g[v].append(u)
    st = []
    pu = st.append
    po = st.pop
    ans = 0
    if k % 2:
        k = k / 2 + 1
        for u, v in a:
            c = 0
            pu((u, k, v))
            pu((v, k, u))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    else:
        k = k / 2 + 1
        for i in xrange(n):
            c = 0
            pu((i, k, -1))
            while c < le(st):
                u, d, p = st[c]
                d -= 1
                if d:
                    for v in g[u]:
                        if v != p:
                            pu((v, d, u))
                c += 1
            if ans < c:
                ans = c
            del st[:]
    print n - ans
main()


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


const int MAX = 510000;
const int mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

int main(){
  int n;cin>>n;
  int d[n];rep(i,n)cin>>d[i];
  sort(d,d+n);
  cout<<d[n/2]-d[n/2-1]<<endl;
}


Measured memory_bytes: 640
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

map<int, int> mp;
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    int a;
    cin >> a;
    if(mp.find(a) == mp.end()) mp[a] = 1;
    else mp[a]++;
  }

  int ret = 0;
  for(auto i: mp) {
    if(i.second%2==1) ret++;
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 4864
#include<stdio.h>

int main(){
	int i = 0;
	int j = 0;
	
	for ( i=1; i<10; i++ ) {
		for ( j=1; j<10; j++ ) {
			printf("%dx%d=%d\n", i, j, i*j);
		}
	}
	
    return 0;
}

Measured memory_bytes: 524
#include "bits/stdc++.h"
using namespace std;
#pragma warning(disable:4996)


int main() {
	while (1) {
		int n; cin >> n;
		if (!n)break;
		vector<vector<int>>frees(n, vector<int>(30));
		for (int i = 0; i < n; ++i) {
			int f; cin >> f;
			for (int j = 0; j < f; ++j) {
				int t; cin >> t;
				t--;
				frees[i][t] = true;
			}
		}
		vector<vector<int>>meettime(n, vector<int>(n, 99));
		for (int day = 0; day < 30; ++day) {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					if (frees[i][day] && frees[j][day]) {
						meettime[i][j] = min(meettime[i][j], day);
					}
				}
			}
		}
		vector<vector<bool>>meets(n, vector<bool>(n));
		for (int i = 0; i < n; ++i) {
			meets[i][i] = true;
		}
		int ans = -1;
		for (int day = 0; day < 30; ++day) {
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < n; ++j) {
					if (frees[i][day] && frees[j][day]) {
						for (int k = 0; k < n; ++k) {
							meets[i][k] =meets[i][k]|| meets[j][k];
							meets[j][k] = meets[i][k] || meets[j][k];
						}
						
					}
				}
			}
			for (int i = 0; i < n; ++i) {
				bool ok = true;
				for (int k = 0; k < n; ++k) {
					if (!meets[i][k]) {
						ok = false; break;
					}
				}
				if (ok) {
					ans = day + 1; goto g;
				}
			}
			
		}
		g:0;
		cout << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
  cin >> N;
  vector<int> M(N);
  for(int i=0;i<N;i++)
    cin >> M.at(i);
  sort(M.begin(),M.end());
  reverse(M.begin(),M.end());
  int tower;
  tower=0;
  for(int j=0;j<N-1;j++){
    if(M.at(j)>M.at(j+1))
      tower++;
  }
  cout << tower+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<=999;i++){
		ll now=i;
		ll a=now%10;
		ll j=0;
		bool ch=false;
		for(;j<n;j++){
			if(s[j]-'0'==a){
				j++;
				ch=true;
				break;
			}
		}
		if(ch==false){
			continue;
		}
		ch=false;
		now/=10;
		a=now%10;
		for(;j<n;j++){
			if(s[j]-'0'==a){
				j++;
				ch=true;
				break;
			}
		}
		if(ch==false){
			continue;
		}
		ch=false;
		now/=10;
		a=now%10;
		for(;j<n;j++){
			if(s[j]-'0'==a){
				ch=true;
				break;
			}
		}	
		if(ch==false){
			continue;
		}		
		ans++;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main (){
    int ans = 0;
    int toy = 0;
 
    int N;
    cin >> N;
    
    string array1[N];
    for (int i = 0; i < N; i++){
        cin >> array1[i];
    }
    
    int M;
    cin >> M;
    
    string array2[M];
    for (int t = 0; t < M; t++){
        cin >> array2[t];
    }
 
    for (int a = 0; a < N; a++ ){
        for(int b = 0; b < N; b++){
            if(array1[a] == array1[b]){
                toy += 1;
            }
        }
 
        for(int c = 0; c < M; c++){
            if(array1[a] == array2[c]){
                toy -= 1;
            }
        }
        if(ans <= toy){
            ans = toy;
        }
        
        toy = 0;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
int  N,K,h[1000000];
cin >> N >> K;

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

int count = 0;
for(int i = 0;i < N;i++){
	if(h[i] >= K){
		count++;
	}
}

cout << count << endl;

}

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

void swap(int*a,int*b)
{
	int mem = *a;
	*a = *b;
	*b = mem;
}

int main()
{
	int a, b, c= 0;
	int SortChecker = 0;
	cin >> a >> b >> c;
	do {
		SortChecker = 0;
		if (a > b)
		{
			swap(&a, &b);
			SortChecker++;
		}
		if (b > c)
		{
			swap(&b, &c);
			SortChecker++;
		}

	} while (SortChecker >0);
	cout << a<<" " << b <<" "<< c << endl;
}

Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
using namespace std;
int n;
long long check(long long k,long long a,long long b)
{
	if((k-a)%(a-b)>=1)
	{
		n=1;
	}
	return ((k-a)/(a-b)+n)*2+1;
}
int main()
{
	ios::sync_with_stdio(false);
	long long k,a,b,h=0;
	cin>>k>>a>>b;
	if(k<=a)
	{
		cout<<1<<"\n";
		return 0;
	}
	if(b>=a)
	{
		cout<<-1<<"\n";
		return 0;
	}
	cout<<check(k,a,b)<<"\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	int l = 0, r = s.size() - 1;
	int x = 0;
	while (r - l > 0) {
		if (s[l] == s[r]) {
			l++;
			r--;
		}
		else {
			if (s[l] == 'x') {
				l++;
				x++;
			}
			else if (s[r] == 'x') {
				r--;
				x++;
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
	}
	cout << x << endl;
}

Measured memory_bytes: 512