akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<string>
#include<math.h>
#define pi 3.141592653589
#include<iomanip>
using namespace std;
#include<algorithm>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1e9
#define LINF 1e17
#define ll long long
#define MOD (int)(1e9+7)

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

ll kaijo(ll x,ll a){
    for(int i=x;i>1;i--){
        a*=i;
        a%=MOD;
    }
    return a;
}

int main(){
    
    ll n,m,ans;
    
    cin>>n>>m;
    if(abs(n-m)>1){
        ans=0;
    }
    else{
        ans=kaijo(n,1);
        ans=kaijo(m,ans);
        if(abs(n-m)==0)ans=kaijo(2,ans);
    }
    cout<<ans<<endl;
        
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

int main(){
  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());

  cout << (s < t ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
type = {}
(1..n).map {|i| type[i] = gets.chomp}
g = {}
(1..n).each {|i| g[i] = []}
(n - 1).times do
    i, j = gets.split.map(&:to_i)
    g[i] << j
end
def f(g, type, i)
    k = (type[i].size > 1 ? 1 : 0)
    if type[i][0] == ?A
        g[i].each do |j|
            k += f(g, type, j)
        end
    elsif type[i][0] == ?R
        k += g[i].map {|j| 1 + f(g, type, j)}.inject(:*) - 1
    elsif type[i][0] == ?E
        if g[i].empty?
            k += 1
        else
            k += g[i].map {|j| f(g, type, j)}.inject(:*)
        end
    end
    k % 1_000_000_007
end
p f(g, type, 1)



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

int main(){

 int n;
 long a, min = 1000000, max = -1000000, sum = 0;

 cin >> n;

 for (n; n > 0; n--) {
  cin >> a;
  if ( a > max) max = a;
  if ( a < min) min = a;
  sum += a;
 }

 cout << min << " " << max << " " << sum << "\n";

 return 0;
}

Measured memory_bytes: 1164
import sys
sys.setrecursionlimit(2000000)
n = int(input())
a=[[]for i in range(n)]
for i in range(n-1):
  x = int(input())
  x-=1
  a[x].append(i+1)
  
dp=[0]*n
ya = [[0,i] for i in range(n)]
def dfs(x,y):
  ya[x][0]=y
  for i in a[x]:
    dfs(i,y+1)
dfs(0,0)
ya.sort(key=lambda x:-x[0])
tmp=[]
for i in range(n):
  bb=ya[i][1]
  for j in a[bb]:
    tmp.append(dp[j])
  tmp.sort(key=lambda x:-x)
  dai =0
  for j in range(len(tmp),0,-1):
    cc=tmp.pop()
    cc+=j
    dai=max(dai,cc)
  dp[bb]=dai
print(dp[0])

Measured memory_bytes: 124432
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

vector<int> prime;
bool is_prime[10001];

void sieve(int n){
    rep(i, 0, n) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    rep(i, 2, n){
        if(is_prime[i]) prime. push_back(i);
        for(int j = 2 * i; j < n; j += i) is_prime[j] = false;
    } 
    return;
}

int d[10001];

signed main(){
    prime. push_back(0);
    sieve(10001);
    rep(i, 1, prime.size()){
        prime[i] += prime[i - 1];
    }
    rep(i, 0 ,prime.size()){
        rep(j, i + 1, prime.size()){
            int tmp = prime[j] - prime[i];
            if(tmp <= 10000) d[tmp]++;
        }
    }
    int n;
    while(cin >> n, n){
        cout << d[n] << endl;
    }
}

Measured memory_bytes: 1324
d=[(0,0,1),(-1,0,0),(0,1,0),(0,-1,0),(1,0,0),(0,0,-1)]
def crosspro(y,x):
    return (y[1]*x[2]-y[2]*x[1],y[2]*x[0]-y[0]*x[2],y[0]*x[1]-y[1]*x[0])
def north(r):
    res=[]
    for p in r:
        res.append((p[2],p[1],-p[0]))
    return res
def south(r):
    res=[]
    for p in r:
        res.append((-p[2],p[1],p[0]))
    return res
def east(r):
    res=[]
    for p in r:
        res.append((p[0],p[2],-p[1]))
    return res
def west(r):
    res=[]
    for p in r:
        res.append((p[0],-p[2],p[1]))
    return res
def left(r):
    res=[]
    for p in r:
        res.append((p[1],-p[0],p[2]))
    return res
def right(r):
    res=[]
    for p in r:
        res.append((-p[1],p[0],p[2]))
    return res
T=["","N","E","W","S","NN"]
U=["","L","LL","LLL"]
def change(S):
    D=d
    for i in S:
        if i=="N":
            D=north(D)
        elif i=="E":
            D=east(D)
        elif i=="W":
            D=west(D)
        elif i=="S":
            D=south(D)
        elif i=="L":
            D=left(D)
        else:
            D=right(D)
    return D
def same(c1,c2):
    for i in T:
        for j in U:
            D=change(i+j)
            flag=0
            for x in range(6):
                for y in range(6):
                    if d[x]==D[y]:
                        if c1[x]!=c2[y]:
                            flag=1
            if flag==0:
                return True
    return False
N=int(input())
c=[[int(i) for i in input().split()] for j in range(N)]
for i in range(N):
    for j in range(N):
        if i<j:
            if same(c[i],c[j]):
                print("No")
                exit()
print("Yes")



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

int main(){
	string S;
	int K;
	cin>>K>>S;
	if(S.size()<=K)cout<<S<<endl;
	else {
		for(int i=0;i<K;i++){
		cout<<S[i];
	}
		cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
long long n,a[5];
int main(){
	cin>>n>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	sort(a,a+5);
	long long b=(n/a[0]);
	if(((n%a[0])==0)&&(b!=0))b--;
	cout<<(5+b)<<endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef vector<pll> vpll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){

  string S, T;
  IN(S,T);
  ll ans = 0;
  REP(i,S.size()){
    if(S[i]==T[i]) ans++;
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  ll n;
  cin >> n;
  ll r = 0;
  for(int i = 1; i < n; i++) {
    r += n / i;
    if(0 < n / i && n % i == 0)
      r--;
  }
  cout << r << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int ans, rmd, idx = 1, rmds[2019] = { 1 };
string s;
int main()
{
	cin >> s;
	for (int i = s.length() - 1; i >= 0; i--)
	{
		rmd = (idx * (s[i] - '0') + rmd) % 2019;
		rmds[rmd]++;
		idx = idx * 10 % 2019;
	}
	for (int i = 0; i < 2019; i++)
	{
		ans += rmds[i] * (rmds[i] - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3716
# -*- coding: utf-8 -*-
#ABC142B
import sys
#sys.setrecursionlimit(100000)

#n=int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))
tmp = input().split()
h = list(map(lambda a: int(a), tmp))

count=0
for i in range(n):
	if(h[i]>=k):
		count+=1

print(count)

Measured memory_bytes: 11912
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, m;
	string s, t; cin>>s>>t;
	n=s.size(), m=t.size();
	int nx[26][100010];
	for(int i=0; i<26; i++) nx[i][n]=-1;
	for(int i=n-1; i>=0; i--){
		for(int j=0; j<26; j++) nx[j][i]=nx[j][i+1];
		nx[s[i]-'a'][i]=i+1;
	}
	for(int i=0; i<m; i++){
		if(nx[t[i]-'a'][0]==-1){
			cout<<-1<<endl;
			return 0;
		}
	}
	ll ans=nx[t[0]-'a'][0];
	for(int i=1; i<m; i++){
		if(nx[t[i]-'a'][(ans-1)%n+1]!=-1){
			ans+=nx[t[i]-'a'][(ans-1)%n+1]-((ans-1)%n+1);
		}else{
			ans=((ans-1)/n+1)*(ll)n+nx[t[i]-'a'][0];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <vector>
#include <algorithm>

class element
{
  public:
  int i;
  std::string s;
  int p;
};

int main()
{
  int N;
  std::cin >> N;
  
  std::vector<element *> resutoran;
  resutoran.reserve(N);
  
  for(int i=0; i<N;i++)
  {
    auto l = new element();
    l->i = i + 1;
    std::cin >> l->s >> l->p;
    resutoran.push_back(l);
  }
  
  std::sort(resutoran.begin(), resutoran.end(), []
            (const element * a, const element *  b) {
              return a->p > b->p;
            });
  
  std::stable_sort(resutoran.begin(), resutoran.end(), []
            (const element * a, const element *  b) {
              return a->s < b->s;
            });
  
  for(auto it=resutoran.begin(); it!=resutoran.end(); it++)
    std::cout << (*it)->i << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    string s1,s2;
    cin>>s1>>s2;
    ll i,ct=0;
    for(i=0;i<3;i++)
    {
        if(s1[i]==s2[i])
        {
            ct++;
        }
    }
    cout<<ct;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define task "close-vertices"
#define INF 2e9
#define fi first
#define se second
typedef long long ll;
ll n,m,ans;
int main()
{
	//freopen("c.cpp","r",stdin);

	cin>>n>>m;
	while(n<=m)
		ans++,n*=2;
	cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+10;
int a[N];
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
const funcA = (input: string): string => {
    switch (Number(input)) {
        case 22: return 'Christmas Eve Eve Eve'
        case 23: return 'Christmas Eve Eve'
        case 24: return 'Christmas Eve'
        case 25: return 'Christmas'
    }
}

const hoge: string = funcA(require('fs').readFileSync('/dev/stdin', 'utf8'));
console.log(hoge);

Measured memory_bytes: 7372
base' = cycle "#."
base  = [base'] ++ [tail base'] ++ base

chessBoard [h,w] = unlines $ take h $ map (take w) base

main = do
  s <- getLine
  let [h,w] = map read $ words s

  if [h,w] == [0,0] then return ()
  else do
    putStrLn $ chessBoard [h,w]
    main

Measured memory_bytes: 3928
using System;
using System.Linq;
using System.Windows.Markup;

class IDONTKNOWCSHARP
{

    public static void Main()
    {
        string str = Console.ReadLine();
    int a = str.IndexOf("A");
    int b = str.LastIndexOf("Z");

        Console.WriteLine((b-a)+1);
   //     Console.ReadLine();
    }


}

Measured memory_bytes: 26800
#include <bits/stdc++.h>
using namespace std;
int main (){
  int i,j,k;
  int s[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      cin>>s[i][j];
    }
  }
  int n,b;
  cin>>n;
  for(k=0;k<n;k++){
    cin>>b;
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
        if(s[i][j]==b)
          s[i][j]=0;
      }
    }
  }
  int f=0;
  for(i=0;i<3;i++){
    if(s[0][i]+s[1][i]+s[2][i]==0)
    f++;
    if(s[i][0]+s[i][1]+s[i][2]==0)
    f++;
    
  }
  if(s[0][0]+s[1][1]+s[2][2]==0)
    f++;
    if(s[2][0]+s[1][1]+s[0][2]==0)
    f++;
  if(f==0)
  cout<<"No"<<endl;
  else 
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 998244353;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
int h,w;
char maze[1001][1001];//迷路
int d[1001][1001];//最短距離の配列
vector<pair<int,int>> bl;
void bfs(int n){
    vector<queue<pair<int,int>>> q(n);
    REP(i,h) REP(j,w) d[i][j] = INF;
    rep(i,n){
        q[i].push(pair<int,int>(bl[i].fi,bl[i].se));
        d[bl[i].fi][bl[i].se] = 0;
    }
    
    int c = 0;
    while(1){
      //cerr << 1 << endl;
        c = 0;
        rep(i,n){
            if(q[i].size()){
              //cerr << 2 << endl;
                c = 1;
                pair<int,int> p = q[i].front();
                q[i].pop();
        //cerr << 3 << endl;
                REP(j,4){
                    int nx = p.fi + dx[j],ny = p.se + dy[j];
                  
                    if(0<=nx && nx<h && 0<=ny && ny< w && d[nx][ny] >= d[p.fi][p.se]+2){
                      //cerr << p.fi << " " << p.se << "->" << nx << " " << ny << endl;  
                      q[i].push(MP(nx,ny));
                      //cerr << "a"<<endl;
                        d[nx][ny] = d[p.fi][p.se] + 1;
                    }
                }
                
            }
        }
        if(c == 0)break;
    }
}
signed main(){
    cin >> h >> w;
    int cnt = 0;
    rep(i,h){
        rep(j,w){
            cin >> maze[i][j];
            if(maze[i][j] == '#'){
                cnt++;
                bl.pb(MP(i,j));
            }
        }
    }
    if(cnt == h*w){
        cout << 0 << endl;
        return 0;
    }

    bfs(cnt);

    int ans = 0;
    rep(i,h)rep(j,w)ans = max(ans,d[i][j]);
    cout << ans << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://agc033.contest.atcoder.jp/tasks/agc033_a

Measured memory_bytes: 436836
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC083
{
    class SugarWater
    {
        public static void Main()
        {
            var param = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray();
            var a = param[0]; var b = param[1]; var c = param[2]; var d = param[3]; var e = param[4]; var f = param[5];
            var beaker = CalDensity(a, b, c, d, e, f);
            WriteLine($"{beaker.Weight} {beaker.Sugar}");
        }
        static Beaker CalDensity(int A, int B, int C, int D, int E, int F)
        {
            var best = new Beaker();
            for (var beaker = new Beaker(); beaker.Weight <= F; beaker = beaker.AddWater(A)) {
                for (var water = beaker; water.Weight <= F; water = water.AddWater(B)) {
                    for (var sugar = water; sugar.Weight <= F && sugar.Percentage <= E; sugar = sugar.AddSugar(C)) {
                        for (var last = sugar; last.Weight <= F && last.Percentage <= E; last = last.AddSugar(D)) {
                            best = best.ChoiceBetter(last);
                        }
                    }
                }
            }
            return best;
        }
        class Beaker
        {
            public Beaker() { Water = 0; Sugar = 0; }
            private  Beaker(int w, int s) { Water = w; Sugar = s; }
            public int Water { get; private set; }
            public int Sugar { get; private set; }
            public int Weight { get { return Water + Sugar; } }
            public Beaker AddWater(int n)
            {
                return new Beaker(Water + 100 * n, Sugar);
            }
            public Beaker AddSugar(int n)
            {
                return new Beaker(Water, Sugar + n);
            }
            public int Percentage
            {
                get { return (Water == 0) ? 100 : (Sugar + Water / 100 - 1) / (Water / 100); }
            }
            public Beaker ChoiceBetter(Beaker other)
            {
                return (other.Water == 0 || other.Water * this.Sugar > other.Sugar * this.Water) ? this : other;
            }
        }
    }
}


Measured memory_bytes: 15424
#include<iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int p[N];
  for(int i=0;i<N;i++){
    cin >> p[i];
  }
  
  int c=0;
  int i=0;
  while(i<N-1){
    if(p[i+1]==p[i]+1){
      i++;
    }else{
      c++;
      p[i+1]=i+2;
      i++;
    }
  }
  if(c==0||c==2){
    cout << "YES";
  }else{
    cout << "NO";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

int main(void) {                                                                                                                                                                                     long long n;

        cin >> n;

        vector<int> count;
        do {
                int mod = n % 26;                                                                                                                                                                            if (mod == 0) {                                                                                                                                                                                      count.push_back(25);
                        n = (n-26) / 26;
                } else {
                        count.push_back(mod-1);
                        n = (n-mod) / 26;                                                                                                                                                                    }                                                                                                                                                                                    } while(n);                                                                                                                                                                                                                                                                                                                                                                               char ch[26];
        for (int i = 0; i < 26; i++) {
                ch[i] = i+'a';
        }
        for (auto it = count.rbegin(); it < count.rend(); it++) {
                printf("%c", ch[*it]);
        }
        cout << endl;


        return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> a >> b;
  if(a <= 9 && b <= 9) cout << (a * b) << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	int to,cost;
};

struct Data{
	Data(int arg_node_id,int arg_cost_sum){
		node_id = arg_node_id;
		cost_sum = arg_cost_sum;
	}
	bool operator<(const struct Data &arg) const{
		return cost_sum > arg.cost_sum;
	};
	int node_id,cost_sum;
};

int main(){

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

	if(N == 1){
		printf("0\n");
		return 0;
	}

	int* min_dist = new int[N];

	vector<Info> V[N];

	int from,to,cost;

	for(int i = 0; i < N-1; i++){
		scanf("%d %d %d",&from,&to,&cost);
		V[from].push_back(Info(to,cost));
		V[to].push_back(Info(from,cost));
	}

	min_dist[0] = 0;
	for(int i = 1; i < N; i++)min_dist[i] = BIG_NUM;

	priority_queue<Data> Q;

	for(int i = 0; i < V[0].size();i++){
		min_dist[V[0][i].to] = V[0][i].cost;
		Q.push(Data(V[0][i].to,V[0][i].cost));
	}

	int index;
	while(!Q.empty()){
		if(Q.top().cost_sum > min_dist[Q.top().node_id]){
			Q.pop();
		}else{
			index = Q.top().node_id;
			Q.pop();

			for(int i = 0; i < V[index].size();i++){
				if(min_dist[V[index][i].to] > min_dist[index]+V[index][i].cost){
					min_dist[V[index][i].to] = min_dist[index]+V[index][i].cost;
					Q.push(Data(V[index][i].to,min_dist[V[index][i].to]));
				}
			}
		}
	}

	int maximum = -1,max_index;
	for(int i = 1; i < N; i++){
		if(maximum < min_dist[i]){
			maximum = min_dist[i];
			max_index = i;
		}
	}

	for(int i = 0; i < N; i++)min_dist[i] = BIG_NUM;
	min_dist[max_index] = 0;

	for(int i = 0; i < V[max_index].size();i++){
		min_dist[V[max_index][i].to] = V[max_index][i].cost;
		Q.push(Data(V[max_index][i].to,V[max_index][i].cost));
	}

	while(!Q.empty()){
		if(Q.top().cost_sum > min_dist[Q.top().node_id]){
			Q.pop();
		}else{
			index = Q.top().node_id;
			Q.pop();

			for(int i = 0; i < V[index].size();i++){
				if(min_dist[V[index][i].to] > min_dist[index]+V[index][i].cost){
					min_dist[V[index][i].to] = min_dist[index]+V[index][i].cost;
					Q.push(Data(V[index][i].to,min_dist[V[index][i].to]));
				}
			}
		}
	}

	int ans = -1;
	for(int i = 0; i < N; i++)ans = max(ans,min_dist[i]);

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

	return 0;
}

Measured memory_bytes: 9884
import * as fs from 'fs';

namespace AtCoder.abc132 {

    export class ProgramB {
        args: string[];

        constructor(args: string[]) {
            this.args = args;
        }

        /**
         * in
         * 5
         * 1 3 5 4 2
         * out
         * 2
         */
        main(this: ProgramB): void {

            const n = parseInt(this.args[0]);
            const p: number[] = this.args[1].split(' ').map(Number);
            const ans: number = p.reduce((acc: number, cur: number, idx: number) => {
                if (idx === 0) return acc;
                if (idx === n - 1) return acc;
                if (p[idx] > p[idx - 1] && p[idx] < p[idx + 1]) return acc + 1;
                if (p[idx] < p[idx - 1] && p[idx] > p[idx + 1]) return acc + 1;
                return acc;
            }, 0);

            console.log(ans);

        }
    }
}

const args = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const prg = new AtCoder.abc132.ProgramB(args);
prg.main();


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
 
int main() {
  string s;
  cin >> s;
  int count=0;
  if(s=="RRR") count=3;
  if(s=="RRS") count=2;
  if(s=="RSR") count=1;
  if(s=="RSS") count=1;
  if(s=="SRR") count=2;
  if(s=="SRS") count=1;
  if(s=="SSR") count=1;
  if(s=="SSS") count=0;
  /*bool rain=false;
  if(s[0]=='R'){
    count++;
    rain=true;
    if(s[1]=='R' && rain==true){
      count++;
      rain=true;
      if(s[2]=='R' && rain==true){
        count++;
      }
      else
    rain=false;
    }
  else
    rain=false;
  }*/
  cout << count << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstring>
using namespace std;
#define mod 1000000007
typedef long long ll;
const int maxn = 1e6 + 5;
ll fac[2 * maxn], inv[2 * maxn];
int k, len;
ll qpow(ll a, ll b)
{
	ll res = 1;
	while (b)
	{
		if (b & 1)
		{
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		b /= 2;
	}
	return res % mod;
}
void init()
{
	fac[0] = 1;
	for (int i = 1; i <= len + k; i++)
	{
		fac[i] = fac[i - 1] * i % mod;
	}
	inv[len + k] = qpow(fac[len + k], mod - 2);
	for (int i = len + k - 1; i >= 0; i--)
	{
		inv[i] = inv[i + 1] * (i + 1) % mod;
	}
}
ll C(int m, int n)
{
	return  fac[m] * inv[m - n] % mod * inv[n] % mod;
}
int main()
{
	ios::sync_with_stdio(false);
	char s[maxn];
	cin >> k >> s;
	len = strlen(s);
	init();
	ll ans = 0;
	for (int i = 0; i <= k; i++)
	{
		ans = (ans + qpow(26, i) * C(k + len - i - 1, len - 1) % mod * qpow(25, k - i) % mod) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35804
fun main(args: Array<String>) {
    var (N, K) = readLine()!!.split(" ").map { it.toInt() }
    val H = readLine()!!.split(" ").map { it.toInt() }
    var ans = 0L
    H.sortedDescending().forEach {
        if (K>0) {
            K--
        } else {
            ans += it
        }
    }
    println(ans)
}


Measured memory_bytes: 83656
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for (auto &e: a) {
        cin >> e;
        e--;
    }
    for (auto &e: b) cin >> e;
    for (auto &e: c) cin >> e;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += b[a[i]];
        if (i != 0 && a[i-1] == a[i]-1) {
            ans += c[a[i-1]];
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    // データ数Nを取得
    int n;  std::cin >> n;
    std::vector<int> input_a(n);

    // A_nについて、何回２で割れるかカウント→要素としてvectorに格納
    for (int i = 0; i < n; i++) {
        int a_i;  std::cin >> a_i;
        int counter = 0;
        while (!(a_i % 2)) {
            a_i /= 2;  // 除算代入　a_i = a_i / 2
            counter += 1; 
        }
        input_a.at(i) = counter;
    }
    
    int min;  min = *min_element( input_a.begin(), input_a.end() );
    printf("%d\n", min);

    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, M;
ll X[MAX_N] = {};
ll Y[MAX_N] = {};

int main()
{
    cin >> N >> M;
    REP(i, N) { cin >> X[i]; }
    REP(i, M) { cin >> Y[i]; }

    // 部分線の全パターンを足したもの
    ll ans_x = 0, ans_y = 0;
    REP(i, N) {
        ans_x = (ans_x + (X[i] * i)) % MOD;
        ans_x = (ans_x - (X[i] * (N - 1 - i)) + MOD) % MOD;
    }
    REP(i, M) {
        ans_y = (ans_y + (Y[i] * i)) % MOD;
        ans_y = (ans_y - (Y[i] * (M - 1 - i)) + MOD) % MOD;
    }
    printf("%lld\n", (ans_x * ans_y) % MOD);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main() {
    string S;
    cin >> S;

    vector<string> cand(4);
    cand[0] = "dream";
    cand[1] = "dreamer";
    cand[2] = "erase";
    cand[3] = "eraser";

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) reverse(cand[i].begin(), cand[i].end());

    int pos = 0;
    while (pos < S.size()) {
        bool cannot = 1;
        for (int i = 0; i < 4; i++) {
            if (S.substr(pos, cand[i].size()) == cand[i]) {
                pos += cand[i].size();
                cannot = 0;
                break;
            }
        }
        if (cannot) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

ll mod = 998244353;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

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

class combination{
public:
    vector<mint> fact,inv,finv;
    combination(int N){
        fact = inv = finv = vector<mint>(N+1);
        fact[0] = fact[1] = 1;
        inv[0] = inv[1] = 1;
        finv[0] = finv[1] = 1;
        for(ll i=2;i<=N;i++){
            fact[i] = fact[i-1]*i;
            inv[i] = (mint) mod - inv[mod%i]*(mod/i);
            finv[i] = finv[i-1]*inv[i];
        }
    }
    mint f(int i){
        return fact[i];
    }
    mint comb(int n,int k){
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fact[n]*finv[k]*finv[n-k];
    }
    mint hcomb(int n,int k){
        if(n==0 && k==0) return 1;
        return comb(n+k-1,k);
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll M,N,K;
    cin >> M >> N >> K;
    mint ans = ((mint) M).pow(N);
    vec<mint> A(K+1);
    combination C(K);
    for(int i=1;i<min(M+1,K);i++){
        mint now = ((mint) i).pow(N);
        for(int j=1;j<i;j++) now -= A[j]*C.comb(i,j);
        A[i] = now;
        for(int j=0;j<i;j++){
            now *= (M-j)%mod;
            now /= (j+1);
        }
        ans -= now;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 3252
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
setrecursionlimit(1000000)

# INF = float('inf')
INF = int(1e10)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()

    # 番兵
    # if A[0] != 0:
    A.append(K + A[0])

    # min, maxまでの和
    dist = A[-1] - A[0]

    # remove max diff
    diff = 0
    for i in range(len(A) - 1):
        diff = max(diff, A[i + 1] - A[i])
    # print(A)
    # print(dist)
    # print(diff)
    print(dist - diff)


if __name__ == '__main__':
    main()

Measured memory_bytes: 73204
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> ii;

const int MAXN = 100000;

int N, E, num[MAXN], low[MAXN], cnt = 1;
bool vis[MAXN];
vector<int> adjList[MAXN];
vector<ii> ans;
 
void dfs(int u, int par) {
    vis[u] = true;
    low[u] = num[u] = cnt++;
    for (int i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];

        if (!vis[v]) {
            dfs(v, u);
            if (low[v] > num[u]) {
                int s = min(v, u);
                int t = max(v, u);
                ans.push_back(ii(s,t));
            }
            low[u] = min(low[u], low[v]);
        }
        else if (v != par) low[u] = min(low[u], num[v]);
    }
}
     
 
int main() {

    scanf("%d%d",&N,&E);
    for (int i = 0, u, v; i < E; i++) {
        scanf("%d%d",&u,&v);

        adjList[u].push_back(v);
        adjList[v].push_back(u);
    }
 
    dfs(0, 0);
 
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++)
        printf("%d %d\n", ans[i].first, ans[i].second);

    return 0;
}

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template <class T>
struct Knapsack {
    vector<T> weight;
    vector<T> value;
    int N;

    Knapsack(vector<T> weight_, vector<T> value_) : weight(weight_), value(value_){
        N = weight_.size();
    }; 

    vector<vector<T>> one_limited(T max_weight) {
        vector<vector<T>> dp(N + 1, vector<T>(max_weight+1, 0));
        for(int i = 0; i < N; i++) {
            for(int j = max_weight; j >= 0; j--) {
                if(j - weight[i] >= 0) chmax(dp[i+1][j], dp[i][j - weight[i]] + value[i]);
                chmax(dp[i+1][j], dp[i][j]);
            }
        }
        return dp;
    }

    vector<vector<T>> non_limited(T max_weight) {
        vector<vector<T>> dp(N + 1, vector<T>(max_weight + 1, 0));
        for(int i = 0; i < N; i++) {
            for(int j = 0; j <= max_weight; j++) {
                if(j - weight[i] >= 0) chmax(dp[i+1][j], dp[i+1][j - weight[i]] + value[i]);
                chmax(dp[i+1][j], dp[i][j]);
            }
        }
        return dp;
    }
};

int main(){
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(int i = 0; i < N; i++) cin >> v[i] >> w[i];
    Knapsack<ll> dp(w, v);
    cout << dp.non_limited(W)[N][W] << endl;
}


Measured memory_bytes: 10792
#!/usr/bin/env ruby

K = 64

def main(argv)
  (a, b) = gets.chomp.split(' ').map(&:to_i)
  
  v = (1..K).to_a.map{|i| (d, m) = a.divmod(1 << i); {:b => 1 << i, :d => d, :m => m}}
  u = (1..K).to_a.map{|i| (d, m) = b.divmod(1 << i); {:b => 1 << i, :d => d, :m => m}}
  
  t = [0] * K
  K.times do |i|
    x = 0
    if v[i][:m] >= (v[i][:b] / 2) then
      x = v[i][:b] - v[i][:m]
    else
      if (b - a) < v[i][:b] then
        x = 0
      else
        x = v[i][:b] / 2
      end
    end
    
    y = 0
    if u[i][:m] >= (u[i][:b] / 2) then
      y = u[i][:m] - (u[i][:b] / 2) + 1
    end
    
    t[i] = (x + y) % 2
  end
  
  t[0] = (t[0] + [u[0][:d] - v[0][:d] - 1, 0].max) % 2
  
  puts t.reverse.join('').to_i(2).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
vector<int> v[60];
bool vis[60];
void DFS(int x,bool first,int to){
	if(vis[x]==true)return;
	vis[x]=true;
	lol(i,v[x].size()){
		if(first&&v[x][i]==to)continue;
		DFS(v[x][i],false,to);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	lol(i,m){
		int a,b;cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int ans=0;
	lol(i,n){
		lol(j,v[i].size()){
			lol(k,n)vis[k]=false;
			DFS(i,true,v[i][j]);
			if(vis[v[i][j]]==false){
				ans++;
			}
		}
	}
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a0(n), b0(n);
    for(int i = 0; i < n; ++i){
        cin >> a0.at(i);
    }
    for(int i = 0; i < n; ++i){
        cin >> b0.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < 30; ++i){
        const ll m = 1 << i;
        vector<ll> a(n), b(n);
        for(int j = 0; j < n; ++j){
            a.at(j) = a0.at(j) % (2 * m);
            b.at(j) = b0.at(j) % (2 * m);
        }
        sort(b.begin(), b.end());
        ll tmp = 0;
        for(ll x : a){
            ll i1 = lower_bound(b.begin(), b.end(), m - x) - b.begin();
            ll i2 = lower_bound(b.begin(), b.end(), 2 * m - x) - b.begin();
            ll i3 = lower_bound(b.begin(), b.end(), 3 * m - x) - b.begin();
            tmp += i2 - i1 + n - i3;
        }
        if(tmp % 2){
            ans += (1 << i);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8500
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
ll mod = 1e9+7;

int main(){
	string t,b;
	cin>>t>>b;
	ll n1 = t.size(),n2 = b.size();
	vector<vector<ll > > dp(n1,vector<ll> (n2,0) );
	for(int i=0;i<n1;i++){
		if(t[i]==b[0])	dp[i][0] = 1;
	}
	if(n1 < n2){
		cout<<0<<endl;
		return 0;
	}
	for(int i=1;i<n2;i++){
		ll sum = 0;
		for(int j=0;j<i;j++) {
			sum+=dp[j][i-1];
			sum%=mod;
		}
		for(int j=i;j<n1;j++){
			if(t[j]==b[i]) {
				dp[j][i] = sum;
			}
			sum+=dp[j][i-1];
			sum%=mod;
		}
	}
	ll res = 0;
	/*for(int i=0;i<n2;i++){
		for(int j=0;j<n1;j++){
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
	}*/
	for(int i=0;i<n1;i++) {
		res += dp[i][n2-1];
		res %= mod;
	}
	cout<<res<<endl;
	return 0;
}




Measured memory_bytes: 10876
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    if(N%10==9) {
        cout << "Yes" << endl;
    } else if(N/10==9) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

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

int main() {
    vector<char> S(6);

    for(int i = 0;i < 6;i++) {
        cin >> S.at(i);
    }
    if(S.at(2) == S.at(3) && S.at(4) == S.at(5))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for _ in range(d)]
ans = 1001
for i in range(1<<d):
    count, score, left = 0, 0, 0
    for j in range(d):
        if (i >> j) & 1:
            score += (j+1)*100*pc[j][0] + pc[j][1]
            count += pc[j][0]
        else: left = j
    for j in range(pc[left][0]):
        if score >= g: break
        score += (left+1)*100
        count += 1
    if score >= g: ans = min(ans, count)
print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>

int main(int argc, char* argv[])
{
  int N;
  std::vector< int > a;

  std::cin >> N;
  for (int i = 0; i < N; i++) {
    int tmp;
    std::cin >> tmp;
    a.push_back(tmp);
  }

  std::sort(a.begin(), a.end());
  std::reverse(a.begin(), a.end());

  std::vector< int >::iterator it;

  int number = 0;
  int sum[2] = {0, 0};
  
  for (it = a.begin(); it != a.end(); it++) {
    sum[number] += *it;
    number = number == 0 ? 1 : 0;
  }

  std::cout << sum[0] - sum[1] << std::endl;
  
  return 0;
}


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

#define llint long long int

using namespace std;

int main()
{
    llint a, b, c, d;

    cin >> a >> b >> c >> d;

    llint max = a * c;

    if (a * d > max)
    {
        max = a * d;
    }
    if (b * c > max)
    {
        max = b * c;
    }
    if (b * d > max)
    {
        max = b * d;
    }
    cout << max << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repeq(i,a,b) for(int i=a;i<=(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
const ll MOD=1e9+7;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, s,t;
    cin >> n >> m >> s >> t;
    --s, --t;
    vector<vector<pair<int,ll>>> g(n);
    rep(i,0,m) {
        int u, v;
        ll c;
        cin >> u >> v >> c;
        --u, --v;
        g[u].emplace_back(v,c);
        g[v].emplace_back(u,c);
    }
    const ll INFTY=LLONG_MAX;
    vector<ll> dist(n,INFTY);
    priority_queue<tuple<ll,int,int>> qu;
    qu.emplace(0,s,-1);
    vector<vi> backs(n);
    vi ord;
    while(!qu.empty()) {
        int u, pr;
        ll d;
        tie(d,u,pr) = qu.top();
        qu.pop();
        d=-d;
        if(d<dist[u]) {
            backs[u].push_back(pr);
            ord.push_back(u);
            dist[u]=d;
            for(auto e:g[u]) {
                qu.emplace(-d-e.second,e.first,u);
            }
        }
        else if(d==dist[u]) {
            backs[u].push_back(pr);
        }
    }
    vector<ll> posr(n,0);
    vector<bool> relev(n);
    posr[t]=1;
    relev[t]=true;
    assert(sz(ord)==n);
    for(int i=n-1;i>=0;--i) {
        int u = ord[i];
        if(!relev[u]) continue;
        for(auto v:backs[u]) {
            if(v!=-1) {
                posr[v]=(posr[v]+posr[u])%MOD;
                relev[v]=true;
            }
        }
    }
    vector<ll> posl(n,0);
    posl[s]=1;
    rep(i,0,n) {
        int u=ord[i];
        if(!relev[u]) continue;
        for(auto v:backs[u]) {
            if(v==-1 || !relev[v]) continue;
            posl[u] = (posl[u]+posl[v])%MOD;
        }
    }
    ll tot=posr[s], ans=0;
    //debug(tot);
    ll time=dist[t];
    rep(u,0,n) {
        if(!relev[u]) continue;
        if(dist[u]*2==time) {
            ll x = (posl[u]*posr[u])%MOD;
            ans=(ans+(x*(tot-x+MOD)%MOD)%MOD)%MOD;
        }
        for(auto e:g[u]) {
            int v=e.first;
            if(!relev[v] || dist[v]!=dist[u]+e.second) continue;
            if(2*dist[u]<time && time<2*dist[v]) {
                ll x = (posl[u]*posr[v])%MOD;
                ans=(ans+(x*(tot-x+MOD)%MOD)%MOD)%MOD;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 23788
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N, K;
    cin >> N >> K;
    i32 sum = 0;
    for (i32 i = 0; i < N; i++) {
        i32 h;
        cin >> h;
        if (h >= K) sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,m;
    cin>>n>>m;
    vi dp(1<<n,INF);
    dp[0]=0;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        int x=0;
        REP(j,b){
            int c;cin>>c;
            x|=1<<(c-1);
        }
        REP(j,1<<n){
            chmin(dp[j|x], dp[j]+a);
        }
    }
    const auto& en=dp[(1<<n)-1];
    if(en==INF){
        cout<<-1<<endl;
    }else{
        cout<<en<<endl;
    }

}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func get_int(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := range as {
		as[i] = get_int(sc)
	}

	i := len(as) - 1
	ans := make([]string, 0)
	for i >= 0 {
		ans = append(ans, strconv.Itoa(as[i]))
		i -= 2
	}
	if i == -1 {
		i = 0
	} else {
		i = 1
	}
	for i < len(as) {
		ans = append(ans, strconv.Itoa(as[i]))
		i += 2
	}
	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 21504