akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <limits>
#include <numeric>
#include <cmath>

using namespace std;

template<class T>
class Input {
public:
    auto operator()() const {
        T v;
        cin >> v;
        return v;
    }
};

template<class L, class R>
class Input<pair<L, R>> {
public:
    auto operator()() const {
        L l;
        R r;
        cin >> l >> r;
        return make_pair(l, r);
    }
};

template<class U>
class Input<vector<U>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        return (*this)(n);
    }
    auto operator()(size_t n) const {
        vector<U> v;
        v.reserve(n);
        Input<U> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in();
            v.emplace_back(move(u));
        }
        return v;
    }
};

template<class U>
class Input<vector<vector<U>>> {
public:
    auto operator()() const {
        Input<size_t> in{};
        auto n = in();
        auto m = in();
        return (*this)(n, m);
    }
    auto operator()(size_t n, size_t m) const {
        vector<vector<U>> v;
        v.reserve(n);
        Input<vector<U>> in{};
        for (size_t i = 0; i < n; ++i) {
            auto u = in(m);
            v.emplace_back(move(u));
        }
        return v;
    }
};

class InputType
{
public:
    template<class T>
    operator T() const {
        Input<T> i{};
        return i();
    }
};

class InputType2
{
public:
    InputType2(size_t n)
        : n_(n)
    {}
    template<class T>
    operator T() const {
        Input<T> i{};
        return i(n_);
    }
private:
    size_t n_;
};

auto input() {
    return InputType();
}

template<class... Args>
auto input(Args&&... args) {
    return InputType2(std::forward<Args>(args)...);
}

size_t bitcount(size_t n) {
    size_t c = 0;
    while (n) {
        if (n & 1ull)
            ++c;
        n >>= 1;
    }
    return c;
}

auto make_order(size_t n) {
    vector<size_t> a(n, 0);
    iota(begin(a), end(a), 0);
    return a;
}

template<class T>
auto next_permutation(T&& x) {
    using std::begin;
    using std::end;
    return next_permutation(begin(x), end(x));
}

using ll = long long;
using ull = unsigned long long;

auto gcd(size_t l, size_t r) {
    if (r == 0)
        return l;
    return gcd(r, l % r);
}

auto gcd(size_t a, size_t b, size_t c) {
    return gcd(a, gcd(b, c));
}

int main() {
    size_t s = input();
    size_t w = input();
    if (s <= w)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstring>

using namespace std;

int main(void) {
	
	int d;
	cin >>d;
	
	if (d==25) {
		cout <<"Christmas" <<endl;
	}
	if (d==24) {
		cout <<"Christmas Eve" <<endl;
	}
	if (d==23) {
		cout <<"Christmas Eve Eve" <<endl;
	}
	if (d==22) {
		cout <<"Christmas Eve Eve Eve" <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int pmax(int a, int b){
	if(a>b)return a;
	else return b;
}

int pmin(int a, int b){
	if(a<b)return a;
	else return b;
}

int main(){
	int n,max=-1000000000,min;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	min=a[0];
	for(int i=1;i<n;i++){
		max=pmax(max,a[i]-min);
		min=pmin(min,a[i]);
	}
	cout << max << "\n";
	return 0;
}


Measured memory_bytes: 3864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n,w,d;
    cin>>n>>w>>d;
    if(!d)return;
    vp v;
    v.pb({w,d});
    rep(i,n){
        int p,s;
        cin>>p>>s;
        p--;
        pi t=v[p];
        w=t.fi,d=t.se;
        v.erase(v.begin()+p);
        s%=w+d;
        if(s<w){
            int w1=min(s,w-s);
            int w2=w-w1;
            v.pb({w1,d});
            v.pb({w2,d});
        }
        else{
            s-=w;
            int d1=min(s,d-s);
            int d2=d-d1;
            v.pb({w,d1});
            v.pb({w,d2});
        }
    }
    vi ans(n+1);
    rep(i,n+1){
        ans[i]=v[i].fi*v[i].se;
    }
    SORT(ans);
    rep(i,n+1)cout<<ans[i]<<(i<n?sp:"");
    cout<<endl;
    run();
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF=(1<<30)-1;
const int MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

string s;
ll ans;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> s;
    int n = s.size();
    rep(i, 0, (int)pow(2, n-1)) {
        ll p = 0;
        rep(j, 0, n) {
            p *= 10;
            p += s[j]-'0';
            if (i & (1 << j)) {
                ans += p;
                p = 0;
            }
        }
        ans += p;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ab = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            Console.WriteLine(F(ab[0], ab[1]));
        }

        static long F(long l, long r)
        {
            if (l % 2 == 0)
            {
                var diff = r - l + 1;
                if (diff % 2 == 0) return F(l, r - 1) ^ r;
                else return ((diff / 2) % 2) ^ r;
            }
            else
            {
                return l ^ F(l + 1, r - 1) ^ r;
            }
        }
    }
}


Measured memory_bytes: 13396
from itertools import permutations
import numpy as np
n=int(input())
nn=np.arange(1,n+1).tolist()
a=tuple(map(int,input().split()))
b=tuple(map(int,input().split()))

s=list(permutations(nn))

a=s.index(a)
b=s.index(b)
print(abs(a-b))
    

Measured memory_bytes: 16976
n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = [0] * n

for j in range(n):
  for i in range(j):
    d = min(j-i, abs(x-i)+1+abs(j-y))
    ans[d] += 1

print( "\n".join( [str(d) for d in ans][1:] ))

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);

