akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<int, int>;

int main(){
    int N;
    cin >> N;
    vector<P> x(N), y(N);
    vector<int> used(N, 0);
    for(int i = 0;i < N;i++){
        int a, b;
        cin >> a >> b;
        x[i] = P(a, i);
        y[i] = P(b, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    vector<vector<P>>   vp(N);
    int h[] = {1, -1};
    for(int i = 0;i < N;i++){
        for(int j = 0;j < 2;j++){
            int d = h[j];
            if(i+d >= 0 && i+d <= N-1){
                vp[x[i].second].push_back(P(abs(x[i].first-x[i+d].first), x[i+d].second));
                vp[y[i].second].push_back(P(abs(y[i].first-y[i+d].first), y[i+d].second));
            }
        }
    }
    priority_queue<P, vector<P>, greater<P>>  que;
    LL ans = 0;
    int count = 0;
    que.push(P(0, 0));
    while(count < N){
        P p = que.top();
        que.pop();
        int d = p.first;
        int v = p.second;
        if(used[v]) continue;
        used[v] = true;
        count++;
        ans += d;
        for(auto& itr : vp[v])  que.push(itr);
    }
    cout << ans << endl;
}

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

int main(void){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        if(c<=0){
            cout << "Yes" << endl;
            return 0;
        }
        a -= d;
        if(a<=0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1e4+7;
typedef long long ll;

int n,m,ans;
int a[maxn];

int main()
{
	int i,j,k;
	a[0]=1;
	scanf("%d",&n);
	for(i=1;i<=n;++i)
	{
		scanf("%d",&k);
		for(j=10000;j>=k;--j)
		  if(a[j-k]) a[j]=1;
	}
	
	for(i=10000;i>=1;--i)
	{
		if(i%10!=0&&a[i])
		{
			printf("%d",i);
			return 0;
		}
	}
	
	printf("0");
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt(), minimum = 0, maximum = 0;
		long total = 0;

		for (int i = 0; i < length; i++) {
			int number = scanner.nextInt();

			if (i == 0) {
				minimum = number;
				maximum = number;
			}

			total += number;

			if (number < minimum)
				minimum = number;
			if (number > maximum)
				maximum = number;
		}

		System.out.println(minimum + " " + maximum + " " + total);
	}
}

Measured memory_bytes: 41244
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#define rep(x, a, b) for(int x = (a); x <= (b); ++x)
#define rop(x, a, b) for(int x = (a); x < (b); ++x)
#define per(x, a, b) for(int x = (a); x >= (b); --x)
using namespace std;
typedef long long LL;
typedef double DB;
LL f[100005], g[100005];
int x[100005], n, t, e;
multiset<LL> S;
int main() {
	memset(f, 0x3f, sizeof(f));
	memset(g, 0x3f, sizeof(g));
	f[0] = 0;
	g[0] = 0;
	scanf("%d%d%d", &n, &e, &t);
	rep(i, 1, n) scanf("%d", &x[i]);
	int k = 0;
	LL ZY = f[n];
	S.insert(0);
	rep(i, 1, n) {
		while((x[i] - x[k + 1]) * 2 > t) {
			S.erase(S.find(f[k]));
			ZY = min(ZY, f[k] - x[k + 1] * 2);
			++k;
		}
		f[i] = min(f[i], ZY + x[i] * 2);
		if(S.size()) f[i] = min(f[i], (*S.begin()) + t);
//		rop(j, 0, i) {
//			f[i] = min(f[i], f[j] + max((x[i] - x[j + 1]) * 2, t));
//		}
		S.insert(f[i]);
	}
	cout << f[n] + e << endl;
//	rop(i, 0, n) { 
//		rep(j, i + 1, n) {
//			g[j] = min(g[j], g[i] + max((x[j] - x[i + 1]) * 2, t));
//		}
//	}
//	cout << g[n] + e << endl;
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N, M;
vector<int64> G[610];
using ld = long double;
vector<ld> dp;
PLL ng;

ld dfs(int64 v) {
  if (v == N-1) return 1;
  if (dp[v] != -1) return dp[v];
  ld sum = 0;
  ld maxi = 0;
  int64 cnt = 0;
  REP(i, G[v].size()) {
    if (ng == PLL(v, G[v][i])) continue;
    cnt++;
    chmax(maxi, dfs(G[v][i]));
    sum += dfs(G[v][i]);
  }
  if (cnt == 0) return INF;
  dp[v] = sum/cnt+1;
  return dp[v];
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	vector<PLL> es;
  REP(i, M) {
    int64 s, t;
    cin >> s >> t; s--; t--;
    G[s].push_back(t);
  }
  ld res = INF;
  es.emplace_back(0, 0);
  ng = PLL(0, 0);
  dp = vector<ld>(N, -1);
  dfs(0);

  REP(i, N) {
    ld mx = 0;
    REP(j, G[i].size()) {
      chmax(mx, dp[G[i][j]]);
    }
    REP(j, G[i].size()) {
      if (dp[G[i][j]] >= mx) {
        es.emplace_back(i, G[i][j]);
        break;
      }
    }
  }

  REP(i, es.size()) {
    dp = vector<ld>(N, -1);
    ng = es[i];
    chmin(res, dfs(0));
  }
  cout << fixed << setprecision(10) << res-1 << endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int a[200001] = {};
int b[200001] = {};

int main(void)
{
	int n,p;
	INPUT(n);

	for (int i = 0; i < n; i++) {
		INPUT(p);
		p--;
		a[p] += i;
		a[n + 1] -= i;
		b[0] += i;
		b[p + 1] -= i;
	}

	for (int i = 0; i < n; i++) {
		a[i + 1] += a[i];
		b[i + 1] += b[i];
		a[i] += i + 1;
		b[i] += n - i;
		PUT(a[i]);
		puts((i == n - 1 ? "\n" : " "));
	}

	for (int i = 0; i < n; i++) {
		PUT(b[i]);
		puts((i == n - 1 ? "\n" : " "));
	}

	return 0;
}



Measured memory_bytes: 768
import sys
h,w =map(int,input().split())
a = [list(map(int,input().split())) for l in range(h)]
ki = 0
ans = []
for i in range(h):
  if i%2 == 0:
    for j in range(w):
      if ki == 1:
        if j != 0:
          ans.append([i+1,j,i+1,j+1])
        else:
          ans.append([i,j+1,i+1,j+1])
      if a[i][j]%2 ==1:
        ki += 1
        if ki == 2:
          ki = 0
  else:
    for j in range(w-1,-1,-1):
      if ki == 1:
        if j != w-1:
          ans.append([i+1,j+2,i+1,j+1])
        else:
          ans.append([i,j+1,i+1,j+1])
      if a[i][j]%2 ==1:
        ki += 1
        if ki == 2:
          ki = 0
print(len(ans))
for b,c,d,e in ans:
  print(b,c,d,e)

Measured memory_bytes: 72604
#include <stdio.h>
int main(void){
  int sum = 0;
  int i = 0;
  char tmp[5];
  
  scanf("%s",tmp);
  
  for(i=0;i < 4 ; i++){
    if(tmp[i] == '+'){
      sum++;
    }else if(tmp[i] == '-'){
      sum--;
    }
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
while True:
 try:
  a=raw_input()
  a+="  "
  ans,ans2=0,0
  for i in range(len(a)-4):
    if a[i:i+3] == 'JOI': ans+=1
    elif a[i:i+3] == 'IOI': ans2+=1
  else:
    print "%d\n%d"%(ans,ans2)
 except EOFError: break

Measured memory_bytes: 4316
#include <iostream>

std::string A;
std::string B;

int main(void){
    std::cin >> A;
    std::cin >> B;

    if( A.length() > B.length() ){
        std::cout << "GREATER" << std::endl;
        return 0;
    }
    if( A.length() < B.length() ){
        std::cout << "LESS" << std::endl;
        return 0;
    }

    int len = A.length();
    for(int i=0; i<len; ++i){
        if( A[i] == B[i] ) continue;
        if( A[i]  > B[i] ){
            std::cout << "GREATER" << std::endl;
            return 0;
        }
        if( A[i]  < B[i] ){
            std::cout << "LESS" << std::endl;
            return 0;
        }
    }
    std::cout << "EQUAL" << std::endl;
    return 0;
}


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

int main() {
    int K, S;
    cin >> K >> S;
    int answer =-0;
    for(int x = 0; x < K+1; x++){
        for(int y = 0; y < K+1; y++){
            int z;
            z = S - x- y;
            if(z >=0 && z <= K){
                answer++;
            }
        }
    }
    cout << answer << endl;
}

Measured memory_bytes: 256
S = input()
if 'N' in S and 'W' in S and 'S' in S and 'E' in S:
    print('Yes')
elif 'N' in S and 'S' in S and not 'W' in S and not 'E' in S:
    print('Yes')
elif 'E' in S and 'W' in S and not 'N' in S and not 'S' in S:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n;
  cin>>n;
  int i,a[n],t[n],ans[n];
  for(i=0;i<n;i++){
    cin>>a[i];
    t[i]=a[i];
  }
  sort(a,a+n);
  for(i=0;i<n;i++){
    if(t[i]!=a[n-1]){
      ans[i]=a[n-1];}
    else if(t[i]==a[n-1]){
      ans[i]=a[n-2];}
  }
  for(i=0;i<n;i++){
    cout<<ans[i]<<endl;}
  
  return 0;
}


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n,k;
    cin >> n >> k;
    lint ans=0;
    ans = min(k - n%k, n % k);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

#ifndef UNION_FIND_TREE
#define UNION_FIND_TREE
class UnionFindTree{
	private:
		int N;
		unique_ptr<int[]> parent;
		unique_ptr<int[]> rank;
		unique_ptr<int[]> size;
	public:
		UnionFindTree(int N){
			this -> N = N;
			this -> parent = make_unique<int[]>(N);
			this -> rank = make_unique<int[]>(N);
			this -> size = make_unique<int[]>(N);
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		void init(){
			for(int i = 0; i < (int) N; i++){
				parent[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		int find(int x){
			if(parent[x] == x) return x;
			else return parent[x] = find(parent[x]);
		}
		void unite(int x, int y){
			x = find(x); y = find(y);
			if(x == y) return;

			if(rank[x] < rank[y]){
				parent[x] = y;
				size[y] += size[x];
			}else{
				parent[y] = x;
				size[x] += size[y];
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
		int count(int x){
			return size[find(x)];
		}
};
#endif

int N, M;
int p[100000]; 

int main(void){
    cin >> N >> M;
    UnionFindTree ut(N);
    for(int i = 0; i < N; i++){
        cin >> p[i];
        p[i]--;
    }
    for(int i = 0; i < M; i++){
        int x, y; cin >> x >> y;
        ut.unite(--x, --y);
    }

    int res = 0;
    for(int i = 0; i < N; i++){
        if(ut.same(p[i], i)) res++;
    }

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 1792
from math import sqrt, ceil

# ユークリッドの互除法で最大公約数を返す
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

A, B = map(int, input().split())
if A > B:
    A, B = B, A
g = gcd(A, B)
s = set(); s.add(1)
sqrt_g_plus = ceil(sqrt(g))+1
i = 2

# 最大公約数の平方根までの素数を見つける
while i < sqrt_g_plus:
    if g%i == 0:
        s.add(i)
        g //= i
    else:
        i += 1
# 平方根以上の素数がある場合、追加する（あるとした場合一つだけである）
if g > 1:
    s.add(g)

print(len(s))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAX 105
#define int long long int
using namespace std;

const int N = 100005;
vector<int> adj[N];
int dp[N];
bool visited[N];

void dfs(int v)
{
    visited[v] = true;
    for(auto it: adj[v])
    {
        if(!visited[it])
            dfs(it);
        dp[v] = max(dp[v], dp[it]+1);
    }
}
int32_t main()
{
    int n,m;
    cin >> n >> m;
    for(int i = 0 ; i < m ; i++)
    {
        int a,b;
        cin >> a >> b;
        adj[a].pb(b);
    }
    
    memset(dp,0,sizeof(dp));
    memset(visited,false,sizeof(visited));
    
    for(int i = 1 ; i <= N ; i ++)
    {
        if(!visited[i])
            dfs(i);
    }
    
    int ans = 0;
    for(auto it: dp)
        ans = max(ans,it);
    cout << ans;
    return 0;
}


Measured memory_bytes: 12424
def main():
    INF = 10 ** 12
    N, M, L = list(map(int, input().split(' ')))
    D = [[INF for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        A, B, C = list(map(int, input().split(' ')))
        A -= 1
        B -= 1
        D[A][B] = C
        D[B][A] = C
    Q = int(input())
    query_list = [list(map(lambda x: int(x) - 1, input().split(' '))) for _ in range(Q)]
    # calc min cost by warshall-floyd method
    for via in range(N):
        for s in range(N):
            for t in range(N):
                d = D[s][via] + D[via][t]
                if D[s][t] > d:
                    D[s][t] = d
                    D[t][s] = d
    # calc min number of charges
    counts = [[INF for _ in range(N)] for _ in range(N)]
    for s in range(N):
        for t in range(N):
            if D[s][t] <= L:
                counts[s][t] = 1
                counts[t][s] = 1
    for via in range(N):
        for s in range(N):
            for t in range(N):
                d = counts[s][via] + counts[via][t]
                if counts[s][t] > d:
                    counts[s][t] = d
                    counts[t][s] = d
    # answer query
    for query in query_list:
        s, t = query
        if counts[s][t] >= INF:
            print(-1)
        else:
            print(counts[s][t] - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 95296
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n;
    string s;
    cin >> n >> s;
    VI a(n);
    REP(i,n){
        if (s[i] == 'G') a[i] = 1;
        else if (s[i] == 'B') a[i] = 2;
    }
    ll ans = 0;
    FOR(i,1,n-2){
        VL cl(3), cr(3);
        REP(j,i) cl[a[j]]++;
        FOR(j,i+1,n-1) cr[a[j]]++;
        REP(x,3) REP(y,3){
            if (x == y) continue;
            if (x == a[i]) continue;
            if (y == a[i]) continue;
            ans += cl[x] * cr[y];
        }
        FOR(j,1,n-1){
            if (i - j < 0 || i + j >= n) break;
            if (a[i] != a[i - j] && a[i] != a[i + j] && a[i - j] != a[i + j]) ans--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(void)
{
  int a, b, i, sum;
  
  while(scanf("%d %d",&a,&b)!= EOF)
    {
      sum = a + b;
      for(i=0;sum!=0;i++)
	{
	  sum = sum / 10;
	}
      printf("%d\n", i);
    }
  return 0;
}

Measured memory_bytes: 600
<?php
fgets(STDIN);
foreach(array_map("intval", explode(" ", trim(fgets(STDIN)))) as $d){
    @$map[$d]++;
}
fgets(STDIN);
foreach(array_map("intval", explode(" ", trim(fgets(STDIN)))) as $d){
    if(@$map[$d]>0){
        $map[$d]--;
    }else{
        echo "NO\n";exit;
    }
}
echo "YES\n";


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

int main(){
    ll n,k;cin>>n>>k;
    ll h[200000];
    ll sum = 0;
    for(ll i=0;i<n;i++)
    {
        cin>>h[i];
        sum += h[i];
    }
    sort(h,h+n,greater<>());
    for(ll i=0;i<k;i++)
    {
        sum -= h[i];
    }
    cout<<sum;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
vector<ll> Dijkstra_list(int n, int s, vector<vector<pair<ll, ll>>> &Edge) {
    vector<bool> visited(n, false); //確定済み
    vector<ll> d(n, __LONG_LONG_MAX__);
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
        que; //頂点とsからの距離
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        visited[now.second] = true;
        for(auto e : Edge[now.second]) {
            if(visited[e.second])
                continue;
            if(d[e.second] > d[now.second] + e.first) {
                d[e.second] = d[now.second] + e.first;
                que.push(make_pair(d[e.second], e.second));
            }
        }
    }
    return d;
}
int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> s(h, vector<char>(w, 0));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    vector<vector<pair<ll, ll>>> edge(h * w);
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == '#') {
                continue;
            }
            if(i - 1 >= 0 && s[i - 1][j] == '.') {
                edge[i * w + j].push_back(make_pair(1, (i - 1) * w + j));
            }
            if(i + 1 < h && s[i + 1][j] == '.') {
                edge[i * w + j].push_back(make_pair(1, (i + 1) * w + j));
            }
            if(j + 1 < w && s[i][j + 1] == '.') {
                edge[i * w + j].push_back(make_pair(1, i * w + j + 1));
            }
            if(j - 1 >= 0 && s[i][j - 1] == '.') {
                edge[i * w + j].push_back(make_pair(1, i * w + j - 1));
            }
        }
    }
    ll ans = 0;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == '.') {
                auto hoge = Dijkstra_list(h * w, i * w + j, edge);
                sort(all(hoge));
                auto itr = lower_bound(all(hoge), 11451418);
                itr--;
                ans = max(ans, *itr);
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
  int k,s; cin>>k>>s;
  int res=0;
  rep(i, k+1) {
    rep(j, k+1) {
      int tmp=s-i-j;
      if (tmp>=0&&tmp<=k) res++;
    }
  }
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int num;

void merge(int *a, int left, int mid, int right){

  int n1 = mid-left;
  int n2 = right-mid;

  int *L = new int[n1+1];
  int *R = new int[n2+1];

  for(int i=0;i<n1;i++){
    L[i] = a[left+i];
  }

  for(int i=0;i<n2;i++){
    R[i] = a[mid+i];
  }

  L[n1] = INT_MAX;
  R[n2] = INT_MAX;

  int i = 0;
  int j = 0;
  for(int k = left;k<right;k++){
    num++;
    if(L[i] < R[j]){
      a[k] = L[i];
      i += 1;
    }else{
      a[k] = R[j];
      j += 1;
    }
  }
  return;
}

void mergeSort(int *a, int left, int right){
  int num=0;
  if(left+1<right){
    int mid = (left + right)/2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
  return;
}


int main(){
  num = 0;
  int n;
  cin >> n;
  int *S = new int[n];

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

  // for(int i=0;i<n;i++){
    // if(i!=0)cout<<" ";
    // cout << S[i];
  // }
  // cout << endl;
  

  mergeSort(S, 0, n);

  for(int i=0;i<n;i++){
    if(i!=0){cout<<" ";}
    cout << S[i];
  }
  cout << endl;

  cout << num << endl;
}

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

int main() {
	int n;
	cin >> n;
	int index[100] = {};
	 vector< pair <string,int> > vec(n+1);
	int b;string s;
	for(int i = 1; i < n+1; i++)
	{
	cin >> s >> b;
	vec[i].first = s;
    vec[i].second = b; 
    index[b] = i;
	}
	sort(vec.begin() +1, vec.end());
		for(int i = 1; i < n+1; i++)
	{
		int count = 1;
		for(int j = i+1;j < n+1; j++)
		{
			if(vec[i].first == vec[j].first)
			count++;
			else break;
		}
		int temp =count;

		while(count !=0)
		{
		cout << index[vec[i+count-1].second]<<endl;
		count--;
		}
		i+=temp;
		i--;
	
	}
	// your code goes here
	return 0;
}

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

using namespace std;

int N, D;

int X[12][12];

int IsQ(int num) {

	for (int i = 1; i <= 1000; i++) {
		if (i*i == num) { return 1; }
	}

	return -1;

}

int main(void) {

	cin >> N >> D;

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= D; j++) {
			cin >> X[i][j];
		}
	}

	int ans = 0;

	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			int tmp = 0;
			for (int k = 1; k <= D; k++) {
				tmp += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			if (IsQ(tmp) == 1) { ans++; }
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
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(a > b){a = b; return 1;}return 0;}
typedef long long ll;

string sol(string &S){
  string tmp = S.substr(0,1);
  if(S.size() == 1){
    S = "";
  }else{
    S = S.substr(1, S.size()-1);
  }
  return tmp;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ABC045B - 3人でカードゲームイージー/Card Game for Three(ABC Edit)
  // 'a','b','c'いずれかの文字が書かれたカードを何枚か持っている
  // 入力順で持っており、途中で並べ替えたりしない
  // 自分のターンで1枚も持っていないなら勝ち
  // 線形処理でも間に合うので、愚直に実装する
  // 文字列を参照渡して、先頭の文字を削除して、その先頭の文字を返す関数を作成
  // 返ってきた文字により、次に渡す文字列を決定する
  string A, B, C; cin >> A >> B >> C;
  A += "A"; B += "B"; C += "C";
  string next = "a";
  while(next != "A" && next != "B" && next != "C"){
    if(next == "a") next = sol(A);
    if(next == "b") next = sol(B);
    if(next == "c") next = sol(C);
  }
  cout << next << endl;
}

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

int main(){
  int n;
  cin >> n;
  int numbers[n];
  for(int i =0; i < n; i++){
      numbers[i] = 0;
  }
  for(int i = 0; i <(n-1); i++){
      int d;
      cin >> d;
      numbers[d-1] += 1;
  }
  for(int i=0; i <n; i++){
      cout << numbers[i] << endl;
  }
}

Measured memory_bytes: 4296
#include <stdio.h>
#include <math.h>
int main(void) {
    int x, b, p, max=1;
    scanf("%d", &x);
    
    for(b=1; b<32; b++) {
        for(p=2; p<11; p++) {
            if(max<pow(b, p) && pow(b, p)<=x) {
                    max = pow(b, p);
            }
        }
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 256
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    cout<<nxt()*nxt()<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3804
#include <iostream>

#define N_MAX 1000

struct edge{
    long from;
    long to;
    long cost;
};

using namespace std;

//return
//true:if nagetive loop does not exist
//false:if negative loop exists
bool bellmanford(edge es[],long long d[], long start, long num_v, long num_e){
    for(long i = 1; i <= num_v; i++){
        d[i] = __LONG_MAX__;
    }
    d[start] = 0;
    int cnt_loop = 0;
    while(true){
        cnt_loop++;
        bool update = false;
        bool update_end = false;
        for(int i = 0; i < num_e; i++){
            edge e = es[i];
            if(d[e.from] != __LONG_MAX__ && d[e.from]+e.cost < d[e.to]){
                d[e.to] = d[e.from]+e.cost;
                update = true;
                if(e.to == num_v)update_end = true;
            }
        }
        if(!update) return true;
        else if(cnt_loop >= num_v) return !update_end;
    }
}

int main(){
    long N, M;
    edge es[2000];
    long long d[1001];
    cin >> N >> M;
    for(int i = 0; i < M;i++){
        long a, b, c;
        cin >> a >> b >> c;
        es[i].from = a;
        es[i].to = b;
        es[i].cost = -c;
    }
    if(bellmanford(es, d, 1, N, M)){
        cout << -d[N] << endl;
    }else{
        cout << "inf" << endl;
    }
}

Measured memory_bytes: 256
import numpy as np
INF = 10**10
N, M = map(int, raw_input().split())
G = [map(int, raw_input().split()) for i in range(M)]
d = np.full((N+1, N+1), INF)
for i in range(N+1):
    d[i, i] = 0
for u, v, c in G:
    d[u, v] = d[v, u] = c
for u in range(N+1):
    for s in range(N+1):
        for t in range(N+1):
            d[s, t] = d[t, s] = min(d[s, t], d[s, u] + d[u, t])
ans = 0
for u, v, c in G:
    if c > d[u, v]:
        ans += 1
print ans

Measured memory_bytes: 18672
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int,int);
void dfs( vector< vector<int> >&, int , vector<int>& );
void bfs( vector< vector<int> >&, int , vector<int>& );

void solve()
{
    int r;
    cin>>r;

    cout<<setprecision(20)<<2*(3.141592653589793238)*r<<endl;
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;
    
    while(t--)
    {
        solve();
    }
    return 0;
}

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

void dfs ( vector< vector<int> > &v , int x , vector<int> &vis )
{
    vis[x] = 1;

    rep(i,0,v[x].size())
    {
        if( vis[v[x][i]] == 0 )
        {
            dfs(v,v[x][i],vis);
        }
    }
}

void bfs( vector< vector<int> > &v , int x , vector<int> &vis )
{
    queue<int> q;
    q.push(x);

    while( !q.empty() )
    {
        int p = q.front();
        q.pop();

        rep(i,0,v[p].size())
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
            }
        }
    }
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define int long long int
#define pb(a) push_back(a)
#define INF 1e+16
#define MOD 1000000007

using namespace std;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, b[100010], suma, sumc;
priority_queue<int> c;
priority_queue<int, vector<int>, greater<int> > a;

signed main(){
	cin >> n;
	for(int i=0;i<n;i++){
		int aa;
		cin >> aa;
		suma += aa;
		a.push(aa);
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	for(int i=0;i<n;i++){
		int cc;
		cin >> cc;
		sumc += cc;
		c.push(cc);
	}
	int sma[100010], smc[100010];
	sma[0]=suma;
	smc[n]=sumc;
	for(int i=0;i<n;i++){
		a.push(b[i]);
		sma[i+1] = sma[i] + b[i] - a.top();
		a.pop();
	}
	for(int i=n-1;i>=0;i--){
		c.push(b[i]);
		smc[i] = smc[i+1] + b[i] - c.top();
		c.pop();
	}
	int ans = 0-INF;
	for(int i=0;i<=n;i++){
		ans = max(ans, sma[i]-smc[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4340
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL A,B,C,K;
	cin>>A>>B>>C>>K;
	/*bool flag = false;
	if(A<B){
		flag = true;
		swap(A,B);
	}*/
	LL AB = A-B;
	if(K&1){
		AB = -AB;
	}
	cout << AB << endl;
	/*
	LL LIM=(LL)1e18;
	LL ter = (LIM-1+AB)/AB;
	
	if(K==0){
		LL res = A-B;
		if(flag){
			res = -res;
		}
		cout<<res <<endl;
		return;
	}
	else if(K==1){
		LL res = A-B;
		res *= -1;
		if(flag){
			res = -res;
		}
		cout << res << endl;
		return;
	}
	LL B0 = 0;
	LL B1 = 1;
	for(int i=0;i<K;++i){
		LL C1=B1-B0*2;
		cerr << C1 << endl;
		//Bの更新
		LL BB0 = B1;
		LL BB1 = B1 + 2*B0;
		B0 = BB0;
		B1 = BB1;
	}*/
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
    int A[110] = {0};
	scanf("%d %d", &N, &K);
    for(int i=0; i < K; i++) {
        int d;
        scanf("%d", &d);
        for (int j=0; j < d; j++) {
            int a;
            scanf("%d", &a);
            A[a]++;
        }
    }
    int count = 0;
    for (int i=1; i <= N; i++) {
        if (A[i] == 0) {
            count++;
        }
    }
    printf("%d\n", count);
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    cout << fixed << setprecision(6);
    if(N % 2 == 1){
    cout << ((N+1.0)/2.0)/N << endl;
    }
    else{
    cout << 0.5000000 << endl;
    }
}



Measured memory_bytes: 256
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	a, b, k := nextInt(), nextInt(), nextInt()
	for i := a; i <= b; i++ {
		if i-a+1 <= k || b-i+1 <= k {
			puts(i)
		}
	}
	wt.Flush()
}

var (
	sc  = bufio.NewScanner(os.Stdin)
	rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	wt  = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func nextMega() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, _ := rdr.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
using namespace std;
const int N = 500;
string mat[N];
int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> mat[i];
	for (int i = 0; i < n; i++)
	{
		if (i & 1)
		{
			cout.put('#');
			for (int j = 1; j < m; j++)
				cout.put(mat[i][j]);
		}
		else
		{
			for (int j = 0; j < m - 1; j++)
				cout.put('#');
			cout.put('.');
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < n; i++)
	{
		if (i & 1)
		{
			cout.put('.');
			for (int j = 1; j < m; j++)
				cout.put('#');
		}
		else
		{
			for (int j = 0; j < m - 1; j++)
				cout.put(mat[i][j]);
			cout.put('#');
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
# ABC084  B - Postal Code  

# Request user input from stdin 
a,b = map(int,input().split())
s = input()

def isThereHyphen():
  rslt = False
   
  if s[a] == "-":
    firstStr = (s.split("-"))[0]
    secondStr = (s.split("-"))[1]
    if((firstStr.isdigit() == True) and (secondStr.isdigit() == True)):
      rslt = True

  return rslt

def main():
  rslt = isThereHyphen()

  if True==rslt:
    print("Yes")
  else:
    print("No")

# main logic
main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int out = 1;
        String slime = sc.next();
        for (int i=0; i<A-1; i++) {
            if (slime.charAt(i)!=slime.charAt(i+1)) {
                out++;
            }
        }
        System.out.println(out);
    }
}

Measured memory_bytes: 25840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

struct RAQ{
  ll size;
  ll *tree;
  RAQ(ll sz){
    ll logsize; for(logsize=0;(1ll<<logsize)<=sz;logsize++);
    size=(1ll<<logsize);
    tree=new ll[size*2-1]; REP(i,size*2-1) tree[i]=0;
  }
  void add(ll s,ll t,ll x){
    add(s,t,0,size,x,0);
  }
  void add(ll s,ll t,ll l,ll r,ll x,ll k){
    if(r<=s||t<=l||r<=l) return;
    if(l+1==r) {tree[k]+=x; return;}
    if(s<=l&&r<=t) {tree[k]+=x; return;}
    ll mid=(l+r+1)/2;
    add(s,t,l,mid,x,k*2+1);
    add(s,t,mid,r,x,k*2+2);
  }
  ll get(ll i){
    ll k=i+size-1;
    ll ret=tree[k];
    while(k){
      k=(k-1)/2;
      ret+=tree[k];
    }
    return ret;
  }
};

int main(){
  ll n,q; cin>>n>>q;
  RAQ raq(n);
  REP(i,q){
    ll com; cin>>com;
    if(com==0) {ll s,t,x; cin>>s>>t>>x; raq.add(s,t+1,x);}
    else {ll t; cin>>t; cout<<raq.get(t)<<endl;}
  }
}

//verified

Measured memory_bytes: 5132
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  int n;
  cin>>n;
  rep(x,500005){
    int m=x*1.08;
    //cout<<x<<" "<<m<<endl;
    if(m==n){
      cout<<x<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
string s;
ll k,n;
ll dp[105][105][2];
ll solve(int ind, int digit, int flag){
	if(ind>=n){
		if(digit==k)
			return 1;
		return 0;
	}
	if(dp[ind][digit][flag]!=-1)
		return dp[ind][digit][flag];
	int limit=9;
	if(!flag)
		limit=(s[ind]-'0');
	ll res=0;
	for (int i = 0; i <= limit; ++i){
		if(!flag && i==limit)
			res=res+solve(ind+1,i==0?digit:digit+1,0);
		else
			res=res+solve(ind+1,i==0?digit:digit+1,1);
	}
	dp[ind][digit][flag]=res;
	return dp[ind][digit][flag];
}
int main(){
	fast_io;
	cin>>s>>k;
	n=s.length();
	memset(dp,-1,sizeof(dp));
	ll ans=solve(0,0,0);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3776
#include <stdio.h>

int main(void)
{
	int a, b, c, d;
	
	scanf("%d %d %d %d", &a, &b, &c, &d);
	
	if(a >= d || c >= b)
		printf("0");
	else{
		if(a < c)
			printf("%d", b<d?b-c:d-c);
		else
			printf("%d", b<d?b-a:d-a);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,K,N,M,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N >> M >> L;
  Vec(dp,lli,N,INF);//dp[i]:頂点Lから頂点iまでの最短経路のコスト
  DV(G,pint,N,0,pint(0,0));//G[i][j]:頂点iから出たj番目の辺の終点とコスト
  rep(i,0,M){
    cin >> X >> Y >> Z;
    G[X].pb(pint(Y,Z));
  }
  dp[L]=0;
  rep(i,0,N-1)rep(j,0,N)for(auto v:G[j])if(dp[j]!=INF)chmin(dp[v.first],dp[j]+v.second);
  rep(i,0,N)for(auto v:G[i])if(dp[i]!=INF&&dp[v.first]>dp[i]+v.second)flag=true;
  if(flag)Out("NEGATIVE CYCLE");
  else{
    rep(i,0,N){
      if(dp[i]==INF)Out("INF");
      else Out(dp[i]);
    }
  }
}



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

int main(void){
    char str[2];

    scanf("%s",str); 

    int y = 700;
    if(strcmp( str, "xxx" ) == 0 ){
        printf("%d\n", y);
    }else if(strcmp( str, "xxo" ) == 0 ){
        y = y + 100;
        printf("%d\n", y);
    }else if(strcmp( str, "xox" ) == 0 ){
        y = y + 100;
        printf("%d\n", y);
    }else if(strcmp( str, "xoo" ) == 0 ){
        y = y + 200;
        printf("%d\n", y);
    }else if(strcmp( str, "oxx" ) == 0 ){
        y = y + 100;
        printf("%d\n", y);
    }else if(strcmp( str, "oxo" ) == 0 ){
        y = y + 200;
        printf("%d\n", y);
    }else if(strcmp( str, "oox" ) == 0 ){
        y = y + 200;
        printf("%d\n", y);
    }else if(strcmp( str, "ooo") == 0 ){
        y = y + 300;
        printf("%d\n", y);
    }else {
        printf("正しい文字列を入力してください\n");
    }
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	V := make([]int, N)
	C := make([]int, N)
	for i := 0; i < N; i++ {
		var v int
		fmt.Scan(&v)
		V[i] = v
	}
	for i := 0; i < N; i++ {
		var c int
		fmt.Scan(&c)
		C[i] = c
	}

	ans := 0
	for i := 0; i < N; i++ {
		if V[i] > C[i] {
			ans += V[i] - C[i]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,n) for(int i=1; i<=(n); i++)

int main() {
    int h,w,ans=0;
    cin>>h>>w;
    vector<string>grid(h);
    rep(j,h)cin>>grid[j];
    //入力
    int cnt=1;//白い必要のあるマス
    vector<vector<int>>went(h,vector<int>(w));
    vector<vector<int>>went2(h,vector<int>(w));
    went[0][0]=1;
    while(went[h-1][w-1]==0){
        cnt++;
        rep(i,h){
            rep(j,w){
                if(grid[i][j]=='.'&&went[i][j]){
                    if(i!=0)went2[i-1][j]=1;//上塗る
                    if(i!=h-1)went2[i+1][j]=1;//下塗る
                    if(j!=0)went2[i][j-1]=1;//左塗る
                    if(j!=w-1)went2[i][j+1]=1;//右塗る
                }
                
            }
        }
        rep(i,h)rep(j,w)went[i][j]|=went2[i][j];
        if(cnt>5000){
            cout<<-1;
            return 0;
        }
    }
    rep(i,h)rep(j,w)if(grid[i][j]=='.')ans++;
    ans-=cnt;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 256
def add_or_do_nothing(s, i, pos):
    if i == len(s):
        pre_i = 0
        ans = 0
        for i, pos_i in enumerate(pos, 1):
            if pos_i == '1':
                ans += int(s[pre_i:i])
                pre_i = i

        ans += int(s[pre_i:len(s)])
        return ans

    f_ans = add_or_do_nothing(s, i+1, pos+'0')
    s_ans = add_or_do_nothing(s, i+1, pos+'1')
    return f_ans + s_ans

s = input()

pos = ''
ans = add_or_do_nothing(s, 1, pos)

print(ans)

Measured memory_bytes: 39152
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sc(x) scanf("%lld",&(x));
#define pb push_back
#define fi first
#define se second
#define P pair<int,int>
#define endl '\n'
int N,T;
P A[200005];
bool cmp(P a, P b)
{
    return a.fi*(b.se+1)>(a.se+1)*b.fi;
}
int dp[104][2];
const int INF = 1e10;
vector<int> v;
signed main()
{
    sc(N)sc(T)
    int cnt=1;
    for(int i=1; i<=N; i++)
    {
        sc(A[cnt].fi)sc(A[cnt].se)
        if(A[cnt].fi==0)
        {
            v.pb(A[cnt].se);
        }
        else cnt++;
    }
    sort(v.begin(),v.end());
    for(int i=0; i<v.size(); i++)
    {
        v[i]+=1;
        if(i>0)
        v[i]+=v[i-1];
    }
    sort(A+1,A+cnt,cmp);
    for(int i=0; i<=100; i++)
        dp[i][0]=dp[i][1]=INF;
    dp[0][0]=dp[0][1]=0;

    int ans=0;
    for(int i=1; i<cnt; i++)
    {
        for(int j=1; j<=i&&j<=100; j++)
        {
            if(dp[(j-1)][(i+1)%2]==INF)break;
            dp[j][i%2]=min(dp[j][(i+1)%2],dp[j-1][(i+1)%2]+1+ (dp[j-1][(i+1)%2]+1)*A[i].fi + A[i].se);
            if(dp[j][i%2] > T)break;
        }
    }
    //cout<<v[0]<<endl;
    for(int j=0; j<=100; j++)
    {
        if(T<dp[j][(cnt+1)%2])break;
        else if(v.size()==0){ans=j;continue;}
        else if(T<dp[j][(cnt+1)%2]+v[0]){
            ans=max(ans,j);
        }
        else{
            int i = lower_bound(v.begin(),v.end(),T-dp[j][(cnt+1)%2])-v.begin();
            if(v[i]!=T-dp[j][(cnt+1)%2])i--;
            ans=max(ans,i+1+j);
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int  cmp(int a,int b){
	return a>b;
}
int main()
{
	int a[110];
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n,cmp);
	/*for(int i=0;i<n;i++)
		cout<<a[i];*/
	int ans,al,bo;
		ans=al=bo=0;
	for(int i=0;i<n;i++)
	{
		if(i%2==0)
			al+=a[i];
		else
			bo+=a[i];
	}
	ans+=al-bo;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

def f(r, c, fact, revfact, mod):
    return (fact[r + c] * revfact[r] * revfact[c]) % mod

def g(r, c, fact, revfact, mod):
    if r == c == 0: return 1
    elif r == 0: return c + 1
    elif c == 0: return r + 1
    ans = 0
    for i in range(1, c + 2):
        ans += f(r, i, fact, revfact, mod)
        ans %= mod
    return ans

def solve():
    input = sys.stdin.readline
    r1, c1, r2, c2 = map(int, input().split())
    mod = 7 + 10 ** 9
    fact = [1] * (5 + r2 + c2)
    revfact = [1] * (5 + r2 + c2)
    for i in range(1, 5 + r2 + c2): fact[i] = (i * fact[i-1]) % mod
    revfact[4 + r2 + c2] = pow(fact[4 + r2 + c2], mod - 2, mod)
    for i in reversed(range(1, 4 + r2 + c2)): revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    ans = g(r2, c2, fact, revfact, mod) - g(r2, c1 - 1, fact, revfact, mod) - g(r1 - 1, c2, fact, revfact, mod) + g(r1 - 1, c1 - 1, fact, revfact, mod)
    print((ans + mod) % mod)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 71532