akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int kyougisuu = sc.NextInt();
        int ninnzuu = sc.NextInt();
        int[] nedann = new int[kyougisuu];
        int nums = 1;
        for (int i = 0; i < kyougisuu; i++)
        {
            nedann[i] = sc.NextInt();
        }
        int[] kyougi = new int[kyougisuu];
        for (int iin = 0; iin < ninnzuu; iin++)
        {
            int sinsaa = int.Parse(Console.ReadLine());
            for (int k = 0; k < kyougisuu; k++)
            {
                if (sinsaa>=nedann[k])
                {
                    kyougi[k] += 1;
                    break;
                }
            }
        }
        int a = kyougi[0];
        for (int i = 0; i < kyougisuu-1; i++)
        {
            if (a>=kyougi[i+1])
            {
            }
            else
            {
                a = kyougi[i + 1];
                nums = i + 2;
            }
        }
        Console.WriteLine(nums);
    }

    static void Main()
    {
        byte[] inputBuffer = new byte[1024];
        Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}
    

Measured memory_bytes: 9200
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
#include <tuple>
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

    vector<vector<int> > dp(100005, vector<int>(3));

    int N, K, R, S, P;
    string T;

    cin >> N >> K >> R >> S >> P >> T;

    int count = 0;

    for(int i = 0; i < K; i++) {
        int pos = 0;
        while(i + pos * K < N) {
            for(int j = 0; j < 3; j++) {
                int c = 0;
                int max = 0;
                if(T[i + pos * K] == 'r') {
                    if(j == 2) c = P;
                } else if(T[i + pos * K] == 's') {
                    if(j == 0) c = R;
                } else {
                    if(j == 1) c = S;
                }
                for(int k = 0; k < 3; k++) {
                    if(j != k) {
                        if(max < c + dp[pos][k]) max = c + dp[pos][k];
                    }
                }
                dp[pos + 1][j] = max;
                //cout << max << " ";
            }
           // cout << endl;
            pos++;
        }
        int max = 0;
        for(int j = 0; j < 3; j++) {
            if(max < dp[pos][j]) max = dp[pos][j];
        }
        count += max;
    }

    cout << count << endl;
}


Measured memory_bytes: 6016
import Control.Monad
import qualified Data.Vector.Unboxed as UV
import Data.List
import qualified Data.ByteString.Char8 as B

r3 [a,b,c]=(a,b,c)
main = do
    n<-readLn::IO Int
    xs<-UV.replicateM n $ r3.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ f n xs
f n xs = (\(a,b,c)->maximum [a,b,c]) $ UV.foldl' q (0,0,0) xs where
    q (u,v,w) (a,b,c) = (a+max v w, b+max u w, c+max u v)


Measured memory_bytes: 23932
#include <bits/stdc++.h>
using namespace std;
#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 repR(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep1R(i,n) for (int i = int(n); i >= 1; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define cauto const auto
#ifdef LOCAL
#define dump(...) cerr << "[" << __LINE__ << ":" << __FUNCTION__ << "] ", _dmp_(#__VA_ARGS__, __VA_ARGS__);
void _dmp_(const char*) { cerr << endl; }
template <class T, class... U>
void _dmp_(const char *s, T const& x, U const& ...y) { const char *o = "({[", *e = "]})"; for (int i = 0; *s != '\0'; cerr << *s++) { if (count(o,o+3,*s)) i++; if (count(e,e+3,*s)) i--; if (!i && *s == ',') break; } cerr << " = " << x; if (*s == ',') cerr << ", ", s++; _dmp_(s, y...); }
#else
#define dump(...)
#endif
using ll = long long;
#define int ll
template <class T> using pque_max = priority_queue<T>;
template <class T> using pque_min = priority_queue<T, vector<T>, greater<T> >;
#define CONAINER_OUTPUT os << "{"; for (auto const& x : v) os << " " << x; return os << " }";
template <class T> ostream& operator<<(ostream& os, vector<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, deque<T> const& v) { CONAINER_OUTPUT }
template <class T> ostream& operator<<(ostream& os, set<T> const& v) { CONAINER_OUTPUT }
template <class T, class U> ostream& operator<<(ostream& os, map<T,U> const& v) { CONAINER_OUTPUT }
#undef CONAINER_OUTPUT
template <class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template <class T, class S> ostream& operator<<(ostream& os, pair<T,S> const& p) { return os << "(" << p.first << ", " << p.second << ")"; }
template <class T, class S> istream& operator>>(istream& is, pair<T,S> const& p) { return is >> p.first >> p.second; }
struct _Init_ { _Init_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } _init_;

