akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#define MAX 101
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, t, top, u[MAX], color[MAX], M[MAX][MAX], S[MAX], d[MAX], f[MAX];

int next(int u){
  for(int i=1; i<=n; i++){
    if(M[u][i] == 1 && color[i] == WHITE){
      return i;
    }
  }
  return NIL;
}

void dfs(int u){
  int v;
  S[++top] = u;
  color[u] = GRAY;
  d[u] = ++t;

  while(top > 0){
    u = S[top];
    v = next(u);
    if(v != NIL){
      color[v] = GRAY;
      d[v] = ++t;
      S[++top] = v;
    }else{
      top--;
      color[u] = BLACK;
      f[u] = ++t;
    }
  }
}

void dfs_init(){
  for(int i=0; i<MAX; i++){
    color[u[i]] = WHITE;
  }

  t = 0;
  top = 0;
}

int main(void){
  int k, m;
  cin >> n;

  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      M[i][j] = 0;
    }
  }

  for(int i=0; i<n; i++){
    cin >> u[i] >> k;
    for(int j=0; j<k; j++){
      cin >> m;
      M[u[i]][m] = 1;
    }
  }

  dfs_init();
  for(int i=0; i<n; i++){
    if(d[u[i]] == 0) dfs(u[i]);
  }

  for(int i=0; i<n; i++){
    cout << u[i] << " " << d[u[i]] << " " << f[u[i]] << endl; 
  }
  return 0;
}



