akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n, k; cin>>n>>k;
  vector<ll> x(n);
  rep(i, n) cin>>x[i];

  ll ans = 0;
  rep(i, n) {
    ans += min(x[i], abs(k-x[i]))*2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3580
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;
#define int LL

const int inf = 1e9,maxn=2e5+5;

int n,a[maxn];

int solve(int x){
	int r=0;
	for(int i=1;i<=n;i++)r += abs(a[i]-x);
	return r;
}

signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]), a[i] -= i;
	int l=-1e9, r=1e9;
	while(l<r-1){
		int lmid = (l+r)>>1, rmid = (lmid+r) >> 1;
		if(solve(lmid) > solve(rmid))l=lmid;
		else r=rmid;
	}
//	printf("%d %d\n",l,r);
	int ans;
	if(solve(l)<solve(r))ans=l;
	else ans=r;
//	printf("? %d\n",ans);
	printf("%lld\n",solve(ans));

	return 0;
}


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

using namespace std;
/*
 * class Solution {
    func baseNeg2(_ N: Int) -> String {
        return BaseK(N, base: -2).reduce("") {$0 + "\($1)"}
    }
    private func BaseK(_ N: Int, base k : Int) -> [Int] {
        guard N != 0 else {
            return [0]
        }
        let absK = k < 0 ? -k : k
        var temp = N
        var ans = [Int]()
        while temp != 0 {
            let r = (temp % k + absK) % absK
            ans.insert(r, at: 0)
            temp -= r
            temp /= k
        }
        return ans
    }
}
 */


//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