template <class T> void quit(T const& x) { cout << x << endl; exit(0); }
template <class T> bool chmin(T& x, T const& y) { if (x > y) { x = y; return true; } return false; }
template <class T> bool chmax(T& x, T const& y) { if (x < y) { x = y; return true; } return false; }
template <class It> auto sumof(It b, It e) { return accumulate(b,e,typename iterator_traits<It>::value_type{}); }
#define YesNo(c) ((c) ? "Yes" : "No")
////////////////////////////////

int32_t main() {
    int n; cin >> n;
    if (n%2 == 0) {
        cout << 0.5 << endl;
    } else {
        double a = (n+1)/2;
        double b = n;
        cout << a/b << endl;
    }
}


Measured memory_bytes: 256
def resolve():
    from copy import deepcopy
    h, w, K = list(map(int, input().split()))

    white = 0
    black = 1
    red = 0
    matrix = []
    for i in range(h):
        chars = input()
        line = []
        for char in chars:
            if char == '.':
                line.append(white)
            elif char == '#':
                line.append(black)
        matrix.append(line)

    count = 0
    for i in range(1 << (h + w)):
        m = deepcopy(matrix)
        for j in range(h):
            if (i >> j) & 1 == 1:
                m[j] = [red for _ in range(w)]

        for j in range(w):
            if (i >> (j + h)) & 1 == 1:
                for k in range(h):
                    m[k][j] = red

        black_count = 0
        for j in range(h):
            for k in range(w):
                if m[j][k] == black:
                    black_count += 1

        if black_count == K:
            count += 1

    print(count)


if 'unittest' not in globals():
    resolve()

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

