akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int n,u,v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<int> graph[n];
  int a,b;
  for(int i=0;i<n-1;i++){
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int d_from_u[n];
  vector<int> path[n];
  for(int i=0;i<n;i++){
    d_from_u[i] = 1000000;
  }
  d_from_u[u] = 0;
  queue<int> q;
  q.push(u);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int i=0;i<graph[now].size();i++){
      if(d_from_u[graph[now][i]] != 1000000) continue;
      d_from_u[graph[now][i]] = d_from_u[now]+1;
      q.push(graph[now][i]);
    }
  }

  int d_from_v[n];
  for(int i=0;i<n;i++){
    d_from_v[i] = 1000000;
  }
  d_from_v[v] = 0;
  q.push(v);
  while(!q.empty()){
    int now = q.front();
    q.pop();
    for(int i=0;i<graph[now].size();i++){
      if(d_from_v[graph[now][i]] != 1000000) continue;
      d_from_v[graph[now][i]] = d_from_v[now]+1;
      q.push(graph[now][i]);
    }
  }

  int ans = 0;
  for(int i=0;i<n;i++){
    if(d_from_u[i] >= d_from_v[i]) continue;
    ans = max(ans,d_from_v[i]-1);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8960
#include <algorithm>
//#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<int>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
void chmax(T& m, T x) {
	m = std::max(m, x);
}

template <typename T>
void chmin(T& m, T x) {
	m = std::min(m, x);
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

template <typename T>
std::vector<T> lis(std::vector<T>& v) {
	int n = v.size();
	std::vector<T> dp;
	dp.push_back(v[0]);
	for(auto&& e : v) {
		if(e > *dp.rbegin()) {
			dp.push_back(e);
		} else {
			*std::lower_bound(dp.begin(), dp.end(), e) = e;
		}
	}
	return dp;
}

int main() {
	int n;
	scanf("%d", &n);
	VI a(n);
	EACH(e, a) { scanf("%d", &e); }
	printf("%d\n", lis(a).size());
	return 0;
}


Measured memory_bytes: 3836
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()

hors = []
for i in range(n):
    hors.append(na())
vers = []
for j in range(m):
    vers.append(na())

xs = set()
for hor in hors:
    xs.add(hor[0])
    xs.add(hor[1])
for ver in vers:
    xs.add(ver[0])

xs = list(xs)
xs.sort()


ys = set()
for hor in hors:
    ys.add(hor[2])
for ver in vers:
    ys.add(ver[1])
    ys.add(ver[2])

ys = list(ys)
ys.sort()

upper = [-1] * ((len(xs)+1)*(len(ys)+1))
H = len(ys)+1

def root(x):
    if upper[x] < 0:
        return x
    else:
        upper[x] = root(upper[x])
        return upper[x]

def equiv(x, y):
    return root(x) == root(y)

def unite(x, y):
    x, y = root(x), root(y)
    if x != y:
        if upper[y] < upper[x]:
            x, y = y, x
        upper[x] += upper[y]
        upper[y] = x
    return x == y

import bisect
horb = [[0] * (len(xs)+1) for _ in range(len(ys))]
for hor in hors:
    y = bisect.bisect_left(ys, hor[2])
    horb[y][bisect.bisect_left(xs, hor[0])] += 1
    horb[y][bisect.bisect_left(xs, hor[1])] -= 1
for i in range(len(ys)):
    for j in range(1, len(xs)+1):
        horb[i][j] += horb[i][j-1]

verb = [[0] * (len(ys)+1) for _ in range(len(xs))]
for ver in vers:
    x = bisect.bisect_left(xs, ver[0])
    verb[x][bisect.bisect_left(ys, ver[1])] += 1
    verb[x][bisect.bisect_left(ys, ver[2])] -= 1
for i in range(len(xs)):
    for j in range(1, len(ys)+1):
        verb[i][j] += verb[i][j-1]

for i in range(len(xs)+1):
    for j in range(len(ys)+1):
        if i < len(xs) and j in (0, len(ys)):
            # print(i, j, i+1, j)
            unite(i*H+j, (i+1)*H+j)
        elif i < len(xs) and verb[i][j-1] == 0:
            # print(i, j, i+1, j)
            unite(i*H+j, (i+1)*H+j)
        if j < len(ys) and i in (0, len(xs)):
            # print(i, j, i, j+1)
            unite(i*H+j, i*H+j+1)
        elif j < len(ys) and horb[j][i-1] == 0:
            # print(i, j, i, j+1)
            unite(i*H+j, i*H+j+1)

ox = bisect.bisect_left(xs, 0)
oy = bisect.bisect_left(ys, 0)

if equiv(ox*H+oy, 0):
    print("INF")
else:
    S = 0
    for i in range(len(xs) + 1):
        for j in range(len(ys) + 1):
            if equiv(i*H+j, ox*H+oy):
                S += (xs[i] - xs[i-1]) * (ys[j] - ys[j-1])
    print(S)


Measured memory_bytes: 488020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int d = sc.nextInt();
        String ans = "a";
        if (d == 24) {
            ans = "Christmas Eve";
        } else if (d == 22) {
            ans = "Christmas Eve Eve Eve";
        } else if (d == 25) {
            ans = "Christmas";
        } else {
            ans = "Christmas Eve Eve";
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, S);
    IN(ll, W);
    YES(W >= S, "unsafe", "safe");
}

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

int main()
{
  int x, a, b;
  cin >> x >> a >> b;
  a = abs(x - a), b = abs(x - b);
  if(a < b)
  {
    cout << 'A' << endl;
  }
  else
  {
    cout << 'B' << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    char c;
    cin >> c;

    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') { cout << "vowel" << endl; }
    else { cout << "consonant" << endl; }
}

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


ll limit,bin[400005]={0};

void update(ll x,ll y)
{
    while (x<=limit)
    {
       bin[x]+= y;
       x+=x&(-x);
    }
}

int answer(ll x)
{
    ll sum=0;
    while (x>0)
    {
        sum += bin[x];
        x-=x&(-x);
    }
    return sum;
}

int main ()
{
   ll i,j,n,ans=0,l,r,num=1,real[400005]={0},check=0,sum=0;
   vector<ll>v[30];
   vector<pair<ll,ll> >pos;
   string s;

   cin>>s;
   n=s.size();
   limit=n+1;
   for(i=0;i<n;i++)
   {
       v[s[i]-'a'].push_back(i);
   }
   for(i=0;i<26;i++)
   {
       if(v[i].size()%2==1)
       {
           check++;
       }
       if(v[i].size()!=0)
       {
            l=0;
            r=v[i].size()-1;
            while(l<=r)
            {
                pos.push_back(make_pair(v[i][l],v[i][r]));
                l++;
                r--;
            }
        }
   }
   if(check>1)
   {
       cout<<-1;
       return 0;
   }
   sort(pos.begin(),pos.end());
   for(i=0;i<pos.size();i++)
   {
       if(pos[i].first==pos[i].second)
       {
           real[pos[i].first]=(n/2)+1;
       }
       else
       {
           real[pos[i].first]=num;
           real[pos[i].second]=n+1-num;
           num++;
       }
   }
   for(i=0;i<n;i++)
   {
       sum+=i-answer(real[i]);
       update(real[i],1);
   }
   cout<<sum;
   return 0;
}


Measured memory_bytes: 10356
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int W,H;
    cin >> W >> H;
    ll sum_W = 0;
    vector<int> p(W);
    for(int i=0; i<W; i++){
        cin >> p[i];
        sum_W += p[i];
    }
    vector<int> q(H);
    ll sum_H = 0;
    for(int i=0; i<H; i++){
        cin >> q[i];
        sum_H += q[i];
    }
    sort(p.begin(),p.end());
    vector<ll> S(W+1,0);
    for(int i=0; i<W; i++){
        S[i+1] = S[i] + p[i];
    }
    ll ans = sum_W + sum_H;
    for(int i=0; i<H; i++){
        int pos = lower_bound(p.begin(),p.end(),q[i]) - p.begin();
        ans += S[pos];
        ans += (ll)q[i]*(W-pos);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;


class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
    boolean flag = true;
        while(n > 0){
            int item = in.nextInt();

            if(item%2 == 0 ){       //even
                if(item%3 == 0 || item%5 ==0 ){
                    flag = true;
                }else{
                    flag = false;
                    break;
                }
            }

            n--;

        }
        if(flag)
            out.println("APPROVED");
        else out.println("DENIED");
        //int n = in.nextInt();

        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <numeric>
#include <iomanip>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 rrep(i, n) for (int i=(int)(n)-1;i>=0;--i)
#define rrep1(i, n) for (int i=(int)(n);i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=(int)(r)-1;i>=l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using vpii=vector<pii>;
using ll=long long;

constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

int f(string s)
{
	int ans = 0;
	ans+= (s[0]-'0')*100;
	ans += (s[2]-'0')*10;
	ans += (s[3]-'0')*1;
	return ans;
}

signed main()
{
	int a;
	string bs;
	cin >> a >> bs;
	int ans = a*f(bs)/100;
	printf("%lld\n",ans);
}




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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll Q;
    cin >> Q;
    REP(i, Q){
    	ll k;
    	cin >> k;
    	ll a = 0, b = 0, c = 0, res = 0;
    	REP(j, N){
    		if(j > k-1){
    			if(S[j-k] == 'D'){
    				a--;
    				c -= b;
    			}
    			if(S[j-k] == 'M'){
    				b--;
    			}
    		}
    		if(S[j] == 'D'){
    			a++;
    		}
    		if(S[j] == 'M'){
    			b++;
    			c += a;
    		}
    		if(S[j] == 'C'){
    			res += c;
    		}
    	}
    	cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1948
// ABC155C - Poll

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

int main() {
	int N;
	cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}

	sort(S.begin(), S.end());
	S.push_back(""); // 門番追加

	int maximum= 0, temp_max = 1;
	for (int i = 0; i < N; i++) {
		if (S.at(i) == S.at(i + 1)) {
			temp_max++;
		} else {
			maximum = max(maximum, temp_max);
			temp_max = 1;
		}
	}
//	cout << maximum << endl;

	temp_max = 1;
	for (int i = 0; i < N; i++) {
		if (S.at(i) == S.at(i + 1)) {
			temp_max++;
		} else {
			if (maximum == temp_max) {
				cout << S.at(i) << endl;
			}
			temp_max = 1;
		}
	}

	return 0;
}


Measured memory_bytes: 15616
loop do
  n = gets.to_i
  break if n==0
  ts = Array.new
  n.times{
    ts << gets.to_i
  }
  if n==1
    puts 0
    next
  end
  ts.sort!
  wt = (0..n-2).inject([0]){|seq,i| seq<<(seq[i]+ts[i])}
  total = wt.inject{|x,y| x+y}
  puts total
end

Measured memory_bytes: 3072
N = int(input())
v = list(map(int, input().split()))

cnt_o = {'*' : 0}
for vi in v[0::2]:
    key = str(vi)
    cnt_o.setdefault(key, 0)
    cnt_o[key] += 1
cnt_o = sorted(cnt_o.items(), key=lambda x: -x[1])

cnt_e = {'*' : 0}
for vi in v[1::2]:
    key = str(vi)
    cnt_e.setdefault(key, 0)
    cnt_e[key] += 1
cnt_e = sorted(cnt_e.items(), key=lambda x: -x[1])

key0, val0 = cnt_o[0]
key1, val1 = cnt_o[1]

ans = N
for key, val in cnt_e:
    if key != key0:
        ans_tmp = N - val0 - val
    else:
        ans_tmp = N - val1 - val
    #
    ans = min(ans, ans_tmp)

print(ans)

Measured memory_bytes: 25820
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9;

int main() {
	int N;
	cin>>N;
	int a[110];
	int sum=0;
	REP(i,0,N) {
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+N);
	int tmp=sum;
	if(sum%10==0){
		REP(i,0,N) {
			if(a[i]%10!=0) {
				sum-=a[i];
				break;
			}
		}
		if(tmp==sum) sum=0;
	}
	p(sum);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
bool prime(int x){
    if(x==2)
        return true;
    else if(x%2==0)
        return false;

    double r = sqrt(x);
    for (int i = 3; i <= r; i += 2)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int x;
    cin >> x;
    while(!prime(x)){
        x++;
    }
    cout << x << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define LL_MAX LLONG_MAX
#define ULL_MAX ULLONG_MAX
#define ull unsigned long long
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define sort(a) sort(a.begin(),a.end())
#define pii pair<int,int>
#define sz(x) int(x.size())
#define mk make_pair
#define endl '\n'

int main()
{
    IOS;
    ll n;
    cin>>n;

    ll p=1;

    ll sum=0;
    while(1)
    {
        sum+=pow(26,p);
        if(sum>=n)
        {
            break;
        }
        p++;
    }

    n-=(sum-pow(26,p));

    string s;
    for (int i = 1; i < p; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            ll var=pow(26,p-i)*j;
            if(var>=n)
            {
                n-=pow(26,p-i)*(j-1);
                s+=(char)'a'+(j-1);
                break;
            }
        }
        
    }

    s+='a'+n-1;
    cout<<s;
}

Measured memory_bytes: 4044
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        if(r<=0 || 10000<=r){
            System.exit(-1);
        }
        System.out.println(String.format("%f",r*r*Math.PI) + " " + 2*r*Math.PI);
    }
}

Measured memory_bytes: 28164
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>

using namespace std;

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

static const double eps = 10e-9;

void rotate90(char input[8][8], char output[8][8])
{
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			double dx = x*cos(M_PI/2.0) - y*sin(M_PI/2.0) + 7;
			double dy = x*sin(M_PI/2.0) + y*cos(M_PI/2.0);

			output[(int)(dy+eps)][(int)(dx+eps)]=input[y][x];
		}
	}
}

