akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;
typedef pair<int, int> pint;

int main() {
    string s,t,u;
    int a,b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (s == u) cout << a- 1 << " " << b<< endl;
    else cout << a << " "<< b -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
	int n;
	long long z = 0, x = 0;
	cin >> n;
	vector<int> a(n), b(n);
	for (int q = 0; q < n; q++) {
		cin >> a[q];
	}
	for (int q = 0; q < n; q++) {
		cin >> b[q];
	}
	for (int q = 0; q < n; q++) {
		if (a[q] < b[q])
			z += (b[q] - a[q]) / 2;
		else if (a[q] > b[q])
			x += a[q] - b[q];
	}
	if (z < x)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#pragma GCC optimize(2)
using namespace std;
#define maxn 400005
#define inf 0x7fffffff
//#define INF 1e18
#define rdint(x) scanf("%d",&x)
#define rdllt(x) scanf("%lld",&x)
#define rdult(x) scanf("%lu",&x)
#define rdlf(x) scanf("%lf",&x)
#define rdstr(x) scanf("%s",x)
typedef long long  ll;
typedef unsigned long long ull;
typedef unsigned int U;
#define ms(x) memset((x),0,sizeof(x))
const long long int mod = 1e9;
#define Mod 1000000000
#define sq(x) (x)*(x)
#define eps 1e-11
typedef pair<int, int> pii;
#define pi acos(-1.0)
//const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> pii;
 
inline int rd() {
    int x = 0;
    char c = getchar();
    bool f = false;
    while (!isdigit(c)) {
        if (c == '-') f = true;
        c = getchar();
    }
    while (isdigit(c)) {
        x = (x << 1) + (x << 3) + (c ^ 48);
        c = getchar();
    }
    return f ? -x : x;
}
 
 
ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a%b);
}
int sqr(int x) { return x * x; }
 
 
 
/*ll ans;
ll exgcd(ll a, ll b, ll &x, ll &y) {
    if (!b) {
        x = 1; y = 0; return a;
    }
    ans = exgcd(b, a%b, x, y);
    ll t = x; x = y; y = t - a / b * y;
    return ans;
}
*/
 
 
struct node {
    double x, y;
}pt[maxn];
 
node o;
int n;
double r;
 
double dis(node a, node b) {
    return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}
 
void dt(node p1, node p2, node p3) {
    double a, b, c, d, e, f;
    a = p2.y - p1.y;
    b = p3.y - p1.y;
    c = p2.x - p1.x;
    d = p3.x - p1.x;
    f = p3.x*p3.x + p3.y*p3.y - p1.x*p1.x - p1.y*p1.y;
    e = p2.x*p2.x + p2.y*p2.y - p1.x*p1.x - p1.y*p1.y;
    o.x = (a*f - b * e) / (2 * a*d - 2 * b*c);
    o.y = (d*e - c * f) / (2 * a*d - 2 * b*c);
    r = dis(o, p1);
}
 
int main() {
//  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    rdint(n);
    for (int i = 1; i <= n; i++) {
        rdlf(pt[i].x); rdlf(pt[i].y);
    }
    random_shuffle(pt + 1, pt + 1 + n);
    o = pt[1]; r = 0;
    for (int i = 2; i <= n; i++) {
        if (dis(pt[i], o) > r + eps) {
            o = pt[i]; r = 0;
            for (int j = 1; j <= i - 1; j++) {
                if (dis(o, pt[j]) > r + eps) {
                    o.x = (pt[i].x + pt[j].x) / 2.0;
                    o.y = (pt[i].y + pt[j].y) / 2.0;
                    r = dis(o, pt[j]);
                    for (int k = 1; k <= j - 1; k++) {
                        if (dis(o, pt[k]) > r + eps) {
                            dt(pt[i], pt[j], pt[k]);
                        }
                    }
                }
            }
        }
    }
    printf("%.10lf\n", 1.0*r);
    return 0;
}

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