int main(){
    int H, W;
    cin >> H >> W;
    map<int, int64_t> mp;
    multiset<int64_t> values;
    for(int i=1; i<=W; i++){
        mp[i] = 0;
        values.insert(0);
    }

    for(int i=1; i<=H; i++){
        int l, r;
        cin >> l >> r;

        if(r != W){
            auto it = mp.upper_bound(r+1);
            if(it != mp.begin()){
                it--;
                if(it->first != r+1){
                    int64_t v = it->second + (r+1-it->first);
                    mp[r+1] = v;
                    values.insert(v);
                }
            }
        }

        auto it = mp.lower_bound(l);
        while(it != mp.end() && it->first <= r){
            values.erase(values.find(it->second));
            it = mp.erase(it);
        }

        if(values.size()){
            cout << i + *values.begin() << endl;
        }else{
            cout << -1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 25512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
int main()
{
	ll N,M;
	string ANS="No";
	vector<vector<char>>A,B;
	cin>>N>>M;
	rep(i,N){
		vector<char>vec;
		string s;
		cin>>s;
		rep(j,N){
			vec.push_back(s[j]);
		}
		A.push_back(vec);
	}
	rep(i,M){
		vector<char>vec;
		string s;
		cin>>s;
		rep(j,M){
			vec.push_back(s[j]);
		}
		B.push_back(vec);
	}
	rep(i,N-M+1){
		rep(j,N-M+1){
			if(A[i][j]==B[0][0]){
				bool f=true;
				rep(k,M){
					rep(l,M){
						if(A[i+k][j+l]!=B[k][l])f=false;
					}
				}
				if(f==true)ANS="Yes";
			}
			//cout<<A[i][j];
		}
		//cout<<endl;
	}
	cout<<ANS<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	deque<int>v;
	rep(i, N) {
		if (!i) {
			v.push_back(A[i]);
		}
		else {
			if (v[0] >= A[i]) {
				v.push_front(A[i]);
			}
			else {
				int a = lower_bound(v.begin(), v.end(), A[i]) - v.begin() - 1;
				v[a] = A[i];
			}
		}
	}
	int ans = v.size();
	cout << ans << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

bool ckmin(int& a,int b) {
    if (a <= b) return false;
    a = b; return true;
}

int N,M,dp[MX];

template<int SZ> struct SCC {
    vi adj[SZ], allComp, st; int num = 0;
    int N, val[SZ], comp[SZ], p[SZ];
    void ae(int u, int v) { adj[u].pb(v); }
    int dfs(int u) {
        static int t = 0; int low = val[u] = ++t; st.pb(u);
        trav(i,adj[u]) if (comp[i] < 0) ckmin(low, val[i]?:dfs(i));
        if (low == val[u]) {
            allComp.pb(u); int x;
            do { comp[x = st.back()] = u; p[x] = num++; st.pop_back(); } while (x != u);
        } return val[u] = low;
    }
    void init(int _N) {
        N = _N; F0R(i,N) val[i] = 0, comp[i] = -1;
        F0R(i,N) if (comp[i] < 0) dfs(i);
        reverse(all(allComp));
    }
};

SCC<MX> K;
vi adj[MX];

int main() {

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

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

    vii edges;
    F0R(i,M) {
        int u,v; cin >> u >> v;
        --u,--v;
        K.ae(u,v); edges.pb({u,v});
    }

    K.init(N);
    trav(x,edges) adj[K.p[x.f]].pb(K.p[x.s]);

    int res = 0;
    F0R(i,N) {
        dp[i] = 1;
        trav(v,adj[i]) {
            dp[i] = max(dp[i],dp[v]+1);
        }
        res = max(res,dp[i]);
    }

    cout << res-1 << "\n";
}


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

vector<vector<char>> tovv(int k, string s) {
  vector<vector<char>> ret(k, vector<char>(k));
  for (int j = 0; j < k; j++) {
    for (int i = 0; i < k; i++) ret.at(j).at(i) = s.at(1 + j*(k+1) + i);
  }
  return ret;
}

const vector<string> bb = {
  "", "", "",
  R"(
.aa
a..
a..
)", R"(
aacd
bbcd
cdaa
cdbb
)", R"(
aabee
c.bff
cddee
efe..
efe..
)", R"(
aab.ee
c.bf..
cddf..
.eeaab
f..c.b
f..cdd
)", R"(
.ccaabb
c..bbaa
c..aabb
aba....
aba....
bab....
bab....
)"
};

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  if (N == 2) {
    cout << "-1\n";
    return 0;
  }

  vector<vector<char>> ans(N, vector<char>(N, '.'));

  auto copy = [&](int j0, int i0, auto brd, int w) -> void {
    for (int j = 0; j < w; j++) {
      for (int i = 0; i < w; i++) {
	ans.at(j0 + j).at(i0 + i) = brd.at(j).at(i);
      }
    }
  };

  if (N == 3) {
    auto brd = tovv(3, bb.at(3));
    copy(0, 0, brd, 3);
  }else {
    int k = 4 + ((N-4) % 4);
    auto brdK = tovv(k, bb.at(k));
    auto brd4 = tovv(4, bb.at(4));
    for (int t = 0; t < (N - k) / 4; t++) copy(4*t, 4*t, brd4, 4);
    copy(N-k, N-k, brdK, k);
  }
  for (int j = 0; j < N; j++) {
    for (int i = 0; i < N; i++) cout << ans.at(j).at(i);
    cout << "\n";
  }
}



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

bool check(int x1,int y1,int x2,int y2) {

        if(x1==y2||x2==y1) return false;
        return ((x1<=x2&&y1>=x2)||(x1<=y2&&y1>=y2));
}


vector < pair <int,int> > v;
int main() {

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

    while(m--) {

            int x,y;cin >> x >> y;
            v.push_back({x,y});
    }

    sort(v.begin(),v.end());
    int l=-1,r=-1,cnt=0;
    for(int i=0;i<v.size();i++) {

           int x=v[i].first,y=v[i].second;
           if(check(l,r,x,y)){
               l=max(l,x);
               r=min(r,y);
    //cout << l << " " << r << endl;

           }
           else{
                ++cnt;
                l=x;
                r=y;
           }

    }
    cout << cnt << endl;

}


Measured memory_bytes: 1400
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    int h = sc.nextInt();
    int w = sc.nextInt();
    int kuro = W * h + H * w - h * w;
    int ans = H * W - kuro;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
program rectangle_cutting

 implicit none
 real(8)::w,h,x,y,ans1
 integer::ans2
 read*,w,h,x,y

 ans1=w*h*0.5

 if(x==w*0.5 .and. y==h*0.5) then
  ans2=1
 else
  ans2=0
 end if

 print*,ans1,ans2

end program rectangle_cutting

Measured memory_bytes: 384
S = input()
n1 = int(S[:2])
n2 = int(S[2:])

if 1 <= n1 <= 12 and 1 <= n2 <= 12:
    print('AMBIGUOUS')
elif 1 <= n1 <= 12 and (not 1 <= n2 <= 12):
    print('MMYY')
elif (not 1 <= n1 <= 12) and 1 <= n2 <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    int A[210];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    int res = 0;
    while (true)
    {
        bool exsist_odd = false;
        for (int i = 0; i < N; i++)
        {
            if (A[i] % 2 != 0)
            {
                exsist_odd = true;
            }
        }
        if (exsist_odd)
        {
            break;
        }
        for (int i = 0; i < N; i++)
        {
            A[i] /= 2;
        }
        res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <queue>
#include <tuple>
#include <stack>
#include <limits>
#define dis(a) get<0>(a)
#define index(a) get<1>(a)
#define min(a,b) a<b?a:b
#define INF numeric_limits<int>::max()
using namespace std;
priority_queue<tuple<int, int>, vector<tuple<int, int>>, greater<tuple<int, int>>> ver_unconfirmed; //distance,index
int ver_n, edge_n, dep_i;
vector<int> dis, dis_u;
vector<vector<tuple<int, int>>> conn_list; //sep;dest,cost
void dijkstra()
{
	ver_unconfirmed.push(make_tuple(0, dep_i)); //distance,index
	dis_u[dep_i] = 0;
	while (!ver_unconfirmed.empty())
	{
		auto ver_nearest = ver_unconfirmed.top();
		if (dis[index(ver_nearest)] == INF)
		{
			dis[index(ver_nearest)] = dis(ver_nearest);
			ver_unconfirmed.pop();
			for (auto vertex : conn_list[index(ver_nearest)])
			{
				if (dis[get<0>(vertex)] == INF)
				{
					dis_u[get<0>(vertex)] = min(dis_u[get<0>(vertex)], dis[index(ver_nearest)] + get<1>(vertex));
					ver_unconfirmed.push(make_tuple(dis_u[get<0>(vertex)], get<0>(vertex)));
				}
			}
		}
		else
		{
			ver_unconfirmed.pop();
		}
	}
}

int main()
{
	scanf("%d%d%d", &ver_n, &edge_n, &dep_i);
	conn_list = vector<vector<tuple<int, int>>>(ver_n, vector<tuple<int, int>>());
	for (int i = 0; i < edge_n; i++)
	{
		int start, end, cost;
		scanf("%d%d%d", &start, &end, &cost);
		conn_list[start].push_back(make_tuple(end, cost));
	}
	dis_u = dis = vector<int>(ver_n, INF);
	dijkstra();
	for (int i : dis)
	{
		if (i != INF)
		{
			printf("%d\n", i);
		}
		else
		{
			printf("INF\n");
		}
	}
}


Measured memory_bytes: 12880
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    vi v(n+1);
    rep(i, n) cin >> v[i+1];
    v.pb(0);
    ll sum = 0LL;
    rep(i, n+1) {
        sum += abs(v[i+1]-v[i]);
    } 
    rep(i, n) {
        int now = v[i+1];
        int prv = v[i];
        int nxt = v[i+2];
        if((prv <= now && now <= nxt) || (nxt <= now && now <= prv)) {
            cout << sum << endl;
        }
        else {
            cout << sum - abs(now - nxt) - abs(now - prv) + abs(prv - nxt) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1656
import java.math.*
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map(String::toInt)
    val a = readLine()!!.split(" ").map(String::toInt)
    println(Math.min(a.filter{ c -> c < x }.count(), a.filter{ c -> c > x}.count()))
}

Measured memory_bytes: 37740
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
LL ar[50000001];
LL br[50000001];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]={2,1,-1,-2,-2,-1,1,2};
LL dy[]={1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m>>o;
        k=0;
        for(i=n;i<=m;i++)
        {
            if(i%o==0)
            {
                k++;
            }
        }

        cout<<k<<endl;

    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void)
{
	int i,a[10],o=0;
	for(i=0;i<10;i++){
		a[i]=0;
		scanf("%d",&a[i]);
		o=o+a[i];
	}
	printf("%d\n",o);
	return 0;
}

Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using Graph = vector<vector<int>>;


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

int main() {
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;

}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using I   = int;
using LL  = long long int;
using VI  = vector <I>;
using VLL = vector <LL>;
#define FOR( i, a, b ) for( int i=(a) ; i < (b) ; ++i )
#define REP( i, n )    for( int i= 0  ; i < (n) ; ++i )
#define ALL(a)         (a).begin(), (a).end()

int main( ) {
	I ans = 0;

	I min = 10;
	REP(i,5){
		I in;
		cin >> in;

		ans += in + 10 - in % 10;
		if( in % 10 == 0 ) {
			ans -= 10;
		}
		if( in % 10 < min && in % 10 != 0 ) {
			min = in % 10;
		}
	}
 
	ans -= 10 - min;
	cout << ans << endl;
}



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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

void solve() {
    string s, t;
    cin >> s >> t;
    int n = (int)s.size(), m = (int)t.size();
    vector<vector<int>> dp(n+1, vector<int>(m + 1));

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i-1] != t[j-1]) {
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            } else {
                dp[i][j] = dp[i-1][j-1] + 1;
            }
        }
    }

    string ans = "";
    int i = n, j = m;
    while (i > 0 && j > 0) {
        if (s[i-1] == t[j-1]) {
            ans.pb(s[i-1]);
            i--, j--;
        } else if (dp[i-1][j] > dp[i][j-1]) {
            i--;
        } else j--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans;

}

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

    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


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

