akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio> 
#include <algorithm>
using namespace std;

int main(){
    string s;
    long long q;

    cin >> s >> q;

    long long reverse_count = 0;
    string front;
    string back;

    for(long long i = 0; i < q; i++){
        long long t, f;
        char c;

        cin >> t;
        if(t == 1){
            reverse_count++;
            
        }
        else{
            cin >> f >> c;
            if(reverse_count % 2 == 0){
                if(f == 1){
                    //s = c + s;
                    //front = front + c;
                    front.insert(front.begin(), c);

                }
                else{
                    //s = s + c;
                    //back = back + c;
                    back.push_back(c);
                }
            }
            else{
                if(f == 1){
                    //s = s + c;
                    //back = back + c;
                    back.push_back(c);
                }
                else{
                    //s = c + s;
                    //front = front + c;
                    //front.push_back(c);
                    front.insert(front.begin(), c);
                }
            }
        }
    }

    s = front + s + back;

    if(reverse_count %2 != 0){
        //reverse(s.begin(), s.end());
        for(long long i = s.size()-1; i >= 0; i--){
            cout << s[i];
        }
        cout << endl;

    }
    else{

        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
#define in(s) ll s; cin>>s
#define pr(r) cout<<r<<endl
#define prr(m,n) cout<<m<<" "<<n<<endl
#define prarr(a,i,n) fab(j,i,n) cout<<a[j]<<" "
#define wh(t) ll t; cin>>t; while(t--)
#define sz(u) u.size()
#define all(v) v.begin(),v.end()
#define arr(a,n) ll a[n]; fab(i,0,n) cin>>a[i]
#define showdp(d,n,m) fab(i,0,n){ fab(j,0,m) if(d[i][j]==-1 || d[i][j]>9) cout<<d[i][j]<<" "; else cout<<" "<<d[i][j]<<" "; cout<<endl; }
#define prs(u) cout<<u<<" "
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fba(i,b,a) for(ll i=b;i>=a;i--)
#define sup ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MX 1000000007
#define MAX 10000007
#define endl "\n"
#define ll long long int
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define pl pair<ll,ll>
#define pll pair<ll,pl>
#define vvl vector<vl>
#define mxe(x,n) *max_element(x,x+n)
#define mne(x,n) *min_element(x,x+n)
#define mp make_pair
#define pb push_back
#define fs first
#define sd second
#define fr front()
#define bk back()
#define rr return
const ll N =(ll)3e5;
const ll inf =(ll)1e18+7;
const ll mod =(ll)1e9+7;
 
bool rsort1(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.first > b.first);}
bool rsort2(const pair<ll,ll> &a,const pair<ll,ll> &b) { return (a.second>b.second);}
bool sort2(const pair<ll,ll> &a,const pair<ll,ll> &b){ return (a.second < b.second);}
 
bool isPrime(ll p)
{
    for(ll i=2;i*i<=p;i++)
        if(p%i==0)
            rr false;
    rr true;
}
 
void sieve(ll n,vl &v)
{
    v.pb(2);
    bool prime[n+1];
    memset(prime,true,sizeof(prime));
    for(ll i=3;i*i<=n;i+=2)
        if(prime[i])
            for(ll j=i;j*i<=n;j+=2)
                prime[j*i]=false;
        
    for(ll i=3;i<=n;i+=2)
        if(prime[i])
            v.pb(i);
}

ll phi(ll n)
{
    ll result=n;
    for(ll p=2;p*p<=n;p++)
    {
        if(n%p==0)
        {
            while(n%p==0)
                n/=p;
            result-=result/p;
        }
    }

    if(n>1)
        result-=result/n;
    return result;
}

ll nCr(ll n, ll k) 
{ 
    ll C[n + 1][k + 1]; 
    ll i, j;  
    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            if (j == 0 || j == i) 
                C[i][j] = 1;  
            else
                C[i][j] = C[i - 1][j - 1] + 
                          C[i - 1][j]; 
        } 
    }
    return C[n][k]; 
} 


int main()
{
	sup;
    
    ll h;
    cin>>h;
    ll sum = 1,cnt = 0;
    while(h)
    {
        h = (h >> 1);
        cnt++;
    }

    sum = (sum << cnt);
    sum = (sum - 1);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        BigDecimal A = sc.nextBigDecimal();
        BigDecimal B = sc.nextBigDecimal();
        sc.close();
        System.out.println(A.multiply(B).toBigInteger());
    }
}


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

struct Process
{
  string name;
  int time;
};