Measured memory_bytes: 3076
n=int(input())
from collections import Counter
c=Counter([])
k=int(pow(n//3,0.5))
for i in range (1,k+1):
    c[12*i*i]+=1
z=int(pow(2*n,0.5))+1
for i in range(2,z):
    for j in range(i+1,z):
        if (i+i+j)%2==0 and ((i+i+j)//2)>j:
            c[i**2+i**2+j**2]+=3
        if (i+j+j)%2==0 and ((i+j+j)//2)>j:
            c[i**2+j**2+j**2]+=3
for i in range(2,z):
    for j in range(i+1,z):
        for k in range(j+1,z):
            a=(i+j+k)
            if a%2==0 and a//2 > k:
                c[i**2+j**2+k**2]+=6
                
for i in range(1,n+1):
    print (c[2*i])

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

int main() {
    ll n, m;
    string s, t;
    cin >> n >> m;
    cin >> s >> t;
    if (s[0] != t[0]) {
        cout << -1;
        return 0;
    } else {
        ll lcm = n * m / __gcd(n, m);
        map<ll, char> ma;
        for (int i = 0; i < s.size(); i++) {
            ma[i * lcm / n] = s[i];
        }
        for (int i = 0; i < t.size(); i++) {
            if (ma.find(i * lcm / m) != ma.end() && ma[i * lcm / m] != t[i]) {
                cout << -1;
                return 0;
            }
        }
        cout << lcm;
    }
    return 0;
}


Measured memory_bytes: 6144
import itertools

N = int(input())
P = tuple(map(int, input().split())) # リスト入力
Q = tuple(map(int, input().split())) # リスト入力

# 1~Nを辞書順にiterateし，Pに一致するまでの数を数える
orig = [i for i in range(1,N+1)]
a = 0
for x in itertools.permutations(orig):
    a += 1
    if x == P: break

# 1~Nを辞書順にiterateし，Qに一致するまでの数を数える
orig = [i for i in range(1,N+1)]
b = 0
for x in itertools.permutations(orig):
    b += 1
    if x == Q: break
    
print(abs(a-b))

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, x;
	cin >> n >> x;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	//I think this is just a greedy
	ll ans = 0LL;
	for(ll i = 0; i < (n - 1); i++){
		if((a[i] + a[i + 1]) > x){
			if(a[i] > x){
				ans += a[i + 1];
				a[i + 1] = 0;
				ans += a[i] - x;
			}
			else{
				ans += (a[i] + a[i + 1]) - x;
				a[i + 1] -= (a[i] + a[i + 1]) - x;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <tuple>
#include <set>
using namespace std;

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

#define max_n 100

int K, X;

int main() {
	
	cin >> K >> X;

	int i = -1000000 + K < X ? X - K + 1:-1000000;
	int e = 1000000 - K > X ? X + K - 1 : 1000000;

	for(;i<=e;i++)
	{
		cout << i << " ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long DP[100100];
vector<int> G[100100];
const long long Mod=1000000007;
long long DFS(int X,int L)
{
  if(DP[X])
    return DP[X];
  long long ret1=1,ret2=1;
  for(int i=0;i<G[X].size();i++)
  	if(G[X][i]!=L)
      ret1=ret1*DFS(G[X][i],X)%Mod;
  for(int i=0;i<G[X].size();i++)
  	if(G[X][i]!=L)
    {
      int x=G[X][i];
      for(int i=0;i<G[x].size();i++)
        if(G[x][i]!=X)
          ret2=ret2*DFS(G[x][i],x)%Mod;
    }
  return DP[X]=(ret1+ret2)%Mod;
}
int main()
{
  int N;
  cin>>N;
  for(int i=1;i<N;i++)
  {
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  cout<<DFS(0,-1)<<endl;
  return 0;
}

Measured memory_bytes: 16256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0])
    {
        cout << "YES\n";
    }
    else
    {
        cout << "NO\n";
    }
    return 0;
}


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

int main() {
    int n, w; cin >> n >> w;
    vector<vector<int64_t> > dp(n+1, vector<int64_t> (w+1, 0));
    vector<pair<int, int> > items(n);
    for (int i = 0; i < n; i++) {
        int wi, vi; cin >> wi >> vi;
        items.at(i).first = wi;
        items.at(i).second = vi;
    }
    for (int i = 1; i < n+1; i++) {
        for (int j = 1; j < w+1; j++) {
            if (j >= items.at(i-1).first) {
                dp.at(i).at(j) = max(dp.at(i-1).at(j-items.at(i-1).first) + items.at(i-1).second, dp.at(i-1).at(j));
            } else {
                dp.at(i).at(j) = dp.at(i-1).at(j);
            }
        }
    }
    cout << dp.at(n).at(w) << endl;
}

Measured memory_bytes: 80256
import java.util.*;
public class Main {
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  long l = sc.nextLong();
	  long r = sc.nextLong();
      
      if(r > l+4038)
        r = l+4038;
      
      long min = 2018;
      long num;
      int cnt = 0;
      for(long i = l; i < r; i++) {
        for(long j = l+1; j <= r; j++) {
          num = ((i*j)%2019);
          if(num < min) {
            min = num;
            if(num == 0) {
              break;
            }
          }
        }
      }
      System.out.println(min);
	}
}

Measured memory_bytes: 23636
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;
int zero[1123456];
int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> cnt(n+1);
  for(int x:a) ++cnt[x];
  reps(i,1,n+1){
    ++zero[n-i];
    --zero[n-i+cnt[i]];
  }
  rep(i,n) zero[i+1]+=zero[i];
  int re=0;
  rep(i,n)if(!zero[i]) ++re;
  rep(_,m){
    int ind,x;
    cin>>ind>>x; --ind;
    --cnt[a[ind]];
    {
      int tmp=(n-a[ind])+cnt[a[ind]];
      --zero[tmp];
      if(tmp<n && zero[tmp]==0) ++re;
    }
    a[ind]=x;
    {
      int tmp=(n-a[ind])+cnt[a[ind]];
      if(tmp<n && zero[tmp]==0) --re;
      ++zero[tmp];
    }
    ++cnt[a[ind]];
    cout<<re<<endl;
  }
  return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cwchar>
#include <cwctype>
#include <exception>
#include <locale>
#include <numeric>
#include <new>
#include <stdexcept>
#include <limits>
#include <valarray>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <list>
#include <utility>
#include <bitset>
#include <algorithm>
#include <functional>
using namespace std;
int n;
char wcz[1005];
char czy[1005];
long long wyn;
void check()
{
	czy[n]=1;
	long long aktu=0;
	for(int i=1;i<=n;i++)
	{
		aktu*=10;
		aktu+=wcz[i]-'0';
		if(czy[i])
		{
			wyn+=aktu;
			aktu=0;
		}
	}
}
void rec(int v)
{
	if(v==n)
	{
		check();
		return;
	}
	czy[v]=0;
	rec(v+1);
	czy[v]=1;
	rec(v+1);
}
int main()
{
	cin>>wcz+1;
	while(wcz[n+1])
	{
		n++;
	}
	rec(1);
	cout<<wyn;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int a, b, c;
    vector<int> v;
    cin >> a >> b >> c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v.size() << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int N;
vector<int> p(20);
int main() {
    cin >> N;
    int max = 0;
    int total = 0;
    for(int i = 0; i < N; ++i) {
        cin >> p.at(i);
        if(max < p.at(i)) {
            max = p.at(i);
        }
        total += p.at(i);
    }

    cout << total - max / 2 << endl;
}

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

int main(void){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if((x >= r) && (x <= W-r) && (y >= r) && (y <= H-r)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


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

typedef long long ll;
ll n, ans;
typedef pair<ll, ll> P;
vector<P> v;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; ++i){
		ll a, b;
		cin >> a >> b;
		v.push_back(P(a+b, a));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	for(int i=0; i<n; ++i){
		if(i % 2 == 0) ans += v[i].second;
		else ans -= v[i].first - v[i].second;
	}
	cout << ans << "\n";
}

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

int N;
int A[200005], cnt[200005];
long long ans;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  for(int i = 1; i <= N; i++) {
    cin >> A[i];
    ans += cnt[A[i]];
    cnt[A[i]]++;
  }
  for(int i = 1; i <= N; i++) {
    cout << ans - cnt[A[i]] + 1 << "\n"; 
  }
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/


int main(){
  ll N;
  cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  
  vector<ll> sum(N);
  sum[0] = a[0];
  rep(i,N){
	sum[i+1] = sum[i] + a[i+1];
    //cout << sum[i] << endl;
  }
  
  ll ans = MAXX;
  
  rep(i,N-1){
    ll tmp = abs(sum[N-1]-2 * sum[i]);
    //cout << sum[i] << endl;
    ans = min(ans,tmp);
  }

  
  cout << ans << endl;
    
  
  
}
  
  

Measured memory_bytes: 3328
object Main extends App {
    val n = io.StdIn.readLine.toInt
    val d = io.StdIn.readLine.split(' ').map(_.toInt)

    val ans = for(i <- 0 until n - 1; j <- i + 1 until n) yield {
        if(i != j) d(i) * d(j) else 0
    }

    println(ans.sum)
}

Measured memory_bytes: 25412
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


def lcm(a: int, b: int) -> int:
    """a, bの最小公倍数(least common multiple: LCM)を求める
    計算量: O(log(min(a, b)))
    """
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める"""
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i])
    return ans


n, k = map(int, input().split())
a = list(map(int, input().split()))

gcd_ = multi_gcd(a)
if k % gcd_ == 0 and k <= max(a):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 62704
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {

		int N = nextInt();
		int[][] x = new int[N][];
		for(int i=0;i<N;i++){
			x[i]=nextInts();
		}
		int[][] dp = new int[N+1][3];
		for(int i=0;i<N;i++){
			Arrays.fill(dp[i], 0);
		}

		for(int i=0;i<N;i++){
			for(int k=0;k<dp[i].length;k++){
				for(int z=0;z<dp[i].length;z++){
					if(k!=z){
						dp[i+1][k]=Math.max(dp[i+1][k],dp[i][z]+x[i][k]);
					}
				}
			}
		}
		int ans =0;
		for(int i=0;i<dp[N].length;i++){
			ans=Math.max(ans, dp[N][i]);
		}
		System.out.println(ans);

	}

	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}

Measured memory_bytes: 48456
#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <string>
#include <climits>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (n); ++i)
#define InitRep(i, begin, n) for (int i = (begin); i < (n); ++i)
#define RepItr(it, begin, end) for (auto it = (begin); it != (end); ++it)
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
const static double PI = ::acos(-1);

constexpr int64 MOD = 1000000007;


struct Vertex
{
    int level, parent, deepestLevel;
    vint edges;
};

int DFS(vector<Vertex>& graph, int current, int parent, int level)
{
    graph[current].level = level;
    graph[current].parent = parent;
    if (graph[current].edges.size() == 1 && graph[current].edges[0] == parent)
    {
        graph[current].deepestLevel = level;
        //
        //cout << "sink " << current << endl;
        //
        return level;
    }

    int deepest = -1;
    for (const int to : graph[current].edges)
    {
        if (graph[to].level == 0)
        {
            int currentDeepest = DFS(graph, to, current, level + 1);
            deepest = max(deepest, currentDeepest);
        }
    }
    graph[current].deepestLevel = deepest;
    return deepest;
}

int getLongest(vector<Vertex>& graph, int start)
{
    if (graph[start].edges.size() == 1)
    {
        return graph[start].level;
    }

    int longest = -1;
    for (const int to : graph[start].edges)
    {
        if (to != graph[start].parent)
        {
            longest = max(longest, getLongest(graph, to));
        }
    }
    return longest;
}

int main()
{
    int n, u, v;
    cin >> n >> u >> v;
    --u;
    --v;
    vector<Vertex> graph(n);
    Rep(i, n - 1)
    {
        int ai, bi;
        cin >> ai >> bi;
        --ai;
        --bi;
        graph[ai].edges.push_back(bi);
        graph[bi].edges.push_back(ai);
    }
    DFS(graph, v, -1, 1);

    /*
    cout << "Vertex" << endl;
    for (const Vertex& vertex : graph)
    {
        cout << "edges count " << vertex.edges.size() << " deepest " << vertex.deepestLevel << endl;
    }
    cout << "Vertex" << endl;
    //*/

    vint route;
    route.push_back(u);
    for (int parent = graph[u].parent; parent != v; parent = graph[parent].parent)
    {
        route.push_back(parent);
    }
    route.push_back(v);


    int ans = -1;
    auto itT = route.begin();
    Rep(i, route.size() / 2)
    {
        int currentLength = graph[*itT].deepestLevel - 2;
        ans = max(ans, currentLength);
        ++itT;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 13824
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(int argc, char* argv[]) {

	int N;

	cin >> N;

	vector<int> p(N,0);

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

	sort(p.begin(),p.end());

	p[p.size()-1] /= 2;

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


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
   using namespace std;
   #define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define text_wali_bakchodi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   #define F first
   #define S second
   #define pb push_back
   #define lb lower_bound
   #define ub upper_bound
   #define endl "\n"
   typedef long long ll;
   typedef long double ld;
   const ll mod = 998244353 ;
   const ld pi=3.1415926535897932384626433;
   const ll inf = 1e18;
   bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
   ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
   ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
   ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
   ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
   ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
   ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
   ll mul(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
   ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
   int main()
   {
      bolt;
      ll x,y,a,b,c;
      cin>>x>>y>>a>>b>>c;
      vector <ll> aa(a),bb(b),cc(c);
      for (ll i=0;i<a;i++)
      {
         cin>>aa[i];
      }
      for (ll i=0;i<b;i++)
      {
         cin>>bb[i];
      }
      for (ll i=0;i<c;i++)
      {
         cin>>cc[i];
      }
      sort (aa.begin(),aa.end());
      sort (bb.begin(),bb.end());
      sort (cc.begin(),cc.end());
      for (ll i=0;i<x;i++)
      {
         cc.pb(aa.back());
         aa.pop_back();
      }
      for (ll i=0;i<y;i++)
      {
         cc.pb(bb.back());
         bb.pop_back();
      }
      ll ans=0;
      sort (cc.rbegin(),cc.rend());
      for (ll i=0;i<x+y;i++)
      {
         ans+=cc[i];
      }
      cout<<ans;
   }


Measured memory_bytes: 6000
import java.util.Scanner
 
fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val string = scanner.next()
  scanner.close()
  var sum = 0
  for (char in string.toCharArray()) {
    sum += char.toString().toInt()
  }
  print(if(string.toInt() % sum == 0) "Yes" else "No")
}

Measured memory_bytes: 29352
a,b=map(int,input().split())

def factorization(n):
    count=0
    for i in range(2,int(-(-n**0.5//1))+1):
        if n%i == 0:
            
            while n%i == 0:
                n //=i
            count +=1
            
    if n !=1:
        count +=1
    
    return count

    
def gcd(x,y):
    
    if y == 0:
        return x
    else:
        return gcd(y,x%y)
        

d=gcd(a,b)
print(factorization(d)+1)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    for(int i=0; i<=x; i++){
        if(2*i+4*(x-i) == y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const double pi = 3.141592653589;
const int mod = 998244353;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
} c(200005);
/* global variables */
/* function */
/* main */
int main(){
    int n, m, k;
    cin >> n >> m >> k;

    // block num = n
    // color num = m
    // group num = n - x
    // same color group = x
    mint ans = 0;
    mint col = m; // assign group color = m * (m - 1)^(n - x - 1)
    for (int x = n - 1; x >= 0; x--) {
        mint now = col;
        now *= c(n - 1, x); // assing group place = n-1Cx
        if (x <= k) ans += now;
        col *= m - 1; // col = m * (m - 1)^(n - x - 2) * (m - 1)
    }
    cout << ans << '\n';
}


Measured memory_bytes: 6236
def p_c():
    from itertools import product
    N = int(input())
    xyh = [tuple(map(int, input().split())) for _ in range(N)]
    h = 0
    for i in xyh:
        if h < i[2]:
            x_, y_, h = i
    for x, y in product(range(101), repeat=2):
        high = h + abs(x_ - x) + abs(y_ - y)
        if all(h == max(0, high - abs(x - i) - abs(y - j)) for i, j, h in xyh):
            print(x, y, high)

p_c()

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

int main()
{
    string s, t;
    cin >> s >> t;
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
#define mp make_pair
#define pb push_back
#define f first
#define s second


//var 
int h, w, bc, ans = 0, k, cur;
int ar[7][7];
char tit;
bool uh[7], uw[7];

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

	cin >> h >> w >> k;
	for(int i = 1; i<=h; i++){
		for(int j = 1; j<=w; j++){
			cin >> tit;
			if(tit == '#'){
				bc++;
				ar[i][j] = 1;
			}
		}
	}	

	for(int h1 = 0; h1 < (1 << h); h1++){
		for(int w1 = 0; w1 < (1 << w); w1++){
			for(int i = 1; i<=h; i++){
				uh[i] = 0;
				if((h1) & (1 << (i-1)))uh[i] = 1;
				//cout << uh[i];
			} //cout << " ";
			for(int i = 1; i<=w; i++){
				uw[i] = 0;
				if((w1) & (1 << (i-1)))uw[i] = 1;
				//cout << uw[i];
			} //cout << endl;

			cur = 0;

			for(int i = 1; i<=h; i++){
				for(int j = 1; j<=w; j++){
					if(!(uh[i] || uw[j]))continue;
					if(ar[i][j])cur++;
				}
			}

			if((bc - cur) == k)ans++;

		}
	}

	cout << ans << endl;

	cout.flush();
	return 0;
}

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


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

	ll t=1;	//cin>>t;
	while(t--){
		ll n; cin>>n;
		ll ans= pow(n, 3);
		cout<<ans;
	}

	
 
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n= sc.nextInt(), m = sc.nextInt(),l=sc.nextInt();    
        long[][] matrixA = new long[m][n];
        long[][] matrixC = new long[l][n];
        
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                matrixA[j][i]=sc.nextLong();
            }
        }
        
        long x;
        for(int i=0;i<m;i++){
            for(int j=0;j<l;j++){
                x=sc.nextLong();
                for(int k=0;k<n;k++){
                    matrixC[j][k]+=x*matrixA[i][k];
                }
            }
        }
        
        for(int i=0;i<n;i++){
            for(int j=0;j<l;j++){
                if(j!=0)System.out.print(" ");
                System.out.print(matrixC[j][i]);
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 53576
#include <cstdio>
#include <cstdlib>
#include <map>
#include <cmath>
#define ll long long
using namespace std;

int n;
//int a[1000000];
map<int ,int> mmap;

int main()
{
    scanf("%d",&n);
    int max1 = -1;
    int max2 = -1;
    int num;
    for(int i = 0; i < n; ++i)
    {
        scanf("%d",&num);
        if(!mmap[num]) mmap[num] = 1;
        else mmap[num]++;
        if(mmap[num] % 2 == 0)
        {
            if(num > max1)
            {
                max2 = max(max2,max1);
                max1 = num;
            }else
            {
                max2 = max(max2,num);
            }
        }
    }
    if(max1 > 0 && max2 > 0)printf("%lld\n",(ll)max1 * max2);
    else printf("0\n");

}


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

int cheaker(vector<string> grid) {
    int ret = 0;
    rep(_i,grid.size()) {
        rep(_j,grid[0].size()) {
            if (grid[_i][_j] == '#') ret++;
        }
    }
    return ret;
}

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];

    int res = 0;
    for (int gyou = 0; gyou < (1 << h); gyou++) {
        for (int retu = 0; retu < (1 << w); retu++) {
            vector<string> c = grid;
            rep(i,h) if (gyou & (1 << i)) { rep(j,w) c[i][j] = 'A'; }
            rep(i,w) if (retu & (1 << i)) { rep(j,h) c[j][i] = 'A'; }
            if (cheaker(c) == k) res++;
        }
    }

    cout << res << endl;
    return 0;
}

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

ll INF = 1e+18;
int iINF = 1e9;

int 
main()
{
  string S; cin >> S;
  int Q; cin >> Q;
  bool flag = true;
  string front = "";

  rep(i, 0, Q){
    int tmp; cin >> tmp;
    if(tmp == 1){
      flag = !flag;
    } else {
      int F; cin >> F;
      string add; cin >> add;
      if(F == 1){
        if(flag) front += add;
        else S += add;
      } else {
        if(flag) S += add;
        else front += add;
      }
    }
  }

  if(flag){
    reverse(front.begin(), front.end());
    cout << front + S << endl;
  } else {
    reverse(S.begin(), S.end());
    cout << S + front << endl;
  }

}

Measured memory_bytes: 4128
//   AtCoder Beginner Contest 072 D

#include<stdio.h>


    int p[100005];

int main(void)
{

    int i, N, a =0, t;

    scanf("%d", &N);

    for(i = 0; i < 100005; i++)
        p[i] = 0;

    for(i = 1; i <= N; i++){
        scanf("%d", &p[i]);
    }
   
    for(i = 1; i <= N-1; i++){
        if (p[i] == i) {
            t = p[i];
            p[i] = p[i+1];
            p[i+1] =t;
            a++;
        }
    }
   
    {
        if (p[i] == i) {
            t = p[i];
            p[i] = p[i-1];
            p[i-1] =t;
            a++;
        }
   }
    printf("%d\n", a);

    return 0;
}

Measured memory_bytes: 512
// B - Digit Sums
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	int s = 0;
	for(int t=N; t; t/=10) s += t%10;
	cout<< (N%s? "No":"Yes") <<endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

ll sum[300000];
int N;
ll A[100010];

inline bool check2(int sp,int cur,ll mini){ return sum[cur] - sum[sp-1] >= mini; }

bool check(ll mini){
  if( sum[N] < mini * 3LL ) return false;
  REP(sp,1,N+1) {
    int cur = sp;
    int end = sp + N; // )
    bool success = true;
    rep(i,3){
      ll remain = sum[end-1] - sum[cur-1];
      if( remain < mini ) { success = false; break; }
      int L = cur, R = cur+N-1;
      while( L + 1 < R ){
	int M = ( L + R ) / 2;
	if( check2(cur,M,mini) ) R = M;
	else                     L = M;
      }
      assert( sum[R] - sum[cur-1] >= mini );
      cur = R+1;
    }
    if( success ) return true;
  }
  return false;
}

int main(){
  cin >> N;
  rep(i,N) cin >> A[i];
  sum[0] = 0;
  REP(i,1,N+1) sum[i] = sum[i-1] + A[i-1];
  REP(i,N+1,2*N+1) sum[i] = sum[i-1] + A[i-N-1];
  ll L = 0, R = 1000000000000000000LL;
  while( R - L ) {
    ll M = ( L + R ) / 2LL;
    if( check(M) ) L = M + 1LL;
    else           R = M;
  }
  cout << L-1LL << endl;
  return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
// Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n;
    cin >> n;
    vector<Int> a(n + 1, 0);
    for (Int i = 1; i <= n; i++) cin >> a[i];
    Int res = 0;
    Int l = 1, r = n;
    while (l < r) {
        res += a[l] / 2;
        a[l] %= 2;
        res += a[r] / 2;
        a[r] %= 2;
        if (a[l] % 2 == 1 && a[l + 1] > 0) {
            res++;
            a[l]--;
            a[l + 1]--;
        }
        if (a[r] % 2 == 1 && a[r - 1] > 0) {
            res++;
            a[r]--;
            a[r - 1]--;
        }
        l++;
        r--;
    }
    if (n % 2 == 1) {
        res += a[l] / 2;
    }
    dump(res);
    return 0;  
} 

Measured memory_bytes: 1024
from heapq import heappop, heappush, heapify
import sys
input = lambda: sys.stdin.readline().rstrip()

def find(x):
    if parents[x] < 0:
        return x
    else:
        parents[x] = find(parents[x])
        return parents[x]
def union(x, y):
    x = find(x)
    y = find(y)

    if x == y:
        return
    if parents[x] > parents[y]:
        x, y = y, x
    parents[x] += parents[y]
    parents[y] = x

def same(x, y):
    return find(x) == find(y)    

N = int(input())

verticies_x = []
verticies_y = []

for i in range(N):
    x, y = map(int, input().split())
    verticies_x.append((x,i))
    verticies_y.append((y,i))
verticies_x.sort()    
verticies_y.sort()

edge = []

for i in range(N-1):
    tmp_x = verticies_x[i+1][0] - verticies_x[i][0]
    tmp_y = verticies_y[i+1][0] - verticies_y[i][0]
    edge.append((tmp_x, verticies_x[i][1], verticies_x[i+1][1]))
    edge.append((tmp_y, verticies_y[i][1], verticies_y[i+1][1]))

ans = 0
edge.sort()
parents = [-1] * N
for cost, s, g in edge:
    if same(s,g):
        continue
    else:
        union(s,g)
        ans += cost
print(ans)

Measured memory_bytes: 115548
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#define BIG 1000000000
#define SIZE 40
#define PI 3.14159265359
using namespace std;

struct Point {
	double x, y;
	void show();
	void init(double a, double b) { x = a; y = b; }
};


void Point::show() {
	printf("%.8f %.8f\n", x, y);
}

void koch(int n, Point a, Point b) {
	if (n == 0)return;

	Point s, t, u;
	s.x = (2 * a.x + b.x) / 3;
	s.y = (2 * a.y + b.y) / 3;
	t.x = (2 * b.x + a.x) / 3;
	t.y = (2 * b.y + a.y) / 3;
	u.x = (t.x - s.x)*cos(PI / 3) - (t.y - s.y)*sin(PI / 3) + s.x;
	u.y = (t.x - s.x)*sin(PI / 3) + (t.y - s.y)*cos(PI / 3) + s.y;

	koch(n - 1, a, s);
	s.show();
	koch(n - 1, s, u);
	u.show();
	koch(n - 1, u, t);
	t.show();
	koch(n - 1, t, b);
}

int main() {
	int n;
	cin >> n;
	Point a, b;
	a.init(0, 0);
	b.init(100, 0);
	a.show();
	koch(n, a, b);
	b.show();
	return 0;
}

Measured memory_bytes: 3104
#include<stdio.h>

int main(void)
{
  int i,r,d;
  long int x[20];
  scanf("%d%d%ld",&r,&d,&x[0]);

  for(i=1;i<10+1;i++){
    x[i] = r*x[i-1]-d;
    printf("%ld\n",x[i]);
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

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

	if(n == 26) {
		for(int i = n - 2; i >= 0; i--) {
			if(s[i] < s[i + 1]) {
				string substr = s.substr(0, i + 1);

				for(char c = s[i]; c <= 'z'; c++) {
					if(count(substr.begin(), substr.end(), c) == 0) {
						s[i] = c;
						break;
					}
				}

				cout << s.substr(0, i + 1) << endl;
				break;
			}
	
			if(i == 0) {
				cout << -1 << endl;
			}
		}
	} else {
		for(char c = 'a'; c <= 'z'; c++) {
			if(count(s.begin(), s.end(), c) == 0) {
				cout << s + c << endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

int main() {
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll ans=0;
    if (x == 0) {
        if (k % 2) {
            cout << d << endl;
        } else {
            cout << 0 << endl;
        }
        return 0;
    }

    ll s = x / abs(x);
    ll n = abs(x) / d;
    if (n > k) {
        cout << x - s*d*k << endl;
        return 0;
    }
    ll p = x - s*d*n;
    ll r = k-n;
    if (r % 2) {
        ans = p - s*d;
    } else {
        ans = p;
    }

    cout << abs(ans) << endl;
    return 0;
}


Measured memory_bytes: 3196
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	double r; cin >> r;
	cout << fixed << setprecision(5) << pow(r, 2) * M_PI << " " << r * 2 * M_PI << endl;
	return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int INF2 = 1e15;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,s,t;
    cin >> n >> m >> s >> t;
    s--;t--;
    vector<vector<pair<int,P>>>cnt(n);
    for(int i = 0; i < m; i++) {
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--;v--;
        cnt[u].push_back({v,{a,b}});
        cnt[v].push_back({u,{a,b}});
    }
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int>sum(n,INF);sum[s] = 0;
    vector<int>sum2(n,INF);sum2[t] = 0;
    que.push({s,0});
    while(!que.empty()) {
        P X = que.top();
        que.pop();
        if(sum[X.first] < X.second) {
            continue;
        }
        for(int i = 0; i < cnt[X.first].size(); i++) {
            if(sum[cnt[X.first][i].first] > X.second+cnt[X.first][i].second.first) {
                sum[cnt[X.first][i].first] = X.second+cnt[X.first][i].second.first;
                que.push({cnt[X.first][i].first,sum[cnt[X.first][i].first]});
            }
        }
    }
    priority_queue<P,vector<P>,greater<P>> que2;
    que2.push({t,0});
    while(!que2.empty()) {
        P X = que2.top();
        que2.pop();
        if(sum2[X.first] < X.second) {
            continue;
        }
        for(int i = 0; i < cnt[X.first].size(); i++) {
            if(sum2[cnt[X.first][i].first] > X.second+cnt[X.first][i].second.second) {
                sum2[cnt[X.first][i].first] = X.second+cnt[X.first][i].second.second;
                que2.push({cnt[X.first][i].first,sum2[cnt[X.first][i].first]});
            }
        }
    }
    vector<int>ans(n);
    for(int i = n-1; i >= 0; i--) {
        ans[i] = sum[i]+sum2[i];
        if(i+1 != n) {
            ans[i] = min(ans[i+1],ans[i]);
        }
    }
    for(int i = 0; i < n; i++) {
        cout << INF2-ans[i] << endl;
    }
}

Measured memory_bytes: 21928
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

#define FOR(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define all(x) (x).begin(),(x).end()

int main(){
  int n,x;
  cin >>n >>x;
  vec<int> m(n);
  REP(i,n) cin >>m[i];

  int s=0;
  REP(i,n) s = s+m[i];
  int minm=m[0];
  REP(i,n) minm = min(minm,m[i]);

  cout <<n+int((x-s)/minm) <<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        s: Chars,
    }

    let r = s.iter().filter(|&c| *c == 'R').count();
    let g = s.iter().filter(|&c| *c == 'G').count();
    let b = s.iter().filter(|&c| *c == 'B').count();

    let total = r * g * b;

    let mut no_count = 0;

    for i in 1..=((n - 1) / 2) {
        //はば
        for j in 0..(n - 2 * i) {
            // スタート位置
            if s[j] != s[j + i] && s[j + i] != s[j + i * 2] && s[j] != s[j + i * 2] {
                no_count += 1;
            }
        }
    }

    println!("{}", total - no_count);
}


Measured memory_bytes: 2188
#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,z):
    while x != None and z.key != x.key:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    return x


def Delete(x, z):
    if z.l == None or z.r == None:
        y = z
    else:
        y = getSuccessor(z)

    if y.l != None:
        x = y.l
    else:
        x = y.r

    if x != None:
        x.p = y.p

    if y.p == None:
        pass
    elif y == y.p.l:
        y.p.l = x
    else:
        y.p.r = x
    if y != z:
        z.key = y.key
        
def getSuccessor(x):
    if x.r != None:
        return getMinimum(x.r)
    y = x.p
    while y != None and x == y.r:
        x = y
        y = y.p
    return y

def getMinimum(x):
    while x.l != None:
        x = x.l
    return x

root = None
for data in trees:
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)

    else:
        z = BinaryTree(int(data[1]))
        if data[0] == "insert":
            root = Insert(root,z)
        elif data[0] == "find":
            a = Find(root, z)
            if a == None:
                print("no")
            else:
                print("yes")
        elif data[0] == "delete":
            Delete(root, Find(root,z))
  



Measured memory_bytes: 237728
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define FOR(i,n) for(size_t i=0;i<(n);i++)
#define REP(n) FOR(i,n)
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(all(v),0l)

int main() {
  nvec(int,a,3);
  if(a[0]+a[1]+a[2]>=22){
    cout<<"bust";
  }else{
    cout<<"win";
  }
}

Measured memory_bytes: 764
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define fi first
#define se second
#define lowbit(x) ((x)&-(x))
#define debug(x) cout << #x " = " << x << endl;
namespace IO{
	const int L = 1 << 15;
	char ibuf[L|1],*iS=ibuf,*iT=ibuf;
	char obuf[L|1],*oS=obuf,*oT=obuf+L;
	char c,st[66];int tp=0,f;
	inline char gc(){
		if(iS==iT) iT=(iS=ibuf)+fread(ibuf,sizeof(char),L,stdin);
		return (*iS++);
	}
	inline void flush() {
		fwrite(obuf,sizeof(char),oS-obuf,stdout);
		oS = obuf;
	}
	inline void pc(char c){*oS++=c;if(oS==oT) flush();}
	#define gc getchar
	#define pc putchar
	inline ll read(){
		ll x=0;f=1,c=gc();
		for(;!isdigit(c);c=gc())if(c=='-')f=-1;
		for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c&15);
		return x*f;
	}
	void write(ll x){
		if(!x) pc('0');if(x<0) pc('-'),x=-x;
		while(x) st[++tp]=x%10+'0',x/=10;
		while(tp) pc(st[tp--]);
	}
	void wri(ll x){write(x);pc(' ');}
	void writeln(ll x){write(x);pc('\n');}
	struct IOflusher{~IOflusher(){flush();}}_ioflusher_;
}
using IO::read;
using IO::writeln;
using IO::wri;
inline void gg(string s){cout << s << endl;exit(0);}
inline void gg(ll x){writeln(x);exit(0);}
const int maxn = 1e7+233;
const int mod = 998244353;
int n,a,b,fac[maxn],ifac[maxn],inv[maxn];
inline int C(int n,int m){
	if(m<0||n<m) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int F(int x,int y){
	if(y<=x-1) return 0;
	return (C(x+y,x)-C(x+y,x-1)+mod)%mod;
}
int main(){
	fac[0] = ifac[0] = fac[1] = ifac[1] = inv[1] = 1;
	rep(i,2,maxn) {
		fac[i] = 1ll * fac[i-1] * i % mod;
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
		ifac[i] = 1ll * ifac[i-1] * inv[i] % mod;
	}
	n = read(),a = read(),b = read();
	if(!b) gg(1);
	int ans = 0;
	Rep(i,0,n-b){
		int ways = F(i,b-1);
		if(i+b==n){
			if(i==a) ans = (ans + ways) % mod;
		} else{
			int x = n - b - i - 1,y = a - i + 1;
			ans = (ans + 1ll * ways * C(x+y-1,y-1)) % mod;
		}
	}writeln(ans);
	return 0;
}
//fix gcz's blog:
//3操作其实并不是最后一次等于，而是递增的最后一次等于，也就是说前面有比他大的我不去管的
//发现这些位置后面恰好都可以放，其它位置都不能放


Measured memory_bytes: 120800