void rotate180(char input[8][8], char output[8][8])
{
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			double dx = x*cos(M_PI) - y*sin(M_PI) + 7;
			double dy = x*sin(M_PI) + y*cos(M_PI) + 7;
			output[(int)(dy+eps)][(int)(dx+eps)]=input[y][x];
		}
	}
}

void rotate270(char input[8][8], char output[8][8])
{
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			double dx = x*cos(3.0*M_PI/2.0) - y*sin(3.0*M_PI/2.0);
			double dy = x*sin(3.0*M_PI/2.0) + y*cos(3.0*M_PI/2.0) + 7;

			output[(int)(dy+eps)][(int)(dx+eps)]=input[y][x];
		}
	}
}

void printStage(char stage[8][8])
{
	for(int y=0;y<8;y++){
		for(int x=0;x<8;x++){
			printf("%c%s",stage[y][x],x==7 ? "\n" : "");
		}
	}
}




int main(){

	double eps = 10e-9;
	char stage[8][8];
	for(int y=0;y<8;y++){
		string str;
		getline(cin,str);
		for(int x=0;x<8;x++){
			stage[y][x] = str[x];
		}
	}

	char res[8][8];
	rotate90(stage,res);
	cout << 90 << endl;
	printStage(res);

	rotate180(stage,res);
	cout << 180 << endl;
	printStage(res);

	rotate270(stage,res);
	cout << 270 << endl;
	printStage(res);
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args ) {
        Scanner scanner = new Scanner(System.in);
        String W = scanner.next();
        String T = scanner.next();
        int count = 0;
        while (!T.equals("END_OF_TEXT")){
            if(T.equalsIgnoreCase(W))
                count++;
            T = scanner.next();
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26168
#include<iostream>
#include<string>

int main(){
    std::string S;
    std::cin >> S;
    for(int i = 0; i < S.size() - 1; i++){
        if(S[i] == S[i + 1]){
            std::cout << "Bad" << std::endl;
            return 0;
        }
    }
    std::cout << "Good" << std::endl;
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	if (s.back() == 's') s += "es";
	else s += "s";
	cout << s << endl;

}



Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(20) << std::fixed;

  // cnt[x] = xの約数の数
  vector<long long> cnt(10000007 + 10, 0);
  for (int i = 1; i <= 100000007; i++) {
    for (int j = i; j <= 10000007; j += i) {
      cnt[j]++;
    }
  }

  long long N; cin >> N;
  long long ans = 0;
  for (long long K = 1; K <= N; K++) {
    ans += K * cnt[K];
  }
  cout << ans << "\n";

  return 0;
}


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

int main(){
  int n;
  cin >> n;

  map<string,int> mp;
  string w;
  cin >> w;
  char prev = w[w.size()-1];
  mp[w]++;
  for (int i = 1; i < n; i++)
  {
    cin >> w;
    if(w[0]!=prev || mp[w]!=0){
      cout << "No" << endl;
      return 0;
    }
    mp[w]++;
    prev = w[w.size()-1];
  }
  cout << "Yes" << endl;  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int change = sc.nextInt();
        char[] s = sc.next().toCharArray();

        s[change-1] = Character.toLowerCase(s[change-1]);
        System.out.println(new String(s));
    }
}