//------------
vector<int > baseK(int N, int k) {
    vector<int> ans;
    if(N == 0) {
        ans.push_back(0);
        return ans;
    }
    const int absK = abs(k);
    while (N != 0) {
        int current = (N % k + absK) % absK;
        ans.push_back(current);
        N -= current;
        N /= k;
    }
    reverse(ans.begin(),ans.end());
    return ans;
}
//-------
void func() {
    int N;
    cin >> N ;
    vector<int > ans = baseK(N,-2);
    string rel = "";
    for (auto num: ans) {
        rel += to_string(num);
    }
    cout << rel << endl;
}

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

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

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (long long )(1e18+1)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){ 
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

const int MOD = 998244353;
const int N = 2e5+1;
int fac[N], inv[N];


struct comb{
    int modPow(int b, int p) { 
        int r = 1; 
        while(p) { 
            if(p&1) r = r*b%MOD;
            b = (b*b)%MOD; 
            p >>= 1; 
        } return r;
    }
    void fact(){
        fac[0] = inv[0] = 1;
        for(int i = 1; i < N; i++){
            fac[i] = fac[i-1]*i%MOD;
            inv[i] = inv[i-1]*modPow(i, MOD-2)%MOD;
        }
    }
    int ncr(int n, int r){
        if(r > n) return 0;
        return fac[n]*inv[r]%MOD*inv[n-r]%MOD;
    }
}cc;

void solve() {
    cc.fact();
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    for(int i = 0; i <= k; i++){
        ans += cc.ncr(n-1, i)*cc.modPow(m-1, n-i-1)%MOD*m%MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   

    int t = 1;
    start = clock(); 

    cout << fixed << setprecision(20);

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif
   
    //cin >> t;
    
    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": "; 
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}

Measured memory_bytes: 6732
#!/usr/bin/ruby
h={2=>[[2,1]],3=>[[3,1]],4=>[[2,2]],5=>[[5,1]],6=>[[2,1],[3,1]],7=>[[7,1]],8=>[[2,3]],9=>[[3,2]],10=>[[2,1],[5,1]],11=>[[11,1]],12=>[[2,2],[3,1]],13=>[[13,1]],14=>[[2,1],[7,1]],15=>[[3,1],[5,1]],16=>[[2,4]],17=>[[17,1]],18=>[[2,1],[3,2]],19=>[[19,1]],20=>[[2,2],[5,1]],21=>[[3,1],[7,1]],22=>[[2,1],[11,1]],23=>[[23,1]],24=>[[2,3],[3,1]],25=>[[5,2]],26=>[[2,1],[13,1]],27=>[[3,3]],28=>[[2,2],[7,1]],29=>[[29,1]],30=>[[2,1],[3,1],[5,1]],31=>[[31,1]],32=>[[2,5]],33=>[[3,1],[11,1]],34=>[[2,1],[17,1]],35=>[[5,1],[7,1]],36=>[[2,2],[3,2]]}
while true
	l=gets.split
	n=l[0].to_i;m=l[1].to_i(n)
	if n==0 then break end
	p h[n].map{|a,b|
		z=m;r=0
		while z>0 do r+=(z/=a) end
		r/b
	}.min
end

Measured memory_bytes: 2592
//
// Created by Ciafrino on 1/6/19.
//
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

typedef long long lint;

vector<int> value, weight;
lint dp[110][100010];

lint get(int idx, int w) {
    if (idx == value.size() || w == 0) return 0;
    if (dp[idx][w] != -1) return dp[idx][w];
    if (weight[idx] > w) return dp[idx][w] = get(idx+1, w);
    return dp[idx][w] = max(get(idx+1, w), value[idx] + get(idx+1, w - weight[idx]));
}

int main() {
    int n, w;
    scanf("%d%d", &n, &w);
    value.resize(n);
    weight.resize(n);
    memset(dp, -1, sizeof dp);
    for(int i = 0; i < n; ++i)
        scanf("%d%d", &weight[i], &value[i]);
    printf("%lld\n", get(0, w));
    return 0;
}

Measured memory_bytes: 86144
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
//////////////////
// Aditya Kumar //
//  BITS H      //
//////////////////
#define mod 1000000007
#define ss second
#define ff first
#define endl '\n' 
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back


int32_t main() {
    FastIO;
     #ifndef ONLINE_JUDGE
   // freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
    #endif
    int n , mw;
    cin>>n;
    unordered_map<int,int> m;
        int tmp;
    for(int i=0;i<n;i++){
        cin>>tmp;
        m[tmp]++;
    }
    cin>>mw;

    for(int j=0;j<mw;j++)
    {
        cin>>tmp;
        if(m[tmp] == 0) {
            cout<<"NO"; return 0;
        }
        m[tmp]--;
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 8520
import bisect

N = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
  a = bisect.bisect_left(A, b)
  c = N-bisect.bisect(C, b)
  ans += a*c
print(ans)

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

using namespace std;
bool c[200001];
int x,ans;
int main()
{
    cin>>x;
    ans=1000000;
    c[1]=1;
    c[0]=1;
    for(int i=2;i<=200000;i++)
        if(c[i]==0)
        {
            if(i>=x&&i<ans)
            {
                ans=i;
                cout<<i;
                return 0;
            }
            for(int j=i*2;j<=200000;j+=i)
                c[j]=1;
        }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;


int main(){
	
	int n;
	cin>>n;
	int d[114514]={0};
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		d[a]++;
		d[b+1]--;
	}
	
	int ans=0;
	for(int i=1;i<114514;i++){
		d[i]+=d[i-1];
		if(d[i]+1>=i)ans=i-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;
typedef long long ll;

int main(){
    ll A;
    double B;
    cin >> A >> B;

    ll b2 = round(B*100);
    // cout << b2 << endl;

    ll ans = A * b2 / 100;

    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	ll L, R;
	cin >> L >> R;
	if(R - L >= 2019)cout << "0" << endl;
	else{
		ll ans = 2019;
		for(ll i = L; i < R; i ++){
			for(ll j = i + 1; j <= R; j ++){
				ans = min(ans, (i * j)%2019);
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def canM n
  n <= 12 && n >= 1
end
s = gets.to_i
a = s / 100
b = s % 100
puts "AMBIGUOUS" if canM(a) && canM(b)
puts "NA" if !canM(a) && !canM(b)
puts "YYMM" if !canM(a) && canM(b)
puts "MMYY" if canM(a) && !canM(b)

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  i64 ans = 0;
  vector<i64> a(n);
  for (auto &z : a) cin >> z;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      ans += a[i] * a[j];
    }
  }
  kek(ans);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int mod = 1e9 + 7;
int main()
{
	SPEED
	int n;
	cin >> n;
	string s;

	unordered_map<string, int> mp2;
	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		if (mp2.count(s))
		{
			mp2[s]++;
		}
		else
		{
			mp2[s] = 1;
		}
	}

	cout << mp2.size();

	return 0;
}

Measured memory_bytes: 17752
import java.util.*;
import java.text.*;
 
class Main {
    public static void main(String[]args)throws Exception {
        Scanner sc = new Scanner(System.in);
        for(;;) {
            int n = sc.nextInt();
            if(n == 0) break;
            int [] xs = new int[n];
            long s = 0;
            for(int i = 0; i < n; i++) {
                xs[i] = sc.nextInt();
                s += xs[i];
            }
            double m = s / (double) n;
            double d = 0;
            for(int i = 0; i < n; i++) {
                d += (xs[i] - m) * (xs[i] - m);
            }
            d /= n;
            NumberFormat format = NumberFormat.getInstance();
            format.setMaximumFractionDigits(5);
            format.setMinimumFractionDigits(5);
            format.setGroupingUsed(false);
            System.out.println("" + format.format(Math.sqrt(d)));
        }
    }
}


Measured memory_bytes: 31484
#define _USE_MATH_DEFINES
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;

int main() {
	int h, w;
	string board[110];

	cin >> h >> w;

	vector<bool> row(h, false);
	vector<bool> col(w, false);

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

	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j < w; j++)
		{
			if (board[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	
	for (int i = 0; i < h; i++)
	{
		if (row[i]) {
			for (int j = 0; j < w; j++)
			{
				if (col[j]) {
					cout << board[i][j];
				}
			}
			cout << endl;
		}
		
	}
}

Measured memory_bytes: 256
# B
import numpy as np
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
T_list = [T-x*0.006 for x in H]
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx
print(getNearestValue(T_list, A) + 1)

Measured memory_bytes: 12472
#include <cstdio>

int N, K;
int a[5010];
//int memo[5010][10010];
int res;
int mm1[5010][5010], mm2[5010][5010];
int val[5010];
int valL;
int left, right;

/*void solve()
{
	int i, j, k;
	for(k=0; k<N; k++){
		for(i=0; i<=N; i++){
			for(j=0; j<=K; j++)
				memo[i][j] = 0;
		}
		memo[0][0] = 1;
		for(i=1; i<=N; i++){
			for(j=0; j<=K; j++){
				if(memo[i-1][j] == 1){
					memo[i][j] = 1;
					if(i-1==k)
						continue;
					if(a[i-1]+j <= K){
						memo[i][a[i-1]+j] = 1;
					}
				}
			}
		}
		int ok = 0;
		j = K-a[k];
		if(j < 0)
			j = 0;///
		//for(j=K-a[k]; j<K; j++){
		for(; j<K; j++){
			if(memo[N][j] == 1){
				ok = 1;
				break;
			}
		}
		if(ok)
			res ++;
	}
	printf("%d\n", N-res);
}*/

int suc()
{
	int l=0, r=valL-1;
	int m;
	while(l<=r){
		m = (l+r)/2;
		if(val[m]>=left && val[m]<=right)
			return 1;
		else if(val[m]<left)
			l = m+1;
		else
			r = m-1;
	}
	return 0;
}

void solve()
{
	int i, j, k;
	mm1[0][0] = 1;
	for(i=1; i<=N; i++){
		for(j=0; j<=K; j++){
			if(mm1[i-1][j] == 1){
				mm1[i][j] = 1;
				if(a[i-1]+j <= K){
					mm1[i][a[i-1]+j] = 1;
				}
			}
		}
	}
	mm2[N+1][0] = 1;
	for(i=N; i>=1; i--){
		for(j=0; j<=K; j++){
			if(mm2[i+1][j] == 1){
				mm2[i][j] = 1;
				if(a[i-1]+j <= K){
					mm2[i][a[i-1]+j] = 1;
				}
			}
		}
	}
	res = 0;
	for(k=1; k<=N; k++){
		valL = 0;
		for(i=0; i<=K; i++){
			if(mm2[k+1][i] == 1){
				val[valL] = i;
				valL ++;
			}
		}
		int ok = 0;
		for(i=0; i<=K-1; i++){///not i<=K
			if(mm1[k-1][i] == 1){
				left = K-a[k-1] -i;
				right = K-1 -i;
				if(left<0)
					left = 0;
				//if(right<0)
				//	right = 0;
				if(suc() ){
					ok = 1;
					break;
				}
			}
		}
		if(ok)
			res ++;
	}
	printf("%d\n", N-res);
}

int main()
{
	int i;
	scanf("%d%d", &N, &K);
	for(i=0; i<N; i++)
		scanf("%d", &a[i]);
	solve();
	return 0;
}

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


int main(){
  long long n,m; cin>>n>>m;
  vector<long long int> a(n);
  long long sum = 0;
  for (auto &&i : a)
  {
    cin>>i;
    sum += i;
  }
  long long count = 0;
  //cerr << sum << endl;
  for (auto &&i : a)
  {
    if(i >= (sum/(4.0*m)))
    {
      count++;
    }

  }
  if (count >= m)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;


struct UnionFind {
    vector<int> size;
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N), size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
            par[i] = i;
            size[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        par[x] = root(par[x]);
        return par[x];
    }

    int getSize(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        return size[root(x)];
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y); 
        if (rx == ry) return;
        int s = size[ry] + size[rx];
        size[rx] = s;
        size[ry] = s;
        par[rx] = ry; 
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

void Main()
{
    ll n, m;
    cin >> n >> m;

    vector<ll> A(m), B(m);
    rep(i, m) cin >> A[i] >> B[i];
    
    UnionFind uf(n);

    vector<ll> inc(m);
    
    for (ll i = m - 1; i >= 0; i--) {
        ll a = A[i] - 1;
        ll b = B[i] - 1;
        if (uf.root(a) != uf.root(b)) {
            inc[i] = uf.getSize(a) * uf.getSize(b);
        }
        uf.unite(a, b);
    }

    ll res = 0;
    rep(i, m) {
        res += inc[i];
        put(res);
    }

}
signed main(){ Main();return 0;}

Measured memory_bytes: 6324
#include <cstdio>
#include <string>
#include <map>
#include <iostream>

using namespace std;

int maxlen = 0, mode = 0;
map<string,int> mp;

int main()
{   
    string len_key, mode_key, s2;
    int m = 9;
    while( cin >> s2 )
    {
        mp[s2]++;
        if( mode < mp[s2] )
        {
            mode = mp[s2];
            mode_key = s2;
        }
        if( maxlen < s2.size() )
        {
            maxlen = s2.size();
            len_key = s2; 
        } 
    }

    cout << mode_key << ' ' << len_key << '\n';
    return 0;
}



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

int main(){
    int N;
    int max_four,total;
    cin >> N;
    int max_seven = N / 7  + 1;
    rep(i,max_seven){
        max_four = (N - i*7)/4 + 1;
        rep(j,max_four){
            total = 4*j + 7*i;
            if(total == N){
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while( x -> left != NIL)
    x = x -> left;
  return x;
  

}

Node treeMaximum(Node x){
  while( x->right != NIL)
    x = x -> right;
  return x;
  

}

Node treeSearch(Node u, int k){
  while( u != NIL && k != u->key){
    if( u->key == k)
      return u;
    else if( k < u->key)
      u = u->left;
    else
      u = u->right;
  }
  return NIL;
    
}

Node treeSuccessor(Node x){
  if( x->right != NIL)
    return treeMinimum(x -> right);
  Node y = x->parent;
  while( y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if( z->left == NIL || z->right == NIL)
    y = z;
  else
    y = treeSuccessor(z);

  if(y->left != NIL)
    x = y->left;
  else
    x = y->right;

  if(x != NIL)
    x -> parent = y -> parent;

  if(y->parent == NIL)
    root = x;
  else{
    if( y == y->parent->left)
      y->parent->left = x;
    else
      y->parent->right = x;
  }

  if( y != z)
    z->key = y->key;
  
  free(y);

}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL){
    y = x;
    if( z -> key < x -> key)
      x = x -> left;
    else
      x = x -> right;
  }
  z -> parent = y;
  if( y == NIL)
    root = z;
  else{
    if( z -> key < y -> key)
      y -> left = z;
    else
      y -> right = z;
  }
}

void inorder(Node u){
  if( u == NIL)
    return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if( u == NIL)
    return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

 for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
#include <iomanip>
#include <sstream>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int get_hash(void);
int get_val(vector<int>);
char change(char, string);
int get_cnt(int, string);

string s;
int pos;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    while(cin >> s)
    {
        if(s == ".") break;
        string p; cin >> p;
        int num; pos = 0;
        if(s[0] == '[' && s[s.size() - 1] == ']') s = s.substr(1, s.size() - 2);
        string tmp = s;
        for(int i = 0; i < s.size(); i++) s[i] = change(s[i], p);
        num = get_hash();
        cout << num << " " << get_cnt(num, tmp) << endl;
    }
	return 0;
}
int get_cnt(int num, string tmp)
{
    int ret = 0;
    for(int i = 0; i <= 9999; i++)
    {
        s = tmp, pos = 0;
        ostringstream sout;
        sout << setfill('0') << setw(4) << i;
        string password = sout.str();
        for(int i = 0; i < s.size(); i++) s[i] = change(s[i], password);
        int x = get_hash();
        if(x == num) ret++;
    }
    return ret;
}
int get_hash()
{
    vector<int> vec;
    if(s.size() < 3) return s[0] -'0';
    while(s[pos] != ']')
    {
        if(pos >= s.size()) break;
        if(s[pos] == '[')
        {
            pos++;
            vec.push_back(get_hash());
        }
        else
        {
            if(s[pos] >= 48 && s[pos] <= 57) vec.push_back(s[pos] - '0');
            else vec.push_back(s[pos]);
        }
        pos++;
    }
    return get_val(vec);
}
char change(char ch, string p)
{
    if(ch == 'a') return p[0];
    else if(ch == 'b') return p[1];
    else if(ch == 'c') return p[2];
    else if(ch == 'd') return p[3];
    else return ch;
}
int get_val(vector<int> vec)
{
    char ch = (char)vec[0];
    int a = vec[1], b = vec[2];
    if(ch == '+') return a | b;
    else if(ch == '*') return a & b;
    else return a ^ b;
}



Measured memory_bytes: 3236
# AOJ 0208 Room Numbers of a Hospital
# Python3 2018.6.23 bal4u
# 8進数に変換して、01234567を01235789に置き換える

dic = {'0':'0','1':'1','2':'2','3':'3','4':'5','5':'7','6':'8','7':'9'}
while 1:
	n = int(input())
	if n == 0: break
	s = list(format(n, 'o'))
	for i in range(len(s)): s[i] = dic[s[i]]
	print(*s, sep='') 



Measured memory_bytes: 5628
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	int a;
	string s;
	cin >> a >> s;
	cout << (a>=3200 ? s : "red") << endl;
	return 0;
}

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

const int N = 200 * 1000 + 20;
int a[N], n;
bool ans = true;

int main() {
  	cin >> n;
  	for (int i = 0; i < n; i++)
      	cin >> a[i];
  	sort(a, a + n);
  	for (int i = 1; i < n; i++)
      	if (a[i] == a[i - 1])
			ans = false;
 	cout << (ans? "YES": "NO") << "\n";
}

Measured memory_bytes: 1024
N=int(input())
A=[]
for i in range(N):
  x,y=map(int,input().split())
  A.append((x,y,i))
A=sorted(A)
B=sorted(A,reverse=False, key=lambda x: x[1]) 
#print(A,B)
E=[]
for i in range(N-1):
  E.append(((A[i+1][0]-A[i][0]),A[i][2],A[i+1][2]))
  E.append(((B[i+1][1]-B[i][1]),B[i][2],B[i+1][2]))
edge=E

def kruskal():
    cost=0
    edge.sort()
    for c,u,v in edge:
        if same(u,v):
            continue
        union(u,v)
        cost+=c
    return cost

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def union(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return False
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x
    return True

def same(x, y):
    return find(x) == find(y)
par=[-1]*N
print(kruskal())

Measured memory_bytes: 123428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

namespace Atcoder
{
	class Program
	{
		//string s = Console.ReadLine();
		//int[] intArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		//int H = intArray[0];
		//int W = intArray[1];
		//int N = int.Parse(Console.ReadLine());
		//List<int> A = new List<int>(Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray());
		//Boolean ok = false;

		//Console.WriteLine(ans);
		//Console.WriteLine("Yes");
		//Console.WriteLine("No");
		//Console.ReadKey();
		//Console.WriteLine(cnt);

		//string[] strArray = Console.ReadLine().Split(' ').ToArray();
		//string S = strArray[0];
		//string T = strArray[1];
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
			int[] B = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
			int[] C = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

			int ans = B.Sum();

			for(int i = 1;i < N; i++)
				if (A[i] - 1 == A[i - 1])
					ans += C[A[i] - 2];

			Console.WriteLine(ans);
		}

		/// <summary>
		/// アナグラム
		/// </summary>
		/// <param name="word1"></param>
		/// <param name="word2"></param>
		/// <returns></returns>
		static bool IsAnagramOf(string word1, string word2)
		{
			return word1.OrderBy(x => x).SequenceEqual(word2.OrderBy(x => x));
		}
		/// <summary>
		/// 最小公倍数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static long Lcm(long a, long b)
		{
			return a * b / Gcd(a, b);
		}

		/// <summary>
		/// 最大公約数
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static long Gcd(long a, long b)
		{
			if (a < b)
				// 引数を入替えて自分を呼び出す
				return Gcd(b, a);
			while (b != 0)
			{
				var remainder = a % b;
				a = b;
				b = remainder;
			}
			return a;
		}
	}
}

Measured memory_bytes: 28280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

signed main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep (i, 0, s.size()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define MN 2000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
vector<int> v[MN+5];
pair<int,int> s[MN*MN+5];
int n,m,head[MN+5],cnt=0,same[MN*MN+5],ans[MN*MN+5],dfn[MN+5],dn,q[MN+5],M,Fa[MN+5],c[MN+5],Ans,dep[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;
}
void Pre(int x)
{
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=Fa[x]) dep[e[i].to]=dep[x]+1,Fa[e[i].to]=x,Pre(e[i].to);
    dfn[x]=++dn;q[dn]=x;
}
int lca(int x,int y)
{
    for(;x!=y;x=Fa[x]) if(dep[x]<dep[y]) swap(x,y);
    return x;
}
int main()
{
    n=read();M=m=read();
    for(int i=1;i<n;++i) ins(read(),read());
    Pre(1);
    for(int i=1;i<=m;++i)
    {
        s[i].first=read();s[i].second=read();
        ++c[s[i].first];++c[s[i].second];c[lca(s[i].first,s[i].second)]-=2;
        if(dfn[s[i].first]>dfn[s[i].second]) swap(s[i].first,s[i].second);
        v[s[i].first].push_back(i);
    }
    for(int i=1;i<=n;++i) c[Fa[q[i]]]+=c[q[i]],Ans+=min(c[q[i]],2);
    for(int i=1;i<n;++i)
    {
        int x=q[i],y;
        for(int j=head[x];j;j=e[j].next) if(dfn[e[j].to]>i) y=e[j].to;
        for(int j=v[x].size()>=2?2:0;j<v[x].size();++j)
        {
            int z=s[v[x][j]].second;
            if(z==y) continue;
            same[v[x][j]]=++m;
            if(dfn[y]<dfn[z]) s[m]=make_pair(y,z),v[y].push_back(m);
            else s[m]=make_pair(z,y),v[z].push_back(m),ans[v[x][j]]=1;
        }
        if(v[x].size()<2) continue;
        int a=s[v[x][0]].second,b=s[v[x][1]].second;
        if(a==b) {ans[v[x][0]]=1;continue;}
        if(dfn[a]<dfn[b]) s[++m]=make_pair(a,b),v[a].push_back(m),same[v[x][0]]=same[v[x][1]]=m,ans[v[x][0]]=1;
        else s[++m]=make_pair(b,a),v[b].push_back(m),same[v[x][0]]=same[v[x][1]]=m,ans[v[x][1]]=1;
    }
    printf("%d\n",Ans);
    for(int i=m;i;--i) if(same[i]) ans[i]^=ans[same[i]];
    for(int i=1;i<=M;++i) if(ans[i]) printf("%d %d\n",s[i].second,s[i].first); else printf("%d %d\n",s[i].first,s[i].second);
    return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
const int N=1e6+10;
int n,m,k;
int main()
{
	double r;
	cin >> r;
	cout <<2*r*M_PI<<endl;
}


Measured memory_bytes: 3788
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Z, W; cin >> N >> Z >> W;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	if (N == 1) {
		cout << abs(a.back() - W);
	}
	else {
		cout << max(abs(a[N - 2] - a[N - 1]), abs(a[N - 1] - W)) << endl;
	}

	return 0;
}

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

int main() {
	int h,n,a;
	cin >> h >> n;
	for(int i=0; i<n; i++){
		cin >> a;
		h-=a;
	}
	if(h<=0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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();
		int x = sc.nextInt();
		
		int[] l = new int[n];
		
		for(int i=0;i<n;i++) {
			l[i] = sc.nextInt();
		}
		
		int d = 0;
		int cnt = 1;
		for(int i=0;i<n;i++) {
			d = d + l[i];
			if(d > x) {
				break;
			}
			cnt++;
		}
		
		System.out.println(cnt);
		
	}
	


}

Measured memory_bytes: 21844
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val d = Array(2) { "" }
    d[0] = readLine()!!
    d[1] = readLine()!!

    var counts = 0L
    var preVertical = false
    var i = 0
    if (d[0][0] == d[1][0]) {
        preVertical = true
        counts = 3
        i++
    } else {
        counts = 6
        preVertical = false
        i += 2
    }

    val MOD = 1000000007
    while (i < N) {
        val isVertical = d[0][i] == d[1][i]

        if (isVertical) {
            if (preVertical) {
                counts = counts * 2 % MOD
            } else {
                counts = counts
            }
            i++
            preVertical = true
        } else {
            if (preVertical) {
                counts = counts * 2 % MOD
            } else {
                counts = counts * 3 % MOD
            }
            preVertical = false
            i+=2
        }
    }
    println(counts)
}

Measured memory_bytes: 33660
/**
*    created: 30.06.2020 14:37:10
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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 (b < a) {a = b; return 1;} return 0;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> e(n);
    vector<int> w(n);
    rep(i,n) {
        if (s[i] == 'E') e[i]++;
        else w[i]++;
    }
    rep(i,n) {
        if (i == 0) continue;
        e[i] += e[i-1];
        w[i] += w[i-1];
    }
    int ans = inf;
    rep(i,n) {
        if (i == 0) chmin(ans,e[n-1]-e[i]);
        else chmin(ans,e[n-1]-e[i]+w[i-1]);
    }
    cout << ans << endl;
    return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 K,N;
    cin >> N >> K;

    vector<i64> h(N);
    rep(i,0,N) cin >> h[i];
    sort(begin(h),end(h));

    i64 ans=inf64;
    rep(i,0,N){
        if(i+K-1>=N) break;
        ans=min(ans,h[i+K-1]-h[i]);
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void){
int a, b, c, i;
 
while(scanf("%d %d", &a, &b) != EOF){
c = a + b;
for( i=0; c != 0;i++){
c /= 10;
}
printf("%d\n", i);
}
return 0;
}
 

Measured memory_bytes: 1028
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, T;
	cin >> N >> T;
	vector<int> A(N);
	int res = 10000;
	int c, t;
	for (int i = 0; i < N; i++) {
		cin >> c >> t;
		if (t <= T) {
			res = min(res, c);
		}
	}
	if (res == 10000) {
		cout << "TLE" << endl;
	}
	else {
		cout << res << endl;
	}
}

Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

template<class T>
struct Dinic{
    const static int N = 10101 , M = N * 10;
    int s , t , n , h[N] , cur[N] , level[N] , q[N] , e , ne[M] , to[M];
    T cap[M] , flow;
    void liu(int u,int v,T w){ to[e] = v;ne[e] = h[u];cap[e] = w;h[u] = e++;}
    void link(int u,int v,T w){ liu(u , v , w);liu(v , u , 0);}
    void ini(int _n = N) { fill(h , h + (n=_n) , -1);e = 0;}
    bool bfs(){
        int L = 0 , R = 0;
        fill(level , level + n , -1);
        level[q[R++] = s] = 0;
        while(L < R && level[t] == -1){
            int c = q[L++];
            for(int k=h[c];~k;k=ne[k])
                if(cap[k] > 0 && level[to[k]] == -1)
                    level[q[R++] = to[k]] = level[c] + 1;
        }
        return ~level[t];
    }
    T dfs(int c,T mx){
        if(c == t) return mx;
        T ret = 0;
        for(int &k = cur[c];~k;k = ne[k]){
            if(level[to[k]] == level[c] + 1 && cap[k] > 0){
                T flow = dfs(to[k] , min(mx , cap[k]));
                ret += flow;cap[k] -= flow , cap[k^1] += flow;mx -= flow;
                if(!mx) return ret;
            }
        }
        level[c] = -1;
        return ret;
    }
    T run(int _s,int _t){
        s = _s , t = _t;
        flow = 0;
        while(bfs()){
            copy(h , h + n , cur);
            flow += dfs(s,~0U>>1);
        }
        return flow;
    }
};
Dinic<ll> it;
const int N = 110;
const ll linf = 1ll<<60;
int n , a[N];

int main(){
    cin >> n;
    ll ans = 0;
    rep(i,1,n+1) cin >> a[i] , ans += a[i];
    int S = 0 , T = n + 1;
    it.ini(T + 1);
    rep(i,1,n+1) {
        if(a[i]>=0) it.link(i,T,a[i]);
        else it.link(S,i,-a[i]),ans+=-a[i];
        rep(j,i+1,n+1) if(j%i==0)
            it.link(i,j,linf);
    }
    ans-=it.run(S,T);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define MAX 100005
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

int a[100005]={};

signed main(){
  int n;
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    b+=1;
    a[b]++;a[b-1]++;a[b+1]++;
  }
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  int ans=0;
  rep(i,n+5){
    if(a[i]>ans)ans=a[i];
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()

int main(){
  string str;
  list<int> data;
  list<int>::iterator it,l;
  int n,x;
  cin >> n;
  while(n--){
    cin >> str;
    if(str == "insert"){
      cin >> x;
      data.push_front(x);
    }else if(str == "delete"){
      cin >> x;
      for(it=data.begin(),l=data.end();it!=l;++it){
	if(*it == x){
	  data.erase(it);
	  break;
	}
      }
    }else if(str == "deleteFirst") data.pop_front();
    else data.pop_back();
  }
  for(it=data.begin(),l=--data.end();it!=l;++it) cout << *it << " ";
  cout << *it << endl;
}


Measured memory_bytes: 34372
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

int main()
{
  int cnt;
  int i;
  int N, K;
  int ret;

  cnt = scanf("%d %d", &N, &K);

  if (K == 1) {
    printf("0");
    return 0;
  }
  printf("%d", (N%K));

  return 0;
}



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

#define llong long long 
#define xx first
#define yy second
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#define ii pair<int, int>

#define maxn 201010
int n, k;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  cin >> n >> k;
  rep(i, n) {
    int u; cin >> u; ++a[u];
  }
  sort(a, a + maxn, greater<int>());
  llong t = remove(a, a + maxn, 0) - a;
  int ans = 0;
  while (t > k) ans += a[--t];
  cout << ans;

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string x;
  cin >> x;
  int n = x.size();
  vector<int> s, t;

  if (x[0] == 'T')
    s.push_back(0);

  int first = x.find('S');

  if (first == -1) {
    cout << n << endl;
    return 0;
  }

  ll ans = first;
  int scount = 0;

  rep(i, first, n) {
    if (x[i] == 'S') {
      scount++;
    } else {
      if (scount == 0)
        ans++;
      else
        scount--;
    }
  }
  ans += scount;
  cout << ans << endl;
}


Measured memory_bytes: 720
n = input()
op_cnt = len(n) - 1 
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt 
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  

    formula = ""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
    if eval(formula) == 7:
        print(formula + '=7')
        break

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
#include <set>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()

using namespace std;

int N, M, K, W,X;

int main() {
	int k,res;

	cin >> N >> M;
	if (M%N == 0) {
		cout << M / N;
	}
	else {
		k = M / N;

		for (int i = 1; i <= k;i++ ) {
			if (M%i == 0) {
				res = i;
			}

		}
		cout << res;
	}


}

Measured memory_bytes: 256
x, y = map(int, input().split())
ans = abs(abs(x) - abs(y))
if x * y < 0:
    ans += 1
if x * y > 0:
    if x > y:
        ans += 2
    if x < y:
        ans += 0
if x * y == 0:
    if x > y:
        ans += 1
print(ans)

Measured memory_bytes: 3060
import 'dart:io';

main(List<String> args) {
  List NM = stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  List<int> A =
      stdin.readLineSync().split(" ").map((x) => int.parse(x)).toList();
  int N = NM[0];
  int M = NM[1];

  int S = A.reduce((a, b) => a + b);

  if (S > N)
    print(-1);
  else
    print(N - S);
}


Measured memory_bytes: 14648
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0ll,a+b-n)<<endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int tmp_N = N;
  if(N < 10){
    cout << "Yes" << endl;
    return 0;
  }
  while(tmp_N>=1){
    fx += tmp_N%10;
    tmp_N /= 10;
  }
  if(N % fx == 0){
    cout << "Yes" << endl;
  }
  else if(N % fx != 0){
    cout << "No" << endl;
  }
  return 0;
}

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

bool ev(string s, int n) {
	if (n % 2 == 1) return false;
	for (int i=0; i+i<n; i++) {
		if (s[i] != s[i+n/2]) return false;
	}
	return true;
}

int main() {
    
	string s;
	cin >> s;
	for (int i=1; i<s.size(); i++) {
		if (ev(s, s.size()-i)) {
			cout << s.size() - i << endl;
			exit(0);
		}
	}
    
}


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

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

    int64_t ans = 0;
    int64_t target = 1;
    for (int64_t i = 0; i < N; i++) {
        if (a[i] == target) {
            target++;
        } else {
            ans++;
        }
    }

    cout << (target == 1 ? -1 : ans) << endl;
}

Measured memory_bytes: 1792