int main(){

  int n,d;
  cin>>n>>d;

  if(n>=d+1){
    
    int ans=0;
    int sum=0;
  while(1){
    ans++;
    sum+=(2*d+1);
    if(sum>=n) break;
  }
  cout<<ans<<endl;

}else {
  cout<<1<<endl;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {

    ios::sync_with_stdio(false);

    int t = 0;
    pair<int, int> poz = {0, 0};

    int n;
    cin >> n;

    int tN = 0;
    pair<int, int> pozN = {0, 0};

    for(int i = 1; i <= n; i++) {

        cin >> tN >> pozN.first >> pozN.second;

        int dif = tN-t;
        int dist = abs(pozN.first - poz.first) + abs(pozN.second - poz.second);

        if(dist%2 != dif%2 || dist > dif) {
            cout << "No";
            return 0;
        }

        t = tN;
        poz = pozN;

    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int H,W;
    cin >> H >> W;
    char S[H][W];
    rep(i,H) cin >> S[i];
    bool reach[H][W]={};
    int dis[H][W];
    int ans=0;
    rep(k,H) rep(l,W){
        if(S[k][l]=='#') continue;
        rep(i,H) rep(j,W) dis[i][j]=INF,reach[i][j]=false;
        dis[k][l]=0;
        queue<pint> q;
        q.push(pint(k,l));
        while(!q.empty()){
            pint p=q.front();
            q.pop();
            if(p.first<0 || p.first>=H || p.second<0 || p.second>=W) continue;
            if(reach[p.first][p.second]) continue;
            reach[p.first][p.second]=true;
            if(p.first<H-1) if(S[p.first+1][p.second]!='#') q.push(pint(p.first+1,p.second));
            if(p.first>0) if(S[p.first-1][p.second]!='#') q.push(pint(p.first-1,p.second));
            if(p.second<W-1) if(S[p.first][p.second+1]!='#') q.push(pint(p.first,p.second+1));
            if(p.second>0) if(S[p.first][p.second-1]!='#') q.push(pint(p.first,p.second-1));
            if(p.first!=0) if(S[p.first-1][p.second]!='#') dis[p.first-1][p.second]=min(dis[p.first-1][p.second],dis[p.first][p.second]+1);
            if(p.first!=H-1) if(S[p.first+1][p.second]!='#') dis[p.first+1][p.second]=min(dis[p.first+1][p.second],dis[p.first][p.second]+1);
            if(p.second!=0) if(S[p.first][p.second-1]!='#') dis[p.first][p.second-1]=min(dis[p.first][p.second-1],dis[p.first][p.second]+1);
            if(p.second!=W-1) if(S[p.first][p.second+1]!='#') dis[p.first][p.second+1]=min(dis[p.first][p.second+1],dis[p.first][p.second]+1);
        }
        rep(i,H) rep(j,W) if(dis[i][j]!=INF) ans=max(ans,dis[i][j]);
    }
  cout << ans << endl;
}

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

using namespace std;

int main() {
    int N, X;
    int m[1010];
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> m[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += m[i];
    }
    int mn = *min_element(m, m + N);
    X -= sum;
    int Xan = X / mn;
    cout << Xan + N << endl;
}

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

int main() {
  int N,a,b,sum;
  cin >> N;
  
  for(int i=0; i<N; i++){
  	b=0;
    cin >> a;
    if(a%2!=0){
      sum = 0;
      break;
    }else{
      while(a%2!=1){
        a/=2;
        b++;
      }
      if(i==0){
        sum=b;
      }else if(sum>b){
        sum=b;
      }
    }
  }
    
    cout << sum << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<numeric>

using namespace std;
typedef long long ll;
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;}


struct edge {
    int to,from,cost;
    edge() {}
    edge(int f,int t,int c) : to(t),from(f),cost(c) {}
};

typedef pair<int,int> P;
vector<edge> G[100];
int d[100], par[100];
int V = 100;
const int INF = 1e9;

void dijkstra(int s) {
    priority_queue<P,vector<P>,greater<P>> que;
    fill(d,d+V,INF);
    for (int i = 0; i < V; i++) par[i] = i;
    d[s] = 0;
    que.push(P(0,s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;

                //追加
                par[e.to] = e.from;

                que.push(P(d[e.to],e.to));
            }
        }
    }
}

bool cand[100][100];

int main() {
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b, c; cin >> a >> b >> c;
        cand[a-1][b-1] = true;
        G[a-1].push_back(edge(a-1,b-1,c));
        G[b-1].push_back(edge(b-1,a-1,c));
    }
    for (int i = 0; i < N; i++) {
        dijkstra(i);
        for (int j = 0; j < N; j++) {
            int k = j;
            while (par[k] != k) {
                cand[par[k]][k] = cand[k][par[k]] = false;
                k = par[k];
            }
        }
    }
    int res = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            res += cand[i][j];
            //cout << cand[i][j] <<  " ";
        } //cout << endl;
    }
    cout << res << endl;
    
}


Measured memory_bytes: 256
import fractions
from functools import reduce
m = 0
sum = 0