Measured memory_bytes: 35680
#include <stdio.h>

typedef long long ll;

int main(){
	
	int N,K;

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

	int i;

	ll ans=0ll;

	for(i=1;i<=N;i++){
		if((2*i)%K==0){
		int A=-i%K;
		A+=K;
		ll add=(ll)(((N-A)/K)+1);
		ans+=add*add;
		}
	}

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

return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int64_t N,A,B;
 cin>>N>>A>>B;
 if(B<A){cout<<0<<endl;}
 else if(N==1&&A!=B){cout<<0<<endl;}
 else if(A==B){cout<<1<<endl;}
 else {cout<<(N-2)*(B-A)+1<<endl;}
 return 0;
}

Measured memory_bytes: 3636
m, n = gets.split().map(&:to_i)
mod = 10**9 + 7

def modPow(m, n, p)
  return m % p if n == 1
  if n % 2 == 0
    tmp = modPow(m, n/2, p)
    return (tmp * tmp) % p
  else
    return (m * modPow(m, n-1, p)) % p
  end
end

puts modPow(m, n, mod)


Measured memory_bytes: 6872
import java.util.Scanner;
class Main {
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();
        if (A1+A2+A3 <= 21) {
        		System.out.println("win");
        } else {
        	System.out.println("bust");
        }
    }
} 

