akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int64_t K;
int main(){
  cin>>K;
  if(K%2==0 ||K%5==0)
    cout<<-1<<endl;
  else{
  if(K%7==0)
    K/=7;
    vector<int64_t>A(9*K);
    A[0]=1;
    for(int i=1;i<9*K;i++)
    A[i]=(10*A[i-1])%K;
    int ans=0;int b=0;
    for(int i=0;i<9*K;i++){
    b=(b+A[i])%K;
      if(b==0){ans=i+1;break;}
    
    }cout<<ans<<endl;
      
  
  }
  return 0;
}

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

int main(void){
	int A,B,C,A1,B1,C1,cnt=0;
	cin>>A>>B>>C;
	while(!(A&1 || B&1 || C&1)){
		cnt++;
		if(cnt>1000000){
			cnt=-1;
			break;
		}
		A/=2; B/=2; C/=2;
		A1=B+C;
		B1=A+C;
		C1=A+B;
		A=A1, B=B1, C=C1;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define FOR(i,m,n) for(i=m;i<n;i++)

void show(int a[])
{
//	for (int i = 0; i < 10; i++)
//		printf("%d ", a[i]);
//	printf("\n");
}

void quicksort(int a[], int left, int right)
{

	int p;	//中央値
	int L = left, R = right;		//ループ中で変化するleft、right
	int temp;
	p = a[(left + right) / 2];

	while (1)
	{
		while (a[L] < p) L++; while (a[R] > p)
			R--;
		
		if (L >= R)
			break;

		temp = a[R];
		a[R] = a[L];
		a[L] = temp;

		L++;
		R--;
	}

	show(a);

	if (left < L - 1) quicksort(a, left, L - 1); if (right > R + 1)
		quicksort(a, R + 1, right); 
	
}

int main(void)
{
	int a,b,c[100010],i,d[100010];
  	long long x=0;
	scanf("%d %d",&a,&b);
	for(i=0;i<b;i++){
		scanf("%d",&c[i]);
	}
	quicksort(c,0,b-1);
	for(i=0;i<b-1;i++){
		d[i]=c[b-i-1]-c[b-i-2];
	}
	quicksort(d,0,b-2);
	for(i=0;i<b-a;i++){
		x=x+d[i];
	}
	printf("%lld\n",x);
}


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

ll a[10][maxn];
ll u[maxn],v[maxn],w[maxn];
ll ans=0;

inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(ll x){writ(x);putchar('\n');}

int main()
{
	int n=read(),m=read();
	for (int i=1;i<=n;++i) u[i]=read(),v[i]=read(),w[i]=read();
	for (int i=1;i<=n;++i)
	{
		a[1][i]=u[i]+v[i]+w[i];
		a[2][i]=u[i]+v[i]-w[i];
		a[3][i]=u[i]-v[i]+w[i];
		a[4][i]=u[i]-v[i]-w[i];
		a[5][i]=-u[i]+v[i]+w[i];
		a[6][i]=-u[i]+v[i]-w[i];
		a[7][i]=-u[i]-v[i]+w[i];
		a[8][i]=-u[i]-v[i]-w[i];
	}
	for (int i=1;i<=8;++i)
	{
		sort(a[i]+1,a[i]+n+1);
		ll ww=0;
		for (int j=n;j>=n-m+1;--j) ww+=a[i][j];
		if (ww>ans) ans=ww;
	}
	write(ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	string s;
	cin>>s;
	int n=s.length();
	int ans[n];
	memset(ans,0,sizeof(ans));
	f(i,0,n-1)
	{
		if(s[i]=='R'&&s[i+1]=='L')
		{
			int cl=0,cr=0;
			for(int j=i+1;j<n;j++)
			{
				if(s[j]=='L')
					cl++;
				else
					break;
			}
			for(int j=i-1;j>=0;j--)
			{
				if(s[j]=='R')
					cr++;
				else
					break;
			}
			cr++;
			int ee=cr/2,oo=cr-cr/2;
			ans[i+1]+=ee;
			ans[i]+=oo;
			int e1=cl/2,o2=cl-cl/2;
			ans[i+1]+=o2;
			ans[i]+=e1;
		}
	}
	f(i,0,n)
	cout<<ans[i]<<" ";
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const ll oo = 1e18;
const int MOD = 1000000007;
const int N = 300010;
#define x first
#define y second
#define pb push_back
#define mp make_pair

int n , m , dp[1 << 16][16], comp[1 << 16], cost[16][1 << 16], vis[1 << 16],val[1<<16], vsId;
struct edge {
	int s , t , c;
};
edge E[16 * 16];
int solve(int msk , int p){
	if(p == n-1)return !msk?0:-1e9;
	int &ret = dp[msk][p];
	if(ret != -1)return ret;
	ret = -1e9;
	for (int i = 0; i < n; ++i){
		if((msk&(1<<i))>0 && cost[i][1<<p]){
			ret = max(ret,cost[i][1<<p]+solve(msk^(1<<i),i));
		}
	}
	return ret;
}
ll all = 0;
vector<int> nodes;
int calc(int msk){
	if(!msk)return 0;
	if(vis[msk]==vsId)return val[msk];
	vis[msk] = vsId;
	int &ret = val[msk];
	ret = -1e9;
	for(int sub = msk ; sub > 0 ; sub=(sub-1)&msk){
		for(int u = 0 ; u < nodes.size() ; ++u){
			int j = nodes[u];
			ret = max(ret,cost[j][sub]+comp[sub]+calc(msk^sub));
		}
	}
	return ret;
}

int main() {
	memset(dp,-1,sizeof dp);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d", &E[i].s, &E[i].t, &E[i].c);
		E[i].s--, E[i].t--;
		all += E[i].c;
	}
	for (int i = 0; i < n; ++i) {
		for (int msk = 0; msk < (1 << n); ++msk) {
			for (int j = 0 ; j < m ; ++j) {
				if (E[j].t == i)
					swap(E[j].s, E[j].t);
				if (E[j].s == i && (msk & (1 << E[j].t)) > 0) {
					cost[i][msk] += E[j].c;
				}
			}
		}
	}
	for (int msk = 0; msk < (1 << n); ++msk) {
		for (int j = 0 ; j < m ; ++j) {
			if((msk & (1 << E[j].s)) > 0 && (msk & (1 << E[j].t)) > 0){
				comp[msk] += E[j].c;
			}
		}
	}
	ll ans = oo;
	for (int msk = 0 ; msk < (1<< n); ++msk){
		if((msk&(1<<0))==0||(msk&(1<<(n-1)))==0)continue;
		if(solve(msk^(1<<0),0) < 0)continue;
		nodes.clear();
		vsId++;
		for(int i = 0 ; i < n ; ++i)
			if((msk&(1<<i))>0)nodes.pb(i);
		ans = min(ans,all-solve(msk^(1<<0),0)-calc(~msk&((1<<n)-1)));
	}
	printf("%lld\n",ans );
	return 0;
}


Measured memory_bytes: 8192
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

#define N_MAX 200200

struct bit{
  long long dat[N_MAX + 1];

  void init(){
    for(int i = 0; i < N_MAX; i++){
      dat[i] = 0;
    }
  }

  long long sum(int i){
    long long s = 0;
    while(i > 0){
      s += dat[i];
      i -= i & -i;
    }
    return s;
  }

  void add(int i, long long x){
    while(i <= N_MAX){
      dat[i] += x;
      i += i & -i;
    }
  }
}bit1,bit2;

int main(){
  ll q;
  cin>>q;
  vector<pair<ll,pair<ll,ll> > > vp;
  set<ll> se;
  rep(i,0,q){
    ll a,b,c;
    cin>>a;
    if(a==2){
      vp.pb(mp(2,mp(0,0)));
    }
    else{
      cin>>b>>c;
      vp.pb(mp(a,mp(b,c)));
      se.insert(b);
    }
  }
  vector<ll> v1(all(se));
  map<ll,ll> ma, ma_index;
  rep(i,0,v1.sz){
    ma[v1[i]] = 10+i;
    ma_index[10+i] = v1[i];
  }
  bit1.init();
  bit2.init();
  ll n = 0;
  ll d = 0;
  rep(i,0,vp.sz){
    ll a = vp[i].fi;
    if(a==1){
      ll b = vp[i].se.fi;
      ll c = vp[i].se.se;
      bit1.add(ma[b],1);
      bit2.add(ma[b],b);
      n++;
      d += c;
    }
    else{
      long long low = 0;
      long long high = 200080;
      while(low < high){
        long long mid = (high + low) >> 1;
        if(n%2==0){
          if(bit1.sum(mid) >= n/2){
            high = mid;
          }
          else{
            low = mid + 1;
          }
        }
        else{
          if(bit1.sum(mid) >= n/2+1){
            high = mid;
          }
          else{
            low = mid + 1;
          }
        }
      }
      ll e = ma_index[low];
      ll n1 = bit1.sum(200100)-bit1.sum(low);
      ll n2 = n-n1;
      ll f1 = bit2.sum(200100)-bit2.sum(low)-e*n1;
      ll f2 = e*n2-bit2.sum(low);
      cout << e << " " << f1+f2+d << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 29740
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N-1);
    rep(i, N)
    {
        cin >> A[i];
        --A[i];
    }
    rep(i, N)
    {
        cin >> B[i];
    }
    rep(i, N-1)
    {
        cin >> C[i];
    }
    ll ans = 0;
    rep(i, N)
    {
        ll ri = A[i];
        ans += B[ri];
        if (i != N - 1)
        {
            if (A[i + 1] == A[i] + 1)
            {
                ans += C[ri];
            }
        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3188
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
/*------------------junk----------------------*/
typedef long long int lli;
typedef unsigned long long int ulli;
const int MOD = 1e9 + 7;
#define ff first
#define ss second
#define gc getchar_unlocked
#define fri(i, j , n) for (auto (i) = (j); (i) < (n); ++(i))
#define frie(i, j , n) for (auto (i) = (j); (i) <= (n); ++(i))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define f2a(x , n , v)  fill(&(x)[0][0], &(x)[0][0] + (0 + n) *(0 + n) , (v))
#define fa(x , n , v) fill( (x), (x)+(n), (v)) 
#define pb emplace_back
#define mp make_pair
#define getchar_unlocked getchar
# define TMP template<typename
#ifdef LOCAL 
template < class c > struct rge { c b, e; };
template < class c > rge<c> range(c i, c j) { return rge<c>{i, j}; }
template < class c > auto dud(c* x) -> decltype(cerr << *x, 0);
template < class c > char dud(...);
struct debug {
    
    ~debug() { cerr << endl; }
    template < class c > typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) { cerr << boolalpha << i; return * this; }
    template < class c > typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) { return * this << range(begin(i), end(i)); }
    template < class c, class b > debug & operator <<(pair < b, c > d) {
        return * this << "(" << d.first << ", " << d.second << ")";
    }
    template < class c > debug & operator <<(rge<c> d) {
        *this << "[";
        for (auto it = d.b; it != d.e; ++it)
            *this << ", " + 2 * (it == d.b) << *it;
        return * this << "]";
    }};
#define oo(...) __f(#__VA_ARGS__, __VA_ARGS__)
TMP Arg1>
void __f(const char *name, Arg1 &&arg1)
{cout << name << ": " << arg1 << "\n";}
TMP Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args)
{const char *comma = strchr(names + 1, ',');cout.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);
}
void in(int &x){
    cin  >> x;
}
#else
inline void in(int &x)
    {
    register int c = getchar_unlocked();
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar_unlocked());
    if(c=='-') {neg=1;c=getchar_unlocked();}
    for(;c>47 && c<58;c = getchar_unlocked()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
    }
inline void uin(ulli &n){
    register ulli c=gc();
    n=0;
    while(c<'0'||c>'9')
    c=gc();
    while(c<='9'&&c>='0'){
    n=n*10+c-'0';
    c=gc();}
}
#endif
/*----------check constraints again-------------*/

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
    int a,b;
    cin >> a >> b;
    if( a>9 || b> 9) cout << "-1";
    else cout << a*b;
}















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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

ll n;
ll p[MAXX];
ll a[MAXX];

int main()
{
    _FastIO;

    cin >> n;
    p[0] = 1;
    p[1] = 26;
    ll t = 0;
    ll s = 26;
    if(n <= 26){
        cout << char(96 + n) << endl;
        return 0;
    }
    for(ll i = 2; i <= n; i++){
        p[i] = p[i - 1] * 26;
        s += p[i];
        if(s >= n){
            t = i;
            break;
        }
    }
    n--;
    s -= p[t];
    n -= s;
    string ans = "";
    while(t){
        ll x = n / p[t - 1];
        n %= p[t - 1];
        ans += char(97 + x);
        t--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    int h[N];
    rep(i, N) cin >> h[i];
    int cnt = 0;
    while(1){
        bool is = true;
        rep(i, N){
            if(h[i] != 0) is = false;
        }
        if(is) break;

        int i = 0;
        while(i < N){
            if(h[i] <= 0) i++;
            else{
                cnt++;
                while(i < N && h[i] > 0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);


    if(A>=13){
        printf("%d",B);
    }
    else if(A>=6 && A<=12){
            B=B/2;
        printf("%d",B);
    }
    else{
        printf("0\n");
    }
}


Measured memory_bytes: 128
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

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

	int num_dom = 0, num_ail = 0;
	rep(i, n){
		if( s[i] == 'a' ){
			if( num_dom + num_ail < a+b ){
				++num_dom;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else if( s[i] == 'b' ){
			if( num_dom + num_ail < a+b && num_ail < b ){
				++num_ail;
				cout << "Yes" << endl;
			}
			else{
				cout << "No" << endl;
			}
		}
		else{
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 896
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

using namespace std;
#define endl '\n'
#define eb emplace_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;

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

// value


void solve() {

	string S;
	cin >> S;

	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == 'o') cnt++;
	}

	cout << (cnt + (15 - S.size()) >= 8 ? "YES" : "NO") << endl;

	return;

}

int main() {

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

	solve();

	return 0;

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll H, W;
    cin >> H >> W;

    if(H==1||W==1){
      cout << 1 <<  endl;
    }else if(H%2==1 && W%2==1){
    	cout << (H*W+1)/2 << endl;
    }else{
    	cout << (H*W)/2 << endl;
    }
    
    return 0;
}

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

using namespace std;

const int MAX_DICE_NUMBER = 5;

void moveNorth(int diceRot[3]) {
	int temp = diceRot[2];
	diceRot[2] = diceRot[1];
	diceRot[1] = MAX_DICE_NUMBER - temp;
}

void moveSouth(int diceRot[3]) {
	int temp = diceRot[1];
	diceRot[1] = diceRot[2];
	diceRot[2] = MAX_DICE_NUMBER - temp;
}

void moveEast(int diceRot[3]) {
	int temp = diceRot[1];
	diceRot[1] = diceRot[0];
	diceRot[0] = MAX_DICE_NUMBER - temp;
}

void moveWest (int diceRot[3]) {
	int temp = diceRot[0];
	diceRot[0] = diceRot[1];
	diceRot[1] = MAX_DICE_NUMBER - temp;
}

int main() {
	int diceValue[6];
	int diceRotation[3] = {3,0,4};


	for (int i = 0; i < 6; i++) {
		cin >> diceValue[i];
	}

	string sequence;
	//cin.sync();
	cin >> sequence;
	//cin.sync();
	//cout << sequence << endl;

	for (int i = 0; i < sequence.length(); i++) {
		switch (sequence[i])
		{
		case 'N':
			moveNorth(diceRotation);
			break;
		case 'S':
			moveSouth(diceRotation);
			break;
		case 'E':
			moveEast(diceRotation);
			break;
		case 'W':
			moveWest(diceRotation);
			break;
		default:
			break;
		}
	}

	cout <<  diceValue[diceRotation[1]]<< endl;

	return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b;cin>>a>>b;
    if(a*b<=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    if((b-a)%2)cout<<"Positive"<<endl;
    else cout<<"Negative"<<endl;
}


Measured memory_bytes: 256
import sys

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, T = MAP()
A = MAP()

ans = 0
end = 0
for a in A:
	if end > a:
		ans += T - (end-a)
	else:
		ans += T
	end = a+T
print(ans)

Measured memory_bytes: 25744
#include<iostream>
using namespace std;
int isPrime[60001];
void prime(){
  for(int i=0;i<60001;i++)isPrime[i]=1;
  isPrime[0]=isPrime[1]=0;
  for(int i=4;i<60001;i+=2)isPrime[i]=0;
  for(int i=3;i*i<=60001;i++){
    if(isPrime[i]){
      for(int j=i+i;j<60001;j+=i)isPrime[j]=0;
    }
  }
}

int main(){
  int a;
  prime();
  while(cin>>a){
    for(int i=a-1;i>=2;i--){
      if(isPrime[i]){
	cout<<i<<' ';
	break;
      }
    }
    for(int i=a+1;i<=60000;i++){
      if(isPrime[i]){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1392
mod = 10**9 + 7

def main():
    N = int(input())
    S = input()
    num_chars = 0
    A = {}
    for s in S:
        if s not in A:
            A[s] = 0
            num_chars += 1
        A[s] += 1
    # print(num_chars, A)
    B = [(a, A[a]) for a in A]

    ans = 1
    for b in B:
        ans = (ans * (b[1] + 1)) % mod
    print(ans - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#[allow(dead_code)]
const MOD: usize = 1_000000000 + 7;

fn main() {
    let mut cin = Scanner::new();
    let n = cin.next_usize();
    let ans = (0..n).fold(0, |acc, _| {
        let l = cin.next_u64();
        let r = cin.next_u64();
        acc + r - l + 1
    });
    println!("{}", ans);
}


struct Scanner {
    reader: std::io::Stdin,
    tokens: std::collections::VecDeque<String>,
}

impl Scanner {
    fn new() -> Self {
        Scanner {
            reader: std::io::stdin(),
            tokens: std::collections::VecDeque::new(),
        }
    }

    fn next(&mut self) -> String {
        if self.tokens.is_empty() {
            let mut s = String::new();
            loop {
                self.reader.read_line(&mut s).ok();
                let s = s.trim();
                if s.len() != 0 {
                    for it in s.split_whitespace() {
                        self.tokens.push_back(it.into())
                    }
                    break;
                }
            }
        }
        self.tokens.pop_front().unwrap()
    }

    fn next_generics<T>(&mut self) -> T where
        T: std::str::FromStr + std::marker::Copy,
        <T as std::str::FromStr>::Err: std::fmt::Debug
    {
        self.next().parse().unwrap()
    }
    
    #[allow(dead_code)] fn next_i32(&mut self) -> i32 { self.next_generics::<i32>() }
    #[allow(dead_code)] fn next_i64(&mut self) -> i64 { self.next_generics::<i64>() }
    #[allow(dead_code)] fn next_u64(&mut self) -> u64 { self.next_generics::<u64>() }
    #[allow(dead_code)] fn next_usize(&mut self) -> usize { self.next_generics::<usize>() }
    #[allow(dead_code)] fn next_isize(&mut self) -> isize { self.next_generics::<isize>() }
}



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

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

const int MAXN = 5e5;

int N, A[MAXN+10];
char S[MAXN+10];

int main()
{
    int i, j;

    scanf("%s", S+1); N=strlen(S+1)+1;

    vector<int> V;
    for(i=2; i<N; i++) if(S[i-1]=='>' && S[i]=='<') V.push_back(i);
    if(S[1]=='<') V.push_back(1);
    if(S[N-1]=='>') V.push_back(N);

    memset(A, -1, sizeof(A));

    queue<pii> Q;
    for(auto it : V) Q.push({it, 0});

    while(!Q.empty())
    {
        pii now=Q.front(); Q.pop();
        if(A[now.first]>=now.second) continue;
        A[now.first]=now.second;
        if(now.first>1 && S[now.first-1]=='>') Q.push({now.first-1, now.second+1});
        if(now.first<N && S[now.first]=='<') Q.push({now.first+1, now.second+1});
    }

    ll ans=0;
    for(i=1; i<=N; i++) ans+=A[i];
    printf("%lld", ans);

}


Measured memory_bytes: 5240
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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 (a>b) { a=b; return 1; } return 0; }

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

	int n;
	cin >> n;

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

	int ans = 0;
	rep(i, n){
		if(i % 2 == 0 && a[i] % 2 == 1) ans++; 
	}

	cout << ans << endl;
}


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

using namespace std;

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

	int number;
	cin >> number;

	int* arr = new int[number];
	int* check = new int[number];

	for (int i = 0; i < number; i++) {
		cin >> arr[i];
		check[i] = 0;
	}

	for (int i = 0; i < number; i++) {
		if (arr[i] % 2 == 0) {
			if (arr[i] % 3 == 0 || arr[i] % 5 == 0) {
				check[i] = 0;
			}
			else {
				check[i] = 1;
			}
		}
	}
	
	bool isOk = false;

	for (int i = 0; i < number; i++) {
		if (check[i] == 1) {
			isOk = true;
			break;
		}
	}

	if (isOk) {
		cout << "DENIED" << endl;
	}
	else {
		cout << "APPROVED" << endl;
	}
}	

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

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var D = int.Parse(Console.ReadLine());
            var r = new Random();
            for(var i = 1; i <= D; i++) {
                Console.WriteLine(r.Next(1,26));
            }
        }
    }
}

Measured memory_bytes: 27556
#include<iostream>
#include <vector>
#include<algorithm>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(),v,end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n, m;
	cin >> n >> m;
	vector<bool> b(n + 1);
	rep(i, m) {
		int a;
		cin >> a;
		b[a] = 1;
	}

	vector<ll> dp(n + 1);
	dp[0] = 1;
	if (b[1]) dp[1] = 0;
	else dp[1] = 1;

	for (int i = 2; i <= n; i++) {
		if (!b[i]) dp[i] = dp[i - 1] + dp[i - 2];
		else dp[i] = 0;
		dp[i] %= MOD;
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.Bool (bool)

main :: IO ()
main = do
  n <- unsafeSignedDecimal <$> T.getLine :: IO Int
  ss <- sequence . replicate n $ T.getLine :: IO [T.Text]
  let
    (ab, a, ba, b) = foldr step (0, 0, 0, 0) $ ss
    ba' = pred ba
    a' = pred a
    b' = pred b
  print $ ab + bool (min a b) (bool 0 1 (a > 0) + ba' + bool 0 1 (b > 0) + min (max a' 0) (max b' 0)) (ba' >= 0)

step :: T.Text -> (Int, Int, Int, Int) -> (Int, Int, Int, Int)
step = g . f
  where
    f = h . T.foldr step' (Nothing, 0, False)
      where
        step' 'A' (Nothing, _, _) = (Just 'A', 0, True)
        step' 'A' (Just 'B', ab, a) = (Just 'A', succ ab, a)
        step' c (_, ab, a) = (Just c, ab, a)
        h (Just 'B', ab, a) = (ab, a, True)
        h (_, ab, a) = (ab, a, False)
    g (ab', True, True) (ab, a, ba, b) = (ab + ab', a, succ ba, b)
    g (ab', a', b') (ab, a, ba, b) = (ab + ab', a + bool 0 1 a', ba, b + bool 0 1 b')

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 4348
n,k=map(int,input().split())
d=list(input().split())
for i in range(n,10*n):
    a=str(i)
    b=len(a)
    ans=True
    for j in a:
        if j in d:
            ans=False
            break 
    if ans:
        print(i)
        exit()

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

int main(){

  int a,b;
  
  cin >> a >> b;
  
  int ans = a - 2 * b;
  
  if(ans <= 0)ans = 0;
    
  cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int b = scanner.nextInt();
        long goukei = b;
        long saishou = b, saidai = b;

        for (int i = 1; i <= a -1; i++) {
            if (a < 0 && a >= 10000) {
                break;
            }
            b = scanner.nextInt();
            if (-1000000 > b && b >= 1000000) {
                break;
            }
            goukei = b + goukei;
            if (saishou > b) {
                saishou = b;
            }
            if (saidai < b) {
                saidai = b;
            }
        }
        System.out.printf("%d %d %d\n",saishou,saidai,goukei);
    }
}

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

int main()
{
	int a[4][3][10] = {};
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
				cout << ' ' << a[i][j][k];
			cout << endl;
		}
		if (i == 3) return 0;
		cout << "####################" << endl;
	}
}


Measured memory_bytes: 3072
#include <stdio.h>

#define WHITE 0
#define BLACK 1
#define INF 10000000

void dijkstra(void);

void prim(void);

int n, d[100], color[100], pi[100], w[100][100];

int main(int argc, char const *argv[]) {
  int i,j,u,k,v,c;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      w[i][j] = -1;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d", &u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d", &v,&c);
      w[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra(){
  int i,j,v,u,mincost,r=0;

  for(i=0;i<n;i++){
    d[i] = INF;
    pi[i] = -1;
    color[i] = WHITE;
  }

  d[r] = 0;

  while (1) {
    mincost = INF;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < mincost){
        mincost = d[i];
        u = i;
      }
    }

    if(mincost == INF) break;

    color[u] = BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && d[u]+w[u][v] < d[v] && w[u][v] > -1){
        pi[v] = u;
        d[v] = w[u][v] + d[u];
      }
    }
  }
  for(i=0;i<n;i++) printf("%d %d\n",i,d[i]);
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=405,mod=998244353;
int n,f[N][N],g[N][N],h[N],C[N][N],pw[N],len[N],idn,ans;

int fpow(int x,int y){
	int res=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) res=1ll*res*x%mod;
	return res;
}

int dico(int l,int r,int lst){
	if(l>r) return 0;
	int mid=l;
	for(int i=l+1;i<=r;i++) if(h[i]<h[mid]) mid=i;
	int x=++idn,lc=dico(l,mid-1,h[mid]),rc=dico(mid+1,r,h[mid]);
	for(int i=0;i<=len[lc];i++) for(int j=0;j<=len[rc];j++){
		int a=1ll*f[lc][i]*f[rc][j]%mod;
		int b=(1ll*g[lc][i]*(f[rc][j]+g[rc][j])+1ll*f[lc][i]*g[rc][j])%mod;
		f[x][i+j]=(f[x][i+j]+a)%mod;
		g[x][i+j]=(g[x][i+j]+b)%mod;
		f[x][i+j+1]=(f[x][i+j+1]-a+mod)%mod;
		g[x][i+j+1]=(g[x][i+j+1]+a)%mod;
	}
	len[x]=len[lc]+len[rc]+1;
	for(int i=0;i<=len[x];i++){
		f[x][i]=1ll*f[x][i]*fpow(pw[len[x]-i],h[mid]-lst)%mod;
		g[x][i]=1ll*g[x][i]*fpow(pw[len[x]-i]-1,h[mid]-lst)%mod;
	}
	return x;
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(h[i]);
	pw[0]=1;
	for(int i=1;i<=n;i++) pw[i]=(pw[i-1]+pw[i-1])%mod;
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	f[0][0]=1;
	int rt=dico(1,n,0);
	for(int i=0;i<=n;i++) ans=(1ll*ans+f[rt][i]+g[rt][i])%mod;
	write(ans);
}

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

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef pair < int, int > ii;
typedef vector < ii > vii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const int MOD = 1e9+7;
const ld pi = acos(-1);

string w;
int main() { BUFF
  cin >> w;
  vi cnt(30, 0);
  for(auto it : w)
    cnt[it - 'a']++;
  for(auto it : cnt) {
    if(it % 2) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,N,r=0,b=0;
	char s[110];
	
	scanf("%d",&N);
	scanf("%s",s);
	
	for(i=0;i<N;i++){
		if(s[i]=='R'){
			r++;
		}else{
			b++;
			
		}
	}
	
	if(r>b){
		printf("Yes");
	}else{
		printf("No");
	}
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
  int list[100001]={0};
  long long answer=0;
  int a,n;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    answer+=a;
    list[a]++;
  }
  int q,b,c;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d %d",&b,&c);
    answer+=(c-b)*(list[b]);
    printf("%lld\n",answer);
    list[c]+=list[b];
    list[b]=0;
  }
  return 0;
}

Measured memory_bytes: 2120
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    int n;
    cin >> n;
    string s[n];
    rep(i, n) {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
    }

    map<string, ll> mp;
    ll count = 0;

    rep(i, n) {
        if(mp[s[i]] > 0) {
            count += mp[s[i]];
        }
        mp[s[i]]++;
    }
    cout << count << endl;
}

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

int main() {
  string a,b;
  cin >> a >> b;
  if(a.size() > b.size()){
    cout << "GREATER" << endl;
  }else if(a.size() < b.size()){
    cout << "LESS" << endl;
  }else{
    if(a > b){
      cout << "GREATER" << endl;
    }else if(a < b){
      cout << "LESS" << endl;
    }else{
      cout << "EQUAL" << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 112345;

int cnt[N];


int main() {
	int n; scanf("%d", &n);
	
	for(int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		cnt[x]++;	
	}
	
	int res = 0;
	
	for(int X = 0; X < N-1; ++X) {
		int cnd1, cnd2, cnd3;
		cnd2 = X;
		cnd1 = X-1;
		cnd3 = X+1;
		
		int cur = 0;
		if(cnd1 >= 0) 
			cur += cnt[cnd1];
		cur += cnt[cnd2]+cnt[cnd3];
		//printf("%d %d %d %d\n", res, cnd1, cnd2, cnd3);
		res = max(res, cur);
		
	}
	printf("%d\n", res);
	
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <bitset>
#include <vector>

using namespace std;

typedef pair<int, int> P;

int n;

int abs(int a)
{
	if(a < 0)
		return a*-1;
	return a;
}
	bool field[5001][5001];
void solve()
{
	vector<P> pos(n);
	int res = 0;

	for(int i = 0; i <= 5000; i++){
		for(int j = 0; j <= 5000; j++)
			field[i][j] = false;
	}

	for(int i = 0; i < n; i++){
		cin >> pos[i].first >> pos[i].second;
		field[pos[i].second][pos[i].first] = 1;
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i == j)
				continue;
			int x[4] = {pos[i].first, pos[j].first, pos[i].first - (pos[j].second-pos[i].second),pos[j].first - (pos[j].second-pos[i].second)},
				y[4] = {pos[i].second, pos[j].second, pos[i].second + (pos[j].first-pos[i].first),pos[j].second + (pos[j].first-pos[i].first)};

			int c = 0;
			for(int k = 0; k < 4; k++){
				if(x[k] >= 0 && x[k] <= 5000 && y[k] >= 0 && y[k] <= 5000 && field[y[k]][x[k]])
					c++;
		//		cout << "( " <<x[k] << ',' << y[k] << ")  ";
			}
		//	cout << endl;

			if(c < 4)
				continue;

			int now = (x[0]-x[1])*(x[0]-x[1])+(y[0]-y[1])*(y[0]-y[1]);
			//cout << now << endl;
			res = max(res,now);


		}
	}

//	for(int i = 0; i <= 20; i++){
//		for(int j = 0; j <= 20; j++)
	//		cout << field[i][j] << ' ';
//		cout << endl;
//	}
	cout << res << endl;
}

int main(void)
{
	while(cin >> n, n){
		solve();
	}
	return 0;
}

Measured memory_bytes: 25636
import sys
n=int(input())
A =list(map(int,input().split()))
mi = 0
for i in range(n):
    if mi < A[i]:
        mi = A[i]-1
    elif mi == A[i]:
        mi = A[i]
    elif A[i]-mi < 0 :
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 14396
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\???????????°????????????????????\???
	int num1, num2;

 	while(1) {
 		
 		scanf("%d %d", &num1, &num2);
 		
 		if(num1 == 0 && num2 ==0)
 			break;

	 	if(num1 <= num2) {
 
 			printf("%d %d\n", num1, num2);
 
		} else {

			printf("%d %d\n", num2, num1);

		}
 	}
	return 0;
}

Measured memory_bytes: 1728
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x,y):
    parx = find(x)
    pary = find(y)
    if parx == pary:
        return False
    else:
        par[parx] += par[pary]
        par[pary] = x
        return True
def same(x,y):
    return find(x) == find(y)
def size(x):
    return -par[find(x)]
n = int(input())
par = [-1]*n
p = []
edge = []
for i in range(n):
    x,y = map(int,input().split())
    p.append([x,y,i])
p.sort(key=lambda x:x[0])
for i in range(n-1):
    x_0,_,j=p[i]
    x_1,_,k=p[i+1]
    edge.append([x_1-x_0,j,k])
p.sort(key=lambda x:x[1])
for i in range(n-1):
    _,y_0,j=p[i]
    _,y_1,k=p[i+1]
    edge.append([y_1-y_0,j,k])
edge.sort()
ans = 0
for i in range(len(edge)):
    cost,u,v = edge[i]
    if not same(u,v):
        unite(u,v)
        ans+=cost
print(ans)

Measured memory_bytes: 128456
#include <climits>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> G(N, vector<int>(N, INT_MAX));
  rep(i, N) G[i][i] = 0;
  vector<int> A(M);
  vector<int> B(M);
  vector<int> C(M);
  rep(i, M) {
    cin >> A[i] >> B[i] >> C[i];
    --A[i];
    --B[i];
    G[A[i]][B[i]] = C[i];
    G[B[i]][A[i]] = C[i];
  }

  rep(k, N) {
    rep(i, N) {
      rep(j, N) {
        if (G[i][k] == INT_MAX || G[k][j] == INT_MAX) continue;
        G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
      }
    }
  }

  int answer = M;
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) {
      if (G[j][A[i]] + C[i] == G[j][B[i]]) {
        --answer;
        break;
      }
    }
  }
  cout << answer << endl;
  return 0;
}

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