n = int(input())
List = list(map(int, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(List)

for i in List:
  sum += m // i
print(sum % (10**9 + 7))


Measured memory_bytes: 6136
#include <iostream>

using namespace std;

int p[10010];
int n,q;
int c,x,y;

int root(int x)
{
    if(p[x]==x)
    {
        return x;
    }
    else
    {
        p[x]=root(p[x]);
        return p[x];
    }
}

void unite(int x,int y)
{
    p[root(x)]=root(y);
}

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

int main()
{
    cin >> n >> q;
    for(int i=0;i<n;i++)
    {
        p[i]=i;
    }
    for(int i=0;i<q;i++)
    {
        cin >> c >> x >> y;
        if(c)
        {
            cout << same(x,y) << endl;
        }
        else
        {
            unite(x,y);
        }
    }
    return 0;
}


Measured memory_bytes: 3220
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const ll MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;



int main(void){

    ll n;
    cin>>n;
    vll v(n);
    rep(i,n)cin>>v[i];

    vs a(n);

    rep(i,n){
        string s="";
        while(v[i]>0) {
            s+='0'+v[i]%2;
            v[i]/=2;
        }
        while(s.size()<=61){
            s+='0';
        }
        // reverse(all(s));
        a[i]=s;
    }

    ll ans=0;

    // rep(i,n){
    //     cout<<a[i]<<endl;
    // }

    rep(i,a[0].size()){
        ll zero=0,iti=0;
        rep(j,n){
            if(a[j][i]=='0')zero++;
            else iti++;
        }
        ans+=((zero*iti%MOD)*((ll)pow(2,i)%MOD))%MOD;
        ans%=MOD;
    }
    fin(ans);




}

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

const int maxN = 2e3 + 13, INF = 1e9 + 13;
int n, k, ans = INF, curans, lvl[maxN], curlvl[maxN], arr[maxN];
vector<int> adj[maxN];
bool cnt[maxN];
bool cmp (int i, int j) {
    if (lvl[i] != lvl[j])
	return lvl[i] > lvl[j];
    return i > j;
}

void dfs (int x, int p) {
    for (auto a : adj[x]) {
	if (a != p) {
	    lvl[a] = lvl[x] + 1;
	    dfs(a, x);
	}
    }
}	    

void solve (int x, int p) {
    for (auto a : adj[x]) {
	if (a != p && !cnt[a]) {
	    curlvl[a] = curlvl[x] + 1;
	    if (curlvl[a] > k)
		curans++;
	    solve(a, x);
	    //cout << a << " " << curlvl[a] << endl;
	}
    }
}

    
int main () {
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
	int a, b;
	cin >> a >> b;
	adj[a].push_back(b);
	adj[b].push_back(a);
    }

    dfs(1, 1);
    iota(arr, arr + n, 1);
    sort(arr, arr + n, cmp);
    for (int i = 0; i < n; i++) {
	int a = arr[i];
	curans = 0;
	memset(curlvl, 0, sizeof curlvl);
	//cout << a << endl;
	solve(a, a);
	cnt[a] = 1;
	ans = min(ans, curans + i);
	/*cout << curans << " " << i << endl;
	  cout << "////////" << endl;*/
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll m,n;
    cin>>m>>n;
    if(n*2 < m)
    {
        cout<<m-(n*2)<<endl;
    }
    else
    {
        cout<<"0\n";
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int dp[1000000];

int main() {

    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    RREP(i, 0, n) {
        int p = a[i];
        dp[p] = dp[p-1] + 1;
        ans = max(ans, dp[p]);
    }

    cout << n - ans << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a;
    cin>>a;
    
    if(a==0){
    cout<<"0"<<endl;
    }
    if(a==1||a==10||a==100){
    cout<<"1"<<endl;
    }
    if(a==11||a==101||a==110){
    cout<<"2"<<endl;
    }
    if(a==111){
    cout<<"3"<<endl;
}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
typedef long long int ll;



int main(int argc, char const *argv[])
{
	ll n;
	cin >> n;
	vector<ll> v(n), a(n, 0), b(n, 0);
	ll sum1 = 0, sum2 = 0;
	for (ll i = 0; i < n; i++)
	{
		cin >> v[i];
		sum1 += v[i];
	}

	ll min = 1000000000;

	for (ll i = 0; i < n; i++)
	{
		sum1 -= v[i];
		sum2 += v[i];
		if (abs(sum1 - sum2) < min)
			min = abs(sum1 - sum2);
	}

	cout << min << endl;
}


Measured memory_bytes: 256
# include <iostream>

using namespace std;

int main() {
    string s; cin >> s;
    int ans = 1001001001;

    for (int i=0; i<s.length()-2; i++) {
        ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    }

    cout << ans << endl;
    return 0;
}



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

const int MOD = 1000000007;

int main() {
    int a;
    cin >> a;
    if (a == 1) {
        cout<<0<<endl;
    }
    else {
        cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    ll a,b,x;
    cin>>a>>b>>x;
    ll a1=a;
    if(a) a--;
    cout<<(b/x)-(a/x)+(a1==0);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
//#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

int main(void)
{
    int a, b;
    cin >> a >> b;

    irep2(i, 1, 1000) {
        int A = floor(i * 0.08);
        int B = floor(i * 0.1);
        if(A == a && B == b) { 
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}
/** atcoder **/


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

typedef long long ll;

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

    int n;cin>>n;
    ll a,b;cin>>a>>b;
    if((n==1 && a!=b) || a>b){
        cout<<0<<endl;
        return 0;
    }
    ll mi=a*(n-1)+b,ma=a+b*(n-1);
    cout<<ma-mi+1<<endl;
}


Measured memory_bytes: 892
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int r, t;
        cin >> r >> t;
        if (r % 100 == 0) {
            if (t % 30 == 0)cout << t / 30 * 5 + r / 100 << endl;
            else {
                for (int i = 1; i <= 6; i++) {
                    if (t < 30 * i) {
                        cout << 5 * i + r / 100 - 5 << " " << 5 * i + r / 100 << endl;
                        break;
                    }
                }
            }
        } else {
            if (t % 30 == 0) {
                for (int i = 1; i <= 5; i++) {
                    if (r - 100 < 100 * i) {
                        cout << t / 30 * 5 + i << " " << t / 30 * 5 + i + 1 << endl;
                        break;
                    }
                }
            } else {
                cout << t / 30 * 5 + r / 100 << " " << t / 30 * 5 + r / 100 + 1 << " "
                     << t / 30 * 5 + r / 100 + 5 << " " << t / 30 * 5 + r / 100 + 6 << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		String op = sc.next();
		long B = sc.nextLong();
		System.out.println(op.equals("+")?A+B:A-B);
		sc.close();
	}

}


Measured memory_bytes: 9804
from itertools import accumulate
from bisect import bisect_right

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = [0] + list(map(int, input().split()))

acc_a = list(accumulate(a))
acc_b = list(accumulate(b))

ans = 0
for i, e in enumerate(acc_b):
    if e > k:
        break
    a_cnt = bisect_right(acc_a, k - e)
    ans = max(ans, i + a_cnt)

print(ans)


Measured memory_bytes: 128420
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){

  int n, a[4]={0}, ans=0;
  char s;

  cin >> n;

  for(int i=0; i<n; i++){
    cin >> s;
    if(s=='P'){
      a[0]++;
    } else if(s=='W'){
      a[1]++;
    } else if(s=='G'){
      a[2]++;
    } else {
      a[3]++;
    }
  }

  for(int i=0; i<4; i++){
    if(a[i]>0){
      ans++;
    }
  }

  if(ans==3){
    cout << "Three" << endl;
  } else {
    cout << "Four" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;

typedef long long ll;

ll A[100002];
ll B[100002];

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

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

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    A[i] -= B[i];
    if (A[i] < 0) {
      ll over = -A[i];
      A[i + 1] -= over;
      if (A[i + 1] < 0) {
        ans += B[i] + A[i + 1];
        A[i + 1] = 0;
      } else {
        ans += B[i];
      }
    } else {
      ans += B[i];
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 1920
use proconio::input;

fn main() {
    input! {
        n:usize,
        mut a:[usize; n],
        mut b:[usize; n],
        mut c:[usize; n],
    }

    a.sort();
    b.sort();
    c.sort();

    // 各bについて考えればいいことがわかる
    let mut res = 0;
    for cmp in b {
        let sma;
        let big;

        let mut lo = -1i32;
        let mut hi = n as i32;
        while hi - lo > 1 {
            let mid = ((hi + lo) / 2) as usize;
            if a[mid as usize] >= cmp {
                hi = mid as i32;
            } else {
                lo = mid as i32;
            }
        }
        sma = hi as usize;

        lo = -1;
        hi = n as i32;
        while hi - lo > 1 {
            let mid = ((hi + lo) / 2) as usize;
            if c[mid] > cmp {
                hi = mid as i32;
            } else {
                lo = mid as i32;
            }
        }
        big = n - hi as usize;
        res += sma * big;
    }
    println!("{}", res);
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    ll ans = 0;
    if (x <= y) {
        ans += min(a + b, c * 2) * x;
        y -= x;
        ans += min(b, c * 2) * y;
    } else {
        ans += min(a + b, c * 2) * y;
        x -= y;
        ans += min(a, c * 2) * x;        
    }
    cout << ans << endl;
    return 0;
}

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

int n;
int has_put;
int a[10];

int main() {
    scanf("%d", &n);
    for (int T=0; T<n; T++) {
        for (int i=0; i<10; i++) {
            scanf("%d", &a[i]);
        }

        has_put = 0;
        for (int bit=0; bit<1024; bit++) {
            int pre1 = -1;
            int pre2 = -1;
            int possible = 1;

            for (int i=0; i<10; i++) {
                if ((bit>>i)&1) {
                    if (a[i] < pre1) {
                        possible = 0;
                        break;
                    }
                    pre1 = a[i];
                } else {
                    if (a[i] < pre2) {
                        possible = 0;
                        break;
                    }
                    pre2 = a[i];
                }
            }

            if (possible) {
                puts("YES");
                has_put = 1;
                break;
            }
        }

        if (!has_put) {
            puts("NO");
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  vector<pair<llong, llong>> tasks;
  rep(i, n) {
    llong a, b;
    cin >> a >> b;
    tasks.push_back(make_pair(b, a));
  }
  sort(tasks.begin(), tasks.end());
  llong time = 0;
  rep(i, n) {
    if (time + tasks[i].second > tasks[i].first) {
      cout << "No" << endl;
      return 0;
    }
    time += tasks[i].second;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 6384
n = int(input())
nums = list(map(int,input().split()))
cnt = 0
for num in nums:
  if num < 0:
    cnt += 1
    
abnums = [abs(i) for i in nums]
if cnt % 2 == 0:
  ans = sum(abnums)
else:
  ans = sum(abnums) - min(abnums)*2
print(ans)

Measured memory_bytes: 14332
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	int a[]=new int[10];
	for(int i=0;i<10;i++)
	    {
		a[i]=scan.nextInt();
	    }
	for(int j=1;j<10;j++)
	    {
		int k=j;
		{
		    while(k>=1 && a[k]>a[k-1])
			{
			    int temp=a[k-1];
			    a[k-1]=a[k];
			    a[k]=temp;
			    k--;
			}
		}
	    }
	for(int i=0;i<3;i++)
	    {
		System.out.println(a[i]);
	    }
    }
}

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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size() - 1; i++){
        if (s[i] == s[i + 1]){
            s.erase(s.begin() + i + 1);
            i--;
        }
    }
    printf("%d\n", s.size());
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = scanner.nextInt();
			}
			System.out.println(31);
			int o = 31;
			loop: while (true) {
				for (int t : num) {
					o = Math.max(o - t, 0);
					System.out.println(o);
					if (o == 0)
						break loop;
					o -= 5 - t;
					System.out.println(o);
				}
			}
		}
	}
}

Measured memory_bytes: 20828
#include<stdio.h>
int main(void)
{
	int a,b,c,max;

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


	if(a>b){
		max=a;
		a=b;
		b=max;
	}
	if(b>c){
		max=b;
		b=c;
		c=max;
	}

	if(a>b){
		max=a;
		a=b;
		b=max;
	}

	printf("%d %d %d\n",a,b,c);

	return 0;
}


Measured memory_bytes: 2044
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
struct name
{
	int x;
	long long y;
}a[200005];

int cmp2(name q,name p)
{
	return q.y>p.y;
}

int main()
{
	long long  n,m;
	cin>>n>>m;
	
	long long max=-1;
	long long ans=0;
	long long sum=0;
	for(int i=0;i<n;i++)
	{	
		long long z,w;
		cin>>z>>w;
		a[ans].x=0;
		a[ans].y=z;
		ans++;
		a[ans].x=1;
		a[ans].y=w;
		ans++;
	}
	sort(a,a+200005,cmp2);
	long long qq=0;
	for(int i=0;i<2*n;i++)
	{
		if(a[i].x==1)
		{
			sum=sum+a[i].y;
			qq++;
			if(sum>=m)
			{
				cout<<qq<<endl;
				return 0;
			}
		}
		else
		{
			while(sum<m)
			{
				sum=sum+a[i].y;
				qq++;	
			}
			cout<<qq<<endl;
			return 0;
			
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 3328
n = int(input())
arr = list(map(float, input().split()))
dp = [0] * (n + 1)
# Base Case
dp[0] = 1

# 0/1 knapsack sarika, pick karna hai ya na karna hai vaisa hi, head aayega ya nahi, aayega to uski prob, + nahi aayega to uski prob, dono ka combi wrt to the last combination we already dealt with.

for i, j in enumerate(arr):
    for k in range(i + 1, -1, -1):
        # if k == 0, i.e. no heads, so head ki prob nahi dalni isme, otherwise combination aayega head aur tails ki prob ka
        if k:
            dp[k] = (dp[k - 1] * j) + (dp[k] * (1-j))
        else:
            dp[k] = dp[k] * (1-j)

mid = n // 2 + 1
ans = 0
for i in range(mid, len(arr) + 1):
    ans += dp[i]
print("{:.10f}".format(ans))


Measured memory_bytes: 41452
#include<stdio.h>
int main()
{
    int a,b,c,i,count=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++)
    {
        if(c%i==0)
        {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 2088
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define N 100000
#define INF 1000000000
using namespace std;

typedef long long ll;

int main()
{
    int n, m = 0, ctr = 0;
    int h[101] = {};
    cin >> n;
    FOR(i, 0, n)
    {
        cin >> h[i];
        m = max(m, h[i]);
    }
    bool flag;
    FOR(i, 0, m)
    {
        flag = false;
        FOR(j, 0, n+1)
        {
            if (h[j] > i)
                flag = true;
            if (flag && h[j]<=i)
            {
                ctr++;
                flag = false;
            }
        }
    }
    cout << ctr << "\n";
    return 0;
}

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

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

	ll N;
	cin >> N;
	ll res = 1;
	vector<ll> A(N);
	REP(i, N) {
		cin >> A[i];
		if (A[i] == 0) {
			res = 0;
		}
	}
	if (res) {
		REP(i, N) {
			if (res >= INT64_MAX / A[i]) {
				res = -1;
				break;
			}
			res *= A[i];
			if (res > (ll)1000000000000000000) {
				res = -1;
				break;
			}
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3976
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
if y>0:
    p,r='U','D'
else:
    p,r='D','U'
if x>0:
    q,s='R','L'
else:
    q,s='L','R'
l=[p]*y+[q]*x+[r]*y+[s]*x+[s]+[p]*(y+1)+[q]*(x+1)+[r]+[q]+[r]*(y+1)+[s]*(x+1)+[p]
print(''.join(l))

Measured memory_bytes: 9304
/*Bismillahir Rahmanir Rahim
->>Code by aimon
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define f(a,b,x) for(int a=b;a<x;a++)
#define pb push_back
#define endl "\n"
#define MX 200000
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define vi vector<int>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int x,y;
    cin>>x>>y;
    if(y>=2*x&&y<=4*x&&y%2==0)
        yes;
    else
        no;

    return 0;
}

Measured memory_bytes: 3652
N=int(input())
S=input()
ans=0

for i in range(10):
  x=S.find(str(i),0)
  if x!=-1:
    for j in range(10):
      y=S.find(str(j),x+1)
      if y!=-1:
        for k in range(10):
          z=S.find(str(k),y+1)
          if z!=-1:
            ans+=1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
using namespace std;
int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int x,n=3982;
    cin >> x;
    int a[n];
    for(int i=0;i<n;i++)
    	a[i]=i*i*i*i*i;
    for(int i=0;i<n;i++){
    	for(int j=0;j<=i;j++){
    		if(a[i]+a[j]==x){
    			cout << i << " "<< -j ;
    			return 0;
    		}
    		if(a[i]-a[j]==x){
    			cout << i << " " << j ;
    			return 0;
    		}
    	}
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload4(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload4(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    string s,t;
    char src,dst;
    cin>>s>>t;
    set<pair<char,char>> a;
    REPARR(i,s){
        a.insert({s[i],t[i]});
    }
    string u,v;
    for(pair<char,char> b:a){
        u+=b.first;
        v+=b.second;
    }
    REPARR(i,u){
        if(u[i]!=v[i]){
            src=u[i];dst=v[i];
            //cerr<<src<<"<>"<<dst<<endl;
            REPARR(j,u){
                if(u[j]==src){
                    u[j]=dst;
                }else if(u[j]==dst){
                    u[j]=src;
                }
            }
            //cerr<<s<<endl<<t<<endl<<endl;
        }
    }
    //cout<<s<<endl;
    //cout<<t<<endl;
    Yes(u==v);
    return 0;
}

Measured memory_bytes: 776
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int H, W; cin >> H >> W;
  int a[85][85];
  rep(i, H){
    rep(j, W){
      cin >> a[i][j];
    }
  }
  rep(i, H){
    rep(j, W){
      int b; cin >> b; a[i][j] -= b;
    }
  }
  bool dp[85][85][26000] = {};
  dp[0][0][a[0][0]+13000] = true;
  rep(i, H){
    rep(j, W){
      rep(k, 26000){
        if(i>=1 && k-a[i][j]>=0) dp[i][j][k] |= dp[i-1][j][k-a[i][j]];
        if(i>=1 && k+a[i][j]>=0) dp[i][j][k] |= dp[i-1][j][k+a[i][j]];
        if(j>=1 && k-a[i][j]>=0) dp[i][j][k] |= dp[i][j-1][k-a[i][j]];
        if(j>=1 && k+a[i][j]>=0) dp[i][j][k] |= dp[i][j-1][k+a[i][j]];
      }
    }
  }
  rep(i, 13000){
    if(dp[H-1][W-1][13000+i] || dp[H-1][W-1][13000-i]){
      cout << i << endl; break;
    }
  }
  
 }

Measured memory_bytes: 183680
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int w = scan.nextInt();
		String ans = "";
		
		while(w != 0) {
			int tmp = w % 3;
			
			if(tmp == 0) {
				ans = "0" + ans;
				w /= 3;
				
			} else if(tmp == 1) {
				ans = "+" + ans;
				w /= 3;
				
			} else if(tmp == 2) {
				ans = "-" + ans;
				w /= 3;
				w++;
			}
		}
		
		System.out.println(ans);
		
		scan.close();
	}
}

Measured memory_bytes: 26160
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
int dy[] = {0, 1, 0, -1};
int dx[] = {1, 0, -1, 0};

int main() {
    int n, a[100001], b[100001], ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> a[i];
    }
    llong needed_point = 0;
    llong extra_point = 0;
    priority_queue<int> E;
    rep(i, n) {
        cin >> b[i];
        if (b[i] > a[i]) {
            needed_point += b[i] - a[i];
            ++ans;
        } else if (b[i] < a[i]) {
            extra_point += a[i] - b[i];
            E.push(a[i] - b[i]);
        }
    }
    if (needed_point == 0) {
        cout << 0 << endl;
        return 0;
    }
    if (needed_point > extra_point) {
        cout << "-1" << endl;
        return 0;
    } else {
        while (!E.empty()) {
            ++ans;
            if (needed_point - E.top() <= 0) break;
            needed_point -= E.top();
            E.pop();
            }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1404
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<iomanip> 
#include<cmath>
using namespace std;
int main()
{
	int n, m;
	int csum = 0;
	string s[110], t[110];
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> s[i];
	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> t[i];
	for (int i = 1; i <= n; i++)
	{
		int sum = 0;
		for (int j = 1; j <= n; j++)
			if (s[i] == s[j])
				sum++;
		for (int k = 1; k <= m; k++)
			if (s[i] == t[k])
				sum--;
		csum = max(csum, sum);
	}
	for (int i = 1; i <= m; i++)
	{
		int sum = 0;
		for (int j = 1; j <= n; j++)
			if (t[i] == s[j])
				sum++;
		for (int k = 1; k <= m; k++)
			if (t[i] == t[k])
				sum--;
		csum = max(csum, sum);
	}
	cout << csum << endl;
	return 0;
}

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

using namespace std;

int solve(vector<array<int, 3>> &v_abc, vector<vector<int>> &memo, int pre = -1,
          int cur = 0) {
  int n = v_abc.size();
  if (cur == n) {
    return 0;
  }

  if (memo[cur][pre + 1] == -1) {
    int ans = 0;
    for (int i = 0; i < 3; ++i) {
      if (i != pre) {
        ans = max(ans, solve(v_abc, memo, i, cur + 1) + v_abc[cur][i]);
      }
    }

    memo[cur][pre + 1] = ans;
  }

  return memo[cur][pre + 1];
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<array<int, 3>> v_abc(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> v_abc[i][j];
    }
  }

  vector<vector<int>> memo(n, vector<int>(4, -1));

  cout << solve(v_abc, memo) << '\n';
  return 0;
}

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

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


int x[100005];
int main(void){
    int n,y;cin>>n>>y>>x[0]>>x[1];
    if(n==1){
        cout<<abs(x[0]-y)<<endl;
        return 0;
    }
    int ans=gcd(abs(x[0]-y),abs(x[1]-y));
    for(int i=2;i<n;i++){
        cin>>x[i];
        ans=gcd(ans,abs(x[i]-y));
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    unsigned long long N;
    cin >> N;

    unsigned long long a, b;

    for(a = sqrt(N); a >= 1; a--){
        
        b = N / a;
        if(a * b == N){
            cout << a + b - 2 << endl;
            return 0;
        }
    }

    cout << N + 1 - 2 << endl;

    return 0;
}



Measured memory_bytes: 888
N = int(input())

h_upper = int(0.75*N)
for h in range(h_upper, 0, -1):
    tmp = int(2/(4/N-1/h))
    for n in range(tmp,0,-1):
        if 4*h*n-N*(h+n)>0 and (N*h*n)%(4*h*n-N*(h+n)) == 0 :
            print(h,n,(N*h*n)//(4*h*n-N*(h+n)))
            break
    else:
        continue
    break
   

Measured memory_bytes: 3064
main(){
	int n,z[2002],*a=z,*b=z+1001,m,i,j,k,*t;
	for(;scanf("%d",&n),n;printf("%d\n",m)){
		for(memset(a,*b=m=i=0,4004);i<n;i++){
			scanf(" ");
			for(j=1;j<=n;j++)
				m=fmax(m,b[j]=getchar()-'*'?1+fmin(fmin(b[j-1],a[j-1]),a[j]):0);
			t=a;a=b;b=t;
		}
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	char c[100001];
	int sizes=0,f=0,ans=0;
	cin>>c;
	for(int i=0;c[i]!='\0';i++)sizes++;
	for(int i=0,i2=sizes-1;i<i2;i++)
	{
		if(c[i]==c[i2])
			i2--;
		else if(c[i]=='x')
			ans++;
		else if(c[i2]=='x')
			i2--,i--,ans++;
		else
		{
			f=1;
			break;
		}
	}
	if(f)cout << "-1\n";
	else cout << ans<<"\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <boost/array.hpp>
//#include <boost/range/numeric.hpp>
//#include <boost/range/algorithm.hpp>
//#include <boost/multiprecision/cpp_int.hpp>

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;
//using namespace boost::multiprecision;

const long long INF = LLONG_MAX;
const long long MOD = 1000000007;
const long double PI = M_PI;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << fixed << setprecision(12)
#define dbglf cerr << '\n'

#define ACCM(arr) accumulate(ALL(arr),0LL)
#define Yes(ex) cout << ((ex) ? "Yes" : "No") << endl
#define YES(ex) cout << ((ex) ? "YES" : "NO") << endl

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void veccin(vector<T>& v) {
    for (auto && e : v) { cin >> e; }
}

template < typename T >
inline void dbg(T a) { cerr << a << ' '; }

ll n, m, k;
ll ans = 0, sum = 0, cnt = 0;
//long double d;
string s/*1, s2, s3*/;
char c/*1, c2, c3*/;
bool flag = false;

/*--------------------template--------------------*/

int main() {
    cin >>n>>m>>k;
  	vi graph[n];
	vi answer(n-1,0);
	//answer[0] = n;
	ll dis = k-m-1;
	REP(i,n) {
    	//graph[i].push_back(i+1);
    	FOR(j,i+1,n){
        	if(i<=m-1&&k-1<=j) {
            	answer[j-i-dis-1]++;
            }else if(i<=m-1&&m-1<=j&&j<=k-1){
            	if(j-i>(k-1)-j+1+(m-1)-i)
                	answer[(k-1)-j+1+(m-1)-i-1]++;
                else
                	answer[j-i-1]++;
            }else if(m-1<=i&&i<=k-1&&k-1<=j){
            	if(j-i>i-(m-1)+1+(j-(k-1)))
                	answer[i-(m-1)+1+(j-(k-1))-1]++;
                else
                	answer[j-i-1]++;
            }else if(m-1<=i&&i<=k-1&&j<=k-1){
            	if(j-i>i-(m-1)+1+(k-1)-j)
                	answer[i-(m-1)+1+(k-1)-j-1]++;
                else
                	answer[j-i-1]++;
            }else{
            	answer[j-i-1]++;
            }
        }
    }
	//graph[m-1].push_back(k-1);
	//graph[k-1].push_back(m-1);
    for(auto&&e:answer)cout << e << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<list>
using namespace std;
int main(void)
{
	int m,n;
	int t = 1;
	list<int>List;
	scanf("%d", &n);
	for (int i = 0; i<n;i++)
	{
		scanf("%d", &m);
		t = !t;
		if(t)
			List.push_back(m);
		else
			List.push_front(m);
	}
	if (n%2==0) 
		List.reverse();
	for(auto i = List.begin(); i!= List.end();i++)
		printf("%d ",*i);
	return 0;
}

Measured memory_bytes: 8448
let readInt () = stdin.ReadLine() |> int
let choice ok ng bool = if bool then ok else ng

()
|> readInt
|> fun x -> [ 1 .. x ] |> List.map (fun _ -> stdin.ReadLine())
|> fun list ->
    let isUniq =
        list
        |> List.groupBy id
        |> List.length
        |> (=)
        <| (list |> List.length)

    let isShiritori =
        list
        |> List.rev
        |> List.tail
        |> List.rev
        |> List.zip
        <| (list |> List.tail)
        |> List.filter (fun (x, y) -> x.[x.Length - 1] = y.[0])
        |> List.length
        |> (=)
        <| (list |> List.length |> (-) <| 1)

    isUniq && isShiritori
|> choice "Yes" "No"
|> printfn "%s"


Measured memory_bytes: 30020
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<fstream>
#include<math.h>
using namespace std;

int main(){
	std::istream & c_in = cin;
	int n;
	c_in >> n;
	cout << n << ":";

	int primes=0;
	int i = 2;
	while (n != 1)
	{
		if ((n % i) == 0) {
			n /= i;
			cout << " " << i;
			continue;
		}
		i += 1 + (i & 1);
		if (i > ::sqrt(n))
		{
			cout << " " << n;
			break;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1168
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string x;
	cin >> x;
	
	int n = (int)x.size();
	stack<char> st;
	
	for(int i = 0; i < n; ++i) {
		if( st.empty() ) st.push(x[i]);
		
		else {
			if( x[i] == 'S' ) st.push(x[i]); 
			if( x[i] == 'T' ) {
				if( st.top() == 'S' ) st.pop();
				else st.push(x[i]);
			}
		}
	}
	
	cout << (int)st.size() << endl;
	
	return 0;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
        if(a<b){
        cout<<"a < b"<<endl;
        }   
   else if(a>b){
        cout<<"a > b"<<endl;
   }
   else if(a==b){
       cout<<"a == b"<<endl;
   }        
   return 0;
}


Measured memory_bytes: 3120