akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

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

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N, M;
vector<pair<int, int> > G[1011];

int D[1011];
int dist[1011][1011];
bool has[200011];

vector<pair<int, int> > E;
VI que;

void bfs(int s) {
    memset(D, 0x3f, sizeof D);
    D[s] = 0;
    que.clear();
    que.push_back(s);
    for (int i=0; i<(int)que.size(); i++) {
	int v = que[i];
	EACH (e, G[v]) {
	    int w = e->first;
	    if (D[w] > D[v] + 1) {
		D[w] = D[v] + 1;
		que.push_back(w);
	    }
	}
    }
    REP (i, N) dist[s][i] = D[i];

    REP (t, 2) {
	// reachable;
	memset(D, 0, sizeof D);
	D[s] = 1;
	EACH (e, G[s]) {
	    if (D[e->first]) {
		has[e->second] = true;
	    } else {
		que.clear();
		que.push_back(e->first);
		D[e->first] = 1;
		for (int i=0; i<(int)que.size(); i++) {
		    int v = que[i];
		    EACH (f, G[v]) {
			int w = f->first;
			if (!D[w]) {
			    D[w] = 1;
			    que.push_back(w);
			}
		    }
		}
	    }
	}

	reverse(G[s].begin(), G[s].end());
    }
}

void MAIN() {
    scanf("%d%d", &N, &M);
    E.reserve(M);
    REP (i, M) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	E.emplace_back(x, y);
	G[x].emplace_back(y, i);
    }
    memset(dist, 0x3f, sizeof dist);
    const int INF = dist[0][0];

    que.reserve(N);
    REP (i, N) bfs(i);

    REP (i, E.size()) {
	int x = E[i].first, y = E[i].second;
	bool diff = false;
	if (!has[i] && dist[y][x] != INF) diff = true;
	if (has[i] && dist[y][x] == INF) diff = true;
	puts(diff? "diff": "same");
    }

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 10112
#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()
{
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n)
    {
        double x;
        string u;
        cin >> x >> u;
        if (u == "BTC")
            x *= 380000.0;
        ans += x;
    }
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 3704
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
//#define F first
//#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

template<typename F>
struct FixPoint : F {
  FixPoint(F&& f) :F(forward<F>(f)) {}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f) {
  return FixPoint<F>{forward<F>(f)};
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  cout << std::fixed << std::setprecision(15);

  int N;
  cin >> N;
  vector<int> A(3, 0);
  F0R(i, N) {
    int a;
    cin >> a;
    A[--a]++;
  }

  vector<vector<vector<double>>> dp(A[0]+A[1]+A[2]+1,
    vector<vector<double>>(A[1]+A[2]+1, vector<double>(A[2]+1, -1)));
  dp[0][0][0] = 0;

  MFP([&](auto dfs, int d1, int d2, int d3)->double {

    if (dp[d1][d2][d3] >= 0) return dp[d1][d2][d3];

    //cout << d1 << ' ' << d2 << ' ' << d3 << newl;

    vector<double> results;

    double result = 0;
    if (d1 > 0) {
      result += dfs(d1 - 1, d2, d3) * d1;
    }
    if (d2 > 0) {
      result += dfs(d1 + 1, d2 - 1, d3) * d2;
    }
    if (d3 > 0) {
      result += dfs(d1, d2 + 1, d3 - 1) * d3;
    }

    result += N;
    result /= (d1 + d2 + d3);
    //debug(result);
    return dp[d1][d2][d3] = result;

  })(A[0], A[1], A[2]);

  cout << dp[A[0]][A[1]][A[2]];
}
#endif


Measured memory_bytes: 216960
#!/usr/bin/env python3

from collections import deque
n, k = list(map(int, input().split()))

td = [list(map(int, input().split())) for i in range(n)]

td = sorted(td, key=lambda x: x[1], reverse=True)

set_ = set()
val = 0
duplicated = deque([])

for t_tmp, d_tmp in td[:k]:
    val += d_tmp
    if t_tmp in set_:
        duplicated.append(d_tmp)
    else:
        set_.add(t_tmp)

now = val + len(set_)**2


nx = deque(td[k:])
ans = now
c = len(set_)
while len(set_) < k and nx:
    i, j = nx.popleft()
    if i in set_:
        continue
    d = duplicated.pop()
    diff = j-d + 2 * c + 1
    set_.add(i)
    ans = max(ans, now + diff)
    now += diff
    c += 1
print(ans)


Measured memory_bytes: 31128
#include <algorithm>
#include <cstdio>

#define MOD 1000000007
#define ll long long
#define maxf 200004

int f[maxf+1], invf[maxf+1];

inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = (1LL * rez * a) % MOD;
        a = (1LL * a * a) % MOD, n /= 2;
    }
    return rez;
}

