akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;
typedef long long ll;

int main() {

    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    rep(i,N) cin >> A[i];
    rep(i,M) cin >> B[i];

    rep(i,N-M+1) rep(j,N-M+1) {
        bool flag = true;
        rep(k,M) if (A[i + k].substr(j,M) != B[k]) flag = false;
        if (flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

const int MAXN = 1e2+10;
int A[MAXN];

int main(){
	int N,D,X;
	scanf("%d",&N);
	scanf("%d %d",&D,&X);
	for(int i=0;i<N;i++){
		scanf("%d",&A[i]);
	}
	int ans = X;
	for(int i=0;i<N;i++){
		int cur = A[i];
		ans++;
		int m = (D-1)/cur;
		if(m>0)	ans+=m;
	}
	
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,m,sn=0,sm=0;
  cin>>n>>m;
  sn=((n*n)-n)/2;
  sm=((m*m)-m)/2;
  cout<<sn+sm;
  return 0;
}

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


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct part_t
{
	string s, r;
	ll c;
	bool operator<(const part_t&rhs) const
	{
		return c>rhs.c;
	}
};


bool is_ok_i(string&s)
{
	int l=s.length();
	for(int i=l/2;i>=0;i--)
	{
		if(s[i]!=s[l-1-i]) return false;
	}
	return true;
}


bool is_ok(part_t&p)
{
	if(p.s.length()>0)
	{
		return is_ok_i(p.s);
	}
	return is_ok_i(p.r);
}


bool is_match(string&a, string&b)
{
	int l=min(a.length(), b.length());
	for(int i=0;i<l;i++)
	{
		if(a[i]!=b[i]) return false;
	}
	return true;
}


struct solve
{
	solve(){}
	ll operator()(vector<part_t>&p) {
		int n=p.size();
		priority_queue<part_t> q;
		for(auto&m:p)
		{
			part_t c;
			c.s=m.s;
			c.c=m.c;
			q.push(c);
		}
		set<string> hs, hr;
		for(;!q.empty();)
		{
			auto c=q.top();
			q.pop();

//cout << "c.s=[" << c.s << "]  c.r=[" << c.r << "]  c.c=" << c.c << "\n";
			if(is_ok(c)) return c.c;

			if(c.s.length()>0)
			{
				if(hs.find(c.s)!=hs.end()) continue;
				hs.insert(c.s);
				for(int i=0;i<n;i++)
				{
					int pl=p[i].r.length();

					if(is_match(c.s, p[i].r))
					{
						part_t nx;
						nx.c=c.c+p[i].c;
						if(c.s.length()>pl)
						{
							nx.s=c.s.substr(pl);
						}
						else
						{
							nx.r=p[i].r.substr(c.s.length());
						}
						q.push(nx);
					}
				}
			}
			else
			{
				if(hr.find(c.r)!=hr.end()) continue;
				hr.insert(c.r);
				for(int i=0;i<n;i++)
				{
					int pl=p[i].s.length();
					if(is_match(c.r, p[i].s))
					{
						part_t nx;
						nx.c=c.c+p[i].c;
						if(c.r.length()>pl)
						{
							nx.r=c.r.substr(pl);
						}
						else
						{
							nx.s=p[i].s.substr(c.r.length());
						}
						q.push(nx);
					}
				}
			}
		}
		return -1;
	}
};

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

	for(;;)
	{
		int n;
		cin >> n;
		if(cin.fail()) break;
		vector<part_t> p(n);
		for(auto&m:p)
		{
			cin >> m.s;
			cin >> m.c;
			m.r=m.s;
			reverse(m.r.begin(), m.r.end());
		}
		cout << solve()(p) << "\n";
	}
	return 0;
}


Measured memory_bytes: 3684
K = int(input())
A = list(map(int,input().split()))
B = [2,2]
for i in range(K-1,-1,-1):
    a = A[i]
    bmin = B[0]
    bmax = B[1]
    if bmin%a==0:
        bmin = bmin
    else:
        bmin = (bmin//a+1)*a
    if bmin>bmax:
        B = []
        break
    else:
        if bmax%a==0:
            bmax = bmax+a-1
        else:
            bmax = (bmax//a)*a+a-1
        B = [bmin,bmax]
if len(B)==0:
    print(-1)
else:
    print(B[0],B[1])

Measured memory_bytes: 63856
#include <stdio.h>

int main()
{
    int x=0,cnt=0;
    
    while(1)
    {
        scanf("%d\n",&x);
        if(x!=0)
        {
            cnt++;
            printf("Case %d: %d\n",cnt,x);
        }else
        {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 1952
N,M=list(map(int,input().split()))
color=["white"]*(N+1)
relation_list=[[] for i in range(N+1)]
count=[0]
for i in range(M):
    a,b=list(map(int,input().split()))
    relation_list[a].append(b)
    relation_list[b].append(a)

def dfs(i,j,cnt,kako):
    keiro=kako[:]
    cnt += 1
    for k in relation_list[i]:
        if k not in keiro:
            keiro.append(k)
            dfs(k,i,cnt,keiro)
            del keiro[-1]
    if cnt==N:
        count[0]+=1
dfs(1,1,0,[1])
print(count[0])




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

#define mem( arr, i ) fill( arr, arr + sizeof (arr), i )
#define MEM( arr, i ) memset( arr, i, sizeof (arr) )
#define Push push_back
#define Pair make_pair
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
#define ACCEL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef unsigned long long ull;
typedef long long lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef pair<pll,lli> p3l;
typedef vector<int> vcI;
typedef vector<lli> vcL;
typedef vector<pii> vPI;
typedef vector<pll> vPL;
typedef vector<p3l> v3L;
typedef vector<vcL> vvL;
//typedef priority_queue<T> prior_S<T>;
//typedef priority_queue< T, vector<T>, greater<T> > prior_B<T>;
const double PI = 3.141592653589793;
const lli I_MAX = 1LL << 60;
      lli   mod = 1000000007;

/// templates ///

const lli maxN = 2E5;

vcL inv( maxN+5, 1 );
vcL fac( maxN+5, 1 );

void ADD(lli &x, lli y) {
	x += y;
	if ( x >= mod ) x -= mod;
	if ( x < 0 ) x += mod;
}

void MUL(lli &x, lli y) {
	x *= y;
	x = ( x%mod + mod ) % mod;
}

lli mypow(lli b, lli e) {
	lli ans = 1;
	while (e) {
		if ( e&1 ) MUL( ans, b );
		MUL( b, b );
		e >>= 1;
	}
	return ans;
}

lli modinv(lli n) {
	return mypow( n, mod-2 );
}

void calcInv(lli n) {
	for (int i = 2; i <= n; ++i) {
		inv[i] = (mod-mod/i) * inv[ mod%i ] % mod;
	}
}

void calcFac(lli n) {
	for (int i = 2; i <= n; ++i) {
		fac[i] = fac[ i-1 ] * i % mod;
	}
}

lli cm(lli a, lli b) {
	lli ans = 1;
	if ( a < b ) return 0;

	MUL( ans, inv[ fac[ a-b ] ] );
	MUL( ans, inv[ fac[b] ] );
	MUL( ans, fac[a] );

	return ans;
}

lli Lucas(lli n, lli m) {
	if ( m == 0 ) return 1;
	return cm( n%mod, m%mod ) * Lucas( n/mod, m/mod ) % mod;
}

lli doLucas(lli n, lli m) {
	calcInv(mod);
	calcFac(mod);
	return Lucas( n, m );
}

/// coding area ///

const lli maxn = 1E5;
vcL adj[ maxn+5 ];
bool visit[ maxn+5 ][3];
vcL depth( maxn+5, -1 );
queue<pll> que;

void precal() {

	return;
}

void bfs(lli now, lli dep) {
	for (auto x : adj[now]) {
		if ( !visit[x][ dep%3 ] ) {
			visit[x][ dep%3 ] = true;
			if ( dep%3 == 0 ) depth[x] = dep/3;
			
//			cout << "goto " << x << " from " << now << " with depth " << dep << '\n';
			que.push( Pair( x, dep ) );
		}
	}
	
	if ( !que.empty() ) {
		pll next = que.front();
		que.pop();
		bfs( next.X, next.Y+1 );
	}
}

void solve() {
	MEM( visit, false );
	
	lli n, m, s, t, sum = 0, ans = 0, cnt = 0, cnt0 = 0, ext = 0;
	cin >> n >> m;

	vPL num(m);
	for (auto &x : num) {
		cin >> x.X >> x.Y;
		adj[x.X].Push(x.Y);
	}
	
	cin >> s >> t;
	
	visit[s][0] = true;
	depth[s] = 0;
	bfs( s, 1 );
	
	#ifdef LOCAL
		for (int i = 1; i <= n; ++i) cout << depth[i] << ' '; cout << '\n';
	#endif
	
	cout << depth[t] << '\n';
}

int main() {
	precal();
	int t = 1;
	#ifdef LOCAL
		t = INT_MAX;
	#else
		ACCEL;
	#endif
//	cin >> t;
	for (int i = 1; i <= t; ++i) {
//		printf("Case #%d: ", i );
		solve();
	}
	return 0;
}



Measured memory_bytes: 11520
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e16 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

string s;
int x, y;

bool dp[8010];
bool check(vector<int>& num, int k) {
    int sum = 0;
    for (int v : num) {
        sum += v;
    }
    if ((sum - k) % 2 == 1 || sum < abs(k)) return false;
    k = (sum - k) / 2;
    
    memset(dp, 0, sizeof(dp));
    dp[0] = 1;

    for (int i = 0; i < (int)num.size(); i++) {
        for (int j = k; j >= 0; j--) {
            if (dp[j])
                dp[j+num[i]] = 1;
        }
    }
    return dp[k];
}

bool solve() {
    vector<int> num[2];
    int l = 0, n = (int)s.size();
    while (l < n && s[l] == 'F') {
        x--;
        l++;
    }

    bool p = 0;
    while (l < n) {
        int t = 0;
        while (l + t < n && s[l+t] == 'T') t++;
        if (t % 2 == 1) p = 1 - p;
        l += t;
        int f = 0;
        while (l + f < n && s[l+f] == 'F') f++;
        num[p].push_back(f);
        l += f;
    }
    return check(num[0], x) && check(num[1], y);
}

void input() {
    cin >> s >> x >> y;
}

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

    input();
    cout << (solve() ? "Yes" : "No") << endl;;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, s, sum, max, min;
  int i;

  while(scanf("%d", &n), n){\
    sum=0;
    max=0;
    min=1000;
    for(i=0;i<n;i++){
      scanf("%d", &s);
      if(max<s) max=s;
      if(min>s) min=s;
      sum+=s;
    }
    printf("%d\n", (sum-max-min)/(n-2));
  }


  return 0;
}

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

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    vector<int> reach(N, -1);
    long long ans;
    int town = 1;

    reach.at(0) = 0;
    for (int i = 1; i <= N; i++) {
        town = A.at(town - 1);
        if (i == K) {
            ans = town;
            break;
        }
        if (reach.at(town - 1) != -1) {
            int num = (K - (long long)i) % (long long)(i - reach.at(town - 1));
            for (int j = 0; j < num; j++) town = A.at(town - 1);
            ans = town;
            break;
        }
        reach.at(town - 1) = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
string LCS(string s,string t,int n,int m)
{
  int i,j,dp[n+1][m+1];
  for(i=0;i<=n;i++)
    dp[i][0]=0;
  for(j=0;j<=m;j++)
    dp[0][j]=0;
  for(i=1;i<=n;i++)
  {
    for(j=1;j<=m;j++)
    {
      if(s[i-1]==t[j-1])
        dp[i][j]=dp[i-1][j-1]+1;
      else
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    }
  }
  int l=dp[n][m];
  i=n;j=m;
  string S;
  while(l!=0)
  {
    if(dp[i][j]==dp[i-1][j])
      i--;
    else if(dp[i][j]==dp[i][j-1])
      j--;
    else
    {
      S+=s[i-1];
      i--;
      j--;
      l--;
    }
  }
  reverse(S.begin(),S.end());
  return S;
}
int main()
{
  int n,m;
  string s,t,ans;
  cin >> s >> t;
  n=s.length();
  m=t.length();
  ans=LCS(s,t,n,m);
  cout<<ans;
}

Measured memory_bytes: 35456
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;

const int X_MAX = 100010;
bool P[X_MAX];

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

    memset(P, true, sizeof(P));
    int ans;
    for(int i = 2; i < X_MAX; i++){
        if (i >= x && P[i]){
            ans = i;
            break;
        }
        if (!P[i])continue;
        for(int j = 2 * i; j < X_MAX; j += i){
            P[j] = false;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.*;

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] param = input.split(" ");
        int x = Integer.parseInt(param[0]);

        double ans = Math.pow(x, 3);
        System.out.println((int)ans);
    }
}

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

long long int N,K;
long long int A[10000007];

int main(){
    long long int ans = 0;
    int min_number = -1;
    cin >> N >> K;

    for(int i = 1;i < N+1;i++) {
        cin >> A[i];
        if(A[i] == 1) min_number = i;
    }
    
    //cout << ((double) min_number-1) / ((double) K-1) << endl;

    ans = ceil(((double) N - 1) / ((double) K-1));

    cout << ans << endl;
}

Measured memory_bytes: 4408
#include <iostream>
#include <cmath>
#define int long long
using namespace std;
int v[500001],n;
int pd[1000001];
main ()
{
    cin>>n;
    for (int i = 1;i<=n;++i)
        cin>>v[i];
    pd[1]=0;
    pd[2]=abs(v[1]-v[2]);
    for (int i = 3;i<=n;++i)
        pd[i]=min(pd[i-1]+(abs(v[i-1]-v[i])),pd[i-2]+abs(v[i-2]-v[i]));
    cout<<pd[n];
    return 0;
}


Measured memory_bytes: 5120
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
//别急 dp找状态 问题看看本身的规律 贪心找方法
int Xiaobo()
{
	int n,k;
	cin>>n>>k;
	int cnt=0;
	while(n) {
		cnt++;
		n/=k;
	}
	cout<<cnt<<'\n';
	return 0;
}

Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
 
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
 
class dsu{
    vi p,rank;
    vi set_count;
  
  public:
    dsu(int n){
        p.assign(n,0); 
        rank.assign(n,0);
        set_count.assign(n,1);
        for(int i=0;i<n;i++) p[i] = i;
    }
    int findSet(int x){
        return (p[x] == x) ? x:(p[x] = findSet(p[x]));
    }
    bool isSame(int i, int j){
        return (findSet(i) == findSet(j));
    }
    void unionSet(int i, int j){
        if(!isSame(i,j)){
            int x = findSet(i), y = findSet(j);
            if(rank[x] > rank[y]) {p[y] = x; set_count[x]+=set_count[y];}
            else{
                p[x] = y;
                set_count[y]+=set_count[x];
                if(rank[x] == rank[y]) rank[y]++;
            }
        }
    }
    int count(int x){
        return set_count[findSet(x)];
    }
};
 
signed main()
{
    tezz
 
    char c;
    cin>>c;
    cout<<(char)(c+1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる





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

  vector<vector<char>> p(a+2,vector<char>(b+2,'#'));
  rep(i,a){
    rep(j,b){
      cin>>p[i+1][j+1];
    }
  }

  rep(i,a+2){
    rep(j,b+2){
      cout << p[i][j];
    }
    cout << endl;
  }

}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 2e5 + 5;
int n, l, t, p;
ll ans;
int b[22];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> t;
        for (int k = 0; k <= 20; ++k) {
            if ((1 << k) & t) {
                l = max(l, b[k]);
                b[k] = i;
            }
        }
        ans += i - l;
    }

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


Measured memory_bytes: 3612
n = int(input())
ws = list(map(int, input().split()))

diffs_s1_s2 = []
sum_w = sum(ws)
for t in range(1, n+1):
    sum_s1 = sum(ws[:t-1])
    diff_s1_s2 = abs(sum_w - (2 * sum_s1))
    diffs_s1_s2.append(diff_s1_s2)
print(min(diffs_s1_s2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<28)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
ll ans;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int n = (int)s.size();
    rep(i, 0, (1<<n-1)) {
        ll sum = 0;
        rep(j, 0, n-1) {
            sum = sum * 10 + (s[j] - '0');
            if (i >> j & 1) {
                ans += sum;
                sum = 0;
            }
        }
        sum = sum * 10 + (s[n-1] - '0');
        ans += sum;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    O=input()
    E=input()+' '
    for a,b in zip(O,E):
        print(a+b,sep='',end='')
    print('')

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
N,M = map(int,input().split())
students = []
checks = []
for _ in range(N):
    students.append(tuple(map(int,input().split())))
    
for _ in range(M):
    checks.append(tuple(map(int,input().split())))

for a,b in students:
    min_d = 10**9 
    min_i = 0
    for i,(c,d) in enumerate(checks):
        dis = abs(a-c) + abs(b-d)
        if dis < min_d:
            min_d = dis
            min_i = i
#         print(a,b,c,d,dis,min_d,min_i,i)
    print(min_i+1)

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

using namespace std;

const int MAX_N = 100010;

int par[MAX_N];
int rrank[MAX_N];

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		rrank[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	} else {
		return par[x] = find(par[x]);
	}
}

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

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

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

int main() {
	int n, m;
	cin >> n >> m;
	init(n);
	vector< vector<int> > l(m);
	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			cin >> b;
			l[b-1].push_back(i);
		}
	}
	for (int i = 0; i < l.size(); i++) {
		for (int j = 0; j < l[i].size(); j++) {
			if (!same(l[i][0], l[i][j])) {
				unite(l[i][0], l[i][j]);
			}
		}
	}
	bool h = true;
	for (int i = 0; i < n-1; i++) {
		if (find(i) != find(i+1)) {
			h = false;
			break;
		}
	}
	if (h) {
		cout << "YES" << endl;
 	} else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int n, a, b,c ;
int main()
{
	cin >> n >> a >> b;
	
  	if(a+b-n>0){c=a+b-n;}else{c=0;}
    cout << min(a , b) << " " << c << endl;

	return 0;
}

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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  string str;
  int ans=0;
  
  cin >> str;
  for (int i=0; i<str.size(); i++){
    ans += (str[i]-'0')^(i%2);
  }
  cout << MIN(ans, str.size()-ans) << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

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

    const char *c = s.c_str();

    for (int i = 0; i < s.length(); ++i)
    {
        if (i % 2)
        {
            continue;
        }
        cout << c[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>

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

    int n;
    std::cin >> n;
    int taro = 0, hanako = 0;
    for(int i=0; i<n; ++i){
        std::string l, r;
        std::cin >> l >> r;
        if(l>r) taro += 3;
        else if(l<r) hanako += 3;
        else ++taro, ++hanako;
    }
    std::cout << taro << " " << hanako << "\n";
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    string s; cin >> s;
    bool ok = false;
    while(true){
        int len = s.size();
        if(len >= 5 && s.substr(len - 5) == "dream"){
            s.erase(len - 5);
        }
        else if(len >= 7 && s.substr(len - 7) == "dreamer"){
            s.erase(len - 7);
        }
        else if(len >= 5 && s.substr(len - 5) == "erase"){
            s.erase(len - 5);
        }
        else if(len >= 6 && s.substr(len - 6) == "eraser"){
            s.erase(len - 6);
        }
        else break;
        if(s.size() == 0){
            ok = true;
            break;
        }
    }
    if(ok) cyes;
    else cno;
    return 0;   
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

int main()
{
  i64 N, K;
  cin >> N >> K;
  vector<i64> A(N);
  for (i64 i = 0; i < N; i++)
    cin >> A[i];
  vector<i64> tmp(N);
  for (i64 i = 0; i < K; i++)
  {
    for (i64 j = 0; j < N; j++)
    {
      tmp[max(0LL, j - A[j])]++;
      if (j + A[j] + 1 < N)
        tmp[j + A[j] + 1]--;
    }
    for (i64 j = 1; j < N; j++)
      tmp[j] += tmp[j - 1];
    A = tmp;
    tmp = vector<i64>(N);
    bool fin = true;
    for (i64 j = 0; j < N; j++)
      if (A[j] != N)
        fin = false;
    if (fin)
      break;
  }
  for (i64 i = 0; i < N; i++)
    cout << A[i] << " \n"[i + 1 == N];
  return 0;
}


Measured memory_bytes: 7984
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
			PriorityQueue<String> t=new PriorityQueue<>();
			int n=sc.nextInt();
			int l=sc.nextInt();
			for(int i=0;i<n;i++) {
				t.add(sc.next());
			}
		while(!t.isEmpty()) {
			System.out.print(t.poll());
		}
		System.out.println();

	}
	
	static void readArray(int[] arr,Scanner sc) { 
		for(int i=0;i<arr.length;i++) {
			arr[i]=sc.nextInt();
		}
	}
	
	
	

}

Measured memory_bytes: 37084
#include <bits/stdc++.h>
#include <functional>
#include<stdio.h>
using namespace std;
#define ll       	long long int
#define dd      	long double
#define pb          push_back
#define pf          push_front
#define pi         pair<ll,ll>
#define vi          vector<ll>
#define vpi        vector<pi>
#define mi          map<ll,ll>
#define vvi         vector<vector<ll>>
#define mpi         map<pi,ll>
#define pipi        pair<ll,pair<ll,ll> >
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x         first
#define y         second
#define sz(x)       (ll)x.size()
#define u        	'\n'
#define PI          3.141592653589
#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define rf(s)       for(auto &c : s)
#define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++) //use Iterator
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define ef          else if
#define yes       cout<<"YES"<<'\n';
#define no        cout<<"NO"<<'\n';
#define C         continue;
#define wa(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
#define debug(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i<<" "; cout<<'\n'
#define debugp(vec) cout<<(#vec)<<": "; for (auto& i: vec) cout<<i.x<<","<<i.y<<" | "; cout<<'\n'
#include <ext/pb_ds/tree_policy.hpp>     
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>     
using namespace __gnu_pbds;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key
const ll N = 350;
 
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); } 
/*
ll power(ll x, ll y) 
{ 
    ll res = 1;  
	x=x%M; 
    while (y > 0) 
    { 
        if (y & 1) 
        res = (res*x)%M; 
        y = y>>1; 
        x = (x*x)%M;  
    } 
    return res; 
}
*/
signed main()
{
	tezz
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n,i;
		cin>>n;
		ll mm=INT_MIN,mn=INT_MAX;
		ll mm1=INT_MIN,mn1=INT_MAX;
		ll mm2=INT_MIN,mn2=INT_MAX;
		fo(i,0,n)
		{
			ll a,b;
			cin>>a>>b;
			ll r=a+b;
			if(r>mm)
			mm=r;
			if(r<mn)
			mn=r;
			ll r1=a-b;
			if(r1>mm1)
			mm1=r1;
			if(r1<mn1)
			mn1=r1;
			ll r2=b-a;
			if(r2>mm2)
			mm2=r2;
			if(r2<mn2)
			mn2=r2;
		}
		ll ans=max({mm-mn,mm1-mn1,mm2-mn2});
		cout<<ans<<u;			
	}
	return 0;
} 

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
	int n,a,b;scanf("%d %d %d",&n,&a,&b);
	vector<int> x(n);ll ans=0;
	rep(i,n)scanf("%d",&x[i]);
	rep(i,n-1){
		ll diff=x[i+1]-x[i];
		ans+=((a*diff<b)?a*diff:b);
	}
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 640
r, c = list(map(int, input().split(' ')))
l = []
for i in range(r):
    l.append(list(map(int, input().split(' '))))
yl = []
xl = []
for y in range(r):
    xl.append(0)
    for x in range(c):
        xl[y] += l[y][x]
    l[y].append(xl[y])
t = [0] * len(l[0])
for y in range(r):
    for x in range(len(t)):
        t[x] += l[y][x]
l.append(t)
for a in l:
    print(*a)


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

int main()
{
  vector<int>A{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
  int K ;
  cin>>K ;
  cout<<A.at(K-1)<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
lines = [[] for _ in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    lines[a-1].append(b-1)
    lines[b-1].append(a-1)

c = list(map(int,input().split()))
c.sort(reverse=True)

not_visited = [-1]*N
not_visited[0] = 0
stack = deque()
stack.append(0)

ans = [0]*N
ans[0] = c[0]

cut = 1
while stack:
    now = stack.popleft()
    for nex in lines[now]:
        if not_visited[nex] == -1:
            ans[nex] = c[cut]
            not_visited[nex] =  not_visited[now] + 1
            cut += 1
            stack.append(nex)

print(sum(c[1:]))
print(*ans)

Measured memory_bytes: 77244
inputA,inputB =map(int, input().split(' '))


plus = 0
mainus = 0
cross = 0

plus = inputA + inputB
mainus = inputA -inputB
cross = inputA * inputB

if plus > mainus:
    if plus > cross:
        print(plus)
    else:
        print(cross)
elif mainus > cross:
    print(mainus)
else:
    print(cross)
    

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct pos { 
  ll m, sum;
  bool operator< (const pos &x) const { return m-sum<x.m-x.sum || (m-sum==x.m-x.sum&&sum>x.sum); }; 
  bool operator> (const pos &x) const { return m>x.m || (m==x.m&&sum>x.sum); }; 
};

int main() {
  int N; cin >> N;
  string S[N]; rep(i,N) cin >> S[i];
  vector<pos> pos_p, pos_m;
  rep(i,N) {
    pos p = {0,0};
    rep(j,S[i].size()) {
      p.sum += S[i][j]=='(' ? 1 : -1;
      p.m = min(p.m,p.sum);
    }
    if (p.sum>0) pos_p.push_back(p);
    else pos_m.push_back(p);
  }
  sort(all(pos_p),greater<pos>());
  sort(all(pos_m));
  // for (auto x: pos_p) cout << x.m << " " << x.sum << endl;
  // for (auto x: pos_m) cout << x.m << " " << x.sum << endl;

  string result = "Yes";
  ll now = 0;
  for (auto x: pos_p) {
    if (now+x.m<0) result ="No";
    now += x.sum;
  }
  for (auto x: pos_m) {
    if (now+x.m<0) result ="No";
    now += x.sum;
  }
  if (now!=0) result = "No";
  cout << result << endl;
  return 0;
}

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

int main(){
    int k, x;
    cin >> k >> x;
    if(k*500>=x){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
 
long long solve(long long n) {
    long long x, k;
    long long min{n};
    x = sqrt(n);
    for (long long i = 1; i <= x; i++) {
        if (n % i == 0) {
            k = n / i;
            min = ((k + i - 2 < min) ? k + i - 2 : min);
        }
    }
    return min;
}
 
int main() {
    long long n;
    cin >> n;
 
    cout << solve(n);
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int w, h, x, y;
  	cin >> w >> h >> x >> y;
  	int flag = 0;
  	if(w == 2*x && h == 2*y) flag = 1;
  	cout << (double)w*h/2 << " " << flag << endl;
	return;
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T> 
struct WeightedUnionFind{
  int n;
  T d;
  vector<int> r,p;
  vector<T> ws;
  WeightedUnionFind(){}
  WeightedUnionFind(int sz,T d_):
    n(sz),d(d_),r(n,1),p(n),ws(n,d){iota(p.begin(),p.end(),0);}
  int find(int x){
    if(x==p[x]){
      return x;
    }else{
      int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  T weight(int x){
    find(x);
    return ws[x];
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y,T w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  T diff(int x,int y){
    return weight(y)-weight(x);
  }
};
//END CUT HERE
signed AOJ_1330(){
  int n,m;
  while(cin>>n>>m,n||m){
    WeightedUnionFind<Int> u(n,0);
    for(int i=0;i<m;i++){
      int a,b;
      char c;
      cin>>c>>a>>b;
      a--;b--;
      if(c=='!'){
	Int w;
	cin>>w;
	u.unite(a,b,w);
      }else{
	if(!u.same(a,b)) cout<<"UNKNOWN"<<endl;
	else cout<<u.diff(a,b)<<endl;
      }
    }
  }
  return 0;
}
/*
  verified on 2017/10/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1330
*/

signed DSL_1_B(){
  Int n,q;
  cin>>n>>q;
  WeightedUnionFind<Int> wuf(n,0);
  
  for(Int i=0;i<q;i++){
    Int t,x,y,z;
    cin>>t>>x>>y;
    //cout<<t<<":"<<x<<" "<<y<<endl;
    if(t){
      if(wuf.same(x,y)) cout<<wuf.diff(x,y)<<endl;
      else cout<<"?"<<endl;
    }else{
      cin>>z;
      wuf.unite(x,y,z);
    }
  }
}
/*
  verified on 2018/04/16
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B&lang=jp
*/

signed main(){
  AOJ_1330();
  //DSL_1_B();
}



Measured memory_bytes: 4436
#include<iostream>
#include<map>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string,int>m;
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		++m[s];
	}
	int maxv=0;
	for(map<string,int>::iterator it=m.begin();it!=m.end();++it)
		maxv=max(maxv,it->second);
	for(map<string,int>::iterator it=m.begin();it!=m.end();++it)
		if(it->second==maxv)
			cout<<it->first<<endl;
	return 0;
}

Measured memory_bytes: 25216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		String[] flds = readFlds();
		long x = plong(flds[0]);
		long y = plong(flds[1]);
		long ans = 0;
		while (x <= y) {
			ans++;
			x *= 2;
		}
		pln(ans);
	}

	int abs(int a) {
		return (a >= 0) ? a : -a;
	}

	int max(int a, int b) {
		return (a > b) ? a : b;
	}

	int min(int a, int b) {
		return (a < b) ? a : b;
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

	String readLine() {
		try {
			return _in.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector<vector<int> > data;
int ans;
pair<bool, int> dfs(int vertex, int last){
    int ant = 0;
    bool can = false;
    int sat = 0, DD=0;
    for (int i=0; i < data[vertex].size(); i++){
        int to = data[vertex][i];
        if (to == last) continue;
        pair<bool, int> res = dfs(to, vertex);
        if (res.second!=0){
            sat = 1;
        }
        if (res.first){
            DD++;
            can = true;
            continue;
        }
        ant++;
    }
    DD += max((int) 0, ant-1);
    if (DD >= 2) sat = 0;
    ans += max((int) 0, ant-1);
    if ((ant > 1 ||(can&&ant==1)) && sat!=1) sat = 2;
    //cout << vertex << " " << ant << " " << sat << endl;
    if (ant>1 || can) return make_pair(true, sat);
    return make_pair(false, sat);
}
signed main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i=0; i < n; i++){
        vector<int> help;
        data.push_back(help);
    }
    for (int i=0; i < n-1; i++){
        int a, b;
        cin >> a >> b;
        data[a].push_back(b);
        data[b].push_back(a);
    }
    ans=0;
    pair<bool, int> rr = dfs(0, -1);
    cout << ans+(rr.second==1)+!rr.first << endl;
    return 0;
}








Measured memory_bytes: 13424
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,X[100],Y[100],sz,m,ys[100];
double mx[10000],my[10000];
double d(int a,int b){
	return sqrt((mx[a]-mx[b])*(mx[a]-mx[b])+(my[a]-my[b])*(my[a]-my[b]));
}
int main()
{
	while(scanf("%d",&n),n){
		rep(i,n)scanf("%d%d",X+i,Y+i),ys[i]=Y[i];
		sort(ys,ys+n);
		sz=unique(ys,ys+n)-ys; m=0;
		rep(i,n){
			mx[m]=X[i]; my[m]=Y[i]; m++;
			if(i<n-1)for(int j=Y[i]<Y[i+1]?0:sz-1;Y[i]<Y[i+1]?j<sz:j>=0;Y[i]<Y[i+1]?j++:j--)
				if(min(Y[i+1],Y[i])<ys[j]&&ys[j]<max(Y[i],Y[i+1])){
					double dy=Y[i+1]-Y[i],dx=(X[i+1]-X[i])/dy*(ys[j]-Y[i]);
					mx[m]=X[i]+dx; my[m]=ys[j]; m++;
			}
		}
		//rep(i,m)cerr<<mx[i]<<" "<<my[i]<<endl;
		
		priority_queue<pair<double,pi> >q;
		set<pi> v;
		q.push(mp(0,mp(0,m-1)));
		while(!q.empty()){
			int l=q.top().second.first, r=q.top().second.second;
			double c=q.top().first; q.pop();
			if(v.count(mp(l,r)))continue;
			v.insert(mp(l,r));
			if(l==r){
				printf("%.9f\n",-c); break;
			}
			for(int i=-1;i<2;i++)for(int j=-1;j<2;j++)
			if(0<=l+i&&l+i<m&&0<=r+j&&r+j<m&&abs(my[l+i]-my[r+j])<1e-9){
				q.push(mp(c-d(l,l+i)-d(r,r+j),mp(l+i,r+j)));
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2112
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>

#define reg register
#define MAX_N 200007
#define rep(i, l, r) for(int i = l; i <= r; ++i)
typedef long long ll;

template <typename _T>
inline bool read (_T& x) {
    x = 0;
    _T y = 1;
    char c = getchar();
    while ((c < '0' || '9' < c) && c != EOF) {
        if (c == '-') y = -1;
        c = getchar();
    }
    if (c == EOF) return false;
    while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getchar();
    x *= y;
    return true;
}

int M, N;
int a[MAX_N], b[MAX_N], c[MAX_N];

inline int calc (int x) {
    rep (i, 1, N) b[i] = (x < a[i]);
    // printf("%d:\n", x);
    // rep (i, 1, N) printf("%d ", b[i]); puts("");
    for (int i = 1, j = 1; i <= N; i = j) {
        int l, r;
        while (j < N && b[j + 1] == b[j]) j++;
        l = j;
        while (j < N && b[j + 1] != b[j]) j++;
        r = j;
        // printf("%d %d\n", l, r);
        if (b[l] == b[r]) {
            rep (k, l + 1, r - 1) b[k] = b[l];
        } else {
            int sum = 0;
            rep (k, l, r) sum += (b[k] == b[l]);
            rep (k, l, l + sum - 1) b[k] = b[l];
            rep (k, l + sum, r) b[k] = b[r];
        }
        j++;
    }
    // rep (i, 1, N) printf("%d ", b[i]); puts("");
    return b[M];
}

int main () {
    //freopen ("triangle.in", "r", stdin);
    //freopen ("triangle.out", "w", stdout);
    read(M), N = 2 * M - 1;
    rep (i, 1, N) read(a[i]), c[i] = a[i];
    std::sort(c + 1, c + N + 1);
    int l = 1, r = N, mid, ans = 0;
    while (l <= r) {
        mid = l + r >> 1;
        if (!calc(c[mid])) ans = mid, r = mid - 1;
        else l = mid + 1;
    }
    printf("%d\n", c[ans]);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
using namespace std;
int main (void) {
    int N;

    cin >> N;

    int a[N];
    int ax = 0;
    int cnt = 11;
    while (true) {
        if (ax >= N) {
            break;
        }

        bool flag = true;
        for (int i = 2; i < cnt; i++) {
            if (cnt % i == 0) {
                flag = false;
            }
        }
        if (flag && cnt % 5 == 1) {
            a[ax++] = cnt;
        }
        cnt++;
    }

    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            cout << a[i] << endl;
        } else {
            cout << a[i] << " ";
        }
    }

    return 0;
}


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

#define reint register int
#define coint const int

using namespace std;

coint SIZE = 100000 + 5;

multiset<int, greater<int> > st;
int li[SIZE];

inline int getint(void) {
    reint x = 0, ch = getchar();
    for (; ch < '0' || ch > '9'; ch = getchar());
    for (; ch >= '0' && ch <= '9';
        x = (x << 1) + (x << 3) + (ch - '0'), ch = getchar());
    return x;
}

int main(void) {
    coint n = getint();
    for (reint i = 1; i <= n; ++i) li[i] = getint();
    for (reint i = 1; i <= n; ++i) {
        multiset<int>::iterator it = st.upper_bound(li[i]);
        if (it == st.end()) { st.insert(li[i]); continue; }
        st.erase(it), st.insert(li[i]);
    }
    printf("%d\n", (int)st.size());

    return 0;
}



Measured memory_bytes: 5376
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

template <int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0)
            v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+(const Fp &r) const noexcept {
        return Fp(*this) += r;
    }
    constexpr Fp operator-(const Fp &r) const noexcept {
        return Fp(*this) -= r;
    }
    constexpr Fp operator*(const Fp &r) const noexcept {
        return Fp(*this) *= r;
    }
    constexpr Fp operator/(const Fp &r) const noexcept {
        return Fp(*this) /= r;
    }
    constexpr Fp &operator+=(const Fp &r) noexcept {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os,
                                         const Fp<MOD> &x) noexcept {
        return os << x.val;
    }
    friend constexpr istream &operator>>(istream &is, Fp<MOD> &x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
using mint = Fp<MOD>;

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

    string L;
    cin >> L;
    ll num = 0;
    mint res = 0;
    for (int i = 0; i < L.size(); i++) {
        int len = (int)L.size() - i - 1;

        if (L[i] == '1') {
            res += modpow((mint)2, num) * modpow((mint)3, len);
            num++;
        }
    }

    res += modpow((mint)2, num);

    cout << res << endl;
}

Measured memory_bytes: 3756
import sys
n = int(sys.stdin.readline().strip('\n'))
a = [list(map(int, sys.stdin.readline().strip('\n').split())) for _ in range(n)]
# dp[i+1][j]: i日目までの活動に加え、i+1日目に活動jを選んだときの幸福度の最大値
dp = [[0 for _ in range(3)] for _ in range(n+1)]
for i in range(n):
  for j in range(3):
    for k in range(3):
      if j==k: continue
      dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])
#for i in range(n+1): print(dp[i])
print(max(dp[n]))

Measured memory_bytes: 47332