akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100000
#define NIL -1

typedef struct {
  int p;
  int left;
  int right;
}Node;

Node T[MAX];
int depth[MAX];

void print(int id){
  int i,left;
  printf("node %d: ",id);
  printf("parent = %d, ",T[id].p);
  printf("depth = %d, ",depth[id]);
  if(T[id].p == NIL) printf("root, ");
  else if(T[id].left == NIL) printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i = 0,left = T[id].left;left != NIL;++i,left = T[left].right){
    if(i) printf(", ");
    printf("%d",left);
  }
  printf("]\n");
}

void rec(int id ,int p){
  depth[id] = p;
  if(T[id].right != NIL){
    rec(T[id].right,p);
  }
  if(T[id].left != NIL){
    rec(T[id].left,p + 1);
  }
}

int main(){
  int k,id,c,left,root,n,i,j;
  scanf("%d",&n);
  for(i = 0;i < n;++i){
    T[i].p = T[i].left = T[i].right = NIL;
  }
  for(i = 0;i < n;++i){
    scanf("%d%d",&id,&k);
    for(j = 0;j < k;++j){
      scanf("%d",&c);
      if(j == 0){
        T[id].left = c;
      }
      else{
        T[left].right = c;
      }
      left = c;
      T[c].p = id;
    }
  }
  
  for(i = 0;i < n;++i){
    if(T[i].p == NIL){
      root = i;
    }
  }
  
  rec(root,0);
  
  for(i = 0;i < n;++i){
    print(i);
  }
  return 0;
}



Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define push_back pb
#define make_pair mp
using ll = long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2e5+10;

string s, t;

