akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	p := make([]int, N+1)
	dp := make([][]int, N+1)
	for i, _ := range dp {
		dp[i] = make([]int, N+1)
	}
	for i := 0; i < N; i++ {
		p[i] = sc.nextInt()
		p[i+1] = sc.nextInt()
	}
	for i := 1; i <= N; i++ {
		dp[i][i] = 0
	}
	for l := 2; l <= N; l++ {
		for i := 1; i <= N-l+1; i++ {
			j := i + l - 1
			dp[i][j] = 1 << 60
			for k := i; k <= j-1; k++ {
				dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j])
			}
		}
	}

	fmt.Fprintln(wtr, dp[1][N])
	wtr.Flush()
}



Measured memory_bytes: 1192
//16-3 ????????¢??????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int W[100] = {};
    int B[100] = {};
    int R[100] = {};
    for(int i=0; i<N; i++){
        string S;
        cin >> S;
        for(int j=0; j<M; j++){
            if(S[j] == 'W'){
                W[i]++;
            }
            else if(S[j] == 'B'){
                B[i]++;
            }
            else if(S[j] == 'R'){
                R[i]++;
            }
        }
    }
    int min1 = 999999;
    for(int i=0; i<N-2; i++){
        int tmp1 = 0;
        for(int j=0; j<i+1; j++){
            tmp1 += B[j] + R[j];
        }
        int min2 = 999999;
        for(int j=i+1; j<N-1; j++){
            int tmp2 = 0;
            for(int k=i+1; k<j+1; k++){
                tmp2 += W[k] + R[k];
            }
            for(int k=j+1; k<N; k++){
                tmp2 += W[k] + B[k];
            }
            if(tmp2 < min2) min2 = tmp2;
        }
        if(tmp1+min2 < min1) min1 = tmp1 + min2;
    }
    cout << min1 << endl;
    return 0;
}


Measured memory_bytes: 3148
#include <cstdio>
#include <algorithm>
#include <cstring>
const int maxn = 3e5 + 5;
using namespace std;

int N;
int a[maxn][4];
int dp[maxn][4];
int main()
{
	scanf("%d", &N);
	for(int i = 1;i <= N;i++)
	{
		for(int j = 1;j <= 3;j++)		
		{
			scanf("%d", &a[i][j]);
		}
	}
	memset(dp, 0, sizeof dp);
	for(int i = 1;i <= 3;i++)
		dp[1][i] = a[1][i];
	for(int i = 2;i <= N;i++)
	{
		dp[i][1] = max(dp[i - 1][2] + a[i][1], dp[i - 1][3] + a[i][1]);
		dp[i][2] = max(dp[i - 1][1] + a[i][2], dp[i - 1][3] + a[i][2]);
		dp[i][3] = max(dp[i - 1][1] + a[i][3], dp[i - 1][2] + a[i][3]);
	}
	int ans = 0;
	for(int i = 1;i <= 3;i++)
		ans = max(dp[N][i], ans);
	printf("%d\n", ans);
	return 0;	
}

Measured memory_bytes: 8320
#include <stdio.h>
#include <math.h>
 
