akhauriyash/Code-Regression huggingface dataset:
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(i) sort(i.begin(),i.end())
#define rSORT(i) sort(i.rbegin(),i.rend())
#define fSORT(i,a) sort(i.begin(),i.end(),a)
#define all(i) i.begin(),i.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string s; cin >> s;
    each(i, s)if (i == '?')i = 'D';
    print(s);

    return 0;
}

Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
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 int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  if (k == 0) {
    cout << n * n << endl;
    return 0;
  }

  ll ans = 0;
  for (int b = k+1; b <= n; b++) {
    ans += (b-k) * (n/b);
    ans += max(ll(0), (n % b - k + 1));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<climits>
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() 
{ 
    int x;
    cin>>x;
    if(x==1)
    {
        cout<<0;
    }
    else if(x==0)
    {
        cout<<1;
    }
} 

Measured memory_bytes: 3632
import Data.Functor
import Data.List
import Data.Maybe

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  print (solve n s)

solve :: Int -> String -> Int
solve n s = fromMaybe n m
  where
    m = succ <$> elemIndex "xx" (zipWith (\a b -> [a, b]) s (tail s))

Measured memory_bytes: 8032
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Ans = 0;cin >> N;
vector<ll> A(N);
vector<bool> B(N, 0);

rep(i, 0, N){

cin >> A[i];

if(i + 1 == A[i])B[i] = 1;

}

double cnt = 0;

rep(i, 0, N){

if(B[i])cnt++;

else{Ans += ceil(cnt/2);cnt = 0;}

}

Ans += ceil(cnt/2);

cout << Ans;
}


Measured memory_bytes: 4056
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
 
int n,m,i,j,x,xi,a[55][2],b[55][2];
 
int main () {
 
	scanf("%d %d",&n,&m);
	FOE(i,1,n){
	  scanf("%d %d",&a[i][0],&a[i][1]);	
	}
	FOE(i,1,m){
	  scanf("%d %d",&b[i][0],&b[i][1]);		
	}
	FOE(i,1,n){
		x=1000000000;
		xi=1;
		FOE(j,1,m){	
	      if (abs(b[j][0]-a[i][0])+abs(b[j][1]-a[i][1])<x) {
	      	x=abs(b[j][0]-a[i][0])+abs(b[j][1]-a[i][1]);
	      	xi=j;
	      }
	      }
	    printf("%d\n",xi);
		}
	return 0;	
}

Measured memory_bytes: 128
n,m = map(int,input().split())
if n==1:
    wide = range(0,10)
else:
    wide = range(10**(n-1), 10**n)
st = set(wide)

for _ in range(m):
    s,c = map(int, input().split())
    lst = list(wide)
    st1 = set()
    if s==1 and c==0 and n != 1:
        st &= set()
    for i in wide:
        x = i // 10**(n-s)
        if x % 10 == c:
            st1.add(i)
    st &= st1

lst = list(st)
lst.sort()
lst.append(-1)
print(lst[0])

Measured memory_bytes: 72132
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int i,n;
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		string str;
		getline(cin,str);
//cout<<str<<endl;
		int a,b;
		for(a=1;a<26;a+=2){
			if(a==13)continue;
			for(b=0;b<26;b++){
				string st="";
				int j;
				for(j=0;j<str.size();j++){
					if('a'<=str[j]&&str[j]<='z'){
						st+=((str[j]-'a')*a+b)%26+'a';
					}else{
						st+=str[j];
					}
				}
//if(st[0]=='i')cout<<st<<endl;
				string::size_type index1=st.find("that");
				string::size_type index2=st.find("this");
				if(index1!=string::npos||index2!=string::npos){
					cout<<st<<endl;
					goto end;
				}
			}
		}
		end:;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main ()
{
	int a,b,c,d,e,f,g,h,i;
	for(int x=1;x<4;x++){
	cin>>a>>b>>c>>d>>e>>f;
	if(f<c){
	f=f+60;
	e=e-1;
	i=f-c;
	}
	else {
	i=f-c;
	}
	if(e<b){
	e=e+60;
	d=d-1;
	h=e-b;
	}
	else {
	h=e-b;
	}
	g=d-a;
        cout<<g<<" ";
        cout<<h<<" ";
        cout<<i<<endl;
    }
	return 0;
}
	

