akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, a, b, c, d;
  cin >> N;

  a = N/1000;
  b = N/100 - a*10;
  c = N/10 - a*100 - b*10;
  d = N - a*1000 - b*100 - c*10;
  if ((a==b && b==c) || (b==c && c==d)) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(){

  int a,b;

  char op;

  for( ; ; ){

    cin >> a >> op  >> b;

    if( op == '+'){
      cout << a+b << endl;
    } else if ( op == '-'){
      cout << a-b << endl;
    } else if ( op == '*'){
      cout << a*b << endl;
    } else if ( op == '/'){
      cout << a/b << endl;
    } else {
      break;    
    }
 
  }

  return 0;
}

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

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

	int n,A,B;
	cin>>n>>A>>B;
	int c=0;
	rep(i,n){
		int a,b;cin>>a>>b;
		if(a>=A&&b>=B)c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  [n, m, a] <- f
  unless (n == 0 && m == 0 && a == 0) $ do
    solve n a <$> sortBy (flip compare) <$> replicateM m f >>= print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> Int -> [[Int]] -> Int
solve n a xs = foldl' f a xs
  where
    f a [_, p, q]
      | a == p = q
      | a == q = p
      | otherwise = a



Measured memory_bytes: 6504
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

w, h, x, y = LI()
if x == w/2 and y == h/2:
    print(w*h/2, 1)
else:
    print(w*h/2, 0)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int count = 1;
    int mini = a[0];
    for (int i = 1; i < n; i++)
    {
        if (a[i] <= mini)
        {
            count++;
            mini = min(mini, a[i]);
        }
    }
    cout << count << endl;

}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 1792
n,q=map(int,input().split())
s=input()
a=[0]*n
k=0
for i in range(n-1):
  if(s[i]=='A' and s[i+1]=='C'):
    k+=1
  a[i]=k
for j in range(q):
  l,r=map(int,input().split())
  if(l==1):
    print(a[r-2])
  else:
    print(a[r-2]-a[l-2])

Measured memory_bytes: 6084
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
typedef long long LL;

LL n, a[20];
unordered_map<LL,LL> dp; 

LL dfs(int l,int r,int xl,int xr){
	if(l+1==r) return 0ll;
	LL k = ((LL)xl<<30)+((LL)xr<<10)+(l<<5)+r;
	if(dp[k]) return dp[k];
	dp[k] = 1ll<<55;
	rep(i,l+1,r-1) dp[k] = min(dp[k], dfs(l,i,xl,xl+xr) + dfs(i,r,xl+xr,xr) + a[i]*(xl+xr) );
	return dp[k];
}

int main(){
	cin>>n;
	rep(i,1,n)cin>>a[i];
	cout<<dfs(1,n,1,1)+a[1]+a[n]<<endl;
	return 0;
}

Measured memory_bytes: 14408
#include<stdio.h>

int main(){

	int a[200];
	int n;
	int i;
	int count=0;
	int f=0;
	int sousa=0;
	
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	
	while(f==0){
	
		for(i=0;i<n;i++){
			
			if(a[i]%2==0) count++;
			
		}
		f=1;
		if(count==n){
			f=0;
			count=0;
			sousa++;
			for(i=0;i<n;i++){
		
				a[i]/=2;
		
			}
	
		}
	}
	
	printf("%d",sousa);




}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main()
{
  int me, fe, re;
  while(true)
  {
    cin>>me>>fe>>re;
    if(me==-1&&fe==-1&&re==-1) return 0;
    if(me==-1||fe==-1) cout << "F\n";
    else if((me+fe) >= 80) cout << "A\n";
    else if ((me+fe)>=65) cout << "B\n";
    else if ((me+fe)>=50 || (me+fe) >= 30 && (me+fe) < 50 && re >= 50) cout << "C\n";
    else if ((me+fe)>=30) cout << "D\n";
    else cout << "F\n";
  }
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
	int A,B,C,D,E;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;
	cin >> E;

	int ct=10*(A/10)+10*(B/10)+10*(C/10)+10*(D/10)+10*(E/10);
	vector<int> S={A%10,B%10,C%10,D%10,E%10};
	sort(S.begin(),S.end());
	while(S.size()>0 && S[0]==0){
		S.erase(S.begin());
	}
	if(S.size()>0){
		ct+=S[0];
		S.erase(S.begin());
		if(S.size()>0){
			for(const auto& s : S){
				if(s!=0){
					ct+=10;
				}
			}
		}
	}

	cout << ct << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    int N; cin >> N;
    vector<ll> x(N),y(N);
    rep(i,N) cin >> x[i] >> y[i];

    set<pair<ll,ll>> st;
    rep(i,N) st.insert(make_pair(x[i],y[i]));

    if(N==1){
        cout << 1 << endl;
        return 0;
    }

    int ans = 1000;
    rep(i,N){
        rep(j,N){
            if(i==j) continue;
            ll p = x[j]-x[i];
            ll q = y[j]-y[i];

            int cost = 0;
            rep(k,N){
                if(!st.count(make_pair(x[k]-p,y[k]-q))){
                    cost++;
                }
            }
            ans = min(ans,cost);
        }
    }
    cout << ans << endl;
}


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