int main()
{
	fastio();
	int N,K,d,ans=0,a;
	cin>>N>>K;
	int A[N+1]={};
	while(K)
	{
		cin>>d;
		while(d)
		{
			cin>>a;
			A[a]++;
			d--;
		}
		K--;
	}
	for(int i=1;i<N+1;i++)
	{
		//cout<<A[i]<<" ";
		if(A[i]==0)
			ans++;
	}
	cout<<ans<<endl;
	return 0;   
}   


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  long long a, b, c;
  scanf("%lld %lld.%lld", &a, &b, &c);
  b = b * 100 + c;
  cout << (a * b) / 100 << endl;

  return 0;
}

// EOF

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<=b; i++)
#define per(i,b,a) for(int i=b; i>=a; i--)
#define pb push_back
using namespace std;
typedef pair<int, int> pi ;
typedef vector<pair<int,int> > vpi ;
typedef vector<int> vi ;
typedef long long ll ;
const ll mod = 998244353 ;
ll powmod(ll a, ll b) { ll res = 1 ; while(b) { if(b&1) res = (res*a)%mod ;  a = (a*a)%mod ; b >>= 1 ; }  return res ; }
const int maxn = 3e5+5 ;
const int inf = 1e9+5 ;
string s ;
int main()
{
    ios::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cin >> s ;
    int n = (int)s.length() ;
    int cnt[maxn] ;
    rep(i,0,maxn-2) cnt[i] = 0;
    rep(i,0,n-1)
    {
        if(s[i] == 'W') cnt[i] = 1 ;
    }
    rep(i,1,n-1) cnt[i]+=cnt[i-1] ;
    ll ret = 0 ;
    rep(i,0,n-1)
    {
        if(s[i] == 'B')
            ret += cnt[n-1] - cnt[i] ;
    }
    cout << ret << "\n" ;
    return 0 ;
}




Measured memory_bytes: 1812
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    vector<vector<ll>> dp(n+10,vector<ll>(2,-1*inf - 10));
    dp[0][0] = 0;
    rep(i,n){
        chmax(dp[i+1][0], max(dp[i][0] + v[i], dp[i][1] - v[i]));
        chmax(dp[i+1][1], max(dp[i][0] - v[i], dp[i][1] + v[i]));
    }
    // rep(j,2){
    //     rep(i,n+1) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 9036
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    h = list(map(int, input().split()))

    dp = [0]*n
    dp[1] = abs(h[0]-h[1])
    for i in range(2, n):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[-1])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 20240
#include <bits/stdc++.h>
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
const int INF = 1 << 30;
const ll INFll = 1ll << 60;
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main() {
  int N, T;
  cin >> N >> T;
  vector<pii> P(N);
  rep(i, N) {
    int c, t;
    cin >> c >> t;
    P[i] = make_pair(c, t);
  }
  sort(all(P));
  pii ans;
  for (auto p : P) {
    if (p.second <= T) {
      cout << p.first << endl;
      return 0;
    }
  }
  cout << "TLE" << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input().rstrip())