Measured memory_bytes: 1160
#include <bits/stdc++.h>  
using namespace std;  
typedef long long LL;  
#define INF 0x3f3f3f3f  
int a[15];  
char str[10];  
int flag[20];  
int main()  
{  
  int k;  
  scanf("%s%d",str,&k);  
  memset(flag,0,sizeof(flag));  
  for(int i=0;i<k;i++)  
  {  
    scanf("%d",&a[i]);  
    flag[a[i]]=1;  
  }  
  int len=strlen(str);  
  int fflag=0;int ans,ssum,pos=0,tt;  
  for(int i=0;i<len;i++)  
  {  
    ssum=0;  
    for(int j=0;j<=9;j++)  
    {  
      if((j>(str[i]-'0'))&&flag[j]==0)  
      {  
        printf("%d",j);  
        fflag=1;  
        ans=i;  
        ssum=1;  
        break;  
      }  
      else if((j==(str[i]-'0'))&&flag[j]==0)  
      {  
        printf("%d",j);  
        ssum=1;  
        break;  
      }  
    }  
    if(ssum==0) {pos=1;tt=i;break;}  
    if(fflag) break;  
  }  
  int cnt=0;  
  for(int i=0;i<=9;i++)  
  {  
    if(flag[i]==0)  
    {  
      cnt=i;break;  
    }  
  }  
  if(fflag)  
  {for(int i=ans+1;i<len;i++)  
    printf("%d",cnt);}  
  if(pos)  
  {  
    for(int i=tt;i<len+1;i++)  
    printf("%d",cnt);  
  }  
  printf("\n");  
  return 0;  
}  

Measured memory_bytes: 256
// abc153_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, A;
    cin >> H >> A;

    int ans = (H + A - 1) / A;
    print(ans);


    return 0;
}