int main(){
  vector<int> a(3);
  rep(i,3) cin >> a[i];
  sort(a.begin(),a.end());
  
  if(a[2] == a[1] + a[0]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*#define _USE_MATH_DEFINES
#include<cmath>*/
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	rep(i, n) {
		if (s.substr(i, 3) == "ABC")++ans;
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std;
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; }

int N;

double dp[310][310][310];
double rec(int i, int j, int k) {
    if (dp[i][j][k] >= 0) return dp[i][j][k];
    if (i == 0 && j == 0 && k == 0) return 0.0;

    double res = 0.0;
    if (i > 0) res += rec(  i-1, j, k) * i;
    if (j > 0) res += rec(i+1, j-1, k) * j;
    if (k > 0) res += rec(i, j+1, k-1) * k;
    res += N;
    res *= 1.0 / (i + j + k);

    return dp[i][j][k] = res;
}

#include <iomanip>
int main() {
    cin >> N;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        if (a == 1) ++one;
        else if (a == 2) ++two;
        else ++three;
    }
    memset(dp, -1, sizeof(dp));
    cout << fixed << setprecision(10) << rec(one, two, three) << endl;
    return 0;
}

Measured memory_bytes: 232960
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	string S;
	cin>>S;
	int l=(int)S.length();
	if(l==1){cout<<0;return 0;}
	else{
		int con=1;
		char x=S[0];
		rep1(i,l-1){
			if(x!=S[i]){
				x=S[i];
				con++;
			}
		}
		cout<<con-1;
	}
}

Measured memory_bytes: 512
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    F=[]
    for i in range(N):
        f=list(map(int,readline().split()))
        F.append(f)
    P=[]
    for i in range(N):
        p=list(map(int,readline().split()))
        P.append(p)
    
    max_res=-float("inf")
    for i in range(1<<10):
        if i==0:
            continue
        else:
            output=[]
            for j in range(10):
                if(i>>j)&1:
                    output.append(j)

            oc=[0]*10  #open or close
            for j in output:
                oc[j]=1
            
            res=0
            for j in range(N):
                c=0
                for k in range(10):
                    if oc[k]==1 and F[j][k]==1:
                        c+=1
                res+=P[j][c]
            max_res=max(res,max_res)

    print(max_res)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
using namespace std;
int main()
{	
	string s, t, u;
	int a,b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;
	if (u == s)
		a -= 1;
	else
		b -= 1;
	cout << a<<" "<< b;
}

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

using namespace std;

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.in","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}

const int N = 1e7 + 10, M = 55, OO = 0x3f3f3f3f;
const ll llOO = 1e18;


int main(){
    init();

    int h, n;   cin >> h >> n;
    int sum = 0;
    for(int i = 0;i < n;i++){
        int x;  cin >> x;
        sum += x;
    }

    cout << ((sum >= h) ? "Yes" : "No");

}

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