typedef long long ll;
#define chmax(a, b) (a) = ((a) < (b)) ? (b) : (a)

using namespace std;



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

  ll ans = a * c;
  chmax(ans, a * d);
  chmax(ans, b * c);
  chmax(ans, b * d);
  
  cout << ans << endl;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define ll long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, n) for(int i = 0; i < n; ++i)

using namespace std;	

const int nax = 1e5 + 111;
const int MAX = 3e5 + 1234;

int n;
int a[nax];

vector <int> val;

struct fen {
	int f[MAX];
	
	void init() {
		for(int i = 0; i < MAX; ++i)
			f[i] = 0;
	}
	
	void add(int x, int c) {
		for(; x < MAX; x += x & -x)
			f[x] += c;
	}
	
	int query(int x) {
		int res = 0;
		for(; 0 < x; x -= x & -x)
			res += f[x];
		return res;
	}
} t;

int pref[nax];

ll ok(int x) {
	t.init();
	ll war = val[x];
	for(int i = 1; i <= n; ++i)
		pref[i] = pref[i - 1] + (a[i] <= war);
	ll res = 0;
	for(int i = 0; i <= n; ++i) {
		int ja = 2 * pref[i] - i + nax;
		res += t.query(ja - 1);
		t.add(ja, 1);
	}
	return res;
}
	

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		val.pb(a[i]);
	}
	
	sort(val.begin(), val.end());
	val.erase(unique(val.begin(), val.end()), val.end());
	
	int l = 0;
	int r = ss(val) - 1;
	
	ll x = 1ll * n * (n + 1) / 2;
	ll y = x / 2 + 1;
	
	while(l < r) {
		int m = (l + r) / 2;
		if(ok(m) < y)
			l = m + 1;
		else
			r = m;
	}
	
	printf("%d\n", val[l]);
	return 0;
}