Measured memory_bytes: 256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<ctime>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
unsigned int randxor()
{
    static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
    unsigned int t;
    t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int d=365;
vector<int> ans(d);
vector<int> ans1(d);
vector<int> c(26);
vector<vector<int> > s(d);
int score=-1000000000;
int keisan(){
  int cost=0,i,j;
  vector<int> x(26,-1);
  for(i=0;i<d;i++){
    cost+=s[i][ans1[i]];
    x[ans1[i]]=i;
    for(j=0;j<26;j++){
      cost=cost-c[j]*(i-x[j]);
    }
  }
  return cost;
}
void solve(){
  int i;
  if(score<=keisan()){
    for(i=0;i<d;i++){
      ans[i]=ans1[i];
    }
    score=keisan();
    int v=randxor()%d;
    int w=randxor()%d;
    swap(ans1[v],ans1[w]);
  }
  else{
    for(i=0;i<d;i++){
      ans1[i]=ans[i];
    }
  }
}
void solve1(){
  int i;
  if(score<=keisan()){
    for(i=0;i<d;i++){
      ans[i]=ans1[i];
    }
    score=keisan();
    ans1[randxor()%d]=randxor()%26;
  }
  else{
    for(i=0;i<d;i++){
      ans1[i]=ans[i];
    }
  }
}
int main(){
  int i,j;
  int ti=clock();
  cin >> d;
  vector<P> e(26);
  for(i=0;i<26;i++){
    scanf("%d",&c[i]);
    e.push_back(P(c[i],i));
  }
  std::sort(e.begin(), e.end(), std::greater<P>() );
  for(i=0;i<d;i++){
    for(j=0;j<26;j++){
      int a;
      scanf("%d",&a);
      s[i].push_back(a);
    }
  }
  for(i=0;i<d;i++){
    ans1[i]=e[i%26].second;
    ans[i]=ans1[i];
  }
  while(clock()-ti<198.5*CLOCKS_PER_SEC/100){
    solve();
    solve1();
    solve();
  }
  for(i=0;i<d;i++){
    printf("%d\n",ans[i]+1);
  }
  return 0;
}


Measured memory_bytes: 3896
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main(void){
	int A[4]={0},B,C,SUM=0;
	for(int i=0;i<4;i++){
		cin>>A[i];
	}
	cin>>B>>C;
	sort(A,A+4);
	for(int i=3;i>0;i--){
		SUM+=A[i];
	}
	SUM+=max(B,C);
	cout<<SUM<<endl;
	return 0;
}


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

int main() {
  int N; cin >> N;
  string S1, S2; cin >> S1 >> S2;
  long long ans = 1;
  long long MOD = 1000000007;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      if (S1.at(0) == S2.at(0)) ans *= 3;
      else { ans *= 6; i++; }
    }
    else if (S1.at(i) == S2.at(i)) {
      if (S1.at(i-1) == S2.at(i-1)) { ans *= 2; ans %= MOD; }
    }
    else {
      if (S1.at(i-1) == S2.at(i-1)) { ans *= 2; ans %= MOD; }
      else { ans *= 3; ans %= MOD; }
      i++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
	int n;
	cin>>n;
	string str;
	string str_ans[4]={"AC","WA","TLE","RE"};
	int ar[4];
	for(int j=0;j<4;j++)
		ar[j]=0;
	for(int i=0;i<n;i++){
		cin>>str;
		if(str_ans[0]==str)
			ar[0]++;
		else if(str_ans[1]==str)
			ar[1]++;
		else if(str_ans[2]==str)
			ar[2]++;
		else 
			ar[3]++;
	}
	for(int j=0;j<4;j++)
		cout<<str_ans[j]<<" x "<<ar[j]<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int x, a;

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
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 INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int A, B;
    cin >> A >> B;
    int ans = 0;
    for(;ans < 1000000; ++ans) if((ans*8)/100 == A && (ans*10)/100 == B) break;
    cout << (ans == 1000000 ? -1 : ans) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
//int Pow(int x,int y){
//	int ans=1;
//	for (;y;y>>=1,x=(LL)x*x%mod)
//		if (y&1)
//			ans=(LL)ans*x%mod;
//	return ans;
//}
//void Add(int &x,int y){
//	if ((x+=y)>=mod)
//		x-=mod;
//}
//void Del(int &x,int y){
//	if ((x-=y)<0)
//		x+=mod;
//}
//int Add(int x){
//	return x>=mod?x-mod:x;
//}
//int Del(int x){
//	return x<0?x+mod:x;
//}
//void ckmax(int &x,int y){
//	if (x<y)
//		x=y;
//}
void ckmin(int &x,int y){
	if (x>y)
		x=y;
}
const int N=20,INF=1e9;
int n;
int a[N],b[N];
int dp[1<<18][51];
int main(){
	n=read();
	For(i,0,n-1)
		a[i]=read();
	For(i,0,n-1)
		b[i]=read();
	For(i,0,(1<<n)-1)
		For(j,0,50)
			dp[i][j]=INF;
	dp[0][0]=0;
	For(i,0,(1<<n)-1){
		int c=0;
		vi s(n,0);
		For(j,0,n-1)
			if (i>>j&1)
				s[j]=1,c++;
		For(j,1,n-1)
			s[j]+=s[j-1];
		For(j,0,50){
			int v=dp[i][j];
			if (v==INF)
				continue;
			For(k,0,n-1){
				if (i>>k&1)
					continue;
				int t=(k^c)&1?b[k]:a[k];
				if (t>=j)
					ckmin(dp[i|1<<k][t],v+s[n-1]-s[k]);
			}
		}
	}
	int ans=INF;
	For(i,0,50)
		ckmin(ans,dp[(1<<n)-1][i]);
	if (ans==INF)
		ans=-1;
	cout<<ans<<endl;
	return 0;
}

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

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
const int INF = 1e9;

using namespace std;

struct UnionFind{
    vector<int> parent;
    UnionFind(int n) : parent(n, -1) {}
    int root(int x) { return parent[x] < 0 ? x : parent[x] = root(parent[x]); }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (parent[y] < parent[x]) swap(x, y);
        if (parent[x] == parent[y]) --parent[x];
        parent[y] = x;
        return true;
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    int com, x, y;
    struct UnionFind trees(n);
    REP(i, q){
        cin >> com >> x >> y;
        if(com)
            cout << (trees.root(x) == trees.root(y) ? "1" : "0") << endl;
        else
            trees.merge(x, y);
    }
    return 0;
}

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

char ch;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> ch;
	cout << ((ch - 'A' >= 0 && ch - 'A' < 26) ? "A\n" : "a\n");
	return 0;
}


Measured memory_bytes: 3644
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n=getint()
hs=getints()

hs[0] -= 1
ok = True
for i in range(1, n):
    if hs[i] > hs[i - 1]:
        hs[i] -= 1
    if hs[i] < hs[i - 1]:
        ok = False

print("Yes" if ok else "No")


Measured memory_bytes: 63984
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#define ll long long
using namespace std;
int main()
{
    double L;
    cin>>L;
    L /= 3;
    double ans = 1.0*L*L*L;
    printf("%.6f\n",ans);
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n-1; i >= 0LL; i--)
#define FOR(i, n, m) for(ll i = n; i < (ll)(m); i++)
#define PRINT(x) cout << x << endl
#define ALL(v) v.begin(), v.end()
#define INF (ll)1e18
#define INFD 1e18
#define PI 3.14159265358979
#define MOD 1000000007
#define vl vector<ll>

vector<ll> dx = {-1, 1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

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

int main()
{
	ll N;
	cin >> N;
	ll cnt = 0;
	vector<P> v;
	if (N % 2 == 0) {
		REP(i, N) {
			FOR(j, i+1, N) {
				if (j+1 == N-i)continue;
				cnt++;
				v.push_back(P(i+1, j+1));
			}
		}
	} else {
		REP(i, N) {
			FOR(j, i+1, N) {
				if (j+1 == N-1-i)continue;
				cnt++;
				v.push_back(P(i+1, j+1));
			}
		}
	}
	PRINT(v.size());
	REP(i, v.size()) {
		PRINT(v[i].first << " " << v[i].second);
	}
	return 0;
}


Measured memory_bytes: 512
h,w,a,b = map(int, input().split())
mx = max(h,w)
mod = 10**9+7
fac = [1]*(h+w+1)
for i in range(1,h+w+1):
	fac[i]=fac[i-1]*i%mod
rev = [1]*(mx+1)
rev[-1] = pow(fac[mx], mod-2, mod)
for i in range(mx-1, -1, -1):
	rev[i] = rev[i+1]*(i+1)%mod
const = rev[h-a-1]*rev[a-1]%mod
ans = 0
for i in range(b,w):
	ans += fac[h-a+i-1]*rev[i]*fac[a+w-2-i]*rev[w-i-1]%mod
print(ans*const%mod)

Measured memory_bytes: 14836
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var abc = ReadSplitInt();
            var order = abc.OrderBy(x => x).ToList();
            Println(order[0] + order[1]);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13396
n, x = map(lambda x: int(x), input().split(' '))
a = list(map(lambda x: int(x), input().split(' ')))

a.sort()
result = 0
for candy in a:
    if x - candy < 0:
        break
    result += 1
    x = x - candy
else:
    if x > 0:
        result -= 1
print(result)


Measured memory_bytes: 3060
#include<iostream>
#include <climits>
#include<vector>
#include<list>
#include<numeric>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll cn = 0;

void merge(vector<int> &a, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1 + 1), R(n2 + 1);
	REP(i, n1) L[i] = a[left + i];
	REP(i, n2) R[i] = a[mid + i];
	L[n1] = INT_MAX;
	R[n2] = INT_MAX;
	int i = 0, j = 0;
	FOR(k, left, right) {
		if (L[i] <= R[j]) {
			a[k] = L[i++];
		}
		else {
			a[k] = R[j++];
			cn += n1 - i;
		}
	}
}

void mergeSort(vector<int> &a, int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}

}

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

	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	mergeSort(a, 0, n);
	cout << cn << "\n";

	return 0;
}


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