int main(){
    int a,b;
    cin >> a;
    cin >> b;
    char char_a = '0'+ a;
    char char_b = '0'+ b;
    // cout << char_a << endl;
    // cout << char_b << endl;
    string str_a(b,char_a);
    string str_b(a,char_b);
    if(a<=b){
        cout << str_a << endl;
    }
    else{
        cout << str_b << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void read(int &x)
{
	x=0;
	int p=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^'0');c=getchar();}
	x*=p;
}
char s[100100];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	scanf("%s",s+1);
	int len=strlen(s+1);
	int tot=len,tott=len;
	for(int i=1;i<=len;i++)if(s[i]=='0')tot=min(tot,max(len-i,i-1));
	else tott=min(tott,max(len-i,i-1));
	cout<<max(tot,tott)<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

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;
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int H, N;
	cin >> H >> N;

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

	vector<ll> dp(H + 1, LINF);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= H; j++) {
			if (dp[j] == LINF) {
				continue;
			}

			int cur = min(j + A[i], H);
			dp[cur] = min(dp[cur], dp[j] + B[i]);
		}
	}
	cout << dp[H] << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

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

    vector<vector<int>> p(n, vector<int>(d));
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < d; ++j)
            cin >> p[i][j];

    int num_pair = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int dis = 0;
            for (int k = 0; k < d; ++k)
                dis += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);

            for (int k = 0; k * k <= dis; ++k) {
                if (k * k == dis) {
                    ++num_pair;
                    break;
                }
            }
        }
    }

    cout << num_pair << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
N,X = map(int,input().split())
array_m = []
for I in range(N):
    array_m.append(int(input()))

if not (2 <= N <= 100):
    sys.exit()


base = 0
for J in range(N):
    if not ( 1<= array_m[J] <= 1000):
        sys.exit()
    base += array_m[J]

if not(1 <= base <= 10 ** 5):
    sys.exit()

print(int(N + (X - base) / min(array_m)))

Measured memory_bytes: 9112
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int k=sc.nextInt();
    String s=sc.next();
    int n=s.length();
    if(n<=k)
      System.out.println(s);
    else
    {
      System.out.println(s.substring(0,k)+"...");
    }
  }
}


Measured memory_bytes: 27056
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int x,y;
    scanf("%d %d\n",&x,&y);
    printf("%d\n",x+y/2);
    return 0;
}

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

struct UnionFind {
    int n, num;
    vector<int> sz, parent;
    UnionFind() {}
    UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), parent(n_, 0) { iota(parent.begin(), parent.end(), 0); }
    int find(int x) { return x==parent[x] ? x : parent[x]=find(parent[x]); }
    bool same(int x, int y) { return find(x) == find(y); }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        parent[y] = x;
        num--;
    }
    int size(int x) { return sz[find(x)]; }
    int count() const { return num; }
};

int main() {
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    for ( int i=0; i<m; i++ ) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a,b);
    }
    cout << uf.num - 1 << '\n';
    return 0;
}

Measured memory_bytes: 4020
#include<iostream>
	#include<stdlib.h>
	#include<math.h>
	#include<algorithm>
	#include<string.h>
	using namespace std;


	int main()

	{
		std::ios_base::sync_with_stdio(0);
		cin.tie(NULL);
		int n; cin >> n;
		for  (int i = 1; ;  i++){
			if (i * i == n) {
				cout << i * i << endl;
				break;
			}
			if (i * i > n) {
				i--;
				cout << i * i << endl;
				break;
			}


		}
		
		return 0;
	
}

Measured memory_bytes: 3688
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define S second
#define F first
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define end cout<<'\n';
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<ll>
#define pii pair<ll,ll>
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()
//X.order_of_key()
int main()
{
fast;
    ll n,W;
    cin>>n>>W;
    ll w[n],v[n];
    f(i,n)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[n+1][W+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else if(w[i-1]<=j)
            {
                dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][W];
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define M_PI 3.14159265358979323846
#define MOD 1000000007
#define int ll
#define sz(x) (int)x.size()
typedef unsigned long long ull; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll; typedef cc_hash_table<int, int, hash<int>> intHashTable; typedef tuple<int, int, int> tiii;
struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } };
inline int powMod(int a, int b) { int x = 1; while (b > 0) { if (b&1) x = (x*a) % MOD; a = (a*a) % MOD; b >>= 1; } return x; }
inline int multiply(int x, int y) { return ((x % MOD) * (y % MOD)) % MOD; }
inline int divide(int x, int y) { return ((x % MOD) * powMod(y % MOD, MOD-2)) % MOD; }
inline int ceil(int a, int b) { return (a+b-1)/b; }
int gcd (int a, int b) { while (b) { a %= b; swap(a, b); } return a; }
int lcm (int a, int b) { return a / gcd(a, b) * b; }
int inverseMod(int a, int m) { a = a % m; for (ll x = 1; x < m; x++) if ((a * x) % m == 1) return x; return -1; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
template<int D, typename T> struct vec : public vector<vec<D - 1, T>> { static_assert(D >= 1, "Vector dimension must be greater than zero!");  template<typename... Args> vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) { } }; template<typename T> struct vec<1, T> : public vector<T> { vec(int n = 0, T val = T()) : vector<T>(n, val) { }};

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x, a; cin >> x >> a;
    if (x < a) cout << "0\n";
    else cout << "10\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		 
		 String str=sc.next();
		 String str2=sc.next();
		 
		 
		boolean j=false;
		
		for(int i=0;i<str.length();i++){
			char ch=str.charAt(i);
			char ch2=str2.charAt(i);
			if(ch==ch2)j=true;
			else {j=false;break;}
		}
		
		if(j)System.out.println("Yes");
		else System.out.println("No");
				
	}
}