Measured memory_bytes: 2680
#include <cstdio>
using namespace std;

int main() {
  int x, y, mapx, mapy, tmp0, tmp1, flag;
  char map[101][101], pmap;
  scanf("%d%d",&mapx,&mapy);
  while (mapx+mapy) {
    for (tmp0 = 0;tmp0 < mapx;tmp0++) scanf("%s", map[tmp0]);
    x = 0, y = 0, flag = 1;
    while (flag && flag != 100) {
      pmap = map[x][y];
      map[x][y] = 1;
      if (pmap == '>') y++;
      else if (pmap == '<') y--;
      else if (pmap == '^') x--;
      else if (pmap == 'v') x++;
      else if (pmap == '.') flag = 0;
      else flag = 100;
    }
    if (flag) puts("LOOP");
    else printf("%d %d\n", y, x);
    scanf("%d%d", &mapx,&mapy);
  }
  return 0;
}

Measured memory_bytes: 1052
#include <cstdio>
    #include <string>
    #include <cmath>
    #include <string>
    #include <algorithm>
    #include <iostream>
    #include <map>
    #include <vector>
    #include <iomanip>
    #include <tuple>
    #include <queue>
    #include <numeric>
    using namespace std;
    typedef long long ll;
    #define rep(i, a, n) for (int i=a;i<n;++i)
    #define repeq(i, a, n) for(int i=a;i<=n;++i)
    #define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
    #define per(i, a, n) for (int i=n-1; i>=a;--i)
    #define pb push_back
    #define mp make_pair
    #define all(x) (x).begin(), (x).end()

    vector<ll> divisor(ll n){
        vector<ll> divise;

        rep(i, 1, (ll)sqrt(n)+1){
            if(n%i == 0){
                divise.push_back(i);
                divise.push_back(n / i);
            }
        }
        return divise;
    }

    // D - Partition
    ll N, M;
    ll ans = 1;

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

        ll tmp = M / N;

        vector<ll> divi = divisor(M);
        repi(divi, itr){
            if(tmp >= *itr){
                ans = max(ans, *itr);
            }
        }
        
        cout << ans << endl;
        return 0;
    }




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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

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

ll N,M,ans;
ll A[101010],B[101010];
vector<ll> gv[101010];
ll ct[101010];
ll i, j;
ll mk[101010];
void bfs(ll a){
    ll i = 0;
    fornum(i,0,gv[a].size()){
        ll b = gv[a][i];
        
    }
}