int main() {
    long long n, x, ret = 1e18;
    std::cin >> n >> x;
    std::vector<long long> v(n + 1);
    for (auto i = 1ll; i <= n; i++) {
        std::cin >> v[i];
        v[i] += v[i - 1];
    }
    for (auto i = 1ll; i <= n; i++) {
        auto tmp = (n + i) * x;
        auto flg = true;
        for (auto j = 0; j <= n / i - (n % i == 0); j++) {
            tmp += (j ? (2 * j + 3) : 5) * (v[n - j * i] - v[std::max(0ll, n - (j + 1) * i)]);
            if (tmp > 1e18) {
                flg = false;
                break;
            }
        }
        if (flg) ret = std::min(ret, tmp);
    }

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <algorithm>
using namespace std;

int num_scanf(){
	int buf;
	scanf("%d", &buf);
	return buf;
}

int main(){
	int time = 0;
	for (int a = 0; a < 4; a++){
		time += num_scanf();
	}
	printf("%d\n%d\n", time / 60, time % 60);
	return 0;
}

Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 111111;
int a[N];
int n;

pair<vector<int>, vector<int> > split() {
    vector<int> ev, ov;
    rep(i, 1, n) {
        if(i & 1) {
            ov.pb(a[i]);
        } else {
            ev.pb(a[i]);
        }
    }
    return {ov, ev};
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i];
    }
    pair<vector<int>, vector<int> > v = split();
    sort(a + 1, a + n + 1);
    unordered_set<int> so, se;
    rep(i, 1, n) {
        if(i & 1) {
            so.insert(a[i]);
        } else {
            se.insert(a[i]);
        }
    }
    int ans = 0;
    rep(i, 0, sz(v.fi) - 1) {
        ans += so.find(v.fi[i]) == so.end();
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5108
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

const int N=2e5+5;

char s[N];
int n,f[N];

int main() {
	scanf("%s",s+1);n=strlen(s+1);
	fo(i,1,n)
		if (s[i]==s[i-1]) f[i]=(i>=3)?f[i-3]+2:1;
		else f[i]=f[i-1]+1;
	printf("%d\n",f[n]);
	return 0;
}

Measured memory_bytes: 1152
// abc117_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;

int main(void){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec[i];
  }
  int max = 0;
  int sum = 0;
  for (int i = 0; i < N; i++) {
	  sum += vec[i];
	  if (max < vec[i]) {
		  max = vec[i];
	  }
  }
  sum -= max;
  if (sum > max) {
	  cout << "Yes" << endl;
	  return 0;
  }
  cout << "No" << endl;
}

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

