akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 using namespace std;
#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define pb                      push_back
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define asort(c)                sort(all(c)) 
#define lbpos(x,v)              (int)(lower_bound(all(v),x)-v.begin())//=v.size()==>No LB 
#define ubpos(x,v)              (int)(upper_bound(all(v),x)-v.begin())//=v.size()==>No UB
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  long double                 ld;
#define debug(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1;
  ZZ(comma, args...);
}
clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(double)(time_p)/CLOCKS_PER_SEC<<"\n";
}

int32_t main()
{
  FIO;
 
  
  int n,h,w,a,b;
  cin>>n>>h>>w;
  int cnt=0;
  forn(i,n)
  {
    cin>>a>>b;
    int tem=min(a/h,b/w);
   // debug(tem);
    cnt+=tem;
  }
  cout<<cnt;
  timer();
  return 0;
}  

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

int n,m;
string s,t;

int main() {
  cin >> s >> t;
  t.pop_back();
  cout << (s==t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3588
N, K = map(int, input().split())
A = list(map(int, input().split()))
v = []
w = {}
now = 0
for i in range(K):
  p = A[now]
  now = p-1
  if p in w:
    j = v.index(p)
    df = i-j
    Kn = (K-i-1) % df
    p = v[j+Kn]
    break
  else:
    v.append(p)
    w[p] = p
print(p)

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

int f[64][64] = {0};
int dx[] = {0,0,1,1,1,-1,-1,-1};
int dy[] = {1,-1,0,1,-1,0,1,-1};

void dfs(int y, int x)
{
	f[y][x] = 0;
	for(int i=0; i<8; i++)
	{
		int ny = y+dy[i];
		int nx = x+dx[i];
		if(f[ny][nx])
		{
			dfs(ny,nx);
		}
	}
}

int main()
{
	int w,h,c,x,y;
	while(cin >> w >> h, w||h)
	{
		memset(f,0,sizeof(f));

		for(y=1; y<=h; y++)
		for(x=1; x<=w; x++)
		{
			cin >> f[y][x];
		}

		c=0;
		for(y=1; y<=h; y++)
		for(x=1; x<=w; x++)
		{
			if(f[y][x])
			{
				c++;
				dfs(y,x);
			}
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 0
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from bisect import bisect

def resolve():
    it = map(int, sys.stdin.read().split())
    N, M, K = next(it), next(it), next(it)

    A = [0] * (N+1)
    B = [0] * (M+1)
    for i in range(1, N+1):
        A[i] = A[i-1] + next(it)
    for i in range(1, M+1):
        B[i] = B[i-1] + next(it)

    ax = min(bisect(A, K), N)
    bx = min(bisect(B, K), M)

    ans = 0
    for i in range(ax+1):
        rest = K - A[i]
        for j in range(bx, -1, -1):
            if B[j] <= rest:
                bx = j
                ans = max(ans, i+j)
                break

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 111012
import scala.collection.mutable.ListBuffer
import scala.io.StdIn

object Main extends App {

  var Array(n, x) = Array(-1, -1)
  var count = 0
  val buff = ListBuffer.empty[Int]
  
  while(n != 0 || x != 0){
    val Array(inn, inx) = StdIn.readLine().split(' ').map(_.toInt)
    n = inn
    x = inx
    count = 0
    (1 to n).foreach{ h =>
      (h+1 to n).foreach{ i =>
        (i+1 to n).foreach{ k =>
          count += (if(h + i + k == x) 1 else 0)
        }
      }
    }
    
    buff += count
  }
  
  buff.dropRight(1).foreach(println)
  
}


Measured memory_bytes: 46080
#include <iostream>
#include <cstdio>
#define N 105
using namespace std;

int h, w, c[150], na[4];
string a;
int main()
{
	int i, j;
	cin >> h >> w;
	for (i = 0; i < h; i++) {
		cin >> a;
		for (j = 0; j < w; j++) c[a[j]]++;
	}
	for (i = 'a'; i <= 'z'; i++) {
		na[c[i] % 4]++;
	}
	if (na[1] + na[3] != (h % 2) * (w % 2)) {puts("No"); return 0;}
	if ((na[2] + na[3]) * 2 > h * (w % 2) + w * (h % 2) - (h % 2) * (w % 2)) {puts("No"); return 0;}
	puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
int ans;
int n,c,k;
pair<int,int> a[MAX];
int main()
{
	cin>>n>>c>>k;
	for(int i=1;i<=n;++i){
		cin>>a[i].first;
		a[i].second=a[i].first+k;
	}
	sort(a+1,a+n+1);
	int number=1;
	while(number<=n)
	{
		int used=0;
		int temp=a[number].second;
		for(int i=number;used<c&&a[i].first<=temp&&i<=n;++i){
			used++;
			number++;
		}
		ans++;
	}
	cout<<ans<<endl;
	return 0;	
}

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

#define int long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define repi(i, l, r) for(int i=(int)(l);i>=(int)(r);i--)
const int inf = 1e18;

using namespace std;


void solve() {
    string s;
    cin >> s;
    int n = s.size() - 1;
    if(s[n] == 's'){
        s+='e';
        s+='s';
    }
    else
        s+='s';

    cout << s << endl;
}


int32_t main() {
    fastIO
    int t = 1;
//    cin >> t;
    rep(i, 1, t) {
        solve();
    }
}



Measured memory_bytes: 3660
import sys
LA = RA = 0
LB = RB = 0
LC = RC = 0
LD = RD = 0

for i in sys.stdin:
    l,r = map(float,i.split())
    if l >= 1.1:
        LA += 1
    elif 0.6 <= l <1.1:
        LB += 1
    elif 0.2 <= l < 0.6:
        LC += 1
    else:
        LD += 1

    if r >= 1.1:
        RA += 1
    elif 0.6 <= r <1.1:
        RB += 1
    elif 0.2 <= r < 0.6:
        RC += 1
    else:
        RD += 1

print(LA,RA)
print(LB,RB)
print(LC,RC)
print(LD,RD)



Measured memory_bytes: 5576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll X,K,D; cin>>X>>K>>D;
  ll x = abs(X), ans = 1e15;
  ll count = x/D;
  if (count >= K){
    ans = x - K * D;
    abs(ans);
  }
  else{
    ll left = K-count;
    if (left%2 == 1){
      ans =  x - count * D;
      ans -= D;
      abs(ans);
    }
    else{
      ans = x - count * D;
      abs(ans);
    }      
  }
  if (ans<0)
    ans*=-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    else return gcd(b, a%b);
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e14;
using Graph = vector<vector<int>>;

signed main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A[i];

  int money = 1000;
  int kabu = 0;
  for( int i = 0; i < N; i++ ){
    if( i > 0 && A[i] > A[i-1] ){
      money += kabu*A[i];
      kabu = 0;
    }
    if( i < N-1 && A[i] < A[i+1] ){
      kabu += (money/A[i]);
      money -= (money/A[i])*A[i];
    }
  }
  money += kabu*A[N-1];
  cout << money << endl;

}


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

int main()
{
  int x;
  cin >> x;
  
  int delight = 0;

  delight += (x / 500) * 1000;
  x = x % 500;
  delight += (x / 5) * 5;
  
  cout << delight << endl;
  
  return 0;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
// #define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
	cin>>n;
	int d[110][4][4][4];
	rep(i,110)rep(j,4)rep(k,4)rep(l,4)
		d[i][j][k][l]=0;
	int MOD=1000000007;
	d[0][0][0][0]=1;
	//TAGC
	rep(i,n)rep(j,4)rep(k,4)rep(l,4)rep(x,4){
		int I=i+1,J=k,K=l,L=x;
		if(j==1&&k==2&&l==3)continue;
		if(k==1&&j==2&&l==3)continue;
		if(j==1&&l==2&&k==3)continue;
		if(j==1&&k==2&&x==3)continue;
		if(k==1&&l==2&&x==3)continue;
		if(j==1&&l==2&&x==3)continue;
		if(l==1&&k==2&&x==3)continue;
		if(k==1&&x==2&&l==3)continue;
		(d[I][J][K][L]+=d[i][j][k][l])%=MOD;
	}
	int s=0;
	rep(i,4)rep(j,4)rep(k,4)(s+=d[n][i][j][k])%=MOD;
	cout<<s<<endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> L(N);
    rep(i, N) cin >> L[i];
    sort(L.begin(), L.end());
    ll ans = 0;
    // print(L);
    rep(i, N) {
        ll a = L[i];
        rep2(j, i + 1, N) {
            ll b = L[j];
            ll t = lower_bound(L.begin(), L.end(), a + b) - L.begin();
            // print(a, b, t);
            ans += max(0LL, t - (j + 1));
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 256
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	k = I()
	x = I()
	y = I()

	if n <= k:
		print(x*n)
	else:
		print(x*k+(n-k)*y)


if __name__ == '__main__':
    main()

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

int main(){
	int x,y,s;
	int i,j;
	int max;
	int tmp_1,tmp_2;
	
	while(1){
		cin >> x >> y >> s;
		max=0;
		if(x==0&&y==0&&s==0){
			break;
		}
		for(i = 1 ; i < s ; i++){
			for(j = 1 ; j < s ; j++){
				tmp_1=(i*(100+x)/100)+(j*(100+x)/100);
				if(tmp_1==s){
					tmp_2 =(i*(100+y)/100)+(j*(100+y)/100);
				if(tmp_2 > max){
					max = tmp_2;
					}
				}
			}
		}
		cout << max << endl;
	}
		return 0;
}

Measured memory_bytes: 1160
from collections import deque

s = deque(input())
q = int(input())
cnt = 0

for _ in range(q):
    qs = input().split()
    if qs[0] == '1':
        cnt += 1
    else:
        if qs[1] == '1':
            if cnt%2 == 0:
                s.appendleft(qs[2])
            else:
                s.append(qs[2])
        else:
            if cnt%2 == 0:
                s.append(qs[2])
            else:
                s.appendleft(qs[2])
ans = ''.join(s)
print(ans if cnt%2 == 0 else ans[::-1])

Measured memory_bytes: 8564
import numpy as np

N = int(input())
A = np.zeros((N,2,N), dtype=bool) # A = {([false],[true]),,}

for i in range(N):
  for j in range(int(input())):
  	x, y = map(int,input().split())
  	A[i][y][x-1] = True

upper = 0

def hantei(mask):
  for a in A[mask]:
    if np.any(mask[a[0]]): return False
    if not(np.all(mask[a[1]])): return False
  return True

seed = 1 << np.arange(N)

for i in range(2**N):
  mask = (seed & i).astype(bool)
  s = np.sum(mask)
  if s <= upper: continue
  if hantei(mask): upper = s

print(upper)


Measured memory_bytes: 14408
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    LL A[N];REP(i,N)cin>>A[i];

    LL ans=0;
    REP(i,N){
        if(A[i]>=2){
            ans+=(A[i]-1)/2;
            A[i]-=((A[i]-1)/2)*2;
        }
    }

    REP(i,N){
        if(A[i]>=2){
            ans++;
        }else if(i<N-1&&A[i]&&A[i+1]){
            ans++;
            A[i+1]--;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;





int main()
{
    
  
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = c + (-d + b), y = d + (c - a);;
    cout << x << " " << y << " ";
    int g = x + (-y + d), f = y + (x - c);
    cout << g << " " << f << endl;

    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true;} return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true;} return false; }
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl kai(intl k){//k!を求める関数,
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所----------------------------------------------------

string s;

void input_var(){
    cin >> s;
}
//-------------------------------------------------------------------------------


signed main(){
    cout << fixed << setprecision(10);
    input_var();
    intl len = s.length();
    intl sum = 0;
    vector<intl> v;
    for(intl i = 0; i < (1 << (len - 1)); i++){
        intl idx = 0;
        intl cnt = 1;
        rep(j,len-1){
            if(i & (1 << j)){
                string t = s.substr(idx,cnt);
                v.pb(stoll(t));
                idx += cnt;
                cnt = 1;
            }
            else cnt++;
        }
        string t = s.substr(idx,cnt);
        v.pb(stoll(t));
    }
    for(auto i : v){
        sum += i;
        //debug(i);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[]a=new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt()-1;
		}
		Arrays.sort(a);
		int ans=0;
		int count=1;
		for(int i=0;i<n-1;i++) {
			if(a[i]==a[i+1]) {
				count++;
			}else {
				if(count%2!=0) {
					ans++;
					count=1;
				}else {
					count=1;
				}
			}
		}
		if(count%2!=0)ans++;
		System.out.println(ans);
	}
}

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll N, M;
    cin >> N >> M;

    vector<ll> P(M);
    vector<ll> Y(M);
    FOR(i, 0, M){
        cin >> P[i] >> Y[i];
        P[i]--;
    }

    vector<vector<ll> > G(N);
    FOR(i, 0, M){
        ll p = P[i];
        ll y = Y[i];
        G[p].push_back(y);
    }

    FOR(i, 0, N){
        sort(ALL(G[i]));
        
        // 重複除去
        auto it = unique(ALL(G[i]));
        G[i].erase(it, G[i].end());
    }

    FOR(i, 0, M){
        ll p = P[i];
        ll y = Y[i];

        ll index = lower_bound(ALL(G[p]), y) - G[p].begin();

        printf("%06d%06d\n", p+1, index+1);
    }
    
    return 0;
}

Measured memory_bytes: 8576
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
  // 標準入力からデータを読み込む準備
  Scanner sc = new Scanner(System.in);
  // 最初の文字の固まりを整数値と想定して読み込む
  int x = sc.nextInt();
  int answer = x*x*x /* ここを変えて3乗しよう! */;
  System.out.println(answer);
  }
 }


Measured memory_bytes: 26156
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) cout << "Zero" << endl;
	else {
		if (b < 0) {
			if ((b - a) % 2 == 0)cout << "Negative" << endl;
			else cout << "Positive" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n int
        fmt.Scanln(&n)
        a := make([]int, n+2)
        for i := range a[1 : n+1] {
                fmt.Scanf("%d", &a[i+1])
        }

        fullcost := 0
        for i := 1; i < len(a); i++ {
                fullcost += abs(a[i-1] - a[i])
        }

        for skip := 1; skip <= n; skip++ {
                cost := fullcost
                cost -= abs(a[skip-1] - a[skip])
                cost -= abs(a[skip] - a[skip+1])
                cost += abs(a[skip-1] - a[skip+1])
                fmt.Println(cost)
        }
}

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

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(void)
{
    int A,B;
    char op;
    cin >> A >> op >> B;
    if(op == '+') cout << A + B << endl;
    if(op == '-') cout << A - B << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}

int main(){
    string s;cin>>s;
    ll n=s.size(),start,goal;

    bool cant=true;
    rep(i,n){
        if(i+1<n){
            if(s[i]==s[i+1]){
                start=i;
                goal=i+1;
                cant=false;
                break;
            }
        }
        if(i+2<n){
            if(s[i]==s[i+2]){
                start=i;
                goal=i+2;
                cant=false;
                break;
            }
        }
    }

    if(!cant) cout<<start+1<<" "<<goal+1<<endl;
    else cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}
 
const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
struct combination {
  vector<mint> fact, bfact;
  combination(int n, int k):fact(k+1),bfact(k+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= k; ++i) fact[i] = fact[i-1]*i;
    bfact[0] = 1;
    for (int i = n; i >= n-k+1; --i) bfact[n-i+1] = bfact[n-i]*i;
  }
  mint operator()(int k) {
    //if (k < 0 || k > n) return 0;
    return bfact[k]*fact[k].inv();
  }
};

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    mint m = mpow(2LL,n);
    m -= 1;
    combination comb(n,min(200010LL,n));
    mint c = comb(a);
    mint d = comb(b);
    cout << (m - c - d) << endl;
    //cout << c << endl;
}



Measured memory_bytes: 3328
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
        double r=sc.nextDouble();
        
        double S=r*r*Math.PI;
        double R=2*r*Math.PI;

		System.out.printf("%.6f %.6f",S,R);
		System.out.println();

	}

}



Measured memory_bytes: 28276
#include <stdio.h>

int main(void){
    int x,y,z;
    scanf("%d",&x);
    scanf("%d",&y);
	if(x<y){
		z=x;
		x=y;
		y=z;
	}
	while(1){
		z = x%y;
		if(z==0){break;}
		x=y;
		y=z;
	}
	printf("%d\n",y);
	return 0;
}



Measured memory_bytes: 2144
#include<stdio.h>

int main(){
	int i,x,a,b,c,d,e,f,g,h;

	scanf("%d", &x);
	for (i = 1; i < x+1; i++){
		a = i % 10000;
		b = (i - a) / 10000;
		c = a % 1000;
		d = (a - c) / 1000;
		e = (c % 100);
		f = (c - e) / 100;
		g = (e % 10);
		h = (e - g) / 10;


		if (i % 3 == 0||a==3||b==3||c==3||d==3||e==3||f==3||g==3||h==3){
			printf(" %d", i);
		}
	}

	printf("\n");

	return 0;
}


Measured memory_bytes: 2140
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
#include<set>
#include<map>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
template<typename T>
T rabs(T a)
{
	return a>0?a:-a;
}
int n;
int a[200005];
long long s[200005];
long long que(int l,int r)
{
	return l?s[r]-s[l-1]:s[r];
}
long long ans=1234567998765ll;
int main()
{
	read(n);
	for(int i=0;i<n;i++)
		read(a[i]);
	s[0]=a[0];
	for(int i=1;i<n;i++)
		s[i]=s[i-1]+a[i];
	for(int i=1;i<n-2;i++)
	{
		int pos1=lower_bound(s,s+i+1,s[i]/2)-s;
		int pos2=lower_bound(s+i+1,s+n,(s[n-1]+s[i])/2)-s;
		for(int p1=pos1-1;p1<=pos1;p1++)
		{
			if(p1<0 || p1>=i)	continue;
			for(int p2=pos2-1;p2<=pos2;p2++)
			{
				if(p2>=n || p2<=i)	continue;
				long long a1=que(0,p1);
				long long a2=que(p1+1,i);
				long long a3=que(i+1,p2);
				long long a4=que(p2+1,n-1);
				ans=min(ans,max(a1,max(a2,max(a3,a4)))-min(a1,min(a2,min(a3,a4))));
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

using namespace std;

int main() {
    int A,B;cin>>A>>B;
    if(A>0 && A<10 && B>0 && B<10)cout<<A*B<<endl;
    else cout<<-1<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * ACB063-C-Bugged
 */
public class Main {

	static final int MAX = 10_000;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());
		boolean[][] dp = new boolean[N + 1][MAX + 1];

		dp[0][0] = true;

		for (int i = 1; i <= N; i++) {
			int s = parseInt(br.readLine());
			for (int j = 0; j <= MAX; j++) {
				if (dp[i - 1][j]) {
					dp[i][j] = true;
					dp[i][j + s] = true;
				}
			}
		}

		int ans = 0;

		for (int i = MAX; i >= 0; i--) {
			if (dp[N][i] && (i % 10) != 0) {
				ans = i;
				break;
			}
		}

		System.out.println(ans);
	}
}

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

prime = []
for n in range(3, X, 2):
    lim = int(n ** 0.5)
    f = True
    for p in prime:
        if p > lim:
            break
        if n % p == 0:
            f = False
            break
    if f:
        prime.append(n)
if X >= 3:
    prime = [2] + prime

for n in range(X, X+10**5):
    for p in prime:
        if n % p == 0:
            break
    else:
        print(n)
        break

Measured memory_bytes: 9864
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut cnt = 0;
	let mut ret = 0;
	for i in 1..(n+1) {
		if i%2 == 1 {
			for j in 1..(i+1) {
				if i % j == 0 {
					cnt += 1;
				}
			}
			if cnt == 8 {
				ret += 1;
			}
			cnt = 0;
		}
	}
	println!("{}", ret);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct edge{
    int to;
    ll cap;
    int rev;
};

vector<edge> es[111];
bool used[111];

void add_edge(int from, int to, ll cap){
    edge e1 = {to, cap, (int)es[to].size()}, e2 = {from, 0, (int)es[from].size()};
    es[from].emplace_back(e1), es[to].emplace_back(e2);
}

ll dfs(int now, int goal, ll flow){
    used[now] = true;
    if(now == goal) return flow;
    for(auto &e: es[now]){
        if(!used[e.to] && e.cap > 0){
            ll f = dfs(e.to, goal, min(flow, e.cap));
            if(f > 0){
                e.cap -= f;
                es[e.to][e.rev].cap += f;
                return f;
            }
        }
    }
    return 0;
}

ll max_flow(int s, int t){
    ll flow = 0;
    while(true){
        fill(used, used+111, false);
        ll f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){
    int N; cin >> N;
    rep2(i, 1, N){
        rep2(j, 2, N/i) add_edge(i, i*j, INF);
    }
    ll ans = 0;
    rep2(i, 1, N){
        ll A; cin >> A;
        if(A > 0) add_edge(i, N+1, A), ans += A;
        else add_edge(0, i, -A);
    }
    cout << ans-max_flow(0, N+1) << endl;
}

Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
      
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
      	int co = 0;
      
      while(true){
        co++;
		if(s==4||s==2||s==1){
          co=co+3;
          break;
        }
        if(s%2==0){s=s/2;}
        else if(s%2!=0){s=(s*3)+1;}
      }
      
        System.out.println(co);
    }
}

Measured memory_bytes: 23124
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner c = new Scanner(System.in);

        String str1 = c.nextLine();
        String str2 = c.nextLine();
        int count = 0;

        for (int i = 0; i < str1.length(); i++) {
            if (!str1.substring(i, i + 1).equals(str2.substring(i, i + 1))) {
                count++;
            }
        }

        System.out.println(count);

    }

}

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

using namespace std;

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

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(int i = (int)m; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define rep2(i,n) REP(i,1,n+1)
#define rep3(i,n) REP(i,0,n+1)
#define REPM(i,m,n) for(int i = (int)m; i >= (int)n; i--)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define repll(i,n) REPLL(i,0,n)
#define repll2(i,n) REPLL(i,1,n+1)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define Size(s) (int) s.size()

//------------------------------------------------------
//union-find

const int MAX_V = limit;

int par[MAX_V];
int rank_[MAX_V];

void init(int n) {

    rep(i, n) {
        par[i] = i;
        rank_[i] = 0;
    }
}

int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]); //経路圧縮
}