int main()
{
  int n, q;
  cin >> n >> q;
  queue<Process> P;
  for (int i = 0; i < n; i++)
  {
    Process p;
    cin >> p.name >> p.time;
    P.push(p);
  }
  queue<Process> ans;
  int now = 0;
  while (!P.empty())
  {
    Process p = P.front();
    P.pop();
    if (p.time <= q)
    {
      now += p.time;
      p.time = now;
      ans.push(p);
    }
    else
    {
      now += q;
      p.time -= q;
      P.push(p);
    }
  }
  for (int i = 0; i < n; i++)
  {
    Process p = ans.front();
    ans.pop();
    cout << p.name << " " << p.time << endl;
  }
}


Measured memory_bytes: 6272
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <limits>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i, start, end) for(int i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

constexpr double ROOT3 = 1.7320508075688772;

struct Point {
    double x;
    double y;
    Point(double xx, double yy) : x(xx), y(yy) {}

    Point operator+(const Point& other) const
    {
        return Point(x+other.x, y+other.y);
    }

    Point operator-(const Point& other) const
    {
        return Point(x-other.x, y-other.y);
    }

    Point rotate60() const
    {
        double xx = 0.5*x       - 0.5*ROOT3*y;
        double yy = 0.5*ROOT3*x + 0.5*y;
        return Point(xx, yy);
    }

    void print() const
    {
        printf("%lf %lf\n", x, y);
    }
};

Point operator*(double t, Point p)
{
    return Point(t*p.x, t*p.y);
}

void koch(const Point& p1, const Point& p2, int n)
{
    if(n == 0) {
        p2.print();
        return;
    }

    Point s = 2.0/3.0*p1 + 1.0/3.0*p2;
    Point t = 1.0/3.0*p1 + 2.0/3.0*p2;
    Point u = s + (t-s).rotate60();

    koch(p1, s, n-1);
    koch(s,  u, n-1);
    koch(u,  t, n-1);
    koch(t, p2, n-1);
}

int main()
{
    int n;
    scanf("%d", &n);

    Point p1(  0.0, 0.0);
    Point p2(100.0, 0.0);
    p1.print();
    koch(p1, p2, n);

    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> E(N);
  for (int i = 0; i < M; i++){
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    E[L].push_back(make_pair(D, R));
    E[R].push_back(make_pair(-D, L));
  }
  vector<int> d(N);
  vector<int> comp(N, -1);
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (comp[i] == -1){
      comp[i] = i;
      d[i] = 0;
      queue<int> Q;
      Q.push(i);
      while (!Q.empty()){
        int v = Q.front();
        Q.pop();
        for (auto P : E[v]){
          int dist = P.first;
          int w = P.second;
          if (comp[w] != -1){
            if (d[w] != d[v] + dist){
              ok = false;
            }
          } else {
            comp[w] = i;
            d[w] = d[v] + dist;
            Q.push(w);
          }
        }
      }
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 12816
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
import functools

def SelectionSort(A):
    cnt = 0
    for i in range(len(A)):
        mini = i
        for j in range(i,len(A)):
            if A[j] < A[mini]:
                mini = j
        if mini != i:
            tmp = A[i]
            A[i] = A[mini]
            A[mini] = tmp
            cnt += 1
    return cnt
n = int(input())
A = list(map(int,input().split()))
cnt = SelectionSort(A)
print(*A)
print(cnt)



Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,i,x,y,s=0,q;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		s=s+a[i];
	}

	cin>>q;
	for(i=0;i<q;i++)
	{
		cin>>x>>y;
		ll f=((s-a[x-1])+y);
		cout<<f<<endl;
	}
	return;
	
}
	
int main()
{
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output1.txt", "w", stdout);
//#endif
	ll t=1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 256
n = int(input())
import sys

def ato(x):
    if x == "Male":
        return 0
    elif x == "Female":
        return 1
    else:
        return -1
    
print(0)
s0 = ato(input())
if s0 == -1:
    sys.exit()
    
print(n-1)
s1 = ato(input())
if s1 == -1:
    sys.exit()
    
left = 0
right = n-1
center = (left+right) // 2
while True:
    center = (left+right) // 2
    
    print(center)
    s2 = ato(input())
    if s2 == -1:
        break
    
    if (center - left)%2 == abs(s2 - s0):
        left = center
        s0 = s2
    else:
        right = center
        s1 = s2

Measured memory_bytes: 40288
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;

template<typename T> class CumulativeSum2D{
    public:
        vector<vector<T>> sum;
        
        CumulativeSum2D(int h, int w);
        void add(int x, int y, T v);
        void build();
        T get_rectangle(int sx, int sy, int gx, int gy);

        void build_row();
        void build_column();
        T get(int i, int j);
};

template<typename T> CumulativeSum2D<T>::CumulativeSum2D(int h, int w){
    sum = vector<vector<T>>(h + 2, vector<T>(w + 2, 0));
}

template<typename T> void CumulativeSum2D<T>::add(int x, int y, T v){
    sum[x + 1][y + 1] += v;
}

template<typename T> void CumulativeSum2D<T>::build(){
    for (int i = 1; i < sum.size(); i++){
        for (int j = 1; j < sum[i].size(); j++){
            sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
        }
    }
}

template<typename T> void CumulativeSum2D<T>::build_row(){
    for (int i = 1; i < sum.size(); i++){
        for (int j = 1; j < sum[i].size(); j++){
            sum[i][j] += sum[i][j - 1];
        }
    }
}

template<typename T> void CumulativeSum2D<T>::build_column(){
    for (int i = 1; i < sum.size(); i++){
        for (int j = 1; j < sum[i].size(); j++){
            sum[i][j] += sum[i - 1][j];
        }
    }
}

template<typename T> T CumulativeSum2D<T>::get_rectangle(int sx, int sy, int gx, int gy){
    return sum[gx + 1][gy + 1] - sum[sx][gy + 1] - sum[gx + 1][sy] + sum[sx][sy];
}

template<typename T> T CumulativeSum2D<T>::get(int i, int j){
    return sum[i + 1][j + 1];
}

const int Max = 100010;

int main(){
    int n, ch;
    cin >> n >> ch;
    CumulativeSum2D<int> cs(ch, Max);
    for (int i = 0; i < n; i++){
        int s, t, c;
        cin >> s >> t >> c;
        cs.add(c - 1, s - 1, 1);
        cs.add(c - 1, t, -1);
    }

    cs.build_row();
    for (int i = 0; i < ch; i++){
        for (int j = 0; j < Max; j++){
            if (cs.get(i, j) >= 2) cs.add(i, j, -1);
        }
    }

    cs.build_column();
    int ans = 0;
    for (int i = 1; i < Max; i++){
        ans = max(ans, cs.get(ch - 1, i));
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int v=0;
  if(n%10==2)v++;
  if((n%100-n%10)/10==2)v++;
  if(n/1000==2)v++;
  if((n-(n/1000)*1000)/100==2)v++;
cout << v << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const int N = 1e5+5,mod = 1e9+7;
it add(int x,int y){ return x+y>=mod?x+y-mod:x+y; }
it mul(int x,int y){ return 1ll*x*y%mod; }
il inc(int &x,int y){ x=add(x,y); }
int n,m,S,ans,val[N],fac[N],ifac[N],num[N],f[20][N];
it C(int n,int m){ return mul(mul(ifac[m],ifac[n-m]),fac[n]); }
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m),fac[0]=1,S=1<<n;
	for(ri i=1;i<=m;++i) read(val[i]);
	for(ri i=1;i<=S;++i) fac[i]=mul(fac[i-1],i);
	ifac[S]=qpow(fac[S],mod-2,mod);
	for(ri i=S-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	sort(val+1,val+1+m),f[m+1][0]=1;
	for(ri i=m;i>=1;--i) for(ri T=0;T<S;++T){
		inc(f[i][T],f[i+1][T]);
		for(ri j=0;j<n;++j) if(!(T&(1<<j))){
			int p=S-T-val[i];
			inc(f[i][T^(1<<j)],mul(f[i+1][T],mul(C(p,(1<<j)-1),fac[1<<j])));
		}
	}
	for(ri T=0;T<S;++T){
		num[T]=num[T>>1]+(T&1);
		f[1][T]=mul(f[1][T],fac[S-T-1]);
		if(num[T]&1) inc(ans,mod-f[1][T]);
		else inc(ans,f[1][T]);
	}
	print(mul(ans,S));
	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    int l = s.size();
    int counter = 0;
    for (int i = 0; i < l / 2; i++)
    {
        if (s[i] == s[l - i - 1])
            continue;
        counter++;
    }

    cout << counter << endl;

    return 0;
}

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

using namespace std ;
#define maxn 450
#define inf 1<<30 
typedef long long ll ;

int map[maxn+100][maxn+100] ;
int n,ma,mb ;
int ans ;

int main(void){
	for(int i=0; i<maxn; i++)
		for(int j=0; j<maxn; j++) map[i][j] = inf ;
			
	map[0][0] = 0 ;
	scanf("%d %d %d",&n,&ma,&mb ) ;
	for(int ii=0; ii<n; ii++) {
		int a, b,c ;
		scanf("%d%d%d",&a,&b,&c) ;
		for(int i=maxn; i>=a; i-- )
			for(int j=maxn; j>=b;j--) {
					map[i][j] = min(map[i][j],map[i-a][j-b]+c) ; 
			}
	}
	ans = 1<<30;
	for(int i=1; i<maxn; i++) 
		for(int j=1; j<maxn; j++) {
			if(i*mb==j*ma ) 
					ans = min(ans,map[i][j]) ;
		}
	if(ans == 1<<30) printf("-1\n") ;
		else printf("%d\n",ans) ;
	return 0 ;
}

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

int main() {
  ll x, i = 1, tmp = 0, ans1 = 0, ans2 = 0;
  cin >> x;
  while (i * (i + 1) / 2 < x) {
    ++i;
  }
  cout << i << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int asc(const void* a, const void* b) { return *(int*)a - *(int*)b; }
int desc(const void* a, const void* b) { return *(int*)b - *(int*)a; }

//qsort(data,10,sizeof(int),compare_int);

int main(void)
{
	int n;
	long long int sum;

	scanf("%d", &n);
	sum = 0;
	for (int i = 1; i < n; i++) {
		sum += i;
	}
	printf("%lld\n", sum);
	return 0;
}

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

const int mod = 1e9 + 7, N = 1e5 + 10;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}

ll getinv(ll n) {
    return pw(n, mod - 2);
}

void upd(ll &a, ll b) {
    a = (a + b) % mod;
}

int n, q;

ll cnt[N]; // 记录每个颜色出现次数
ll sum[N]; // 记录每个颜色的边权和
ll S;

struct E {
    int v, c, w;
};
vector<E> g[N];

int fa[N][22], dep[N];

struct T {
    int ids;
    int x, y; // 把颜色x的长度都改成y
    int tag; // 对答案贡献 +-1
};
vector<T> nekko[N];
ll ans[N];

int main() {
    scanf("%d%d", &n, &q);
    for(int i = 1 ; i < n ; ++ i) {
        int u, v, c, w;
        scanf("%d%d%d%d", &u, &v, &c, &w);
        g[u].push_back((E) { v, c, w });
        g[v].push_back((E) { u, c, w });
    }
    if(1) {
        function<void(int, int)> dfs = [&] (int u, int fa) {
            dep[u] = dep[fa] + 1;
            :: fa[u][0] = fa;
            for(int i = 1 ; i <= 20 ; ++ i) {
                :: fa[u][i] = :: fa[:: fa[u][i - 1]][i - 1];
            }
            for(auto e: g[u]) {
                int v = e.v;
                if(v != fa) {
                    dfs(v, u);
                }
            }
        };
        dfs(1, 0);
    }

    function<int(int, int)> getlca = [&] (int u, int v) {
        if(dep[u] < dep[v]) {
            swap(u, v);
        }
        for(int i = 20 ; ~ i ; -- i) {
            if(dep[fa[u][i]] >= dep[v]) {
                u = fa[u][i];
            }
        }
        if(u == v) {
            return u;
        }
        for(int i = 20 ; ~ i ; -- i) {
            if(fa[u][i] != fa[v][i]) {
                u = fa[u][i];
                v = fa[v][i];
            }
        }
        return fa[u][0];
    };

    for(int i = 1 ; i <= q ; ++ i) {
        int x, y, u, v;
        scanf("%d%d%d%d", &x, &y, &u, &v);
        int lca = getlca(u, v);
        nekko[u].push_back((T) { i, x, y, 1 });
        nekko[v].push_back((T) { i, x, y, 1 });
        nekko[lca].push_back((T) { i, x, y, -2 });
    }
    
    if(1) {
        function<void(int, int)> dfs = [&] (int u, int fa) {
            for(auto e: nekko[u]) {
                ll val = S - sum[e.x] + (ll) cnt[e.x] * e.y;
                ans[e.ids] += val * e.tag;
            }
            for(auto e: g[u]) {
                int v = e.v;
                if(v != fa) {
                    ++ cnt[e.c];
                    sum[e.c] += e.w;
                    S += e.w;
                    dfs(v, u);
                    -- cnt[e.c];
                    sum[e.c] -= e.w;
                    S -= e.w;
                }
            }
        };
        dfs(1, 0);
    }

    for(int i = 1 ; i <= q ; ++ i) {
        printf("%lld\n", ans[i]);
    }
}


Measured memory_bytes: 33908
#include<iostream>
#include<vector>
#include<queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int ans = 0;
  rep(i,n) ans += a[i];
  
  sort(a.begin(),a.end());
  double num = (double)ans / (4*m);

  for (int i = 0; i<m; i++) {
    if (a[n-1-i] < num) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
  
}
       


Measured memory_bytes: 888
n,q=map(int,input().split())
s=input()

lst=[0]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        lst.append(lst[i-1]+1)
    else:
        lst.append(lst[i-1])

for i in range(q):
    l,r=map(int,input().split())
    print(lst[r-1]-lst[l-1])

Measured memory_bytes: 11468
#include<bits/stdc++.h>
#define int long long

using namespace std;

signed main(){
	int x,y,z;
	cin>>x>>y>>z;
	x = x+y;
	y = x-y;
	x = x-y;
	x = x+z;
	z = x-z;
	x = x-z;
	cout<<x<<" "<<y<<" "<<z<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#define rep(i, j) for(int i = 0; i < j; i++)
#define all(i) i.begin(), i.end()
using namespace std;
string valc = { "mcxi" };
string cnvstr(int num)
{
	string str;
	int dat[] = { (num - (num % 1000)) / 1000, (num % 1000 - num % 100) / 100,	
					  (num % 100 - num % 10) / 10, num % 10 };
	rep(i, 4)
	{
		if (dat[i] == 0) { continue; }
		else if (dat[i] == 1) { str.push_back(valc[i]); }
		else
		{
			str.push_back(dat[i] + '0');
			str.push_back(valc[i]);
		}
	}
	return str;
}
int cnvnum(string str)
{
	int vali[] = { 1000, 100, 10, 1 };
	int num = 0, tmp = 0, j = 0;
	rep(i, (int)str.size())
	{
		int val = valc.find(str[i]);
		if (val >= 0)
		{
			if (tmp > 0) { tmp *= vali[val]; }
			else { tmp += vali[val]; }
			j = 0;
		}
		else
		{
			tmp += str[i] - '0';
			j++;
		}
		if (j == 0) 
		{ 
			num += tmp;
			tmp = 0;
		}
	}
	return num;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	rep(i, n)
	{
		string str1, str2; cin >> str1 >> str2;
		cout << cnvstr(cnvnum(str1) + cnvnum(str2)) << "\n";
	}
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
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); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#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 cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
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 digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n;
    cin >> n;
    string s;
    cin >> s;
    intl max = 0;
    rep(i,n - 1){
        intl cnt = 0;
        string t,u;
        rep(j,i + 1)t += s[j];
        repi(j,i + 1, n)u += s[j];
        sort(all(t));
        sort(all(u));
        char a = '0';
        rep(j,t.length()){
            if(a == t[j])continue;
            a = t[j];
            rep(k,u.length()){
                if(t[j] == u[k]){
                    cnt++;
                    break;
                }
            }
        }
        max = max(max,cnt);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
			System.out.println(n / 2 - 1);
		} else {
			System.out.println(n / 2);
		}
	}
}


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

int main()
{
    int n,W;
    cin>>n>>W;
    long long int val[n];
    int wt[n];
    for(int i=0;i<n;i++){
        cin>>wt[i]>>val[i];
    }
    long long int dp[n+1][W+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=W;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(wt[i-1]<=j){
                dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
            }
            else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    

    return 0;
}


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

using namespace std;
const int N = 1e5 + 3;
int n, a[N];
int main() {
#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);
	int cur = 0, res = 0;
	for (int i = n - 2; i >= 0; --i) {
		if (a[i] >= a[i + 1])
			++cur;
		else
			cur = 0;
		res = max(res, cur);
	}
	printf("%d\n", res);
	return 0;
}


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

using namespace std;
typedef long long ll;
typedef double ld;

ll n, m, x;
ll a[200010];
ll b[200010];
ll nu1[200010];
ll nu2[200010];
ll ans;
ll s;
ll sum;

int main(void)
{
	scanf("%lld %lld %lld", &n, &m, &x);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		scanf("%lld", &a[i]);
		nu1[i] = nu1[i - 1] + a[i];
	}
	
	for(ll i = 1 ; i <= m ; i++)
	{
		scanf("%lld", &b[i]);
		nu2[i] = nu2[i - 1] + b[i];
	}
	
	s = m;
	
	for(ll i = 0 ; i <= n ; i++)
	{
		if(x - nu1[i] < 0)
			break;
		
		ll gap = x - nu1[i];
		
		while(s >= 0 && nu2[s] > gap)
			s--;
		
		ans = max(ans, i + s);
	}
	
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 10068
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val n = readInt()
  val area = Array.tabulate(n){_ ⇒ readLine.trim.map{_ == 'o'}.toArray}
  var count = 0
  for (x ← 0 until n by 2; y ← 0 until n by 2 if area(y)(x)) {
    count += 1
    draw(area, x, y)
  }
  println((count - 1) / 3)
  def draw(area: Array[Array[Boolean]], x: Int, y: Int): Unit = {
    val queue = mutable.Queue(Coordinate(x, y))
    area(y)(x) = false
    while (queue.nonEmpty) {
      val current = queue.dequeue()
      for (c@Coordinate(nx, ny) ← current.neighbor if area.indices.contains(ny) && area(ny).indices.contains(nx) && area(ny)(nx)) {
        area(ny)(nx) = false
        queue.enqueue(c)
      }
    }
  }
  case class Coordinate(x: Int, y: Int) {
    def neighbor: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
  }
}


Measured memory_bytes: 57928
import sys
for l in sys.stdin:
 d=[{'o':1,'x':-1,'s':0}[s]for s in l.strip()]
 a=[sum(s)for s in(d[0:3],d[3:6],d[6:],d[0::3],d[1::3],d[2::3],d[0::4],d[2:8:2])]
 print('o'if 3 in a else'x'if -3 in a else'd')

Measured memory_bytes: 5572
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/












ll A, B;
//---------------------------------------------------------------------------------------------------
ll f(ll x) {
    if (x <= 0) return 0;

    ll tot = 0;
    ll res = 0;

    rrep(d, 50, 0) {
        ll sm = tot;

        if (x & (1LL << d)) {
            tot += (1LL << d) / 2;
            x -= (1LL << d);
            sm += x + 1;
        }

        if (sm % 2 == 1) res += 1LL << d;
    }

    return res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    ll ans = f(B) ^ f(A - 1);
    cout << ans << endl;
}




Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
int main(void){
    int i=0,cnt=0,x;
    char tile[100000];
    scanf("%s",tile);
    x=strlen(tile);
    do{
      if(tile[i]==tile[i+1]&&tile[i]=='1'){
      tile[i+1]='0';
      cnt++;
      
     
      }
     else if(tile[i]==tile[i+1]&&tile[i]=='0'){
      tile[i+1]='1';
      cnt++;
      
     
     }  
      i++;
    }while(i<strlen(tile));
  printf("%d",cnt);
   
    
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int maxx=100010;

vector<pair<int,int > > A[maxx];
int d[maxx];
bool flag[maxx];
int n,a,s,b,ans=0;

int bfs(int u){
	int cur;
	queue<int> S; 
	S.push(u);
	d[u]=0;
	while(S.empty()==0){
		cur=S.front();
		S.pop();
		flag[cur]=true;
		for(int i=0;i<A[cur].size();i++){
			if(flag[A[cur][i].first]==false){
				d[A[cur][i].first]=d[cur]+A[cur][i].second;
				S.push(A[cur][i].first);
			}
		}
	}
	int m=d[u];
	cur=u;
	for(int i=0;i<n;i++) {
		if(d[i]>m){
			m=d[i];
			cur=i;
		}
	}
	ans=d[cur];
	return cur;
}


int main(){
	std::ios::sync_with_stdio(false);
	for(int i=0;i<maxx;i++){
		flag[i]=false;
	}
	
	cin>>n;
	int x,y,v;
	for(int i=1;i<n;i++){
		cin>>x>>y>>v;
		A[x].push_back(make_pair(y,v));
		A[y].push_back(make_pair(x,v));
	}
	
	a=0;
	s=bfs(a);
	for(int i=0;i<maxx;i++){
		flag[i]=false;
	}
	b=bfs(s);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10048
N = int(input())
even = [2, 4, 3, 9, 8, 10, 6, 12]
odd = [6, 2, 4, 3, 9, 8, 10, 12]

if N == 3:
    print(2, 5, 63)
    exit()
    
ans = []
if N % 2 == 0:
    for i in range(N):
        ans.append(even[i%8]+12*(i//8))
else:
    for i in range(N):
        ans.append(odd[i%8]+12*(i//8))
ans = list(map(str, ans))
print(" ".join(ans))

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

int main(){
    int i, c = 700;
    string s;
    cin >> s;
    for(i=0; i<3; i++){
        if(s[i] == 'o'){
            c += 100;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <utility>
using namespace std;
//#define local
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    char s[105][105],t[105];
    int n,l,i,j;
    cin>>n>>l;
    for(i=0; i<n; i++)
        scanf("%s",s[i]);
    for(i=0; i<n-1; i++)
    {
        for(j=0; j<n-1-i; j++)
        {
            if(strcmp(s[j],s[j+1])>0)
            {
                strcpy(t,s[j]);
                strcpy(s[j],s[j+1]);
                strcpy(s[j+1],t);
            }
        }
    }
    for(i=0; i<n; i++) cout<<s[i];
    return 0;
}


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

int main()
{
    int n, k;
    string s;
    cin>>n>>k>>s;

    int i=0, j=0;
    for(; j<n; ++j) {
        if (s[j]=='0' and (j==0 or s[j-1]=='1')) --k;
        if (k<0) {
            if (s[i]=='0' and s[i+1]=='1') ++k;
            ++i;
        }
    }
    cout<<j-i<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
double tanri(long first,double rate,long price,int year){
	long rsum=0,final=first;
	for(int k=0;k<year;k++){
		rsum += final*rate;
		final -= price;
	}
	final += rsum;
	return final;
}

double hukuri(long first,double rate,long price,int year){
	long final=first;
	for(int k=0;k<year;k++){
		final += final*rate-price;
	}
	return final;
}

int main(){
	int m;
	cin>>m;
	for(int i=0;i<m;i++){
		vector<long> money;
		long first;
		int year,n;
		cin>>first;
		cin>>year;
		cin>>n;
		for(int j=0;j<n;j++){
			int p;
			double rate;
			long final,price;
			cin>>p>>rate>>price;
			if(p==0){
				final=tanri(first,rate,price,year);
			}else if(p==1){
				final=hukuri(first,rate,price,year);
			}
			money.push_back(final);
		}
		sort(money.begin(),money.end());
		cout<<money[money.size()-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n; std::cin >> n;
	std::vector<int> values(n); for (auto& v : values) std::cin >> v;
	std::cout << std::distance(values.begin(), std::min_element(values.begin(), values.end())) + 1 << std::endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, x, t; scanf("%d%d%d", &n, &x, &t);
  printf("%d", (n+x-1)/x*t);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define INF  numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()

using namespace std;
using ll = long long;

const int N_MAX = 8;
int N, M;
bool edge[N_MAX][N_MAX];
int reached_vertex[N_MAX];

int dfs(int vertex) {
    if(std::accumulate(reached_vertex, reached_vertex + N, 0) == N) {
        return 1;
    }

    int ret = 0;
    REP(i, N) {
        if(!edge[vertex][i] || reached_vertex[i]) continue;

        reached_vertex[i] = 1;
        ret += dfs(i);
        reached_vertex[i] = 0;
    }

    return ret;
}

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

    std::cin >> N >> M;
    REP(i, N) {
        reached_vertex[i] = 0;
    }

    REP(i, M) {
        int a, b;
        std::cin >> a >> b;
        edge[a - 1][b - 1] = edge[b - 1][a - 1] = true;
    }

    reached_vertex[0] = 1;
    std::cout << dfs(0) << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String []args){

		//????????????
		int count = 0;

		//????????£?????????????????????
		Scanner sc = new Scanner(System.in);
		//a?????????
		int a = sc.nextInt();
		//b?????????
		int b = sc.nextInt();
		//c?????????
		int c = sc.nextInt();

		//
		for(int i = a; i <= b; i++){
			if(c % i == 0)
			//????????????
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 26232
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	n := p.NextInts()
	a, b, c, d := n[0], n[1], n[2], n[3]
	if abs(a-b) <= d && abs(c-b) <= d || abs(c-a) <= d {
		p.Printf("Yes")
	} else {
		p.Printf("No")
	}
}

func abs(x int) int {
	if x < 0 {
		return x * -1
	}
	return x
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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



int main() {
  int N;
  cin >> N;

  vector<int> vec(N+1, 1);
  for (int i = 1; i < N+1; ++i){
    cin >> vec.at(i);
  }

  int num = 0;
  int now = 0;
  int next = 0;
  while (0 <= num){
    next = vec.at(now);
    vec.at(now) = 0;
    num++;
    if (0 == vec.at(next)){
      num = -1;
    }
    else if (2 == vec.at(next)){
      break;
    }
    now = next;
  }
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 640
fn main() {
    let n: i32 = read();
    let l_list: Vec<i32> = read_vec();

    let mut count = 0;

    // 三角形の条件
    // |a−b| < c < a + b
    for i in 0..(n-2) {
        let a = l_list[i as usize];
        for j in i..(n-1) {
            let b = l_list[j as usize];
            if a == b {
                continue;
            }

            for k in j..n {
                let c = l_list[k as usize];
                if a == c || b == c {
                    continue;
                }

                if (a - b).abs() < c && c < (a + b) {
                    count += 1;
                }
            }
        }
    }

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

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {
	private StringTokenizer st;
	private BufferedReader bf;
	private int w,h,x,y,r;
	
	Main() {
//		readData();
		
		for (int i=1;i<=9;i++) {
			for (int j=1;j<=9;j++) {
				System.out.println(i+"x"+j+"="+(i*j));
			}
		}

	}
	

	private void readData() {
		try {
			bf = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(bf.readLine());
			
//			w = nextInt();


			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private int nextInt() throws IOException {
		return Integer.parseInt(next());
	}
	
	private String next() throws IOException {
		if (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(bf.readLine());
		return st.nextToken();
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Main m = new Main();
	}

}

Measured memory_bytes: 16864
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

struct edge { int to, cost; };
int n, m, s, g;
vector<edge>GS[114514], GY[114514];
int ds[114514], dy[114514];
void dijkstra1() {
	prique(P)que;
	fill(ds, ds + n, inf);
	que.push({ 0,s });
	ds[s] = 0;
	while (que.size()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (ds[v] < p.first)continue;
		rep(i, GS[v].size()) {
			edge e = GS[v][i];
			if (ds[e.to] > ds[v] + e.cost) {
				ds[e.to] = ds[v] + e.cost;
				que.push({ ds[e.to],e.to });
			}
		}
	}
}
void dijkstra2() {
	prique(P)que;
	fill(dy, dy + n, inf);
	que.push({ 0,g });
	dy[g] = 0;
	while (que.size()) {
		P p = que.top(); que.pop();
		int v = p.second;
		if (dy[v] < p.first)continue;
		rep(i, GY[v].size()) {
			edge e = GY[v][i];
			if (dy[e.to] > dy[v] + e.cost) {
				dy[e.to] = dy[v] + e.cost;
				que.push({ dy[e.to],e.to });
			}
		}
	}
	dijkstra1();
}
int BEGIN = 1000000000000000;
int ans[114514];
signed main() {
	cin >> n >> m >> s >> g;
	s--; g--;
	rep(i, m) {
		int p, q, r, t; cin >> p >> q >> r >> t;
		GS[p - 1].push_back({ q - 1,r });
		GS[q - 1].push_back({ p - 1,r });
		GY[p - 1].push_back({ q - 1,t });
		GY[q - 1].push_back({ p - 1,t });
	}
	dijkstra2();
	for (int i = n - 1; i >= 0; i--) {
		ans[i] = max(ans[i + 1], BEGIN - ds[i] - dy[i]);
	}
	rep(i, n) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 19968
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define reads(s) string s; cin >> s;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
#define setprec(x) cout << fixed << setprecision(x);
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 

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

    //start from here

    readc(r, D, xi)

    fori (i, 1, 10)
    {
        xi = r*xi - D;
        print(xi)
    }

    return 0;
}


Measured memory_bytes: 256
// Author - Kartikeya Gupta
// Problem Link - https://atcoder.jp/contests/dp/tasks/dp_e

#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <fstream>
#include <typeinfo>
#include <sstream>
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define I insert
#define pb push_back
#define F first
#define S second
#define br "\n"
#define repi(i, a, b) for (ll i = a; i < b; i++)
#define repj(j, a, b) for (ll j = a; j < b; j++)
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define mod 1000000007
#define lim 100001
#define pi 3.14159265

using namespace std;

ll factorial(ll n)      {    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1); }
ll gcd(ll a, ll b)      {    if (a == 0)  return b; else return gcd(b % a, a);}
ll power(ll a, ll n)    {    if (n == 1) return a;else if (n == 0) return 1; else{ ll r = power(a, n / 2);if (n % 2 == 0)    return r * r;    else    return r * a * r;}}
ll nCr(ll n, ll r)      {    return ((factorial(n)) / (factorial(n - r) * factorial(r))); }
double precise(double n){    return floor(pow(10, 250) * n) / pow(10, 250);}

ll calculate(ll w,ll n, ll weights[], ll value[], vector<vll>& rec){
    if((w==0) or (n==-1)){
        return 0;
    }
    if(rec[w][n]!=-1){
        return (rec[w][n]);
    }
    ll weight = weights[n];
    if(weight>w){
        return  rec[w][n] = calculate(w, n - 1, weights,value,rec);
    }
    else{
    return rec[w][n] = max(calculate(w, n - 1, weights, value, rec), value[n] + calculate(w - weight, n-1, weights, value, rec));
    }
}

void solve(){
    int temp;
    cin >> temp;
    if(temp>29){
        cout << "Yes";
    }
    else
        cout << "No";
}

int main()
{    
/*#ifndef ONLINE_JUDGE
    // for getting input from input.
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif*/
    ll t;
	t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	//cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){

  int a, b, c;
  int x;

  scanf("%d %d %d", &a, &b, &c);

  x=a-b;

  if(x<c){
    printf("%d", c-x);
  }else{
    printf("0\n");
  }

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int k;
    cin >> k;
    string str;
    cin >> str;
    int temp = 0;
    char before = ' ';
    for (int i = 0; i < n; i++)
    {
        if (before != str[i])
        {
            temp++;
        }
        before = str[i];
    }
    cout << n - max(temp - 2 * k, 1) << endl;
    return 0;
}

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

using namespace std;

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const double PI = 3.14159265358979323846;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;
int h[110000];
int dp[110000];

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++)cin >> h[i];
    for (int i = 1; i < N; i++) {
        dp[i] = 1145141919;
        for (int j = i - 1; j >= max(0LL, i - K); j--)dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
    }
    cout << dp[N - 1] << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
	int X,Y,Z,n,m;
	while(scanf("%d %d %d",&X,&Y,&Z)!=EOF)
	{
		n=X/(Y+Z);
		if(X-(Y+Z)*n<Z)
			n--;	
		printf("%d\n",n);
	}
	return 0;
}

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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    
	int a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
}


Measured memory_bytes: 3632