Measured memory_bytes: 35684
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(ReadLine());

        var ans = long.MaxValue;

        for (int i = 1; i <= Math.Sqrt(N) + 1; i++)
        {
            if(N % i == 0)
            {
                var j = N / i;

                var step = (i - 1) + (j - 1);
                ans = Math.Min(ans, step);
            }
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 27516
using System;
using System.Linq;

namespace ABC086_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var T = new int[N][];
            var canGo = true;

            for (int i = 0; i < N; i++)
            {
                T[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
                var t = T[i][0];
                var x = T[i][1];
                var y = T[i][2];

                if (!(canGo = x + y <= t && (x + y) % 2 == t % 2)) break;
            }
            Console.WriteLine(canGo ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 22336
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n],arr1[n];
for(int i=0; i<n; ++i)
cin>>arr[i]>>arr1[i];
for(int i=0; i<n-2; ++i)
{
bool fn(0);
for(int j=i; j<i+3; ++j)
{
if(arr[j]!=arr1[j])
fn=1;
}
if(fn==0)
{
cout<<"Yes";
return 0;
}
}
cout<<"No";
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n, m;
  
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++){
    cin >> s.at(i);
  }
  
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++){
    cin >> t.at(i);
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++){
  	int cnt = 0;
    for (int j = 0; j < n; j++)
      if (s.at(i) == s.at(j)) cnt++;
	for (int j = 0; j < m; j++)
      if (s.at(i) == t.at(j)) cnt--;
	ans = max(ans, cnt);
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int N, M;
vector<vector<int> > G;

int dfs(int v, int bit) {
  if ( bit == (1<<N)-1 ) return 1;
  int ret = 0;
  for ( int &u: G[v] ) {
    if ( (1<<u) & bit ) continue;
    ret += dfs(u, bit|(1<<u));
  }

  return ret;
}
 
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  cin >> N >> M;
  G.resize(N);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  cout << dfs(0, 1) << endl;

  return 0;
}


Measured memory_bytes: 3612
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

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

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

    if x==y:
      return

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

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

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

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

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

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

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

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

Measured memory_bytes: 9648
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 9999999999999999
#define MOD 1000000007

void func()
{
    ll n;
    cin>>n;
    ll a[n];
    loop(i,1,n+1)
    {
        cin>>a[i];
    }
    map<ll,ll> m;
    ll s=0;
    revloop(i,n,1)
    {
        s=s+m[i+a[i]];
        m[i-a[i]]++;
    }
    cout<<s<<"\n";

}

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

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif

    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 27912
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
	int n, d[100];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> d[i];
	}

	set<int> se;

	for(int i = 0;i < n;i++){
		se.insert(d[i]);
	}

	cout << se.size() << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

public class Solution
{
    public static void Main()
    {
        var N = int.Parse(Console.ReadLine());
        var d = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(v => v).ToArray();

        var low = d[N / 2 - 1];
        var high = d[N / 2];
        var K = high - low;
        if (K < 0)
        {
            K = 0;
        }

        Console.WriteLine(K);
    }
}

Measured memory_bytes: 22112
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>
#include <complex>
 
 
using namespace std;
 
 
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 << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
 
 
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
 
const int MOD =  1e9 + 7; 
 
 
 
ll power(ll a, ll b){
	if(b == 0) return 1;
	else {
		ll x = power(a,b/2);
		x = (x*x)%MOD;
		if(b&1) return (x*a)%MOD;
		else return x;
	}
}
 
 
ll& Mod(ll& a) {
    if (a >= MOD) {
        return Mod(a -= MOD);
    } else if (a < 0) {
        return Mod(a += MOD);
    } else {
        return a;
    }
}
 