bool same(int x, int y) {
    return root(x) == root(y);
}

void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank_[x] < rank_[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rank_[x] == rank_[y]) rank_[x]++;
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    init(n);
    int p[n];

    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        unite(x, y);
    }

    int cnt = 0;

    rep(i, n) {
        if (root(p[i]) == root(i)) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int a, b;

int main() {
    vint alt;
    int points[500];
    
    while (scanf("%d,%d", &a, &b)) {
        if (a == 0 && b == 0) break;
        
        alt.PB(b);
        points[a] = b;
    }
    sort(ALL(alt));
    alt.erase(unique(ALL(alt)), alt.end());
    
    int n;
    while (cin >> n) {
        int it = lower_bound(ALL(alt), points[n]) - alt.begin();
        cout << alt.size() - it << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1264
# ARC60 D input
nw = list(map(int, input().split()))
N = nw[0]
w_limit = nw[1]

w = []
v = []
for i in range(N):
    wv = list(map(int, input().split()))
    w.append(wv[0])
    v.append(wv[1])

# ARC60 D recursive with memorization
dp = [{} for j in range(N+1)]
def rec_dp(i, j):
    if(j in dp[i]):
        return dp[i][j]
    
    res = 0
    if(i == N):
        res = 0
    elif(j < w[i]):
        res = rec_dp(i+1, j)
    else:
        res = max(rec_dp(i+1, j), rec_dp(i+1, j-w[i]) + v[i])
    
    dp[i][j] = res
    return res

print(rec_dp(0, w_limit))

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

n = int(input())
A = tuple(map(int, input().split()))
M = sum(A)
l = -(-M//2)
dp = 1
mask = (1<<(2*M))-1
for a in A:
  dp |= (dp<<a)&mask
dp >>= l
ans = (dp&(-dp)).bit_length() - 1 + l
print(ans)

Measured memory_bytes: 12184
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 28;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;
int n;

vector<ll> dijkstra(map<int, vector<pair<int, ll>>> &g, int start)
{
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pque;
    pque.push({0, start});
    vector<ll> ret(n + 2, INF);
    while (!pque.empty())
    {
        auto cost = pque.top().first;
        auto cur = pque.top().second;
        pque.pop();
        if (ret[cur] <= cost)
            continue;
        ret[cur] = cost;
        for (auto x : g[cur])
        {
            int next = x.first;
            ll d = x.second;
            pque.push({cost + d, next});
        }
    }

    return ret;
}

int main()
{
    int m, s, t;
    cin >> n >> m >> s >> t;
    map<int, vector<pair<int, ll>>> g1, g2;
    s--;
    t--;
    rep(i, m)
    {
        int a, b, c1, c2;
        cin >> a >> b >> c1 >> c2;
        a--;
        b--;
        g1[a].push_back({b, c1});
        g1[b].push_back({a, c1});
        g2[a].push_back({b, c2});
        g2[b].push_back({a, c2});
    }
    auto costs = dijkstra(g1, s);
    auto costt = dijkstra(g2, t);
    priority_queue<pair<ll, int>> ans;
    ll base = 1000000000000000ll;

    rep(i, n)
    {
        ans.push({base - costs[i] - costt[i], i});
    }
    rep(i, n)
    {
        while (ans.top().second < i)
        {
            ans.pop();
        }
        cout << ans.top().first << endl;
    }

    return 0;
}

Measured memory_bytes: 33140
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1,ll y1, ll x2,ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll k, x;
	cin >> k >> x;
	f(i, x - k + 1, x + k - 1)
	{
		cout << i << " ";
	}
	cout << x + k - 1;
	return 0;
}


Measured memory_bytes: 256
nums = [int(x) for x in input().split()]
k = int(input())

# R < G < B の関係性が成り立つようにする。
# 一度の操作で任意のカードの数字を二倍にできる　⇒  数字の操作はnums[x] }* (2**n)ということ。
# k回の2倍化処理が可能で、カードの種類は3種類なので、 3**k通りのパターンが考えられる。

def nums_check(nums):
      if nums[0] < nums[1] and nums[1] < nums[2]:
            return True
      else:
            return False

for i in range(k):
      if nums_check(nums) == True:
            break
      elif nums[0] >= nums[1]:
            nums[1] *= 2
      elif nums[1] >= nums[2]:
            nums[2] *= 2

print("Yes") if nums_check(nums) == True else print("No")

Measured memory_bytes: 9212
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
int a[maxn];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	} 
	if(a[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	ll res=0;
	for(int i=n-1;i>=0;){
		if(a[i]>i){
			cout<<-1<<endl;
			return 0;
		}
		res+=a[i];
		while(i>0&&a[i-1]==a[i]-1){
			--i;
		}
		if(i>0&&a[i-1]<a[i]){
			cout<<-1<<endl;
			return 0;
		}
		--i;
	}
	cout<<res<<endl;
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 2e5+5;

struct p{
    LL x, y;
    bool operator<(const p &p2) const {
        return x < p2.x || (x == p2.x && y < p2.y);
    }
};

LL cross(p o, p a, p b){
    return (a.x-o.x)*(b.y-o.y) - (a.y-o.y)*(b.x-o.x);
}

LL dis(p a, p b){
    return abs(a.x-b.x) + abs(a.y-b.y);
}

vector<p> andrew(vector<p>& arr){
    sort(All(arr));
    int n = arr.size();
    vector<p> res(2*n);
    int k = 0;
    for(int i = 0; i < n; ++i){
        while(k > 1 && (cross(res[k-2], res[k-1], arr[i]) <= 0)) k--;
        res[k++] = arr[i];
    }
    for(int i = n-2, t = k; i >= 0; --i){
        while(k > t && (cross(res[k-2], res[k-1], arr[i]) <= 0)) k--;
        res[k++] = arr[i];
    }
    k--;
    res.resize(k);
    return res;
}

void solve(){
    int n;
    cin >> n;
    vector<p> arr(n);
    for(int i = 0; i < n; ++i){
        cin >> arr[i].x >> arr[i].y;
    }

    vector<p> res = andrew(arr);
    LL mx = 0;
    for(int i = 0; i < sz(res); ++i){
        for(int j = i+1; j < sz(res); ++j){
            mx = max(mx, dis(res[i], res[j]));
        }
    }
    cout << mx << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 12684
#include<bits/stdc++.h>
using namespace std;
int a[10005],b[10005],n;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=n-2;i++)
	{
		if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]) 
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
using namespace std;
#define ll long long
int main()
{
    ll a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]%2 == 0 || a[1]%2 == 0 || a[2]%2 == 0)
    {
        cout<<0;
    }
    else cout<<(ll)(a[0] * a[1] * (a[2]%2));
    return 0;
}


Measured memory_bytes: 256
import sys
import numpy as np
import math
import random
import itertools
import re
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(2147483647)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

def binary_search(list,target):
	left = 0
	right = len(list)-1
	middle = 0
	while left+1 < right:
		middle = (right + left) // 2
		if list[middle] >= target:
			right = middle
		elif list[middle] < target:
			left = middle
	if list[left] >= target:
		return left
	else:
		return right

def main():
	a, b = LI()
	print(a*b)




if __name__ == '__main__':
    main()

Measured memory_bytes: 27152
n = int(input())
R = []
for _ in range(n):
    R.append(int(input()))

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(R[j] - minv, maxv)
    minv = min(R[j],minv)
print(maxv)

Measured memory_bytes: 15628
N, K = map(int, input().split())
h = [0] + list(map(int, input().split()))
dp = [0 for i in range(N+1)]

for i in range(2, N+1):
    kouho = []
    for k in range(1, min(i-1, K)+1):
        kouho.append(dp[i-k] + abs(h[i]-h[i-k]))
    dp[i] = min(kouho)
print(dp[N])

Measured memory_bytes: 57568