inline ll comb (int a, int b) {
    if(b < a) return 0;
    else return 1LL * f[b] % MOD * invf[a] % MOD * invf[b-a] % MOD;
}
int v[maxf + 3], nr[maxf + 3];
int main() {
    int n, a, d;
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++) {
        scanf("%d", &a);
        v[a]++;
        if(v[a] == 2) {
            d = n + 1 - (i - nr[a] + 1);
        }
        nr[a] = i;
    }

    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= maxf; i++) f[i] = 1LL * i * f[i-1] % MOD;
    invf[maxf] = 1LL * lgput (f[maxf], MOD - 2);
    for (int i = maxf - 1; i >= 1; i--) invf[i] = 1LL * invf[i+1] * (i+1) % MOD;

    for (int i = 1; i <= n + 1; i++) {
        ll rez = ( ( 1LL * comb(i, n) + 1LL * comb(i - 1, n) ) % MOD - 1LL * comb(i - 1, d) )% MOD ;
        if (rez < 0)
            rez = rez + MOD;
        printf("%lld", rez);
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
using namespace std;
//Ford-Fulkerson O(FE)
#include<algorithm>
#include<utility>
#include<vector>
#include<limits>
template<typename T>
struct MF{
	struct edge{
		int to,rev;
		T cap;
	};
	vector<vector<edge> >G;
	vector<int>used;
	MF(int n_=0):G(n_),used(n_,0){}
	void add_edge(int from,int to,T cap)
	{
		G[from].push_back({to,(int)G[to].size(),cap});
		G[to].push_back({from,(int)G[from].size()-1,0});
	}
	T dfs(int u,int t,T f,int dfstime)
	{
		if(u==t)return f;
		used[u]=dfstime;
		for(edge&e:G[u])
		{
			if(used[e.to]<dfstime&&e.cap>0)
			{
				T d=dfs(e.to,t,min(f,e.cap),dfstime);
				if(d>0)
				{
					e.cap-=d;
					G[e.to][e.rev].cap+=d;
					return d;
				}
			}
		}
		return 0;
	}
	T max_flow(int s,int t)
	{
		T ret=0;
		for(int dfstime=1;;dfstime++)
		{
			T f=dfs(s,t,numeric_limits<T>::max(),dfstime);
			if(f>0)ret+=f;
			else break;
		}
		return ret;
	}
};
int H,W;
string s[100];
int d[4]={1,0,-1,0};
main()
{
	cin>>H>>W;
	for(int i=0;i<H;i++)cin>>s[i];
	MF<long>P(H*W*2+2);
	int st=H*W*2,go=H*W*2+1;
	for(int i=0;i<H;i++)for(int j=0;j<W;j++)
	{
		int id=i*W+j;
		if(i==0||j==0||i==H-1||j==W-1)P.add_edge(id*2+1,go,1e9);
		if(s[i][j]=='X')P.add_edge(st,id*2+1,1e9);
		P.add_edge(id*2,id*2+1,1);
		for(int r=0;r<4;r++)
		{
			int x=i+d[r],y=j+d[r^1];
			if(x<0||y<0||x>=H||y>=W)continue;
			P.add_edge(id*2+1,2*(x*W+y),1);
		}
	}
	long ans=P.max_flow(st,go);
	if(ans<1e9)cout<<ans<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <string>
#include <limits.h>

#define ll long long

using namespace std;

int main(){

    
    int n;
    cin >> n;

    vector<int> p;

    for(int i = 0; i< n; i++){
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    int ans = 0;

    for(int i = 0; i < n - 2; i++){
        if(p[i + 1] != min(p[i], min(p[i + 1], p[i + 2])) && p[i + 1] != max(p[i], max(p[i + 1], p[i + 2]))) ans++;
    }

    cout << ans << endl;

    return 0;
}

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

// with answer
int main(){

    int n = -99999999;
    int maxv = (int)-1e+9;
    int minv = 0;
    int R[200000];

    cin >> n;

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

    minv = R[0];

    for(int j = 1 ; j < n ; ++j){
        maxv = std::max(maxv, R[j] - minv);
        minv = std::min(minv, R[j]);
    }

    cout << maxv << endl;

}



Measured memory_bytes: 3896
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<i64>();
    let (a, b, c, d) = (line[0], line[1], line[2], line[3]);
    let mut x_range = vec![a, b];
    let mut y_range = vec![c, d];
    if a <= 0 && 0 <= b {
        x_range.push(0);
    }
    if c <= 0 && 0 <= d {
        y_range.push(0);
    }
    let mut ans: i64 = x_range[0] * y_range[0];
    for x in &x_range {
        for y in &y_range {
            ans = cmp::max(ans, (*x) * (*y));
        }
    }

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


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

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

using ll = long long;
#define INF 1e9


int main(){
  int N, M;
  cin >> N >> M;
  int ans = INF;
  
  for(int i = 1; (i*i) <= M; i++){
    if(M % i == 0){
      if(i >= N){
        ans = min(ans, i);
      }
      else{
        int m = M/i;
        if(m >= N){
          ans = min(ans, M / i);
        }
      }
    }
  }
  cout << M / ans << endl;
  return 0;
}


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


void solve(long long N, long long M){
    if(N > M) swap(N, M);
    if(N == 1 && M==1) cout << 1 << endl;
    else if(N == 1) cout << M - 2 << endl;
    else
    {
        cout << (N-2)*(M-2) << endl;
    }
     
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	string s = "APPROVED";
	cin >> n;

	vector<long long> a(n);

	for(long long i = 0;i < a.size();i++)
		cin >> a[i];

	for(long long i = 0;i < a.size();i++)
		if(a[i] %2==0)
			if (a[i] % 3 != 0 && a[i] % 5 != 0)
			{
				s = "DENIED";
				break;
			}

	cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pb push_back
#define inf 1000000000000000000
void checkpoint1()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	*/
}
int main()
{
	checkpoint1();
	ll n;
	cin>>n;
	ll a[n][3],dp[n][3];
	for(ll i=0;i<n;i++){
		for(ll j=0;j<3;j++)
		{
			cin>>a[i][j];
			if(i==0)
				dp[i][j]=a[i][j];
		}
	}
	for(ll i=1;i<n;i++)
	{
		dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
	return 0;
}


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

int main(){
	int N;
	string P,Q;

	cin >> N;
	rep(i,N){ char c; cin >> c; P+=c;}
	rep(i,N){ char c; cin >> c; Q+=c;}

	vector<string> S;
	string s;
	rep(i,N){ s += (i+1)+'0';}

	do{
		S.push_back(s);
	}while(next_permutation(s.begin(), s.end()));

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

	int a = find(S.begin(),S.end(),P) - S.begin();
	int b = find(S.begin(),S.end(),Q) - S.begin();

	cout << abs(a-b) << endl;

}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
    int N;
    vector<string> S;
    vector<int> color;
    bool dfs(int i, int c) {
        color[i] = c;
        REP(j, N) {
            if (S[i][j] == '1') {
                if (color[j] == c) {
                    return false;
                } else if (color[j] == 0 && !dfs(j, -c)) {
                    return false;
                }
            }
        }
        return true;
    }
    void input() {
        cin >> N;
        S.resize(N);
        REP(i, N) { cin >> S[i]; }
    }
    void output() {
        color.resize(N);
        if (!dfs(0, 1)) {
            cout << -1 << endl;
            return;
        }
        const int INF = 1e9;
        vector<vector<int>> d(N, vector<int>(N, INF));
        REP(i, N) { d[i][i] = 0; }
        REP(i, N - 1) {
            FOR(j, i + 1, N) {
                if (S[i][j] == '1') {
                    d[i][j] = 1;
                    d[j][i] = 1;
                }
            }
        }
        REP(k, N) {
            REP(i, N) {
                REP(j, N) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
            }
        }
        int res = 0;
        REP(i, N) {
            REP(j, N) { res = max(res, d[i][j] + 1); }
        }
        cout << res << endl;
    }

public:
    Main() {
        input();
        output();
    }
};

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

    Main();

    return 0;
}


Measured memory_bytes: 3856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
const long long INF = 1LL << 60;
using namespace std;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

int main() {
string s;
cin >> s;
if(s == "ABC")cout << "ARC";
else cout << "ABC";
return 0;
}

Measured memory_bytes: 3596
using System;
using System.Diagnostics;
using System.IO;

namespace AtCoder.ABC120 {
    class B {
        static void Main() => CustomMain();

        static void Solve() {
            int a, b, k;
            ReadMulti(out a, out b, out k);

            var cnt = 0;
            var start = Math.Min(a, b);
            for (int i = start; i > 0; i--) {
                if (a % i == 0 && b % i == 0) {
                    cnt++;
                }

                if (cnt == k) {
                    WriteAnswer(i);
                    return;
                }
            }
        }

        static void CustomMain() {
#if DEBUG
            // ファイルからテストケースを読み込む
            global::Common.ChangeStdIn();
            // 時間計測
            var stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            // 出力高速化
            var streamWriter = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(streamWriter);
            // 回答
            Solve();
#if DEBUG
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
#endif
            Console.Out.Flush();
        }

        static string ReadString() => Console.ReadLine().Trim();
        static int ReadInt() => int.Parse(ReadString());
        static long ReadLong() => long.Parse(ReadString());
        static float ReadFloat() => float.Parse(ReadString());
        static double ReadDouble => double.Parse(ReadString());

        static string[] ReadStringArray() => ReadString().Split(' ');
        static int[] ReadIntArray() => Array.ConvertAll(ReadString().Split(' '), int.Parse);
        static long[] ReadLongArray() => Array.ConvertAll(ReadString().Split(' '), long.Parse);
        static float[] ReadFloatArray() => Array.ConvertAll(ReadString().Split(' '), float.Parse);
        static double[] ReadDoubleArray() => Array.ConvertAll(ReadString().Split(' '), double.Parse);

        static T TypeConversion<T>(string s) {
            if (typeof(T) == typeof(int)) {
                return (T) Convert.ChangeType(int.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(long)) {
                return (T) Convert.ChangeType(long.Parse(s), typeof(T));
            } else if (typeof(T) == typeof(double)) {
                return (T) Convert.ChangeType(double.Parse(s), typeof(T));
            } else {
                return (T) Convert.ChangeType(s, typeof(T));
            }
        }

        static void ReadMulti<T, U>(out T a, out U b) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
        }

        static void ReadMulti<T, U, V>(out T a, out U b, out V c) {
            var str = ReadStringArray();
            a = TypeConversion<T>(str[0]);
            b = TypeConversion<U>(str[1]);
            c = TypeConversion<V>(str[2]);
        }

        static void WriteAnswer(object ans) => Console.WriteLine(ans);

        static bool IsOdd(long num) {
            return (num & 1) == 1;
        }

        static bool IsEven(long num) {
            return (num & 1) == 0;
        }
    }
}

Measured memory_bytes: 11348
import math

n = int(input())
R = [int(input()) for _ in range(n)]

maxv = -math.inf
minv = R[0]
for i in range(1, n):
    diff = R[i] - minv
    maxv = diff if diff > maxv else maxv
    minv = R[i] if R[i] < minv else minv

print(maxv)


Measured memory_bytes: 13576
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	double n,k,ans = 0; cin >> n >> k;
	FOR(i,1,n+1){
		int m = 0;
		int temp = i;
		while(temp < k){
			temp *= 2;
			++m;
		}
		ans += pow(0.5,m);
	}
	ans /= n;
	cout << fixed << setprecision(10) << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


Measured memory_bytes: 4248
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> m = vector<vector<char>>(h+2, vector<char>(w+2, '.'));
	for (int ii = 0; ii < h; ii++) {
		for (int jj = 0; jj < w; jj++) {
			cin >> m[ii+1][jj+1];
		}
	}

	for (int ii = 1; ii < h + 1; ii++) {
		for (int jj = 1; jj < w + 1; jj++) {
			if (m[ii][jj] == '.') continue;
			if (m[ii - 1][jj] == '#') continue;
			if (m[ii + 1][jj] == '#') continue;
			if (m[ii][jj - 1] == '#') continue;
			if (m[ii][jj + 1] == '#') continue;
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M), c(M);
  vector<vector<int>> d(N, vector<int>(N, INF));
  rep(i, M) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  rep(i, N) {
    d[i][i] = 0;
  }

  auto d_init = d;
  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 0;
  rep(i, N) {
    rep(j, N) {
      if (d[i][j] != d_init[i][j] && d_init[i][j] != INF)
        ans++;
    }
  }
  ans /= 2;
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
	double w,h,x,y;
	cin >> w >> h >> x >> y;
	
	if(w/2 == x && h/2 == y){
		cout << fixed << setprecision(6) << (w*h)/2 << ' ';
		cout << '1' << endl;
	}
	else{
		cout << fixed << setprecision(6) << (w*h)/2 << ' ';
		cout << '0' << endl;
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mxn 1000010
#define db double
#define LL long long
#define ldb long double
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pll pair<LL,LL> 
#define pii pair<int,int> 
#define mp make_pair
#define fr first
#define sc second
#define x1 faqx1
#define y1 faqy1
#define x2 faqx2
#define y2 faqy2
using namespace std;
const int inf=1e9,mod=1e9+7;
LL X,Y,sl,fh,ans;
pll a,b;
int n,m;
LL rd()
{
	sl=0;fh=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch) {if(ch=='-') fh=-1; ch=getchar();}
	while('0'<=ch&&ch<='9') sl=sl*10+ch-'0',ch=getchar();
	return sl*fh;
}
void upd(int &x,int y) {x+=y; if(x>=mod) x-=mod;}
int main()
{
	n=rd();m=rd();a.fr=rd();a.sc=rd();b.fr=rd();b.sc=rd();
	if(a.fr*n+a.sc*m>b.fr*n+b.sc*m) swap(a,b);
	if(a.fr==b.fr||a.fr*n+a.sc*m==b.fr*n+b.sc*m) return puts("infinity"),0;
	if(a.fr<b.fr&&a.sc<=b.sc) return puts("0"),0;
	X=a.fr*n+a.sc*m;Y=b.fr*n+b.sc*m;
	if(a.fr>b.fr) ans=(n*(a.fr-b.fr)/(Y-X))*2+(n*(a.fr-b.fr)%(Y-X)>0);
	else ans=(m*(a.sc-b.sc)+n*(a.fr-b.fr))/(Y-X)+1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<long long, int> prime_factorize(long long n){
  map<long long, int> rtn;
  for(long long i = 2; i * i <= n; ++i){
    while(n % i == 0){
      rtn[i]++;
      n /= i;
    }
  }
  if(n > 1) rtn[n] = 1;
  return rtn;
}
int main(){
  long long  n; cin >> n;
  auto mp = prime_factorize(n);
  int ans = 0;
  for(auto &a: mp){
    int now = 1;
    while(true){
      if(a.second >= now){
        ans++;
        a.second -= now;
        now++;
      }
      else {
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
bool com[10];

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,x;
	int N;
	cin>>N;
	cin>>n;
	loop(i,0,n){
		cin>>x;
		com[x]=true;
	}
	for(int i=N;i<=1000000;i++){
		string s=to_string(i);
		int cnt=0;
		for(int j=0;j<s.size();j++){
				if(com[s[j]-'0']){
				break;
			}
			cnt++;
		}
		if(cnt==s.size()){
			cout<<i;
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
import collections

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

if (a >= k):
    print(k)
elif ((a + b) >= k):
    print(a)
else:
    num_c = k - (a+b)
    print(a - num_c)


Measured memory_bytes: 27136
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(Math.abs(x-a) < Math.abs(x-b)){
            System.out.println("A");
        }
        else{
            System.out.println("B");
        }
    }
}


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

int main() {
    long long n, k, x, y, ans=0;
    cin >> n >> k;
    if(k%2==0) {
        x=n/k;
        y=(n+k/2)/k;
        ans+=x*x*x;
        ans+=y*y*y;

    }
    else {
        x=n/k;
        ans=x*x*x;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    char a[4];
    cin >> a;
    int cnt{0};
    for(int i=0;i<3;i++)
    {
        if(a[i]=='R')
        {
            cnt++;
            if(a[i+1]=='S')
                break;
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+5;
ll a[maxn];
string s;
int main()
{
    //freopen("input.txt","r",stdin);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;

    if(n<=m)
        cout<<min(n,m-n)<<endl;
    else
        cout<<min(n%m,m-(n%m))<<endl;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
	int x, n; cin >> x >> n;
	vi p(n); 
	rep(i, n) {
	    cin >> p[i];
	    p[i] -= x;
	}
	sort(all(p));
	
	int ans = 0;
	int cnt = 1;
	while(1){
	    //cout << ans + x << endl;
	    if(find(all(p), ans) == p.end()) {
	        cout << ans + x <<  endl;
	        return;
	    }
	    if(cnt%2) {
	        ans -= cnt;
	    }
	    else {
	        ans += cnt;
	    }
	    cnt++;
	}
	
    return;
}

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

Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <vector>

class Node {
    public:
        int id;
        int left_id;
        int right_id;
        int parent_id;
        int sibling_id;
        int depth;
        int height;
        Node(); 
        int get_degree();
        void print_type();
};

Node::Node()
{
    id = -1;
    left_id = -1;
    right_id = -1;
    parent_id = -1;
    sibling_id = -1;
    depth = -1;
    height = -1;
}

int Node::get_degree()
{
    return (int)(this->left_id != -1) + (int)(this->right_id != -1);
}

void Node::print_type()
{
    if(this->parent_id == -1) {
        fputs("root", stdout);
    } else if(1 <= this->get_degree()) {
        fputs("internal node", stdout);
    } else {
        fputs("leaf", stdout);
    }
}

int search_root(std::vector<Node>& data, int current_id)
{
    if(data[current_id].parent_id == -1) {
        return current_id;
    } else {
        return search_root(data, data[current_id].parent_id);
    }
}

void validate_depth(std::vector<Node>& data, int current_id, int current_depth)
{
    data[current_id].depth = current_depth;
    if(data[current_id].left_id != -1) {
        validate_depth(data, data[current_id].left_id, current_depth + 1);
    }
    if(data[current_id].right_id != -1) {
        validate_depth(data, data[current_id].right_id, current_depth + 1);
    }
}

void validate_height(std::vector<Node>& data, int current_id)
{
    if(data[current_id].left_id == -1 && data[current_id].right_id == -1) {
        data[current_id].height = 0;
        return;
    }
    int left_height = 0;
    int right_height = 0;
    if(data[current_id].left_id != -1) {
        validate_height(data, data[current_id].left_id);
        left_height = data[data[current_id].left_id].height + 1;
    }
    if(data[current_id].right_id != -1) {
        validate_height(data, data[current_id].right_id);
        right_height = data[data[current_id].right_id].height + 1;
    }
    data[current_id].height = std::max(left_height, right_height);
}

void show_results(std::vector<Node>& data)
{
    for(int i = 0; i < data.size(); i++) {
        printf("node %d: parent = %d, sibling = %d, ", i, data[i].parent_id, data[i].sibling_id);
        printf("degree = %d, ", data[i].get_degree());
        printf("depth = %d, ", data[i].depth);
        printf("height = %d, ", data[i].height);
        data[i].print_type();
        putchar('\n');
    }
}

int main()
{
    int input_size;
    scanf("%d", &input_size);
    std::vector<Node> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        int id, left_id, right_id;
        scanf("%d %d %d", &id, &left_id, &right_id);
        data[id].id = id;
        data[id].left_id = left_id;
        data[id].right_id = right_id;
        if(left_id != -1) {
            data[left_id].parent_id = id;
            data[left_id].sibling_id = right_id;
        }
        if(right_id != -1) {
            data[right_id].parent_id = id;
            data[right_id].sibling_id = left_id;
        }
    }

    int root_id = search_root(data, 0);
    validate_depth(data, root_id, 0);
    validate_height(data, root_id);
    show_results(data);
    return 0;
}

Measured memory_bytes: 2744
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	int N; cin >> N;
	long res = 0;
	long a[1000000]; for (int i = 1; i <= N; i++) cin >> a[i];
	long d[1000000]; for (int i = 1; i <= N; i++) d[i] = a[i] - i;

	sort(d + 1, d + N + 1); long b = (N % 2 == 1) ? d[(N + 1)/ 2] : (d[N / 2] + d[N / 2 + 1]) / 2;

	for (int i = 1; i <= N; i++) res += abs(a[i] - b - i);

	cout << res << endl;

}

Measured memory_bytes: 7424
#include<iostream>
#include<string>
using namespace std;
int main(){
      int n;
      cin>>n;
      long long min=10000000,max=-10000000,s=0;
      for(int i=1;i<=n;i++){
		  int a;
		  cin>>a;
		  s+=a;
		  if(max<a)max=a;
		  if(min>a)min=a;
      }
      cout<<min<<" "<<max<<" "<<s<<endl;
}




Measured memory_bytes: 3120
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    a = [int(ipt()) for i in range(n)]
    a.sort()
    if n%2:
        ans = a[n//2+1]-a[n//2-1]
        for i in range(n//2-1):
            ans += (a[n-1-i]-a[i])*2
        print(ans+max(a[n//2+1]-a[n//2],a[n//2]-a[n//2-1]))
    else:
        ans = a[n//2]-a[n//2-1]
        for i in range(n//2-1):
            ans += (a[n-1-i]-a[i])*2
        print(ans)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
typedef long long ll;
using namespace std;

const int MAXN = 1e3+5;
const int MOD = 1e9+7;

int main()
{
    int h, a, ans;
    scanf("%d%d", &h, &a);
    ans = h / a;
    if (a*ans < h)
        ans++;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair
#define BIN(n,x) bitset<>  
using namespace std;

//BITSET
//bitset< ##no of digits required in binary## > x( ##integral string value## )   // bitset< ##no of digits required in binary## > x( ##number## ) 
//stores binary value of the string in x // constructor sets all values to 0 by default // x.set() sets all value to 1 //x.none() checks for 0{gives bool}
//-->x.count() gives no of 1's //--> x.size() gives total bits //--> x.test(i) returns binary value of i'th bit

//SETPRECISION
//cout<<fixed<<setprecision(#n#)<<x;  --> sets the no of digits of x after decimal to n

//SET STL
//insert();*** count() returns 1 if element is present or 0  **** ;find() {returns iterator pointing to element else returns end iterator}; ---> O(log(N))
//begin();end(){next to last};---->O(1)
//See sorting

//VECTOR STL
//begin(); back();-->O(1)
//sort(v.begin(),v.end()); -->{O(Nlog(N))}

//MAP STL map<U,V> mp; U=key val  V = mapped val
//count(k) (returns 1 if element with key value k is found}-->O(log(N))
//See sorting



long long BERem(long long a, long long b, long long m){
    a%=m;
    long long res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}


int main(){

    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    
    
    


    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	string str;
	cin >> str;
	bool check = false;

	if (str[0] == str[1] && str[2] == str[3] && str[0] != str[2]) {
		check = true;
	}
	else if (str[0] == str[2] && str[1] == str[3] && str[0] != str[1]) {
		check = true;
	}
	else if (str[0] == str[3] && str[1] == str[2] && str[0] != str[1]) {
		check = true;
	}

	if (check) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[][] a = new int[2][n];
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < n; j++){
                a[i][j] = scan.nextInt();
            }
        }
        int[][] sum = new int[2][n];
        sum[0][0] = a[0][0];
        sum[1][0] = a[1][0];
        for(int i = 1; i < n; i++){
            sum[0][i] = sum[0][i - 1] + a[0][i];
            sum[1][i] = sum[1][i - 1] + a[1][i];
        }
        int out = 0;
        for(int i = 0; i < n; i++){
            out = Math.max(out, sum[0][i] + sum[1][n - 1] - sum[1][i] + a[1][i]);
        }
        System.out.println(out);
    }

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


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

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

void debug(vector<string> c) {
  rep(_i,c.size()) {
    rep(_j,c[0].size()) {
      cout << c[_i][_j];
    }
    cout << endl;
  }
}

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

  int res = 0;
  for (int gyou = 0; gyou < (1 << h); gyou++) {
    for (int retu = 0; retu < (1 << w); retu++) {
      //cout << bitset<2> (gyou) << " & " << bitset<3> (retu) << endl;
      vector<string> c = grid;
      rep(i,h) if (gyou & (1 << i)) { rep(j,w) c[i][j] = 'A'; }
      rep(i,w) if (retu & (1 << i)) { rep(j,h) c[j][i] = 'A'; }
      if (cheaker(c) == k) res++;
      //debug(c);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def argmax(a):
    index, value = -1, -float("inf")
    for i, v in enumerate(a):
        if value < v:
            index, value = i, v
    return index, value


def argmin(a):
    index, value = -1, float("inf")
    for i, v in enumerate(a):
        if value > v:
            index, value = i, v
    return index, value


def solve(N: int, a: "List[int]"):
    # 正のみからなる数列に直す
    amin_arg, amin = argmin(a)
    amax_arg, amax = argmax(a)
    ans = []
    if abs(amin) <= abs(amax):
        for i in range(N):
            if a[i] < 0:
                ans.append([amax_arg+1, i+1])
                a[i] += amax
        # すべて0以上の要素の数列となった
        # print(a)
        # 累積和の要領
        for i in range(N-1):
            if a[i] > a[i+1]:
                ans.append([i+1, i+2])
                a[i+1] += a[i]
        # print(a)

    else:
        for i in range(N):
            if a[i] > 0:
                ans.append([amin_arg+1, i+1])
                a[i] += amin
        # すべて0以下の要素の数列となった。
        # print(a)
        # 累積和の要領
        for i in range(N-1, 0, -1):
            if a[i-1] > a[i]:
                ans.append([i+1, i])
                a[i-1] += a[i]
        # print(a)
    print(len(ans))
    for a in ans:
        print(*a)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;

#define deb(x) cerr<<#x<<":"<<x<<"\n";
#define dvi(x) for(ll i=0;i<x.size();i++)cerr<<#x<<"["<<i<<"]:"<<x[i]<<" ";
#define iter(v) for(auto it:v)
#define wt ll t;cin>>t;while(t--)
#define rl(x) ll x;cin>>x;
#define rvi(x,n) vi x(n);for(ll i=0;i<n;i++) cin>>x[i];
#define rs(x) string x;cin>>x;
#define w(x) cout<<x<<endl;
#define wvi(x) for(ll i=0;i<x.size();i++) cout<<x[i]<<" ";cout<<endl;
#define ws(x) cout<<x<<endl;
#define all(v) v.begin(),v.end()
#define pb push_back
#define ppb pop_back
#define pll pair<ll, ll>
#define fo(i,n) for(ll i=0;i<n;i++)
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
const ll N = 1e9+7;

map<long long, long long> factorize(long long n) {	//returns map containing factor and multiplicity, Eg: 60 = {{2,2},{3,1},{5,1}}
	map<long long, long long> ans;
	for (long long i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ans[i]++;
			n /= i;
		}
	}
	if (n > 1) {
		ans[n]++;
		n = 1;
	}
	return ans;
}

void FAST() {	//FAST Input Output, DONT use both scnaf,prllf / cin,cout , Use any ONE system
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt","w", stdout);
    #endif
	FAST();
	rl(n)
	ll ans=2;
	if(n==1)cout<<0;
	else
	{
		ans=binpow(10,n,N);
		ll val=binpow(9,n,N);
		val*=2;
		val%=N;
		ans+=N-val;
		ans+=binpow(8,n,N);
		ans%=N;
		cout<<ans;
	}
	
}

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

using namespace std;

#define P(s) cout << s << endl;
#define DEBUG(x) cout << #x << ": " << x << endl;
#define INF 1 << 29

vector<int> rs; // 巡回必要なもの全てRs
int Cs[201][201] = {0}; // 全パスの距離

int main() {

  int N, M, R;
  cin >> N >> M >> R;
  
  for (int i = 0; i < R; i++) {
    int r;
    cin >> r;
    rs.push_back(r);
  }

  for (int i = 1; i <= N; i++) { 
    for (int j = 1; j <= N; j++) { 
      if (i != j) {
        Cs[i][j] = INF;
      }
    }
  } // fill

  for (int i = 0; i < M; i++) {
    int A, B, C;
    cin >> A >> B >> C;
    Cs[A][B] = C;
    Cs[B][A] = C;
  }

  // cout << "---------" << endl;
  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }
  // cout << "---------" << endl;

  // 1. ワーシャルフロイドですべての頂点の対の最小距離を求める
  for (int k = 1; k <= N; k++) {
    for (int i = 1; i <= N; i++) { 
      for (int j = 1; j <= N; j++) { 
        if(Cs[i][k] != INF && Cs[k][j] != INF) { // オーバーフロー対策!!!!
          Cs[i][j] = min(Cs[i][j], Cs[i][k] + Cs[k][j]);
        }
      }
    }
  }

  // for (int i = 1; i <= N; i++) { 
  //   for (int j = 1; j <= N; j++) { 
  //     DEBUG(i);
  //     DEBUG(j);
  //     DEBUG(Cs[i][j]);
  //   }
  // }

  // 2. rsのすべての順列組み合わせを作り、最短距離を使ってそれぞれの全コストを求め、最短を出力
  vector<int> paths = rs;
  int min = INF;
  sort(paths.begin(), paths.end()); // next_permutation は sortされている必要があった！
  do {
    int sum = 0;
    for (int i = 0; i < R - 1; i++) {
      int start = paths[i];
      int end = paths[i + 1];
      sum = sum + Cs[start][end];
      // cout << start << "->" << end << " ";
    }
    // cout << " : " << sum << endl;
    if (sum <= min) min = sum;
  } while (next_permutation(paths.begin(), paths.end()));

  cout << min << endl;
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;

constexpr int inf = 1ll<<61;
constexpr int mod = 1e9+7;

map<int,int> pf(int n){
  map<int,int> res;
  int i = 2;
  while(n != 1){
    if(n % i == 0){
      res[i]++;
      n /= i;
    }else
      i++;
  }
    
  return res;
}

class ModuloCombination{
public:
  vector<ll> fact, fact_inv;

  static ll mod_pow(ll a, ll n){
    if(n == 0) return 1;
    if(n % 2 == 0) return mod_pow((a * a) % mod, n/2);
    return (a * mod_pow(a, n-1) % mod);
  }

  ModuloCombination(ll N):fact(N+1), fact_inv(N+1){ // N log Nで初期化
    fact[0] = 1;
    FOR(i, 1, N+1) fact[i] = (i * fact[i-1]) % mod;
    FOR(i, 0, N+1) fact_inv[i] = mod_pow(fact[i], mod-2);
  }

  ll op(ll n, ll r){ // nCr
    if(r < 0 or n < r) return 0;
    return fact[n] * fact_inv[r] % mod * fact_inv[n-r] % mod;
  }
};

main(){
  int n,m; cin >> n >> m;
  auto fact = pf(m);
  dump(fact);

  ModuloCombination C(n+30);
  int res = 1;
  for(auto x : fact){
    int tmp = C.op(n+x.second-1,x.second);
    tmp %= mod;
    dump(x.fst,x.snd,tmp);
    res *= tmp;
    res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<utility>
#include<bitset>
#include<complex>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=a; i<=b; ++i)
#define FOR(i,a,b) for(int i=a; i<b; ++i)
#define MP make_pair
typedef long long LL;
typedef pair<int,int> pii;


int main() {
	LL n, a, b;
	scanf("%lld%lld%lld", &n, &a, &b);
	LL res = (n-1)*b + a - (n-1)*a - b + 1;
	printf("%lld\n", max(res, 0LL));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
  int a,b;
  std::cin >> a>>b;
  std::cout << max({a+b,a-b,a*b}) << std::endl;
  
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) {
    Main m = new Main();
    m.run();
  }
  private void run() {
    String s = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
      s = br.readLine();
    } catch (IOException e) {
      e.printStackTrace();
    }
    s = s.replaceAll("[ABDEG-Z]","");
    if (s.contains("CF")) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 21972
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()

dp = [[0 for j in range(13)] for i in range(len(S)+1)]
dp[0][0] = 1
for i in range(len(S)):
    if S[i] != "?":
        k = int(S[i])
        for j in range(13):
            dp[i+1][(j*10+k)%13] = (dp[i+1][(j*10+k)%13] + dp[i][j])% mod
    else:
        for k in range(10):
            for j in range(13):
                dp[i + 1][(j * 10 + k) % 13] = (dp[i + 1][(j * 10 + k) % 13] + dp[i][j]) % mod

print(dp[len(S)][5] % mod)


Measured memory_bytes: 101300