using namespace std;

int n, m;
char a[1005][1005];

bool check(int x, int y) {
    return x >= 0 && x < n && y >= 0 && y < m && a[x][y] == '.';
}

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

struct node {int x, y, step; };

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i++) scanf("%s", a[i]);
    queue<node> que;
    int cnt = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if(a[i][j] == '#') que.push({i, j, 0});

    while(!que.empty())
    {
        int x = que.front().x, y = que.front().y, st = que.front().step;
        que.pop();
        cnt = max(cnt, st);
        for(int i = 0; i < 4; i++)
        {
            int fx = x + dx[i], fy = y + dy[i];
            if(check(fx, fy)) 
            {   
                que.push({fx, fy, st + 1});
                a[fx][fy] = '#';
            }
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 13328
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
int dfs(vector< vector< int > > &G, vector< vector< int > > &dp, int x, int y, int p) {
	if (dp[x][y] != -1)
		return dp[x][y];
	int ret = 1, ret2 = 1 - y;
	for (auto j : G[x]) {
		if (j == p)
			continue;
		if (!y) {
			ret2 *= dfs(G, dp, j, 1, x);
			ret2 %= MOD;
		}
		ret *= dfs(G, dp, j, 0, x);
		ret %= MOD;
	}
	return dp[x][y] = (ret + ret2) % MOD;
}
signed main() {
	cin >> N;
	vector< vector< int > > G(N);
	rep(i, N - 1) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	vector< vector< int > > dp(N, vector< int >(2, -1));
	cout << dfs(G, dp, 0, 0, -1) << endl;

	return 0;
}

Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    ll la = a-v*t;
    ll ra = a+v*t;
    ll lb = b-w*t;
    ll rb = b+w*t;
    if(la<=lb && rb<=ra){
        cout << "YES" <<endl;
    }
    else {
        cout << "NO" <<endl; 
    }

   return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = long long;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||debg||local||debug
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}
template<class T>vector<T> _vec(size_t a,T v){return vector<T>(a,v);}
template<class T, class... Ts>auto _vec(size_t a, Ts... ts){return vector<decltype(_vec<T>(ts...))>(a, _vec<T>(ts...));}

int main(){

  ll n;
  cin>>n;
  ll nl = to_string(n).size();
  
  auto cnt = vec<ll>(10,10);
  for(ll a=1;a<=n;++a){
    string as = to_string(a);
    cnt[as[0]-'0'][as.back()-'0']++;
  }
  ll ans = 0;
  for(ll a=1;a<=n;++a){
    string as = to_string(a);
    ans += cnt[as.back()-'0'][as[0]-'0'];
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Optional;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		long ac = (long)a*c;
		long ad = (long)a*d;
		long bc = (long)b*c;
		long bd = (long)b*d;

		Optional<Long> max = Arrays.asList(ac,ad,bc,bd).stream().max(Comparator.naturalOrder());

		System.out.println(max.get());

	}
}

Measured memory_bytes: 35852
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long r = in.nextLong();
		long d = in.nextLong();
		long x = in.nextLong();
		for(int i=0;i<10;i++) {
			x = r*x-d;
			System.out.println(x);
		}
		in.close();

	}

}


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

#define MAX_N 1000
#define MAX_M 1000


int main(){
	string s; cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)) cout << "Yes" << endl;
    else cout << "No" << endl;

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n, m;
	scanf("%d", &n);
	if (n == 1)
	{
		printf("%d\n", 1);
		printf("%d\n", 1);
		return 0;
	}
	m = (n + 3) / 4 * 2;
	printf("%d\n", m);
	for (int i = 1; i <= m; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			int x = (i + j - 2) % m + 1;
			if (i % 2 == 0) x += m;
			if (x > n) x -= m;
			printf("%d ", x);
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1152