int main(void)
{
  int a, sum;
  scanf("%d", &a);
  for (int i = 0; i < 3; i++)
  {
    sum += pow(a, i + 1);
  }
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iterator>
#include<math.h>
#define debug() puts("what the fuck")
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
    int  n,k,s;
    cin>>n>>k>>s;
    for(int i=1;i<=k;i++)
        cout<<s<<' ';
        if(s==1e9)
        {
            for(int i=1;i<=n-k;i++)
                cout<<1<<' ';
        }
        else
        {
            for(int i=1;i<=n-k;i++)
        cout<<s+5<<' ';
        }
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int q;cin>>q;
  REP(i,q){
    ll a,b;cin>>a>>b;
    if(a>b)swap(a,b);
    ll c=a*b;
    ll d=sqrt(c);
    if(d*d==c && d==a){
      P(2*d-2);
    }else if(d*d==c && d!=a){
      P(2*d-3);
    }else if(d*(d+1)<c){
      P(2*d-1);
    }else{
      P(2*d-2);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<pair<int, int>> xl(n);
	REP(i,n){
		int x,l;
		cin >> x >> l;
		xl[i] = make_pair(x+l,x-l);
	}
	sort(ALL(xl));
	int res = 0;
	int end_p = -1e9;
	REP(i,n){
		if(xl[i].second >= end_p){
			end_p = xl[i].first;
			res++;
		}
	}
	cout << res << '\n';
	return 0;
}



Measured memory_bytes: 1024
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>

long solve(
    long n,
    long m,
    long k,
    const std::vector<long>& minutes_a,
    const std::vector<long>& minutes_b)
{
  long count_a = 0;
  long sum_a = 0;
  for (; count_a < n;) {
    const auto a = minutes_a.at(count_a);
    if (sum_a + a > k) break;
    sum_a += a;
    ++count_a;
  }

  long result = count_a;


  long count_b = 0;
  long sum_b = 0;
  for (; count_b < m;) {
    const auto b = minutes_b.at(count_b);

    while (sum_a > 0 && sum_a + sum_b + b > k) {
      --count_a;
      sum_a -= minutes_a.at(count_a);
    }

    if (sum_a + sum_b + b > k) break;
    sum_b += b;
    ++count_b;
    result = std::max(result, count_a + count_b);
  }

  return result;
}

int main()
{
  long n, m, k;
  std::cin >> n >> m >> k;
  std::vector<long> minutes_a(n);
  std::vector<long> minutes_b(m);
  for (auto& a : minutes_a) {
    std::cin >> a;
  }
  for (auto& b : minutes_b) {
    std::cin >> b;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, m, k, minutes_a, minutes_b) << std::endl;
}


Measured memory_bytes: 6424
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    string S;
    cin >> N >> S;
    string ans;
    for (const char ch : S)
    {
        if (ch + N > 'Z')
        {
            ans += ch + N - 26;
        }
        else
        {
            ans += ch + N;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll h,n; cin >> h >> n;
	ll sum = 0;
	rep(i,n){
		ll a; cin >> a;
		sum += a;
	}
	if(sum >= h) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<int> W(n, 0), E(n, 0);
    for(int i=0; i<n-1; i++){
        W[i+1] = W[i] + (s[i] == 'W');
    }
    int ans = W.back();
    for(int i=n-1; i>=1; i--){
        E[i-1] = E[i] + (s[i] == 'E');
        ans = min(ans, W[i-1] + E[i-1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6156
# -*- coding: utf-8 -*-
import sys
import math
import copy

def main():
	S = input()
	S = list(S)
	length = len(S)
	
	con = []
	for i in range(2 ** (length-1)):
		tmp = []
		for j in range(length):
			if (i >> j) & 1 == 1:
				tmp.append("+")
			else:
				tmp.append("")
		con.append(tmp)
	
	ans = 0
	for i, val in enumerate(con):
		counts = 0
		tmp = copy.deepcopy(S)
		for j, vol in enumerate(val):
			if vol == "+":
				counts += 1
				tmp.insert(j + counts, "+")
				
		lin = "".join(tmp)
		lin = lin.split("+")
		for i in lin:
			ans += int(i)
	
	print(ans)
	
if __name__ == "__main__":
	main()
	

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV int(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

/*Coding Space*/
int n; string s;

using tss = tuple<string,string>;
map<tss,ll> ltable;
map<tss,ll> rtable;
int main(){
  cin >> n >> s;
  rep(i,(1<<n)){
    string lin1 = "",lin2 = "", rin1 ="", rin2 = "";
    rep(j,n){
      if(i&(1 << j)){
        lin1 += s[j];
        rin1 += s[j+n];
      }else{
        lin2 += s[j];
        rin2 += s[j+n];
      }
    }
    ltable[tss{lin1,lin2}]++;
    rtable[tss{rin1,rin2}]++;
  }
  ll ans = 0;
  for(auto ss: ltable){
    string a,b; tie(a,b) = ss.FST;
    string ta = a,tb = b;
    reverse(ALL(ta)),reverse(ALL(tb));
    ans += rtable[tss{ta,tb}]*ss.SEC;
    //cerr << ans << " " << a << " " << b << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 132864
package main

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

func main() {
	a := getInt()
	b := getInt()
	c := getInt()
	d := getInt()
	e := getInt()
	f := getInt()

	concentration := 0.0
	ansSum := 0
	ansSugar := 0
	for i := 0; ; i++ {
		untilA := (a * 100 * i)
		if untilA > f {
			break
		}
		for j := 0; ; j++ {
			untilB := untilA + (b * 100 * j)
			if untilB > f {
				break
			}
			if untilB == 0 {
				continue
			}
			for k := 0; ; k++ {
				untilC := untilB + (c * k)
				if untilC > f {
					break
				}
				for l := 0; ; l++ {
					sum := untilC + (d * l)
					if sum > f {
						break
					}
					water := untilB
					sugar := sum - untilB
					if float64(sugar)/(float64(water)/100.0) > float64(e) {
						break
					}

					tmp := float64(100*sugar) / float64(water+sugar)
					if tmp >= concentration {
						concentration = tmp
						ansSum = sum
						ansSugar = sugar
					}
				}
			}
		}
	}

	fmt.Println(ansSum, ansSugar)
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

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

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


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


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> row_cnt(h + 1, 0);
    vector<int> col_cnt(w + 1, 0);
    set<pair<int,int>> target;
    for (int i = 1; i <= m; i++) {
        int x, y;
        cin >> x >> y;
        row_cnt[x]++;
        col_cnt[y]++;
        target.insert({x, y});
    }
    int mx_row = *max_element(row_cnt.begin(), row_cnt.end());
    int mx_col = *max_element(col_cnt.begin(), col_cnt.end());
    vector<int> mx_rows;
    vector<int> mx_cols;
    for (int i = 1; i <= h; i++) {
        if (row_cnt[i] == mx_row) mx_rows.push_back(i);
    }
    for (int i = 1; i <= w; i++) {
        if (col_cnt[i] == mx_col) mx_cols.push_back(i);
    }
    int ans = mx_row + mx_col;
    int repeated = 0;
    for (int i = 0; i < mx_rows.size(); i++) {
        int x = mx_rows[i];
        for (int j = 0; j < mx_cols.size(); j++) {
            int y = mx_cols[j];
            if (target.find({x, y}) == target.end()) {
                repeated = 1;
                break;
            }
        }
    }
    cout << ans - (not repeated ? 1 : 0) << '\n'; 
    return 0;
}

Measured memory_bytes: 23748
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;


int main() {
  string S;
  cin >> S;
  vector<vector<long long>> dp(110000,vector<long long>(13));
  dp[0][0] = 1;
  REP(i,S.size()){
    int c;
    if (S[i] == '?'){
      c = -1;
    }else{
      c = S[i] - '0';
    }

    REP(j,10){
      if(c!=-1 && c!=j) continue;
      REP(ki,13){
        dp[i+1][(ki*10 + j)%13] += dp[i][ki];
      }
    }
    REP(j,13) dp[i+1][j] %= MOD;
  }

  long long res = dp[S.size()][5];
  cout << res << endl;

}

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

int main(){
  int N;
  cin >> N;
  ll M;
  // vector<int> A(N);
  vector<int> X(100005,0);
  rep(i,N){
    int a;
    cin >> a;
    M += a;
    X.at(a)++;
  }
  int Q;
  cin >> Q;
  vector<int> B(100005);
  vector<int> D(100005);
  rep(i,Q){
    int b,c;
    cin >> b >> c;
    M += X.at(b) * (c-b);
    cout << M << endl;
    X.at(c) += X.at(b);
    X.at(b) = 0;
  }
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n, k;
	cin >> n >> k;
	VI h(n);
	REP(i, n)cin >> h[i];
	VI dp(100010, INF);
	dp[0] = 0;
	FOR(i, 1, n) {
		FOR(j, 1, k + 1) {
			if (i >= j) {
				dp[i] = min(dp[i - j] + abs(h[i] - h[i - j]), dp[i]);
			}
		}
		//dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]));
	}
	cout << dp[n-1] << endl;

	return 0;
}


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

#define ll long long

int main(){
    int n;
    cin >> n;
    vector<long long> luca;
    luca.push_back(2);
    luca.push_back(1);
    if(n >= 2){
        for(int i = 2; i <= n; i++){
            luca.push_back(luca[i - 2] + luca[i - 1]);
        }
    }

    cout << luca[n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

template <typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>> &G) {
    const T INF = numeric_limits<T>::max();
    using P     = pair<T, int>;
    int n       = G.size();
    vector<T> d(n, INF);
    vector<int> b(n, -1);
    priority_queue<P, vector<P>, greater<P>> q;
    d[s] = 0;
    q.emplace(d[s], s);
    while (!q.empty()) {
        P p = q.top();
        q.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (auto &e : G[v]) {
            int u = e.first;
            T c   = e.second;
            if (d[u] > d[v] + c) {
                d[u] = d[v] + c;
                b[u] = v;
                q.emplace(d[u], u);
            }
        }
    }
    return d;
}

int main() {
    int n, m, l;
    cin >> n >> m >> l;
    vector<vector<pair<int, ll>>> edges(n);
    for (int i = 0; i < m; ++i) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    int q;
    cin >> q;
    vi s(q), t(q);
    for (int i = 0; i < q; ++i) {
        cin >> s[i] >> t[i];
        s[i]--, t[i]--;
    }
    vvl ret(n, vl(n, INF));
    for (int i = 0; i < n; ++i) {
        ret[i][i] = 0;
    }
    vvl dist;
    for (int i = 0; i < n; ++i) {
        dist.push_back(dijkstra(i, edges));
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (dist[i][j] <= l)
                dist[i][j] = 1;
            else
                dist[i][j] = INF;
        }
    }
    for (int i = 0; i < n; i++)         // 経由する頂点
        for (int j = 0; j < n; j++)     // 開始頂点
            for (int k = 0; k < n; k++) // 終端
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
    for (int i = 0; i < q; ++i) {
        if (dist[s[i]][t[i]] == INF)
            cout << -1 << "\n";
        else
            cout << dist[s[i]][t[i]] - 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int work(int i,int j){
    i--,j--;
    int xxx=i^j,ans=0;
    while(xxx){
        ans++,xxx>>=1;
    }
    return ans;
}
int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            cout<<work(i,j)<<" ";
        }
        cout<< endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define INF pow(10, 9) + 7
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define chmax(x, y) x = max(x, y)
#define print(x) cout << x << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

vl div(ll n){
	vl ret;
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0){
		  ret.push_back(i);
		  if(i * i != n) ret.push_back(n / i);
		}
	}
	SORT(ret);
	return ret;
}

void solve(){
	
	ll N, M, d;
	cin >> N >> M;
	ll ans = 0;
	
	vl m = div(M);
	rep(i, m.size()){
		
		d = (ll)(M / m[i]);
		if(d >= N) ans = m[i];
		
	}
	
	print(ans);

}	

int main(){
    
    fastio;
	solve();
    
	return 0;
	
}


Measured memory_bytes: 3644
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
  if 500 * i > X:
    break
  for j in range(B + 1):
    if 500 * i + 100 * j > X:
      break
    tmp = X - 500 * i - 100 * j
    if tmp % 50 == 0 and tmp // 50 <= C:
      ans += 1
print(ans)

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

vector<int> get_acc(int n) {
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    vector<int> acc(n + 1);
    for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
    return acc;
}

int main() {
    int n; cin >> n;
    auto acc_t = get_acc(n);
    auto acc_b = get_acc(n);
    int ma = 0;
    for (int i = 0; i < n; i++) {
        ma = max(ma, acc_t[i + 1] + acc_b[n] - acc_b[i]);
    }
    cout << ma << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  string s;
  cin>>s;
  if(s[0]=='7'||s[1]=='7'||s[2]=='7') cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	long long int n,q,h,s,d;
	cin>>q>>h>>s>>d>>n;
	s=min(min(s,h*2),q*4);
	d=min(s*2,d);
	cout<<n/2*d+(n%2)*s<<endl;
}


Measured memory_bytes: 256
A, B = map(int, input().split())

def floor(x, f):
    res = int(x / f)
    if int(res * f) < x:
        res += 1
    return res

ra = [floor(A, 0.08), floor(A + 1, 0.08)]
rb = [floor(B, 0.1), floor(B + 1, 0.1)]

if ra[1] <= rb[0] or rb[1] <= ra[0]:
    print(-1)
else:
    print(max(ra[0], rb[0]))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0, loop##i = (int)(n); i < loop##i; ++i)
#define FORE(x, c) for (auto &x : c)
#define ALL(x) x.begin(), x.end()
#define SZ(x) ((int)(x.size()))

#define dump(x) cerr << #x << ": " << x << endl

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

signed main() {
	while (1) {
		int A, B, P;
		cin >> A >> B >> P;
		if (A == 0 && B == 0 && P == 0) break;
		
		int N = B - A;
		vector<int> dp(N + 2, 0);
		vector<int> add(N + 2, 0);
		for (int i = 0; i <= N; ++i) {
			if (i > 0) (add[i] += add[i - 1]) %= P;
			(dp[i] += add[i] + 1) %= P;

			int len = SZ(to_string(i + A));	
			int R = 1;
			REP(i, len) R *= 10;
			R--;
			R = min(R, B);
			int L = i + A;

			if (L > R) continue;
			for (int j = 0; j < 10; ++j) {
				if (max(i + A + 1, L) > B) break;
				(add[max(i + A + 1, L) - A] += dp[i]) %= P;
				add[R - A + 1] = (add[R - A + 1] - dp[i] + P) % P;
				if (R >= B) break;
				L *= 10;
				R *= 10;
				R += 9;
				R = min(R, B);
			}
		}
		
		int ans = 0;
		for (int i = 0; i <= N; ++i) {
			ans += dp[i];
		  	ans %= P;
		}
		cout << ans << endl;
	}
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N, K;
P dat[100005];

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

	cin >> N >> K;

	for (int i = 0;i < N;i++){
		cin >> dat[i].first >> dat[i].second;
	}	

	sort(dat,dat+N); reverse(dat,dat+N);

	priority_queue<ll,vector<ll>, greater<ll> > a;
	priority_queue<ll>                          b;

	ll p = -1;
	ll sum = 0;
	ll numt = 0;
	for (int i = 0;i < N;i++){
		ll t = dat[i].first;
		ll d = dat[i].second;
		if(p != t){
				numt++;
				sum += d;
			   	a.push(d);
		}
		else b.push(d);
		p = t;
	}

	while(numt > K && a.size()){
		sum -= a.top();
		a.pop();
		numt--;
	}

	ll nums = numt;

	while(nums < K && b.size()){
		sum += b.top();
		nums++;
		b.pop();
	}

	ll ans = sum + numt*numt;

	while(a.size() && b.size()){
		sum -= a.top();
		a.pop();
		numt--;
		sum += b.top();
		b.pop();
		ll val = sum + numt*numt;
		if(val > ans) ans = val;
		else break;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 2936
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val dList = readLine()!!.split(" ").map { it.toInt() }
    var sum = 0
    for (x in 0 until n) {
        for (y in x+1 until n) {
            sum += dList[x] * dList[y]
        }
    }
    println(sum)
}

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

using namespace std;

typedef long long ll;

ll P[202020], C[101010], K[101010];
ll S[101010], E[101010], V[101010];
ll n, m, k, t, ans, cnt;

ll find(ll p) { return p == P[p]? p : P[p] = find(P[p]); }

int main()
{
	int i, s, e;
	
	scanf("%lld%lld%lld", &n, &m, &k);
	
	t = k;
	for(i=1; i<=n; i++){
		scanf("%lld", C+i);
		if(C[i] == 0) C[i] = ++t;
	}
	
	for(i=1; i<=t; i++) P[i] = i;
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld%lld", S+i, E+i, V+i);
		K[i] = i;
	}
	
	sort(K+1, K+m+1, [=](int ca, int cb){
		return V[ca] < V[cb];
	});
	
	for(i=1; i<=m; i++){
		s = find(C[S[K[i]]]);
		e = find(C[E[K[i]]]);
		if(s != e){
			P[s] = e;
			ans += V[K[i]];
			cnt ++;
		}
		
		if(cnt == k - 1) break;
	}
	
	if(i > m) printf("-1\n");
	else printf("%lld\n", ans);
	
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

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

int main(){
	int n;
	cin>>n;
	vector<pii> v;
	for (int i = 0; i < n; i++){
		int a,b;
		cin>>a>>b;
		v.push_back(make_pair(a+b,a-b));
	}

	sort(all(v));

	int ans=0;
	int now=-1000000010;
	for (int i = 0; i < n; i++){
		int r=v[i].first;
		int l=v[i].second;
		if(now<=l){
			ans++;
			now=r;
		}
	}

	cout<<ans<<endl;



	return 0;
}


Measured memory_bytes: 1400
n, m = map(int, input().split())
drinks = []
for i in range(n):
  drinks.append(list(map(int, input().split())))
  
drinks.sort(key=lambda x: x[0])
ans = 0
i = 0
while m > 0:
  buy = min(m, drinks[i][1])
  ans += drinks[i][0] * buy
  m -= buy
  i += 1
print(ans)

Measured memory_bytes: 29024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class abc125c
{
    public static int GCD(int a, int b)
    {
        if(b > a)
            Swap(ref a, ref b);
        if(b == 0)
            return a;
        return GCD(b, a % b);
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var temp = a;
        a = b;
        b = temp;
    }

    static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);

        var L = Enumerable.Repeat(0, N).ToList();
        for(var i = 0; i != N; ++i) {
            L[i] = i == 0 ? 0 : GCD(L[i - 1], A[i - 1]);
        }

        var R = Enumerable.Repeat(0, N).ToList();
        R[N - 1] = 0;
        R[N - 2] = A[N - 1];
        for(var i = N - 3; i >= 0; --i) {
            R[i] = GCD(R[i + 1], A[i + 1]);
        }

        var answer = 0;
        for(var i = 0; i != N; ++i) {
            answer = Math.Max(GCD(L[i], R[i]), answer);
        }
        Console.WriteLine(answer);
    }
}


Measured memory_bytes: 29276
/*
Submitted With (^^) by -> Hossam ^_^
 _____________________
|     ___     ___     |
|    (^_^)   (^_^)    |
|   /( | )\_/( | )\   |
|_____|_|_____|_|_____|
*/

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

using namespace std;

inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

#define X first
#define Y second
#define endl '\n'
#define ll long long
#define inf (0x7fffffffffffffff)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << (x) << "\n";
#define ZXC cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl;

// const int mod = (int)1e9 + 7;
const int mod = 998244353;
const int MX = (int)1e5 + 10;

int main()
{
    prep();

    int a, b, k;
    cin >> k >> a >> b;

    if(a - 1 + 2 > k || b - a <= 2){cout << k + 1; return 0;}

    //first reach A yens
    k -= a - 1 + 2;

    ll have = b + (k / 2) * 1ll * (b - a) + k % 2;
    cout << have << endl;


    return 0;
}

Measured memory_bytes: 256
from collections import Counter
import sys

n = int(input())
C = Counter(list(map(int, input().split())))

if n % 2 == 0:
    for key in C.keys():
        if C[key] != 2:
            print(0)
            sys.exit()
    print(pow(2,n//2,10**9+7))
else:
    for key in C.keys():
        if key == 0:
            if C[key] != 1:
                print(0)
                sys.exit()
        else:
            if C[key] != 2:
                print(0)
                sys.exit()
    print(pow(2,n//2,10**9+7))

Measured memory_bytes: 14820
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  sort(all(a));
  vector<ll> sum(n+1); rep(i,n) sum[i+1] += sum[i]+a[i];
  int ans = 0;
  for(int i = n-1; 0 <= i; i--){
    if(a[i] <= 2*sum[i]) ans++;
    else break;
  }
  cout << ans+1;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4476
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<long long>Wx, Wy, Vx, Vy;
long long X1[2100], Y1[2100], X2[2100], Y2[2100], n, dp[4100][4100], sum;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		Wx.push_back(X1[i]); Wx.push_back(X2[i]);
		Wy.push_back(Y1[i]); Wy.push_back(Y2[i]);
	}
	sort(Wx.begin(), Wx.end()); sort(Wy.begin(), Wy.end());
	for (int i = 0; i < Wx.size(); i++) {
		if (i == 0 || Wx[i] != Wx[i - 1])Vx.push_back(Wx[i]);
		if (i == 0 || Wy[i] != Wy[i - 1])Vy.push_back(Wy[i]);
	}
	for (int i = 0; i < n; i++) {
		int pos1 = lower_bound(Vx.begin(), Vx.end(), X1[i]) - Vx.begin();
		int pos3 = lower_bound(Vx.begin(), Vx.end(), X2[i]) - Vx.begin();
		int pos2 = lower_bound(Vy.begin(), Vy.end(), Y1[i]) - Vy.begin();
		int pos4 = lower_bound(Vy.begin(), Vy.end(), Y2[i]) - Vy.begin();
		dp[pos1][pos2]++; dp[pos3][pos2]--; dp[pos1][pos4]--; dp[pos3][pos4]++;
	}
	for (int i = 0; i < 4100; i++) {
		for (int j = 1; j < 4100; j++)dp[i][j] += dp[i][j - 1];
	}
	for (int i = 1; i < 4100; i++) {
		for (int j = 0; j < 4100; j++)dp[i][j] += dp[i - 1][j];
	}
	for (int i = 0; i < Vx.size(); i++) {
		for (int j = 0; j < Vy.size(); j++) {
			if (dp[i][j] >= 1)sum += (Vx[i + 1] - Vx[i])*(Vy[j + 1] - Vy[j]);
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 134636
package main

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

var sc = bufio.NewScanner(os.Stdin)

type st struct {
	ind int
	min int64
}

func main() {
	var T string
	var S string
	fmt.Scan(&S)
	fmt.Scan(&T)
	min := math.MaxInt32
	for i := 0; i < len(S)-len(T)+1; i++ {
		tmp := S[i : i+len(T)]
		ct := 0
		for j := 0; j < len(T); j++ {
			if tmp[j] != T[j] {
				ct++
			}
		}
		min = Min(ct, min)
	}

	// sc.Split(bufio.ScanWords)
	fmt.Print(min)
}
func bc(s string, pos int) string {
	ch := "1"
	if string(s[pos]) == "1" {
		ch = "0"
	}
	pre := string(s[:pos])
	post := ""
	if pos != len(s)-1 {
		post = string(s[pos+1:])
	}
	tmp := pre + ch + post
	return tmp
}
func popCount(n string) int {
	count := 0
	for _, s := range n {
		if string(s) == "1" {
			count++
		}
	}
	return count
}
func chc(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for i, l := range m {
		tmp := []bool{}
		for _, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[i] = tmp
	}
	return ret
}
func chl(m [][]bool, p int) [][]bool {
	ret := make([][]bool, len(m))
	for j, l := range m {
		tmp := []bool{}
		for i, c := range l {
			if i == p {
				tmp = append(tmp, false)
			} else if c == true {
				tmp = append(tmp, true)
			} else {
				tmp = append(tmp, false)
			}
		}
		ret[j] = tmp
	}
	return ret
}
func helper(ma [][]bool) int {
	count := 0
	for _, l := range ma {
		for _, c := range l {
			if c == true {
				count++
			}
		}
	}
	return count
}
func nextLine() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int64 {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return int64(i)
}
func MySort(a []int) {
	sort.Slice(a, func(i, j int) bool { return a[i] < a[j] })

}
func SortedBinaryAppend(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinaryDelete(sortedArr []int, targetValue int) []int {
	return []int{}
}
func SortedBinarySearch(sortedArr []int, targetValue int) int {
	post := len(sortedArr) - 1
	pre := 0
	for {
		div := (post + pre) / 2
		tim := sortedArr[div]
		if tim == targetValue {
			return pre + div
		} else if tim > targetValue {
			post = tim
		} else {
			pre = tim
		}
		if pre == post {
			return -1
		}
	}
}
func Abs(i int) int {
	if i < 0 {
		return -1 * i
	}
	return i
}
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func CalcNum(tate int, yoko int, A int, B int, dp *map[[2]int]int) int {
	if (*dp)[[2]int{tate, yoko}] != 0 {
		return (*dp)[[2]int{tate, yoko}]
	}
	return yoko*CalcNum(tate-1, yoko, A, B, dp) + tate*CalcNum(tate, yoko-1, A, B, dp)
}
func arrSum(arr []int) int {
	sum := 0
	for _, a := range arr {
		sum += a
	}
	return sum
}
func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}
func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
const int INF = 1e9;

void solve(){

}

int main(){
	vector<int> v(5);
	int res = 0;
	fori(i,5){
		cin >> v[i];
		if (v[i] == 0) res = i+1;
	}
	cout << res;
    return 0;
}



Measured memory_bytes: 3544
X = int(input())

a = 0
b = 0

for i in range(-1000, 1000):
    for j in range(-1000, 1000):
        if(i * i * i * i * i - j * j * j * j * j == X):
            a = i
            b = j
            break




print("{} {}".format(a, b))

Measured memory_bytes: 9176
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll gcd(ll a, ll b){
  ll tmp, r, x = a * b;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];

    if(n == 2){
        ll rec = max(a[0], a[1]);
        cout << rec << endl;
        return 0;
    }

    vll l(n - 1), r(n - 1);
    ll res = a[0];
    REP(i, n - 1){
        l[i] = gcd(res, a[i]);
        res = l[i];
    }
    res = a[n - 1];
    REP(i, n - 1){
        r[i] = gcd(res, a[n - 1 - i]);
        res = r[i];
    }
    ll ans = max(l[n - 2], r[n - 2]);
    REP(i, n - 2){
        ll tmp = gcd(l[i], r[n - 3 - i]);
        ans = max(ans, tmp);
    }
    //REP(i, n - 1) cout << l[i] << " " << r[i] << endl;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int solve(int N)
{
    int ans = 0;
    do {
        ans += (N % 10);
        N /= 10;
    } while (N);
    return ans == 1 ? 10 : ans;
}
int main()
{
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    auto ans = solve(N);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int time[] = new int[5];
		int itiKeta;
		int minItiKeta = Integer.MAX_VALUE;
		int minItiKetaTime = 0;
		int answer = 0;

		for (int i = 0; i < 5; i++) {
			time[i] = sc.nextInt();
			itiKeta = Character.getNumericValue(String.valueOf(time[i]).charAt(String.valueOf(time[i]).length() - 1));
			if (itiKeta == 0) continue;
			minItiKeta = Math.min(minItiKeta, itiKeta);
			if (itiKeta == minItiKeta) minItiKetaTime = i;
		}

		for (int i = 0; i < 5; i++) {
			if (i != minItiKetaTime) answer += Math.ceil((double)time[i] / 10) * 10;
		}

		System.out.println(answer + time[minItiKetaTime]);
	}
}


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

using namespace std;


int main() {
	int r, g, b, k;
	cin >> r >> g >> b >> k;

	int n = 0;
	while (!(g > r)) {
		g *= 2;
		n++;
	}
	while (!(b > g)) {
		b *= 2;
		n++;
	}

	cout << (n <= k ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3132
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
  n,m=map(int,input().split())
  uf=UnionFind(n)
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    uf.union(a,b)
  return max(uf.size(x) for x in range(n))

print(main())



Measured memory_bytes: 75460
#include<iostream>
using namespace std;
int main()
{
	int m,n,s;
	cin>>m>>n>>s;
	int t=0;
	int a[m+1];
	for(int i=1;i<=m;i++)
	{
		cin>>a[i];
		t+=1;
		if(n%a[i]==0)
		t-=1;
		t+=n/a[i];
	}
	cout<<t+s<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define sqr(x) (x) * (x)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 1e3 + 10;
const ld inf = 1e18;

struct circle {
	ld x, y, r = 0;
	ld dist(circle &c) {
		ld ans = sqr(x - c.x) + sqr(y - c.y);
		ans = sqrt(ans) - r - c.r;
		ans = max(ld(0), ans);
		return ans;
	}
} p[N];

ld g[N][N];

ld dijsktra(int s, int t, int n);

int main() {
	cin >> p[1].x >> p[1].y >> p[2].x >> p[2].y;
	int n; cin >> n;
	n += 2;
	for (int i = 3; i <= n; ++i) {
		cin >> p[i].x >> p[i].y >> p[i].r;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = i + 1; j <= n; ++j) {
			g[i][j] = g[j][i] = p[i].dist(p[j]);
		}
	}
	cout << fixed << setprecision(20) << dijsktra(1, 2, n);
}

ld dijsktra(int s, int t, int n) {
	vector<ld> dist(n + 1);
	vector<bool> seen(n + 1);
	for (int i = 0; i <= n; ++i) {
		dist[i] = inf;
		seen[i] = 0;
	}
	dist[s] = 0;
	for (int i = 0; i < n; ++i) {
		int cur = 0;
		for (int j = 1; j <= n; ++j) {
			if (!seen[j] and dist[j] < dist[cur]) {
				cur = j;
			}
		}
		for (int j = 1; j <= n; ++j) {
			if (dist[cur] + g[cur][j] < dist[j]) {
				dist[j] = dist[cur] + g[cur][j];
			}
		}
		seen[cur] = true;
	}
	return dist[t];
}

Measured memory_bytes: 16128
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int MAX = 100100;
    InputStream in = System.in;
    PrintStream out = System.out;
    //static int d[] = new int[MAX];
    // static int dp[][] = new int[MAX][MAX];

    public void _main(String[] args) {
        Scanner sc = new Scanner(in);
        int N = sc.nextInt();
        int d[] = new int[N];
        for (int i=0;i<N;i++) d[i] = sc.nextInt();

        Arrays.sort(d);
        if ((N&1)==1) {out.println("0"); return;}
        int mid = N/2;
        out.println(d[mid] - d[mid-1]);
    }

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


Measured memory_bytes: 50688
#include <string>
#include <iostream>
using namespace std;
int main(void){
  int a;
  string str;
  cin >> a;
  if((a % 10) == 3){
    str = "bon";
  }
  else if(((a % 10) == 0) || ((a % 10) == 1) || ((a % 10) == 6) || ((a % 10) == 8)){
    str = "pon";
  }
  else{
    str = "hon";
  }
  cout << str << endl;
}

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

int main() {

  int a, b, c;
  
  cin >> a >> b >> c;
  
  int count = 0;
  for (int i=a; i<=b; i++) {
	if (c%i == 0) {
	  count++;
    }
  }
  
  cout << count << endl;
  
  return 0;
}


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

using namespace std;

int n;
long long ans = 0;
map<char, long long> m;
char c[5] = {'M', 'A', 'R', 'C', 'H'};

int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        string s; 
        cin >> s;
        m[s[0]]++;
    }
    for (int i = 0; i < 3; i++)
        for (int j = i + 1; j < 4; j++)
            for (int k = j + 1; k < 5; k++){
                ans += m[c[i]]*m[c[j]]*m[c[k]];
            }
    cout << ans;
}

Measured memory_bytes: 256
use std::io;
use std::collections::HashSet;
use std::cmp::max;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let s = buf.trim();
	let mut ret = 0;
	for i in 1..s.len() {
		let mut set1:HashSet<char> = HashSet::new();
		let mut set2:HashSet<char> = HashSet::new();
		let s1 = &s[..i].to_string();
		let s2 = &s[i..].to_string();
		let vs1:Vec<char> = s1.chars().collect();
		let vs2:Vec<char> = s2.chars().collect();
		for i in vs1 {
			set1.insert(i);
		}
		for i in vs2 {
			set2.insert(i);
		}
		let intersection:HashSet<_> = set1.intersection(&set2).collect();
		ret = max(intersection.len(), ret);
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << ((max(a, b) <= 8) ? "Yay!\n" : ":(\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
    int N, K, Q;
    cin >> N >> K >> Q;
    int A[Q];
    for(int i=0;i<Q;i++) cin >> A[i];
    int B[N];
    for(int i=0;i<N;i++) B[i] = 0;
    for(int i=0;i<Q;i++){
        B[A[i]-1]++;
    }
    for(int i=0;i<N;i++){
        if(K - (Q-B[i])>0) cout << "Yes" << endl;
        else cout <<"No"<<endl;
    }
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int []hairetu= new int[N];
		int []hairetu2=new int[N];
		int count=0;
		for(int i=0;i<N;i++) {
			hairetu[i]=sc.nextInt();
			}
		for(int i=0;i<N;i++) {
			while(hairetu[i]%2==0){
				hairetu[i]=hairetu[i]/2;
			count++;
			}
			hairetu2[i]=count;
			count=0;
			}
		int min = hairetu2[0];
		for(int i=0;i<N;i++) {
			if(min>hairetu2[i]){
				min = hairetu2[i];
			}
		}
			System.out.println(min);
		}
	
		}
	


Measured memory_bytes: 23892
#include<stdio.h>
int main(){
    int S;
    scanf("%d",&S);
    int h,m,s;
    h=S/3600;
    m=(S%3600)/60;
    //s=S-(h*3600)-(m*60);
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

Measured memory_bytes: 2728
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


m=10**9+7
# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def comb(n, k, mod):
	a=1
	b=1
	for i in range(1,k+1):
		a*=i
		b*=n-i+1
		a%=m
		b%=m
	
	return (b*pow(a,m-2,m))%m
	

def main():
	n,a,b=map(int,input().split())
	ans=pow(2,n,m)-1-comb(n,a,m)-comb(n,b,m)
	ans%=m
	print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3064