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

int S[1000],top;

void push(int x){
	S[++top] = x;
}

int pop(){
	top--;
	return S[top + 1];
}

int main(){
	char s[100];
	int a, b;
	top = 0;
	while (scanf("%s",s)!=EOF){
		if (s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 3228
let count f s = Array.init (String.length s) (fun i -> if f s.[i] then 1 else 0) |> Array.fold_left (+) 0
let () = Scanf.scanf "%s" @@ fun s ->
  print_endline @@ if
    s.[0] = 'A' &&
    1 = count ((=) 'C') (String.sub s 2 (String.length s - 3)) &&
    2 = count (fun x -> 'A' <= x && x <= 'Z') s
  then "AC" else "WA"

Measured memory_bytes: 384
N, A, B = map(int,input().split())


if N == 1:
  if A==B:
    print(1)
  else:
    print(0)
else:
  ans = (B*(N-1)+A)-(A*(N-1)+B) +1
  if ans > 0:
    print(ans)
  else:
    print(0)

Measured memory_bytes: 9016
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;


int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

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

  ll ans = 0;
  rep(i,n-1){
    repLRE(j, i + 1, n - 1) { ans += ds[i] * ds[j]; }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    ll n;
    cin>>n;
    string s;
    while(n>0){
        s+=(char)('a'+(n-1)%26);
        if(n%26==0) n--;
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}

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

const int mod = 1000000007;

int N;
vector<int> G[100009];
long long white[100009], black[100009];

void dfs(int u, int p) {
    black[u] = 1;
    white[u] = 1;
    for(int v : G[u]) {
        if(v == p) continue; // 親に帰る辺は無視
        dfs(v, u);
        black[u] *= white[v];
        black[u] %= mod;
        white[u] *= white[v] + black[v];
        white[u] %= mod;
    }
}

int main() {
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--; // 0-indexed にする
        G[x].push_back(y);
        G[y].push_back(x);
    }

    dfs(0, -1);

    cout << (black[0] + white[0]) % mod << endl;

    return 0;
}

Measured memory_bytes: 14208
<?php
  fscanf(STDIN,"%d %d %d %d",$a,$b,$c,$k);
  $total = 0;
  
  $total = min($a,$k);
  
 
  if(($a+$b)<$k){
      $total -= min($c,abs($k-($a+$b)));
  }
  echo $total."\n";

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

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

int main() {
    ll n;
    cin >> n;
    vector<ll> list(n+1, 2);
    
    ll ans = 0;
    for(int i = 1; i <= n; i++) {
        ll p = n/i;
        ans += i*p*(p+1)/2;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<vector<pair<int, int>>> tree(n, vector<pair<int, int>>(0));
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        tree[a].emplace_back(mp(i, b));
        tree[b].emplace_back(mp(i, a));
    }
    vector<int> ans(n - 1, -1);
    ans[0] = 0;
    queue<int> q;
    vector<int> dist(n, -1);
    dist[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        int c = 0;
        int parent_color = -1;
        for (pair<int, int> nv : tree[v]) {
            if (dist[nv.second] != -1) {
                parent_color = ans[nv.first];
                break;
            }
        }
        for (pair<int, int> nv : tree[v]) {
            if (dist[nv.second] != -1) continue;
            if (v != 0 and c == parent_color) c++;
            ans[nv.first] = c;
            dist[nv.second] = dist[v] + 1;
            q.push(nv.second);
            c++;
        }
    }
    set<int> st;
    for (int i : ans) st.insert(i);
    cout << st.size() << endl;
    for (int i : ans) cout << i + 1 << endl;
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 1000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

ll gcd(ll a,ll b) { return b ? gcd(b, a%b) : a; }

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 // 二項係数計算
ll COM(ll n, ll k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

 using graph = vector<vector<ll>>;
 pair<pair<ll,ll>,ll> p[100010];

 int main(){
     cin.tie(0);
     ios::sync_with_stdio(false);
     
     string s;
     cin>>s;
     rep(i,s.size()){
         for(ll j=i;j<s.size();j++){
             string t=s.substr(0,i)+s.substr(j,s.size()-j);
             if(t=="keyence"){
                 cout<<"YES"<<endl;
                 return 0;
             }
         }
     }
     cout<<"NO"<<endl;
     return 0;
 }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind, COM//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 1; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
class UnionFind {
public:
	vl rank, par, siz;
	UnionFind() {}
	UnionFind(ll N) {
		rank.resize(N, 0);
		par.resize(N, 0);
		siz.resize(N, 1);
		init(N);
	}
	void init(ll N) {
		for (ll i = 0; i < N; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	ll find(ll x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}
	void unite(ll x, ll y) {
		x = find(x);
		y = find(y);
		if (x != y) {
			if (rank[x] < rank[y]) {
				par[x] = y;
				siz[y] += siz[x];
			}
			else {
				par[y] = x;
				siz[x] += siz[y];
				if (rank[x] == rank[y]) rank[x]++;
			}
		}
	}
	bool issame(ll x, ll y) {
		return find(x) == find(y);
	}
	ll size(ll x) {
		return siz[find(x)];
	}
};
int main() {
	cin >> N >> M;
	UnionFind UF(N);
	UF.init(N);
	for (i = 0; i < M; i++) {
		ll x, y, z;
		cin >> x >> y >> z;
		UF.unite(x - 1, y - 1);
	}
	vl P(N);
	for (i = 0; i < N; i++) {
		P[i] = UF.find(i);
	}
	sort(P.begin(), P.end());
	for (i = 0; i < N-1; i++) {
		if (P[i] != P[i + 1]) {
			ans++;
		}
	}
	cout << ans;
}


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

typedef long long ll;
typedef unsigned long long int ull;
#define endl "\n"
#define pb push_back
#define sq(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define MOD 1000000007
#define PI 3.141592653589793238
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

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

ll exp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n)
    {
        if(n & 1)
            result=(result * x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return result;
}

struct HASH{
  size_t operator()(const pair<long long,long long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

const double N=1e9;

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

    int n;
    cin>>n;
    double s[n];
    for(int i=0;i<n;i++)
    	cin>>s[i];

    ll b[n]={0};

    for(int i=0;i<n;i++)
    	b[i] = llround(s[i]*N);

    unordered_map<pair<ll,ll>,ll,HASH> mp;
    mp.reserve(1024);
	mp.max_load_factor(0.25);
	
    for(int i=0;i<n;i++)
    {
    	ll two=0,five=0;
    	while(b[i] && (b[i]%2==0))
    	{
    		b[i]/=2;
    		two++;
    	}

    	while(b[i] && (b[i]%5==0))
    	{
    		b[i]/=5;
    		five++;
    	}

    	mp[{two,five}]++;
    }

    ll ans=0;
    for(auto x1:mp)
    {
    	for(auto x2:mp)
    	{
    		if(x1.first.first+x2.first.first>=18 && x1.first.second+x2.first.second>=18)
    		{
    			if(x1<x2)
    				ans+=x1.second*x2.second;
    			else if(x1==x2)
    				ans+=(x1.second*(x1.second-1))/2;
    		}	
    	}
    }

    cout<<ans<<endl;

    
    return 0;
}

Measured memory_bytes: 6864
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

int n, m;

void solve(){
	scanf("%d%d", &n, &m);
	int k; scanf("%d", &k);
	rep(i, n+1) rep(j, m+1) {
		int s = i * j + (n - i) * (m - j);
		if(s == k) {
			puts("Yes");
			return;
		}
	}
	puts("No");
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		// printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,i,a[100000],b,c;
int main(){
  cin>>n;
  for(;i<n;a[i]=c-1,i++)cin>>c;
  for(i=0;i<n;i++){
    if(b==1)return cout<<i,0;
    b=a[b];
  }
  cout<<-1;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

/*
 * https://atcoder.jp/contests/dp/
 */
public class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in); 
        int n = sc.nextInt();
        int[] dp = new int[n];
        dp[0] = 0;
        List asiba = new ArrayList();
        for (int i=0; i<n; i++) asiba.add(sc.nextInt());

        for (int i=1; i<n; i++) {
        	dp[i] = dp[i-1] + Math.abs((Integer)asiba.get(i) - (Integer)asiba.get(i-1));
        	if (i > 1) {
        		dp[i] = Math.min(dp[i], dp[i-2] + Math.abs((Integer)asiba.get(i) - (Integer)asiba.get(i-2)));
        	}
        }
        System.out.println(dp[n-1]);
        sc.close();
	}
}

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

int power(int x, int n) {
  if (n == 0) {
    return 1;
  } else {
    int c = 1;
    int i;
    for (i = 0; i <= n; i++) {
      c = c * x;
    }
    return c;
  }
}

int main() {
  int X;
  cin >> X;
  int i;
  int ans = 1;
  for (i = 2; i <= X; i++) {
    int j = 1;
    while (power(i, j) <= X) {
      j++;
    }
    if (power(i, j - 1) > ans) {
      ans = power(i, j - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //

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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c && a % 2 == 0) {
        cout << -1 << endl;
        return 0;
    }

    ll cnt = 0;
    while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
        int a_give = a / 2;
        int b_give = b / 2;
        int c_give = c / 2;
        a = b_give + c_give;
        b = a_give + c_give;
        c = b_give + a_give;

        cnt++;
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a;
	scanf("%d",&a);
	
	long long int ans = 0;
	for(int i=1;i<=a;i++) ans += (long long int)i*(a-i+1);
	
	for(int i=1;i<a;i++)
	{
		int b,c;
		scanf("%d%d",&b,&c);
		if(b>c)
		{
			int k = b;
			b = c;
			c = k;
		}
		ans -= (long long int)(b-1+1)*(a-c+1);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n > 0) {
        if(n & 1) (res *= x) %= mod;
        (x *= x) %= mod;
        n>>=1;
    }
    return res;
}

long long modinv(long long x, long long mod){
    return modpow(x, mod - 2, mod); }
int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    ll tmp = 0;
    for (ll i = 0; i < n; i++) {
        tmp += a[i];
        tmp %= MOD;
    }
    tmp = modpow(tmp, 2, MOD);
    for (ll i = 0; i < n;i++){
        if (a[i] == 0) continue;
        tmp -= modpow(a[i], 2, MOD);
        while (tmp < 0) tmp += MOD;
        tmp %= MOD;
    }
    ll ans = tmp * modinv(2, MOD);
    ans %= MOD;
    cout << ans << endl;
}

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

int main(){
    long long int N;
    cin >> N;
    int ans = 0;
    for(int i=2;i<1000010;i++){
        int cur = 0;
        while (N % i == 0) {
            cur++;
            N /= i;
        }
        for(int j=1;j<10000;j++) {
           if (cur < j) break;
            ans++; cur -= j;
        }
    }
    if(N>1) ans++;
    cout << ans << endl;

	return 0;

}





Measured memory_bytes: 3628
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
cnt = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if l[i] != l[j] and l[j] != l[k] and l[i] + l[j] > l[k]:
                cnt += 1
print(cnt)

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


string s;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> s;
    for(int i = 0; i + 2 < s.size(); i++){
        if(s[i] == s[i + 1] && s[i] == s[i + 2]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


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

long long f(int n) {
    if (n == 0) return 2;
    if (n == 1) return 1;
    long long a = 2, b = 1;
    long long ret;
    for (int i = 0; i < n - 1; i++) {
        ret = a + b;
        a = b;
        b = ret;
    }
    return ret;
}
int main()
{
    int n;
    cin >> n;

    cout << f(n) << endl;

    return 0;
}


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

#define MAX_H 10

using namespace std;

int s[5][MAX_H+1];
int H;

void solve() {
	int point = 0, pre = 0;
	while(1){
		pre = point;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if(s[j][i] == s[j+1][i] && s[j+1][i] == s[j+2][i]){
					int p = s[j][i];
					for (int k = j; k < 5; k++)
					{
						if(s[k][i] != p) break;
						s[k][i] = 0;
						point += p;
					}
				}
			}
		}
		if(point == pre) break;
		for (int i = 0; i < 5; i++)
		{
			for (int j = H-1; j >= 0 ; j--)
			{
				if(s[i][j] == 0){
					for (int k = j-1; k >= 0; k--)
					{
						if(s[i][k] != 0){
							s[i][j] = s[i][k];
							s[i][k] = 0;
							break;
						}
					}
				}
			}
		}
	}
	cout << point << endl;
	return;
}

int main(){
	while(1){
		cin >> H;
		if(H == 0) break;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < 5; j++)
			{
				cin >> s[j][i];
			}
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 1160
function main(input){
  input = input.split('\n');
  const N = Number(input[0]);
  const colors = input[1].split('');

  let count=0;
  let st = 0;
  let ed = colors.length-1;
  while(true){
    //console.log(colors);
    let w = firstW(colors, st, ed);
    let r = lastR(colors, st, ed);
    //console.log(w, r)
    if((w==-1) || (r==-1) || (r <= w)) break;
    colors[w] = 'R';
    colors[r] = 'W';
    st = w;
    ed = r;
    // if(errors.length === 1){
    //   count++;
    //   break;
    // }
    // let w = errors[0];
    // let r = errors[errors.length-1];
    // colors[w] = 'R';
    // colors[r+1] = 'W';
    count++;
  }

  console.log(count);
}

function findWR(colors, st, ed){
  for(let i=st; i<ed; i++){
    if(colors[i] === 'W' && colors[i+1] === 'R'){
      return true
    }
  }
  return false;
}

function firstW(colors, st, ed){
  for(let i=st; i<= ed; i++){
    if(colors[i] === 'W') return i;
  }
  return -1;
}

function lastR(colors, st, ed){
  for(let i=ed; i>=st; i--){
    if(colors[i] === 'R') return i;
  }
  return -1;
}


main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 35272
# -*- coding: utf-8 -*-
# @Date    : 2019-06-24 21:08:43
# @Author  : raj lath (oorja.halt@gmail.com)
# @Link    : link
# @Version : 1.0.0

import sys
sys.setrecursionlimit(10**5+1)

inf     =  int(10 ** 20)
max_val =  inf
min_val = -inf

RW  = lambda : sys.stdin.readline().strip()
RI  = lambda : int(RW())
RMI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
RWI = lambda : [x for x in sys.stdin.readline().strip().split()]


ins = list(RW())
last = ins.pop()
ans  = "Good"
while ins:
    if last == ins[-1]:
        ans = "Bad"
        break
    else:
        last = ins.pop()
print(ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const string YES = "Yes";
const string NO = "No";

int A[3][3];
int N;

string solve() {

    REP (h, 3) REP (w, 3) cin >> A[h][w];
    cin >> N;
    REP (i, N) {
        int b; cin >> b;
        REP (h, 3) REP (w, 3) if (A[h][w] == b) A[h][w] = 0;
    }

    REP (h, 3) {
        int n = 0;
        REP (w, 3) if (A[h][w] == 0) n++;
        if (n == 3) return YES;
    }
    REP (h, 3) {
        int n = 0;
        REP (w, 3) if (A[w][h] == 0) n++;
        if (n == 3) return YES;
    }
    REP (h, 3) {
        int n = 0;
        REP (w, 3) if (A[w][w] == 0) n++;
        if (n == 3) return YES;
    }
    REP (h, 3) {
        int n = 0;
        REP (w, 3) if (A[2-w][w] == 0) n++;
        if (n == 3) return YES;
    }

    return NO;
}

int main() {
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cctype>
#include<set>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;

inline int read() {
	int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}

const int N = 500005;
struct Edge{
	int fr, to, nxt; 
}e[N << 1];
int head[N], f1[N], f2[N], c1[N], c2[N], sk[N << 1], ans[N], top = 0, En = 1;
bool vis[N << 1];

inline void add_edge(int u,int v) {
//	cout << u << " " << v << "\n";
	++En; e[En].fr = u, e[En].to = v, e[En].nxt = head[u]; head[u] = En;
	++En; e[En].fr = v, e[En].to = u, e[En].nxt = head[v]; head[v] = En;
}
void dfs(int u) {
	while (1) {
		int k = head[u]; 
		if (!k) break;
		head[u] = e[k].nxt;
		if (!vis[k]) {
			vis[k] = vis[k ^ 1] = 1;
			dfs(e[k].to);
			sk[++top] = k;
		}
	}
}
int main() {
	int n = read();
	for (int i = 1; i <= n; ++i) {
		int x = read();
		if (x == -1) x = 0;
		f1[i] = x, c1[x] ++;
		add_edge(x, i);
	}
	for (int i = 1; i <= n; ++i) {
		int x = read();
		if (x == -1) x = 0;
		f2[i] = x, c2[x] ++;
		if (x == 0) add_edge(x, i + n);
		else add_edge(x + n, i + n);
	}
	for (int i = 1; i <= n; ++i) {
		if (c1[i] % 2 != c2[i] % 2) { puts("IMPOSSIBLE"); return 0; }
		if ((c1[i] & 1) && (c2[i] & 1)) ans[i] = 0;
		else add_edge(i, i + n);
	}
	puts("POSSIBLE");
	dfs(0);
	for (int i = top; i >= 1; --i) {
		int k = sk[i];
		if (e[k].fr + n == e[k].to) ans[e[k].fr] = 1;
		if (e[k].fr - n == e[k].to) ans[e[k].fr - n] = -1;
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d ", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 33408
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<long long,long long>;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  string s;
  cin >> s;
  ll n=s.size()+1;
  vector<ll>vec(n);
  ll sum=0;
  rep(i,n-1){
    if(s[i]=='<'){
      vec[i]=max(sum,vec[i]);
      sum++;
    }
    else{
      vec[i]=max(sum,vec[i]);
      sum=0;
    }
  }
  vec[n-1]=max(sum,vec[n-1]);
  sum=0;
  rep(i,n-1){
    if(s[n-2-i]=='>'){
      vec[n-1-i]=max(sum,vec[n-1-i]);
      sum++;
    }
    else{
      vec[n-1-i]=max(sum,vec[n-1-i]);
      sum=0;
    }
  }
  vec[0]=max(sum,vec[0]);
  ll ans=0;
  rep(i,n){
    ans+=vec[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4764
#include<stdio.h>
int main()
{
    int n,m,i,j,k,mat1[100][100]= {0},mat2[100],mat3[100];
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            scanf("%d",&mat1[i][j]);
        }
    }
    for(i=0; i<m; i++)
    {
        scanf("%d",&mat2[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=0; j<m; j++)
        {
            mat3[i]=mat3[i]+mat1[i][j]*mat2[j];
        }
    }
    for(i=0; i<n; i++)
    {
        printf("%d\n",mat3[i]);
    }
    return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s,int v,vector<int>&d,whei(edge)&G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size();i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int n,k;
	cin >> n>>k;
	map<int, int> s;
	for (int i = 0; i < k; i++) {
		int a;
		cin >> a;
		s[a] = 1;

	}
	for (int i = n;i<=10*n; i++) {
		int a = i;
		bool z = true;
		while (a>0) {
			int x = a % 10;
			if (s[x])z = false;
			a /= 10;
		}
		if (z) {
			cout << i << endl;
			break;
		}
	}
	
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int a, b; cin >> a >> b;
    if(a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
  int A,B,C,K;
  bool hantei = false;
  cin >> A >> B >> C >> K;
  for (int l=0; l<=K; l++) {
    for(int m=0; m<=K-l; m++) {
      for (int n=0; n<=K-l-m; n++) {
        if ((C*pow(2,l)>B*pow(2,m))&&(B*pow(2,m)>A*pow(2,n))) {
          hantei = true;
        }
      }
    }
  }
  if (hantei) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 4092
import scala.io.StdIn.readLine

class Dice(var d:List[Int]) {
  val fs = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x5,x1,x3,x4,x6,x2) }
  val fn = (x:List[Int]) => x match {case List(x5,x1,x3,x4,x6,x2) => List(x1,x2,x3,x4,x5,x6) }
  val fw = (x:List[Int]) => x match {case List(x1,x2,x3,x4,x5,x6) => List(x3,x2,x6,x1,x5,x4) }
  val fe = (x:List[Int]) => x match {case List(x3,x2,x6,x1,x5,x4) => List(x1,x2,x3,x4,x5,x6) }

  def roll(dir:Char)  =
    d = dir match {
      case 'S' => fs(d)
      case 'N' => fn(d)
      case 'W' => fw(d)
      case 'E' => fe(d)
    }

  def getTopFace() = d(0)
}

object Main extends App {
  val faces = readLine.split(" ").map(_.toInt).toList
  val dice = new Dice(faces)

  readLine.foreach { dice.roll _ }
  println(dice.getTopFace)
}

Measured memory_bytes: 44252
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
#include <chrono>
#include <fstream>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


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

Measured memory_bytes: 3604
h, w = map(int, input().split())
a = []
for i in range(h):
    tmp = list(input())
    if tmp[0] != '.' or tmp.count('.') != len(tmp):
        a.append(tmp)
b = []
for j in range(w):
    f = True
    for k in range(len(a)):
        if a[k][j] == '#':
            f = False
    else:
        if f:
            b.append(j)
for x in range(len(a)):
    for y in range(len(a[x])):
        if y not in b:
            print(a[x][y], end='')
    else:
        print('')


Measured memory_bytes: 4596
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var xkd = Console.ReadLine().Split(' ').Select(num => long.Parse(num)).ToArray();
            var x = Math.Abs(xkd[0]);
            var k = xkd[1];
            var d = xkd[2];

            var stepToZero = x / d;
            if (stepToZero >= k) { Console.WriteLine(Math.Abs(x - d * k)); return; }

            var result = 0L;
            if ((k - stepToZero) % 2 == 0)
            {
                result = Math.Abs(x - d * stepToZero);
            }
            else
            {
                result = Math.Abs(x - d * (stepToZero + 1));
            }

            Console.WriteLine(result);
        }

    }
}

Measured memory_bytes: 28240
def main():
    H1, M1, H2, M2, K = map(int, input().split())

    ret = H2 * 60 + M2 - (H1 * 60 + M1) - K

    print(ret)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

const int mod = 998244353;

int n;
ll m;
ll a, b;
int f[300001];
int rf[300001];

int power (int a, int b) {
	int c = 1;
	while (b) {
		if (b & 1) c = ((ll)c * a) % mod;
		a = ((ll)a * a) % mod;
		b /= 2;
	}
	re c;
}

int cnk (int n, int k) {
	if (n < 0 || k < 0 || k > n) re 0;
	re ((ll)f[n] * rf[k] % mod * rf[n - k]) % mod;
}

int main () {
	f[0] = rf[0] = 1;
	cin >> n >> a >> b >> m;
	for (int i = 1; i <= n; i++) {
		f[i] = ((ll)f[i - 1] * i) % mod;
		rf[i] = power (f[i], mod - 2);
	}
	int ans = 0;
	for (int ta = 0; ta <= n && ta * a <= m; ta++)	
		if ((m - ta * a) % b == 0) {
			ll tb = (m - ta * a) / b;
			if (tb > n) continue;
			ans = (ans + (ll)cnk (n, ta) * cnk (n, tb)) % mod;
		}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

int main()
{
	// 入力
	ll N;
	cin >> N;
	vec A(5);
	ll minA = INF;
	REP(i, 5) {
		cin >> A[i];
		minA = min(minA, A[i]);
	}

	cout << 4 + (N + minA - 1) / minA  << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set> 
#include<cmath>
using namespace std;
long long p = 998244353;
//long long p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) lower_bound(h.begin(),h.end(),val)
#define upper(h,val) upper_bound(h.begin(),h.end(),val)
#define mint modint<998244353>
#define end_s(a) cout <<a<<endl;return 0
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) { pa[x] = y; }
}
signed main() {
	int n; cin >> n;
	vel l(n), r(n);
	int maxl = 0;
	int minr = 1000000000;
	int mdiff = 0;
	V<pin> pa(n);
	rep(i, n) { 
		cin >> l[i] >> r[i]; r[i]++;
		pa[i] = mkp(r[i], l[i]);
		mmax(maxl, l[i]);
		mmin(minr, r[i]);
		mmax(mdiff, r[i] - l[i]);
	}
	sor(pa);
	int ans=minr-maxl;
	if (ans < 0) { ans = 0; }
	ans += mdiff;
	int now_max_l = pa[0].second;
	for(int i=0;i<n-1;i++) {
		mmax(now_max_l, pa[i].second);
		int haba = minr - now_max_l;
		if (haba < 0) { haba = 0; }
		int haba2 = pa[i+1].first - maxl;
		if (haba2 < 0) { haba2 = 0; }
		mmax(ans, haba + haba2);
	}
	cout << ans << Endl;
	return 0;
}
/*
4
1 R B 1 L A 1 R H 1 R D
1 L B 0 L C 1 L D 0 R A
5
1 R B 1 R C 1 R D 1 L A 1 R H
1 L C 1 R B 0 L E 1 L D 0 L A
6
1 R B 1 R C 1 L D 1 R E 1 L A 1 L H
1 L E 1 R F 0 R B 0 L C 0 R D 1 R C
*/

Measured memory_bytes: 3328
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Set<Character> set = new HashSet<Character>();
		int N = sc.nextInt();
		for(int i = 0; i < N; i++) {
			set.add(sc.next().charAt(0));
		}
		sc.close();
		if(set.size() == 3) {
			System.out.println("Three");
		}else {
			System.out.println("Four");
		}
	}
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    string w = "abcdefghijklmnopqrstuvwxyz";
    cin >> s;
    int n=s.size();
    if(s=="zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << "\n";
        return 0;
    }
    if(n==26){
        string t,ss;
        ss=s;
        next_permutation(s.begin(),s.end());
        rep(i,n){
            if(s[i]==ss[i]){
                t+=s[i];
                continue;
            }
            else{
                t+=s[i];
                cout << t << "\n";
                return 0;
            }
        }
        cout << -1 << "\n";
        return 0;
    }
    rep(i,26){
        bool ok=true;
        rep(j,n){
            if(w[i]==s[j]) ok=false;
        }
        if(ok){
            s+=w[i];
            cout << s << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}   

Measured memory_bytes: 3612
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n;
    cin >> n;

    cout << "AB";
    cout << (char)('C' + (n / 1000));
    cout << endl;

    return 0;
}



Measured memory_bytes: 888
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  m1 += 60 * h1;
  m2 += 60 * h2;
  cout << m2 - m1 - k << endl;
  return 0;
}

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

int main(void){
    string s;
    cin >> s;
    if (s.substr(0,1) == s.substr(1,1) && s.substr(0,1) == s.substr(2,1)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    //#include "testlib.h"
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    #define pii pair<int,int>
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        int n;
        cin>>n;
        vi a(n);
        rep0(n) cin>>a[i];
        vi sum(n,0);
        //sort(all(a));
        sum[0]=a[0];
        rep(1,n) sum[i]=sum[i-1]+a[i];
        int ans=1e10;
        rep0(n-1){
            if(a[i]!=a[i+1]){
                ans=min(ans,abs(sum[n-1]-2*sum[i]));
            }
         
     }
     cout<<ans;
        }
    signed main()
    {   
        asdf
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

Measured memory_bytes: 256