Measured memory_bytes: 21716
integer N
integer,allocatable,dimension(:)::P
integer mae,ushiro
integer ans
read*,N
allocate(P(N))
read*,P
mae=0
ushiro=sum(P)
ans=huge(ans)
do i=1,N
  mae=mae+p(i)
  ushiro=ushiro-p(i)
  ans=min(ans,abs(mae-ushiro))
end do
print"(I0)",ans
end

Measured memory_bytes: 768
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b; cin >> a >> b;
    
    string ans = "";
    if ((a*b) % 2 == 0) ans = "Even";
    else ans = "Odd";

    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 sz(x) int(x.size())
using namespace std;

int N;
vector<int> p;

int main() {
    cin >> N;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    auto iter = max_element(p.begin(), p.end());
    int idx = distance(p.begin(), iter); 

    p[idx] /= 2;

    cout << accumulate(p.begin(), p.end(), 0) << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string vowel = "aiueo";
    char c;
    cin >> c;
    if(vowel.find(c) == string::npos) cout << "consonant";
    else cout << "vowel";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
import java.math.BigDecimal;
import java.util.Scanner;

class Main{
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
        int   a = sc.nextInt();
        int   b = sc.nextInt();
        long  d = a/b;
        int   r = a%b;
        double f = (double)a/b;
        sc.close();

        System.out.println(new StringBuilder()
            .append(d).append(" ")
            .append(r).append(" ")
            .append(BigDecimal.valueOf(f).toPlainString()));
    }
}

Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int a[3], b[3];
    for(int i=0;i<3;i++)
        cin >> a[i] >> b[i];
    
    int count;    
    for(int i=1;i<=4;i++){
        count = 0;
        for(int j=0;j<3;j++){
            if(a[j] == i)
                count++;
            if(b[j] == i)
                count++;
            if(count > 2){
                cout << "NO" << endl;
                return 0;
            }
        }
    }
    
    cout << "YES" << endl;
    return 0;
}

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