int main(){
    scanf("%lld%lld", &N,&M);
    fornum(i, 0,N+M-1){
        ll a, b;
        scanf("%lld%lld", &a, &b);
        gv[a].push_back(b);
        ct[b]++;
    }
    fornum(i,0,N){
        if(ct[i+1]==0){
            break;
        }
    }
    mk[i+1] = i+1;
    queue<ll> q;
    q.push(i + 1);
    while(!q.empty()){
        auto qa = q.front();
        q.pop();
        fornum(i, 0, gv[qa].size()){
            ll b = gv[qa][i];
            if(mk[b]==0){
            ct[b]--;
            if(ct[b]==0){
                mk[b] = qa;
                //printf("%lld,%lld\n", b, a);
                q.push(b);
            }
        }
        }
    }



    fornum(i,0,N){
        printf("%lld\n", mk[i+1]==i+1?0:mk[i+1]);
    }
    return 0;
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

#define SIZE 500
typedef struct {
  int sx,sy,dx,dy;
} OP;

void printOP(OP op){
  cout << (op.sy+1) << " " << (op.sx+1) << " " <<
  (op.dy+1) << " " << (op.dx+1) << endl;
}

int main(void){
  int h,w;
  int fld[SIZE][SIZE];
  OP opList[SIZE*SIZE];
  int opCnt=0;
  
  cin >> h >> w;
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cin >> fld[j][i];
    }
  }
  
  for (int i=0; i<h; i++){
    for (int j=0; j<w-1; j++){
      if (fld[j][i]>0 && fld[j][i]%2){
        fld[j][i]--; fld[j+1][i]++;
        opList[opCnt].sy = i;
        opList[opCnt].sx = j;
        opList[opCnt].dy = i;
        opList[opCnt].dx = j+1;
        opCnt++;
      }
    }
  }
  for (int i=0; i<h-1; i++){
    int j=w-1;
    if (fld[j][i]>0 && fld[j][i]%2){
      fld[j][i]--; fld[j][i+1]++;
      opList[opCnt].sy = i;
      opList[opCnt].sx = j;
      opList[opCnt].dy = i+1;
      opList[opCnt].dx = j;
      opCnt++;
    }
  }
  
  cout << opCnt << endl;
  for (int i=0; i<opCnt; i++){
    printOP(opList[i]);
  }
  return 0;
}


Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
//#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 5;
#define ll long long
#define inf 0x3f3f
#define mod 1000000007
#define endl '\n'
//int a[maxn];
//int b[maxn][maxn];
int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s1, s2;
	cin >> s1 >> s2;
	int ans = inf;
	for (int i = 0; i+s2.length()-1 < s1.length(); i++)
	{int c = 0;
		for (int j = 0; j < s2.length(); j++)
		{
			if (s1[i+j] != s2[j])
			{
				c++;
			}
		}ans = min(ans, c);
	}
	cout << ans << '\n';

}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;

const int maxin = 5e5 + 10;
const int inf = INT_MAX / 2;
const ll llinf = LLONG_MAX / 2;
const double eps = 1e-9;

int dp[1111][100 * 100 + 111];
int n;
int a[1111];

main ()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   cin >> n;
   for (int i = 1;i <= n;++i)
   {
      cin >> a[i];
      dp[i][a[i]] = 1;
   }
   for (int i = 1;i <= n;++i)
   {
      for (int j = 1;j <= 100 * 100;++j)
      {
         if (dp[i][j])
         {
            dp[i + 1][j + a[i + 1]]++;
            dp[i + 1][j]++;
         }
      }
   }
   int ans = 0;
   for (int i = 1;i <= n;++i)
   {
      for (int j = 1;j <= 100 * 100;++j)
      {
         if (dp[i][j] && j % 10 != 0)
            ans = max(ans, j);
      }
   }
   cout << ans;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    if(x % 11 >= 7){
        ans += 2;
    }else if(x % 11 != 0) ans++;
    print(ans);
    
}

Measured memory_bytes: 256
import statistics
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n,a,b = list(map(int,input().strip().split()))
v = list(map(int,input().strip().split()))
v.sort(reverse=True)

result = 0
mean_min = statistics.mean(v[0:a])
for i in range(a,b+1):
  st_mean = statistics.mean(v[0:i])
  if mean_min == st_mean:
    v_n = v.count(v[a])
    v_r = v[0:i].count(v[a])
    result += combinations_count(v_n,v_r)
  else:
    break
print(mean_min)
print(result)

Measured memory_bytes: 5084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;