using namespace std;

int n,t,e;
int a[101];
int main(void){
	scanf("%d%d%d",&n,&t,&e);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int i=1;
	for(i=1;i<=n;i++){
		for(int j=1;j*a[i]<=14400;j++){
			if(j*a[i]>=t-e && j*a[i]<=t+e){
				printf("%d\n",i);
				goto ch;
			}
		}
		if(i==n)printf("-1\n");
	}
	ch:
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<string.h>

int main(){
    int i, j, k;
    int ans=0, length;
    char s[210000];
    int nums=0, numt=0;

    scanf("%s", &s);
    length = strlen(s);
    for(i=0; i<length; i++){
        if(s[i]=='S'){
            nums++;
        }else if(s[i]=='T'){
            if(nums>0){
                nums--;
                ans++;
            }
        }
    }
    printf("%d", length-ans*2);

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P=pair<int,int>;
int main(){
  string S;
  cin>>S;
  
  string ans="No";
  if(S[2]==S[3]){
    if(S[4]==S[5]){
      ans="Yes";
    }
  }
  cout<<ans<<endl;

}


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

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

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

int main(void)
{
    long long N, M;
    cin >> N >> M;
    vector<long long> A(M);
    vector<long long> B(M);
    for (long long  i = 0; i < M; i++)
    {
        cin >> A[i] >> B[i];
    }
    UnionFind tree(N);
    for (long long i = 0; i < M; i++)
    {
        tree.unite(A[i]-1, B[i]-1);
    }
    vector<long long> count(N, 0);
    long long ans = 0;
    for (long long  i = 0; i < N; i++)
    {
        if (count[tree.root(i)] == 1) 
        {
        }
        else
        {
            count[tree.root(i)] = 1;
            ans++;
        }
    }
    cout << ans-1 << endl;
}

Measured memory_bytes: 5880
from math import floor
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    X = int(readline())
    
    money = 100
    y = 0
    while money < X:
        money *= 1.01
        money = floor(money)
        y += 1
    
    print(y)


if __name__ == "__main__":
    main()


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

int n,m;

int cnt[30];

int f0,t1,t0;

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

      for(int i=0;i<n;i++)    {
            string in;
            cin>>in;
            for(int j=0;j<m;j++)    {
                  cnt[in[j]-'a']++;
            }
      }


      for(int i=0;i<26;i++)    {
            if(cnt[i]==0)    continue;
            if(cnt[i]%4!=0)    f0++;
            if(cnt[i]%4!=0 && cnt[i]%2==0)   t0++;
            else if(cnt[i]%2==1)   t1++;
      }


      bool b=0;

      if(m%2==1 && n%2==1)    {
            if(t1==1&&f0==1)    b=1;
            else if(t1==1&&t0<=(m-1)/2+(n-1)/2)    b=1;
      }
      else if(m%2==0 && n%2==0)    {
            if(f0==0)    b=1;
      }
      else if(m%2==0)    {
            if(t1==0 && t0<=m/2)    b=1;
      }
      else    {
           if(t1==0 && t0<=n/2)    b=1;
      }

      if(b)    cout<<"Yes"<<endl;
      else    cout<<"No"<<endl;



      return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
char s[maxn];
int num[26][maxn],L;
int main(){
	scanf("%s",s+1);
	for(int i=1;s[i];i++)num[s[i]-'a'][i]++;
	for(int i=1;s[i];i++)for(int j=0;j<26;j++)num[j][i]+=num[j][i-1];
	L=strlen(s+1);int now=0,l1=0;
	scanf("%s",s+1);
	for(int i=1;s[i];i++){
		int x=s[i]-'a';
		while(num[x][L]-num[x][l1]<=0){
			if(num[x][L]<=0){
				puts("-1");return 0;
			}
			now++,l1=0;
		}
		int r=L,l=l1+1,mid;
		while(l<=r){
			mid=(l+r)>>1;
			if(num[x][mid]-num[x][l1]>0)r=mid-1;
			else l=mid+1;
		}
		l1=l;
	}
	printf("%lld\n",1ll*now*L+l1);
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string nyan="Three";
    for(int i=0;i<n;i++){
        char wan;
        cin>>wan;
        if(wan=='Y'){
            nyan="Four";
            break;
        }
    }
    cout<<nyan<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 100001
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<int,ll>Pil;
typedef pair<P1,ll> P2;
typedef list<int> li;
typedef list<li> lli;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll a;
	int b;
};

int main(){

	int x;
	cin>>x;
	if(x)cout<<"0"<<endl;
	else cout<<"1"<<endl;

	return 0;
}


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

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

using namespace std;

vector<vector<int>> calc(int H,int W,int w){
	vector<vector<int>> res(H,vector<int>(W));
	rep(i,H){
		rep(j,W){
			res[i][j]=(j%w<w-1?100000:-100000*(w-1)-1);
		}
	}
	return res;
}

int main(){
	int H,W,h,w; scanf("%d%d%d%d",&H,&W,&h,&w);

	if(H%h==0 && W%w==0){
		puts("No");
	}
	else{
		puts("Yes");
		if(W%w!=0){
			auto ans=calc(H,W,w);
			rep(i,H) rep(j,W) printf("%d%c",ans[i][j],j<W-1?' ':'\n');
		}
		else{
			auto ans=calc(W,H,h);
			rep(i,H) rep(j,W) printf("%d%c",ans[j][i],j<W-1?' ':'\n');
		}
	}

	return 0;
}


Measured memory_bytes: 3072
using System;
class c
{
    static void Main()
    {
        var hw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int h = hw[0], w = hw[1];
        var s = new string[h];
        for (int i = 0; i < h; i++) s[i] = Console.ReadLine();
        var map = new int[h, w];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                map[i, j] = int.MaxValue;
            }
        }
        if (s[0][0] == '#') map[0, 0] = 1;
        else map[0, 0] = 0;

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (i == 0 && j == 0) continue;
                int a = int.MaxValue, b = int.MaxValue;
                if (i > 0)
                {
                    if (s[i - 1][j] == '.' && s[i][j] == '#') a = map[i - 1, j] + 1;
                    else a = map[i - 1, j];
                }
                if (j > 0)
                {
                    if (s[i][j - 1] == '.' && s[i][j] == '#') b = map[i, j - 1] + 1;
                    else b = map[i, j - 1];
                }
                map[i, j] = Math.Min(a, b);
            }
        }
        Console.WriteLine(map[h - 1, w - 1]);
    }
}