h = list(map(int, input().rstrip().split()))
num = 0
m_num = 0
for i in range(1, n):
    if h[i - 1] >= h[i]:
        num = num + 1
    else:
        m_num = max(m_num, num)
        num = 0

m_num = max(m_num, num)
print(m_num)


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

int main() {
  vector<string> vec(2);

  cin >> vec[0] >> vec[1];

  if (vec[0][0] == vec[1][2] && vec[0][1] == vec[1][1] &&
      vec[0][2] == vec[1][0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
(let ((n (read))
      (m (read))
      (x (read))
      (p1 0)
      (p2 0))
  (dotimes (i m)
    (let ((a (read)))
      (if (> a x)
        (setq p1 (1+ p1))
        (setq p2 (1+ p2)))))
  (format t "~A~%" (min p1 p2)))

Measured memory_bytes: 12520
package main

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

func main() {
	n := getUint()
	m := getInt()

	ls := make([]uint, m)
	for i := range ls {
		k := getInt()
		for j := 0; j < k; j++ {
			ls[i] += (1 << (getUint() - 1))
		}
	}

	ps := make([]uint, m)
	for i := range ps {
		ps[i] = getUint()
	}

	ans := 0
	for bits := uint(0); bits < (1 << n); bits++ {
		ok := true
		for i, sw := range ls {
			cnt := bitCount(sw&bits, n)
			if cnt%2 != ps[i] {
				ok = false
			}
		}
		if ok {
			ans++
		}
	}

	fmt.Println(ans)
}

func bitCount(bits, n uint) uint {
	cnt := uint(0)
	for m := uint(1); m < (1 << n); m <<= 1 {
		if (bits & m) != 0 {
			cnt++
		}
	}

	return cnt
}

// -----------------------------------------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	// tmp := 200001
	// sc.Buffer(make([]byte, tmp), tmp)
	sc.Split(bufio.ScanWords)
}

func getInt() int {
	i, err := strconv.Atoi(getString())
	if err != nil {
		panic(err)
	}
	return i
}

func getUint() uint {
	return uint(getInt())
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        final Scanner scanner = new Scanner(System.in);
        final int count = scanner.nextInt();
        if (count == 1) {
            System.out.println(1);
            return;
        }
        final long[][] table = new long[count][2];

        for (int i = 0; i < count; i++) {
            table[i][0] = scanner.nextLong();
            table[i][1] = scanner.nextLong();
        }

        List<Len> lens = new ArrayList<>();
        List<MyInteger> counts = new ArrayList<>();

        for (int i = 0; i < count; i++) {
            for (int j = i + 1; j < count; j++) {
                if (table[i][0] > table[j][0]) {
                    extracted(table, lens, counts, j, i);
                } else if (table[i][0] == table[j][0]) {
                    if (table[i][1] > table[j][1]) {
                        extracted(table, lens, counts, i, j);
                    } else {
                        extracted(table, lens, counts, j, i);
                    }
                } else {
                    extracted(table, lens, counts, i, j);
                }
            }
        }
        Collections.sort(counts);
        System.out.println(count - counts.get(0).getInteger());
    }

    private void extracted(final long[][] table, final List<Len> lens, final List<MyInteger> counts, final int i, final int j) {
        final Len len = new Len(table[j][0] - table[i][0], table[j][1] - table[i][1]);
        int index;
        if ((index = lens.indexOf(len)) != -1) {
            counts.get(index).increment();
        } else {
            lens.add(len);
            counts.add(new MyInteger());
        }
    }

    class MyInteger implements Comparable {
        private int integer = 1;

        void increment() {
            this.integer++;
        }

        public int getInteger() {
            return integer;
        }

        @Override
        public int compareTo(final Object o) {
            return ((MyInteger) o).getInteger() - this.integer;
        }
    }

    class Len {
        private final long x;
        private final long y;

        Len(final long x, final long y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public boolean equals(final Object obj) {
            return ((Len) obj).getX() == this.getX() && ((Len) obj).getY() == this.getY();
        }

        long getX() {
            return x;
        }

        long getY() {
            return y;
        }
    }
}


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


void solve(std::string S){
  cout << ((S == "ABC") ? "ARC" : "ABC") << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


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

@SuppressWarnings("unused")
public class Main {
	static class InputReader{ 
	BufferedReader reader;
	StringTokenizer tokenizer;
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public Long nextLong() {
		return Long.parseLong(next());
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	}
	static InputReader r = new InputReader(System.in);
	static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) {
		new Solve();
		pw.close();
	}
	static class Solve {
		Solve() {// if b > a || c > b
			int a = r.nextInt(), b = r.nextInt(), c = r.nextInt(), k = r.nextInt();
			boolean work = false;
			while (k > 0 && b <= a) {
				if (b <= a && k > 0) {
					b *= 2;
					k = k - 1;
				} else {
					break;
				}
			}
			while (k > 0 && c <= b) {
				if (k > 0 && c <= b) {
					c*=2;
					k = k - 1;
				}
			}
			if (c > b && b > a) {
				work = true;
			}
			if (work) {
				pw.println("Yes");
			} else {
				pw.println("No");
			}
			return;
		}
	}
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}





void _main() {
        ll a, b, n; cin >> a >> b >> n;
        cout << (a * min(b - 1, n)) / b;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

int main() {
  int m, f, b;
  cin >> m >> f >> b;
  if (m >= b) {
    cout << 0 << endl;
  } else if (m + f >= b) {
    cout << b - m << endl;
  } else {
    cout << "NA" << endl; 
  }
}


Measured memory_bytes: 3096
import java.util.*;
import java.io.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {
	static int[][] dp;
	static int[] p;

	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());

    dp = new int[n+1][n+1];
    p = new int[n+1];

    for (int i = 0; i < n; i++) {
      int[] input = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
      p[i] = input[0];
      p[i+1] = input[1];
    }

    out.println(count(1,n));
	}

	static int count(int i,int j) {
		if (dp[i][j] != 0 || i==j) return dp[i][j];
    if (i-j == 1) return dp[i][j] = p[i-1] * p[i] * p[j];

		int min = Integer.MAX_VALUE;
		for (int k=i; k<j; k++){
			min = min(min, count(i,k) + count(k+1,j) + p[i-1] * p[k] * p[j]);
    }

		return dp[i][j] = min;
	}
}


Measured memory_bytes: 32468
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;

class BellmanFord {
 private:
  const ll INF = 1LL << 60;
  ll n_;
  vector<tuple<ll, ll, ll>> edges_;
  vector<vector<ll>> to_, rto_;
  vector<ll> dist_;
  vector<bool> reachableFromSrc_, reachableToDst_;

  void dfs(ll u, const vector<vector<ll>>& to, vector<bool>& reachable) {
    if (reachable[u]) return;
    reachable[u] = true;
    for (ll v : to[u]) {
      dfs(v, to, reachable);
    }
  }

 public:
  BellmanFord(ll n)
      : n_(n),
        dist_(n, INF),
        to_(n),
        rto_(n),
        reachableFromSrc_(n, false),
        reachableToDst_(n, false) {}

  void addEdge(ll u, ll v, ll w) {
    edges_.emplace_back(u, v, w);
    to_[u].emplace_back(v);
    rto_[v].emplace_back(u);
  }

  bool exec(ll src, ll dst, ll& ans) {
    // To remove edges which is not involved in path from src to dst
    dfs(src, to_, reachableFromSrc_);
    dfs(dst, rto_, reachableToDst_);

    dist_[src] = 0;
    rep(i, n_) {
      for (auto& e : edges_) {
        ll u = get<0>(e);
        ll v = get<1>(e);
        ll w = get<2>(e);
        if (reachableFromSrc_[u] && reachableFromSrc_[v] &&
            reachableToDst_[u] && reachableToDst_[v]) {
          if (dist_[v] > dist_[u] + w) {
            dist_[v] = dist_[u] + w;
          }
        }
      }
    }
    for (auto& e : edges_) {
      ll u = get<0>(e);
      ll v = get<1>(e);
      ll w = get<2>(e);
      if (reachableFromSrc_[u] && reachableFromSrc_[v] && reachableToDst_[u] &&
          reachableToDst_[v]) {
        if (dist_[v] > dist_[u] + w) {
          // has negative cycle
          return true;
        }
      }
    }
    // no negative cycle
    ans = dist_[dst];
    return false;
  }
};

int main() {
  //
  ll n, m, p;
  cin >> n >> m >> p;
  BellmanFord g(n);

  rep(i, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c -= p;
    c = -c;
    g.addEdge(a, b, c);
  }
  ll ret = 0;
  if (g.exec(0, n - 1, ret)) {
    cout << -1 << endl;
  } else {
    cout << max(0LL, -ret) << endl;
  }

  return 0;
}


Measured memory_bytes: 896
fun main() {
//    a()
    b()
}

fun a() {
    val n = readLine()!!.toInt()
    if (n % 1000 == 0) println(0) else println("${1000 - n % 1000}")
}

fun b() {
    val n = readLine()!!.toInt()
    val result = mutableListOf<Int>(0, 0, 0, 0)
    for (i in 0 until n) {
        when (readLine()!!) {
            "AC" -> result[0]++
            "WA" -> result[1]++
            "TLE" -> result[2]++
            else -> result[3]++
        }
    }
    println("AC x ${result[0]}")
    println("WA x ${result[1]}")
    println("TLE x ${result[2]}")
    println("RE x ${result[3]}")
}

Measured memory_bytes: 58216
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    forn(i, n - 1){
        if (s[i] == s[i + 1]){
            cout << i + 1 << ' ' << i + 2 << '\n';
            return;
        }
    }
    forn(i, n - 2){
        if (s[i] == s[i + 2]){
            cout << i + 1 << ' ' << i + 3 << '\n';
            return;
        }
    }
    cout << "-1 -1\n";
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

int A, B;

void solve() {
    FOR(202020) {
        if ((i * 8) / 100 == A && (i * 10) / 100 == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}


signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    solve();
    return 0;
}


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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e-a > k) cout << ":(";
  else cout << "Yay!";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
N,M,K = map(int, input().split())

mod = 10**9 + 7
n = 2*10**5

fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod

def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod

base = comb(N*M-2,K-2)
first = 0
for i in range(N):
  for j in range(M):
    first += (i+j)
dp = [0]*M
dp[0] = first
for i in range(1,M):
  dp[i] = dp[i-1] - (M-2*i) * N
SUM = sum(dp)
dp2 = [0]*N
dp2[0] = SUM
for i in range(1,N):
  dp2[i] = dp2[i-1] - (N-2*i) * (M ** 2)
SUM = sum(dp2)
ans = comb(N*M-2,K-2) * (SUM % mod) * pow(2,mod-2,mod)
ans %= mod
print(ans)


Measured memory_bytes: 44144
<?php
  
  list($a, $b) = explode(" ", trim(fgets(STDIN)));

  $p = 0;
  $n = 1;
  while($n < $b){
    $p++;
    $n = $n - 1 + $a;
//    echo $p." ".$n.PHP_EOL;
  }

  echo $p;

Measured memory_bytes: 4604
#!/usr/bin/env python
n = int(input())
ans = 0 

is_primes = [True for _ in range(n+1)]
is_primes[0] = is_primes[1] = False
minFactor = [-1 for _ in range(n+1)]

for i in range(2, n+1):
    if not is_primes[i]: continue
    minFactor[i] = i 
    for j in range(i*i, n+1, i): 
        is_primes[j] = False
        minFactor[j] = i 


def fast_factorization(n):
    data = {}
    while n > 1:
        if minFactor[n] not in data:
            data[minFactor[n]] = 1 
        else:
            data[minFactor[n]] += 1
        n //= minFactor[n]
    return data


def count_divisors(n):
    ret = 1 
    for v in fast_factorization(n).values():
        ret *= (v+1)
    return ret 

for i in range(1, n): 
    ans += count_divisors(i)

print(ans)

Measured memory_bytes: 208944
n = gets.chop.to_i

def count_digit(num)
  num.to_s.length
end

l = count_digit(n)

s = 0

for t in 1...l do
  if t == 1
    s += 9
  elsif t % 2 == 1
    s += (10 ** t) - (10 ** (t - 1))
  end
end

if l % 2 == 1
  s += n - (10 ** (l-1)) + 1
end

puts s

Measured memory_bytes: 1788
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  s <-  T.getLine :: IO T.Text
  let
    l = T.length . T.filter (== 'x') $ s :: Int
  putStrLn $ if l <= 7 then "YES" else "NO"


Measured memory_bytes: 508
//解説後
#include <set>
#include<iostream>
using namespace std;
int main(void){
    set <int> s;
    int n;
    cin >>n;
    for(int i=0;i<n;i++){
        int d;
        cin >>d;
        s.insert(d);
    }
    cout <<s.size()<<endl;
    return 0;
    
}

Measured memory_bytes: 256
import re
Sp = input().replace('?','.')
T = input()
flag = 0
for i in range(len(Sp)-len(T),-1,-1):
    if re.match(Sp[i:i+len(T)],T):
        Sp = Sp[:i]+T+Sp[i+len(T):]
        flag = 1
        break
if flag == 1:
    print(Sp.replace('.','a'))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 9740
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

int main(void) {
    llong H, W, D;
    cin >> H >> W >> D;

    vector<pair<llong, llong>> cordinate(H * W + 1);

    FOR(i, H) {
        FOR(j, W) {
            llong p;
            cin >> p;
            cordinate[p] = make_pair(i + 1, j + 1);
        }
    }

    vvecllong sumCost(D, vecllong(0));

    for (llong startPoint = 1; startPoint <= D; startPoint++) {
        llong type = startPoint % D;
        sumCost[type].push_back(0);

        llong j = 1;
        pair<llong, llong> prevCordinate = cordinate[startPoint];
        pair<llong, llong> nextCordinate;
        llong cost;
        while (startPoint + j * D <= H * W) {
            nextCordinate = cordinate[startPoint + j * D];
            cost = abs(nextCordinate.first - prevCordinate.first) + abs(nextCordinate.second - prevCordinate.second);
            sumCost[type].push_back(sumCost[type][j - 1] + cost);
            prevCordinate = nextCordinate;
            j++;
        }
    }

    llong Q;
    cin >> Q;

    FOR(q, Q) {
        llong start, end;
        cin >> start >> end;

        llong startPoint = start % D;
        if (startPoint == 0) {
            startPoint = D;
        }

        llong startTime = (start - startPoint) / D;
        llong endTime = (end - startPoint) / D;

        llong ans = sumCost[startPoint % D][endTime] - sumCost[startPoint % D][startTime];

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

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

  // 1:+, 0:-
  rep(b,1<<3) {
    int res = s[0]-'0';
    string ans = {s[0]};
    rep(i,3) {
      if (b&(1<<i)) {
        res += s[i+1]-'0';
        ans += '+';
        ans += s[i+1];
      }
      else {
        res -= s[i+1]-'0';
        ans += '-';
        ans += s[i+1];
      }
    }
    if (res == 7) {
      ans += "=7";
      cout << ans << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO ()
main = do
  { [a,b] <- getInts
  ; let (x,y) = a `divMod` b
  ; let z = fromIntegral a / fromIntegral b
  ; putStrLn (unwords [showFFloat Nothing (fromIntegral x) ""
                      ,showFFloat Nothing (fromIntegral y) ""
                      ,showFFloat Nothing z ""])
  }

--

getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show




Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

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

    int h, w, k;
    cin >> h >> w >> k;
    int cnt = 0;
    vector <vector <char> > c;
    c.resize(h);
    rep(i, 0, h) {
        c[i].resize(w);
        rep(j, 0, w) {
            cin >> c[i][j];
        }
    }
    int ans = 0;
    rep(i, 0, pow(2, h + w)) {
        auto tmp = c;
        rep(j, 0, h) {
            if (i & (1 << j)) {
                rep(l, 0, w) {
                    tmp[j][l] = '.';
                }
            }
        }
        rep(j, 0, w) {
            if (i & (1 << (h + j))) {
                rep (l, 0, h) {
                    tmp[l][j] = '.';
                }
            }
        }
        int cnt = 0;
        rep(j, 0, h) {
            rep(l, 0, w) {
                if (tmp[j][l] == '#') {
                    cnt++;
                }
            }
        }
        if (cnt == k) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4076
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        double v;
        if(!(cin >> v))
            return 0;

        double t = v / 9.8;
        double y = 4.9 * t * t;
        int ret = y / 5 + 2;
        cout << ret << endl;
    }
}

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

using i64 = int64_t;

i64 solve(i64 n, i64 m){
    if(m > n)return 0;
    i64 res = 0;
    vector<bool> exist(10);
    i64 num = m;
    while(num > 0){
        exist[num%10] = true;
        num /= 10;
    }
    if(exist[3] && exist[5] && exist[7])res++;
    res += solve(n, m*10+3);
    res += solve(n, m*10+5);
    res += solve(n, m*10+7);
    return res;
}

int main(){
    i64 n;
    cin >> n;
    cout << solve(n, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
/* Greatest Common Divisor */

#include <iostream>
using namespace std;

inline void swap(unsigned long *a, unsigned long *b) {
  unsigned long c;
  c = *a;
  *a = *b;
  *b = c;
}

int main(void) {
  unsigned long x, y, z;
  cin >> x >> y;
  if (x < y) swap(&x, &y);
  while(y != 0) {
    z = y;
    y = x % y;
    x = z;
  }
  cout << x << endl;
}


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

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

 int main(){
  int n, m;

  cin >> n >> m;
  int a[51],b[51];

  rep(i,m+1){
     cin >> a[i] >> b[i];  
  }

  int ansA[n],ansB[n];
 
  rep(i,n+1){
   ansA[i]= 0;
   rep(k,m+1){  
    if(a[k] != i) continue;
    else ansA[i]++;
   }
  }

  rep(i,n+1){
   ansB[i]= 0;
   rep(k,m+1){  
    if(b[k] != i) continue;
    else ansB[i]++;
   }
  }

  rep(i,n+1){ 
   cout << (ansA[i]) + (ansB[i]) << endl;
   }

 return 0;
}


Measured memory_bytes: 256
s = input()
if s[0] == 'A' and s[2:-1].count('C') == 1:
    for i in range(len(s)):
        if not (i == 0 or i == s[2:-1].index('C')+2):
            if not s[i].islower():
                print('WA')
                exit()
    print('AC')
    exit()
print('WA')

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define push_back pb
#define int long long int
unordered_map<string, bool>mp;
string factorial(long long n)
{
	if (n > 1000) {
		cout << " Integer Overflow"
		     << endl;
		return "";
	}

	long long counter;
	long double sum = 0;

	// Base case
	if (n == 0)
		return "1";

	// Calculate the sum of
	// logarithmic values

	for (counter = 1; counter <= n;
	        counter++) {
		sum = sum + log(counter);
	}
	cout << sum << endl;

	// Number becomes too big to hold in
	// unsigned long integers.
	// Hence converted to string
	// Answer is sometimes under
	// estimated due to floating point
	// operations so round() is used
	string result
	    = to_string(round(exp(sum)));

	return result;
}
bool solve(string a, string b)
{
	if (a.compare(b) == 0)
		return true;

	if (a.length() <= 1)  //if a ki length is 1 it means a!=b(becz we checked for equality above so it returns false
		return false;

	string key = a;
	key.push_back(' ');
	key.append(b);
	if (mp.find(key) != mp.end())
		return mp[key];

	int n = a.length();
	bool flag = false;

	for (int i = 1; i < n; i++)
	{
		bool cond_1 = false, cond_2 = false;
		if ((solve(a.substr(0, i), b.substr(n - i, i)) == true) && (solve(a.substr(i, n - i), b.substr(0, n - i)) == true))
			cond_1 = true;

		if ((solve(a.substr(0, i), b.substr(0, i)) == true) && (solve(a.substr(i, n - i), b.substr(i, n - i)) == true))
			cond_2 = true;

		if (cond_1 || cond_2)
		{
			flag = true;
			break;
		}
	}
	return mp[key] = flag;
}
int result(int n, unordered_map<int, int>&m)
{
	if (n <= 2)
		return 1;
	if (m.find(n) != m.end())
		return m[n];

	int ans = result(n - 1, m) + result(n - 2, m);
	return m[n] = ans;

}
int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	int a = n ^ 1;
	cout << a;
	return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279


int main(){
    int N; cin >> N; pair<ll, ll> P[N], Q[N];
    rep(i, N){
        ll a, b; cin >> a >> b;
        P[i] = {a, b};
        Q[i] = {b, a};
    }
    sort(P, P+N); sort(Q, Q+N, greater<>());
    ll ans;
    if(N%2==0){
        ll mi = (P[N/2-1].first+P[N/2].first);
        ll ma = (Q[N/2-1].first+Q[N/2].first);
        ans = ma-mi+1;
    }
    else{
        ll mi = P[N/2].first; ll ma = Q[N/2].first;
        ans = ma-mi+1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9848
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define MOD 1000000008

int gcd(int a, int b){
    if( a < b){
        swap(a,b);
    }
    return (a % b == 0)? b:gcd(a, a%b);
}

int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}

ll solve(ll h){
    if(h == 1) return 1;
    return 1 + 2 * solve(h/2);
}

int main(){
    ll h;
    cin >> h;
    cout << solve(h) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 
int a, b, vis[200000];
vector<int> v[200000];

void dfs(int k)
{
	vis[k]=1;
	forr(i, 0, v[k].size())
	{
		if(!vis[v[k][i]])
			dfs(v[k][i]);
	}
}

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	cin>>a>>b;
	set<int> s;
	forr(i, 0, b)
	{
		int x,y;
		cin>>x>>y;
		s.insert(x);
		s.insert(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int ans=0; 
	ans+=a-s.size();
	forr(i, 1, 1+a)
	{
		if(!vis[i] and s.find(i)!=s.end())
		{
			ans++;
			dfs(i);
		}
	}
	cout<<ans-1;
	
	return 0;
}

Measured memory_bytes: 16376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    string n;
    cin >> n;
    int now = 0;
    rep(i,(int)n.size()){
        now += int(n[i]-'0');
    }
    if(now%9==0) cyes;
    else cno;
    return 0;
}

Measured memory_bytes: 3700
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Point struct {
	X, Y int
}

func fact(x int) int {
	ans := 1

	for i := 2; i <= x; i++ {
		ans *= i
		ans %= 1000000007
	}

	return ans
}

func modinv(a, m int) int {
	b, u, v := m, 1, 0
	for b != 0 {
		t := a/b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}

	u %= m
	if u < 0 {
		u += m
	}
	return u
}

func main() {
	sc.Split(bufio.ScanWords)

	x, y := nextInt(), nextInt()
	if (x+y)%3 != 0 {
		fmt.Println(0)
		return
	}

	c := (x+y)/3
	// AパターンとBパターンの回数を探す
	a, b := -1, -1
	for i := 0; i <= c; i++ {
		if i + 2*(c-i) == x && 2*i + (c-i) == y {
			a, b = i, c-i
		}
	}

	if a == -1 || b == -1 {
		fmt.Println(0)
		return
	}

	fmt.Println(fact(c)*modinv(fact(a)*fact(b), 1000000007)%1000000007)
}

Measured memory_bytes: 640
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1000000000000000000:
            print(-1)
            return

    print(ans)

main()

Measured memory_bytes: 21492
#include <bits/stdc++.h>
using namespace std;
const auto start_time = std::chrono::high_resolution_clock::now();
void timecalculater(){
    #ifndef ONLINE_JUDGE
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
    #endif
}
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=998244353;
const int N=2e5+5;
int main() {
    
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
        ll k;cin>>k;
        ll ans=0;
        for(ll i=1;i<=k;i++){
            for(ll j=1;j<=k;j++){
                for(ll l=1;l<=k;l++){
                    ll y;y=__gcd(i,j);y=__gcd(y,l);
                    ans+=y;
                }
            }
        }
        cout<<ans;
    }   
    timecalculater();
    return 0;   
} 


Measured memory_bytes: 3656