void solve(void){
    int N;
    cin >> N;
    vector<int> a(N), b(N);
    rep(N, i) cin >> a.at(i);
    rep(N, i) cin >> b.at(i);
    int ans = 0;
    rep(29, k) {
        int t = 1<<k, mod = 2*t, cnt = 0;
        vector<int> nb(N);
        rep(N, i) nb[i] = b[i]%mod;
        sort(all(nb));
        rep(N, ai) {
            int ma = a[ai]%mod;
            if ((upper_bound(all(nb), t*2-ma-1) - lower_bound(all(nb), t-ma) + upper_bound(all(nb), t*4-ma-1) - lower_bound(all(nb), t*3-ma))%2) {
                    cnt++;
                }
        }
        if (cnt%2) ans += t;
    }
    cout << ans << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 2560
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
S = input()

ans = 0
for i in range(n):
    a = S[:i]
    b = S[i:]
    c = set(a) & set(b)
    ans = max( ans, len(c) )
print(ans)

Measured memory_bytes: 38440
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int m = sc.nextInt();
		int d = sc.nextInt();


		// 計算
		int result = 0;
		
		if(d < 22){
		}else{
    		for(int i = 1; i < m + 1; i++){
    		    for(int j = 22; j < d + 1; j++){
    		        
    		        int b = j%10;
    		        
    		        int a = (j - b)/10;
    		        
    		        if(b > 1 && i == a*b){
    		            result++;

    		        }
    		        
    		    }
    		}
		}

		// 出力
		System.out.println(result);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int maxn = 1e5 + 5;

int dis[maxn];
int k;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> k;
    fill_n(dis,maxn,100);
    deque<int> q;
    q.push_back(1);
    dis[1] = 1;
    while(q.size()){
        int u = q.front();q.pop_front();
//        cout << u << endl;
        if(dis[(u + 1) % k] > dis[u] + 1){
            dis[(u + 1) % k] = dis[u] + 1;
            q.push_back((u + 1) % k);
        }
        if(dis[u * 10 % k] > dis[u]){
            dis[u * 10 % k] = dis[u];
            q.push_front(u * 10 % k);
        }
    }
    cout << dis[0];
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define N 2005
using namespace std;

int n,m;
char s[N];
int a[N][N],h[N],b[N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
    {
        scanf("%s",s);
        for(int j=0;j<m;j++)
            a[i][j]=s[j]=='#'?1:0;
    }
    int ans=max(n,m);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(i&&!(a[i-1][j+1]^a[i][j]^a[i-1][j]^a[i][j+1]))h[j]++;
            else h[j]=1;
        }
        int t=0;
        for(int j=0;j<=m-1;j++)
        {
            while(t&&h[b[t-1]]>=h[j])
            {
                int x=b[--t];
                if(!t)ans=max(ans,(j+1)*h[x]);
                else ans=max(ans,(j-b[t-1])*h[x]);
            }
            b[t++]=j;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15872
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<int, ll> PIL;

const int N = 100100;

/**
 * Dijkstra's algorithm.
 * First, call add_edge() to add edges.
 * Second, call solve() to calculate the length of the shortest path from source to each vertex.
 * Header requirement: algorithm, queue, vector
 * Verified by AtCoder ARC026-C (http://arc026.contest.atcoder.jp/submissions/604231)
 */
 template<class Len = int>
class Dijkstra {
private:
  int n;
  std::vector<std::vector<std::pair<int, Len> > > edges;
public:
  /**
   * n: the number of vertices
   */
  Dijkstra(int n) : n(n), edges(n) {}
  /*
   * from: the source of edge to add
   * to: the target of edge to add
   * cost: the cost of edge to add
   */
  void add_edge(int from, int to, Len cost) {
    edges[from].push_back(std::pair<int, Len>(to, cost));
  }
  /*
   * This function returns an array consisting of the distances from vertex source.
   */
  std::vector<Len> solve(int source) {
    const Len inf = 1e16;
    typedef std::pair<Len, int> pi;
    std::vector<Len> d(n, inf);
    std::priority_queue<pi, std::vector<pi>, std::greater<pi> > que;
    que.push(pi(0, source));
    while (!que.empty()) {
      pi p = que.top(); que.pop();
      int idx = p.second;
      if (d[idx] <= p.first) {
	continue;
      }
      d[idx] = p.first;
      for(int j = 0; j < edges[idx].size(); ++j) {
	que.push(pi(p.first + edges[idx][j].second, edges[idx][j].first));
      }
    }
    return d;
  }
};


vector<PIL> gy[N];
vector<PIL> gs[N];


int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  s--, t--;
  Dijkstra<ll> dij_y(n), dij_s(n);
  REP(i, 0, m) {
    int u, v;
    ll a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    gy[u].push_back(PIL(v, a));
    gy[v].push_back(PIL(u, a));
    gs[u].push_back(PIL(v, b));
    gs[v].push_back(PIL(u, b));
    dij_y.add_edge(u, v, a);
    dij_y.add_edge(v, u, a);
    dij_s.add_edge(u, v, b);
    dij_s.add_edge(v, u, b);
  }
  VL ans(n);
  VL sol_y = dij_y.solve(s);
  VL sol_s = dij_s.solve(t);
  REP(i, 0, n) {
    ans[i] = (ll)1e15 - sol_y[i] - sol_s[i];
  }
  for (int i = n - 2; i >= 0; --i) {
    ans[i] = max(ans[i], ans[i + 1]);
  }
  REP(i, 0, n) {
    cout << ans[i] << "\n";
  }
}


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

int main() {
	
	long long n;
	long long bi = 1000 * 1000 * 1000;
	bi = bi * bi;
	cin >> n;
	if (n % 2 == 1) cout << 0 << endl;
	else {
		long long c = 0;
		long long tr = 10;
		for (int i=0; i<100000; i++) {
			c += n / tr;
			tr = tr * 5;
			if (tr > bi) {
				cout << c << endl;
				exit(0);
			}
		}
		cout << c << endl;
	}
	
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
int n,m,k;

int main(){
    scanf("%d",&n);
    if((n&(n-1))==0){
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    printf("%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n",n+1,n+2,n+2,n+3,n+3,1,1,2,2,3);
    for(int i=4;i<n;i+=2){
        printf("%d %d\n",1,i);
        printf("%d %d\n",i,i+1);
        printf("%d %d\n",1,n+i+1);
        printf("%d %d\n",n+i+1,n+i);
    }
    if(n%2==0){
        m=n^1; k=0;
        while((m>>k)!=1) k++;
        k=1<<k; m^=k;
        printf("%d %d\n%d %d\n",k,n,n+m,n+n);
    }
}

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

int main() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

// HH: ok
// HD: ng
// DH: ng
// DD: ok

void solve() {
  string a, b;
  cin >> a >> b;
  puts(a == b ? "H" : "D");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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; }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll fact[2005];

void prepare(){
  ll now=1;
  reps(i,2000){
    now*=i;
    now%=MOD;
    fact[i]=now;
  }
}

long long modinv(long long a, long long m) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll x(n);
  rep(i,n) cin>>x[i];
  vll d(n-1);
  rep(i,n-1) d[i]=x[i+1]-x[i];
  
  ll c=0, ans=0;
  rep(i,n-1){
    c=(c+modinv(i+1,MOD))%MOD;
    ans=(ans+c*d[i])%MOD;
  }
  ll fact=1;
  reps(i,n-1) fact=fact*i%MOD;
  ans=ans*fact%MOD;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-10;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second

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

typedef struct _edge{
  int to,cost;
  _edge(int ito,int icost):to(ito),cost(icost){};
}edge;

vector<edge> E[110];
int s,d;
bool used[50];

int prim(){
  memset(used,0,sizeof(used));
  priority_queue<PI> Q;//cost,to;

  Q.push(mp(0,0));

  int ret=0;
  
  while(!Q.empty()){
    int ccost=-Q.top().F,from=Q.top().S;
    Q.pop();
    if(used[from])continue;
    used[from]=true;

    ret+=ccost;
    rep(i,E[from].size()){
      int to=E[from][i].to,cost=E[from][i].cost;
      if(used[to])continue;
      Q.push(mp(-cost,to));
    }
  }
  return ret;

}
    

main(){
  while(cin>>s>>d,s|d){
    rep(i,s+d)E[i].clear();
    rep(i,s){
      rep(j,d){
	int co;
	cin>>co;
	if(!co)continue;
	E[i].pb(edge(j+s,co));
      }
    }
    rep(i,d-1){
      rep(j,d-i-1){
	int co;
	cin>>co;
	if(!co)continue;
	int to=i+j+1+s;
	E[i+s].pb(edge(to,co));
	E[to].pb(edge(i+s,co));
      }
    }

    rep(i,s){
      rep(j,i){
	E[i].pb(edge(j,0));
	E[j].pb(edge(i,0));
      }
    }

    cout<<prim()<<endl;
  }
}
      

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

int main() {
int n;
cin >> n;
vector<double> a(n);
rep(i,n){
   cin >> a[i];
}
double ans = 0.0;
rep(i,n){
  ans += 1/a[i];
}
cout << 1/ans << endl;
}

Measured memory_bytes: 256
s = int(input())
a_list = [s]
INF = 10 ** 5
for i in range(INF):
    value = a_list[-1]
    if value % 2 == 0:
        next_value = value / 2
        if next_value in a_list:
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))
    else:
        next_value = (3 * value) + 1
        if next_value in a_list:
            print(i + 2)
            break
        else:
            a_list.append(int(next_value))

Measured memory_bytes: 3064