ll gcd(ll a, ll b) { 
	// b < a
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 


int main() {
	fast_cin();	
	int n;
	cin >> n;
	
	while(n != 0){
		if(n%10==7) {
			cout << "Yes" << '\n';
			return 0;
		}
		n/=10;
	}
	cout << "No" << '\n';
	
	
}


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

int main() {
	int n, m;
	while (cin >> n, n) {
		cin >> m;
		string s;
		s.push_back('I');
		for (int i = 0;i < n;i++)s += "OI";

		int ans = 0;
		string ioi;
		cin >> ioi;
		for (int i = 0;i <= m - (n * 2 + 1);i++) {
			string sb = ioi.substr(i, (n * 2 + 1));
			if (sb == s)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3904
def resolve():
    a = int(input())
    b = int(input())
    c = int(input())
    x = int(input())
    ans = 0
    for ai in range(a + 1):
        for bi in range(b + 1):
            for ci in range(c + 1):
                mon = 500 * ai + 100 * bi + 50 * ci
                if mon == x:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 38896
def main():
    from collections import deque
    S = deque(input())
    Q = int(input())

    q_list = [input().split() for _ in range(Q)]

    flag = False
    for q in q_list:
        if len(q) == 1:
            t = q[0]
        else:
            t, f, c = q

        if t == '1':
            flag = not flag
        else:
            if (f == '1') ^ flag:
                S.appendleft(c)
            else:
                S.append(c)
    prS(S, flag)
    # prS(S, flag)


def prS(S, flag):
    if flag:
        S.reverse()
    print("".join(S))
    if flag:
        S.reverse()


if __name__ == '__main__':
    main()


Measured memory_bytes: 44780
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,ans=1,next;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
     ans=min(ans*2,ans+k);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
inline bool read(ll &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;
ll x=1,y=1;

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

void yf(ll &a,ll &b){
ll g=__gcd(a,b);
a/=g,b/=g;
}

int main(){
int n=read();
ll lastt=read(),lasta=read();
for (;--n;){
  ll t=read(),a=read();
  ll tmp=max(lastt/t,lasta/a);
  bool nico=tmp*t<lastt||tmp*a<lasta;
  t=nico?tmp*t+t:tmp*t;
  a=nico?tmp*a+a:tmp*a;
  lastt=t,lasta=a;
  }
write(lastt+lasta);
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main() {
    int n,cnt=0,Max=0,h;
    scanf("%d",&n);
    for(int i=0; i<n; ++i) {
        scanf("%d",&h);
        if(h>=Max) {
            cnt++;
            Max=h;
        }

    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    string sa, sb, sc;
    cin>>sa>>sb>>sc;
    int ia=1, ib=0, ic=0;
    char next=sa[0];
    //cout<<next<<endl;
    while(1){
        if(next=='a'){
            if(ia>=sa.length()){
                cout<<"A"<<endl;
                return 0;
            }
            next=sa[ia++];
        }
        else if(next=='b'){
            if(ib>=sb.length()){
                cout<<"B"<<endl;
                return 0;
            }
            next=sb[ib++];
        }
        else if(next=='c'){
            if(ic>=sc.length()){
                cout<<"C"<<endl;
                return 0;
            }
            next=sc[ic++];
        }
        //cout<<next<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
  int N;
  cin >> N;
  long long int a[N];
  rep(i,N) cin >> a[i];
  int count=0;
  rep(i,N){
  	while(a[i]%2==0){
      a[i]/=2;
      count++;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

LL dfs(int x,int y,vector<vector<LL>> &dp,vector<LL> &sif){
	if(x>y) return 0ll;
	if(dp[x][y]!=-1) return dp[x][y];
	dp[x][y] = max(sif[y+1]-sif[x]-dfs(x+1,y,dp,sif),sif[y+1]-sif[x]-dfs(x,y-1,dp,sif));
	return dp[x][y];
}
void solve(){
	int n;
	cin>>n;
	vector<int> nums(n);
	for(int i=0;i<n;i++) cin>>nums[i];
	vector<LL> sif(n+1,0);
	for(int i=0;i<n;i++){
		sif[i+1]=sif[i]+nums[i];
	}
	vector<vector<LL>> dp(n,vector<LL>(n,-1ll));
	// for(int i=0;i<n;i++){
	// 	dp[i][i] = nums[i];
	// }
	// // for(int len=2;len<=n;len++){
	// // 	for(int i=0;i<(n-len+1);i++){
	// // 		int j = i+len-1;
	// // 		dp[i][j] = max(sif[j+1]-sif[i]-dp[i+1][j],sif[j+1]-sif[i]-dp[i][j-1]);
	// // 	}
	// // }
	cout<<2ll * dfs(0,n-1,dp,sif)-sif[n]<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 71040
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: String,
        b: String,
    }
    println!("{}",
        if a != b { "D" } else { "H" });
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
  int a,i;
  int f=0,b=0;
  long sum=0;
  
  scanf("%d", &a);
  
  for(i=1;i<=a;i++) {
     f = i%3;
     b = i%5;
     if(f!=0&&b!=0) 
       sum=sum+i;   
  }

  printf("%ld",sum);
  
  return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	cin>>a>>b>>c;
  if(a==1)
    cout<<"Hello World"<<endl;
  else 
    cout<<b+c<<endl;
 /* else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
  
  return 0;
}


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

int main(int, char**) {
        int N;
        std::cin >> N;
        int d = 100;
        for (int i=0; i<3; i++) {
                if (N/d == 7) {
                        std::cout << "Yes" << std::endl;
                        return 0;
                } else {
                        N = N%d;
                        d = d/10;
                }
        }
        std::cout << "No" << std::endl;
        return 0;
}


Measured memory_bytes: 3616
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
ll x, y;
void solve() {
    while(cin >> x >> y) {
        ll res = 1e10;
        if(x == y) {
            res = 0;
        } else if(x == -y) res = 1;
        else {
            if(x < y) {
                res = min(res, y - x);
            }
            if(x < -y) {
                res = min(res, -y - x + 1);
            }
            if(-x < y) {
                res = min(res, y + x + 1);
            }
            if(-x < -y) {
                res = min(res, -y + x + 2);
            }
        }
        cout << res << endl;
    }
}
int main() {
   // freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int A = int.Parse(s[0]);
            int B = int.Parse(s[1]);

            int ans = Math.Max(A + B, Math.Max(A + A - 1, B + B - 1));
            Console.WriteLine("{0}", ans);
        }
    }
}


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

int main(){
    int a,b;
    char op;
    while(1){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        switch(op){
            case '+':
                cout<<a+b<<endl;
                break;
            case '-':
                cout<<a-b<<endl;
                break;
            case '*':
                cout<<a*b<<endl;
                break;
            case '/':
                cout<<a/b<<endl;
                break;
        }        
    }
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int const MOD = 1000000007;

int main() {
  int N; cin >> N;
  vector<string> F(2); cin >> F;
  vector<ll> dp(55);
  dp[0] = 1;
  int x = 0, dp_index = 0;
  while (x < N) {
    if (F[0][x] == F[1][x]) {
      dp[dp_index] = x == 0                     ? 3
                   : F[0][x - 1] == F[1][x - 1] ? dp[dp_index - 1] * 2
                                                : dp[dp_index - 1] * 1;
      x++;
    } else {
      dp[dp_index] = x == 0                     ? 6
                   : F[0][x - 1] == F[1][x - 1] ? dp[dp_index - 1] * 2
                                                : dp[dp_index - 1] * 3;
      x += 2;
    }
    dp[dp_index++] %= MOD;
  }
  cout << dp[dp_index - 1] << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define MAX 300005
const int maxk = 1e6+5;
int main() {
    LL n;
    cin>>n;
    string s;
    cin>>s;

    int cntR = 0;
    for (int i = 0; i < n; ++i) {
        if(s[i] == 'R')cntR++;
    }


    int rev = 0;
    for (int j = 0; j < n; ++j) {
        if(j < cntR){
            if(s[j] == 'W')rev++;
        }
        else if(s[j] == 'R') rev++;
    }

    cout<<(rev)/2<<endl;

}

Measured memory_bytes: 3752
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;


int i,j,n,m;
char a[105][105];
int main()
{
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
	for(i=1;i<=n;i++)
	{
		cout<<"#";
		for(j=1;j<=m;j++)
		{
			cout<<a[i][j];
		}
		cout<<"#"<<endl;
	}
	for(i=1;i<=m+2;i++)
	{
		cout<<"#";
	}
	cout<<endl;
}

Measured memory_bytes: 256