Measured memory_bytes: 27552
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String word = s.next();
		if(word.contains("A") && word.contains("B")) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35660
#include<stdio.h>
int main(void){
int A,B;
  int i;
  int sum=0;
scanf("%d",&A);
  scanf("%d",&B);
  for(i=0;i<2;i++){
if(A>=B){
  sum=sum+A;
  A--;
}else{
  sum=sum+B;
  B--;
}
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
	int array[26] = { 0 };
	int n;
	string str;
	cin >> str;

	for (int i = 0;str[i] != '\0';i++) {
		array[str[i] - 'a']++;
	}
	for (n = 0;n < 26 && array[n] != 0;n++);

	if (n < 26)
		printf("%c\n", 'a' + n);
	else
		printf("None\n");

	return 0;
}

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

int main() {
  long long w,h,x,y;
  cin>>w>>h>>x>>y;
  double ans=w*h/2.0;
  int answ=0;
  if((w%2==0 && h%2==0) && (w/2==x && h/2==y)) answ=1;
  cout<<setprecision(10)<<ans<<" "<<answ<<endl;
}

Measured memory_bytes: 256
import collections
N = int(input())
tree = [[] for i in range(N+1)]

for i in range(N-1):
    u, v, w = map(int, input().split())
    tree[u].append([v, w])
    tree[v].append([u, w])

for i in range(1, N+1):
    if len(tree[i]) == 1:
        start = i
        break
queue = collections.deque()
queue.append([start, 0])
ans = [-1] * (N+1)
ans[start] = 0


while len(queue) > 0:
    now = queue.popleft()
    for next in tree[now[0]]:
        if ans[next[0]] == -1:
            queue.append(next)
            ans[next[0]] = (ans[now[0]] + next[1])%2
for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 82464
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans=0;
    for(int i=a; i<=b; i++){
        string s;
        s=to_string(i);
        if(s[0]==s[4] && s[1]==s[3]) ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int count=0;
  int s; cin>>s;
  vector<int> x(1000000);
  x.at(0)=s;
  for(int i=1;i<1000000;i++){
   if(x.at(i-1)%2==0){
   x.at(i)=x.at(i-1)/2;
   }
   else if(x.at(i-1)%2==1){
   x.at(i)=x.at(i-1)*3+1;
   }
   for(int j=0;j<i;j++){
         if(x.at(i)==x.at(j))count++;
      }
  if(count==1){cout<<i+1<<endl;
           break;}
   }
}


Measured memory_bytes: 4096
unittest
{
	assert( [ "4", "3 3 3 3" ].parse.expand.solve == 1 );
	assert( [ "5", "2 4 1 4 2" ].parse.expand.solve == 2 );
	assert( [ "1", "1000000000" ].parse.expand.solve == 1 );
	assert( [ "8", "2 7 1 8 2 8 1 8" ].parse.expand.solve == 5 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	as ~= 0L;		// 最後に集計したいので被らないやつを追加しておく
	
	auto r = 0L;
	auto d = 0L;
	auto x = as[ 0 ];
	
	foreach( i, a; as )
	{
		// 要素が変わったら集計
		if( a != x )
		{
			if( d < x ) r += d;			// 要素が少なかった場合は全部取り除く
			else        r += d - x;		// 要素が多かった場合は多い分だけ取り除く
			d = 0L;
			x = a;
		}

		// 同じ要素の数をカウント
		d++;
	}
	
	return r;
}


Measured memory_bytes: 7112
import java.util.Arrays;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        
        Scanner scan = new Scanner(System.in);
        
        char[] a = scan.nextLine().toCharArray();
        char[] b = scan.nextLine().toCharArray();

        Arrays.sort(a);
        Arrays.sort(b);

        boolean flg = false;
        for(int i=0; i<a.length; i++){
            int j = b.length - i - 1;
            if(j < 0){
                break;
            }else if(a[i] < b[j]){
                flg = true;
                break;
            }else if(a[i] == b[j] && (i+1) == a.length && a.length < b.length){
                flg = true;
            }
        }
        if(flg) System.out.println("Yes");
        else System.out.println("No");

        scan.close();
        
    }
}

