akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


const int max_comb=210000;
vector<ll> fac(max_comb+1); //n! (mod M)
vector<ll> ifac(max_comb+1); //k!^(-1) (mod M)

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

ll minv(ll x){
    return mpow( x, MOD-2 );
}

ll comb(int a, int b){     // C(a,b) = a! * b!^(-1) * (a-b)^(-1)
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

ll perm(int a, int b){     // P(a,b) = a! * (a-b)!^(-1)
    if(b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b] % MOD;
    return tmp * fac[a] % MOD;
}

void pre_comb()
{
    fac[0] = 1;
    ifac[0] = 1;
    for(int i = 0; i<max_comb; i++){
        fac[i+1] = fac[i]*(i+1) % MOD; // n!(mod M)
        ifac[i+1] = ifac[i]*minv(i+1) % MOD; // k!^(-1) (mod M)
    }
    return;
}

void solve()
{
    int n, m, K;
    scanf("%d%d%d", &n, &m, &K);

    pre_comb();
    ll ans = 0;
    int i;
    for (i = 0; i <= K; i++) {
        ll ans0 = m * mpow(m - 1, n - 1 - i) %MOD;
        ll ans1 = comb(n - 1, i);
        ll ans2 = ans0 * ans1 %MOD;
        ans = (ans + ans2) % MOD;
    }

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

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 5736
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> L(N);
    REP(i, 0, N) cin >> L[i];

    ll ans = 0;
    sort(ALL(L));
    REP(i, 0, N) {
        REP(j, i + 1, N) {
            int to = (int)(lower_bound(ALL(L), L[i] + L[j]) - L.begin());
            REP(k, j + 1, to) {
                if (i == k || j == k) continue;
                if (L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long 

const int mod = 1e9 + 7;

vector<vector<int>> mul(vector<vector<int>> A, vector<vector<int>> B){
    int n = A.size();
    vector<vector<int>> res(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            res[i][j] = 0;
            for(int k=0;k<n;k++){
                res[i][j] += (A[i][k]*B[k][j]) % mod;
                res[i][j] %= mod;
            }
        }
    }
    return res;
}

vector<vector<int>> expo(vector<vector<int>> A, int k){
    int n = A.size();
    vector<vector<int>>res(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        res[i][i] = 1;
    }
    int x = k;
    while(x > 0){
        if(x%2 == 1){
            res = mul(res,A);
        }
        x >>= 1;
        A = mul(A,A);
    }
    return res;
}

int32_t main(){
    int n,k;
    cin >> n >> k;
    vector<vector<int>> A(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> A[i][j];
        }
    }   
    vector<vector<int>>res = expo(A,k);
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            ans += res[i][j];
            ans %= mod;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3744
/*
  author: ruruvuvu
  GitHub account: colon-ku

  created at: 2020-01-04 13:03:41
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++)
        cin >> a[i];

    vector<int> row(h, 0), col(w, 0);
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (a[i][j] == '#') {
                row[i] = 1;
                col[j] = 1;
            }
        }
    }

    for (int i = 0; i < h; i++) {
        if (row[i]) {
            for (int j = 0; j < w; j++) {
                if (col[j]) {
                    cout << a[i][j];
                }
            }

            cout << 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;
typedef long long ll;
const int inf = 1001001001;


// i * j = n
// i + j -> min?
int main(){
  ll n;
  cin >> n;

  ll mn = (n-1) + (1-1);

  for(int i = 2; i <= sqrt(n); i++){
    if(n%i == 0){
      mn = min(mn, i-1 + n/i-1);
    }
  }
  cout << mn << endl;
}


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

//関数


int main() {
    
    
    //入力
    long N,M;
    cin>>N>>M;
    vector<vector<bool>> edge(N,vector<bool>(N,false));
    for(int i=0;i<M;i++){
        long a,b;
        cin>>a>>b;
        edge.at(a-1).at(b-1)=true;
        edge.at(b-1).at(a-1)=true;
    }
    
    //計算
    vector<long> path(N-1);
    for(int i=0;i<N-1;i++){
        path.at(i)=i+1;
    }
    
    long ans=0;
    do{
        bool possible=edge.at(0).at(path.at(0));
        for(int i=1;i<N-1;i++){
            possible&=edge.at(path.at(i-1)).at(path.at(i)) ;
        }
        if(possible) ans++;
    }while(next_permutation(path.begin(),path.end()));
    
    //出力
    cout<<ans<<endl;
}

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

int main()
{
    string c1, c2;
    cin >> c1 >> c2;
    if(c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
L1 = 0
R1 = N

for m in range(M):
  L2,R2 = map(int,input().split())
  L1 = max(L1,L2)
  R1 = min(R1,R2)
  
print(max(0,R1-L1+1))

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	LL k, n; cin >> k >> n;
	vector<int> a(n);

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

	LL ans = k-(k-a[n-1]+a[0]);
	for (int i = 0; i < n-1; i++) {
		LL tmp = k - abs(a[i + 1] - a[i]);
		ans = min(ans, tmp);
	}

	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main()
{
    int N; cin >> N;
    vector<int> A(N); cin >> A;
    vector<int> s;

    for (int a : A) {
        auto it = lower_bound(s.rbegin(), s.rend(), a);
        if (it == s.rbegin()) {
            s.push_back(a);
        } else {
            *(--it) = a;
        }
    }

    cout << s.size() << endl;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<float,float>;
const int INF=1001001001;
const int NMAX=8;
const int MOD=1000000007;
const int dbase=80*160;


int main(){
	int n;
	cin>>n;
	vector<P>g(n);
	rep(i,n){
		double x1,y1;
		cin>>x1>>y1;
		g[i]=make_pair(x1,y1);
	}
	vector<int> a(n);
	rep(i,n)a[i]=i;
	double ans=0;
	int ct=0;
	do{
		double cnt=0;
		rep(i,n-1){
			double tmp=0;
			int l,r;
			l=a[i];r=a[i+1];
			tmp=(g[l].first-g[r].first)*(g[l].first-g[r].first)+(g[l].second-g[r].second)*(g[l].second-g[r].second);
			cnt+=sqrt(tmp);
		}
		ans+=cnt;
		//cout<<cnt<<endl;
		ct++;
	}while (next_permutation(a.begin(), a.end()));
	ans=ans/ct;
	cout<<fixed<<setprecision(10)<<ans;


}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		// 計算
		int result = 0;
		result = x - a;
		result %= b;
		
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
import sys

N, W = map(int, input().split())
WEIGHTS = list(list(map(int, input().split())) for _ in range(N))
M = len(WEIGHTS)
MAX_VALUE = sum(value for (weight, value) in WEIGHTS)

INF = sys.maxsize
DP = [[INF for _ in range(MAX_VALUE + 1)] for _ in range(M + 1)]

for i, (weight, value) in enumerate(WEIGHTS):
    for v in range(MAX_VALUE + 1):
        if v - value >= 0:
            DP[i+1][v] = min(DP[i][v - value] + weight, DP[i][v])
        else:
            DP[i+1][v] = min(DP[i][v], weight)

res = 0
for v, w in enumerate(DP[M]):
    if w <= W:
        res = max(res, v)

print(res + 1)

Measured memory_bytes: 171376
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<lint, lint> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	if (!b)return T(1);
	if (b & 1)return mypow(a, b - 1) * a;
	T memo = mypow(a, b >> 1);
	return memo * memo;
}
lint modpow(lint a, lint b, lint m) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	lint memo = modpow(a, b >> 1, m);
	return memo * memo % m;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size() - 1)std::cout << vec[i] << " ";
	std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
lint a,b,v,w,t;
int main(){
	std::cin>>a>>v>>b>>w>>t;
	if((v-w)*t<std::abs(a-b))puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
	char a, b, c;
	
	scanf("%c %c %c",&a, &b, &c);
	
	if ((a==b && a!=c)||(a==c && a!=b)||(b==c && b!=a)){
	printf ("Yes\n");
	
	}else
	printf ("No\n");
	return 0;
}

Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(){
        int N;
        int array[100];
        cin >> N;
        for(int i=0 ; i<N ; i++ )
                cin>> array[i];
        for(int i=1 ; i<=N ; i++ ){
                int tmp=array[i];
                for(int l=0 ; l<N ; l++ ){
                        cout << array[l];
                        if(l<N-1)
                                cout<<" ";
                }
                cout << endl;
                int j=i-1;
                while(array[j]>tmp && j>=0){
                        array[j+1]=array[j];
                        j--;
                }
                array[j+1]=tmp;
        }
        return 0;
}

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

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

    sort(d, d + N, greater<int>());
    int ans = 0;
    int tmp = 101;
    for (int i = 0; i < N; i++) {
        if (d[i] < tmp) {
            ans++;
            tmp = d[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  while True:
    x = c.get(i, 0)
    if x == 0:
      break
    r = r * pow(p, x, M) % M
    p = x; n -= p; i += 1
print((r, 0)[n > 1])


Measured memory_bytes: 22636
#include <iostream>
#include <string>
#include <cctype>
#include <cmath>

using namespace std;

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

  // 1 - 9
  // 100 - 999
  // 10000 - 99999
  int sum = 0;
  while (N > 0) {
    if (N <= 9) {
      sum += N;
      N = 0;
    }
    else if (N <= 99) {
      N = 9;
    }
    else if (N <= 999) {
      sum += N - 100 + 1;
      N = 99;
    }
    else if (N <= 9999) {
      N = 999;
    }
    else if (N <= 99999) {
      sum += N - 10000 + 1;
      N = 999;
    }
    else {
      N = 99999;
    }
  }

  cout << sum << endl;
  return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};

void solve(int n){
    vector<vector<int>> d(n);
    rep(i,n){
        int f;
        cin>>f;
        d[i] = vi(f);
        rep(j,f){
            cin>>d[i][j];
            d[i][j]--;
        }
    }
    set<int> days[31];
    rep(i,n){
        rep(j,d[i].size()){
            days[d[i][j]].insert(i);
        }
    }


    for(int i=0;i<31;i++){
        // i??\??§?????????????
        set<int> st;
        for(int v : days[i]) st.insert(v);
        for(int j=i-1;j>=0;j--){
            bool flag=false;
            for(int t : days[j]) if(st.count(t)){
                flag=true;
                break;
            }
            if(flag){
                for(int t : days[j]) st.insert(t);
            }
        }
        if(st.size()==n){
            cout << i+1 << endl;
            return;
        }
    }

    cout << -1 << endl;
}

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        solve(n);
    }
}

Measured memory_bytes: 3076
//
//  main.cpp
//  C - Walk on Multiplication Table
//
//  Created by Hashizo on 2019/10/27.
//  Copyright © 2019 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

int main(int argc, const char * argv[]) {
	ll ans = LONG_MAX;
	ll kuku = 0;
	
	ll n;
	cin >> n;

	FOR(i, 1, (10000000)){
		if ((n % i) == 0) {
			kuku = n / i;
			if (ans > (kuku+i-2)) {
				ans = (kuku+i-2);
			}
		}
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int x,y,z; cin>>x>>y>>z;
	swap (x,y), swap (x,z);
	cout<<x<<" "<<y<<" "<<z;
	return 0;
}


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

using ll = long long;

constexpr ll INF = 1e18;

struct edge {
    int from, to;
    ll cost;
};

using edges = vector<edge>;
using graph = vector<edges>;

vector<ll> dijkstra(graph const& g, int s) {
    const int V = g.size();
    vector<ll> d(V, INF);
    d[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<>> que;
    que.emplace(0, s);
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        const int v = now.second;
        if(d[v] < now.first) continue;
        for(auto& e : g[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.emplace(d[e.to], e.to);
            }
        }
    }
    return d;
}

int main() {
    int N, M, s, t, u, v;
    cin >> N >> M >> s >> t >> u >> v;
    s--; t--; u--; v--;
    graph g(N);
    for(int i = 0; i < M; ++i) {
        int a, b, c; cin >> a >> b >> c;
        g[a - 1].push_back(edge{a - 1, b - 1, c});
        g[b - 1].push_back(edge{b - 1, a - 1, c});
    }
    auto from_s = dijkstra(g, s);
    auto from_t = dijkstra(g, t);
    graph sg(N);
    for(int i = 0; i < N; ++i) {
        for(auto& e : g[i]) {
            if(from_s[t] == from_s[e.from] + e.cost + from_t[e.to]) {
                sg[i].push_back(e);
            }
        }
    }
    auto from_u = dijkstra(g, u);
    auto from_v = dijkstra(g, v);
    ll ans = INF;
    vector<pair<ll, ll>> memo(N, make_pair(INF, INF));
    std::function<pair<ll, ll> (int)> dfs = [&](int i) {
        if(memo[i].first != INF) return memo[i];
        auto res = make_pair(from_u[i], from_v[i]);
        for(auto& e : sg[i]) {
            auto tmp = dfs(e.to);
            res.first = min(res.first, tmp.first);
            res.second = min(res.second, tmp.second);
        }
        ans = min({ans, from_v[i] + res.first, from_u[i] + res.second});
        return memo[i] = res;
    };
    dfs(s);
    ans = min(ans, from_u[v]);

    cout << ans << endl;
}



Measured memory_bytes: 30260
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define PB push_back
#define MP make_tuple
#define ALL(V) V.begin(), V.end()
#define RALL(V) V.rbegin(), V.rend()
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, pii> pipi;

constexpr int INF = 1LL << 60;
constexpr int MOD = 1000000007;
constexpr int MAX_N = 105;
constexpr int MAX_M = 1005;
//constexpr int MAX_H = 1005;
constexpr int dx[] = { 0, 1, 0, -1 };
constexpr int dy[] = { 1, 0, -1, 0 };

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;
    cin >> s;
    s[5] = s[13] = ' ';
    cout << s << endl;
}

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

long long Gcd(long long a, long long b) {
  if (b == 0)
    return a;
  return Gcd(b, a % b);
}

long long Lcm(long long a, long long b) { return a / Gcd(a, b) * b; }

int main() {
  long long A, B, C, D;
  cin >> A >> B >> C >> D;
  long long E = Lcm(C, D);
  long long c = B / C - (A - 1) / C, d = B / D - (A - 1) / D,
            c_and_d = B / E - (A - 1) / E;
  cout << B - A + 1 - (c + d - c_and_d) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int k, n, vt, d1, d2, d3, d4, meow;
    vector <int> v;
    cin>>k>>n;
    while(n--) {
        cin>>vt;
        v.push_back(vt);
    }
    sort(v.begin(), v.end());
    meow=v.size();
    d1=(v[meow-1]-v[0]);
    ///d4=(k-v[meow-1])+v[meow-2];
    d3=k;
    for(int i=1; i<meow; i++) {
        d2=(k-v[i])+(v[i-1]);
        if(d2<d3) d3=d2;
    }
    cout<<min(d1, d3)<<endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  double ans = 0;
  if (N % 2 == 0) {
    ans = 0.5;
  }
  else {
    ans = (N / 2 + 1) / (double)N;
  }
  cout << ans << endl;
}
  


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		if(n<10) {
			System.out.println( 100*(10-n)+r);
					
		}
		else {
			System.out.println(r);
		}
		

	}

}


Measured memory_bytes: 35576
import java.util.*;

public class Main {
	public static void main(String[] args) {
			Scanner scan =  new Scanner(System.in);
			int X = scan.nextInt();
			int Y = scan.nextInt();
			if(Y<=X*4 && Y>=X*2 && Y%2 == 0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
	}
}


Measured memory_bytes: 27080
#include<bits/stdc++.h>
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 15000
using namespace std;

template <typename T>
void print(T x){cout<<x<<"\n";}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<"\n";}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<"\n";}

int mincost(int jumps[],int n,int k)
{
    int dp[n];
    dp[0]=0;
    for(int i=1;i<n;i++) dp[i]=INT_MAX;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=i+k;j++)
        if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(jumps[j]-jumps[i]));    
    }
    
    return dp[n-1];
}

int main()
{
    io;
    ll test_case;
    //cin>>test_case;
    test_case=1;
    while(test_case--)
    {
        ll n,k;
        cin>>n>>k;
        int arr[n];
        for(int i=0;i<n;i++) cin>>arr[i];
        cout<<mincost(arr,n,k)<<"\n";
    }   
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const int INF = (1 << 30)-1;

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

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

  int dp[101010] = {};
  rep(i, 101010) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) {
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 998244353
  #define N 200005
  #define INF 1000000000000
  #define eps 1e-6
int32_t main()
{

    IOS

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

    priority_queue<int> pq;

    for(int i = 1; i <= n; i++)
    {
      int x;
      cin >> x;
      pq.push(x);
    }

    while(m--)
    {
      int k = pq.top();
      pq.pop();
      k/=2;
      pq.push(k);
    }

    int ans = 0;

    while(!pq.empty())
    {
      ans += pq.top();
      pq.pop();
    }

    cout << ans;

	return 0;  
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);

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

    int count = 0;
    while(n>5) {
       count++;
       n-=3;
    }
    if(n > 2) count++;
    cout << count << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}



Measured memory_bytes: 256
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(a.Max() - a.Min());
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は√N
 */
const int mod = 1e9 + 7;

//ここから書き始める
//二つの文字列に、同じ文字の種類ががどれだけあるかを見る たとえば aabcde と aabe
//ならa,b,e が被っているので3を返す。 aが二つあるが、種類数を見るので3が返ってくる
int main(){
	ll n;
	cin >> n;
	string s; 
	cin >> s;
	ll ans = 1;

	for(int i = 1; i < n; i++){
		if(s[i] != s[i-1]) ans++;
	}
	cout << ans<<endl;
}



Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, M;

	public static void main(String[] args) {
		while (true) {
			N = sc.nextInt();
			M = sc.nextInt();
			if (N == 0) break;
			Edge[] edges = new Edge[M];
			for (int i = 0; i < M; ++i) {
				int s = sc.nextInt() - 1;
				int t = sc.nextInt() - 1;
				int c = sc.nextInt();
				edges[i] = new Edge(s, t, c);
			}
			Arrays.sort(edges);
			ArrayList<Integer> costs = new ArrayList<Integer>();
			UnionFind uf = new UnionFind(N);
			for (int i = 0; i < M; ++i) {
				if (!uf.find(edges[i].s, edges[i].e)) {
					uf.union(edges[i].s, edges[i].e);
					costs.add(edges[i].c);
					if (costs.size() == N - 1) break;
				}
			}
			System.out.println(costs.get(N / 2 - 1));
		}
	}

	static class Edge implements Comparable<Edge> {
		int s, e, c;

		Edge(int s, int e, int c) {
			this.s = s;
			this.e = e;
			this.c = c;
		}

		public int compareTo(Edge o) {
			return this.c - o.c;
		}
	}

	static class UnionFind {
		int[] set;

		UnionFind(int n) {
			set = new int[n];
			Arrays.fill(set, -1);
		}

		void union(int a, int b) {
			int rtA = root(a);
			int rtb = root(b);
			if (rtA == rtb) {
				return;
			}
			set[rtA] += set[rtb];
			set[rtb] = rtA;
		}

		boolean find(int a, int b) {
			return root(a) == root(b);
		}

		int root(int a) {
			if (set[a] < 0) {
				return a;
			} else {
				set[a] = root(set[a]);
				return set[a];
			}
		}

		int size(int a) {
			return -set[root(a)];
		}
	}

}

Measured memory_bytes: 101376
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <queue>
using namespace std;

int main(void){
  string str1, str2;
  cin >> str1 >> str2;
  for(int i=0;i<str1.size();i++){
    for(int j=0;j<str2.size();j++){
      if(str1[i+j] != str2[j])  break;
      if(j == str2.size() - 1)
        cout << i  << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <iterator>
#include <cstdio>


using namespace std;


int d[4];
char c[3];


void solve(char op[3], int depth)
{
    if (depth == 3) {
        int ans = d[0];
        for (int i = 0; i < 3; i++) {
            switch (op[i]) {
                case '+':
                    ans += d[i+1];
                    break;
                case '-':
                    ans -= d[i+1];
                    break;
            }
        }

        if (ans == 7) {
            c[0] = op[0];
            c[1] = op[1];
            c[2] = op[2];
        }

        return;
    }

    op[depth] = '+';
    solve(op, depth + 1);
    op[depth] = '-';
    solve(op, depth + 1);
}


int main()
{
    for (int i = 0; i < 4; i++) {
        d[i] = getchar() - '0';
    }

    char op[3];
    solve(op, 0);

    cout << d[0];
    for (int i = 0; i < 3; i++) {
        cout << c[i] << d[i+1];
    }
    cout << "=7" << endl;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
dp = [float('inf')] * (N + 3)
dp[0] = 0
for i in range(1, N):
    if 0 <= i - 2:
        dp[i] = min(dp[i], dp[i - 2] + abs(H[i] - H[i - 2]))
    dp[i] = min(dp[i], dp[i - 1] + abs(H[i] - H[i - 1]))
# print(dp)
print(dp[N - 1])

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> p(m);
  vector<string> s(m);
  for (int i = 0; i < m; i++) {
    cin >> p.at(i) >> s.at(i);
  }
  
  int ans = 0;
  int penalty = 0;
  vector<bool> checked(n, false);
  vector<bool> final_checked(n, false);
  
  for (int i = 0; i < m; i++) {
    if (s.at(i) == "AC") final_checked.at(p.at(i) - 1) = true;
  }
  
   for (int i = 0; i < m; i++) {
    if (s.at(i) == "AC" && !checked.at(p.at(i) - 1)) {
      ans++;
      checked.at(p.at(i) - 1) = true;
    }
    else if (s.at(i) == "WA" && !checked.at(p.at(i) - 1) && final_checked.at(p.at(i) - 1)) {
      penalty++;
    }
  }
  if (ans == 0) penalty = 0;
  cout << ans << " " << penalty << endl;
}

Measured memory_bytes: 6144
#include<stdio.h>
#include<map>
#include<array>
#include<vector>

long long rev(long long);

int main()
{
	long long ans = 1;
	long long n, m;

	scanf("%lld%lld", &n, &m);
	for (long long i = 2; m != 1; ++i)
	{
		if (m % i) continue;

		int count{};
		for (count = 0; !(m % i); ++count)
			m /= i;
		long long tmp = count + n;

		for (int j = 1; j <= count; ++j)
		{
			ans *= (tmp - j);
			ans %= 1000000007;
			ans *= rev(j);
			ans %= 1000000007;
		}
	}

	printf("%lld", ans);
	return 0;
}

long long rev(long long a)
{
	std::array<long long, 40> table{};
	table[0] = 1;
	table[1] = a;
	for (int i = 2; i < 35; ++i)
		table[i] = table[i - 1] * table[i - 1] % 1000000007;

	long long ret = 1;
	long long p = 1000000005;
	for (int i = 1; p; ++i, p >>= 1)
	{
		if (p & 1)
			ret = (ret * table[i]) % 1000000007;
	}
	return ret;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 5e15;

vector<ll> primes;

int main(){
    ll M = 55555;
    bool po[M + 1] = {};
    for(ll m = 2; m <= M; m++){
        if(po[m]) continue;
        primes.push_back(m);
        for(ll i = 1; i * m <= M; i++) po[i * m] = 1;
    }
    ll N;
    cin >> N;
    ll cnt = 0;
    for(auto p : primes){
        if(p % 5 == 1){
            cnt++;
            cout << p << " ";
        }
        if(cnt == N){
            break;
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//うまく0の時をはじけてない
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);

    ll n;cin>>n;
    vector<ll> a(n),b(n),mt(n,-1);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];

    bool f=true;
    if(a[0]>b[0])f=false;
    for(int i=1;i<n;i++){
        if(a[i]!=a[i-1]){
            if(a[i]>b[i])f=false;
        }
    }

    if(b[n-1]>a[n-1])f=false;
    for(int i=n-2;i>=0;i--){
        if(b[i]!=b[i+1]){
            if(b[i]>a[i])f=false;
        }
    }
    if(!f){
        cout<<0<<endl;return 0;
    }








    ll nw=0;
    rep(i,n){
        if(nw!=a[i]){
            mt[i]=a[i];
            nw=a[i];
        }
    }

    if(mt[n-1]>0&&mt[n-1]!=b[n-1]){
        cout<<0<<endl;return 0;
    }
    mt[n-1]=b[n-1];
    for(int i=n-2;i>=0;i--){
        if(b[i+1]!=b[i]){
            if(mt[i]<0){
                mt[i]=b[i];
                nw=b[i];
            }
            else{
                if(mt[i]!=b[i]){
                    cout<<0<<endl;return 0;
                }
            }
        }
    }

    ll l=mt[0],cnt=0,ans=1ll;
    for(int i=1;i<n;i++){
        if(mt[i]<0){
            cnt++;
            continue;
        }
        ll mul=min(mt[i],l);
        rep(_,cnt){
            ans=(ans*mul)%mod;
        }
        l=mt[i];
        cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
	int k,a,b;
	cin>>k;
	cin>>a>>b;
	b=b/k;
	a-=1;
	a=a/k;
	if(b-a>=1){
		cout<<"OK"<<endl;

	}
	else{
		cout<<"NG"<<endl;
	}
}

Measured memory_bytes: 3588
#include <stdio.h>

using namespace std;

int main(){
	int m,f,r;
	char grade;
	while(true){
		scanf("%d %d %d",&m,&f,&r);
		if(m == -1 && f == -1 && r == -1) break;
		if(m == -1 || f == -1){
			grade = 'F';
		}else if(m+f >= 80){
			grade = 'A';
		}else if(m+f >= 65){
			grade = 'B';
		}else if(m+f >= 50){
			grade = 'C';
		}else if(m+f >= 30){
			grade = (r >= 50)? 'C':'D';
		}else{
			grade = 'F';
		}
		printf("%c\n",grade);
	}
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
const int N = 2003;
int n, k, res;
vector <int> e[N], f[N];
int ances[N][15], level[N];;

void dfs(const int u, const int p) {
    for (auto v: e[u])
        if (v != p) {
            level[v] = level[u] + 1;
            ances[v][0] = u;
            dfs(v, u);
        }
}

void make_lca() {
    for (int k = 1; k < 15; k++)
        for (int i = 1; i <= n; i++)
            ances[i][k] = ances[ances[i][k - 1]][k - 1];
}

int lca(int u, int v) {
    if (level[u] < level[v]) swap(u, v);
    for (int i = 14; i > - 1; i--)
        if (level[ances[u][i]] >= level[v])
            u = ances[u][i];
    if (u == v) return u;
    for (int i = 14; i > - 1; i--)
        if (ances[u][i] != ances[v][i]) {
            u = ances[u][i];
            v = ances[v][i];
        }
    return ances[u][0];
}

int dist(const int u, const int v) {
    return level[u] + level[v] - 2 * level[lca(u, v)];
}

int dfs2(const int root, const int u, const int p) {
    int ans = 0;
    if (dist(u, root) > k / 2) ans++;
    for (auto v: e[u])
        if (v != root && v != p)
            ans += dfs2(root, v, u);
    return ans;
}

void prepare(const int u) {
    f[u].resize(e[u].size());
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        f[u][i] = dfs2(u, v, -1);
    }
}

void progress() {
    for (int i = 1; i <= n; i++)
        prepare(i);
    if (k % 2 == 0) {
        for (int u = 1; u <= n; u++) {
            int cnt = 0;
            for (int i = 0; i < e[u].size(); i++)
                cnt += f[u][i];
            res = min(res, cnt);
        }
    } else {
        for (int u = 1; u <= n; u++) {
            int cnt1 = 0;
            for (int i = 0; i < e[u].size(); i++)
                cnt1 += f[u][i];
            for (int i = 0; i < e[u].size(); i++) {
                int v = e[u][i];
                int cnt2 = 0;
                for (int j = 0; j < e[v].size(); j++)
                    if (e[v][j] != u)
                        cnt2 += f[v][j];
                res = min(res, cnt1 + cnt2 - f[u][i]);
            }
        }
    }
}

int main() {
    ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> k;
    res = n;
    for (int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs (1, -1);
    make_lca();
    progress();
    cout << res;
    return 0;
}


Measured memory_bytes: 768
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        int array[]= new int[n + 1];
        st = new StringTokenizer(br.readLine());
        int cnt = 0;
        for(int i = 1;i <= n;i++){
            int a = Integer.parseInt(st.nextToken());
            if(a % 2 == 1)++cnt;
        }
        if(cnt % 2 == 1){
            System.out.println("NO");
        }
        else System.out.println("YES");
    }
}


Measured memory_bytes: 24196
#include<iostream>
using namespace std;
string t;
char str[8][8],tmp[8][8];
int main(){
  for(int i=0;i<8;i++){
    cin>>t;
    for(int j=0;j<8;j++){
      str[i][j]=t[j];
    }
  }

  for(int i=90;i<360;i+=90){
    cout<<i<<endl;

    for(int j=0;j<8;j++)
      for(int k=0;k<8;k++)
	tmp[j][k]=str[j][k];
    


    for(int j=0;j<8;j++){
      for(int k=0;k<8;k++){
	str[j][k]=tmp[7-k][j];
	cout<<str[j][k];
      }
      cout<<endl;
    }

  }
  return 0;
}

Measured memory_bytes: 1180
#include<bits//stdc++.h>
using namespace std;
string s, x[2][2][2] = { {{"black","blue"}, {"lime","aqua"}}, { {"red","fuchsia"}, {"yellow","white"} } },T = "89abcdef";
int main() {
	while (1) {
		int a = 0, b = 0, c = 0;cin >> s;
		if (s == "0") { break; }
		for (int i = 0; i < 8; i++) if (T[i] == s[1]) a++;
		for (int i = 0; i < 8; i++) if (T[i] == s[3]) b++;
		for (int i = 0; i < 8; i++) if (T[i] == s[5]) c++;
		cout << x[a][b][c] << endl;
	}
}


Measured memory_bytes: 3232
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int d,n,i,tmp=1;
	scanf("%d%d",&d,&n);
	while (d>0) {tmp*=100;d--;}
	int ans=0;
	if (n<=99) ans=tmp*n; else ans=tmp*101;
	printf("%d",ans);
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin>>n){
        int ans=0;
        for(int a=0; a<=9; a++){
            for(int b=0; b<=9; b++){
                for(int c=0; c<=9; c++){
                    int d=n-a-b-c;
                    if(0<=d&&d<=9) ++ans;
                }
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3140
[N,Y] = list(map(int,input().split()))

flag=0
for x in range(N+1):
    for y in range(N+1):
        if flag==1:
            break
        z = N - x - y
        if z in range(N+1) and 10000*x + 5000*y + 1000*z == Y:
            print(x,y,z)
            flag=1
            break


if flag==0:
    print('-1 -1 -1')

Measured memory_bytes: 41324
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

A=get_nsp
N=A.size
ab=Hash.new(0)
A.each do|a|
  ab[a]+=1
end
ans=N*(N-1)/2+1
ab.each do|k,v|
    ans-=v*(v-1)/2
end
puts ans

Measured memory_bytes: 24964
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <bitset>
#include <set>
#include <chrono>
#include <string>

using namespace std;

#define endl '\n'

long long solve(int n)
{
    long long a, b;
    cin >> a >> b;

    long long c = 0;

    if (n > 1)
    {
        c = solve(n - 1);
        a += c;
    }

    a %= b;

    if (a)
        c += b - a;

    return c;
}

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

    int n;
    cin >> n;

    cout << solve(n) << endl;

    return 0;
}

Measured memory_bytes: 3328
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int x,y;
    cin>>x>>y;
    int a[3] = {100000, 200000, 300000};
    x--, y--;
    int sum =0;
    //cout<<x<<y<<endl;
    if(x<=2){
        sum += a[2-x];
    }
    if(y<=2){
        sum += a[2-y]; 
    }
    if(x==0 && y==0)    sum += 400000;

    cout<<sum<<endl;
    return 0;
}



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

struct Edge {
  int src, dst, weight;
  Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};

using Graph = vector<vector<Edge>>;

main() {
  int N, M, L, K, A, H;
  while (cin >> N >> M >> L >> K >> A >> H, N) {
    Graph g(N);
    vector<int> canReitou(N); // V -> bool
    rep(i, L) {
      int x;
      cin >> x;
      canReitou[x] = true;
    }
    rep(i, K) {
      int u, v, c;
      cin >> u >> v >> c;
      g[u].emplace_back(u, v, c);
      g[v].emplace_back(v, u, c);
    }

    vector<vector<int>> dist(N, vector<int>(M + 1, INF));
    using state = tuple<int, int, int>;
    priority_queue<state, vector<state>, greater<state>> q;
    q.emplace(0, A, M);
    dist[A][M] = 0;
    while (q.size()) {
      int d, v, r;
      tie(d, v, r) = q.top();
      q.pop();
      if (dist[v][r] < d) continue;
      for (auto &&e : g[v]) {
        if (canReitou[v]) {
          loop(nr, r, M + 1) {
            if (nr - e.weight < 0) continue;
            if (dist[e.dst][nr - e.weight] > d + nr - r + e.weight) {
              dist[e.dst][nr - e.weight] = d + nr - r + e.weight;
              q.emplace(dist[e.dst][nr - e.weight], e.dst, nr - e.weight);
            }
          }
        } else {
          if (r < e.weight) continue;
          if (dist[e.dst][r - e.weight] > d + e.weight) {
            dist[e.dst][r - e.weight] = d + e.weight;
            q.emplace(dist[e.dst][r - e.weight], e.dst, r - e.weight);
          }
        }
      }
    }

    int ans = INF;
    rep(i, M + 1) ans = min(ans, dist[H][i]);
    if (ans == INF) {
      cout << "Help!" << endl;
    } else {
      cout << ans << endl;
    }
  }
}



Measured memory_bytes: 3616