void solve()
{
	int ans = 0;
	for(int i=0; i<3; ++i){
		if(s[i]==t[i]) ans++;
	}
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> s >> t;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, bool> is;
	for(int i=0; i<n; i++){
		cin >> a[i];
		is[a[i]] ^= true;
	}
	sort(a.begin(),a.end());
	int num=0, prev=0;
	for(int i=0; i<n; i++){
		if(a[i]!=prev && is[a[i]])
			num++;
		prev=a[i];
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 5376
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();

            Console.WriteLine((N - 2) * 180);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

int main(){
    int N, K; cin >> N >> K;
    int R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    
    int ans = 0;
    rep(i, K){
        int dp[100005][3];
        dp[i][0] = 0;
        dp[i][1] = 0;
        dp[i][2] = 0;
        if (T[i] == 'r') dp[i][2] = P;
        else if (T[i] == 's') dp[i][0] = R;
        else dp[i][1] = S;
        int j = i;
        for (; j<N; j+=K){
            if (j == i) continue;
            if (T[j] == 'r'){
                dp[j][0] = max(dp[j-K][1], dp[j-K][2]);
                dp[j][1] = max(dp[j-K][0], dp[j-K][2]);
                dp[j][2] = max(dp[j-K][0], dp[j-K][1]) + P;
            } else if (T[j] == 's'){
                dp[j][0] = max(dp[j-K][1], dp[j-K][2]) + R;
                dp[j][1] = max(dp[j-K][0], dp[j-K][2]);
                dp[j][2] = max(dp[j-K][0], dp[j-K][1]);
            } else {
                dp[j][0] = max(dp[j-K][1], dp[j-K][2]);
                dp[j][1] = max(dp[j-K][0], dp[j-K][2]) + S;
                dp[j][2] = max(dp[j-K][0], dp[j-K][1]);
            }
        }
        ans += max(max(dp[j-K][0], dp[j-K][1]), dp[j-K][2]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1664
k = int(input())
a = []

def lun(x,y,z): # xが一つ前の桁の数字 yがここまでの仮のルンルン数 zが桁数
  if z == 1:
    if x != 0:
      a.append(y+x-1)
    a.append(y+x)
    if x != 9:
      a.append(y+x+1)
  else:
    if x != 0: 
      b = y + (x-1)*(10**(z-1))
      lun(x-1,b,z-1)
    b = y + x*(10**(z-1))
    lun(x,b,z-1)
    if x!= 9:
      b = y + (x+1)*(10**(z-1))
      lun(x+1,b,z-1)

# 1桁のルンルン数
for i in range(1,10):
  a.append(i)

for j in range(2,11):
  for i in range(1,10):
    lun(i,i*(10**(j-1)),j-1)

print(a[k-1])

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

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

    for( int i = 1; ; ++i ){
        int cnt = 0;
        for( int j = 1; j < i+1; ++j ){
            if( i % j == 0 ) ++cnt;
        }
        if( cnt == N ){
            cout << i << endl;
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>

int main() {
	long state[2001];
	memset(state, 0, 2001 * sizeof(long));
	int i, j, n;
	long c;
	for (i = 0; i <= 1000; i++) {
		for (j = 0; j <= 1000; j++) {
			state[i+j]++;
		}
	}

	while(1) {
		c = 0;
		if(scanf("%d", &n) == EOF) {
			break;
		}
		for (i = 0; i <= 1000; i++) {
			if (n - i < 0) {
				break;
			}
			for (j = 0; j <= 1000; j++) {
				if (n - i - j < 0) {
					break;
				}
				if (n - i - j >= 2001) {
					continue;
				}
				c += state[n - i - j];
			}
		}
		printf("%ld\n", c);
	}

	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    if(n % 2 == 1){
        p(0);
    }else{
        ll ans = 0;
        n /= 2;
        while(true){
            if(n == 0)break;
            ans += n / 5;
            n /= 5;
        }
        p(ans);
    }

    return 0;
}















Measured memory_bytes: 38784
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, X;
  std::cin >> N >> X;
  std::vector<i64> m;
  tools::read(m, N);

  std::cout << N + (X - std::accumulate(m.begin(), m.end(), static_cast<i64>(0))) / *std::min_element(m.begin(), m.end()) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int arr[205];
int main()
{
int n=D(),c=0;
for(int i=0;i<n;++i){
    arr[i]=D();
    if(arr[i]%2!=0)
        c++;
}
if(c!=0){
    cout<<0<<endl;
    return 0;
}
int c1=1;
for(int i=0;i<n;++i){
for(int j=0;j<n;++j){
    arr[j]/=2;
    if(arr[j]%2)
    {
     cout<<c1<<endl;
     return 0;
    }
}
c1++;
}
cout<<c1+1<<endl;
}



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

int main() {
  int n, m;
  cin >> n >> m;
  long long cntday = 0;
  for (int i = 0; i < m; i++) {
    int day;
    cin >> day;
    cntday += day;
  }
	int ans=n-cntday;
  cout << max(-1, ans) << endl;
}


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

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

  int result = 0;

  for(int i = 0; i < N; i++){

    int li , ri;
    cin >> li >> ri;

    result += ri - li + 1;

  }

  cout << result << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    if(b > c){
        t = b;
        b = c;
        c = t;
    }
    if(a > b){
        t = a;
        a = b;
        b = t;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
  int n,i,o1=0,o2=0;
  string s;
  cin >> n >> s;
  for (i=0;i<n;i++){
    if (s[i]==')'){
      if (o1>0) o1--;
      else o2++;
    }else o1++;
  }
  for (i=0;i<o2;i++) cout << '(';
  cout << s;
  for (i=0;i<o1;i++) cout << ')';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 1010
#define M 1010

int main(void){
  int i,num,j,jj;
  char ch[N];
  int count,wcount;
  int locm[M]={0},lenm[M]={0};

  for(i=0;scanf("%c",&ch[i])==1;i++){}
  num=i;
  count=0;
  wcount=0;
  for(i=0;i<num;i++){
    if(ch[i]==' ' ||
        ch[i]=='.' ||
        ch[i]==','){
      if(3<=count && count<=6){
        wcount++;
        locm[i-count]=i-count;
        lenm[i-count]=count;
      }
      count=0;
    }else{
      count++;
    }
  }
  for(i=0,jj=0;i<num;i++){
    if(lenm[i]>0){
      for(j=locm[i];j<locm[i]+lenm[i];j++){
        printf("%c",ch[j]);
        
      }
      if(jj<wcount-1){
        printf(" ");
        jj++;
      }
    }
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 0
// atcoder/abc131/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  string s;
  while (cin >> s) {
    bool f = false;
    for (int i = 0; i + 1 < s.size(); ++i) {
      f = f || (s[i] == s[i + 1]);
    }
    cout << (!f ? "Good" : "Bad") << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main(){
    int L,R,d;

    cin >> L >> R >> d;

    int ans = 0;

    for(int i = L;i <= R;i++){
        if(i % d == 0)ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3180
from math import pi, cos
import math
s=input()	.split(" ")
a=float(s[0])
b=float(s[1])
h=float(s[2])
m=float(s[3])
mm=float(6*m)
gg=float((h*60+m)/2)
alf=float(abs(gg-mm))
if(alf>180):
	alf-=180
	alf=180-alf
alf=float(alf*pi/180)
x=a*a+b*b-a*b*2*cos(alf)
print("{:.12f}".format(math.sqrt(x)))


Measured memory_bytes: 9464
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll N = 2000000LL + 2LL;
const ll M = static_cast<ll>(1e9) + 7LL;

int main()
{
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    vector<ll> fact(N, 0);
    vector<ll> finv(N, 0);
    vector<ll> inv(N, 0);

    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1]  = 1;

    for (ll i=2;i<N;++i)
    {
        fact[i] = (i * fact[i - 1]) % M;
        inv[i]  = M - (inv[M % i] * (M / i)) % M;
        finv[i] = (finv[i - 1] * inv[i]) % M;
    }

    const auto ncr = [&](ll n, ll r)
    {
        return (fact[n] * ((finv[r] * finv[n - r]) % M)) % M;
    };

    const auto sum = [&](ll x, ll y)
    {
        ll res = 0;
        for (ll i=0;i<x+1;++i) { res = (res + ncr(y + i + 1, y)) % M; }
        return res;
    };

    const ll a = sum(r2, c2);
    const ll b = sum(r1 - 1, c2);
    const ll c = sum(r2, c1 - 1);
    const ll d = sum(r1 - 1, c1 - 1);

    const ll ans = (a + d - b - c + 4 * M) % M;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 47104
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int a=0;
  for(int i=0;i<3;i++){
    if(s[i] == 'o'){
      a++;
    }
  }
  cout<<a*100+700<<'\n';
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <stack>
#include <queue>
#include <deque>
using namespace std;

int n, r;
vector<int> cs;
int main() {
    while (cin >> n >> r) {
        cs.clear();
        for (int i = 0; i < r; i++) {
            int c; cin >> c; cs.push_back(c);
        }

        vector<int> deck(n);
        for (int i = 0; i < n; i++) deck[i] = i;
        for (int i = 0; i < cs.size(); i++) {
            int c = cs[i];
            queue<int> A, B;
            for (int i = n/2; i < n; i++) A.push(deck[i]);
            for (int i = 0; i < n/2; i++) B.push(deck[i]);
            deck.clear();

            while (!A.empty() || !B.empty()) {
                for (int j = 0; j < c; j++) {
                    if (A.empty()) break;
                    deck.push_back(A.front()); A.pop();
                }
                for (int j = 0; j < c; j++) {
                    if (B.empty()) break;
                    deck.push_back(B.front()); B.pop();
                }
            }
        }

        cout << deck.back() << endl;
    }
    return 0;
}

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

using namespace std;
int n , a[100000],dp[100000];
int f(int i = 0)
{
    if(i == n-1) return 0;
    if(i == n-2) return abs(a[n-2]-a[n-1]);
    if( dp[i] != -1 ) return dp[i];
    return dp[i] = min( f(i+1) + abs(a[i]-a[i+1]) , f(i+2) + abs(a[i]-a[i+2]) );
}
int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=0;i<n;++i)
        cin >> a[i];
    cout << f();
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
using namespace std;
int main() {
int a, b, no_count = 0;
cin >> a >> b;
int reversed_a = (a % 10000 / 1000) * 10 + (a / 10000);
int reversed_b = (b % 10000 / 1000) * 10 + (b / 10000);
if (reversed_a < a % 100) --no_count;
if (reversed_b > b % 100) --no_count;
cout << b / 100 - a / 100 + 1 + no_count << endl;
}

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

int main() {
  string s;
  cin >> s;
  string ans = "Yes";
  string r = s;
  reverse(r.begin(), r.end());
  if (s != r) ans = "No";

  int n = s.length();
  string s1 = s.substr(0, n/2);
  string s2 = s.substr(n/2+1, n/2);
  if (s1 != s2) ans = "No";

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M = (1LL<<N);
    vector<ll> s(M+1);
    rep(i,0,M) cin >> s[i];
    sort(s.rbegin(), s.rend());
    multiset<ll> mt;
    rep(i,1,M) mt.insert(s[i]);
    vector<ll> v;
    v.push_back(s[0]);
    rep(i,0,N){
        ll sz = v.size();
        rep(j,0,sz){
            ll e = v[j];
            auto itr = mt.lower_bound(e);
            if(itr == mt.begin()){
                print("No");
                return 0;
            }
            itr--;
            ll val = *itr;
            v.push_back(val);
            mt.erase(itr);
        }
        sort(v.rbegin(), v.rend());
    }
    print("Yes");

    

}

Measured memory_bytes: 16764
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int a,b;
  cin>>a>>b;
  if(b>=a){
    cout<<"unsafe"<<endl;
    return 0;
  }
  cout<<"safe"<<endl;
}

Measured memory_bytes: 3604
import sys
n = int(input())
h = list(map(int,input().split()))
dp = [0]

if n == 2:
    print(abs(h[1]-h[0]))
    sys.exit()

dp.append(abs(h[1]-h[0]))
for i in range(2,n):
    x1 = dp[i-1] + abs(h[i]-h[i-1])
    x2 = dp[i-2] + abs(h[i]-h[i-2])
    dp.append(min(x1,x2))

print(dp[-1])

Measured memory_bytes: 13980
#include<stdio.h>
int main(){
  int m,o,o500,a500,o100,a100,o50,a50,o10,a10,o5,a5,o1,a1;
  
  while(1){
      scanf("%d", &m);
      if(m==0){
	break;
      }
      else{
      o = 1000-m;
      o500 = o / 500;
      a500 = o % 500;
      o100 = a500 / 100;
      a100 = a500 % 100;
      o50 = a100 / 50;
      a50 = a100 % 50;
      o10 = a50 / 10;
      a10 =a50 % 10;
      o5 = a10 / 5;
      a5 = a10 % 5;
      o1 = a5 / 1;
      a1 = a5 % 1;
      
      printf("%d\n",o500 + o100 + o50 + o10 + o5 + o1);
      }
  }
  
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define int long long
int mod=1e9+7;

signed main(){
  string s;
  cin>>s;
  string t=s;
  reverse(t.begin(),t.end());
  for(int i=0;i<t.size();i++){
    if(t[i]=='b'){
      t[i]='d';
    }else if(t[i]=='d'){
      t[i]='b';
    }else if(t[i]=='p'){
      t[i]='q';
    }else if(t[i]=='q'){
      t[i]='p';
    }
  }
  if(s==t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	vector<ll> s(n + 1);
	s[0] = 0;
	unordered_map<int,int> mp;
	REP(i, n) {
		cin >> a[i];
		a[i]--;
		s[i + 1] = s[i] + a[i];
	}
	ll res = 0;
	REP(i, n + 1) {
		if (i < k) {
			res += mp[s[i] % k];
			mp[s[i] % k]++;
		} else {
			mp[s[i - k] % k]--;
			res += mp[s[i] % k];
			mp[s[i] % k]++;
		}
	}
	put(res);
	return 0;
}


Measured memory_bytes: 10824
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

def main():
    N, M = LI()
    jobsavailable = [[] for _ in range(10**5+1)]
    for _ in range(N):
        a, b = LI()
        if a > M:
            continue
        jobsavailable[M-a].append(b)
    cur_jobs = []
    cnt = 0
    for i in range(1, M+1):
        # a <= iのなかで最大のbがあるものをとりだす
        jobs = jobsavailable[M-i]
        for j in jobs:
            _heappush_max(cur_jobs, j)
        if cur_jobs != []:
            j = _heappop_max(cur_jobs)
            cnt += j
    print(cnt)

main()



Measured memory_bytes: 20184
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if(flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
vl par(MAX_N, -1);
class LCA {
public:
	ll LOG_N = floor(log2(n)) + 1;
	vector<vl> NEXT;
	vl DEPTH;


	void init() {
		DEPTH = vl(n, -1);
		NEXT = vector<vl>(LOG_N + 2, vector<ll>(n));
		for (ll i = 0; i < n; ++i) {
			NEXT[0][i] = par[i];
		}

		for (ll k = 0; k < LOG_N; k++) {
			for (ll i = 0; i < n; i++) {
				if (NEXT[k][i] == -1) {
					NEXT[k + 1][i] = -1;
				}
				else {
					NEXT[k + 1][i] = NEXT[k][NEXT[k][i]];
				}
			}
		}
	}

	ll vertex(ll p, ll Q) {
		for (ll k = LOG_N - 1; k >= 0; --k) {
			if (p == -1) {
				break;
			}
			if ((Q >> k) & 1) {
				p = NEXT[k][p];
			}
		}

		return p;
	}

	ll depth(ll x) {
		if (DEPTH[x] == -1) {
			ll ok = n, ng = -1;
			while (ok - ng > 1) {
				if (this->vertex(x, (ok + ng) / 2) > -1)ng = (ok + ng) / 2;
				else ok = (ok + ng) / 2;
			}
			DEPTH[x] = ok;
			return ok;
		}
		else return DEPTH[x];
	}

	ll kyoutuu(ll x, ll y) {
		ll a = this->depth(x);
		ll b = this->depth(y);
		if (a > b) {
			swap(x, y);
			swap(a, b);
		}
		ll t = this->vertex(y, b - a);

		ll ok = n, ng = -1;
		while (ok - ng > 1) {
			ll mid = (ok + ng) / 2;
			if (this->vertex(x, mid) == this->vertex(t, mid))ok = (ok + ng) / 2;
			else ng = (ok + ng) / 2;
		}

		return this->vertex(x, ok); 
			//return b - a + ok * 2 + 1;
	}

};
int main() {
    cin >> n;
	rep(i, n) {
		cin >> x;
		rep(j, x) {
			cin >> a;
			par[a] = i;
		}
	}

	LCA L;
	L.init();
	cin >> q;
	rep(i, q) {
		cin >> a >> b;
		cout << L.kyoutuu(a, b) << endl;
	}
}


Measured memory_bytes: 23364
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}

int main(void){
    ll n;
    cin>>n;
    //cout<<(ll)sqrt(n)<<endl;
    for(ll i=(ll)sqrt(n);i>=1;i--){
        if(n%i==0){
            ll a=n/i;
            //cout<<a<<endl;
            ll ans=0;
            while(a>=1){
                a/=10;
                ans++;
            }
            cout<<ans<<endl;
            break;
        }
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int k;
  int o = 0;
  int y = 100000;
  for (int i = 0; i < N; i++){
    cin >> k;
    o = 0;
    while (k % 2 == 0) {
      k = k / 2;
      o++;
    }
    if (y > o){
      y = o;
    }
  }
  cout << y << endl;
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define int long long

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = INT64_MAX;
const int INF = INT_MAX;

inline int sqr(int x) { return (x * x); }
inline void printd(double x) { printf("%.10lf\n", x); }
inline void upsort(VI& x) { sort((x).begin(), (x).end()); }
inline void downsort(VI& x) { sort((x).begin(), (x).end(), greater<int>()); }
inline int absdiff(int a, int b) { return (a - b)*(1|((a - b)>>(8*sizeof(int)-1)));}
int gcd(int a, int b) { // 最大公約数
	if (a < b) return gcd(b, a);
	int r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
inline int lcm(int a, int b) { return a * b / gcd(a, b); } // 最小公倍数

signed main()
{
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	while (true) {
		C -= B;
		if (C <= 0) {
			COL("Yes");
			break;
		}
		A -= D;
		if (A <= 0) {
			COL("No");
			break;
		}

	}

	return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>
 
main(){
    int *A,key,i,j,tmp,count =0;
    scanf("%d",&key);
    A = (int *)malloc(sizeof(int) * key);
    if(A == NULL){
    exit(0);
    }
     
    for(i=0;i<key;i++){
        A[i] = 0;
    }
    for(i=0;i<key;i++){
    scanf("%d",&A[i]);
    }
    for(i =0; i<=key-1;i++){
        for(j=key-1;j >i;j--){
            if(A[j] < A[j-1]){
        count++;
                tmp=A[j];
                A[j]=A[j-1];
                A[j-1]=tmp;
            }
        }
    }
    for(i=0;i<key;i++){
        if(i!=key-1){
        printf("%d ",A[i]);
        }else{
        printf("%d",A[i]);
        printf("\n");
        }
    }
    printf("%d\n",count);
     
    free(A);
     
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
const int N=1e3+5,M=2e5+5;
int n,m,U[M],V[M];
vector<int>e[N],d[N];
stack<int>s;
bool vis[N];
int mp[N][N];
int vis1[N],vis2[N];
void dfs1(int u,int k)
{
    vis1[u]=k;
    for(int i=0;i<e[u].size();i++)
    {
        int v=e[u][i];if(vis1[v]) continue;
        dfs1(v,k);
    }
}
void dfs2(int u,int k)
{
    vis2[u]=k;
    for(int i=0;i<e[u].size();i++)
    {
        int v=e[u][i];if(vis2[v]) continue;
        dfs2(v,k);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&U[i],&V[i]);
        e[U[i]].push_back(V[i]);
        d[U[i]].push_back(V[i]);
    }
    for(int i=1;i<=n;i++)
    {
        memset(vis1,0,sizeof(vis1));
        memset(vis2,0,sizeof(vis2));
        vis1[i]=vis2[i]=666;
        int up=e[i].size();
        for(int j=0;j<up;j++)
            if(!vis1[e[i][j]])
            dfs1(e[i][j],d[i][j]);
        for(int j=up-1;j>=0;j--)
            if(!vis2[e[i][j]])
            dfs2(e[i][j],d[i][j]);
        for(int j=1;j<=n;j++)
            if(vis1[j]&&j!=i)
        {
            if(vis1[j]==vis2[j]) mp[i][j]=1;
            else mp[i][j]=2;
        }
    }
    for(int i=1;i<=m;i++)
    {
        if(mp[U[i]][V[i]]&&mp[V[i]][U[i]])
        {
            if(mp[U[i]][V[i]]==2) printf("same\n");
            else printf("diff\n");
        }
        else
        {
            if(mp[U[i]][V[i]]==1) printf("same\n");
            else printf("diff\n");
        }
    }
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define pow2 ansdasdnml
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const double PI = acos(-1.0);
int mod = 998244353;
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
int c[4001][4001];
int K , N;
int add(int a , int b)
{
	return a + b >= mod ? a + b - mod : a + b;
}
int sub(int a , int b)
{
	return a - b < 0 ? a - b + mod : a - b;
}
int mult(int a , int b)
{
	return (a * (LL)b) % mod;
}
void init()
{
	c[0][0] = 1;
	for(int i = 1; i <= 4000; i++)
	{
		c[i][0] = 1;
		for(int j = 1; j <= 4000; j++)
			c[i][j] = add(c[i - 1][j - 1] , c[i - 1][j]);
	}
}

int pow2[4001];
int main()
{

	pow2[0] = 1;
	for(int i = 1; i <= 4000; i++)
		pow2[i] = mult(pow2[i - 1] , 2);
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	init();
	cin >> K >> N;
	for(int i = 2; i <= 2 * K; i++)
	{
		int ans = 0;
		int p;
		int I = i;
		if(I > K)
		{
			I = 2 * K - I + 2;
		}
		p = (I - 1) / 2;
		//cout << p << endl;

		for(int q = 0; q <= p; q++)
		{
			int additor = mult(c[p][q] , pow2[q]);

			//int sum = n - q;
			if(N - q < 0)
			{
				continue;
			}

			int multik = 0;
			if(i % 2)
			{
				if(N + K - 2 * p - 1 >= N - q)
				{
					multik = add(multik , c[N + K - 2 * p - 1][N - q]);
				}
			}
			else
			{
				if(N + K - 2 * p - 2 >= N - q)
				{
					multik = add(multik , c[N + K - 2 * p - 2][N - q]);
					if(N - q - 1 >= 0 && !(i % 2))
					{
						multik = add(multik , c[N + K - 2 * p - 3][N - q - 1]);
					}
				}

				//multik = add(multik , c[N + K - 2 * p - 1][N - q]);

			}
			//cout << additor << " " << multik << endl;
			ans = add(ans , mult(additor , multik));
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 62848
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x, y;
    in >> x >> y;

    vector<ll> g1 = {1, 3, 5, 7, 8, 10, 12};
    vector<ll> g2 = {4, 6, 9, 11};
    vector<ll> g3 = {2};

    ll xg, yg;
    REP(i, g1.size()){
        if(g1[i] == x) xg = 1;
        if(g1[i] == y) yg = 1;
    }
    REP(i, g2.size()){
        if(g2[i] == x) xg = 2;
        if(g2[i] == y) yg = 2;
    }
    REP(i, g3.size()){
        if(g3[i] == x) xg = 3;
        if(g3[i] == y) yg = 3;
    }
    if(xg == yg) out << "Yes" << endl;
    else out << "No" << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	string s;
	cin >> a;
	cin >> s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int a, b;

	cin >> a >> b;
	if (a == b){
		cout << "a == b" << endl;
	}
	else if (b > a){
		cout << "a < b" << endl;
	}
	else{
		cout << "a > b" << endl;
	}


	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#define MAX 3001
using namespace std;
int n;
vector<int>ABC(3);

int calc(vector<int> vec,vector<int>take)
{
  vector< vector<int>>abc(4);
  for(int i=0;i<n;i++)
  {
    abc[vec[i]].push_back(take[i]);
  }
  if(abc[0].size()==0 or abc[1].size()==0  or abc[2].size()==0)return MAX;
  int res=0;
  for(int i=0;i<3;i++)
  {
    res+=(abc[i].size()-1)*10;
    res+=abs(ABC[i]-accumulate(abc[i].begin(), abc[i].end(),0));
  }
  //cout<<res;
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>ABC[0]>>ABC[1]>>ABC[2];
  vector<int>l(n);
  int resu=MAX;
  for(int i=0;i<n;i++)
  {
    cin>>l[i];
  }
  vector<int>use(n);
  for(int i=0;i<(1<<(2*n));i++)
  {
    //初期化
    for(int j=0;j<n;j++)
    {
      use[j]=(i>>(2*j))&3;
    }
    resu=min(resu,calc(use,l));

  }
  cout<<resu<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
using namespace std;

struct Graph {
    struct Edge {
        bool operator>(Edge o) { return d > o.d; }
        int d, i;
    };
    Graph(int n) : e(n), v(n) {}
    void add_edge(int i, int j, int l) {
        e[i].push_back({ l, j });
    }
    void dijkstra(int i) {
        priority_queue<Edge, vector<Edge>, greater<>> q;
        fill(v.begin(), v.end(), 1 << 30);
        q.push({ v[i] = 0, i });
        while (!q.empty()) {
            auto p = q.top(); q.pop();
            if (p.d > v[p.i]) continue;
            for (auto o : e[p.i]) {
                int j = o.i;
                int d = p.d + o.d;
                if (d < v[j]) {
                    v[j] = d;
                    q.push({ d, j });
                }
            }
        }
    }
    int abc051_d() {
        int k = 0;
        for (int i = 1; i < e.size(); i++) {
            dijkstra(i);
            for (auto o : e[i]) {
                if (o.i < i && v[o.i] < o.d) k++;
            }
        }
        return k;
    }
    vector<vector<Edge>> e;
    vector<int> v;
};

int main() {
    int n, m;
    cin >> n >> m;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    cout << g.abc051_d() << endl;

    return 0;
}

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




struct Node{
  double x;
  double y;
};



void koch(int n, struct Node x, struct Node y ){


  struct Node a,b,c;
  double radian=M_PI*60.0/180.0;

  if(n==0){return;}

  
  a.x=(2.0*x.x + y.x)/3.0;
  a.y=(2.0*x.y + y.y)/3.0;

  b.x=(x.x + 2.0*y.x)/3.0;
  b.y=(x.y + 2.0*y.y)/3.0;


  
  c.x=(b.x-a.x)*cos(radian)-(b.y-a.y)*sin(radian)+a.x;
  c.y=(b.x-a.x)*sin(radian)+(b.y-a.y)*cos(radian)+a.y;



  
  if(n>0){
  koch(n-1,x,a);
  printf("%.8f %.8f\n",a.x,a.y);

  koch(n-1,a,c);
  printf("%.8f %.8f\n",c.x,c.y);

  koch(n-1,c,b);
  printf("%.8f %.8f\n",b.x,b.y);

  koch(n-1,b,y);
  
  }



}

int main(){
  struct Node a,b;
  
  int number;
  scanf("%d",&number);
  
  
  a.x=0;
  b.x=100;
  a.y=0;
  b.y=0;

  
  printf("%.8f %.8f\n",a.x,a.y);
  koch(number,a,b);

  
  printf("%.8f %.8f\n",b.x,b.y);

  
  return 0;
}



Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;

const int MOD = (int) 1e9 + 7;

void sadd(int &a, int b)
{
    a += b;
    if (a >= MOD)
        a -= MOD;
}
int add(int a, int b)
{
    sadd(a, b);
    return a;
}
void ssub(int &a, int b)
{
    a -= b;
    if (a < 0)
        a += MOD;
}
int sub(int a, int b)
{
    ssub(a, b);
    return a;
}
int mul(int a, int b)
{
    return (a * 1LL * b) % MOD;
}

int fpow(int x, long long n)
{
    if (n == 0)
        return 1;
    int a = fpow(x, n >> 1);
    a = mul(a, a);
    if (n & 1)
        a = mul(a, x);
    return a;
}

const int K = 2;

struct Matr
{
    long long a[K][K];

    Matr(int mid = 0) : a() {
        for (int i = 0; i < K; i++)
            a[i][i] = mid;
    }

    Matr operator * (const Matr &A) const
    {
        Matr ans = Matr();
        for (int i = 0; i < K; i++)
            for (int j = 0; j < K; j++)
            {
                for (int h = 0; h < K; h++)
                    ans.a[i][j] += a[i][h] * A.a[h][j];
                ans.a[i][j] %= MOD;
            }
        return ans;
    }

    Matr fpow(long long n) const
    {
        if (n == 0)
            return Matr(1);
        Matr A = fpow(n >> 1);
        A = A * A;
        if (n & 1)
            A = A * *this;
        return A;
    }
};

const int N = 1005;
char f[N][N];

int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m;
    long long k;
    scanf("%d%d%lld", &n, &m, &k);

    for (int i = 0; i < n; i++)
        scanf("%s", f[i]);

    int cnt = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            cnt += (f[i][j] == '#');

    int cntV = 0, cntH = 0;
    int neiH = 0, neiV = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m - 1; j++)
            neiH += (f[i][j] == '#' && f[i][j + 1] == '#');
        cntH += (f[i][0] == '#' && f[i][m - 1] == '#');
    }

    for (int j = 0; j < m; j++)
    {
        for (int i = 0; i < n - 1; i++)
            neiV += (f[i][j] == '#' && f[i + 1][j] == '#');
        cntV += (f[0][j] == '#' && f[n - 1][j] == '#');
    }

    if ((cntH && cntV) || k == 0)
    {
        printf("1\n");
        return 0;
    }

    if (!cntH && !cntV)
    {
        printf("%d\n", fpow(cnt, k - 1));
        return 0;
    }

    if (cntH == 0)
    {
        cntH = cntV;
        neiH = neiV;
    }

    //eprintf("!! cnt = %d, k = %lld, neiH = %d, cntH = %d\n", cnt, k, neiH, cntH);

    Matr M;
    M.a[0][0] = cnt;
    M.a[1][0] = sub(0, neiH);
    M.a[0][1] = 0;
    M.a[1][1] = cntH;

    Matr XM = M.fpow(k - 1);

  
    printf("%d\n", add(XM.a[0][0], XM.a[1][0]));

	return 0;
}




Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#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};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll l,r;
    cin>>l>>r;
    for(ll i=l;i<=min(l+2019,r);i++){
        if(i%2019==0){
            cout<<0<<endl;return 0;
        }
    }
    ll ans=LINF;
    l=l%2019;r=r%2019;
    for(ll i=l;i<r;i++){
        for(ll j=i+1;j<=r;j++){
            ans=min(ans,(i*j)%2019);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define maxLL 1000000000000000000

int main(){
	int angka;
	long long int a[100000];
	long long int hasil = 1;
	scanf("%d", &angka);
	for(int i=0; i<angka; i++){
		scanf("%lld", &a[i]);
		if(a[i] == 0){
			printf("0");
			return 0;
		}
	}
	
	for(int i=0; i<angka; i++){
		if(a[i] > maxLL/hasil){
			printf("-1");
			return 0;
		}
		hasil = hasil * a[i];
	}
	if(hasil > maxLL){
		puts("-1");
	}
	else{
		printf("%lld", hasil);
	}
	
	return 0;
}


Measured memory_bytes: 2516
N ,K, C = map(int,input().split())
S = input()

L = list()
R = list()


i = 0
work_i = 0
while i < N and work_i < K:
    if S[i] == "o":
        L.append(i)
        work_i += 1
        i += C
    i += 1

j = N-1
work_j = 0
while j >= 0 and work_j < K:
    if S[j] == "o":
        R.append(j)
        work_j += 1
        j -= C
    j -= 1

R.reverse()

# print(L)
# print(R)
length = min(len(L), len(R))
for i in range(length):
    if L[i] == R[i]:
        print(L[i] + 1)



Measured memory_bytes: 20748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define rfore(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);--i)
#define rrep(i,n) rfore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
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;}
const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[0]==S[1]&&S[1]==S[2]){
        cout<<NO<<endl;
    }else{
        cout<<YES<<endl;
    }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
}


Measured memory_bytes: 256
/*氏名：保坂優介, 学籍番号：200441141
  概要：入力をそのまま出力する*/

#include<stdio.h>

int main(void)
{
    int x,i=0;

    scanf("%d", &x);        //入力

    while (x != 0)      //0が入力されるまで繰り返す
    {
        i++;

        printf("Case %d: %d\n", i, x);      //出力

        scanf("%d", &x);        //入力
    }

    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  if(a >= b){
    ans +=a;
    a -= 1;
  }else{
    ans += b;
    b -= 1;
  }
  
  cout << ans+max(a,b) << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]

ans = -1
skip_flag = False
if N == 1:
    target = '0'
    if all([target[s-1] == str(c) for s, c in SC]):
        ans = 0
        skip_flag = True

if not skip_flag:
    for i in range(10**(N-1), 10**N):
        target = str(i)
        if all([target[s-1] == str(c) for s, c in SC]):
            ans = i
            break
print(ans)


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

signed main() {
int n;
cin>>n;
vector<int>x(n);
vector<int>y(n);
long double ans=0;
rep(i,n)cin>>x[i]>>y[i];
vector<int>a(0);
rep(i,n)a.push_back(i);
do{
  rep(i,n-1){
    ans+=pow((x[a[i]]-x[a[i+1]])*(x[a[i]]-x[a[i+1]])+(y[a[i]]-y[a[i+1]])*(y[a[i]]-y[a[i+1]]),0.5);
  }
}while(next_permutation(a.begin(),a.end()));
rep(i,n){ans/=(i+1);}
cout<<fixed<<setprecision(10);
cout<<ans<<endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::*;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}



fn main() {
    let N: isize = read();
    let S: String = read();

    let mut ans = N;
    let mut prev: char = 'u';
    for (i, s) in S.chars().enumerate() {
        if i==0 {
            prev = s;
        }
        else {
            if prev==s {
                ans -= 1;
            }
            prev = s;
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 2224