Measured memory_bytes: 22612
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;


public class Main {
	public static void main(String args[]) {
		
		Scanner scanner = new Scanner(System.in);
		ArrayList<Integer> w=new ArrayList<Integer>();
		ArrayList<Integer> k=new ArrayList<Integer>();
		for(int i=0;i<10;i++){
			w.add(scanner.nextInt());
		}
		for(int i=0;i<10;i++){
			k.add(scanner.nextInt());
		}
		Collections.sort(w);
		Collections.sort(k);
		int ws=0,ks=0;
		for(int i=0;i<3;i++){
			ws+=w.get(9-i);
			ks+=k.get(9-i);
		}
		System.out.println(ws+" "+ks);
	}
}

Measured memory_bytes: 17188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define SIZE 100005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct UF
{
	int par[SIZE],rank[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=1;
		}
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF uf;
ll inv[SIZE*2],fac[SIZE*2],finv[SIZE*2];
int to[SIZE],deg[SIZE];
vector <int> nd[SIZE];
int cnt[SIZE];
int org[SIZE];
int back[SIZE];
int L[SIZE];

void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE*2;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
ll mpow(ll m,ll t)
{
	if(t==0) return 1LL;
	ll ret=mpow(m,t/2);
	ret=ret*ret%MOD;
	if(t%2==1) ret=ret*m%MOD;
	return ret;
}
int main()
{
	make();
	int n;
	scanf("%d",&n);
	uf.init(n+2);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&to[i]);
		to[i]--;
		deg[to[i]]++;
		uf.unite(i,to[i]);
		L[i]=0;
	}
	for(int i=0;i<n;i++) nd[uf.find(i)].push_back(i);
	queue <int> que;
	for(int i=0;i<n;i++)
	{
		org[i]=deg[i];
		if(deg[i]==0) que.push(i);
	}
	while(!que.empty())
	{
		int v=que.front();que.pop();
		deg[to[v]]--;
		L[to[v]]=max(L[to[v]],L[v]+1);
		if(deg[to[v]]==0) que.push(to[v]);
	}
	for(int i=0;i<n;i++)
	{
		if(org[i]>=3||(deg[i]==0&&org[i]==2))
		{
			puts("0");
			return 0;
		}
		if(deg[i]==1)
		{
			back[to[i]]=i;
		}
	}
	ll ret=1;
	for(int i=0;i<n;i++)
	{
		if(uf.find(i)==i)
		{
			bool cyc=true;
			for(int j=0;j<nd[i].size();j++) if(deg[nd[i][j]]==0) cyc=false;
			if(cyc)
			{
				cnt[nd[i].size()]++;
				continue;
			}
			int now=-1;
			for(int j=0;j<nd[i].size();j++) if(deg[nd[i][j]]==1&&L[nd[i][j]]>=1) now=nd[i][j];
			int f=now;
			do
			{
				if(L[now]==0)
				{
					now=back[now];
					if(now==f) break;
					continue;
				}
				int to=now;
				for(int j=0;j<L[now];j++)
				{
					if(j>0)
					{
						if(to==f||L[to]>0)
						{
							puts("0");
							return 0;
						}
					}
					to=back[to];
				}
				if(to!=f&&L[to]==0) ret=ret*2LL%MOD;
				now=to;
			}while(now!=f);
		}
	}
	for(int i=1;i<=n;i++)
	{
		ll sum=0;
		ll mul=1;
		for(int j=0;2*j<=cnt[i];j++)
		{
			ll way=mul*finv[j]%MOD;
			way=way*mpow(i,j)%MOD;
			if(i>=3&&i%2==1) way=way*mpow(2LL,cnt[i]-2*j)%MOD;
			sum+=way;
			if(sum>=MOD) sum-=MOD;
			mul=mul*C(cnt[i]-2*j,2)%MOD;
		}
		ret=ret*sum%MOD;
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>
 
using namespace std;
 
/* template */
 
using ll = long long;
 
void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};
 
struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};
 
 
using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;
 
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;
}
 
template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}
 
ll 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;
	}
}
 
constexpr ll LNF = 1LL<<50;
 
constexpr int INF = 1e9+7;
 
const long double PI=3.14159265358979323846;
 
 
vector<int> dx = {1,0,-1,1,-1,0};
vector<int> dy = {1,1,1,0,0,-1};
 
/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,0,n){
        cin >> a[i];
    }
    ll ans = 0;
    rep(i,1,n){
        ans += max(0ll,a[i-1]-a[i]);
        chmax(a[i],a[i-1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4780