int main(){
    int N;
    int abc[3][110000];
    int i,j,k;
    int prevabc;
    int dpa[3], dpb[3], dpmax;

    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%d %d %d", &abc[0][i], &abc[1][i], &abc[2][i]);
    }

    prevabc = 0;
    for(i=0; i<3; i++){
        dpa[i]=0;
        dpb[i]=0;
    }

    for(i=0; i<N; i++){
        for(j=0; j<3; j++){
            dpmax = 0;
            for(k=0; k<3; k++){
                if(j==k){
                    continue;
                }
                if(dpmax<dpa[k]+abc[j][i]){
                    dpmax = dpa[k]+abc[j][i];
                }
            }
            dpb[j] = dpmax;
        }
        for(j=0; j<3; j++){
            dpa[j] = dpb[j];
        }
    }

    if(dpa[1]<=dpa[0] && dpa[2]<=dpa[0]){
        printf("%d", dpa[0]);
    }else if(dpa[0]<=dpa[1] && dpa[2]<=dpa[1]){
        printf("%d", dpa[1]);
    }else{
        printf("%d", dpa[2]);
    }

    return 0;
}

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

int main()
{
	long long int N, i, ans, a[100001], b[100001]; 
	cin>> N;
	ans=0;
	for(i=1;i<=N;i++)
	{
		b[i]=0;
	}
	for(i=1;i<=N;i++)
	{
		cin >> a[i];
		if(a[i]>N) ans++;
		else b[a[i]]++;
		
	}
	for(i=1;i<=N;i++)
	{
		if(b[i]<i) ans+=b[i];
		else ans+=b[i]-i;	
	}
	cout<< ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl
 
int main(){
  int N; string S;
  cin >> N >> S;
  int res;
  REP(i, N){
    if(i == 0) res+=1;
    else{
      if(S[i-1] != S[i]) res+=1;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define me(a,x) memset(a,x,sizeof(a))
#define sc scanf
#define itn int
using namespace std;
const int N=1e6;
const long long mod=1e9+7;
const int oo=0x7fffffff;
const int sup=0x80000000;
typedef long long ll;
typedef unsigned long long ull;
template <typename it>void db(it *begin,it *end){while(begin!=end)cout<<(*begin++)<<" ";puts("");}
template <typename it>
string to_str(it n){string s="";while(n)s+=n%10+'0',n/=10;reverse(s.begin(),s.end());return s;}
template <typename it>int o(it a){cout<<a<<endl;return 0;}
ll mul(ll a,ll b,ll c){ll ans=0;for(;b;b>>=1,a=(a+a)%c)if(b&1)ans=(ans+a)%c;return ans;}
ll ksm(ll a,ll b,ll c){ll ans=1;for(;b;b>>=1,a=mul(a,a,c))if(b&1)ans=mul(ans,a,c);return ans;}
int n,d[N];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>d[i];
	sort(d+1,d+n+1);
	o(d[n/2+1]-d[n/2]);
}


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

using namespace std;

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

const int N = 1e5 + 5;

int n,k,a[N];
ll ans,pre[N],pre2[N];

ll get(int l,int r) {
  if (l > r)
    return 0;
  return pre2[r] - pre2[l - 1];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  cin >> n >> k;
  for (int i = 1 ; i <= n ; i++) {
    cin >> a[i];
    pre[i] = pre[i - 1] + a[i];
    pre2[i] = pre2[i - 1] + max(a[i],0);
  }

  for (int i = 1 ; i <= n - k + 1 ; i++) 
    ans = max(ans,max(0ll,pre[i + k - 1] - pre[i - 1]) + get(1,i - 1) + get(i + k,n));

  cout << ans << endl;

}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

int main() {

    // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    long long N; cin >> N;

    int v = sqrt(N);

    for (int i = v; i > 0; --i) {
        if (N % i == 0) {
            int res = to_string(i).length();
            chmax(res, (int)to_string(N/ i).length());
            cout << res << endl;
            break;
        }
    }

	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int x,a,b;
    while(scanf("%d%d%d",&x,&a,&b)==3)
    {
        x=x-a;
        while(x>=b)
        {
            x-=b;
        }
        printf("%d\n",x);
    }
    return 0;
}


Measured memory_bytes: 256
// AOJ 2331
import java.util.Scanner;
 
public class Main{
	
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] m = new int[100001];
        for(int i = 0; i < n; i++) {
        	int a = sc.nextInt();
        	int b = sc.nextInt();
        	for(int j = a; j <= b; j++) {
        		m[j - 1]++;
        	}
        }
        int max = 0;
        for(int i = 0; i <= n; i++) {
        	//System.out.println(m[i]);
        	if(i <= m[i]) {
        		max = Math.max(i, max);
        	}
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 69332
#include <stdio.h>
int main(void){
	int n;
	int i;
	int k,p;
	int a;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&k,&p);
		a=k%p;
		if(a==0){
			printf("%d\n",p);
		}else{
		printf("%d\n",a);
		}
	}
	return 0;
}

Measured memory_bytes: 1028
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    A = [list(map(int, input().split())) for _ in [0] * 3]
    N = int(input())
    B = [int(input()) for _ in [0] * N]

    for i, (a1, a2, a3) in enumerate(A):
        if a1 in B:
            A[i][0] = 0
        if a2 in B:
            A[i][1] = 0
        if a3 in B:
            A[i][2] = 0
    for a in A:
        if not sum(a):
            print('Yes')
            return
    for i in range(3):
        a = [A[0][i], A[1][i], A[2][i]]
        if not sum(a):
            print('Yes')
            return
    if any((A[0][0] == A[1][1] == A[2][2] == 0,
            A[0][2] == A[1][1] == A[2][0] == 0)):
            print('Yes')
            return
    print('No')


main()


Measured memory_bytes: 3064
module M = Map.Make(struct type t = int let compare = (-) end)
let () =
  Scanf.scanf "%d" @@ fun n ->
  let g = Array.init n (fun _ -> []) in
  for i = 1 to n-1 do
    Scanf.scanf " %d %d" @@ fun a b ->
    let a, b = a-1, b-1 in
    g.(a) <- b :: g.(a);
    g.(b) <- a :: g.(b);
  done;
  let c = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  Array.sort (fun x y -> y-x) c;

  let rec dfs x p (i, m) =
    let m = M.add x c.(i) m in
    List.fold_left (fun pr y ->
      if y = p || M.mem y m then pr
      else dfs y x pr
    ) (i+1, m) g.(x)
  in
  let _, m = dfs 0 (-1) (0, M.empty) in

  Printf.printf "%d\n" (Array.fold_left (+) (-c.(0)) c);
  m |> M.iter (fun k v -> Printf.printf "%d " v);
  print_newline ()
  


Measured memory_bytes: 10112
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#define ll long long
using namespace std;

int main(){
	int t;
	cin>>t;
	if(t>=64){
		cout<<64<<endl;
	}else if(t>=32&&t<64){
		cout<<32<<endl;
	}else if(t>=16&&t<32){
		cout<<16<<endl;
	}else if(t>=8&&t<16){
		cout<<8<<endl;
	}else if(t>=4&&t<8){
		cout<<4<<endl;
	}else if(t>=2&&t<4){
		cout<<2<<endl;
	}else{
		cout<<1<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = long long;
using namespace std;
#define PUTS(x) cout << (x) << endl;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
int main() {
    Int n;
    cin >> n;
    Int s=0;
    Int t=0;
    rep(i, n) {
        Int x;
        cin >> x;
        s += x;
        t += x * x;
    }
    auto f = [&](Int p) {
        return n * p * p - 2 * s * p + t;
    };
    PUTS(min(f(s/n),f(s/n+1)))
}


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

int main()
{
    int k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    ll now = 7;
    rep2(i, 1, 1e6) {
        if (now % k == 0) {
            cout << i << endl;
            return 0;
        }
        now = 10 * now + 7;
        now %= k;
    }
    // cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, m;
int dp[100005];
vector<int> adj[100005];

int solve(int node)
{
    int &ret = dp[node];
    if(~ret)
        return ret;
    ret = 0;
    for(auto &e : adj[node])
        ret = max(ret, 1 + solve(e));
    return ret;
}

int main()
{
    IO;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    int ans = 0;
    memset(dp, -1, sizeof dp);
    for(int i = 1; i <= n; i++)
        ans = max(ans, solve(i));
    cout << ans;
    return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define tcase int _; cin >> _; while(_--)
const int MAX = 1e6;

long long n;

void solve() {
	cin >> n;
	vector<char> ans;
	while(n) {
		n--;
		ans.push_back( (char)('a' + n%26) );
		n /= 26;	
	}
	for(int i=ans.size()-1; i>=0; i--) cout << ans[i];
	cout << "\n";
}

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

 	solve();

  	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int a=1;
    for(int i=1;i<=N;i++){
        if(a<K){
            a=a*2;
        }else if(a>=K){
            a=a+K;
        }
    }
    cout<<a<<endl;
    return 0;
    
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

N = int(input())
aa = [0]
for i in range(N):
	aa.append(int(input()))

now = 1
count = 0
while True:
	if now == 2:
		print(count)
		break
	elif now == -1:
		print(-1)
		break
	bef = now
	now = aa[now]
	aa[bef] = -1
	count += 1

Measured memory_bytes: 7692
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int a,b, coin = 0;
		Scanner scanner = new Scanner(System.in);
		a = scanner.nextInt();
		b = scanner.nextInt();
		
		
		for (int i = 1; i <= 2; i++) {
			if (a < b) {
				coin += b;
				b--;
			} else {
				coin += a;
				a--;
			}
		}
		
		System.out.println(coin);

	}

}


Measured memory_bytes: 21716
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 1e5 + 10;
int n , ans , mn = 2 , a[MAXN];
int32_t main()
{
        cin >> n;
        for(int i = 0 ; i < n ; i ++)
                cin >> a[i];
        ans = a[0] - 1;
        for(int i = 1 ; i < n ; i ++)
                if(a[i] == mn)
                        mn ++;
                else if(a[i] > mn)
                        ans += (a[i] - 1) / mn;
        return cout << ans << endl , 0;
}                                                                                                                                                                                                          


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const int MOD=1e9+7;
const int MAX=1e5+100;

int main() {
  int N;cin>>N;
  deque<ll> q{-1, 2};

  REP(i,N) {
    ll nex = accumulate(ALL(q),0LL);
    q.pop_front();
    q.push_back(nex);
  }
  OUT(q[1]);

  return 0;
}

Measured memory_bytes: 256